import{aw as B,J as g,a3 as S,aN as l,b9 as I,a4 as L,L as N,ax as k,ay as u,o as i,aD as r,az as p,aG as d,aB as o,E as m,be as w,bf as f,aL as c,bg as y,b_ as _,cC as P,aS as C,bF as j,c1 as U,bT as H,M as O,aQ as x,b6 as D,bv as z,bL as F,aC as G}from"./index-BeguICWm.js";import{E as J}from"./EditConfig-BikzkWGK.js";import{n as Q}from"./index.browser-OxPLOBIU.js";import{V as R}from"./VSwitch-DhgrqvI4.js";import"./VForm-o34xemXk.js";import"./VExpansionPanels-B8yzmmSz.js";import"./VDialog-3N5CnNiB.js";import"./VAlert-Dkia6PbV.js";import"./VSlider-5AtOwDvY.js";import"./VSelect-Be4aEu8s.js";import"./VVirtualScroll-Vx_hX6dw.js";import"./VCheckboxBtn-HpD-UT_z.js";const q={key:0},K={id:"auth",href:"",target:"_blank"},re=B({__name:"EditProvider",props:{instanceId:{}},setup(h){const M=G(),a=g(),V=Q(11),v=g(!1),b=g(!1),T=h;S(()=>{const n=l.subscribe(I.AUTH_SESSION,e=>{if(e.object_id!==V)return;const t=e.data;b.value=!0,window.setTimeout(()=>{const s=document.getElementById("auth");s.setAttribute("href",t),s.click()},100)});L(n)}),N(()=>T.instanceId,async n=>{n&&(a.value=await l.getProviderConfig(n))},{immediate:!0});const A=async function(n){v.value=!0,n.enabled=a.value.enabled,n.name=a.value.name||null,l.saveProviderConfig(a.value.domain,n,a.value.instance_id).then(()=>{M.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{v.value=!1,b.value=!1})},E=async function(n,e){v.value=!0;for(const t of Object.values(a.value.values))t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=V,l.getProviderConfigEntries(a.value.domain,a.value.instance_id,n,e).then(t=>{a.value.values={};for(const s of t)a.value.values[s.key]=s}).catch(t=>{alert(t)}).finally(()=>{v.value=!1,b.value=!1})},$=function(n){const e=[],{t}=F();for(const s of n)s.includes("@")?e.push(`[${s.replace("@","")}](https://github.com/${s.replace("@","")})`):e.push(s);return`**${t("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(u(),k("section",null,[i(U,null,{default:r(()=>[a.value&&o(l).providerManifests[a.value.domain]?(u(),k("div",q,[i(w,null,{default:r(()=>[f(c(n.$t("settings.setup_provider",[o(l).providerManifests[a.value.domain].name])),1)]),_:1}),i(y,{style:{"white-space":"normal"}},{default:r(()=>[f(c(o(l).providerManifests[a.value.domain].description),1)]),_:1}),e[5]||(e[5]=m("br",null,null,-1)),o(l).providerManifests[a.value.domain].codeowners.length?(u(),d(y,{key:0,innerHTML:o(_)($(o(l).providerManifests[a.value.domain].codeowners))},null,8,["innerHTML"])):p("",!0),o(l).providerManifests[a.value.domain].documentation?(u(),d(y,{key:1},{default:r(()=>[m("b",null,c(n.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=f("  ",-1)),m("a",{onClick:e[0]||(e[0]=t=>o(P)(o(l).providerManifests[a.value.domain].documentation))},c(n.$t("settings.check_docs")),1)]),_:1})):p("",!0),e[6]||(e[6]=m("br",null,null,-1)),i(C),e[7]||(e[7]=m("br",null,null,-1)),e[8]||(e[8]=m("br",null,null,-1)),"name"in a.value?(u(),d(j,{key:2,modelValue:a.value.name,"onUpdate:modelValue":e[1]||(e[1]=t=>a.value.name=t),placeholder:o(l).getProvider(a.value.instance_id)?.name,label:n.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):p("",!0),"enabled"in a.value?(u(),d(R,{key:3,modelValue:a.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=t=>a.value.enabled=t),label:n.$t("settings.enable_provider"),color:"primary",disabled:!o(l).providerManifests[a.value.domain]?.allow_disable},null,8,["modelValue","label","disabled"])):p("",!0)])):p("",!0),i(C),a.value?(u(),d(J,{key:1,"config-entries":Object.values(a.value.values),disabled:!a.value.enabled,onSubmit:A,onAction:E},null,8,["config-entries","disabled"])):p("",!0)]),_:1}),i(z,{modelValue:v.value,"onUpdate:modelValue":e[3]||(e[3]=t=>v.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[b.value?(u(),d(x,{key:0,style:{"background-color":"white"}},{default:r(()=>[i(w,null,{default:r(()=>[...e[9]||(e[9]=[f("Authenticating...",-1)])]),_:1}),i(y,null,{default:r(()=>[...e[10]||(e[10]=[f("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),i(H,null,{default:r(()=>[m("a",K,[i(O,null,{default:r(()=>[...e[11]||(e[11]=[f("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),d(D,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{re as default};
