import{n as $}from"./index.browser-OxPLOBIU.js";import{d as H,i as y,j as I,m as o,a_ as L,l as N,ad as S,c as C,o as d,b as i,w as r,bI as P,bl as j,q as k,a as l,u as s,e as c,b3 as V,b4 as p,t as w,b5 as b,bE as h,ce as U,p as D,bC as O,n as q,bJ as z,bw as J}from"./index-LFx1jIjH.js";import{E as R}from"./EditConfig-UygF_D1P.js";import{a as _,b as F}from"./VBtn-BYKkZzw0.js";import"./VForm-DI6jEBhI.js";import"./VInput-B3Z2GK8Z.js";import"./VExpansionPanels-DUWI7Gyy.js";import"./VAlert-Cyb25ra3.js";import"./VSwitch-B-ONWUbe.js";import"./VTextField-DyzwZgKh.js";import"./VVirtualScroll-DYZmdOFl.js";import"./VSlider-B0DY4XNd.js";import"./VDialog-zNF2U_x9.js";import"./VSpacer-Cg-cZSyv.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const G={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},K={id:"auth",href:"",target:"_blank"},de=H({__name:"AddProvider",props:{domain:{}},setup(M){const T=z(),m=y([]),g=$(11),u=y(!1),f=y(!1),v=M;I(()=>{const t=o.subscribe(L.AUTH_SESSION,e=>{if(e.object_id!==g)return;const n=e.data;f.value=!0,window.setTimeout(()=>{const a=document.getElementById("auth");a.setAttribute("href",n),a.click()},100)});N(t)}),S(()=>v.domain,async t=>{t&&(m.value=await o.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:g}))},{immediate:!0});const A=async function(t){u.value=!0,o.saveProviderConfig(v.domain,t).then(()=>{T.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{u.value=!1,f.value=!1})},E=async function(t,e){u.value=!0;for(const n of m.value)n.value!==void 0&&e[n.key]==null&&(e[n.key]=n.value);e.session_id=g,o.getProviderConfigEntries(v.domain,void 0,t,e).then(n=>{m.value=n}).catch(n=>{alert(n)}).finally(()=>{u.value=!1,f.value=!1})},B=function(t){const e=[],{t:n}=J();for(const a of t)a.includes("@")?e.push(`[${a.replace("@","")}](https://github.com/${a.replace("@","")})`):e.push(a);return`**${n("settings.codeowners")}**: `+e.join(" / ")};return(t,e)=>(d(),C("section",null,[i(P,null,{default:r(()=>[s(o).providerManifests[t.domain]?(d(),C("div",G,[i(V,null,{default:r(()=>[p(w(t.$t("settings.setup_provider",[s(o).providerManifests[t.domain].name])),1)]),_:1}),i(b,{innerHTML:s(h)(s(o).providerManifests[t.domain].description)},null,8,["innerHTML"]),e[3]||(e[3]=l("br",null,null,-1)),s(o).providerManifests[t.domain].codeowners.length?(d(),c(b,{key:0,innerHTML:s(h)(B(s(o).providerManifests[t.domain].codeowners))},null,8,["innerHTML"])):k("",!0),s(o).providerManifests[t.domain].documentation?(d(),c(b,{key:1},{default:r(()=>[l("b",null,w(t.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=p("  ",-1)),l("a",{onClick:e[0]||(e[0]=n=>s(U)(s(o).providerManifests[t.domain].documentation))},w(t.$t("settings.check_docs")),1)]),_:1})):k("",!0)])):k("",!0),e[4]||(e[4]=l("br",null,null,-1)),i(D),e[5]||(e[5]=l("br",null,null,-1)),e[6]||(e[6]=l("br",null,null,-1)),i(R,{"config-entries":m.value,disabled:!1,onSubmit:A,onAction:E},null,8,["config-entries"])]),_:1}),i(j,{modelValue:u.value,"onUpdate:modelValue":e[1]||(e[1]=n=>u.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[f.value?(d(),c(q,{key:0,style:{"background-color":"white"}},{default:r(()=>[i(V,null,{default:r(()=>[...e[7]||(e[7]=[p("Authenticating...",-1)])]),_:1}),i(b,null,{default:r(()=>[...e[8]||(e[8]=[p("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),i(O,null,{default:r(()=>[l("a",K,[i(_,null,{default:r(()=>[...e[9]||(e[9]=[p("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(d(),c(F,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{de as default};
