import{v as $,aa as B,r as y,o as E,L as l,an as N,b as T,w as j,y as s,E as V,l as r,A as d,x as i,Q as f,N as m,z as p,B as u,I as v}from"./index-5804982a.js";import{V as x,_ as I}from"./EditConfig.vue_vue_type_style_index_0_lang-884cccde.js";import{n as P}from"./index.browser-342e672c.js";import{a as U,V as O}from"./VCardText-963b2439.js";import{a as _}from"./VCard-cc8044ef.js";import{k as h,x as A}from"./forwardRefs-03519353.js";import{V as z}from"./VTextField-b58cde95.js";import{f as D}from"./VMenu-18f2572a.js";import"./VExpansionPanel-3bba88b7.js";import"./VInput-fe7a35fc.js";import"./VSlideGroup-711de993.js";import"./VForm-85034c32.js";/* empty css              */import"./VDialog-c56f60de.js";import"./VAlert-8600f5db.js";import"./VSelect-e6597dd4.js";import"./VVirtualScroll-72995e2a.js";const F={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},H=u("br",null,null,-1),L=["href"],Q=u("br",null,null,-1),R=u("br",null,null,-1),q=u("br",null,null,-1),de=$({__name:"EditProvider",props:{instanceId:{}},setup(k){const w=B(),e=y(),g=P(11),o=y(!1),C=k;E(()=>{const a=l.subscribe(N.AUTH_SESSION,n=>{if(n.object_id!==g)return;const t=n.data;window.open(t,"_blank").focus()});T(a)}),j(()=>C.instanceId,async a=>{a&&(e.value=await l.getProviderConfig(a))},{immediate:!0});const M=async function(a){o.value=!0,a.enabled=e.value.enabled,a.name=e.value.name||null,l.saveProviderConfig(e.value.domain,a,e.value.instance_id).then(()=>{o.value=!1,w.push({name:"providersettings"})}).catch(n=>{alert(n),o.value=!1})},S=async function(a,n){o.value=!0;for(const t of Object.values(e.value.values))t.value!==void 0&&n[t.key]==null&&(n[t.key]=t.value);n.session_id=g,l.getProviderConfigEntries(e.value.domain,e.value.instance_id,a,n).then(t=>{e.value.values={};for(const c of t)e.value.values[c.key]=c;o.value=!1}).catch(t=>{alert(t),o.value=!1})};return(a,n)=>(s(),V("section",null,[r(O,null,{default:d(()=>{var t,c;return[e.value&&i(l).providerManifests[e.value.domain]?(s(),V("div",F,[r(U,null,{default:d(()=>[f(m(a.$t("settings.setup_provider",[i(l).providerManifests[e.value.domain].name])),1)]),_:1}),r(_,null,{default:d(()=>[f(m(i(l).providerManifests[e.value.domain].description),1)]),_:1}),H,i(l).providerManifests[e.value.domain].codeowners.length?(s(),p(_,{key:0},{default:d(()=>[u("b",null,m(a.$t("settings.codeowners"))+": ",1),f(m(i(l).providerManifests[e.value.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),i(l).providerManifests[e.value.domain].documentation?(s(),p(_,{key:1},{default:d(()=>[u("b",null,m(a.$t("settings.need_help_setup_provider")),1),f("  "),u("a",{href:i(l).providerManifests[e.value.domain].documentation,target:"_blank"},m(a.$t("settings.check_docs")),9,L)]),_:1})):v("",!0),Q,r(h),R,q,"name"in e.value?(s(),p(z,{key:2,modelValue:e.value.name,"onUpdate:modelValue":n[0]||(n[0]=b=>e.value.name=b),placeholder:(t=e.value)==null?void 0:t.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in e.value?(s(),p(x,{key:3,modelValue:e.value.enabled,"onUpdate:modelValue":n[1]||(n[1]=b=>e.value.enabled=b),label:a.$t("settings.enable_provider"),color:"primary",disabled:(c=i(l).providerManifests[e.value.domain])==null?void 0:c.builtin},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),r(h),e.value?(s(),p(I,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:M,onAction:S},null,8,["config-entries","disabled"])):v("",!0)]}),_:1}),r(D,{modelValue:o.value,"onUpdate:modelValue":n[2]||(n[2]=t=>o.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:d(()=>[r(A,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{de as default};
