import{x as I,az as P,r as g,o as _,I as l,ag as $,b as h,w as N,y as s,D as w,n as i,A as o,G as r,S as v,J as b,B as d,z as p,K as c,aR as j}from"./index-DuDRe8hE.js";import{E as U}from"./EditConfig-cy0cMyvl.js";import{n as O}from"./index.browser-OxPLOBIU.js";import{b as z,V as C,a as V}from"./VCardText-Dn8Yf3BC.js";import{e as D}from"./VMenu-B49kEbTj.js";import{V as A}from"./VList-BlpguAX2.js";import{V as x}from"./VTextField-D5EFKWzi.js";import{V as L}from"./VSwitch--4YJ0kPH.js";import{a as R,V as F}from"./VCard-Cf5RelEw.js";import{v as G,C as H}from"./VListItem-CuoSvcqW.js";import"./VExpansionPanels-BNWc0M_m.js";import"./VCheckboxBtn-CMIUd74V.js";import"./VAlert-sqJ4UeFM.js";import"./VSlider-BanbeyJ6.js";import"./VVirtualScroll-CdwGYB7u.js";import"./VChip-BRQkwjNJ.js";import"./VForm-COUW7cJR.js";import"./VSpacer-CYzCqmAo.js";/* empty css              */import"./VDialog-BsvLwk-0.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const J={key:0},K={id:"auth",href:"",target:"_blank"},be=I({__name:"EditProvider",props:{instanceId:{}},setup(B){const E=P(),t=g(),k=O(11),f=g(!1),y=g(!1),M=B;_(()=>{const a=l.subscribe($.AUTH_SESSION,e=>{if(e.object_id!==k)return;const n=e.data;y.value=!0,window.setTimeout(()=>{const u=document.getElementById("auth");u.setAttribute("href",n),u.click()},100)});h(a)}),N(()=>M.instanceId,async a=>{a&&(t.value=await l.getProviderConfig(a))},{immediate:!0});const S=async function(a){f.value=!0,a.enabled=t.value.enabled,a.name=t.value.name||null,l.saveProviderConfig(t.value.domain,a,t.value.instance_id).then(()=>{E.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{f.value=!1,y.value=!1})},T=async function(a,e){f.value=!0;for(const n of Object.values(t.value.values))n.value!==void 0&&e[n.key]==null&&(e[n.key]=n.value);e.session_id=k,l.getProviderConfigEntries(t.value.domain,t.value.instance_id,a,e).then(n=>{t.value.values={};for(const u of n)t.value.values[u.key]=u}).catch(n=>{alert(n)}).finally(()=>{f.value=!1,y.value=!1})};return(a,e)=>(s(),w("section",null,[i(z,null,{default:o(()=>{var n,u;return[t.value&&r(l).providerManifests[t.value.domain]?(s(),w("div",J,[i(C,null,{default:o(()=>{var m;return[v(b(a.$t("settings.setup_provider",[t.value.name||((m=r(l).getProvider(t.value.instance_id))==null?void 0:m.name)])),1)]}),_:1}),i(V,{style:{"white-space":"normal"}},{default:o(()=>[v(b(r(l).providerManifests[t.value.domain].description),1)]),_:1}),e[5]||(e[5]=d("br",null,null,-1)),r(l).providerManifests[t.value.domain].codeowners.length?(s(),p(V,{key:0},{default:o(()=>[d("b",null,b(a.$t("settings.codeowners"))+": ",1),v(b(r(l).providerManifests[t.value.domain].codeowners.join(" / ")),1)]),_:1})):c("",!0),r(l).providerManifests[t.value.domain].documentation?(s(),p(V,{key:1},{default:o(()=>[d("b",null,b(a.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=v("  ")),d("a",{onClick:e[0]||(e[0]=m=>r(j)(r(l).providerManifests[t.value.domain].documentation))},b(a.$t("settings.check_docs")),1)]),_:1})):c("",!0),e[6]||(e[6]=d("br",null,null,-1)),i(A),e[7]||(e[7]=d("br",null,null,-1)),e[8]||(e[8]=d("br",null,null,-1)),"name"in t.value?(s(),p(x,{key:2,modelValue:t.value.name,"onUpdate:modelValue":e[1]||(e[1]=m=>t.value.name=m),placeholder:(n=r(l).getProvider(t.value.instance_id))==null?void 0:n.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):c("",!0),"enabled"in t.value?(s(),p(L,{key:3,modelValue:t.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=m=>t.value.enabled=m),label:a.$t("settings.enable_provider"),color:"primary",disabled:!((u=r(l).providerManifests[t.value.domain])!=null&&u.allow_disable)},null,8,["modelValue","label","disabled"])):c("",!0)])):c("",!0),i(A),t.value?(s(),p(U,{key:1,"config-entries":Object.values(t.value.values),disabled:!t.value.enabled,onSubmit:S,onAction:T},null,8,["config-entries","disabled"])):c("",!0)]}),_:1}),i(D,{modelValue:f.value,"onUpdate:modelValue":e[3]||(e[3]=n=>f.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:o(()=>[y.value?(s(),p(F,{key:0,style:{"background-color":"white"}},{default:o(()=>[i(C,null,{default:o(()=>e[9]||(e[9]=[v("Authenticating...")])),_:1}),i(V,null,{default:o(()=>e[10]||(e[10]=[v("A new tab/popup should be opened where you can authenticate")])),_:1}),i(R,null,{default:o(()=>[d("a",K,[i(G,null,{default:o(()=>e[11]||(e[11]=[v("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(s(),p(H,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{be as default};
