import{n as x}from"./index.browser-OxPLOBIU.js";import{ay as P,J as b,a3 as S,aP as s,bb as H,a4 as I,L,az as v,aA as u,aB as _,o,aD as i,aG as r,E as c,aV as $,aN as k,c0 as V,aS as M,c3 as j,aI as w,bg as D,bh as y,bi as z,bV as U,M as O,b8 as G,bx as J,aE as R,bN as C,_ as q}from"./index-DQ0AtwBO.js";import{E as F}from"./EditConfig-BNMIWkCt.js";import"./VAlert-DHftkkb2.js";import"./VCheckbox-BR0Jkn6d.js";import"./VCheckboxBtn-CmKDOTuO.js";import"./VSelectionControl-CwC4p8T5.js";import"./VSlider-Ytg7ck22.js";import"./VSelect-BolewkSQ.js";import"./VVirtualScroll-DJ5JNDOI.js";import"./VForm-Bte0E1cE.js";import"./VExpansionPanels-DrWFTZ7L.js";import"./VDialog-DPUbCG_Q.js";const K={class:"add-provider-details"},Q={key:0},W={class:"header-content"},X={class:"header-icon"},Y={class:"header-info"},Z={class:"header-title"},ee={class:"header-description"},te=["innerHTML"],ae=["innerHTML"],se={id:"auth",href:"",target:"_blank"},ne=P({__name:"AddProviderDetails",props:{domain:{}},setup(n){const A=R(),f=b([]),p=x(11),l=b(!1),m=b(!1),h=n;S(()=>{const a=s.subscribe(H.AUTH_SESSION,e=>{if(e.object_id!==p)return;const t=e.data;m.value=!0,window.setTimeout(()=>{const d=document.getElementById("auth");d.setAttribute("href",t),d.click()},100)});I(a)}),L(()=>h.domain,async a=>{a&&(f.value=await s.getProviderConfigEntries(h.domain,void 0,void 0,{session_id:p}))},{immediate:!0});const T=async function(a){l.value=!0,s.saveProviderConfig(h.domain,a).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{l.value=!1,m.value=!1})},E=async function(a,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,s.getProviderConfigEntries(h.domain,void 0,a,e).then(t=>{f.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,m.value=!1})},B=function(a){const e=[],{t}=C();for(const d of a)if(d.includes("@")){let g=d.replace("@","");g=="music-assistant"&&(g="the Music Assistant team"),e.push(`[${g}](https://github.com/${d.replace("@","")})`)}else e.push(d);return`**${t("settings.provider_codeowners")}**: `+e.join(" / ")},N=function(a){const{t:e}=C();return`**${e("settings.provider_credits")}**: `+a.join(" / ")};return(a,e)=>(u(),v("section",K,[i(s).providerManifests[n.domain]?(u(),v("div",Q,[o(M,{class:"header-card mb-4",elevation:"0"},{default:r(()=>[c("div",W,[c("div",X,[o($,{domain:n.domain,size:48},null,8,["domain"])]),c("div",Y,[c("h2",Z,k(a.$t("settings.setup_provider",[i(s).providerManifests[n.domain].name])),1),c("p",ee,k(i(s).providerManifests[n.domain].description),1),i(s).providerManifests[n.domain].codeowners.length?(u(),v("div",{key:0,class:"header-authors",innerHTML:i(V)(B(i(s).providerManifests[n.domain].codeowners))},null,8,te)):_("",!0),i(s).providerManifests[n.domain].credits.length?(u(),v("div",{key:1,class:"header-authors",innerHTML:i(V)(N(i(s).providerManifests[n.domain].credits))},null,8,ae)):_("",!0)])])]),_:1})])):_("",!0),o(j,null,{default:r(()=>[o(F,{"config-entries":f.value,disabled:!1,onSubmit:T,onAction:E},null,8,["config-entries"])]),_:1}),o(J,{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:r(()=>[m.value?(u(),w(M,{key:0,style:{"background-color":"white"}},{default:r(()=>[o(D,null,{default:r(()=>[...e[1]||(e[1]=[y("Authenticating...",-1)])]),_:1}),o(z,null,{default:r(()=>[...e[2]||(e[2]=[y("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),o(U,null,{default:r(()=>[c("a",se,[o(O,null,{default:r(()=>[...e[3]||(e[3]=[y("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),w(G,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),be=q(ne,[["__scopeId","data-v-ba5ab01e"]]);export{be as default};
