import{Q as S,x as V,o as I,a4 as o,aU as U,b as _,w as N,Z as w,B as s,U as r,bD as P,bg as j,S as u,a9 as v,R as d,a0 as i,W as m,aZ as C,ao as f,ab as y,a_ as g,bz as x,c9 as H,Y as h,bx as L,a7 as O,br as D,bE as z}from"./index-CjKqSS7W.js";import{E as R}from"./EditConfig-9zjcpbs4.js";import{n as Z}from"./index.browser-OxPLOBIU.js";import{V as F}from"./VTextField-cwB3gAIj.js";import{V as Q}from"./VSwitch-Bc2Oj35C.js";import{a as W,b as Y}from"./VBtn-CIAN6k9R.js";import"./VForm-BKq248nc.js";import"./VCheckboxBtn-Yw1fo7EH.js";import"./VExpansionPanels-DQqGBT2F.js";import"./VAlert-uW_UuQw8.js";import"./VSlider-B9z5HH84.js";import"./VVirtualScroll-LbHvdAV3.js";import"./VDialog-OUDbMT8x.js";import"./VSpacer-DzR7cAEV.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const q={key:0},G={id:"auth",href:"",target:"_blank"},ve=S({__name:"EditProvider",props:{instanceId:{}},setup(M){const T=z(),a=V(),k=Z(11),p=V(!1),b=V(!1),A=M;I(()=>{const t=o.subscribe(U.AUTH_SESSION,e=>{if(e.object_id!==k)return;const n=e.data;b.value=!0,window.setTimeout(()=>{const l=document.getElementById("auth");l.setAttribute("href",n),l.click()},100)});_(t)}),N(()=>A.instanceId,async t=>{t&&(a.value=await o.getProviderConfig(t))},{immediate:!0});const E=async function(t){p.value=!0,t.enabled=a.value.enabled,t.name=a.value.name||null,o.saveProviderConfig(a.value.domain,t,a.value.instance_id).then(()=>{T.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{p.value=!1,b.value=!1})},$=async function(t,e){p.value=!0;for(const n of Object.values(a.value.values))n.value!==void 0&&e[n.key]==null&&(e[n.key]=n.value);e.session_id=k,o.getProviderConfigEntries(a.value.domain,a.value.instance_id,t,e).then(n=>{a.value.values={};for(const l of n)a.value.values[l.key]=l}).catch(n=>{alert(n)}).finally(()=>{p.value=!1,b.value=!1})},B=function(t){const e=[],{t:n}=D();for(const l of t)l.includes("@")?e.push(`[${l.replace("@","")}](https://github.com/${l.replace("@","")})`):e.push(l);return`**${n("settings.codeowners")}**: `+e.join(" / ")};return(t,e)=>(u(),w("section",null,[s(P,null,{default:r(()=>{var n,l;return[a.value&&i(o).providerManifests[a.value.domain]?(u(),w("div",q,[s(C,null,{default:r(()=>[f(y(t.$t("settings.setup_provider",[i(o).providerManifests[a.value.domain].name])),1)]),_:1}),s(g,{style:{"white-space":"normal"}},{default:r(()=>[f(y(i(o).providerManifests[a.value.domain].description),1)]),_:1}),e[5]||(e[5]=m("br",null,null,-1)),i(o).providerManifests[a.value.domain].codeowners.length?(u(),d(g,{key:0,innerHTML:i(x)(B(i(o).providerManifests[a.value.domain].codeowners))},null,8,["innerHTML"])):v("",!0),i(o).providerManifests[a.value.domain].documentation?(u(),d(g,{key:1},{default:r(()=>[m("b",null,y(t.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=f("  ")),m("a",{onClick:e[0]||(e[0]=c=>i(H)(i(o).providerManifests[a.value.domain].documentation))},y(t.$t("settings.check_docs")),1)]),_:1})):v("",!0),e[6]||(e[6]=m("br",null,null,-1)),s(h),e[7]||(e[7]=m("br",null,null,-1)),e[8]||(e[8]=m("br",null,null,-1)),"name"in a.value?(u(),d(F,{key:2,modelValue:a.value.name,"onUpdate:modelValue":e[1]||(e[1]=c=>a.value.name=c),placeholder:(n=i(o).getProvider(a.value.instance_id))==null?void 0:n.name,label:t.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in a.value?(u(),d(Q,{key:3,modelValue:a.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=c=>a.value.enabled=c),label:t.$t("settings.enable_provider"),color:"primary",disabled:!((l=i(o).providerManifests[a.value.domain])!=null&&l.allow_disable)},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),s(h),a.value?(u(),d(R,{key:1,"config-entries":Object.values(a.value.values),disabled:!a.value.enabled,onSubmit:E,onAction:$},null,8,["config-entries","disabled"])):v("",!0)]}),_:1}),s(j,{modelValue:p.value,"onUpdate:modelValue":e[3]||(e[3]=n=>p.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[b.value?(u(),d(O,{key:0,style:{"background-color":"white"}},{default:r(()=>[s(C,null,{default:r(()=>e[9]||(e[9]=[f("Authenticating...")])),_:1}),s(g,null,{default:r(()=>e[10]||(e[10]=[f("A new tab/popup should be opened where you can authenticate")])),_:1}),s(L,null,{default:r(()=>[m("a",G,[s(W,null,{default:r(()=>e[11]||(e[11]=[f("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(u(),d(Y,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{ve as default};
