import{d as S,as as j,r as g,o as T,b as o,a8 as $,a as B,L as N,c as s,g as y,f as r,w as d,u as i,X as f,t as m,e as p,i as u,j as v}from"./index-2e87fa03.js";import{V as P,E as U}from"./EditConfig-a577dc6c.js";import{n as I}from"./index.browser-342e672c.js";import{V as O,a as A}from"./VCardText-064374a3.js";import{a as _}from"./VCard-c125380f.js";import{V as h}from"./VList-a4b75488.js";import{V as D}from"./VTextField-6302d32d.js";import{y as x}from"./VListItem-89fd7b1a.js";import{c as z}from"./VMenu-148e092d.js";import"./VExpansionPanels-24b8856d.js";import"./VCheckboxBtn-95584b13.js";import"./VForm-92cff6e5.js";import"./VVirtualScroll-9a54f195.js";import"./VSpacer-f5f551d9.js";/* empty css              */import"./VDialog-8481a663.js";import"./VAlert-d83244d0.js";import"./_plugin-vue_export-helper-c27b6911.js";const F={key:0},H=u("br",null,null,-1),L=["href"],R=u("br",null,null,-1),X=u("br",null,null,-1),q=u("br",null,null,-1),me=S({__name:"EditProvider",props:{instanceId:{}},setup(k){const C=j(),e=g(),V=I(11),l=g(!1),w=k;T(()=>{const a=o.subscribe($.AUTH_SESSION,t=>{if(t.object_id!==V)return;const n=t.data;window.open(n,"_blank").focus()});B(a)}),N(()=>w.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,C.push({name:"providersettings"})}).catch(t=>{alert(t),l.value=!1})},E=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=V,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(A,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,L)]),_:1})):v("",!0),R,r(h),X,q,"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(P,{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(U,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:M,onAction:E},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(x,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{me as default};
