import{_ as N,a as E}from"./CRjpF7qy.js";import{_ as T}from"./Co_Pqrtl.js";import{_ as V,a as B}from"./DfqdNhl2.js";import{_ as I}from"./4isL45Eu.js";import{_ as L}from"./_XME2JEy.js";import{_ as D,a as P,b as F}from"./4TAfYWvs.js";import{h as O,e as U,D as G,G as K,f as R,k as v,E as C,m as W,c as Y,o as y,v as j,I as q,b as a,g as s,w as e,d as n,t as l,a as z}from"./BzhixHsn.js";import{u as H}from"./D01W4VS-.js";import{u as J}from"./G5O1m7ek.js";import"./vJ3Jskde.js";import"./BkS3akZz.js";import"./DKMWZZOl.js";import"./BmLyE0U0.js";import"./CMS48I6h.js";const M={class:"space-y-6"},Q={class:"flex items-center space-x-2"},m="allow_user_create_assistants",ds=O({__name:"settings",async setup(X){let r,d;const{t}=U(),{showError:w,showSuccess:h}=H(),{$api:S}=G(),$=K(),{data:A,pending:Z,error:p,refresh:b}=([r,d]=R(()=>J("/v1/admin/config",{server:!1})),r=await r,d(),r),g=v(()=>A.value?.configs??[]),f=v(()=>g.value.find(o=>o.key===m)),c=C(!0);W(g,o=>{const i=o.find(u=>u.key===m);i?c.value=String(i.value).toLowerCase()!=="false":c.value=!0},{immediate:!0});const _=C(!1),k=async o=>{_.value=!0;try{const i=f.value?{value:o,is_enabled:!0}:{key:m,value:o,description:t("admin.systemConfig.assistants.configDescription"),is_public:!0,is_enabled:!0},u=f.value?`/v1/admin/config/${m}`:"/v1/admin/config",x=f.value?"PUT":"POST";await S(u,{method:x,body:i}),await b(),await $.loadConfig(!0),h(t("admin.systemConfig.messages.saveSuccess"))}catch(i){w(i.message||t("admin.systemConfig.messages.saveFailed")),c.value=!o}finally{_.value=!1}};return(o,i)=>(y(),Y("div",M,[s(p)?(y(),j(s(F),{key:0,variant:"destructive"},{default:e(()=>[a(s(D),null,{default:e(()=>[n(l(s(t)("common.error")),1)]),_:1}),a(s(P),null,{default:e(()=>[n(l(s(p)?.message||s(t)("admin.systemConfig.messages.saveFailed")),1)]),_:1})]),_:1})):q("",!0),a(s(E),null,{default:e(()=>[a(s(V),null,{default:e(()=>[a(s(B),null,{default:e(()=>[n(l(s(t)("admin.systemConfig.assistants.title")),1)]),_:1}),a(s(T),null,{default:e(()=>[n(l(s(t)("admin.systemConfig.assistants.description")),1)]),_:1})]),_:1}),a(s(N),null,{default:e(()=>[z("div",Q,[a(s(L),{id:"allow-create-assistants","model-value":s(c),"onUpdate:modelValue":k,disabled:s(_)},null,8,["model-value","disabled"]),a(s(I),{for:"allow-create-assistants"},{default:e(()=>[n(l(s(t)("admin.systemConfig.assistants.allowCreateLabel")),1)]),_:1})])]),_:1})]),_:1})]))}});export{ds as default};
