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