import{n as P}from"./index.browser-OxPLOBIU.js";import{az as L,J as b,a3 as N,bc as a,bB as S,a4 as $,L as x,aP as v,aG as c,aK as y,o as i,aE as o,aH as d,E as u,bl as I,aW as k,ct as M,bg as V,aF as w,bF as j,aV as _,bG as z,cm as D,M as U,by as F,bV as G,b8 as C,ba as O,_ as J}from"./index-D2rF_80D.js";import{E as K}from"./EditConfig-DwDuuRhd.js";import"./VCheckbox-DccbdgFZ.js";import"./VCheckboxBtn-Dik76WyM.js";import"./VSelectionControl-BHjDOTFl.js";import"./VSlider-N-Vl7wpy.js";import"./VSelect-Cz5ACGBh.js";import"./VVirtualScroll-CG155sfU.js";import"./VForm-BPHMcC1Q.js";import"./VExpansionPanels-BYnWit6K.js";const R={class:"add-provider-details"},W={key:0},q={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=L({__name:"AddProviderDetails",props:{domain:{}},setup(n){const A=O(),f=b([]),p=P(11),l=b(!1),m=b(!1),h=n;N(()=>{const s=a.subscribe(S.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)}),x(()=>h.domain,async s=>{s&&(f.value=await a.getProviderConfigEntries(h.domain,void 0,void 0,{session_id:p}))},{immediate:!0});const E=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})},T=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}=C();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(" / ")},H=function(s){const{t:e}=C();return`**${e("settings.provider_credits")}**: `+s.join(" / ")};return(s,e)=>(c(),v("section",R,[o(a).providerManifests[n.domain]?(c(),v("div",W,[i(V,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[u("div",q,[u("div",Q,[i(I,{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)):y("",!0),o(a).providerManifests[n.domain].credits.length?(c(),v("div",{key:1,class:"header-authors",innerHTML:o(M)(H(o(a).providerManifests[n.domain].credits))},null,8,te)):y("",!0)])])]),_:1})])):y("",!0),i(K,{"config-entries":f.value,disabled:!1,onSubmit:E,onAction:T},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(),w(V,{key:0,style:{"background-color":"white"}},{default:d(()=>[i(j,null,{default:d(()=>[...e[1]||(e[1]=[_("Authenticating...",-1)])]),_:1}),i(z,null,{default:d(()=>[...e[2]||(e[2]=[_("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),i(D,null,{default:d(()=>[u("a",se,[i(U,null,{default:d(()=>[...e[3]||(e[3]=[_("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(c(),w(F,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),ve=J(ae,[["__scopeId","data-v-0a2b0962"]]);export{ve as default};
