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 p,aA as u,aB as _,o as n,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-B4UF4wLI.js";import{E as F}from"./EditConfig-JmZdV3ab.js";import"./VAlert-4-piUH1o.js";import"./VCheckbox-D8f2Z6se.js";import"./VCheckboxBtn-CzJltldW.js";import"./VSelectionControl-D7cbOkhF.js";import"./VSlider-6ci0gEBm.js";import"./VSelect-k6Sczint.js";import"./VVirtualScroll-B4qViT6U.js";import"./VForm-DAq47WE0.js";import"./VSwitch-PcL2mz3l.js";import"./VExpansionPanels-D1YYtrDw.js";import"./VDialog-BIfmHFFw.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"},oe=P({__name:"AddProviderDetails",props:{domain:{}},setup(o){const A=R(),m=b([]),v=x(11),l=b(!1),f=b(!1),h=o;S(()=>{const a=s.subscribe(H.AUTH_SESSION,e=>{if(e.object_id!==v)return;const t=e.data;f.value=!0,window.setTimeout(()=>{const d=document.getElementById("auth");d.setAttribute("href",t),d.click()},100)});I(a)}),L(()=>h.domain,async a=>{a&&(m.value=await s.getProviderConfigEntries(h.domain,void 0,void 0,{session_id:v}))},{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,f.value=!1})},E=async function(a,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=v,s.getProviderConfigEntries(h.domain,void 0,a,e).then(t=>{m.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,f.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(),p("section",K,[i(s).providerManifests[o.domain]?(u(),p("div",Q,[n(M,{class:"header-card mb-4",elevation:"0"},{default:r(()=>[c("div",W,[c("div",X,[n($,{domain:o.domain,size:48},null,8,["domain"])]),c("div",Y,[c("h2",Z,k(a.$t("settings.setup_provider",[i(s).providerManifests[o.domain].name])),1),c("p",ee,k(i(s).providerManifests[o.domain].description),1),i(s).providerManifests[o.domain].codeowners.length?(u(),p("div",{key:0,class:"header-authors",innerHTML:i(V)(B(i(s).providerManifests[o.domain].codeowners))},null,8,te)):_("",!0),i(s).providerManifests[o.domain].credits.length?(u(),p("div",{key:1,class:"header-authors",innerHTML:i(V)(N(i(s).providerManifests[o.domain].credits))},null,8,ae)):_("",!0)])])]),_:1})])):_("",!0),n(j,null,{default:r(()=>[n(F,{"config-entries":m.value,disabled:!1,onSubmit:T,onAction:E},null,8,["config-entries"])]),_:1}),n(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(()=>[f.value?(u(),w(M,{key:0,style:{"background-color":"white"}},{default:r(()=>[n(D,null,{default:r(()=>[...e[1]||(e[1]=[y("Authenticating...",-1)])]),_:1}),n(z,null,{default:r(()=>[...e[2]||(e[2]=[y("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),n(U,null,{default:r(()=>[c("a",se,[n(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"])]))}}),_e=q(oe,[["__scopeId","data-v-ba5ab01e"]]);export{_e as default};
