import{n as P}from"./index.browser-OxPLOBIU.js";import{ay as S,J as b,a3 as $,aP as a,bb as x,a4 as H,L as I,az as v,aA as u,aB as y,o as i,aD as n,aG as d,E as c,aV as L,aN as k,b$ as M,aS as w,aI as V,bg as j,bh as _,bi as D,bU as U,M as z,b8 as O,bx as G,bM as C,aE as J,_ as R}from"./index-CZ2q8ncR.js";import{E as q}from"./EditConfig-X--k1oK2.js";import"./VAlert-DaNbIj7X.js";import"./VCheckbox-BN08M28F.js";import"./VCheckboxBtn-7DEdwotr.js";import"./VSelectionControl-BURj_b4N.js";import"./VSlider-CttbO-BF.js";import"./VSelect-3IoW2wUm.js";import"./VVirtualScroll-DOg_xag1.js";import"./VForm-C2dJlirE.js";import"./VExpansionPanels-DvFcslHQ.js";import"./VDialog-CA6XzZUU.js";const F={class:"add-provider-details"},K={key:0},Q={class:"header-content"},W={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=S({__name:"AddProviderDetails",props:{domain:{}},setup(o){const A=J(),m=b([]),p=P(11),l=b(!1),f=b(!1),h=o;$(()=>{const s=a.subscribe(x.AUTH_SESSION,e=>{if(e.object_id!==p)return;const t=e.data;f.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",t),r.click()},100)});H(s)}),I(()=>h.domain,async s=>{s&&(m.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,f.value=!1})},T=async function(s,e){l.value=!0;for(const t of m.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=>{m.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,f.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(" / ")},N=function(s){const{t:e}=C();return`**${e("settings.provider_credits")}**: `+s.join(" / ")};return(s,e)=>(u(),v("section",F,[n(a).providerManifests[o.domain]?(u(),v("div",K,[i(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[c("div",Q,[c("div",W,[i(L,{domain:o.domain,size:48},null,8,["domain"])]),c("div",X,[c("h2",Y,k(s.$t("settings.setup_provider",[n(a).providerManifests[o.domain].name])),1),c("p",Z,k(n(a).providerManifests[o.domain].description),1),n(a).providerManifests[o.domain].codeowners.length?(u(),v("div",{key:0,class:"header-authors",innerHTML:n(M)(B(n(a).providerManifests[o.domain].codeowners))},null,8,ee)):y("",!0),n(a).providerManifests[o.domain].credits.length?(u(),v("div",{key:1,class:"header-authors",innerHTML:n(M)(N(n(a).providerManifests[o.domain].credits))},null,8,te)):y("",!0)])])]),_:1})])):y("",!0),i(q,{"config-entries":m.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(()=>[f.value?(u(),V(w,{key:0,style:{"background-color":"white"}},{default:d(()=>[i(j,null,{default:d(()=>[...e[1]||(e[1]=[_("Authenticating...",-1)])]),_:1}),i(D,null,{default:d(()=>[...e[2]||(e[2]=[_("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),i(U,null,{default:d(()=>[c("a",se,[i(z,null,{default:d(()=>[...e[3]||(e[3]=[_("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),V(O,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),ge=R(ae,[["__scopeId","data-v-0a2b0962"]]);export{ge as default};
