System.register(["./index-legacy-BGUFxny_.js","./useTitle-legacy-Ck1as0cr.js","./index-legacy-BbfMcMsh.js","./SettingItem-legacy-DcuCPY8O.js","./ResponsiveGrid-legacy-B3XB4KcT.js","./FolderTree-legacy-DAN7i0-E.js","./index-legacy-DgbbakiJ.js","./index-legacy-CwkvHJvM.js","./index-legacy-DVBgQjo3.js","./item_type-legacy-BFH7Oxl9.js"],function(e,t){"use strict";var n,r,s,l,a,c,i,g,u,o,d,y,h,m,f,k,b,p,_,v,w,x,S,$,j,C,I,D,J;return{setters:[e=>{n=e.D,r=e.bR,s=e.bE,l=e.o,a=e.I,c=e.cy,i=e.K,g=e.R,u=e.Q,o=e.ah,d=e.b9,y=e.bq,h=e.bV,m=e.df,f=e.B,k=e.dg,b=e.S,p=e.bt,_=e.r,v=e.c0,w=e.aw,x=e.dh,S=e.di},e=>{$=e.b},e=>{j=e.G},e=>{C=e.I},e=>{I=e.R},e=>{D=e.a},e=>{J=e.c},null,null,null],execute:function(){const t=e=>{const t=l();return n(c,{w:"$full",overflowX:"auto",shadow:"$md",rounded:"$lg",p:"$2",direction:{"@initial":"column","@xl":"row"},spacing:"$2",get children(){return[n(r,{w:"$full",display:"flex",flexDirection:"column",required:!0,get children(){return[n(s,{for:"path",display:"flex",alignItems:"center",get children(){return t("global.name")}}),n(a,{id:"name",get value(){return e.name},onChange:t=>e.onChange({...e,name:t.currentTarget.value})})]}}),n(r,{w:"$full",display:"flex",flexDirection:"column",required:!0,get children(){return[n(s,{for:"path",display:"flex",alignItems:"center",get children(){return t("metas.path")}}),n(D,{id:"path",get value(){return e.path},onChange:t=>e.onChange({...e,path:t})})]}}),n(c,{direction:{"@initial":"row","@xl":"column"},justifyContent:{"@xl":"center"},spacing:"$1",get children(){return n(i,{colorScheme:"danger",onClick:async()=>{e.onDelete()},get children(){return t("global.delete")}})}})]}})},N=e=>{const r=l();return console.log(e.buckets),n(o,{alignItems:"start",w:"$full",get children(){return[n(s,{display:"flex",alignItems:"center",get children(){return r("settings.s3_buckets")}}),n(i,{onClick:()=>{e.setSettings(e=>"s3_buckets"===e.key,"value",JSON.stringify([...e.buckets,{name:"",path:""}])),console.log(e.buckets)},get children(){return r("global.add")}}),n(g,{get each(){return e.buckets},children:r=>n(t,u(r,{onChange:t=>{console.log(t),e.setSettings(e=>"s3_buckets"===e.key,"value",JSON.stringify(e.buckets.map(e=>e.name===r.name?t:e)))},onDelete:()=>{e.setSettings(e=>"s3_buckets"===e.key,"value",JSON.stringify(e.buckets.filter(e=>e.name!==r.name)))}}))})]}})},O=e=>{const t={...e.find(e=>"s3_buckets"===e.key)};return t.value?JSON.parse(t.value):[]};e("default",()=>{const e=l();$("manage.sidemenu.s3");const[t,r]=d(()=>y.get(`/admin/setting/list?group=${j.S3}`)),[s,a]=h([]),c=async()=>{const e=await r();p(e,a)};c();const[g,D]=d(()=>y.post("/admin/setting/save",m(s))),[R,q]=f(!1);return n(o,{w:"$full",alignItems:"start",spacing:"$2",get children(){return[n(I,{get children(){return[n(k,{each:s,children:(t,r)=>n(b,{get when(){return"s3_buckets"!=t().key},get children(){return n(C,u(t,{onChange:e=>{a(e=>t().key===e.key,"value",e)},onDelete:async()=>{q(!0);const n=await y.post(`/admin/setting/delete?key=${t().key}`);q(!1),p(n,()=>{_.success(e("global.delete_success")),c()})}}))}})}),n(i,{onClick:()=>{const e=J.lib.WordArray.random(15),t=J.lib.WordArray.random(30),n=J.enc.Base64.stringify(e).replace(/[\r\n]/g,""),r=J.enc.Base64.stringify(t).replace(/[\r\n]/g,"");a(e=>"s3_access_key_id"===e.key,"value",n),a(e=>"s3_secret_access_key"===e.key,"value",r)},get children(){return e("settings.s3_generate")}}),n(v,{get children(){return e("settings.s3_restart_to_apply")}}),n(N,{get buckets(){return O(s)},setSettings:a})]}}),n(w,{spacing:"$2",get children(){return[n(i,{colorScheme:"accent",onClick:c,get loading(){return t()||R()},get children(){return e("global.refresh")}}),n(i,{get loading(){return g()},onClick:async()=>{const t=O(s),n=new Set;for(const s of t){if(""===s.name||""===s.path)return void _.error(e("settings.s3_buckets_empty"));if(n.has(s.name))return void _.error(e("settings.s3_buckets_duplicate_name"));n.add(s.name)}const r=await D();p(r,async()=>{_.success(e("global.save_success")),x(await y.get("/public/settings"),S)})},get children(){return e("global.save")}})]}})]}})})}}});
