import{d as P,an as S,r as y,o as T,b as l,a7 as j,a as N,N as $,c as s,g as V,f as i,w as o,u as r,Y as m,t as p,e as c,i as d,j as b}from"./index-e34071c2.js";import{V as I,E as U}from"./EditConfig-5e7973cb.js";import{n as O}from"./index.browser-342e672c.js";import{V as k,a as D}from"./VCardText-2a290ffe.js";import{a as _,b as x,V as z}from"./VCard-0f63f60c.js";import{V as w}from"./VList-5a526902.js";import{V as F}from"./VTextField-df721147.js";import{s as H,y as L}from"./VListItem-6fb16d04.js";import{c as R}from"./VMenu-8ea0aa0a.js";import"./VExpansionPanels-a37be689.js";import"./VCheckboxBtn-43c6a5b9.js";import"./VForm-9598bded.js";import"./VVirtualScroll-8b839030.js";import"./VSpacer-b7ae4876.js";/* empty css              */import"./VDialog-57dacf99.js";import"./VAlert-cd8a958f.js";import"./_plugin-vue_export-helper-c27b6911.js";const Y={key:0},q=d("br",null,null,-1),G=["href"],J=d("br",null,null,-1),K=d("br",null,null,-1),Q=d("br",null,null,-1),W={id:"auth",href:"",target:"_blank"},be=P({__name:"EditProvider",props:{instanceId:{}},setup(C){const E=S(),e=y(),g=O(11),v=y(!1),h=y(!1),M=C;T(()=>{const a=l.subscribe(j.AUTH_SESSION,t=>{if(t.object_id!==g)return;const n=t.data;window.setTimeout(()=>{const u=document.getElementById("auth");u.setAttribute("href",n),u.click()},100)});N(a)}),$(()=>M.instanceId,async a=>{a&&(e.value=await l.getProviderConfig(a))},{immediate:!0});const A=async function(a){v.value=!0,a.enabled=e.value.enabled,a.name=e.value.name||null,l.saveProviderConfig(e.value.domain,a,e.value.instance_id).then(()=>{E.push({name:"providersettings"})}).catch(t=>{alert(t)}).finally(()=>{v.value=!1,h.value=!1})},B=async function(a,t){v.value=!0;for(const n of Object.values(e.value.values))n.value!==void 0&&t[n.key]==null&&(t[n.key]=n.value);t.session_id=g,l.getProviderConfigEntries(e.value.domain,e.value.instance_id,a,t).then(n=>{e.value.values={};for(const u of n)e.value.values[u.key]=u}).catch(n=>{alert(n)}).finally(()=>{v.value=!1,h.value=!1})};return(a,t)=>(s(),V("section",null,[i(D,null,{default:o(()=>{var n,u;return[e.value&&r(l).providerManifests[e.value.domain]?(s(),V("div",Y,[i(k,null,{default:o(()=>{var f;return[m(p(a.$t("settings.setup_provider",[e.value.name||((f=r(l).getProvider(e.value.instance_id))==null?void 0:f.name)])),1)]}),_:1}),i(_,{style:{"white-space":"normal"}},{default:o(()=>[m(p(r(l).providerManifests[e.value.domain].description),1)]),_:1}),q,r(l).providerManifests[e.value.domain].codeowners.length?(s(),c(_,{key:0},{default:o(()=>[d("b",null,p(a.$t("settings.codeowners"))+": ",1),m(p(r(l).providerManifests[e.value.domain].codeowners.join(" / ")),1)]),_:1})):b("",!0),r(l).providerManifests[e.value.domain].documentation?(s(),c(_,{key:1},{default:o(()=>[d("b",null,p(a.$t("settings.need_help_setup_provider")),1),m("  "),d("a",{href:r(l).providerManifests[e.value.domain].documentation,target:"_blank"},p(a.$t("settings.check_docs")),9,G)]),_:1})):b("",!0),J,i(w),K,Q,"name"in e.value?(s(),c(F,{key:2,modelValue:e.value.name,"onUpdate:modelValue":t[0]||(t[0]=f=>e.value.name=f),placeholder:(n=r(l).getProvider(e.value.instance_id))==null?void 0:n.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):b("",!0),"enabled"in e.value?(s(),c(I,{key:3,modelValue:e.value.enabled,"onUpdate:modelValue":t[1]||(t[1]=f=>e.value.enabled=f),label:a.$t("settings.enable_provider"),color:"primary",disabled:!((u=r(l).providerManifests[e.value.domain])!=null&&u.allow_disable)},null,8,["modelValue","label","disabled"])):b("",!0)])):b("",!0),i(w),e.value?(s(),c(U,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:A,onAction:B},null,8,["config-entries","disabled"])):b("",!0)]}),_:1}),i(R,{modelValue:v.value,"onUpdate:modelValue":t[2]||(t[2]=n=>v.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:o(()=>[h.value?(s(),c(z,{key:0,style:{"background-color":"white"}},{default:o(()=>[i(k,null,{default:o(()=>[m("Authenticating...")]),_:1}),i(_,null,{default:o(()=>[m("A new tab/popup should be opened where you can authenticate")]),_:1}),i(x,null,{default:o(()=>[d("a",W,[i(H,null,{default:o(()=>[m("Click here if the popup did not open")]),_:1})])]),_:1})]),_:1})):(s(),c(L,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{be as default};
