import{n as N}from"./index.browser-BY9c7rfI.js";import{u as P}from"./vue-router-lrCq0UAu.js";import{a as s,E as S,V as M,_ as $}from"./index-Cc0s9xHj.js";import{E as x}from"./EditConfig-BtpVihKG.js";import{_ as I}from"./ProviderIcon.vue_vue_type_style_index_0_lang-7ardqVNw.js";import{a as b,a0 as L,p as j,G as D,T as U,m as z,k as G}from"./vuetify-CvGbteJu.js";import{d as O,o as q,r as y,a3 as J,w as K,c as v,K as _,J as a,u as n,H as d,e as u,a4 as V,G as C,a2 as k,b as c}from"./lucide-C_a_D9Y7.js";import{u as A}from"./vue-i18n-COI_JhGQ.js";import"./qrcode-DICVlH4J.js";import"./marked-D9eDbhZJ.js";import"./color-CqFg8eif.js";import"./vueuse-Blk5jQ0T.js";/* empty css            */import"./swiper-UowLVX5q.js";import"./index-CT6dMj3N.js";import"./reka-ui-jliV5UPF.js";import"./index-DX8SDiTF.js";import"./NumberFieldInput.vue_vue_type_script_setup_true_lang-C70L_o2l.js";const R={class:"add-provider-details"},F={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"],oe={id:"auth",href:"",target:"_blank"},se=O({__name:"AddProviderDetails",props:{domain:{}},setup(i){const w=P(),f=y([]),h=N(11),l=y(!1),p=y(!1),m=i;q(()=>{const o=s.subscribe(S.AUTH_SESSION,e=>{if(e.object_id!==h)return;const t=e.data;p.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",t),r.click()},100)});J(o)}),K(()=>m.domain,async o=>{o&&(f.value=await s.getProviderConfigEntries(m.domain,void 0,void 0,{session_id:h}))},{immediate:!0});const T=async function(o){l.value=!0,s.saveProviderConfig(m.domain,o).then(()=>{const e=s.providerManifests[m.domain]?.type;e?w.push({name:"providersettings",query:{types:e}}):w.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{l.value=!1,p.value=!1})},E=async function(o,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=h,s.getProviderConfigEntries(m.domain,void 0,o,e).then(t=>{f.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,p.value=!1})},B=function(o){const e=[],{t}=A();for(const r of o)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(o){const{t:e}=A();return`**${e("settings.provider_credits")}**: `+o.join(" / ")};return(o,e)=>(c(),v("section",R,[n(s).providerManifests[i.domain]?(c(),v("div",F,[a(b,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[u("div",Q,[u("div",W,[a(I,{domain:i.domain,size:48},null,8,["domain"])]),u("div",X,[u("h2",Y,V(o.$t("settings.setup_provider",[n(s).providerManifests[i.domain].name])),1),u("p",Z,V(n(s).providerManifests[i.domain].description),1),n(s).providerManifests[i.domain].codeowners.length?(c(),v("div",{key:0,class:"header-authors",innerHTML:n(M)(B(n(s).providerManifests[i.domain].codeowners))},null,8,ee)):_("",!0),n(s).providerManifests[i.domain].credits.length?(c(),v("div",{key:1,class:"header-authors",innerHTML:n(M)(H(n(s).providerManifests[i.domain].credits))},null,8,te)):_("",!0)])])]),_:1})])):_("",!0),a(x,{"config-entries":f.value,disabled:!1,onSubmit:T,onAction:E},null,8,["config-entries"]),a(L,{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(()=>[p.value?(c(),C(b,{key:0,style:{"background-color":"white"}},{default:d(()=>[a(j,null,{default:d(()=>[...e[1]||(e[1]=[k("Authenticating...",-1)])]),_:1}),a(D,null,{default:d(()=>[...e[2]||(e[2]=[k("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),a(U,null,{default:d(()=>[u("a",oe,[a(z,null,{default:d(()=>[...e[3]||(e[3]=[k("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(c(),C(G,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),Me=$(se,[["__scopeId","data-v-07f8d305"]]);export{Me as default};
