import{n as B}from"./index.browser-OxPLOBIU.js";import{a7 as L,F as k,L as S,ap as a,aN as $,N as H,M as I,a8 as w,a9 as f,o,ae as s,aa as V,E as u,ac as i,ai as g,aS as C,aT as m,an as h,aU as y,bF as M,cq as x,au as P,bI as U,by as j,ah as D,as as F,aK as O,b9 as q,ad as z,bp as K}from"./index-CFcIX8RO.js";import{E as R}from"./EditConfig-tTm2yaGt.js";import"./VForm-D4C74Wdm.js";import"./VExpansionPanels-D5FURIHn.js";import"./VDialog-C2cPU7vi.js";import"./VAlert-DZurr_D6.js";import"./VSwitch-JHKrUQHN.js";import"./VCheckboxBtn-Dy9mjR59.js";import"./VSlider-BVc6Euty.js";import"./VSelect-9ABLzY_9.js";import"./VVirtualScroll-BRrQ8Y7O.js";const G={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},J={id:"auth",href:"",target:"_blank"},se=L({__name:"AddProviderDetails",props:{domain:{}},setup(r){const T=z(),p=k([]),b=B(11),d=k(!1),c=k(!1),v=r;S(()=>{const n=a.subscribe($.AUTH_SESSION,e=>{if(e.object_id!==b)return;const t=e.data;c.value=!0,window.setTimeout(()=>{const l=document.getElementById("auth");l.setAttribute("href",t),l.click()},100)});H(n)}),I(()=>v.domain,async n=>{n&&(p.value=await a.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:b}))},{immediate:!0});const A=async function(n){d.value=!0,a.saveProviderConfig(v.domain,n).then(()=>{T.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{d.value=!1,c.value=!1})},E=async function(n,e){d.value=!0;for(const t of p.value)t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=b,a.getProviderConfigEntries(v.domain,void 0,n,e).then(t=>{p.value=t}).catch(t=>{alert(t)}).finally(()=>{d.value=!1,c.value=!1})},N=function(n){const e=[],{t}=K();for(const l of n)l.includes("@")?e.push(`[${l.replace("@","")}](https://github.com/${l.replace("@","")})`):e.push(l);return`**${t("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(f(),w("section",null,[o(U,null,{default:s(()=>[i(a).providerManifests[r.domain]?(f(),w("div",G,[o(C,null,{default:s(()=>[m(h(n.$t("settings.setup_provider",[i(a).providerManifests[r.domain].name])),1)]),_:1}),o(y,{innerHTML:i(M)(i(a).providerManifests[r.domain].description)},null,8,["innerHTML"]),e[3]||(e[3]=u("br",null,null,-1)),i(a).providerManifests[r.domain].codeowners.length?(f(),g(y,{key:0,innerHTML:i(M)(N(i(a).providerManifests[r.domain].codeowners))},null,8,["innerHTML"])):V("",!0),i(a).providerManifests[r.domain].documentation?(f(),g(y,{key:1},{default:s(()=>[u("b",null,h(n.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=m("  ",-1)),u("a",{onClick:e[0]||(e[0]=t=>i(x)(i(a).providerManifests[r.domain].documentation))},h(n.$t("settings.check_docs")),1)]),_:1})):V("",!0)])):V("",!0),e[4]||(e[4]=u("br",null,null,-1)),o(P),e[5]||(e[5]=u("br",null,null,-1)),e[6]||(e[6]=u("br",null,null,-1)),o(R,{"config-entries":p.value,disabled:!1,onSubmit:A,onAction:E},null,8,["config-entries"])]),_:1}),o(q,{modelValue:d.value,"onUpdate:modelValue":e[1]||(e[1]=t=>d.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:s(()=>[c.value?(f(),g(F,{key:0,style:{"background-color":"white"}},{default:s(()=>[o(C,null,{default:s(()=>[...e[7]||(e[7]=[m("Authenticating...",-1)])]),_:1}),o(y,null,{default:s(()=>[...e[8]||(e[8]=[m("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),o(j,null,{default:s(()=>[u("a",J,[o(D,null,{default:s(()=>[...e[9]||(e[9]=[m("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(f(),g(O,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{se as default};
