import{n as A,u as S,j as s,B as d,k as c,L as N,I as y,l as n,m as w}from"./index-DXI13nSQ.js";import{r as x}from"./react-Cb2sDjhD.js";import{C as L}from"./confirm-dialog-_BtUs6oW.js";import{E as P}from"./empty-state-WHzNYVaT.js";import{T as E,a as z,b as C,c as h,d as B,e as u}from"./table-oUi0mGOn.js";import{n as F,o as D,p as H}from"./use-settings-DJlVLnjo.js";import{L as T}from"./loader-circle-BS5FFFg-.js";import{R as U}from"./refresh-ccw-BPKXoMZa.js";import{T as _}from"./trash-2-CTkSvnZX.js";import"./dialog-BVYFRXlI.js";import"./x-OHUicFfn.js";import"./useQuery-CEwGD94N.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const M=A("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $=A("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function es(){const{t:e}=S(["settings","common"]),i=F(),t=i.data,r=D(),f=H(),[l,p]=x.useState(""),[m,j]=x.useState(""),[o,g]=x.useState(null);async function k(a){a.preventDefault();const b=l.trim(),v=m.trim();if(!(!b||!v))try{await r.mutateAsync({platform:b,userId:v}),n.success(e("admins.toast.added")),p(""),j("")}catch(R){n.error(w(R,e).message)}}async function I(){if(o)try{await f.mutateAsync(o),n.success(e("admins.toast.removed"))}catch(a){throw n.error(w(a,e).message),a}}return s.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-4",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("h1",{className:"text-xl font-semibold",children:e("admins.title")}),s.jsxs(d,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>i.refetch(),disabled:i.isFetching,"aria-label":e("actions.refresh",{ns:"common"}),children:[i.isFetching?s.jsx(T,{className:"h-4 w-4 animate-spin"}):s.jsx(U,{className:"h-4 w-4"}),s.jsx("span",{className:"hidden sm:inline",children:e("actions.refresh",{ns:"common"})})]})]}),s.jsx("p",{className:"text-sm text-text-dim",children:e("admins.subtitle")})]}),t&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.configured?s.jsx(c,{variant:"success",children:e("admins.configured")}):s.jsx(c,{variant:"warning",children:e("admins.notConfigured")}),t.bootstrapAvailable&&s.jsx(c,{variant:"info",title:t.bootstrapTokenPath,children:e("admins.bootstrapAvailable")})]}),i.isLoading?s.jsx("div",{className:"h-32 rounded-md bg-surface-2 animate-pulse"}):t&&t.admins.length===0?s.jsx(P,{icon:s.jsx(M,{}),title:e("admins.empty")}):t?s.jsxs(E,{children:[s.jsx(z,{children:s.jsxs(C,{children:[s.jsx(h,{className:"w-40",children:e("admins.col.platform")}),s.jsx(h,{children:e("admins.col.userId")}),s.jsx(h,{className:"w-24"})]})}),s.jsx(B,{children:t.admins.map(a=>s.jsxs(C,{children:[s.jsx(u,{className:"font-mono",children:a.platform}),s.jsx(u,{className:"font-mono text-xs",children:a.userId}),s.jsx(u,{children:s.jsxs(d,{variant:"ghost",size:"sm",onClick:()=>g(a),disabled:f.isPending,"aria-label":e("admins.remove.label"),children:[s.jsx(_,{className:"h-3 w-3"}),s.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:e("admins.remove.label")})]})})]},`${a.platform}:${a.userId}`))})]}):null,s.jsxs("form",{onSubmit:a=>void k(a),className:"rounded-md border border-border bg-surface p-4",children:[s.jsx("div",{className:"mb-3 text-sm font-medium",children:e("admins.add.title")}),s.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[180px_1fr_auto] sm:items-end",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(N,{htmlFor:"admin-platform",className:"text-xs text-text-dim",children:e("admins.add.platform")}),s.jsx(y,{id:"admin-platform",value:l,onChange:a=>p(a.target.value),placeholder:"wechat",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(N,{htmlFor:"admin-user",className:"text-xs text-text-dim",children:e("admins.add.userId")}),s.jsx(y,{id:"admin-user",value:m,onChange:a=>j(a.target.value),placeholder:"wxid_abc123",className:"font-mono text-xs"})]}),s.jsxs(d,{type:"submit",size:"sm",disabled:r.isPending||!l.trim()||!m.trim(),children:[r.isPending?s.jsx(T,{className:"h-4 w-4 animate-spin"}):s.jsx($,{className:"h-4 w-4"}),e("admins.add.submit")]})]})]}),s.jsx(L,{open:o!=null,onOpenChange:a=>{a||g(null)},title:e("admins.remove.confirmTitle"),description:e("admins.remove.confirmDescription"),intent:"danger",confirmLabel:e("admins.remove.label"),onConfirm:I})]})}export{es as default};
//# sourceMappingURL=admins-D3j7wkvL.js.map
