import{d as $,a1 as j,r as V,o as T,b as o,ah as B,a as E,I,c as s,h as y,f as r,w as d,u as i,m as f,t as m,e as p,g as u,j as v}from"./index-0ae84607.js";import{V as N,_ as P}from"./EditConfig.vue_vue_type_style_index_0_lang-991e1055.js";import{n as U}from"./index.browser-342e672c.js";import{a as O,V as x}from"./VCardText-b1a0de89.js";import{a as _}from"./VCard-e96ab32b.js";import{a as h,t as A}from"./forwardRefs-d0d7c5bd.js";import{V as D}from"./VTextField-4bf39c0d.js";import{e as z}from"./VMenu-f26d3a19.js";import"./VExpansionPanel-4cf67b18.js";import"./VInput-00e20677.js";import"./VSlideGroup-18f8a11f.js";import"./VForm-272c3dd0.js";/* empty css              */import"./VDialog-2b5eada8.js";import"./VAlert-212471f5.js";import"./VSelect-2b6c5c22.js";import"./VVirtualScroll-06bbaaf5.js";const F={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},H=u("br",null,null,-1),R=["href"],q=u("br",null,null,-1),G=u("br",null,null,-1),J=u("br",null,null,-1),de=$({__name:"EditProvider",props:{instanceId:{}},setup(k){const w=j(),e=V(),g=U(11),l=V(!1),C=k;T(()=>{const a=o.subscribe(B.AUTH_SESSION,t=>{if(t.object_id!==g)return;const n=t.data;window.open(n,"_blank").focus()});E(a)}),I(()=>C.instanceId,async a=>{a&&(e.value=await o.getProviderConfig(a))},{immediate:!0});const M=async function(a){l.value=!0,a.enabled=e.value.enabled,a.name=e.value.name||null,o.saveProviderConfig(e.value.domain,a,e.value.instance_id).then(()=>{l.value=!1,w.push({name:"providersettings"})}).catch(t=>{alert(t),l.value=!1})},S=async function(a,t){l.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,o.getProviderConfigEntries(e.value.domain,e.value.instance_id,a,t).then(n=>{e.value.values={};for(const c of n)e.value.values[c.key]=c;l.value=!1}).catch(n=>{alert(n),l.value=!1})};return(a,t)=>(s(),y("section",null,[r(x,null,{default:d(()=>{var n,c;return[e.value&&i(o).providerManifests[e.value.domain]?(s(),y("div",F,[r(O,null,{default:d(()=>[f(m(a.$t("settings.setup_provider",[i(o).providerManifests[e.value.domain].name])),1)]),_:1}),r(_,null,{default:d(()=>[f(m(i(o).providerManifests[e.value.domain].description),1)]),_:1}),H,i(o).providerManifests[e.value.domain].codeowners.length?(s(),p(_,{key:0},{default:d(()=>[u("b",null,m(a.$t("settings.codeowners"))+": ",1),f(m(i(o).providerManifests[e.value.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),i(o).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(o).providerManifests[e.value.domain].documentation,target:"_blank"},m(a.$t("settings.check_docs")),9,R)]),_:1})):v("",!0),q,r(h),G,J,"name"in e.value?(s(),p(D,{key:2,modelValue:e.value.name,"onUpdate:modelValue":t[0]||(t[0]=b=>e.value.name=b),placeholder:(n=e.value)==null?void 0:n.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in e.value?(s(),p(N,{key:3,modelValue:e.value.enabled,"onUpdate:modelValue":t[1]||(t[1]=b=>e.value.enabled=b),label:a.$t("settings.enable_provider"),color:"primary",disabled:(c=i(o).providerManifests[e.value.domain])==null?void 0:c.builtin},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),r(h),e.value?(s(),p(P,{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(z,{modelValue:l.value,"onUpdate:modelValue":t[2]||(t[2]=n=>l.value=n),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};
