import{d as B,r as g,m as I,v as l,a$ as S,q as N,ae as P,c as k,b as s,w as r,bJ as _,bm as j,o as u,e as v,h as d,u as o,a as m,b4 as w,b5 as f,t as c,b6 as y,bF as U,cg as x,y as C,bD as H,x as L,bx as O,f as D}from"./index-Bn2Tzsay.js";import{E as F}from"./EditConfig-C3k2Tp_5.js";import{n as q}from"./index.browser-OxPLOBIU.js";import{V as z}from"./VTextField-fPA0WAHx.js";import{V as J}from"./VSwitch-CO9p2KhR.js";import{V as R,b as G}from"./VBtn-BQk37KYJ.js";import"./VForm-DEMT2Ugv.js";import"./VInput-C_1AW61Q.js";import"./VExpansionPanels-DxWEyLfJ.js";import"./VAlert-Bj5fXNhB.js";import"./VSlider-DnweLLtQ.js";import"./VVirtualScroll-B56qZ1Y0.js";import"./VDialog-DRfRMr5_.js";import"./VSpacer-ygjaGObn.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const K={key:0},Q={id:"auth",href:"",target:"_blank"},pe=B({__name:"EditProvider",props:{instanceId:{}},setup(h){const M=D(),t=g(),V=q(11),p=g(!1),b=g(!1),T=h;I(()=>{const n=l.subscribe(S.AUTH_SESSION,e=>{if(e.object_id!==V)return;const a=e.data;b.value=!0,window.setTimeout(()=>{const i=document.getElementById("auth");i.setAttribute("href",a),i.click()},100)});N(n)}),P(()=>T.instanceId,async n=>{n&&(t.value=await l.getProviderConfig(n))},{immediate:!0});const $=async function(n){p.value=!0,n.enabled=t.value.enabled,n.name=t.value.name||null,l.saveProviderConfig(t.value.domain,n,t.value.instance_id).then(()=>{M.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{p.value=!1,b.value=!1})},A=async function(n,e){p.value=!0;for(const a of Object.values(t.value.values))a.value!==void 0&&e[a.key]==null&&(e[a.key]=a.value);e.session_id=V,l.getProviderConfigEntries(t.value.domain,t.value.instance_id,n,e).then(a=>{t.value.values={};for(const i of a)t.value.values[i.key]=i}).catch(a=>{alert(a)}).finally(()=>{p.value=!1,b.value=!1})},E=function(n){const e=[],{t:a}=O();for(const i of n)i.includes("@")?e.push(`[${i.replace("@","")}](https://github.com/${i.replace("@","")})`):e.push(i);return`**${a("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(u(),k("section",null,[s(_,null,{default:r(()=>[t.value&&o(l).providerManifests[t.value.domain]?(u(),k("div",K,[s(w,null,{default:r(()=>[f(c(n.$t("settings.setup_provider",[o(l).providerManifests[t.value.domain].name])),1)]),_:1}),s(y,{style:{"white-space":"normal"}},{default:r(()=>[f(c(o(l).providerManifests[t.value.domain].description),1)]),_:1}),e[5]||(e[5]=m("br",null,null,-1)),o(l).providerManifests[t.value.domain].codeowners.length?(u(),d(y,{key:0,innerHTML:o(U)(E(o(l).providerManifests[t.value.domain].codeowners))},null,8,["innerHTML"])):v("",!0),o(l).providerManifests[t.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]=a=>o(x)(o(l).providerManifests[t.value.domain].documentation))},c(n.$t("settings.check_docs")),1)]),_:1})):v("",!0),e[6]||(e[6]=m("br",null,null,-1)),s(C),e[7]||(e[7]=m("br",null,null,-1)),e[8]||(e[8]=m("br",null,null,-1)),"name"in t.value?(u(),d(z,{key:2,modelValue:t.value.name,"onUpdate:modelValue":e[1]||(e[1]=a=>t.value.name=a),placeholder:o(l).getProvider(t.value.instance_id)?.name,label:n.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in t.value?(u(),d(J,{key:3,modelValue:t.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=a=>t.value.enabled=a),label:n.$t("settings.enable_provider"),color:"primary",disabled:!o(l).providerManifests[t.value.domain]?.allow_disable},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),s(C),t.value?(u(),d(F,{key:1,"config-entries":Object.values(t.value.values),disabled:!t.value.enabled,onSubmit:$,onAction:A},null,8,["config-entries","disabled"])):v("",!0)]),_:1}),s(j,{modelValue:p.value,"onUpdate:modelValue":e[3]||(e[3]=a=>p.value=a),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[b.value?(u(),d(L,{key:0,style:{"background-color":"white"}},{default:r(()=>[s(w,null,{default:r(()=>[...e[9]||(e[9]=[f("Authenticating...",-1)])]),_:1}),s(y,null,{default:r(()=>[...e[10]||(e[10]=[f("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),s(H,null,{default:r(()=>[m("a",Q,[s(R,null,{default:r(()=>[...e[11]||(e[11]=[f("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),d(G,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{pe as default};
