import{n as $}from"./index.browser-OxPLOBIU.js";import{u as x}from"./vue-router-DvALZv_2.js";import{f as s,E as I,a2 as b,_ as L}from"./index-BTUEMLf5.js";import{E as N}from"./EditConfig-C5e8qvuy.js";import{_ as P}from"./ProviderIcon.vue_vue_type_style_index_0_lang-DjFjyMgl.js";import{a as w,p as S,D,x as j,m as U,k as z,L as O}from"./vuetify-BaCqMXPP.js";import{d as R,o as q,r as _,a0 as F,w as G,b as h,I as y,H as a,u as n,E as d,f as u,a1 as M,D as C,$ as k,e as c}from"./lucide-_oCiFqes.js";import{u as V}from"./vue-i18n-Dtd59yt5.js";import"./qrcode-fG4AAl2w.js";import"./marked-i_gIkIP3.js";import"./color-BTziYnFN.js";import"./vueuse-CtSQZy69.js";/* empty css            */import"./swiper-B7iBjdLa.js";import"./index-CpZ4YSWB.js";import"./reka-ui-BT9Jz-E-.js";import"./index-MfQlFusE.js";const J={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"],oe={id:"auth",href:"",target:"_blank"},se=R({__name:"AddProviderDetails",props:{domain:{}},setup(i){const A=x(),m=_([]),v=$(11),l=_(!1),f=_(!1),p=i;q(()=>{const o=s.subscribe(I.AUTH_SESSION,e=>{if(e.object_id!==v)return;const t=e.data;f.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",t),r.click()},100)});F(o)}),G(()=>p.domain,async o=>{o&&(m.value=await s.getProviderConfigEntries(p.domain,void 0,void 0,{session_id:v}))},{immediate:!0});const E=async function(o){l.value=!0,s.saveProviderConfig(p.domain,o).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{l.value=!1,f.value=!1})},T=async function(o,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(p.domain,void 0,o,e).then(t=>{m.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,f.value=!1})},B=function(o){const e=[],{t}=V();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}=V();return`**${e("settings.provider_credits")}**: `+o.join(" / ")};return(o,e)=>(c(),h("section",J,[n(s).providerManifests[i.domain]?(c(),h("div",K,[a(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[u("div",Q,[u("div",W,[a(P,{domain:i.domain,size:48},null,8,["domain"])]),u("div",X,[u("h2",Y,M(o.$t("settings.setup_provider",[n(s).providerManifests[i.domain].name])),1),u("p",Z,M(n(s).providerManifests[i.domain].description),1),n(s).providerManifests[i.domain].codeowners.length?(c(),h("div",{key:0,class:"header-authors",innerHTML:n(b)(B(n(s).providerManifests[i.domain].codeowners))},null,8,ee)):y("",!0),n(s).providerManifests[i.domain].credits.length?(c(),h("div",{key:1,class:"header-authors",innerHTML:n(b)(H(n(s).providerManifests[i.domain].credits))},null,8,te)):y("",!0)])])]),_:1})])):y("",!0),a(N,{"config-entries":m.value,disabled:!1,onSubmit:E,onAction:T},null,8,["config-entries"]),a(O,{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?(c(),C(w,{key:0,style:{"background-color":"white"}},{default:d(()=>[a(S,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(j,null,{default:d(()=>[u("a",oe,[a(U,null,{default:d(()=>[...e[3]||(e[3]=[k("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(c(),C(z,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),be=L(se,[["__scopeId","data-v-0a2b0962"]]);export{be as default};
