import{j as $,bV as x,b9 as o,bq as g,D as t,ah as _,c0 as C,o as b,bR as d,bE as m,R as v,K as k,bt as h,r as S,ao as I,b$ as T,ab as i,I as F,bQ as E,T as L,bc as R,S as D,H}from"./index-CNZMR1GT.js";import{a as M}from"./FolderTree-CTh3_qOS.js";import"./index-DsSWFirV.js";const q=e=>{const r=b();return t(d,{w:"$full",display:"flex",flexDirection:"column",get children(){return[t(m,{get for(){return e.name},display:"flex",alignItems:"center",get children(){return r("metas.".concat(e.name))}}),t(T,{w:"$full",get direction(){return e.type==="bool"?"row":{"@initial":"column","@md":"row"}},gap:"$2",get children(){return[i(()=>i(()=>e.type==="string")()?t(F,{get id(){return e.name},get value(){return e.value},onInput:n=>e.onChange(n.currentTarget.value)}):i(()=>e.type==="bool")()?t(E,{get id(){return e.name},get checked(){return e.value},onChange:n=>e.onChange(n.currentTarget.checked)}):t(L,{get id(){return e.name},get value(){return e.value},onChange:n=>e.onChange(n.currentTarget.value)})),t(d,{w:"fit-content",display:"flex",get children(){return t(R,{css:{whiteSpace:"nowrap"},get id(){return"".concat(e.name,"_sub")},onChange:n=>e.onSub(n.currentTarget.checked),color:"$neutral10",fontSize:"$sm",get checked(){return e.sub},get children(){return r("metas.apply_sub")}})}})]}}),t(D,{get when(){return e.help},get children(){return t(H,{get children(){return r("metas.".concat(e.name,"_help"))}})}})]}})},B=()=>{const e=b(),{params:r,back:n}=$(),{id:u}=r,[s,l]=x({id:0,path:"",password:"",p_sub:!1,write:!1,w_sub:!1,hide:"",h_sub:!1,readme:"",r_sub:!1,header:"",header_sub:!1}),[f,w]=o(()=>g.get("/admin/meta/get?id=".concat(u)));u&&(async()=>{const a=await w();h(a,l)})();const[y,p]=o(()=>g.post("/admin/meta/".concat(u?"update":"create"),s));return t(I,{get loading(){return f()},get children(){return t(_,{w:"$full",alignItems:"start",spacing:"$2",get children(){return[t(C,{get children(){return e("global.".concat(u?"edit":"add"))}}),t(d,{w:"$full",display:"flex",flexDirection:"column",required:!0,get children(){return[t(m,{for:"path",display:"flex",alignItems:"center",get children(){return e("metas.path")}}),t(M,{id:"path",get value(){return s.path},onChange:a=>l("path",a)})]}}),t(v,{each:[{name:"password",type:"string",sub:"p_sub"},{name:"write",type:"bool",sub:"w_sub"},{name:"hide",type:"text",sub:"h_sub",help:!0},{name:"header",type:"text",sub:"header_sub",help:!0},{name:"readme",type:"text",sub:"r_sub",help:!0}],children:a=>t(q,{get name(){return a.name},get type(){return a.type},get value(){return s[a.name]},onChange:c=>l(a.name,c),get sub(){return s[a.sub]},onSub:c=>l(a.sub,c),get help(){return a.help}})}),t(k,{get loading(){return y()},onClick:async()=>{const a=await p();h(a,()=>{S.success(e("global.save_success")),n()})},get children(){return e("global.".concat(u?"save":"add"))}})]}})}})};export{B as default};
