From f1654a7ef79f06ca4361727e6764edddf3138268 Mon Sep 17 00:00:00 2001 From: xboard Date: Thu, 16 Jan 2025 10:55:13 +0800 Subject: [PATCH] feat: remove email format validation for admin login --- public/assets/admin/assets/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index dc4cc1c..9f5877a 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,4 +1,4 @@ -import{r as m,j as e,t as ll,c as ol,I as Na,a as Ts,S as Zt,u as is,b as Xt,d as il,O as ea,e as cl,f as q,g as dl,h as ml,i as ul,k as xl,B as hl,l as fl,Q as pl,m as gl,R as jl,n as vl,P as bl,o as yl,p as Nl,q as Ka,F as _l,C as wl,s as Cl,v as Sl,w as kl,x as Dl,y as Ha,z as I,A as h,D as ce,E as ue,G as Ua,H as St,J as kt,K as sa,L as Oe,T as Dt,M as Tt,N as Ba,U as Ga,V as Wa,W as ta,X as Ya,Y as Tl,Z as Ja,_ as Qa,$ as Za,a0 as Xa,a1 as Ps,a2 as en,a3 as Pl,a4 as sn,a5 as tn,a6 as Rl,a7 as El,a8 as Vl,a9 as Il,aa as Fl,ab as Ml,ac as Ol,ad as zl,ae as Ll,af as Al,ag as $l,ah as an,ai as ql,aj as Kl,ak as Rs,al as nn,am as Hl,an as Ul,ao as rn,ap as Bl,aq as Gl,ar as _a,as as Wl,at as ln,au as Yl,av as on,aw as Jl,ax as Ql,ay as Zl,az as Xl,aA as eo,aB as so,aC as cn,aD as to,aE as ao,aF as no,aG as Se,aH as ro,aI as lo,aJ as oo,aK as io,aL as dn,aM as mn,aN as un,aO as co,aP as xn,aQ as hn,aR as fn,aS as mo,aT as uo,aU as xo,aV as pn,aW as ho,aX as aa,aY as gn,aZ as fo,a_ as jn,a$ as po,b0 as vn,b1 as go,b2 as bn,b3 as yn,b4 as jo,b5 as vo,b6 as Nn,b7 as bo,b8 as yo,b9 as _n,ba as No,bb as wn,bc as _o,bd as wo,be as qe,bf as se,bg as $e,bh as it,bi as Co,bj as So,bk as ko,bl as Do,bm as To,bn as Po,bo as wa,bp as Ca,bq as Ro,br as Eo,bs as Vo,bt as Io,bu as Fo,bv as Kt,bw as Ht,bx as Mo,by as Oo,bz as Cn,bA as zo,bB as Lo,bC as Sn,bD as Ao,bE as pe,bF as $o,bG as Sa,bH as Ut,bI as Bt,bJ as qo,bK as Ko,bL as kn,bM as Ho,bN as na,bO as Uo,bP as Bo,bQ as Go,bR as Dn,bS as Tn,bT as Pn,bU as Wo,bV as Yo,bW as Jo,bX as Qo,bY as Rn,bZ as Zo,b_ as es,b$ as Xo,c0 as ei,c1 as si,c2 as bt,c3 as Ne,c4 as ka,c5 as ti,c6 as En,c7 as Vn,c8 as In,c9 as Fn,ca as Mn,cb as On,cc as ai,cd as ni,ce as ri,cf as Pt,cg as Es,ch as cs,ci as ze,cj as Le,ck as Ue,cl as Be,cm as Ge,cn as li,co as oi,cp as ii,cq as Gt,cr as ra,cs as la,ct as ci,cu as ds,cv as ms,cw as ct,cx as di,cy as yt,cz as mi,cA as Da,cB as zn,cC as Ta,cD as Nt,cE as ui,cF as xi,cG as hi,cH as fi,cI as Ln,cJ as pi,cK as gi,cL as An,cM as Wt,cN as $n,cO as ji,cP as qn,cQ as Kn,cR as vi,cS as bi,cT as yi,cU as Ni,cV as _i}from"./vendor.js";import"./index.js";var bh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function wi(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var a=function l(){return this instanceof l?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(s).forEach(function(l){var r=Object.getOwnPropertyDescriptor(s,l);Object.defineProperty(a,l,r.get?r:{enumerable:!0,get:function(){return s[l]}})}),a}const Ci={theme:"system",setTheme:()=>null},Hn=m.createContext(Ci);function Si({children:s,defaultTheme:n="system",storageKey:a="vite-ui-theme",...l}){const[r,c]=m.useState(()=>localStorage.getItem(a)||n);m.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),r==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(x);return}u.classList.add(r)},[r]);const i={theme:r,setTheme:u=>{localStorage.setItem(a,u),c(u)}};return e.jsx(Hn.Provider,{...l,value:i,children:s})}const ki=()=>{const s=m.useContext(Hn);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Di=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),Ti=function(s,n){return new URL(s,n).href},Pa={},oe=function(n,a,l){let r=Promise.resolve();if(a&&a.length>0){const i=document.getElementsByTagName("link"),u=document.querySelector("meta[property=csp-nonce]"),x=u?.nonce||u?.getAttribute("nonce");r=Promise.allSettled(a.map(o=>{if(o=Ti(o,l),o in Pa)return;Pa[o]=!0;const d=o.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(!!l)for(let f=i.length-1;f>=0;f--){const _=i[f];if(_.href===o&&(!d||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${p}`))return;const V=document.createElement("link");if(V.rel=d?"stylesheet":Di,d||(V.as="script"),V.crossOrigin="",V.href=o,x&&V.setAttribute("nonce",x),document.head.appendChild(V),d)return new Promise((f,_)=>{V.addEventListener("load",f),V.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}function c(i){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=i,window.dispatchEvent(u),!u.defaultPrevented)throw i}return r.then(i=>{for(const u of i||[])u.status==="rejected"&&c(u.reason);return n().catch(c)})};function y(...s){return ll(ol(s))}const Ks=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),R=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,children:r,disabled:c,loading:i=!1,leftSection:u,rightSection:x,...o},d)=>{const p=l?Zt:"button";return e.jsxs(p,{className:y(Ks({variant:n,size:a,className:s})),disabled:i||c,ref:d,...o,children:[(u&&i||!u&&!x&&i)&&e.jsx(Na,{className:"mr-2 h-4 w-4 animate-spin"}),!i&&u&&e.jsx("div",{className:"mr-2",children:u}),r,!i&&x&&e.jsx("div",{className:"ml-2",children:x}),x&&i&&e.jsx(Na,{className:"ml-2 h-4 w-4 animate-spin"})]})});R.displayName="Button";function Os({className:s,minimal:n=!1}){const a=is();return e.jsx("div",{className:y("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{})," Please try again later."]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(R,{variant:"outline",onClick:()=>a(-1),children:"Go Back"}),e.jsx(R,{onClick:()=>a("/"),children:"Back to Home"})]})]})})}function Ra(){const s=is();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(R,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(R,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Pi(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(R,{variant:"outline",children:"Learn more"})})]})})}function Ri(s){return typeof s>"u"}function Ei(s){return s===null}function Vi(s){return Ei(s)||Ri(s)}class Ii{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,a,l=null){const r=JSON.stringify({value:a,time:Date.now(),expire:l!==null?new Date().getTime()+l*1e3:null});this.storage.setItem(this.getKey(n),r)}get(n,a=null){const l=this.storage.getItem(this.getKey(n));if(!l)return{value:a,time:0};try{const r=JSON.parse(l),{value:c,time:i,expire:u}=r;return Vi(u)||u>new Date().getTime()?{value:c,time:i}:(this.remove(n),{value:a,time:0})}catch{return this.remove(n),{value:a,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function Un({prefixKey:s="",storage:n=sessionStorage}){return new Ii({prefixKey:s,storage:n})}const Bn="Xboard_",Fi=function(s={}){return Un({prefixKey:s.prefixKey||"",storage:localStorage})},Mi=function(s={}){return Un({prefixKey:s.prefixKey||"",storage:sessionStorage})},Rt=Fi({prefixKey:Bn});Mi({prefixKey:Bn});const Gn="access_token";function st(){return Rt.get(Gn)}function Wn(){Rt.remove(Gn)}const Ea=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Oi({children:s}){const n=is(),a=Xt(),l=st();return m.useEffect(()=>{if(!l.value&&!Ea.includes(a.pathname)){const r=encodeURIComponent(a.pathname+a.search);n(`/sign-in?redirect=${r}`)}},[l.value,a.pathname,a.search,n]),Ea.includes(a.pathname)||l.value?e.jsx(e.Fragment,{children:s}):null}const zi=()=>e.jsx(Oi,{children:e.jsx(ea,{})}),Li=il([{path:"/sign-in",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>dc);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(zi,{}),children:[{path:"/",lazy:async()=>({Component:(await oe(()=>Promise.resolve().then(()=>vc),void 0,import.meta.url)).default}),errorElement:e.jsx(Os,{}),children:[{index:!0,lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Bd);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Os,{}),children:[{path:"system",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Jd);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>em);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>rm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>dm);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>fm);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>bm);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Cm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Fm);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Am);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Zm);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>tu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>cu);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>gu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Os,{}),children:[{path:"manage",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>qu);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Gu);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Os,{}),children:[{path:"plan",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>ix);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Nx);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Rx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Os,{}),children:[{path:"manage",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>eh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>gh);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Os},{path:"/404",Component:Ra},{path:"/503",Component:Pi},{path:"*",Component:Ra}]),Ai="locale";function $i(){return Rt.get(Ai)}function Yn(){Wn();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),a=new URL(window.location.href),r=`${a.pathname.split("/")[1]?`/${a.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=r+(n?`?redirect=${s}`:"")}const qi=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Ki(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const O=cl.create({baseURL:Ki(),timeout:12e3,headers:{"Content-Type":"application/json"}});O.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=st();if(!qi.includes(s.url?.split("?")[0]||"")){if(!n.value)return Yn(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=$i().value||"zh-CN",s},s=>Promise.reject(s));O.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,a=s.response?.data?.message;return(n===401||n===403)&&Yn(),q.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function Hi(){return O.get("/user/info")}const Ot={token:st()?.value||"",userInfo:null,isLoggedIn:!!st()?.value,loading:!1,error:null},Xs=dl("user/fetchUserInfo",async()=>(await Hi()).data,{condition:(s,{getState:n})=>{const{user:a}=n();return!!a.token&&!a.loading}}),Jn=ml({name:"user",initialState:Ot,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>Ot},extraReducers:s=>{s.addCase(Xs.pending,n=>{n.loading=!0,n.error=null}).addCase(Xs.fulfilled,(n,a)=>{n.loading=!1,n.userInfo=a.payload,n.error=null}).addCase(Xs.rejected,(n,a)=>{if(n.loading=!1,n.error=a.error.message||"Failed to fetch user info",!n.token)return Ot})}}),{setToken:Ui,resetUserState:Bi}=Jn.actions,Gi=s=>s.user.userInfo,Wi=Jn.reducer,Qn=ul({reducer:{user:Wi}});st()?.value&&Qn.dispatch(Xs());xl.use(hl).use(fl).init({resources:{"en-US":window.XBOARD_TRANSLATIONS?.["en-US"]||{},"zh-CN":window.XBOARD_TRANSLATIONS?.["zh-CN"]||{},"ko-KR":window.XBOARD_TRANSLATIONS?.["ko-KR"]||{}},fallbackLng:"zh-CN",supportedLngs:["en-US","zh-CN","ko-KR"],detection:{order:["querystring","localStorage","navigator"],lookupQuerystring:"lang",lookupLocalStorage:"i18nextLng",caches:["localStorage"]},interpolation:{escapeValue:!1}});const Yi=new pl;gl.createRoot(document.getElementById("root")).render(e.jsx(jl.StrictMode,{children:e.jsx(vl,{client:Yi,children:e.jsx(bl,{store:Qn,children:e.jsxs(Si,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(yl,{router:Li}),e.jsx(Nl,{richColors:!0,position:"top-right"})]})})})}));const He=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...n}));He.displayName="Card";const ss=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex flex-col space-y-1.5 p-6",s),...n}));ss.displayName="CardHeader";const bs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:y("font-semibold leading-none tracking-tight",s),...n}));bs.displayName="CardTitle";const tt=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:y("text-sm text-muted-foreground",s),...n}));tt.displayName="CardDescription";const ts=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("p-6 pt-0",s),...n}));ts.displayName="CardContent";const Ji=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex items-center p-6 pt-0",s),...n}));Ji.displayName="CardFooter";const Qi=Ts("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_t=m.forwardRef(({className:s,...n},a)=>e.jsx(Ka,{ref:a,className:y(Qi(),s),...n}));_t.displayName=Ka.displayName;const xe=_l,Zn=m.createContext({}),j=({...s})=>e.jsx(Zn.Provider,{value:{name:s.name},children:e.jsx(wl,{...s})}),Et=()=>{const s=m.useContext(Zn),n=m.useContext(Xn),{getFieldState:a,formState:l}=Cl(),r=a(s.name,l);if(!s)throw new Error("useFormField should be used within ");const{id:c}=n;return{id:c,name:s.name,formItemId:`${c}-form-item`,formDescriptionId:`${c}-form-item-description`,formMessageId:`${c}-form-item-message`,...r}},Xn=m.createContext({}),g=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(Xn.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:y("space-y-2",s),...n})})});g.displayName="FormItem";const v=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=Et();return e.jsx(_t,{ref:a,className:y(l&&"text-destructive",s),htmlFor:r,...n})});v.displayName="FormLabel";const N=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=Et();return e.jsx(Zt,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});N.displayName="FormControl";const F=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=Et();return e.jsx("p",{ref:a,id:l,className:y("text-[0.8rem] text-muted-foreground",s),...n})});F.displayName="FormDescription";const P=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=Et(),i=r?String(r?.message):n;return i?e.jsx("p",{ref:l,id:c,className:y("text-[0.8rem] font-medium text-destructive",s),...a,children:i}):null});P.displayName="FormMessage";const T=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:l,...a}));T.displayName="Input";const er=m.forwardRef(({className:s,...n},a)=>{const[l,r]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:l?"text":"password",className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}),e.jsx(R,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>r(c=>!c),children:l?e.jsx(Sl,{size:18}):e.jsx(kl,{size:18})})]})});er.displayName="PasswordInput";const Zi=s=>O({url:"/passport/auth/login",method:"post",data:s});function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Dl(s).format(n))}function Xi(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function As(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const a=typeof s=="string"?parseFloat(s):s;if(isNaN(a))return n?"¥0.00":"0.00";const r=(a/100).toFixed(2).replace(/\.?0+$/,c=>c.includes(".")?".00":c);return n?`¥${r}`:r}function wt(s){return new Promise(n=>{(async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(s);else{const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();const r=document.execCommand("copy");if(document.body.removeChild(l),!r)throw new Error("execCommand failed")}n(!0)}catch(l){console.error(l),n(!1)}})()})}function Ze(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?As(r)+" TB":l>=1?As(l)+" GB":a>=1?As(a)+" MB":As(n)+" KB"}const ec="access_token";function sc(s){Rt.set(ec,s)}function tc({className:s,onForgotPassword:n,...a}){const l=is(),r=Ha(),{t:c}=I("auth"),i=h.object({email:h.string().min(1,{message:c("signIn.validation.emailRequired")}).email({message:c("signIn.validation.emailInvalid")}),password:h.string().min(1,{message:c("signIn.validation.passwordRequired")}).min(7,{message:c("signIn.validation.passwordLength")})}),u=ce({resolver:ue(i),defaultValues:{email:"",password:""}});async function x(o){Zi(o).then(({data:d})=>{sc(d.auth_data),r(Ui(d.auth_data)),r(Xs()).unwrap(),l("/")})}return e.jsx("div",{className:y("grid gap-6",s),...a,children:e.jsx(xe,{...u,children:e.jsx("form",{onSubmit:u.handleSubmit(x),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:u.control,name:"email",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:c("signIn.email")}),e.jsx(N,{children:e.jsx(T,{placeholder:c("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"password",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:c("signIn.password")}),e.jsx(N,{children:e.jsx(er,{placeholder:c("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(P,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:c("signIn.forgotPassword")})}),e.jsx(R,{className:"w-full",size:"lg",loading:u.formState.isSubmitting,children:c("signIn.submit")})]})})})})}const ge=Ua,Fe=Ba,ac=Ga,dt=sa,sr=m.forwardRef(({className:s,...n},a)=>e.jsx(St,{ref:a,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));sr.displayName=St.displayName;const he=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(ac,{children:[e.jsx(sr,{}),e.jsxs(kt,{ref:l,className:y("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a,children:[n,e.jsxs(sa,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Oe,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));he.displayName=kt.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Me=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Me.displayName="DialogFooter";const je=m.forwardRef(({className:s,...n},a)=>e.jsx(Dt,{ref:a,className:y("text-lg font-semibold leading-none tracking-tight",s),...n}));je.displayName=Dt.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Tt,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Te.displayName=Tt.displayName;const qs=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const i=l?Zt:"button";return e.jsx(i,{className:y(qs({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";const ys=Rl,Ns=El,nc=Vl,rc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(Wa,{ref:r,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...l,children:[a,e.jsx(ta,{className:"ml-auto h-4 w-4"})]}));rc.displayName=Wa.displayName;const lc=m.forwardRef(({className:s,...n},a)=>e.jsx(Ya,{ref:a,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));lc.displayName=Ya.displayName;const os=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Tl,{children:e.jsx(Ja,{ref:l,sideOffset:n,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a})}));os.displayName=Ja.displayName;const fe=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(Qa,{ref:l,className:y("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...a}));fe.displayName=Qa.displayName;const oc=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(Za,{ref:r,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:a,...l,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xa,{children:e.jsx(Ps,{className:"h-4 w-4"})})}),n]}));oc.displayName=Za.displayName;const ic=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(en,{ref:l,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xa,{children:e.jsx(Pl,{className:"h-4 w-4 fill-current"})})}),n]}));ic.displayName=en.displayName;const oa=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(sn,{ref:l,className:y("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));oa.displayName=sn.displayName;const at=m.forwardRef(({className:s,...n},a)=>e.jsx(tn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));at.displayName=tn.displayName;const Yt=({className:s,...n})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...n});Yt.displayName="DropdownMenuShortcut";const zt=[{code:"en-US",name:"English",flag:Il,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Fl,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:Ml,shortName:"KR"}];function tr(){const{i18n:s}=I(),n=r=>{s.changeLanguage(r)},a=zt.find(r=>r.code===s.language)||zt[1],l=a.flag;return e.jsxs(ys,{children:[e.jsx(Ns,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(l,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:a.shortName})]})}),e.jsx(os,{align:"end",className:"w-[120px]",children:zt.map(r=>{const c=r.flag,i=r.code===s.language;return e.jsxs(fe,{onClick:()=>n(r.code),className:y("flex items-center gap-2 px-2 py-1.5 cursor-pointer",i&&"bg-accent"),children:[e.jsx(c,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:y("text-sm",i&&"font-medium"),children:r.name})]},r.code)})})]})}function cc(){const[s,n]=m.useState(!1),{t:a}=I("auth"),l=a("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:[e.jsx("div",{className:"absolute right-4 top-4 md:right-8 md:top-8",children:e.jsx(tr,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[480px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(He,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:a("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("signIn.description")})]}),e.jsx(tc,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(he,{children:e.jsxs(ve,{children:[e.jsx(je,{children:a("signIn.resetPassword.title")}),e.jsx(Te,{children:a("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12 text-sm",children:l}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>wt(l).then(()=>{q.success(a("common:copy.success"))}),children:e.jsx(Ol,{className:"h-4 w-4"})})]})})]})})})]})}const dc=Object.freeze(Object.defineProperty({__proto__:null,default:cc},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:y("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",a&&"md:h-svh",s),...l}));we.displayName="Layout";const Ce=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const ke=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));ke.displayName="LayoutBody";const ar=zl,nr=Ll,rr=Al,ie=$l,re=ql,le=Kl,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(an,{ref:l,sideOffset:n,className:y("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a}));te.displayName=an.displayName;function Vt(){const{pathname:s}=Xt();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function lr({key:s,defaultValue:n}){const[a,l]=m.useState(()=>{const r=localStorage.getItem(s);return r!==null?JSON.parse(r):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,l]}function mc(){const[s,n]=lr({key:"collapsed-sidebar-items",defaultValue:[]}),a=r=>!s.includes(r);return{isExpanded:a,toggleItem:r=>{a(r)?n([...s,r]):n(s.filter(c=>c!==r))}}}function uc({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=I(),c=({sub:i,...u})=>{const x=`${r(u.title)}-${u.href}`;return n&&i?m.createElement(fc,{...u,sub:i,key:x,closeNav:l}):n?m.createElement(hc,{...u,key:x,closeNav:l}):i?m.createElement(xc,{...u,sub:i,key:x,closeNav:l}):m.createElement(or,{...u,key:x,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",a),children:e.jsx(ie,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(c)})})})}function or({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:i}=Vt(),{t:u}=I();return e.jsxs(Rs,{to:l,onClick:r,className:y(Ks({variant:i(l)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",c&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":i(l)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),u(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(a)})]})}function xc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Vt(),{isExpanded:i,toggleItem:u}=mc(),{t:x}=I(),o=!!l?.find(D=>c(D.href)),d=x(s),p=i(d)||o;return e.jsxs(ar,{open:p,onOpenChange:()=>u(d),children:[e.jsxs(nr,{className:y(Ks({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),x(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:x(a)}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(nn,{stroke:1})})]}),e.jsx(rr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(D=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(or,{...D,subLink:!0,closeNav:r})},x(D.title)))})})]})}function hc({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=Vt(),{t:i}=I();return e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsxs(Rs,{to:l,onClick:r,className:y(Ks({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:i(s)})]})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[i(s),a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:i(a)})]})]})}function fc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Vt(),{t:i}=I(),u=!!l?.find(x=>c(x.href));return e.jsxs(ys,{children:[e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsx(Ns,{asChild:!0,children:e.jsx(R,{variant:u?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[i(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:i(a)}),e.jsx(nn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(os,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(oa,{children:[i(s)," ",a?`(${i(a)})`:""]}),e.jsx(at,{}),l.map(({title:x,icon:o,label:d,href:p})=>e.jsx(fe,{asChild:!0,children:e.jsxs(Rs,{to:p,onClick:r,className:`${c(p)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:i(x)}),d&&e.jsx("span",{className:"ml-auto text-xs",children:i(d)})]})},`${i(x)}-${p}`))]})]})}const ir=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Hl,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Ul,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(rn,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Bl,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Gl,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(_a,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Wl,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(ln,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Yl,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(on,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Jl,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Ql,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Zl,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(_a,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Xl,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(eo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(so,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(cn,{size:18})}]}];function pc({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=m.useState(!1),{t:c}=I();return m.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:y(`fixed left-0 right-0 top-0 z-50 w-full border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>r(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${l?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(we,{children:[e.jsxs(Ce,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":c("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":l,onClick:()=>r(i=>!i),children:l?e.jsx(to,{}):e.jsx(ao,{})})]}),e.jsx(uc,{id:"sidebar-menu",className:`h-full flex-1 overflow-auto ${l?"max-h-screen":"max-h-0 py-0 md:max-h-screen md:py-2"}`,closeNav:()=>r(!1),isCollapsed:n,links:ir}),e.jsx("div",{className:y("px-4 py-3 text-xs text-muted-foreground/70 border-t border-border/50 bg-muted/20","transition-all duration-200 ease-in-out",n?"text-center":"text-left"),children:e.jsxs("div",{className:y("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500/70"}),e.jsxs("span",{className:"tracking-wide",children:["v",window?.settings?.version]})]})}),e.jsx(R,{onClick:()=>a(i=>!i),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":c("common:toggleSidebar"),children:e.jsx(no,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function gc(){const[s,n]=lr({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const a=()=>{n(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),[s,n]}function jc(){const[s,n]=gc();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(pc,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(ea,{})})]})}const vc=Object.freeze(Object.defineProperty({__proto__:null,default:jc},Symbol.toStringTag,{value:"Module"})),_s=m.forwardRef(({className:s,...n},a)=>e.jsx(Se,{ref:a,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));_s.displayName=Se.displayName;const bc=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(he,{className:"overflow-hidden p-0",children:e.jsx(_s,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Vs=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ro,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Se.Input,{ref:a,className:y("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Vs.displayName=Se.Input.displayName;const ws=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.List,{ref:a,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));ws.displayName=Se.List.displayName;const Is=m.forwardRef((s,n)=>e.jsx(Se.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Is.displayName=Se.Empty.displayName;const Ie=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Group,{ref:a,className:y("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Ie.displayName=Se.Group.displayName;const Hs=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Separator,{ref:a,className:y("-mx-1 h-px bg-border",s),...n}));Hs.displayName=Se.Separator.displayName;const _e=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Item,{ref:a,className:y("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));_e.displayName=Se.Item.displayName;function yc(){const s=[];for(const n of ir)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function Pe(){const[s,n]=m.useState(!1),a=is(),l=yc(),{t:r}=I("search"),{t:c}=I("nav");m.useEffect(()=>{const u=x=>{x.key==="k"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const i=m.useCallback(u=>{n(!1),a(u)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(lo,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:r("placeholder")}),e.jsx("span",{className:"sr-only",children:r("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:r("shortcut.key")})]}),e.jsxs(bc,{open:s,onOpenChange:n,children:[e.jsx(Vs,{placeholder:r("placeholder")}),e.jsxs(ws,{children:[e.jsx(Is,{children:r("noResults")}),e.jsx(Ie,{heading:r("title"),children:l.map(u=>e.jsxs(_e,{value:`${u.parent?u.parent+" ":""}${u.title}`,onSelect:()=>i(u.href),children:[e.jsx("div",{className:"mr-2",children:u.icon}),e.jsx("span",{children:c(u.title)}),u.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c(u.parent)})]},u.href))})]})]})]})}function Re(){const{theme:s,setTheme:n}=ki();return m.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",l=document.querySelector("meta[name='theme-color']");l&&l.setAttribute("content",a)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(oo,{size:20}):e.jsx(io,{size:20})}),e.jsx(tr,{})]})}const cr=m.forwardRef(({className:s,...n},a)=>e.jsx(dn,{ref:a,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));cr.displayName=dn.displayName;const dr=m.forwardRef(({className:s,...n},a)=>e.jsx(mn,{ref:a,className:y("aspect-square h-full w-full",s),...n}));dr.displayName=mn.displayName;const mr=m.forwardRef(({className:s,...n},a)=>e.jsx(un,{ref:a,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));mr.displayName=un.displayName;function Ee(){const s=is(),n=Ha(),a=co(Gi),{t:l}=I(["common"]),r=()=>{Wn(),n(Bi()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),i=c.substring(0,2).toUpperCase();return e.jsxs(ys,{children:[e.jsx(Ns,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(cr,{className:"h-8 w-8",children:[e.jsx(dr,{src:a?.avatar_url,alt:c}),e.jsx(mr,{children:i})]})})}),e.jsxs(os,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(oa,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:c}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:a?.email||l("common:defaultEmail")})]})}),e.jsx(at,{}),e.jsx(fe,{asChild:!0,children:e.jsxs(Rs,{to:"/config/system",children:[l("common:settings"),e.jsx(Yt,{children:"⌘S"})]})}),e.jsx(at,{}),e.jsxs(fe,{onClick:r,children:[l("common:logout"),e.jsx(Yt,{children:"⇧⌘Q"})]})]})]})}const Qe=window?.settings?.secure_path,ur=5*60*1e3,Jt=new Map,Nc=s=>{const n=Jt.get(s);return n?Date.now()-n.timestamp>ur?(Jt.delete(s),null):n.data:null},_c=(s,n)=>{Jt.set(s,{data:n,timestamp:Date.now()})},wc=async(s,n=ur)=>{const a=Nc(s);if(a)return a;const l=await O.get(s);return _c(s,l),l},Cc={getList:()=>wc(`${Qe}/notice/fetch`),save:s=>O.post(`${Qe}/notice/save`,s),drop:s=>O.post(`${Qe}/notice/drop`,{id:s}),updateStatus:s=>O.post(`${Qe}/notice/show`,{id:s}),sort:s=>O.post(`${Qe}/notice/sort`,{ids:s})},Va={getSystemStatus:()=>O.get(`${Qe}/system/getSystemStatus`),getQueueStats:()=>O.get(`${Qe}/system/getQueueStats`),getQueueWorkload:()=>O.get(`${Qe}/system/getQueueWorkload`),getQueueMasters:()=>O.get(`${Qe}/system/getQueueMasters`),getSystemLog:s=>O.get(`${Qe}/system/getSystemLog`,{params:s})},L=window?.settings?.secure_path,Sc=s=>O.get(L+"/stat/getOrder",{params:s}),kc=()=>O.get(L+"/stat/getStats"),Ia=s=>O.get(L+"/stat/getTrafficRank",{params:s}),Dc=()=>O.get(L+"/theme/getThemes"),Tc=s=>O.post(L+"/theme/getThemeConfig",{name:s}),Pc=(s,n)=>O.post(L+"/theme/saveThemeConfig",{name:s,config:n}),Rc=s=>{const n=new FormData;return n.append("file",s),O.post(L+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Ec=s=>O.post(L+"/theme/delete",{name:s}),Vc=s=>O.post(L+"/config/save",s),xr=()=>O.get(L+"/server/manage/getNodes"),Ic=s=>O.post(L+"/server/manage/save",s),Fc=s=>O.post(L+"/server/manage/drop",s),Mc=s=>O.post(L+"/server/manage/copy",s),Oc=s=>O.post(L+"/server/manage/update",s),zc=s=>O.post(L+"/server/manage/sort",s),It=()=>O.get(L+"/server/group/fetch"),Lc=s=>O.post(L+"/server/group/save",s),Ac=s=>O.post(L+"/server/group/drop",s),hr=()=>O.get(L+"/server/route/fetch"),$c=s=>O.post(L+"/server/route/save",s),qc=s=>O.post(L+"/server/route/drop",s),Kc=()=>O.get(L+"/payment/fetch"),Hc=()=>O.get(L+"/payment/getPaymentMethods"),Uc=s=>O.post(L+"/payment/getPaymentForm",s),Bc=s=>O.post(L+"/payment/save",s),Gc=s=>O.post(L+"/payment/drop",s),Wc=s=>O.post(L+"/payment/show",s),Yc=s=>O.post(L+"/payment/sort",s),Jc=()=>O.get(L+"/notice/fetch"),Qc=s=>O.post(L+"/notice/save",s),Zc=s=>O.post(L+"/notice/drop",s),Xc=s=>O.post(L+"/notice/show",s),ed=()=>O.get(L+"/knowledge/fetch"),sd=s=>O.get(L+"/knowledge/fetch?id="+s),td=s=>O.post(L+"/knowledge/save",s),ad=s=>O.post(L+"/knowledge/drop",s),nd=s=>O.post(L+"/knowledge/show",s),rd=s=>O.post(L+"/knowledge/sort",s),Fs=()=>O.get(L+"/plan/fetch"),ld=s=>O.post(L+"/plan/save",s),Lt=s=>O.post(L+"/plan/update",s),od=s=>O.post(L+"/plan/drop",s),id=s=>O.post(L+"/plan/sort",{ids:s}),cd=async s=>O.post(L+"/order/fetch",s),dd=s=>O.post(L+"/order/detail",s),md=s=>O.post(L+"/order/paid",s),ud=s=>O.post(L+"/order/cancel",s),Fa=s=>O.post(L+"/order/update",s),xd=s=>O.post(L+"/order/assign",s),hd=s=>O.post(L+"/coupon/fetch",s),fd=s=>O.post(L+"/coupon/generate",s),pd=s=>O.post(L+"/coupon/drop",s),gd=s=>O.post(L+"/coupon/update",s),jd=s=>O.post(L+"/user/fetch",s),vd=s=>O.post(L+"/user/update",s),bd=s=>O.post(L+"/user/resetSecret",s),yd=s=>O.post(L+"/user/generate",s),Nd=s=>O.post(L+"/stat/getStatUser",s),_d=s=>O.post(L+"/ticket/fetch",s),wd=s=>O.get(L+"/ticket/fetch?id= "+s),Cd=s=>O.post(L+"/ticket/reply",s),fr=s=>O.post(L+"/ticket/close",{id:s}),us=(s="")=>O.get(L+"/config/fetch?key="+s),xs=s=>O.post(L+"/config/save",s),Sd=()=>O.get(L+"/config/getEmailTemplate"),kd=()=>O.post(L+"/config/testSendMail"),Dd=()=>O.post(L+"/config/setTelegramWebhook"),Td=Cc.sort,pr=mo,ia=m.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));ia.displayName=xn.displayName;const nt=m.forwardRef(({className:s,...n},a)=>e.jsx(hn,{ref:a,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));nt.displayName=hn.displayName;const Pd=m.forwardRef(({className:s,...n},a)=>e.jsx(fn,{ref:a,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));Pd.displayName=fn.displayName;const W=uo,fs=bo,Y=xo,B=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(pn,{ref:l,className:y("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...a,children:[n,e.jsx(ho,{asChild:!0,children:e.jsx(aa,{className:"h-4 w-4 opacity-50"})})]}));B.displayName=pn.displayName;const gr=m.forwardRef(({className:s,...n},a)=>e.jsx(gn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(fo,{className:"h-4 w-4"})}));gr.displayName=gn.displayName;const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(jn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(aa,{className:"h-4 w-4"})}));jr.displayName=jn.displayName;const G=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(po,{children:e.jsxs(vn,{ref:r,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:a,...l,children:[e.jsx(gr,{}),e.jsx(go,{className:y("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(jr,{})]})}));G.displayName=vn.displayName;const Rd=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:y("px-2 py-1.5 text-sm font-semibold",s),...n}));Rd.displayName=bn.displayName;const $=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(yn,{ref:l,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(jo,{children:e.jsx(Ps,{className:"h-4 w-4"})})}),e.jsx(vo,{children:n})]}));$.displayName=yn.displayName;const Ed=m.forwardRef(({className:s,...n},a)=>e.jsx(Nn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));Ed.displayName=Nn.displayName;function Ms({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(yo,{showOutsideDays:a,className:y("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:y(qs({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:y("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",l.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:y(qs({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx(_n,{className:y("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(ta,{className:y("h-4 w-4",r),...c})},...l})}Ms.displayName="Calendar";const as=_o,ns=wo,We=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(No,{children:e.jsx(wn,{ref:r,align:n,sideOffset:a,className:y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...l})}));We.displayName=wn.displayName;const ps={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Qs=s=>(s/100).toFixed(2),Vd=({active:s,payload:n,label:a})=>{const{t:l}=I();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:a}),n.map((r,c)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[l(r.name),":"]}),e.jsx("span",{className:"font-medium",children:r.name.includes(l("dashboard:overview.amount"))?`¥${Qs(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},Id=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],Fd=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=qe(a,7);break;case"30d":l=qe(a,30);break;case"90d":l=qe(a,90);break;case"180d":l=qe(a,180);break;case"365d":l=qe(a,365);break;default:l=qe(a,30)}return{startDate:l,endDate:a}};function Md(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:qe(new Date,7),to:new Date}),{t:i}=I(),{startDate:u,endDate:x}=Fd(a,r),{data:o}=se({queryKey:["orderStat",{start_date:$e(u,"yyyy-MM-dd"),end_date:$e(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await Sc({start_date:$e(u,"yyyy-MM-dd"),end_date:$e(x,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(He,{children:[e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(bs,{children:i("dashboard:overview.title")}),e.jsxs(tt,{children:[o?.summary.start_date," ",i("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(W,{value:a,onValueChange:d=>l(d),children:[e.jsx(B,{className:"w-[120px]",children:e.jsx(Y,{placeholder:i("dashboard:overview.selectTimeRange")})}),e.jsx(G,{children:Id.map(d=>e.jsx($,{value:d.value,children:i(d.label)},d.value))})]}),a==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(it,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r?.from?r.to?e.jsxs(e.Fragment,{children:[$e(r.from,"yyyy-MM-dd")," -"," ",$e(r.to,"yyyy-MM-dd")]}):$e(r.from,"yyyy-MM-dd"):i("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Ms,{mode:"range",defaultMonth:r?.from,selected:{from:r?.from,to:r?.to},onSelect:d=>{d?.from&&d?.to&&c({from:d.from,to:d.to})},numberOfMonths:2})})]})]}),e.jsx(pr,{value:s,onValueChange:d=>n(d),children:e.jsxs(ia,{children:[e.jsx(nt,{value:"amount",children:i("dashboard:overview.amount")}),e.jsx(nt,{value:"count",children:i("dashboard:overview.count")})]})})]})]})}),e.jsxs(ts,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:i("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:i("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("dashboard:overview.avgOrderAmount")," ¥",Qs(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:i("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:i("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Co,{width:"100%",height:"100%",children:e.jsxs(So,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:ps.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:ps.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:ps.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:ps.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(ko,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>$e(new Date(d),"MM-dd",{locale:Ro})}),e.jsx(Do,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${Qs(d)}`:i("dashboard:overview.transactions",{count:d})}),e.jsx(To,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Po,{content:e.jsx(Vd,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(wa,{type:"monotone",dataKey:"paid_total",name:i("dashboard:overview.orderAmount"),stroke:ps.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(wa,{type:"monotone",dataKey:"commission_total",name:i("dashboard:overview.commissionAmount"),stroke:ps.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{dataKey:"paid_count",name:i("dashboard:overview.orderCount"),fill:ps.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Ca,{dataKey:"commission_count",name:i("dashboard:overview.commissionCount"),fill:ps.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function Ve({className:s,...n}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...n})}function Od(){return e.jsxs(He,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ve,{className:"h-4 w-[120px]"}),e.jsx(Ve,{className:"h-4 w-4"})]}),e.jsxs(ts,{children:[e.jsx(Ve,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx(Ve,{className:"h-4 w-[100px]"})]})]})]})}function zd(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:8}).map((s,n)=>e.jsx(Od,{},n))})}var Q=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(Q||{});const Ys={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Js={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Ke=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Ke||{}),ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(ne||{});const ut={0:"待确认",1:"发放中",2:"有效",3:"无效"},xt={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var de=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(de||{});const Ld={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ye=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(ye||{});const Ds=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ls={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var js=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(js||{});const Ad={1:"按金额优惠",2:"按比例优惠"};var et=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(et||{}),Xe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Xe||{});function gs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:i,className:u}){return e.jsxs(He,{className:y("transition-colors",c&&"cursor-pointer hover:bg-muted/50",i&&"border-primary/50",u),onClick:c,children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(bs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Oo,{className:y("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("ml-1 text-xs",l.isPositive?"text-emerald-500":"text-red-500"),children:[l.isPositive?"+":"-",Math.abs(l.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:l.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]})}function $d({className:s}){const n=is(),{t:a}=I(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await kc()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(zd,{});const c=()=>{const i=new URLSearchParams;i.set("commission_status",ne.PENDING.toString()),i.set("status",Q.COMPLETED.toString()),i.set("commission_balance","gt:0"),n(`/finance/order?${i.toString()}`)};return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(gs,{title:a("dashboard:stats.todayIncome"),value:ks(l.todayIncome),icon:e.jsx(Eo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.monthlyIncome"),value:ks(l.currentMonthIncome),icon:e.jsx(Vo,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Io,{className:y("h-4 w-4",l.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:l.ticketPendingTotal>0?a("dashboard:stats.hasPendingTickets"):a("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:l.ticketPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Fo,{className:y("h-4 w-4",l.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:l.commissionPendingTotal>0?a("dashboard:stats.hasPendingCommission"):a("dashboard:stats.noPendingCommission"),onClick:c,highlight:l.commissionPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Kt,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Kt,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(gs,{title:a("dashboard:stats.monthlyUpload"),value:Ze(l.monthTraffic.upload),icon:e.jsx(Ht,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.upload)})}),e.jsx(gs,{title:a("dashboard:stats.monthlyDownload"),value:Ze(l.monthTraffic.download),icon:e.jsx(Mo,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.download)})})]})}const rt=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Cn,{ref:l,className:y("relative overflow-hidden",s),...a,children:[e.jsx(zo,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ct,{}),e.jsx(Lo,{})]}));rt.displayName=Cn.displayName;const Ct=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Sn,{ref:l,orientation:n,className:y("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...a,children:e.jsx(Ao,{className:"relative flex-1 rounded-full bg-border"})}));Ct.displayName=Sn.displayName;const Qt={today:{getValue:()=>{const s=qo();return{start:s,end:Ko(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:qe(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:qe(s,30),end:s}}},custom:{getValue:()=>null}};function Ma({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=I(),c={today:r("dashboard:trafficRank.today"),last7days:r("dashboard:trafficRank.last7days"),last30days:r("dashboard:trafficRank.last30days"),custom:r("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(W,{value:s,onValueChange:a,children:[e.jsx(B,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(G,{position:"popper",className:"z-50",children:Object.entries(Qt).map(([i])=>e.jsx($,{value:i,children:c[i]},i))})]}),s==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(it,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[$e(n.from,"yyyy-MM-dd")," -"," ",$e(n.to,"yyyy-MM-dd")]}):$e(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Ms,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:i=>{i?.from&&i?.to&&l({from:i.from,to:i.to})},numberOfMonths:2})})]})]})}const zs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function qd({className:s}){const{t:n}=I(),[a,l]=m.useState("today"),[r,c]=m.useState({from:qe(new Date,7),to:new Date}),[i,u]=m.useState("today"),[x,o]=m.useState({from:qe(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:Qt[a].getValue(),[a,r]),p=m.useMemo(()=>i==="custom"?{start:x.from,end:x.to}:Qt[i].getValue(),[i,x]),{data:D}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Ia({type:"node",start_time:pe.round(d.start.getTime()/1e3),end_time:pe.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:V}=se({queryKey:["userTrafficRank",p.start,p.end],queryFn:()=>Ia({type:"user",start_time:pe.round(p.start.getTime()/1e3),end_time:pe.round(p.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(He,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx($o,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Ma,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(Sa,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:D?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:D.data.map(f=>e.jsx(ie,{delayDuration:200,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:f.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Ut,{className:"mr-1 h-3 w-3"}):e.jsx(Bt,{className:"mr-1 h-3 w-3"}),Math.abs(f.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${f.value/D.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:zs(f.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(He,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx(Kt,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Ma,{selectedRange:i,customDateRange:x,onRangeChange:u,onCustomRangeChange:o}),e.jsx(Sa,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:V?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:V.data.map(f=>e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:f.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Ut,{className:"mr-1 h-3 w-3"}):e.jsx(Bt,{className:"mr-1 h-3 w-3"}),Math.abs(f.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${f.value/V.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:zs(f.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const Kd=Ts("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function K({className:s,variant:n,...a}){return e.jsx("div",{className:y(Kd({variant:n}),s),...a})}const vt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(kn,{ref:l,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(Ho,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));vt.displayName=kn.displayName;function Hd(){const{t:s}=I(),[n,a]=m.useState(null),[l,r]=m.useState(null),[c,i]=m.useState(!0),[u,x]=m.useState(!1),o=async()=>{try{x(!0);const[D,V]=await Promise.all([Va.getSystemStatus(),Va.getQueueStats()]);a(D.data),r(V.data)}catch(D){console.error("Error fetching system data:",D)}finally{i(!1),x(!1)}};m.useEffect(()=>{o();const D=setInterval(o,3e4);return()=>clearInterval(D)},[]);const d=()=>{o()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(na,{className:"h-6 w-6 animate-spin"})});const p=D=>D?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Tn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(He,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(tt,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Bo,{className:y("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p(l?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(K,{variant:l?.status?"secondary":"destructive",children:l?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:l?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.recentJobs||0}),e.jsx(vt,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.jobsPerMinute||0}),e.jsx(vt,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(He,{children:[e.jsxs(ss,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Go,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(tt,{children:s("dashboard:queue.details.description")})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:l?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:l?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[l?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[l?.processes||0," /"," ",(l?.processes||0)+(l?.pausedMasters||0)]})]}),e.jsx(vt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Ud(){const{t:s}=I();return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Pe,{}),e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsx(ke,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx($d,{}),e.jsx(Md,{}),e.jsx(qd,{}),e.jsx(Hd,{})]})})})]})}const Bd=Object.freeze(Object.defineProperty({__proto__:null,default:Ud},Symbol.toStringTag,{value:"Module"})),be=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(Pn,{ref:r,decorative:a,orientation:n,className:y("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));be.displayName=Pn.displayName;function Gd({className:s,items:n,...a}){const{pathname:l}=Xt(),r=is(),[c,i]=m.useState(l??"/settings"),u=o=>{i(o),r(o)},{t:x}=I("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(W,{value:c,onValueChange:u,children:[e.jsx(B,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(G,{children:n.map(o=>e.jsx($,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:x(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:y("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(o=>e.jsxs(Rs,{to:o.href,className:y(Ks({variant:"ghost"}),l===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),x(o.title)]},o.href))})})]})}const Wd=[{title:"site.title",key:"site",icon:e.jsx(Wo,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(on,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(cn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Yo,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(ln,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Jo,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Qo,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(rn,{size:18}),href:"/config/system/app",description:"app.description"}];function Yd(){const{t:s}=I("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(Pe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(be,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(Gd,{items:Wd})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(ea,{})})})]})]})]})}const Jd=Object.freeze(Object.defineProperty({__proto__:null,default:Yd},Symbol.toStringTag,{value:"Module"})),H=m.forwardRef(({className:s,...n},a)=>e.jsx(Rn,{className:y("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:a,children:e.jsx(Zo,{className:y("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));H.displayName=Rn.displayName;const Cs=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:y("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}));Cs.displayName="Textarea";const Qd=h.object({logo:h.string().nullable().default(""),force_https:h.number().nullable().default(0),stop_register:h.number().nullable().default(0),app_name:h.string().nullable().default(""),app_description:h.string().nullable().default(""),app_url:h.string().nullable().default(""),subscribe_url:h.string().nullable().default(""),try_out_plan_id:h.number().nullable().default(0),try_out_hour:h.coerce.number().nullable().default(0),tos_url:h.string().nullable().default(""),currency:h.string().nullable().default(""),currency_symbol:h.string().nullable().default("")});function Zd(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>us("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Fs()}),i=ce({resolver:ue(Qd),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=es({mutationFn:xs,onSuccess:d=>{d.data&&q.success(s("common.autoSaved"))}});m.useEffect(()=>{if(r?.data?.site){const d=r?.data?.site;Object.entries(d).forEach(([p,D])=>{i.setValue(p,D)}),l.current=d}},[r]);const x=m.useCallback(pe.debounce(async d=>{if(!pe.isEqual(d,l.current)){a(!0);try{const p=Object.entries(d).reduce((D,[V,f])=>(D[V]=f===null?"":f,D),{});await u(p),l.current=d}finally{a(!1)}}},1e3),[u]),o=m.useCallback(d=>{x(d)},[x]);return m.useEffect(()=>{const d=i.watch(p=>{o(p)});return()=>d.unsubscribe()},[i.watch,o]),e.jsx(xe,{...i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:i.control,name:"app_name",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"app_description",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"app_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"force_https",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(j,{control:i.control,name:"logo",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"subscribe_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(N,{children:e.jsx(Cs,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"tos_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"stop_register",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(j,{control:i.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(N,{children:e.jsxs(W,{value:d.value?.toString(),onValueChange:p=>{d.onChange(Number(p)),o(i.getValues())},children:[e.jsx(B,{children:e.jsx(Y,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(p=>e.jsx($,{value:p.id.toString(),children:p.name},p.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(P,{})]})}),!!i.watch("try_out_plan_id")&&e.jsx(j,{control:i.control,name:"try_out_hour",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"currency",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"currency_symbol",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(P,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Xd(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(be,{}),e.jsx(Zd,{})]})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Xd},Symbol.toStringTag,{value:"Module"})),sm=h.object({email_verify:h.boolean().nullable(),safe_mode_enable:h.boolean().nullable(),secure_path:h.string().nullable(),email_whitelist_enable:h.boolean().nullable(),email_whitelist_suffix:h.array(h.string().nullable()).nullable(),email_gmail_limit_enable:h.boolean().nullable(),recaptcha_enable:h.boolean().nullable(),recaptcha_key:h.string().nullable(),recaptcha_site_key:h.string().nullable(),register_limit_by_ip_enable:h.boolean().nullable(),register_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:h.boolean().nullable(),password_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:h.coerce.string().transform(s=>s===""?null:s).nullable()}),tm={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,recaptcha_enable:!1,recaptcha_key:"",recaptcha_site_key:"",register_limit_by_ip_enable:!1,register_limit_count:"",register_limit_expire:"",password_limit_enable:!1,password_limit_count:"",password_limit_expire:""};function am(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(sm),defaultValues:tm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>us("safe")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:o=>{o.data&&q.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data.safe){const o=c.data.safe;Object.entries(o).forEach(([d,p])=>{typeof p=="number"?r.setValue(d,String(p)):r.setValue(d,p)}),l.current=o}},[c]);const u=m.useCallback(pe.debounce(async o=>{if(!pe.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(xe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"email_verify",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"secure_path",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(j,{control:r.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(N,{children:e.jsx(Cs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` +import{r as m,j as e,t as ll,c as ol,I as Na,a as Ts,S as Zt,u as is,b as Xt,d as il,O as ea,e as cl,f as q,g as dl,h as ml,i as ul,k as xl,B as hl,l as fl,Q as pl,m as gl,R as jl,n as vl,P as bl,o as yl,p as Nl,q as Ka,F as _l,C as wl,s as Cl,v as Sl,w as kl,x as Dl,y as Ha,z as I,A as h,D as ce,E as ue,G as Ua,H as St,J as kt,K as sa,L as Oe,T as Dt,M as Tt,N as Ba,U as Ga,V as Wa,W as ta,X as Ya,Y as Tl,Z as Ja,_ as Qa,$ as Za,a0 as Xa,a1 as Ps,a2 as en,a3 as Pl,a4 as sn,a5 as tn,a6 as Rl,a7 as El,a8 as Vl,a9 as Il,aa as Fl,ab as Ml,ac as Ol,ad as zl,ae as Ll,af as Al,ag as $l,ah as an,ai as ql,aj as Kl,ak as Rs,al as nn,am as Hl,an as Ul,ao as rn,ap as Bl,aq as Gl,ar as _a,as as Wl,at as ln,au as Yl,av as on,aw as Jl,ax as Ql,ay as Zl,az as Xl,aA as eo,aB as so,aC as cn,aD as to,aE as ao,aF as no,aG as Se,aH as ro,aI as lo,aJ as oo,aK as io,aL as dn,aM as mn,aN as un,aO as co,aP as xn,aQ as hn,aR as fn,aS as mo,aT as uo,aU as xo,aV as pn,aW as ho,aX as aa,aY as gn,aZ as fo,a_ as jn,a$ as po,b0 as vn,b1 as go,b2 as bn,b3 as yn,b4 as jo,b5 as vo,b6 as Nn,b7 as bo,b8 as yo,b9 as _n,ba as No,bb as wn,bc as _o,bd as wo,be as qe,bf as se,bg as $e,bh as it,bi as Co,bj as So,bk as ko,bl as Do,bm as To,bn as Po,bo as wa,bp as Ca,bq as Ro,br as Eo,bs as Vo,bt as Io,bu as Fo,bv as Kt,bw as Ht,bx as Mo,by as Oo,bz as Cn,bA as zo,bB as Lo,bC as Sn,bD as Ao,bE as pe,bF as $o,bG as Sa,bH as Ut,bI as Bt,bJ as qo,bK as Ko,bL as kn,bM as Ho,bN as na,bO as Uo,bP as Bo,bQ as Go,bR as Dn,bS as Tn,bT as Pn,bU as Wo,bV as Yo,bW as Jo,bX as Qo,bY as Rn,bZ as Zo,b_ as es,b$ as Xo,c0 as ei,c1 as si,c2 as bt,c3 as Ne,c4 as ka,c5 as ti,c6 as En,c7 as Vn,c8 as In,c9 as Fn,ca as Mn,cb as On,cc as ai,cd as ni,ce as ri,cf as Pt,cg as Es,ch as cs,ci as ze,cj as Le,ck as Ue,cl as Be,cm as Ge,cn as li,co as oi,cp as ii,cq as Gt,cr as ra,cs as la,ct as ci,cu as ds,cv as ms,cw as ct,cx as di,cy as yt,cz as mi,cA as Da,cB as zn,cC as Ta,cD as Nt,cE as ui,cF as xi,cG as hi,cH as fi,cI as Ln,cJ as pi,cK as gi,cL as An,cM as Wt,cN as $n,cO as ji,cP as qn,cQ as Kn,cR as vi,cS as bi,cT as yi,cU as Ni,cV as _i}from"./vendor.js";import"./index.js";var bh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function wi(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var a=function l(){return this instanceof l?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};a.prototype=n.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(s).forEach(function(l){var r=Object.getOwnPropertyDescriptor(s,l);Object.defineProperty(a,l,r.get?r:{enumerable:!0,get:function(){return s[l]}})}),a}const Ci={theme:"system",setTheme:()=>null},Hn=m.createContext(Ci);function Si({children:s,defaultTheme:n="system",storageKey:a="vite-ui-theme",...l}){const[r,c]=m.useState(()=>localStorage.getItem(a)||n);m.useEffect(()=>{const u=window.document.documentElement;if(u.classList.remove("light","dark"),r==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";u.classList.add(x);return}u.classList.add(r)},[r]);const i={theme:r,setTheme:u=>{localStorage.setItem(a,u),c(u)}};return e.jsx(Hn.Provider,{...l,value:i,children:s})}const ki=()=>{const s=m.useContext(Hn);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Di=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),Ti=function(s,n){return new URL(s,n).href},Pa={},oe=function(n,a,l){let r=Promise.resolve();if(a&&a.length>0){const i=document.getElementsByTagName("link"),u=document.querySelector("meta[property=csp-nonce]"),x=u?.nonce||u?.getAttribute("nonce");r=Promise.allSettled(a.map(o=>{if(o=Ti(o,l),o in Pa)return;Pa[o]=!0;const d=o.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(!!l)for(let f=i.length-1;f>=0;f--){const _=i[f];if(_.href===o&&(!d||_.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${p}`))return;const V=document.createElement("link");if(V.rel=d?"stylesheet":Di,d||(V.as="script"),V.crossOrigin="",V.href=o,x&&V.setAttribute("nonce",x),document.head.appendChild(V),d)return new Promise((f,_)=>{V.addEventListener("load",f),V.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}function c(i){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=i,window.dispatchEvent(u),!u.defaultPrevented)throw i}return r.then(i=>{for(const u of i||[])u.status==="rejected"&&c(u.reason);return n().catch(c)})};function y(...s){return ll(ol(s))}const Ks=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),R=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,children:r,disabled:c,loading:i=!1,leftSection:u,rightSection:x,...o},d)=>{const p=l?Zt:"button";return e.jsxs(p,{className:y(Ks({variant:n,size:a,className:s})),disabled:i||c,ref:d,...o,children:[(u&&i||!u&&!x&&i)&&e.jsx(Na,{className:"mr-2 h-4 w-4 animate-spin"}),!i&&u&&e.jsx("div",{className:"mr-2",children:u}),r,!i&&x&&e.jsx("div",{className:"ml-2",children:x}),x&&i&&e.jsx(Na,{className:"ml-2 h-4 w-4 animate-spin"})]})});R.displayName="Button";function Os({className:s,minimal:n=!1}){const a=is();return e.jsx("div",{className:y("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{})," Please try again later."]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(R,{variant:"outline",onClick:()=>a(-1),children:"Go Back"}),e.jsx(R,{onClick:()=>a("/"),children:"Back to Home"})]})]})})}function Ra(){const s=is();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(R,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(R,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Pi(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(R,{variant:"outline",children:"Learn more"})})]})})}function Ri(s){return typeof s>"u"}function Ei(s){return s===null}function Vi(s){return Ei(s)||Ri(s)}class Ii{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,a,l=null){const r=JSON.stringify({value:a,time:Date.now(),expire:l!==null?new Date().getTime()+l*1e3:null});this.storage.setItem(this.getKey(n),r)}get(n,a=null){const l=this.storage.getItem(this.getKey(n));if(!l)return{value:a,time:0};try{const r=JSON.parse(l),{value:c,time:i,expire:u}=r;return Vi(u)||u>new Date().getTime()?{value:c,time:i}:(this.remove(n),{value:a,time:0})}catch{return this.remove(n),{value:a,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function Un({prefixKey:s="",storage:n=sessionStorage}){return new Ii({prefixKey:s,storage:n})}const Bn="Xboard_",Fi=function(s={}){return Un({prefixKey:s.prefixKey||"",storage:localStorage})},Mi=function(s={}){return Un({prefixKey:s.prefixKey||"",storage:sessionStorage})},Rt=Fi({prefixKey:Bn});Mi({prefixKey:Bn});const Gn="access_token";function st(){return Rt.get(Gn)}function Wn(){Rt.remove(Gn)}const Ea=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Oi({children:s}){const n=is(),a=Xt(),l=st();return m.useEffect(()=>{if(!l.value&&!Ea.includes(a.pathname)){const r=encodeURIComponent(a.pathname+a.search);n(`/sign-in?redirect=${r}`)}},[l.value,a.pathname,a.search,n]),Ea.includes(a.pathname)||l.value?e.jsx(e.Fragment,{children:s}):null}const zi=()=>e.jsx(Oi,{children:e.jsx(ea,{})}),Li=il([{path:"/sign-in",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>dc);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(zi,{}),children:[{path:"/",lazy:async()=>({Component:(await oe(()=>Promise.resolve().then(()=>vc),void 0,import.meta.url)).default}),errorElement:e.jsx(Os,{}),children:[{index:!0,lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Bd);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Os,{}),children:[{path:"system",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Jd);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>em);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>rm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>dm);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>fm);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>bm);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Cm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Fm);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Am);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Zm);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>tu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>cu);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>gu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Os,{}),children:[{path:"manage",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>qu);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Gu);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Os,{}),children:[{path:"plan",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>ix);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Nx);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Rx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Os,{}),children:[{path:"manage",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>eh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>gh);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Os},{path:"/404",Component:Ra},{path:"/503",Component:Pi},{path:"*",Component:Ra}]),Ai="locale";function $i(){return Rt.get(Ai)}function Yn(){Wn();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),a=new URL(window.location.href),r=`${a.pathname.split("/")[1]?`/${a.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=r+(n?`?redirect=${s}`:"")}const qi=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Ki(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const O=cl.create({baseURL:Ki(),timeout:12e3,headers:{"Content-Type":"application/json"}});O.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=st();if(!qi.includes(s.url?.split("?")[0]||"")){if(!n.value)return Yn(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=$i().value||"zh-CN",s},s=>Promise.reject(s));O.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,a=s.response?.data?.message;return(n===401||n===403)&&Yn(),q.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function Hi(){return O.get("/user/info")}const Ot={token:st()?.value||"",userInfo:null,isLoggedIn:!!st()?.value,loading:!1,error:null},Xs=dl("user/fetchUserInfo",async()=>(await Hi()).data,{condition:(s,{getState:n})=>{const{user:a}=n();return!!a.token&&!a.loading}}),Jn=ml({name:"user",initialState:Ot,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>Ot},extraReducers:s=>{s.addCase(Xs.pending,n=>{n.loading=!0,n.error=null}).addCase(Xs.fulfilled,(n,a)=>{n.loading=!1,n.userInfo=a.payload,n.error=null}).addCase(Xs.rejected,(n,a)=>{if(n.loading=!1,n.error=a.error.message||"Failed to fetch user info",!n.token)return Ot})}}),{setToken:Ui,resetUserState:Bi}=Jn.actions,Gi=s=>s.user.userInfo,Wi=Jn.reducer,Qn=ul({reducer:{user:Wi}});st()?.value&&Qn.dispatch(Xs());xl.use(hl).use(fl).init({resources:{"en-US":window.XBOARD_TRANSLATIONS?.["en-US"]||{},"zh-CN":window.XBOARD_TRANSLATIONS?.["zh-CN"]||{},"ko-KR":window.XBOARD_TRANSLATIONS?.["ko-KR"]||{}},fallbackLng:"zh-CN",supportedLngs:["en-US","zh-CN","ko-KR"],detection:{order:["querystring","localStorage","navigator"],lookupQuerystring:"lang",lookupLocalStorage:"i18nextLng",caches:["localStorage"]},interpolation:{escapeValue:!1}});const Yi=new pl;gl.createRoot(document.getElementById("root")).render(e.jsx(jl.StrictMode,{children:e.jsx(vl,{client:Yi,children:e.jsx(bl,{store:Qn,children:e.jsxs(Si,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(yl,{router:Li}),e.jsx(Nl,{richColors:!0,position:"top-right"})]})})})}));const He=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("rounded-xl border bg-card text-card-foreground shadow",s),...n}));He.displayName="Card";const ss=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex flex-col space-y-1.5 p-6",s),...n}));ss.displayName="CardHeader";const bs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:y("font-semibold leading-none tracking-tight",s),...n}));bs.displayName="CardTitle";const tt=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:y("text-sm text-muted-foreground",s),...n}));tt.displayName="CardDescription";const ts=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("p-6 pt-0",s),...n}));ts.displayName="CardContent";const Ji=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex items-center p-6 pt-0",s),...n}));Ji.displayName="CardFooter";const Qi=Ts("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_t=m.forwardRef(({className:s,...n},a)=>e.jsx(Ka,{ref:a,className:y(Qi(),s),...n}));_t.displayName=Ka.displayName;const xe=_l,Zn=m.createContext({}),j=({...s})=>e.jsx(Zn.Provider,{value:{name:s.name},children:e.jsx(wl,{...s})}),Et=()=>{const s=m.useContext(Zn),n=m.useContext(Xn),{getFieldState:a,formState:l}=Cl(),r=a(s.name,l);if(!s)throw new Error("useFormField should be used within ");const{id:c}=n;return{id:c,name:s.name,formItemId:`${c}-form-item`,formDescriptionId:`${c}-form-item-description`,formMessageId:`${c}-form-item-message`,...r}},Xn=m.createContext({}),g=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(Xn.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:y("space-y-2",s),...n})})});g.displayName="FormItem";const v=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=Et();return e.jsx(_t,{ref:a,className:y(l&&"text-destructive",s),htmlFor:r,...n})});v.displayName="FormLabel";const N=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=Et();return e.jsx(Zt,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});N.displayName="FormControl";const F=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=Et();return e.jsx("p",{ref:a,id:l,className:y("text-[0.8rem] text-muted-foreground",s),...n})});F.displayName="FormDescription";const P=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=Et(),i=r?String(r?.message):n;return i?e.jsx("p",{ref:l,id:c,className:y("text-[0.8rem] font-medium text-destructive",s),...a,children:i}):null});P.displayName="FormMessage";const T=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:l,...a}));T.displayName="Input";const er=m.forwardRef(({className:s,...n},a)=>{const[l,r]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:l?"text":"password",className:y("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}),e.jsx(R,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>r(c=>!c),children:l?e.jsx(Sl,{size:18}):e.jsx(kl,{size:18})})]})});er.displayName="PasswordInput";const Zi=s=>O({url:"/passport/auth/login",method:"post",data:s});function me(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Dl(s).format(n))}function Xi(s=void 0,n="YYYY-MM-DD"){return me(s,n)}function As(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function ks(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const a=typeof s=="string"?parseFloat(s):s;if(isNaN(a))return n?"¥0.00":"0.00";const r=(a/100).toFixed(2).replace(/\.?0+$/,c=>c.includes(".")?".00":c);return n?`¥${r}`:r}function wt(s){return new Promise(n=>{(async()=>{try{if(navigator.clipboard)await navigator.clipboard.writeText(s);else{const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();const r=document.execCommand("copy");if(document.body.removeChild(l),!r)throw new Error("execCommand failed")}n(!0)}catch(l){console.error(l),n(!1)}})()})}function Ze(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?As(r)+" TB":l>=1?As(l)+" GB":a>=1?As(a)+" MB":As(n)+" KB"}const ec="access_token";function sc(s){Rt.set(ec,s)}function tc({className:s,onForgotPassword:n,...a}){const l=is(),r=Ha(),{t:c}=I("auth"),i=h.object({email:h.string().min(1,{message:c("signIn.validation.emailRequired")}),password:h.string().min(1,{message:c("signIn.validation.passwordRequired")}).min(7,{message:c("signIn.validation.passwordLength")})}),u=ce({resolver:ue(i),defaultValues:{email:"",password:""}});async function x(o){Zi(o).then(({data:d})=>{sc(d.auth_data),r(Ui(d.auth_data)),r(Xs()).unwrap(),l("/")})}return e.jsx("div",{className:y("grid gap-6",s),...a,children:e.jsx(xe,{...u,children:e.jsx("form",{onSubmit:u.handleSubmit(x),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:u.control,name:"email",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:c("signIn.email")}),e.jsx(N,{children:e.jsx(T,{placeholder:c("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"password",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:c("signIn.password")}),e.jsx(N,{children:e.jsx(er,{placeholder:c("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(P,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:c("signIn.forgotPassword")})}),e.jsx(R,{className:"w-full",size:"lg",loading:u.formState.isSubmitting,children:c("signIn.submit")})]})})})})}const ge=Ua,Fe=Ba,ac=Ga,dt=sa,sr=m.forwardRef(({className:s,...n},a)=>e.jsx(St,{ref:a,className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n}));sr.displayName=St.displayName;const he=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(ac,{children:[e.jsx(sr,{}),e.jsxs(kt,{ref:l,className:y("max-h-[95%] overflow-auto fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a,children:[n,e.jsxs(sa,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Oe,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));he.displayName=kt.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Me=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Me.displayName="DialogFooter";const je=m.forwardRef(({className:s,...n},a)=>e.jsx(Dt,{ref:a,className:y("text-lg font-semibold leading-none tracking-tight",s),...n}));je.displayName=Dt.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Tt,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Te.displayName=Tt.displayName;const qs=Ts("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),J=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const i=l?Zt:"button";return e.jsx(i,{className:y(qs({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";const ys=Rl,Ns=El,nc=Vl,rc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(Wa,{ref:r,className:y("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",n&&"pl-8",s),...l,children:[a,e.jsx(ta,{className:"ml-auto h-4 w-4"})]}));rc.displayName=Wa.displayName;const lc=m.forwardRef(({className:s,...n},a)=>e.jsx(Ya,{ref:a,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n}));lc.displayName=Ya.displayName;const os=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Tl,{children:e.jsx(Ja,{ref:l,sideOffset:n,className:y("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a})}));os.displayName=Ja.displayName;const fe=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(Qa,{ref:l,className:y("relative flex cursor-default cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",s),...a}));fe.displayName=Qa.displayName;const oc=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(Za,{ref:r,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:a,...l,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xa,{children:e.jsx(Ps,{className:"h-4 w-4"})})}),n]}));oc.displayName=Za.displayName;const ic=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(en,{ref:l,className:y("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Xa,{children:e.jsx(Pl,{className:"h-4 w-4 fill-current"})})}),n]}));ic.displayName=en.displayName;const oa=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(sn,{ref:l,className:y("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));oa.displayName=sn.displayName;const at=m.forwardRef(({className:s,...n},a)=>e.jsx(tn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));at.displayName=tn.displayName;const Yt=({className:s,...n})=>e.jsx("span",{className:y("ml-auto text-xs tracking-widest opacity-60",s),...n});Yt.displayName="DropdownMenuShortcut";const zt=[{code:"en-US",name:"English",flag:Il,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Fl,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:Ml,shortName:"KR"}];function tr(){const{i18n:s}=I(),n=r=>{s.changeLanguage(r)},a=zt.find(r=>r.code===s.language)||zt[1],l=a.flag;return e.jsxs(ys,{children:[e.jsx(Ns,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(l,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:a.shortName})]})}),e.jsx(os,{align:"end",className:"w-[120px]",children:zt.map(r=>{const c=r.flag,i=r.code===s.language;return e.jsxs(fe,{onClick:()=>n(r.code),className:y("flex items-center gap-2 px-2 py-1.5 cursor-pointer",i&&"bg-accent"),children:[e.jsx(c,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:y("text-sm",i&&"font-medium"),children:r.name})]},r.code)})})]})}function cc(){const[s,n]=m.useState(!1),{t:a}=I("auth"),l=a("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative grid h-svh flex-col items-center justify-center bg-primary-foreground lg:max-w-none lg:px-0",children:[e.jsx("div",{className:"absolute right-4 top-4 md:right-8 md:top-8",children:e.jsx(tr,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[480px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(He,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:a("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("signIn.description")})]}),e.jsx(tc,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(ge,{open:s,onOpenChange:n,children:e.jsx(he,{children:e.jsxs(ve,{children:[e.jsx(je,{children:a("signIn.resetPassword.title")}),e.jsx(Te,{children:a("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"rounded-md bg-secondary p-4 pr-12 text-sm",children:l}),e.jsx(J,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>wt(l).then(()=>{q.success(a("common:copy.success"))}),children:e.jsx(Ol,{className:"h-4 w-4"})})]})})]})})})]})}const dc=Object.freeze(Object.defineProperty({__proto__:null,default:cc},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:y("relative flex h-full w-full flex-col",n&&"after:pointer-events-none after:absolute after:bottom-0 after:left-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_hsl(var(--background))_70%)] after:md:block",a&&"md:h-svh",s),...l}));we.displayName="Layout";const Ce=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:y("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const ke=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:y("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));ke.displayName="LayoutBody";const ar=zl,nr=Ll,rr=Al,ie=$l,re=ql,le=Kl,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(an,{ref:l,sideOffset:n,className:y("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...a}));te.displayName=an.displayName;function Vt(){const{pathname:s}=Xt();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function lr({key:s,defaultValue:n}){const[a,l]=m.useState(()=>{const r=localStorage.getItem(s);return r!==null?JSON.parse(r):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,l]}function mc(){const[s,n]=lr({key:"collapsed-sidebar-items",defaultValue:[]}),a=r=>!s.includes(r);return{isExpanded:a,toggleItem:r=>{a(r)?n([...s,r]):n(s.filter(c=>c!==r))}}}function uc({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=I(),c=({sub:i,...u})=>{const x=`${r(u.title)}-${u.href}`;return n&&i?m.createElement(fc,{...u,sub:i,key:x,closeNav:l}):n?m.createElement(hc,{...u,key:x,closeNav:l}):i?m.createElement(xc,{...u,sub:i,key:x,closeNav:l}):m.createElement(or,{...u,key:x,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:y("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",a),children:e.jsx(ie,{delayDuration:0,children:e.jsx("nav",{className:"grid gap-1 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2",children:s.map(c)})})})}function or({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:i}=Vt(),{t:u}=I();return e.jsxs(Rs,{to:l,onClick:r,className:y(Ks({variant:i(l)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",c&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":i(l)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),u(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(a)})]})}function xc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Vt(),{isExpanded:i,toggleItem:u}=mc(),{t:x}=I(),o=!!l?.find(D=>c(D.href)),d=x(s),p=i(d)||o;return e.jsxs(ar,{open:p,onOpenChange:()=>u(d),children:[e.jsxs(nr,{className:y(Ks({variant:o?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),x(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:x(a)}),e.jsx("span",{className:y('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(nn,{stroke:1})})]}),e.jsx(rr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(D=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(or,{...D,subLink:!0,closeNav:r})},x(D.title)))})})]})}function hc({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=Vt(),{t:i}=I();return e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsxs(Rs,{to:l,onClick:r,className:y(Ks({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:i(s)})]})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[i(s),a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:i(a)})]})]})}function fc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Vt(),{t:i}=I(),u=!!l?.find(x=>c(x.href));return e.jsxs(ys,{children:[e.jsxs(re,{delayDuration:0,children:[e.jsx(le,{asChild:!0,children:e.jsx(Ns,{asChild:!0,children:e.jsx(R,{variant:u?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(te,{side:"right",className:"flex items-center gap-4",children:[i(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:i(a)}),e.jsx(nn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(os,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(oa,{children:[i(s)," ",a?`(${i(a)})`:""]}),e.jsx(at,{}),l.map(({title:x,icon:o,label:d,href:p})=>e.jsx(fe,{asChild:!0,children:e.jsxs(Rs,{to:p,onClick:r,className:`${c(p)?"bg-secondary":""}`,children:[o," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:i(x)}),d&&e.jsx("span",{className:"ml-auto text-xs",children:i(d)})]})},`${i(x)}-${p}`))]})]})}const ir=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Hl,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Ul,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(rn,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Bl,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Gl,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(_a,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Wl,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(ln,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Yl,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(on,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Jl,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Ql,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Zl,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(_a,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Xl,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(eo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(so,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(cn,{size:18})}]}];function pc({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=m.useState(!1),{t:c}=I();return m.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:y(`fixed left-0 right-0 top-0 z-50 w-full border-r-2 border-r-muted transition-[width] md:bottom-0 md:right-auto md:h-svh ${n?"md:w-14":"md:w-64"}`,s),children:[e.jsx("div",{onClick:()=>r(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${l?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(we,{children:[e.jsxs(Ce,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":c("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":l,onClick:()=>r(i=>!i),children:l?e.jsx(to,{}):e.jsx(ao,{})})]}),e.jsx(uc,{id:"sidebar-menu",className:`h-full flex-1 overflow-auto ${l?"max-h-screen":"max-h-0 py-0 md:max-h-screen md:py-2"}`,closeNav:()=>r(!1),isCollapsed:n,links:ir}),e.jsx("div",{className:y("px-4 py-3 text-xs text-muted-foreground/70 border-t border-border/50 bg-muted/20","transition-all duration-200 ease-in-out",n?"text-center":"text-left"),children:e.jsxs("div",{className:y("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500/70"}),e.jsxs("span",{className:"tracking-wide",children:["v",window?.settings?.version]})]})}),e.jsx(R,{onClick:()=>a(i=>!i),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":c("common:toggleSidebar"),children:e.jsx(no,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function gc(){const[s,n]=lr({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const a=()=>{n(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),[s,n]}function jc(){const[s,n]=gc();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(pc,{isCollapsed:s,setIsCollapsed:n}),e.jsx("main",{id:"content",className:`overflow-x-hidden pt-16 transition-[margin] md:overflow-y-hidden md:pt-0 ${s?"md:ml-14":"md:ml-64"} h-full`,children:e.jsx(ea,{})})]})}const vc=Object.freeze(Object.defineProperty({__proto__:null,default:jc},Symbol.toStringTag,{value:"Module"})),_s=m.forwardRef(({className:s,...n},a)=>e.jsx(Se,{ref:a,className:y("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));_s.displayName=Se.displayName;const bc=({children:s,...n})=>e.jsx(ge,{...n,children:e.jsx(he,{className:"overflow-hidden p-0",children:e.jsx(_s,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:s})})}),Vs=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ro,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Se.Input,{ref:a,className:y("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...n})]}));Vs.displayName=Se.Input.displayName;const ws=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.List,{ref:a,className:y("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));ws.displayName=Se.List.displayName;const Is=m.forwardRef((s,n)=>e.jsx(Se.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Is.displayName=Se.Empty.displayName;const Ie=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Group,{ref:a,className:y("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...n}));Ie.displayName=Se.Group.displayName;const Hs=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Separator,{ref:a,className:y("-mx-1 h-px bg-border",s),...n}));Hs.displayName=Se.Separator.displayName;const _e=m.forwardRef(({className:s,...n},a)=>e.jsx(Se.Item,{ref:a,className:y("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...n}));_e.displayName=Se.Item.displayName;function yc(){const s=[];for(const n of ir)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function Pe(){const[s,n]=m.useState(!1),a=is(),l=yc(),{t:r}=I("search"),{t:c}=I("nav");m.useEffect(()=>{const u=x=>{x.key==="k"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[]);const i=m.useCallback(u=>{n(!1),a(u)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(J,{variant:"outline",className:"relative h-9 w-9 p-0 xl:h-10 xl:w-60 xl:justify-start xl:px-3 xl:py-2",onClick:()=>n(!0),children:[e.jsx(lo,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:r("placeholder")}),e.jsx("span",{className:"sr-only",children:r("shortcut.label")}),e.jsx("kbd",{className:"pointer-events-none absolute right-1.5 top-2 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:r("shortcut.key")})]}),e.jsxs(bc,{open:s,onOpenChange:n,children:[e.jsx(Vs,{placeholder:r("placeholder")}),e.jsxs(ws,{children:[e.jsx(Is,{children:r("noResults")}),e.jsx(Ie,{heading:r("title"),children:l.map(u=>e.jsxs(_e,{value:`${u.parent?u.parent+" ":""}${u.title}`,onSelect:()=>i(u.href),children:[e.jsx("div",{className:"mr-2",children:u.icon}),e.jsx("span",{children:c(u.title)}),u.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c(u.parent)})]},u.href))})]})]})]})}function Re(){const{theme:s,setTheme:n}=ki();return m.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",l=document.querySelector("meta[name='theme-color']");l&&l.setAttribute("content",a)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(oo,{size:20}):e.jsx(io,{size:20})}),e.jsx(tr,{})]})}const cr=m.forwardRef(({className:s,...n},a)=>e.jsx(dn,{ref:a,className:y("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));cr.displayName=dn.displayName;const dr=m.forwardRef(({className:s,...n},a)=>e.jsx(mn,{ref:a,className:y("aspect-square h-full w-full",s),...n}));dr.displayName=mn.displayName;const mr=m.forwardRef(({className:s,...n},a)=>e.jsx(un,{ref:a,className:y("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));mr.displayName=un.displayName;function Ee(){const s=is(),n=Ha(),a=co(Gi),{t:l}=I(["common"]),r=()=>{Wn(),n(Bi()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),i=c.substring(0,2).toUpperCase();return e.jsxs(ys,{children:[e.jsx(Ns,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(cr,{className:"h-8 w-8",children:[e.jsx(dr,{src:a?.avatar_url,alt:c}),e.jsx(mr,{children:i})]})})}),e.jsxs(os,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(oa,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:c}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:a?.email||l("common:defaultEmail")})]})}),e.jsx(at,{}),e.jsx(fe,{asChild:!0,children:e.jsxs(Rs,{to:"/config/system",children:[l("common:settings"),e.jsx(Yt,{children:"⌘S"})]})}),e.jsx(at,{}),e.jsxs(fe,{onClick:r,children:[l("common:logout"),e.jsx(Yt,{children:"⇧⌘Q"})]})]})]})}const Qe=window?.settings?.secure_path,ur=5*60*1e3,Jt=new Map,Nc=s=>{const n=Jt.get(s);return n?Date.now()-n.timestamp>ur?(Jt.delete(s),null):n.data:null},_c=(s,n)=>{Jt.set(s,{data:n,timestamp:Date.now()})},wc=async(s,n=ur)=>{const a=Nc(s);if(a)return a;const l=await O.get(s);return _c(s,l),l},Cc={getList:()=>wc(`${Qe}/notice/fetch`),save:s=>O.post(`${Qe}/notice/save`,s),drop:s=>O.post(`${Qe}/notice/drop`,{id:s}),updateStatus:s=>O.post(`${Qe}/notice/show`,{id:s}),sort:s=>O.post(`${Qe}/notice/sort`,{ids:s})},Va={getSystemStatus:()=>O.get(`${Qe}/system/getSystemStatus`),getQueueStats:()=>O.get(`${Qe}/system/getQueueStats`),getQueueWorkload:()=>O.get(`${Qe}/system/getQueueWorkload`),getQueueMasters:()=>O.get(`${Qe}/system/getQueueMasters`),getSystemLog:s=>O.get(`${Qe}/system/getSystemLog`,{params:s})},L=window?.settings?.secure_path,Sc=s=>O.get(L+"/stat/getOrder",{params:s}),kc=()=>O.get(L+"/stat/getStats"),Ia=s=>O.get(L+"/stat/getTrafficRank",{params:s}),Dc=()=>O.get(L+"/theme/getThemes"),Tc=s=>O.post(L+"/theme/getThemeConfig",{name:s}),Pc=(s,n)=>O.post(L+"/theme/saveThemeConfig",{name:s,config:n}),Rc=s=>{const n=new FormData;return n.append("file",s),O.post(L+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Ec=s=>O.post(L+"/theme/delete",{name:s}),Vc=s=>O.post(L+"/config/save",s),xr=()=>O.get(L+"/server/manage/getNodes"),Ic=s=>O.post(L+"/server/manage/save",s),Fc=s=>O.post(L+"/server/manage/drop",s),Mc=s=>O.post(L+"/server/manage/copy",s),Oc=s=>O.post(L+"/server/manage/update",s),zc=s=>O.post(L+"/server/manage/sort",s),It=()=>O.get(L+"/server/group/fetch"),Lc=s=>O.post(L+"/server/group/save",s),Ac=s=>O.post(L+"/server/group/drop",s),hr=()=>O.get(L+"/server/route/fetch"),$c=s=>O.post(L+"/server/route/save",s),qc=s=>O.post(L+"/server/route/drop",s),Kc=()=>O.get(L+"/payment/fetch"),Hc=()=>O.get(L+"/payment/getPaymentMethods"),Uc=s=>O.post(L+"/payment/getPaymentForm",s),Bc=s=>O.post(L+"/payment/save",s),Gc=s=>O.post(L+"/payment/drop",s),Wc=s=>O.post(L+"/payment/show",s),Yc=s=>O.post(L+"/payment/sort",s),Jc=()=>O.get(L+"/notice/fetch"),Qc=s=>O.post(L+"/notice/save",s),Zc=s=>O.post(L+"/notice/drop",s),Xc=s=>O.post(L+"/notice/show",s),ed=()=>O.get(L+"/knowledge/fetch"),sd=s=>O.get(L+"/knowledge/fetch?id="+s),td=s=>O.post(L+"/knowledge/save",s),ad=s=>O.post(L+"/knowledge/drop",s),nd=s=>O.post(L+"/knowledge/show",s),rd=s=>O.post(L+"/knowledge/sort",s),Fs=()=>O.get(L+"/plan/fetch"),ld=s=>O.post(L+"/plan/save",s),Lt=s=>O.post(L+"/plan/update",s),od=s=>O.post(L+"/plan/drop",s),id=s=>O.post(L+"/plan/sort",{ids:s}),cd=async s=>O.post(L+"/order/fetch",s),dd=s=>O.post(L+"/order/detail",s),md=s=>O.post(L+"/order/paid",s),ud=s=>O.post(L+"/order/cancel",s),Fa=s=>O.post(L+"/order/update",s),xd=s=>O.post(L+"/order/assign",s),hd=s=>O.post(L+"/coupon/fetch",s),fd=s=>O.post(L+"/coupon/generate",s),pd=s=>O.post(L+"/coupon/drop",s),gd=s=>O.post(L+"/coupon/update",s),jd=s=>O.post(L+"/user/fetch",s),vd=s=>O.post(L+"/user/update",s),bd=s=>O.post(L+"/user/resetSecret",s),yd=s=>O.post(L+"/user/generate",s),Nd=s=>O.post(L+"/stat/getStatUser",s),_d=s=>O.post(L+"/ticket/fetch",s),wd=s=>O.get(L+"/ticket/fetch?id= "+s),Cd=s=>O.post(L+"/ticket/reply",s),fr=s=>O.post(L+"/ticket/close",{id:s}),us=(s="")=>O.get(L+"/config/fetch?key="+s),xs=s=>O.post(L+"/config/save",s),Sd=()=>O.get(L+"/config/getEmailTemplate"),kd=()=>O.post(L+"/config/testSendMail"),Dd=()=>O.post(L+"/config/setTelegramWebhook"),Td=Cc.sort,pr=mo,ia=m.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:y("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));ia.displayName=xn.displayName;const nt=m.forwardRef(({className:s,...n},a)=>e.jsx(hn,{ref:a,className:y("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",s),...n}));nt.displayName=hn.displayName;const Pd=m.forwardRef(({className:s,...n},a)=>e.jsx(fn,{ref:a,className:y("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));Pd.displayName=fn.displayName;const W=uo,fs=bo,Y=xo,B=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(pn,{ref:l,className:y("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...a,children:[n,e.jsx(ho,{asChild:!0,children:e.jsx(aa,{className:"h-4 w-4 opacity-50"})})]}));B.displayName=pn.displayName;const gr=m.forwardRef(({className:s,...n},a)=>e.jsx(gn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(fo,{className:"h-4 w-4"})}));gr.displayName=gn.displayName;const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(jn,{ref:a,className:y("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(aa,{className:"h-4 w-4"})}));jr.displayName=jn.displayName;const G=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(po,{children:e.jsxs(vn,{ref:r,className:y("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:a,...l,children:[e.jsx(gr,{}),e.jsx(go,{className:y("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(jr,{})]})}));G.displayName=vn.displayName;const Rd=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:y("px-2 py-1.5 text-sm font-semibold",s),...n}));Rd.displayName=bn.displayName;const $=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(yn,{ref:l,className:y("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...a,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(jo,{children:e.jsx(Ps,{className:"h-4 w-4"})})}),e.jsx(vo,{children:n})]}));$.displayName=yn.displayName;const Ed=m.forwardRef(({className:s,...n},a)=>e.jsx(Nn,{ref:a,className:y("-mx-1 my-1 h-px bg-muted",s),...n}));Ed.displayName=Nn.displayName;function Ms({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(yo,{showOutsideDays:a,className:y("p-3",s),classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:y(qs({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:y("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",l.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:y(qs({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx(_n,{className:y("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(ta,{className:y("h-4 w-4",r),...c})},...l})}Ms.displayName="Calendar";const as=_o,ns=wo,We=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(No,{children:e.jsx(wn,{ref:r,align:n,sideOffset:a,className:y("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...l})}));We.displayName=wn.displayName;const ps={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Qs=s=>(s/100).toFixed(2),Vd=({active:s,payload:n,label:a})=>{const{t:l}=I();return s&&n&&n.length?e.jsxs("div",{className:"rounded-lg border bg-background p-3 shadow-sm",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:a}),n.map((r,c)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[l(r.name),":"]}),e.jsx("span",{className:"font-medium",children:r.name.includes(l("dashboard:overview.amount"))?`¥${Qs(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},Id=[{value:"7d",label:"dashboard:overview.last7Days"},{value:"30d",label:"dashboard:overview.last30Days"},{value:"90d",label:"dashboard:overview.last90Days"},{value:"180d",label:"dashboard:overview.last180Days"},{value:"365d",label:"dashboard:overview.lastYear"},{value:"custom",label:"dashboard:overview.customRange"}],Fd=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=qe(a,7);break;case"30d":l=qe(a,30);break;case"90d":l=qe(a,90);break;case"180d":l=qe(a,180);break;case"365d":l=qe(a,365);break;default:l=qe(a,30)}return{startDate:l,endDate:a}};function Md(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:qe(new Date,7),to:new Date}),{t:i}=I(),{startDate:u,endDate:x}=Fd(a,r),{data:o}=se({queryKey:["orderStat",{start_date:$e(u,"yyyy-MM-dd"),end_date:$e(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await Sc({start_date:$e(u,"yyyy-MM-dd"),end_date:$e(x,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(He,{children:[e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(bs,{children:i("dashboard:overview.title")}),e.jsxs(tt,{children:[o?.summary.start_date," ",i("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(W,{value:a,onValueChange:d=>l(d),children:[e.jsx(B,{className:"w-[120px]",children:e.jsx(Y,{placeholder:i("dashboard:overview.selectTimeRange")})}),e.jsx(G,{children:Id.map(d=>e.jsx($,{value:d.value,children:i(d.label)},d.value))})]}),a==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(it,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:r?.from?r.to?e.jsxs(e.Fragment,{children:[$e(r.from,"yyyy-MM-dd")," -"," ",$e(r.to,"yyyy-MM-dd")]}):$e(r.from,"yyyy-MM-dd"):i("dashboard:overview.selectDate")})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Ms,{mode:"range",defaultMonth:r?.from,selected:{from:r?.from,to:r?.to},onSelect:d=>{d?.from&&d?.to&&c({from:d.from,to:d.to})},numberOfMonths:2})})]})]}),e.jsx(pr,{value:s,onValueChange:d=>n(d),children:e.jsxs(ia,{children:[e.jsx(nt,{value:"amount",children:i("dashboard:overview.amount")}),e.jsx(nt,{value:"count",children:i("dashboard:overview.count")})]})})]})]})}),e.jsxs(ts,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:i("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(o?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:i("dashboard:overview.totalTransactions",{count:o?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("dashboard:overview.avgOrderAmount")," ¥",Qs(o?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:i("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Qs(o?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:i("dashboard:overview.totalTransactions",{count:o?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[i("dashboard:overview.commissionRate")," ",o?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(Co,{width:"100%",height:"100%",children:e.jsxs(So,{data:o?.list||[],margin:{top:20,right:20,left:0,bottom:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"incomeGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:ps.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:ps.income.gradient.end,stopOpacity:.1})]}),e.jsxs("linearGradient",{id:"commissionGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:ps.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:ps.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(ko,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>$e(new Date(d),"MM-dd",{locale:Ro})}),e.jsx(Do,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${Qs(d)}`:i("dashboard:overview.transactions",{count:d})}),e.jsx(To,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Po,{content:e.jsx(Vd,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(wa,{type:"monotone",dataKey:"paid_total",name:i("dashboard:overview.orderAmount"),stroke:ps.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(wa,{type:"monotone",dataKey:"commission_total",name:i("dashboard:overview.commissionAmount"),stroke:ps.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{dataKey:"paid_count",name:i("dashboard:overview.orderCount"),fill:ps.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Ca,{dataKey:"commission_count",name:i("dashboard:overview.commissionCount"),fill:ps.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function Ve({className:s,...n}){return e.jsx("div",{className:y("animate-pulse rounded-md bg-primary/10",s),...n})}function Od(){return e.jsxs(He,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ve,{className:"h-4 w-[120px]"}),e.jsx(Ve,{className:"h-4 w-4"})]}),e.jsxs(ts,{children:[e.jsx(Ve,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx(Ve,{className:"h-4 w-[100px]"})]})]})]})}function zd(){return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:8}).map((s,n)=>e.jsx(Od,{},n))})}var Q=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.CANCELLED=2]="CANCELLED",s[s.COMPLETED=3]="COMPLETED",s[s.DISCOUNTED=4]="DISCOUNTED",s))(Q||{});const Ys={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Js={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Ke=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Ke||{}),ne=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(ne||{});const ut={0:"待确认",1:"发放中",2:"有效",3:"无效"},xt={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var de=(s=>(s.MONTH_PRICE="month_price",s.QUARTER_PRICE="quarter_price",s.HALF_YEAR_PRICE="half_year_price",s.YEAR_PRICE="year_price",s.TWO_YEAR_PRICE="two_year_price",s.THREE_YEAR_PRICE="three_year_price",s.ONETIME_PRICE="onetime_price",s.RESET_PRICE="reset_price",s))(de||{});const Ld={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var ye=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(ye||{});const Ds=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ls={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var js=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(js||{});const Ad={1:"按金额优惠",2:"按比例优惠"};var et=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(et||{}),Xe=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Xe||{});function gs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:i,className:u}){return e.jsxs(He,{className:y("transition-colors",c&&"cursor-pointer hover:bg-muted/50",i&&"border-primary/50",u),onClick:c,children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(bs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(ts,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Oo,{className:y("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:y("ml-1 text-xs",l.isPositive?"text-emerald-500":"text-red-500"),children:[l.isPositive?"+":"-",Math.abs(l.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:l.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]})}function $d({className:s}){const n=is(),{t:a}=I(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await kc()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(zd,{});const c=()=>{const i=new URLSearchParams;i.set("commission_status",ne.PENDING.toString()),i.set("status",Q.COMPLETED.toString()),i.set("commission_balance","gt:0"),n(`/finance/order?${i.toString()}`)};return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(gs,{title:a("dashboard:stats.todayIncome"),value:ks(l.todayIncome),icon:e.jsx(Eo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.monthlyIncome"),value:ks(l.currentMonthIncome),icon:e.jsx(Vo,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Io,{className:y("h-4 w-4",l.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:l.ticketPendingTotal>0?a("dashboard:stats.hasPendingTickets"):a("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:l.ticketPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Fo,{className:y("h-4 w-4",l.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:l.commissionPendingTotal>0?a("dashboard:stats.hasPendingCommission"):a("dashboard:stats.noPendingCommission"),onClick:c,highlight:l.commissionPendingTotal>0}),e.jsx(gs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Kt,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(gs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Kt,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(gs,{title:a("dashboard:stats.monthlyUpload"),value:Ze(l.monthTraffic.upload),icon:e.jsx(Ht,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.upload)})}),e.jsx(gs,{title:a("dashboard:stats.monthlyDownload"),value:Ze(l.monthTraffic.download),icon:e.jsx(Mo,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:Ze(l.todayTraffic.download)})})]})}const rt=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Cn,{ref:l,className:y("relative overflow-hidden",s),...a,children:[e.jsx(zo,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ct,{}),e.jsx(Lo,{})]}));rt.displayName=Cn.displayName;const Ct=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Sn,{ref:l,orientation:n,className:y("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...a,children:e.jsx(Ao,{className:"relative flex-1 rounded-full bg-border"})}));Ct.displayName=Sn.displayName;const Qt={today:{getValue:()=>{const s=qo();return{start:s,end:Ko(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:qe(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:qe(s,30),end:s}}},custom:{getValue:()=>null}};function Ma({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=I(),c={today:r("dashboard:trafficRank.today"),last7days:r("dashboard:trafficRank.last7days"),last30days:r("dashboard:trafficRank.last30days"),custom:r("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(W,{value:s,onValueChange:a,children:[e.jsx(B,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(G,{position:"popper",className:"z-50",children:Object.entries(Qt).map(([i])=>e.jsx($,{value:i,children:c[i]},i))})]}),s==="custom"&&e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:y("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(it,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:n?.from?n.to?e.jsxs(e.Fragment,{children:[$e(n.from,"yyyy-MM-dd")," -"," ",$e(n.to,"yyyy-MM-dd")]}):$e(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(We,{className:"w-auto p-0",align:"end",children:e.jsx(Ms,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:i=>{i?.from&&i?.to&&l({from:i.from,to:i.to})},numberOfMonths:2})})]})]})}const zs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function qd({className:s}){const{t:n}=I(),[a,l]=m.useState("today"),[r,c]=m.useState({from:qe(new Date,7),to:new Date}),[i,u]=m.useState("today"),[x,o]=m.useState({from:qe(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:Qt[a].getValue(),[a,r]),p=m.useMemo(()=>i==="custom"?{start:x.from,end:x.to}:Qt[i].getValue(),[i,x]),{data:D}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Ia({type:"node",start_time:pe.round(d.start.getTime()/1e3),end_time:pe.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:V}=se({queryKey:["userTrafficRank",p.start,p.end],queryFn:()=>Ia({type:"user",start_time:pe.round(p.start.getTime()/1e3),end_time:pe.round(p.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:y("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(He,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx($o,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.nodeTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Ma,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(Sa,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:D?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:D.data.map(f=>e.jsx(ie,{delayDuration:200,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:f.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Ut,{className:"mr-1 h-3 w-3"}):e.jsx(Bt,{className:"mr-1 h-3 w-3"}),Math.abs(f.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${f.value/D.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:zs(f.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]}),e.jsxs(He,{children:[e.jsx(ss,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(bs,{className:"flex items-center text-base font-medium",children:[e.jsx(Kt,{className:"mr-2 h-4 w-4"}),n("dashboard:trafficRank.userTrafficRank")]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(Ma,{selectedRange:i,customDateRange:x,onRangeChange:u,onCustomRangeChange:o}),e.jsx(Sa,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(ts,{className:"flex-1",children:V?.data?e.jsxs(rt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:V.data.map(f=>e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx("div",{className:"flex cursor-pointer items-center justify-between space-x-2 rounded-lg bg-muted/50 p-2 transition-colors hover:bg-muted/70",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:f.name}),e.jsxs("span",{className:y("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Ut,{className:"mr-1 h-3 w-3"}):e.jsx(Bt,{className:"mr-1 h-3 w-3"}),Math.abs(f.change),"%"]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${f.value/V.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:zs(f.value)})]})]})})}),e.jsx(te,{side:"right",className:"space-y-2 p-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.currentTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:zs(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:y("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Ct,{orientation:"vertical"})]}):e.jsx("div",{className:"flex h-[400px] items-center justify-center",children:e.jsx("div",{className:"animate-pulse",children:n("common:loading")})})})]})]})}const Kd=Ts("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/10",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function K({className:s,variant:n,...a}){return e.jsx("div",{className:y(Kd({variant:n}),s),...a})}const vt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(kn,{ref:l,className:y("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(Ho,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));vt.displayName=kn.displayName;function Hd(){const{t:s}=I(),[n,a]=m.useState(null),[l,r]=m.useState(null),[c,i]=m.useState(!0),[u,x]=m.useState(!1),o=async()=>{try{x(!0);const[D,V]=await Promise.all([Va.getSystemStatus(),Va.getQueueStats()]);a(D.data),r(V.data)}catch(D){console.error("Error fetching system data:",D)}finally{i(!1),x(!1)}};m.useEffect(()=>{o();const D=setInterval(o,3e4);return()=>clearInterval(D)},[]);const d=()=>{o()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(na,{className:"h-6 w-6 animate-spin"})});const p=D=>D?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Tn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(He,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Uo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(tt,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Bo,{className:y("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[p(l?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(K,{variant:l?.status?"secondary":"destructive",children:l?.status?s("dashboard:queue.status.normal"):s("dashboard:queue.status.abnormal")})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.status.waitTime",{seconds:l?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.recentJobs")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.recentJobs||0}),e.jsx(vt,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.jobsPerMinute")}),e.jsx("p",{className:"text-2xl font-bold",children:l?.jobsPerMinute||0}),e.jsx(vt,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(te,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(He,{children:[e.jsxs(ss,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Go,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(tt,{children:s("dashboard:queue.details.description")})]}),e.jsx(ts,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.failedJobs7Days")}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:l?.failedJobs||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:l?.periods?.failedJobs||0})})]}),e.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/50 p-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.longestRunningQueue")}),e.jsxs("p",{className:"text-2xl font-bold",children:[l?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:l?.queueWithMaxRuntime?.name||"N/A"})]})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s("dashboard:queue.details.activeProcesses")}),e.jsxs("span",{className:"font-medium",children:[l?.processes||0," /"," ",(l?.processes||0)+(l?.pausedMasters||0)]})]}),e.jsx(vt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Ud(){const{t:s}=I();return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("dashboard:title")})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Pe,{}),e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsx(ke,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx($d,{}),e.jsx(Md,{}),e.jsx(qd,{}),e.jsx(Hd,{})]})})})]})}const Bd=Object.freeze(Object.defineProperty({__proto__:null,default:Ud},Symbol.toStringTag,{value:"Module"})),be=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(Pn,{ref:r,decorative:a,orientation:n,className:y("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));be.displayName=Pn.displayName;function Gd({className:s,items:n,...a}){const{pathname:l}=Xt(),r=is(),[c,i]=m.useState(l??"/settings"),u=o=>{i(o),r(o)},{t:x}=I("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(W,{value:c,onValueChange:u,children:[e.jsx(B,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(G,{children:n.map(o=>e.jsx($,{value:o.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:o.icon}),e.jsx("span",{className:"text-md",children:x(o.title)})]})},o.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:y("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(o=>e.jsxs(Rs,{to:o.href,className:y(Ks({variant:"ghost"}),l===o.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:o.icon}),x(o.title)]},o.href))})})]})}const Wd=[{title:"site.title",key:"site",icon:e.jsx(Wo,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(on,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(cn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Yo,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(ln,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Jo,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Qo,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(rn,{size:18}),href:"/config/system/app",description:"app.description"}];function Yd(){const{t:s}=I("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(Pe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:s("title")}),e.jsx("div",{className:"text-muted-foreground",children:s("description")})]}),e.jsx(be,{className:"my-6"}),e.jsxs("div",{className:"flex flex-1 flex-col space-y-8 overflow-auto lg:flex-row lg:space-x-12 lg:space-y-0",children:[e.jsx("aside",{className:"sticky top-0 lg:w-1/5",children:e.jsx(Gd,{items:Wd})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(ea,{})})})]})]})]})}const Jd=Object.freeze(Object.defineProperty({__proto__:null,default:Yd},Symbol.toStringTag,{value:"Module"})),H=m.forwardRef(({className:s,...n},a)=>e.jsx(Rn,{className:y("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...n,ref:a,children:e.jsx(Zo,{className:y("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));H.displayName=Rn.displayName;const Cs=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:y("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}));Cs.displayName="Textarea";const Qd=h.object({logo:h.string().nullable().default(""),force_https:h.number().nullable().default(0),stop_register:h.number().nullable().default(0),app_name:h.string().nullable().default(""),app_description:h.string().nullable().default(""),app_url:h.string().nullable().default(""),subscribe_url:h.string().nullable().default(""),try_out_plan_id:h.number().nullable().default(0),try_out_hour:h.coerce.number().nullable().default(0),tos_url:h.string().nullable().default(""),currency:h.string().nullable().default(""),currency_symbol:h.string().nullable().default("")});function Zd(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>us("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Fs()}),i=ce({resolver:ue(Qd),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=es({mutationFn:xs,onSuccess:d=>{d.data&&q.success(s("common.autoSaved"))}});m.useEffect(()=>{if(r?.data?.site){const d=r?.data?.site;Object.entries(d).forEach(([p,D])=>{i.setValue(p,D)}),l.current=d}},[r]);const x=m.useCallback(pe.debounce(async d=>{if(!pe.isEqual(d,l.current)){a(!0);try{const p=Object.entries(d).reduce((D,[V,f])=>(D[V]=f===null?"":f,D),{});await u(p),l.current=d}finally{a(!1)}}},1e3),[u]),o=m.useCallback(d=>{x(d)},[x]);return m.useEffect(()=>{const d=i.watch(p=>{o(p)});return()=>d.unsubscribe()},[i.watch,o]),e.jsx(xe,{...i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:i.control,name:"app_name",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.siteName.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"app_description",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.siteDescription.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"app_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.siteUrl.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"force_https",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(F,{children:s("site.form.forceHttps.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(j,{control:i.control,name:"logo",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.logo.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"subscribe_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(N,{children:e.jsx(Cs,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.subscribeUrl.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"tos_url",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.tosUrl.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"stop_register",render:({field:d})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(F,{children:s("site.form.stopRegister.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(j,{control:i.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(N,{children:e.jsxs(W,{value:d.value?.toString(),onValueChange:p=>{d.onChange(Number(p)),o(i.getValues())},children:[e.jsx(B,{children:e.jsx(Y,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(p=>e.jsx($,{value:p.id.toString(),children:p.name},p.id.toString()))]})]})}),e.jsx(F,{children:s("site.form.tryOut.description")}),e.jsx(P,{})]})}),!!i.watch("try_out_plan_id")&&e.jsx(j,{control:i.control,name:"try_out_hour",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.tryOut.duration.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"currency",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.currency.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:i.control,name:"currency_symbol",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(F,{children:s("site.form.currencySymbol.description")}),e.jsx(P,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Xd(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(be,{}),e.jsx(Zd,{})]})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Xd},Symbol.toStringTag,{value:"Module"})),sm=h.object({email_verify:h.boolean().nullable(),safe_mode_enable:h.boolean().nullable(),secure_path:h.string().nullable(),email_whitelist_enable:h.boolean().nullable(),email_whitelist_suffix:h.array(h.string().nullable()).nullable(),email_gmail_limit_enable:h.boolean().nullable(),recaptcha_enable:h.boolean().nullable(),recaptcha_key:h.string().nullable(),recaptcha_site_key:h.string().nullable(),register_limit_by_ip_enable:h.boolean().nullable(),register_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),register_limit_expire:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_enable:h.boolean().nullable(),password_limit_count:h.coerce.string().transform(s=>s===""?null:s).nullable(),password_limit_expire:h.coerce.string().transform(s=>s===""?null:s).nullable()}),tm={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,recaptcha_enable:!1,recaptcha_key:"",recaptcha_site_key:"",register_limit_by_ip_enable:!1,register_limit_count:"",register_limit_expire:"",password_limit_enable:!1,password_limit_count:"",password_limit_expire:""};function am(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(sm),defaultValues:tm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>us("safe")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:o=>{o.data&&q.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data.safe){const o=c.data.safe;Object.entries(o).forEach(([d,p])=>{typeof p=="number"?r.setValue(d,String(p)):r.setValue(d,p)}),l.current=o}},[c]);const u=m.useCallback(pe.debounce(async o=>{if(!pe.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(xe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"email_verify",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(F,{children:s("safe.form.emailVerify.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(F,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(F,{children:s("safe.form.safeMode.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"secure_path",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.securePath.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(F,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(j,{control:r.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(N,{children:e.jsx(Cs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` `),onChange:d=>{const p=d.target.value.split(` `).filter(Boolean);o.onChange(p),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(F,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.key.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(P,{})]})})]}),e.jsx(j,{control:r.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(F,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"register_limit_count",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.count.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(P,{})]})})]}),e.jsx(j,{control:r.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(F,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"password_limit_count",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(F,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(P,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function nm(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("safe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("safe.description")})]}),e.jsx(be,{}),e.jsx(am,{})]})}const rm=Object.freeze(Object.defineProperty({__proto__:null,default:nm},Symbol.toStringTag,{value:"Module"})),lm=h.object({plan_change_enable:h.boolean().nullable().default(!1),reset_traffic_method:h.coerce.number().nullable().default(0),surplus_enable:h.boolean().nullable().default(!1),new_order_event_id:h.coerce.number().nullable().default(0),renew_order_event_id:h.coerce.number().nullable().default(0),change_order_event_id:h.coerce.number().nullable().default(0),show_info_to_server_enable:h.boolean().nullable().default(!1),show_protocol_to_server_enable:h.boolean().nullable().default(!1),default_remind_expire:h.boolean().nullable().default(!1),default_remind_traffic:h.boolean().nullable().default(!1),subscribe_path:h.string().nullable().default("s")}),om={plan_change_enable:!1,reset_traffic_method:0,surplus_enable:!1,new_order_event_id:0,renew_order_event_id:0,change_order_event_id:0,show_info_to_server_enable:!1,show_protocol_to_server_enable:!1,default_remind_expire:!1,default_remind_traffic:!1,subscribe_path:"s"};function im(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(lm),defaultValues:om,mode:"onBlur"}),{data:c}=se({queryKey:["settings","subscribe"],queryFn:()=>us("subscribe")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:o=>{o.data&&q.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.subscribe){const o=c?.data?.subscribe;Object.entries(o).forEach(([d,p])=>{r.setValue(d,p)}),l.current=o}},[c]);const u=m.useCallback(pe.debounce(async o=>{if(!pe.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(xe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(F,{children:s("subscribe.plan_change_enable.description")}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(N,{children:e.jsx(B,{children:e.jsx(Y,{placeholder:"请选择重置方式"})})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx($,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx($,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx($,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx($,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(F,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"surplus_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(F,{children:s("subscribe.surplus_enable.description")}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(N,{children:e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(B,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.new_order_event.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(N,{children:e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(B,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("renew_order_event.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(N,{children:e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(B,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx($,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(F,{children:s("subscribe.change_order_event.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"subscribe_path",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:"subscribe",...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s("subscribe.subscribe_path.description"),e.jsx("br",{}),s("subscribe.subscribe_path.current_format",{path:o.value||"s"})]}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(F,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(F,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function cm(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("subscribe.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe.description")})]}),e.jsx(be,{}),e.jsx(im,{})]})}const dm=Object.freeze(Object.defineProperty({__proto__:null,default:cm},Symbol.toStringTag,{value:"Module"})),mm=h.object({invite_force:h.boolean().default(!1),invite_commission:h.coerce.string().default("0"),invite_gen_limit:h.coerce.string().default("0"),invite_never_expire:h.boolean().default(!1),commission_first_time_enable:h.boolean().default(!1),commission_auto_check_enable:h.boolean().default(!1),commission_withdraw_limit:h.coerce.string().default("0"),commission_withdraw_method:h.array(h.string()).default(["支付宝","USDT","Paypal"]),withdraw_close_enable:h.boolean().default(!1),commission_distribution_enable:h.boolean().default(!1),commission_distribution_l1:h.coerce.number().default(0),commission_distribution_l2:h.coerce.number().default(0),commission_distribution_l3:h.coerce.number().default(0)}),um={invite_force:!1,invite_commission:"0",invite_gen_limit:"0",invite_never_expire:!1,commission_first_time_enable:!1,commission_auto_check_enable:!1,commission_withdraw_limit:"0",commission_withdraw_method:["支付宝","USDT","Paypal"],withdraw_close_enable:!1,commission_distribution_enable:!1,commission_distribution_l1:0,commission_distribution_l2:0,commission_distribution_l3:0};function xm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(mm),defaultValues:um,mode:"onBlur"}),{data:c}=se({queryKey:["settings","invite"],queryFn:()=>us("invite")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:o=>{o.data&&q.success(s("common.autoSaved"))}});m.useEffect(()=>{if(c?.data?.invite){const o=c?.data?.invite;Object.entries(o).forEach(([d,p])=>{typeof p=="number"?r.setValue(d,String(p)):r.setValue(d,p)}),l.current=o}},[c]);const u=m.useCallback(pe.debounce(async o=>{if(!pe.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(xe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"invite_force",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(F,{children:s("invite.invite_force.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"invite_commission",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_commission.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.invite_gen_limit.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(F,{children:s("invite.invite_never_expire.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(F,{children:s("invite.commission_first_time.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(F,{children:s("invite.commission_auto_check.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("invite.commission_withdraw_method.placeholder"),...o,value:Array.isArray(o.value)?o.value.join(","):"",onChange:d=>{const p=d.target.value.split(",").filter(Boolean);o.onChange(p),x(r.getValues())}})}),e.jsx(F,{children:s("invite.commission_withdraw_method.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(F,{children:s("invite.withdraw_close.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(F,{children:s("invite.commission_distribution.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(j,{control:r.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:s("invite.commission_distribution.l1")}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:d=>{const p=d.target.value?Number(d.target.value):0;o.onChange(p),x(r.getValues())}})}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:s("invite.commission_distribution.l2")}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:d=>{const p=d.target.value?Number(d.target.value):0;o.onChange(p),x(r.getValues())}})}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:s("invite.commission_distribution.l3")}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...o,value:o.value||"",onChange:d=>{const p=d.target.value?Number(d.target.value):0;o.onChange(p),x(r.getValues())}})}),e.jsx(P,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function hm(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(be,{}),e.jsx(xm,{})]})}const fm=Object.freeze(Object.defineProperty({__proto__:null,default:hm},Symbol.toStringTag,{value:"Module"})),pm=h.object({frontend_theme:h.string().nullable(),frontend_theme_sidebar:h.string().nullable(),frontend_theme_header:h.string().nullable(),frontend_theme_color:h.string().nullable(),frontend_background_url:h.string().url().nullable()}),gm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function jm(){const{data:s}=se({queryKey:["settings","frontend"],queryFn:()=>us("frontend")}),n=ce({resolver:ue(pm),defaultValues:gm,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([r,c])=>{n.setValue(r,c)})}},[s]);function a(l){xs(l).then(({data:r})=>{r&&q.success("更新成功")})}return e.jsx(xe,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(j,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:"边栏风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(N,{children:e.jsx(H,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:"头部风格"}),e.jsx(F,{children:"边栏风格"})]}),e.jsx(N,{children:e.jsx(H,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(j,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(g,{children:[e.jsx(v,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(N,{children:e.jsxs("select",{className:y(Ks({variant:"outline"}),"w-[200px] appearance-none font-normal"),...l,children:[e.jsx("option",{value:"default",children:"默认"}),e.jsx("option",{value:"black",children:"黑色"}),e.jsx("option",{value:"blackblue",children:"暗蓝色"}),e.jsx("option",{value:"green",children:"奶绿色"})]})}),e.jsx(aa,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(F,{children:"主题色"}),e.jsx(P,{})]})}),e.jsx(j,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(g,{children:[e.jsx(v,{children:"背景"}),e.jsx(N,{children:e.jsx(T,{placeholder:"请输入图片地址",...l})}),e.jsx(F,{children:"将会在后台登录页面进行展示。"}),e.jsx(P,{})]})}),e.jsx(R,{type:"submit",children:"保存设置"})]})})}function vm(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"个性化设置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自定义系统界面外观,包括主题风格、布局、颜色方案、背景图等个性化选项。"})]}),e.jsx(be,{}),e.jsx(jm,{})]})}const bm=Object.freeze(Object.defineProperty({__proto__:null,default:vm},Symbol.toStringTag,{value:"Module"})),ym=h.object({server_pull_interval:h.coerce.number().nullable(),server_push_interval:h.coerce.number().nullable(),server_token:h.string().nullable(),device_limit_mode:h.coerce.number().nullable()}),Nm={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function _m(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(ym),defaultValues:Nm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","server"],queryFn:()=>us("server")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:d=>{d.data&&q.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(c?.data.server){const d=c.data.server;Object.entries(d).forEach(([p,D])=>{r.setValue(p,D)}),l.current=d}},[c]);const u=m.useCallback(pe.debounce(async d=>{if(!pe.isEqual(d,l.current)){a(!0);try{await i(d),l.current=d}finally{a(!1)}}},1e3),[i]),x=m.useCallback(d=>{u(d)},[u]);m.useEffect(()=>{const d=r.watch(p=>{x(p)});return()=>d.unsubscribe()},[r.watch,x]);const o=()=>{const d=Math.floor(Math.random()*17)+16,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let D="";for(let V=0;Ve.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.server_token.title")}),e.jsx(N,{children:e.jsxs("div",{className:"relative",children:[e.jsx(T,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(ie,{children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 py-2",onClick:p=>{p.preventDefault(),o()},children:e.jsx(Xo,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(te,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(F,{children:s("server.server_token.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const D=p.target.value?Number(p.target.value):null;d.onChange(D)}})}),e.jsx(F,{children:s("server.server_pull_interval.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const D=p.target.value?Number(p.target.value):null;d.onChange(D)}})}),e.jsx(F,{children:s("server.server_push_interval.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(W,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(N,{children:e.jsx(B,{children:e.jsx(Y,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx($,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(F,{children:s("server.device_limit_mode.description")}),e.jsx(P,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function wm(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("server.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("server.description")})]}),e.jsx(be,{}),e.jsx(_m,{})]})}const Cm=Object.freeze(Object.defineProperty({__proto__:null,default:wm},Symbol.toStringTag,{value:"Module"}));function Sm({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(ge,{open:s,onOpenChange:n,children:e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Dn,{className:"h-5 w-5 text-green-500"}):e.jsx(Tn,{className:"h-5 w-5 text-destructive"}),e.jsx(je,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Te,{children:l?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"发送详情"}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"收件地址"}),e.jsx("div",{children:a.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:a.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:a.template_name})]})]}),a.error&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium text-destructive",children:"错误信息"}),e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive break-all",children:a.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(rt,{className:"h-[200px] rounded-md border p-4",children:e.jsx("div",{className:"grid gap-2 text-sm",children:e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-2",children:[e.jsx("div",{className:"text-muted-foreground",children:"驱动"}),e.jsx("div",{children:a.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:a.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:a.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:a.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:a.config.from.address?`${a.config.from.address}${a.config.from.name?` (${a.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:a.config.username||"未设置"})]})})})]})]})]})})}const km=h.object({email_template:h.string().nullable().default("classic"),email_host:h.string().nullable().default(""),email_port:h.coerce.number().nullable().default(465),email_username:h.string().nullable().default(""),email_password:h.string().nullable().default(""),email_encryption:h.string().nullable().default(""),email_from_address:h.string().email().nullable().default(""),remind_mail_enable:h.boolean().nullable().default(!1)});function Dm(){const{t:s}=I("settings"),[n,a]=m.useState(null),[l,r]=m.useState(!1),c=m.useRef(null),[i,u]=m.useState(!1),x=ce({resolver:ue(km),defaultValues:{},mode:"onBlur"}),{data:o}=se({queryKey:["settings","email"],queryFn:()=>us("email")}),{data:d}=se({queryKey:["emailTemplate"],queryFn:()=>Sd()}),{mutateAsync:p}=es({mutationFn:xs,onSuccess:k=>{k.data&&q.success(s("common.autoSaved"))}}),{mutate:D,isPending:V}=es({mutationFn:kd,onMutate:()=>{a(null),r(!1)},onSuccess:k=>{a(k.data),r(!0),k.data.error?q.error(s("email.test.error")):q.success(s("email.test.success"))}});m.useEffect(()=>{if(o?.data.email){const k=o.data.email;Object.entries(k).forEach(([b,w])=>{x.setValue(b,w)}),c.current=k}},[o]);const f=m.useCallback(pe.debounce(async k=>{if(!pe.isEqual(k,c.current)){u(!0);try{await p(k),c.current=k}finally{u(!1)}}},1e3),[p]),_=m.useCallback(k=>{f(k)},[f]);return m.useEffect(()=>{const k=x.watch(b=>{_(b)});return()=>k.unsubscribe()},[x.watch,_]),e.jsxs(e.Fragment,{children:[e.jsx(xe,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:x.control,name:"email_host",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_host.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(F,{children:s("email.email_host.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"email_port",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_port.title")}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:s("common.placeholder"),...k,value:k.value||"",onChange:b=>{const w=b.target.value?Number(b.target.value):null;k.onChange(w)}})}),e.jsx(F,{children:s("email.email_port.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"email_encryption",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(W,{onValueChange:k.onChange,value:k.value||"none",children:[e.jsx(N,{children:e.jsx(B,{children:e.jsx(Y,{placeholder:"请选择加密方式"})})}),e.jsxs(G,{children:[e.jsx($,{value:"none",children:s("email.email_encryption.none")}),e.jsx($,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx($,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(F,{children:s("email.email_encryption.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"email_username",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email.email_username.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(F,{children:s("email.email_username.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"email_password",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email_password.title")}),e.jsx(N,{children:e.jsx(T,{type:"password",placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(F,{children:s("email_password.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"email_from_address",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email_from.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...k,value:k.value||""})}),e.jsx(F,{children:s("email_from.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"email_template",render:({field:k})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("email_template.title")}),e.jsxs(W,{onValueChange:b=>{k.onChange(b),_(x.getValues())},value:k.value||void 0,children:[e.jsx(N,{children:e.jsx(B,{className:"w-[200px]",children:e.jsx(Y,{placeholder:s("email_template.placeholder")})})}),e.jsx(G,{children:d?.data?.map(b=>e.jsx($,{value:b,children:b},b))})]}),e.jsx(F,{children:s("email_template.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:x.control,name:"remind_mail_enable",render:({field:k})=>e.jsxs(g,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{className:"text-base",children:s("remind_mail.title")}),e.jsx(F,{children:s("remind_mail.description")})]}),e.jsx(N,{children:e.jsx(H,{checked:k.value||!1,onCheckedChange:b=>{k.onChange(b),_(x.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{onClick:()=>D(),loading:V,disabled:V,children:s(V?"test.sending":"test.title")})})]})}),i&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Sm,{open:l,onOpenChange:r,result:n})]})}function Tm(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("email.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("email.description")})]}),e.jsx(be,{}),e.jsx(Dm,{})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:Tm},Symbol.toStringTag,{value:"Module"})),Rm=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Em={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Vm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Rm),defaultValues:Em,mode:"onBlur"}),{data:c}=se({queryKey:["settings","telegram"],queryFn:()=>us("telegram")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:p=>{p.data&&q.success(s("common.autoSaved"))}}),{mutate:u,isPending:x}=es({mutationFn:Dd,onSuccess:p=>{p.data&&q.success(s("telegram.webhook_success"))}});m.useEffect(()=>{if(c?.data.telegram){const p=c.data.telegram;Object.entries(p).forEach(([D,V])=>{r.setValue(D,V)}),l.current=p}},[c]);const o=m.useCallback(pe.debounce(async p=>{if(!pe.isEqual(p,l.current)){a(!0);try{await i(p),l.current=p}finally{a(!1)}}},1e3),[i]),d=m.useCallback(p=>{o(p)},[o]);return m.useEffect(()=>{const p=r.watch(D=>{d(D)});return()=>p.unsubscribe()},[r.watch,d]),e.jsx(xe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"telegram_bot_token",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("telegram.bot_token.placeholder"),...p,value:p.value||""})}),e.jsx(F,{children:s("telegram.bot_token.description")}),e.jsx(P,{})]})}),r.watch("telegram_bot_token")&&e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(R,{loading:x,disabled:x,onClick:()=>u(),children:s(x?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(F,{children:s("telegram.webhook.description")}),e.jsx(P,{})]}),e.jsx(j,{control:r.control,name:"telegram_bot_enable",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(F,{children:s("telegram.bot_enable.description")}),e.jsx(N,{children:e.jsx(H,{checked:p.value||!1,onCheckedChange:D=>{p.onChange(D),d(r.getValues())}})}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"telegram_discuss_link",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("telegram.discuss_link.placeholder"),...p,value:p.value||""})}),e.jsx(F,{children:s("telegram.discuss_link.description")}),e.jsx(P,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Im(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("telegram.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("telegram.description")})]}),e.jsx(be,{}),e.jsx(Vm,{})]})}const Fm=Object.freeze(Object.defineProperty({__proto__:null,default:Im},Symbol.toStringTag,{value:"Module"})),Mm=h.object({windows_version:h.string().nullable(),windows_download_url:h.string().nullable(),macos_version:h.string().nullable(),macos_download_url:h.string().nullable(),android_version:h.string().nullable(),android_download_url:h.string().nullable()}),Om={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function zm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ce({resolver:ue(Mm),defaultValues:Om,mode:"onBlur"}),{data:c}=se({queryKey:["settings","app"],queryFn:()=>us("app")}),{mutateAsync:i}=es({mutationFn:xs,onSuccess:o=>{o.data&&q.success(s("app.save_success"))}});m.useEffect(()=>{if(c?.data.app){const o=c.data.app;Object.entries(o).forEach(([d,p])=>{r.setValue(d,p)}),l.current=o}},[c]);const u=m.useCallback(pe.debounce(async o=>{if(!pe.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(xe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:r.control,name:"windows_version",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.version.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"windows_download_url",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.windows.download.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"macos_version",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.version.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"macos_download_url",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.macos.download.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"android_version",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.android.version.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.version.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:r.control,name:"android_download_url",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{className:"text-base",children:s("app.android.download.title")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(F,{children:s("app.android.download.description")}),e.jsx(P,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Lm(){const{t:s}=I("settings");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("app.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("app.description")})]}),e.jsx(be,{}),e.jsx(zm,{})]})}const Am=Object.freeze(Object.defineProperty({__proto__:null,default:Lm},Symbol.toStringTag,{value:"Module"})),ca=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:y("w-full caption-bottom text-sm",s),...n})}));ca.displayName="Table";const da=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:y("[&_tr]:border-b",s),...n}));da.displayName="TableHeader";const ma=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:y("[&_tr:last-child]:border-0",s),...n}));ma.displayName="TableBody";const $m=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:y("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));$m.displayName="TableFooter";const vs=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:y("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));vs.displayName="TableRow";const ua=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:y("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));ua.displayName="TableHead";const $s=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:y("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));$s.displayName="TableCell";const qm=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:y("mt-4 text-sm text-muted-foreground",s),...n}));qm.displayName="TableCaption";function Km({table:s}){const[n,a]=m.useState("");m.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const l=r=>{const c=parseInt(r);!isNaN(c)&&c>=1&&c<=s.getPageCount()?s.setPageIndex(c-1):a((s.getState().pagination.pageIndex+1).toString())};return e.jsxs("div",{className:"flex flex-col-reverse gap-4 px-2 py-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex-1 text-sm text-muted-foreground",children:["已选择 ",s.getFilteredSelectedRowModel().rows.length," 项, 共"," ",s.getFilteredRowModel().rows.length," 项"]}),e.jsxs("div",{className:"flex flex-col-reverse items-center gap-4 sm:flex-row sm:gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"每页显示"}),e.jsxs(W,{value:`${s.getState().pagination.pageSize}`,onValueChange:r=>{s.setPageSize(Number(r))},children:[e.jsx(B,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:s.getState().pagination.pageSize})}),e.jsx(G,{side:"top",children:[10,20,30,40,50,100,500].map(r=>e.jsx($,{value:`${r}`,children:r},r))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:"第"}),e.jsx(T,{type:"text",value:n,onChange:r=>a(r.target.value),onBlur:r=>l(r.target.value),onKeyDown:r=>{r.key==="Enter"&&l(r.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsxs("span",{children:["页,共 ",s.getPageCount()," 页"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到第一页"}),e.jsx(ei,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"上一页"}),e.jsx(_n,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"下一页"}),e.jsx(ta,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"跳转到最后一页"}),e.jsx(si,{className:"h-4 w-4"})]})]})]})]})}function Ye({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:u,showPagination:x=!0,isLoading:o=!1}){const d=m.useRef(null),p=s.getAllColumns().filter(_=>_.getIsPinned()==="left"),D=s.getAllColumns().filter(_=>_.getIsPinned()==="right"),V=_=>p.slice(0,_).reduce((k,b)=>k+(b.getSize()??0),0),f=_=>D.slice(_+1).reduce((k,b)=>k+(b.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:d,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(ca,{children:[e.jsx(da,{children:s.getHeaderGroups().map(_=>e.jsx(vs,{className:"hover:bg-transparent",children:_.headers.map((k,b)=>{const w=k.column.getIsPinned()==="left",S=k.column.getIsPinned()==="right",C=w?V(p.indexOf(k.column)):void 0,E=S?f(D.indexOf(k.column)):void 0;return e.jsx(ua,{colSpan:k.colSpan,style:{width:k.getSize(),...w&&{left:C},...S&&{right:E}},className:y("h-11 bg-card px-4 text-muted-foreground",(w||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",w&&"before:right-0",S&&"before:left-0"]),children:k.isPlaceholder?null:bt(k.column.columnDef.header,k.getContext())},k.id)})},_.id))}),e.jsx(ma,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((_,k)=>e.jsx(vs,{"data-state":_.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:b=>l?.(b,k),onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:b=>u?.(b,k),children:_.getVisibleCells().map((b,w)=>{const S=b.column.getIsPinned()==="left",C=b.column.getIsPinned()==="right",E=S?V(p.indexOf(b.column)):void 0,z=C?f(D.indexOf(b.column)):void 0;return e.jsx($s,{style:{width:b.column.getSize(),...S&&{left:E},...C&&{right:z}},className:y("bg-card",(S||C)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",S&&"before:right-0",C&&"before:left-0"]),children:bt(b.column.columnDef.cell,b.getContext())},b.id)})},_.id)):e.jsx(vs,{children:e.jsx($s,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:"暂无数据"})})})]})})}),x&&e.jsx(Km,{table:s})]})}const Hm=s=>h.object({id:h.number().nullable(),name:h.string().min(2,s("form.validation.name.min")).max(30,s("form.validation.name.max")),icon:h.string().optional().nullable(),notify_domain:h.string().refine(a=>!a||/^https?:\/\/\S+/.test(a),s("form.validation.notify_domain.url")).optional().nullable(),handling_fee_fixed:h.coerce.number().min(0).optional().nullable(),handling_fee_percent:h.coerce.number().min(0).max(100).optional().nullable(),payment:h.string().min(1,s("form.validation.payment.required")),config:h.record(h.string(),h.string())}),Oa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function vr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Oa}){const{t:r}=I("payment"),[c,i]=m.useState(!1),[u,x]=m.useState(!1),[o,d]=m.useState([]),[p,D]=m.useState([]),V=Hm(r),f=ce({resolver:ue(V),defaultValues:l,mode:"onChange"}),_=f.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:w}=await Hc();d(w)})()},[c]),m.useEffect(()=>{if(!_||!c)return;(async()=>{const w={payment:_,...a==="edit"&&{id:Number(f.getValues("id"))}};Uc(w).then(({data:S})=>{D(S);const C=S.reduce((E,z)=>(z.field_name&&(E[z.field_name]=z.value??""),E),{});f.setValue("config",C)})})()},[_,c,f,a]);const k=async b=>{x(!0);try{(await Bc(b)).data&&(q.success(r("form.messages.success")),f.reset(Oa),s(),i(!1))}finally{x(!1)}};return e.jsxs(ge,{open:c,onOpenChange:i,children:[e.jsx(Fe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ne,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(xe,{...f,children:e.jsxs("form",{onSubmit:f.handleSubmit(k),className:"space-y-4",children:[e.jsx(j,{control:f.control,name:"name",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:r("form.fields.name.placeholder"),...b})}),e.jsx(F,{children:r("form.fields.name.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"icon",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.icon.label")}),e.jsx(N,{children:e.jsx(T,{...b,value:b.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(F,{children:r("form.fields.icon.description")}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"notify_domain",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.notify_domain.label")}),e.jsx(N,{children:e.jsx(T,{...b,value:b.value||"",placeholder:r("form.fields.notify_domain.placeholder")})}),e.jsx(F,{children:r("form.fields.notify_domain.description")}),e.jsx(P,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(j,{control:f.control,name:"handling_fee_percent",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(N,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"handling_fee_fixed",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(N,{children:e.jsx(T,{type:"number",...b,value:b.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(P,{})]})})]}),e.jsx(j,{control:f.control,name:"payment",render:({field:b})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.payment.label")}),e.jsxs(W,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(N,{children:e.jsx(B,{children:e.jsx(Y,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(G,{children:o.map(w=>e.jsx($,{value:w,children:w},w))})]}),e.jsx(F,{children:r("form.fields.payment.description")}),e.jsx(P,{})]})}),p.length>0&&e.jsx("div",{className:"space-y-4",children:p.map(b=>e.jsx(j,{control:f.control,name:`config.${b.field_name}`,render:({field:w})=>e.jsxs(g,{children:[e.jsx(v,{children:b.label}),e.jsx(N,{children:e.jsx(T,{...w,value:w.value||""})}),e.jsx(P,{})]})},b.field_name))}),e.jsxs(Me,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",disabled:u,children:r("form.buttons.submit")})]})]})})]})]})}function M({column:s,title:n,tooltip:a,className:l}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(R,{variant:"ghost",size:"default",className:y("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",l),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),a&&e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(ka,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(te,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(Ut,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Bt,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ti,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:y("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",l),children:[e.jsx("span",{children:n}),a&&e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsx(ka,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(te,{children:a})]})})]})}const Um=ai,Bm=ni,Gm=ri,br=m.forwardRef(({className:s,...n},a)=>e.jsx(En,{className:y("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...n,ref:a}));br.displayName=En.displayName;const yr=m.forwardRef(({className:s,...n},a)=>e.jsxs(Gm,{children:[e.jsx(br,{}),e.jsx(Vn,{ref:a,className:y("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...n})]}));yr.displayName=Vn.displayName;const Nr=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col space-y-2 text-center sm:text-left",s),...n});Nr.displayName="AlertDialogHeader";const _r=({className:s,...n})=>e.jsx("div",{className:y("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});_r.displayName="AlertDialogFooter";const wr=m.forwardRef(({className:s,...n},a)=>e.jsx(In,{ref:a,className:y("text-lg font-semibold",s),...n}));wr.displayName=In.displayName;const Cr=m.forwardRef(({className:s,...n},a)=>e.jsx(Fn,{ref:a,className:y("text-sm text-muted-foreground",s),...n}));Cr.displayName=Fn.displayName;const Sr=m.forwardRef(({className:s,...n},a)=>e.jsx(Mn,{ref:a,className:y(qs(),s),...n}));Sr.displayName=Mn.displayName;const kr=m.forwardRef(({className:s,...n},a)=>e.jsx(On,{ref:a,className:y(qs({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));kr.displayName=On.displayName;function Je({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:u}){return e.jsxs(Um,{children:[e.jsx(Bm,{asChild:!0,children:n}),e.jsxs(yr,{className:y("sm:max-w-[425px]",u),children:[e.jsxs(Nr,{children:[e.jsx(wr,{children:a}),e.jsx(Cr,{children:l})]}),e.jsxs(_r,{children:[e.jsx(kr,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r})}),e.jsx(Sr,{asChild:!0,children:e.jsx(R,{variant:i,onClick:s,children:c})})]})]})]})}const Dr=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),Wm=({refetch:s,isSortMode:n=!1})=>{const{t:a}=I("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Pt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(M,{column:l,title:a("table.columns.id")}),cell:({row:l})=>e.jsx(K,{variant:"outline",children:l.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:l})=>e.jsx(M,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(H,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await Wc({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(M,{column:l,title:a("table.columns.name")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:l})=>e.jsx(M,{column:l,title:a("table.columns.payment")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:l.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:l})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(M,{column:l,title:a("table.columns.notify_url")}),e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{className:"ml-1",children:e.jsx(Dr,{className:"h-4 w-4"})}),e.jsx(te,{children:a("table.columns.notify_url_tooltip")})]})})]}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:l.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:l})=>e.jsx(M,{className:"justify-end",column:l,title:a("table.columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(vr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("table.actions.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await Gc({id:l.original.id});r&&s()},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:a("table.actions.delete.title")})]})})]}),size:100}]};function Ym({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=I("payment"),c=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:r("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vr,{refetch:n}),e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:i=>s.getColumn("name")?.setFilterValue(i.target.value),className:"h-8 w-[250px]"}),c&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Oe,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Jm(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[i,u]=m.useState([]),[x,o]=m.useState({"drag-handle":!1}),[d,p]=m.useState({pageSize:20,pageIndex:0}),{refetch:D}=se({queryKey:["paymentList"],queryFn:async()=>{const{data:b}=await Kc();return u(b?.map(w=>({...w,enable:!!w.enable}))||[]),b}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const V=(b,w)=>{r&&(b.dataTransfer.setData("text/plain",w.toString()),b.currentTarget.classList.add("opacity-50"))},f=(b,w)=>{if(!r)return;b.preventDefault(),b.currentTarget.classList.remove("bg-muted");const S=parseInt(b.dataTransfer.getData("text/plain"));if(S===w)return;const C=[...i],[E]=C.splice(S,1);C.splice(w,0,E),u(C)},_=async()=>{r?Yc({ids:i.map(b=>b.id)}).then(()=>{D(),c(!1),q.success("排序保存成功")}):c(!0)},k=ze({data:i,columns:Wm({refetch:D,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:Le(),getFilteredRowModel:Ue(),getPaginationRowModel:Be(),getSortedRowModel:Ge(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(Ye,{table:k,toolbar:b=>e.jsx(Ym,{table:b,refetch:D,saveOrder:_,isSortMode:r}),draggable:r,onDragStart:V,onDragEnd:b=>b.currentTarget.classList.remove("opacity-50"),onDragOver:b=>{b.preventDefault(),b.currentTarget.classList.add("bg-muted")},onDragLeave:b=>b.currentTarget.classList.remove("bg-muted"),onDrop:f,showPagination:!r})}function Qm(){const{t:s}=I("payment");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Pe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{children:[e.jsx("header",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("section",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Jm,{})})]})]})}const Zm=Object.freeze(Object.defineProperty({__proto__:null,default:Qm},Symbol.toStringTag,{value:"Module"})),Xm=(s,n)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(T,{placeholder:s.placeholder,...n});break;case"textarea":a=e.jsx(Cs,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:y(qs({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:a=null;break}return a};function eu({themeKey:s,themeInfo:n}){const{t:a}=I("theme"),[l,r]=m.useState(!1),[c,i]=m.useState(!1),[u,x]=m.useState(!1),o=ce({defaultValues:n.configs.reduce((D,V)=>(D[V.field_name]="",D),{})}),d=async()=>{i(!0),Tc(s).then(({data:D})=>{Object.entries(D).forEach(([V,f])=>{o.setValue(V,f)})}).finally(()=>{i(!1)})},p=async D=>{x(!0),Pc(s,D).then(()=>{q.success(a("config.success")),r(!1)}).finally(()=>{x(!1)})};return e.jsxs(ge,{open:l,onOpenChange:D=>{r(D),D?d():o.reset()},children:[e.jsx(Fe,{asChild:!0,children:e.jsx(R,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(he,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:a("config.title",{name:n.name})}),e.jsx(Te,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(na,{className:"h-6 w-6 animate-spin"})}):e.jsx(xe,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(p),className:"space-y-4",children:[n.configs.map(D=>e.jsx(j,{control:o.control,name:D.field_name,render:({field:V})=>e.jsxs(g,{children:[e.jsx(v,{children:D.label}),e.jsx(N,{children:Xm(D,V)}),e.jsx(P,{})]})},D.field_name)),e.jsxs(Me,{className:"mt-6 gap-2",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(R,{type:"submit",loading:u,children:a("config.save")})]})]})})]})]})}function su(){const{t:s}=I("theme"),[n,a]=m.useState(null),[l,r]=m.useState(!1),[c,i]=m.useState(!1),[u,x]=m.useState(!1),[o,d]=m.useState(null),p=m.useRef(null),[D,V]=m.useState(0),{data:f,isLoading:_,refetch:k}=se({queryKey:["themeList"],queryFn:async()=>{const{data:A}=await Dc();return A}}),b=async A=>{a(A),Vc({frontend_theme:A}).then(()=>{q.success("主题切换成功"),k()}).finally(()=>{a(null)})},w=async A=>{if(!A.name.endsWith(".zip")){q.error(s("upload.error.format"));return}r(!0),Rc(A).then(()=>{q.success("主题上传成功"),i(!1),k()}).finally(()=>{r(!1),p.current&&(p.current.value="")})},S=A=>{A.preventDefault(),A.stopPropagation(),A.type==="dragenter"||A.type==="dragover"?x(!0):A.type==="dragleave"&&x(!1)},C=A=>{A.preventDefault(),A.stopPropagation(),x(!1),A.dataTransfer.files&&A.dataTransfer.files[0]&&w(A.dataTransfer.files[0])},E=()=>{o&&V(A=>A===0?o.images.length-1:A-1)},z=()=>{o&&V(A=>A===o.images.length-1?0:A+1)},Z=(A,X)=>{V(0),d({name:A,images:X})};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Pe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(R,{onClick:()=>i(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Ht,{className:"mr-2 h-4 w-4"}),s("upload.button")]})]})]}),e.jsx("section",{className:"grid gap-6 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3",children:_?e.jsxs(e.Fragment,{children:[e.jsx(za,{}),e.jsx(za,{})]}):f?.themes&&Object.entries(f.themes).map(([A,X])=>e.jsx(He,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:X.background_url?`url(${X.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:y("relative z-10 h-full transition-colors",X.background_url?"group-hover:from-background/98 bg-gradient-to-t from-background/95 via-background/80 to-background/60 backdrop-blur-[1px] group-hover:via-background/90 group-hover:to-background/70":"bg-background"),children:[!!X.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(Je,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(A===f?.active){q.error(s("card.delete.error.active"));return}a(A),Ec(A).then(()=>{q.success("主题删除成功"),k()}).finally(()=>{a(null)})},children:e.jsx(R,{disabled:n===A,loading:n===A,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(cs,{className:"h-4 w-4"})})})}),e.jsxs(ss,{children:[e.jsx(bs,{children:X.name}),e.jsx(tt,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:X.description}),X.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:X.version})})]})})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Z(X.name,X.images),children:e.jsx(li,{className:"h-4 w-4"})}),e.jsx(eu,{themeKey:A,themeInfo:X}),e.jsx(R,{onClick:()=>b(A),disabled:n===A||A===f.active,loading:n===A,variant:A===f.active?"secondary":"default",children:A===f.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},A))}),e.jsx(ge,{open:c,onOpenChange:i,children:e.jsxs(he,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(je,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:y("relative mt-4 flex h-64 flex-col items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25 px-5 py-10 text-center transition-colors",u&&"border-primary/50 bg-muted/50"),onDragEnter:S,onDragLeave:S,onDragOver:S,onDrop:C,children:[e.jsx("input",{type:"file",ref:p,className:"hidden",accept:".zip",onChange:A=>{const X=A.target.files?.[0];X&&w(X)}}),l?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(Ht,{className:"h-6 w-6 text-muted-foreground/50"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium",children:[s("upload.dragText")," ",e.jsx("button",{type:"button",onClick:()=>p.current?.click(),className:"mx-1 text-primary hover:underline",children:s("upload.clickText")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("upload.supportText")})]})]})})]})]})}),e.jsx(ge,{open:!!o,onOpenChange:A=>{A||(d(null),V(0))},children:e.jsxs(he,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(je,{children:[o?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:o&&s("preview.imageCount",{current:D+1,total:o.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:o?.images[D]&&e.jsx("img",{src:o.images[D],alt:`${o.name} 预览图 ${D+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:E,children:e.jsx(oi,{className:"h-4 w-4"})}),e.jsx(R,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:z,children:e.jsx(ii,{className:"h-4 w-4"})})]})]}),o&&o.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:o.images.map((A,X)=>e.jsx("button",{onClick:()=>V(X),className:y("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",D===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:A,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function za(){return e.jsxs(He,{children:[e.jsxs(ss,{children:[e.jsx(Ve,{className:"h-6 w-[200px]"}),e.jsx(Ve,{className:"h-4 w-[300px]"})]}),e.jsxs(ts,{className:"flex items-center justify-end space-x-3",children:[e.jsx(Ve,{className:"h-10 w-[100px]"}),e.jsx(Ve,{className:"h-10 w-[100px]"})]})]})}const tu=Object.freeze(Object.defineProperty({__proto__:null,default:su},Symbol.toStringTag,{value:"Module"})),xa=m.forwardRef(({className:s,value:n,onChange:a,...l},r)=>{const[c,i]=m.useState("");m.useEffect(()=>{if(c.includes(",")){const x=new Set([...n,...c.split(",").map(o=>o.trim())]);a(Array.from(x)),i("")}},[c,a,n]);const u=()=>{if(c){const x=new Set([...n,c]);a(Array.from(x)),i("")}};return e.jsxs("div",{className:y(" has-[:focus-visible]:outline-none has-[:focus-visible]:ring-1 has-[:focus-visible]:ring-neutral-950 dark:has-[:focus-visible]:ring-neutral-300 flex w-full flex-wrap gap-2 rounded-md border border-input shadow-sm px-3 py-2 text-sm ring-offset-white disabled:cursor-not-allowed disabled:opacity-50",s),children:[n.map(x=>e.jsxs(K,{variant:"secondary",children:[x,e.jsx(J,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(n.filter(o=>o!==x))},children:e.jsx(Gt,{className:"w-3"})})]},x)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:c,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Enter"||x.key===","?(x.preventDefault(),u()):x.key==="Backspace"&&c.length===0&&n.length>0&&(x.preventDefault(),a(n.slice(0,-1)))},...l,ref:r})]})});xa.displayName="InputTags";const au=h.object({id:h.number().nullable(),title:h.string().min(1).max(250),content:h.string().min(1),show:h.boolean(),tags:h.array(h.string()),img_url:h.string().nullable()}),nu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Tr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=nu}){const{t:r}=I("notice"),[c,i]=m.useState(!1),u=ce({resolver:ue(au),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new ra({html:!0});return e.jsx(xe,{...u,children:e.jsxs(ge,{onOpenChange:i,open:c,children:[e.jsx(Fe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ne,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(he,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(j,{control:u.control,name:"title",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(N,{children:e.jsx(T,{placeholder:r("form.fields.title.placeholder"),...o})})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"content",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.content.label")}),e.jsx(N,{children:e.jsx(la,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"img_url",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(T,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"tags",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.fields.tags.label")}),e.jsx(N,{children:e.jsx(xa,{value:o.value,onChange:o.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(P,{})]})}),e.jsxs(Me,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",onClick:o=>{o.preventDefault(),u.handleSubmit(async d=>{Qc(d).then(({data:p})=>{p&&(q.success(r("form.buttons.success")),s(),i(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function ru({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=I("notice"),c=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between space-x-2 ",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[!l&&e.jsx(Tr,{refetch:n}),!l&&e.jsx(T,{placeholder:r("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:i=>s.getColumn("title")?.setFilterValue(i.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),c&&!l&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Oe,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const lu=s=>{const{t:n}=I("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(ci,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(M,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(K,{variant:"outline",className:"font-mono",children:a.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:a})=>e.jsx(M,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(H,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{const{data:l}=await Xc({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(M,{column:a,title:n("table.columns.title")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:a.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:a})=>e.jsx(M,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(Tr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),type:"edit",defaultFormValues:a.original}),e.jsx(Je,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{Zc({id:a.original.id}).then(()=>{q.success(n("table.actions.delete.success")),s()})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("table.actions.delete.title")})]})})]}),size:100}]};function ou(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[i,u]=m.useState([]),[x,o]=m.useState(!1),[d,p]=m.useState({}),[D,V]=m.useState({pageSize:50,pageIndex:0}),[f,_]=m.useState([]),{refetch:k}=se({queryKey:["notices"],queryFn:async()=>{const{data:E}=await Jc();return _(E),E}});m.useEffect(()=>{l({"drag-handle":x,content:!x,created_at:!x,actions:!x}),V({pageSize:x?99999:50,pageIndex:0})},[x]);const b=(E,z)=>{x&&(E.dataTransfer.setData("text/plain",z.toString()),E.currentTarget.classList.add("opacity-50"))},w=(E,z)=>{if(!x)return;E.preventDefault(),E.currentTarget.classList.remove("bg-muted");const Z=parseInt(E.dataTransfer.getData("text/plain"));if(Z===z)return;const A=[...f],[X]=A.splice(Z,1);A.splice(z,0,X),_(A)},S=async()=>{if(!x){o(!0);return}Td(f.map(E=>E.id)).then(()=>{q.success("排序保存成功"),o(!1),k()}).finally(()=>{o(!1)})},C=ze({data:f??[],columns:lu(k),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:D},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:p,onPaginationChange:V,getCoreRowModel:Le(),getFilteredRowModel:Ue(),getPaginationRowModel:Be(),getSortedRowModel:Ge(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:C,toolbar:E=>e.jsx(ru,{table:E,refetch:k,saveOrder:S,isSortMode:x}),draggable:x,onDragStart:b,onDragEnd:E=>E.currentTarget.classList.remove("opacity-50"),onDragOver:E=>{E.preventDefault(),E.currentTarget.classList.add("bg-muted")},onDragLeave:E=>E.currentTarget.classList.remove("bg-muted"),onDrop:w,showPagination:!x})})}function iu(){const{t:s}=I("notice");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Pe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(ou,{})})]})]})}const cu=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),du=h.object({id:h.number().nullable(),language:h.string().max(250),category:h.string().max(250),title:h.string().min(1).max(250),body:h.string().min(1),show:h.boolean()}),mu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Pr({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=mu}){const{t:r}=I("knowledge"),[c,i]=m.useState(!1),u=ce({resolver:ue(du),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new ra({html:!0});return m.useEffect(()=>{c&&l.id&&sd(l.id).then(({data:o})=>{u.reset(o)})},[l.id,u,c]),e.jsxs(ge,{onOpenChange:i,open:c,children:[e.jsx(Fe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ne,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(he,{className:"sm:max-w-[1025px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(xe,{...u,children:[e.jsx(j,{control:u.control,name:"title",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(N,{children:e.jsx(T,{placeholder:r("form.titlePlaceholder"),...o})})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"category",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(N,{children:e.jsx(T,{placeholder:r("form.categoryPlaceholder"),...o})})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"language",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.language")}),e.jsx(N,{children:e.jsxs(W,{value:o.value,onValueChange:o.onChange,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:r("form.languagePlaceholder")})}),e.jsx(G,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx($,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(j,{control:u.control,name:"body",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.content")}),e.jsx(N,{children:e.jsx(la,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"show",render:({field:o})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(N,{children:e.jsx(H,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(P,{})]})}),e.jsxs(Me,{children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{u.handleSubmit(o=>{td(o).then(({data:d})=>{d&&(u.reset(),q.success(r("messages.operationSuccess")),i(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function uu({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(be,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(_s,{children:[e.jsx(Vs,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Is,{children:"No results found."}),e.jsx(Ie,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(_e,{onSelect:()=>{i?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",i?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ps,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Hs,{}),e.jsx(Ie,{children:e.jsx(_e,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function xu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const r=s.getState().columnFilters.length>0,{t:c}=I("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[l?e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pr,{refreshData:n}),e.jsx(T,{placeholder:c("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:i=>s.getColumn("title")?.setFilterValue(i.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(uu,{column:s.getColumn("category"),title:c("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(i=>i.getValue("category")))).map(i=>({label:i,value:i}))}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Oe,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const hu=({refetch:s,isSortMode:n=!1})=>{const{t:a}=I("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Pt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(M,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(K,{variant:"outline",className:"justify-center",children:l.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:l})=>e.jsx(M,{column:l,title:a("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(H,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{nd({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(M,{column:l,title:a("columns.title")}),cell:({row:l})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:l.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:l})=>e.jsx(M,{column:l,title:a("columns.category")}),cell:({row:l})=>e.jsx(K,{variant:"secondary",className:"max-w-[180px] truncate",children:l.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:l})=>e.jsx(M,{className:"justify-end",column:l,title:a("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(Pr,{refreshData:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:a("form.edit")})]}),type:"edit",defaultFormValues:l.original}),e.jsx(Je,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{ad({id:l.original.id}).then(({data:r})=>{r&&(q.success(a("messages.operationSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:a("messages.deleteButton")})]})})]}),size:100}]};function fu(){const[s,n]=m.useState([]),[a,l]=m.useState([]),[r,c]=m.useState(!1),[i,u]=m.useState([]),[x,o]=m.useState({"drag-handle":!1}),[d,p]=m.useState({pageSize:20,pageIndex:0}),{refetch:D,isLoading:V,data:f}=se({queryKey:["knowledge"],queryFn:async()=>{const{data:S}=await ed();return u(S||[]),S}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const _=(S,C)=>{r&&(S.dataTransfer.setData("text/plain",C.toString()),S.currentTarget.classList.add("opacity-50"))},k=(S,C)=>{if(!r)return;S.preventDefault(),S.currentTarget.classList.remove("bg-muted");const E=parseInt(S.dataTransfer.getData("text/plain"));if(E===C)return;const z=[...i],[Z]=z.splice(E,1);z.splice(C,0,Z),u(z)},b=async()=>{r?rd({ids:i.map(S=>S.id)}).then(()=>{D(),c(!1),q.success("排序保存成功")}):c(!0)},w=ze({data:i,columns:hu({refetch:D,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:Le(),getFilteredRowModel:Ue(),getPaginationRowModel:Be(),getSortedRowModel:Ge(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:w,toolbar:S=>e.jsx(xu,{table:S,refetch:D,saveOrder:b,isSortMode:r}),draggable:r,onDragStart:_,onDragEnd:S=>S.currentTarget.classList.remove("opacity-50"),onDragOver:S=>{S.preventDefault(),S.currentTarget.classList.add("bg-muted")},onDragLeave:S=>S.currentTarget.classList.remove("bg-muted"),onDrop:k,showPagination:!r})}function pu(){const{t:s}=I("knowledge");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Pe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight mb-2",children:s("title")}),e.jsx("p",{className:"text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(fu,{})})]})]})}const gu=Object.freeze(Object.defineProperty({__proto__:null,default:pu},Symbol.toStringTag,{value:"Module"}));function ju(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function At(s,n){if(s.length===0)return{};if(!n)return{"":s};const a={};return s.forEach(l=>{const r=l[n]||"";a[r]||(a[r]=[]),a[r].push(l)}),a}function vu(s,n){const a=JSON.parse(JSON.stringify(s));for(const[l,r]of Object.entries(a))a[l]=r.filter(c=>!n.find(i=>i.value===c.value));return a}function bu(s,n){for(const[,a]of Object.entries(s))if(a.some(l=>n.find(r=>r.value===l.value)))return!0;return!1}const Rr=m.forwardRef(({className:s,...n},a)=>di(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:y("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Rr.displayName="CommandEmpty";const lt=m.forwardRef(({value:s,onChange:n,placeholder:a,defaultOptions:l=[],options:r,delay:c,onSearch:i,loadingIndicator:u,emptyIndicator:x,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:p,disabled:D,groupBy:V,className:f,badgeClassName:_,selectFirstItem:k=!0,creatable:b=!1,triggerSearchOnFocus:w=!1,commandProps:S,inputProps:C,hideClearAllButton:E=!1},z)=>{const Z=m.useRef(null),[A,X]=m.useState(!1),Us=m.useRef(!1),[va,ba]=m.useState(!1),[ee,Bs]=m.useState(s||[]),[Ss,ya]=m.useState(At(l,V)),[hs,Mt]=m.useState(""),Gs=ju(hs,c||500);m.useImperativeHandle(z,()=>({selectedValue:[...ee],input:Z.current,focus:()=>Z.current?.focus()}),[ee]);const mt=m.useCallback(U=>{const ae=ee.filter(De=>De.value!==U.value);Bs(ae),n?.(ae)},[n,ee]),el=m.useCallback(U=>{const ae=Z.current;ae&&((U.key==="Delete"||U.key==="Backspace")&&ae.value===""&&ee.length>0&&(ee[ee.length-1].fixed||mt(ee[ee.length-1])),U.key==="Escape"&&ae.blur())},[mt,ee]);m.useEffect(()=>{s&&Bs(s)},[s]),m.useEffect(()=>{if(!r||i)return;const U=At(r||[],V);JSON.stringify(U)!==JSON.stringify(Ss)&&ya(U)},[l,r,V,i,Ss]),m.useEffect(()=>{const U=async()=>{ba(!0);const De=await i?.(Gs);ya(At(De||[],V)),ba(!1)};(async()=>{!i||!A||(w&&await U(),Gs&&await U())})()},[Gs,V,A,w]);const sl=()=>{if(!b||bu(Ss,[{value:hs,label:hs}])||ee.find(ae=>ae.value===hs))return;const U=e.jsx(_e,{value:hs,className:"cursor-pointer",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onSelect:ae=>{if(ee.length>=o){d?.(ee.length);return}Mt("");const De=[...ee,{value:ae,label:ae}];Bs(De),n?.(De)},children:`Create "${hs}"`});if(!i&&hs.length>0||i&&Gs.length>0&&!va)return U},tl=m.useCallback(()=>{if(x)return i&&!b&&Object.keys(Ss).length===0?e.jsx(_e,{value:"-",disabled:!0,children:x}):e.jsx(Rr,{children:x})},[b,x,i,Ss]),al=m.useMemo(()=>vu(Ss,ee),[Ss,ee]),nl=m.useCallback(()=>{if(S?.filter)return S.filter;if(b)return(U,ae)=>U.toLowerCase().includes(ae.toLowerCase())?1:-1},[b,S?.filter]),rl=m.useCallback(()=>{const U=ee.filter(ae=>ae.fixed);Bs(U),n?.(U)},[n,ee]);return e.jsxs(_s,{...S,onKeyDown:U=>{el(U),S?.onKeyDown?.(U)},className:y("h-auto overflow-visible bg-transparent",S?.className),shouldFilter:S?.shouldFilter!==void 0?S.shouldFilter:!i,filter:nl(),children:[e.jsx("div",{className:y("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":ee.length!==0,"cursor-text":!D&&ee.length!==0},f),onClick:()=>{D||Z.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(U=>e.jsxs(K,{className:y("data-[disabled]:bg-muted-foreground data-[disabled]:text-muted data-[disabled]:hover:bg-muted-foreground","data-[fixed]:bg-muted-foreground data-[fixed]:text-muted data-[fixed]:hover:bg-muted-foreground",_),"data-fixed":U.fixed,"data-disabled":D||void 0,children:[U.label,e.jsx("button",{className:y("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(D||U.fixed)&&"hidden"),onKeyDown:ae=>{ae.key==="Enter"&&mt(U)},onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:()=>mt(U),children:e.jsx(Gt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},U.value)),e.jsx(Se.Input,{...C,ref:Z,value:hs,disabled:D,onValueChange:U=>{Mt(U),C?.onValueChange?.(U)},onBlur:U=>{Us.current===!1&&X(!1),C?.onBlur?.(U)},onFocus:U=>{X(!0),w&&i?.(Gs),C?.onFocus?.(U)},placeholder:p&&ee.length!==0?"":a,className:y("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":p,"px-3 py-2":ee.length===0,"ml-1":ee.length!==0},C?.className)}),e.jsx("button",{type:"button",onClick:rl,className:y((E||D||ee.length<1||ee.filter(U=>U.fixed).length===ee.length)&&"hidden"),children:e.jsx(Gt,{})})]})}),e.jsx("div",{className:"relative",children:A&&e.jsx(ws,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Us.current=!1},onMouseEnter:()=>{Us.current=!0},onMouseUp:()=>{Z.current?.focus()},children:va?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[tl(),sl(),!k&&e.jsx(_e,{value:"-",className:"hidden"}),Object.entries(al).map(([U,ae])=>e.jsx(Ie,{heading:U,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ae.map(De=>e.jsx(_e,{value:De.value,disabled:De.disable,onMouseDown:Ws=>{Ws.preventDefault(),Ws.stopPropagation()},onSelect:()=>{if(ee.length>=o){d?.(ee.length);return}Mt("");const Ws=[...ee,De];Bs(Ws),n?.(Ws)},className:y("cursor-pointer",De.disable&&"cursor-default text-muted-foreground"),children:De.label},De.value))})},U))]})})})]})});lt.displayName="MultipleSelector";const yu=s=>h.object({id:h.number().optional(),name:h.string().min(2,s("messages.nameValidation.min")).max(50,s("messages.nameValidation.max")).regex(/^[a-zA-Z0-9\u4e00-\u9fa5_-]+$/,s("messages.nameValidation.pattern"))});function Ft({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=I("group"),c=ce({resolver:ue(yu(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1),[x,o]=m.useState(!1),d=async p=>{o(!0),Lc(p).then(()=>{q.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{o(!1)})};return e.jsxs(ge,{open:i,onOpenChange:u,children:[e.jsx(Fe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ne,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(xe,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(j,{control:c.control,name:"name",render:({field:p})=>e.jsxs(g,{children:[e.jsx(v,{children:r("form.name")}),e.jsx(N,{children:e.jsx(T,{placeholder:r("form.namePlaceholder"),...p,className:"w-full"})}),e.jsx(F,{children:r("form.nameDescription")}),e.jsx(P,{})]})}),e.jsxs(Me,{className:"gap-2",children:[e.jsx(dt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(R,{type:"submit",disabled:x||!c.formState.isValid,children:[x&&e.jsx(na,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Er=m.createContext(void 0);function Nu({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[i,u]=m.useState(ye.Shadowsocks);return e.jsx(Er.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:i,setServerType:u,refetch:n},children:s})}function Vr(){const s=m.useContext(Er);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function $t({dialogTrigger:s,value:n,setValue:a,templateType:l}){const{t:r}=I("server");m.useEffect(()=>{console.log(n)},[n]);const[c,i]=m.useState(!1),[u,x]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,d]=m.useState(null),p=b=>{if(!b)return null;try{const w=JSON.parse(b);return typeof w!="object"||w===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},D={tcp:{label:"TCP",content:{acceptProxyProtocol:!1,header:{type:"none"}}},"tcp-http":{label:"TCP + HTTP",content:{acceptProxyProtocol:!1,header:{type:"http",request:{version:"1.1",method:"GET",path:["/"],headers:{Host:["www.example.com"]}},response:{version:"1.1",status:"200",reason:"OK"}}}},grpc:{label:"gRPC",content:{serviceName:"GunService"}},ws:{label:"WebSocket",content:{path:"/",headers:{Host:"v2ray.com"}}}},V=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},f=()=>{const b=p(u||"");if(b){q.error(b);return}try{if(!u){a(null),i(!1);return}a(JSON.parse(u)),i(!1)}catch{q.error(r("network_settings.errors.save_failed"))}},_=b=>{x(b),d(p(b))},k=b=>{const w=D[b];if(w){const S=JSON.stringify(w.content,null,2);x(S),d(null)}};return m.useEffect(()=>{c&&console.log(n)},[c,n]),m.useEffect(()=>{c&&n&&Object.keys(n).length>0&&x(JSON.stringify(n,null,2))},[c,n]),e.jsxs(ge,{open:c,onOpenChange:b=>{!b&&c&&f(),i(b)},children:[e.jsx(Fe,{asChild:!0,children:s??e.jsx(J,{variant:"link",children:r("network_settings.edit_protocol")})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(je,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[V().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:V().map(b=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>k(b),children:r("network_settings.use_template",{template:D[b].label})},b))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Cs,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:u,placeholder:V().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:b=>_(b.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Me,{className:"gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>i(!1),children:r("common.cancel")}),e.jsx(J,{onClick:f,disabled:!!o,children:r("common.confirm")})]})]})]})}function Nh(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const _u={},wu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"})),_h=wi(wu),La=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Cu=()=>{try{const s=mi.box.keyPair(),n=La(Da.encodeBase64(s.secretKey)),a=La(Da.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Su=()=>{try{return Cu()}catch(s){throw console.error("Error generating key pair:",s),s}},ku=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("").substring(0,s)},Du=()=>{const s=Math.floor(Math.random()*8)*2+2;return ku(s)},Tu=h.object({cipher:h.string().default("aes-128-gcm"),obfs:h.string().default("0"),obfs_settings:h.object({path:h.string().default(""),host:h.string().default("")}).default({})}),Pu=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({})}),Ru=h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({})}),Eu=h.object({version:h.coerce.number().default(2),alpn:h.string().default("h2"),obfs:h.object({open:h.coerce.boolean().default(!1),type:h.string().default("salamander"),password:h.string().default("")}).default({}),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),bandwidth:h.object({up:h.string().default(""),down:h.string().default("")}).default({})}),Vu=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({}),reality_settings:h.object({server_port:h.coerce.number().default(443),server_name:h.string().default(""),allow_insecure:h.boolean().default(!1),public_key:h.string().default(""),private_key:h.string().default(""),short_id:h.string().default("")}).default({}),network:h.string().default("tcp"),network_settings:h.record(h.any()).default({}),flow:h.string().default("")}),rs={shadowsocks:{schema:Tu,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]},vmess:{schema:Pu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Ru,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Eu,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Vu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"},{value:"kcp",label:"mKCP"},{value:"httpupgrade",label:"HttpUpgrade"},{value:"xhttp",label:"XHTTP"}],flowOptions:["none","xtls-rprx-direct","xtls-rprx-splice","xtls-rprx-vision"]}},Iu=({serverType:s,value:n,onChange:a})=>{const{t:l}=I("server"),r=s?rs[s]:null,c=r?.schema||h.record(h.any()),i=s?c.parse({}):{},u=ce({resolver:ue(c),defaultValues:i,mode:"onChange"});if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const f=c.parse({});u.reset(f)}}else u.reset(n)},[s,n,a,u,c]),m.useEffect(()=>{const f=u.watch(_=>{a(_)});return()=>f.unsubscribe()},[u,a]),!s||!r)return null;const V={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"cipher",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(N,{children:e.jsxs(W,{onValueChange:f.onChange,value:f.value,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:rs.shadowsocks.ciphers.map(_=>e.jsx($,{value:_,children:_},_))})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(N,{children:e.jsxs(W,{onValueChange:f.onChange,value:f.value,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(G,{children:e.jsxs(fs,{children:[e.jsx($,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx($,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs_settings.path",render:({field:f})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(N,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...f})}),e.jsx(P,{})]})}),e.jsx(j,{control:u.control,name:"obfs_settings.host",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(N,{children:e.jsx(T,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.host"),...f})}),e.jsx(P,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(N,{children:e.jsxs(W,{value:f.value?.toString(),onValueChange:_=>f.onChange(Number(_)),children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx($,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:f})=>e.jsxs(g,{children:[e.jsxs(v,{children:[l("dynamic_form.vmess.network.label"),e.jsx($t,{value:u.watch("network_settings"),setValue:_=>u.setValue("network_settings",_),templateType:u.watch("network")})]}),e.jsx(N,{children:e.jsxs(W,{onValueChange:f.onChange,value:f.value,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:rs.vmess.networkOptions.map(_=>e.jsx($,{value:_.value,className:"cursor-pointer",children:_.label},_.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"server_name",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(j,{control:u.control,name:"allow_insecure",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:f})=>e.jsxs(g,{children:[e.jsxs(v,{children:[l("dynamic_form.trojan.network.label"),e.jsx($t,{value:u.watch("network_settings")||{},setValue:_=>u.setValue("network_settings",_),templateType:u.watch("network")||"tcp"})]}),e.jsx(N,{children:e.jsxs(W,{onValueChange:f.onChange,value:f.value||"tcp",children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:rs.trojan.networkOptions.map(_=>e.jsx($,{value:_.value,className:"cursor-pointer",children:_.label},_.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"version",render:({field:f})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(N,{children:e.jsxs(W,{value:(f.value||2).toString(),onValueChange:_=>f.onChange(Number(_)),children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:rs.hysteria.versions.map(_=>e.jsxs($,{value:_,className:"cursor-pointer",children:["V",_]},_))})})]})})]})}),u.watch("version")==1&&e.jsx(j,{control:u.control,name:"alpn",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(N,{children:e.jsxs(W,{value:f.value||"h2",onValueChange:f.onChange,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:rs.hysteria.alpnOptions.map(_=>e.jsx($,{value:_,children:_},_))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"obfs.open",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})}),!!u.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[u.watch("version")=="2"&&e.jsx(j,{control:u.control,name:"obfs.type",render:({field:f})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(N,{children:e.jsxs(W,{value:f.value||"salamander",onValueChange:f.onChange,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:e.jsx($,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(j,{control:u.control,name:"obfs.password",render:({field:f})=>e.jsxs(g,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...f,value:f.value||"",className:"pr-9"})}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",k=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(b=>_[b%_.length]).join("");u.setValue("obfs.password",k),q.success(l("dynamic_form.hysteria.obfs.password.generate_success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ne,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})]})]})})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls.server_name",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(j,{control:u.control,name:"tls.allow_insecure",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(j,{control:u.control,name:"bandwidth.up",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(u.watch("version")==2?l("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...f,value:f.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(j,{control:u.control,name:"bandwidth.down",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(u.watch("version")==2?l("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...f,value:f.value||""})}),e.jsx("div",{className:"pointer-events-none z-[-1] flex items-center rounded-md rounded-bl-none rounded-tl-none border border-l-0 border-input px-3 shadow-sm",children:e.jsx("span",{className:"text-gray-500",children:l("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(j,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.tls.label")}),e.jsx(N,{children:e.jsxs(W,{value:f.value?.toString(),onValueChange:_=>f.onChange(Number(_)),children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx($,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx($,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(j,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),u.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:u.control,name:"reality_settings.server_name",render:({field:f})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...f})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.server_port",render:({field:f})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...f})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.allow_insecure",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(N,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(j,{control:u.control,name:"reality_settings.private_key",render:({field:f})=>e.jsxs(g,{className:"flex-1",children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{children:e.jsx(T,{...f,className:"pr-9"})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const _=Su();u.setValue("reality_settings.private_key",_.privateKey),u.setValue("reality_settings.public_key",_.publicKey),q.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{q.error(l("dynamic_form.vless.reality_settings.key_pair.error"))}},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ne,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(j,{control:u.control,name:"reality_settings.public_key",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(N,{children:e.jsx(T,{...f})})]})}),e.jsx(j,{control:u.control,name:"reality_settings.short_id",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(N,{children:e.jsx(T,{...f,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const _=Du();u.setValue("reality_settings.short_id",_),q.success(l("dynamic_form.vless.reality_settings.short_id.success"))},className:"absolute right-0 top-0 h-full px-2 active:scale-90 transition-transform duration-150",children:e.jsx(Ne,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(yt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(F,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(j,{control:u.control,name:"network",render:({field:f})=>e.jsxs(g,{children:[e.jsxs(v,{children:[l("dynamic_form.vless.network.label"),e.jsx($t,{value:u.watch("network_settings"),setValue:_=>u.setValue("network_settings",_),templateType:u.watch("network")})]}),e.jsx(N,{children:e.jsxs(W,{onValueChange:f.onChange,value:f.value,children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(G,{children:e.jsx(fs,{children:rs.vless.networkOptions.map(_=>e.jsx($,{value:_.value,className:"cursor-pointer",children:_.label},_.value))})})]})})]})}),e.jsx(j,{control:u.control,name:"flow",render:({field:f})=>e.jsxs(g,{children:[e.jsx(v,{children:l("dynamic_form.vless.flow.label")}),e.jsx(N,{children:e.jsxs(W,{onValueChange:_=>f.onChange(_==="none"?null:_),value:f.value||"none",children:[e.jsx(B,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(G,{children:rs.vless.flowOptions.map(_=>e.jsx($,{value:_,children:_},_))})]})})]})})]})};return e.jsx(ie,{children:V[s]?.()})},Fu=h.object({id:h.number().optional().nullable(),code:h.string().optional(),name:h.string().min(1,"form.name.error"),rate:h.string().min(1,"form.rate.error"),tags:h.array(h.string()).default([]),excludes:h.array(h.string()).default([]),ips:h.array(h.string()).default([]),group_ids:h.array(h.string()).default([]),host:h.string().min(1,"form.host.error"),port:h.string().min(1,"form.port.error"),server_port:h.string().min(1,"form.server_port.error"),parent_id:h.string().default("0").nullable(),route_ids:h.array(h.string()).default([]),protocol_settings:h.record(h.any()).default({}).nullable()}),ht={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Mu(){const{t:s}=I("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:i,refetch:u}=Vr(),[x,o]=m.useState([]),[d,p]=m.useState([]),[D,V]=m.useState([]),f=ce({resolver:ue(Fu),defaultValues:ht,mode:"onChange"});m.useEffect(()=>{_()},[n]),m.useEffect(()=>{l?.type&&l.type!==c&&i(l.type)},[l,c,i]),m.useEffect(()=>{l?l.type===c&&f.reset({...ht,...l}):f.reset({...ht,protocol_settings:rs[c].schema.parse({})})},[l,f,c]);const _=async()=>{if(!n)return;const[C,E,z]=await Promise.all([It(),hr(),xr()]);o(C.data?.map(Z=>({label:Z.name,value:Z.id.toString()}))||[]),p(E.data?.map(Z=>({label:Z.remarks,value:Z.id.toString()}))||[]),V(z.data||[])},k=m.useMemo(()=>D?.filter(C=>(C.parent_id===0||C.parent_id===null)&&C.type===c&&C.id!==f.watch("id")),[c,D,f]),b=()=>e.jsxs(ys,{children:[e.jsx(Ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ne,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(os,{align:"start",children:e.jsx(nc,{children:Ds.map(({type:C,label:E})=>e.jsx(fe,{onClick:()=>{i(C),a(!0)},className:"cursor-pointer",children:e.jsx(K,{variant:"outline",className:"text-white",style:{background:ls[C]},children:E})},C))})})]}),w=()=>{a(!1),r(null),f.reset(ht)},S=async()=>{const C=f.getValues();(await Ic({...C,type:c})).data&&(w(),q.success(s("form.success")),u())};return e.jsxs(ge,{open:n,onOpenChange:w,children:[b(),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(xe,{...f,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{control:f.control,name:"name",render:({field:C})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:s("form.name.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("form.name.placeholder"),...C})}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"rate",render:({field:C})=>e.jsxs(g,{className:"flex-[1]",children:[e.jsx(v,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(N,{children:e.jsx(T,{type:"number",min:"0",step:"0.1",...C})})}),e.jsx(P,{})]})})]}),e.jsx(j,{control:f.control,name:"code",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(v,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(N,{children:e.jsx(T,{placeholder:s("form.code.placeholder"),...C,value:C.value||""})}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"tags",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.tags.label")}),e.jsx(N,{children:e.jsx(xa,{value:C.value,onChange:C.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"group_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsxs(v,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Ft,{dialogTrigger:e.jsx(R,{variant:"link",children:s("form.groups.add")}),refetch:_})]}),e.jsx(N,{children:e.jsx(lt,{options:x,onChange:E=>C.onChange(E.map(z=>z.value)),value:x?.filter(E=>C.value.includes(E.value)),placeholder:s("form.groups.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.groups.empty")})})}),e.jsx(P,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:f.control,name:"host",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.host.label")}),e.jsx(N,{children:e.jsx(T,{placeholder:s("form.host.placeholder"),...C})}),e.jsx(P,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(j,{control:f.control,name:"port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(Ne,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.port.tooltip")})})})]})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(N,{children:e.jsx(T,{placeholder:s("form.port.placeholder"),...C})}),e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const E=C.value;E&&f.setValue("server_port",E)},children:e.jsx(Ne,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(te,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"server_port",render:({field:C})=>e.jsxs(g,{className:"flex-1",children:[e.jsxs(v,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(Ne,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(yt,{children:e.jsx(te,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(N,{children:e.jsx(T,{placeholder:s("form.server_port.placeholder"),...C})}),e.jsx(P,{})]})})]})]}),n&&e.jsx(Iu,{serverType:c,value:f.watch("protocol_settings"),onChange:C=>f.setValue("protocol_settings",C,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(j,{control:f.control,name:"parent_id",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.parent.label")}),e.jsxs(W,{onValueChange:C.onChange,value:C.value?.toString()||"0",children:[e.jsx(N,{children:e.jsx(B,{children:e.jsx(Y,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(G,{children:[e.jsx($,{value:"0",children:s("form.parent.none")}),k?.map(E=>e.jsx($,{value:E.id.toString(),className:"cursor-pointer",children:E.name},E.id))]})]}),e.jsx(P,{})]})}),e.jsx(j,{control:f.control,name:"route_ids",render:({field:C})=>e.jsxs(g,{children:[e.jsx(v,{children:s("form.route.label")}),e.jsx(N,{children:e.jsx(lt,{options:d,onChange:E=>C.onChange(E.map(z=>z.value)),value:d?.filter(E=>C.value.includes(E.value)),placeholder:s("form.route.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:s("form.route.empty")})})}),e.jsx(P,{})]})})]}),e.jsxs(Me,{className:"mt-6",children:[e.jsx(R,{type:"button",variant:"outline",onClick:w,children:s("form.cancel")}),e.jsx(R,{type:"submit",onClick:S,children:s("form.submit")})]})]})]})]})}function Aa({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(as,{children:[e.jsx(ns,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(be,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:r.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:r.size>2?e.jsxs(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(We,{className:"w-[200px] p-0",align:"start",children:e.jsxs(_s,{children:[e.jsx(Vs,{placeholder:n}),e.jsxs(ws,{children:[e.jsx(Is,{children:"No results found."}),e.jsx(Ie,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(_e,{onSelect:()=>{i?r.delete(c.value):r.add(c.value);const u=Array.from(r);s?.setFilterValue(u.length?u:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:y("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",i?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ps,{className:y("h-4 w-4")})}),c.icon&&e.jsx(c.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${c.color}`}),e.jsx("span",{children:c.label}),l?.get(c.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(c.value)})]},c.value)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Hs,{}),e.jsx(Ie,{children:e.jsx(_e,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Ou=[{value:ye.Shadowsocks,label:Ds.find(s=>s.type===ye.Shadowsocks)?.label,color:ls[ye.Shadowsocks]},{value:ye.Vmess,label:Ds.find(s=>s.type===ye.Vmess)?.label,color:ls[ye.Vmess]},{value:ye.Trojan,label:Ds.find(s=>s.type===ye.Trojan)?.label,color:ls[ye.Trojan]},{value:ye.Hysteria,label:Ds.find(s=>s.type===ye.Hysteria)?.label,color:ls[ye.Hysteria]},{value:ye.Vless,label:Ds.find(s=>s.type===ye.Vless)?.label,color:ls[ye.Vless]}];function zu({table:s,saveOrder:n,isSortMode:a,groups:l}){const r=s.getState().columnFilters.length>0,{t:c}=I("server"),i=l.map(u=>({label:u,value:u}));return e.jsxs("div",{className:"flex items-center justify-between ",children:[e.jsxs("div",{className:"flex flex-1 flex-col-reverse items-start gap-y-2 sm:flex-row sm:items-center sm:space-x-2",children:[!a&&e.jsxs(e.Fragment,{children:[e.jsx(Mu,{}),e.jsx(T,{placeholder:c("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:u=>s.getColumn("name")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(Aa,{column:s.getColumn("type"),title:c("toolbar.type"),options:Ou}),s.getColumn("groups")&&e.jsx(Aa,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:i})]}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Oe,{className:"ml-2 h-4 w-4"})]})]}),a&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const ot=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M15.71 12.71a6 6 0 1 0-7.42 0a10 10 0 0 0-6.22 8.18a1 1 0 0 0 2 .22a8 8 0 0 1 15.9 0a1 1 0 0 0 1 .89h.11a1 1 0 0 0 .88-1.1a10 10 0 0 0-6.25-8.19M12 12a4 4 0 1 1 4-4a4 4 0 0 1-4 4"})}),ft={0:"bg-destructive/80 shadow-sm shadow-destructive/50",1:"bg-yellow-500/80 shadow-sm shadow-yellow-500/50",2:"bg-emerald-500/80 shadow-sm shadow-emerald-500/50"},Lu=s=>{const{t:n}=I("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Pt,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(K,{variant:"outline",className:y("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:ls[a.original.type]},children:[e.jsx(zn,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:r??l}),a.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:a.original.parent?.code||a.original.parent?.id})]}):""]})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:c=>{c.stopPropagation(),wt(r||l.toString()).then(()=>{q.success(n("common:copy.success"))})},children:e.jsx(Ta,{className:"size-3"})})]})}),e.jsxs(te,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ds.find(c=>c.type===a.original.type)?.label,a.original.parent_id?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:200,enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.show")}),cell:({row:a})=>{const[l,r]=m.useState(!!a.getValue("show"));return e.jsx(H,{checked:l,onCheckedChange:async c=>{r(c),Oc({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?ls[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(M,{column:a,title:n("columns.node"),tooltip:e.jsxs("div",{className:"grid grid-cols-1 gap-3 p-2",children:[e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",ft[0])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.0")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",ft[1])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.1")})]}),e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("h-2.5 w-2.5 rounded-full",ft[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(ie,{delayDuration:100,children:e.jsxs(re,{children:[e.jsx(le,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:y("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",ft[a.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:a.getValue("name")})]})}),e.jsx(te,{children:e.jsx("p",{className:"font-medium",children:n(`columns.status.${a.original.available_status}`)})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.address")}),cell:({row:a})=>{const l=`${a.original.host}:${a.original.port}`,r=a.original.port!==a.original.server_port;return e.jsxs("div",{className:"group relative flex min-w-0 items-start",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 pr-7",children:[e.jsx("div",{className:"flex items-center ",children:e.jsxs("span",{className:"font-mono text-sm font-medium text-foreground/90",children:[a.original.host,":",a.original.port]})}),r&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",a.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(ie,{delayDuration:0,children:e.jsxs(re,{children:[e.jsx(le,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:c=>{c.stopPropagation(),wt(l).then(()=>{q.success(n("common:copy.success"))})},children:e.jsx(Ta,{className:"size-3"})})}),e.jsx(te,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ot,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:a})=>e.jsxs(K,{variant:"secondary",className:"font-medium",children:[a.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"groups",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:a})=>{const l=a.getValue("groups")||[];return e.jsx("div",{className:"flex min-w-[300px] max-w-[600px] flex-wrap items-center gap-1.5",children:l.length>0?l.map((r,c)=>e.jsx(K,{variant:"secondary",className:y("px-2 py-0.5 font-medium","bg-secondary/50 hover:bg-secondary/70","border border-border/50","transition-all duration-200","cursor-default select-none","flex items-center gap-1.5"),children:r.name},c)):e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})})},enableSorting:!1,size:600,filterFn:(a,l,r)=>{const c=a.getValue(l);return c?r.some(i=>c.includes(i)):!1}},{accessorKey:"type",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.type")}),cell:({row:a})=>{const l=a.getValue("type");return e.jsx(K,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:ls[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(M,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=Vr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(ys,{modal:!1,children:[e.jsx(Ns,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Nt,{className:"size-4"})})}),e.jsxs(os,{align:"end",className:"w-40",children:[e.jsx(fe,{className:"cursor-pointer",onClick:()=>{c(a.original.type),r(a.original),l(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(ui,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(fe,{className:"cursor-pointer",onClick:async()=>{Mc({id:a.original.id}).then(({data:i})=>{i&&(q.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(xi,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(at,{}),e.jsx(fe,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:i=>i.preventDefault(),children:e.jsx(Je,{title:n("columns.actions_dropdown.delete.title"),description:n("columns.actions_dropdown.delete.description"),confirmText:n("columns.actions_dropdown.delete.confirm"),variant:"destructive",onConfirm:async()=>{Fc({id:a.original.id}).then(({data:i})=>{i&&(q.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(cs,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Au(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[i,u]=m.useState({pageSize:500,pageIndex:0}),[x,o]=m.useState([]),[d,p]=m.useState(!1),[D,V]=m.useState({}),[f,_]=m.useState([]),{refetch:k}=se({queryKey:["nodeList"],queryFn:async()=>{const{data:z}=await xr();return _(z),z}}),b=m.useMemo(()=>{const z=new Set;return f.forEach(Z=>{Z.groups&&Z.groups.forEach(A=>z.add(A.name))}),Array.from(z).sort()},[f]);m.useEffect(()=>{l({"drag-handle":d,show:!d,host:!d,online:!d,rate:!d,groups:!d,type:!1,actions:!d}),V({name:d?2e3:200}),u({pageSize:d?99999:500,pageIndex:0})},[d]);const w=(z,Z)=>{d&&(z.dataTransfer.setData("text/plain",Z.toString()),z.currentTarget.classList.add("opacity-50"))},S=(z,Z)=>{if(!d)return;z.preventDefault(),z.currentTarget.classList.remove("bg-muted");const A=parseInt(z.dataTransfer.getData("text/plain"));if(A===Z)return;const X=[...f],[Us]=X.splice(A,1);X.splice(Z,0,Us),_(X)},C=async()=>{if(!d){p(!0);return}const z=f?.map((Z,A)=>({id:Z.id,order:A+1}));zc(z).then(()=>{q.success("排序保存成功"),p(!1),k()}).finally(()=>{p(!1)})},E=ze({data:f||[],columns:Lu(k),state:{sorting:x,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:D,pagination:i},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:V,onPaginationChange:u,getCoreRowModel:Le(),getFilteredRowModel:Ue(),getPaginationRowModel:Be(),getSortedRowModel:Ge(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Nu,{refetch:k,children:e.jsx("div",{className:"space-y-4",children:e.jsx(Ye,{table:E,toolbar:z=>e.jsx(zu,{table:z,refetch:k,saveOrder:C,isSortMode:d,groups:b}),draggable:d,onDragStart:w,onDragEnd:z=>z.currentTarget.classList.remove("opacity-50"),onDragOver:z=>{z.preventDefault(),z.currentTarget.classList.add("bg-muted")},onDragLeave:z=>z.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!d})})})}function $u(){const{t:s}=I("server");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Pe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("manage.title")}),e.jsx("p",{className:"text-muted-foreground mt-2",children:s("manage.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Au,{})})]})]})}const qu=Object.freeze(Object.defineProperty({__proto__:null,default:$u},Symbol.toStringTag,{value:"Module"}));function Ku({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=I("group");return e.jsx("div",{className:"flex items-center justify-between space-x-4",children:e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(Ft,{refetch:n}),e.jsx(T,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:y("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Oe,{className:"ml-2 h-4 w-4"})]})]})})}const Hu=s=>{const{t:n}=I("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(K,{variant:"outline",children:a.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:a.getValue("name")})})},{accessorKey:"users_count",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ot,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:a})=>e.jsx(M,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(zn,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:a.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:a})=>e.jsx(M,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Ft,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Es,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Je,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ac({id:a.original.id}).then(({data:l})=>{l&&(q.success(n("messages.updateSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(cs,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:n("messages.deleteButton")})]})})]})}]};function Uu(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[i,u]=m.useState([]),{data:x,refetch:o,isLoading:d}=se({queryKey:["serverGroupList"],queryFn:async()=>{const{data:D}=await It();return D}}),p=ze({data:x||[],columns:Hu(o),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Le(),getFilteredRowModel:Ue(),getPaginationRowModel:Be(),getSortedRowModel:Ge(),getFacetedRowModel:ds(),getFacetedUniqueValues:ms(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ye,{table:p,toolbar:D=>e.jsx(Ku,{table:D,refetch:o}),isLoading:d})}function Bu(){const{t:s}=I("group");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Pe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Re,{}),e.jsx(Ee,{})]})]}),e.jsxs(ke,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-2 flex items-center justify-between space-y-2",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:s("title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0",children:e.jsx(Uu,{})})]})]})}const Gu=Object.freeze(Object.defineProperty({__proto__:null,default:Bu},Symbol.toStringTag,{value:"Module"})),Wu=s=>h.object({remarks:h.string().min(1,s("form.validation.remarks")),match:h.array(h.string()),action:h.enum(["block","dns"]),action_value:h.string().optional()});function Ir({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=I("route"),c=ce({resolver:ue(Wu(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1);return e.jsxs(ge,{open:i,onOpenChange:u,children:[e.jsx(Fe,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ne,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(je,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(xe,{...c,children:[e.jsx(j,{control:c.control,name:"remarks",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(T,{type:"text",placeholder:r("form.remarksPlaceholder"),...x})})}),e.jsx(P,{})]})}),e.jsx(j,{control:c.control,name:"match",render:({field:x})=>e.jsxs(g,{className:"flex-[2]",children:[e.jsx(v,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(N,{children:e.jsx(Cs,{className:"min-h-[120px]",placeholder:r("form.matchPlaceholder"),value:x.value.join(` `),onChange:o=>{x.onChange(o.target.value.split(`