import{n as B}from"./index.browser-DP16PUbO.js";import{d as S,ak as T,r as b,o as _,b as n,a7 as N,a as P,K as j,c as u,h as C,f as r,w as i,u as s,W as l,t as f,g as a,e as g,j as V}from"./index-CLKg64ON.js";import{E as $}from"./EditConfig-CkB1xNeb.js";import{b as I,V as h,a as c}from"./VCardText-BAUfdzDA.js";import{c as U}from"./VMenu-CLSWQG_U.js";import{V as z}from"./VList-BvG6-yh2.js";import{a as D,V as O}from"./VCard-BaRPabiE.js";import{s as H,z as K}from"./VListItem-B_TSjQ1y.js";import"./VExpansionPanels-BBVj4yuE.js";import"./VCheckboxBtn-DXJHHMHd.js";import"./VAlert-CCGDAWu2.js";import"./VTextField-C1QkMZRy.js";import"./VForm-Cft_KNdc.js";import"./VVirtualScroll-DKBgr9yN.js";import"./VSpacer-CqqJVVs3.js";/* empty css              */import"./VDialog-BpGrcp5y.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const L={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},R=["href"],W={id:"auth",href:"",target:"_blank"},de=S({__name:"AddProvider",props:{domain:{}},setup(w){const A=T(),m=b([]),y=B(11),d=b(!1),p=b(!1),v=w;_(()=>{const t=n.subscribe(N.AUTH_SESSION,e=>{if(e.object_id!==y)return;const o=e.data;p.value=!0,window.setTimeout(()=>{const k=document.getElementById("auth");k.setAttribute("href",o),k.click()},100)});P(t)}),j(()=>v.domain,async t=>{t&&(m.value=await n.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:y}))},{immediate:!0});const E=async function(t){d.value=!0,n.saveProviderConfig(v.domain,t).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{d.value=!1,p.value=!1})},M=async function(t,e){d.value=!0;for(const o of m.value)o.value!==void 0&&e[o.key]==null&&(e[o.key]=o.value);e.session_id=y,n.getProviderConfigEntries(v.domain,void 0,t,e).then(o=>{m.value=o}).catch(o=>{alert(o)}).finally(()=>{d.value=!1,p.value=!1})};return(t,e)=>(u(),C("section",null,[r(I,null,{default:i(()=>[s(n).providerManifests[t.domain]?(u(),C("div",L,[r(h,null,{default:i(()=>[l(f(t.$t("settings.setup_provider",[s(n).providerManifests[t.domain].name])),1)]),_:1}),r(c,null,{default:i(()=>[l(f(s(n).providerManifests[t.domain].description),1)]),_:1}),e[2]||(e[2]=a("br",null,null,-1)),s(n).providerManifests[t.domain].codeowners.length?(u(),g(c,{key:0},{default:i(()=>[a("b",null,f(t.$t("settings.codeowners"))+": ",1),l(f(s(n).providerManifests[t.domain].codeowners.join(" / ")),1)]),_:1})):V("",!0),s(n).providerManifests[t.domain].documentation?(u(),g(c,{key:1},{default:i(()=>[a("b",null,f(t.$t("settings.need_help_setup_provider")),1),e[1]||(e[1]=l("  ")),a("a",{href:s(n).providerManifests[t.domain].documentation,target:"_blank"},f(t.$t("settings.check_docs")),9,R)]),_:1})):V("",!0)])):V("",!0),e[3]||(e[3]=a("br",null,null,-1)),r(z),e[4]||(e[4]=a("br",null,null,-1)),e[5]||(e[5]=a("br",null,null,-1)),r($,{"config-entries":m.value,disabled:!1,onSubmit:E,onAction:M},null,8,["config-entries"])]),_:1}),r(U,{modelValue:d.value,"onUpdate:modelValue":e[0]||(e[0]=o=>d.value=o),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:i(()=>[p.value?(u(),g(O,{key:0,style:{"background-color":"white"}},{default:i(()=>[r(h,null,{default:i(()=>e[6]||(e[6]=[l("Authenticating...")])),_:1}),r(c,null,{default:i(()=>e[7]||(e[7]=[l("A new tab/popup should be opened where you can authenticate")])),_:1}),r(D,null,{default:i(()=>[a("a",W,[r(H,null,{default:i(()=>e[8]||(e[8]=[l("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(u(),g(K,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{de as default};
