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