import{n as w}from"./index.browser-342e672c.js";import{v as M,aa as B,r as g,o as E,L as n,an as N,b as S,w as P,y as f,E as h,l as s,A as l,x as a,Q as p,N as d,z as y,B as r,I as v}from"./index-5804982a.js";import{_ as T}from"./EditConfig.vue_vue_type_style_index_0_lang-884cccde.js";import{a as $,V as A}from"./VCardText-963b2439.js";import{a as _}from"./VCard-cc8044ef.js";import{k as j,x as I}from"./forwardRefs-03519353.js";import{f as U}from"./VMenu-18f2572a.js";import"./VExpansionPanel-3bba88b7.js";import"./VInput-fe7a35fc.js";import"./VSlideGroup-711de993.js";import"./VForm-85034c32.js";/* empty css              */import"./VDialog-c56f60de.js";import"./VAlert-8600f5db.js";import"./VTextField-b58cde95.js";import"./VSelect-e6597dd4.js";import"./VVirtualScroll-72995e2a.js";const z={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},D=r("br",null,null,-1),O=["href"],H=r("br",null,null,-1),L=r("br",null,null,-1),Q=r("br",null,null,-1),ae=M({__name:"AddProvider",props:{domain:{}},setup(b){const V=B(),u=g([]),c=w(11),i=g(!1),m=b;E(()=>{const e=n.subscribe(N.AUTH_SESSION,o=>{if(o.object_id!==c)return;const t=o.data;window.open(t,"_blank").focus()});S(e)}),P(()=>m.domain,async e=>{e&&(u.value=await n.getProviderConfigEntries(m.domain,void 0,void 0,{session_id:c}))},{immediate:!0});const k=async function(e){i.value=!0,n.saveProviderConfig(m.domain,e).then(()=>{i.value=!1,V.push({name:"providersettings"})}).catch(o=>{alert(o),i.value=!1})},C=async function(e,o){i.value=!0;for(const t of u.value)t.value!==void 0&&o[t.key]==null&&(o[t.key]=t.value);o.session_id=c,n.getProviderConfigEntries(m.domain,void 0,e,o).then(t=>{u.value=t,i.value=!1}).catch(t=>{alert(t),i.value=!1})};return(e,o)=>(f(),h("section",null,[s(A,null,{default:l(()=>[a(n).providerManifests[e.domain]?(f(),h("div",z,[s($,null,{default:l(()=>[p(d(e.$t("settings.setup_provider",[a(n).providerManifests[e.domain].name])),1)]),_:1}),s(_,null,{default:l(()=>[p(d(a(n).providerManifests[e.domain].description),1)]),_:1}),D,a(n).providerManifests[e.domain].codeowners.length?(f(),y(_,{key:0},{default:l(()=>[r("b",null,d(e.$t("settings.codeowners"))+": ",1),p(d(a(n).providerManifests[e.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),a(n).providerManifests[e.domain].documentation?(f(),y(_,{key:1},{default:l(()=>[r("b",null,d(e.$t("settings.need_help_setup_provider")),1),p("  "),r("a",{href:a(n).providerManifests[e.domain].documentation,target:"_blank"},d(e.$t("settings.check_docs")),9,O)]),_:1})):v("",!0)])):v("",!0),H,s(j),L,Q,s(T,{"config-entries":u.value,disabled:!1,onSubmit:k,onAction:C},null,8,["config-entries"])]),_:1}),s(U,{modelValue:i.value,"onUpdate:modelValue":o[0]||(o[0]=t=>i.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:l(()=>[s(I,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{ae as default};
