import{ay as S,J as b,a3 as I,aP as l,bb as N,a4 as P,L as _,az as V,aA as r,o as s,aG as i,aB as v,aI as m,aD as u,E as p,bg as k,bh as f,aN as w,bi as y,c0 as U,aU as h,bH as $,c3 as j,bV as x,M as H,aS as L,b8 as O,bx as D,bN as z,aE as F}from"./index-BRUnowC8.js";import{E as G}from"./EditConfig-DaKyuWVG.js";import{n as J}from"./index.browser-OxPLOBIU.js";import{V as R}from"./VSwitch-Dcs-7m3i.js";import"./VForm-CLH0WxMk.js";import"./VExpansionPanels-CpHWuHN2.js";import"./VDialog-Bh3mGVOy.js";import"./VAlert-DQxypmdN.js";import"./VSlider-BOibVdD7.js";import"./VSelect-B-WERBOu.js";import"./VVirtualScroll-htzu2YXu.js";import"./VCheckboxBtn-D390s4L9.js";import"./VSelectionControl-Co1cRcmS.js";const q={key:0},K={id:"auth",href:"",target:"_blank"},re=S({__name:"EditProvider",props:{instanceId:{}},setup(C){const M=F(),a=b(),g=J(11),d=b(!1),c=b(!1),A=C;I(()=>{const n=l.subscribe(N.AUTH_SESSION,e=>{if(e.object_id!==g)return;const t=e.data;c.value=!0,window.setTimeout(()=>{const o=document.getElementById("auth");o.setAttribute("href",t),o.click()},100)});P(n)}),_(()=>A.instanceId,async n=>{n&&(a.value=await l.getProviderConfig(n))},{immediate:!0});const E=async function(n){d.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(()=>{d.value=!1,c.value=!1})},T=async function(n,e){d.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=g,l.getProviderConfigEntries(a.value.domain,a.value.instance_id,n,e).then(t=>{a.value.values={};for(const o of t)a.value.values[o.key]=o}).catch(t=>{alert(t)}).finally(()=>{d.value=!1,c.value=!1})},B=function(n){const e=[],{t}=z();for(const o of n)o.includes("@")?e.push(`[${o.replace("@","")}](https://github.com/${o.replace("@","")})`):e.push(o);return`**${t("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(r(),V("section",null,[s(j,null,{default:i(()=>[a.value&&u(l).providerManifests[a.value.domain]?(r(),V("div",q,[s(k,null,{default:i(()=>[f(w(n.$t("settings.setup_provider",[u(l).providerManifests[a.value.domain].name])),1)]),_:1}),s(y,{style:{"white-space":"normal"}},{default:i(()=>[f(w(u(l).providerManifests[a.value.domain].description),1)]),_:1}),e[3]||(e[3]=p("br",null,null,-1)),u(l).providerManifests[a.value.domain].codeowners.length?(r(),m(y,{key:0,innerHTML:u(U)(B(u(l).providerManifests[a.value.domain].codeowners))},null,8,["innerHTML"])):v("",!0),e[4]||(e[4]=p("br",null,null,-1)),s(h),e[5]||(e[5]=p("br",null,null,-1)),e[6]||(e[6]=p("br",null,null,-1)),"name"in a.value?(r(),m($,{key:1,modelValue:a.value.name,"onUpdate:modelValue":e[0]||(e[0]=t=>a.value.name=t),placeholder:u(l).getProvider(a.value.instance_id)?.name,label:n.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in a.value?(r(),m(R,{key:2,modelValue:a.value.enabled,"onUpdate:modelValue":e[1]||(e[1]=t=>a.value.enabled=t),label:n.$t("settings.enable_provider"),color:"primary",disabled:!u(l).providerManifests[a.value.domain]?.allow_disable},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),s(h),a.value?(r(),m(G,{key:1,"config-entries":Object.values(a.value.values),disabled:!a.value.enabled,onSubmit:E,onAction:T},null,8,["config-entries","disabled"])):v("",!0)]),_:1}),s(D,{modelValue:d.value,"onUpdate:modelValue":e[2]||(e[2]=t=>d.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:i(()=>[c.value?(r(),m(L,{key:0,style:{"background-color":"white"}},{default:i(()=>[s(k,null,{default:i(()=>[...e[7]||(e[7]=[f("Authenticating...",-1)])]),_:1}),s(y,null,{default:i(()=>[...e[8]||(e[8]=[f("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),s(x,null,{default:i(()=>[p("a",K,[s(H,null,{default:i(()=>[...e[9]||(e[9]=[f("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(r(),m(O,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{re as default};
