import{k as e,bV as t,b7 as r,bq as a,E as n,a7 as s,c1 as u,q as l,bR as i,bE as d,G as g,a8 as c,bt as o,x as h,af as p,c0 as b,a1 as m,bo as f,bQ as w,bW as y,ba as x,S as _,df as $}from"./index-C-dDkA_D.js";import{a as v}from"./FolderTree-BPZyL9IS.js";import"./index-BA8MiV3y.js";const C=e=>{const t=l();return n(i,{w:"$full",display:"flex",flexDirection:"column",get children(){return[n(d,{get for(){return e.name},display:"flex",alignItems:"center",get children(){return t(`metas.${e.name}`)}}),n(b,{w:"$full",get direction(){return"bool"===e.type?"row":{"@initial":"column","@md":"row"}},gap:"$2",get children(){return[m(()=>m(()=>"string"===e.type)()?n(f,{get id(){return e.name},get value(){return e.value},onInput:t=>e.onChange(t.currentTarget.value)}):m(()=>"bool"===e.type)()?n(w,{get id(){return e.name},get checked(){return e.value},onChange:t=>e.onChange(t.currentTarget.checked)}):n(y,{get id(){return e.name},get value(){return e.value},onChange:t=>e.onChange(t.currentTarget.value)})),n(i,{w:"fit-content",display:"flex",get children(){return n(x,{css:{whiteSpace:"nowrap"},get id(){return`${e.name}_sub`},onChange:t=>e.onSub(t.currentTarget.checked),color:"$neutral10",fontSize:"$sm",get checked(){return e.sub},get children(){return t("metas.apply_sub")}})}})]}}),n(_,{get when(){return e.help},get children(){return n($,{get children(){return t(`metas.${e.name}_help`)}})}})]}})},k=()=>{const b=l(),{params:m,back:f}=e(),{id:w}=m,[y,x]=t({id:0,path:"",password:"",p_sub:!1,write:!1,w_sub:!1,hide:"",h_sub:!1,readme:"",r_sub:!1,header:"",header_sub:!1}),[_,$]=r(()=>a.get(`/admin/meta/get?id=${w}`));w&&(async()=>{const e=await $();o(e,x)})();const[k,S]=r(()=>a.post("/admin/meta/"+(w?"update":"create"),y));return n(p,{get loading(){return _()},get children(){return n(s,{w:"$full",alignItems:"start",spacing:"$2",get children(){return[n(u,{get children(){return b("global."+(w?"edit":"add"))}}),n(i,{w:"$full",display:"flex",flexDirection:"column",required:!0,get children(){return[n(d,{for:"path",display:"flex",alignItems:"center",get children(){return b("metas.path")}}),n(v,{id:"path",get value(){return y.path},onChange:e=>x("path",e)})]}}),n(g,{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:e=>n(C,{get name(){return e.name},get type(){return e.type},get value(){return y[e.name]},onChange:t=>x(e.name,t),get sub(){return y[e.sub]},onSub:t=>x(e.sub,t),get help(){return e.help}})}),n(c,{get loading(){return k()},onClick:async()=>{const e=await S();o(e,()=>{h.success(b("global.save_success")),f()})},get children(){return b("global."+(w?"save":"add"))}})]}})}})};export{k as default};
