diff --git a/app/Http/Controllers/V1/User/CouponController.php b/app/Http/Controllers/V1/User/CouponController.php index af47a653..d1adf9c6 100644 --- a/app/Http/Controllers/V1/User/CouponController.php +++ b/app/Http/Controllers/V1/User/CouponController.php @@ -11,11 +11,11 @@ class CouponController extends Controller { public function check(Request $request) { - $request->validate([ - 'code' => 'required|string', - 'plan_id' => 'required|integer', - 'period' => 'nullable|string', - ]); + // $request->validate([ + // 'code' => 'required|string', + // 'plan_id' => 'required|integer', + // 'period' => 'nullable|string', + // ]); if (empty($request->input('code'))) { return $this->fail([422,__('Coupon cannot be empty')]); } diff --git a/app/Services/PlanService.php b/app/Services/PlanService.php index db72b079..30b73b8c 100644 --- a/app/Services/PlanService.php +++ b/app/Services/PlanService.php @@ -114,7 +114,8 @@ public static function getPeriodKey(string $period): string */ public static function convertToLegacyPeriod(string $period): string { - return Plan::LEGACY_PERIOD_MAPPING[$period] ?? $period; + $flippedMapping = array_flip(Plan::LEGACY_PERIOD_MAPPING); + return $flippedMapping[$period] ?? $period; } /** diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index be727da4..92035e77 100644 --- a/public/assets/admin/assets/index.js +++ b/public/assets/admin/assets/index.js @@ -1,9 +1,9 @@ -import{r as m,j as e,t as xl,c as hl,I as Pa,a as Es,S as aa,u as ms,b as na,d as fl,O as ra,e as pl,f as q,g as gl,h as jl,i as vl,k as bl,B as yl,l as Nl,Q as _l,m as wl,R as Cl,n as Sl,P as kl,o as Pl,p as Tl,q as Ja,F as Dl,C as El,s as Rl,v as Vl,w as Il,x as Fl,y as Qa,z as I,A as h,D as de,E as me,G as Za,H as Pt,J as Tt,K as la,L as Ae,T as Dt,M as Et,N as Xa,U as en,V as sn,W as oa,X as tn,Y as Ml,Z as an,_ as nn,$ as rn,a0 as ln,a1 as Rs,a2 as on,a3 as Ol,a4 as cn,a5 as dn,a6 as zl,a7 as Ll,a8 as Al,a9 as $l,aa as ql,ab as Kl,ac as Hl,ad as Ul,ae as Bl,af as Gl,ag as Wl,ah as mn,ai as Yl,aj as Jl,ak as Vs,al as un,am as Ql,an as Zl,ao as xn,ap as ia,aq as Xl,ar as eo,as as Ta,at as so,au as hn,av as to,aw as fn,ax as ao,ay as no,az as ro,aA as lo,aB as oo,aC as io,aD as pn,aE as co,aF as mo,aG as uo,aH as De,aI as xo,aJ as gn,aK as ho,aL as fo,aM as jn,aN as vn,aO as bn,aP as po,aQ as go,aR as yn,aS as Nn,aT as _n,aU as jo,aV as vo,aW as wn,aX as bo,aY as ca,aZ as Cn,a_ as yo,a$ as Sn,b0 as No,b1 as kn,b2 as _o,b3 as Pn,b4 as Tn,b5 as wo,b6 as Co,b7 as Dn,b8 as So,b9 as ko,ba as En,bb as Po,bc as Rn,bd as To,be as Do,bf as We,bg as se,bh as Ge,bi as ct,bj as Eo,bk as Ro,bl as Vo,bm as Io,bn as Fo,bo as Mo,bp as Da,bq as Ea,br as Oo,bs as zo,bt as Lo,bu as Ao,bv as $o,bw as Wt,bx as Yt,by as qo,bz as Ko,bA as Vn,bB as Ho,bC as Uo,bD as In,bE as Bo,bF as ve,bG as Go,bH as Ra,bI as Jt,bJ as Qt,bK as Wo,bL as Yo,bM as Fn,bN as Jo,bO as da,bP as Qo,bQ as Zo,bR as Xo,bS as Mn,bT as On,bU as zn,bV as ei,bW as si,bX as ti,bY as ai,bZ as Ln,b_ as ni,b$ as as,c0 as ri,c1 as li,c2 as oi,c3 as Nt,c4 as Se,c5 as Va,c6 as ii,c7 as An,c8 as $n,c9 as qn,ca as Kn,cb as Hn,cc as Un,cd as ci,ce as di,cf as mi,cg as Rt,ch as Is,ci as ns,cj as Ke,ck as He,cl as Je,cm as Qe,cn as Ze,co as ui,cp as xi,cq as hi,cr as fi,cs as pi,ct as gi,cu as ji,cv as vi,cw as bi,cx as Zt,cy as ma,cz as ua,cA as yi,cB as us,cC as xs,cD as dt,cE as Ni,cF as _t,cG as _i,cH as Ia,cI as Bn,cJ as Fa,cK as wt,cL as wi,cM as Ci,cN as Si,cO as ki,cP as Gn,cQ as Pi,cR as Ti,cS as Wn,cT as Xt,cU as Yn,cV as Di,cW as Jn,cX as Qn,cY as Ei,cZ as Ri,c_ as Vi,c$ as Ii,d0 as Fi}from"./vendor.js";import"./index.js";var Eh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Rh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Mi(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 Oi={theme:"system",setTheme:()=>null},Zn=m.createContext(Oi);function zi({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(Zn.Provider,{...l,value:i,children:s})}const Li=()=>{const s=m.useContext(Zn);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Ai=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),$i=function(s,n){return new URL(s,n).href},Ma={},ne=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=$i(o,l),o in Ma)return;Ma[o]=!0;const d=o.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(!!l)for(let f=i.length-1;f>=0;f--){const g=i[f];if(g.href===o&&(!d||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${p}`))return;const R=document.createElement("link");if(R.rel=d?"stylesheet":Ai,d||(R.as="script"),R.crossOrigin="",R.href=o,x&&R.setAttribute("nonce",x),document.head.appendChild(R),d)return new Promise((f,g)=>{R.addEventListener("load",f),R.addEventListener("error",()=>g(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 _(...s){return xl(hl(s))}const Bs=Es("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"}}),V=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?aa:"button";return e.jsxs(p,{className:_(Bs({variant:n,size:a,className:s})),disabled:i||c,ref:d,...o,children:[(u&&i||!u&&!x&&i)&&e.jsx(Pa,{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(Pa,{className:"ml-2 h-4 w-4 animate-spin"})]})});V.displayName="Button";function Ls({className:s,minimal:n=!1}){const a=ms();return e.jsx("div",{className:_("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(V,{variant:"outline",onClick:()=>a(-1),children:"Go Back"}),e.jsx(V,{onClick:()=>a("/"),children:"Back to Home"})]})]})})}function Oa(){const s=ms();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(V,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(V,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function qi(){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(V,{variant:"outline",children:"Learn more"})})]})})}function Ki(s){return typeof s>"u"}function Hi(s){return s===null}function Ui(s){return Hi(s)||Ki(s)}class Bi{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 Ui(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 Xn({prefixKey:s="",storage:n=sessionStorage}){return new Bi({prefixKey:s,storage:n})}const er="Xboard_",Gi=function(s={}){return Xn({prefixKey:s.prefixKey||"",storage:localStorage})},Wi=function(s={}){return Xn({prefixKey:s.prefixKey||"",storage:sessionStorage})},Vt=Gi({prefixKey:er});Wi({prefixKey:er});const sr="access_token";function nt(){return Vt.get(sr)}function tr(){Vt.remove(sr)}const za=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Yi({children:s}){const n=ms(),a=na(),l=nt();return m.useEffect(()=>{if(!l.value&&!za.includes(a.pathname)){const r=encodeURIComponent(a.pathname+a.search);n(`/sign-in?redirect=${r}`)}},[l.value,a.pathname,a.search,n]),za.includes(a.pathname)||l.value?e.jsx(e.Fragment,{children:s}):null}const Ji=()=>e.jsx(Yi,{children:e.jsx(ra,{})}),Qi=fl([{path:"/sign-in",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Nc);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Ji,{}),children:[{path:"/",lazy:async()=>({Component:(await ne(()=>Promise.resolve().then(()=>Ec),void 0,import.meta.url)).default}),errorElement:e.jsx(Ls,{}),children:[{index:!0,lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>em);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ls,{}),children:[{path:"system",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>nm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>im);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>xm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>jm);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>_m);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Vm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>zm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Km);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Wm);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>lu);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>cu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>xu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>bu);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Pu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ls,{}),children:[{path:"manage",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>nx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>dx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ls,{}),children:[{path:"plan",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>vx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Vx);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>qx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ls,{}),children:[{path:"manage",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>mh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ph);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ls},{path:"/404",Component:Oa},{path:"/503",Component:qi},{path:"*",Component:Oa}]),Zi="locale";function Xi(){return Vt.get(Zi)}function ar(){tr();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 ec=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function sc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const F=pl.create({baseURL:sc(),timeout:12e3,headers:{"Content-Type":"application/json"}});F.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=nt();if(!ec.includes(s.url?.split("?")[0]||"")){if(!n.value)return ar(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Xi().value||"zh-CN",s},s=>Promise.reject(s));F.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)&&ar(),q.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function tc(){return F.get("/user/info")}const At={token:nt()?.value||"",userInfo:null,isLoggedIn:!!nt()?.value,loading:!1,error:null},tt=gl("user/fetchUserInfo",async()=>(await tc()).data,{condition:(s,{getState:n})=>{const{user:a}=n();return!!a.token&&!a.loading}}),nr=jl({name:"user",initialState:At,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>At},extraReducers:s=>{s.addCase(tt.pending,n=>{n.loading=!0,n.error=null}).addCase(tt.fulfilled,(n,a)=>{n.loading=!1,n.userInfo=a.payload,n.error=null}).addCase(tt.rejected,(n,a)=>{if(n.loading=!1,n.error=a.error.message||"Failed to fetch user info",!n.token)return At})}}),{setToken:ac,resetUserState:nc}=nr.actions,rc=s=>s.user.userInfo,lc=nr.reducer,rr=vl({reducer:{user:lc}});nt()?.value&&rr.dispatch(tt());bl.use(yl).use(Nl).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 oc=new _l;wl.createRoot(document.getElementById("root")).render(e.jsx(Cl.StrictMode,{children:e.jsx(Sl,{client:oc,children:e.jsx(kl,{store:rr,children:e.jsxs(zi,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Pl,{router:Qi}),e.jsx(Tl,{richColors:!0,position:"top-right"})]})})})}));const Me=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Me.displayName="Card";const $e=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("flex flex-col space-y-1.5 p-6",s),...n}));$e.displayName="CardHeader";const cs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:_("font-semibold leading-none tracking-tight",s),...n}));cs.displayName="CardTitle";const Hs=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Hs.displayName="CardDescription";const qe=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("p-6 pt-0",s),...n}));qe.displayName="CardContent";const ic=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("flex items-center p-6 pt-0",s),...n}));ic.displayName="CardFooter";const cc=Es("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ct=m.forwardRef(({className:s,...n},a)=>e.jsx(Ja,{ref:a,className:_(cc(),s),...n}));Ct.displayName=Ja.displayName;const ue=Dl,lr=m.createContext({}),y=({...s})=>e.jsx(lr.Provider,{value:{name:s.name},children:e.jsx(El,{...s})}),It=()=>{const s=m.useContext(lr),n=m.useContext(or),{getFieldState:a,formState:l}=Rl(),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}},or=m.createContext({}),b=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(or.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:_("space-y-2",s),...n})})});b.displayName="FormItem";const N=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=It();return e.jsx(Ct,{ref:a,className:_(l&&"text-destructive",s),htmlFor:r,...n})});N.displayName="FormLabel";const w=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=It();return e.jsx(aa,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});w.displayName="FormControl";const M=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=It();return e.jsx("p",{ref:a,id:l,className:_("text-[0.8rem] text-muted-foreground",s),...n})});M.displayName="FormDescription";const E=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=It(),i=r?String(r?.message):n;return i?e.jsx("p",{ref:l,id:c,className:_("text-[0.8rem] font-medium text-destructive",s),...a,children:i}):null});E.displayName="FormMessage";const D=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:_("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}));D.displayName="Input";const ir=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:_("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(V,{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(Vl,{size:18}):e.jsx(Il,{size:18})})]})});ir.displayName="PasswordInput";const dc=s=>F({url:"/passport/auth/login",method:"post",data:s});function xe(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Fl(s).format(n))}function mc(s=void 0,n="YYYY-MM-DD"){return xe(s,n)}function qs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ps(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 St(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 ss(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?qs(r)+" TB":l>=1?qs(l)+" GB":a>=1?qs(a)+" MB":qs(n)+" KB"}const uc="access_token";function xc(s){Vt.set(uc,s)}function hc({className:s,onForgotPassword:n,...a}){const l=ms(),r=Qa(),{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=de({resolver:me(i),defaultValues:{email:"",password:""}});async function x(o){try{const{data:d}=await dc(o);xc(d.auth_data),r(ac(d.auth_data)),await r(tt()).unwrap(),l("/")}catch(d){console.error("Login failed:",d),d.response?.data?.message&&u.setError("root",{message:d.response.data.message})}}return e.jsx("div",{className:_("grid gap-6",s),...a,children:e.jsx(ue,{...u,children:e.jsx("form",{onSubmit:u.handleSubmit(x),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[u.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:u.formState.errors.root.message}),e.jsx(y,{control:u.control,name:"email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:c("signIn.email")}),e.jsx(w,{children:e.jsx(D,{placeholder:c("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"password",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:c("signIn.password")}),e.jsx(w,{children:e.jsx(ir,{placeholder:c("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(E,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(V,{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(V,{className:"w-full",size:"lg",loading:u.formState.isSubmitting,children:c("signIn.submit")})]})})})})}const pe=Za,ze=Xa,fc=en,mt=la,cr=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{ref:a,className:_("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}));cr.displayName=Pt.displayName;const he=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(fc,{children:[e.jsx(cr,{}),e.jsxs(Tt,{ref:l,className:_("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(la,{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(Ae,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));he.displayName=Tt.displayName;const be=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});be.displayName="DialogHeader";const Le=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Le.displayName="DialogFooter";const ge=m.forwardRef(({className:s,...n},a)=>e.jsx(Dt,{ref:a,className:_("text-lg font-semibold leading-none tracking-tight",s),...n}));ge.displayName=Dt.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Et,{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Te.displayName=Et.displayName;const Us=Es("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?aa:"button";return e.jsx(i,{className:_(Us({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";const _s=zl,ws=Ll,pc=Al,gc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(sn,{ref:r,className:_("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(oa,{className:"ml-auto h-4 w-4"})]}));gc.displayName=sn.displayName;const jc=m.forwardRef(({className:s,...n},a)=>e.jsx(tn,{ref:a,className:_("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}));jc.displayName=tn.displayName;const ds=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Ml,{children:e.jsx(an,{ref:l,sideOffset:n,className:_("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})}));ds.displayName=an.displayName;const je=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(nn,{ref:l,className:_("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}));je.displayName=nn.displayName;const vc=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(rn,{ref:r,className:_("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(ln,{children:e.jsx(Rs,{className:"h-4 w-4"})})}),n]}));vc.displayName=rn.displayName;const bc=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(on,{ref:l,className:_("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(ln,{children:e.jsx(Ol,{className:"h-4 w-4 fill-current"})})}),n]}));bc.displayName=on.displayName;const xa=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(cn,{ref:l,className:_("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));xa.displayName=cn.displayName;const rt=m.forwardRef(({className:s,...n},a)=>e.jsx(dn,{ref:a,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));rt.displayName=dn.displayName;const ea=({className:s,...n})=>e.jsx("span",{className:_("ml-auto text-xs tracking-widest opacity-60",s),...n});ea.displayName="DropdownMenuShortcut";const $t=[{code:"en-US",name:"English",flag:$l,shortName:"EN"},{code:"zh-CN",name:"中文",flag:ql,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:Kl,shortName:"KR"}];function dr(){const{i18n:s}=I(),n=r=>{s.changeLanguage(r)},a=$t.find(r=>r.code===s.language)||$t[1],l=a.flag;return e.jsxs(_s,{children:[e.jsx(ws,{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(ds,{align:"end",className:"w-[120px]",children:$t.map(r=>{const c=r.flag,i=r.code===s.language;return e.jsxs(je,{onClick:()=>n(r.code),className:_("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:_("text-sm",i&&"font-medium"),children:r.name})]},r.code)})})]})}function yc(){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(dr,{})}),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(Me,{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(hc,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(pe,{open:s,onOpenChange:n,children:e.jsx(he,{children:e.jsxs(be,{children:[e.jsx(ge,{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:()=>St(l).then(()=>{q.success(a("common:copy.success"))}),children:e.jsx(Hl,{className:"h-4 w-4"})})]})})]})})})]})}const Nc=Object.freeze(Object.defineProperty({__proto__:null,default:yc},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:_("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:_("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const Pe=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:_("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));Pe.displayName="LayoutBody";const mr=Ul,ur=Bl,xr=Gl,ce=Wl,oe=Yl,ie=Jl,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(mn,{ref:l,sideOffset:n,className:_("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=mn.displayName;function Ft(){const{pathname:s}=na();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function hr({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 _c(){const[s,n]=hr({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 wc({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(kc,{...u,sub:i,key:x,closeNav:l}):n?m.createElement(Sc,{...u,key:x,closeNav:l}):i?m.createElement(Cc,{...u,sub:i,key:x,closeNav:l}):m.createElement(fr,{...u,key:x,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:_("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(ce,{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 fr({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:i}=Ft(),{t:u}=I();return e.jsxs(Vs,{to:l,onClick:r,className:_(Bs({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 Cc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Ft(),{isExpanded:i,toggleItem:u}=_c(),{t:x}=I(),o=!!l?.find(T=>c(T.href)),d=x(s),p=i(d)||o;return e.jsxs(mr,{open:p,onOpenChange:()=>u(d),children:[e.jsxs(ur,{className:_(Bs({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:_('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(un,{stroke:1})})]}),e.jsx(xr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(T=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(fr,{...T,subLink:!0,closeNav:r})},x(T.title)))})})]})}function Sc({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=Ft(),{t:i}=I();return e.jsxs(oe,{delayDuration:0,children:[e.jsx(ie,{asChild:!0,children:e.jsxs(Vs,{to:l,onClick:r,className:_(Bs({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 kc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Ft(),{t:i}=I(),u=!!l?.find(x=>c(x.href));return e.jsxs(_s,{children:[e.jsxs(oe,{delayDuration:0,children:[e.jsx(ie,{asChild:!0,children:e.jsx(ws,{asChild:!0,children:e.jsx(V,{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(un,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(ds,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(xa,{children:[i(s)," ",a?`(${i(a)})`:""]}),e.jsx(rt,{}),l.map(({title:x,icon:o,label:d,href:p})=>e.jsx(je,{asChild:!0,children:e.jsxs(Vs,{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 pr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Ql,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Zl,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(xn,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(ia,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Xl,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(eo,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Ta,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(so,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(hn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(to,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(fn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(ao,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(no,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(ro,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Ta,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(lo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(oo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(io,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(pn,{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:_(`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(V,{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(co,{}):e.jsx(mo,{})})]}),e.jsx(wc,{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:pr}),e.jsx("div",{className:_("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:_("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(V,{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(uo,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Tc(){const[s,n]=hr({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 Dc(){const[s,n]=Tc();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(ra,{})})]})}const Ec=Object.freeze(Object.defineProperty({__proto__:null,default:Dc},Symbol.toStringTag,{value:"Module"})),Cs=m.forwardRef(({className:s,...n},a)=>e.jsx(De,{ref:a,className:_("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Cs.displayName=De.displayName;const Rc=({children:s,...n})=>e.jsx(pe,{...n,children:e.jsx(he,{className:"overflow-hidden p-0",children:e.jsx(Cs,{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})})}),Fs=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(xo,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(De.Input,{ref:a,className:_("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})]}));Fs.displayName=De.Input.displayName;const Ss=m.forwardRef(({className:s,...n},a)=>e.jsx(De.List,{ref:a,className:_("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Ss.displayName=De.List.displayName;const Ms=m.forwardRef((s,n)=>e.jsx(De.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ms.displayName=De.Empty.displayName;const Oe=m.forwardRef(({className:s,...n},a)=>e.jsx(De.Group,{ref:a,className:_("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}));Oe.displayName=De.Group.displayName;const Gs=m.forwardRef(({className:s,...n},a)=>e.jsx(De.Separator,{ref:a,className:_("-mx-1 h-px bg-border",s),...n}));Gs.displayName=De.Separator.displayName;const ke=m.forwardRef(({className:s,...n},a)=>e.jsx(De.Item,{ref:a,className:_("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}));ke.displayName=De.Item.displayName;function Vc(){const s=[];for(const n of pr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function Ie(){const[s,n]=m.useState(!1),a=ms(),l=Vc(),{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(gn,{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(Rc,{open:s,onOpenChange:n,children:[e.jsx(Fs,{placeholder:r("placeholder")}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:r("noResults")}),e.jsx(Oe,{heading:r("title"),children:l.map(u=>e.jsxs(ke,{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 Ee(){const{theme:s,setTheme:n}=Li();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(V,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(ho,{size:20}):e.jsx(fo,{size:20})}),e.jsx(dr,{})]})}const gr=m.forwardRef(({className:s,...n},a)=>e.jsx(jn,{ref:a,className:_("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));gr.displayName=jn.displayName;const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(vn,{ref:a,className:_("aspect-square h-full w-full",s),...n}));jr.displayName=vn.displayName;const vr=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:_("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));vr.displayName=bn.displayName;function Re(){const s=ms(),n=Qa(),a=po(rc),{t:l}=I(["common"]),r=()=>{tr(),n(nc()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),i=c.substring(0,2).toUpperCase();return e.jsxs(_s,{children:[e.jsx(ws,{asChild:!0,children:e.jsx(V,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(gr,{className:"h-8 w-8",children:[e.jsx(jr,{src:a?.avatar_url,alt:c}),e.jsx(vr,{children:i})]})})}),e.jsxs(ds,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(xa,{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(rt,{}),e.jsx(je,{asChild:!0,children:e.jsxs(Vs,{to:"/config/system",children:[l("common:settings"),e.jsx(ea,{children:"⌘S"})]})}),e.jsx(rt,{}),e.jsxs(je,{onClick:r,children:[l("common:logout"),e.jsx(ea,{children:"⇧⌘Q"})]})]})]})}const A=window?.settings?.secure_path,Ic=s=>F.get(A+"/stat/getOrder",{params:s}),Fc=()=>F.get(A+"/stat/getStats"),La=s=>F.get(A+"/stat/getTrafficRank",{params:s}),Mc=()=>F.get(A+"/theme/getThemes"),Oc=s=>F.post(A+"/theme/getThemeConfig",{name:s}),zc=(s,n)=>F.post(A+"/theme/saveThemeConfig",{name:s,config:n}),Lc=s=>{const n=new FormData;return n.append("file",s),F.post(A+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Ac=s=>F.post(A+"/theme/delete",{name:s}),$c=s=>F.post(A+"/config/save",s),br=()=>F.get(A+"/server/manage/getNodes"),qc=s=>F.post(A+"/server/manage/save",s),Kc=s=>F.post(A+"/server/manage/drop",s),Hc=s=>F.post(A+"/server/manage/copy",s),Uc=s=>F.post(A+"/server/manage/update",s),Bc=s=>F.post(A+"/server/manage/sort",s),Mt=()=>F.get(A+"/server/group/fetch"),Gc=s=>F.post(A+"/server/group/save",s),Wc=s=>F.post(A+"/server/group/drop",s),yr=()=>F.get(A+"/server/route/fetch"),Yc=s=>F.post(A+"/server/route/save",s),Jc=s=>F.post(A+"/server/route/drop",s),Qc=()=>F.get(A+"/payment/fetch"),Zc=()=>F.get(A+"/payment/getPaymentMethods"),Xc=s=>F.post(A+"/payment/getPaymentForm",s),ed=s=>F.post(A+"/payment/save",s),sd=s=>F.post(A+"/payment/drop",s),td=s=>F.post(A+"/payment/show",s),ad=s=>F.post(A+"/payment/sort",s),nd=s=>F.post(A+"/notice/save",s),rd=s=>F.post(A+"/notice/drop",s),ld=s=>F.post(A+"/notice/show",s),od=()=>F.get(A+"/knowledge/fetch"),id=s=>F.get(A+"/knowledge/fetch?id="+s),cd=s=>F.post(A+"/knowledge/save",s),dd=s=>F.post(A+"/knowledge/drop",s),md=s=>F.post(A+"/knowledge/show",s),ud=s=>F.post(A+"/knowledge/sort",s),Os=()=>F.get(A+"/plan/fetch"),xd=s=>F.post(A+"/plan/save",s),qt=s=>F.post(A+"/plan/update",s),hd=s=>F.post(A+"/plan/drop",s),fd=s=>F.post(A+"/plan/sort",{ids:s}),pd=async s=>F.post(A+"/order/fetch",s),gd=s=>F.post(A+"/order/detail",s),jd=s=>F.post(A+"/order/paid",s),vd=s=>F.post(A+"/order/cancel",s),Aa=s=>F.post(A+"/order/update",s),bd=s=>F.post(A+"/order/assign",s),yd=s=>F.post(A+"/coupon/fetch",s),Nd=s=>F.post(A+"/coupon/generate",s),_d=s=>F.post(A+"/coupon/drop",s),wd=s=>F.post(A+"/coupon/update",s),Cd=s=>F.post(A+"/user/fetch",s),Sd=s=>F.post(A+"/user/update",s),kd=s=>F.post(A+"/user/resetSecret",s),Pd=s=>F.post(A+"/user/generate",s),Td=s=>F.post(A+"/stat/getStatUser",s),Dd=s=>F.post(A+"/ticket/fetch",s),Ed=s=>F.get(A+"/ticket/fetch?id= "+s),Rd=s=>F.post(A+"/ticket/reply",s),Nr=s=>F.post(A+"/ticket/close",{id:s}),hs=(s="")=>F.get(A+"/config/fetch?key="+s),fs=s=>F.post(A+"/config/save",s),Vd=()=>F.get(A+"/config/getEmailTemplate"),Id=()=>F.post(A+"/config/testSendMail"),Fd=()=>F.post(A+"/config/setTelegramWebhook"),ha=go,Ot=m.forwardRef(({className:s,...n},a)=>e.jsx(yn,{ref:a,className:_("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));Ot.displayName=yn.displayName;const Ns=m.forwardRef(({className:s,...n},a)=>e.jsx(Nn,{ref:a,className:_("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}));Ns.displayName=Nn.displayName;const bt=m.forwardRef(({className:s,...n},a)=>e.jsx(_n,{ref:a,className:_("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));bt.displayName=_n.displayName;const G=jo,js=So,W=vo,U=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(wn,{ref:l,className:_("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(bo,{asChild:!0,children:e.jsx(ca,{className:"h-4 w-4 opacity-50"})})]}));U.displayName=wn.displayName;const _r=m.forwardRef(({className:s,...n},a)=>e.jsx(Cn,{ref:a,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(yo,{className:"h-4 w-4"})}));_r.displayName=Cn.displayName;const wr=m.forwardRef(({className:s,...n},a)=>e.jsx(Sn,{ref:a,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(ca,{className:"h-4 w-4"})}));wr.displayName=Sn.displayName;const B=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(No,{children:e.jsxs(kn,{ref:r,className:_("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(_r,{}),e.jsx(_o,{className:_("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(wr,{})]})}));B.displayName=kn.displayName;const Md=m.forwardRef(({className:s,...n},a)=>e.jsx(Pn,{ref:a,className:_("px-2 py-1.5 text-sm font-semibold",s),...n}));Md.displayName=Pn.displayName;const L=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Tn,{ref:l,className:_("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(wo,{children:e.jsx(Rs,{className:"h-4 w-4"})})}),e.jsx(Co,{children:n})]}));L.displayName=Tn.displayName;const Od=m.forwardRef(({className:s,...n},a)=>e.jsx(Dn,{ref:a,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));Od.displayName=Dn.displayName;function zs({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(ko,{showOutsideDays:a,className:_("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:_(Us({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:_("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:_(Us({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(En,{className:_("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(oa,{className:_("h-4 w-4",r),...c})},...l})}zs.displayName="Calendar";const rs=To,ls=Do,Xe=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(Po,{children:e.jsx(Rn,{ref:r,align:n,sideOffset:a,className:_("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})}));Xe.displayName=Rn.displayName;const vs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},et=s=>(s/100).toFixed(2),zd=({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"))?`¥${et(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},Ld=[{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"}],Ad=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=We(a,7);break;case"30d":l=We(a,30);break;case"90d":l=We(a,90);break;case"180d":l=We(a,180);break;case"365d":l=We(a,365);break;default:l=We(a,30)}return{startDate:l,endDate:a}};function $d(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:We(new Date,7),to:new Date}),{t:i}=I(),{startDate:u,endDate:x}=Ad(a,r),{data:o}=se({queryKey:["orderStat",{start_date:Ge(u,"yyyy-MM-dd"),end_date:Ge(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await Ic({start_date:Ge(u,"yyyy-MM-dd"),end_date:Ge(x,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(Me,{children:[e.jsx($e,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(cs,{children:i("dashboard:overview.title")}),e.jsxs(Hs,{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(G,{value:a,onValueChange:d=>l(d),children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(W,{placeholder:i("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:Ld.map(d=>e.jsx(L,{value:d.value,children:i(d.label)},d.value))})]}),a==="custom"&&e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(ct,{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:[Ge(r.from,"yyyy-MM-dd")," -"," ",Ge(r.to,"yyyy-MM-dd")]}):Ge(r.from,"yyyy-MM-dd"):i("dashboard:overview.selectDate")})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(zs,{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(ha,{value:s,onValueChange:d=>n(d),children:e.jsxs(Ot,{children:[e.jsx(Ns,{value:"amount",children:i("dashboard:overview.amount")}),e.jsx(Ns,{value:"count",children:i("dashboard:overview.count")})]})})]})]})}),e.jsxs(qe,{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:["¥",et(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")," ¥",et(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:["¥",et(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(Eo,{width:"100%",height:"100%",children:e.jsxs(Ro,{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:vs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:vs.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:vs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:vs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Vo,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Ge(new Date(d),"MM-dd",{locale:Oo})}),e.jsx(Io,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${et(d)}`:i("dashboard:overview.transactions",{count:d})}),e.jsx(Fo,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Mo,{content:e.jsx(zd,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Da,{type:"monotone",dataKey:"paid_total",name:i("dashboard:overview.orderAmount"),stroke:vs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Da,{type:"monotone",dataKey:"commission_total",name:i("dashboard:overview.commissionAmount"),stroke:vs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ea,{dataKey:"paid_count",name:i("dashboard:overview.orderCount"),fill:vs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Ea,{dataKey:"commission_count",name:i("dashboard:overview.commissionCount"),fill:vs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function le({className:s,...n}){return e.jsx("div",{className:_("animate-pulse rounded-md bg-primary/10",s),...n})}function qd(){return e.jsxs(Me,{children:[e.jsxs($e,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"h-4 w-[120px]"}),e.jsx(le,{className:"h-4 w-4"})]}),e.jsxs(qe,{children:[e.jsx(le,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(le,{className:"h-4 w-[100px]"})]})]})]})}function Kd(){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(qd,{},n))})}var Z=(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))(Z||{});const Zs={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Xs={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Ye=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Ye||{}),re=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(re||{});const xt={0:"待确认",1:"发放中",2:"有效",3:"无效"},ht={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var fe=(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))(fe||{});const Hd={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var Ne=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(Ne||{});const Ts=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],is={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var Fe=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Fe||{});const Ud={1:"按金额优惠",2:"按比例优惠"};var at=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(at||{}),ts=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(ts||{});function bs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:i,className:u}){return e.jsxs(Me,{className:_("transition-colors",c&&"cursor-pointer hover:bg-muted/50",i&&"border-primary/50",u),onClick:c,children:[e.jsxs($e,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(cs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(qe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Ko,{className:_("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:_("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 Bd({className:s}){const n=ms(),{t:a}=I(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await Fc()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Kd,{});const c=()=>{const i=new URLSearchParams;i.set("commission_status",re.PENDING.toString()),i.set("status",Z.COMPLETED.toString()),i.set("commission_balance","gt:0"),n(`/finance/order?${i.toString()}`)};return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(bs,{title:a("dashboard:stats.todayIncome"),value:Ps(l.todayIncome),icon:e.jsx(zo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(bs,{title:a("dashboard:stats.monthlyIncome"),value:Ps(l.currentMonthIncome),icon:e.jsx(Lo,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(bs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Ao,{className:_("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(bs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx($o,{className:_("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(bs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Wt,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(bs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Wt,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(bs,{title:a("dashboard:stats.monthlyUpload"),value:ss(l.monthTraffic.upload),icon:e.jsx(Yt,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:ss(l.todayTraffic.upload)})}),e.jsx(bs,{title:a("dashboard:stats.monthlyDownload"),value:ss(l.monthTraffic.download),icon:e.jsx(qo,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:ss(l.todayTraffic.download)})})]})}const lt=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Vn,{ref:l,className:_("relative overflow-hidden",s),...a,children:[e.jsx(Ho,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(kt,{}),e.jsx(Uo,{})]}));lt.displayName=Vn.displayName;const kt=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(In,{ref:l,orientation:n,className:_("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(Bo,{className:"relative flex-1 rounded-full bg-border"})}));kt.displayName=In.displayName;const sa={today:{getValue:()=>{const s=Wo();return{start:s,end:Yo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:We(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:We(s,30),end:s}}},custom:{getValue:()=>null}};function $a({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(G,{value:s,onValueChange:a,children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(W,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(sa).map(([i])=>e.jsx(L,{value:i,children:c[i]},i))})]}),s==="custom"&&e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ct,{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:[Ge(n.from,"yyyy-MM-dd")," -"," ",Ge(n.to,"yyyy-MM-dd")]}):Ge(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(zs,{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 As=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Gd({className:s}){const{t:n}=I(),[a,l]=m.useState("today"),[r,c]=m.useState({from:We(new Date,7),to:new Date}),[i,u]=m.useState("today"),[x,o]=m.useState({from:We(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:sa[a].getValue(),[a,r]),p=m.useMemo(()=>i==="custom"?{start:x.from,end:x.to}:sa[i].getValue(),[i,x]),{data:T}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>La({type:"node",start_time:ve.round(d.start.getTime()/1e3),end_time:ve.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:R}=se({queryKey:["userTrafficRank",p.start,p.end],queryFn:()=>La({type:"user",start_time:ve.round(p.start.getTime()/1e3),end_time:ve.round(p.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Me,{children:[e.jsx($e,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(cs,{className:"flex items-center text-base font-medium",children:[e.jsx(Go,{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($a,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(Ra,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(qe,{className:"flex-1",children:T?.data?e.jsxs(lt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:T.data.map(f=>e.jsx(ce,{delayDuration:200,children:e.jsxs(oe,{children:[e.jsx(ie,{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:_("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Jt,{className:"mr-1 h-3 w-3"}):e.jsx(Qt,{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/T.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(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:As(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(kt,{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(Me,{children:[e.jsx($e,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(cs,{className:"flex items-center text-base font-medium",children:[e.jsx(Wt,{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($a,{selectedRange:i,customDateRange:x,onRangeChange:u,onCustomRangeChange:o}),e.jsx(Ra,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(qe,{className:"flex-1",children:R?.data?e.jsxs(lt,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:R.data.map(f=>e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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:_("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Jt,{className:"mr-1 h-3 w-3"}):e.jsx(Qt,{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/R.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(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:As(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(kt,{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 Wd=Es("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:_(Wd({variant:n}),s),...a})}const _e=window?.settings?.secure_path,Cr=5*60*1e3,ta=new Map,Yd=s=>{const n=ta.get(s);return n?Date.now()-n.timestamp>Cr?(ta.delete(s),null):n.data:null},Jd=(s,n)=>{ta.set(s,{data:n,timestamp:Date.now()})},Qd=async(s,n=Cr)=>{const a=Yd(s);if(a)return a;const l=await F.get(s);return Jd(s,l),l},qa={getList:()=>Qd(`${_e}/notice/fetch`),save:s=>F.post(`${_e}/notice/save`,s),drop:s=>F.post(`${_e}/notice/drop`,{id:s}),updateStatus:s=>F.post(`${_e}/notice/show`,{id:s}),sort:s=>F.post(`${_e}/notice/sort`,{ids:s})},Ka={getSystemStatus:()=>F.get(`${_e}/system/getSystemStatus`),getQueueStats:()=>F.get(`${_e}/system/getQueueStats`),getQueueWorkload:()=>F.get(`${_e}/system/getQueueWorkload`),getQueueMasters:()=>F.get(`${_e}/system/getQueueMasters`),getSystemLog:s=>F.get(`${_e}/system/getSystemLog`,{params:s})},Ds={getPluginList:()=>F.get(`${_e}/plugin/getPlugins`),installPlugin:s=>F.post(`${_e}/plugin/install`,{code:s}),uninstallPlugin:s=>F.post(`${_e}/plugin/uninstall`,{code:s}),enablePlugin:s=>F.post(`${_e}/plugin/enable`,{code:s}),disablePlugin:s=>F.post(`${_e}/plugin/disable`,{code:s}),getPluginConfig:s=>F.get(`${_e}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>F.post(`${_e}/plugin/config`,{code:s,config:n})},yt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Fn,{ref:l,className:_("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(Jo,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));yt.displayName=Fn.displayName;function Zd(){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[T,R]=await Promise.all([Ka.getSystemStatus(),Ka.getQueueStats()]);a(T.data),r(R.data)}catch(T){console.error("Error fetching system data:",T)}finally{i(!1),x(!1)}};m.useEffect(()=>{o();const T=setInterval(o,3e4);return()=>clearInterval(T)},[]);const d=()=>{o()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(da,{className:"h-6 w-6 animate-spin"})});const p=T=>T?e.jsx(Mn,{className:"h-5 w-5 text-green-500"}):e.jsx(On,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Me,{children:[e.jsxs($e,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(cs,{className:"flex items-center gap-2",children:[e.jsx(Qo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Hs,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Zo,{className:_("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(qe,{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(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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(yt,{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(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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(yt,{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(Me,{children:[e.jsxs($e,{children:[e.jsxs(cs,{className:"flex items-center gap-2",children:[e.jsx(Xo,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Hs,{children:s("dashboard:queue.details.description")})]}),e.jsx(qe,{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(yt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function Xd(){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(Ie,{}),e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsx(Pe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Bd,{}),e.jsx($d,{}),e.jsx(Gd,{}),e.jsx(Zd,{})]})})})]})}const em=Object.freeze(Object.defineProperty({__proto__:null,default:Xd},Symbol.toStringTag,{value:"Module"})),ye=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(zn,{ref:r,decorative:a,orientation:n,className:_("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));ye.displayName=zn.displayName;function sm({className:s,items:n,...a}){const{pathname:l}=na(),r=ms(),[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(G,{value:c,onValueChange:u,children:[e.jsx(U,{className:"h-12 sm:w-48",children:e.jsx(W,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(L,{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:_("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(o=>e.jsxs(Vs,{to:o.href,className:_(Bs({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 tm=[{title:"site.title",key:"site",icon:e.jsx(ei,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(fn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(pn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(si,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(hn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(ti,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(ai,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(xn,{size:18}),href:"/config/system/app",description:"app.description"}];function am(){const{t:s}=I("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(ye,{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(sm,{items:tm})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(ra,{})})})]})]})]})}const nm=Object.freeze(Object.defineProperty({__proto__:null,default:am},Symbol.toStringTag,{value:"Module"})),H=m.forwardRef(({className:s,...n},a)=>e.jsx(Ln,{className:_("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(ni,{className:_("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=Ln.displayName;const ps=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:_("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}));ps.displayName="Textarea";const rm=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 lm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>hs("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Os()}),i=de({resolver:me(rm),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=as({mutationFn:fs,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,T])=>{i.setValue(p,T)}),l.current=d}},[r]);const x=m.useCallback(ve.debounce(async d=>{if(!ve.isEqual(d,l.current)){a(!0);try{const p=Object.entries(d).reduce((T,[R,f])=>(T[R]=f===null?"":f,T),{});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(ue,{...i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:i.control,name:"app_name",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.siteName.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"app_description",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.siteDescription.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"app_url",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.siteUrl.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"force_https",render:({field:d})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(M,{children:s("site.form.forceHttps.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(y,{control:i.control,name:"logo",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.logo.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"subscribe_url",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(w,{children:e.jsx(ps,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.subscribeUrl.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"tos_url",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.tosUrl.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"stop_register",render:({field:d})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(M,{children:s("site.form.stopRegister.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(y,{control:i.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(w,{children:e.jsxs(G,{value:d.value?.toString(),onValueChange:p=>{d.onChange(Number(p)),o(i.getValues())},children:[e.jsx(U,{children:e.jsx(W,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(p=>e.jsx(L,{value:p.id.toString(),children:p.name},p.id.toString()))]})]})}),e.jsx(M,{children:s("site.form.tryOut.description")}),e.jsx(E,{})]})}),!!i.watch("try_out_plan_id")&&e.jsx(y,{control:i.control,name:"try_out_hour",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.tryOut.duration.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"currency",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.currency.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"currency_symbol",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.currencySymbol.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function om(){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(ye,{}),e.jsx(lm,{})]})}const im=Object.freeze(Object.defineProperty({__proto__:null,default:om},Symbol.toStringTag,{value:"Module"})),cm=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()}),dm={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 mm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(cm),defaultValues:dm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>hs("safe")}),{mutateAsync:i}=as({mutationFn:fs,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(ve.debounce(async o=>{if(!ve.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"email_verify",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(M,{children:s("safe.form.emailVerify.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(M,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(M,{children:s("safe.form.safeMode.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"secure_path",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.securePath.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(M,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(y,{control:r.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(w,{children:e.jsx(ps,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` +import{r as m,j as e,t as hl,c as fl,I as Pa,a as Es,S as na,u as ms,b as ra,d as pl,O as la,e as gl,f as q,g as jl,h as vl,i as bl,k as yl,B as Nl,l as _l,Q as wl,m as Cl,R as Sl,n as kl,P as Tl,o as Pl,p as Dl,q as Qa,F as El,C as Rl,s as Vl,v as Il,w as Fl,x as Ml,y as Za,z as I,A as h,D as de,E as me,G as Xa,H as Pt,J as Dt,K as oa,L as Ae,T as Et,M as Rt,N as en,U as sn,V as tn,W as ia,X as an,Y as Ol,Z as nn,_ as rn,$ as ln,a0 as on,a1 as Rs,a2 as cn,a3 as zl,a4 as dn,a5 as mn,a6 as Ll,a7 as Al,a8 as $l,a9 as ql,aa as Kl,ab as Hl,ac as Ul,ad as Bl,ae as Gl,af as Yl,ag as Wl,ah as un,ai as Jl,aj as Ql,ak as Vs,al as xn,am as Zl,an as Xl,ao as hn,ap as ca,aq as eo,ar as so,as as Da,at as to,au as fn,av as ao,aw as pn,ax as no,ay as ro,az as lo,aA as oo,aB as io,aC as co,aD as gn,aE as mo,aF as uo,aG as xo,aH as De,aI as ho,aJ as jn,aK as fo,aL as po,aM as vn,aN as bn,aO as yn,aP as go,aQ as jo,aR as Nn,aS as _n,aT as wn,aU as vo,aV as bo,aW as Cn,aX as yo,aY as da,aZ as Sn,a_ as No,a$ as kn,b0 as _o,b1 as Tn,b2 as wo,b3 as Pn,b4 as Dn,b5 as Co,b6 as So,b7 as En,b8 as ko,b9 as To,ba as Rn,bb as Po,bc as Vn,bd as Do,be as Eo,bf as Ye,bg as se,bh as Ge,bi as dt,bj as Ro,bk as Vo,bl as Io,bm as Fo,bn as Mo,bo as Oo,bp as Ea,bq as Ra,br as zo,bs as Lo,bt as Ao,bu as $o,bv as qo,bw as Wt,bx as Jt,by as Ko,bz as Ho,bA as In,bB as Uo,bC as Bo,bD as Fn,bE as Go,bF as je,bG as Yo,bH as Va,bI as Qt,bJ as Zt,bK as Wo,bL as Jo,bM as Mn,bN as Qo,bO as ma,bP as Zo,bQ as Xo,bR as ei,bS as On,bT as zn,bU as Ln,bV as si,bW as ti,bX as ai,bY as ni,bZ as An,b_ as ri,b$ as as,c0 as li,c1 as oi,c2 as ii,c3 as _t,c4 as Se,c5 as Ia,c6 as ci,c7 as $n,c8 as qn,c9 as Kn,ca as Hn,cb as Un,cc as Bn,cd as di,ce as mi,cf as ui,cg as Vt,ch as Is,ci as ns,cj as Ke,ck as He,cl as Je,cm as Qe,cn as Ze,co as xi,cp as hi,cq as fi,cr as pi,cs as gi,ct as ji,cu as vi,cv as bi,cw as yi,cx as Xt,cy as ua,cz as xa,cA as Ni,cB as us,cC as xs,cD as mt,cE as _i,cF as wt,cG as wi,cH as Fa,cI as Gn,cJ as Ma,cK as Ct,cL as Ci,cM as Si,cN as ki,cO as Ti,cP as Yn,cQ as Pi,cR as Di,cS as Wn,cT as ea,cU as Jn,cV as Ei,cW as Qn,cX as Zn,cY as Ri,cZ as Vi,c_ as Ii,c$ as Fi,d0 as Mi}from"./vendor.js";import"./index.js";var Rh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Oi(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 zi={theme:"system",setTheme:()=>null},Xn=m.createContext(zi);function Li({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(Xn.Provider,{...l,value:i,children:s})}const Ai=()=>{const s=m.useContext(Xn);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},$i=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),qi=function(s,n){return new URL(s,n).href},Oa={},ne=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=qi(o,l),o in Oa)return;Oa[o]=!0;const d=o.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(!!l)for(let f=i.length-1;f>=0;f--){const g=i[f];if(g.href===o&&(!d||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${p}`))return;const R=document.createElement("link");if(R.rel=d?"stylesheet":$i,d||(R.as="script"),R.crossOrigin="",R.href=o,x&&R.setAttribute("nonce",x),document.head.appendChild(R),d)return new Promise((f,g)=>{R.addEventListener("load",f),R.addEventListener("error",()=>g(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 _(...s){return hl(fl(s))}const Bs=Es("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"}}),V=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?na:"button";return e.jsxs(p,{className:_(Bs({variant:n,size:a,className:s})),disabled:i||c,ref:d,...o,children:[(u&&i||!u&&!x&&i)&&e.jsx(Pa,{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(Pa,{className:"ml-2 h-4 w-4 animate-spin"})]})});V.displayName="Button";function Ls({className:s,minimal:n=!1}){const a=ms();return e.jsx("div",{className:_("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(V,{variant:"outline",onClick:()=>a(-1),children:"Go Back"}),e.jsx(V,{onClick:()=>a("/"),children:"Back to Home"})]})]})})}function za(){const s=ms();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(V,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(V,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Ki(){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(V,{variant:"outline",children:"Learn more"})})]})})}function Hi(s){return typeof s>"u"}function Ui(s){return s===null}function Bi(s){return Ui(s)||Hi(s)}class Gi{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 Bi(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 er({prefixKey:s="",storage:n=sessionStorage}){return new Gi({prefixKey:s,storage:n})}const sr="Xboard_",Yi=function(s={}){return er({prefixKey:s.prefixKey||"",storage:localStorage})},Wi=function(s={}){return er({prefixKey:s.prefixKey||"",storage:sessionStorage})},It=Yi({prefixKey:sr});Wi({prefixKey:sr});const tr="access_token";function rt(){return It.get(tr)}function ar(){It.remove(tr)}const La=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Ji({children:s}){const n=ms(),a=ra(),l=rt();return m.useEffect(()=>{if(!l.value&&!La.includes(a.pathname)){const r=encodeURIComponent(a.pathname+a.search);n(`/sign-in?redirect=${r}`)}},[l.value,a.pathname,a.search,n]),La.includes(a.pathname)||l.value?e.jsx(e.Fragment,{children:s}):null}const Qi=()=>e.jsx(Ji,{children:e.jsx(la,{})}),Zi=pl([{path:"/sign-in",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>_c);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Qi,{}),children:[{path:"/",lazy:async()=>({Component:(await ne(()=>Promise.resolve().then(()=>Rc),void 0,import.meta.url)).default}),errorElement:e.jsx(Ls,{}),children:[{index:!0,lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>sm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ls,{}),children:[{path:"system",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>rm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>cm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>hm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>vm);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>wm);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Pm);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Im);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Lm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Hm);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Wm);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ou);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>du);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>hu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>yu);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Pu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ls,{}),children:[{path:"manage",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ex);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>rx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>mx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ls,{}),children:[{path:"plan",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>bx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ix);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Kx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ls,{}),children:[{path:"manage",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>uh);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ph);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ls},{path:"/404",Component:za},{path:"/503",Component:Ki},{path:"*",Component:za}]),Xi="locale";function ec(){return It.get(Xi)}function nr(){ar();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 sc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function tc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const F=gl.create({baseURL:tc(),timeout:12e3,headers:{"Content-Type":"application/json"}});F.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=rt();if(!sc.includes(s.url?.split("?")[0]||"")){if(!n.value)return nr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=ec().value||"zh-CN",s},s=>Promise.reject(s));F.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)&&nr(),q.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function ac(){return F.get("/user/info")}const $t={token:rt()?.value||"",userInfo:null,isLoggedIn:!!rt()?.value,loading:!1,error:null},tt=jl("user/fetchUserInfo",async()=>(await ac()).data,{condition:(s,{getState:n})=>{const{user:a}=n();return!!a.token&&!a.loading}}),rr=vl({name:"user",initialState:$t,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>$t},extraReducers:s=>{s.addCase(tt.pending,n=>{n.loading=!0,n.error=null}).addCase(tt.fulfilled,(n,a)=>{n.loading=!1,n.userInfo=a.payload,n.error=null}).addCase(tt.rejected,(n,a)=>{if(n.loading=!1,n.error=a.error.message||"Failed to fetch user info",!n.token)return $t})}}),{setToken:nc,resetUserState:rc}=rr.actions,lc=s=>s.user.userInfo,oc=rr.reducer,lr=bl({reducer:{user:oc}});rt()?.value&&lr.dispatch(tt());yl.use(Nl).use(_l).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 ic=new wl;Cl.createRoot(document.getElementById("root")).render(e.jsx(Sl.StrictMode,{children:e.jsx(kl,{client:ic,children:e.jsx(Tl,{store:lr,children:e.jsxs(Li,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Pl,{router:Zi}),e.jsx(Dl,{richColors:!0,position:"top-right"})]})})})}));const Me=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Me.displayName="Card";const $e=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("flex flex-col space-y-1.5 p-6",s),...n}));$e.displayName="CardHeader";const cs=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:_("font-semibold leading-none tracking-tight",s),...n}));cs.displayName="CardTitle";const Hs=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Hs.displayName="CardDescription";const qe=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("p-6 pt-0",s),...n}));qe.displayName="CardContent";const cc=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:_("flex items-center p-6 pt-0",s),...n}));cc.displayName="CardFooter";const dc=Es("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),St=m.forwardRef(({className:s,...n},a)=>e.jsx(Qa,{ref:a,className:_(dc(),s),...n}));St.displayName=Qa.displayName;const ue=El,or=m.createContext({}),y=({...s})=>e.jsx(or.Provider,{value:{name:s.name},children:e.jsx(Rl,{...s})}),Ft=()=>{const s=m.useContext(or),n=m.useContext(ir),{getFieldState:a,formState:l}=Vl(),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}},ir=m.createContext({}),b=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(ir.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:_("space-y-2",s),...n})})});b.displayName="FormItem";const N=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=Ft();return e.jsx(St,{ref:a,className:_(l&&"text-destructive",s),htmlFor:r,...n})});N.displayName="FormLabel";const w=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=Ft();return e.jsx(na,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});w.displayName="FormControl";const M=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=Ft();return e.jsx("p",{ref:a,id:l,className:_("text-[0.8rem] text-muted-foreground",s),...n})});M.displayName="FormDescription";const E=m.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=Ft(),i=r?String(r?.message):n;return i?e.jsx("p",{ref:l,id:c,className:_("text-[0.8rem] font-medium text-destructive",s),...a,children:i}):null});E.displayName="FormMessage";const D=m.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:_("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}));D.displayName="Input";const cr=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:_("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(V,{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(Il,{size:18}):e.jsx(Fl,{size:18})})]})});cr.displayName="PasswordInput";const mc=s=>F({url:"/passport/auth/login",method:"post",data:s});function xe(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Ml(s).format(n))}function uc(s=void 0,n="YYYY-MM-DD"){return xe(s,n)}function qs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Ts(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 kt(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 ss(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?qs(r)+" TB":l>=1?qs(l)+" GB":a>=1?qs(a)+" MB":qs(n)+" KB"}const xc="access_token";function hc(s){It.set(xc,s)}function fc({className:s,onForgotPassword:n,...a}){const l=ms(),r=Za(),{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=de({resolver:me(i),defaultValues:{email:"",password:""}});async function x(o){try{const{data:d}=await mc(o);hc(d.auth_data),r(nc(d.auth_data)),await r(tt()).unwrap(),l("/")}catch(d){console.error("Login failed:",d),d.response?.data?.message&&u.setError("root",{message:d.response.data.message})}}return e.jsx("div",{className:_("grid gap-6",s),...a,children:e.jsx(ue,{...u,children:e.jsx("form",{onSubmit:u.handleSubmit(x),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[u.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:u.formState.errors.root.message}),e.jsx(y,{control:u.control,name:"email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:c("signIn.email")}),e.jsx(w,{children:e.jsx(D,{placeholder:c("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"password",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:c("signIn.password")}),e.jsx(w,{children:e.jsx(cr,{placeholder:c("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(E,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(V,{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(V,{className:"w-full",size:"lg",loading:u.formState.isSubmitting,children:c("signIn.submit")})]})})})})}const fe=Xa,ze=en,pc=sn,ut=oa,dr=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{ref:a,className:_("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}));dr.displayName=Pt.displayName;const he=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(pc,{children:[e.jsx(dr,{}),e.jsxs(Dt,{ref:l,className:_("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(oa,{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(Ae,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));he.displayName=Dt.displayName;const ve=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ve.displayName="DialogHeader";const Le=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Le.displayName="DialogFooter";const pe=m.forwardRef(({className:s,...n},a)=>e.jsx(Et,{ref:a,className:_("text-lg font-semibold leading-none tracking-tight",s),...n}));pe.displayName=Et.displayName;const Pe=m.forwardRef(({className:s,...n},a)=>e.jsx(Rt,{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Pe.displayName=Rt.displayName;const Us=Es("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?na:"button";return e.jsx(i,{className:_(Us({variant:n,size:a,className:s})),ref:c,...r})});J.displayName="Button";const _s=Ll,ws=Al,gc=$l,jc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(tn,{ref:r,className:_("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(ia,{className:"ml-auto h-4 w-4"})]}));jc.displayName=tn.displayName;const vc=m.forwardRef(({className:s,...n},a)=>e.jsx(an,{ref:a,className:_("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}));vc.displayName=an.displayName;const ds=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Ol,{children:e.jsx(nn,{ref:l,sideOffset:n,className:_("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})}));ds.displayName=nn.displayName;const ge=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(rn,{ref:l,className:_("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}));ge.displayName=rn.displayName;const bc=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(ln,{ref:r,className:_("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(on,{children:e.jsx(Rs,{className:"h-4 w-4"})})}),n]}));bc.displayName=ln.displayName;const yc=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(cn,{ref:l,className:_("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(on,{children:e.jsx(zl,{className:"h-4 w-4 fill-current"})})}),n]}));yc.displayName=cn.displayName;const ha=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(dn,{ref:l,className:_("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));ha.displayName=dn.displayName;const lt=m.forwardRef(({className:s,...n},a)=>e.jsx(mn,{ref:a,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));lt.displayName=mn.displayName;const sa=({className:s,...n})=>e.jsx("span",{className:_("ml-auto text-xs tracking-widest opacity-60",s),...n});sa.displayName="DropdownMenuShortcut";const qt=[{code:"en-US",name:"English",flag:ql,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Kl,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:Hl,shortName:"KR"}];function mr(){const{i18n:s}=I(),n=r=>{s.changeLanguage(r)},a=qt.find(r=>r.code===s.language)||qt[1],l=a.flag;return e.jsxs(_s,{children:[e.jsx(ws,{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(ds,{align:"end",className:"w-[120px]",children:qt.map(r=>{const c=r.flag,i=r.code===s.language;return e.jsxs(ge,{onClick:()=>n(r.code),className:_("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:_("text-sm",i&&"font-medium"),children:r.name})]},r.code)})})]})}function Nc(){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(mr,{})}),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(Me,{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(fc,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(fe,{open:s,onOpenChange:n,children:e.jsx(he,{children:e.jsxs(ve,{children:[e.jsx(pe,{children:a("signIn.resetPassword.title")}),e.jsx(Pe,{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:()=>kt(l).then(()=>{q.success(a("common:copy.success"))}),children:e.jsx(Ul,{className:"h-4 w-4"})})]})})]})})})]})}const _c=Object.freeze(Object.defineProperty({__proto__:null,default:Nc},Symbol.toStringTag,{value:"Module"})),we=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:_("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:_("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ce.displayName="LayoutHeader";const Te=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:_("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));Te.displayName="LayoutBody";const ur=Bl,xr=Gl,hr=Yl,ce=Wl,oe=Jl,ie=Ql,te=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(un,{ref:l,sideOffset:n,className:_("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=un.displayName;function Mt(){const{pathname:s}=ra();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function fr({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 wc(){const[s,n]=fr({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 Cc({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(Tc,{...u,sub:i,key:x,closeNav:l}):n?m.createElement(kc,{...u,key:x,closeNav:l}):i?m.createElement(Sc,{...u,sub:i,key:x,closeNav:l}):m.createElement(pr,{...u,key:x,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:_("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(ce,{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 pr({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:i}=Mt(),{t:u}=I();return e.jsxs(Vs,{to:l,onClick:r,className:_(Bs({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 Sc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Mt(),{isExpanded:i,toggleItem:u}=wc(),{t:x}=I(),o=!!l?.find(P=>c(P.href)),d=x(s),p=i(d)||o;return e.jsxs(ur,{open:p,onOpenChange:()=>u(d),children:[e.jsxs(xr,{className:_(Bs({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:_('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(xn,{stroke:1})})]}),e.jsx(hr,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(P=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(pr,{...P,subLink:!0,closeNav:r})},x(P.title)))})})]})}function kc({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=Mt(),{t:i}=I();return e.jsxs(oe,{delayDuration:0,children:[e.jsx(ie,{asChild:!0,children:e.jsxs(Vs,{to:l,onClick:r,className:_(Bs({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 Tc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=Mt(),{t:i}=I(),u=!!l?.find(x=>c(x.href));return e.jsxs(_s,{children:[e.jsxs(oe,{delayDuration:0,children:[e.jsx(ie,{asChild:!0,children:e.jsx(ws,{asChild:!0,children:e.jsx(V,{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(xn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(ds,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(ha,{children:[i(s)," ",a?`(${i(a)})`:""]}),e.jsx(lt,{}),l.map(({title:x,icon:o,label:d,href:p})=>e.jsx(ge,{asChild:!0,children:e.jsxs(Vs,{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 gr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(Zl,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Xl,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(hn,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(ca,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(eo,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(so,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(Da,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(to,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(fn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(ao,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(pn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(no,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(ro,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(lo,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(Da,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(oo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(io,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(co,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(gn,{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:_(`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(V,{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(mo,{}):e.jsx(uo,{})})]}),e.jsx(Cc,{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:gr}),e.jsx("div",{className:_("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:_("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(V,{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(xo,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Dc(){const[s,n]=fr({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 Ec(){const[s,n]=Dc();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(la,{})})]})}const Rc=Object.freeze(Object.defineProperty({__proto__:null,default:Ec},Symbol.toStringTag,{value:"Module"})),Cs=m.forwardRef(({className:s,...n},a)=>e.jsx(De,{ref:a,className:_("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Cs.displayName=De.displayName;const Vc=({children:s,...n})=>e.jsx(fe,{...n,children:e.jsx(he,{className:"overflow-hidden p-0",children:e.jsx(Cs,{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})})}),Fs=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(ho,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(De.Input,{ref:a,className:_("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})]}));Fs.displayName=De.Input.displayName;const Ss=m.forwardRef(({className:s,...n},a)=>e.jsx(De.List,{ref:a,className:_("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Ss.displayName=De.List.displayName;const Ms=m.forwardRef((s,n)=>e.jsx(De.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));Ms.displayName=De.Empty.displayName;const Oe=m.forwardRef(({className:s,...n},a)=>e.jsx(De.Group,{ref:a,className:_("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}));Oe.displayName=De.Group.displayName;const Gs=m.forwardRef(({className:s,...n},a)=>e.jsx(De.Separator,{ref:a,className:_("-mx-1 h-px bg-border",s),...n}));Gs.displayName=De.Separator.displayName;const ke=m.forwardRef(({className:s,...n},a)=>e.jsx(De.Item,{ref:a,className:_("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}));ke.displayName=De.Item.displayName;function Ic(){const s=[];for(const n of gr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function Ie(){const[s,n]=m.useState(!1),a=ms(),l=Ic(),{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(jn,{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(Vc,{open:s,onOpenChange:n,children:[e.jsx(Fs,{placeholder:r("placeholder")}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:r("noResults")}),e.jsx(Oe,{heading:r("title"),children:l.map(u=>e.jsxs(ke,{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 Ee(){const{theme:s,setTheme:n}=Ai();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(V,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(fo,{size:20}):e.jsx(po,{size:20})}),e.jsx(mr,{})]})}const jr=m.forwardRef(({className:s,...n},a)=>e.jsx(vn,{ref:a,className:_("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));jr.displayName=vn.displayName;const vr=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:_("aspect-square h-full w-full",s),...n}));vr.displayName=bn.displayName;const br=m.forwardRef(({className:s,...n},a)=>e.jsx(yn,{ref:a,className:_("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));br.displayName=yn.displayName;function Re(){const s=ms(),n=Za(),a=go(lc),{t:l}=I(["common"]),r=()=>{ar(),n(rc()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),i=c.substring(0,2).toUpperCase();return e.jsxs(_s,{children:[e.jsx(ws,{asChild:!0,children:e.jsx(V,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(jr,{className:"h-8 w-8",children:[e.jsx(vr,{src:a?.avatar_url,alt:c}),e.jsx(br,{children:i})]})})}),e.jsxs(ds,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(ha,{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(lt,{}),e.jsx(ge,{asChild:!0,children:e.jsxs(Vs,{to:"/config/system",children:[l("common:settings"),e.jsx(sa,{children:"⌘S"})]})}),e.jsx(lt,{}),e.jsxs(ge,{onClick:r,children:[l("common:logout"),e.jsx(sa,{children:"⇧⌘Q"})]})]})]})}const A=window?.settings?.secure_path,Fc=s=>F.get(A+"/stat/getOrder",{params:s}),Mc=()=>F.get(A+"/stat/getStats"),Aa=s=>F.get(A+"/stat/getTrafficRank",{params:s}),Oc=()=>F.get(A+"/theme/getThemes"),zc=s=>F.post(A+"/theme/getThemeConfig",{name:s}),Lc=(s,n)=>F.post(A+"/theme/saveThemeConfig",{name:s,config:n}),Ac=s=>{const n=new FormData;return n.append("file",s),F.post(A+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},$c=s=>F.post(A+"/theme/delete",{name:s}),qc=s=>F.post(A+"/config/save",s),yr=()=>F.get(A+"/server/manage/getNodes"),Kc=s=>F.post(A+"/server/manage/save",s),Hc=s=>F.post(A+"/server/manage/drop",s),Uc=s=>F.post(A+"/server/manage/copy",s),Bc=s=>F.post(A+"/server/manage/update",s),Gc=s=>F.post(A+"/server/manage/sort",s),Ot=()=>F.get(A+"/server/group/fetch"),Yc=s=>F.post(A+"/server/group/save",s),Wc=s=>F.post(A+"/server/group/drop",s),Nr=()=>F.get(A+"/server/route/fetch"),Jc=s=>F.post(A+"/server/route/save",s),Qc=s=>F.post(A+"/server/route/drop",s),Zc=()=>F.get(A+"/payment/fetch"),Xc=()=>F.get(A+"/payment/getPaymentMethods"),ed=s=>F.post(A+"/payment/getPaymentForm",s),sd=s=>F.post(A+"/payment/save",s),td=s=>F.post(A+"/payment/drop",s),ad=s=>F.post(A+"/payment/show",s),nd=s=>F.post(A+"/payment/sort",s),rd=s=>F.post(A+"/notice/save",s),ld=s=>F.post(A+"/notice/drop",s),od=s=>F.post(A+"/notice/show",s),id=()=>F.get(A+"/knowledge/fetch"),cd=s=>F.get(A+"/knowledge/fetch?id="+s),dd=s=>F.post(A+"/knowledge/save",s),md=s=>F.post(A+"/knowledge/drop",s),ud=s=>F.post(A+"/knowledge/show",s),xd=s=>F.post(A+"/knowledge/sort",s),Os=()=>F.get(A+"/plan/fetch"),hd=s=>F.post(A+"/plan/save",s),Kt=s=>F.post(A+"/plan/update",s),fd=s=>F.post(A+"/plan/drop",s),pd=s=>F.post(A+"/plan/sort",{ids:s}),gd=async s=>F.post(A+"/order/fetch",s),jd=s=>F.post(A+"/order/detail",s),vd=s=>F.post(A+"/order/paid",s),bd=s=>F.post(A+"/order/cancel",s),$a=s=>F.post(A+"/order/update",s),yd=s=>F.post(A+"/order/assign",s),Nd=s=>F.post(A+"/coupon/fetch",s),_d=s=>F.post(A+"/coupon/generate",s),wd=s=>F.post(A+"/coupon/drop",s),Cd=s=>F.post(A+"/coupon/update",s),Sd=s=>F.post(A+"/user/fetch",s),kd=s=>F.post(A+"/user/update",s),Td=s=>F.post(A+"/user/resetSecret",s),Pd=s=>F.post(A+"/user/generate",s),Dd=s=>F.post(A+"/stat/getStatUser",s),Ed=s=>F.post(A+"/ticket/fetch",s),Rd=s=>F.get(A+"/ticket/fetch?id= "+s),Vd=s=>F.post(A+"/ticket/reply",s),_r=s=>F.post(A+"/ticket/close",{id:s}),hs=(s="")=>F.get(A+"/config/fetch?key="+s),fs=s=>F.post(A+"/config/save",s),Id=()=>F.get(A+"/config/getEmailTemplate"),Fd=()=>F.post(A+"/config/testSendMail"),Md=()=>F.post(A+"/config/setTelegramWebhook"),fa=jo,zt=m.forwardRef(({className:s,...n},a)=>e.jsx(Nn,{ref:a,className:_("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));zt.displayName=Nn.displayName;const Ns=m.forwardRef(({className:s,...n},a)=>e.jsx(_n,{ref:a,className:_("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}));Ns.displayName=_n.displayName;const yt=m.forwardRef(({className:s,...n},a)=>e.jsx(wn,{ref:a,className:_("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));yt.displayName=wn.displayName;const G=vo,js=ko,Y=bo,U=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Cn,{ref:l,className:_("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(yo,{asChild:!0,children:e.jsx(da,{className:"h-4 w-4 opacity-50"})})]}));U.displayName=Cn.displayName;const wr=m.forwardRef(({className:s,...n},a)=>e.jsx(Sn,{ref:a,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(No,{className:"h-4 w-4"})}));wr.displayName=Sn.displayName;const Cr=m.forwardRef(({className:s,...n},a)=>e.jsx(kn,{ref:a,className:_("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(da,{className:"h-4 w-4"})}));Cr.displayName=kn.displayName;const B=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(_o,{children:e.jsxs(Tn,{ref:r,className:_("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(wr,{}),e.jsx(wo,{className:_("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Cr,{})]})}));B.displayName=Tn.displayName;const Od=m.forwardRef(({className:s,...n},a)=>e.jsx(Pn,{ref:a,className:_("px-2 py-1.5 text-sm font-semibold",s),...n}));Od.displayName=Pn.displayName;const L=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Dn,{ref:l,className:_("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(Co,{children:e.jsx(Rs,{className:"h-4 w-4"})})}),e.jsx(So,{children:n})]}));L.displayName=Dn.displayName;const zd=m.forwardRef(({className:s,...n},a)=>e.jsx(En,{ref:a,className:_("-mx-1 my-1 h-px bg-muted",s),...n}));zd.displayName=En.displayName;function zs({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(To,{showOutsideDays:a,className:_("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:_(Us({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:_("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:_(Us({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(Rn,{className:_("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(ia,{className:_("h-4 w-4",r),...c})},...l})}zs.displayName="Calendar";const rs=Do,ls=Eo,Xe=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(Po,{children:e.jsx(Vn,{ref:r,align:n,sideOffset:a,className:_("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})}));Xe.displayName=Vn.displayName;const vs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},et=s=>(s/100).toFixed(2),Ld=({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"))?`¥${et(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},Ad=[{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"}],$d=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=Ye(a,7);break;case"30d":l=Ye(a,30);break;case"90d":l=Ye(a,90);break;case"180d":l=Ye(a,180);break;case"365d":l=Ye(a,365);break;default:l=Ye(a,30)}return{startDate:l,endDate:a}};function qd(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:Ye(new Date,7),to:new Date}),{t:i}=I(),{startDate:u,endDate:x}=$d(a,r),{data:o}=se({queryKey:["orderStat",{start_date:Ge(u,"yyyy-MM-dd"),end_date:Ge(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await Fc({start_date:Ge(u,"yyyy-MM-dd"),end_date:Ge(x,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(Me,{children:[e.jsx($e,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(cs,{children:i("dashboard:overview.title")}),e.jsxs(Hs,{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(G,{value:a,onValueChange:d=>l(d),children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(Y,{placeholder:i("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:Ad.map(d=>e.jsx(L,{value:d.value,children:i(d.label)},d.value))})]}),a==="custom"&&e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(dt,{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:[Ge(r.from,"yyyy-MM-dd")," -"," ",Ge(r.to,"yyyy-MM-dd")]}):Ge(r.from,"yyyy-MM-dd"):i("dashboard:overview.selectDate")})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(zs,{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(fa,{value:s,onValueChange:d=>n(d),children:e.jsxs(zt,{children:[e.jsx(Ns,{value:"amount",children:i("dashboard:overview.amount")}),e.jsx(Ns,{value:"count",children:i("dashboard:overview.count")})]})})]})]})}),e.jsxs(qe,{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:["¥",et(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")," ¥",et(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:["¥",et(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(Ro,{width:"100%",height:"100%",children:e.jsxs(Vo,{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:vs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:vs.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:vs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:vs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Io,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Ge(new Date(d),"MM-dd",{locale:zo})}),e.jsx(Fo,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${et(d)}`:i("dashboard:overview.transactions",{count:d})}),e.jsx(Mo,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Oo,{content:e.jsx(Ld,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(Ea,{type:"monotone",dataKey:"paid_total",name:i("dashboard:overview.orderAmount"),stroke:vs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(Ea,{type:"monotone",dataKey:"commission_total",name:i("dashboard:overview.commissionAmount"),stroke:vs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ra,{dataKey:"paid_count",name:i("dashboard:overview.orderCount"),fill:vs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Ra,{dataKey:"commission_count",name:i("dashboard:overview.commissionCount"),fill:vs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function le({className:s,...n}){return e.jsx("div",{className:_("animate-pulse rounded-md bg-primary/10",s),...n})}function Kd(){return e.jsxs(Me,{children:[e.jsxs($e,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(le,{className:"h-4 w-[120px]"}),e.jsx(le,{className:"h-4 w-4"})]}),e.jsxs(qe,{children:[e.jsx(le,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx(le,{className:"h-4 w-[100px]"})]})]})]})}function Hd(){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(Kd,{},n))})}var Z=(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))(Z||{});const Zs={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},Xs={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var We=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(We||{}),re=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(re||{});const ht={0:"待确认",1:"发放中",2:"有效",3:"无效"},ft={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Ne=(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))(Ne||{});const Ud={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 Ps=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],is={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var Fe=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Fe||{});const Bd={1:"按金额优惠",2:"按比例优惠"};var at=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(at||{}),ts=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(ts||{}),nt=(s=>(s.MONTH="monthly",s.QUARTER="quarterly",s.HALF_YEAR="half_yearly",s.YEAR="yearly",s.TWO_YEAR="two_yearly",s.THREE_YEAR="three_yearly",s.ONETIME="onetime",s.RESET="reset_traffic",s))(nt||{});function bs({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:i,className:u}){return e.jsxs(Me,{className:_("transition-colors",c&&"cursor-pointer hover:bg-muted/50",i&&"border-primary/50",u),onClick:c,children:[e.jsxs($e,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(cs,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(qe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Ho,{className:_("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:_("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 Gd({className:s}){const n=ms(),{t:a}=I(),{data:l,isLoading:r}=se({queryKey:["dashboardStats"],queryFn:async()=>(await Mc()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Hd,{});const c=()=>{const i=new URLSearchParams;i.set("commission_status",re.PENDING.toString()),i.set("status",Z.COMPLETED.toString()),i.set("commission_balance","gt:0"),n(`/finance/order?${i.toString()}`)};return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(bs,{title:a("dashboard:stats.todayIncome"),value:Ts(l.todayIncome),icon:e.jsx(Lo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(bs,{title:a("dashboard:stats.monthlyIncome"),value:Ts(l.currentMonthIncome),icon:e.jsx(Ao,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(bs,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx($o,{className:_("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(bs,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(qo,{className:_("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(bs,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Wt,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(bs,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Wt,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(bs,{title:a("dashboard:stats.monthlyUpload"),value:ss(l.monthTraffic.upload),icon:e.jsx(Jt,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:ss(l.todayTraffic.upload)})}),e.jsx(bs,{title:a("dashboard:stats.monthlyDownload"),value:ss(l.monthTraffic.download),icon:e.jsx(Ko,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:ss(l.todayTraffic.download)})})]})}const ot=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(In,{ref:l,className:_("relative overflow-hidden",s),...a,children:[e.jsx(Uo,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Tt,{}),e.jsx(Bo,{})]}));ot.displayName=In.displayName;const Tt=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Fn,{ref:l,orientation:n,className:_("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(Go,{className:"relative flex-1 rounded-full bg-border"})}));Tt.displayName=Fn.displayName;const ta={today:{getValue:()=>{const s=Wo();return{start:s,end:Jo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:Ye(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:Ye(s,30),end:s}}},custom:{getValue:()=>null}};function qa({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(G,{value:s,onValueChange:a,children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(ta).map(([i])=>e.jsx(L,{value:i,children:c[i]},i))})]}),s==="custom"&&e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(J,{variant:"outline",className:_("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(dt,{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:[Ge(n.from,"yyyy-MM-dd")," -"," ",Ge(n.to,"yyyy-MM-dd")]}):Ge(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(zs,{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 As=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Yd({className:s}){const{t:n}=I(),[a,l]=m.useState("today"),[r,c]=m.useState({from:Ye(new Date,7),to:new Date}),[i,u]=m.useState("today"),[x,o]=m.useState({from:Ye(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:ta[a].getValue(),[a,r]),p=m.useMemo(()=>i==="custom"?{start:x.from,end:x.to}:ta[i].getValue(),[i,x]),{data:P}=se({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Aa({type:"node",start_time:je.round(d.start.getTime()/1e3),end_time:je.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:R}=se({queryKey:["userTrafficRank",p.start,p.end],queryFn:()=>Aa({type:"user",start_time:je.round(p.start.getTime()/1e3),end_time:je.round(p.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:_("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Me,{children:[e.jsx($e,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(cs,{className:"flex items-center text-base font-medium",children:[e.jsx(Yo,{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(qa,{selectedRange:a,customDateRange:r,onRangeChange:l,onCustomRangeChange:c}),e.jsx(Va,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(qe,{className:"flex-1",children:P?.data?e.jsxs(ot,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:P.data.map(f=>e.jsx(ce,{delayDuration:200,children:e.jsxs(oe,{children:[e.jsx(ie,{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:_("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Qt,{className:"mr-1 h-3 w-3"}):e.jsx(Zt,{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/P.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(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:As(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Tt,{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(Me,{children:[e.jsx($e,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(cs,{className:"flex items-center text-base font-medium",children:[e.jsx(Wt,{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(qa,{selectedRange:i,customDateRange:x,onRangeChange:u,onCustomRangeChange:o}),e.jsx(Va,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(qe,{className:"flex-1",children:R?.data?e.jsxs(ot,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:R.data.map(f=>e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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:_("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(Qt,{className:"mr-1 h-3 w-3"}):e.jsx(Zt,{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/R.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:As(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:As(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:As(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:_("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Tt,{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 Wd=Es("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:_(Wd({variant:n}),s),...a})}const _e=window?.settings?.secure_path,Sr=5*60*1e3,aa=new Map,Jd=s=>{const n=aa.get(s);return n?Date.now()-n.timestamp>Sr?(aa.delete(s),null):n.data:null},Qd=(s,n)=>{aa.set(s,{data:n,timestamp:Date.now()})},Zd=async(s,n=Sr)=>{const a=Jd(s);if(a)return a;const l=await F.get(s);return Qd(s,l),l},Ka={getList:()=>Zd(`${_e}/notice/fetch`),save:s=>F.post(`${_e}/notice/save`,s),drop:s=>F.post(`${_e}/notice/drop`,{id:s}),updateStatus:s=>F.post(`${_e}/notice/show`,{id:s}),sort:s=>F.post(`${_e}/notice/sort`,{ids:s})},Ha={getSystemStatus:()=>F.get(`${_e}/system/getSystemStatus`),getQueueStats:()=>F.get(`${_e}/system/getQueueStats`),getQueueWorkload:()=>F.get(`${_e}/system/getQueueWorkload`),getQueueMasters:()=>F.get(`${_e}/system/getQueueMasters`),getSystemLog:s=>F.get(`${_e}/system/getSystemLog`,{params:s})},Ds={getPluginList:()=>F.get(`${_e}/plugin/getPlugins`),installPlugin:s=>F.post(`${_e}/plugin/install`,{code:s}),uninstallPlugin:s=>F.post(`${_e}/plugin/uninstall`,{code:s}),enablePlugin:s=>F.post(`${_e}/plugin/enable`,{code:s}),disablePlugin:s=>F.post(`${_e}/plugin/disable`,{code:s}),getPluginConfig:s=>F.get(`${_e}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>F.post(`${_e}/plugin/config`,{code:s,config:n})},Nt=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Mn,{ref:l,className:_("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(Qo,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Nt.displayName=Mn.displayName;function Xd(){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[P,R]=await Promise.all([Ha.getSystemStatus(),Ha.getQueueStats()]);a(P.data),r(R.data)}catch(P){console.error("Error fetching system data:",P)}finally{i(!1),x(!1)}};m.useEffect(()=>{o();const P=setInterval(o,3e4);return()=>clearInterval(P)},[]);const d=()=>{o()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(ma,{className:"h-6 w-6 animate-spin"})});const p=P=>P?e.jsx(On,{className:"h-5 w-5 text-green-500"}):e.jsx(zn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Me,{children:[e.jsxs($e,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(cs,{className:"flex items-center gap-2",children:[e.jsx(Zo,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Hs,{children:s("dashboard:queue.status.description")})]}),e.jsx(J,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(Xo,{className:_("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(qe,{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(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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(Nt,{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(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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(Nt,{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(Me,{children:[e.jsxs($e,{children:[e.jsxs(cs,{className:"flex items-center gap-2",children:[e.jsx(ei,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Hs,{children:s("dashboard:queue.details.description")})]}),e.jsx(qe,{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(Nt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function em(){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(Ie,{}),e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsx(Te,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Gd,{}),e.jsx(qd,{}),e.jsx(Yd,{}),e.jsx(Xd,{})]})})})]})}const sm=Object.freeze(Object.defineProperty({__proto__:null,default:em},Symbol.toStringTag,{value:"Module"})),be=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(Ln,{ref:r,decorative:a,orientation:n,className:_("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));be.displayName=Ln.displayName;function tm({className:s,items:n,...a}){const{pathname:l}=ra(),r=ms(),[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(G,{value:c,onValueChange:u,children:[e.jsx(U,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(L,{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:_("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(o=>e.jsxs(Vs,{to:o.href,className:_(Bs({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 am=[{title:"site.title",key:"site",icon:e.jsx(si,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(pn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(gn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(ti,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(fn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(ai,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(ni,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(hn,{size:18}),href:"/config/system/app",description:"app.description"}];function nm(){const{t:s}=I("settings");return e.jsxs(we,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(tm,{items:am})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(la,{})})})]})]})]})}const rm=Object.freeze(Object.defineProperty({__proto__:null,default:nm},Symbol.toStringTag,{value:"Module"})),H=m.forwardRef(({className:s,...n},a)=>e.jsx(An,{className:_("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(ri,{className:_("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=An.displayName;const ps=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:_("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}));ps.displayName="Textarea";const lm=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 om(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=se({queryKey:["settings","site"],queryFn:()=>hs("site")}),{data:c}=se({queryKey:["plans"],queryFn:()=>Os()}),i=de({resolver:me(lm),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=as({mutationFn:fs,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,P])=>{i.setValue(p,P)}),l.current=d}},[r]);const x=m.useCallback(je.debounce(async d=>{if(!je.isEqual(d,l.current)){a(!0);try{const p=Object.entries(d).reduce((P,[R,f])=>(P[R]=f===null?"":f,P),{});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(ue,{...i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:i.control,name:"app_name",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.siteName.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.siteName.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"app_description",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.siteDescription.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.siteDescription.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"app_url",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.siteUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.siteUrl.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"force_https",render:({field:d})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(M,{children:s("site.form.forceHttps.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(y,{control:i.control,name:"logo",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.logo.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.logo.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"subscribe_url",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(w,{children:e.jsx(ps,{placeholder:s("site.form.subscribeUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.subscribeUrl.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"tos_url",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.tosUrl.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.tosUrl.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"stop_register",render:({field:d})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(M,{children:s("site.form.stopRegister.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(y,{control:i.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(w,{children:e.jsxs(G,{value:d.value?.toString(),onValueChange:p=>{d.onChange(Number(p)),o(i.getValues())},children:[e.jsx(U,{children:e.jsx(Y,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(p=>e.jsx(L,{value:p.id.toString(),children:p.name},p.id.toString()))]})]})}),e.jsx(M,{children:s("site.form.tryOut.description")}),e.jsx(E,{})]})}),!!i.watch("try_out_plan_id")&&e.jsx(y,{control:i.control,name:"try_out_hour",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.tryOut.duration.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.tryOut.duration.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"currency",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.currency.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.currency.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:i.control,name:"currency_symbol",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("site.form.currencySymbol.placeholder"),...d,value:d.value||"",onChange:p=>{d.onChange(p),o(i.getValues())}})}),e.jsx(M,{children:s("site.form.currencySymbol.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.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("site.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("site.description")})]}),e.jsx(be,{}),e.jsx(om,{})]})}const cm=Object.freeze(Object.defineProperty({__proto__:null,default:im},Symbol.toStringTag,{value:"Module"})),dm=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()}),mm={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 um(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(dm),defaultValues:mm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","safe"],queryFn:()=>hs("safe")}),{mutateAsync:i}=as({mutationFn:fs,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(je.debounce(async o=>{if(!je.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"email_verify",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(M,{children:s("safe.form.emailVerify.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(M,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(M,{children:s("safe.form.safeMode.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"secure_path",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.securePath.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.securePath.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(M,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(y,{control:r.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(w,{children:e.jsx(ps,{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(M,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(M,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.recaptcha.key.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(E,{})]})})]}),e.jsx(y,{control:r.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(M,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"register_limit_count",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.registerLimit.count.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(E,{})]})})]}),e.jsx(y,{control:r.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(M,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"password_limit_count",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(E,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function um(){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(ye,{}),e.jsx(mm,{})]})}const xm=Object.freeze(Object.defineProperty({__proto__:null,default:um},Symbol.toStringTag,{value:"Module"})),hm=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")}),fm={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 pm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(hm),defaultValues:fm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","subscribe"],queryFn:()=>hs("subscribe")}),{mutateAsync:i}=as({mutationFn:fs,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(ve.debounce(async o=>{if(!ve.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(M,{children:s("subscribe.plan_change_enable.description")}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(L,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(L,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(L,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(L,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(M,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"surplus_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(M,{children:s("subscribe.surplus_enable.description")}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(L,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(M,{children:s("subscribe.new_order_event.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(L,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(M,{children:s("renew_order_event.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(W,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(L,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(M,{children:s("subscribe.change_order_event.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"subscribe_path",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})}),e.jsx(y,{control:r.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(M,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(M,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(w,{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 gm(){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(ye,{}),e.jsx(pm,{})]})}const jm=Object.freeze(Object.defineProperty({__proto__:null,default:gm},Symbol.toStringTag,{value:"Module"})),vm=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)}),bm={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 ym(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(vm),defaultValues:bm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","invite"],queryFn:()=>hs("invite")}),{mutateAsync:i}=as({mutationFn:fs,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(ve.debounce(async o=>{if(!ve.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"invite_force",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(M,{children:s("invite.invite_force.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"invite_commission",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("invite.invite_commission.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("invite.invite_gen_limit.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(M,{children:s("invite.invite_never_expire.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(M,{children:s("invite.commission_first_time.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(M,{children:s("invite.commission_auto_check.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(w,{children:e.jsx(D,{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(M,{children:s("invite.commission_withdraw_method.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(M,{children:s("invite.withdraw_close.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(M,{children:s("invite.commission_distribution.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:s("invite.commission_distribution.l1")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})}),e.jsx(y,{control:r.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:s("invite.commission_distribution.l2")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})}),e.jsx(y,{control:r.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:s("invite.commission_distribution.l3")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.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("invite.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("invite.description")})]}),e.jsx(ye,{}),e.jsx(ym,{})]})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:Nm},Symbol.toStringTag,{value:"Module"})),wm=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()}),Cm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Sm(){const{data:s}=se({queryKey:["settings","frontend"],queryFn:()=>hs("frontend")}),n=de({resolver:me(wm),defaultValues:Cm,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){fs(l).then(({data:r})=>{r&&q.success("更新成功")})}return e.jsx(ue,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(y,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:"边栏风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(w,{children:e.jsx(H,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(y,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:"头部风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(w,{children:e.jsx(H,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(y,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(b,{children:[e.jsx(N,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(w,{children:e.jsxs("select",{className:_(Bs({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(ca,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(M,{children:"主题色"}),e.jsx(E,{})]})}),e.jsx(y,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(b,{children:[e.jsx(N,{children:"背景"}),e.jsx(w,{children:e.jsx(D,{placeholder:"请输入图片地址",...l})}),e.jsx(M,{children:"将会在后台登录页面进行展示。"}),e.jsx(E,{})]})}),e.jsx(V,{type:"submit",children:"保存设置"})]})})}function km(){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(ye,{}),e.jsx(Sm,{})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:km},Symbol.toStringTag,{value:"Module"})),Tm=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()}),Dm={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Em(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(Tm),defaultValues:Dm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","server"],queryFn:()=>hs("server")}),{mutateAsync:i}=as({mutationFn:fs,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,T])=>{r.setValue(p,T)}),l.current=d}},[c]);const u=m.useCallback(ve.debounce(async d=>{if(!ve.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 T="";for(let R=0;Re.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.server_token.title")}),e.jsx(w,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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(ri,{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(M,{children:s("server.server_token.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const T=p.target.value?Number(p.target.value):null;d.onChange(T)}})}),e.jsx(M,{children:s("server.server_pull_interval.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const T=p.target.value?Number(p.target.value):null;d.onChange(T)}})}),e.jsx(M,{children:s("server.server_push_interval.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(G,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(L,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(M,{children:s("server.device_limit_mode.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Rm(){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(ye,{}),e.jsx(Em,{})]})}const Vm=Object.freeze(Object.defineProperty({__proto__:null,default:Rm},Symbol.toStringTag,{value:"Module"}));function Im({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(pe,{open:s,onOpenChange:n,children:e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Mn,{className:"h-5 w-5 text-green-500"}):e.jsx(On,{className:"h-5 w-5 text-destructive"}),e.jsx(ge,{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(lt,{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 Fm=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 Mm(){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=de({resolver:me(Fm),defaultValues:{},mode:"onBlur"}),{data:o}=se({queryKey:["settings","email"],queryFn:()=>hs("email")}),{data:d}=se({queryKey:["emailTemplate"],queryFn:()=>Vd()}),{mutateAsync:p}=as({mutationFn:fs,onSuccess:S=>{S.data&&q.success(s("common.autoSaved"))}}),{mutate:T,isPending:R}=as({mutationFn:Id,onMutate:()=>{a(null),r(!1)},onSuccess:S=>{a(S.data),r(!0),S.data.error?q.error(s("email.test.error")):q.success(s("email.test.success"))}});m.useEffect(()=>{if(o?.data.email){const S=o.data.email;Object.entries(S).forEach(([j,C])=>{x.setValue(j,C)}),c.current=S}},[o]);const f=m.useCallback(ve.debounce(async S=>{if(!ve.isEqual(S,c.current)){u(!0);try{await p(S),c.current=S}finally{u(!1)}}},1e3),[p]),g=m.useCallback(S=>{f(S)},[f]);return m.useEffect(()=>{const S=x.watch(j=>{g(j)});return()=>S.unsubscribe()},[x.watch,g]),e.jsxs(e.Fragment,{children:[e.jsx(ue,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:x.control,name:"email_host",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_host.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_host.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_port",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_port.title")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...S,value:S.value||"",onChange:j=>{const C=j.target.value?Number(j.target.value):null;S.onChange(C)}})}),e.jsx(M,{children:s("email.email_port.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_encryption",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(G,{onValueChange:S.onChange,value:S.value||"none",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(L,{value:"none",children:s("email.email_encryption.none")}),e.jsx(L,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(L,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(M,{children:s("email.email_encryption.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_username",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_username.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_username.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_password",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_password.title")}),e.jsx(w,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_password.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_from_address",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_from.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_from.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_template",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(G,{onValueChange:j=>{S.onChange(j),g(x.getValues())},value:S.value||void 0,children:[e.jsx(w,{children:e.jsx(U,{className:"w-[200px]",children:e.jsx(W,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(B,{children:d?.data?.map(j=>e.jsx(L,{value:j,children:j},j))})]}),e.jsx(M,{children:s("email.email_template.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"remind_mail_enable",render:({field:S})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(M,{children:s("email.remind_mail.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:S.value||!1,onCheckedChange:j=>{S.onChange(j),g(x.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(V,{onClick:()=>T(),loading:R,disabled:R,children:s(R?"test.sending":"test.title")})})]})}),i&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Im,{open:l,onOpenChange:r,result:n})]})}function Om(){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(ye,{}),e.jsx(Mm,{})]})}const zm=Object.freeze(Object.defineProperty({__proto__:null,default:Om},Symbol.toStringTag,{value:"Module"})),Lm=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Am={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function $m(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(Lm),defaultValues:Am,mode:"onBlur"}),{data:c}=se({queryKey:["settings","telegram"],queryFn:()=>hs("telegram")}),{mutateAsync:i}=as({mutationFn:fs,onSuccess:p=>{p.data&&q.success(s("common.autoSaved"))}}),{mutate:u,isPending:x}=as({mutationFn:Fd,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(([T,R])=>{r.setValue(T,R)}),l.current=p}},[c]);const o=m.useCallback(ve.debounce(async p=>{if(!ve.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(T=>{d(T)});return()=>p.unsubscribe()},[r.watch,d]),e.jsx(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"telegram_bot_token",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...p,value:p.value||""})}),e.jsx(M,{children:s("telegram.bot_token.description")}),e.jsx(E,{})]})}),r.watch("telegram_bot_token")&&e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(V,{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(M,{children:s("telegram.webhook.description")}),e.jsx(E,{})]}),e.jsx(y,{control:r.control,name:"telegram_bot_enable",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(M,{children:s("telegram.bot_enable.description")}),e.jsx(w,{children:e.jsx(H,{checked:p.value||!1,onCheckedChange:T=>{p.onChange(T),d(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"telegram_discuss_link",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...p,value:p.value||""})}),e.jsx(M,{children:s("telegram.discuss_link.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function qm(){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(ye,{}),e.jsx($m,{})]})}const Km=Object.freeze(Object.defineProperty({__proto__:null,default:qm},Symbol.toStringTag,{value:"Module"})),Hm=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()}),Um={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Bm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(Hm),defaultValues:Um,mode:"onBlur"}),{data:c}=se({queryKey:["settings","app"],queryFn:()=>hs("app")}),{mutateAsync:i}=as({mutationFn:fs,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(ve.debounce(async o=>{if(!ve.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"windows_version",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.windows.version.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"windows_download_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.windows.download.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"macos_version",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.macos.version.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"macos_download_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.macos.download.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"android_version",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.android.version.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.android.version.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"android_download_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.android.download.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.android.download.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Gm(){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(ye,{}),e.jsx(Bm,{})]})}const Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"})),fa=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:_("w-full caption-bottom text-sm",s),...n})}));fa.displayName="Table";const pa=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:_("[&_tr]:border-b",s),...n}));pa.displayName="TableHeader";const ga=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:_("[&_tr:last-child]:border-0",s),...n}));ga.displayName="TableBody";const Ym=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:_("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Ym.displayName="TableFooter";const ys=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:_("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));ys.displayName="TableRow";const ja=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:_("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}));ja.displayName="TableHead";const Ks=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:_("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Ks.displayName="TableCell";const Jm=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:_("mt-4 text-sm text-muted-foreground",s),...n}));Jm.displayName="TableCaption";function Qm({table:s}){const[n,a]=m.useState(""),{t:l}=I("common");m.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const r=c=>{const i=parseInt(c);!isNaN(i)&&i>=1&&i<=s.getPageCount()?s.setPageIndex(i-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.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:l("table.pagination.selected",{selected:s.getFilteredSelectedRowModel().rows.length,total: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:l("table.pagination.itemsPerPage")}),e.jsxs(G,{value:`${s.getState().pagination.pageSize}`,onValueChange:c=>{s.setPageSize(Number(c))},children:[e.jsx(U,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(c=>e.jsx(L,{value:`${c}`,children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:l("table.pagination.page")}),e.jsx(D,{type:"text",value:n,onChange:c=>a(c.target.value),onBlur:c=>r(c.target.value),onKeyDown:c=>{c.key==="Enter"&&r(c.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:l("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(V,{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:l("table.pagination.firstPage")}),e.jsx(li,{className:"h-4 w-4"})]}),e.jsxs(V,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.previousPage")}),e.jsx(En,{className:"h-4 w-4"})]}),e.jsxs(V,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.nextPage")}),e.jsx(oa,{className:"h-4 w-4"})]}),e.jsxs(V,{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:l("table.pagination.lastPage")}),e.jsx(oi,{className:"h-4 w-4"})]})]})]})]})}function es({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:u,showPagination:x=!0,isLoading:o=!1}){const{t:d}=I("common"),p=m.useRef(null),T=s.getAllColumns().filter(S=>S.getIsPinned()==="left"),R=s.getAllColumns().filter(S=>S.getIsPinned()==="right"),f=S=>T.slice(0,S).reduce((j,C)=>j+(C.getSize()??0),0),g=S=>R.slice(S+1).reduce((j,C)=>j+(C.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:p,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(fa,{children:[e.jsx(pa,{children:s.getHeaderGroups().map(S=>e.jsx(ys,{className:"hover:bg-transparent",children:S.headers.map((j,C)=>{const k=j.column.getIsPinned()==="left",v=j.column.getIsPinned()==="right",P=k?f(T.indexOf(j.column)):void 0,z=v?g(R.indexOf(j.column)):void 0;return e.jsx(ja,{colSpan:j.colSpan,style:{width:j.getSize(),...k&&{left:P},...v&&{right:z}},className:_("h-11 bg-card px-4 text-muted-foreground",(k||v)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",k&&"before:right-0",v&&"before:left-0"]),children:j.isPlaceholder?null:Nt(j.column.columnDef.header,j.getContext())},j.id)})},S.id))}),e.jsx(ga,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((S,j)=>e.jsx(ys,{"data-state":S.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:C=>l?.(C,j),onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:C=>u?.(C,j),children:S.getVisibleCells().map((C,k)=>{const v=C.column.getIsPinned()==="left",P=C.column.getIsPinned()==="right",z=v?f(T.indexOf(C.column)):void 0,Q=P?g(R.indexOf(C.column)):void 0;return e.jsx(Ks,{style:{width:C.column.getSize(),...v&&{left:z},...P&&{right:Q}},className:_("bg-card",(v||P)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",v&&"before:right-0",P&&"before:left-0"]),children:Nt(C.column.columnDef.cell,C.getContext())},C.id)})},S.id)):e.jsx(ys,{children:e.jsx(Ks,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:d("table.noData")})})})]})})}),x&&e.jsx(Qm,{table:s})]})}const Zm=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())}),Ha={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function Sr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Ha}){const{t:r}=I("payment"),[c,i]=m.useState(!1),[u,x]=m.useState(!1),[o,d]=m.useState([]),[p,T]=m.useState([]),R=Zm(r),f=de({resolver:me(R),defaultValues:l,mode:"onChange"}),g=f.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:C}=await Zc();d(C)})()},[c]),m.useEffect(()=>{if(!g||!c)return;(async()=>{const C={payment:g,...a==="edit"&&{id:Number(f.getValues("id"))}};Xc(C).then(({data:k})=>{T(k);const v=k.reduce((P,z)=>(z.field_name&&(P[z.field_name]=z.value??""),P),{});f.setValue("config",v)})})()},[g,c,f,a]);const S=async j=>{x(!0);try{(await ed(j)).data&&(q.success(r("form.messages.success")),f.reset(Ha),s(),i(!1))}finally{x(!1)}};return e.jsxs(pe,{open:c,onOpenChange:i,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(ge,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(ue,{...f,children:e.jsxs("form",{onSubmit:f.handleSubmit(S),className:"space-y-4",children:[e.jsx(y,{control:f.control,name:"name",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:r("form.fields.name.placeholder"),...j})}),e.jsx(M,{children:r("form.fields.name.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"icon",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.icon.label")}),e.jsx(w,{children:e.jsx(D,{...j,value:j.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(M,{children:r("form.fields.icon.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"notify_domain",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.notify_domain.label")}),e.jsx(w,{children:e.jsx(D,{...j,value:j.value||"",placeholder:r("form.fields.notify_domain.placeholder")})}),e.jsx(M,{children:r("form.fields.notify_domain.description")}),e.jsx(E,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(y,{control:f.control,name:"handling_fee_percent",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(w,{children:e.jsx(D,{type:"number",...j,value:j.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"handling_fee_fixed",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(w,{children:e.jsx(D,{type:"number",...j,value:j.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(E,{})]})})]}),e.jsx(y,{control:f.control,name:"payment",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.payment.label")}),e.jsxs(G,{onValueChange:j.onChange,defaultValue:j.value,children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(B,{children:o.map(C=>e.jsx(L,{value:C,children:C},C))})]}),e.jsx(M,{children:r("form.fields.payment.description")}),e.jsx(E,{})]})}),p.length>0&&e.jsx("div",{className:"space-y-4",children:p.map(j=>e.jsx(y,{control:f.control,name:`config.${j.field_name}`,render:({field:C})=>e.jsxs(b,{children:[e.jsx(N,{children:j.label}),e.jsx(w,{children:e.jsx(D,{...C,value:C.value||""})}),e.jsx(E,{})]})},j.field_name))}),e.jsxs(Le,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(V,{type:"submit",disabled:u,children:r("form.buttons.submit")})]})]})})]})]})}function O({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(V,{variant:"ghost",size:"default",className:_("-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(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(Va,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(te,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(Jt,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Qt,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ii,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:_("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(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsx(Va,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(te,{children:a})]})})]})}const Xm=ci,eu=di,su=mi,kr=m.forwardRef(({className:s,...n},a)=>e.jsx(An,{className:_("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}));kr.displayName=An.displayName;const Pr=m.forwardRef(({className:s,...n},a)=>e.jsxs(su,{children:[e.jsx(kr,{}),e.jsx($n,{ref:a,className:_("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})]}));Pr.displayName=$n.displayName;const Tr=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});Tr.displayName="AlertDialogHeader";const Dr=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Dr.displayName="AlertDialogFooter";const Er=m.forwardRef(({className:s,...n},a)=>e.jsx(qn,{ref:a,className:_("text-lg font-semibold",s),...n}));Er.displayName=qn.displayName;const Rr=m.forwardRef(({className:s,...n},a)=>e.jsx(Kn,{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Rr.displayName=Kn.displayName;const Vr=m.forwardRef(({className:s,...n},a)=>e.jsx(Hn,{ref:a,className:_(Us(),s),...n}));Vr.displayName=Hn.displayName;const Ir=m.forwardRef(({className:s,...n},a)=>e.jsx(Un,{ref:a,className:_(Us({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Ir.displayName=Un.displayName;function Ue({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:u}){return e.jsxs(Xm,{children:[e.jsx(eu,{asChild:!0,children:n}),e.jsxs(Pr,{className:_("sm:max-w-[425px]",u),children:[e.jsxs(Tr,{children:[e.jsx(Er,{children:a}),e.jsx(Rr,{children:l})]}),e.jsxs(Dr,{children:[e.jsx(Ir,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r})}),e.jsx(Vr,{asChild:!0,children:e.jsx(V,{variant:i,onClick:s,children:c})})]})]})]})}const Fr=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"})}),tu=({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(Rt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{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(O,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(H,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await td({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(O,{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(O,{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(O,{column:l,title:a("table.columns.notify_url")}),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{className:"ml-1",children:e.jsx(Fr,{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(O,{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(Sr,{refetch:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{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(Ue,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await sd({id:l.original.id});r&&s()},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(ns,{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 au({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(Sr,{refetch:n}),e.jsx(D,{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(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function nu(){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:T}=se({queryKey:["paymentList"],queryFn:async()=>{const{data:j}=await Qc();return u(j?.map(C=>({...C,enable:!!C.enable}))||[]),j}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const R=(j,C)=>{r&&(j.dataTransfer.setData("text/plain",C.toString()),j.currentTarget.classList.add("opacity-50"))},f=(j,C)=>{if(!r)return;j.preventDefault(),j.currentTarget.classList.remove("bg-muted");const k=parseInt(j.dataTransfer.getData("text/plain"));if(k===C)return;const v=[...i],[P]=v.splice(k,1);v.splice(C,0,P),u(v)},g=async()=>{r?ad({ids:i.map(j=>j.id)}).then(()=>{T(),c(!1),q.success("排序保存成功")}):c(!0)},S=Ke({data:i,columns:tu({refetch:T,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(es,{table:S,toolbar:j=>e.jsx(au,{table:j,refetch:T,saveOrder:g,isSortMode:r}),draggable:r,onDragStart:R,onDragEnd:j=>j.currentTarget.classList.remove("opacity-50"),onDragOver:j=>{j.preventDefault(),j.currentTarget.classList.add("bg-muted")},onDragLeave:j=>j.currentTarget.classList.remove("bg-muted"),onDrop:f,showPagination:!r})}function ru(){const{t:s}=I("payment");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Ie,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(nu,{})})]})]})}const lu=Object.freeze(Object.defineProperty({__proto__:null,default:ru},Symbol.toStringTag,{value:"Module"}));function ou({pluginName:s,onClose:n,onSuccess:a}){const{t:l}=I("plugin"),[r,c]=m.useState(!0),[i,u]=m.useState(!1),[x,o]=m.useState(null),d=ui({config:xi(hi())}),p=de({resolver:me(d),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:g}=await Ds.getPluginConfig(s);o(g),p.reset({config:Object.fromEntries(Object.entries(g).map(([S,j])=>[S,j.value]))})}catch{q.error(l("messages.configLoadError"))}finally{c(!1)}})()},[s]);const T=async f=>{u(!0);try{await Ds.updatePluginConfig(s,f.config),q.success(l("messages.configSaveSuccess")),a()}catch{q.error(l("messages.configSaveError"))}finally{u(!1)}},R=(f,g)=>{switch(g.type){case"string":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsx(w,{children:e.jsx(D,{placeholder:g.placeholder,...S})}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);case"number":case"percentage":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsx(w,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:g.placeholder,...S,onChange:j=>{const C=Number(j.target.value);g.type==="percentage"?S.onChange(Math.min(100,Math.max(0,C))):S.onChange(C)},className:g.type==="percentage"?"pr-8":"",min:g.type==="percentage"?0:void 0,max:g.type==="percentage"?100:void 0,step:g.type==="percentage"?1:void 0}),g.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(fi,{className:"h-4 w-4 text-muted-foreground"})})]})}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);case"select":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsxs(G,{onValueChange:S.onChange,defaultValue:S.value,children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:g.placeholder})})}),e.jsx(B,{children:g.options?.map(j=>e.jsx(L,{value:j.value,children:j.label},j.value))})]}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);case"boolean":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:g.label||g.description}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description})]}),e.jsx(w,{children:e.jsx(H,{checked:S.value,onCheckedChange:S.onChange})})]})},f);case"text":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsx(w,{children:e.jsx(ps,{placeholder:g.placeholder,...S})}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);default:return null}};return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{className:"h-4 w-[200px]"}),e.jsx(le,{className:"h-10 w-full"}),e.jsx(le,{className:"h-4 w-[200px]"}),e.jsx(le,{className:"h-10 w-full"})]}):e.jsx(ue,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(T),className:"space-y-4",children:[x&&Object.entries(x).map(([f,g])=>R(f,g)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:n,disabled:i,children:l("config.cancel")}),e.jsx(V,{type:"submit",loading:i,disabled:i,children:l("config.save")})]})]})})}function iu(){const{t:s}=I("plugin"),[n,a]=m.useState(null),[l,r]=m.useState(!1),[c,i]=m.useState(null),[u,x]=m.useState(""),[o,d]=m.useState("all"),{data:p,isLoading:T,refetch:R}=se({queryKey:["pluginList"],queryFn:async()=>{const{data:v}=await Ds.getPluginList();return v}}),f=p?["all",...new Set(p.map(v=>v.category||"other"))]:["all"],g=p?.filter(v=>{const P=v.name.toLowerCase().includes(u.toLowerCase())||v.description.toLowerCase().includes(u.toLowerCase())||v.code.toLowerCase().includes(u.toLowerCase()),z=o==="all"||v.category===o;return P&&z}),S=async v=>{a(v),Ds.installPlugin(v).then(()=>{q.success(s("messages.installSuccess")),R()}).catch(P=>{q.error(P.message||s("messages.installError"))}).finally(()=>{a(null)})},j=async v=>{a(v),Ds.uninstallPlugin(v).then(()=>{q.success(s("messages.uninstallSuccess")),R()}).catch(P=>{q.error(P.message||s("messages.uninstallError"))}).finally(()=>{a(null)})},C=async(v,P)=>{a(v),(P?Ds.disablePlugin:Ds.enablePlugin)(v).then(()=>{q.success(s(P?"messages.disableSuccess":"messages.enableSuccess")),R()}).catch(Q=>{q.error(Q.message||s(P?"messages.disableError":"messages.enableError"))}).finally(()=>{a(null)})},k=v=>{p?.find(P=>P.code===v),i(v),r(!0)};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ia,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(gn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:u,onChange:v=>x(v.target.value),className:"pl-9"})]}),e.jsxs(G,{value:o,onValueChange:d,children:[e.jsx(U,{className:"w-[180px]",children:e.jsx(W,{placeholder:s("category.placeholder")})}),e.jsx(B,{children:f.map(v=>e.jsx(L,{value:v,children:s(`category.${v}`)},v))})]})]}),e.jsxs(ha,{defaultValue:"all",className:"w-full",children:[e.jsxs(Ot,{children:[e.jsx(Ns,{value:"all",children:s("tabs.all")}),e.jsx(Ns,{value:"installed",children:s("tabs.installed")}),e.jsx(Ns,{value:"available",children:s("tabs.available")})]}),e.jsx(bt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:T?e.jsxs(e.Fragment,{children:[e.jsx(Ht,{}),e.jsx(Ht,{}),e.jsx(Ht,{})]}):g?.map(v=>e.jsx(Kt,{plugin:v,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:k,isLoading:n===v.name},v.name))})}),e.jsx(bt,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g?.filter(v=>v.is_installed).map(v=>e.jsx(Kt,{plugin:v,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:k,isLoading:n===v.name},v.name))})}),e.jsx(bt,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g?.filter(v=>!v.is_installed).map(v=>e.jsx(Kt,{plugin:v,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:k,isLoading:n===v.name},v.code))})})]})]}),e.jsx(pe,{open:l,onOpenChange:r,children:e.jsxs(he,{className:"sm:max-w-lg",children:[e.jsxs(be,{children:[e.jsxs(ge,{children:[p?.find(v=>v.code===c)?.name," ",s("config.title")]}),e.jsx(Te,{children:s("config.description")})]}),c&&e.jsx(ou,{pluginName:c,onClose:()=>r(!1),onSuccess:()=>{r(!1),R()}})]})})]})]})}function Kt({plugin:s,onInstall:n,onUninstall:a,onToggleEnable:l,onOpenConfig:r,isLoading:c}){const{t:i}=I("plugin");return e.jsxs(Me,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs($e,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cs,{children:s.name}),s.is_installed&&e.jsx(K,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?i("status.enabled"):i("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ia,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Hs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[i("author"),": ",s.author]})})]})})]}),e.jsx(qe,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>r(s.code),disabled:!s.is_enabled||c,children:[e.jsx(pi,{className:"mr-2 h-4 w-4"}),i("button.config")]}),e.jsxs(V,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>l(s.code,s.is_enabled),disabled:c,children:[e.jsx(gi,{className:"mr-2 h-4 w-4"}),s.is_enabled?i("button.disable"):i("button.enable")]}),e.jsx(Ue,{title:i("uninstall.title"),description:i("uninstall.description"),confirmText:i("uninstall.button"),variant:"destructive",onConfirm:()=>a(s.code),children:e.jsx(V,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:c,children:e.jsx(ns,{className:"h-4 w-4"})})})]}):e.jsx(V,{onClick:()=>n(s.code),disabled:c,loading:c,children:i("button.install")})})})]})}function Ht(){return e.jsxs(Me,{children:[e.jsxs($e,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-6 w-[200px]"}),e.jsx(le,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(le,{className:"h-5 w-[120px]"}),e.jsx(le,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(le,{className:"h-4 w-[300px]"}),e.jsx(le,{className:"h-4 w-[150px]"})]})]}),e.jsx(qe,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(le,{className:"h-9 w-[100px]"}),e.jsx(le,{className:"h-9 w-[100px]"}),e.jsx(le,{className:"h-8 w-8"})]})})]})}const cu=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),du=(s,n)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(D,{placeholder:s.placeholder,...n});break;case"textarea":a=e.jsx(ps,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:_(Us({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 mu({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=de({defaultValues:n.configs.reduce((T,R)=>(T[R.field_name]="",T),{})}),d=async()=>{i(!0),Oc(s).then(({data:T})=>{Object.entries(T).forEach(([R,f])=>{o.setValue(R,f)})}).finally(()=>{i(!1)})},p=async T=>{x(!0),zc(s,T).then(()=>{q.success(a("config.success")),r(!1)}).finally(()=>{x(!1)})};return e.jsxs(pe,{open:l,onOpenChange:T=>{r(T),T?d():o.reset()},children:[e.jsx(ze,{asChild:!0,children:e.jsx(V,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(he,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(ge,{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(da,{className:"h-6 w-6 animate-spin"})}):e.jsx(ue,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(p),className:"space-y-4",children:[n.configs.map(T=>e.jsx(y,{control:o.control,name:T.field_name,render:({field:R})=>e.jsxs(b,{children:[e.jsx(N,{children:T.label}),e.jsx(w,{children:du(T,R)}),e.jsx(E,{})]})},T.field_name)),e.jsxs(Le,{className:"mt-6 gap-2",children:[e.jsx(V,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(V,{type:"submit",loading:u,children:a("config.save")})]})]})})]})]})}function uu(){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),[T,R]=m.useState(0),{data:f,isLoading:g,refetch:S}=se({queryKey:["themeList"],queryFn:async()=>{const{data:$}=await Mc();return $}}),j=async $=>{a($),$c({frontend_theme:$}).then(()=>{q.success("主题切换成功"),S()}).finally(()=>{a(null)})},C=async $=>{if(!$.name.endsWith(".zip")){q.error(s("upload.error.format"));return}r(!0),Lc($).then(()=>{q.success("主题上传成功"),i(!1),S()}).finally(()=>{r(!1),p.current&&(p.current.value="")})},k=$=>{$.preventDefault(),$.stopPropagation(),$.type==="dragenter"||$.type==="dragover"?x(!0):$.type==="dragleave"&&x(!1)},v=$=>{$.preventDefault(),$.stopPropagation(),x(!1),$.dataTransfer.files&&$.dataTransfer.files[0]&&C($.dataTransfer.files[0])},P=()=>{o&&R($=>$===0?o.images.length-1:$-1)},z=()=>{o&&R($=>$===o.images.length-1?0:$+1)},Q=($,X)=>{R(0),d({name:$,images:X})};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Ie,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(V,{onClick:()=>i(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Yt,{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:g?e.jsxs(e.Fragment,{children:[e.jsx(Ua,{}),e.jsx(Ua,{})]}):f?.themes&&Object.entries(f.themes).map(([$,X])=>e.jsx(Me,{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:_("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(Ue,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if($===f?.active){q.error(s("card.delete.error.active"));return}a($),Ac($).then(()=>{q.success("主题删除成功"),S()}).finally(()=>{a(null)})},children:e.jsx(V,{disabled:n===$,loading:n===$,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(ns,{className:"h-4 w-4"})})})}),e.jsxs($e,{children:[e.jsx(cs,{children:X.name}),e.jsx(Hs,{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(qe,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(V,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(X.name,X.images),children:e.jsx(ji,{className:"h-4 w-4"})}),e.jsx(mu,{themeKey:$,themeInfo:X}),e.jsx(V,{onClick:()=>j($),disabled:n===$||$===f.active,loading:n===$,variant:$===f.active?"secondary":"default",children:$===f.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},$))}),e.jsx(pe,{open:c,onOpenChange:i,children:e.jsxs(he,{className:"sm:max-w-md",children:[e.jsxs(be,{children:[e.jsx(ge,{children:s("upload.title")}),e.jsx(Te,{children:s("upload.description")})]}),e.jsxs("div",{className:_("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:k,onDragLeave:k,onDragOver:k,onDrop:v,children:[e.jsx("input",{type:"file",ref:p,className:"hidden",accept:".zip",onChange:$=>{const X=$.target.files?.[0];X&&C(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(Yt,{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(pe,{open:!!o,onOpenChange:$=>{$||(d(null),R(0))},children:e.jsxs(he,{className:"max-w-4xl",children:[e.jsxs(be,{children:[e.jsxs(ge,{children:[o?.name," ",s("preview.title")]}),e.jsx(Te,{className:"text-center",children:o&&s("preview.imageCount",{current:T+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[T]&&e.jsx("img",{src:o.images[T],alt:`${o.name} 预览图 ${T+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(V,{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:P,children:e.jsx(vi,{className:"h-4 w-4"})}),e.jsx(V,{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(bi,{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(($,X)=>e.jsx("button",{onClick:()=>R(X),className:_("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",T===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:$,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function Ua(){return e.jsxs(Me,{children:[e.jsxs($e,{children:[e.jsx(le,{className:"h-6 w-[200px]"}),e.jsx(le,{className:"h-4 w-[300px]"})]}),e.jsxs(qe,{className:"flex items-center justify-end space-x-3",children:[e.jsx(le,{className:"h-10 w-[100px]"}),e.jsx(le,{className:"h-10 w-[100px]"})]})]})}const xu=Object.freeze(Object.defineProperty({__proto__:null,default:uu},Symbol.toStringTag,{value:"Module"})),va=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:_(" 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(Zt,{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})]})});va.displayName="InputTags";const hu=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()}),fu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Mr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=fu}){const{t:r}=I("notice"),[c,i]=m.useState(!1),u=de({resolver:me(hu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new ma({html:!0});return e.jsx(ue,{...u,children:e.jsxs(pe,{onOpenChange:i,open:c,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(he,{className:"sm:max-w-[1025px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Te,{})]}),e.jsx(y,{control:u.control,name:"title",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(w,{children:e.jsx(D,{placeholder:r("form.fields.title.placeholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"content",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.content.label")}),e.jsx(w,{children:e.jsx(ua,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"img_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"show",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"tags",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.tags.label")}),e.jsx(w,{children:e.jsx(va,{value:o.value,onChange:o.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(V,{type:"submit",onClick:o=>{o.preventDefault(),u.handleSubmit(async d=>{nd(d).then(({data:p})=>{p&&(q.success(r("form.buttons.success")),s(),i(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function pu({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(Mr,{refetch:n}),!l&&e.jsx(D,{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(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(V,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const gu=s=>{const{t:n}=I("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(yi,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{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(O,{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 ld({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(O,{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(O,{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(Mr,{refetch:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{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(Ue,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{rd({id:a.original.id}).then(()=>{q.success(n("table.actions.delete.success")),s()})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 ju(){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({}),[T,R]=m.useState({pageSize:50,pageIndex:0}),[f,g]=m.useState([]),{refetch:S}=se({queryKey:["notices"],queryFn:async()=>{const{data:P}=await qa.getList();return g(P),P}});m.useEffect(()=>{l({"drag-handle":x,content:!x,created_at:!x,actions:!x}),R({pageSize:x?99999:50,pageIndex:0})},[x]);const j=(P,z)=>{x&&(P.dataTransfer.setData("text/plain",z.toString()),P.currentTarget.classList.add("opacity-50"))},C=(P,z)=>{if(!x)return;P.preventDefault(),P.currentTarget.classList.remove("bg-muted");const Q=parseInt(P.dataTransfer.getData("text/plain"));if(Q===z)return;const $=[...f],[X]=$.splice(Q,1);$.splice(z,0,X),g($)},k=async()=>{if(!x){o(!0);return}qa.sort(f.map(P=>P.id)).then(()=>{q.success("排序保存成功"),o(!1),S()}).finally(()=>{o(!1)})},v=Ke({data:f??[],columns:gu(S),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:T},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:p,onPaginationChange:R,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(es,{table:v,toolbar:P=>e.jsx(pu,{table:P,refetch:S,saveOrder:k,isSortMode:x}),draggable:x,onDragStart:j,onDragEnd:P=>P.currentTarget.classList.remove("opacity-50"),onDragOver:P=>{P.preventDefault(),P.currentTarget.classList.add("bg-muted")},onDragLeave:P=>P.currentTarget.classList.remove("bg-muted"),onDrop:C,showPagination:!x})})}function vu(){const{t:s}=I("notice");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Ie,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(ju,{})})]})]})}const bu=Object.freeze(Object.defineProperty({__proto__:null,default:vu},Symbol.toStringTag,{value:"Module"})),yu=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()}),Nu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function Or({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Nu}){const{t:r}=I("knowledge"),[c,i]=m.useState(!1),u=de({resolver:me(yu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new ma({html:!0});return m.useEffect(()=>{c&&l.id&&id(l.id).then(({data:o})=>{u.reset(o)})},[l.id,u,c]),e.jsxs(pe,{onOpenChange:i,open:c,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(he,{className:"sm:max-w-[1025px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Te,{})]}),e.jsxs(ue,{...u,children:[e.jsx(y,{control:u.control,name:"title",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(w,{children:e.jsx(D,{placeholder:r("form.titlePlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"category",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(w,{children:e.jsx(D,{placeholder:r("form.categoryPlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"language",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.language")}),e.jsx(w,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(U,{children:e.jsx(W,{placeholder:r("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx(L,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(y,{control:u.control,name:"body",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.content")}),e.jsx(w,{children:e.jsx(ua,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"show",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(V,{type:"submit",onClick:()=>{u.handleSubmit(o=>{cd(o).then(({data:d})=>{d&&(u.reset(),q.success(r("messages.operationSuccess")),i(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function _u({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{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(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(ke,{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:_("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(Rs,{className:_("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(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function wu({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(Or,{refreshData:n}),e.jsx(D,{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(_u,{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(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const Cu=({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(Rt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{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(O,{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()=>{md({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(O,{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(O,{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(O,{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(Or,{refreshData:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{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(Ue,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{dd({id:l.original.id}).then(({data:r})=>{r&&(q.success(a("messages.operationSuccess")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 Su(){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:T,isLoading:R,data:f}=se({queryKey:["knowledge"],queryFn:async()=>{const{data:k}=await od();return u(k||[]),k}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const g=(k,v)=>{r&&(k.dataTransfer.setData("text/plain",v.toString()),k.currentTarget.classList.add("opacity-50"))},S=(k,v)=>{if(!r)return;k.preventDefault(),k.currentTarget.classList.remove("bg-muted");const P=parseInt(k.dataTransfer.getData("text/plain"));if(P===v)return;const z=[...i],[Q]=z.splice(P,1);z.splice(v,0,Q),u(z)},j=async()=>{r?ud({ids:i.map(k=>k.id)}).then(()=>{T(),c(!1),q.success("排序保存成功")}):c(!0)},C=Ke({data:i,columns:Cu({refetch:T,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:C,toolbar:k=>e.jsx(wu,{table:k,refetch:T,saveOrder:j,isSortMode:r}),draggable:r,onDragStart:g,onDragEnd:k=>k.currentTarget.classList.remove("opacity-50"),onDragOver:k=>{k.preventDefault(),k.currentTarget.classList.add("bg-muted")},onDragLeave:k=>k.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!r})}function ku(){const{t:s}=I("knowledge");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(Su,{})})]})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:ku},Symbol.toStringTag,{value:"Module"}));function Tu(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function Ut(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 Du(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 Eu(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 zr=m.forwardRef(({className:s,...n},a)=>Ni(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:_("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);zr.displayName="CommandEmpty";const ot=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:T,groupBy:R,className:f,badgeClassName:g,selectFirstItem:S=!0,creatable:j=!1,triggerSearchOnFocus:C=!1,commandProps:k,inputProps:v,hideClearAllButton:P=!1},z)=>{const Q=m.useRef(null),[$,X]=m.useState(!1),Ws=m.useRef(!1),[Ca,Sa]=m.useState(!1),[ee,Ys]=m.useState(s||[]),[ks,ka]=m.useState(Ut(l,R)),[gs,Lt]=m.useState(""),Js=Tu(gs,c||500);m.useImperativeHandle(z,()=>({selectedValue:[...ee],input:Q.current,focus:()=>Q.current?.focus()}),[ee]);const ut=m.useCallback(Y=>{const ae=ee.filter(Ve=>Ve.value!==Y.value);Ys(ae),n?.(ae)},[n,ee]),ol=m.useCallback(Y=>{const ae=Q.current;ae&&((Y.key==="Delete"||Y.key==="Backspace")&&ae.value===""&&ee.length>0&&(ee[ee.length-1].fixed||ut(ee[ee.length-1])),Y.key==="Escape"&&ae.blur())},[ut,ee]);m.useEffect(()=>{s&&Ys(s)},[s]),m.useEffect(()=>{if(!r||i)return;const Y=Ut(r||[],R);JSON.stringify(Y)!==JSON.stringify(ks)&&ka(Y)},[l,r,R,i,ks]),m.useEffect(()=>{const Y=async()=>{Sa(!0);const Ve=await i?.(Js);ka(Ut(Ve||[],R)),Sa(!1)};(async()=>{!i||!$||(C&&await Y(),Js&&await Y())})()},[Js,R,$,C]);const il=()=>{if(!j||Eu(ks,[{value:gs,label:gs}])||ee.find(ae=>ae.value===gs))return;const Y=e.jsx(ke,{value:gs,className:"cursor-pointer",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onSelect:ae=>{if(ee.length>=o){d?.(ee.length);return}Lt("");const Ve=[...ee,{value:ae,label:ae}];Ys(Ve),n?.(Ve)},children:`Create "${gs}"`});if(!i&&gs.length>0||i&&Js.length>0&&!Ca)return Y},cl=m.useCallback(()=>{if(x)return i&&!j&&Object.keys(ks).length===0?e.jsx(ke,{value:"-",disabled:!0,children:x}):e.jsx(zr,{children:x})},[j,x,i,ks]),dl=m.useMemo(()=>Du(ks,ee),[ks,ee]),ml=m.useCallback(()=>{if(k?.filter)return k.filter;if(j)return(Y,ae)=>Y.toLowerCase().includes(ae.toLowerCase())?1:-1},[j,k?.filter]),ul=m.useCallback(()=>{const Y=ee.filter(ae=>ae.fixed);Ys(Y),n?.(Y)},[n,ee]);return e.jsxs(Cs,{...k,onKeyDown:Y=>{ol(Y),k?.onKeyDown?.(Y)},className:_("h-auto overflow-visible bg-transparent",k?.className),shouldFilter:k?.shouldFilter!==void 0?k.shouldFilter:!i,filter:ml(),children:[e.jsx("div",{className:_("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":!T&&ee.length!==0},f),onClick:()=>{T||Q.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(Y=>e.jsxs(K,{className:_("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",g),"data-fixed":Y.fixed,"data-disabled":T||void 0,children:[Y.label,e.jsx("button",{className:_("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(T||Y.fixed)&&"hidden"),onKeyDown:ae=>{ae.key==="Enter"&&ut(Y)},onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:()=>ut(Y),children:e.jsx(Zt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},Y.value)),e.jsx(De.Input,{...v,ref:Q,value:gs,disabled:T,onValueChange:Y=>{Lt(Y),v?.onValueChange?.(Y)},onBlur:Y=>{Ws.current===!1&&X(!1),v?.onBlur?.(Y)},onFocus:Y=>{X(!0),C&&i?.(Js),v?.onFocus?.(Y)},placeholder:p&&ee.length!==0?"":a,className:_("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},v?.className)}),e.jsx("button",{type:"button",onClick:ul,className:_((P||T||ee.length<1||ee.filter(Y=>Y.fixed).length===ee.length)&&"hidden"),children:e.jsx(Zt,{})})]})}),e.jsx("div",{className:"relative",children:$&&e.jsx(Ss,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Ws.current=!1},onMouseEnter:()=>{Ws.current=!0},onMouseUp:()=>{Q.current?.focus()},children:Ca?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[cl(),il(),!S&&e.jsx(ke,{value:"-",className:"hidden"}),Object.entries(dl).map(([Y,ae])=>e.jsx(Oe,{heading:Y,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ae.map(Ve=>e.jsx(ke,{value:Ve.value,disabled:Ve.disable,onMouseDown:Qs=>{Qs.preventDefault(),Qs.stopPropagation()},onSelect:()=>{if(ee.length>=o){d?.(ee.length);return}Lt("");const Qs=[...ee,Ve];Ys(Qs),n?.(Qs)},className:_("cursor-pointer",Ve.disable&&"cursor-default text-muted-foreground"),children:Ve.label},Ve.value))})},Y))]})})})]})});ot.displayName="MultipleSelector";const Ru=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 zt({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=I("group"),c=de({resolver:me(Ru(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1),[x,o]=m.useState(!1),d=async p=>{o(!0),Gc(p).then(()=>{q.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{o(!1)})};return e.jsxs(pe,{open:i,onOpenChange:u,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(ue,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(y,{control:c.control,name:"name",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.name")}),e.jsx(w,{children:e.jsx(D,{placeholder:r("form.namePlaceholder"),...p,className:"w-full"})}),e.jsx(M,{children:r("form.nameDescription")}),e.jsx(E,{})]})}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(mt,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(V,{type:"submit",disabled:x||!c.formState.isValid,children:[x&&e.jsx(da,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Lr=m.createContext(void 0);function Vu({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[i,u]=m.useState(Ne.Shadowsocks);return e.jsx(Lr.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:i,setServerType:u,refetch:n},children:s})}function Ar(){const s=m.useContext(Lr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Bt({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=j=>{if(!j)return null;try{const C=JSON.parse(j);return typeof C!="object"||C===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},T={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"}}}},R=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},f=()=>{const j=p(u||"");if(j){q.error(j);return}try{if(!u){a(null),i(!1);return}a(JSON.parse(u)),i(!1)}catch{q.error(r("network_settings.errors.save_failed"))}},g=j=>{x(j),d(p(j))},S=j=>{const C=T[j];if(C){const k=JSON.stringify(C.content,null,2);x(k),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(pe,{open:c,onOpenChange:j=>{!j&&c&&f(),i(j)},children:[e.jsx(ze,{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(be,{children:e.jsx(ge,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[R().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:R().map(j=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>S(j),children:r("network_settings.use_template",{template:T[j].label})},j))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ps,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:u,placeholder:R().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:j=>g(j.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Le,{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 Vh(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 Iu={},Fu=Object.freeze(Object.defineProperty({__proto__:null,default:Iu},Symbol.toStringTag,{value:"Module"})),Ih=Mi(Fu),Ba=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Mu=()=>{try{const s=_i.box.keyPair(),n=Ba(Ia.encodeBase64(s.secretKey)),a=Ba(Ia.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Ou=()=>{try{return Mu()}catch(s){throw console.error("Error generating key pair:",s),s}},zu=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)},Lu=()=>{const s=Math.floor(Math.random()*8)*2+2;return zu(s)},Au=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({})}),$u=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({})}),qu=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({})}),Ku=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({})}),Hu=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("")}),os={shadowsocks:{schema:Au,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:$u,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:qu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Ku,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Hu,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"]}},Uu=({serverType:s,value:n,onChange:a})=>{const{t:l}=I("server"),r=s?os[s]:null,c=r?.schema||h.record(h.any()),i=s?c.parse({}):{},u=de({resolver:me(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(g=>{a(g)});return()=>f.unsubscribe()},[u,a]),!s||!r)return null;const R={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(y,{control:u.control,name:"cipher",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.shadowsocks.ciphers.map(g=>e.jsx(L,{value:g,children:g},g))})})]})})]})}),e.jsx(y,{control:u.control,name:"obfs",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(js,{children:[e.jsx(L,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(L,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"obfs_settings.path",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...f})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"obfs_settings.host",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.host"),...f})}),e.jsx(E,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(y,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value?.toString(),onValueChange:g=>f.onChange(Number(g)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(L,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx(y,{control:u.control,name:"network",render:({field:f})=>e.jsxs(b,{children:[e.jsxs(N,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Bt,{value:u.watch("network_settings"),setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")})]}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.vmess.networkOptions.map(g=>e.jsx(L,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(y,{control:u.control,name:"allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(y,{control:u.control,name:"network",render:({field:f})=>e.jsxs(b,{children:[e.jsxs(N,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Bt,{value:u.watch("network_settings")||{},setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")||"tcp"})]}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value||"tcp",children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.trojan.networkOptions.map(g=>e.jsx(L,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"version",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(w,{children:e.jsxs(G,{value:(f.value||2).toString(),onValueChange:g=>f.onChange(Number(g)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.hysteria.versions.map(g=>e.jsxs(L,{value:g,className:"cursor-pointer",children:["V",g]},g))})})]})})]})}),u.watch("version")==1&&e.jsx(y,{control:u.control,name:"alpn",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value||"h2",onValueChange:f.onChange,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.hysteria.alpnOptions.map(g=>e.jsx(L,{value:g,children:g},g))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"obfs.open",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{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(y,{control:u.control,name:"obfs.type",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value||"salamander",onValueChange:f.onChange,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:e.jsx(L,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(y,{control:u.control,name:"obfs.password",render:({field:f})=>e.jsxs(b,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{children:e.jsx(D,{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 g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(j=>g[j%g.length]).join("");u.setValue("obfs.password",S),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(Se,{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(y,{control:u.control,name:"tls.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(y,{control:u.control,name:"tls.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(y,{control:u.control,name:"bandwidth.up",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{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(y,{control:u.control,name:"bandwidth.down",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{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(y,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.tls.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value?.toString(),onValueChange:g=>f.onChange(Number(g)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(L,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(L,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{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(y,{control:u.control,name:"reality_settings.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"reality_settings.server_port",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"reality_settings.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(y,{control:u.control,name:"reality_settings.private_key",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{children:e.jsx(D,{...f,className:"pr-9"})}),e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const g=Ou();u.setValue("reality_settings.private_key",g.privateKey),u.setValue("reality_settings.public_key",g.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(Se,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(_t,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(y,{control:u.control,name:"reality_settings.public_key",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(w,{children:e.jsx(D,{...f})})]})}),e.jsx(y,{control:u.control,name:"reality_settings.short_id",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{children:e.jsx(D,{...f,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const g=Lu();u.setValue("reality_settings.short_id",g),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(Se,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(_t,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(M,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(y,{control:u.control,name:"network",render:({field:f})=>e.jsxs(b,{children:[e.jsxs(N,{children:[l("dynamic_form.vless.network.label"),e.jsx(Bt,{value:u.watch("network_settings"),setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")})]}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.vless.networkOptions.map(g=>e.jsx(L,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})}),e.jsx(y,{control:u.control,name:"flow",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.flow.label")}),e.jsx(w,{children:e.jsxs(G,{onValueChange:g=>f.onChange(g==="none"?null:g),value:f.value||"none",children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:os.vless.flowOptions.map(g=>e.jsx(L,{value:g,children:g},g))})]})})]})})]})};return e.jsx(ce,{children:R[s]?.()})},Bu=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()}),ft={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Gu(){const{t:s}=I("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:i,refetch:u}=Ar(),[x,o]=m.useState([]),[d,p]=m.useState([]),[T,R]=m.useState([]),f=de({resolver:me(Bu),defaultValues:ft,mode:"onChange"});m.useEffect(()=>{g()},[n]),m.useEffect(()=>{l?.type&&l.type!==c&&i(l.type)},[l,c,i]),m.useEffect(()=>{l?l.type===c&&f.reset({...ft,...l}):f.reset({...ft,protocol_settings:os[c].schema.parse({})})},[l,f,c]);const g=async()=>{if(!n)return;const[v,P,z]=await Promise.all([Mt(),yr(),br()]);o(v.data?.map(Q=>({label:Q.name,value:Q.id.toString()}))||[]),p(P.data?.map(Q=>({label:Q.remarks,value:Q.id.toString()}))||[]),R(z.data||[])},S=m.useMemo(()=>T?.filter(v=>(v.parent_id===0||v.parent_id===null)&&v.type===c&&v.id!==f.watch("id")),[c,T,f]),j=()=>e.jsxs(_s,{children:[e.jsx(ws,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(ds,{align:"start",children:e.jsx(pc,{children:Ts.map(({type:v,label:P})=>e.jsx(je,{onClick:()=>{i(v),a(!0)},className:"cursor-pointer",children:e.jsx(K,{variant:"outline",className:"text-white",style:{background:is[v]},children:P})},v))})})]}),C=()=>{a(!1),r(null),f.reset(ft)},k=async()=>{const v=f.getValues();(await qc({...v,type:c})).data&&(C(),q.success(s("form.success")),u())};return e.jsxs(pe,{open:n,onOpenChange:C,children:[j(),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Te,{})]}),e.jsxs(ue,{...f,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:f.control,name:"name",render:({field:v})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:s("form.name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...v})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"rate",render:({field:v})=>e.jsxs(b,{className:"flex-[1]",children:[e.jsx(N,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(w,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...v})})}),e.jsx(E,{})]})})]}),e.jsx(y,{control:f.control,name:"code",render:({field:v})=>e.jsxs(b,{children:[e.jsxs(N,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(w,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...v,value:v.value||""})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"tags",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.tags.label")}),e.jsx(w,{children:e.jsx(va,{value:v.value,onChange:v.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"group_ids",render:({field:v})=>e.jsxs(b,{children:[e.jsxs(N,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(zt,{dialogTrigger:e.jsx(V,{variant:"link",children:s("form.groups.add")}),refetch:g})]}),e.jsx(w,{children:e.jsx(ot,{options:x,onChange:P=>v.onChange(P.map(z=>z.value)),value:x?.filter(P=>v.value.includes(P.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(E,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:f.control,name:"host",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.host.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...v})}),e.jsx(E,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(y,{control:f.control,name:"port",render:({field:v})=>e.jsxs(b,{className:"flex-1",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(Se,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(_t,{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(w,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...v})}),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const P=v.value;P&&f.setValue("server_port",P)},children:e.jsx(Se,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(te,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"server_port",render:({field:v})=>e.jsxs(b,{className:"flex-1",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(Se,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(_t,{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(w,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...v})}),e.jsx(E,{})]})})]})]}),n&&e.jsx(Uu,{serverType:c,value:f.watch("protocol_settings"),onChange:v=>f.setValue("protocol_settings",v,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(y,{control:f.control,name:"parent_id",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.parent.label")}),e.jsxs(G,{onValueChange:v.onChange,value:v.value?.toString()||"0",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("form.parent.none")}),S?.map(P=>e.jsx(L,{value:P.id.toString(),className:"cursor-pointer",children:P.name},P.id))]})]}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"route_ids",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.route.label")}),e.jsx(w,{children:e.jsx(ot,{options:d,onChange:P=>v.onChange(P.map(z=>z.value)),value:d?.filter(P=>v.value.includes(P.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(E,{})]})})]}),e.jsxs(Le,{className:"mt-6",children:[e.jsx(V,{type:"button",variant:"outline",onClick:C,children:s("form.cancel")}),e.jsx(V,{type:"submit",onClick:k,children:s("form.submit")})]})]})]})]})}function Ga({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{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(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(ke,{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:_("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(Rs,{className:_("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(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Wu=[{value:Ne.Shadowsocks,label:Ts.find(s=>s.type===Ne.Shadowsocks)?.label,color:is[Ne.Shadowsocks]},{value:Ne.Vmess,label:Ts.find(s=>s.type===Ne.Vmess)?.label,color:is[Ne.Vmess]},{value:Ne.Trojan,label:Ts.find(s=>s.type===Ne.Trojan)?.label,color:is[Ne.Trojan]},{value:Ne.Hysteria,label:Ts.find(s=>s.type===Ne.Hysteria)?.label,color:is[Ne.Hysteria]},{value:Ne.Vless,label:Ts.find(s=>s.type===Ne.Vless)?.label,color:is[Ne.Vless]}];function Yu({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(Gu,{}),e.jsx(D,{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(Ga,{column:s.getColumn("type"),title:c("toolbar.type"),options:Wu}),s.getColumn("groups")&&e.jsx(Ga,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:i})]}),r&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Ae,{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(V,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const it=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"})}),pt={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"},Ju=s=>{const{t:n}=I("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Rt,{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(O,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(K,{variant:"outline",className:_("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:is[a.original.type]},children:[e.jsx(Bn,{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(V,{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(),St(r||l.toString()).then(()=>{q.success(n("common:copy.success"))})},children:e.jsx(Fa,{className:"size-3"})})]})}),e.jsxs(te,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ts.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(O,{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),Uc({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?is[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{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:_("h-2.5 w-2.5 rounded-full",pt[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:_("h-2.5 w-2.5 rounded-full",pt[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:_("h-2.5 w-2.5 rounded-full",pt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:_("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",pt[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(O,{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(ce,{delayDuration:0,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{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(),St(l).then(()=>{q.success(n("common:copy.success"))})},children:e.jsx(Fa,{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(O,{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(it,{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(O,{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(O,{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:_("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(O,{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:is[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=Ar();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(_s,{modal:!1,children:[e.jsx(ws,{asChild:!0,children:e.jsx(V,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(wt,{className:"size-4"})})}),e.jsxs(ds,{align:"end",className:"w-40",children:[e.jsx(je,{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(wi,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(je,{className:"cursor-pointer",onClick:async()=>{Hc({id:a.original.id}).then(({data:i})=>{i&&(q.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Ci,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(rt,{}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:i=>i.preventDefault(),children:e.jsx(Ue,{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()=>{Kc({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(ns,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Qu(){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),[T,R]=m.useState({}),[f,g]=m.useState([]),{refetch:S}=se({queryKey:["nodeList"],queryFn:async()=>{const{data:z}=await br();return g(z),z}}),j=m.useMemo(()=>{const z=new Set;return f.forEach(Q=>{Q.groups&&Q.groups.forEach($=>z.add($.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}),R({name:d?2e3:200}),u({pageSize:d?99999:500,pageIndex:0})},[d]);const C=(z,Q)=>{d&&(z.dataTransfer.setData("text/plain",Q.toString()),z.currentTarget.classList.add("opacity-50"))},k=(z,Q)=>{if(!d)return;z.preventDefault(),z.currentTarget.classList.remove("bg-muted");const $=parseInt(z.dataTransfer.getData("text/plain"));if($===Q)return;const X=[...f],[Ws]=X.splice($,1);X.splice(Q,0,Ws),g(X)},v=async()=>{if(!d){p(!0);return}const z=f?.map((Q,$)=>({id:Q.id,order:$+1}));Bc(z).then(()=>{q.success("排序保存成功"),p(!1),S()}).finally(()=>{p(!1)})},P=Ke({data:f||[],columns:Ju(S),state:{sorting:x,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:T,pagination:i},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:R,onPaginationChange:u,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Vu,{refetch:S,children:e.jsx("div",{className:"space-y-4",children:e.jsx(es,{table:P,toolbar:z=>e.jsx(Yu,{table:z,refetch:S,saveOrder:v,isSortMode:d,groups:j}),draggable:d,onDragStart:C,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:k,showPagination:!d})})})}function Zu(){const{t:s}=I("server");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(Qu,{})})]})]})}const Xu=Object.freeze(Object.defineProperty({__proto__:null,default:Zu},Symbol.toStringTag,{value:"Module"}));function ex({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(zt,{refetch:n}),e.jsx(D,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:_("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})})}const sx=s=>{const{t:n}=I("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{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(O,{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(O,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(it,{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(O,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Bn,{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(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(zt,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Ue,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Wc({id:a.original.id}).then(({data:l})=>{l&&(q.success(n("messages.updateSuccess")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 tx(){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:T}=await Mt();return T}}),p=Ke({data:x||[],columns:sx(o),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:p,toolbar:T=>e.jsx(ex,{table:T,refetch:o}),isLoading:d})}function ax(){const{t:s}=I("group");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(tx,{})})]})]})}const nx=Object.freeze(Object.defineProperty({__proto__:null,default:ax},Symbol.toStringTag,{value:"Module"})),rx=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 $r({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=I("route"),c=de({resolver:me(rx(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1);return e.jsxs(pe,{open:i,onOpenChange:u,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Te,{})]}),e.jsxs(ue,{...c,children:[e.jsx(y,{control:c.control,name:"remarks",render:({field:x})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:r("form.remarksPlaceholder"),...x})})}),e.jsx(E,{})]})}),e.jsx(y,{control:c.control,name:"match",render:({field:x})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(ps,{className:"min-h-[120px]",placeholder:r("form.matchPlaceholder"),value:x.value.join(` +`).filter(Boolean);o.onChange(p),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(M,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.key.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.recaptcha.key.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.recaptcha.siteKey.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.recaptcha.siteKey.description")}),e.jsx(E,{})]})})]}),e.jsx(y,{control:r.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(M,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"register_limit_count",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.count.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.registerLimit.count.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(E,{})]})})]}),e.jsx(y,{control:r.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(M,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"password_limit_count",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...o,value:o.value||"",onChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(M,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(E,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function xm(){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(um,{})]})}const hm=Object.freeze(Object.defineProperty({__proto__:null,default:xm},Symbol.toStringTag,{value:"Module"})),fm=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")}),pm={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 gm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(fm),defaultValues:pm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","subscribe"],queryFn:()=>hs("subscribe")}),{mutateAsync:i}=as({mutationFn:fs,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(je.debounce(async o=>{if(!je.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(M,{children:s("subscribe.plan_change_enable.description")}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(L,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(L,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(L,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(L,{value:"4",children:s("subscribe.reset_traffic_method.options.yearly_reset")})]})]}),e.jsx(M,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"surplus_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(M,{children:s("subscribe.surplus_enable.description")}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(L,{value:"1",children:s("subscribe.new_order_event.options.reset_traffic")})]})]})})}),e.jsx(M,{children:s("subscribe.new_order_event.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(L,{value:"1",children:s("subscribe.renew_order_event.options.reset_traffic")})]})]})})}),e.jsx(M,{children:s("renew_order_event.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(L,{value:"1",children:s("subscribe.change_order_event.options.reset_traffic")})]})]})})}),e.jsx(M,{children:s("subscribe.change_order_event.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"subscribe_path",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})}),e.jsx(y,{control:r.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(M,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(M,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(w,{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 jm(){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(gm,{})]})}const vm=Object.freeze(Object.defineProperty({__proto__:null,default:jm},Symbol.toStringTag,{value:"Module"})),bm=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)}),ym={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 Nm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(bm),defaultValues:ym,mode:"onBlur"}),{data:c}=se({queryKey:["settings","invite"],queryFn:()=>hs("invite")}),{mutateAsync:i}=as({mutationFn:fs,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(je.debounce(async o=>{if(!je.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"invite_force",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(M,{children:s("invite.invite_force.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"invite_commission",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("invite.invite_commission.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("invite.invite_commission.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("invite.invite_gen_limit.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("invite.invite_gen_limit.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(M,{children:s("invite.invite_never_expire.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(M,{children:s("invite.commission_first_time.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(M,{children:s("invite.commission_auto_check.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(w,{children:e.jsx(D,{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(M,{children:s("invite.commission_withdraw_method.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(M,{children:s("invite.withdraw_close.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(y,{control:r.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(M,{children:s("invite.commission_distribution.description")})]}),e.jsx(w,{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(y,{control:r.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:s("invite.commission_distribution.l1")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})}),e.jsx(y,{control:r.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:s("invite.commission_distribution.l2")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})}),e.jsx(y,{control:r.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:s("invite.commission_distribution.l3")}),e.jsx(w,{children:e.jsx(D,{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(E,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function _m(){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(Nm,{})]})}const wm=Object.freeze(Object.defineProperty({__proto__:null,default:_m},Symbol.toStringTag,{value:"Module"})),Cm=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()}),Sm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function km(){const{data:s}=se({queryKey:["settings","frontend"],queryFn:()=>hs("frontend")}),n=de({resolver:me(Cm),defaultValues:Sm,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){fs(l).then(({data:r})=>{r&&q.success("更新成功")})}return e.jsx(ue,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(y,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:"边栏风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(w,{children:e.jsx(H,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(y,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:"头部风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(w,{children:e.jsx(H,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(y,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(b,{children:[e.jsx(N,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(w,{children:e.jsxs("select",{className:_(Bs({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(da,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(M,{children:"主题色"}),e.jsx(E,{})]})}),e.jsx(y,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(b,{children:[e.jsx(N,{children:"背景"}),e.jsx(w,{children:e.jsx(D,{placeholder:"请输入图片地址",...l})}),e.jsx(M,{children:"将会在后台登录页面进行展示。"}),e.jsx(E,{})]})}),e.jsx(V,{type:"submit",children:"保存设置"})]})})}function Tm(){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(km,{})]})}const Pm=Object.freeze(Object.defineProperty({__proto__:null,default:Tm},Symbol.toStringTag,{value:"Module"})),Dm=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()}),Em={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Rm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(Dm),defaultValues:Em,mode:"onBlur"}),{data:c}=se({queryKey:["settings","server"],queryFn:()=>hs("server")}),{mutateAsync:i}=as({mutationFn:fs,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,P])=>{r.setValue(p,P)}),l.current=d}},[c]);const u=m.useCallback(je.debounce(async d=>{if(!je.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 P="";for(let R=0;Re.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.server_token.title")}),e.jsx(w,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{placeholder:s("server.server_token.placeholder"),...d,value:d.value||"",className:"pr-10"}),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{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(li,{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(M,{children:s("server.server_token.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const P=p.target.value?Number(p.target.value):null;d.onChange(P)}})}),e.jsx(M,{children:s("server.server_pull_interval.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const P=p.target.value?Number(p.target.value):null;d.onChange(P)}})}),e.jsx(M,{children:s("server.server_push_interval.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(G,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(L,{value:"1",children:s("server.device_limit_mode.relaxed")})]})]}),e.jsx(M,{children:s("server.device_limit_mode.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function Vm(){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(Rm,{})]})}const Im=Object.freeze(Object.defineProperty({__proto__:null,default:Vm},Symbol.toStringTag,{value:"Module"}));function Fm({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(fe,{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(On,{className:"h-5 w-5 text-green-500"}):e.jsx(zn,{className:"h-5 w-5 text-destructive"}),e.jsx(pe,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Pe,{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(ot,{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 Mm=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 Om(){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=de({resolver:me(Mm),defaultValues:{},mode:"onBlur"}),{data:o}=se({queryKey:["settings","email"],queryFn:()=>hs("email")}),{data:d}=se({queryKey:["emailTemplate"],queryFn:()=>Id()}),{mutateAsync:p}=as({mutationFn:fs,onSuccess:S=>{S.data&&q.success(s("common.autoSaved"))}}),{mutate:P,isPending:R}=as({mutationFn:Fd,onMutate:()=>{a(null),r(!1)},onSuccess:S=>{a(S.data),r(!0),S.data.error?q.error(s("email.test.error")):q.success(s("email.test.success"))}});m.useEffect(()=>{if(o?.data.email){const S=o.data.email;Object.entries(S).forEach(([j,C])=>{x.setValue(j,C)}),c.current=S}},[o]);const f=m.useCallback(je.debounce(async S=>{if(!je.isEqual(S,c.current)){u(!0);try{await p(S),c.current=S}finally{u(!1)}}},1e3),[p]),g=m.useCallback(S=>{f(S)},[f]);return m.useEffect(()=>{const S=x.watch(j=>{g(j)});return()=>S.unsubscribe()},[x.watch,g]),e.jsxs(e.Fragment,{children:[e.jsx(ue,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:x.control,name:"email_host",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_host.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_host.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_port",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_port.title")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...S,value:S.value||"",onChange:j=>{const C=j.target.value?Number(j.target.value):null;S.onChange(C)}})}),e.jsx(M,{children:s("email.email_port.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_encryption",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(G,{onValueChange:S.onChange,value:S.value||"none",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(L,{value:"none",children:s("email.email_encryption.none")}),e.jsx(L,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(L,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(M,{children:s("email.email_encryption.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_username",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_username.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_username.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_password",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_password.title")}),e.jsx(w,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_password.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_from_address",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_from.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...S,value:S.value||""})}),e.jsx(M,{children:s("email.email_from.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"email_template",render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(G,{onValueChange:j=>{S.onChange(j),g(x.getValues())},value:S.value||void 0,children:[e.jsx(w,{children:e.jsx(U,{className:"w-[200px]",children:e.jsx(Y,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(B,{children:d?.data?.map(j=>e.jsx(L,{value:j,children:j},j))})]}),e.jsx(M,{children:s("email.email_template.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"remind_mail_enable",render:({field:S})=>e.jsxs(b,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(M,{children:s("email.remind_mail.description")})]}),e.jsx(w,{children:e.jsx(H,{checked:S.value||!1,onCheckedChange:j=>{S.onChange(j),g(x.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(V,{onClick:()=>P(),loading:R,disabled:R,children:s(R?"test.sending":"test.title")})})]})}),i&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Fm,{open:l,onOpenChange:r,result:n})]})}function zm(){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(Om,{})]})}const Lm=Object.freeze(Object.defineProperty({__proto__:null,default:zm},Symbol.toStringTag,{value:"Module"})),Am=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),$m={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function qm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(Am),defaultValues:$m,mode:"onBlur"}),{data:c}=se({queryKey:["settings","telegram"],queryFn:()=>hs("telegram")}),{mutateAsync:i}=as({mutationFn:fs,onSuccess:p=>{p.data&&q.success(s("common.autoSaved"))}}),{mutate:u,isPending:x}=as({mutationFn:Md,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(([P,R])=>{r.setValue(P,R)}),l.current=p}},[c]);const o=m.useCallback(je.debounce(async p=>{if(!je.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(P=>{d(P)});return()=>p.unsubscribe()},[r.watch,d]),e.jsx(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"telegram_bot_token",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("telegram.bot_token.placeholder"),...p,value:p.value||""})}),e.jsx(M,{children:s("telegram.bot_token.description")}),e.jsx(E,{})]})}),r.watch("telegram_bot_token")&&e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(V,{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(M,{children:s("telegram.webhook.description")}),e.jsx(E,{})]}),e.jsx(y,{control:r.control,name:"telegram_bot_enable",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(M,{children:s("telegram.bot_enable.description")}),e.jsx(w,{children:e.jsx(H,{checked:p.value||!1,onCheckedChange:P=>{p.onChange(P),d(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"telegram_discuss_link",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("telegram.discuss_link.placeholder"),...p,value:p.value||""})}),e.jsx(M,{children:s("telegram.discuss_link.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Km(){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(qm,{})]})}const Hm=Object.freeze(Object.defineProperty({__proto__:null,default:Km},Symbol.toStringTag,{value:"Module"})),Um=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()}),Bm={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Gm(){const{t:s}=I("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=de({resolver:me(Um),defaultValues:Bm,mode:"onBlur"}),{data:c}=se({queryKey:["settings","app"],queryFn:()=>hs("app")}),{mutateAsync:i}=as({mutationFn:fs,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(je.debounce(async o=>{if(!je.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(ue,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:r.control,name:"windows_version",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.windows.version.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"windows_download_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.windows.download.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"macos_version",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.macos.version.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"macos_download_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.macos.download.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"android_version",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.android.version.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.android.version.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"android_download_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{className:"text-base",children:s("app.android.download.title")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("common.placeholder"),...o,value:o.value||""})}),e.jsx(M,{children:s("app.android.download.description")}),e.jsx(E,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Ym(){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(Gm,{})]})}const Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Ym},Symbol.toStringTag,{value:"Module"})),pa=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:_("w-full caption-bottom text-sm",s),...n})}));pa.displayName="Table";const ga=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:_("[&_tr]:border-b",s),...n}));ga.displayName="TableHeader";const ja=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:_("[&_tr:last-child]:border-0",s),...n}));ja.displayName="TableBody";const Jm=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:_("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));Jm.displayName="TableFooter";const ys=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:_("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));ys.displayName="TableRow";const va=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:_("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}));va.displayName="TableHead";const Ks=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:_("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Ks.displayName="TableCell";const Qm=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:_("mt-4 text-sm text-muted-foreground",s),...n}));Qm.displayName="TableCaption";function Zm({table:s}){const[n,a]=m.useState(""),{t:l}=I("common");m.useEffect(()=>{a((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const r=c=>{const i=parseInt(c);!isNaN(i)&&i>=1&&i<=s.getPageCount()?s.setPageIndex(i-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.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:l("table.pagination.selected",{selected:s.getFilteredSelectedRowModel().rows.length,total: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:l("table.pagination.itemsPerPage")}),e.jsxs(G,{value:`${s.getState().pagination.pageSize}`,onValueChange:c=>{s.setPageSize(Number(c))},children:[e.jsx(U,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:s.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50,100,500].map(c=>e.jsx(L,{value:`${c}`,children:c},c))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:l("table.pagination.page")}),e.jsx(D,{type:"text",value:n,onChange:c=>a(c.target.value),onBlur:c=>r(c.target.value),onKeyDown:c=>{c.key==="Enter"&&r(c.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:l("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(V,{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:l("table.pagination.firstPage")}),e.jsx(oi,{className:"h-4 w-4"})]}),e.jsxs(V,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.previousPage")}),e.jsx(Rn,{className:"h-4 w-4"})]}),e.jsxs(V,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.nextPage")}),e.jsx(ia,{className:"h-4 w-4"})]}),e.jsxs(V,{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:l("table.pagination.lastPage")}),e.jsx(ii,{className:"h-4 w-4"})]})]})]})]})}function es({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:u,showPagination:x=!0,isLoading:o=!1}){const{t:d}=I("common"),p=m.useRef(null),P=s.getAllColumns().filter(S=>S.getIsPinned()==="left"),R=s.getAllColumns().filter(S=>S.getIsPinned()==="right"),f=S=>P.slice(0,S).reduce((j,C)=>j+(C.getSize()??0),0),g=S=>R.slice(S+1).reduce((j,C)=>j+(C.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:p,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(pa,{children:[e.jsx(ga,{children:s.getHeaderGroups().map(S=>e.jsx(ys,{className:"hover:bg-transparent",children:S.headers.map((j,C)=>{const k=j.column.getIsPinned()==="left",v=j.column.getIsPinned()==="right",T=k?f(P.indexOf(j.column)):void 0,z=v?g(R.indexOf(j.column)):void 0;return e.jsx(va,{colSpan:j.colSpan,style:{width:j.getSize(),...k&&{left:T},...v&&{right:z}},className:_("h-11 bg-card px-4 text-muted-foreground",(k||v)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",k&&"before:right-0",v&&"before:left-0"]),children:j.isPlaceholder?null:_t(j.column.columnDef.header,j.getContext())},j.id)})},S.id))}),e.jsx(ja,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((S,j)=>e.jsx(ys,{"data-state":S.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:C=>l?.(C,j),onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:C=>u?.(C,j),children:S.getVisibleCells().map((C,k)=>{const v=C.column.getIsPinned()==="left",T=C.column.getIsPinned()==="right",z=v?f(P.indexOf(C.column)):void 0,Q=T?g(R.indexOf(C.column)):void 0;return e.jsx(Ks,{style:{width:C.column.getSize(),...v&&{left:z},...T&&{right:Q}},className:_("bg-card",(v||T)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",v&&"before:right-0",T&&"before:left-0"]),children:_t(C.column.columnDef.cell,C.getContext())},C.id)})},S.id)):e.jsx(ys,{children:e.jsx(Ks,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:d("table.noData")})})})]})})}),x&&e.jsx(Zm,{table:s})]})}const Xm=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())}),Ua={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function kr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Ua}){const{t:r}=I("payment"),[c,i]=m.useState(!1),[u,x]=m.useState(!1),[o,d]=m.useState([]),[p,P]=m.useState([]),R=Xm(r),f=de({resolver:me(R),defaultValues:l,mode:"onChange"}),g=f.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:C}=await Xc();d(C)})()},[c]),m.useEffect(()=>{if(!g||!c)return;(async()=>{const C={payment:g,...a==="edit"&&{id:Number(f.getValues("id"))}};ed(C).then(({data:k})=>{P(k);const v=k.reduce((T,z)=>(z.field_name&&(T[z.field_name]=z.value??""),T),{});f.setValue("config",v)})})()},[g,c,f,a]);const S=async j=>{x(!0);try{(await sd(j)).data&&(q.success(r("form.messages.success")),f.reset(Ua),s(),i(!1))}finally{x(!1)}};return e.jsxs(fe,{open:c,onOpenChange:i,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{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(pe,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(ue,{...f,children:e.jsxs("form",{onSubmit:f.handleSubmit(S),className:"space-y-4",children:[e.jsx(y,{control:f.control,name:"name",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:r("form.fields.name.placeholder"),...j})}),e.jsx(M,{children:r("form.fields.name.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"icon",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.icon.label")}),e.jsx(w,{children:e.jsx(D,{...j,value:j.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(M,{children:r("form.fields.icon.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"notify_domain",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.notify_domain.label")}),e.jsx(w,{children:e.jsx(D,{...j,value:j.value||"",placeholder:r("form.fields.notify_domain.placeholder")})}),e.jsx(M,{children:r("form.fields.notify_domain.description")}),e.jsx(E,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(y,{control:f.control,name:"handling_fee_percent",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(w,{children:e.jsx(D,{type:"number",...j,value:j.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"handling_fee_fixed",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(w,{children:e.jsx(D,{type:"number",...j,value:j.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(E,{})]})})]}),e.jsx(y,{control:f.control,name:"payment",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.payment.label")}),e.jsxs(G,{onValueChange:j.onChange,defaultValue:j.value,children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(B,{children:o.map(C=>e.jsx(L,{value:C,children:C},C))})]}),e.jsx(M,{children:r("form.fields.payment.description")}),e.jsx(E,{})]})}),p.length>0&&e.jsx("div",{className:"space-y-4",children:p.map(j=>e.jsx(y,{control:f.control,name:`config.${j.field_name}`,render:({field:C})=>e.jsxs(b,{children:[e.jsx(N,{children:j.label}),e.jsx(w,{children:e.jsx(D,{...C,value:C.value||""})}),e.jsx(E,{})]})},j.field_name))}),e.jsxs(Le,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(V,{type:"submit",disabled:u,children:r("form.buttons.submit")})]})]})})]})]})}function O({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(V,{variant:"ghost",size:"default",className:_("-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(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(Ia,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(te,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(Qt,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(Zt,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ci,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:_("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(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsx(Ia,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(te,{children:a})]})})]})}const eu=di,su=mi,tu=ui,Tr=m.forwardRef(({className:s,...n},a)=>e.jsx($n,{className:_("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}));Tr.displayName=$n.displayName;const Pr=m.forwardRef(({className:s,...n},a)=>e.jsxs(tu,{children:[e.jsx(Tr,{}),e.jsx(qn,{ref:a,className:_("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})]}));Pr.displayName=qn.displayName;const Dr=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});Dr.displayName="AlertDialogHeader";const Er=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Er.displayName="AlertDialogFooter";const Rr=m.forwardRef(({className:s,...n},a)=>e.jsx(Kn,{ref:a,className:_("text-lg font-semibold",s),...n}));Rr.displayName=Kn.displayName;const Vr=m.forwardRef(({className:s,...n},a)=>e.jsx(Hn,{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Vr.displayName=Hn.displayName;const Ir=m.forwardRef(({className:s,...n},a)=>e.jsx(Un,{ref:a,className:_(Us(),s),...n}));Ir.displayName=Un.displayName;const Fr=m.forwardRef(({className:s,...n},a)=>e.jsx(Bn,{ref:a,className:_(Us({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Fr.displayName=Bn.displayName;function Ue({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:u}){return e.jsxs(eu,{children:[e.jsx(su,{asChild:!0,children:n}),e.jsxs(Pr,{className:_("sm:max-w-[425px]",u),children:[e.jsxs(Dr,{children:[e.jsx(Rr,{children:a}),e.jsx(Vr,{children:l})]}),e.jsxs(Er,{children:[e.jsx(Fr,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r})}),e.jsx(Ir,{asChild:!0,children:e.jsx(V,{variant:i,onClick:s,children:c})})]})]})]})}const Mr=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"})}),au=({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(Vt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{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(O,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(H,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await ad({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(O,{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(O,{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(O,{column:l,title:a("table.columns.notify_url")}),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{className:"ml-1",children:e.jsx(Mr,{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(O,{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(kr,{refetch:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{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(Ue,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await td({id:l.original.id});r&&s()},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(ns,{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 nu({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(kr,{refetch:n}),e.jsx(D,{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(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function ru(){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:P}=se({queryKey:["paymentList"],queryFn:async()=>{const{data:j}=await Zc();return u(j?.map(C=>({...C,enable:!!C.enable}))||[]),j}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const R=(j,C)=>{r&&(j.dataTransfer.setData("text/plain",C.toString()),j.currentTarget.classList.add("opacity-50"))},f=(j,C)=>{if(!r)return;j.preventDefault(),j.currentTarget.classList.remove("bg-muted");const k=parseInt(j.dataTransfer.getData("text/plain"));if(k===C)return;const v=[...i],[T]=v.splice(k,1);v.splice(C,0,T),u(v)},g=async()=>{r?nd({ids:i.map(j=>j.id)}).then(()=>{P(),c(!1),q.success("排序保存成功")}):c(!0)},S=Ke({data:i,columns:au({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(es,{table:S,toolbar:j=>e.jsx(nu,{table:j,refetch:P,saveOrder:g,isSortMode:r}),draggable:r,onDragStart:R,onDragEnd:j=>j.currentTarget.classList.remove("opacity-50"),onDragOver:j=>{j.preventDefault(),j.currentTarget.classList.add("bg-muted")},onDragLeave:j=>j.currentTarget.classList.remove("bg-muted"),onDrop:f,showPagination:!r})}function lu(){const{t:s}=I("payment");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Ie,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(ru,{})})]})]})}const ou=Object.freeze(Object.defineProperty({__proto__:null,default:lu},Symbol.toStringTag,{value:"Module"}));function iu({pluginName:s,onClose:n,onSuccess:a}){const{t:l}=I("plugin"),[r,c]=m.useState(!0),[i,u]=m.useState(!1),[x,o]=m.useState(null),d=xi({config:hi(fi())}),p=de({resolver:me(d),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:g}=await Ds.getPluginConfig(s);o(g),p.reset({config:Object.fromEntries(Object.entries(g).map(([S,j])=>[S,j.value]))})}catch{q.error(l("messages.configLoadError"))}finally{c(!1)}})()},[s]);const P=async f=>{u(!0);try{await Ds.updatePluginConfig(s,f.config),q.success(l("messages.configSaveSuccess")),a()}catch{q.error(l("messages.configSaveError"))}finally{u(!1)}},R=(f,g)=>{switch(g.type){case"string":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsx(w,{children:e.jsx(D,{placeholder:g.placeholder,...S})}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);case"number":case"percentage":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsx(w,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:g.placeholder,...S,onChange:j=>{const C=Number(j.target.value);g.type==="percentage"?S.onChange(Math.min(100,Math.max(0,C))):S.onChange(C)},className:g.type==="percentage"?"pr-8":"",min:g.type==="percentage"?0:void 0,max:g.type==="percentage"?100:void 0,step:g.type==="percentage"?1:void 0}),g.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(pi,{className:"h-4 w-4 text-muted-foreground"})})]})}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);case"select":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsxs(G,{onValueChange:S.onChange,defaultValue:S.value,children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:g.placeholder})})}),e.jsx(B,{children:g.options?.map(j=>e.jsx(L,{value:j.value,children:j.label},j.value))})]}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);case"boolean":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:g.label||g.description}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description})]}),e.jsx(w,{children:e.jsx(H,{checked:S.value,onCheckedChange:S.onChange})})]})},f);case"text":return e.jsx(y,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(b,{children:[e.jsx(N,{children:g.label||g.description}),e.jsx(w,{children:e.jsx(ps,{placeholder:g.placeholder,...S})}),g.description&&g.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:g.description}),e.jsx(E,{})]})},f);default:return null}};return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(le,{className:"h-4 w-[200px]"}),e.jsx(le,{className:"h-10 w-full"}),e.jsx(le,{className:"h-4 w-[200px]"}),e.jsx(le,{className:"h-10 w-full"})]}):e.jsx(ue,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(P),className:"space-y-4",children:[x&&Object.entries(x).map(([f,g])=>R(f,g)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:n,disabled:i,children:l("config.cancel")}),e.jsx(V,{type:"submit",loading:i,disabled:i,children:l("config.save")})]})]})})}function cu(){const{t:s}=I("plugin"),[n,a]=m.useState(null),[l,r]=m.useState(!1),[c,i]=m.useState(null),[u,x]=m.useState(""),[o,d]=m.useState("all"),{data:p,isLoading:P,refetch:R}=se({queryKey:["pluginList"],queryFn:async()=>{const{data:v}=await Ds.getPluginList();return v}}),f=p?["all",...new Set(p.map(v=>v.category||"other"))]:["all"],g=p?.filter(v=>{const T=v.name.toLowerCase().includes(u.toLowerCase())||v.description.toLowerCase().includes(u.toLowerCase())||v.code.toLowerCase().includes(u.toLowerCase()),z=o==="all"||v.category===o;return T&&z}),S=async v=>{a(v),Ds.installPlugin(v).then(()=>{q.success(s("messages.installSuccess")),R()}).catch(T=>{q.error(T.message||s("messages.installError"))}).finally(()=>{a(null)})},j=async v=>{a(v),Ds.uninstallPlugin(v).then(()=>{q.success(s("messages.uninstallSuccess")),R()}).catch(T=>{q.error(T.message||s("messages.uninstallError"))}).finally(()=>{a(null)})},C=async(v,T)=>{a(v),(T?Ds.disablePlugin:Ds.enablePlugin)(v).then(()=>{q.success(s(T?"messages.disableSuccess":"messages.enableSuccess")),R()}).catch(Q=>{q.error(Q.message||s(T?"messages.disableError":"messages.enableError"))}).finally(()=>{a(null)})},k=v=>{p?.find(T=>T.code===v),i(v),r(!0)};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(ca,{className:"h-6 w-6"}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(jn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{placeholder:s("search.placeholder"),value:u,onChange:v=>x(v.target.value),className:"pl-9"})]}),e.jsxs(G,{value:o,onValueChange:d,children:[e.jsx(U,{className:"w-[180px]",children:e.jsx(Y,{placeholder:s("category.placeholder")})}),e.jsx(B,{children:f.map(v=>e.jsx(L,{value:v,children:s(`category.${v}`)},v))})]})]}),e.jsxs(fa,{defaultValue:"all",className:"w-full",children:[e.jsxs(zt,{children:[e.jsx(Ns,{value:"all",children:s("tabs.all")}),e.jsx(Ns,{value:"installed",children:s("tabs.installed")}),e.jsx(Ns,{value:"available",children:s("tabs.available")})]}),e.jsx(yt,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:P?e.jsxs(e.Fragment,{children:[e.jsx(Ut,{}),e.jsx(Ut,{}),e.jsx(Ut,{})]}):g?.map(v=>e.jsx(Ht,{plugin:v,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:k,isLoading:n===v.name},v.name))})}),e.jsx(yt,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g?.filter(v=>v.is_installed).map(v=>e.jsx(Ht,{plugin:v,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:k,isLoading:n===v.name},v.name))})}),e.jsx(yt,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g?.filter(v=>!v.is_installed).map(v=>e.jsx(Ht,{plugin:v,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:k,isLoading:n===v.name},v.code))})})]})]}),e.jsx(fe,{open:l,onOpenChange:r,children:e.jsxs(he,{className:"sm:max-w-lg",children:[e.jsxs(ve,{children:[e.jsxs(pe,{children:[p?.find(v=>v.code===c)?.name," ",s("config.title")]}),e.jsx(Pe,{children:s("config.description")})]}),c&&e.jsx(iu,{pluginName:c,onClose:()=>r(!1),onSuccess:()=>{r(!1),R()}})]})})]})]})}function Ht({plugin:s,onInstall:n,onUninstall:a,onToggleEnable:l,onOpenConfig:r,isLoading:c}){const{t:i}=I("plugin");return e.jsxs(Me,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs($e,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cs,{children:s.name}),s.is_installed&&e.jsx(K,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?i("status.enabled"):i("status.disabled")})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ca,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Hs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[i("author"),": ",s.author]})})]})})]}),e.jsx(qe,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(V,{variant:"outline",size:"sm",onClick:()=>r(s.code),disabled:!s.is_enabled||c,children:[e.jsx(gi,{className:"mr-2 h-4 w-4"}),i("button.config")]}),e.jsxs(V,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>l(s.code,s.is_enabled),disabled:c,children:[e.jsx(ji,{className:"mr-2 h-4 w-4"}),s.is_enabled?i("button.disable"):i("button.enable")]}),e.jsx(Ue,{title:i("uninstall.title"),description:i("uninstall.description"),confirmText:i("uninstall.button"),variant:"destructive",onConfirm:()=>a(s.code),children:e.jsx(V,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:c,children:e.jsx(ns,{className:"h-4 w-4"})})})]}):e.jsx(V,{onClick:()=>n(s.code),disabled:c,loading:c,children:i("button.install")})})})]})}function Ut(){return e.jsxs(Me,{children:[e.jsxs($e,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-6 w-[200px]"}),e.jsx(le,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(le,{className:"h-5 w-[120px]"}),e.jsx(le,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(le,{className:"h-4 w-[300px]"}),e.jsx(le,{className:"h-4 w-[150px]"})]})]}),e.jsx(qe,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(le,{className:"h-9 w-[100px]"}),e.jsx(le,{className:"h-9 w-[100px]"}),e.jsx(le,{className:"h-8 w-8"})]})})]})}const du=Object.freeze(Object.defineProperty({__proto__:null,default:cu},Symbol.toStringTag,{value:"Module"})),mu=(s,n)=>{let a=null;switch(s.field_type){case"input":a=e.jsx(D,{placeholder:s.placeholder,...n});break;case"textarea":a=e.jsx(ps,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:_(Us({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 uu({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=de({defaultValues:n.configs.reduce((P,R)=>(P[R.field_name]="",P),{})}),d=async()=>{i(!0),zc(s).then(({data:P})=>{Object.entries(P).forEach(([R,f])=>{o.setValue(R,f)})}).finally(()=>{i(!1)})},p=async P=>{x(!0),Lc(s,P).then(()=>{q.success(a("config.success")),r(!1)}).finally(()=>{x(!1)})};return e.jsxs(fe,{open:l,onOpenChange:P=>{r(P),P?d():o.reset()},children:[e.jsx(ze,{asChild:!0,children:e.jsx(V,{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(pe,{children:a("config.title",{name:n.name})}),e.jsx(Pe,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(ma,{className:"h-6 w-6 animate-spin"})}):e.jsx(ue,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(p),className:"space-y-4",children:[n.configs.map(P=>e.jsx(y,{control:o.control,name:P.field_name,render:({field:R})=>e.jsxs(b,{children:[e.jsx(N,{children:P.label}),e.jsx(w,{children:mu(P,R)}),e.jsx(E,{})]})},P.field_name)),e.jsxs(Le,{className:"mt-6 gap-2",children:[e.jsx(V,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(V,{type:"submit",loading:u,children:a("config.save")})]})]})})]})]})}function xu(){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),[P,R]=m.useState(0),{data:f,isLoading:g,refetch:S}=se({queryKey:["themeList"],queryFn:async()=>{const{data:$}=await Oc();return $}}),j=async $=>{a($),qc({frontend_theme:$}).then(()=>{q.success("主题切换成功"),S()}).finally(()=>{a(null)})},C=async $=>{if(!$.name.endsWith(".zip")){q.error(s("upload.error.format"));return}r(!0),Ac($).then(()=>{q.success("主题上传成功"),i(!1),S()}).finally(()=>{r(!1),p.current&&(p.current.value="")})},k=$=>{$.preventDefault(),$.stopPropagation(),$.type==="dragenter"||$.type==="dragover"?x(!0):$.type==="dragleave"&&x(!1)},v=$=>{$.preventDefault(),$.stopPropagation(),x(!1),$.dataTransfer.files&&$.dataTransfer.files[0]&&C($.dataTransfer.files[0])},T=()=>{o&&R($=>$===0?o.images.length-1:$-1)},z=()=>{o&&R($=>$===o.images.length-1?0:$+1)},Q=($,X)=>{R(0),d({name:$,images:X})};return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Ie,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(V,{onClick:()=>i(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(Jt,{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:g?e.jsxs(e.Fragment,{children:[e.jsx(Ba,{}),e.jsx(Ba,{})]}):f?.themes&&Object.entries(f.themes).map(([$,X])=>e.jsx(Me,{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:_("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(Ue,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if($===f?.active){q.error(s("card.delete.error.active"));return}a($),$c($).then(()=>{q.success("主题删除成功"),S()}).finally(()=>{a(null)})},children:e.jsx(V,{disabled:n===$,loading:n===$,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(ns,{className:"h-4 w-4"})})})}),e.jsxs($e,{children:[e.jsx(cs,{children:X.name}),e.jsx(Hs,{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(qe,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(V,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Q(X.name,X.images),children:e.jsx(vi,{className:"h-4 w-4"})}),e.jsx(uu,{themeKey:$,themeInfo:X}),e.jsx(V,{onClick:()=>j($),disabled:n===$||$===f.active,loading:n===$,variant:$===f.active?"secondary":"default",children:$===f.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},$))}),e.jsx(fe,{open:c,onOpenChange:i,children:e.jsxs(he,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsx(pe,{children:s("upload.title")}),e.jsx(Pe,{children:s("upload.description")})]}),e.jsxs("div",{className:_("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:k,onDragLeave:k,onDragOver:k,onDrop:v,children:[e.jsx("input",{type:"file",ref:p,className:"hidden",accept:".zip",onChange:$=>{const X=$.target.files?.[0];X&&C(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(Jt,{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(fe,{open:!!o,onOpenChange:$=>{$||(d(null),R(0))},children:e.jsxs(he,{className:"max-w-4xl",children:[e.jsxs(ve,{children:[e.jsxs(pe,{children:[o?.name," ",s("preview.title")]}),e.jsx(Pe,{className:"text-center",children:o&&s("preview.imageCount",{current:P+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[P]&&e.jsx("img",{src:o.images[P],alt:`${o.name} 预览图 ${P+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(V,{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:T,children:e.jsx(bi,{className:"h-4 w-4"})}),e.jsx(V,{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(yi,{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(($,X)=>e.jsx("button",{onClick:()=>R(X),className:_("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",P===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:$,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function Ba(){return e.jsxs(Me,{children:[e.jsxs($e,{children:[e.jsx(le,{className:"h-6 w-[200px]"}),e.jsx(le,{className:"h-4 w-[300px]"})]}),e.jsxs(qe,{className:"flex items-center justify-end space-x-3",children:[e.jsx(le,{className:"h-10 w-[100px]"}),e.jsx(le,{className:"h-10 w-[100px]"})]})]})}const hu=Object.freeze(Object.defineProperty({__proto__:null,default:xu},Symbol.toStringTag,{value:"Module"})),ba=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:_(" 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(Xt,{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})]})});ba.displayName="InputTags";const fu=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()}),pu={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Or({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=pu}){const{t:r}=I("notice"),[c,i]=m.useState(!1),u=de({resolver:me(fu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new ua({html:!0});return e.jsx(ue,{...u,children:e.jsxs(fe,{onOpenChange:i,open:c,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{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(pe,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Pe,{})]}),e.jsx(y,{control:u.control,name:"title",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(w,{children:e.jsx(D,{placeholder:r("form.fields.title.placeholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"content",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.content.label")}),e.jsx(w,{children:e.jsx(xa,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"img_url",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"show",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"tags",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.fields.tags.label")}),e.jsx(w,{children:e.jsx(ba,{value:o.value,onChange:o.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(V,{type:"submit",onClick:o=>{o.preventDefault(),u.handleSubmit(async d=>{rd(d).then(({data:p})=>{p&&(q.success(r("form.buttons.success")),s(),i(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function gu({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(Or,{refetch:n}),!l&&e.jsx(D,{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(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(V,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const ju=s=>{const{t:n}=I("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ni,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{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(O,{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 od({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(O,{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(O,{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(Or,{refetch:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{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(Ue,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{ld({id:a.original.id}).then(()=>{q.success(n("table.actions.delete.success")),s()})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 vu(){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({}),[P,R]=m.useState({pageSize:50,pageIndex:0}),[f,g]=m.useState([]),{refetch:S}=se({queryKey:["notices"],queryFn:async()=>{const{data:T}=await Ka.getList();return g(T),T}});m.useEffect(()=>{l({"drag-handle":x,content:!x,created_at:!x,actions:!x}),R({pageSize:x?99999:50,pageIndex:0})},[x]);const j=(T,z)=>{x&&(T.dataTransfer.setData("text/plain",z.toString()),T.currentTarget.classList.add("opacity-50"))},C=(T,z)=>{if(!x)return;T.preventDefault(),T.currentTarget.classList.remove("bg-muted");const Q=parseInt(T.dataTransfer.getData("text/plain"));if(Q===z)return;const $=[...f],[X]=$.splice(Q,1);$.splice(z,0,X),g($)},k=async()=>{if(!x){o(!0);return}Ka.sort(f.map(T=>T.id)).then(()=>{q.success("排序保存成功"),o(!1),S()}).finally(()=>{o(!1)})},v=Ke({data:f??[],columns:ju(S),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:P},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:p,onPaginationChange:R,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(es,{table:v,toolbar:T=>e.jsx(gu,{table:T,refetch:S,saveOrder:k,isSortMode:x}),draggable:x,onDragStart:j,onDragEnd:T=>T.currentTarget.classList.remove("opacity-50"),onDragOver:T=>{T.preventDefault(),T.currentTarget.classList.add("bg-muted")},onDragLeave:T=>T.currentTarget.classList.remove("bg-muted"),onDrop:C,showPagination:!x})})}function bu(){const{t:s}=I("notice");return e.jsxs(we,{children:[e.jsxs(Ce,{className:"flex items-center justify-between",children:[e.jsx(Ie,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(vu,{})})]})]})}const yu=Object.freeze(Object.defineProperty({__proto__:null,default:bu},Symbol.toStringTag,{value:"Module"})),Nu=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()}),_u={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function zr({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=_u}){const{t:r}=I("knowledge"),[c,i]=m.useState(!1),u=de({resolver:me(Nu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new ua({html:!0});return m.useEffect(()=>{c&&l.id&&cd(l.id).then(({data:o})=>{u.reset(o)})},[l.id,u,c]),e.jsxs(fe,{onOpenChange:i,open:c,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{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(pe,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Pe,{})]}),e.jsxs(ue,{...u,children:[e.jsx(y,{control:u.control,name:"title",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(w,{children:e.jsx(D,{placeholder:r("form.titlePlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"category",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(w,{children:e.jsx(D,{placeholder:r("form.categoryPlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"language",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.language")}),e.jsx(w,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("form.languagePlaceholder")})}),e.jsx(B,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx(L,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(y,{control:u.control,name:"body",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.content")}),e.jsx(w,{children:e.jsx(xa,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"show",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(V,{type:"submit",onClick:()=>{u.handleSubmit(o=>{dd(o).then(({data:d})=>{d&&(u.reset(),q.success(r("messages.operationSuccess")),i(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function wu({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(mt,{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(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(ke,{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:_("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(Rs,{className:_("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(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function Cu({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(zr,{refreshData:n}),e.jsx(D,{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(wu,{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(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const Su=({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(Vt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(O,{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(O,{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()=>{ud({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(O,{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(O,{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(O,{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(zr,{refreshData:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{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(Ue,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{md({id:l.original.id}).then(({data:r})=>{r&&(q.success(a("messages.operationSuccess")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 ku(){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:P,isLoading:R,data:f}=se({queryKey:["knowledge"],queryFn:async()=>{const{data:k}=await id();return u(k||[]),k}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const g=(k,v)=>{r&&(k.dataTransfer.setData("text/plain",v.toString()),k.currentTarget.classList.add("opacity-50"))},S=(k,v)=>{if(!r)return;k.preventDefault(),k.currentTarget.classList.remove("bg-muted");const T=parseInt(k.dataTransfer.getData("text/plain"));if(T===v)return;const z=[...i],[Q]=z.splice(T,1);z.splice(v,0,Q),u(z)},j=async()=>{r?xd({ids:i.map(k=>k.id)}).then(()=>{P(),c(!1),q.success("排序保存成功")}):c(!0)},C=Ke({data:i,columns:Su({refetch:P,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:C,toolbar:k=>e.jsx(Cu,{table:k,refetch:P,saveOrder:j,isSortMode:r}),draggable:r,onDragStart:g,onDragEnd:k=>k.currentTarget.classList.remove("opacity-50"),onDragOver:k=>{k.preventDefault(),k.currentTarget.classList.add("bg-muted")},onDragLeave:k=>k.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!r})}function Tu(){const{t:s}=I("knowledge");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(ku,{})})]})]})}const Pu=Object.freeze(Object.defineProperty({__proto__:null,default:Tu},Symbol.toStringTag,{value:"Module"}));function Du(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function Bt(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 Eu(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 Ru(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 Lr=m.forwardRef(({className:s,...n},a)=>_i(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:_("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);Lr.displayName="CommandEmpty";const it=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:P,groupBy:R,className:f,badgeClassName:g,selectFirstItem:S=!0,creatable:j=!1,triggerSearchOnFocus:C=!1,commandProps:k,inputProps:v,hideClearAllButton:T=!1},z)=>{const Q=m.useRef(null),[$,X]=m.useState(!1),Ys=m.useRef(!1),[Sa,ka]=m.useState(!1),[ee,Ws]=m.useState(s||[]),[ks,Ta]=m.useState(Bt(l,R)),[gs,At]=m.useState(""),Js=Du(gs,c||500);m.useImperativeHandle(z,()=>({selectedValue:[...ee],input:Q.current,focus:()=>Q.current?.focus()}),[ee]);const xt=m.useCallback(W=>{const ae=ee.filter(Ve=>Ve.value!==W.value);Ws(ae),n?.(ae)},[n,ee]),il=m.useCallback(W=>{const ae=Q.current;ae&&((W.key==="Delete"||W.key==="Backspace")&&ae.value===""&&ee.length>0&&(ee[ee.length-1].fixed||xt(ee[ee.length-1])),W.key==="Escape"&&ae.blur())},[xt,ee]);m.useEffect(()=>{s&&Ws(s)},[s]),m.useEffect(()=>{if(!r||i)return;const W=Bt(r||[],R);JSON.stringify(W)!==JSON.stringify(ks)&&Ta(W)},[l,r,R,i,ks]),m.useEffect(()=>{const W=async()=>{ka(!0);const Ve=await i?.(Js);Ta(Bt(Ve||[],R)),ka(!1)};(async()=>{!i||!$||(C&&await W(),Js&&await W())})()},[Js,R,$,C]);const cl=()=>{if(!j||Ru(ks,[{value:gs,label:gs}])||ee.find(ae=>ae.value===gs))return;const W=e.jsx(ke,{value:gs,className:"cursor-pointer",onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onSelect:ae=>{if(ee.length>=o){d?.(ee.length);return}At("");const Ve=[...ee,{value:ae,label:ae}];Ws(Ve),n?.(Ve)},children:`Create "${gs}"`});if(!i&&gs.length>0||i&&Js.length>0&&!Sa)return W},dl=m.useCallback(()=>{if(x)return i&&!j&&Object.keys(ks).length===0?e.jsx(ke,{value:"-",disabled:!0,children:x}):e.jsx(Lr,{children:x})},[j,x,i,ks]),ml=m.useMemo(()=>Eu(ks,ee),[ks,ee]),ul=m.useCallback(()=>{if(k?.filter)return k.filter;if(j)return(W,ae)=>W.toLowerCase().includes(ae.toLowerCase())?1:-1},[j,k?.filter]),xl=m.useCallback(()=>{const W=ee.filter(ae=>ae.fixed);Ws(W),n?.(W)},[n,ee]);return e.jsxs(Cs,{...k,onKeyDown:W=>{il(W),k?.onKeyDown?.(W)},className:_("h-auto overflow-visible bg-transparent",k?.className),shouldFilter:k?.shouldFilter!==void 0?k.shouldFilter:!i,filter:ul(),children:[e.jsx("div",{className:_("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":!P&&ee.length!==0},f),onClick:()=>{P||Q.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(W=>e.jsxs(K,{className:_("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",g),"data-fixed":W.fixed,"data-disabled":P||void 0,children:[W.label,e.jsx("button",{className:_("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(P||W.fixed)&&"hidden"),onKeyDown:ae=>{ae.key==="Enter"&&xt(W)},onMouseDown:ae=>{ae.preventDefault(),ae.stopPropagation()},onClick:()=>xt(W),children:e.jsx(Xt,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},W.value)),e.jsx(De.Input,{...v,ref:Q,value:gs,disabled:P,onValueChange:W=>{At(W),v?.onValueChange?.(W)},onBlur:W=>{Ys.current===!1&&X(!1),v?.onBlur?.(W)},onFocus:W=>{X(!0),C&&i?.(Js),v?.onFocus?.(W)},placeholder:p&&ee.length!==0?"":a,className:_("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},v?.className)}),e.jsx("button",{type:"button",onClick:xl,className:_((T||P||ee.length<1||ee.filter(W=>W.fixed).length===ee.length)&&"hidden"),children:e.jsx(Xt,{})})]})}),e.jsx("div",{className:"relative",children:$&&e.jsx(Ss,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Ys.current=!1},onMouseEnter:()=>{Ys.current=!0},onMouseUp:()=>{Q.current?.focus()},children:Sa?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[dl(),cl(),!S&&e.jsx(ke,{value:"-",className:"hidden"}),Object.entries(ml).map(([W,ae])=>e.jsx(Oe,{heading:W,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ae.map(Ve=>e.jsx(ke,{value:Ve.value,disabled:Ve.disable,onMouseDown:Qs=>{Qs.preventDefault(),Qs.stopPropagation()},onSelect:()=>{if(ee.length>=o){d?.(ee.length);return}At("");const Qs=[...ee,Ve];Ws(Qs),n?.(Qs)},className:_("cursor-pointer",Ve.disable&&"cursor-default text-muted-foreground"),children:Ve.label},Ve.value))})},W))]})})})]})});it.displayName="MultipleSelector";const Vu=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 Lt({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=I("group"),c=de({resolver:me(Vu(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1),[x,o]=m.useState(!1),d=async p=>{o(!0),Yc(p).then(()=>{q.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{o(!1)})};return e.jsxs(fe,{open:i,onOpenChange:u,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{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(pe,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Pe,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(ue,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(y,{control:c.control,name:"name",render:({field:p})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.name")}),e.jsx(w,{children:e.jsx(D,{placeholder:r("form.namePlaceholder"),...p,className:"w-full"})}),e.jsx(M,{children:r("form.nameDescription")}),e.jsx(E,{})]})}),e.jsxs(Le,{className:"gap-2",children:[e.jsx(ut,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(V,{type:"submit",disabled:x||!c.formState.isValid,children:[x&&e.jsx(ma,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Ar=m.createContext(void 0);function Iu({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[i,u]=m.useState(ye.Shadowsocks);return e.jsx(Ar.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:i,setServerType:u,refetch:n},children:s})}function $r(){const s=m.useContext(Ar);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Gt({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=j=>{if(!j)return null;try{const C=JSON.parse(j);return typeof C!="object"||C===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},P={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"}}}},R=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},f=()=>{const j=p(u||"");if(j){q.error(j);return}try{if(!u){a(null),i(!1);return}a(JSON.parse(u)),i(!1)}catch{q.error(r("network_settings.errors.save_failed"))}},g=j=>{x(j),d(p(j))},S=j=>{const C=P[j];if(C){const k=JSON.stringify(C.content,null,2);x(k),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(fe,{open:c,onOpenChange:j=>{!j&&c&&f(),i(j)},children:[e.jsx(ze,{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(pe,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[R().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:R().map(j=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>S(j),children:r("network_settings.use_template",{template:P[j].label})},j))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ps,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:u,placeholder:R().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:j=>g(j.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Le,{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 Ih(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 Fu={},Mu=Object.freeze(Object.defineProperty({__proto__:null,default:Fu},Symbol.toStringTag,{value:"Module"})),Fh=Oi(Mu),Ga=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Ou=()=>{try{const s=wi.box.keyPair(),n=Ga(Fa.encodeBase64(s.secretKey)),a=Ga(Fa.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},zu=()=>{try{return Ou()}catch(s){throw console.error("Error generating key pair:",s),s}},Lu=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)},Au=()=>{const s=Math.floor(Math.random()*8)*2+2;return Lu(s)},$u=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({})}),qu=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({})}),Ku=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({})}),Hu=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({})}),Uu=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("")}),os={shadowsocks:{schema:$u,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:qu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Ku,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Hu,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Uu,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"]}},Bu=({serverType:s,value:n,onChange:a})=>{const{t:l}=I("server"),r=s?os[s]:null,c=r?.schema||h.record(h.any()),i=s?c.parse({}):{},u=de({resolver:me(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(g=>{a(g)});return()=>f.unsubscribe()},[u,a]),!s||!r)return null;const R={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(y,{control:u.control,name:"cipher",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.shadowsocks.ciphers.map(g=>e.jsx(L,{value:g,children:g},g))})})]})})]})}),e.jsx(y,{control:u.control,name:"obfs",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(B,{children:e.jsxs(js,{children:[e.jsx(L,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(L,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"obfs_settings.path",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...f})}),e.jsx(E,{})]})}),e.jsx(y,{control:u.control,name:"obfs_settings.host",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.host"),...f})}),e.jsx(E,{})]})})]})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(y,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value?.toString(),onValueChange:g=>f.onChange(Number(g)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(L,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx(y,{control:u.control,name:"network",render:({field:f})=>e.jsxs(b,{children:[e.jsxs(N,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Gt,{value:u.watch("network_settings"),setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")})]}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.vmess.networkOptions.map(g=>e.jsx(L,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(y,{control:u.control,name:"allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(y,{control:u.control,name:"network",render:({field:f})=>e.jsxs(b,{children:[e.jsxs(N,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Gt,{value:u.watch("network_settings")||{},setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")||"tcp"})]}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value||"tcp",children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.trojan.networkOptions.map(g=>e.jsx(L,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"version",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(w,{children:e.jsxs(G,{value:(f.value||2).toString(),onValueChange:g=>f.onChange(Number(g)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.hysteria.versions.map(g=>e.jsxs(L,{value:g,className:"cursor-pointer",children:["V",g]},g))})})]})})]})}),u.watch("version")==1&&e.jsx(y,{control:u.control,name:"alpn",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value||"h2",onValueChange:f.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.hysteria.alpnOptions.map(g=>e.jsx(L,{value:g,children:g},g))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"obfs.open",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{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(y,{control:u.control,name:"obfs.type",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value||"salamander",onValueChange:f.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:e.jsx(L,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(y,{control:u.control,name:"obfs.password",render:({field:f})=>e.jsxs(b,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{children:e.jsx(D,{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 g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",S=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(j=>g[j%g.length]).join("");u.setValue("obfs.password",S),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(Se,{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(y,{control:u.control,name:"tls.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(y,{control:u.control,name:"tls.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(y,{control:u.control,name:"bandwidth.up",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{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(y,{control:u.control,name:"bandwidth.down",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{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(y,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.tls.label")}),e.jsx(w,{children:e.jsxs(G,{value:f.value?.toString(),onValueChange:g=>f.onChange(Number(g)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(L,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(L,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{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(y,{control:u.control,name:"reality_settings.server_name",render:({field:f})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"reality_settings.server_port",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...f})})]})}),e.jsx(y,{control:u.control,name:"reality_settings.allow_insecure",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(w,{children:e.jsx(H,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(y,{control:u.control,name:"reality_settings.private_key",render:({field:f})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{children:e.jsx(D,{...f,className:"pr-9"})}),e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const g=zu();u.setValue("reality_settings.private_key",g.privateKey),u.setValue("reality_settings.public_key",g.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(Se,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(wt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(y,{control:u.control,name:"reality_settings.public_key",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(w,{children:e.jsx(D,{...f})})]})}),e.jsx(y,{control:u.control,name:"reality_settings.short_id",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{children:e.jsx(D,{...f,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const g=Au();u.setValue("reality_settings.short_id",g),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(Se,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(wt,{children:e.jsx(te,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(M,{className:"text-xs text-muted-foreground",children:l("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(y,{control:u.control,name:"network",render:({field:f})=>e.jsxs(b,{children:[e.jsxs(N,{children:[l("dynamic_form.vless.network.label"),e.jsx(Gt,{value:u.watch("network_settings"),setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")})]}),e.jsx(w,{children:e.jsxs(G,{onValueChange:f.onChange,value:f.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(B,{children:e.jsx(js,{children:os.vless.networkOptions.map(g=>e.jsx(L,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})}),e.jsx(y,{control:u.control,name:"flow",render:({field:f})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dynamic_form.vless.flow.label")}),e.jsx(w,{children:e.jsxs(G,{onValueChange:g=>f.onChange(g==="none"?null:g),value:f.value||"none",children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(B,{children:os.vless.flowOptions.map(g=>e.jsx(L,{value:g,children:g},g))})]})})]})})]})};return e.jsx(ce,{children:R[s]?.()})},Gu=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()}),pt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Yu(){const{t:s}=I("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:i,refetch:u}=$r(),[x,o]=m.useState([]),[d,p]=m.useState([]),[P,R]=m.useState([]),f=de({resolver:me(Gu),defaultValues:pt,mode:"onChange"});m.useEffect(()=>{g()},[n]),m.useEffect(()=>{l?.type&&l.type!==c&&i(l.type)},[l,c,i]),m.useEffect(()=>{l?l.type===c&&f.reset({...pt,...l}):f.reset({...pt,protocol_settings:os[c].schema.parse({})})},[l,f,c]);const g=async()=>{if(!n)return;const[v,T,z]=await Promise.all([Ot(),Nr(),yr()]);o(v.data?.map(Q=>({label:Q.name,value:Q.id.toString()}))||[]),p(T.data?.map(Q=>({label:Q.remarks,value:Q.id.toString()}))||[]),R(z.data||[])},S=m.useMemo(()=>P?.filter(v=>(v.parent_id===0||v.parent_id===null)&&v.type===c&&v.id!==f.watch("id")),[c,P,f]),j=()=>e.jsxs(_s,{children:[e.jsx(ws,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(ds,{align:"start",children:e.jsx(gc,{children:Ps.map(({type:v,label:T})=>e.jsx(ge,{onClick:()=>{i(v),a(!0)},className:"cursor-pointer",children:e.jsx(K,{variant:"outline",className:"text-white",style:{background:is[v]},children:T})},v))})})]}),C=()=>{a(!1),r(null),f.reset(pt)},k=async()=>{const v=f.getValues();(await Kc({...v,type:c})).data&&(C(),q.success(s("form.success")),u())};return e.jsxs(fe,{open:n,onOpenChange:C,children:[j(),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(pe,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Pe,{})]}),e.jsxs(ue,{...f,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(y,{control:f.control,name:"name",render:({field:v})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:s("form.name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...v})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"rate",render:({field:v})=>e.jsxs(b,{className:"flex-[1]",children:[e.jsx(N,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(w,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...v})})}),e.jsx(E,{})]})})]}),e.jsx(y,{control:f.control,name:"code",render:({field:v})=>e.jsxs(b,{children:[e.jsxs(N,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(w,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...v,value:v.value||""})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"tags",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.tags.label")}),e.jsx(w,{children:e.jsx(ba,{value:v.value,onChange:v.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"group_ids",render:({field:v})=>e.jsxs(b,{children:[e.jsxs(N,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Lt,{dialogTrigger:e.jsx(V,{variant:"link",children:s("form.groups.add")}),refetch:g})]}),e.jsx(w,{children:e.jsx(it,{options:x,onChange:T=>v.onChange(T.map(z=>z.value)),value:x?.filter(T=>v.value.includes(T.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(E,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:f.control,name:"host",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.host.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...v})}),e.jsx(E,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(y,{control:f.control,name:"port",render:({field:v})=>e.jsxs(b,{className:"flex-1",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(Se,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(wt,{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(w,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...v})}),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const T=v.value;T&&f.setValue("server_port",T)},children:e.jsx(Se,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(te,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"server_port",render:({field:v})=>e.jsxs(b,{className:"flex-1",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(Se,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(wt,{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(w,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...v})}),e.jsx(E,{})]})})]})]}),n&&e.jsx(Bu,{serverType:c,value:f.watch("protocol_settings"),onChange:v=>f.setValue("protocol_settings",v,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(y,{control:f.control,name:"parent_id",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.parent.label")}),e.jsxs(G,{onValueChange:v.onChange,value:v.value?.toString()||"0",children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:s("form.parent.none")}),S?.map(T=>e.jsx(L,{value:T.id.toString(),className:"cursor-pointer",children:T.name},T.id))]})]}),e.jsx(E,{})]})}),e.jsx(y,{control:f.control,name:"route_ids",render:({field:v})=>e.jsxs(b,{children:[e.jsx(N,{children:s("form.route.label")}),e.jsx(w,{children:e.jsx(it,{options:d,onChange:T=>v.onChange(T.map(z=>z.value)),value:d?.filter(T=>v.value.includes(T.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(E,{})]})})]}),e.jsxs(Le,{className:"mt-6",children:[e.jsx(V,{type:"button",variant:"outline",onClick:C,children:s("form.cancel")}),e.jsx(V,{type:"submit",onClick:k,children:s("form.submit")})]})]})]})]})}function Ya({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(mt,{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(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(ke,{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:_("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(Rs,{className:_("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(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Wu=[{value:ye.Shadowsocks,label:Ps.find(s=>s.type===ye.Shadowsocks)?.label,color:is[ye.Shadowsocks]},{value:ye.Vmess,label:Ps.find(s=>s.type===ye.Vmess)?.label,color:is[ye.Vmess]},{value:ye.Trojan,label:Ps.find(s=>s.type===ye.Trojan)?.label,color:is[ye.Trojan]},{value:ye.Hysteria,label:Ps.find(s=>s.type===ye.Hysteria)?.label,color:is[ye.Hysteria]},{value:ye.Vless,label:Ps.find(s=>s.type===ye.Vless)?.label,color:is[ye.Vless]}];function Ju({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(Yu,{}),e.jsx(D,{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(Ya,{column:s.getColumn("type"),title:c("toolbar.type"),options:Wu}),s.getColumn("groups")&&e.jsx(Ya,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:i})]}),r&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Ae,{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(V,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const ct=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"})}),gt={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"},Qu=s=>{const{t:n}=I("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Vt,{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(O,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(K,{variant:"outline",className:_("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:is[a.original.type]},children:[e.jsx(Gn,{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(V,{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(),kt(r||l.toString()).then(()=>{q.success(n("common:copy.success"))})},children:e.jsx(Ma,{className:"size-3"})})]})}),e.jsxs(te,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ps.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(O,{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),Bc({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?is[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{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:_("h-2.5 w-2.5 rounded-full",gt[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:_("h-2.5 w-2.5 rounded-full",gt[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:_("h-2.5 w-2.5 rounded-full",gt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:_("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",gt[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(O,{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(ce,{delayDuration:0,children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{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(),kt(l).then(()=>{q.success(n("common:copy.success"))})},children:e.jsx(Ma,{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(O,{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(ct,{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(O,{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(O,{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:_("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(O,{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:is[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=$r();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(_s,{modal:!1,children:[e.jsx(ws,{asChild:!0,children:e.jsx(V,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Ct,{className:"size-4"})})}),e.jsxs(ds,{align:"end",className:"w-40",children:[e.jsx(ge,{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(Ci,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(ge,{className:"cursor-pointer",onClick:async()=>{Uc({id:a.original.id}).then(({data:i})=>{i&&(q.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Si,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(lt,{}),e.jsx(ge,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:i=>i.preventDefault(),children:e.jsx(Ue,{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()=>{Hc({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(ns,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Zu(){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),[P,R]=m.useState({}),[f,g]=m.useState([]),{refetch:S}=se({queryKey:["nodeList"],queryFn:async()=>{const{data:z}=await yr();return g(z),z}}),j=m.useMemo(()=>{const z=new Set;return f.forEach(Q=>{Q.groups&&Q.groups.forEach($=>z.add($.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}),R({name:d?2e3:200}),u({pageSize:d?99999:500,pageIndex:0})},[d]);const C=(z,Q)=>{d&&(z.dataTransfer.setData("text/plain",Q.toString()),z.currentTarget.classList.add("opacity-50"))},k=(z,Q)=>{if(!d)return;z.preventDefault(),z.currentTarget.classList.remove("bg-muted");const $=parseInt(z.dataTransfer.getData("text/plain"));if($===Q)return;const X=[...f],[Ys]=X.splice($,1);X.splice(Q,0,Ys),g(X)},v=async()=>{if(!d){p(!0);return}const z=f?.map((Q,$)=>({id:Q.id,order:$+1}));Gc(z).then(()=>{q.success("排序保存成功"),p(!1),S()}).finally(()=>{p(!1)})},T=Ke({data:f||[],columns:Qu(S),state:{sorting:x,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:P,pagination:i},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:R,onPaginationChange:u,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Iu,{refetch:S,children:e.jsx("div",{className:"space-y-4",children:e.jsx(es,{table:T,toolbar:z=>e.jsx(Ju,{table:z,refetch:S,saveOrder:v,isSortMode:d,groups:j}),draggable:d,onDragStart:C,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:k,showPagination:!d})})})}function Xu(){const{t:s}=I("server");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(Zu,{})})]})]})}const ex=Object.freeze(Object.defineProperty({__proto__:null,default:Xu},Symbol.toStringTag,{value:"Module"}));function sx({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(Lt,{refetch:n}),e.jsx(D,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:_("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})})}const tx=s=>{const{t:n}=I("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{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(O,{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(O,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ct,{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(O,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Gn,{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(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Lt,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Ue,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Wc({id:a.original.id}).then(({data:l})=>{l&&(q.success(n("messages.updateSuccess")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 ax(){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:P}=await Ot();return P}}),p=Ke({data:x||[],columns:tx(o),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:p,toolbar:P=>e.jsx(sx,{table:P,refetch:o}),isLoading:d})}function nx(){const{t:s}=I("group");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(ax,{})})]})]})}const rx=Object.freeze(Object.defineProperty({__proto__:null,default:nx},Symbol.toStringTag,{value:"Module"})),lx=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 qr({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=I("route"),c=de({resolver:me(lx(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1);return e.jsxs(fe,{open:i,onOpenChange:u,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Se,{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(pe,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Pe,{})]}),e.jsxs(ue,{...c,children:[e.jsx(y,{control:c.control,name:"remarks",render:({field:x})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:r("form.remarksPlaceholder"),...x})})}),e.jsx(E,{})]})}),e.jsx(y,{control:c.control,name:"match",render:({field:x})=>e.jsxs(b,{className:"flex-[2]",children:[e.jsx(N,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(ps,{className:"min-h-[120px]",placeholder:r("form.matchPlaceholder"),value:x.value.join(` `),onChange:o=>{x.onChange(o.target.value.split(` -`))}})})}),e.jsx(E,{})]})}),e.jsx(y,{control:c.control,name:"action",render:({field:x})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(U,{children:e.jsx(W,{placeholder:r("form.actionPlaceholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"block",children:r("actions.block")}),e.jsx(L,{value:"dns",children:r("actions.dns")})]})]})})}),e.jsx(E,{})]})}),c.watch("action")==="dns"&&e.jsx(y,{control:c.control,name:"action_value",render:({field:x})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:r("form.dnsPlaceholder"),...x})})})]})}),e.jsxs(Le,{children:[e.jsx(mt,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r("form.cancel")})}),e.jsx(V,{type:"submit",onClick:()=>{Yc(c.getValues()).then(({data:x})=>{x&&(u(!1),s&&s(),toast.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),c.reset())})},children:r("form.submit")})]})]})]})]})}function lx({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=I("route");return e.jsx("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:[e.jsx($r,{refetch:n}),e.jsx(D,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:r=>s.getColumn("remarks")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),a&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})})}function ox({columns:s,data:n,refetch:a}){const[l,r]=m.useState({}),[c,i]=m.useState({}),[u,x]=m.useState([]),[o,d]=m.useState([]),p=Ke({data:n,columns:s,state:{sorting:o,columnVisibility:c,rowSelection:l,columnFilters:u},enableRowSelection:!0,onRowSelectionChange:r,onSortingChange:d,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:p,toolbar:T=>e.jsx(lx,{table:T,refetch:a})})}const ix=s=>{const{t:n}=I("route"),a={block:{icon:Si,variant:"destructive",className:"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-800"},dns:{icon:ki,variant:"secondary",className:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-400 hover:bg-blue-200 dark:hover:bg-blue-800"}};return[{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.id")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(K,{variant:"outline",children:l.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.remarks")}),cell:({row:l})=>{const r=l.original.match?.length||0;return e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:n("columns.matchRules",{count:r})})})},enableHiding:!1,enableSorting:!1},{accessorKey:"action",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.action")}),cell:({row:l})=>{const r=l.getValue("action"),c=a[r]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(K,{variant:a[r]?.variant||"default",className:_("flex items-center gap-1.5 px-3 py-1 capitalize",a[r]?.className),children:[c&&e.jsx(c,{className:"h-3.5 w-3.5"}),n(`actions.${r}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx($r,{defaultValues:l.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Ue,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Jc({id:l.original.id}).then(({data:r})=>{r&&(q.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 cx(){const{t:s}=I("route"),[n,a]=m.useState([]);function l(){yr().then(({data:r})=>{a(r)})}return m.useEffect(()=>{l()},[]),e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(ox,{data:n,columns:ix(l),refetch:l})})]})]})}const dx=Object.freeze(Object.defineProperty({__proto__:null,default:cx},Symbol.toStringTag,{value:"Module"})),qr=m.createContext(void 0);function mx({children:s,refreshData:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null);return e.jsx(qr.Provider,{value:{isOpen:a,setIsOpen:l,editingPlan:r,setEditingPlan:c,refreshData:n},children:s})}function ba(){const s=m.useContext(qr);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function ux({table:s,saveOrder:n,isSortMode:a}){const{setIsOpen:l}=ba(),{t:r}=I("subscribe");return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(V,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>l(!0),children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:r("plan.add")})]}),e.jsx(D,{placeholder:r("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:c=>s.getColumn("name")?.setFilterValue(c.target.value),className:"h-8 w-[150px] lg:w-[250px]"})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{variant:a?"default":"outline",onClick:n,size:"sm",children:r(a?"plan.sort.save":"plan.sort.edit")})})]})}const Wa={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},xx=s=>{const{t:n}=I("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Rt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.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,enableHiding:!1},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.show")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("show"),onCheckedChange:l=>{qt({id:a.original.id,show:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.sell")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("sell"),onCheckedChange:l=>{qt({id:a.original.id,sell:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("renew"),onCheckedChange:l=>{qt({id:a.original.id,renew:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.stats")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(it,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.group")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(K,{variant:"secondary",className:_("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:a.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.price")}),cell:({row:a})=>{const l=a.getValue("prices"),r=[{period:n("plan.columns.price_period.monthly"),key:"monthly",unit:n("plan.columns.price_period.unit.month")},{period:n("plan.columns.price_period.quarterly"),key:"quarterly",unit:n("plan.columns.price_period.unit.quarter")},{period:n("plan.columns.price_period.half_yearly"),key:"half_yearly",unit:n("plan.columns.price_period.unit.half_year")},{period:n("plan.columns.price_period.yearly"),key:"yearly",unit:n("plan.columns.price_period.unit.year")},{period:n("plan.columns.price_period.two_yearly"),key:"two_yearly",unit:n("plan.columns.price_period.unit.two_year")},{period:n("plan.columns.price_period.three_yearly"),key:"three_yearly",unit:n("plan.columns.price_period.unit.three_year")},{period:n("plan.columns.price_period.onetime"),key:"onetime",unit:""},{period:n("plan.columns.price_period.reset_traffic"),key:"reset_traffic",unit:n("plan.columns.price_period.unit.times")}];return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.map(({period:c,key:i,unit:u})=>l[i]!=null&&e.jsxs(K,{variant:"secondary",className:_("px-2 py-0.5 font-medium transition-colors text-nowrap",Wa[i].color,Wa[i].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[c," ¥",l[i],u]},i))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("plan.columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingPlan:r}=ba();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{r(a.original),l(!0)},children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(Ue,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{hd({id:a.original.id}).then(({data:c})=>{c&&(q.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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("plan.columns.delete")})]})})]})}}]},hx=h.object({id:h.number().nullable(),group_id:h.union([h.number(),h.string()]).nullable().optional(),name:h.string().min(1).max(250),content:h.string().nullable().optional(),transfer_enable:h.union([h.number().min(0),h.string().min(1)]),prices:h.object({monthly:h.union([h.number(),h.string()]).nullable().optional(),quarterly:h.union([h.number(),h.string()]).nullable().optional(),half_yearly:h.union([h.number(),h.string()]).nullable().optional(),yearly:h.union([h.number(),h.string()]).nullable().optional(),two_yearly:h.union([h.number(),h.string()]).nullable().optional(),three_yearly:h.union([h.number(),h.string()]).nullable().optional(),onetime:h.union([h.number(),h.string()]).nullable().optional(),reset_traffic:h.union([h.number(),h.string()]).nullable().optional()}).default({}),speed_limit:h.union([h.number(),h.string()]).nullable().optional(),capacity_limit:h.union([h.number(),h.string()]).nullable().optional(),device_limit:h.union([h.number(),h.string()]).nullable().optional(),force_update:h.boolean().optional(),reset_traffic_method:h.number().nullable(),users_count:h.number().optional()}),Kr=m.forwardRef(({className:s,...n},a)=>e.jsx(Gn,{ref:a,className:_("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...n,children:e.jsx(Pi,{className:_("flex items-center justify-center text-current"),children:e.jsx(Rs,{className:"h-4 w-4"})})}));Kr.displayName=Gn.displayName;const gt={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},jt={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},fx=[{value:null,label:"follow_system"},{value:0,label:"monthly_first"},{value:1,label:"monthly_reset"},{value:2,label:"no_reset"},{value:3,label:"yearly_first"},{value:4,label:"yearly_reset"}];function px(){const{isOpen:s,setIsOpen:n,editingPlan:a,setEditingPlan:l,refreshData:r}=ba(),[c,i]=m.useState(!1),{t:u}=I("subscribe"),x=de({resolver:me(hx),defaultValues:{...gt,...a||{}},mode:"onChange"});m.useEffect(()=>{a?x.reset({...gt,...a}):x.reset(gt)},[a,x]);const o=new ma({html:!0}),[d,p]=m.useState();async function T(){Mt().then(({data:g})=>{p(g)})}m.useEffect(()=>{s&&T()},[s]);const R=g=>{if(isNaN(g))return;const S=Object.entries(jt).reduce((j,[C,k])=>{const v=g*k.months*k.discount;return{...j,[C]:v.toFixed(2)}},{});x.setValue("prices",S,{shouldDirty:!0})},f=()=>{n(!1),l(null),x.reset(gt)};return e.jsx(pe,{open:s,onOpenChange:f,children:e.jsxs(he,{children:[e.jsxs(be,{children:[e.jsx(ge,{children:u(a?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Te,{})]}),e.jsxs(ue,{...x,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:x.control,name:"name",render:({field:g})=>e.jsxs(b,{children:[e.jsx(N,{children:u("plan.form.name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:u("plan.form.name.placeholder"),...g})}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"group_id",render:({field:g})=>e.jsxs(b,{children:[e.jsxs(N,{className:"flex items-center justify-between",children:[u("plan.form.group.label"),e.jsx(zt,{dialogTrigger:e.jsx(V,{variant:"link",children:u("plan.form.group.add")}),refetch:T})]}),e.jsxs(G,{value:g.value?.toString()??"",onValueChange:S=>g.onChange(S?Number(S):null),children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:u("plan.form.group.placeholder")})})}),e.jsx(B,{children:d?.map(S=>e.jsx(L,{value:S.id.toString(),children:S.name},S.id))})]}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"transfer_enable",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.transfer.placeholder"),className:"rounded-r-none",...g})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.transfer.unit")})]}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"speed_limit",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.speed.placeholder"),className:"rounded-r-none",...g,value:g.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.speed.unit")})]}),e.jsx(E,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:u("plan.form.price.title")}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(D,{type:"number",placeholder:u("plan.form.price.base_price"),className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:g=>{const S=parseFloat(g.target.value);R(S)}})]}),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const g=Object.keys(jt).reduce((S,j)=>({...S,[j]:""}),{});x.setValue("prices",g,{shouldDirty:!0})},children:u("plan.form.price.clear.button")})}),e.jsx(te,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:u("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(jt).filter(([g])=>!["onetime","reset_traffic"].includes(g)).map(([g,S])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(y,{control:x.control,name:`prices.${g}`,render:({field:j})=>e.jsxs(b,{children:[e.jsxs(N,{className:"text-xs font-medium text-muted-foreground",children:[u(`plan.columns.price_period.${g}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",S.months===1?u("plan.form.price.period.monthly"):u("plan.form.price.period.months",{count:S.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...j,value:j.value??"",onChange:C=>j.onChange(C.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},g))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(jt).filter(([g])=>["onetime","reset_traffic"].includes(g)).map(([g,S])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(y,{control:x.control,name:`prices.${g}`,render:({field:j})=>e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(N,{className:"text-xs font-medium",children:u(`plan.columns.price_period.${g}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:u(g==="onetime"?"plan.form.price.onetime_desc":"plan.form.price.reset_desc")})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...j,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},g))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(y,{control:x.control,name:"device_limit",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.device.placeholder"),className:"rounded-r-none",...g,value:g.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.device.unit")})]}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"capacity_limit",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.capacity.placeholder"),className:"rounded-r-none",...g,value:g.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.capacity.unit")})]}),e.jsx(E,{})]})})]}),e.jsx(y,{control:x.control,name:"reset_traffic_method",render:({field:g})=>e.jsxs(b,{children:[e.jsx(N,{children:u("plan.form.reset_method.label")}),e.jsxs(G,{value:g.value?.toString()??"null",onValueChange:S=>g.onChange(S=="null"?null:Number(S)),children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(W,{placeholder:u("plan.form.reset_method.placeholder")})})}),e.jsx(B,{children:fx.map(S=>e.jsx(L,{value:S.value?.toString()??"null",children:u(`plan.form.reset_method.options.${S.label}`)},S.value))})]}),e.jsx(M,{className:"text-xs",children:u("plan.form.reset_method.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"content",render:({field:g})=>{const[S,j]=m.useState(!1);return e.jsxs(b,{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u("plan.form.content.label"),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>j(!S),children:S?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(te,{side:"top",children:e.jsx("p",{className:"text-xs",children:u(S?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{variant:"outline",size:"sm",onClick:()=>{g.onChange(u("plan.form.content.template.content"))},children:u("plan.form.content.template.button")})}),e.jsx(te,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:u("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${S?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(w,{children:e.jsx(ua,{style:{height:"400px"},value:g.value||"",renderHTML:C=>o.render(C),onChange:({text:C})=>g.onChange(C),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:u("plan.form.content.placeholder"),className:"rounded-md border"})})}),S&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:u("plan.form.content.preview")}),e.jsx("div",{className:"prose prose-sm dark:prose-invert h-[400px] max-w-none overflow-y-auto rounded-md border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:o.render(g.value||"")}})})]})]}),e.jsx(M,{className:"text-xs",children:u("plan.form.content.description")}),e.jsx(E,{})]})}})]}),e.jsx(Le,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:a&&e.jsx(y,{control:x.control,name:"force_update",render:({field:g})=>e.jsxs(b,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(w,{children:e.jsx(Kr,{checked:g.value,onCheckedChange:g.onChange})}),e.jsx("div",{className:"",children:e.jsx(N,{className:"text-sm",children:u("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:f,children:u("plan.form.submit.cancel")}),e.jsx(V,{type:"submit",disabled:c,onClick:()=>{x.handleSubmit(async g=>{i(!0),(await xd(g)).data&&(q.success(u(a?"plan.form.submit.success.update":"plan.form.submit.success.add")),f(),r()),i(!1)})()},children:u(c?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function gx(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[i,u]=m.useState([]),[x,o]=m.useState(!1),[d,p]=m.useState({pageSize:20,pageIndex:0}),[T,R]=m.useState([]),{refetch:f}=se({queryKey:["planList"],queryFn:async()=>{const{data:k}=await Os();return R(k),k}});m.useEffect(()=>{l({"drag-handle":x}),p({pageSize:x?99999:10,pageIndex:0})},[x]);const g=(k,v)=>{x&&(k.dataTransfer.setData("text/plain",v.toString()),k.currentTarget.classList.add("opacity-50"))},S=(k,v)=>{if(!x)return;k.preventDefault(),k.currentTarget.classList.remove("bg-muted");const P=parseInt(k.dataTransfer.getData("text/plain"));if(P===v)return;const z=[...T],[Q]=z.splice(P,1);z.splice(v,0,Q),R(z)},j=async()=>{if(!x){o(!0);return}const k=T?.map(v=>v.id);fd(k).then(()=>{q.success("排序保存成功"),o(!1),f()}).finally(()=>{o(!1)})},C=Ke({data:T||[],columns:xx(f),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:d},enableRowSelection:!0,onPaginationChange:p,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}},pageCount:x?1:void 0});return e.jsx(mx,{refreshData:f,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(es,{table:C,toolbar:k=>e.jsx(ux,{table:k,refetch:f,saveOrder:j,isSortMode:x}),draggable:x,onDragStart:g,onDragEnd:k=>k.currentTarget.classList.remove("opacity-50"),onDragOver:k=>{k.preventDefault(),k.currentTarget.classList.add("bg-muted")},onDragLeave:k=>k.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!x}),e.jsx(px,{})]})})}function jx(){const{t:s}=I("subscribe");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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("plan.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("plan.page.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(gx,{})})]})]})}const vx=Object.freeze(Object.defineProperty({__proto__:null,default:jx},Symbol.toStringTag,{value:"Module"})),$s=[{value:Z.PENDING,label:Zs[Z.PENDING],icon:Ti,color:Xs[Z.PENDING]},{value:Z.PROCESSING,label:Zs[Z.PROCESSING],icon:Wn,color:Xs[Z.PROCESSING]},{value:Z.COMPLETED,label:Zs[Z.COMPLETED],icon:Xt,color:Xs[Z.COMPLETED]},{value:Z.CANCELLED,label:Zs[Z.CANCELLED],icon:Yn,color:Xs[Z.CANCELLED]},{value:Z.DISCOUNTED,label:Zs[Z.DISCOUNTED],icon:Xt,color:Xs[Z.DISCOUNTED]}],st=[{value:re.PENDING,label:xt[re.PENDING],icon:Di,color:ht[re.PENDING]},{value:re.PROCESSING,label:xt[re.PROCESSING],icon:Wn,color:ht[re.PROCESSING]},{value:re.VALID,label:xt[re.VALID],icon:Xt,color:ht[re.VALID]},{value:re.INVALID,label:xt[re.INVALID],icon:Yn,color:ht[re.INVALID]}];function vt({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=s?.getFilterValue(),c=Array.isArray(r)?new Set(r):r!==void 0?new Set([r]):new Set;return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),n,c?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:c.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:c.size>2?e.jsxs(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[c.size," selected"]}):a.filter(i=>c.has(i.value)).map(i=>e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(i=>{const u=c.has(i.value);return e.jsxs(ke,{onSelect:()=>{const x=new Set(c);u?x.delete(i.value):x.add(i.value);const o=Array.from(x);s?.setFilterValue(o.length?o:void 0)},children:[e.jsx("div",{className:_("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",u?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Rs,{className:_("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),l?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(i.value)})]},i.value)})}),c.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const bx=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),yx={email:"",plan_id:0,total_amount:0,period:""};function Hr({refetch:s,trigger:n,defaultValues:a}){const{t:l}=I("order"),[r,c]=m.useState(!1),i=de({resolver:me(bx),defaultValues:{...yx,...a},mode:"onChange"}),[u,x]=m.useState([]);return m.useEffect(()=>{r&&Os().then(({data:o})=>{x(o)})},[r]),e.jsxs(pe,{open:r,onOpenChange:c,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:l("dialog.addOrder")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:l("dialog.assignOrder")}),e.jsx(Te,{})]}),e.jsxs(ue,{...i,children:[e.jsx(y,{control:i.control,name:"email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.userEmail")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dialog.placeholders.email"),...o})})]})}),e.jsx(y,{control:i.control,name:"plan_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.subscriptionPlan")}),e.jsx(w,{children:e.jsxs(G,{value:o.value?o.value?.toString():void 0,onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dialog.placeholders.plan")})}),e.jsx(B,{children:u.map(d=>e.jsx(L,{value:d.id.toString(),children:d.name},d.id))})]})})]})}),e.jsx(y,{control:i.control,name:"period",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.orderPeriod")}),e.jsx(w,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(U,{children:e.jsx(W,{placeholder:l("dialog.placeholders.period")})}),e.jsx(B,{children:Object.keys(Hd).map(d=>e.jsx(L,{value:d,children:l(`period.${d}`)},d))})]})})]})}),e.jsx(y,{control:i.control,name:"total_amount",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.paymentAmount")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:l("dialog.placeholders.amount"),value:o.value/100,onChange:d=>o.onChange(parseFloat(d.currentTarget.value)*100)})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(V,{variant:"outline",onClick:()=>c(!1),children:l("dialog.actions.cancel")}),e.jsx(V,{type:"submit",onClick:()=>{i.handleSubmit(o=>{bd(o).then(({data:d})=>{d&&(s&&s(),i.reset(),c(!1),q.success(l("dialog.messages.addSuccess")))})})()},children:l("dialog.actions.confirm")})]})]})]})]})}function Nx({table:s,refetch:n}){const{t:a}=I("order"),l=s.getState().columnFilters.length>0,r=Object.values(Ye).filter(x=>typeof x=="number").map(x=>({label:a(`type.${Ye[x]}`),value:x,color:x===Ye.NEW?"green-500":x===Ye.RENEWAL?"blue-500":x===Ye.UPGRADE?"purple-500":"orange-500"})),c=Object.values(fe).map(x=>({label:a(`period.${x}`),value:x,color:x===fe.MONTH_PRICE?"slate-500":x===fe.QUARTER_PRICE?"cyan-500":x===fe.HALF_YEAR_PRICE?"indigo-500":x===fe.YEAR_PRICE?"violet-500":x===fe.TWO_YEAR_PRICE?"fuchsia-500":x===fe.THREE_YEAR_PRICE?"pink-500":x===fe.ONETIME_PRICE?"rose-500":"orange-500"})),i=Object.values(Z).filter(x=>typeof x=="number").map(x=>({label:a(`status.${Z[x]}`),value:x,icon:x===Z.PENDING?$s[0].icon:x===Z.PROCESSING?$s[1].icon:x===Z.COMPLETED?$s[2].icon:x===Z.CANCELLED?$s[3].icon:$s[4].icon,color:x===Z.PENDING?"yellow-500":x===Z.PROCESSING?"blue-500":x===Z.COMPLETED?"green-500":x===Z.CANCELLED?"red-500":"green-500"})),u=Object.values(re).filter(x=>typeof x=="number").map(x=>({label:a(`commission.${re[x]}`),value:x,icon:x===re.PENDING?st[0].icon:x===re.PROCESSING?st[1].icon:x===re.VALID?st[2].icon:st[3].icon,color:x===re.PENDING?"yellow-500":x===re.PROCESSING?"blue-500":x===re.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Hr,{refetch:n}),e.jsx(D,{placeholder:a("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:x=>s.getColumn("trade_no")?.setFilterValue(x.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2",children:[s.getColumn("type")&&e.jsx(vt,{column:s.getColumn("type"),title:a("table.columns.type"),options:r}),s.getColumn("period")&&e.jsx(vt,{column:s.getColumn("period"),title:a("table.columns.period"),options:c}),s.getColumn("status")&&e.jsx(vt,{column:s.getColumn("status"),title:a("table.columns.status"),options:i}),s.getColumn("commission_status")&&e.jsx(vt,{column:s.getColumn("commission_status"),title:a("table.columns.commissionStatus"),options:u})]}),l&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[a("actions.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})}function Be({label:s,value:n,className:a,valueClassName:l}){return e.jsxs("div",{className:_("flex items-center py-1.5",a),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:_("text-sm",l),children:n||"-"})]})}function _x({status:s}){const{t:n}=I("order"),a={[Z.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[Z.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[Z.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[Z.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[Z.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(K,{variant:"secondary",className:_("font-medium",a[s]),children:n(`status.${Z[s]}`)})}function wx({id:s,trigger:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(),{t:i}=I("order");return m.useEffect(()=>{(async()=>{if(a){const{data:x}=await gd({id:s});c(x)}})()},[a,s]),e.jsxs(pe,{onOpenChange:l,open:a,children:[e.jsx(ze,{asChild:!0,children:n}),e.jsxs(he,{className:"max-w-xl",children:[e.jsxs(be,{className:"space-y-2",children:[e.jsx(ge,{className:"text-lg font-medium",children:i("dialog.title")}),e.jsx("div",{className:"flex items-center justify-between text-sm",children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-muted-foreground",children:[i("table.columns.tradeNo"),":",r?.trade_no]}),r?.status&&e.jsx(_x,{status:r.status})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:i("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Be,{label:i("dialog.fields.userEmail"),value:r?.user?.email?e.jsxs(Vs,{to:`/user/manage?email=${r.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[r.user.email,e.jsx(Jn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(Be,{label:i("dialog.fields.orderPeriod"),value:r&&i(`period.${r.period}`)}),e.jsx(Be,{label:i("dialog.fields.subscriptionPlan"),value:r?.plan?.name,valueClassName:"font-medium"}),e.jsx(Be,{label:i("dialog.fields.callbackNo"),value:r?.callback_no,valueClassName:"font-mono text-xs"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:i("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Be,{label:i("dialog.fields.paymentAmount"),value:Ps(r?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(ye,{className:"my-2"}),e.jsx(Be,{label:i("dialog.fields.balancePayment"),value:Ps(r?.balance_amount||0)}),e.jsx(Be,{label:i("dialog.fields.discountAmount"),value:Ps(r?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(Be,{label:i("dialog.fields.refundAmount"),value:Ps(r?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(Be,{label:i("dialog.fields.deductionAmount"),value:Ps(r?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:i("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Be,{label:i("dialog.fields.createdAt"),value:xe(r?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(Be,{label:i("dialog.fields.updatedAt"),value:xe(r?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const Cx={[Ye.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ye.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ye.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ye.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Sx={[fe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[fe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},kx=s=>Z[s],Px=s=>re[s],Tx=s=>Ye[s],Dx=s=>{const{t:n}=I("order");return[{accessorKey:"trade_no",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.tradeNo")}),cell:({row:a})=>{const l=a.original.trade_no,r=l.length>6?`${l.slice(0,3)}...${l.slice(-3)}`:l;return e.jsx("div",{className:"flex items-center",children:e.jsx(wx,{trigger:e.jsxs(J,{variant:"ghost",size:"sm",className:"flex h-8 items-center gap-1.5 px-2 font-medium text-primary transition-colors hover:bg-primary/10 hover:text-primary/80",children:[e.jsx("span",{className:"font-mono",children:r}),e.jsx(Jn,{className:"h-3.5 w-3.5 opacity-70"})]}),id:a.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.type")}),cell:({row:a})=>{const l=a.getValue("type"),r=Cx[l];return e.jsx(K,{variant:"secondary",className:_("font-medium transition-colors text-nowrap",r.color,r.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${Tx(l)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.plan")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium text-foreground/90 sm:max-w-72 md:max-w-[31rem]",children:a.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.period")}),cell:({row:a})=>{const l=a.getValue("period"),r=Sx[l];return e.jsx(K,{variant:"secondary",className:_("font-medium transition-colors text-nowrap",r.color,r.bgColor,"hover:bg-opacity-80"),children:n(`period.${l}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.amount")}),cell:({row:a})=>{const l=a.getValue("total_amount"),r=typeof l=="number"?(l/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",r]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:a})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:a,title:n("table.columns.status")}),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsx(Fr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(te,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:a})=>{const l=$s.find(r=>r.value===a.getValue("status"));return l?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.icon&&e.jsx(l.icon,{className:`h-4 w-4 text-${l.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${kx(l.value)}`)})]}),l.value===Z.PENDING&&e.jsxs(_s,{modal:!0,children:[e.jsx(ws,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(wt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(ds,{align:"end",className:"w-[140px]",children:[e.jsx(je,{className:"cursor-pointer",onClick:async()=>{await jd({trade_no:a.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await vd({trade_no:a.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.commission")}),cell:({row:a})=>{const l=a.getValue("commission_balance"),r=l?(l/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:l?`¥${r}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.commissionStatus")}),cell:({row:a})=>{const l=a.original.status,r=a.original.commission_balance,c=st.find(i=>i.value===a.getValue("commission_status"));return r==0||!c?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c.icon&&e.jsx(c.icon,{className:`h-4 w-4 text-${c.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${Px(c.value)}`)})]}),c.value===re.PENDING&&l===Z.COMPLETED&&e.jsxs(_s,{modal:!0,children:[e.jsx(ws,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(wt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(ds,{align:"end",className:"w-[120px]",children:[e.jsx(je,{className:"cursor-pointer",onClick:async()=>{await Aa({trade_no:a.original.trade_no,commission_status:re.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(je,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await Aa({trade_no:a.original.trade_no,commission_status:re.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.createdAt")}),cell:({row:a})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:xe(a.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function Ex(){const[s]=Qn(),[n,a]=m.useState({}),[l,r]=m.useState({}),[c,i]=m.useState([]),[u,x]=m.useState([]),[o,d]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const S=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([j,C])=>{const k=s.get(j);return k?{id:j,value:C==="number"?parseInt(k):k}:null}).filter(Boolean);S.length>0&&i(S)},[s]);const{refetch:p,data:T,isLoading:R}=se({queryKey:["orderList",o,c,u],queryFn:()=>pd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:u})}),f=Ke({data:T?.data??[],columns:Dx(p),state:{sorting:u,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:o},rowCount:T?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),onPaginationChange:d,getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:f,toolbar:e.jsx(Nx,{table:f,refetch:p}),showPagination:!0})}function Rx(){const{t:s}=I("order");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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:"text-muted-foreground mt-2",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(Ex,{})})]})]})}const Vx=Object.freeze(Object.defineProperty({__proto__:null,default:Rx},Symbol.toStringTag,{value:"Module"}));function Ix({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{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(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(ke,{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:_("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(Rs,{className:_("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(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Fx=h.object({id:h.coerce.number().nullable().optional(),name:h.string().min(1,"请输入优惠券名称"),code:h.string().nullable(),type:h.coerce.number(),value:h.coerce.number(),started_at:h.coerce.number(),ended_at:h.coerce.number(),limit_use:h.union([h.string(),h.number()]).nullable(),limit_use_with_user:h.union([h.string(),h.number()]).nullable(),generate_count:h.coerce.number().nullable().optional(),limit_plan_ids:h.array(h.number()).default([]).nullable(),limit_period:h.array(h.nativeEnum(fe)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),Ya={name:"",code:"",type:Fe.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:"",limit_use_with_user:"",limit_plan_ids:[],limit_period:[],generate_count:""};function Ur({defaultValues:s,refetch:n,type:a="create",dialogTrigger:l=null,open:r,onOpenChange:c}){const{t:i}=I("coupon"),[u,x]=m.useState(!1),o=r??u,d=c??x,[p,T]=m.useState([]),R=de({resolver:me(Fx),defaultValues:s||Ya});m.useEffect(()=>{s&&R.reset(s)},[s,R]),m.useEffect(()=>{Os().then(({data:j})=>T(j))},[]);const f=j=>{if(!j)return;const C=(k,v)=>{const P=new Date(v*1e3);return k.setHours(P.getHours(),P.getMinutes(),P.getSeconds()),Math.floor(k.getTime()/1e3)};j.from&&R.setValue("started_at",C(j.from,R.watch("started_at"))),j.to&&R.setValue("ended_at",C(j.to,R.watch("ended_at")))},g=async j=>{Nd(j).then(()=>{d(!1),a==="create"&&R.reset(Ya),n()})},S=(j,C)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:C}),e.jsx(D,{type:"datetime-local",step:"1",value:xe(R.watch(j),"YYYY-MM-DDTHH:mm:ss"),onChange:k=>{const v=new Date(k.target.value);R.setValue(j,Math.floor(v.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(pe,{open:o,onOpenChange:d,children:[l&&e.jsx(ze,{asChild:!0,children:l}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsx(be,{children:e.jsx(ge,{children:i(a==="create"?"form.add":"form.edit")})}),e.jsx(ue,{...R,children:e.jsxs("form",{onSubmit:R.handleSubmit(g),className:"space-y-4",children:[e.jsx(y,{control:R.control,name:"name",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.name.label")}),e.jsx(D,{placeholder:i("form.name.placeholder"),...j}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"code",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.code.label")}),e.jsx(D,{placeholder:i("form.code.placeholder"),...j,className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.code.description")}),e.jsx(E,{})]})}),e.jsxs(b,{children:[e.jsx(N,{children:i("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(y,{control:R.control,name:"type",render:({field:j})=>e.jsxs(G,{value:j.value.toString(),onValueChange:C=>{const k=j.value,v=parseInt(C);j.onChange(v);const P=R.getValues("value");P&&(k===Fe.AMOUNT&&v===Fe.PERCENT?R.setValue("value",P/100):k===Fe.PERCENT&&v===Fe.AMOUNT&&R.setValue("value",P*100))},children:[e.jsx(U,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(W,{placeholder:i("form.type.placeholder")})}),e.jsx(B,{children:Object.entries(Ud).map(([C,k])=>e.jsx(L,{value:C,children:i(`table.toolbar.types.${C}`)},C))})]})}),e.jsx(y,{control:R.control,name:"value",render:({field:j})=>{const C=j.value===""?"":R.watch("type")===Fe.AMOUNT&&typeof j.value=="number"?(j.value/100).toString():j.value.toString();return e.jsx(D,{type:"number",placeholder:i("form.value.placeholder"),...j,value:C,onChange:k=>{const v=k.target.value;if(v===""){j.onChange("");return}const P=parseFloat(v);isNaN(P)||j.onChange(R.watch("type")===Fe.AMOUNT?Math.round(P*100):P)},step:"any",min:0,className:"flex-[2] rounded-none border-x-0 text-left"})}}),e.jsx("div",{className:"flex min-w-[40px] items-center justify-center rounded-md rounded-l-none border border-l-0 border-input bg-muted/50 px-3 font-medium text-muted-foreground",children:e.jsx("span",{children:R.watch("type")==Fe.AMOUNT?"¥":"%"})})]})]}),e.jsxs(b,{children:[e.jsx(N,{children:i("form.validity.label")}),e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",className:_("w-full justify-start text-left font-normal",!R.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(ct,{className:"mr-2 h-4 w-4"}),xe(R.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",i("form.validity.to")," ",xe(R.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(Xe,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(zs,{mode:"range",selected:{from:new Date(R.watch("started_at")*1e3),to:new Date(R.watch("ended_at")*1e3)},onSelect:f,numberOfMonths:2})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-4",children:[S("started_at",i("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:i("form.validity.to")}),S("ended_at",i("table.validity.endTime"))]})})]})]}),e.jsx(E,{})]}),e.jsx(y,{control:R.control,name:"limit_use",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.limitUse.placeholder"),...j,value:j.value===void 0?"":j.value,onChange:C=>j.onChange(C.target.value===""?"":C.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.limitUse.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"limit_use_with_user",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.limitUseWithUser.placeholder"),...j,value:j.value===void 0?"":j.value,onChange:C=>j.onChange(C.target.value===""?"":C.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.limitUseWithUser.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"limit_period",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitPeriod.label")}),e.jsx(ot,{options:Object.entries(fe).filter(([C])=>isNaN(Number(C))).map(([C,k])=>({label:i(`order:period.${k}`),value:C})),onChange:C=>{if(C.length===0){j.onChange([]);return}const k=C.map(v=>fe[v.value]);j.onChange(k)},value:(j.value||[]).map(C=>({label:i(`order:period.${C}`),value:Object.entries(fe).find(([k,v])=>v===C)?.[0]||""})),placeholder:i("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:i("form.limitPeriod.empty")})}),e.jsx(M,{className:"text-xs",children:i("form.limitPeriod.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"limit_plan_ids",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitPlan.label")}),e.jsx(ot,{options:p?.map(C=>({label:C.name,value:C.id.toString()}))||[],onChange:C=>j.onChange(C.map(k=>Number(k.value))),value:(p||[]).filter(C=>(j.value||[]).includes(C.id)).map(C=>({label:C.name,value:C.id.toString()})),placeholder:i("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:i("form.limitPlan.empty")})}),e.jsx(E,{})]})}),a==="create"&&e.jsx(e.Fragment,{children:e.jsx(y,{control:R.control,name:"generate_count",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.generateCount.placeholder"),...j,value:j.value===void 0?"":j.value,onChange:C=>j.onChange(C.target.value===""?"":C.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.generateCount.description")}),e.jsx(E,{})]})})}),e.jsx(Le,{children:e.jsx(V,{type:"submit",disabled:R.formState.isSubmitting,children:R.formState.isSubmitting?i("form.submit.saving"):i("form.submit.save")})})]})})]})]})}function Mx({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=I("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ur,{refetch:n,dialogTrigger:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:l("form.add")})]})}),e.jsx(D,{placeholder:l("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(Ix,{column:s.getColumn("type"),title:l("table.toolbar.type"),options:[{value:Fe.AMOUNT,label:l(`table.toolbar.types.${Fe.AMOUNT}`)},{value:Fe.PERCENTAGE,label:l(`table.toolbar.types.${Fe.PERCENTAGE}`)}]}),a&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("table.toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})}const Br=m.createContext(void 0);function Ox({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),i=x=>{c(x),l(!0)},u=()=>{l(!1),c(null)};return e.jsxs(Br.Provider,{value:{isOpen:a,currentCoupon:r,openEdit:i,closeEdit:u},children:[s,r&&e.jsx(Ur,{defaultValues:r,refetch:n,type:"edit",open:a,onOpenChange:l})]})}function zx(){const s=m.useContext(Br);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Lx=s=>{const{t:n}=I("coupon");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(K,{children:a.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.original.show,onCheckedChange:l=>{wd({id:a.original.id,show:l}).then(({data:r})=>!r&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:a.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.type")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:n(`table.toolbar.types.${a.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.code")}),cell:({row:a})=>e.jsx(K,{variant:"secondary",children:a.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.limitUse")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:a.original.limit_use===null?n("table.validity.unlimited"):a.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.limitUseWithUser")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:a.original.limit_use_with_user===null?n("table.validity.noLimit"):a.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.validity")}),cell:({row:a})=>{const[l,r]=m.useState(!1),c=Date.now(),i=a.original.started_at*1e3,u=a.original.ended_at*1e3,x=c>u,o=ce.jsx(O,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>{const{openEdit:l}=zx();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>l(a.original),children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(Ue,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{_d({id:a.original.id}).then(({data:r})=>{r&&(q.success("删除成功"),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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")})]})})]})}}]};function Ax(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[i,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:d,data:p}=se({queryKey:["couponList",x,r,i],queryFn:()=>yd({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),T=Ke({data:p?.data??[],columns:Lx(d),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:x},pageCount:Math.ceil((p?.total??0)/x.pageSize),rowCount:p?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onPaginationChange:o,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ox,{refetch:d,children:e.jsx("div",{className:"space-y-4",children:e.jsx(es,{table:T,toolbar:e.jsx(Mx,{table:T,refetch:d})})})})}function $x(){const{t:s}=I("coupon");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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:"text-muted-foreground mt-2",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(Ax,{})})]})]})}const qx=Object.freeze(Object.defineProperty({__proto__:null,default:$x},Symbol.toStringTag,{value:"Module"})),Kx=h.object({email_prefix:h.string().optional(),email_suffix:h.string().min(1),password:h.string().optional(),expired_at:h.number().optional().nullable(),plan_id:h.number().nullable(),generate_count:h.number().optional().nullable()}).refine(s=>s.generate_count===null?s.email_prefix!==void 0&&s.email_prefix!=="":!0,{message:"Email prefix is required when generate_count is null",path:["email_prefix"]}),Hx={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function Ux({refetch:s}){const{t:n}=I("user"),[a,l]=m.useState(!1),r=de({resolver:me(Kx),defaultValues:Hx,mode:"onChange"}),[c,i]=m.useState([]);return m.useEffect(()=>{a&&Os().then(({data:u})=>{u&&i(u)})},[a]),e.jsxs(pe,{open:a,onOpenChange:l,children:[e.jsx(ze,{asChild:!0,children:e.jsxs(J,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(be,{children:[e.jsx(ge,{children:n("generate.title")}),e.jsx(Te,{})]}),e.jsxs(ue,{...r,children:[e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!r.watch("generate_count")&&e.jsx(y,{control:r.control,name:"email_prefix",render:({field:u})=>e.jsx(D,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...u})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${r.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(y,{control:r.control,name:"email_suffix",render:({field:u})=>e.jsx(D,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...u})})]})]}),e.jsx(y,{control:r.control,name:"password",render:({field:u})=>e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...u}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"expired_at",render:({field:u})=>e.jsxs(b,{className:"flex flex-col",children:[e.jsx(N,{children:n("generate.form.expire_time")}),e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsx(w,{children:e.jsxs(J,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!u.value&&"text-muted-foreground"),children:[u.value?xe(u.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(ct,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(Xe,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Ri,{asChild:!0,children:e.jsx(J,{variant:"outline",className:"w-full",onClick:()=>{u.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(zs,{mode:"single",selected:u.value?new Date(u.value*1e3):void 0,onSelect:x=>{x&&u.onChange(x?.getTime()/1e3)}})})]})]})]})}),e.jsx(y,{control:r.control,name:"plan_id",render:({field:u})=>e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.subscription")}),e.jsx(w,{children:e.jsxs(G,{value:u.value?u.value.toString():"null",onValueChange:x=>u.onChange(x==="null"?null:parseInt(x)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(L,{value:"null",children:n("generate.form.subscription_none")}),c.map(x=>e.jsx(L,{value:x.id.toString(),children:x.name},x.id))]})]})})]})}),!r.watch("email_prefix")&&e.jsx(y,{control:r.control,name:"generate_count",render:({field:u})=>e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.generate_count")}),e.jsx(D,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:u.value||"",onChange:x=>u.onChange(x.target.value?parseInt(x.target.value):null)})]})})]}),e.jsxs(Le,{children:[e.jsx(J,{variant:"outline",onClick:()=>l(!1),children:n("generate.form.cancel")}),e.jsx(J,{onClick:()=>r.handleSubmit(u=>{Pd(u).then(({data:x})=>{x&&(q.success(n("generate.form.success")),r.reset(),s(),l(!1))})})(),children:n("generate.form.submit")})]})]})]})}const Gr=Za,Wr=Xa,Bx=en,Yr=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{className:_("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}));Yr.displayName=Pt.displayName;const Gx=Es("fixed overflow-y-scroll z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-md",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-md"}},defaultVariants:{side:"right"}}),ya=m.forwardRef(({side:s="right",className:n,children:a,...l},r)=>e.jsxs(Bx,{children:[e.jsx(Yr,{}),e.jsxs(Tt,{ref:r,className:_(Gx({side:s}),n),...l,children:[e.jsxs(la,{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-secondary",children:[e.jsx(Ae,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),a]})]}));ya.displayName=Tt.displayName;const Na=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});Na.displayName="SheetHeader";const Jr=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Jr.displayName="SheetFooter";const _a=m.forwardRef(({className:s,...n},a)=>e.jsx(Dt,{ref:a,className:_("text-lg font-semibold text-foreground",s),...n}));_a.displayName=Dt.displayName;const wa=m.forwardRef(({className:s,...n},a)=>e.jsx(Et,{ref:a,className:_("text-sm text-muted-foreground",s),...n}));wa.displayName=Et.displayName;function Wx({table:s,refetch:n,permissionGroups:a=[],subscriptionPlans:l=[]}){const{t:r}=I("user"),c=s.getState().columnFilters.length>0,[i,u]=m.useState([]),[x,o]=m.useState(!1),d=[{label:r("filter.fields.email"),value:"email",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.id"),value:"id",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:r("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:r("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"},{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"}]},{label:r("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.token"),value:"token",type:"text",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.banned"),value:"banned",type:"select",operators:[{label:r("filter.operators.eq"),value:"eq"}],options:[{label:r("filter.status.normal"),value:"0"},{label:r("filter.status.banned"),value:"1"}]},{label:r("filter.fields.remark"),value:"remark",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.inviter_email"),value:"inviter_email",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:r("filter.operators.eq"),value:"eq"}]}],p=C=>C*1024*1024*1024,T=C=>C/(1024*1024*1024),R=()=>{u([...i,{field:"",operator:"",value:""}])},f=C=>{u(i.filter((k,v)=>v!==C))},g=(C,k,v)=>{const P=[...i];if(P[C]={...P[C],[k]:v},k==="field"){const z=d.find(Q=>Q.value===v);z&&(P[C].operator=z.operators[0].value,P[C].value=z.type==="boolean"?!1:"")}u(P)},S=(C,k)=>{const v=d.find(P=>P.value===C.field);if(!v)return null;switch(v.type){case"text":return e.jsx(D,{placeholder:r("filter.sheet.value"),value:C.value,onChange:P=>g(k,"value",P.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(D,{type:"number",placeholder:r("filter.sheet.value_number",{unit:v.unit}),value:v.unit==="GB"?T(C.value||0):C.value,onChange:P=>{const z=Number(P.target.value);g(k,"value",v.unit==="GB"?p(z):z)}}),v.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:v.unit})]});case"date":return e.jsx(zs,{mode:"single",selected:C.value,onSelect:P=>g(k,"value",P),className:"rounded-md border"});case"select":return e.jsxs(G,{value:C.value,onValueChange:P=>g(k,"value",P),children:[e.jsx(U,{children:e.jsx(W,{placeholder:r("filter.sheet.value")})}),e.jsx(B,{children:v.useOptions?l.map(P=>e.jsx(L,{value:P.value.toString(),children:P.label},P.value)):v.options?.map(P=>e.jsx(L,{value:P.value.toString(),children:P.label},P.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(H,{checked:C.value,onCheckedChange:P=>g(k,"value",P)}),e.jsx(Ct,{children:C.value?r("filter.boolean.true"):r("filter.boolean.false")})]});default:return null}},j=()=>{const C=i.filter(k=>k.field&&k.operator&&k.value!=="").map(k=>{const v=d.find(z=>z.value===k.field);let P=k.value;return k.operator==="contains"?{id:k.field,value:P}:(v?.type==="date"&&P instanceof Date&&(P=Math.floor(P.getTime()/1e3)),v?.type==="boolean"&&(P=P?1:0),{id:k.field,value:`${k.operator}:${P}`})});s.setColumnFilters(C),o(!1)};return e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2",children:e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsx(Ux,{refetch:n}),e.jsx(D,{placeholder:r("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:C=>s.getColumn("email")?.setFilterValue(C.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Gr,{open:x,onOpenChange:o,children:[e.jsx(Wr,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Vi,{className:"mr-2 h-4 w-4"}),r("filter.advanced"),i.length>0&&e.jsx(K,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:i.length})]})}),e.jsxs(ya,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(Na,{children:[e.jsx(_a,{children:r("filter.sheet.title")}),e.jsx(wa,{children:r("filter.sheet.description")})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:r("filter.sheet.conditions")}),e.jsx(V,{variant:"outline",size:"sm",onClick:R,children:r("filter.sheet.add")})]}),e.jsx(lt,{className:"h-[calc(100vh-280px)] pr-4",children:e.jsx("div",{className:"space-y-4",children:i.map((C,k)=>e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ct,{children:r("filter.sheet.condition",{number:k+1})}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>f(k),children:e.jsx(Ae,{className:"h-4 w-4"})})]}),e.jsxs(G,{value:C.field,onValueChange:v=>g(k,"field",v),children:[e.jsx(U,{children:e.jsx(W,{placeholder:r("filter.sheet.field")})}),e.jsx(B,{children:d.map(v=>e.jsx(L,{value:v.value,children:v.label},v.value))})]}),C.field&&e.jsxs(G,{value:C.operator,onValueChange:v=>g(k,"operator",v),children:[e.jsx(U,{children:e.jsx(W,{placeholder:r("filter.sheet.operator")})}),e.jsx(B,{children:d.find(v=>v.value===C.field)?.operators.map(v=>e.jsx(L,{value:v.value,children:v.label},v.value))})]}),C.field&&C.operator&&S(C,k)]},k))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(V,{variant:"outline",onClick:()=>{u([]),o(!1)},children:r("filter.sheet.reset")}),e.jsx(V,{onClick:j,children:r("filter.sheet.apply")})]})]})]})]}),c&&e.jsxs(V,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[r("filter.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})})}const Yx=h.object({id:h.number(),email:h.string().email(),invite_user_email:h.string().email().nullable().optional(),password:h.string().optional().nullable(),balance:h.coerce.number(),commission_balance:h.coerce.number(),u:h.number(),d:h.number(),transfer_enable:h.number(),expired_at:h.number().nullable(),plan_id:h.number().nullable(),banned:h.number(),commission_type:h.number(),commission_rate:h.number().nullable(),discount:h.number().nullable(),speed_limit:h.number().nullable(),device_limit:h.number().nullable(),is_admin:h.number(),is_staff:h.number(),remarks:h.string().nullable()}),Qr=m.createContext(void 0);function Jx({children:s,defaultValues:n,open:a,onOpenChange:l}){const[r,c]=m.useState(!1),[i,u]=m.useState(!1),[x,o]=m.useState([]),d=de({resolver:me(Yx),defaultValues:n,mode:"onChange"});m.useEffect(()=>{a!==void 0&&c(a)},[a]);const p=T=>{c(T),l?.(T)};return e.jsx(Qr.Provider,{value:{form:d,formOpen:r,setFormOpen:p,datePickerOpen:i,setDatePickerOpen:u,planList:x,setPlanList:o},children:s})}function Qx(){const s=m.useContext(Qr);if(!s)throw new Error("useUserForm must be used within a UserFormProvider");return s}function Zx({refetch:s}){const{t:n}=I("user"),{form:a,formOpen:l,setFormOpen:r,datePickerOpen:c,setDatePickerOpen:i,planList:u,setPlanList:x}=Qx();return m.useEffect(()=>{l&&Os().then(({data:o})=>{x(o)})},[l,x]),e.jsxs(ue,{...a,children:[e.jsx(y,{control:a.control,name:"email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.email")}),e.jsx(w,{children:e.jsx(D,{...o,placeholder:n("edit.form.email_placeholder")})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"invite_user_email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.inviter_email")}),e.jsx(w,{children:e.jsx(D,{value:o.value||"",onChange:d=>o.onChange(d.target.value?d.target.value:null),placeholder:n("edit.form.inviter_email_placeholder")})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"password",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.password")}),e.jsx(w,{children:e.jsx(D,{value:o.value||"",onChange:o.onChange,placeholder:n("edit.form.password_placeholder")})}),e.jsx(E,{...o})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(y,{control:a.control,name:"balance",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.balance")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:n("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"commission_balance",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.commission_balance")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:n("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"u",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.upload")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{value:o.value/1024/1024/1024||"",onChange:d=>o.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"d",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.download")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value/1024/1024/1024||"",onChange:d=>o.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{...o})]})})]}),e.jsx(y,{control:a.control,name:"transfer_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.total_traffic")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value/1024/1024/1024||"",onChange:d=>o.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"expired_at",render:({field:o})=>e.jsxs(b,{className:"flex flex-col",children:[e.jsx(N,{children:n("edit.form.expire_time")}),e.jsxs(rs,{open:c,onOpenChange:i,children:[e.jsx(ls,{asChild:!0,children:e.jsx(w,{children:e.jsxs(V,{type:"button",variant:"outline",className:_("w-full pl-3 text-left font-normal",!o.value&&"text-muted-foreground"),onClick:()=>i(!0),children:[o.value?xe(o.value):e.jsx("span",{children:n("edit.form.expire_time_placeholder")}),e.jsx(ct,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:d=>{d.preventDefault()},onEscapeKeyDown:d=>{d.preventDefault()},children:e.jsxs("div",{className:"flex flex-col space-y-3 p-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{o.onChange(null),i(!1)},children:n("edit.form.expire_time_permanent")}),e.jsx(V,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;d.setMonth(d.getMonth()+1),d.setHours(23,59,59,999),o.onChange(Math.floor(d.getTime()/1e3)),i(!1)},children:n("edit.form.expire_time_1month")}),e.jsx(V,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;d.setMonth(d.getMonth()+3),d.setHours(23,59,59,999),o.onChange(Math.floor(d.getTime()/1e3)),i(!1)},children:n("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(zs,{mode:"single",selected:o.value?new Date(o.value*1e3):void 0,onSelect:d=>{if(d){const p=new Date(o.value?o.value*1e3:Date.now());d.setHours(p.getHours(),p.getMinutes(),p.getSeconds()),o.onChange(Math.floor(d.getTime()/1e3))}},disabled:d=>d{const d=new Date;d.setHours(23,59,59,999),o.onChange(Math.floor(d.getTime()/1e3))},className:"h-6 px-2 text-xs",children:n("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"datetime-local",step:"1",value:xe(o.value,"YYYY-MM-DDTHH:mm:ss"),onChange:d=>{const p=new Date(d.target.value);isNaN(p.getTime())||o.onChange(Math.floor(p.getTime()/1e3))},className:"flex-1"}),e.jsx(V,{type:"button",variant:"outline",onClick:()=>i(!1),children:n("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"plan_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.subscription")}),e.jsx(w,{children:e.jsxs(G,{value:o.value?o.value.toString():"null",onValueChange:d=>o.onChange(d==="null"?null:parseInt(d)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(L,{value:"null",children:n("edit.form.subscription_none")}),u.map(d=>e.jsx(L,{value:d.id.toString(),children:d.name},d.id))]})]})})]})}),e.jsx(y,{control:a.control,name:"banned",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.account_status")}),e.jsx(w,{children:e.jsxs(G,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(W,{})}),e.jsxs(B,{children:[e.jsx(L,{value:"1",children:n("columns.status_text.banned")}),e.jsx(L,{value:"0",children:n("columns.status_text.normal")})]})]})})]})}),e.jsx(y,{control:a.control,name:"commission_type",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.commission_type")}),e.jsx(w,{children:e.jsxs(G,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(W,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:n("edit.form.commission_type_system")}),e.jsx(L,{value:"1",children:n("edit.form.commission_type_cycle")}),e.jsx(L,{value:"2",children:n("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(y,{control:a.control,name:"commission_rate",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.commission_rate")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(y,{control:a.control,name:"discount",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.discount")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"speed_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.speed_limit")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"device_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.device_limit")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"is_admin",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(y,{control:a.control,name:"is_staff",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(y,{control:a.control,name:"remarks",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.remarks")}),e.jsx(w,{children:e.jsx(ps,{className:"h-24",value:o.value||"",onChange:d=>o.onChange(d.currentTarget.value??null),placeholder:n("edit.form.remarks_placeholder")})}),e.jsx(E,{})]})}),e.jsxs(Jr,{children:[e.jsx(V,{variant:"outline",onClick:()=>r(!1),children:n("edit.form.cancel")}),e.jsx(V,{type:"submit",onClick:()=>{a.handleSubmit(o=>{Sd(o).then(({data:d})=>{d&&(q.success(n("edit.form.success")),r(!1),s())})})()},children:n("edit.form.submit")})]})]})}function Zr({refetch:s,defaultValues:n,dialogTrigger:a=e.jsxs(V,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),t("edit.button")]})}){const{t:l}=I("user"),[r,c]=m.useState(!1);return e.jsx(Jx,{defaultValues:n,open:r,onOpenChange:c,children:e.jsxs(Gr,{open:r,onOpenChange:c,children:[e.jsx(Wr,{asChild:!0,children:a}),e.jsxs(ya,{className:"max-w-[90%] space-y-4",children:[e.jsxs(Na,{children:[e.jsx(_a,{children:l("edit.title")}),e.jsx(wa,{})]}),e.jsx(Zx,{refetch:s})]})]})})}const Xr=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:"m17.71 11.29l-5-5a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21l-5 5a1 1 0 0 0 1.42 1.42L11 9.41V17a1 1 0 0 0 2 0V9.41l3.29 3.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42"})}),el=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:"M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42"})}),Xx=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:"M17 11H9.41l3.3-3.29a1 1 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l5 5a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L9.41 13H17a1 1 0 0 0 0-2"})}),eh=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:"M17.92 11.62a1 1 0 0 0-.21-.33l-5-5a1 1 0 0 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l5-5a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76"})}),Gt=[{accessorKey:"record_at",header:"时间",cell:({row:s})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("time",{className:"text-sm text-muted-foreground",children:mc(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Xr,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:ss(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(el,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:ss(s.original.d)})]})},{accessorKey:"server_rate",header:"倍率",cell:({row:s})=>{const n=s.original.server_rate;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(K,{variant:"outline",className:"font-mono",children:[n,"x"]})})}},{id:"total",header:"总计",cell:({row:s})=>{const n=s.original.u+s.original.d;return e.jsx("div",{className:"flex items-center justify-end font-mono text-sm",children:ss(n)})}}];function sl({user_id:s,dialogTrigger:n}){const{t:a}=I(["traffic"]),[l,r]=m.useState(!1),[c,i]=m.useState({pageIndex:0,pageSize:20}),{data:u,isLoading:x}=se({queryKey:["userStats",s,c,l],queryFn:()=>l?Td({user_id:s,pageSize:c.pageSize,page:c.pageIndex+1}):null}),o=Ke({data:u?.data??[],columns:Gt,pageCount:Math.ceil((u?.total??0)/c.pageSize),state:{pagination:c},manualPagination:!0,getCoreRowModel:He(),onPaginationChange:i});return e.jsxs(pe,{open:l,onOpenChange:r,children:[e.jsx(ze,{asChild:!0,children:n}),e.jsxs(he,{className:"sm:max-w-[700px]",children:[e.jsx(be,{children:e.jsx(ge,{children:a("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(fa,{children:[e.jsx(pa,{children:o.getHeaderGroups().map(d=>e.jsx(ys,{children:d.headers.map(p=>e.jsx(ja,{className:_("h-10 px-2 text-xs",p.id==="total"&&"text-right"),children:p.isPlaceholder?null:Nt(p.column.columnDef.header,p.getContext())},p.id))},d.id))}),e.jsx(ga,{children:x?Array.from({length:c.pageSize}).map((d,p)=>e.jsx(ys,{children:Array.from({length:Gt.length}).map((T,R)=>e.jsx(Ks,{className:"p-2",children:e.jsx(le,{className:"h-6 w-full"})},R))},p)):o.getRowModel().rows?.length?o.getRowModel().rows.map(d=>e.jsx(ys,{"data-state":d.getIsSelected()&&"selected",className:"h-10",children:d.getVisibleCells().map(p=>e.jsx(Ks,{className:"px-2",children:Nt(p.column.columnDef.cell,p.getContext())},p.id))},d.id)):e.jsx(ys,{children:e.jsx(Ks,{colSpan:Gt.length,className:"h-24 text-center",children:a("trafficRecord.noRecords")})})})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("trafficRecord.perPage")}),e.jsxs(G,{value:`${o.getState().pagination.pageSize}`,onValueChange:d=>{o.setPageSize(Number(d))},children:[e.jsx(U,{className:"h-8 w-[70px]",children:e.jsx(W,{placeholder:o.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50].map(d=>e.jsx(L,{value:`${d}`,children:d},d))})]}),e.jsx("p",{className:"text-sm font-medium",children:a("trafficRecord.records")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex w-[100px] items-center justify-center text-sm",children:a("trafficRecord.page",{current:o.getState().pagination.pageIndex+1,total:o.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||x,children:e.jsx(Xx,{className:"h-4 w-4"})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||x,children:e.jsx(eh,{className:"h-4 w-4"})})]})]})]})]})]})]})}const sh=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:"M5 18h4.24a1 1 0 0 0 .71-.29l6.92-6.93L19.71 8a1 1 0 0 0 0-1.42l-4.24-4.29a1 1 0 0 0-1.42 0l-2.82 2.83l-6.94 6.93a1 1 0 0 0-.29.71V17a1 1 0 0 0 1 1m9.76-13.59l2.83 2.83l-1.42 1.42l-2.83-2.83ZM6 13.17l5.93-5.93l2.83 2.83L8.83 16H6ZM21 20H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2"})}),th=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:"M19 11h-6V5a1 1 0 0 0-2 0v6H5a1 1 0 0 0 0 2h6v6a1 1 0 0 0 2 0v-6h6a1 1 0 0 0 0-2"})}),ah=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:"M21 8.94a1.3 1.3 0 0 0-.06-.27v-.09a1 1 0 0 0-.19-.28l-6-6a1 1 0 0 0-.28-.19a.3.3 0 0 0-.09 0a.9.9 0 0 0-.33-.11H10a3 3 0 0 0-3 3v1H6a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-1h1a3 3 0 0 0 3-3zm-6-3.53L17.59 8H16a1 1 0 0 1-1-1ZM15 19a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h1v7a3 3 0 0 0 3 3h5Zm4-4a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3v3a3 3 0 0 0 3 3h3Z"})}),nh=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:"M21 11a1 1 0 0 0-1 1a8.05 8.05 0 1 1-2.22-5.5h-2.4a1 1 0 0 0 0 2h4.53a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v1.77A10 10 0 1 0 22 12a1 1 0 0 0-1-1"})}),rh=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:"M9.5 10.5H12a1 1 0 0 0 0-2h-1V8a1 1 0 0 0-2 0v.55a2.5 2.5 0 0 0 .5 4.95h1a.5.5 0 0 1 0 1H8a1 1 0 0 0 0 2h1v.5a1 1 0 0 0 2 0v-.55a2.5 2.5 0 0 0-.5-4.95h-1a.5.5 0 0 1 0-1M21 12h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Z"})}),lh=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:"M12.3 12.22A4.92 4.92 0 0 0 14 8.5a5 5 0 0 0-10 0a4.92 4.92 0 0 0 1.7 3.72A8 8 0 0 0 1 19.5a1 1 0 0 0 2 0a6 6 0 0 1 12 0a1 1 0 0 0 2 0a8 8 0 0 0-4.7-7.28M9 11.5a3 3 0 1 1 3-3a3 3 0 0 1-3 3m9.74.32A5 5 0 0 0 15 3.5a1 1 0 0 0 0 2a3 3 0 0 1 3 3a3 3 0 0 1-1.5 2.59a1 1 0 0 0-.5.84a1 1 0 0 0 .45.86l.39.26l.13.07a7 7 0 0 1 4 6.38a1 1 0 0 0 2 0a9 9 0 0 0-4.23-7.68"})}),oh=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:"M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2m0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1"})}),ih=(s,n)=>{const{t:a}=I("user");return[{accessorKey:"is_admin",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r)),size:0},{accessorKey:"is_staff",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r)),size:0},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(K,{variant:"outline",children:l.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.email")}),cell:({row:l})=>{const r=l.original.t||0,c=Date.now()/1e3-r<120,i=Math.floor(Date.now()/1e3-r);let u=c?a("columns.online_status.online"):r===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:xe(r)});if(!c&&r!==0){const x=Math.floor(i/60),o=Math.floor(x/60),d=Math.floor(o/24);d>0?u+=` +`))}})})}),e.jsx(E,{})]})}),e.jsx(y,{control:c.control,name:"action",render:({field:x})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsxs(G,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("form.actionPlaceholder")})}),e.jsxs(B,{children:[e.jsx(L,{value:"block",children:r("actions.block")}),e.jsx(L,{value:"dns",children:r("actions.dns")})]})]})})}),e.jsx(E,{})]})}),c.watch("action")==="dns"&&e.jsx(y,{control:c.control,name:"action_value",render:({field:x})=>e.jsxs(b,{children:[e.jsx(N,{children:r("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(w,{children:e.jsx(D,{type:"text",placeholder:r("form.dnsPlaceholder"),...x})})})]})}),e.jsxs(Le,{children:[e.jsx(ut,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r("form.cancel")})}),e.jsx(V,{type:"submit",onClick:()=>{Jc(c.getValues()).then(({data:x})=>{x&&(u(!1),s&&s(),toast.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),c.reset())})},children:r("form.submit")})]})]})]})]})}function ox({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=I("route");return e.jsx("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:[e.jsx(qr,{refetch:n}),e.jsx(D,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:r=>s.getColumn("remarks")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),a&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})})}function ix({columns:s,data:n,refetch:a}){const[l,r]=m.useState({}),[c,i]=m.useState({}),[u,x]=m.useState([]),[o,d]=m.useState([]),p=Ke({data:n,columns:s,state:{sorting:o,columnVisibility:c,rowSelection:l,columnFilters:u},enableRowSelection:!0,onRowSelectionChange:r,onSortingChange:d,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:p,toolbar:P=>e.jsx(ox,{table:P,refetch:a})})}const cx=s=>{const{t:n}=I("route"),a={block:{icon:ki,variant:"destructive",className:"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-800"},dns:{icon:Ti,variant:"secondary",className:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-400 hover:bg-blue-200 dark:hover:bg-blue-800"}};return[{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.id")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(K,{variant:"outline",children:l.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.remarks")}),cell:({row:l})=>{const r=l.original.match?.length||0;return e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:n("columns.matchRules",{count:r})})})},enableHiding:!1,enableSorting:!1},{accessorKey:"action",header:({column:l})=>e.jsx(O,{column:l,title:n("columns.action")}),cell:({row:l})=>{const r=l.getValue("action"),c=a[r]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(K,{variant:a[r]?.variant||"default",className:_("flex items-center gap-1.5 px-3 py-1 capitalize",a[r]?.className),children:[c&&e.jsx(c,{className:"h-3.5 w-3.5"}),n(`actions.${r}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:l})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(qr,{defaultValues:l.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(Ue,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Qc({id:l.original.id}).then(({data:r})=>{r&&(q.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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 dx(){const{t:s}=I("route"),[n,a]=m.useState([]);function l(){Nr().then(({data:r})=>{a(r)})}return m.useEffect(()=>{l()},[]),e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(ix,{data:n,columns:cx(l),refetch:l})})]})]})}const mx=Object.freeze(Object.defineProperty({__proto__:null,default:dx},Symbol.toStringTag,{value:"Module"})),Kr=m.createContext(void 0);function ux({children:s,refreshData:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null);return e.jsx(Kr.Provider,{value:{isOpen:a,setIsOpen:l,editingPlan:r,setEditingPlan:c,refreshData:n},children:s})}function ya(){const s=m.useContext(Kr);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function xx({table:s,saveOrder:n,isSortMode:a}){const{setIsOpen:l}=ya(),{t:r}=I("subscribe");return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsxs(V,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>l(!0),children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:r("plan.add")})]}),e.jsx(D,{placeholder:r("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:c=>s.getColumn("name")?.setFilterValue(c.target.value),className:"h-8 w-[150px] lg:w-[250px]"})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(V,{variant:a?"default":"outline",onClick:n,size:"sm",children:r(a?"plan.sort.save":"plan.sort.edit")})})]})}const Wa={monthly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},quarterly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},half_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},two_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},three_yearly:{color:"text-slate-700",bgColor:"bg-slate-100/80"},onetime:{color:"text-slate-700",bgColor:"bg-slate-100/80"},reset_traffic:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},hx=s=>{const{t:n}=I("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Vt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.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,enableHiding:!1},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.show")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("show"),onCheckedChange:l=>{Kt({id:a.original.id,show:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.sell")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("sell"),onCheckedChange:l=>{Kt({id:a.original.id,sell:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.getValue("renew"),onCheckedChange:l=>{Kt({id:a.original.id,renew:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.stats")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-2",children:[e.jsx(ct,{}),e.jsx("span",{className:"max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]",children:a.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"group",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.group")}),cell:({row:a})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(K,{variant:"secondary",className:_("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:a.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:a})=>e.jsx(O,{column:a,title:n("plan.columns.price")}),cell:({row:a})=>{const l=a.getValue("prices"),r=[{period:n("plan.columns.price_period.monthly"),key:"monthly",unit:n("plan.columns.price_period.unit.month")},{period:n("plan.columns.price_period.quarterly"),key:"quarterly",unit:n("plan.columns.price_period.unit.quarter")},{period:n("plan.columns.price_period.half_yearly"),key:"half_yearly",unit:n("plan.columns.price_period.unit.half_year")},{period:n("plan.columns.price_period.yearly"),key:"yearly",unit:n("plan.columns.price_period.unit.year")},{period:n("plan.columns.price_period.two_yearly"),key:"two_yearly",unit:n("plan.columns.price_period.unit.two_year")},{period:n("plan.columns.price_period.three_yearly"),key:"three_yearly",unit:n("plan.columns.price_period.unit.three_year")},{period:n("plan.columns.price_period.onetime"),key:"onetime",unit:""},{period:n("plan.columns.price_period.reset_traffic"),key:"reset_traffic",unit:n("plan.columns.price_period.unit.times")}];return e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:r.map(({period:c,key:i,unit:u})=>l[i]!=null&&e.jsxs(K,{variant:"secondary",className:_("px-2 py-0.5 font-medium transition-colors text-nowrap",Wa[i].color,Wa[i].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[c," ¥",l[i],u]},i))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("plan.columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingPlan:r}=ya();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{r(a.original),l(!0)},children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(Ue,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{fd({id:a.original.id}).then(({data:c})=>{c&&(q.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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("plan.columns.delete")})]})})]})}}]},fx=h.object({id:h.number().nullable(),group_id:h.union([h.number(),h.string()]).nullable().optional(),name:h.string().min(1).max(250),content:h.string().nullable().optional(),transfer_enable:h.union([h.number().min(0),h.string().min(1)]),prices:h.object({monthly:h.union([h.number(),h.string()]).nullable().optional(),quarterly:h.union([h.number(),h.string()]).nullable().optional(),half_yearly:h.union([h.number(),h.string()]).nullable().optional(),yearly:h.union([h.number(),h.string()]).nullable().optional(),two_yearly:h.union([h.number(),h.string()]).nullable().optional(),three_yearly:h.union([h.number(),h.string()]).nullable().optional(),onetime:h.union([h.number(),h.string()]).nullable().optional(),reset_traffic:h.union([h.number(),h.string()]).nullable().optional()}).default({}),speed_limit:h.union([h.number(),h.string()]).nullable().optional(),capacity_limit:h.union([h.number(),h.string()]).nullable().optional(),device_limit:h.union([h.number(),h.string()]).nullable().optional(),force_update:h.boolean().optional(),reset_traffic_method:h.number().nullable(),users_count:h.number().optional()}),Hr=m.forwardRef(({className:s,...n},a)=>e.jsx(Yn,{ref:a,className:_("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...n,children:e.jsx(Pi,{className:_("flex items-center justify-center text-current"),children:e.jsx(Rs,{className:"h-4 w-4"})})}));Hr.displayName=Yn.displayName;const jt={id:null,group_id:null,name:"",content:"",transfer_enable:"",prices:{monthly:"",quarterly:"",half_yearly:"",yearly:"",two_yearly:"",three_yearly:"",onetime:"",reset_traffic:""},speed_limit:"",capacity_limit:"",device_limit:"",force_update:!1,reset_traffic_method:null},vt={monthly:{label:"月付",months:1,discount:1},quarterly:{label:"季付",months:3,discount:.95},half_yearly:{label:"半年付",months:6,discount:.9},yearly:{label:"年付",months:12,discount:.85},two_yearly:{label:"两年付",months:24,discount:.8},three_yearly:{label:"三年付",months:36,discount:.75},onetime:{label:"流量包",months:1,discount:1},reset_traffic:{label:"重置包",months:1,discount:1}},px=[{value:null,label:"follow_system"},{value:0,label:"monthly_first"},{value:1,label:"monthly_reset"},{value:2,label:"no_reset"},{value:3,label:"yearly_first"},{value:4,label:"yearly_reset"}];function gx(){const{isOpen:s,setIsOpen:n,editingPlan:a,setEditingPlan:l,refreshData:r}=ya(),[c,i]=m.useState(!1),{t:u}=I("subscribe"),x=de({resolver:me(fx),defaultValues:{...jt,...a||{}},mode:"onChange"});m.useEffect(()=>{a?x.reset({...jt,...a}):x.reset(jt)},[a,x]);const o=new ua({html:!0}),[d,p]=m.useState();async function P(){Ot().then(({data:g})=>{p(g)})}m.useEffect(()=>{s&&P()},[s]);const R=g=>{if(isNaN(g))return;const S=Object.entries(vt).reduce((j,[C,k])=>{const v=g*k.months*k.discount;return{...j,[C]:v.toFixed(2)}},{});x.setValue("prices",S,{shouldDirty:!0})},f=()=>{n(!1),l(null),x.reset(jt)};return e.jsx(fe,{open:s,onOpenChange:f,children:e.jsxs(he,{children:[e.jsxs(ve,{children:[e.jsx(pe,{children:u(a?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Pe,{})]}),e.jsxs(ue,{...x,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{control:x.control,name:"name",render:({field:g})=>e.jsxs(b,{children:[e.jsx(N,{children:u("plan.form.name.label")}),e.jsx(w,{children:e.jsx(D,{placeholder:u("plan.form.name.placeholder"),...g})}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"group_id",render:({field:g})=>e.jsxs(b,{children:[e.jsxs(N,{className:"flex items-center justify-between",children:[u("plan.form.group.label"),e.jsx(Lt,{dialogTrigger:e.jsx(V,{variant:"link",children:u("plan.form.group.add")}),refetch:P})]}),e.jsxs(G,{value:g.value?.toString()??"",onValueChange:S=>g.onChange(S?Number(S):null),children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:u("plan.form.group.placeholder")})})}),e.jsx(B,{children:d?.map(S=>e.jsx(L,{value:S.id.toString(),children:S.name},S.id))})]}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"transfer_enable",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.transfer.placeholder"),className:"rounded-r-none",...g})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.transfer.unit")})]}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"speed_limit",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.speed.placeholder"),className:"rounded-r-none",...g,value:g.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.speed.unit")})]}),e.jsx(E,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex flex-1 items-center",children:[e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"}),e.jsx("h3",{className:"mx-4 text-sm font-medium text-gray-500 dark:text-gray-400",children:u("plan.form.price.title")}),e.jsx("div",{className:"flex-grow border-t border-gray-200 dark:border-gray-700"})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(D,{type:"number",placeholder:u("plan.form.price.base_price"),className:"h-7 w-32 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500",onChange:g=>{const S=parseFloat(g.target.value);R(S)}})]}),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const g=Object.keys(vt).reduce((S,j)=>({...S,[j]:""}),{});x.setValue("prices",g,{shouldDirty:!0})},children:u("plan.form.price.clear.button")})}),e.jsx(te,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:u("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(vt).filter(([g])=>!["onetime","reset_traffic"].includes(g)).map(([g,S])=>e.jsx("div",{className:"group relative rounded-md bg-card p-2 ring-1 ring-gray-200 transition-all hover:ring-primary dark:ring-gray-800",children:e.jsx(y,{control:x.control,name:`prices.${g}`,render:({field:j})=>e.jsxs(b,{children:[e.jsxs(N,{className:"text-xs font-medium text-muted-foreground",children:[u(`plan.columns.price_period.${g}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",S.months===1?u("plan.form.price.period.monthly"):u("plan.form.price.period.months",{count:S.months}),")"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...j,value:j.value??"",onChange:C=>j.onChange(C.target.value),className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})},g))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(vt).filter(([g])=>["onetime","reset_traffic"].includes(g)).map(([g,S])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(y,{control:x.control,name:`prices.${g}`,render:({field:j})=>e.jsx(b,{children:e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsx(N,{className:"text-xs font-medium",children:u(`plan.columns.price_period.${g}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:u(g==="onetime"?"plan.form.price.onetime_desc":"plan.form.price.reset_desc")})]}),e.jsxs("div",{className:"relative w-full md:w-32",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"¥"})}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...j,className:"h-7 border-0 bg-gray-50 pl-6 pr-2 text-sm shadow-none ring-1 ring-gray-200 transition-shadow focus-visible:ring-2 focus-visible:ring-primary dark:bg-gray-800/50 dark:ring-gray-700 dark:placeholder:text-gray-500"})})]})]})})})},g))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(y,{control:x.control,name:"device_limit",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.device.placeholder"),className:"rounded-r-none",...g,value:g.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.device.unit")})]}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"capacity_limit",render:({field:g})=>e.jsxs(b,{className:"flex-1",children:[e.jsx(N,{children:u("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(w,{children:e.jsx(D,{type:"number",min:0,placeholder:u("plan.form.capacity.placeholder"),className:"rounded-r-none",...g,value:g.value??""})}),e.jsx("div",{className:"flex items-center rounded-r-md border border-l-0 border-input bg-muted px-3 text-sm text-muted-foreground",children:u("plan.form.capacity.unit")})]}),e.jsx(E,{})]})})]}),e.jsx(y,{control:x.control,name:"reset_traffic_method",render:({field:g})=>e.jsxs(b,{children:[e.jsx(N,{children:u("plan.form.reset_method.label")}),e.jsxs(G,{value:g.value?.toString()??"null",onValueChange:S=>g.onChange(S=="null"?null:Number(S)),children:[e.jsx(w,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:u("plan.form.reset_method.placeholder")})})}),e.jsx(B,{children:px.map(S=>e.jsx(L,{value:S.value?.toString()??"null",children:u(`plan.form.reset_method.options.${S.label}`)},S.value))})]}),e.jsx(M,{className:"text-xs",children:u("plan.form.reset_method.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:x.control,name:"content",render:({field:g})=>{const[S,j]=m.useState(!1);return e.jsxs(b,{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u("plan.form.content.label"),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>j(!S),children:S?e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),e.jsx("path",{fillRule:"evenodd",d:"M.664 10.59a1.651 1.651 0 010-1.186A10.004 10.004 0 0110 3c4.257 0 7.893 2.66 9.336 6.41.147.381.146.804 0 1.186A10.004 10.004 0 0110 17c-4.257 0-7.893-2.66-9.336-6.41zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}):e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4",children:[e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.091 1.092a4 4 0 00-5.557-5.557z",clipRule:"evenodd"}),e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"})]})})}),e.jsx(te,{side:"top",children:e.jsx("p",{className:"text-xs",children:u(S?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(ce,{children:e.jsxs(oe,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(V,{variant:"outline",size:"sm",onClick:()=>{g.onChange(u("plan.form.content.template.content"))},children:u("plan.form.content.template.button")})}),e.jsx(te,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:u("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${S?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(w,{children:e.jsx(xa,{style:{height:"400px"},value:g.value||"",renderHTML:C=>o.render(C),onChange:({text:C})=>g.onChange(C),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:u("plan.form.content.placeholder"),className:"rounded-md border"})})}),S&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:u("plan.form.content.preview")}),e.jsx("div",{className:"prose prose-sm dark:prose-invert h-[400px] max-w-none overflow-y-auto rounded-md border p-4",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:o.render(g.value||"")}})})]})]}),e.jsx(M,{className:"text-xs",children:u("plan.form.content.description")}),e.jsx(E,{})]})}})]}),e.jsx(Le,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:a&&e.jsx(y,{control:x.control,name:"force_update",render:({field:g})=>e.jsxs(b,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(w,{children:e.jsx(Hr,{checked:g.value,onCheckedChange:g.onChange})}),e.jsx("div",{className:"",children:e.jsx(N,{className:"text-sm",children:u("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:f,children:u("plan.form.submit.cancel")}),e.jsx(V,{type:"submit",disabled:c,onClick:()=>{x.handleSubmit(async g=>{i(!0),(await hd(g)).data&&(q.success(u(a?"plan.form.submit.success.update":"plan.form.submit.success.add")),f(),r()),i(!1)})()},children:u(c?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function jx(){const[s,n]=m.useState({}),[a,l]=m.useState({"drag-handle":!1}),[r,c]=m.useState([]),[i,u]=m.useState([]),[x,o]=m.useState(!1),[d,p]=m.useState({pageSize:20,pageIndex:0}),[P,R]=m.useState([]),{refetch:f}=se({queryKey:["planList"],queryFn:async()=>{const{data:k}=await Os();return R(k),k}});m.useEffect(()=>{l({"drag-handle":x}),p({pageSize:x?99999:10,pageIndex:0})},[x]);const g=(k,v)=>{x&&(k.dataTransfer.setData("text/plain",v.toString()),k.currentTarget.classList.add("opacity-50"))},S=(k,v)=>{if(!x)return;k.preventDefault(),k.currentTarget.classList.remove("bg-muted");const T=parseInt(k.dataTransfer.getData("text/plain"));if(T===v)return;const z=[...P],[Q]=z.splice(T,1);z.splice(v,0,Q),R(z)},j=async()=>{if(!x){o(!0);return}const k=P?.map(v=>v.id);pd(k).then(()=>{q.success("排序保存成功"),o(!1),f()}).finally(()=>{o(!1)})},C=Ke({data:P||[],columns:hx(f),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:d},enableRowSelection:!0,onPaginationChange:p,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}},pageCount:x?1:void 0});return e.jsx(ux,{refreshData:f,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(es,{table:C,toolbar:k=>e.jsx(xx,{table:k,refetch:f,saveOrder:j,isSortMode:x}),draggable:x,onDragStart:g,onDragEnd:k=>k.currentTarget.classList.remove("opacity-50"),onDragOver:k=>{k.preventDefault(),k.currentTarget.classList.add("bg-muted")},onDragLeave:k=>k.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!x}),e.jsx(gx,{})]})})}function vx(){const{t:s}=I("subscribe");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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("plan.title")}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:s("plan.page.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(jx,{})})]})]})}const bx=Object.freeze(Object.defineProperty({__proto__:null,default:vx},Symbol.toStringTag,{value:"Module"})),$s=[{value:Z.PENDING,label:Zs[Z.PENDING],icon:Di,color:Xs[Z.PENDING]},{value:Z.PROCESSING,label:Zs[Z.PROCESSING],icon:Wn,color:Xs[Z.PROCESSING]},{value:Z.COMPLETED,label:Zs[Z.COMPLETED],icon:ea,color:Xs[Z.COMPLETED]},{value:Z.CANCELLED,label:Zs[Z.CANCELLED],icon:Jn,color:Xs[Z.CANCELLED]},{value:Z.DISCOUNTED,label:Zs[Z.DISCOUNTED],icon:ea,color:Xs[Z.DISCOUNTED]}],st=[{value:re.PENDING,label:ht[re.PENDING],icon:Ei,color:ft[re.PENDING]},{value:re.PROCESSING,label:ht[re.PROCESSING],icon:Wn,color:ft[re.PROCESSING]},{value:re.VALID,label:ht[re.VALID],icon:ea,color:ft[re.VALID]},{value:re.INVALID,label:ht[re.INVALID],icon:Jn,color:ft[re.INVALID]}];function bt({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=s?.getFilterValue(),c=Array.isArray(r)?new Set(r):r!==void 0?new Set([r]):new Set;return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(mt,{className:"mr-2 h-4 w-4"}),n,c?.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:c.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:c.size>2?e.jsxs(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[c.size," selected"]}):a.filter(i=>c.has(i.value)).map(i=>e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(i=>{const u=c.has(i.value);return e.jsxs(ke,{onSelect:()=>{const x=new Set(c);u?x.delete(i.value):x.add(i.value);const o=Array.from(x);s?.setFilterValue(o.length?o:void 0)},children:[e.jsx("div",{className:_("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",u?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Rs,{className:_("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${i.color}`}),e.jsx("span",{children:i.label}),l?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:l.get(i.value)})]},i.value)})}),c.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const yx=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),Nx={email:"",plan_id:0,total_amount:0,period:""};function Ur({refetch:s,trigger:n,defaultValues:a}){const{t:l}=I("order"),[r,c]=m.useState(!1),i=de({resolver:me(yx),defaultValues:{...Nx,...a},mode:"onChange"}),[u,x]=m.useState([]);return m.useEffect(()=>{r&&Os().then(({data:o})=>{x(o)})},[r]),e.jsxs(fe,{open:r,onOpenChange:c,children:[e.jsx(ze,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:l("dialog.addOrder")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(pe,{children:l("dialog.assignOrder")}),e.jsx(Pe,{})]}),e.jsxs(ue,{...i,children:[e.jsx(y,{control:i.control,name:"email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.userEmail")}),e.jsx(w,{children:e.jsx(D,{placeholder:l("dialog.placeholders.email"),...o})})]})}),e.jsx(y,{control:i.control,name:"plan_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.subscriptionPlan")}),e.jsx(w,{children:e.jsxs(G,{value:o.value?o.value?.toString():void 0,onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dialog.placeholders.plan")})}),e.jsx(B,{children:u.map(d=>e.jsx(L,{value:d.id.toString(),children:d.name},d.id))})]})})]})}),e.jsx(y,{control:i.control,name:"period",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.orderPeriod")}),e.jsx(w,{children:e.jsxs(G,{value:o.value,onValueChange:o.onChange,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:l("dialog.placeholders.period")})}),e.jsx(B,{children:Object.keys(Ud).map(d=>e.jsx(L,{value:d,children:l(`period.${d}`)},d))})]})})]})}),e.jsx(y,{control:i.control,name:"total_amount",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:l("dialog.fields.paymentAmount")}),e.jsx(w,{children:e.jsx(D,{type:"number",placeholder:l("dialog.placeholders.amount"),value:o.value/100,onChange:d=>o.onChange(parseFloat(d.currentTarget.value)*100)})}),e.jsx(E,{})]})}),e.jsxs(Le,{children:[e.jsx(V,{variant:"outline",onClick:()=>c(!1),children:l("dialog.actions.cancel")}),e.jsx(V,{type:"submit",onClick:()=>{i.handleSubmit(o=>{yd(o).then(({data:d})=>{d&&(s&&s(),i.reset(),c(!1),q.success(l("dialog.messages.addSuccess")))})})()},children:l("dialog.actions.confirm")})]})]})]})]})}function _x({table:s,refetch:n}){const{t:a}=I("order"),l=s.getState().columnFilters.length>0,r=Object.values(We).filter(x=>typeof x=="number").map(x=>({label:a(`type.${We[x]}`),value:x,color:x===We.NEW?"green-500":x===We.RENEWAL?"blue-500":x===We.UPGRADE?"purple-500":"orange-500"})),c=Object.values(Ne).map(x=>({label:a(`period.${x}`),value:x,color:x===Ne.MONTH_PRICE?"slate-500":x===Ne.QUARTER_PRICE?"cyan-500":x===Ne.HALF_YEAR_PRICE?"indigo-500":x===Ne.YEAR_PRICE?"violet-500":x===Ne.TWO_YEAR_PRICE?"fuchsia-500":x===Ne.THREE_YEAR_PRICE?"pink-500":x===Ne.ONETIME_PRICE?"rose-500":"orange-500"})),i=Object.values(Z).filter(x=>typeof x=="number").map(x=>({label:a(`status.${Z[x]}`),value:x,icon:x===Z.PENDING?$s[0].icon:x===Z.PROCESSING?$s[1].icon:x===Z.COMPLETED?$s[2].icon:x===Z.CANCELLED?$s[3].icon:$s[4].icon,color:x===Z.PENDING?"yellow-500":x===Z.PROCESSING?"blue-500":x===Z.COMPLETED?"green-500":x===Z.CANCELLED?"red-500":"green-500"})),u=Object.values(re).filter(x=>typeof x=="number").map(x=>({label:a(`commission.${re[x]}`),value:x,icon:x===re.PENDING?st[0].icon:x===re.PROCESSING?st[1].icon:x===re.VALID?st[2].icon:st[3].icon,color:x===re.PENDING?"yellow-500":x===re.PROCESSING?"blue-500":x===re.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ur,{refetch:n}),e.jsx(D,{placeholder:a("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:x=>s.getColumn("trade_no")?.setFilterValue(x.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2",children:[s.getColumn("type")&&e.jsx(bt,{column:s.getColumn("type"),title:a("table.columns.type"),options:r}),s.getColumn("period")&&e.jsx(bt,{column:s.getColumn("period"),title:a("table.columns.period"),options:c}),s.getColumn("status")&&e.jsx(bt,{column:s.getColumn("status"),title:a("table.columns.status"),options:i}),s.getColumn("commission_status")&&e.jsx(bt,{column:s.getColumn("commission_status"),title:a("table.columns.commissionStatus"),options:u})]}),l&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[a("actions.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})}function Be({label:s,value:n,className:a,valueClassName:l}){return e.jsxs("div",{className:_("flex items-center py-1.5",a),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:_("text-sm",l),children:n||"-"})]})}function wx({status:s}){const{t:n}=I("order"),a={[Z.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[Z.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[Z.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[Z.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[Z.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(K,{variant:"secondary",className:_("font-medium",a[s]),children:n(`status.${Z[s]}`)})}function Cx({id:s,trigger:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(),{t:i}=I("order");return m.useEffect(()=>{(async()=>{if(a){const{data:x}=await jd({id:s});c(x)}})()},[a,s]),e.jsxs(fe,{onOpenChange:l,open:a,children:[e.jsx(ze,{asChild:!0,children:n}),e.jsxs(he,{className:"max-w-xl",children:[e.jsxs(ve,{className:"space-y-2",children:[e.jsx(pe,{className:"text-lg font-medium",children:i("dialog.title")}),e.jsx("div",{className:"flex items-center justify-between text-sm",children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsxs("div",{className:"text-muted-foreground",children:[i("table.columns.tradeNo"),":",r?.trade_no]}),r?.status&&e.jsx(wx,{status:r.status})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:i("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Be,{label:i("dialog.fields.userEmail"),value:r?.user?.email?e.jsxs(Vs,{to:`/user/manage?email=${r.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[r.user.email,e.jsx(Qn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(Be,{label:i("dialog.fields.orderPeriod"),value:r&&i(`period.${r.period}`)}),e.jsx(Be,{label:i("dialog.fields.subscriptionPlan"),value:r?.plan?.name,valueClassName:"font-medium"}),e.jsx(Be,{label:i("dialog.fields.callbackNo"),value:r?.callback_no,valueClassName:"font-mono text-xs"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:i("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Be,{label:i("dialog.fields.paymentAmount"),value:Ts(r?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(be,{className:"my-2"}),e.jsx(Be,{label:i("dialog.fields.balancePayment"),value:Ts(r?.balance_amount||0)}),e.jsx(Be,{label:i("dialog.fields.discountAmount"),value:Ts(r?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(Be,{label:i("dialog.fields.refundAmount"),value:Ts(r?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(Be,{label:i("dialog.fields.deductionAmount"),value:Ts(r?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:i("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Be,{label:i("dialog.fields.createdAt"),value:xe(r?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(Be,{label:i("dialog.fields.updatedAt"),value:xe(r?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const Sx={[We.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[We.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[We.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[We.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},kx={[Ne.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ne.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Tx=s=>Z[s],Px=s=>re[s],Dx=s=>We[s],Ex=s=>{const{t:n}=I("order");return[{accessorKey:"trade_no",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.tradeNo")}),cell:({row:a})=>{const l=a.original.trade_no,r=l.length>6?`${l.slice(0,3)}...${l.slice(-3)}`:l;return e.jsx("div",{className:"flex items-center",children:e.jsx(Cx,{trigger:e.jsxs(J,{variant:"ghost",size:"sm",className:"flex h-8 items-center gap-1.5 px-2 font-medium text-primary transition-colors hover:bg-primary/10 hover:text-primary/80",children:[e.jsx("span",{className:"font-mono",children:r}),e.jsx(Qn,{className:"h-3.5 w-3.5 opacity-70"})]}),id:a.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.type")}),cell:({row:a})=>{const l=a.getValue("type"),r=Sx[l];return e.jsx(K,{variant:"secondary",className:_("font-medium transition-colors text-nowrap",r.color,r.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${Dx(l)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.plan")}),cell:({row:a})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium text-foreground/90 sm:max-w-72 md:max-w-[31rem]",children:a.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.period")}),cell:({row:a})=>{const l=a.getValue("period"),r=kx[l];return e.jsx(K,{variant:"secondary",className:_("font-medium transition-colors text-nowrap",r.color,r.bgColor,"hover:bg-opacity-80"),children:n(`period.${l}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.amount")}),cell:({row:a})=>{const l=a.getValue("total_amount"),r=typeof l=="number"?(l/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",r]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:a})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:a,title:n("table.columns.status")}),e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsx(Mr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(te,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:a})=>{const l=$s.find(r=>r.value===a.getValue("status"));return l?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.icon&&e.jsx(l.icon,{className:`h-4 w-4 text-${l.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${Tx(l.value)}`)})]}),l.value===Z.PENDING&&e.jsxs(_s,{modal:!0,children:[e.jsx(ws,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Ct,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(ds,{align:"end",className:"w-[140px]",children:[e.jsx(ge,{className:"cursor-pointer",onClick:async()=>{await vd({trade_no:a.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(ge,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await bd({trade_no:a.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.commission")}),cell:({row:a})=>{const l=a.getValue("commission_balance"),r=l?(l/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:l?`¥${r}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.commissionStatus")}),cell:({row:a})=>{const l=a.original.status,r=a.original.commission_balance,c=st.find(i=>i.value===a.getValue("commission_status"));return r==0||!c?e.jsx("span",{className:"text-muted-foreground",children:"-"}):e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c.icon&&e.jsx(c.icon,{className:`h-4 w-4 text-${c.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${Px(c.value)}`)})]}),c.value===re.PENDING&&l===Z.COMPLETED&&e.jsxs(_s,{modal:!0,children:[e.jsx(ws,{asChild:!0,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Ct,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(ds,{align:"end",className:"w-[120px]",children:[e.jsx(ge,{className:"cursor-pointer",onClick:async()=>{await $a({trade_no:a.original.trade_no,commission_status:re.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(ge,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await $a({trade_no:a.original.trade_no,commission_status:re.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.createdAt")}),cell:({row:a})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:xe(a.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function Rx(){const[s]=Zn(),[n,a]=m.useState({}),[l,r]=m.useState({}),[c,i]=m.useState([]),[u,x]=m.useState([]),[o,d]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const S=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([j,C])=>{const k=s.get(j);return k?{id:j,value:C==="number"?parseInt(k):k}:null}).filter(Boolean);S.length>0&&i(S)},[s]);const{refetch:p,data:P,isLoading:R}=se({queryKey:["orderList",o,c,u],queryFn:()=>gd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:u})}),f=Ke({data:P?.data??[],columns:Ex(p),state:{sorting:u,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:o},rowCount:P?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),onPaginationChange:d,getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(es,{table:f,toolbar:e.jsx(_x,{table:f,refetch:p}),showPagination:!0})}function Vx(){const{t:s}=I("order");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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:"text-muted-foreground mt-2",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(Rx,{})})]})]})}const Ix=Object.freeze(Object.defineProperty({__proto__:null,default:Vx},Symbol.toStringTag,{value:"Module"}));function Fx({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(mt,{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(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(ke,{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:_("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(Rs,{className:_("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(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Mx=h.object({id:h.coerce.number().nullable().optional(),name:h.string().min(1,"请输入优惠券名称"),code:h.string().nullable(),type:h.coerce.number(),value:h.coerce.number(),started_at:h.coerce.number(),ended_at:h.coerce.number(),limit_use:h.union([h.string(),h.number()]).nullable(),limit_use_with_user:h.union([h.string(),h.number()]).nullable(),generate_count:h.coerce.number().nullable().optional(),limit_plan_ids:h.array(h.number()).default([]).nullable(),limit_period:h.array(h.nativeEnum(nt)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),Ja={name:"",code:"",type:Fe.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:"",limit_use_with_user:"",limit_plan_ids:[],limit_period:[],generate_count:""};function Br({defaultValues:s,refetch:n,type:a="create",dialogTrigger:l=null,open:r,onOpenChange:c}){const{t:i}=I("coupon"),[u,x]=m.useState(!1),o=r??u,d=c??x,[p,P]=m.useState([]),R=de({resolver:me(Mx),defaultValues:s||Ja});m.useEffect(()=>{s&&R.reset(s)},[s,R]),m.useEffect(()=>{Os().then(({data:j})=>P(j))},[]);const f=j=>{if(!j)return;const C=(k,v)=>{const T=new Date(v*1e3);return k.setHours(T.getHours(),T.getMinutes(),T.getSeconds()),Math.floor(k.getTime()/1e3)};j.from&&R.setValue("started_at",C(j.from,R.watch("started_at"))),j.to&&R.setValue("ended_at",C(j.to,R.watch("ended_at")))},g=async j=>{_d(j).then(()=>{d(!1),a==="create"&&R.reset(Ja),n()})},S=(j,C)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:C}),e.jsx(D,{type:"datetime-local",step:"1",value:xe(R.watch(j),"YYYY-MM-DDTHH:mm:ss"),onChange:k=>{const v=new Date(k.target.value);R.setValue(j,Math.floor(v.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(fe,{open:o,onOpenChange:d,children:[l&&e.jsx(ze,{asChild:!0,children:l}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsx(ve,{children:e.jsx(pe,{children:i(a==="create"?"form.add":"form.edit")})}),e.jsx(ue,{...R,children:e.jsxs("form",{onSubmit:R.handleSubmit(g),className:"space-y-4",children:[e.jsx(y,{control:R.control,name:"name",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.name.label")}),e.jsx(D,{placeholder:i("form.name.placeholder"),...j}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"code",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.code.label")}),e.jsx(D,{placeholder:i("form.code.placeholder"),...j,className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.code.description")}),e.jsx(E,{})]})}),e.jsxs(b,{children:[e.jsx(N,{children:i("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(y,{control:R.control,name:"type",render:({field:j})=>e.jsxs(G,{value:j.value.toString(),onValueChange:C=>{const k=j.value,v=parseInt(C);j.onChange(v);const T=R.getValues("value");T&&(k===Fe.AMOUNT&&v===Fe.PERCENT?R.setValue("value",T/100):k===Fe.PERCENT&&v===Fe.AMOUNT&&R.setValue("value",T*100))},children:[e.jsx(U,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Y,{placeholder:i("form.type.placeholder")})}),e.jsx(B,{children:Object.entries(Bd).map(([C,k])=>e.jsx(L,{value:C,children:i(`table.toolbar.types.${C}`)},C))})]})}),e.jsx(y,{control:R.control,name:"value",render:({field:j})=>{const C=j.value===""?"":R.watch("type")===Fe.AMOUNT&&typeof j.value=="number"?(j.value/100).toString():j.value.toString();return e.jsx(D,{type:"number",placeholder:i("form.value.placeholder"),...j,value:C,onChange:k=>{const v=k.target.value;if(v===""){j.onChange("");return}const T=parseFloat(v);isNaN(T)||j.onChange(R.watch("type")===Fe.AMOUNT?Math.round(T*100):T)},step:"any",min:0,className:"flex-[2] rounded-none border-x-0 text-left"})}}),e.jsx("div",{className:"flex min-w-[40px] items-center justify-center rounded-md rounded-l-none border border-l-0 border-input bg-muted/50 px-3 font-medium text-muted-foreground",children:e.jsx("span",{children:R.watch("type")==Fe.AMOUNT?"¥":"%"})})]})]}),e.jsxs(b,{children:[e.jsx(N,{children:i("form.validity.label")}),e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(V,{variant:"outline",className:_("w-full justify-start text-left font-normal",!R.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),xe(R.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",i("form.validity.to")," ",xe(R.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(Xe,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(zs,{mode:"range",selected:{from:new Date(R.watch("started_at")*1e3),to:new Date(R.watch("ended_at")*1e3)},onSelect:f,numberOfMonths:2})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-4",children:[S("started_at",i("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:i("form.validity.to")}),S("ended_at",i("table.validity.endTime"))]})})]})]}),e.jsx(E,{})]}),e.jsx(y,{control:R.control,name:"limit_use",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.limitUse.placeholder"),...j,value:j.value===void 0?"":j.value,onChange:C=>j.onChange(C.target.value===""?"":C.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.limitUse.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"limit_use_with_user",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.limitUseWithUser.placeholder"),...j,value:j.value===void 0?"":j.value,onChange:C=>j.onChange(C.target.value===""?"":C.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.limitUseWithUser.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"limit_period",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitPeriod.label")}),e.jsx(it,{options:Object.entries(nt).filter(([C])=>isNaN(Number(C))).map(([C,k])=>({label:i(`coupon:period.${k}`),value:C})),onChange:C=>{if(C.length===0){j.onChange([]);return}const k=C.map(v=>nt[v.value]);j.onChange(k)},value:(j.value||[]).map(C=>({label:i(`coupon:period.${C}`),value:Object.entries(nt).find(([k,v])=>v===C)?.[0]||""})),placeholder:i("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:i("form.limitPeriod.empty")})}),e.jsx(M,{className:"text-xs",children:i("form.limitPeriod.description")}),e.jsx(E,{})]})}),e.jsx(y,{control:R.control,name:"limit_plan_ids",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.limitPlan.label")}),e.jsx(it,{options:p?.map(C=>({label:C.name,value:C.id.toString()}))||[],onChange:C=>j.onChange(C.map(k=>Number(k.value))),value:(p||[]).filter(C=>(j.value||[]).includes(C.id)).map(C=>({label:C.name,value:C.id.toString()})),placeholder:i("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:i("form.limitPlan.empty")})}),e.jsx(E,{})]})}),a==="create"&&e.jsx(e.Fragment,{children:e.jsx(y,{control:R.control,name:"generate_count",render:({field:j})=>e.jsxs(b,{children:[e.jsx(N,{children:i("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.generateCount.placeholder"),...j,value:j.value===void 0?"":j.value,onChange:C=>j.onChange(C.target.value===""?"":C.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.generateCount.description")}),e.jsx(E,{})]})})}),e.jsx(Le,{children:e.jsx(V,{type:"submit",disabled:R.formState.isSubmitting,children:R.formState.isSubmitting?i("form.submit.saving"):i("form.submit.save")})})]})})]})]})}function Ox({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=I("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{refetch:n,dialogTrigger:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:l("form.add")})]})}),e.jsx(D,{placeholder:l("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(Fx,{column:s.getColumn("type"),title:l("table.toolbar.type"),options:[{value:Fe.AMOUNT,label:l(`table.toolbar.types.${Fe.AMOUNT}`)},{value:Fe.PERCENTAGE,label:l(`table.toolbar.types.${Fe.PERCENTAGE}`)}]}),a&&e.jsxs(V,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("table.toolbar.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})}const Gr=m.createContext(void 0);function zx({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),i=x=>{c(x),l(!0)},u=()=>{l(!1),c(null)};return e.jsxs(Gr.Provider,{value:{isOpen:a,currentCoupon:r,openEdit:i,closeEdit:u},children:[s,r&&e.jsx(Br,{defaultValues:r,refetch:n,type:"edit",open:a,onOpenChange:l})]})}function Lx(){const s=m.useContext(Gr);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Ax=s=>{const{t:n}=I("coupon");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(K,{children:a.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx(H,{defaultChecked:a.original.show,onCheckedChange:l=>{Cd({id:a.original.id,show:l}).then(({data:r})=>!r&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.name")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:a.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.type")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:n(`table.toolbar.types.${a.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.code")}),cell:({row:a})=>e.jsx(K,{variant:"secondary",children:a.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.limitUse")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:a.original.limit_use===null?n("table.validity.unlimited"):a.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.limitUseWithUser")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:a.original.limit_use_with_user===null?n("table.validity.noLimit"):a.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.validity")}),cell:({row:a})=>{const[l,r]=m.useState(!1),c=Date.now(),i=a.original.started_at*1e3,u=a.original.ended_at*1e3,x=c>u,o=ce.jsx(O,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>{const{openEdit:l}=Lx();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>l(a.original),children:[e.jsx(Is,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(Ue,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{wd({id:a.original.id}).then(({data:r})=>{r&&(q.success("删除成功"),s())})},children:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ns,{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")})]})})]})}}]};function $x(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[i,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:d,data:p}=se({queryKey:["couponList",x,r,i],queryFn:()=>Nd({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),P=Ke({data:p?.data??[],columns:Ax(d),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:x},pageCount:Math.ceil((p?.total??0)/x.pageSize),rowCount:p?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,onPaginationChange:o,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(zx,{refetch:d,children:e.jsx("div",{className:"space-y-4",children:e.jsx(es,{table:P,toolbar:e.jsx(Ox,{table:P,refetch:d})})})})}function qx(){const{t:s}=I("coupon");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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:"text-muted-foreground mt-2",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($x,{})})]})]})}const Kx=Object.freeze(Object.defineProperty({__proto__:null,default:qx},Symbol.toStringTag,{value:"Module"})),Hx=h.object({email_prefix:h.string().optional(),email_suffix:h.string().min(1),password:h.string().optional(),expired_at:h.number().optional().nullable(),plan_id:h.number().nullable(),generate_count:h.number().optional().nullable()}).refine(s=>s.generate_count===null?s.email_prefix!==void 0&&s.email_prefix!=="":!0,{message:"Email prefix is required when generate_count is null",path:["email_prefix"]}),Ux={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function Bx({refetch:s}){const{t:n}=I("user"),[a,l]=m.useState(!1),r=de({resolver:me(Hx),defaultValues:Ux,mode:"onChange"}),[c,i]=m.useState([]);return m.useEffect(()=>{a&&Os().then(({data:u})=>{u&&i(u)})},[a]),e.jsxs(fe,{open:a,onOpenChange:l,children:[e.jsx(ze,{asChild:!0,children:e.jsxs(J,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(Se,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(he,{className:"sm:max-w-[425px]",children:[e.jsxs(ve,{children:[e.jsx(pe,{children:n("generate.title")}),e.jsx(Pe,{})]}),e.jsxs(ue,{...r,children:[e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!r.watch("generate_count")&&e.jsx(y,{control:r.control,name:"email_prefix",render:({field:u})=>e.jsx(D,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...u})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${r.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(y,{control:r.control,name:"email_suffix",render:({field:u})=>e.jsx(D,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...u})})]})]}),e.jsx(y,{control:r.control,name:"password",render:({field:u})=>e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...u}),e.jsx(E,{})]})}),e.jsx(y,{control:r.control,name:"expired_at",render:({field:u})=>e.jsxs(b,{className:"flex flex-col",children:[e.jsx(N,{children:n("generate.form.expire_time")}),e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsx(w,{children:e.jsxs(J,{variant:"outline",className:_("w-full pl-3 text-left font-normal",!u.value&&"text-muted-foreground"),children:[u.value?xe(u.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(dt,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(Xe,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Vi,{asChild:!0,children:e.jsx(J,{variant:"outline",className:"w-full",onClick:()=>{u.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(zs,{mode:"single",selected:u.value?new Date(u.value*1e3):void 0,onSelect:x=>{x&&u.onChange(x?.getTime()/1e3)}})})]})]})]})}),e.jsx(y,{control:r.control,name:"plan_id",render:({field:u})=>e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.subscription")}),e.jsx(w,{children:e.jsxs(G,{value:u.value?u.value.toString():"null",onValueChange:x=>u.onChange(x==="null"?null:parseInt(x)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(L,{value:"null",children:n("generate.form.subscription_none")}),c.map(x=>e.jsx(L,{value:x.id.toString(),children:x.name},x.id))]})]})})]})}),!r.watch("email_prefix")&&e.jsx(y,{control:r.control,name:"generate_count",render:({field:u})=>e.jsxs(b,{children:[e.jsx(N,{children:n("generate.form.generate_count")}),e.jsx(D,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:u.value||"",onChange:x=>u.onChange(x.target.value?parseInt(x.target.value):null)})]})})]}),e.jsxs(Le,{children:[e.jsx(J,{variant:"outline",onClick:()=>l(!1),children:n("generate.form.cancel")}),e.jsx(J,{onClick:()=>r.handleSubmit(u=>{Pd(u).then(({data:x})=>{x&&(q.success(n("generate.form.success")),r.reset(),s(),l(!1))})})(),children:n("generate.form.submit")})]})]})]})}const Yr=Xa,Wr=en,Gx=sn,Jr=m.forwardRef(({className:s,...n},a)=>e.jsx(Pt,{className:_("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}));Jr.displayName=Pt.displayName;const Yx=Es("fixed overflow-y-scroll z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-300 data-[state=open]:animate-in data-[state=closed]:animate-out",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-md",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-md"}},defaultVariants:{side:"right"}}),Na=m.forwardRef(({side:s="right",className:n,children:a,...l},r)=>e.jsxs(Gx,{children:[e.jsx(Jr,{}),e.jsxs(Dt,{ref:r,className:_(Yx({side:s}),n),...l,children:[e.jsxs(oa,{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-secondary",children:[e.jsx(Ae,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),a]})]}));Na.displayName=Dt.displayName;const _a=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col space-y-2 text-center sm:text-left",s),...n});_a.displayName="SheetHeader";const Qr=({className:s,...n})=>e.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Qr.displayName="SheetFooter";const wa=m.forwardRef(({className:s,...n},a)=>e.jsx(Et,{ref:a,className:_("text-lg font-semibold text-foreground",s),...n}));wa.displayName=Et.displayName;const Ca=m.forwardRef(({className:s,...n},a)=>e.jsx(Rt,{ref:a,className:_("text-sm text-muted-foreground",s),...n}));Ca.displayName=Rt.displayName;function Wx({table:s,refetch:n,permissionGroups:a=[],subscriptionPlans:l=[]}){const{t:r}=I("user"),c=s.getState().columnFilters.length>0,[i,u]=m.useState([]),[x,o]=m.useState(!1),d=[{label:r("filter.fields.email"),value:"email",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.id"),value:"id",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:r("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:r("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"},{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.lt"),value:"lt"}]},{label:r("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:r("filter.operators.lt"),value:"lt"},{label:r("filter.operators.gt"),value:"gt"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.token"),value:"token",type:"text",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.banned"),value:"banned",type:"select",operators:[{label:r("filter.operators.eq"),value:"eq"}],options:[{label:r("filter.status.normal"),value:"0"},{label:r("filter.status.banned"),value:"1"}]},{label:r("filter.fields.remark"),value:"remark",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.inviter_email"),value:"inviter_email",type:"text",operators:[{label:r("filter.operators.contains"),value:"contains"},{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:r("filter.operators.eq"),value:"eq"}]},{label:r("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:r("filter.operators.eq"),value:"eq"}]}],p=C=>C*1024*1024*1024,P=C=>C/(1024*1024*1024),R=()=>{u([...i,{field:"",operator:"",value:""}])},f=C=>{u(i.filter((k,v)=>v!==C))},g=(C,k,v)=>{const T=[...i];if(T[C]={...T[C],[k]:v},k==="field"){const z=d.find(Q=>Q.value===v);z&&(T[C].operator=z.operators[0].value,T[C].value=z.type==="boolean"?!1:"")}u(T)},S=(C,k)=>{const v=d.find(T=>T.value===C.field);if(!v)return null;switch(v.type){case"text":return e.jsx(D,{placeholder:r("filter.sheet.value"),value:C.value,onChange:T=>g(k,"value",T.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(D,{type:"number",placeholder:r("filter.sheet.value_number",{unit:v.unit}),value:v.unit==="GB"?P(C.value||0):C.value,onChange:T=>{const z=Number(T.target.value);g(k,"value",v.unit==="GB"?p(z):z)}}),v.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:v.unit})]});case"date":return e.jsx(zs,{mode:"single",selected:C.value,onSelect:T=>g(k,"value",T),className:"rounded-md border"});case"select":return e.jsxs(G,{value:C.value,onValueChange:T=>g(k,"value",T),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("filter.sheet.value")})}),e.jsx(B,{children:v.useOptions?l.map(T=>e.jsx(L,{value:T.value.toString(),children:T.label},T.value)):v.options?.map(T=>e.jsx(L,{value:T.value.toString(),children:T.label},T.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(H,{checked:C.value,onCheckedChange:T=>g(k,"value",T)}),e.jsx(St,{children:C.value?r("filter.boolean.true"):r("filter.boolean.false")})]});default:return null}},j=()=>{const C=i.filter(k=>k.field&&k.operator&&k.value!=="").map(k=>{const v=d.find(z=>z.value===k.field);let T=k.value;return k.operator==="contains"?{id:k.field,value:T}:(v?.type==="date"&&T instanceof Date&&(T=Math.floor(T.getTime()/1e3)),v?.type==="boolean"&&(T=T?1:0),{id:k.field,value:`${k.operator}:${T}`})});s.setColumnFilters(C),o(!1)};return e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2",children:e.jsxs("div",{className:"flex flex-1 flex-wrap items-center gap-2",children:[e.jsx(Bx,{refetch:n}),e.jsx(D,{placeholder:r("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:C=>s.getColumn("email")?.setFilterValue(C.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Yr,{open:x,onOpenChange:o,children:[e.jsx(Wr,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ii,{className:"mr-2 h-4 w-4"}),r("filter.advanced"),i.length>0&&e.jsx(K,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:i.length})]})}),e.jsxs(Na,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(_a,{children:[e.jsx(wa,{children:r("filter.sheet.title")}),e.jsx(Ca,{children:r("filter.sheet.description")})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-medium",children:r("filter.sheet.conditions")}),e.jsx(V,{variant:"outline",size:"sm",onClick:R,children:r("filter.sheet.add")})]}),e.jsx(ot,{className:"h-[calc(100vh-280px)] pr-4",children:e.jsx("div",{className:"space-y-4",children:i.map((C,k)=>e.jsxs("div",{className:"space-y-3 rounded-lg border p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(St,{children:r("filter.sheet.condition",{number:k+1})}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>f(k),children:e.jsx(Ae,{className:"h-4 w-4"})})]}),e.jsxs(G,{value:C.field,onValueChange:v=>g(k,"field",v),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("filter.sheet.field")})}),e.jsx(B,{children:d.map(v=>e.jsx(L,{value:v.value,children:v.label},v.value))})]}),C.field&&e.jsxs(G,{value:C.operator,onValueChange:v=>g(k,"operator",v),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("filter.sheet.operator")})}),e.jsx(B,{children:d.find(v=>v.value===C.field)?.operators.map(v=>e.jsx(L,{value:v.value,children:v.label},v.value))})]}),C.field&&C.operator&&S(C,k)]},k))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(V,{variant:"outline",onClick:()=>{u([]),o(!1)},children:r("filter.sheet.reset")}),e.jsx(V,{onClick:j,children:r("filter.sheet.apply")})]})]})]})]}),c&&e.jsxs(V,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[r("filter.reset"),e.jsx(Ae,{className:"ml-2 h-4 w-4"})]})]})})}const Jx=h.object({id:h.number(),email:h.string().email(),invite_user_email:h.string().email().nullable().optional(),password:h.string().optional().nullable(),balance:h.coerce.number(),commission_balance:h.coerce.number(),u:h.number(),d:h.number(),transfer_enable:h.number(),expired_at:h.number().nullable(),plan_id:h.number().nullable(),banned:h.number(),commission_type:h.number(),commission_rate:h.number().nullable(),discount:h.number().nullable(),speed_limit:h.number().nullable(),device_limit:h.number().nullable(),is_admin:h.number(),is_staff:h.number(),remarks:h.string().nullable()}),Zr=m.createContext(void 0);function Qx({children:s,defaultValues:n,open:a,onOpenChange:l}){const[r,c]=m.useState(!1),[i,u]=m.useState(!1),[x,o]=m.useState([]),d=de({resolver:me(Jx),defaultValues:n,mode:"onChange"});m.useEffect(()=>{a!==void 0&&c(a)},[a]);const p=P=>{c(P),l?.(P)};return e.jsx(Zr.Provider,{value:{form:d,formOpen:r,setFormOpen:p,datePickerOpen:i,setDatePickerOpen:u,planList:x,setPlanList:o},children:s})}function Zx(){const s=m.useContext(Zr);if(!s)throw new Error("useUserForm must be used within a UserFormProvider");return s}function Xx({refetch:s}){const{t:n}=I("user"),{form:a,formOpen:l,setFormOpen:r,datePickerOpen:c,setDatePickerOpen:i,planList:u,setPlanList:x}=Zx();return m.useEffect(()=>{l&&Os().then(({data:o})=>{x(o)})},[l,x]),e.jsxs(ue,{...a,children:[e.jsx(y,{control:a.control,name:"email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.email")}),e.jsx(w,{children:e.jsx(D,{...o,placeholder:n("edit.form.email_placeholder")})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"invite_user_email",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.inviter_email")}),e.jsx(w,{children:e.jsx(D,{value:o.value||"",onChange:d=>o.onChange(d.target.value?d.target.value:null),placeholder:n("edit.form.inviter_email_placeholder")})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"password",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.password")}),e.jsx(w,{children:e.jsx(D,{value:o.value||"",onChange:o.onChange,placeholder:n("edit.form.password_placeholder")})}),e.jsx(E,{...o})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(y,{control:a.control,name:"balance",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.balance")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:n("edit.form.balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"commission_balance",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.commission_balance")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:n("edit.form.commission_balance_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"¥"})]})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"u",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.upload")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{value:o.value/1024/1024/1024||"",onChange:d=>o.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.upload_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{...o})]})}),e.jsx(y,{control:a.control,name:"d",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.download")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value/1024/1024/1024||"",onChange:d=>o.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.download_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{...o})]})})]}),e.jsx(y,{control:a.control,name:"transfer_enable",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.total_traffic")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value/1024/1024/1024||"",onChange:d=>o.onChange(parseInt(d.target.value)*1024*1024*1024),placeholder:n("edit.form.total_traffic_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"GB"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"expired_at",render:({field:o})=>e.jsxs(b,{className:"flex flex-col",children:[e.jsx(N,{children:n("edit.form.expire_time")}),e.jsxs(rs,{open:c,onOpenChange:i,children:[e.jsx(ls,{asChild:!0,children:e.jsx(w,{children:e.jsxs(V,{type:"button",variant:"outline",className:_("w-full pl-3 text-left font-normal",!o.value&&"text-muted-foreground"),onClick:()=>i(!0),children:[o.value?xe(o.value):e.jsx("span",{children:n("edit.form.expire_time_placeholder")}),e.jsx(dt,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:d=>{d.preventDefault()},onEscapeKeyDown:d=>{d.preventDefault()},children:e.jsxs("div",{className:"flex flex-col space-y-3 p-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{o.onChange(null),i(!1)},children:n("edit.form.expire_time_permanent")}),e.jsx(V,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;d.setMonth(d.getMonth()+1),d.setHours(23,59,59,999),o.onChange(Math.floor(d.getTime()/1e3)),i(!1)},children:n("edit.form.expire_time_1month")}),e.jsx(V,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;d.setMonth(d.getMonth()+3),d.setHours(23,59,59,999),o.onChange(Math.floor(d.getTime()/1e3)),i(!1)},children:n("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(zs,{mode:"single",selected:o.value?new Date(o.value*1e3):void 0,onSelect:d=>{if(d){const p=new Date(o.value?o.value*1e3:Date.now());d.setHours(p.getHours(),p.getMinutes(),p.getSeconds()),o.onChange(Math.floor(d.getTime()/1e3))}},disabled:d=>d{const d=new Date;d.setHours(23,59,59,999),o.onChange(Math.floor(d.getTime()/1e3))},className:"h-6 px-2 text-xs",children:n("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"datetime-local",step:"1",value:xe(o.value,"YYYY-MM-DDTHH:mm:ss"),onChange:d=>{const p=new Date(d.target.value);isNaN(p.getTime())||o.onChange(Math.floor(p.getTime()/1e3))},className:"flex-1"}),e.jsx(V,{type:"button",variant:"outline",onClick:()=>i(!1),children:n("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"plan_id",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.subscription")}),e.jsx(w,{children:e.jsxs(G,{value:o.value?o.value.toString():"null",onValueChange:d=>o.onChange(d==="null"?null:parseInt(d)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(L,{value:"null",children:n("edit.form.subscription_none")}),u.map(d=>e.jsx(L,{value:d.id.toString(),children:d.name},d.id))]})]})})]})}),e.jsx(y,{control:a.control,name:"banned",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.account_status")}),e.jsx(w,{children:e.jsxs(G,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(Y,{})}),e.jsxs(B,{children:[e.jsx(L,{value:"1",children:n("columns.status_text.banned")}),e.jsx(L,{value:"0",children:n("columns.status_text.normal")})]})]})})]})}),e.jsx(y,{control:a.control,name:"commission_type",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.commission_type")}),e.jsx(w,{children:e.jsxs(G,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(B,{children:[e.jsx(L,{value:"0",children:n("edit.form.commission_type_system")}),e.jsx(L,{value:"1",children:n("edit.form.commission_type_cycle")}),e.jsx(L,{value:"2",children:n("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(y,{control:a.control,name:"commission_rate",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.commission_rate")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.commission_rate_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})})]})}),e.jsx(y,{control:a.control,name:"discount",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.discount")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.discount_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"%"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"speed_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.speed_limit")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.speed_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"Mbps"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"device_limit",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.device_limit")}),e.jsx(w,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:d=>o.onChange(parseInt(d.currentTarget.value)||null),placeholder:n("edit.form.device_limit_placeholder"),className:"rounded-r-none"}),e.jsx("div",{className:"z-[-1] rounded-md rounded-l-none border border-l-0 border-input px-3 py-1 shadow-sm",children:"台"})]})}),e.jsx(E,{})]})}),e.jsx(y,{control:a.control,name:"is_admin",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(y,{control:a.control,name:"is_staff",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(w,{children:e.jsx(H,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(y,{control:a.control,name:"remarks",render:({field:o})=>e.jsxs(b,{children:[e.jsx(N,{children:n("edit.form.remarks")}),e.jsx(w,{children:e.jsx(ps,{className:"h-24",value:o.value||"",onChange:d=>o.onChange(d.currentTarget.value??null),placeholder:n("edit.form.remarks_placeholder")})}),e.jsx(E,{})]})}),e.jsxs(Qr,{children:[e.jsx(V,{variant:"outline",onClick:()=>r(!1),children:n("edit.form.cancel")}),e.jsx(V,{type:"submit",onClick:()=>{a.handleSubmit(o=>{kd(o).then(({data:d})=>{d&&(q.success(n("edit.form.success")),r(!1),s())})})()},children:n("edit.form.submit")})]})]})}function Xr({refetch:s,defaultValues:n,dialogTrigger:a=e.jsxs(V,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(mt,{className:"mr-2 h-4 w-4"}),t("edit.button")]})}){const{t:l}=I("user"),[r,c]=m.useState(!1);return e.jsx(Qx,{defaultValues:n,open:r,onOpenChange:c,children:e.jsxs(Yr,{open:r,onOpenChange:c,children:[e.jsx(Wr,{asChild:!0,children:a}),e.jsxs(Na,{className:"max-w-[90%] space-y-4",children:[e.jsxs(_a,{children:[e.jsx(wa,{children:l("edit.title")}),e.jsx(Ca,{})]}),e.jsx(Xx,{refetch:s})]})]})})}const el=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:"m17.71 11.29l-5-5a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21l-5 5a1 1 0 0 0 1.42 1.42L11 9.41V17a1 1 0 0 0 2 0V9.41l3.29 3.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42"})}),sl=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:"M17.71 11.29a1 1 0 0 0-1.42 0L13 14.59V7a1 1 0 0 0-2 0v7.59l-3.29-3.3a1 1 0 0 0-1.42 1.42l5 5a1 1 0 0 0 .33.21a.94.94 0 0 0 .76 0a1 1 0 0 0 .33-.21l5-5a1 1 0 0 0 0-1.42"})}),eh=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:"M17 11H9.41l3.3-3.29a1 1 0 1 0-1.42-1.42l-5 5a1 1 0 0 0-.21.33a1 1 0 0 0 0 .76a1 1 0 0 0 .21.33l5 5a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42L9.41 13H17a1 1 0 0 0 0-2"})}),sh=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:"M17.92 11.62a1 1 0 0 0-.21-.33l-5-5a1 1 0 0 0-1.42 1.42l3.3 3.29H7a1 1 0 0 0 0 2h7.59l-3.3 3.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l5-5a1 1 0 0 0 .21-.33a1 1 0 0 0 0-.76"})}),Yt=[{accessorKey:"record_at",header:"时间",cell:({row:s})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("time",{className:"text-sm text-muted-foreground",children:uc(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(el,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:ss(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(sl,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:ss(s.original.d)})]})},{accessorKey:"server_rate",header:"倍率",cell:({row:s})=>{const n=s.original.server_rate;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(K,{variant:"outline",className:"font-mono",children:[n,"x"]})})}},{id:"total",header:"总计",cell:({row:s})=>{const n=s.original.u+s.original.d;return e.jsx("div",{className:"flex items-center justify-end font-mono text-sm",children:ss(n)})}}];function tl({user_id:s,dialogTrigger:n}){const{t:a}=I(["traffic"]),[l,r]=m.useState(!1),[c,i]=m.useState({pageIndex:0,pageSize:20}),{data:u,isLoading:x}=se({queryKey:["userStats",s,c,l],queryFn:()=>l?Dd({user_id:s,pageSize:c.pageSize,page:c.pageIndex+1}):null}),o=Ke({data:u?.data??[],columns:Yt,pageCount:Math.ceil((u?.total??0)/c.pageSize),state:{pagination:c},manualPagination:!0,getCoreRowModel:He(),onPaginationChange:i});return e.jsxs(fe,{open:l,onOpenChange:r,children:[e.jsx(ze,{asChild:!0,children:n}),e.jsxs(he,{className:"sm:max-w-[700px]",children:[e.jsx(ve,{children:e.jsx(pe,{children:a("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(pa,{children:[e.jsx(ga,{children:o.getHeaderGroups().map(d=>e.jsx(ys,{children:d.headers.map(p=>e.jsx(va,{className:_("h-10 px-2 text-xs",p.id==="total"&&"text-right"),children:p.isPlaceholder?null:_t(p.column.columnDef.header,p.getContext())},p.id))},d.id))}),e.jsx(ja,{children:x?Array.from({length:c.pageSize}).map((d,p)=>e.jsx(ys,{children:Array.from({length:Yt.length}).map((P,R)=>e.jsx(Ks,{className:"p-2",children:e.jsx(le,{className:"h-6 w-full"})},R))},p)):o.getRowModel().rows?.length?o.getRowModel().rows.map(d=>e.jsx(ys,{"data-state":d.getIsSelected()&&"selected",className:"h-10",children:d.getVisibleCells().map(p=>e.jsx(Ks,{className:"px-2",children:_t(p.column.columnDef.cell,p.getContext())},p.id))},d.id)):e.jsx(ys,{children:e.jsx(Ks,{colSpan:Yt.length,className:"h-24 text-center",children:a("trafficRecord.noRecords")})})})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("trafficRecord.perPage")}),e.jsxs(G,{value:`${o.getState().pagination.pageSize}`,onValueChange:d=>{o.setPageSize(Number(d))},children:[e.jsx(U,{className:"h-8 w-[70px]",children:e.jsx(Y,{placeholder:o.getState().pagination.pageSize})}),e.jsx(B,{side:"top",children:[10,20,30,40,50].map(d=>e.jsx(L,{value:`${d}`,children:d},d))})]}),e.jsx("p",{className:"text-sm font-medium",children:a("trafficRecord.records")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"flex w-[100px] items-center justify-center text-sm",children:a("trafficRecord.page",{current:o.getState().pagination.pageIndex+1,total:o.getPageCount()})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||x,children:e.jsx(eh,{className:"h-4 w-4"})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||x,children:e.jsx(sh,{className:"h-4 w-4"})})]})]})]})]})]})]})}const th=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:"M5 18h4.24a1 1 0 0 0 .71-.29l6.92-6.93L19.71 8a1 1 0 0 0 0-1.42l-4.24-4.29a1 1 0 0 0-1.42 0l-2.82 2.83l-6.94 6.93a1 1 0 0 0-.29.71V17a1 1 0 0 0 1 1m9.76-13.59l2.83 2.83l-1.42 1.42l-2.83-2.83ZM6 13.17l5.93-5.93l2.83 2.83L8.83 16H6ZM21 20H3a1 1 0 0 0 0 2h18a1 1 0 0 0 0-2"})}),ah=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:"M19 11h-6V5a1 1 0 0 0-2 0v6H5a1 1 0 0 0 0 2h6v6a1 1 0 0 0 2 0v-6h6a1 1 0 0 0 0-2"})}),nh=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:"M21 8.94a1.3 1.3 0 0 0-.06-.27v-.09a1 1 0 0 0-.19-.28l-6-6a1 1 0 0 0-.28-.19a.3.3 0 0 0-.09 0a.9.9 0 0 0-.33-.11H10a3 3 0 0 0-3 3v1H6a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-1h1a3 3 0 0 0 3-3zm-6-3.53L17.59 8H16a1 1 0 0 1-1-1ZM15 19a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h1v7a3 3 0 0 0 3 3h5Zm4-4a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3v3a3 3 0 0 0 3 3h3Z"})}),rh=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:"M21 11a1 1 0 0 0-1 1a8.05 8.05 0 1 1-2.22-5.5h-2.4a1 1 0 0 0 0 2h4.53a1 1 0 0 0 1-1V3a1 1 0 0 0-2 0v1.77A10 10 0 1 0 22 12a1 1 0 0 0-1-1"})}),lh=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:"M9.5 10.5H12a1 1 0 0 0 0-2h-1V8a1 1 0 0 0-2 0v.55a2.5 2.5 0 0 0 .5 4.95h1a.5.5 0 0 1 0 1H8a1 1 0 0 0 0 2h1v.5a1 1 0 0 0 2 0v-.55a2.5 2.5 0 0 0-.5-4.95h-1a.5.5 0 0 1 0-1M21 12h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Z"})}),oh=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:"M12.3 12.22A4.92 4.92 0 0 0 14 8.5a5 5 0 0 0-10 0a4.92 4.92 0 0 0 1.7 3.72A8 8 0 0 0 1 19.5a1 1 0 0 0 2 0a6 6 0 0 1 12 0a1 1 0 0 0 2 0a8 8 0 0 0-4.7-7.28M9 11.5a3 3 0 1 1 3-3a3 3 0 0 1-3 3m9.74.32A5 5 0 0 0 15 3.5a1 1 0 0 0 0 2a3 3 0 0 1 3 3a3 3 0 0 1-1.5 2.59a1 1 0 0 0-.5.84a1 1 0 0 0 .45.86l.39.26l.13.07a7 7 0 0 1 4 6.38a1 1 0 0 0 2 0a9 9 0 0 0-4.23-7.68"})}),ih=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:"M12 2a10 10 0 0 0-6.88 2.77V3a1 1 0 0 0-2 0v4.5a1 1 0 0 0 1 1h4.5a1 1 0 0 0 0-2h-2.4A8 8 0 1 1 4 12a1 1 0 0 0-2 0A10 10 0 1 0 12 2m0 6a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 0-2h-1V9a1 1 0 0 0-1-1"})}),ch=(s,n)=>{const{t:a}=I("user");return[{accessorKey:"is_admin",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r)),size:0},{accessorKey:"is_staff",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r)),size:0},{accessorKey:"id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.id")}),cell:({row:l})=>e.jsx(K,{variant:"outline",children:l.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.email")}),cell:({row:l})=>{const r=l.original.t||0,c=Date.now()/1e3-r<120,i=Math.floor(Date.now()/1e3-r);let u=c?a("columns.online_status.online"):r===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:xe(r)});if(!c&&r!==0){const x=Math.floor(i/60),o=Math.floor(x/60),d=Math.floor(o/24);d>0?u+=` `+a("columns.online_status.offline_duration.days",{count:d}):o>0?u+=` `+a("columns.online_status.offline_duration.hours",{count:o}):x>0?u+=` `+a("columns.online_status.offline_duration.minutes",{count:x}):u+=` -`+a("columns.online_status.offline_duration.seconds",{count:i})}return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:_("size-2.5 rounded-full ring-2 ring-offset-2",c?"bg-green-500 ring-green-500/20":"bg-gray-300 ring-gray-300/20","transition-all duration-300")}),e.jsx("span",{className:"font-medium text-foreground/90",children:l.original.email})]})}),e.jsx(te,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:u})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.online_count")}),cell:({row:l})=>{const r=l.original.device_limit,c=l.original.online_count||0;return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:_("min-w-[4rem] justify-center",r!==null&&c>=r?"border-destructive/50 bg-destructive/10 text-destructive":"border-primary/40 bg-primary/5 text-primary/90"),children:[c," / ",r===null?"∞":r]})})}),e.jsx(te,{side:"bottom",children:e.jsx("p",{className:"text-sm",children:r===null?a("columns.device_limit.unlimited"):a("columns.device_limit.limited",{count:r})})})]})})},enableSorting:!0,enableHiding:!1},{accessorKey:"banned",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.status")}),cell:({row:l})=>{const r=l.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(K,{className:_("min-w-20 justify-center transition-colors",r?"bg-destructive/15 text-destructive hover:bg-destructive/25":"bg-success/15 text-success hover:bg-success/25"),children:a(r?"columns.status_text.banned":"columns.status_text.normal")})})},enableSorting:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r))},{accessorKey:"plan_id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.subscription")}),cell:({row:l})=>e.jsx("div",{className:"min-w-[10em] break-all",children:l.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.group")}),cell:({row:l})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(K,{variant:"outline",className:_("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 whitespace-nowrap"),children:l.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.used_traffic")}),cell:({row:l})=>{const r=ss(l.original?.total_used),c=ss(l.original?.transfer_enable),i=l.original?.total_used/l.original?.transfer_enable*100||0;return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{className:"w-full",children:e.jsxs("div",{className:"w-full space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:r}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:_("h-full rounded-full transition-all",i>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(i,100)}%`}})})]})}),e.jsx(te,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",c]})})]})})}},{accessorKey:"transfer_enable",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.total_traffic")}),cell:({row:l})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:ss(l.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.expire_time")}),cell:({row:l})=>{const r=l.original.expired_at,c=Date.now()/1e3,i=r!=null&&re.jsx(O,{column:l,title:a("columns.balance")}),cell:({row:l})=>{const r=qs(l.original?.balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:r})]})}},{accessorKey:"commission_balance",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.commission")}),cell:({row:l})=>{const r=qs(l.original?.commission_balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:r})]})}},{accessorKey:"created_at",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.register_time")}),cell:({row:l})=>e.jsx("div",{className:"truncate",children:xe(l.original?.created_at)}),size:1e3},{id:"actions",header:({column:l})=>e.jsx(O,{column:l,className:"justify-end",title:a("columns.actions")}),cell:({row:l,table:r})=>e.jsxs(_s,{modal:!0,children:[e.jsx(ws,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(J,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(wt,{className:"size-4"})})})}),e.jsxs(ds,{align:"end",className:"min-w-[40px]",children:[e.jsx(je,{onSelect:c=>{c.preventDefault()},className:"p-0",children:e.jsx(Zr,{defaultValues:{...l.original,invite_user_email:l.original.invite_user?.email},refetch:s,dialogTrigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(sh,{className:"mr-2"}),a("columns.actions_menu.edit")]})})}),e.jsx(je,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(Hr,{defaultValues:{email:l.original.email},trigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(th,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(je,{onSelect:()=>{St(l.original.subscribe_url).then(()=>{q.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(ah,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(je,{onSelect:()=>{kd({id:l.original.id}).then(({data:c})=>{c&&q.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(nh,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(je,{onSelect:()=>{},className:"p-0",children:e.jsxs(Vs,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=${l.original?.id}`,children:[e.jsx(rh,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(je,{onSelect:()=>{r.setColumnFilters([{id:"invite_user_id",value:l.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(lh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(je,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(sl,{user_id:l.original?.id,dialogTrigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(oh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})})]})]})}]};function ch(){const[s]=Qn(),[n,a]=m.useState({}),[l,r]=m.useState({is_admin:!1,is_staff:!1}),[c,i]=m.useState([]),[u,x]=m.useState([]),[o,d]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const P=s.get("email");P&&i(z=>z.some($=>$.id==="email")?z:[...z,{id:"email",value:P}])},[s]);const{refetch:p,data:T,isLoading:R}=se({queryKey:["userList",o,c,u],queryFn:()=>Cd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:u})}),[f,g]=m.useState([]),[S,j]=m.useState([]);m.useEffect(()=>{Mt().then(({data:P})=>{g(P)}),Os().then(({data:P})=>{j(P)})},[]);const C=f.map(P=>({label:P.name,value:P.id})),k=S.map(P=>({label:P.name,value:P.id})),v=Ke({data:T?.data??[],columns:ih(p),state:{sorting:u,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:o},rowCount:T?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),onPaginationChange:d,getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnVisibility:{commission_balance:!1,created_at:!1,is_admin:!1,is_staff:!1,permission_group:!1,plan_id:!1},columnPinning:{right:["actions"]}}});return e.jsx(es,{table:v,toolbar:e.jsx(Wx,{table:v,refetch:p,serverGroupList:f,permissionGroups:C,subscriptionPlans:k})})}function dh(){const{t:s}=I("user");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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:"mt-2 text-muted-foreground",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("div",{className:"w-full",children:e.jsx(ch,{})})})]})]})}const mh=Object.freeze(Object.defineProperty({__proto__:null,default:dh},Symbol.toStringTag,{value:"Module"}));function uh({column:s,title:n,options:a}){const l=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(J,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Ii,{className:"mr-2 h-4 w-4"}),n,l?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:l.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:l.size>2?e.jsxs(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[l.size," selected"]}):a.filter(r=>l.has(r.value)).map(r=>e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:r.label},`selected-${r.value}`))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(r=>{const c=l.has(r.value);return e.jsxs(ke,{onSelect:()=>{c?l.delete(r.value):l.add(r.value);const i=Array.from(l);s?.setFilterValue(i.length?i:void 0)},children:[e.jsx("div",{className:_("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",c?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Fi,{className:_("h-4 w-4")})}),r.icon&&e.jsx(r.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:r.label})]},`option-${r.value}`)})}),l.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const xh=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:"M19 11H5a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})});function hh({table:s}){const{t:n}=I("ticket");return e.jsx("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-4",children:[e.jsx(ha,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:a=>s.getColumn("status")?.setFilterValue(a),children:e.jsxs(Ot,{className:"grid w-full grid-cols-2",children:[e.jsx(Ns,{value:"0",children:n("status.pending")}),e.jsx(Ns,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(uh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:ts.LOW,icon:xh,color:"gray"},{label:n("level.medium"),value:ts.MIDDLE,icon:Xr,color:"yellow"},{label:n("level.high"),value:ts.HIGH,icon:el,color:"red"}]})]})})}function fh(){return e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[e.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}const ph=Es("flex gap-2 max-w-[60%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),tl=m.forwardRef(({className:s,variant:n,layout:a,children:l,...r},c)=>e.jsx("div",{className:_(ph({variant:n,layout:a,className:s}),"relative group"),ref:c,...r,children:m.Children.map(l,i=>m.isValidElement(i)&&typeof i.type!="string"?m.cloneElement(i,{variant:n,layout:a}):i)}));tl.displayName="ChatBubble";const gh=Es("p-4",{variants:{variant:{received:"bg-secondary text-secondary-foreground rounded-r-lg rounded-tl-lg",sent:"bg-primary text-primary-foreground rounded-l-lg rounded-tr-lg"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),al=m.forwardRef(({className:s,variant:n,layout:a,isLoading:l=!1,children:r,...c},i)=>e.jsx("div",{className:_(gh({variant:n,layout:a,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:i,...c,children:l?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(fh,{})}):r}));al.displayName="ChatBubbleMessage";const jh=m.forwardRef(({variant:s,className:n,children:a,...l},r)=>e.jsx("div",{ref:r,className:_("absolute top-1/2 -translate-y-1/2 flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",s==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",n),...l,children:a}));jh.displayName="ChatBubbleActionWrapper";const nl=m.forwardRef(({className:s,...n},a)=>e.jsx(ps,{autoComplete:"off",ref:a,name:"message",className:_("max-h-12 px-4 py-3 bg-background text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-md flex items-center h-16 resize-none",s),...n}));nl.displayName="ChatInput";const rl=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:"m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"})}),ll=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.098 12.634L13 11.423V7a1 1 0 0 0-2 0v5a1 1 0 0 0 .5.866l2.598 1.5a1 1 0 1 0 1-1.732M12 2a10 10 0 1 0 10 10A10.01 10.01 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8.01 8.01 0 0 1-8 8"})}),vh=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:"M3.71 16.29a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21a1 1 0 0 0-.21.33a1 1 0 0 0 .21 1.09a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1 1 0 0 0 .21-1.09a1 1 0 0 0-.21-.33M7 8h14a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m-3.29 3.29a1 1 0 0 0-1.09-.21a1.2 1.2 0 0 0-.33.21a1 1 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1 1 0 0 0-.21-.33M21 11H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2M3.71 6.29a1 1 0 0 0-.33-.21a1 1 0 0 0-1.09.21a1.2 1.2 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a1 1 0 0 0 1.09-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1.2 1.2 0 0 0-.21-.33M21 16H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})}),bh=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:"M9 12H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m-1-2h4a1 1 0 0 0 0-2H8a1 1 0 0 0 0 2m1 6H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m12-4h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Zm-6.44-2.83a.8.8 0 0 0-.18-.09a.6.6 0 0 0-.19-.06a1 1 0 0 0-.9.27A1.05 1.05 0 0 0 12 17a1 1 0 0 0 .07.38a1.2 1.2 0 0 0 .22.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21A1 1 0 0 0 14 17a1.05 1.05 0 0 0-.29-.71a2 2 0 0 0-.15-.12m.14-3.88a1 1 0 0 0-1.62.33A1 1 0 0 0 13 14a1 1 0 0 0 1-1a1 1 0 0 0-.08-.38a.9.9 0 0 0-.22-.33"})});function yh(){return e.jsxs("div",{className:"flex h-full flex-col space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"h-8 w-3/4"}),e.jsx(le,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(le,{className:"h-20 w-2/3"},s))})]})}function Nh({ticketId:s,dialogTrigger:n}){const{t:a}=I("ticket"),l=ms(),r=m.useRef(null),[c,i]=m.useState(!1),[u,x]=m.useState(""),[o,d]=m.useState(!1),{data:p,refetch:T,isLoading:R}=se({queryKey:["ticket",s,c],queryFn:()=>c?Ed(s):Promise.resolve(null),refetchInterval:c?5e3:!1,retry:3}),f=p?.data,g=(v="smooth")=>{if(r.current){const{scrollHeight:P,clientHeight:z}=r.current;r.current.scrollTo({top:P-z,behavior:v})}};m.useEffect(()=>{if(!c)return;const v=requestAnimationFrame(()=>{g("instant"),setTimeout(()=>g(),1e3)});return()=>{cancelAnimationFrame(v)}},[c,f?.messages]);const S=async()=>{const v=u.trim();!v||o||(d(!0),Rd({id:s,message:v}).then(()=>{x(""),T(),g()}).finally(()=>{d(!1)}))},j=async()=>{Nr(s).then(()=>{q.success(a("actions.close_success")),T()})},C=()=>{f?.user&&l("/finance/order?user_id="+f.user.id)},k=f?.status===at.CLOSED;return e.jsxs(pe,{open:c,onOpenChange:i,children:[e.jsx(ze,{asChild:!0,children:n??e.jsx(J,{variant:"outline",children:a("actions.view_ticket")})}),e.jsxs(he,{className:"flex h-[90vh] max-w-4xl flex-col gap-0 p-0",children:[e.jsx(ge,{}),R?e.jsx(yh,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col space-y-4 border-b p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:f?.subject}),e.jsx(K,{variant:k?"secondary":"default",children:a(k?"status.closed":"status.processing")}),!k&&e.jsx(Ue,{title:a("actions.close_confirm_title"),description:a("actions.close_confirm_description"),confirmText:a("actions.close_confirm_button"),variant:"destructive",onConfirm:j,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(rl,{className:"h-4 w-4"}),a("actions.close_ticket")]})})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{children:f?.user?.email})]}),e.jsx(ye,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsxs("span",{children:[a("detail.created_at")," ",xe(f?.created_at)]})]}),e.jsx(ye,{orientation:"vertical",className:"h-4"}),e.jsx(K,{variant:"outline",children:f?.level!=null&&a(`level.${f.level===ts.LOW?"low":f.level===ts.MIDDLE?"medium":"high"}`)})]})]}),f?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(Zr,{defaultValues:f.user,refetch:T,dialogTrigger:e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.user_info"),children:e.jsx(it,{className:"h-4 w-4"})})}),e.jsx(sl,{user_id:f.user.id,dialogTrigger:e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.traffic_records"),children:e.jsx(vh,{className:"h-4 w-4"})})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.order_records"),onClick:C,children:e.jsx(bh,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{ref:r,className:"h-full space-y-4 overflow-y-auto p-6",children:f?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a("detail.no_messages")}):f?.messages?.map(v=>e.jsx(tl,{variant:v.is_me?"sent":"received",className:v.is_me?"ml-auto":"mr-auto",children:e.jsx(al,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:v.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:xe(v.created_at)})})]})})},v.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(nl,{disabled:k||o,placeholder:a(k?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:u,onChange:v=>x(v.target.value),onKeyDown:v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),S())}}),e.jsx(J,{disabled:k||o||!u.trim(),onClick:S,children:a(o?"detail.input.sending":"detail.input.send")})]})})]})]})]})}const _h=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:"M19 4H5a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3V7a3 3 0 0 0-3-3m-.41 2l-5.88 5.88a1 1 0 0 1-1.42 0L5.41 6ZM20 17a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7.41l5.88 5.88a3 3 0 0 0 4.24 0L20 7.41Z"})}),wh=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:"M21.92 11.6C19.9 6.91 16.1 4 12 4s-7.9 2.91-9.92 7.6a1 1 0 0 0 0 .8C4.1 17.09 7.9 20 12 20s7.9-2.91 9.92-7.6a1 1 0 0 0 0-.8M12 18c-3.17 0-6.17-2.29-7.9-6C5.83 8.29 8.83 6 12 6s6.17 2.29 7.9 6c-1.73 3.71-4.73 6-7.9 6m0-10a4 4 0 1 0 4 4a4 4 0 0 0-4-4m0 6a2 2 0 1 1 2-2a2 2 0 0 1-2 2"})}),Ch=s=>{const{t:n}=I("ticket");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:a.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.subject")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(_h,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[500px] truncate font-medium",children:a.getValue("subject")})]}),enableSorting:!1,enableHiding:!1,size:4e3},{accessorKey:"level",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.level")}),cell:({row:a})=>{const l=a.getValue("level"),r=l===ts.LOW?"default":l===ts.MIDDLE?"secondary":"destructive";return e.jsx(K,{variant:r,className:"whitespace-nowrap",children:n(`level.${l===ts.LOW?"low":l===ts.MIDDLE?"medium":"high"}`)})},filterFn:(a,l,r)=>r.includes(a.getValue(l))},{accessorKey:"status",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.status")}),cell:({row:a})=>{const l=a.getValue("status"),r=a.original.reply_status,c=l===at.CLOSED?n("status.closed"):n(r===0?"status.replied":"status.pending"),i=l===at.CLOSED?"default":r===0?"secondary":"destructive";return e.jsx(K,{variant:i,className:"whitespace-nowrap",children:c})}},{accessorKey:"updated_at",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.updated_at")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:xe(a.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.created_at")}),cell:({row:a})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:xe(a.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const l=a.original.status!==at.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Nh,{ticketId:a.original.id,dialogTrigger:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(wh,{className:"h-4 w-4"})})}),l&&e.jsx(Ue,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{Nr(a.original.id).then(()=>{q.success(n("actions.close_success")),s()})},children:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(rl,{className:"h-4 w-4"})})})]})}}]};function Sh(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([{id:"status",value:"0"}]),[i,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:d,data:p,isLoading:T}=se({queryKey:["orderList",x,r,i],queryFn:()=>Dd({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),R=Ke({data:p?.data??[],columns:Ch(d),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:x},rowCount:p?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),onPaginationChange:o,getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(hh,{table:R,refetch:d}),e.jsx(es,{table:R,showPagination:!0})]})}function kh(){const{t:s}=I("ticket");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Pe,{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(Sh,{})})]})]})}const Ph=Object.freeze(Object.defineProperty({__proto__:null,default:kh},Symbol.toStringTag,{value:"Module"}));export{Vh as a,Eh as c,Rh as g,Ih as r}; +`+a("columns.online_status.offline_duration.seconds",{count:i})}return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:_("size-2.5 rounded-full ring-2 ring-offset-2",c?"bg-green-500 ring-green-500/20":"bg-gray-300 ring-gray-300/20","transition-all duration-300")}),e.jsx("span",{className:"font-medium text-foreground/90",children:l.original.email})]})}),e.jsx(te,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:u})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.online_count")}),cell:({row:l})=>{const r=l.original.device_limit,c=l.original.online_count||0;return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:_("min-w-[4rem] justify-center",r!==null&&c>=r?"border-destructive/50 bg-destructive/10 text-destructive":"border-primary/40 bg-primary/5 text-primary/90"),children:[c," / ",r===null?"∞":r]})})}),e.jsx(te,{side:"bottom",children:e.jsx("p",{className:"text-sm",children:r===null?a("columns.device_limit.unlimited"):a("columns.device_limit.limited",{count:r})})})]})})},enableSorting:!0,enableHiding:!1},{accessorKey:"banned",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.status")}),cell:({row:l})=>{const r=l.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(K,{className:_("min-w-20 justify-center transition-colors",r?"bg-destructive/15 text-destructive hover:bg-destructive/25":"bg-success/15 text-success hover:bg-success/25"),children:a(r?"columns.status_text.banned":"columns.status_text.normal")})})},enableSorting:!0,filterFn:(l,r,c)=>c.includes(l.getValue(r))},{accessorKey:"plan_id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.subscription")}),cell:({row:l})=>e.jsx("div",{className:"min-w-[10em] break-all",children:l.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.group")}),cell:({row:l})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(K,{variant:"outline",className:_("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 whitespace-nowrap"),children:l.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.used_traffic")}),cell:({row:l})=>{const r=ss(l.original?.total_used),c=ss(l.original?.transfer_enable),i=l.original?.total_used/l.original?.transfer_enable*100||0;return e.jsx(ce,{delayDuration:100,children:e.jsxs(oe,{children:[e.jsx(ie,{className:"w-full",children:e.jsxs("div",{className:"w-full space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:r}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:_("h-full rounded-full transition-all",i>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(i,100)}%`}})})]})}),e.jsx(te,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",c]})})]})})}},{accessorKey:"transfer_enable",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.total_traffic")}),cell:({row:l})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:ss(l.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.expire_time")}),cell:({row:l})=>{const r=l.original.expired_at,c=Date.now()/1e3,i=r!=null&&re.jsx(O,{column:l,title:a("columns.balance")}),cell:({row:l})=>{const r=qs(l.original?.balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:r})]})}},{accessorKey:"commission_balance",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.commission")}),cell:({row:l})=>{const r=qs(l.original?.commission_balance);return e.jsxs("div",{className:"flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"¥"}),e.jsx("span",{className:"tabular-nums text-foreground",children:r})]})}},{accessorKey:"created_at",header:({column:l})=>e.jsx(O,{column:l,title:a("columns.register_time")}),cell:({row:l})=>e.jsx("div",{className:"truncate",children:xe(l.original?.created_at)}),size:1e3},{id:"actions",header:({column:l})=>e.jsx(O,{column:l,className:"justify-end",title:a("columns.actions")}),cell:({row:l,table:r})=>e.jsxs(_s,{modal:!0,children:[e.jsx(ws,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(J,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Ct,{className:"size-4"})})})}),e.jsxs(ds,{align:"end",className:"min-w-[40px]",children:[e.jsx(ge,{onSelect:c=>{c.preventDefault()},className:"p-0",children:e.jsx(Xr,{defaultValues:{...l.original,invite_user_email:l.original.invite_user?.email},refetch:s,dialogTrigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(th,{className:"mr-2"}),a("columns.actions_menu.edit")]})})}),e.jsx(ge,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(Ur,{defaultValues:{email:l.original.email},trigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(ah,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(ge,{onSelect:()=>{kt(l.original.subscribe_url).then(()=>{q.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(nh,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(ge,{onSelect:()=>{Td({id:l.original.id}).then(({data:c})=>{c&&q.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(rh,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(ge,{onSelect:()=>{},className:"p-0",children:e.jsxs(Vs,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=${l.original?.id}`,children:[e.jsx(lh,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(ge,{onSelect:()=>{r.setColumnFilters([{id:"invite_user_id",value:l.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(oh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(ge,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(tl,{user_id:l.original?.id,dialogTrigger:e.jsxs(J,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(ih,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})})]})]})}]};function dh(){const[s]=Zn(),[n,a]=m.useState({}),[l,r]=m.useState({is_admin:!1,is_staff:!1}),[c,i]=m.useState([]),[u,x]=m.useState([]),[o,d]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const T=s.get("email");T&&i(z=>z.some($=>$.id==="email")?z:[...z,{id:"email",value:T}])},[s]);const{refetch:p,data:P,isLoading:R}=se({queryKey:["userList",o,c,u],queryFn:()=>Sd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:u})}),[f,g]=m.useState([]),[S,j]=m.useState([]);m.useEffect(()=>{Ot().then(({data:T})=>{g(T)}),Os().then(({data:T})=>{j(T)})},[]);const C=f.map(T=>({label:T.name,value:T.id})),k=S.map(T=>({label:T.name,value:T.id})),v=Ke({data:P?.data??[],columns:ch(p),state:{sorting:u,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:o},rowCount:P?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),onPaginationChange:d,getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnVisibility:{commission_balance:!1,created_at:!1,is_admin:!1,is_staff:!1,permission_group:!1,plan_id:!1},columnPinning:{right:["actions"]}}});return e.jsx(es,{table:v,toolbar:e.jsx(Wx,{table:v,refetch:p,serverGroupList:f,permissionGroups:C,subscriptionPlans:k})})}function mh(){const{t:s}=I("user");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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:"mt-2 text-muted-foreground",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("div",{className:"w-full",children:e.jsx(dh,{})})})]})]})}const uh=Object.freeze(Object.defineProperty({__proto__:null,default:mh},Symbol.toStringTag,{value:"Module"}));function xh({column:s,title:n,options:a}){const l=new Set(s?.getFilterValue());return e.jsxs(rs,{children:[e.jsx(ls,{asChild:!0,children:e.jsxs(J,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Fi,{className:"mr-2 h-4 w-4"}),n,l?.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:l.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:l.size>2?e.jsxs(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[l.size," selected"]}):a.filter(r=>l.has(r.value)).map(r=>e.jsx(K,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:r.label},`selected-${r.value}`))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Cs,{children:[e.jsx(Fs,{placeholder:n}),e.jsxs(Ss,{children:[e.jsx(Ms,{children:"No results found."}),e.jsx(Oe,{children:a.map(r=>{const c=l.has(r.value);return e.jsxs(ke,{onSelect:()=>{c?l.delete(r.value):l.add(r.value);const i=Array.from(l);s?.setFilterValue(i.length?i:void 0)},children:[e.jsx("div",{className:_("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",c?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Mi,{className:_("h-4 w-4")})}),r.icon&&e.jsx(r.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:r.label})]},`option-${r.value}`)})}),l.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Gs,{}),e.jsx(Oe,{children:e.jsx(ke,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const hh=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:"M19 11H5a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})});function fh({table:s}){const{t:n}=I("ticket");return e.jsx("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-4",children:[e.jsx(fa,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:a=>s.getColumn("status")?.setFilterValue(a),children:e.jsxs(zt,{className:"grid w-full grid-cols-2",children:[e.jsx(Ns,{value:"0",children:n("status.pending")}),e.jsx(Ns,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(xh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:ts.LOW,icon:hh,color:"gray"},{label:n("level.medium"),value:ts.MIDDLE,icon:el,color:"yellow"},{label:n("level.high"),value:ts.HIGH,icon:sl,color:"red"}]})]})})}function ph(){return e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[e.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),e.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:e.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}const gh=Es("flex gap-2 max-w-[60%] items-end relative group",{variants:{variant:{received:"self-start",sent:"self-end flex-row-reverse"},layout:{default:"",ai:"max-w-full w-full items-center"}},defaultVariants:{variant:"received",layout:"default"}}),al=m.forwardRef(({className:s,variant:n,layout:a,children:l,...r},c)=>e.jsx("div",{className:_(gh({variant:n,layout:a,className:s}),"relative group"),ref:c,...r,children:m.Children.map(l,i=>m.isValidElement(i)&&typeof i.type!="string"?m.cloneElement(i,{variant:n,layout:a}):i)}));al.displayName="ChatBubble";const jh=Es("p-4",{variants:{variant:{received:"bg-secondary text-secondary-foreground rounded-r-lg rounded-tl-lg",sent:"bg-primary text-primary-foreground rounded-l-lg rounded-tr-lg"},layout:{default:"",ai:"border-t w-full rounded-none bg-transparent"}},defaultVariants:{variant:"received",layout:"default"}}),nl=m.forwardRef(({className:s,variant:n,layout:a,isLoading:l=!1,children:r,...c},i)=>e.jsx("div",{className:_(jh({variant:n,layout:a,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:i,...c,children:l?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(ph,{})}):r}));nl.displayName="ChatBubbleMessage";const vh=m.forwardRef(({variant:s,className:n,children:a,...l},r)=>e.jsx("div",{ref:r,className:_("absolute top-1/2 -translate-y-1/2 flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",s==="sent"?"-left-1 -translate-x-full flex-row-reverse":"-right-1 translate-x-full",n),...l,children:a}));vh.displayName="ChatBubbleActionWrapper";const rl=m.forwardRef(({className:s,...n},a)=>e.jsx(ps,{autoComplete:"off",ref:a,name:"message",className:_("max-h-12 px-4 py-3 bg-background text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-md flex items-center h-16 resize-none",s),...n}));rl.displayName="ChatInput";const ll=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:"m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"})}),ol=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.098 12.634L13 11.423V7a1 1 0 0 0-2 0v5a1 1 0 0 0 .5.866l2.598 1.5a1 1 0 1 0 1-1.732M12 2a10 10 0 1 0 10 10A10.01 10.01 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8.01 8.01 0 0 1-8 8"})}),bh=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:"M3.71 16.29a1 1 0 0 0-.33-.21a1 1 0 0 0-.76 0a1 1 0 0 0-.33.21a1 1 0 0 0-.21.33a1 1 0 0 0 .21 1.09a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1 1 0 0 0 .21-1.09a1 1 0 0 0-.21-.33M7 8h14a1 1 0 0 0 0-2H7a1 1 0 0 0 0 2m-3.29 3.29a1 1 0 0 0-1.09-.21a1.2 1.2 0 0 0-.33.21a1 1 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1 1 0 0 0-.21-.33M21 11H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2M3.71 6.29a1 1 0 0 0-.33-.21a1 1 0 0 0-1.09.21a1.2 1.2 0 0 0-.21.33a.94.94 0 0 0 0 .76a1.2 1.2 0 0 0 .21.33a1.2 1.2 0 0 0 .33.21a1 1 0 0 0 1.09-.21a1.2 1.2 0 0 0 .21-.33a.94.94 0 0 0 0-.76a1.2 1.2 0 0 0-.21-.33M21 16H7a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2"})}),yh=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:"M9 12H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m-1-2h4a1 1 0 0 0 0-2H8a1 1 0 0 0 0 2m1 6H7a1 1 0 0 0 0 2h2a1 1 0 0 0 0-2m12-4h-3V3a1 1 0 0 0-.5-.87a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0l-3 1.72l-3-1.72a1 1 0 0 0-1 0A1 1 0 0 0 2 3v16a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3v-6a1 1 0 0 0-1-1M5 20a1 1 0 0 1-1-1V4.73l2 1.14a1.08 1.08 0 0 0 1 0l3-1.72l3 1.72a1.08 1.08 0 0 0 1 0l2-1.14V19a3 3 0 0 0 .18 1Zm15-1a1 1 0 0 1-2 0v-5h2Zm-6.44-2.83a.8.8 0 0 0-.18-.09a.6.6 0 0 0-.19-.06a1 1 0 0 0-.9.27A1.05 1.05 0 0 0 12 17a1 1 0 0 0 .07.38a1.2 1.2 0 0 0 .22.33a1.2 1.2 0 0 0 .33.21a.94.94 0 0 0 .76 0a1.2 1.2 0 0 0 .33-.21A1 1 0 0 0 14 17a1.05 1.05 0 0 0-.29-.71a2 2 0 0 0-.15-.12m.14-3.88a1 1 0 0 0-1.62.33A1 1 0 0 0 13 14a1 1 0 0 0 1-1a1 1 0 0 0-.08-.38a.9.9 0 0 0-.22-.33"})});function Nh(){return e.jsxs("div",{className:"flex h-full flex-col space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{className:"h-8 w-3/4"}),e.jsx(le,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(le,{className:"h-20 w-2/3"},s))})]})}function _h({ticketId:s,dialogTrigger:n}){const{t:a}=I("ticket"),l=ms(),r=m.useRef(null),[c,i]=m.useState(!1),[u,x]=m.useState(""),[o,d]=m.useState(!1),{data:p,refetch:P,isLoading:R}=se({queryKey:["ticket",s,c],queryFn:()=>c?Rd(s):Promise.resolve(null),refetchInterval:c?5e3:!1,retry:3}),f=p?.data,g=(v="smooth")=>{if(r.current){const{scrollHeight:T,clientHeight:z}=r.current;r.current.scrollTo({top:T-z,behavior:v})}};m.useEffect(()=>{if(!c)return;const v=requestAnimationFrame(()=>{g("instant"),setTimeout(()=>g(),1e3)});return()=>{cancelAnimationFrame(v)}},[c,f?.messages]);const S=async()=>{const v=u.trim();!v||o||(d(!0),Vd({id:s,message:v}).then(()=>{x(""),P(),g()}).finally(()=>{d(!1)}))},j=async()=>{_r(s).then(()=>{q.success(a("actions.close_success")),P()})},C=()=>{f?.user&&l("/finance/order?user_id="+f.user.id)},k=f?.status===at.CLOSED;return e.jsxs(fe,{open:c,onOpenChange:i,children:[e.jsx(ze,{asChild:!0,children:n??e.jsx(J,{variant:"outline",children:a("actions.view_ticket")})}),e.jsxs(he,{className:"flex h-[90vh] max-w-4xl flex-col gap-0 p-0",children:[e.jsx(pe,{}),R?e.jsx(Nh,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col space-y-4 border-b p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h2",{className:"text-2xl font-semibold",children:f?.subject}),e.jsx(K,{variant:k?"secondary":"default",children:a(k?"status.closed":"status.processing")}),!k&&e.jsx(Ue,{title:a("actions.close_confirm_title"),description:a("actions.close_confirm_description"),confirmText:a("actions.close_confirm_button"),variant:"destructive",onConfirm:j,children:e.jsxs(J,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(ll,{className:"h-4 w-4"}),a("actions.close_ticket")]})})]}),e.jsxs("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(ct,{className:"h-4 w-4"}),e.jsx("span",{children:f?.user?.email})]}),e.jsx(be,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(ol,{className:"h-4 w-4"}),e.jsxs("span",{children:[a("detail.created_at")," ",xe(f?.created_at)]})]}),e.jsx(be,{orientation:"vertical",className:"h-4"}),e.jsx(K,{variant:"outline",children:f?.level!=null&&a(`level.${f.level===ts.LOW?"low":f.level===ts.MIDDLE?"medium":"high"}`)})]})]}),f?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(Xr,{defaultValues:f.user,refetch:P,dialogTrigger:e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.user_info"),children:e.jsx(ct,{className:"h-4 w-4"})})}),e.jsx(tl,{user_id:f.user.id,dialogTrigger:e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.traffic_records"),children:e.jsx(bh,{className:"h-4 w-4"})})}),e.jsx(J,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.order_records"),onClick:C,children:e.jsx(yh,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{ref:r,className:"h-full space-y-4 overflow-y-auto p-6",children:f?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a("detail.no_messages")}):f?.messages?.map(v=>e.jsx(al,{variant:v.is_me?"sent":"received",className:v.is_me?"ml-auto":"mr-auto",children:e.jsx(nl,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:v.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:xe(v.created_at)})})]})})},v.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(rl,{disabled:k||o,placeholder:a(k?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:u,onChange:v=>x(v.target.value),onKeyDown:v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),S())}}),e.jsx(J,{disabled:k||o||!u.trim(),onClick:S,children:a(o?"detail.input.sending":"detail.input.send")})]})})]})]})]})}const wh=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:"M19 4H5a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h14a3 3 0 0 0 3-3V7a3 3 0 0 0-3-3m-.41 2l-5.88 5.88a1 1 0 0 1-1.42 0L5.41 6ZM20 17a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7.41l5.88 5.88a3 3 0 0 0 4.24 0L20 7.41Z"})}),Ch=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:"M21.92 11.6C19.9 6.91 16.1 4 12 4s-7.9 2.91-9.92 7.6a1 1 0 0 0 0 .8C4.1 17.09 7.9 20 12 20s7.9-2.91 9.92-7.6a1 1 0 0 0 0-.8M12 18c-3.17 0-6.17-2.29-7.9-6C5.83 8.29 8.83 6 12 6s6.17 2.29 7.9 6c-1.73 3.71-4.73 6-7.9 6m0-10a4 4 0 1 0 4 4a4 4 0 0 0-4-4m0 6a2 2 0 1 1 2-2a2 2 0 0 1-2 2"})}),Sh=s=>{const{t:n}=I("ticket");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx(K,{variant:"outline",children:a.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.subject")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(wh,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[500px] truncate font-medium",children:a.getValue("subject")})]}),enableSorting:!1,enableHiding:!1,size:4e3},{accessorKey:"level",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.level")}),cell:({row:a})=>{const l=a.getValue("level"),r=l===ts.LOW?"default":l===ts.MIDDLE?"secondary":"destructive";return e.jsx(K,{variant:r,className:"whitespace-nowrap",children:n(`level.${l===ts.LOW?"low":l===ts.MIDDLE?"medium":"high"}`)})},filterFn:(a,l,r)=>r.includes(a.getValue(l))},{accessorKey:"status",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.status")}),cell:({row:a})=>{const l=a.getValue("status"),r=a.original.reply_status,c=l===at.CLOSED?n("status.closed"):n(r===0?"status.replied":"status.pending"),i=l===at.CLOSED?"default":r===0?"secondary":"destructive";return e.jsx(K,{variant:i,className:"whitespace-nowrap",children:c})}},{accessorKey:"updated_at",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.updated_at")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[e.jsx(ol,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:xe(a.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.created_at")}),cell:({row:a})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:xe(a.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:a})=>e.jsx(O,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const l=a.original.status!==at.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(_h,{ticketId:a.original.id,dialogTrigger:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(Ch,{className:"h-4 w-4"})})}),l&&e.jsx(Ue,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{_r(a.original.id).then(()=>{q.success(n("actions.close_success")),s()})},children:e.jsx(J,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(ll,{className:"h-4 w-4"})})})]})}}]};function kh(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([{id:"status",value:"0"}]),[i,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20}),{refetch:d,data:p,isLoading:P}=se({queryKey:["orderList",x,r,i],queryFn:()=>Ed({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),R=Ke({data:p?.data??[],columns:Sh(d),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:x},rowCount:p?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:He(),getFilteredRowModel:Je(),getPaginationRowModel:Qe(),onPaginationChange:o,getSortedRowModel:Ze(),getFacetedRowModel:us(),getFacetedUniqueValues:xs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fh,{table:R,refetch:d}),e.jsx(es,{table:R,showPagination:!0})]})}function Th(){const{t:s}=I("ticket");return e.jsxs(we,{children:[e.jsxs(Ce,{children:[e.jsx(Ie,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ee,{}),e.jsx(Re,{})]})]}),e.jsxs(Te,{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(kh,{})})]})]})}const Ph=Object.freeze(Object.defineProperty({__proto__:null,default:Th},Symbol.toStringTag,{value:"Module"}));export{Ih as a,Rh as c,Vh as g,Fh as r}; diff --git a/public/assets/admin/locales/en-US.js b/public/assets/admin/locales/en-US.js index 81b7d209..140aabf7 100644 --- a/public/assets/admin/locales/en-US.js +++ b/public/assets/admin/locales/en-US.js @@ -1219,6 +1219,16 @@ window.XBOARD_TRANSLATIONS['en-US'] = { "error": { "saveFailed": "Failed to save coupon" } + }, + "period": { + "monthly": "Monthly", + "quarterly": "Quarterly", + "half_yearly": "Half Yearly", + "yearly": "Yearly", + "two_yearly": "Two Yearly", + "three_yearly": "Three Yearly", + "onetime": "One Time", + "reset_traffic": "Reset Traffic" } }, "notice": { diff --git a/public/assets/admin/locales/ko-KR.js b/public/assets/admin/locales/ko-KR.js index add98ae5..c4e6e828 100644 --- a/public/assets/admin/locales/ko-KR.js +++ b/public/assets/admin/locales/ko-KR.js @@ -1219,6 +1219,16 @@ window.XBOARD_TRANSLATIONS['ko-KR'] = { "error": { "saveFailed": "쿠폰 저장 실패" } + }, + "period": { + "monthly": "월별", + "quarterly": "분기별", + "half_yearly": "반년별", + "yearly": "연간", + "two_yearly": "두 년", + "three_yearly": "세 년", + "onetime": "한 번", + "reset_traffic": "트래픽 재설정" } }, "notice": { diff --git a/public/assets/admin/locales/zh-CN.js b/public/assets/admin/locales/zh-CN.js index e19a824d..a0e12e72 100644 --- a/public/assets/admin/locales/zh-CN.js +++ b/public/assets/admin/locales/zh-CN.js @@ -1211,6 +1211,16 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "error": { "saveFailed": "保存优惠券失败" } + }, + "period": { + "monthly": "月", + "quarterly": "季度", + "half_yearly": "半年", + "yearly": "年", + "two_yearly": "两年", + "three_yearly": "三年", + "onetime": "一次性", + "reset_traffic": "重置流量" } }, "notice": {