import{d as E,aj as S,r as g,o as N,b as o,a7 as T,a as $,N as B,c as r,g as y,f as s,w as d,u as i,Y as f,t as m,e as p,i as u,j as v}from"./index-103db515.js";import{V as P,E as U}from"./EditConfig-f05929af.js";import{n as I}from"./index.browser-342e672c.js";import{V as O,a as A}from"./VCardText-1a59cac1.js";import{a as _}from"./VCard-d4f085fd.js";import{V as h}from"./VList-cac73f62.js";import{V as D}from"./VTextField-73438668.js";import{y as x}from"./VListItem-ab7a82e2.js";import{c as z}from"./VMenu-482e7fbc.js";import"./VExpansionPanels-dacf6c3c.js";import"./VCheckboxBtn-19bafbc9.js";import"./VForm-f2e1d3c9.js";import"./VVirtualScroll-b23fb9a8.js";import"./VSpacer-adcb10ea.js";/* empty css              */import"./VDialog-08f8879f.js";import"./VAlert-4165d2e6.js";import"./_plugin-vue_export-helper-c27b6911.js";const F={key:0},H=u("br",null,null,-1),R=["href"],Y=u("br",null,null,-1),q=u("br",null,null,-1),G=u("br",null,null,-1),me=E({__name:"EditProvider",props:{instanceId:{}},setup(k){const C=S(),e=g(),V=I(11),l=g(!1),w=k;N(()=>{const a=o.subscribe(T.AUTH_SESSION,t=>{if(t.object_id!==V)return;const n=t.data;window.open(n,"_blank").focus()});$(a)}),B(()=>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})},j=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)=>(r(),y("section",null,[s(A,null,{default:d(()=>{var n,c;return[e.value&&i(o).providerManifests[e.value.domain]?(r(),y("div",F,[s(O,null,{default:d(()=>[f(m(a.$t("settings.setup_provider",[i(o).providerManifests[e.value.domain].name])),1)]),_:1}),s(_,null,{default:d(()=>[f(m(i(o).providerManifests[e.value.domain].description),1)]),_:1}),H,i(o).providerManifests[e.value.domain].codeowners.length?(r(),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?(r(),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),Y,s(h),q,G,"name"in e.value?(r(),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?(r(),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),s(h),e.value?(r(),p(U,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:M,onAction:j},null,8,["config-entries","disabled"])):v("",!0)]}),_:1}),s(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(()=>[s(x,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{me as default};
