import{n as P}from"./index.browser-OxPLOBIU.js";import{ay as H,J as y,a3 as I,aP as a,bc as L,a4 as S,L as $,az as v,aA as c,aB as _,o as i,aD as o,aG as d,E as u,aW as j,aN as k,cd as M,aT as w,aI as C,bh as x,bi as b,bj as D,c6 as z,M as U,b9 as O,by as G,b_ as V,aE as J,_ as R}from"./index-D-FY8Yx2.js";import{E as W}from"./EditConfig-BeVcr9VT.js";import"./VCheckbox-W6o6QHjE.js";import"./VCheckboxBtn-DpMGI-si.js";import"./VSelectionControl-CyrHFsUF.js";import"./VSlider-CGKKjACx.js";import"./VSelect-Y8F8SAQI.js";import"./VVirtualScroll-cGuYysLa.js";import"./VForm-DYLmSGkE.js";import"./VExpansionPanels-CuU7p-4b.js";const q={class:"add-provider-details"},F={key:0},K={class:"header-content"},Q={class:"header-icon"},X={class:"header-info"},Y={class:"header-title"},Z={class:"header-description"},ee=["innerHTML"],te=["innerHTML"],se={id:"auth",href:"",target:"_blank"},ae=H({__name:"AddProviderDetails",props:{domain:{}},setup(n){const A=J(),f=y([]),p=P(11),l=y(!1),m=y(!1),h=n;I(()=>{const s=a.subscribe(L.AUTH_SESSION,e=>{if(e.object_id!==p)return;const t=e.data;m.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",t),r.click()},100)});S(s)}),$(()=>h.domain,async s=>{s&&(f.value=await a.getProviderConfigEntries(h.domain,void 0,void 0,{session_id:p}))},{immediate:!0});const T=async function(s){l.value=!0,a.saveProviderConfig(h.domain,s).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{l.value=!1,m.value=!1})},E=async function(s,e){l.value=!0;for(const t of f.value)t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=p,a.getProviderConfigEntries(h.domain,void 0,s,e).then(t=>{f.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,m.value=!1})},B=function(s){const e=[],{t}=V();for(const r of s)if(r.includes("@")){let g=r.replace("@","");g=="music-assistant"&&(g="the Music Assistant team"),e.push(`[${g}](https://github.com/${r.replace("@","")})`)}else e.push(r);return`**${t("settings.provider_codeowners")}**: `+e.join(" / ")},N=function(s){const{t:e}=V();return`**${e("settings.provider_credits")}**: `+s.join(" / ")};return(s,e)=>(c(),v("section",q,[o(a).providerManifests[n.domain]?(c(),v("div",F,[i(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[u("div",K,[u("div",Q,[i(j,{domain:n.domain,size:48},null,8,["domain"])]),u("div",X,[u("h2",Y,k(s.$t("settings.setup_provider",[o(a).providerManifests[n.domain].name])),1),u("p",Z,k(o(a).providerManifests[n.domain].description),1),o(a).providerManifests[n.domain].codeowners.length?(c(),v("div",{key:0,class:"header-authors",innerHTML:o(M)(B(o(a).providerManifests[n.domain].codeowners))},null,8,ee)):_("",!0),o(a).providerManifests[n.domain].credits.length?(c(),v("div",{key:1,class:"header-authors",innerHTML:o(M)(N(o(a).providerManifests[n.domain].credits))},null,8,te)):_("",!0)])])]),_:1})])):_("",!0),i(W,{"config-entries":f.value,disabled:!1,onSubmit:T,onAction:E},null,8,["config-entries"]),i(G,{modelValue:l.value,"onUpdate:modelValue":e[0]||(e[0]=t=>l.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:d(()=>[m.value?(c(),C(w,{key:0,style:{"background-color":"white"}},{default:d(()=>[i(x,null,{default:d(()=>[...e[1]||(e[1]=[b("Authenticating...",-1)])]),_:1}),i(D,null,{default:d(()=>[...e[2]||(e[2]=[b("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),i(z,null,{default:d(()=>[u("a",se,[i(U,null,{default:d(()=>[...e[3]||(e[3]=[b("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(c(),C(O,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),ve=R(ae,[["__scopeId","data-v-0a2b0962"]]);export{ve as default};
