diff --git a/app/Http/Controllers/V2/Admin/PluginController.php b/app/Http/Controllers/V2/Admin/PluginController.php index de78e3c..4be814e 100644 --- a/app/Http/Controllers/V2/Admin/PluginController.php +++ b/app/Http/Controllers/V2/Admin/PluginController.php @@ -192,4 +192,56 @@ class PluginController extends Controller ], 400); } } + + /** + * 上传插件 + */ + public function upload(Request $request) + { + $request->validate([ + 'file' => [ + 'required', + 'file', + 'mimes:zip', + 'max:10240', // 最大10MB + ] + ], [ + 'file.required' => '请选择插件包文件', + 'file.file' => '无效的文件类型', + 'file.mimes' => '插件包必须是zip格式', + 'file.max' => '插件包大小不能超过10MB' + ]); + + try { + $this->pluginManager->upload($request->file('file')); + return response()->json([ + 'message' => '插件上传成功' + ]); + } catch (\Exception $e) { + return response()->json([ + 'message' => '插件上传失败:' . $e->getMessage() + ], 400); + } + } + + /** + * 删除插件 + */ + public function delete(Request $request) + { + $request->validate([ + 'code' => 'required|string' + ]); + + try { + $this->pluginManager->delete($request->input('code')); + return response()->json([ + 'message' => '插件删除成功' + ]); + } catch (\Exception $e) { + return response()->json([ + 'message' => '插件删除失败:' . $e->getMessage() + ], 400); + } + } } \ No newline at end of file diff --git a/app/Http/Controllers/V2/Admin/ThemeController.php b/app/Http/Controllers/V2/Admin/ThemeController.php index c2d3170..727cd27 100644 --- a/app/Http/Controllers/V2/Admin/ThemeController.php +++ b/app/Http/Controllers/V2/Admin/ThemeController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Controller; use App\Services\ThemeService; use Illuminate\Http\Request; use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Log; class ThemeController extends Controller { @@ -75,7 +76,7 @@ class ThemeController extends Controller } catch (ApiException $e) { throw $e; } catch (\Exception $e) { - \Log::error('Theme upload failed', [ + Log::error('Theme upload failed', [ 'error' => $e->getMessage(), 'file' => $request->file('file')?->getClientOriginalName() ]); diff --git a/app/Http/Routes/V2/AdminRoute.php b/app/Http/Routes/V2/AdminRoute.php index 50d507e..c1c97b7 100644 --- a/app/Http/Routes/V2/AdminRoute.php +++ b/app/Http/Routes/V2/AdminRoute.php @@ -210,6 +210,8 @@ class AdminRoute 'prefix' => 'plugin' ], function ($router) { $router->get('/getPlugins', [\App\Http\Controllers\V2\Admin\PluginController::class, 'index']); + $router->post('/upload', [\App\Http\Controllers\V2\Admin\PluginController::class, 'upload']); + $router->post('/delete', [\App\Http\Controllers\V2\Admin\PluginController::class, 'delete']); $router->post('install', [\App\Http\Controllers\V2\Admin\PluginController::class, 'install']); $router->post('uninstall', [\App\Http\Controllers\V2\Admin\PluginController::class, 'uninstall']); $router->post('enable', [\App\Http\Controllers\V2\Admin\PluginController::class, 'enable']); diff --git a/app/Services/Plugin/HookManager.php b/app/Services/Plugin/HookManager.php index 9137ddf..decad6e 100644 --- a/app/Services/Plugin/HookManager.php +++ b/app/Services/Plugin/HookManager.php @@ -80,11 +80,12 @@ class HookManager * 移除钩子监听器 * * @param string $hook 钩子名称 + * @param callable|null $callback 回调函数 * @return void */ - public static function remove(string $hook): void + public static function remove(string $hook, ?callable $callback = null): void { - Eventy::removeAction($hook); - Eventy::removeFilter($hook); + Eventy::removeAction($hook, $callback); + Eventy::removeFilter($hook, $callback); } } \ No newline at end of file diff --git a/app/Services/Plugin/PluginManager.php b/app/Services/Plugin/PluginManager.php index ca78a97..c1ac99a 100644 --- a/app/Services/Plugin/PluginManager.php +++ b/app/Services/Plugin/PluginManager.php @@ -144,6 +144,31 @@ class PluginManager return true; } + /** + * 删除插件 + * + * @param string $pluginCode + * @return bool + * @throws \Exception + */ + public function delete(string $pluginCode): bool + { + // 先卸载插件 + if (Plugin::where('code', $pluginCode)->exists()) { + $this->uninstall($pluginCode); + } + + $pluginPath = $this->pluginPath . '/' . $pluginCode; + if (!File::exists($pluginPath)) { + throw new \Exception('插件不存在'); + } + + // 删除插件目录 + File::deleteDirectory($pluginPath); + + return true; + } + /** * 加载插件实例 */ @@ -183,4 +208,59 @@ class PluginManager } return true; } + + /** + * 上传插件 + * + * @param \Illuminate\Http\UploadedFile $file + * @return bool + * @throws \Exception + */ + public function upload($file): bool + { + $tmpPath = storage_path('tmp/plugins'); + if (!File::exists($tmpPath)) { + File::makeDirectory($tmpPath, 0755, true); + } + + $extractPath = $tmpPath . '/' . uniqid(); + $zip = new \ZipArchive(); + + if ($zip->open($file->path()) !== true) { + throw new \Exception('无法打开插件包文件'); + } + + $zip->extractTo($extractPath); + $zip->close(); + + $configFile = File::glob($extractPath . '/*/config.json'); + if (empty($configFile)) { + $configFile = File::glob($extractPath . '/config.json'); + } + + if (empty($configFile)) { + File::deleteDirectory($extractPath); + throw new \Exception('插件包格式错误:缺少配置文件'); + } + + $pluginPath = dirname(reset($configFile)); + $config = json_decode(File::get($pluginPath . '/config.json'), true); + + if (!$this->validateConfig($config)) { + File::deleteDirectory($extractPath); + throw new \Exception('插件配置文件格式错误'); + } + + $targetPath = $this->pluginPath . '/' . $config['code']; + if (File::exists($targetPath)) { + File::deleteDirectory($extractPath); + throw new \Exception('插件已存在'); + } + + File::copyDirectory($pluginPath, $targetPath); + File::deleteDirectory($pluginPath); + File::deleteDirectory($extractPath); + + return true; + } } \ No newline at end of file diff --git a/composer.json b/composer.json index 67a67b0..71966cd 100755 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "symfony/http-client": "^6.4", "symfony/mailgun-mailer": "^6.4", "symfony/yaml": "*", + "tormjens/eventy": "^0.8.0", "zoujingli/ip2region": "^2.0" }, "require-dev": { diff --git a/docs/en/installation/1panel.md b/docs/en/installation/1panel.md index 1e86a64..67a246a 100644 --- a/docs/en/installation/1panel.md +++ b/docs/en/installation/1panel.md @@ -78,6 +78,7 @@ services: - ./.docker/.data/:/www/.docker/.data - ./storage/logs:/www/storage/logs - ./storage/theme:/www/storage/theme + - ./plugins:/www/plugins environment: - docker=true depends_on: @@ -96,6 +97,7 @@ services: - ./.env:/www/.env - ./.docker/.data/:/www/.docker/.data - ./storage/logs:/www/storage/logs + - ./plugins:/www/plugins restart: on-failure command: php artisan horizon networks: diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js index 55fbd44..5bb01c0 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 gl,c as jl,I as Oa,a as Fs,S as ia,u as hs,b as ca,d as vl,O as da,e as bl,f as $,g as yl,h as Nl,i as _l,k as wl,B as Cl,l as Sl,Q as kl,m as Tl,R as Pl,n as Dl,P as El,o as Rl,p as Vl,q as ln,F as Il,C as Fl,s as Ml,v as Ol,w as zl,x as Ll,y as on,z as F,A as h,D as ue,E as he,G as cn,H as Vt,J as It,K as ma,L as He,T as Ft,M as Mt,N as dn,U as mn,V as un,W as ua,X as xn,Y as Al,Z as hn,_ as fn,$ as pn,a0 as gn,a1 as Ms,a2 as jn,a3 as $l,a4 as vn,a5 as bn,a6 as ql,a7 as Hl,a8 as Kl,a9 as Ul,aa as Bl,ab as Gl,ac as Wl,ad as Yl,ae as Ql,af as Jl,ag as Zl,ah as yn,ai as Xl,aj as eo,ak as Os,al as Nn,am as so,an as to,ao as _n,ap as xa,aq as ao,ar as no,as as za,at as ro,au as wn,av as lo,aw as Cn,ax as oo,ay as io,az as co,aA as mo,aB as uo,aC as xo,aD as Sn,aE as ho,aF as fo,aG as po,aH as Re,aI as go,aJ as kn,aK as jo,aL as vo,aM as Tn,aN as Pn,aO as Dn,aP as bo,aQ as yo,aR as En,aS as Rn,aT as Vn,aU as No,aV as _o,aW as In,aX as wo,aY as ha,aZ as Fn,a_ as Co,a$ as Mn,b0 as So,b1 as On,b2 as ko,b3 as zn,b4 as Ln,b5 as To,b6 as Po,b7 as An,b8 as Do,b9 as Eo,ba as $n,bb as Ro,bc as qn,bd as Vo,be as Io,bf as Je,bg as te,bh as Qe,bi as ht,bj as Fo,bk as Mo,bl as Oo,bm as zo,bn as Lo,bo as Ao,bp as La,bq as Aa,br as $o,bs as qo,bt as Ho,bu as Ko,bv as Uo,bw as Xt,bx as ea,by as Bo,bz as Go,bA as Hn,bB as Wo,bC as Yo,bD as Kn,bE as Qo,bF as be,bG as Jo,bH as $a,bI as sa,bJ as ta,bK as Zo,bL as Xo,bM as Un,bN as ei,bO as fa,bP as si,bQ as ti,bR as ai,bS as Bn,bT as Gn,bU as Wn,bV as ni,bW as ri,bX as li,bY as oi,bZ as Yn,b_ as ii,b$ as ls,c0 as ci,c1 as di,c2 as mi,c3 as kt,c4 as ke,c5 as qa,c6 as ui,c7 as Qn,c8 as Jn,c9 as Zn,ca as Xn,cb as er,cc as sr,cd as xi,ce as hi,cf as fi,cg as Ot,ch as zs,ci as os,cj as Be,ck as Ge,cl as Xe,cm as es,cn as ss,co as pi,cp as gi,cq as ji,cr as vi,cs as bi,ct as yi,cu as Ni,cv as _i,cw as wi,cx as aa,cy as pa,cz as ga,cA as Ci,cB as fs,cC as ps,cD as ft,cE as Si,cF as Tt,cG as ki,cH as Ha,cI as tr,cJ as Ka,cK as Pt,cL as Ti,cM as Pi,cN as Di,cO as Ei,cP as ar,cQ as Ri,cR as Vi,cS as nr,cT as na,cU as rr,cV as Ii,cW as lr,cX as or,cY as Fi,cZ as Mi,c_ as Oi,c$ as zi,d0 as Li}from"./vendor.js";import"./index.js";var Lh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ah(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ai(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 $i={theme:"system",setTheme:()=>null},ir=m.createContext($i);function qi({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(ir.Provider,{...l,value:i,children:s})}const Hi=()=>{const s=m.useContext(ir);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Ki=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),Ui=function(s,n){return new URL(s,n).href},Ua={},oe=function(n,a,l){let r=Promise.resolve();if(a&&a.length>0){const i=document.getElementsByTagName("link"),u=document.querySelector("meta[property=csp-nonce]"),x=u?.nonce||u?.getAttribute("nonce");r=Promise.allSettled(a.map(o=>{if(o=Ui(o,l),o in Ua)return;Ua[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":Ki,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 N(...s){return gl(jl(s))}const Zs=Fs("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?ia:"button";return e.jsxs(p,{className:N(Zs({variant:n,size:a,className:s})),disabled:i||c,ref:d,...o,children:[(u&&i||!u&&!x&&i)&&e.jsx(Oa,{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(Oa,{className:"ml-2 h-4 w-4 animate-spin"})]})});V.displayName="Button";function Ks({className:s,minimal:n=!1}){const a=hs();return e.jsx("div",{className:N("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 Ba(){const s=hs();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 Bi(){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 Gi(s){return typeof s>"u"}function Wi(s){return s===null}function Yi(s){return Wi(s)||Gi(s)}class Qi{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 Yi(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 cr({prefixKey:s="",storage:n=sessionStorage}){return new Qi({prefixKey:s,storage:n})}const dr="Xboard_",Ji=function(s={}){return cr({prefixKey:s.prefixKey||"",storage:localStorage})},Zi=function(s={}){return cr({prefixKey:s.prefixKey||"",storage:sessionStorage})},zt=Ji({prefixKey:dr});Zi({prefixKey:dr});const mr="access_token";function dt(){return zt.get(mr)}function ur(){zt.remove(mr)}const Ga=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Xi({children:s}){const n=hs(),a=ca(),l=dt();return m.useEffect(()=>{if(!l.value&&!Ga.includes(a.pathname)){const r=encodeURIComponent(a.pathname+a.search);n(`/sign-in?redirect=${r}`)}},[l.value,a.pathname,a.search,n]),Ga.includes(a.pathname)||l.value?e.jsx(e.Fragment,{children:s}):null}const ec=()=>e.jsx(Xi,{children:e.jsx(da,{})}),sc=vl([{path:"/sign-in",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Sc);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(ec,{}),children:[{path:"/",lazy:async()=>({Component:(await oe(()=>Promise.resolve().then(()=>Fc),void 0,import.meta.url)).default}),errorElement:e.jsx(Ks,{}),children:[{index:!0,lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>rm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Ks,{}),children:[{path:"system",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>cm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>xm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>jm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>_m);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Tm);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Vm);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>zm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Hm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Wm);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Xm);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>cu);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>uu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>pu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>_u);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Eu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Ks,{}),children:[{path:"manage",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>tx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>ox);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>xx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Ks,{}),children:[{path:"plan",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Nx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Mx);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Ux);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Ks,{}),children:[{path:"manage",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>ph);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await oe(async()=>{const{default:s}=await Promise.resolve().then(()=>Mh);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Ks},{path:"/404",Component:Ba},{path:"/503",Component:Bi},{path:"*",Component:Ba}]),tc="locale";function ac(){return zt.get(tc)}function xr(){ur();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 nc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function rc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const I=bl.create({baseURL:rc(),timeout:12e3,headers:{"Content-Type":"application/json"}});I.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=dt();if(!nc.includes(s.url?.split("?")[0]||"")){if(!n.value)return xr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=ac().value||"zh-CN",s},s=>Promise.reject(s));I.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)&&xr(),$.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function lc(){return I.get("/user/info")}const Kt={token:dt()?.value||"",userInfo:null,isLoggedIn:!!dt()?.value,loading:!1,error:null},it=yl("user/fetchUserInfo",async()=>(await lc()).data,{condition:(s,{getState:n})=>{const{user:a}=n();return!!a.token&&!a.loading}}),hr=Nl({name:"user",initialState:Kt,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>Kt},extraReducers:s=>{s.addCase(it.pending,n=>{n.loading=!0,n.error=null}).addCase(it.fulfilled,(n,a)=>{n.loading=!1,n.userInfo=a.payload,n.error=null}).addCase(it.rejected,(n,a)=>{if(n.loading=!1,n.error=a.error.message||"Failed to fetch user info",!n.token)return Kt})}}),{setToken:oc,resetUserState:ic}=hr.actions,cc=s=>s.user.userInfo,dc=hr.reducer,fr=_l({reducer:{user:dc}});dt()?.value&&fr.dispatch(it());wl.use(Cl).use(Sl).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 mc=new kl;Tl.createRoot(document.getElementById("root")).render(e.jsx(Pl.StrictMode,{children:e.jsx(Dl,{client:mc,children:e.jsx(El,{store:fr,children:e.jsxs(qi,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Rl,{router:sc}),e.jsx(Vl,{richColors:!0,position:"top-right"})]})})})}));const Le=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Le.displayName="Card";const Ke=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("flex flex-col space-y-1.5 p-6",s),...n}));Ke.displayName="CardHeader";const us=m.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:N("font-semibold leading-none tracking-tight",s),...n}));us.displayName="CardTitle";const Ys=m.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ys.displayName="CardDescription";const Ue=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("p-6 pt-0",s),...n}));Ue.displayName="CardContent";const uc=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("flex items-center p-6 pt-0",s),...n}));uc.displayName="CardFooter";const xc=Fs("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Dt=m.forwardRef(({className:s,...n},a)=>e.jsx(ln,{ref:a,className:N(xc(),s),...n}));Dt.displayName=ln.displayName;const fe=Il,pr=m.createContext({}),b=({...s})=>e.jsx(pr.Provider,{value:{name:s.name},children:e.jsx(Fl,{...s})}),Lt=()=>{const s=m.useContext(pr),n=m.useContext(gr),{getFieldState:a,formState:l}=Ml(),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}},gr=m.createContext({}),v=m.forwardRef(({className:s,...n},a)=>{const l=m.useId();return e.jsx(gr.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:N("space-y-2",s),...n})})});v.displayName="FormItem";const y=m.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=Lt();return e.jsx(Dt,{ref:a,className:N(l&&"text-destructive",s),htmlFor:r,...n})});y.displayName="FormLabel";const _=m.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=Lt();return e.jsx(ia,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});_.displayName="FormControl";const M=m.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=Lt();return e.jsx("p",{ref:a,id:l,className:N("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}=Lt(),i=r?String(r?.message):n;return i?e.jsx("p",{ref:l,id:c,className:N("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:N("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 jr=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:N("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(Ol,{size:18}):e.jsx(zl,{size:18})})]})});jr.displayName="PasswordInput";const hc=s=>I({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),Ll(s).format(n))}function fc(s=void 0,n="YYYY-MM-DD"){return xe(s,n)}function Gs(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Rs(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 Et(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 rs(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?Gs(r)+" TB":l>=1?Gs(l)+" GB":a>=1?Gs(a)+" MB":Gs(n)+" KB"}const pc="access_token";function gc(s){zt.set(pc,s)}function jc({className:s,onForgotPassword:n,...a}){const l=hs(),r=on(),{t:c}=F("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=ue({resolver:he(i),defaultValues:{email:"",password:""}});async function x(o){try{const{data:d}=await hc(o);gc(d.auth_data),r(oc(d.auth_data)),await r(it()).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:N("grid gap-6",s),...a,children:e.jsx(fe,{...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(b,{control:u.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:c("signIn.email")}),e.jsx(_,{children:e.jsx(D,{placeholder:c("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"password",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:c("signIn.password")}),e.jsx(_,{children:e.jsx(jr,{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 je=cn,$e=dn,vc=mn,pt=ma,vr=m.forwardRef(({className:s,...n},a)=>e.jsx(Vt,{ref:a,className:N("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}));vr.displayName=Vt.displayName;const pe=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(vc,{children:[e.jsx(vr,{}),e.jsxs(It,{ref:l,className:N("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(ma,{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(He,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pe.displayName=It.displayName;const ye=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});ye.displayName="DialogHeader";const qe=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});qe.displayName="DialogFooter";const ve=m.forwardRef(({className:s,...n},a)=>e.jsx(Ft,{ref:a,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));ve.displayName=Ft.displayName;const Ee=m.forwardRef(({className:s,...n},a)=>e.jsx(Mt,{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ee.displayName=Mt.displayName;const Qs=Fs("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"}}),G=m.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const i=l?ia:"button";return e.jsx(i,{className:N(Qs({variant:n,size:a,className:s})),ref:c,...r})});G.displayName="Button";const ks=ql,Ts=Hl,bc=Kl,yc=m.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(un,{ref:r,className:N("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(ua,{className:"ml-auto h-4 w-4"})]}));yc.displayName=un.displayName;const Nc=m.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:N("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}));Nc.displayName=xn.displayName;const xs=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Al,{children:e.jsx(hn,{ref:l,sideOffset:n,className:N("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})}));xs.displayName=hn.displayName;const ge=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(fn,{ref:l,className:N("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=fn.displayName;const _c=m.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(pn,{ref:r,className:N("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(gn,{children:e.jsx(Ms,{className:"h-4 w-4"})})}),n]}));_c.displayName=pn.displayName;const wc=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(jn,{ref:l,className:N("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(gn,{children:e.jsx($l,{className:"h-4 w-4 fill-current"})})}),n]}));wc.displayName=jn.displayName;const ja=m.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(vn,{ref:l,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));ja.displayName=vn.displayName;const mt=m.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));mt.displayName=bn.displayName;const ra=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});ra.displayName="DropdownMenuShortcut";const Ut=[{code:"en-US",name:"English",flag:Ul,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Bl,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:Gl,shortName:"KR"}];function br(){const{i18n:s}=F(),n=r=>{s.changeLanguage(r)},a=Ut.find(r=>r.code===s.language)||Ut[1],l=a.flag;return e.jsxs(ks,{children:[e.jsx(Ts,{asChild:!0,children:e.jsxs(G,{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(xs,{align:"end",className:"w-[120px]",children:Ut.map(r=>{const c=r.flag,i=r.code===s.language;return e.jsxs(ge,{onClick:()=>n(r.code),className:N("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:N("text-sm",i&&"font-medium"),children:r.name})]},r.code)})})]})}function Cc(){const[s,n]=m.useState(!1),{t:a}=F("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(br,{})}),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(Le,{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(jc,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(je,{open:s,onOpenChange:n,children:e.jsx(pe,{children:e.jsxs(ye,{children:[e.jsx(ve,{children:a("signIn.resetPassword.title")}),e.jsx(Ee,{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(G,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Et(l).then(()=>{$.success(a("common:copy.success"))}),children:e.jsx(Wl,{className:"h-4 w-4"})})]})})]})})})]})}const Sc=Object.freeze(Object.defineProperty({__proto__:null,default:Cc},Symbol.toStringTag,{value:"Module"})),Ce=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:N("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}));Ce.displayName="Layout";const Se=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Se.displayName="LayoutHeader";const Pe=m.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));Pe.displayName="LayoutBody";const yr=Yl,Nr=Ql,_r=Jl,me=Zl,ce=Xl,de=eo,re=m.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(yn,{ref:l,sideOffset:n,className:N("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}));re.displayName=yn.displayName;function At(){const{pathname:s}=ca();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function wr({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 kc(){const[s,n]=wr({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 Tc({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=F(),c=({sub:i,...u})=>{const x=`${r(u.title)}-${u.href}`;return n&&i?m.createElement(Ec,{...u,sub:i,key:x,closeNav:l}):n?m.createElement(Dc,{...u,key:x,closeNav:l}):i?m.createElement(Pc,{...u,sub:i,key:x,closeNav:l}):m.createElement(Cr,{...u,key:x,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:N("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(me,{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 Cr({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:i}=At(),{t:u}=F();return e.jsxs(Os,{to:l,onClick:r,className:N(Zs({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 Pc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=At(),{isExpanded:i,toggleItem:u}=kc(),{t:x}=F(),o=!!l?.find(T=>c(T.href)),d=x(s),p=i(d)||o;return e.jsxs(yr,{open:p,onOpenChange:()=>u(d),children:[e.jsxs(Nr,{className:N(Zs({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:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Nn,{stroke:1})})]}),e.jsx(_r,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(T=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Cr,{...T,subLink:!0,closeNav:r})},x(T.title)))})})]})}function Dc({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=At(),{t:i}=F();return e.jsxs(ce,{delayDuration:0,children:[e.jsx(de,{asChild:!0,children:e.jsxs(Os,{to:l,onClick:r,className:N(Zs({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:i(s)})]})}),e.jsxs(re,{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 Ec({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=At(),{t:i}=F(),u=!!l?.find(x=>c(x.href));return e.jsxs(ks,{children:[e.jsxs(ce,{delayDuration:0,children:[e.jsx(de,{asChild:!0,children:e.jsx(Ts,{asChild:!0,children:e.jsx(V,{variant:u?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(re,{side:"right",className:"flex items-center gap-4",children:[i(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:i(a)}),e.jsx(Nn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(xs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(ja,{children:[i(s)," ",a?`(${i(a)})`:""]}),e.jsx(mt,{}),l.map(({title:x,icon:o,label:d,href:p})=>e.jsx(ge,{asChild:!0,children:e.jsxs(Os,{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 Sr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(so,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(to,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(_n,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(xa,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(ao,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(no,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(za,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(ro,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(wn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(lo,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Cn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(oo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(io,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(co,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(za,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(mo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(uo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(xo,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(Sn,{size:18})}]}];function Rc({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=m.useState(!1),{t:c}=F();return m.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:N(`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(Ce,{children:[e.jsxs(Se,{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(ho,{}):e.jsx(fo,{})})]}),e.jsx(Tc,{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:Sr}),e.jsx("div",{className:N("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:N("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(po,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Vc(){const[s,n]=wr({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 Ic(){const[s,n]=Vc();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Rc,{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(da,{})})]})}const Fc=Object.freeze(Object.defineProperty({__proto__:null,default:Ic},Symbol.toStringTag,{value:"Module"})),Ps=m.forwardRef(({className:s,...n},a)=>e.jsx(Re,{ref:a,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Ps.displayName=Re.displayName;const Mc=({children:s,...n})=>e.jsx(je,{...n,children:e.jsx(pe,{className:"overflow-hidden p-0",children:e.jsx(Ps,{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})})}),Ls=m.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(go,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Re.Input,{ref:a,className:N("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})]}));Ls.displayName=Re.Input.displayName;const Ds=m.forwardRef(({className:s,...n},a)=>e.jsx(Re.List,{ref:a,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Ds.displayName=Re.List.displayName;const As=m.forwardRef((s,n)=>e.jsx(Re.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));As.displayName=Re.Empty.displayName;const Ae=m.forwardRef(({className:s,...n},a)=>e.jsx(Re.Group,{ref:a,className:N("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}));Ae.displayName=Re.Group.displayName;const Xs=m.forwardRef(({className:s,...n},a)=>e.jsx(Re.Separator,{ref:a,className:N("-mx-1 h-px bg-border",s),...n}));Xs.displayName=Re.Separator.displayName;const Te=m.forwardRef(({className:s,...n},a)=>e.jsx(Re.Item,{ref:a,className:N("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}));Te.displayName=Re.Item.displayName;function Oc(){const s=[];for(const n of Sr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function Oe(){const[s,n]=m.useState(!1),a=hs(),l=Oc(),{t:r}=F("search"),{t:c}=F("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(G,{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(kn,{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(Mc,{open:s,onOpenChange:n,children:[e.jsx(Ls,{placeholder:r("placeholder")}),e.jsxs(Ds,{children:[e.jsx(As,{children:r("noResults")}),e.jsx(Ae,{heading:r("title"),children:l.map(u=>e.jsxs(Te,{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 Ve(){const{theme:s,setTheme:n}=Hi();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(jo,{size:20}):e.jsx(vo,{size:20})}),e.jsx(br,{})]})}const kr=m.forwardRef(({className:s,...n},a)=>e.jsx(Tn,{ref:a,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));kr.displayName=Tn.displayName;const Tr=m.forwardRef(({className:s,...n},a)=>e.jsx(Pn,{ref:a,className:N("aspect-square h-full w-full",s),...n}));Tr.displayName=Pn.displayName;const Pr=m.forwardRef(({className:s,...n},a)=>e.jsx(Dn,{ref:a,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));Pr.displayName=Dn.displayName;function Ie(){const s=hs(),n=on(),a=bo(cc),{t:l}=F(["common"]),r=()=>{ur(),n(ic()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),i=c.substring(0,2).toUpperCase();return e.jsxs(ks,{children:[e.jsx(Ts,{asChild:!0,children:e.jsx(V,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(kr,{className:"h-8 w-8",children:[e.jsx(Tr,{src:a?.avatar_url,alt:c}),e.jsx(Pr,{children:i})]})})}),e.jsxs(xs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(ja,{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(mt,{}),e.jsx(ge,{asChild:!0,children:e.jsxs(Os,{to:"/config/system",children:[l("common:settings"),e.jsx(ra,{children:"⌘S"})]})}),e.jsx(mt,{}),e.jsxs(ge,{onClick:r,children:[l("common:logout"),e.jsx(ra,{children:"⇧⌘Q"})]})]})]})}const q=window?.settings?.secure_path,zc=s=>I.get(q+"/stat/getOrder",{params:s}),Lc=()=>I.get(q+"/stat/getStats"),Wa=s=>I.get(q+"/stat/getTrafficRank",{params:s}),Ac=()=>I.get(q+"/theme/getThemes"),$c=s=>I.post(q+"/theme/getThemeConfig",{name:s}),qc=(s,n)=>I.post(q+"/theme/saveThemeConfig",{name:s,config:n}),Hc=s=>{const n=new FormData;return n.append("file",s),I.post(q+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Kc=s=>I.post(q+"/theme/delete",{name:s}),Uc=s=>I.post(q+"/config/save",s),Dr=()=>I.get(q+"/server/manage/getNodes"),Bc=s=>I.post(q+"/server/manage/save",s),Gc=s=>I.post(q+"/server/manage/drop",s),Wc=s=>I.post(q+"/server/manage/copy",s),Yc=s=>I.post(q+"/server/manage/update",s),Qc=s=>I.post(q+"/server/manage/sort",s),$t=()=>I.get(q+"/server/group/fetch"),Jc=s=>I.post(q+"/server/group/save",s),Zc=s=>I.post(q+"/server/group/drop",s),Er=()=>I.get(q+"/server/route/fetch"),Xc=s=>I.post(q+"/server/route/save",s),ed=s=>I.post(q+"/server/route/drop",s),sd=()=>I.get(q+"/payment/fetch"),td=()=>I.get(q+"/payment/getPaymentMethods"),ad=s=>I.post(q+"/payment/getPaymentForm",s),nd=s=>I.post(q+"/payment/save",s),rd=s=>I.post(q+"/payment/drop",s),ld=s=>I.post(q+"/payment/show",s),od=s=>I.post(q+"/payment/sort",s),id=s=>I.post(q+"/notice/save",s),cd=s=>I.post(q+"/notice/drop",s),dd=s=>I.post(q+"/notice/show",s),md=()=>I.get(q+"/knowledge/fetch"),ud=s=>I.get(q+"/knowledge/fetch?id="+s),xd=s=>I.post(q+"/knowledge/save",s),hd=s=>I.post(q+"/knowledge/drop",s),fd=s=>I.post(q+"/knowledge/show",s),pd=s=>I.post(q+"/knowledge/sort",s),$s=()=>I.get(q+"/plan/fetch"),gd=s=>I.post(q+"/plan/save",s),Bt=s=>I.post(q+"/plan/update",s),jd=s=>I.post(q+"/plan/drop",s),vd=s=>I.post(q+"/plan/sort",{ids:s}),bd=async s=>I.post(q+"/order/fetch",s),yd=s=>I.post(q+"/order/detail",s),Nd=s=>I.post(q+"/order/paid",s),_d=s=>I.post(q+"/order/cancel",s),Ya=s=>I.post(q+"/order/update",s),wd=s=>I.post(q+"/order/assign",s),Cd=s=>I.post(q+"/coupon/fetch",s),Sd=s=>I.post(q+"/coupon/generate",s),kd=s=>I.post(q+"/coupon/drop",s),Td=s=>I.post(q+"/coupon/update",s),Pd=s=>I.post(q+"/user/fetch",s),Dd=s=>I.post(q+"/user/update",s),Ed=s=>I.post(q+"/user/resetSecret",s),Rd=s=>I.post(q+"/user/generate",s),Vd=s=>I.post(q+"/stat/getStatUser",s),Id=s=>I.post(q+"/ticket/fetch",s),Fd=s=>I.get(q+"/ticket/fetch?id= "+s),Md=s=>I.post(q+"/ticket/close",{id:s}),gs=(s="")=>I.get(q+"/config/fetch?key="+s),js=s=>I.post(q+"/config/save",s),Od=()=>I.get(q+"/config/getEmailTemplate"),zd=()=>I.post(q+"/config/testSendMail"),Ld=()=>I.post(q+"/config/setTelegramWebhook"),va=yo,qt=m.forwardRef(({className:s,...n},a)=>e.jsx(En,{ref:a,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));qt.displayName=En.displayName;const Cs=m.forwardRef(({className:s,...n},a)=>e.jsx(Rn,{ref:a,className:N("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}));Cs.displayName=Rn.displayName;const Ct=m.forwardRef(({className:s,...n},a)=>e.jsx(Vn,{ref:a,className:N("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));Ct.displayName=Vn.displayName;const W=No,ys=Do,Y=_o,U=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(In,{ref:l,className:N("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(wo,{asChild:!0,children:e.jsx(ha,{className:"h-4 w-4 opacity-50"})})]}));U.displayName=In.displayName;const Rr=m.forwardRef(({className:s,...n},a)=>e.jsx(Fn,{ref:a,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Co,{className:"h-4 w-4"})}));Rr.displayName=Fn.displayName;const Vr=m.forwardRef(({className:s,...n},a)=>e.jsx(Mn,{ref:a,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(ha,{className:"h-4 w-4"})}));Vr.displayName=Mn.displayName;const B=m.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(So,{children:e.jsxs(On,{ref:r,className:N("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(Rr,{}),e.jsx(ko,{className:N("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Vr,{})]})}));B.displayName=On.displayName;const Ad=m.forwardRef(({className:s,...n},a)=>e.jsx(zn,{ref:a,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));Ad.displayName=zn.displayName;const A=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Ln,{ref:l,className:N("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(To,{children:e.jsx(Ms,{className:"h-4 w-4"})})}),e.jsx(Po,{children:n})]}));A.displayName=Ln.displayName;const $d=m.forwardRef(({className:s,...n},a)=>e.jsx(An,{ref:a,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));$d.displayName=An.displayName;function qs({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(Eo,{showOutsideDays:a,className:N("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:N(Qs({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:N("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:N(Qs({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx($n,{className:N("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(ua,{className:N("h-4 w-4",r),...c})},...l})}qs.displayName="Calendar";const is=Vo,cs=Io,ts=m.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(Ro,{children:e.jsx(qn,{ref:r,align:n,sideOffset:a,className:N("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})}));ts.displayName=qn.displayName;const Ns={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},lt=s=>(s/100).toFixed(2),qd=({active:s,payload:n,label:a})=>{const{t:l}=F();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"))?`¥${lt(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},Hd=[{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"}],Kd=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=Je(a,7);break;case"30d":l=Je(a,30);break;case"90d":l=Je(a,90);break;case"180d":l=Je(a,180);break;case"365d":l=Je(a,365);break;default:l=Je(a,30)}return{startDate:l,endDate:a}};function Ud(){const[s,n]=m.useState("amount"),[a,l]=m.useState("30d"),[r,c]=m.useState({from:Je(new Date,7),to:new Date}),{t:i}=F(),{startDate:u,endDate:x}=Kd(a,r),{data:o}=te({queryKey:["orderStat",{start_date:Qe(u,"yyyy-MM-dd"),end_date:Qe(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await zc({start_date:Qe(u,"yyyy-MM-dd"),end_date:Qe(x,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(Le,{children:[e.jsx(Ke,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(us,{children:i("dashboard:overview.title")}),e.jsxs(Ys,{children:[o?.summary.start_date," ",i("dashboard:overview.to")," ",o?.summary.end_date]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsxs(W,{value:a,onValueChange:d=>l(d),children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(Y,{placeholder:i("dashboard:overview.selectTimeRange")})}),e.jsx(B,{children:Hd.map(d=>e.jsx(A,{value:d.value,children:i(d.label)},d.value))})]}),a==="custom"&&e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(ht,{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:[Qe(r.from,"yyyy-MM-dd")," -"," ",Qe(r.to,"yyyy-MM-dd")]}):Qe(r.from,"yyyy-MM-dd"):i("dashboard:overview.selectDate")})]})}),e.jsx(ts,{className:"w-auto p-0",align:"end",children:e.jsx(qs,{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(va,{value:s,onValueChange:d=>n(d),children:e.jsxs(qt,{children:[e.jsx(Cs,{value:"amount",children:i("dashboard:overview.amount")}),e.jsx(Cs,{value:"count",children:i("dashboard:overview.count")})]})})]})]})}),e.jsxs(Ue,{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:["¥",lt(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")," ¥",lt(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:["¥",lt(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(Fo,{width:"100%",height:"100%",children:e.jsxs(Mo,{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:Ns.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Ns.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:Ns.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Ns.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Oo,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Qe(new Date(d),"MM-dd",{locale:$o})}),e.jsx(zo,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${lt(d)}`:i("dashboard:overview.transactions",{count:d})}),e.jsx(Lo,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Ao,{content:e.jsx(qd,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(La,{type:"monotone",dataKey:"paid_total",name:i("dashboard:overview.orderAmount"),stroke:Ns.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(La,{type:"monotone",dataKey:"commission_total",name:i("dashboard:overview.commissionAmount"),stroke:Ns.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Aa,{dataKey:"paid_count",name:i("dashboard:overview.orderCount"),fill:Ns.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Aa,{dataKey:"commission_count",name:i("dashboard:overview.commissionCount"),fill:Ns.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function ae({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function Bd(){return e.jsxs(Le,{children:[e.jsxs(Ke,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ae,{className:"h-4 w-[120px]"}),e.jsx(ae,{className:"h-4 w-4"})]}),e.jsxs(Ue,{children:[e.jsx(ae,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),e.jsx(ae,{className:"h-4 w-[100px]"})]})]})]})}function Gd(){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(Bd,{},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 nt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},rt={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Ze=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Ze||{}),ie=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(ie||{});const jt={0:"待确认",1:"发放中",2:"有效",3:"无效"},vt={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var we=(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))(we||{});const Wd={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var _e=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(_e||{});const Vs=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],ms={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var ze=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(ze||{});const Yd={1:"按金额优惠",2:"按比例优惠"};var Ss=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Ss||{}),De=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(De||{}),ct=(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))(ct||{});function _s({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:i,className:u}){return e.jsxs(Le,{className:N("transition-colors",c&&"cursor-pointer hover:bg-muted/50",i&&"border-primary/50",u),onClick:c,children:[e.jsxs(Ke,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(us,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(Ue,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Go,{className:N("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("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 Qd({className:s}){const n=hs(),{t:a}=F(),{data:l,isLoading:r}=te({queryKey:["dashboardStats"],queryFn:async()=>(await Lc()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Gd,{});const c=()=>{const i=new URLSearchParams;i.set("commission_status",ie.PENDING.toString()),i.set("status",Z.COMPLETED.toString()),i.set("commission_balance","gt:0"),n(`/finance/order?${i.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(_s,{title:a("dashboard:stats.todayIncome"),value:Rs(l.todayIncome),icon:e.jsx(qo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(_s,{title:a("dashboard:stats.monthlyIncome"),value:Rs(l.currentMonthIncome),icon:e.jsx(Ho,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(_s,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Ko,{className:N("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(_s,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Uo,{className:N("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(_s,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(Xt,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(_s,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(_s,{title:a("dashboard:stats.monthlyUpload"),value:rs(l.monthTraffic.upload),icon:e.jsx(ea,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:rs(l.todayTraffic.upload)})}),e.jsx(_s,{title:a("dashboard:stats.monthlyDownload"),value:rs(l.monthTraffic.download),icon:e.jsx(Bo,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:rs(l.todayTraffic.download)})})]})}const Js=m.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Hn,{ref:l,className:N("relative overflow-hidden",s),...a,children:[e.jsx(Wo,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Rt,{}),e.jsx(Yo,{})]}));Js.displayName=Hn.displayName;const Rt=m.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Kn,{ref:l,orientation:n,className:N("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(Qo,{className:"relative flex-1 rounded-full bg-border"})}));Rt.displayName=Kn.displayName;const la={today:{getValue:()=>{const s=Zo();return{start:s,end:Xo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:Je(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:Je(s,30),end:s}}},custom:{getValue:()=>null}};function Qa({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=F(),c={today:r("dashboard:trafficRank.today"),last7days:r("dashboard:trafficRank.last7days"),last30days:r("dashboard:trafficRank.last30days"),custom:r("dashboard:trafficRank.customRange")};return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[e.jsxs(W,{value:s,onValueChange:a,children:[e.jsx(U,{className:"w-[120px]",children:e.jsx(Y,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(B,{position:"popper",className:"z-50",children:Object.entries(la).map(([i])=>e.jsx(A,{value:i,children:c[i]},i))})]}),s==="custom"&&e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ht,{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:[Qe(n.from,"yyyy-MM-dd")," -"," ",Qe(n.to,"yyyy-MM-dd")]}):Qe(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(ts,{className:"w-auto p-0",align:"end",children:e.jsx(qs,{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 Us=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Jd({className:s}){const{t:n}=F(),[a,l]=m.useState("today"),[r,c]=m.useState({from:Je(new Date,7),to:new Date}),[i,u]=m.useState("today"),[x,o]=m.useState({from:Je(new Date,7),to:new Date}),d=m.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:la[a].getValue(),[a,r]),p=m.useMemo(()=>i==="custom"?{start:x.from,end:x.to}:la[i].getValue(),[i,x]),{data:T}=te({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Wa({type:"node",start_time:be.round(d.start.getTime()/1e3),end_time:be.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:R}=te({queryKey:["userTrafficRank",p.start,p.end],queryFn:()=>Wa({type:"user",start_time:be.round(p.start.getTime()/1e3),end_time:be.round(p.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Le,{children:[e.jsx(Ke,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(us,{className:"flex items-center text-base font-medium",children:[e.jsx(Jo,{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($a,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Ue,{className:"flex-1",children:T?.data?e.jsxs(Js,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:T.data.map(f=>e.jsx(me,{delayDuration:200,children:e.jsxs(ce,{children:[e.jsx(de,{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:N("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(sa,{className:"mr-1 h-3 w-3"}):e.jsx(ta,{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:Us(f.value)})]})]})})}),e.jsx(re,{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:Us(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Us(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Rt,{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(Le,{children:[e.jsx(Ke,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(us,{className:"flex items-center text-base font-medium",children:[e.jsx(Xt,{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($a,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Ue,{className:"flex-1",children:R?.data?e.jsxs(Js,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:R.data.map(f=>e.jsx(me,{children:e.jsxs(ce,{children:[e.jsx(de,{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:N("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(sa,{className:"mr-1 h-3 w-3"}):e.jsx(ta,{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:Us(f.value)})]})]})})}),e.jsx(re,{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:Us(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Us(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(Rt,{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 Zd=Fs("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 H({className:s,variant:n,...a}){return e.jsx("div",{className:N(Zd({variant:n}),s),...a})}const ne=window?.settings?.secure_path,Ir=5*60*1e3,oa=new Map,Xd=s=>{const n=oa.get(s);return n?Date.now()-n.timestamp>Ir?(oa.delete(s),null):n.data:null},em=(s,n)=>{oa.set(s,{data:n,timestamp:Date.now()})},sm=async(s,n=Ir)=>{const a=Xd(s);if(a)return a;const l=await I.get(s);return em(s,l),l},tm={getList:s=>I.post(`${ne}/user/fetch`,s),update:s=>I.post(`${ne}/user/update`,s),resetSecret:s=>I.post(`${ne}/user/resetSecret`,{id:s}),generate:s=>I.post(`${ne}/user/generate`,s),getStats:s=>I.post(`${ne}/stat/getStatUser`,s),destroy:s=>I.post(`${ne}/user/destroy`,{id:s})},Ja={getList:()=>sm(`${ne}/notice/fetch`),save:s=>I.post(`${ne}/notice/save`,s),drop:s=>I.post(`${ne}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${ne}/notice/show`,{id:s}),sort:s=>I.post(`${ne}/notice/sort`,{ids:s})},Gt={getList:s=>I.post(`${ne}/ticket/fetch`,s),getInfo:s=>I.get(`${ne}/ticket/fetch?id=${s}`),reply:s=>I.post(`${ne}/ticket/reply`,s),close:s=>I.post(`${ne}/ticket/close`,{id:s})},Za={getSystemStatus:()=>I.get(`${ne}/system/getSystemStatus`),getQueueStats:()=>I.get(`${ne}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${ne}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${ne}/system/getQueueMasters`),getSystemLog:s=>I.get(`${ne}/system/getSystemLog`,{params:s})},Is={getPluginList:()=>I.get(`${ne}/plugin/getPlugins`),installPlugin:s=>I.post(`${ne}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${ne}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${ne}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${ne}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${ne}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${ne}/plugin/config`,{code:s,config:n})},St=m.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Un,{ref:l,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(ei,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));St.displayName=Un.displayName;function am(){const{t:s}=F(),[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([Za.getSystemStatus(),Za.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(fa,{className:"h-6 w-6 animate-spin"})});const p=T=>T?e.jsx(Bn,{className:"h-5 w-5 text-green-500"}):e.jsx(Gn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Le,{children:[e.jsxs(Ke,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(si,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Ys,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:d,disabled:u,children:e.jsx(ti,{className:N("h-4 w-4",u&&"animate-spin")})})]}),e.jsx(Ue,{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(H,{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(me,{children:e.jsxs(ce,{children:[e.jsx(de,{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(St,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(re,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(me,{children:e.jsxs(ce,{children:[e.jsx(de,{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(St,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(re,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(Le,{children:[e.jsxs(Ke,{children:[e.jsxs(us,{className:"flex items-center gap-2",children:[e.jsx(ai,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Ys,{children:s("dashboard:queue.details.description")})]}),e.jsx(Ue,{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(St,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function nm(){const{t:s}=F();return e.jsxs(Ce,{children:[e.jsxs(Se,{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(Oe,{}),e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),e.jsx(Pe,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Qd,{}),e.jsx(Ud,{}),e.jsx(Jd,{}),e.jsx(am,{})]})})})]})}const rm=Object.freeze(Object.defineProperty({__proto__:null,default:nm},Symbol.toStringTag,{value:"Module"})),Ne=m.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(Wn,{ref:r,decorative:a,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));Ne.displayName=Wn.displayName;function lm({className:s,items:n,...a}){const{pathname:l}=ca(),r=hs(),[c,i]=m.useState(l??"/settings"),u=o=>{i(o),r(o)},{t:x}=F("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(W,{value:c,onValueChange:u,children:[e.jsx(U,{className:"h-12 sm:w-48",children:e.jsx(Y,{placeholder:"Theme"})}),e.jsx(B,{children:n.map(o=>e.jsx(A,{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:N("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(o=>e.jsxs(Os,{to:o.href,className:N(Zs({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 om=[{title:"site.title",key:"site",icon:e.jsx(ni,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Cn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Sn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(ri,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(wn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(li,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(oi,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(_n,{size:18}),href:"/config/system/app",description:"app.description"}];function im(){const{t:s}=F("settings");return e.jsxs(Ce,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(Ne,{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(lm,{items:om})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(da,{})})})]})]})]})}const cm=Object.freeze(Object.defineProperty({__proto__:null,default:im},Symbol.toStringTag,{value:"Module"})),K=m.forwardRef(({className:s,...n},a)=>e.jsx(Yn,{className:N("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(ii,{className:N("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")})}));K.displayName=Yn.displayName;const vs=m.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:N("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}));vs.displayName="Textarea";const dm=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 mm(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),{data:r}=te({queryKey:["settings","site"],queryFn:()=>gs("site")}),{data:c}=te({queryKey:["plans"],queryFn:()=>$s()}),i=ue({resolver:he(dm),defaultValues:{},mode:"onBlur"}),{mutateAsync:u}=ls({mutationFn:js,onSuccess:d=>{d.data&&$.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(be.debounce(async d=>{if(!be.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(fe,{...i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:i.control,name:"app_name",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(_,{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(b,{control:i.control,name:"app_description",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(_,{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(b,{control:i.control,name:"app_url",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(_,{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(b,{control:i.control,name:"force_https",render:({field:d})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(M,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(b,{control:i.control,name:"logo",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(_,{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(b,{control:i.control,name:"subscribe_url",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(vs,{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(b,{control:i.control,name:"tos_url",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(_,{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(b,{control:i.control,name:"stop_register",render:({field:d})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(M,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(b,{control:i.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(p=>e.jsx(A,{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(b,{control:i.control,name:"try_out_hour",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(_,{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(b,{control:i.control,name:"currency",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(_,{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(b,{control:i.control,name:"currency_symbol",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(_,{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 um(){const{t:s}=F("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(Ne,{}),e.jsx(mm,{})]})}const xm=Object.freeze(Object.defineProperty({__proto__:null,default:um},Symbol.toStringTag,{value:"Module"})),hm=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()}),fm={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 pm(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ue({resolver:he(hm),defaultValues:fm,mode:"onBlur"}),{data:c}=te({queryKey:["settings","safe"],queryFn:()=>gs("safe")}),{mutateAsync:i}=ls({mutationFn:js,onSuccess:o=>{o.data&&$.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(be.debounce(async o=>{if(!be.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(fe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"email_verify",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(M,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(M,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(M,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"secure_path",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(_,{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(b,{control:r.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(M,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(b,{control:r.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(vs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...o,value:(o.value||[]).join(` +import{r as u,j as e,t as gl,c as jl,I as Oa,a as Os,S as ia,u as js,b as ca,d as vl,O as da,e as bl,f as A,g as yl,h as Nl,i as _l,k as wl,B as Cl,l as Sl,Q as kl,m as Tl,R as Pl,n as Dl,P as El,o as Rl,p as Il,q as ln,F as Vl,C as Fl,s as Ml,v as Ol,w as zl,x as Ll,y as on,z as F,A as h,D as he,E as ge,G as cn,H as Vt,J as Ft,K as ma,L as Be,T as Mt,M as Ot,N as dn,U as mn,V as un,W as ua,X as xn,Y as Al,Z as hn,_ as fn,$ as pn,a0 as gn,a1 as zs,a2 as jn,a3 as $l,a4 as vn,a5 as bn,a6 as ql,a7 as Hl,a8 as Kl,a9 as Ul,aa as Bl,ab as Gl,ac as Wl,ad as Yl,ae as Ql,af as Jl,ag as Zl,ah as yn,ai as Xl,aj as eo,ak as Ls,al as Nn,am as so,an as to,ao as _n,ap as xa,aq as ao,ar as no,as as za,at as ro,au as wn,av as lo,aw as Cn,ax as oo,ay as io,az as co,aA as mo,aB as uo,aC as xo,aD as Sn,aE as ho,aF as fo,aG as po,aH as Ve,aI as go,aJ as kn,aK as jo,aL as vo,aM as Tn,aN as Pn,aO as Dn,aP as bo,aQ as yo,aR as En,aS as Rn,aT as In,aU as No,aV as _o,aW as Vn,aX as wo,aY as ha,aZ as Fn,a_ as Co,a$ as Mn,b0 as So,b1 as On,b2 as ko,b3 as zn,b4 as Ln,b5 as To,b6 as Po,b7 as An,b8 as Do,b9 as Eo,ba as $n,bb as Ro,bc as qn,bd as Io,be as Vo,bf as es,bg as ne,bh as Xe,bi as ft,bj as Fo,bk as Mo,bl as Oo,bm as zo,bn as Lo,bo as Ao,bp as La,bq as Aa,br as $o,bs as qo,bt as Ho,bu as Ko,bv as Uo,bw as ea,bx as dt,by as Bo,bz as Go,bA as Hn,bB as Wo,bC as Yo,bD as Kn,bE as Qo,bF as _e,bG as Jo,bH as $a,bI as sa,bJ as ta,bK as Zo,bL as Xo,bM as Un,bN as ei,bO as fa,bP as si,bQ as ti,bR as ai,bS as Bn,bT as Gn,bU as Wn,bV as ni,bW as ri,bX as li,bY as oi,bZ as Yn,b_ as ii,b$ as ds,c0 as ci,c1 as di,c2 as mi,c3 as Tt,c4 as Pe,c5 as qa,c6 as ui,c7 as Qn,c8 as Jn,c9 as Zn,ca as Xn,cb as er,cc as sr,cd as xi,ce as hi,cf as fi,cg as zt,ch as As,ci as ts,cj as Ye,ck as Qe,cl as as,cm as ns,cn as rs,co as pi,cp as gi,cq as ji,cr as vi,cs as bi,ct as yi,cu as Ni,cv as _i,cw as wi,cx as aa,cy as pa,cz as ga,cA as Ci,cB as vs,cC as bs,cD as pt,cE as Si,cF as Pt,cG as ki,cH as Ha,cI as tr,cJ as Ka,cK as Dt,cL as Ti,cM as Pi,cN as Di,cO as Ei,cP as ar,cQ as Ri,cR as Ii,cS as nr,cT as na,cU as rr,cV as Vi,cW as lr,cX as or,cY as Fi,cZ as Mi,c_ as Oi,c$ as zi,d0 as Li}from"./vendor.js";import"./index.js";var Lh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ah(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ai(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 $i={theme:"system",setTheme:()=>null},ir=u.createContext($i);function qi({children:s,defaultTheme:n="system",storageKey:a="vite-ui-theme",...l}){const[r,c]=u.useState(()=>localStorage.getItem(a)||n);u.useEffect(()=>{const m=window.document.documentElement;if(m.classList.remove("light","dark"),r==="system"){const x=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";m.classList.add(x);return}m.classList.add(r)},[r]);const i={theme:r,setTheme:m=>{localStorage.setItem(a,m),c(m)}};return e.jsx(ir.Provider,{...l,value:i,children:s})}const Hi=()=>{const s=u.useContext(ir);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Ki=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),Ui=function(s,n){return new URL(s,n).href},Ua={},ce=function(n,a,l){let r=Promise.resolve();if(a&&a.length>0){const i=document.getElementsByTagName("link"),m=document.querySelector("meta[property=csp-nonce]"),x=m?.nonce||m?.getAttribute("nonce");r=Promise.allSettled(a.map(o=>{if(o=Ui(o,l),o in Ua)return;Ua[o]=!0;const d=o.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(!!l)for(let f=i.length-1;f>=0;f--){const j=i[f];if(j.href===o&&(!d||j.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${p}`))return;const I=document.createElement("link");if(I.rel=d?"stylesheet":Ki,d||(I.as="script"),I.crossOrigin="",I.href=o,x&&I.setAttribute("nonce",x),document.head.appendChild(I),d)return new Promise((f,j)=>{I.addEventListener("load",f),I.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${o}`)))})}))}function c(i){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=i,window.dispatchEvent(m),!m.defaultPrevented)throw i}return r.then(i=>{for(const m of i||[])m.status==="rejected"&&c(m.reason);return n().catch(c)})};function N(...s){return gl(jl(s))}const Xs=Os("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),R=u.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,children:r,disabled:c,loading:i=!1,leftSection:m,rightSection:x,...o},d)=>{const p=l?ia:"button";return e.jsxs(p,{className:N(Xs({variant:n,size:a,className:s})),disabled:i||c,ref:d,...o,children:[(m&&i||!m&&!x&&i)&&e.jsx(Oa,{className:"mr-2 h-4 w-4 animate-spin"}),!i&&m&&e.jsx("div",{className:"mr-2",children:m}),r,!i&&x&&e.jsx("div",{className:"ml-2",children:x}),x&&i&&e.jsx(Oa,{className:"ml-2 h-4 w-4 animate-spin"})]})});R.displayName="Button";function Us({className:s,minimal:n=!1}){const a=js();return e.jsx("div",{className:N("h-svh w-full",s),children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[!n&&e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"500"}),e.jsxs("span",{className:"font-medium",children:["Oops! Something went wrong ",":')"]}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["We apologize for the inconvenience. ",e.jsx("br",{})," Please try again later."]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(R,{variant:"outline",onClick:()=>a(-1),children:"Go Back"}),e.jsx(R,{onClick:()=>a("/"),children:"Back to Home"})]})]})})}function Ba(){const s=js();return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"404"}),e.jsx("span",{className:"font-medium",children:"Oops! Page Not Found!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["It seems like the page you're looking for ",e.jsx("br",{}),"does not exist or might have been removed."]}),e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(R,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(R,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Bi(){return e.jsx("div",{className:"h-svh",children:e.jsxs("div",{className:"m-auto flex h-full w-full flex-col items-center justify-center gap-2",children:[e.jsx("h1",{className:"text-[7rem] font-bold leading-tight",children:"503"}),e.jsx("span",{className:"font-medium",children:"Website is under maintenance!"}),e.jsxs("p",{className:"text-center text-muted-foreground",children:["The site is not available at the moment. ",e.jsx("br",{}),"We'll be back online shortly."]}),e.jsx("div",{className:"mt-6 flex gap-4",children:e.jsx(R,{variant:"outline",children:"Learn more"})})]})})}function Gi(s){return typeof s>"u"}function Wi(s){return s===null}function Yi(s){return Wi(s)||Gi(s)}class Qi{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:m}=r;return Yi(m)||m>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 cr({prefixKey:s="",storage:n=sessionStorage}){return new Qi({prefixKey:s,storage:n})}const dr="Xboard_",Ji=function(s={}){return cr({prefixKey:s.prefixKey||"",storage:localStorage})},Zi=function(s={}){return cr({prefixKey:s.prefixKey||"",storage:sessionStorage})},Lt=Ji({prefixKey:dr});Zi({prefixKey:dr});const mr="access_token";function mt(){return Lt.get(mr)}function ur(){Lt.remove(mr)}const Ga=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function Xi({children:s}){const n=js(),a=ca(),l=mt();return u.useEffect(()=>{if(!l.value&&!Ga.includes(a.pathname)){const r=encodeURIComponent(a.pathname+a.search);n(`/sign-in?redirect=${r}`)}},[l.value,a.pathname,a.search,n]),Ga.includes(a.pathname)||l.value?e.jsx(e.Fragment,{children:s}):null}const ec=()=>e.jsx(Xi,{children:e.jsx(da,{})}),sc=vl([{path:"/sign-in",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Sc);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(ec,{}),children:[{path:"/",lazy:async()=>({Component:(await ce(()=>Promise.resolve().then(()=>Fc),void 0,import.meta.url)).default}),errorElement:e.jsx(Us,{}),children:[{index:!0,lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>rm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(Us,{}),children:[{path:"system",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>cm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>xm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>jm);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>_m);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Tm);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Im);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>zm);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Hm);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Wm);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Xm);return{default:s}},void 0,import.meta.url)).default})}]},{path:"payment",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>cu);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>uu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>pu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>_u);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Eu);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(Us,{}),children:[{path:"manage",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>tx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>ox);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>xx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(Us,{}),children:[{path:"plan",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Nx);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Mx);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Ux);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(Us,{}),children:[{path:"manage",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>ph);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await ce(async()=>{const{default:s}=await Promise.resolve().then(()=>Mh);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:Us},{path:"/404",Component:Ba},{path:"/503",Component:Bi},{path:"*",Component:Ba}]),tc="locale";function ac(){return Lt.get(tc)}function xr(){ur();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 nc=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function rc(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const V=bl.create({baseURL:rc(),timeout:12e3,headers:{"Content-Type":"application/json"}});V.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=mt();if(!nc.includes(s.url?.split("?")[0]||"")){if(!n.value)return xr(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=ac().value||"zh-CN",s},s=>Promise.reject(s));V.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)&&xr(),A.error(a||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});function lc(){return V.get("/user/info")}const Ut={token:mt()?.value||"",userInfo:null,isLoggedIn:!!mt()?.value,loading:!1,error:null},it=yl("user/fetchUserInfo",async()=>(await lc()).data,{condition:(s,{getState:n})=>{const{user:a}=n();return!!a.token&&!a.loading}}),hr=Nl({name:"user",initialState:Ut,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>Ut},extraReducers:s=>{s.addCase(it.pending,n=>{n.loading=!0,n.error=null}).addCase(it.fulfilled,(n,a)=>{n.loading=!1,n.userInfo=a.payload,n.error=null}).addCase(it.rejected,(n,a)=>{if(n.loading=!1,n.error=a.error.message||"Failed to fetch user info",!n.token)return Ut})}}),{setToken:oc,resetUserState:ic}=hr.actions,cc=s=>s.user.userInfo,dc=hr.reducer,fr=_l({reducer:{user:dc}});mt()?.value&&fr.dispatch(it());wl.use(Cl).use(Sl).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 mc=new kl;Tl.createRoot(document.getElementById("root")).render(e.jsx(Pl.StrictMode,{children:e.jsx(Dl,{client:mc,children:e.jsx(El,{store:fr,children:e.jsxs(qi,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(Rl,{router:sc}),e.jsx(Il,{richColors:!0,position:"top-right"})]})})})}));const Ae=u.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));Ae.displayName="Card";const Ge=u.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("flex flex-col space-y-1.5 p-6",s),...n}));Ge.displayName="CardHeader";const ps=u.forwardRef(({className:s,...n},a)=>e.jsx("h3",{ref:a,className:N("font-semibold leading-none tracking-tight",s),...n}));ps.displayName="CardTitle";const Qs=u.forwardRef(({className:s,...n},a)=>e.jsx("p",{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Qs.displayName="CardDescription";const We=u.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("p-6 pt-0",s),...n}));We.displayName="CardContent";const uc=u.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("flex items-center p-6 pt-0",s),...n}));uc.displayName="CardFooter";const xc=Os("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Et=u.forwardRef(({className:s,...n},a)=>e.jsx(ln,{ref:a,className:N(xc(),s),...n}));Et.displayName=ln.displayName;const je=Vl,pr=u.createContext({}),b=({...s})=>e.jsx(pr.Provider,{value:{name:s.name},children:e.jsx(Fl,{...s})}),At=()=>{const s=u.useContext(pr),n=u.useContext(gr),{getFieldState:a,formState:l}=Ml(),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}},gr=u.createContext({}),v=u.forwardRef(({className:s,...n},a)=>{const l=u.useId();return e.jsx(gr.Provider,{value:{id:l},children:e.jsx("div",{ref:a,className:N("space-y-2",s),...n})})});v.displayName="FormItem";const y=u.forwardRef(({className:s,...n},a)=>{const{error:l,formItemId:r}=At();return e.jsx(Et,{ref:a,className:N(l&&"text-destructive",s),htmlFor:r,...n})});y.displayName="FormLabel";const _=u.forwardRef(({...s},n)=>{const{error:a,formItemId:l,formDescriptionId:r,formMessageId:c}=At();return e.jsx(ia,{ref:n,id:l,"aria-describedby":a?`${r} ${c}`:`${r}`,"aria-invalid":!!a,...s})});_.displayName="FormControl";const M=u.forwardRef(({className:s,...n},a)=>{const{formDescriptionId:l}=At();return e.jsx("p",{ref:a,id:l,className:N("text-[0.8rem] text-muted-foreground",s),...n})});M.displayName="FormDescription";const E=u.forwardRef(({className:s,children:n,...a},l)=>{const{error:r,formMessageId:c}=At(),i=r?String(r?.message):n;return i?e.jsx("p",{ref:l,id:c,className:N("text-[0.8rem] font-medium text-destructive",s),...a,children:i}):null});E.displayName="FormMessage";const D=u.forwardRef(({className:s,type:n,...a},l)=>e.jsx("input",{type:n,className:N("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 jr=u.forwardRef(({className:s,...n},a)=>{const[l,r]=u.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:l?"text":"password",className:N("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",s),ref:a,...n}),e.jsx(R,{type:"button",size:"icon",variant:"ghost",className:"absolute right-1 top-1/2 h-6 w-6 -translate-y-1/2 rounded-md text-muted-foreground",onClick:()=>r(c=>!c),children:l?e.jsx(Ol,{size:18}):e.jsx(zl,{size:18})})]})});jr.displayName="PasswordInput";const hc=s=>V({url:"/passport/auth/login",method:"post",data:s});function fe(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),Ll(s).format(n))}function fc(s=void 0,n="YYYY-MM-DD"){return fe(s,n)}function Ws(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function Fs(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 Rt(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 cs(s){const n=s/1024,a=n/1024,l=a/1024,r=l/1024;return r>=1?Ws(r)+" TB":l>=1?Ws(l)+" GB":a>=1?Ws(a)+" MB":Ws(n)+" KB"}const pc="access_token";function gc(s){Lt.set(pc,s)}function jc({className:s,onForgotPassword:n,...a}){const l=js(),r=on(),{t:c}=F("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")})}),m=he({resolver:ge(i),defaultValues:{email:"",password:""}});async function x(o){try{const{data:d}=await hc(o);gc(d.auth_data),r(oc(d.auth_data)),await r(it()).unwrap(),l("/")}catch(d){console.error("Login failed:",d),d.response?.data?.message&&m.setError("root",{message:d.response.data.message})}}return e.jsx("div",{className:N("grid gap-6",s),...a,children:e.jsx(je,{...m,children:e.jsx("form",{onSubmit:m.handleSubmit(x),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[m.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:m.formState.errors.root.message}),e.jsx(b,{control:m.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:c("signIn.email")}),e.jsx(_,{children:e.jsx(D,{placeholder:c("signIn.emailPlaceholder"),autoComplete:"email",...o})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"password",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:c("signIn.password")}),e.jsx(_,{children:e.jsx(jr,{placeholder:c("signIn.passwordPlaceholder"),autoComplete:"current-password",...o})}),e.jsx(E,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:c("signIn.forgotPassword")})}),e.jsx(R,{className:"w-full",size:"lg",loading:m.formState.isSubmitting,children:c("signIn.submit")})]})})})})}const ve=cn,He=dn,vc=mn,gt=ma,vr=u.forwardRef(({className:s,...n},a)=>e.jsx(Vt,{ref:a,className:N("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}));vr.displayName=Vt.displayName;const pe=u.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(vc,{children:[e.jsx(vr,{}),e.jsxs(Ft,{ref:l,className:N("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(ma,{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(Be,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pe.displayName=Ft.displayName;const Ne=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});Ne.displayName="DialogHeader";const Ke=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ke.displayName="DialogFooter";const be=u.forwardRef(({className:s,...n},a)=>e.jsx(Mt,{ref:a,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));be.displayName=Mt.displayName;const Ee=u.forwardRef(({className:s,...n},a)=>e.jsx(Ot,{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ee.displayName=Ot.displayName;const Js=Os("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"}}),B=u.forwardRef(({className:s,variant:n,size:a,asChild:l=!1,...r},c)=>{const i=l?ia:"button";return e.jsx(i,{className:N(Js({variant:n,size:a,className:s})),ref:c,...r})});B.displayName="Button";const Ds=ql,Es=Hl,bc=Kl,yc=u.forwardRef(({className:s,inset:n,children:a,...l},r)=>e.jsxs(un,{ref:r,className:N("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(ua,{className:"ml-auto h-4 w-4"})]}));yc.displayName=un.displayName;const Nc=u.forwardRef(({className:s,...n},a)=>e.jsx(xn,{ref:a,className:N("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}));Nc.displayName=xn.displayName;const gs=u.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(Al,{children:e.jsx(hn,{ref:l,sideOffset:n,className:N("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})}));gs.displayName=hn.displayName;const ye=u.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(fn,{ref:l,className:N("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}));ye.displayName=fn.displayName;const _c=u.forwardRef(({className:s,children:n,checked:a,...l},r)=>e.jsxs(pn,{ref:r,className:N("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(gn,{children:e.jsx(zs,{className:"h-4 w-4"})})}),n]}));_c.displayName=pn.displayName;const wc=u.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(jn,{ref:l,className:N("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(gn,{children:e.jsx($l,{className:"h-4 w-4 fill-current"})})}),n]}));wc.displayName=jn.displayName;const ja=u.forwardRef(({className:s,inset:n,...a},l)=>e.jsx(vn,{ref:l,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...a}));ja.displayName=vn.displayName;const ut=u.forwardRef(({className:s,...n},a)=>e.jsx(bn,{ref:a,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));ut.displayName=bn.displayName;const ra=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});ra.displayName="DropdownMenuShortcut";const Bt=[{code:"en-US",name:"English",flag:Ul,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Bl,shortName:"CN"},{code:"ko-KR",name:"한국어",flag:Gl,shortName:"KR"}];function br(){const{i18n:s}=F(),n=r=>{s.changeLanguage(r)},a=Bt.find(r=>r.code===s.language)||Bt[1],l=a.flag;return e.jsxs(Ds,{children:[e.jsx(Es,{asChild:!0,children:e.jsxs(B,{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(gs,{align:"end",className:"w-[120px]",children:Bt.map(r=>{const c=r.flag,i=r.code===s.language;return e.jsxs(ye,{onClick:()=>n(r.code),className:N("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:N("text-sm",i&&"font-medium"),children:r.name})]},r.code)})})]})}function Cc(){const[s,n]=u.useState(!1),{t:a}=F("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(br,{})}),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(Ae,{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(jc,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(ve,{open:s,onOpenChange:n,children:e.jsx(pe,{children:e.jsxs(Ne,{children:[e.jsx(be,{children:a("signIn.resetPassword.title")}),e.jsx(Ee,{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(B,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>Rt(l).then(()=>{A.success(a("common:copy.success"))}),children:e.jsx(Wl,{className:"h-4 w-4"})})]})})]})})})]})}const Sc=Object.freeze(Object.defineProperty({__proto__:null,default:Cc},Symbol.toStringTag,{value:"Module"})),ke=u.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:a=!1,...l},r)=>e.jsx("div",{ref:r,className:N("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}));ke.displayName="Layout";const Te=u.forwardRef(({className:s,...n},a)=>e.jsx("div",{ref:a,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Te.displayName="LayoutHeader";const Re=u.forwardRef(({className:s,fixedHeight:n,...a},l)=>e.jsx("div",{ref:l,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...a}));Re.displayName="LayoutBody";const yr=Yl,Nr=Ql,_r=Jl,xe=Zl,me=Xl,ue=eo,oe=u.forwardRef(({className:s,sideOffset:n=4,...a},l)=>e.jsx(yn,{ref:l,sideOffset:n,className:N("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}));oe.displayName=yn.displayName;function $t(){const{pathname:s}=ca();return{checkActiveNav:a=>{if(a==="/"&&s==="/")return!0;const l=a.replace(/^\//,""),r=s.replace(/^\//,"");return l?r.startsWith(l):!1}}}function wr({key:s,defaultValue:n}){const[a,l]=u.useState(()=>{const r=localStorage.getItem(s);return r!==null?JSON.parse(r):n});return u.useEffect(()=>{localStorage.setItem(s,JSON.stringify(a))},[a,s]),[a,l]}function kc(){const[s,n]=wr({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 Tc({links:s,isCollapsed:n,className:a,closeNav:l}){const{t:r}=F(),c=({sub:i,...m})=>{const x=`${r(m.title)}-${m.href}`;return n&&i?u.createElement(Ec,{...m,sub:i,key:x,closeNav:l}):n?u.createElement(Dc,{...m,key:x,closeNav:l}):i?u.createElement(Pc,{...m,sub:i,key:x,closeNav:l}):u.createElement(Cr,{...m,key:x,closeNav:l})};return e.jsx("div",{"data-collapsed":n,className:N("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(xe,{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 Cr({title:s,icon:n,label:a,href:l,closeNav:r,subLink:c=!1}){const{checkActiveNav:i}=$t(),{t:m}=F();return e.jsxs(Ls,{to:l,onClick:r,className:N(Xs({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}),m(s),a&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:m(a)})]})}function Pc({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=$t(),{isExpanded:i,toggleItem:m}=kc(),{t:x}=F(),o=!!l?.find(k=>c(k.href)),d=x(s),p=i(d)||o;return e.jsxs(yr,{open:p,onOpenChange:()=>m(d),children:[e.jsxs(Nr,{className:N(Xs({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:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Nn,{stroke:1})})]}),e.jsx(_r,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:l.map(k=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Cr,{...k,subLink:!0,closeNav:r})},x(k.title)))})})]})}function Dc({title:s,icon:n,label:a,href:l,closeNav:r}){const{checkActiveNav:c}=$t(),{t:i}=F();return e.jsxs(me,{delayDuration:0,children:[e.jsx(ue,{asChild:!0,children:e.jsxs(Ls,{to:l,onClick:r,className:N(Xs({variant:c(l)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:i(s)})]})}),e.jsxs(oe,{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 Ec({title:s,icon:n,label:a,sub:l,closeNav:r}){const{checkActiveNav:c}=$t(),{t:i}=F(),m=!!l?.find(x=>c(x.href));return e.jsxs(Ds,{children:[e.jsxs(me,{delayDuration:0,children:[e.jsx(ue,{asChild:!0,children:e.jsx(Es,{asChild:!0,children:e.jsx(R,{variant:m?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(oe,{side:"right",className:"flex items-center gap-4",children:[i(s)," ",a&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:i(a)}),e.jsx(Nn,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(gs,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(ja,{children:[i(s)," ",a?`(${i(a)})`:""]}),e.jsx(ut,{}),l.map(({title:x,icon:o,label:d,href:p})=>e.jsx(ye,{asChild:!0,children:e.jsxs(Ls,{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 Sr=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(so,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(to,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(_n,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(xa,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(ao,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(no,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(za,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(ro,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(wn,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(lo,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Cn,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(oo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(io,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(co,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(za,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(mo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(uo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(xo,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(Sn,{size:18})}]}];function Rc({className:s,isCollapsed:n,setIsCollapsed:a}){const[l,r]=u.useState(!1),{t:c}=F();return u.useEffect(()=>{l?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[l]),e.jsxs("aside",{className:N(`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(ke,{children:[e.jsxs(Te,{className:"sticky top-0 justify-between px-4 py-3 shadow md:px-4",children:[e.jsxs("div",{className:`flex items-center ${n?"":"gap-2"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",className:`transition-all ${n?"h-6 w-6":"h-8 w-8"}`,children:[e.jsx("rect",{width:"256",height:"256",fill:"none"}),e.jsx("line",{x1:"208",y1:"128",x2:"128",y2:"208",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("line",{x1:"192",y1:"40",x2:"40",y2:"192",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"16"}),e.jsx("span",{className:"sr-only",children:"Website Name"})]}),e.jsx("div",{className:`flex flex-col justify-end truncate ${n?"invisible w-0":"visible w-auto"}`,children:e.jsx("span",{className:"font-medium",children:window?.settings?.title})})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":c("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":l,onClick:()=>r(i=>!i),children:l?e.jsx(ho,{}):e.jsx(fo,{})})]}),e.jsx(Tc,{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:Sr}),e.jsx("div",{className:N("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:N("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-green-500/70"}),e.jsxs("span",{className:"tracking-wide",children:["v",window?.settings?.version]})]})}),e.jsx(R,{onClick:()=>a(i=>!i),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":c("common:toggleSidebar"),children:e.jsx(po,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function Ic(){const[s,n]=wr({key:"collapsed-sidebar",defaultValue:!1});return u.useEffect(()=>{const a=()=>{n(window.innerWidth<768?!1:s)};return a(),window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}},[s,n]),[s,n]}function Vc(){const[s,n]=Ic();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(Rc,{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(da,{})})]})}const Fc=Object.freeze(Object.defineProperty({__proto__:null,default:Vc},Symbol.toStringTag,{value:"Module"})),Rs=u.forwardRef(({className:s,...n},a)=>e.jsx(Ve,{ref:a,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));Rs.displayName=Ve.displayName;const Mc=({children:s,...n})=>e.jsx(ve,{...n,children:e.jsx(pe,{className:"overflow-hidden p-0",children:e.jsx(Rs,{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})})}),$s=u.forwardRef(({className:s,...n},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(go,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ve.Input,{ref:a,className:N("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})]}));$s.displayName=Ve.Input.displayName;const Is=u.forwardRef(({className:s,...n},a)=>e.jsx(Ve.List,{ref:a,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));Is.displayName=Ve.List.displayName;const qs=u.forwardRef((s,n)=>e.jsx(Ve.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));qs.displayName=Ve.Empty.displayName;const $e=u.forwardRef(({className:s,...n},a)=>e.jsx(Ve.Group,{ref:a,className:N("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}));$e.displayName=Ve.Group.displayName;const et=u.forwardRef(({className:s,...n},a)=>e.jsx(Ve.Separator,{ref:a,className:N("-mx-1 h-px bg-border",s),...n}));et.displayName=Ve.Separator.displayName;const De=u.forwardRef(({className:s,...n},a)=>e.jsx(Ve.Item,{ref:a,className:N("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}));De.displayName=Ve.Item.displayName;function Oc(){const s=[];for(const n of Sr)if(n.href&&s.push(n),n.sub)for(const a of n.sub)s.push({...a,parent:n.title});return s}function ze(){const[s,n]=u.useState(!1),a=js(),l=Oc(),{t:r}=F("search"),{t:c}=F("nav");u.useEffect(()=>{const m=x=>{x.key==="k"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),n(o=>!o))};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[]);const i=u.useCallback(m=>{n(!1),a(m)},[a]);return e.jsxs(e.Fragment,{children:[e.jsxs(B,{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(kn,{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(Mc,{open:s,onOpenChange:n,children:[e.jsx($s,{placeholder:r("placeholder")}),e.jsxs(Is,{children:[e.jsx(qs,{children:r("noResults")}),e.jsx($e,{heading:r("title"),children:l.map(m=>e.jsxs(De,{value:`${m.parent?m.parent+" ":""}${m.title}`,onSelect:()=>i(m.href),children:[e.jsx("div",{className:"mr-2",children:m.icon}),e.jsx("span",{children:c(m.title)}),m.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c(m.parent)})]},m.href))})]})]})]})}function Fe(){const{theme:s,setTheme:n}=Hi();return u.useEffect(()=>{const a=s==="dark"?"#020817":"#fff",l=document.querySelector("meta[name='theme-color']");l&&l.setAttribute("content",a)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(R,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(jo,{size:20}):e.jsx(vo,{size:20})}),e.jsx(br,{})]})}const kr=u.forwardRef(({className:s,...n},a)=>e.jsx(Tn,{ref:a,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));kr.displayName=Tn.displayName;const Tr=u.forwardRef(({className:s,...n},a)=>e.jsx(Pn,{ref:a,className:N("aspect-square h-full w-full",s),...n}));Tr.displayName=Pn.displayName;const Pr=u.forwardRef(({className:s,...n},a)=>e.jsx(Dn,{ref:a,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));Pr.displayName=Dn.displayName;function Me(){const s=js(),n=on(),a=bo(cc),{t:l}=F(["common"]),r=()=>{ur(),n(ic()),s("/sign-in")},c=a?.email?.split("@")[0]||l("common:user"),i=c.substring(0,2).toUpperCase();return e.jsxs(Ds,{children:[e.jsx(Es,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(kr,{className:"h-8 w-8",children:[e.jsx(Tr,{src:a?.avatar_url,alt:c}),e.jsx(Pr,{children:i})]})})}),e.jsxs(gs,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(ja,{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(ut,{}),e.jsx(ye,{asChild:!0,children:e.jsxs(Ls,{to:"/config/system",children:[l("common:settings"),e.jsx(ra,{children:"⌘S"})]})}),e.jsx(ut,{}),e.jsxs(ye,{onClick:r,children:[l("common:logout"),e.jsx(ra,{children:"⇧⌘Q"})]})]})]})}const H=window?.settings?.secure_path,zc=s=>V.get(H+"/stat/getOrder",{params:s}),Lc=()=>V.get(H+"/stat/getStats"),Wa=s=>V.get(H+"/stat/getTrafficRank",{params:s}),Ac=()=>V.get(H+"/theme/getThemes"),$c=s=>V.post(H+"/theme/getThemeConfig",{name:s}),qc=(s,n)=>V.post(H+"/theme/saveThemeConfig",{name:s,config:n}),Hc=s=>{const n=new FormData;return n.append("file",s),V.post(H+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},Kc=s=>V.post(H+"/theme/delete",{name:s}),Uc=s=>V.post(H+"/config/save",s),Dr=()=>V.get(H+"/server/manage/getNodes"),Bc=s=>V.post(H+"/server/manage/save",s),Gc=s=>V.post(H+"/server/manage/drop",s),Wc=s=>V.post(H+"/server/manage/copy",s),Yc=s=>V.post(H+"/server/manage/update",s),Qc=s=>V.post(H+"/server/manage/sort",s),qt=()=>V.get(H+"/server/group/fetch"),Jc=s=>V.post(H+"/server/group/save",s),Zc=s=>V.post(H+"/server/group/drop",s),Er=()=>V.get(H+"/server/route/fetch"),Xc=s=>V.post(H+"/server/route/save",s),ed=s=>V.post(H+"/server/route/drop",s),sd=()=>V.get(H+"/payment/fetch"),td=()=>V.get(H+"/payment/getPaymentMethods"),ad=s=>V.post(H+"/payment/getPaymentForm",s),nd=s=>V.post(H+"/payment/save",s),rd=s=>V.post(H+"/payment/drop",s),ld=s=>V.post(H+"/payment/show",s),od=s=>V.post(H+"/payment/sort",s),id=s=>V.post(H+"/notice/save",s),cd=s=>V.post(H+"/notice/drop",s),dd=s=>V.post(H+"/notice/show",s),md=()=>V.get(H+"/knowledge/fetch"),ud=s=>V.get(H+"/knowledge/fetch?id="+s),xd=s=>V.post(H+"/knowledge/save",s),hd=s=>V.post(H+"/knowledge/drop",s),fd=s=>V.post(H+"/knowledge/show",s),pd=s=>V.post(H+"/knowledge/sort",s),Hs=()=>V.get(H+"/plan/fetch"),gd=s=>V.post(H+"/plan/save",s),Gt=s=>V.post(H+"/plan/update",s),jd=s=>V.post(H+"/plan/drop",s),vd=s=>V.post(H+"/plan/sort",{ids:s}),bd=async s=>V.post(H+"/order/fetch",s),yd=s=>V.post(H+"/order/detail",s),Nd=s=>V.post(H+"/order/paid",s),_d=s=>V.post(H+"/order/cancel",s),Ya=s=>V.post(H+"/order/update",s),wd=s=>V.post(H+"/order/assign",s),Cd=s=>V.post(H+"/coupon/fetch",s),Sd=s=>V.post(H+"/coupon/generate",s),kd=s=>V.post(H+"/coupon/drop",s),Td=s=>V.post(H+"/coupon/update",s),Pd=s=>V.post(H+"/user/fetch",s),Dd=s=>V.post(H+"/user/update",s),Ed=s=>V.post(H+"/user/resetSecret",s),Rd=s=>V.post(H+"/user/generate",s),Id=s=>V.post(H+"/stat/getStatUser",s),Vd=s=>V.post(H+"/ticket/fetch",s),Fd=s=>V.get(H+"/ticket/fetch?id= "+s),Md=s=>V.post(H+"/ticket/close",{id:s}),ys=(s="")=>V.get(H+"/config/fetch?key="+s),Ns=s=>V.post(H+"/config/save",s),Od=()=>V.get(H+"/config/getEmailTemplate"),zd=()=>V.post(H+"/config/testSendMail"),Ld=()=>V.post(H+"/config/setTelegramWebhook"),va=yo,Ht=u.forwardRef(({className:s,...n},a)=>e.jsx(En,{ref:a,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));Ht.displayName=En.displayName;const Ts=u.forwardRef(({className:s,...n},a)=>e.jsx(Rn,{ref:a,className:N("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}));Ts.displayName=Rn.displayName;const St=u.forwardRef(({className:s,...n},a)=>e.jsx(In,{ref:a,className:N("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));St.displayName=In.displayName;const J=No,ws=Do,Z=_o,W=u.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Vn,{ref:l,className:N("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(wo,{asChild:!0,children:e.jsx(ha,{className:"h-4 w-4 opacity-50"})})]}));W.displayName=Vn.displayName;const Rr=u.forwardRef(({className:s,...n},a)=>e.jsx(Fn,{ref:a,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Co,{className:"h-4 w-4"})}));Rr.displayName=Fn.displayName;const Ir=u.forwardRef(({className:s,...n},a)=>e.jsx(Mn,{ref:a,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(ha,{className:"h-4 w-4"})}));Ir.displayName=Mn.displayName;const Y=u.forwardRef(({className:s,children:n,position:a="popper",...l},r)=>e.jsx(So,{children:e.jsxs(On,{ref:r,className:N("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(Rr,{}),e.jsx(ko,{className:N("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(Ir,{})]})}));Y.displayName=On.displayName;const Ad=u.forwardRef(({className:s,...n},a)=>e.jsx(zn,{ref:a,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));Ad.displayName=zn.displayName;const q=u.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Ln,{ref:l,className:N("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(To,{children:e.jsx(zs,{className:"h-4 w-4"})})}),e.jsx(Po,{children:n})]}));q.displayName=Ln.displayName;const $d=u.forwardRef(({className:s,...n},a)=>e.jsx(An,{ref:a,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));$d.displayName=An.displayName;function Ks({className:s,classNames:n,showOutsideDays:a=!0,...l}){return e.jsx(Eo,{showOutsideDays:a,className:N("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:N(Js({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:N("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:N(Js({variant:"ghost"}),"h-8 w-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start",day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...n},components:{IconLeft:({className:r,...c})=>e.jsx($n,{className:N("h-4 w-4",r),...c}),IconRight:({className:r,...c})=>e.jsx(ua,{className:N("h-4 w-4",r),...c})},...l})}Ks.displayName="Calendar";const ms=Io,us=Vo,ls=u.forwardRef(({className:s,align:n="center",sideOffset:a=4,...l},r)=>e.jsx(Ro,{children:e.jsx(qn,{ref:r,align:n,sideOffset:a,className:N("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})}));ls.displayName=qn.displayName;const Cs={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},lt=s=>(s/100).toFixed(2),qd=({active:s,payload:n,label:a})=>{const{t:l}=F();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"))?`¥${lt(r.value)}`:l("dashboard:overview.transactions",{count:r.value})})]},c))]}):null},Hd=[{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"}],Kd=(s,n)=>{const a=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let l;switch(s){case"7d":l=es(a,7);break;case"30d":l=es(a,30);break;case"90d":l=es(a,90);break;case"180d":l=es(a,180);break;case"365d":l=es(a,365);break;default:l=es(a,30)}return{startDate:l,endDate:a}};function Ud(){const[s,n]=u.useState("amount"),[a,l]=u.useState("30d"),[r,c]=u.useState({from:es(new Date,7),to:new Date}),{t:i}=F(),{startDate:m,endDate:x}=Kd(a,r),{data:o}=ne({queryKey:["orderStat",{start_date:Xe(m,"yyyy-MM-dd"),end_date:Xe(x,"yyyy-MM-dd")}],queryFn:async()=>{const{data:d}=await zc({start_date:Xe(m,"yyyy-MM-dd"),end_date:Xe(x,"yyyy-MM-dd")});return d},refetchInterval:3e4});return e.jsxs(Ae,{children:[e.jsx(Ge,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ps,{children:i("dashboard:overview.title")}),e.jsxs(Qs,{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(J,{value:a,onValueChange:d=>l(d),children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Z,{placeholder:i("dashboard:overview.selectTimeRange")})}),e.jsx(Y,{children:Hd.map(d=>e.jsx(q,{value:d.value,children:i(d.label)},d.value))})]}),a==="custom"&&e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(B,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx(ft,{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:[Xe(r.from,"yyyy-MM-dd")," -"," ",Xe(r.to,"yyyy-MM-dd")]}):Xe(r.from,"yyyy-MM-dd"):i("dashboard:overview.selectDate")})]})}),e.jsx(ls,{className:"w-auto p-0",align:"end",children:e.jsx(Ks,{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(va,{value:s,onValueChange:d=>n(d),children:e.jsxs(Ht,{children:[e.jsx(Ts,{value:"amount",children:i("dashboard:overview.amount")}),e.jsx(Ts,{value:"count",children:i("dashboard:overview.count")})]})})]})]})}),e.jsxs(We,{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:["¥",lt(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")," ¥",lt(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:["¥",lt(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(Fo,{width:"100%",height:"100%",children:e.jsxs(Mo,{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:Cs.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Cs.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:Cs.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Cs.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Oo,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>Xe(new Date(d),"MM-dd",{locale:$o})}),e.jsx(zo,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:d=>s==="amount"?`¥${lt(d)}`:i("dashboard:overview.transactions",{count:d})}),e.jsx(Lo,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Ao,{content:e.jsx(qd,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(La,{type:"monotone",dataKey:"paid_total",name:i("dashboard:overview.orderAmount"),stroke:Cs.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(La,{type:"monotone",dataKey:"commission_total",name:i("dashboard:overview.commissionAmount"),stroke:Cs.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(Aa,{dataKey:"paid_count",name:i("dashboard:overview.orderCount"),fill:Cs.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(Aa,{dataKey:"commission_count",name:i("dashboard:overview.commissionCount"),fill:Cs.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function re({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function Bd(){return e.jsxs(Ae,{children:[e.jsxs(Ge,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(re,{className:"h-4 w-[120px]"}),e.jsx(re,{className:"h-4 w-4"})]}),e.jsxs(We,{children:[e.jsx(re,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx(re,{className:"h-4 w-[100px]"})]})]})]})}function Gd(){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(Bd,{},n))})}var se=(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))(se||{});const nt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},rt={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var ss=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(ss||{}),de=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(de||{});const vt={0:"待确认",1:"发放中",2:"有效",3:"无效"},bt={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Se=(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))(Se||{});const Wd={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var Ce=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s))(Ce||{});const Ms=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"}],fs={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a"};var Le=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Le||{});const Yd={1:"按金额优惠",2:"按比例优惠"};var Ps=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Ps||{}),Ie=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(Ie||{}),ct=(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))(ct||{});function Ss({title:s,value:n,icon:a,trend:l,description:r,onClick:c,highlight:i,className:m}){return e.jsxs(Ae,{className:N("transition-colors",c&&"cursor-pointer hover:bg-muted/50",i&&"border-primary/50",m),onClick:c,children:[e.jsxs(Ge,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ps,{className:"text-sm font-medium",children:s}),a]}),e.jsxs(We,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),l?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Go,{className:N("h-4 w-4",l.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("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 Qd({className:s}){const n=js(),{t:a}=F(),{data:l,isLoading:r}=ne({queryKey:["dashboardStats"],queryFn:async()=>(await Lc()).data,refetchInterval:1e3*60*5});if(r||!l)return e.jsx(Gd,{});const c=()=>{const i=new URLSearchParams;i.set("commission_status",de.PENDING.toString()),i.set("status",se.COMPLETED.toString()),i.set("commission_balance","gt:0"),n(`/finance/order?${i.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Ss,{title:a("dashboard:stats.todayIncome"),value:Fs(l.todayIncome),icon:e.jsx(qo,{className:"h-4 w-4 text-emerald-500"}),trend:{value:l.dayIncomeGrowth,label:a("dashboard:stats.vsYesterday"),isPositive:l.dayIncomeGrowth>0}}),e.jsx(Ss,{title:a("dashboard:stats.monthlyIncome"),value:Fs(l.currentMonthIncome),icon:e.jsx(Ho,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.monthIncomeGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.monthIncomeGrowth>0}}),e.jsx(Ss,{title:a("dashboard:stats.pendingTickets"),value:l.ticketPendingTotal,icon:e.jsx(Ko,{className:N("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(Ss,{title:a("dashboard:stats.pendingCommission"),value:l.commissionPendingTotal,icon:e.jsx(Uo,{className:N("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(Ss,{title:a("dashboard:stats.monthlyNewUsers"),value:l.currentMonthNewUsers,icon:e.jsx(ea,{className:"h-4 w-4 text-blue-500"}),trend:{value:l.userGrowth,label:a("dashboard:stats.vsLastMonth"),isPositive:l.userGrowth>0}}),e.jsx(Ss,{title:a("dashboard:stats.totalUsers"),value:l.totalUsers,icon:e.jsx(ea,{className:"h-4 w-4 text-muted-foreground"}),description:a("dashboard:stats.activeUsers",{count:l.activeUsers})}),e.jsx(Ss,{title:a("dashboard:stats.monthlyUpload"),value:cs(l.monthTraffic.upload),icon:e.jsx(dt,{className:"h-4 w-4 text-emerald-500"}),description:a("dashboard:stats.todayTraffic",{value:cs(l.todayTraffic.upload)})}),e.jsx(Ss,{title:a("dashboard:stats.monthlyDownload"),value:cs(l.monthTraffic.download),icon:e.jsx(Bo,{className:"h-4 w-4 text-blue-500"}),description:a("dashboard:stats.todayTraffic",{value:cs(l.todayTraffic.download)})})]})}const Zs=u.forwardRef(({className:s,children:n,...a},l)=>e.jsxs(Hn,{ref:l,className:N("relative overflow-hidden",s),...a,children:[e.jsx(Wo,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(It,{}),e.jsx(Yo,{})]}));Zs.displayName=Hn.displayName;const It=u.forwardRef(({className:s,orientation:n="vertical",...a},l)=>e.jsx(Kn,{ref:l,orientation:n,className:N("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(Qo,{className:"relative flex-1 rounded-full bg-border"})}));It.displayName=Kn.displayName;const la={today:{getValue:()=>{const s=Zo();return{start:s,end:Xo(s,1)}}},last7days:{getValue:()=>{const s=new Date;return{start:es(s,7),end:s}}},last30days:{getValue:()=>{const s=new Date;return{start:es(s,30),end:s}}},custom:{getValue:()=>null}};function Qa({selectedRange:s,customDateRange:n,onRangeChange:a,onCustomRangeChange:l}){const{t:r}=F(),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(J,{value:s,onValueChange:a,children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Z,{placeholder:r("dashboard:trafficRank.selectTimeRange")})}),e.jsx(Y,{position:"popper",className:"z-50",children:Object.entries(la).map(([i])=>e.jsx(q,{value:i,children:c[i]},i))})]}),s==="custom"&&e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(B,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ft,{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:[Xe(n.from,"yyyy-MM-dd")," -"," ",Xe(n.to,"yyyy-MM-dd")]}):Xe(n.from,"yyyy-MM-dd"):e.jsx("span",{children:r("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(ls,{className:"w-auto p-0",align:"end",children:e.jsx(Ks,{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 Bs=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Jd({className:s}){const{t:n}=F(),[a,l]=u.useState("today"),[r,c]=u.useState({from:es(new Date,7),to:new Date}),[i,m]=u.useState("today"),[x,o]=u.useState({from:es(new Date,7),to:new Date}),d=u.useMemo(()=>a==="custom"?{start:r.from,end:r.to}:la[a].getValue(),[a,r]),p=u.useMemo(()=>i==="custom"?{start:x.from,end:x.to}:la[i].getValue(),[i,x]),{data:k}=ne({queryKey:["nodeTrafficRank",d.start,d.end],queryFn:()=>Wa({type:"node",start_time:_e.round(d.start.getTime()/1e3),end_time:_e.round(d.end.getTime()/1e3)}),refetchInterval:3e4}),{data:I}=ne({queryKey:["userTrafficRank",p.start,p.end],queryFn:()=>Wa({type:"user",start_time:_e.round(p.start.getTime()/1e3),end_time:_e.round(p.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(Ae,{children:[e.jsx(Ge,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(ps,{className:"flex items-center text-base font-medium",children:[e.jsx(Jo,{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($a,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(We,{className:"flex-1",children:k?.data?e.jsxs(Zs,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:k.data.map(f=>e.jsx(xe,{delayDuration:200,children:e.jsxs(me,{children:[e.jsx(ue,{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:N("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(sa,{className:"mr-1 h-3 w-3"}):e.jsx(ta,{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/k.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Bs(f.value)})]})]})})}),e.jsx(oe,{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:Bs(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Bs(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(It,{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(Ae,{children:[e.jsx(Ge,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(ps,{className:"flex items-center text-base font-medium",children:[e.jsx(ea,{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:m,onCustomRangeChange:o}),e.jsx($a,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(We,{className:"flex-1",children:I?.data?e.jsxs(Zs,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:I.data.map(f=>e.jsx(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{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:N("ml-2 flex items-center text-xs font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?e.jsx(sa,{className:"mr-1 h-3 w-3"}):e.jsx(ta,{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/I.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Bs(f.value)})]})]})})}),e.jsx(oe,{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:Bs(f.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:Bs(f.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",f.change>=0?"text-green-600":"text-red-600"),children:[f.change>=0?"+":"",f.change,"%"]})]})})]})},f.id))}),e.jsx(It,{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 Zd=Os("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:N(Zd({variant:n}),s),...a})}const le=window?.settings?.secure_path,Vr=5*60*1e3,oa=new Map,Xd=s=>{const n=oa.get(s);return n?Date.now()-n.timestamp>Vr?(oa.delete(s),null):n.data:null},em=(s,n)=>{oa.set(s,{data:n,timestamp:Date.now()})},sm=async(s,n=Vr)=>{const a=Xd(s);if(a)return a;const l=await V.get(s);return em(s,l),l},tm={getList:s=>V.post(`${le}/user/fetch`,s),update:s=>V.post(`${le}/user/update`,s),resetSecret:s=>V.post(`${le}/user/resetSecret`,{id:s}),generate:s=>V.post(`${le}/user/generate`,s),getStats:s=>V.post(`${le}/stat/getStatUser`,s),destroy:s=>V.post(`${le}/user/destroy`,{id:s})},Ja={getList:()=>sm(`${le}/notice/fetch`),save:s=>V.post(`${le}/notice/save`,s),drop:s=>V.post(`${le}/notice/drop`,{id:s}),updateStatus:s=>V.post(`${le}/notice/show`,{id:s}),sort:s=>V.post(`${le}/notice/sort`,{ids:s})},Wt={getList:s=>V.post(`${le}/ticket/fetch`,s),getInfo:s=>V.get(`${le}/ticket/fetch?id=${s}`),reply:s=>V.post(`${le}/ticket/reply`,s),close:s=>V.post(`${le}/ticket/close`,{id:s})},Za={getSystemStatus:()=>V.get(`${le}/system/getSystemStatus`),getQueueStats:()=>V.get(`${le}/system/getQueueStats`),getQueueWorkload:()=>V.get(`${le}/system/getQueueWorkload`),getQueueMasters:()=>V.get(`${le}/system/getQueueMasters`),getSystemLog:s=>V.get(`${le}/system/getSystemLog`,{params:s})},hs={getPluginList:()=>V.get(`${le}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),V.post(`${le}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>V.post(`${le}/plugin/delete`,{code:s}),installPlugin:s=>V.post(`${le}/plugin/install`,{code:s}),uninstallPlugin:s=>V.post(`${le}/plugin/uninstall`,{code:s}),enablePlugin:s=>V.post(`${le}/plugin/enable`,{code:s}),disablePlugin:s=>V.post(`${le}/plugin/disable`,{code:s}),getPluginConfig:s=>V.get(`${le}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>V.post(`${le}/plugin/config`,{code:s,config:n})},kt=u.forwardRef(({className:s,value:n,...a},l)=>e.jsx(Un,{ref:l,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...a,children:e.jsx(ei,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));kt.displayName=Un.displayName;function am(){const{t:s}=F(),[n,a]=u.useState(null),[l,r]=u.useState(null),[c,i]=u.useState(!0),[m,x]=u.useState(!1),o=async()=>{try{x(!0);const[k,I]=await Promise.all([Za.getSystemStatus(),Za.getQueueStats()]);a(k.data),r(I.data)}catch(k){console.error("Error fetching system data:",k)}finally{i(!1),x(!1)}};u.useEffect(()=>{o();const k=setInterval(o,3e4);return()=>clearInterval(k)},[]);const d=()=>{o()};if(c)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(fa,{className:"h-6 w-6 animate-spin"})});const p=k=>k?e.jsx(Bn,{className:"h-5 w-5 text-green-500"}):e.jsx(Gn,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ae,{children:[e.jsxs(Ge,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(ps,{className:"flex items-center gap-2",children:[e.jsx(si,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Qs,{children:s("dashboard:queue.status.description")})]}),e.jsx(B,{variant:"outline",size:"icon",onClick:d,disabled:m,children:e.jsx(ti,{className:N("h-4 w-4",m&&"animate-spin")})})]}),e.jsx(We,{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(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{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(kt,{value:(l?.recentJobs||0)/(l?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(oe,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:l?.periods?.recentJobs||0})})})]})}),e.jsx(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{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(kt,{value:(l?.jobsPerMinute||0)/(l?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(oe,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:l?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(Ae,{children:[e.jsxs(Ge,{children:[e.jsxs(ps,{className:"flex items-center gap-2",children:[e.jsx(ai,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Qs,{children:s("dashboard:queue.details.description")})]}),e.jsx(We,{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(kt,{value:(l?.processes||0)/((l?.processes||0)+(l?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]})}function nm(){const{t:s}=F();return e.jsxs(ke,{children:[e.jsxs(Te,{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(ze,{}),e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Qd,{}),e.jsx(Ud,{}),e.jsx(Jd,{}),e.jsx(am,{})]})})})]})}const rm=Object.freeze(Object.defineProperty({__proto__:null,default:nm},Symbol.toStringTag,{value:"Module"})),we=u.forwardRef(({className:s,orientation:n="horizontal",decorative:a=!0,...l},r)=>e.jsx(Wn,{ref:r,decorative:a,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...l}));we.displayName=Wn.displayName;function lm({className:s,items:n,...a}){const{pathname:l}=ca(),r=js(),[c,i]=u.useState(l??"/settings"),m=o=>{i(o),r(o)},{t:x}=F("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(J,{value:c,onValueChange:m,children:[e.jsx(W,{className:"h-12 sm:w-48",children:e.jsx(Z,{placeholder:"Theme"})}),e.jsx(Y,{children:n.map(o=>e.jsx(q,{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:N("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...a,children:n.map(o=>e.jsxs(Ls,{to:o.href,className:N(Xs({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 om=[{title:"site.title",key:"site",icon:e.jsx(ni,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Cn,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Sn,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(ri,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(wn,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(li,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(oi,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(_n,{size:18}),href:"/config/system/app",description:"app.description"}];function im(){const{t:s}=F("settings");return e.jsxs(ke,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(we,{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(lm,{items:om})}),e.jsx("div",{className:"w-full p-1 pr-4 lg:max-w-xl",children:e.jsx("div",{className:"pb-16",children:e.jsx(da,{})})})]})]})]})}const cm=Object.freeze(Object.defineProperty({__proto__:null,default:im},Symbol.toStringTag,{value:"Module"})),U=u.forwardRef(({className:s,...n},a)=>e.jsx(Yn,{className:N("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(ii,{className:N("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")})}));U.displayName=Yn.displayName;const _s=u.forwardRef(({className:s,...n},a)=>e.jsx("textarea",{className:N("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}));_s.displayName="Textarea";const dm=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 mm(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),{data:r}=ne({queryKey:["settings","site"],queryFn:()=>ys("site")}),{data:c}=ne({queryKey:["plans"],queryFn:()=>Hs()}),i=he({resolver:ge(dm),defaultValues:{},mode:"onBlur"}),{mutateAsync:m}=ds({mutationFn:Ns,onSuccess:d=>{d.data&&A.success(s("common.autoSaved"))}});u.useEffect(()=>{if(r?.data?.site){const d=r?.data?.site;Object.entries(d).forEach(([p,k])=>{i.setValue(p,k)}),l.current=d}},[r]);const x=u.useCallback(_e.debounce(async d=>{if(!_e.isEqual(d,l.current)){a(!0);try{const p=Object.entries(d).reduce((k,[I,f])=>(k[I]=f===null?"":f,k),{});await m(p),l.current=d}finally{a(!1)}}},1e3),[m]),o=u.useCallback(d=>{x(d)},[x]);return u.useEffect(()=>{const d=i.watch(p=>{o(p)});return()=>d.unsubscribe()},[i.watch,o]),e.jsx(je,{...i,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:i.control,name:"app_name",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(_,{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(b,{control:i.control,name:"app_description",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(_,{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(b,{control:i.control,name:"app_url",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(_,{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(b,{control:i.control,name:"force_https",render:({field:d})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(M,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(b,{control:i.control,name:"logo",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(_,{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(b,{control:i.control,name:"subscribe_url",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(_s,{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(b,{control:i.control,name:"tos_url",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(_,{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(b,{control:i.control,name:"stop_register",render:({field:d})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(M,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:!!d.value,onCheckedChange:p=>{d.onChange(Number(p)),o(i.getValues())}})})]})}),e.jsx(b,{control:i.control,name:"try_out_plan_id",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(J,{value:d.value?.toString(),onValueChange:p=>{d.onChange(Number(p)),o(i.getValues())},children:[e.jsx(W,{children:e.jsx(Z,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("site.form.tryOut.placeholder")}),c?.data?.map(p=>e.jsx(q,{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(b,{control:i.control,name:"try_out_hour",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(_,{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(b,{control:i.control,name:"currency",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(_,{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(b,{control:i.control,name:"currency_symbol",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(_,{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 um(){const{t:s}=F("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(we,{}),e.jsx(mm,{})]})}const xm=Object.freeze(Object.defineProperty({__proto__:null,default:um},Symbol.toStringTag,{value:"Module"})),hm=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()}),fm={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 pm(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),r=he({resolver:ge(hm),defaultValues:fm,mode:"onBlur"}),{data:c}=ne({queryKey:["settings","safe"],queryFn:()=>ys("safe")}),{mutateAsync:i}=ds({mutationFn:Ns,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.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 m=u.useCallback(_e.debounce(async o=>{if(!_e.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=u.useCallback(o=>{m(o)},[m]);return u.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(je,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"email_verify",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(M,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"email_gmail_limit_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(M,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"safe_mode_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(M,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"secure_path",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(_,{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(b,{control:r.control,name:"email_whitelist_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(M,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("email_whitelist_enable")&&e.jsx(b,{control:r.control,name:"email_whitelist_suffix",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(_s,{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(b,{control:r.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(M,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:r.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(_,{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(b,{control:r.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(_,{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(b,{control:r.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(M,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(K,{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(b,{control:r.control,name:"register_limit_count",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(_,{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(b,{control:r.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(_,{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(b,{control:r.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(M,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:r.control,name:"password_limit_count",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(_,{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(b,{control:r.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(_,{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 gm(){const{t:s}=F("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(Ne,{}),e.jsx(pm,{})]})}const jm=Object.freeze(Object.defineProperty({__proto__:null,default:gm},Symbol.toStringTag,{value:"Module"})),vm=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")}),bm={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 ym(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ue({resolver:he(vm),defaultValues:bm,mode:"onBlur"}),{data:c}=te({queryKey:["settings","subscribe"],queryFn:()=>gs("subscribe")}),{mutateAsync:i}=ls({mutationFn:js,onSuccess:o=>{o.data&&$.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(be.debounce(async o=>{if(!be.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(fe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(M,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择重置方式"})})}),e.jsxs(B,{children:[e.jsx(A,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(A,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(A,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(A,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(A,{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(b,{control:r.control,name:"surplus_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(M,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(A,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(A,{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(b,{control:r.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(A,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(A,{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(b,{control:r.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择"})}),e.jsxs(B,{children:[e.jsx(A,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(A,{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(b,{control:r.control,name:"subscribe_path",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{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(b,{control:r.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(M,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(M,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(K,{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 Nm(){const{t:s}=F("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(Ne,{}),e.jsx(ym,{})]})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:Nm},Symbol.toStringTag,{value:"Module"})),wm=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)}),Cm={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 Sm(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ue({resolver:he(wm),defaultValues:Cm,mode:"onBlur"}),{data:c}=te({queryKey:["settings","invite"],queryFn:()=>gs("invite")}),{mutateAsync:i}=ls({mutationFn:js,onSuccess:o=>{o.data&&$.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(be.debounce(async o=>{if(!be.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(fe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"invite_force",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(M,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"invite_commission",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(_,{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(b,{control:r.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(_,{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(b,{control:r.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(M,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(M,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(M,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(_,{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(b,{control:r.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(_,{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(b,{control:r.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(M,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(M,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:r.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("invite.commission_distribution.l1")}),e.jsx(_,{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(b,{control:r.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("invite.commission_distribution.l2")}),e.jsx(_,{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(b,{control:r.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("invite.commission_distribution.l3")}),e.jsx(_,{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 km(){const{t:s}=F("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(Ne,{}),e.jsx(Sm,{})]})}const Tm=Object.freeze(Object.defineProperty({__proto__:null,default:km},Symbol.toStringTag,{value:"Module"})),Pm=h.object({frontend_theme:h.string().nullable(),frontend_theme_sidebar:h.string().nullable(),frontend_theme_header:h.string().nullable(),frontend_theme_color:h.string().nullable(),frontend_background_url:h.string().url().nullable()}),Dm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Em(){const{data:s}=te({queryKey:["settings","frontend"],queryFn:()=>gs("frontend")}),n=ue({resolver:he(Pm),defaultValues:Dm,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){js(l).then(({data:r})=>{r&&$.success("更新成功")})}return e.jsx(fe,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(b,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:"边栏风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(K,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:"头部风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(K,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(v,{children:[e.jsx(y,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:N(Zs({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(ha,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(M,{children:"主题色"}),e.jsx(E,{})]})}),e.jsx(b,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(v,{children:[e.jsx(y,{children:"背景"}),e.jsx(_,{children:e.jsx(D,{placeholder:"请输入图片地址",...l})}),e.jsx(M,{children:"将会在后台登录页面进行展示。"}),e.jsx(E,{})]})}),e.jsx(V,{type:"submit",children:"保存设置"})]})})}function Rm(){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(Ne,{}),e.jsx(Em,{})]})}const Vm=Object.freeze(Object.defineProperty({__proto__:null,default:Rm},Symbol.toStringTag,{value:"Module"})),Im=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()}),Fm={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Mm(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ue({resolver:he(Im),defaultValues:Fm,mode:"onBlur"}),{data:c}=te({queryKey:["settings","server"],queryFn:()=>gs("server")}),{mutateAsync:i}=ls({mutationFn:js,onSuccess:d=>{d.data&&$.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(be.debounce(async d=>{if(!be.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(v,{children:[e.jsx(y,{className:"text-base",children:s("server.server_token.title")}),e.jsx(_,{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(me,{children:e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(G,{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(ci,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(re,{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(b,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(_,{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(b,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(_,{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(b,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(W,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(B,{children:[e.jsx(A,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(A,{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 Om(){const{t:s}=F("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(Ne,{}),e.jsx(Mm,{})]})}const zm=Object.freeze(Object.defineProperty({__proto__:null,default:Om},Symbol.toStringTag,{value:"Module"}));function Lm({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(je,{open:s,onOpenChange:n,children:e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Bn,{className:"h-5 w-5 text-green-500"}):e.jsx(Gn,{className:"h-5 w-5 text-destructive"}),e.jsx(ve,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ee,{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(Js,{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 Am=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 $m(){const{t:s}=F("settings"),[n,a]=m.useState(null),[l,r]=m.useState(!1),c=m.useRef(null),[i,u]=m.useState(!1),x=ue({resolver:he(Am),defaultValues:{},mode:"onBlur"}),{data:o}=te({queryKey:["settings","email"],queryFn:()=>gs("email")}),{data:d}=te({queryKey:["emailTemplate"],queryFn:()=>Od()}),{mutateAsync:p}=ls({mutationFn:js,onSuccess:S=>{S.data&&$.success(s("common.autoSaved"))}}),{mutate:T,isPending:R}=ls({mutationFn:zd,onMutate:()=>{a(null),r(!1)},onSuccess:S=>{a(S.data),r(!0),S.data.error?$.error(s("email.test.error")):$.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(be.debounce(async S=>{if(!be.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(fe,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:x.control,name:"email_host",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_host.title")}),e.jsx(_,{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(b,{control:x.control,name:"email_port",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_port.title")}),e.jsx(_,{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(b,{control:x.control,name:"email_encryption",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(W,{onValueChange:S.onChange,value:S.value||"none",children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:"请选择加密方式"})})}),e.jsxs(B,{children:[e.jsx(A,{value:"none",children:s("email.email_encryption.none")}),e.jsx(A,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(A,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(M,{children:s("email.email_encryption.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_username",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_username.title")}),e.jsx(_,{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(b,{control:x.control,name:"email_password",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_password.title")}),e.jsx(_,{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(b,{control:x.control,name:"email_from_address",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_from.title")}),e.jsx(_,{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(b,{control:x.control,name:"email_template",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(W,{onValueChange:j=>{S.onChange(j),g(x.getValues())},value:S.value||void 0,children:[e.jsx(_,{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(A,{value:j,children:j},j))})]}),e.jsx(M,{children:s("email.email_template.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"remind_mail_enable",render:({field:S})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(M,{children:s("email.remind_mail.description")})]}),e.jsx(_,{children:e.jsx(K,{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(Lm,{open:l,onOpenChange:r,result:n})]})}function qm(){const{t:s}=F("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(Ne,{}),e.jsx($m,{})]})}const Hm=Object.freeze(Object.defineProperty({__proto__:null,default:qm},Symbol.toStringTag,{value:"Module"})),Km=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Um={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Bm(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ue({resolver:he(Km),defaultValues:Um,mode:"onBlur"}),{data:c}=te({queryKey:["settings","telegram"],queryFn:()=>gs("telegram")}),{mutateAsync:i}=ls({mutationFn:js,onSuccess:p=>{p.data&&$.success(s("common.autoSaved"))}}),{mutate:u,isPending:x}=ls({mutationFn:Ld,onSuccess:p=>{p.data&&$.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(be.debounce(async p=>{if(!be.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(fe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"telegram_bot_token",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(_,{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(v,{children:[e.jsx(y,{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(b,{control:r.control,name:"telegram_bot_enable",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(M,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(K,{checked:p.value||!1,onCheckedChange:T=>{p.onChange(T),d(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"telegram_discuss_link",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(_,{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 Gm(){const{t:s}=F("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(Ne,{}),e.jsx(Bm,{})]})}const Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"})),Ym=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()}),Qm={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Jm(){const{t:s}=F("settings"),[n,a]=m.useState(!1),l=m.useRef(null),r=ue({resolver:he(Ym),defaultValues:Qm,mode:"onBlur"}),{data:c}=te({queryKey:["settings","app"],queryFn:()=>gs("app")}),{mutateAsync:i}=ls({mutationFn:js,onSuccess:o=>{o.data&&$.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(be.debounce(async o=>{if(!be.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(fe,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"windows_version",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(_,{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(b,{control:r.control,name:"windows_download_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(_,{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(b,{control:r.control,name:"macos_version",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(_,{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(b,{control:r.control,name:"macos_download_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(_,{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(b,{control:r.control,name:"android_version",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.android.version.title")}),e.jsx(_,{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(b,{control:r.control,name:"android_download_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.android.download.title")}),e.jsx(_,{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 Zm(){const{t:s}=F("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(Ne,{}),e.jsx(Jm,{})]})}const Xm=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"})),ba=m.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:N("w-full caption-bottom text-sm",s),...n})}));ba.displayName="Table";const ya=m.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:N("[&_tr]:border-b",s),...n}));ya.displayName="TableHeader";const Na=m.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:N("[&_tr:last-child]:border-0",s),...n}));Na.displayName="TableBody";const eu=m.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:N("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));eu.displayName="TableFooter";const ws=m.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:N("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));ws.displayName="TableRow";const _a=m.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:N("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}));_a.displayName="TableHead";const Ws=m.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:N("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Ws.displayName="TableCell";const su=m.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:N("mt-4 text-sm text-muted-foreground",s),...n}));su.displayName="TableCaption";function tu({table:s}){const[n,a]=m.useState(""),{t:l}=F("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(W,{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(A,{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(di,{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($n,{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(ua,{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(mi,{className:"h-4 w-4"})]})]})]})]})}function as({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}=F("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(ba,{children:[e.jsx(ya,{children:s.getHeaderGroups().map(S=>e.jsx(ws,{className:"hover:bg-transparent",children:S.headers.map((j,C)=>{const P=j.column.getIsPinned()==="left",w=j.column.getIsPinned()==="right",k=P?f(T.indexOf(j.column)):void 0,L=w?g(R.indexOf(j.column)):void 0;return e.jsx(_a,{colSpan:j.colSpan,style:{width:j.getSize(),...P&&{left:k},...w&&{right:L}},className:N("h-11 bg-card px-4 text-muted-foreground",(P||w)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",P&&"before:right-0",w&&"before:left-0"]),children:j.isPlaceholder?null:kt(j.column.columnDef.header,j.getContext())},j.id)})},S.id))}),e.jsx(Na,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((S,j)=>e.jsx(ws,{"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,P)=>{const w=C.column.getIsPinned()==="left",k=C.column.getIsPinned()==="right",L=w?f(T.indexOf(C.column)):void 0,J=k?g(R.indexOf(C.column)):void 0;return e.jsx(Ws,{style:{width:C.column.getSize(),...w&&{left:L},...k&&{right:J}},className:N("bg-card",(w||k)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",w&&"before:right-0",k&&"before:left-0"]),children:kt(C.column.columnDef.cell,C.getContext())},C.id)})},S.id)):e.jsx(ws,{children:e.jsx(Ws,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:d("table.noData")})})})]})})}),x&&e.jsx(tu,{table:s})]})}const au=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())}),Xa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function Fr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Xa}){const{t:r}=F("payment"),[c,i]=m.useState(!1),[u,x]=m.useState(!1),[o,d]=m.useState([]),[p,T]=m.useState([]),R=au(r),f=ue({resolver:he(R),defaultValues:l,mode:"onChange"}),g=f.watch("payment");m.useEffect(()=>{c&&(async()=>{const{data:C}=await td();d(C)})()},[c]),m.useEffect(()=>{if(!g||!c)return;(async()=>{const C={payment:g,...a==="edit"&&{id:Number(f.getValues("id"))}};ad(C).then(({data:P})=>{T(P);const w=P.reduce((k,L)=>(L.field_name&&(k[L.field_name]=L.value??""),k),{});f.setValue("config",w)})})()},[g,c,f,a]);const S=async j=>{x(!0);try{(await nd(j)).data&&($.success(r("form.messages.success")),f.reset(Xa),s(),i(!1))}finally{x(!1)}};return e.jsxs(je,{open:c,onOpenChange:i,children:[e.jsx($e,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ke,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(ye,{children:e.jsx(ve,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(fe,{...f,children:e.jsxs("form",{onSubmit:f.handleSubmit(S),className:"space-y-4",children:[e.jsx(b,{control:f.control,name:"name",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.name.label")}),e.jsx(_,{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(b,{control:f.control,name:"icon",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.icon.label")}),e.jsx(_,{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(b,{control:f.control,name:"notify_domain",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.notify_domain.label")}),e.jsx(_,{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(b,{control:f.control,name:"handling_fee_percent",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...j,value:j.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"handling_fee_fixed",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...j,value:j.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(E,{})]})})]}),e.jsx(b,{control:f.control,name:"payment",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.payment.label")}),e.jsxs(W,{onValueChange:j.onChange,defaultValue:j.value,children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(B,{children:o.map(C=>e.jsx(A,{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(b,{control:f.control,name:`config.${j.field_name}`,render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{children:j.label}),e.jsx(_,{children:e.jsx(D,{...C,value:C.value||""})}),e.jsx(E,{})]})},j.field_name))}),e.jsxs(qe,{children:[e.jsx(pt,{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:N("-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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(qa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(re,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(sa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(ta,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ui,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:N("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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsx(qa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(re,{children:a})]})})]})}const Mr=xi,Or=hi,nu=fi,zr=m.forwardRef(({className:s,...n},a)=>e.jsx(Qn,{className:N("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}));zr.displayName=Qn.displayName;const wa=m.forwardRef(({className:s,...n},a)=>e.jsxs(nu,{children:[e.jsx(zr,{}),e.jsx(Jn,{ref:a,className:N("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})]}));wa.displayName=Jn.displayName;const Ca=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ca.displayName="AlertDialogHeader";const Sa=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Sa.displayName="AlertDialogFooter";const ka=m.forwardRef(({className:s,...n},a)=>e.jsx(Zn,{ref:a,className:N("text-lg font-semibold",s),...n}));ka.displayName=Zn.displayName;const Ta=m.forwardRef(({className:s,...n},a)=>e.jsx(Xn,{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ta.displayName=Xn.displayName;const Pa=m.forwardRef(({className:s,...n},a)=>e.jsx(er,{ref:a,className:N(Qs(),s),...n}));Pa.displayName=er.displayName;const Da=m.forwardRef(({className:s,...n},a)=>e.jsx(sr,{ref:a,className:N(Qs({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Da.displayName=sr.displayName;function We({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:u}){return e.jsxs(Mr,{children:[e.jsx(Or,{asChild:!0,children:n}),e.jsxs(wa,{className:N("sm:max-w-[425px]",u),children:[e.jsxs(Ca,{children:[e.jsx(ka,{children:a}),e.jsx(Ta,{children:l})]}),e.jsxs(Sa,{children:[e.jsx(Da,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r})}),e.jsx(Pa,{asChild:!0,children:e.jsx(V,{variant:i,onClick:s,children:c})})]})]})]})}const Lr=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"})}),ru=({refetch:s,isSortMode:n=!1})=>{const{t:a}=F("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ot,{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(H,{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(K,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await ld({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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{className:"ml-1",children:e.jsx(Lr,{className:"h-4 w-4"})}),e.jsx(re,{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(Fr,{refetch:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(zs,{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(We,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await rd({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(os,{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 lu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=F("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(Fr,{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(He,{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 ou(){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}=te({queryKey:["paymentList"],queryFn:async()=>{const{data:j}=await sd();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 P=parseInt(j.dataTransfer.getData("text/plain"));if(P===C)return;const w=[...i],[k]=w.splice(P,1);w.splice(C,0,k),u(w)},g=async()=>{r?od({ids:i.map(j=>j.id)}).then(()=>{T(),c(!1),$.success("排序保存成功")}):c(!0)},S=Be({data:i,columns:ru({refetch:T,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(as,{table:S,toolbar:j=>e.jsx(lu,{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 iu(){const{t:s}=F("payment");return e.jsxs(Ce,{children:[e.jsxs(Se,{className:"flex items-center justify-between",children:[e.jsx(Oe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(ou,{})})]})]})}const cu=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"}));function du({pluginName:s,onClose:n,onSuccess:a}){const{t:l}=F("plugin"),[r,c]=m.useState(!0),[i,u]=m.useState(!1),[x,o]=m.useState(null),d=pi({config:gi(ji())}),p=ue({resolver:he(d),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:g}=await Is.getPluginConfig(s);o(g),p.reset({config:Object.fromEntries(Object.entries(g).map(([S,j])=>[S,j.value]))})}catch{$.error(l("messages.configLoadError"))}finally{c(!1)}})()},[s]);const T=async f=>{u(!0);try{await Is.updatePluginConfig(s,f.config),$.success(l("messages.configSaveSuccess")),a()}catch{$.error(l("messages.configSaveError"))}finally{u(!1)}},R=(f,g)=>{switch(g.type){case"string":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:g.label||g.description}),e.jsx(_,{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(b,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:g.label||g.description}),e.jsx(_,{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(vi,{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(b,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:g.label||g.description}),e.jsxs(W,{onValueChange:S.onChange,defaultValue:S.value,children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:g.placeholder})})}),e.jsx(B,{children:g.options?.map(j=>e.jsx(A,{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(b,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(v,{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(y,{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(_,{children:e.jsx(K,{checked:S.value,onCheckedChange:S.onChange})})]})},f);case"text":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:g.label||g.description}),e.jsx(_,{children:e.jsx(vs,{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(ae,{className:"h-4 w-[200px]"}),e.jsx(ae,{className:"h-10 w-full"}),e.jsx(ae,{className:"h-4 w-[200px]"}),e.jsx(ae,{className:"h-10 w-full"})]}):e.jsx(fe,{...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 mu(){const{t:s}=F("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}=te({queryKey:["pluginList"],queryFn:async()=>{const{data:w}=await Is.getPluginList();return w}}),f=p?["all",...new Set(p.map(w=>w.category||"other"))]:["all"],g=p?.filter(w=>{const k=w.name.toLowerCase().includes(u.toLowerCase())||w.description.toLowerCase().includes(u.toLowerCase())||w.code.toLowerCase().includes(u.toLowerCase()),L=o==="all"||w.category===o;return k&&L}),S=async w=>{a(w),Is.installPlugin(w).then(()=>{$.success(s("messages.installSuccess")),R()}).catch(k=>{$.error(k.message||s("messages.installError"))}).finally(()=>{a(null)})},j=async w=>{a(w),Is.uninstallPlugin(w).then(()=>{$.success(s("messages.uninstallSuccess")),R()}).catch(k=>{$.error(k.message||s("messages.uninstallError"))}).finally(()=>{a(null)})},C=async(w,k)=>{a(w),(k?Is.disablePlugin:Is.enablePlugin)(w).then(()=>{$.success(s(k?"messages.disableSuccess":"messages.enableSuccess")),R()}).catch(J=>{$.error(J.message||s(k?"messages.disableError":"messages.enableError"))}).finally(()=>{a(null)})},P=w=>{p?.find(k=>k.code===w),i(w),r(!0)};return e.jsxs(Ce,{children:[e.jsxs(Se,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(xa,{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(Ve,{}),e.jsx(Ie,{})]})]}),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(kn,{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:w=>x(w.target.value),className:"pl-9"})]}),e.jsxs(W,{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(w=>e.jsx(A,{value:w,children:s(`category.${w}`)},w))})]})]}),e.jsxs(va,{defaultValue:"all",className:"w-full",children:[e.jsxs(qt,{children:[e.jsx(Cs,{value:"all",children:s("tabs.all")}),e.jsx(Cs,{value:"installed",children:s("tabs.installed")}),e.jsx(Cs,{value:"available",children:s("tabs.available")})]}),e.jsx(Ct,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:T?e.jsxs(e.Fragment,{children:[e.jsx(Yt,{}),e.jsx(Yt,{}),e.jsx(Yt,{})]}):g?.map(w=>e.jsx(Wt,{plugin:w,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:P,isLoading:n===w.name},w.name))})}),e.jsx(Ct,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g?.filter(w=>w.is_installed).map(w=>e.jsx(Wt,{plugin:w,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:P,isLoading:n===w.name},w.name))})}),e.jsx(Ct,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:g?.filter(w=>!w.is_installed).map(w=>e.jsx(Wt,{plugin:w,onInstall:S,onUninstall:j,onToggleEnable:C,onOpenConfig:P,isLoading:n===w.name},w.code))})})]})]}),e.jsx(je,{open:l,onOpenChange:r,children:e.jsxs(pe,{className:"sm:max-w-lg",children:[e.jsxs(ye,{children:[e.jsxs(ve,{children:[p?.find(w=>w.code===c)?.name," ",s("config.title")]}),e.jsx(Ee,{children:s("config.description")})]}),c&&e.jsx(du,{pluginName:c,onClose:()=>r(!1),onSuccess:()=>{r(!1),R()}})]})})]})]})}function Wt({plugin:s,onInstall:n,onUninstall:a,onToggleEnable:l,onOpenConfig:r,isLoading:c}){const{t:i}=F("plugin");return e.jsxs(Le,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(Ke,{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(us,{children:s.name}),s.is_installed&&e.jsx(H,{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(xa,{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(Ys,{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(Ue,{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(bi,{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(yi,{className:"mr-2 h-4 w-4"}),s.is_enabled?i("button.disable"):i("button.enable")]}),e.jsx(We,{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(os,{className:"h-4 w-4"})})})]}):e.jsx(V,{onClick:()=>n(s.code),disabled:c,loading:c,children:i("button.install")})})})]})}function Yt(){return e.jsxs(Le,{children:[e.jsxs(Ke,{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(ae,{className:"h-6 w-[200px]"}),e.jsx(ae,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ae,{className:"h-5 w-[120px]"}),e.jsx(ae,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(ae,{className:"h-4 w-[300px]"}),e.jsx(ae,{className:"h-4 w-[150px]"})]})]}),e.jsx(Ue,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(ae,{className:"h-9 w-[100px]"}),e.jsx(ae,{className:"h-9 w-[100px]"}),e.jsx(ae,{className:"h-8 w-8"})]})})]})}const uu=Object.freeze(Object.defineProperty({__proto__:null,default:mu},Symbol.toStringTag,{value:"Module"})),xu=(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(vs,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:N(Qs({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(l=>e.jsx("option",{value:l,children:s.select_options?.[l]},l))});break;default:a=null;break}return a};function hu({themeKey:s,themeInfo:n}){const{t:a}=F("theme"),[l,r]=m.useState(!1),[c,i]=m.useState(!1),[u,x]=m.useState(!1),o=ue({defaultValues:n.configs.reduce((T,R)=>(T[R.field_name]="",T),{})}),d=async()=>{i(!0),$c(s).then(({data:T})=>{Object.entries(T).forEach(([R,f])=>{o.setValue(R,f)})}).finally(()=>{i(!1)})},p=async T=>{x(!0),qc(s,T).then(()=>{$.success(a("config.success")),r(!1)}).finally(()=>{x(!1)})};return e.jsxs(je,{open:l,onOpenChange:T=>{r(T),T?d():o.reset()},children:[e.jsx($e,{asChild:!0,children:e.jsx(V,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(pe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:a("config.title",{name:n.name})}),e.jsx(Ee,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(fa,{className:"h-6 w-6 animate-spin"})}):e.jsx(fe,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(p),className:"space-y-4",children:[n.configs.map(T=>e.jsx(b,{control:o.control,name:T.field_name,render:({field:R})=>e.jsxs(v,{children:[e.jsx(y,{children:T.label}),e.jsx(_,{children:xu(T,R)}),e.jsx(E,{})]})},T.field_name)),e.jsxs(qe,{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 fu(){const{t:s}=F("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}=te({queryKey:["themeList"],queryFn:async()=>{const{data:z}=await Ac();return z}}),j=async z=>{a(z),Uc({frontend_theme:z}).then(()=>{$.success("主题切换成功"),S()}).finally(()=>{a(null)})},C=async z=>{if(!z.name.endsWith(".zip")){$.error(s("upload.error.format"));return}r(!0),Hc(z).then(()=>{$.success("主题上传成功"),i(!1),S()}).finally(()=>{r(!1),p.current&&(p.current.value="")})},P=z=>{z.preventDefault(),z.stopPropagation(),z.type==="dragenter"||z.type==="dragover"?x(!0):z.type==="dragleave"&&x(!1)},w=z=>{z.preventDefault(),z.stopPropagation(),x(!1),z.dataTransfer.files&&z.dataTransfer.files[0]&&C(z.dataTransfer.files[0])},k=()=>{o&&R(z=>z===0?o.images.length-1:z-1)},L=()=>{o&&R(z=>z===o.images.length-1?0:z+1)},J=(z,X)=>{R(0),d({name:z,images:X})};return e.jsxs(Ce,{children:[e.jsxs(Se,{className:"flex items-center justify-between",children:[e.jsx(Oe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(ea,{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(en,{}),e.jsx(en,{})]}):f?.themes&&Object.entries(f.themes).map(([z,X])=>e.jsx(Le,{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:N("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(We,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(z===f?.active){$.error(s("card.delete.error.active"));return}a(z),Kc(z).then(()=>{$.success("主题删除成功"),S()}).finally(()=>{a(null)})},children:e.jsx(V,{disabled:n===z,loading:n===z,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(os,{className:"h-4 w-4"})})})}),e.jsxs(Ke,{children:[e.jsx(us,{children:X.name}),e.jsx(Ys,{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(Ue,{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:()=>J(X.name,X.images),children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(hu,{themeKey:z,themeInfo:X}),e.jsx(V,{onClick:()=>j(z),disabled:n===z||z===f.active,loading:n===z,variant:z===f.active?"secondary":"default",children:z===f.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},z))}),e.jsx(je,{open:c,onOpenChange:i,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:s("upload.title")}),e.jsx(Ee,{children:s("upload.description")})]}),e.jsxs("div",{className:N("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:P,onDragLeave:P,onDragOver:P,onDrop:w,children:[e.jsx("input",{type:"file",ref:p,className:"hidden",accept:".zip",onChange:z=>{const X=z.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(ea,{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(je,{open:!!o,onOpenChange:z=>{z||(d(null),R(0))},children:e.jsxs(pe,{className:"max-w-4xl",children:[e.jsxs(ye,{children:[e.jsxs(ve,{children:[o?.name," ",s("preview.title")]}),e.jsx(Ee,{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:k,children:e.jsx(_i,{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:L,children:e.jsx(wi,{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((z,X)=>e.jsx("button",{onClick:()=>R(X),className:N("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:z,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function en(){return e.jsxs(Le,{children:[e.jsxs(Ke,{children:[e.jsx(ae,{className:"h-6 w-[200px]"}),e.jsx(ae,{className:"h-4 w-[300px]"})]}),e.jsxs(Ue,{className:"flex items-center justify-end space-x-3",children:[e.jsx(ae,{className:"h-10 w-[100px]"}),e.jsx(ae,{className:"h-10 w-[100px]"})]})]})}const pu=Object.freeze(Object.defineProperty({__proto__:null,default:fu},Symbol.toStringTag,{value:"Module"})),Ea=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:N(" 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(H,{variant:"secondary",children:[x,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(n.filter(o=>o!==x))},children:e.jsx(aa,{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})]})});Ea.displayName="InputTags";const gu=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()}),ju={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Ar({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=ju}){const{t:r}=F("notice"),[c,i]=m.useState(!1),u=ue({resolver:he(gu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new pa({html:!0});return e.jsx(fe,{...u,children:e.jsxs(je,{onOpenChange:i,open:c,children:[e.jsx($e,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ke,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ee,{})]}),e.jsx(b,{control:u.control,name:"title",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:r("form.fields.title.placeholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"content",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.content.label")}),e.jsx(_,{children:e.jsx(ga,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"img_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"show",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"tags",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(Ea,{value:o.value,onChange:o.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsxs(qe,{children:[e.jsx(pt,{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=>{id(d).then(({data:p})=>{p&&($.success(r("form.buttons.success")),s(),i(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function vu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=F("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(Ar,{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(He,{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 bu=s=>{const{t:n}=F("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ci,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(H,{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(K,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{const{data:l}=await dd({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(Ar,{refetch:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(zs,{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(We,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{cd({id:a.original.id}).then(()=>{$.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(os,{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 yu(){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}=te({queryKey:["notices"],queryFn:async()=>{const{data:k}=await Ja.getList();return g(k),k}});m.useEffect(()=>{l({"drag-handle":x,content:!x,created_at:!x,actions:!x}),R({pageSize:x?99999:50,pageIndex:0})},[x]);const j=(k,L)=>{x&&(k.dataTransfer.setData("text/plain",L.toString()),k.currentTarget.classList.add("opacity-50"))},C=(k,L)=>{if(!x)return;k.preventDefault(),k.currentTarget.classList.remove("bg-muted");const J=parseInt(k.dataTransfer.getData("text/plain"));if(J===L)return;const z=[...f],[X]=z.splice(J,1);z.splice(L,0,X),g(z)},P=async()=>{if(!x){o(!0);return}Ja.sort(f.map(k=>k.id)).then(()=>{$.success("排序保存成功"),o(!1),S()}).finally(()=>{o(!1)})},w=Be({data:f??[],columns:bu(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(as,{table:w,toolbar:k=>e.jsx(vu,{table:k,refetch:S,saveOrder:P,isSortMode:x}),draggable:x,onDragStart:j,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:C,showPagination:!x})})}function Nu(){const{t:s}=F("notice");return e.jsxs(Ce,{children:[e.jsxs(Se,{className:"flex items-center justify-between",children:[e.jsx(Oe,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(yu,{})})]})]})}const _u=Object.freeze(Object.defineProperty({__proto__:null,default:Nu},Symbol.toStringTag,{value:"Module"})),wu=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()}),Cu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function $r({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Cu}){const{t:r}=F("knowledge"),[c,i]=m.useState(!1),u=ue({resolver:he(wu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new pa({html:!0});return m.useEffect(()=>{c&&l.id&&ud(l.id).then(({data:o})=>{u.reset(o)})},[l.id,u,c]),e.jsxs(je,{onOpenChange:i,open:c,children:[e.jsx($e,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ke,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Ee,{})]}),e.jsxs(fe,{...u,children:[e.jsx(b,{control:u.control,name:"title",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:r("form.titlePlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"category",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:r("form.categoryPlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"language",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.language")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(b,{control:u.control,name:"body",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.content")}),e.jsx(_,{children:e.jsx(ga,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"show",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(K,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsxs(qe,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(V,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(V,{type:"submit",onClick:()=>{u.handleSubmit(o=>{xd(o).then(({data:d})=>{d&&(u.reset(),$.success(r("messages.operationSuccess")),i(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function Su({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{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(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(ts,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ps,{children:[e.jsx(Ls,{placeholder:n}),e.jsxs(Ds,{children:[e.jsx(As,{children:"No results found."}),e.jsx(Ae,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(Te,{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:N("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(Ms,{className:N("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(Xs,{}),e.jsx(Ae,{children:e.jsx(Te,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function ku({table:s,refetch:n,saveOrder:a,isSortMode:l}){const r=s.getState().columnFilters.length>0,{t:c}=F("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($r,{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(Su,{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(He,{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 Tu=({refetch:s,isSortMode:n=!1})=>{const{t:a}=F("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(Ot,{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(H,{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(K,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{fd({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(H,{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($r,{refreshData:s,dialogTrigger:e.jsxs(V,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(zs,{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(We,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{hd({id:l.original.id}).then(({data:r})=>{r&&($.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(os,{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 Pu(){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}=te({queryKey:["knowledge"],queryFn:async()=>{const{data:P}=await md();return u(P||[]),P}});m.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const g=(P,w)=>{r&&(P.dataTransfer.setData("text/plain",w.toString()),P.currentTarget.classList.add("opacity-50"))},S=(P,w)=>{if(!r)return;P.preventDefault(),P.currentTarget.classList.remove("bg-muted");const k=parseInt(P.dataTransfer.getData("text/plain"));if(k===w)return;const L=[...i],[J]=L.splice(k,1);L.splice(w,0,J),u(L)},j=async()=>{r?pd({ids:i.map(P=>P.id)}).then(()=>{T(),c(!1),$.success("排序保存成功")}):c(!0)},C=Be({data:i,columns:Tu({refetch:T,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(as,{table:C,toolbar:P=>e.jsx(ku,{table:P,refetch:T,saveOrder:j,isSortMode:r}),draggable:r,onDragStart:g,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:S,showPagination:!r})}function Du(){const{t:s}=F("knowledge");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(Pu,{})})]})]})}const Eu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"}));function Ru(s,n){const[a,l]=m.useState(s);return m.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function Qt(s,n){if(s.length===0)return{};if(!n)return{"":s};const a={};return s.forEach(l=>{const r=l[n]||"";a[r]||(a[r]=[]),a[r].push(l)}),a}function Vu(s,n){const a=JSON.parse(JSON.stringify(s));for(const[l,r]of Object.entries(a))a[l]=r.filter(c=>!n.find(i=>i.value===c.value));return a}function Iu(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 qr=m.forwardRef(({className:s,...n},a)=>Si(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:N("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);qr.displayName="CommandEmpty";const ut=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:P,inputProps:w,hideClearAllButton:k=!1},L)=>{const J=m.useRef(null),[z,X]=m.useState(!1),bs=m.useRef(!1),[Hs,et]=m.useState(!1),[ee,Es]=m.useState(s||[]),[Fe,se]=m.useState(Qt(l,R)),[ns,st]=m.useState(""),tt=Ru(ns,c||500);m.useImperativeHandle(L,()=>({selectedValue:[...ee],input:J.current,focus:()=>J.current?.focus()}),[ee]);const gt=m.useCallback(Q=>{const le=ee.filter(Me=>Me.value!==Q.value);Es(le),n?.(le)},[n,ee]),ml=m.useCallback(Q=>{const le=J.current;le&&((Q.key==="Delete"||Q.key==="Backspace")&&le.value===""&&ee.length>0&&(ee[ee.length-1].fixed||gt(ee[ee.length-1])),Q.key==="Escape"&&le.blur())},[gt,ee]);m.useEffect(()=>{s&&Es(s)},[s]),m.useEffect(()=>{if(!r||i)return;const Q=Qt(r||[],R);JSON.stringify(Q)!==JSON.stringify(Fe)&&se(Q)},[l,r,R,i,Fe]),m.useEffect(()=>{const Q=async()=>{et(!0);const Me=await i?.(tt);se(Qt(Me||[],R)),et(!1)};(async()=>{!i||!z||(C&&await Q(),tt&&await Q())})()},[tt,R,z,C]);const ul=()=>{if(!j||Iu(Fe,[{value:ns,label:ns}])||ee.find(le=>le.value===ns))return;const Q=e.jsx(Te,{value:ns,className:"cursor-pointer",onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onSelect:le=>{if(ee.length>=o){d?.(ee.length);return}st("");const Me=[...ee,{value:le,label:le}];Es(Me),n?.(Me)},children:`Create "${ns}"`});if(!i&&ns.length>0||i&&tt.length>0&&!Hs)return Q},xl=m.useCallback(()=>{if(x)return i&&!j&&Object.keys(Fe).length===0?e.jsx(Te,{value:"-",disabled:!0,children:x}):e.jsx(qr,{children:x})},[j,x,i,Fe]),hl=m.useMemo(()=>Vu(Fe,ee),[Fe,ee]),fl=m.useCallback(()=>{if(P?.filter)return P.filter;if(j)return(Q,le)=>Q.toLowerCase().includes(le.toLowerCase())?1:-1},[j,P?.filter]),pl=m.useCallback(()=>{const Q=ee.filter(le=>le.fixed);Es(Q),n?.(Q)},[n,ee]);return e.jsxs(Ps,{...P,onKeyDown:Q=>{ml(Q),P?.onKeyDown?.(Q)},className:N("h-auto overflow-visible bg-transparent",P?.className),shouldFilter:P?.shouldFilter!==void 0?P.shouldFilter:!i,filter:fl(),children:[e.jsx("div",{className:N("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||J.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(Q=>e.jsxs(H,{className:N("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":Q.fixed,"data-disabled":T||void 0,children:[Q.label,e.jsx("button",{className:N("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(T||Q.fixed)&&"hidden"),onKeyDown:le=>{le.key==="Enter"&>(Q)},onMouseDown:le=>{le.preventDefault(),le.stopPropagation()},onClick:()=>gt(Q),children:e.jsx(aa,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},Q.value)),e.jsx(Re.Input,{...w,ref:J,value:ns,disabled:T,onValueChange:Q=>{st(Q),w?.onValueChange?.(Q)},onBlur:Q=>{bs.current===!1&&X(!1),w?.onBlur?.(Q)},onFocus:Q=>{X(!0),C&&i?.(tt),w?.onFocus?.(Q)},placeholder:p&&ee.length!==0?"":a,className:N("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},w?.className)}),e.jsx("button",{type:"button",onClick:pl,className:N((k||T||ee.length<1||ee.filter(Q=>Q.fixed).length===ee.length)&&"hidden"),children:e.jsx(aa,{})})]})}),e.jsx("div",{className:"relative",children:z&&e.jsx(Ds,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{bs.current=!1},onMouseEnter:()=>{bs.current=!0},onMouseUp:()=>{J.current?.focus()},children:Hs?e.jsx(e.Fragment,{children:u}):e.jsxs(e.Fragment,{children:[xl(),ul(),!S&&e.jsx(Te,{value:"-",className:"hidden"}),Object.entries(hl).map(([Q,le])=>e.jsx(Ae,{heading:Q,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:le.map(Me=>e.jsx(Te,{value:Me.value,disabled:Me.disable,onMouseDown:at=>{at.preventDefault(),at.stopPropagation()},onSelect:()=>{if(ee.length>=o){d?.(ee.length);return}st("");const at=[...ee,Me];Es(at),n?.(at)},className:N("cursor-pointer",Me.disable&&"cursor-default text-muted-foreground"),children:Me.label},Me.value))})},Q))]})})})]})});ut.displayName="MultipleSelector";const Fu=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 Ht({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=F("group"),c=ue({resolver:he(Fu(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1),[x,o]=m.useState(!1),d=async p=>{o(!0),Jc(p).then(()=>{$.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),u(!1)}).finally(()=>{o(!1)})};return e.jsxs(je,{open:i,onOpenChange:u,children:[e.jsx($e,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ke,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Ee,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(fe,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(b,{control:c.control,name:"name",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.name")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("form.namePlaceholder"),...p,className:"w-full"})}),e.jsx(M,{children:r("form.nameDescription")}),e.jsx(E,{})]})}),e.jsxs(qe,{className:"gap-2",children:[e.jsx(pt,{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(fa,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Hr=m.createContext(void 0);function Mu({children:s,refetch:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null),[i,u]=m.useState(_e.Shadowsocks);return e.jsx(Hr.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:i,setServerType:u,refetch:n},children:s})}function Kr(){const s=m.useContext(Hr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Jt({dialogTrigger:s,value:n,setValue:a,templateType:l}){const{t:r}=F("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){$.error(j);return}try{if(!u){a(null),i(!1);return}a(JSON.parse(u)),i(!1)}catch{$.error(r("network_settings.errors.save_failed"))}},g=j=>{x(j),d(p(j))},S=j=>{const C=T[j];if(C){const P=JSON.stringify(C.content,null,2);x(P),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(je,{open:c,onOpenChange:j=>{!j&&c&&f(),i(j)},children:[e.jsx($e,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:r("network_settings.edit_protocol")})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(ye,{children:e.jsx(ve,{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(G,{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(vs,{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(qe,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:r("common.cancel")}),e.jsx(G,{onClick:f,disabled:!!o,children:r("common.confirm")})]})]})]})}function $h(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 Ou={},zu=Object.freeze(Object.defineProperty({__proto__:null,default:Ou},Symbol.toStringTag,{value:"Module"})),qh=Ai(zu),sn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Lu=()=>{try{const s=ki.box.keyPair(),n=sn(Ha.encodeBase64(s.secretKey)),a=sn(Ha.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Au=()=>{try{return Lu()}catch(s){throw console.error("Error generating key pair:",s),s}},$u=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)},qu=()=>{const s=Math.floor(Math.random()*8)*2+2;return $u(s)},Hu=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({})}),Ku=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({})}),Uu=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({})}),Bu=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({})}),Gu=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("")}),ds={shadowsocks:{schema:Hu,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:Ku,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Uu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Bu,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Gu,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"]}},Wu=({serverType:s,value:n,onChange:a})=>{const{t:l}=F("server"),r=s?ds[s]:null,c=r?.schema||h.record(h.any()),i=s?c.parse({}):{},u=ue({resolver:he(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(b,{control:u.control,name:"cipher",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:ds.shadowsocks.ciphers.map(g=>e.jsx(A,{value:g,children:g},g))})})]})})]})}),e.jsx(b,{control:u.control,name:"obfs",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:[e.jsx(A,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(A,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),u.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:u.control,name:"obfs_settings.path",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...f})}),e.jsx(E,{})]})}),e.jsx(b,{control:u.control,name:"obfs_settings.host",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(_,{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(b,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(A,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),u.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(b,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(K,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx(b,{control:u.control,name:"network",render:({field:f})=>e.jsxs(v,{children:[e.jsxs(y,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Jt,{value:u.watch("network_settings"),setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:ds.vmess.networkOptions.map(g=>e.jsx(A,{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(b,{control:u.control,name:"server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(b,{control:u.control,name:"allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(K,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(b,{control:u.control,name:"network",render:({field:f})=>e.jsxs(v,{children:[e.jsxs(y,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Jt,{value:u.watch("network_settings")||{},setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:ds.trojan.networkOptions.map(g=>e.jsx(A,{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(b,{control:u.control,name:"version",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:ds.hysteria.versions.map(g=>e.jsxs(A,{value:g,className:"cursor-pointer",children:["V",g]},g))})})]})})]})}),u.watch("version")==1&&e.jsx(b,{control:u.control,name:"alpn",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:ds.hysteria.alpnOptions.map(g=>e.jsx(A,{value:g,children:g},g))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:u.control,name:"obfs.open",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(K,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})}),!!u.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[u.watch("version")=="2"&&e.jsx(b,{control:u.control,name:"obfs.type",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:e.jsx(A,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(b,{control:u.control,name:"obfs.password",render:({field:f})=>e.jsxs(v,{className:u.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...f,value:f.value||"",className:"pr-9"})}),e.jsx(G,{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),$.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(ke,{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(b,{control:u.control,name:"tls.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(b,{control:u.control,name:"tls.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(K,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(b,{control:u.control,name:"bandwidth.up",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{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(b,{control:u.control,name:"bandwidth.down",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{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(b,{control:u.control,name:"tls",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(A,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(A,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),u.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:u.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(b,{control:u.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(K,{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(b,{control:u.control,name:"reality_settings.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...f})})]})}),e.jsx(b,{control:u.control,name:"reality_settings.server_port",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...f})})]})}),e.jsx(b,{control:u.control,name:"reality_settings.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(K,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(b,{control:u.control,name:"reality_settings.private_key",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{...f,className:"pr-9"})}),e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const g=Au();u.setValue("reality_settings.private_key",g.privateKey),u.setValue("reality_settings.public_key",g.publicKey),$.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.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(ke,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Tt,{children:e.jsx(re,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(b,{control:u.control,name:"reality_settings.public_key",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(D,{...f})})]})}),e.jsx(b,{control:u.control,name:"reality_settings.short_id",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{...f,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const g=qu();u.setValue("reality_settings.short_id",g),$.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(ke,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Tt,{children:e.jsx(re,{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(b,{control:u.control,name:"network",render:({field:f})=>e.jsxs(v,{children:[e.jsxs(y,{children:[l("dynamic_form.vless.network.label"),e.jsx(Jt,{value:u.watch("network_settings"),setValue:g=>u.setValue("network_settings",g),templateType:u.watch("network")})]}),e.jsx(_,{children:e.jsxs(W,{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(ys,{children:ds.vless.networkOptions.map(g=>e.jsx(A,{value:g.value,className:"cursor-pointer",children:g.label},g.value))})})]})})]})}),e.jsx(b,{control:u.control,name:"flow",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(W,{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:ds.vless.flowOptions.map(g=>e.jsx(A,{value:g,children:g},g))})]})})]})})]})};return e.jsx(me,{children:R[s]?.()})},Yu=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()}),bt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Qu(){const{t:s}=F("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:i,refetch:u}=Kr(),[x,o]=m.useState([]),[d,p]=m.useState([]),[T,R]=m.useState([]),f=ue({resolver:he(Yu),defaultValues:bt,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({...bt,...l}):f.reset({...bt,protocol_settings:ds[c].schema.parse({})})},[l,f,c]);const g=async()=>{if(!n)return;const[w,k,L]=await Promise.all([$t(),Er(),Dr()]);o(w.data?.map(J=>({label:J.name,value:J.id.toString()}))||[]),p(k.data?.map(J=>({label:J.remarks,value:J.id.toString()}))||[]),R(L.data||[])},S=m.useMemo(()=>T?.filter(w=>(w.parent_id===0||w.parent_id===null)&&w.type===c&&w.id!==f.watch("id")),[c,T,f]),j=()=>e.jsxs(ks,{children:[e.jsx(Ts,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ke,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(xs,{align:"start",children:e.jsx(bc,{children:Vs.map(({type:w,label:k})=>e.jsx(ge,{onClick:()=>{i(w),a(!0)},className:"cursor-pointer",children:e.jsx(H,{variant:"outline",className:"text-white",style:{background:ms[w]},children:k})},w))})})]}),C=()=>{a(!1),r(null),f.reset(bt)},P=async()=>{const w=f.getValues();(await Bc({...w,type:c})).data&&(C(),$.success(s("form.success")),u())};return e.jsxs(je,{open:n,onOpenChange:C,children:[j(),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Ee,{})]}),e.jsxs(fe,{...f,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:f.control,name:"name",render:({field:w})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:s("form.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...w})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"rate",render:({field:w})=>e.jsxs(v,{className:"flex-[1]",children:[e.jsx(y,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(_,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...w})})}),e.jsx(E,{})]})})]}),e.jsx(b,{control:f.control,name:"code",render:({field:w})=>e.jsxs(v,{children:[e.jsxs(y,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...w,value:w.value||""})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"tags",render:({field:w})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(Ea,{value:w.value,onChange:w.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"group_ids",render:({field:w})=>e.jsxs(v,{children:[e.jsxs(y,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Ht,{dialogTrigger:e.jsx(V,{variant:"link",children:s("form.groups.add")}),refetch:g})]}),e.jsx(_,{children:e.jsx(ut,{options:x,onChange:k=>w.onChange(k.map(L=>L.value)),value:x?.filter(k=>w.value.includes(k.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(b,{control:f.control,name:"host",render:({field:w})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...w})}),e.jsx(E,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{control:f.control,name:"port",render:({field:w})=>e.jsxs(v,{className:"flex-1",children:[e.jsxs(y,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(ke,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Tt,{children:e.jsx(re,{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(_,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...w})}),e.jsx(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{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 k=w.value;k&&f.setValue("server_port",k)},children:e.jsx(ke,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(re,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"server_port",render:({field:w})=>e.jsxs(v,{className:"flex-1",children:[e.jsxs(y,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(ke,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Tt,{children:e.jsx(re,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...w})}),e.jsx(E,{})]})})]})]}),n&&e.jsx(Wu,{serverType:c,value:f.watch("protocol_settings"),onChange:w=>f.setValue("protocol_settings",w,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(b,{control:f.control,name:"parent_id",render:({field:w})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.parent.label")}),e.jsxs(W,{onValueChange:w.onChange,value:w.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(B,{children:[e.jsx(A,{value:"0",children:s("form.parent.none")}),S?.map(k=>e.jsx(A,{value:k.id.toString(),className:"cursor-pointer",children:k.name},k.id))]})]}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"route_ids",render:({field:w})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(ut,{options:d,onChange:k=>w.onChange(k.map(L=>L.value)),value:d?.filter(k=>w.value.includes(k.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(qe,{className:"mt-6",children:[e.jsx(V,{type:"button",variant:"outline",onClick:C,children:s("form.cancel")}),e.jsx(V,{type:"submit",onClick:P,children:s("form.submit")})]})]})]})]})}function tn({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{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(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(ts,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ps,{children:[e.jsx(Ls,{placeholder:n}),e.jsxs(Ds,{children:[e.jsx(As,{children:"No results found."}),e.jsx(Ae,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(Te,{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:N("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(Ms,{className:N("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(Xs,{}),e.jsx(Ae,{children:e.jsx(Te,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Ju=[{value:_e.Shadowsocks,label:Vs.find(s=>s.type===_e.Shadowsocks)?.label,color:ms[_e.Shadowsocks]},{value:_e.Vmess,label:Vs.find(s=>s.type===_e.Vmess)?.label,color:ms[_e.Vmess]},{value:_e.Trojan,label:Vs.find(s=>s.type===_e.Trojan)?.label,color:ms[_e.Trojan]},{value:_e.Hysteria,label:Vs.find(s=>s.type===_e.Hysteria)?.label,color:ms[_e.Hysteria]},{value:_e.Vless,label:Vs.find(s=>s.type===_e.Vless)?.label,color:ms[_e.Vless]}];function Zu({table:s,saveOrder:n,isSortMode:a,groups:l}){const r=s.getState().columnFilters.length>0,{t:c}=F("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(Qu,{}),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(tn,{column:s.getColumn("type"),title:c("toolbar.type"),options:Ju}),s.getColumn("groups")&&e.jsx(tn,{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(He,{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 xt=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"})}),yt={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"},Xu=s=>{const{t:n}=F("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(Ot,{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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(H,{variant:"outline",className:N("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:ms[a.original.type]},children:[e.jsx(tr,{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(),Et(r||l.toString()).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(Ka,{className:"size-3"})})]})}),e.jsxs(re,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Vs.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(K,{checked:l,onCheckedChange:async c=>{r(c),Yc({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?ms[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:N("h-2.5 w-2.5 rounded-full",yt[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:N("h-2.5 w-2.5 rounded-full",yt[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:N("h-2.5 w-2.5 rounded-full",yt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",yt[a.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:a.getValue("name")})]})}),e.jsx(re,{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(me,{delayDuration:0,children:e.jsxs(ce,{children:[e.jsx(de,{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(),Et(l).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(Ka,{className:"size-3"})})}),e.jsx(re,{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(xt,{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(H,{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(H,{variant:"secondary",className:N("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(H,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:ms[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}=Kr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(ks,{modal:!1,children:[e.jsx(Ts,{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(Pt,{className:"size-4"})})}),e.jsxs(xs,{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(Ti,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(ge,{className:"cursor-pointer",onClick:async()=>{Wc({id:a.original.id}).then(({data:i})=>{i&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Pi,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(mt,{}),e.jsx(ge,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:i=>i.preventDefault(),children:e.jsx(We,{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()=>{Gc({id:a.original.id}).then(({data:i})=>{i&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(os,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function ex(){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}=te({queryKey:["nodeList"],queryFn:async()=>{const{data:L}=await Dr();return g(L),L}}),j=m.useMemo(()=>{const L=new Set;return f.forEach(J=>{J.groups&&J.groups.forEach(z=>L.add(z.name))}),Array.from(L).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=(L,J)=>{d&&(L.dataTransfer.setData("text/plain",J.toString()),L.currentTarget.classList.add("opacity-50"))},P=(L,J)=>{if(!d)return;L.preventDefault(),L.currentTarget.classList.remove("bg-muted");const z=parseInt(L.dataTransfer.getData("text/plain"));if(z===J)return;const X=[...f],[bs]=X.splice(z,1);X.splice(J,0,bs),g(X)},w=async()=>{if(!d){p(!0);return}const L=f?.map((J,z)=>({id:J.id,order:z+1}));Qc(L).then(()=>{$.success("排序保存成功"),p(!1),S()}).finally(()=>{p(!1)})},k=Be({data:f||[],columns:Xu(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Mu,{refetch:S,children:e.jsx("div",{className:"space-y-4",children:e.jsx(as,{table:k,toolbar:L=>e.jsx(Zu,{table:L,refetch:S,saveOrder:w,isSortMode:d,groups:j}),draggable:d,onDragStart:C,onDragEnd:L=>L.currentTarget.classList.remove("opacity-50"),onDragOver:L=>{L.preventDefault(),L.currentTarget.classList.add("bg-muted")},onDragLeave:L=>L.currentTarget.classList.remove("bg-muted"),onDrop:P,showPagination:!d})})})}function sx(){const{t:s}=F("server");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(ex,{})})]})]})}const tx=Object.freeze(Object.defineProperty({__proto__:null,default:sx},Symbol.toStringTag,{value:"Module"}));function ax({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=F("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(Ht,{refetch:n}),e.jsx(D,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:N("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(He,{className:"ml-2 h-4 w-4"})]})]})})}const nx=s=>{const{t:n}=F("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(H,{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(xt,{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(tr,{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(Ht,{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(zs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(We,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Zc({id:a.original.id}).then(({data:l})=>{l&&($.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(os,{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 rx(){const[s,n]=m.useState({}),[a,l]=m.useState({}),[r,c]=m.useState([]),[i,u]=m.useState([]),{data:x,refetch:o,isLoading:d}=te({queryKey:["serverGroupList"],queryFn:async()=>{const{data:T}=await $t();return T}}),p=Be({data:x||[],columns:nx(o),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:u,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(as,{table:p,toolbar:T=>e.jsx(ax,{table:T,refetch:o}),isLoading:d})}function lx(){const{t:s}=F("group");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(rx,{})})]})]})}const ox=Object.freeze(Object.defineProperty({__proto__:null,default:lx},Symbol.toStringTag,{value:"Module"})),ix=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 Ur({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=F("route"),c=ue({resolver:he(ix(r)),defaultValues:a,mode:"onChange"}),[i,u]=m.useState(!1);return e.jsxs(je,{open:i,onOpenChange:u,children:[e.jsx($e,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(ke,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Ee,{})]}),e.jsxs(fe,{...c,children:[e.jsx(b,{control:c.control,name:"remarks",render:({field:x})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("form.remarksPlaceholder"),...x})})}),e.jsx(E,{})]})}),e.jsx(b,{control:c.control,name:"match",render:({field:x})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(vs,{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(b,{control:r.control,name:"recaptcha_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.recaptcha.enable.label")}),e.jsx(M,{children:s("safe.form.recaptcha.enable.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("recaptcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:r.control,name:"recaptcha_key",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.recaptcha.key.label")}),e.jsx(_,{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(b,{control:r.control,name:"recaptcha_site_key",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.recaptcha.siteKey.label")}),e.jsx(_,{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(b,{control:r.control,name:"register_limit_by_ip_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(M,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(U,{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(b,{control:r.control,name:"register_limit_count",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(_,{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(b,{control:r.control,name:"register_limit_expire",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(_,{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(b,{control:r.control,name:"password_limit_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(M,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:r.control,name:"password_limit_count",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(_,{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(b,{control:r.control,name:"password_limit_expire",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(_,{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 gm(){const{t:s}=F("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(we,{}),e.jsx(pm,{})]})}const jm=Object.freeze(Object.defineProperty({__proto__:null,default:gm},Symbol.toStringTag,{value:"Module"})),vm=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")}),bm={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 ym(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),r=he({resolver:ge(vm),defaultValues:bm,mode:"onBlur"}),{data:c}=ne({queryKey:["settings","subscribe"],queryFn:()=>ys("subscribe")}),{mutateAsync:i}=ds({mutationFn:Ns,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.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 m=u.useCallback(_e.debounce(async o=>{if(!_e.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=u.useCallback(o=>{m(o)},[m]);return u.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(je,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"plan_change_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(M,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"reset_traffic_method",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:"请选择重置方式"})})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("subscribe.reset_traffic_method.options.monthly_first")}),e.jsx(q,{value:"1",children:s("subscribe.reset_traffic_method.options.monthly_reset")}),e.jsx(q,{value:"2",children:s("subscribe.reset_traffic_method.options.no_reset")}),e.jsx(q,{value:"3",children:s("subscribe.reset_traffic_method.options.yearly_first")}),e.jsx(q,{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(b,{control:r.control,name:"surplus_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(M,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"new_order_event_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.new_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("subscribe.new_order_event.options.no_action")}),e.jsx(q,{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(b,{control:r.control,name:"renew_order_event_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.renew_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("subscribe.renew_order_event.options.no_action")}),e.jsx(q,{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(b,{control:r.control,name:"change_order_event_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.change_order_event.title")}),e.jsx("div",{className:"relative w-max",children:e.jsx(_,{children:e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString(),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:"请选择"})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("subscribe.change_order_event.options.no_action")}),e.jsx(q,{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(b,{control:r.control,name:"subscribe_path",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{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(b,{control:r.control,name:"show_info_to_server_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(M,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value||!1,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"show_protocol_to_server_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(M,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(U,{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 Nm(){const{t:s}=F("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(we,{}),e.jsx(ym,{})]})}const _m=Object.freeze(Object.defineProperty({__proto__:null,default:Nm},Symbol.toStringTag,{value:"Module"})),wm=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)}),Cm={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 Sm(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),r=he({resolver:ge(wm),defaultValues:Cm,mode:"onBlur"}),{data:c}=ne({queryKey:["settings","invite"],queryFn:()=>ys("invite")}),{mutateAsync:i}=ds({mutationFn:Ns,onSuccess:o=>{o.data&&A.success(s("common.autoSaved"))}});u.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 m=u.useCallback(_e.debounce(async o=>{if(!_e.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=u.useCallback(o=>{m(o)},[m]);return u.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(je,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"invite_force",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(M,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"invite_commission",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(_,{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(b,{control:r.control,name:"invite_gen_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(_,{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(b,{control:r.control,name:"invite_never_expire",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(M,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_first_time_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(M,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_auto_check_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(M,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_withdraw_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(_,{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(b,{control:r.control,name:"commission_withdraw_method",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(_,{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(b,{control:r.control,name:"withdraw_close_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(M,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),e.jsx(b,{control:r.control,name:"commission_distribution_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(M,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:d=>{o.onChange(d),x(r.getValues())}})})]})}),r.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:r.control,name:"commission_distribution_l1",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("invite.commission_distribution.l1")}),e.jsx(_,{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(b,{control:r.control,name:"commission_distribution_l2",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("invite.commission_distribution.l2")}),e.jsx(_,{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(b,{control:r.control,name:"commission_distribution_l3",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("invite.commission_distribution.l3")}),e.jsx(_,{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 km(){const{t:s}=F("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(we,{}),e.jsx(Sm,{})]})}const Tm=Object.freeze(Object.defineProperty({__proto__:null,default:km},Symbol.toStringTag,{value:"Module"})),Pm=h.object({frontend_theme:h.string().nullable(),frontend_theme_sidebar:h.string().nullable(),frontend_theme_header:h.string().nullable(),frontend_theme_color:h.string().nullable(),frontend_background_url:h.string().url().nullable()}),Dm={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function Em(){const{data:s}=ne({queryKey:["settings","frontend"],queryFn:()=>ys("frontend")}),n=he({resolver:ge(Pm),defaultValues:Dm,mode:"onChange"});u.useEffect(()=>{if(s?.data?.frontend){const l=s?.data?.frontend;Object.entries(l).forEach(([r,c])=>{n.setValue(r,c)})}},[s]);function a(l){Ns(l).then(({data:r})=>{r&&A.success("更新成功")})}return e.jsx(je,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(a),className:"space-y-8",children:[e.jsx(b,{control:n.control,name:"frontend_theme_sidebar",render:({field:l})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:"边栏风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(U,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_header",render:({field:l})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:"头部风格"}),e.jsx(M,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(U,{checked:l.value,onCheckedChange:l.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_color",render:({field:l})=>e.jsxs(v,{children:[e.jsx(y,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:N(Xs({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(ha,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(M,{children:"主题色"}),e.jsx(E,{})]})}),e.jsx(b,{control:n.control,name:"frontend_background_url",render:({field:l})=>e.jsxs(v,{children:[e.jsx(y,{children:"背景"}),e.jsx(_,{children:e.jsx(D,{placeholder:"请输入图片地址",...l})}),e.jsx(M,{children:"将会在后台登录页面进行展示。"}),e.jsx(E,{})]})}),e.jsx(R,{type:"submit",children:"保存设置"})]})})}function Rm(){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(we,{}),e.jsx(Em,{})]})}const Im=Object.freeze(Object.defineProperty({__proto__:null,default:Rm},Symbol.toStringTag,{value:"Module"})),Vm=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()}),Fm={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function Mm(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),r=he({resolver:ge(Vm),defaultValues:Fm,mode:"onBlur"}),{data:c}=ne({queryKey:["settings","server"],queryFn:()=>ys("server")}),{mutateAsync:i}=ds({mutationFn:Ns,onSuccess:d=>{d.data&&A.success(s("common.AutoSaved"))}});u.useEffect(()=>{if(c?.data.server){const d=c.data.server;Object.entries(d).forEach(([p,k])=>{r.setValue(p,k)}),l.current=d}},[c]);const m=u.useCallback(_e.debounce(async d=>{if(!_e.isEqual(d,l.current)){a(!0);try{await i(d),l.current=d}finally{a(!1)}}},1e3),[i]),x=u.useCallback(d=>{m(d)},[m]);u.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 k="";for(let I=0;Ie.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.server_token.title")}),e.jsx(_,{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(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(B,{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(ci,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(oe,{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(b,{control:r.control,name:"server_pull_interval",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const k=p.target.value?Number(p.target.value):null;d.onChange(k)}})}),e.jsx(M,{children:s("server.server_pull_interval.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"server_push_interval",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...d,value:d.value||"",onChange:p=>{const k=p.target.value?Number(p.target.value):null;d.onChange(k)}})}),e.jsx(M,{children:s("server.server_push_interval.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"device_limit_mode",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(J,{onValueChange:d.onChange,value:d.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("server.device_limit_mode.strict")}),e.jsx(q,{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 Om(){const{t:s}=F("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(we,{}),e.jsx(Mm,{})]})}const zm=Object.freeze(Object.defineProperty({__proto__:null,default:Om},Symbol.toStringTag,{value:"Module"}));function Lm({open:s,onOpenChange:n,result:a}){const l=!a.error;return e.jsx(ve,{open:s,onOpenChange:n,children:e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l?e.jsx(Bn,{className:"h-5 w-5 text-green-500"}):e.jsx(Gn,{className:"h-5 w-5 text-destructive"}),e.jsx(be,{children:l?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ee,{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(Zs,{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 Am=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 $m(){const{t:s}=F("settings"),[n,a]=u.useState(null),[l,r]=u.useState(!1),c=u.useRef(null),[i,m]=u.useState(!1),x=he({resolver:ge(Am),defaultValues:{},mode:"onBlur"}),{data:o}=ne({queryKey:["settings","email"],queryFn:()=>ys("email")}),{data:d}=ne({queryKey:["emailTemplate"],queryFn:()=>Od()}),{mutateAsync:p}=ds({mutationFn:Ns,onSuccess:C=>{C.data&&A.success(s("common.autoSaved"))}}),{mutate:k,isPending:I}=ds({mutationFn:zd,onMutate:()=>{a(null),r(!1)},onSuccess:C=>{a(C.data),r(!0),C.data.error?A.error(s("email.test.error")):A.success(s("email.test.success"))}});u.useEffect(()=>{if(o?.data.email){const C=o.data.email;Object.entries(C).forEach(([g,w])=>{x.setValue(g,w)}),c.current=C}},[o]);const f=u.useCallback(_e.debounce(async C=>{if(!_e.isEqual(C,c.current)){m(!0);try{await p(C),c.current=C}finally{m(!1)}}},1e3),[p]),j=u.useCallback(C=>{f(C)},[f]);return u.useEffect(()=>{const C=x.watch(g=>{j(g)});return()=>C.unsubscribe()},[x.watch,j]),e.jsxs(e.Fragment,{children:[e.jsx(je,{...x,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:x.control,name:"email_host",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_host.title")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("common.placeholder"),...C,value:C.value||""})}),e.jsx(M,{children:s("email.email_host.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_port",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_port.title")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:s("common.placeholder"),...C,value:C.value||"",onChange:g=>{const w=g.target.value?Number(g.target.value):null;C.onChange(w)}})}),e.jsx(M,{children:s("email.email_port.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_encryption",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(J,{onValueChange:C.onChange,value:C.value||"none",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:"请选择加密方式"})})}),e.jsxs(Y,{children:[e.jsx(q,{value:"none",children:s("email.email_encryption.none")}),e.jsx(q,{value:"ssl",children:s("email.email_encryption.ssl")}),e.jsx(q,{value:"tls",children:s("email.email_encryption.tls")})]})]}),e.jsx(M,{children:s("email.email_encryption.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_username",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_username.title")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("common.placeholder"),...C,value:C.value||""})}),e.jsx(M,{children:s("email.email_username.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_password",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_password.title")}),e.jsx(_,{children:e.jsx(D,{type:"password",placeholder:s("common.placeholder"),...C,value:C.value||""})}),e.jsx(M,{children:s("email.email_password.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_from_address",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_from.title")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("common.placeholder"),...C,value:C.value||""})}),e.jsx(M,{children:s("email.email_from.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"email_template",render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(J,{onValueChange:g=>{C.onChange(g),j(x.getValues())},value:C.value||void 0,children:[e.jsx(_,{children:e.jsx(W,{className:"w-[200px]",children:e.jsx(Z,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(Y,{children:d?.data?.map(g=>e.jsx(q,{value:g,children:g},g))})]}),e.jsx(M,{children:s("email.email_template.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"remind_mail_enable",render:({field:C})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(M,{children:s("email.remind_mail.description")})]}),e.jsx(_,{children:e.jsx(U,{checked:C.value||!1,onCheckedChange:g=>{C.onChange(g),j(x.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(R,{onClick:()=>k(),loading:I,disabled:I,children:s(I?"test.sending":"test.title")})})]})}),i&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(Lm,{open:l,onOpenChange:r,result:n})]})}function qm(){const{t:s}=F("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(we,{}),e.jsx($m,{})]})}const Hm=Object.freeze(Object.defineProperty({__proto__:null,default:qm},Symbol.toStringTag,{value:"Module"})),Km=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Um={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Bm(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),r=he({resolver:ge(Km),defaultValues:Um,mode:"onBlur"}),{data:c}=ne({queryKey:["settings","telegram"],queryFn:()=>ys("telegram")}),{mutateAsync:i}=ds({mutationFn:Ns,onSuccess:p=>{p.data&&A.success(s("common.autoSaved"))}}),{mutate:m,isPending:x}=ds({mutationFn:Ld,onSuccess:p=>{p.data&&A.success(s("telegram.webhook.success"))}});u.useEffect(()=>{if(c?.data.telegram){const p=c.data.telegram;Object.entries(p).forEach(([k,I])=>{r.setValue(k,I)}),l.current=p}},[c]);const o=u.useCallback(_e.debounce(async p=>{if(!_e.isEqual(p,l.current)){a(!0);try{await i(p),l.current=p}finally{a(!1)}}},1e3),[i]),d=u.useCallback(p=>{o(p)},[o]);return u.useEffect(()=>{const p=r.watch(k=>{d(k)});return()=>p.unsubscribe()},[r.watch,d]),e.jsx(je,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"telegram_bot_token",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(_,{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(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(R,{loading:x,disabled:x,onClick:()=>m(),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(b,{control:r.control,name:"telegram_bot_enable",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(M,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(U,{checked:p.value||!1,onCheckedChange:k=>{p.onChange(k),d(r.getValues())}})}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"telegram_discuss_link",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(_,{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 Gm(){const{t:s}=F("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(we,{}),e.jsx(Bm,{})]})}const Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"})),Ym=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()}),Qm={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Jm(){const{t:s}=F("settings"),[n,a]=u.useState(!1),l=u.useRef(null),r=he({resolver:ge(Ym),defaultValues:Qm,mode:"onBlur"}),{data:c}=ne({queryKey:["settings","app"],queryFn:()=>ys("app")}),{mutateAsync:i}=ds({mutationFn:Ns,onSuccess:o=>{o.data&&A.success(s("app.save_success"))}});u.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 m=u.useCallback(_e.debounce(async o=>{if(!_e.isEqual(o,l.current)){a(!0);try{await i(o),l.current=o}finally{a(!1)}}},1e3),[i]),x=u.useCallback(o=>{m(o)},[m]);return u.useEffect(()=>{const o=r.watch(d=>{x(d)});return()=>o.unsubscribe()},[r.watch,x]),e.jsx(je,{...r,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:r.control,name:"windows_version",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(_,{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(b,{control:r.control,name:"windows_download_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(_,{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(b,{control:r.control,name:"macos_version",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(_,{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(b,{control:r.control,name:"macos_download_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(_,{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(b,{control:r.control,name:"android_version",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.android.version.title")}),e.jsx(_,{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(b,{control:r.control,name:"android_download_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("app.android.download.title")}),e.jsx(_,{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 Zm(){const{t:s}=F("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(we,{}),e.jsx(Jm,{})]})}const Xm=Object.freeze(Object.defineProperty({__proto__:null,default:Zm},Symbol.toStringTag,{value:"Module"})),ba=u.forwardRef(({className:s,...n},a)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:a,className:N("w-full caption-bottom text-sm",s),...n})}));ba.displayName="Table";const ya=u.forwardRef(({className:s,...n},a)=>e.jsx("thead",{ref:a,className:N("[&_tr]:border-b",s),...n}));ya.displayName="TableHeader";const Na=u.forwardRef(({className:s,...n},a)=>e.jsx("tbody",{ref:a,className:N("[&_tr:last-child]:border-0",s),...n}));Na.displayName="TableBody";const eu=u.forwardRef(({className:s,...n},a)=>e.jsx("tfoot",{ref:a,className:N("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));eu.displayName="TableFooter";const ks=u.forwardRef(({className:s,...n},a)=>e.jsx("tr",{ref:a,className:N("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));ks.displayName="TableRow";const _a=u.forwardRef(({className:s,...n},a)=>e.jsx("th",{ref:a,className:N("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}));_a.displayName="TableHead";const Ys=u.forwardRef(({className:s,...n},a)=>e.jsx("td",{ref:a,className:N("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Ys.displayName="TableCell";const su=u.forwardRef(({className:s,...n},a)=>e.jsx("caption",{ref:a,className:N("mt-4 text-sm text-muted-foreground",s),...n}));su.displayName="TableCaption";function tu({table:s}){const[n,a]=u.useState(""),{t:l}=F("common");u.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(J,{value:`${s.getState().pagination.pageSize}`,onValueChange:c=>{s.setPageSize(Number(c))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Z,{placeholder:s.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50,100,500].map(c=>e.jsx(q,{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(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.firstPage")}),e.jsx(di,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.previousPage")}),e.jsx($n,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.nextPage")}),e.jsx(ua,{className:"h-4 w-4"})]}),e.jsxs(R,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:l("table.pagination.lastPage")}),e.jsx(mi,{className:"h-4 w-4"})]})]})]})]})}function os({table:s,toolbar:n,draggable:a=!1,onDragStart:l,onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:m,showPagination:x=!0,isLoading:o=!1}){const{t:d}=F("common"),p=u.useRef(null),k=s.getAllColumns().filter(C=>C.getIsPinned()==="left"),I=s.getAllColumns().filter(C=>C.getIsPinned()==="right"),f=C=>k.slice(0,C).reduce((g,w)=>g+(w.getSize()??0),0),j=C=>I.slice(C+1).reduce((g,w)=>g+(w.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(ba,{children:[e.jsx(ya,{children:s.getHeaderGroups().map(C=>e.jsx(ks,{className:"hover:bg-transparent",children:C.headers.map((g,w)=>{const T=g.column.getIsPinned()==="left",S=g.column.getIsPinned()==="right",P=T?f(k.indexOf(g.column)):void 0,L=S?j(I.indexOf(g.column)):void 0;return e.jsx(_a,{colSpan:g.colSpan,style:{width:g.getSize(),...T&&{left:P},...S&&{right:L}},className:N("h-11 bg-card px-4 text-muted-foreground",(T||S)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",T&&"before:right-0",S&&"before:left-0"]),children:g.isPlaceholder?null:Tt(g.column.columnDef.header,g.getContext())},g.id)})},C.id))}),e.jsx(Na,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((C,g)=>e.jsx(ks,{"data-state":C.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:a,onDragStart:w=>l?.(w,g),onDragEnd:r,onDragOver:c,onDragLeave:i,onDrop:w=>m?.(w,g),children:C.getVisibleCells().map((w,T)=>{const S=w.column.getIsPinned()==="left",P=w.column.getIsPinned()==="right",L=S?f(k.indexOf(w.column)):void 0,G=P?j(I.indexOf(w.column)):void 0;return e.jsx(Ys,{style:{width:w.column.getSize(),...S&&{left:L},...P&&{right:G}},className:N("bg-card",(S||P)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",S&&"before:right-0",P&&"before:left-0"]),children:Tt(w.column.columnDef.cell,w.getContext())},w.id)})},C.id)):e.jsx(ks,{children:e.jsx(Ys,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:d("table.noData")})})})]})})}),x&&e.jsx(tu,{table:s})]})}const au=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())}),Xa={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function Fr({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Xa}){const{t:r}=F("payment"),[c,i]=u.useState(!1),[m,x]=u.useState(!1),[o,d]=u.useState([]),[p,k]=u.useState([]),I=au(r),f=he({resolver:ge(I),defaultValues:l,mode:"onChange"}),j=f.watch("payment");u.useEffect(()=>{c&&(async()=>{const{data:w}=await td();d(w)})()},[c]),u.useEffect(()=>{if(!j||!c)return;(async()=>{const w={payment:j,...a==="edit"&&{id:Number(f.getValues("id"))}};ad(w).then(({data:T})=>{k(T);const S=T.reduce((P,L)=>(L.field_name&&(P[L.field_name]=L.value??""),P),{});f.setValue("config",S)})})()},[j,c,f,a]);const C=async g=>{x(!0);try{(await nd(g)).data&&(A.success(r("form.messages.success")),f.reset(Xa),s(),i(!1))}finally{x(!1)}};return e.jsxs(ve,{open:c,onOpenChange:i,children:[e.jsx(He,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Pe,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(Ne,{children:e.jsx(be,{children:r(a==="add"?"form.add.title":"form.edit.title")})}),e.jsx(je,{...f,children:e.jsxs("form",{onSubmit:f.handleSubmit(C),className:"space-y-4",children:[e.jsx(b,{control:f.control,name:"name",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("form.fields.name.placeholder"),...g})}),e.jsx(M,{children:r("form.fields.name.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"icon",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.icon.label")}),e.jsx(_,{children:e.jsx(D,{...g,value:g.value||"",placeholder:r("form.fields.icon.placeholder")})}),e.jsx(M,{children:r("form.fields.icon.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"notify_domain",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.notify_domain.label")}),e.jsx(_,{children:e.jsx(D,{...g,value:g.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(b,{control:f.control,name:"handling_fee_percent",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...g,value:g.value||"",placeholder:r("form.fields.handling_fee_percent.placeholder")})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"handling_fee_fixed",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...g,value:g.value||"",placeholder:r("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(E,{})]})})]}),e.jsx(b,{control:f.control,name:"payment",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.payment.label")}),e.jsxs(J,{onValueChange:g.onChange,defaultValue:g.value,children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:r("form.fields.payment.placeholder")})})}),e.jsx(Y,{children:o.map(w=>e.jsx(q,{value:w,children:w},w))})]}),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(g=>e.jsx(b,{control:f.control,name:`config.${g.field_name}`,render:({field:w})=>e.jsxs(v,{children:[e.jsx(y,{children:g.label}),e.jsx(_,{children:e.jsx(D,{...w,value:w.value||""})}),e.jsx(E,{})]})},g.field_name))}),e.jsxs(Ke,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",disabled:m,children:r("form.buttons.submit")})]})]})})]})]})}function z({column:s,title:n,tooltip:a,className:l}){return s.getCanSort()?e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(R,{variant:"ghost",size:"default",className:N("-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(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(qa,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(oe,{children:a})]})}),s.getIsSorted()==="asc"?e.jsx(sa,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(ta,{className:"h-4 w-4 text-foreground/70"}):e.jsx(ui,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:N("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(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{children:e.jsx(qa,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(oe,{children:a})]})})]})}const Mr=xi,Or=hi,nu=fi,zr=u.forwardRef(({className:s,...n},a)=>e.jsx(Qn,{className:N("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}));zr.displayName=Qn.displayName;const wa=u.forwardRef(({className:s,...n},a)=>e.jsxs(nu,{children:[e.jsx(zr,{}),e.jsx(Jn,{ref:a,className:N("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})]}));wa.displayName=Jn.displayName;const Ca=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ca.displayName="AlertDialogHeader";const Sa=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Sa.displayName="AlertDialogFooter";const ka=u.forwardRef(({className:s,...n},a)=>e.jsx(Zn,{ref:a,className:N("text-lg font-semibold",s),...n}));ka.displayName=Zn.displayName;const Ta=u.forwardRef(({className:s,...n},a)=>e.jsx(Xn,{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ta.displayName=Xn.displayName;const Pa=u.forwardRef(({className:s,...n},a)=>e.jsx(er,{ref:a,className:N(Js(),s),...n}));Pa.displayName=er.displayName;const Da=u.forwardRef(({className:s,...n},a)=>e.jsx(sr,{ref:a,className:N(Js({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Da.displayName=sr.displayName;function qe({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:m}){return e.jsxs(Mr,{children:[e.jsx(Or,{asChild:!0,children:n}),e.jsxs(wa,{className:N("sm:max-w-[425px]",m),children:[e.jsxs(Ca,{children:[e.jsx(ka,{children:a}),e.jsx(Ta,{children:l})]}),e.jsxs(Sa,{children:[e.jsx(Da,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r})}),e.jsx(Pa,{asChild:!0,children:e.jsx(R,{variant:i,onClick:s,children:c})})]})]})]})}const Lr=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"})}),ru=({refetch:s,isSortMode:n=!1})=>{const{t:a}=F("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(zt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(z,{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(z,{column:l,title:a("table.columns.enable")}),cell:({row:l})=>e.jsx(U,{defaultChecked:l.getValue("enable"),onCheckedChange:async()=>{const{data:r}=await ld({id:l.original.id});r||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:l})=>e.jsx(z,{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(z,{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(z,{column:l,title:a("table.columns.notify_url")}),e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{className:"ml-1",children:e.jsx(Lr,{className:"h-4 w-4"})}),e.jsx(oe,{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(z,{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(Fr,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(As,{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(qe,{title:a("table.actions.delete.title"),description:a("table.actions.delete.description"),onConfirm:async()=>{const{data:r}=await rd({id:l.original.id});r&&s()},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(ts,{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 lu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=F("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(Fr,{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(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[r("table.toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function ou(){const[s,n]=u.useState([]),[a,l]=u.useState([]),[r,c]=u.useState(!1),[i,m]=u.useState([]),[x,o]=u.useState({"drag-handle":!1}),[d,p]=u.useState({pageSize:20,pageIndex:0}),{refetch:k}=ne({queryKey:["paymentList"],queryFn:async()=>{const{data:g}=await sd();return m(g?.map(w=>({...w,enable:!!w.enable}))||[]),g}});u.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const I=(g,w)=>{r&&(g.dataTransfer.setData("text/plain",w.toString()),g.currentTarget.classList.add("opacity-50"))},f=(g,w)=>{if(!r)return;g.preventDefault(),g.currentTarget.classList.remove("bg-muted");const T=parseInt(g.dataTransfer.getData("text/plain"));if(T===w)return;const S=[...i],[P]=S.splice(T,1);S.splice(w,0,P),m(S)},j=async()=>{r?od({ids:i.map(g=>g.id)}).then(()=>{k(),c(!1),A.success("排序保存成功")}):c(!0)},C=Ye({data:i,columns:ru({refetch:k,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),initialState:{columnPinning:{right:["actions"]}},pageCount:r?1:void 0});return e.jsx(os,{table:C,toolbar:g=>e.jsx(lu,{table:g,refetch:k,saveOrder:j,isSortMode:r}),draggable:r,onDragStart:I,onDragEnd:g=>g.currentTarget.classList.remove("opacity-50"),onDragOver:g=>{g.preventDefault(),g.currentTarget.classList.add("bg-muted")},onDragLeave:g=>g.currentTarget.classList.remove("bg-muted"),onDrop:f,showPagination:!r})}function iu(){const{t:s}=F("payment");return e.jsxs(ke,{children:[e.jsxs(Te,{className:"flex items-center justify-between",children:[e.jsx(ze,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(ou,{})})]})]})}const cu=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"}));function du({pluginName:s,onClose:n,onSuccess:a}){const{t:l}=F("plugin"),[r,c]=u.useState(!0),[i,m]=u.useState(!1),[x,o]=u.useState(null),d=pi({config:gi(ji())}),p=he({resolver:ge(d),defaultValues:{config:{}}});u.useEffect(()=>{(async()=>{try{const{data:j}=await hs.getPluginConfig(s);o(j),p.reset({config:Object.fromEntries(Object.entries(j).map(([C,g])=>[C,g.value]))})}catch{A.error(l("messages.configLoadError"))}finally{c(!1)}})()},[s]);const k=async f=>{m(!0);try{await hs.updatePluginConfig(s,f.config),A.success(l("messages.configSaveSuccess")),a()}catch{A.error(l("messages.configSaveError"))}finally{m(!1)}},I=(f,j)=>{switch(j.type){case"string":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{children:j.label||j.description}),e.jsx(_,{children:e.jsx(D,{placeholder:j.placeholder,...C})}),j.description&&j.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:j.description}),e.jsx(E,{})]})},f);case"number":case"percentage":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{children:j.label||j.description}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:j.placeholder,...C,onChange:g=>{const w=Number(g.target.value);j.type==="percentage"?C.onChange(Math.min(100,Math.max(0,w))):C.onChange(w)},className:j.type==="percentage"?"pr-8":"",min:j.type==="percentage"?0:void 0,max:j.type==="percentage"?100:void 0,step:j.type==="percentage"?1:void 0}),j.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})})]})}),j.description&&j.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:j.description}),e.jsx(E,{})]})},f);case"select":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{children:j.label||j.description}),e.jsxs(J,{onValueChange:C.onChange,defaultValue:C.value,children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:j.placeholder})})}),e.jsx(Y,{children:j.options?.map(g=>e.jsx(q,{value:g.value,children:g.label},g.value))})]}),j.description&&j.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:j.description}),e.jsx(E,{})]})},f);case"boolean":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:C})=>e.jsxs(v,{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(y,{className:"text-base",children:j.label||j.description}),j.description&&j.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:j.description})]}),e.jsx(_,{children:e.jsx(U,{checked:C.value,onCheckedChange:C.onChange})})]})},f);case"text":return e.jsx(b,{control:p.control,name:`config.${f}`,render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{children:j.label||j.description}),e.jsx(_,{children:e.jsx(_s,{placeholder:j.placeholder,...C})}),j.description&&j.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:j.description}),e.jsx(E,{})]})},f);default:return null}};return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(re,{className:"h-4 w-[200px]"}),e.jsx(re,{className:"h-10 w-full"}),e.jsx(re,{className:"h-4 w-[200px]"}),e.jsx(re,{className:"h-10 w-full"})]}):e.jsx(je,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(k),className:"space-y-4",children:[x&&Object.entries(x).map(([f,j])=>I(f,j)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(R,{type:"button",variant:"outline",onClick:n,disabled:i,children:l("config.cancel")}),e.jsx(R,{type:"submit",loading:i,disabled:i,children:l("config.save")})]})]})})}function mu(){const{t:s}=F("plugin"),[n,a]=u.useState(null),[l,r]=u.useState(!1),[c,i]=u.useState(null),[m,x]=u.useState(""),[o,d]=u.useState("all"),[p,k]=u.useState(!1),[I,f]=u.useState(!1),[j,C]=u.useState(!1),g=u.useRef(null),{data:w,isLoading:T,refetch:S}=ne({queryKey:["pluginList"],queryFn:async()=>{const{data:$}=await hs.getPluginList();return $}});w&&[...new Set(w.map($=>$.category||"other"))];const P=w?.filter($=>{const ae=$.name.toLowerCase().includes(m.toLowerCase())||$.description.toLowerCase().includes(m.toLowerCase())||$.code.toLowerCase().includes(m.toLowerCase()),te=o==="all"||$.category===o;return ae&&te}),L=async $=>{a($),hs.installPlugin($).then(()=>{A.success(s("messages.installSuccess")),S()}).catch(ae=>{A.error(ae.message||s("messages.installError"))}).finally(()=>{a(null)})},G=async $=>{a($),hs.uninstallPlugin($).then(()=>{A.success(s("messages.uninstallSuccess")),S()}).catch(ae=>{A.error(ae.message||s("messages.uninstallError"))}).finally(()=>{a(null)})},O=async($,ae)=>{a($),(ae?hs.disablePlugin:hs.enablePlugin)($).then(()=>{A.success(s(ae?"messages.disableSuccess":"messages.enableSuccess")),S()}).catch(Ue=>{A.error(Ue.message||s(ae?"messages.disableError":"messages.enableError"))}).finally(()=>{a(null)})},X=$=>{w?.find(ae=>ae.code===$),i($),r(!0)},Je=async $=>{if(!$.name.endsWith(".zip")){A.error(s("upload.error.format"));return}k(!0),hs.uploadPlugin($).then(()=>{A.success(s("messages.uploadSuccess")),f(!1),S()}).catch(ae=>{A.error(ae.message||s("messages.uploadError"))}).finally(()=>{k(!1),g.current&&(g.current.value="")})},is=$=>{$.preventDefault(),$.stopPropagation(),$.type==="dragenter"||$.type==="dragover"?C(!0):$.type==="dragleave"&&C(!1)},Vs=$=>{$.preventDefault(),$.stopPropagation(),C(!1),$.dataTransfer.files&&$.dataTransfer.files[0]&&Je($.dataTransfer.files[0])},ee=async $=>{a($),hs.deletePlugin($).then(()=>{A.success(s("messages.deleteSuccess")),S()}).catch(ae=>{A.error(ae.message||s("messages.deleteError"))}).finally(()=>{a(null)})};return e.jsxs(ke,{children:[e.jsxs(Te,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(xa,{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(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(kn,{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:m,onChange:$=>x($.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(R,{onClick:()=>f(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(va,{defaultValue:"all",className:"w-full",children:[e.jsxs(Ht,{children:[e.jsx(Ts,{value:"all",children:s("tabs.all")}),e.jsx(Ts,{value:"installed",children:s("tabs.installed")}),e.jsx(Ts,{value:"available",children:s("tabs.available")})]}),e.jsx(St,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:T?e.jsxs(e.Fragment,{children:[e.jsx(Qt,{}),e.jsx(Qt,{}),e.jsx(Qt,{})]}):P?.map($=>e.jsx(Yt,{plugin:$,onInstall:L,onUninstall:G,onToggleEnable:O,onOpenConfig:X,onDelete:ee,isLoading:n===$.name},$.name))})}),e.jsx(St,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:P?.filter($=>$.is_installed).map($=>e.jsx(Yt,{plugin:$,onInstall:L,onUninstall:G,onToggleEnable:O,onOpenConfig:X,onDelete:ee,isLoading:n===$.name},$.name))})}),e.jsx(St,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:P?.filter($=>!$.is_installed).map($=>e.jsx(Yt,{plugin:$,onInstall:L,onUninstall:G,onToggleEnable:O,onOpenConfig:X,onDelete:ee,isLoading:n===$.name},$.code))})})]})]}),e.jsx(ve,{open:l,onOpenChange:r,children:e.jsxs(pe,{className:"sm:max-w-lg",children:[e.jsxs(Ne,{children:[e.jsxs(be,{children:[w?.find($=>$.code===c)?.name," ",s("config.title")]}),e.jsx(Ee,{children:s("config.description")})]}),c&&e.jsx(du,{pluginName:c,onClose:()=>r(!1),onSuccess:()=>{r(!1),S()}})]})}),e.jsx(ve,{open:I,onOpenChange:f,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:s("upload.title")}),e.jsx(Ee,{children:s("upload.description")})]}),e.jsxs("div",{className:N("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",j&&"border-primary/50 bg-muted/50"),onDragEnter:is,onDragLeave:is,onDragOver:is,onDrop:Vs,children:[e.jsx("input",{type:"file",ref:g,className:"hidden",accept:".zip",onChange:$=>{const ae=$.target.files?.[0];ae&&Je(ae)}}),p?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(dt,{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:()=>g.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")})]})]})})]})]})})]})]})}function Yt({plugin:s,onInstall:n,onUninstall:a,onToggleEnable:l,onOpenConfig:r,onDelete:c,isLoading:i}){const{t:m}=F("plugin");return e.jsxs(Ae,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(Ge,{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(ps,{children:s.name}),s.is_installed&&e.jsx(K,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?m("status.enabled"):m("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(xa,{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(Qs,{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:[m("author"),": ",s.author]})})]})})]}),e.jsx(We,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[e.jsxs(R,{variant:"outline",size:"sm",onClick:()=>r(s.code),disabled:!s.is_enabled||i,children:[e.jsx(bi,{className:"mr-2 h-4 w-4"}),m("button.config")]}),e.jsxs(R,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>l(s.code,s.is_enabled),disabled:i,children:[e.jsx(yi,{className:"mr-2 h-4 w-4"}),s.is_enabled?m("button.disable"):m("button.enable")]}),e.jsx(qe,{title:m("uninstall.title"),description:m("uninstall.description"),cancelText:m("common:cancel"),confirmText:m("uninstall.button"),variant:"destructive",onConfirm:()=>a(s.code),children:e.jsxs(R,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:i,children:[e.jsx(ts,{className:"mr-2 h-4 w-4"}),m("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:()=>n(s.code),disabled:i,loading:i,children:m("button.install")}),e.jsx(qe,{title:m("delete.title"),description:m("delete.description"),cancelText:m("common:cancel"),confirmText:m("delete.button"),variant:"destructive",onConfirm:()=>c(s.code),children:e.jsx(R,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:i,children:e.jsx(ts,{className:"h-4 w-4"})})})]})})})]})}function Qt(){return e.jsxs(Ae,{children:[e.jsxs(Ge,{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(re,{className:"h-6 w-[200px]"}),e.jsx(re,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(re,{className:"h-5 w-[120px]"}),e.jsx(re,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(re,{className:"h-4 w-[300px]"}),e.jsx(re,{className:"h-4 w-[150px]"})]})]}),e.jsx(We,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(re,{className:"h-9 w-[100px]"}),e.jsx(re,{className:"h-9 w-[100px]"}),e.jsx(re,{className:"h-8 w-8"})]})})]})}const uu=Object.freeze(Object.defineProperty({__proto__:null,default:mu},Symbol.toStringTag,{value:"Module"})),xu=(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(_s,{placeholder:s.placeholder,...n});break;case"select":a=e.jsx("select",{className:N(Js({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 hu({themeKey:s,themeInfo:n}){const{t:a}=F("theme"),[l,r]=u.useState(!1),[c,i]=u.useState(!1),[m,x]=u.useState(!1),o=he({defaultValues:n.configs.reduce((k,I)=>(k[I.field_name]="",k),{})}),d=async()=>{i(!0),$c(s).then(({data:k})=>{Object.entries(k).forEach(([I,f])=>{o.setValue(I,f)})}).finally(()=>{i(!1)})},p=async k=>{x(!0),qc(s,k).then(()=>{A.success(a("config.success")),r(!1)}).finally(()=>{x(!1)})};return e.jsxs(ve,{open:l,onOpenChange:k=>{r(k),k?d():o.reset()},children:[e.jsx(He,{asChild:!0,children:e.jsx(R,{variant:"outline",children:a("card.configureTheme")})}),e.jsxs(pe,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:a("config.title",{name:n.name})}),e.jsx(Ee,{children:a("config.description")})]}),c?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(fa,{className:"h-6 w-6 animate-spin"})}):e.jsx(je,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(p),className:"space-y-4",children:[n.configs.map(k=>e.jsx(b,{control:o.control,name:k.field_name,render:({field:I})=>e.jsxs(v,{children:[e.jsx(y,{children:k.label}),e.jsx(_,{children:xu(k,I)}),e.jsx(E,{})]})},k.field_name)),e.jsxs(Ke,{className:"mt-6 gap-2",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:()=>r(!1),children:a("config.cancel")}),e.jsx(R,{type:"submit",loading:m,children:a("config.save")})]})]})})]})]})}function fu(){const{t:s}=F("theme"),[n,a]=u.useState(null),[l,r]=u.useState(!1),[c,i]=u.useState(!1),[m,x]=u.useState(!1),[o,d]=u.useState(null),p=u.useRef(null),[k,I]=u.useState(0),{data:f,isLoading:j,refetch:C}=ne({queryKey:["themeList"],queryFn:async()=>{const{data:O}=await Ac();return O}}),g=async O=>{a(O),Uc({frontend_theme:O}).then(()=>{A.success("主题切换成功"),C()}).finally(()=>{a(null)})},w=async O=>{if(!O.name.endsWith(".zip")){A.error(s("upload.error.format"));return}r(!0),Hc(O).then(()=>{A.success("主题上传成功"),i(!1),C()}).finally(()=>{r(!1),p.current&&(p.current.value="")})},T=O=>{O.preventDefault(),O.stopPropagation(),O.type==="dragenter"||O.type==="dragover"?x(!0):O.type==="dragleave"&&x(!1)},S=O=>{O.preventDefault(),O.stopPropagation(),x(!1),O.dataTransfer.files&&O.dataTransfer.files[0]&&w(O.dataTransfer.files[0])},P=()=>{o&&I(O=>O===0?o.images.length-1:O-1)},L=()=>{o&&I(O=>O===o.images.length-1?0:O+1)},G=(O,X)=>{I(0),d({name:O,images:X})};return e.jsxs(ke,{children:[e.jsxs(Te,{className:"flex items-center justify-between",children:[e.jsx(ze,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{className:"",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("div",{className:"mb-2",children:e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("title")})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-muted-foreground",children:s("description")}),e.jsxs(R,{onClick:()=>i(!0),variant:"outline",className:"ml-4 shrink-0",size:"sm",children:[e.jsx(dt,{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:j?e.jsxs(e.Fragment,{children:[e.jsx(en,{}),e.jsx(en,{})]}):f?.themes&&Object.entries(f.themes).map(([O,X])=>e.jsx(Ae,{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:N("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(qe,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(O===f?.active){A.error(s("card.delete.error.active"));return}a(O),Kc(O).then(()=>{A.success("主题删除成功"),C()}).finally(()=>{a(null)})},children:e.jsx(R,{disabled:n===O,loading:n===O,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(ts,{className:"h-4 w-4"})})})}),e.jsxs(Ge,{children:[e.jsx(ps,{children:X.name}),e.jsx(Qs,{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(We,{className:"flex items-center justify-end space-x-3",children:[X.images&&Array.isArray(X.images)&&X.images.length>0&&e.jsx(R,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>G(X.name,X.images),children:e.jsx(Ni,{className:"h-4 w-4"})}),e.jsx(hu,{themeKey:O,themeInfo:X}),e.jsx(R,{onClick:()=>g(O),disabled:n===O||O===f.active,loading:n===O,variant:O===f.active?"secondary":"default",children:O===f.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},O))}),e.jsx(ve,{open:c,onOpenChange:i,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:s("upload.title")}),e.jsx(Ee,{children:s("upload.description")})]}),e.jsxs("div",{className:N("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",m&&"border-primary/50 bg-muted/50"),onDragEnter:T,onDragLeave:T,onDragOver:T,onDrop:S,children:[e.jsx("input",{type:"file",ref:p,className:"hidden",accept:".zip",onChange:O=>{const X=O.target.files?.[0];X&&w(X)}}),l?e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("upload.uploading")})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsx("div",{className:"rounded-full border-2 border-muted-foreground/25 p-3",children:e.jsx(dt,{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(ve,{open:!!o,onOpenChange:O=>{O||(d(null),I(0))},children:e.jsxs(pe,{className:"max-w-4xl",children:[e.jsxs(Ne,{children:[e.jsxs(be,{children:[o?.name," ",s("preview.title")]}),e.jsx(Ee,{className:"text-center",children:o&&s("preview.imageCount",{current:k+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[k]&&e.jsx("img",{src:o.images[k],alt:`${o.name} 预览图 ${k+1}`,className:"h-full w-full object-contain"})}),o&&o.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(R,{variant:"outline",size:"icon",className:"absolute left-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:P,children:e.jsx(_i,{className:"h-4 w-4"})}),e.jsx(R,{variant:"outline",size:"icon",className:"absolute right-4 top-1/2 h-8 w-8 -translate-y-1/2 rounded-full bg-background/80 hover:bg-background",onClick:L,children:e.jsx(wi,{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((O,X)=>e.jsx("button",{onClick:()=>I(X),className:N("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",k===X?"border-primary":"border-transparent"),children:e.jsx("img",{src:O,alt:`缩略图 ${X+1}`,className:"h-full w-full object-cover"})},X))})]})})]})]})}function en(){return e.jsxs(Ae,{children:[e.jsxs(Ge,{children:[e.jsx(re,{className:"h-6 w-[200px]"}),e.jsx(re,{className:"h-4 w-[300px]"})]}),e.jsxs(We,{className:"flex items-center justify-end space-x-3",children:[e.jsx(re,{className:"h-10 w-[100px]"}),e.jsx(re,{className:"h-10 w-[100px]"})]})]})}const pu=Object.freeze(Object.defineProperty({__proto__:null,default:fu},Symbol.toStringTag,{value:"Module"})),Ea=u.forwardRef(({className:s,value:n,onChange:a,...l},r)=>{const[c,i]=u.useState("");u.useEffect(()=>{if(c.includes(",")){const x=new Set([...n,...c.split(",").map(o=>o.trim())]);a(Array.from(x)),i("")}},[c,a,n]);const m=()=>{if(c){const x=new Set([...n,c]);a(Array.from(x)),i("")}};return e.jsxs("div",{className:N(" 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(B,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{a(n.filter(o=>o!==x))},children:e.jsx(aa,{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(),m()):x.key==="Backspace"&&c.length===0&&n.length>0&&(x.preventDefault(),a(n.slice(0,-1)))},...l,ref:r})]})});Ea.displayName="InputTags";const gu=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()}),ju={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function Ar({refetch:s,dialogTrigger:n,type:a="add",defaultFormValues:l=ju}){const{t:r}=F("notice"),[c,i]=u.useState(!1),m=he({resolver:ge(gu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new pa({html:!0});return e.jsx(je,{...m,children:e.jsxs(ve,{onOpenChange:i,open:c,children:[e.jsx(He,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Pe,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:r(a==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ee,{})]}),e.jsx(b,{control:m.control,name:"title",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:r("form.fields.title.placeholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"content",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.content.label")}),e.jsx(_,{children:e.jsx(ga,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"img_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("form.fields.img_url.placeholder"),...o,value:o.value||""})})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"show",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"tags",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(Ea,{value:o.value,onChange:o.onChange,placeholder:r("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsxs(Ke,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.buttons.cancel")})}),e.jsx(R,{type:"submit",onClick:o=>{o.preventDefault(),m.handleSubmit(async d=>{id(d).then(({data:p})=>{p&&(A.success(r("form.buttons.success")),s(),i(!1))})})()},children:r("form.buttons.submit")})]})]})]})})}function vu({table:s,refetch:n,saveOrder:a,isSortMode:l}){const{t:r}=F("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(Ar,{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(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,className:"h-8",size:"sm",children:r(l?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const bu=s=>{const{t:n}=F("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(Ci,{className:"h-4 w-4 text-muted-foreground cursor-move"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(z,{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(z,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(U,{defaultChecked:a.getValue("show"),onCheckedChange:async()=>{const{data:l}=await dd({id:a.original.id});l||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:a})=>e.jsx(z,{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(z,{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(Ar,{refetch:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(As,{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(qe,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{cd({id:a.original.id}).then(()=>{A.success(n("table.actions.delete.success")),s()})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ts,{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 yu(){const[s,n]=u.useState({}),[a,l]=u.useState({}),[r,c]=u.useState([]),[i,m]=u.useState([]),[x,o]=u.useState(!1),[d,p]=u.useState({}),[k,I]=u.useState({pageSize:50,pageIndex:0}),[f,j]=u.useState([]),{refetch:C}=ne({queryKey:["notices"],queryFn:async()=>{const{data:P}=await Ja.getList();return j(P),P}});u.useEffect(()=>{l({"drag-handle":x,content:!x,created_at:!x,actions:!x}),I({pageSize:x?99999:50,pageIndex:0})},[x]);const g=(P,L)=>{x&&(P.dataTransfer.setData("text/plain",L.toString()),P.currentTarget.classList.add("opacity-50"))},w=(P,L)=>{if(!x)return;P.preventDefault(),P.currentTarget.classList.remove("bg-muted");const G=parseInt(P.dataTransfer.getData("text/plain"));if(G===L)return;const O=[...f],[X]=O.splice(G,1);O.splice(L,0,X),j(O)},T=async()=>{if(!x){o(!0);return}Ja.sort(f.map(P=>P.id)).then(()=>{A.success("排序保存成功"),o(!1),C()}).finally(()=>{o(!1)})},S=Ye({data:f??[],columns:bu(C),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:d,pagination:k},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:m,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:p,onPaginationChange:I,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(os,{table:S,toolbar:P=>e.jsx(vu,{table:P,refetch:C,saveOrder:T,isSortMode:x}),draggable:x,onDragStart:g,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:w,showPagination:!x})})}function Nu(){const{t:s}=F("notice");return e.jsxs(ke,{children:[e.jsxs(Te,{className:"flex items-center justify-between",children:[e.jsx(ze,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(yu,{})})]})]})}const _u=Object.freeze(Object.defineProperty({__proto__:null,default:Nu},Symbol.toStringTag,{value:"Module"})),wu=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()}),Cu={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function $r({refreshData:s,dialogTrigger:n,type:a="add",defaultFormValues:l=Cu}){const{t:r}=F("knowledge"),[c,i]=u.useState(!1),m=he({resolver:ge(wu),defaultValues:l,mode:"onChange",shouldFocusError:!0}),x=new pa({html:!0});return u.useEffect(()=>{c&&l.id&&ud(l.id).then(({data:o})=>{m.reset(o)})},[l.id,m,c]),e.jsxs(ve,{onOpenChange:i,open:c,children:[e.jsx(He,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Pe,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[1025px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:r(a==="add"?"form.add":"form.edit")}),e.jsx(Ee,{})]}),e.jsxs(je,{...m,children:[e.jsx(b,{control:m.control,name:"title",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:r("form.titlePlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"category",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:r("form.categoryPlaceholder"),...o})})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"language",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.language")}),e.jsx(_,{children:e.jsxs(J,{value:o.value,onValueChange:o.onChange,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:r("form.languagePlaceholder")})}),e.jsx(Y,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(d=>e.jsx(q,{value:d.value,className:"cursor-pointer",children:r(`languages.${d.value}`)},d.value))})]})})]})}),e.jsx(b,{control:m.control,name:"body",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.content")}),e.jsx(_,{children:e.jsx(ga,{style:{height:"500px"},value:o.value,renderHTML:d=>x.render(d),onChange:({text:d})=>{o.onChange(d)}})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"show",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(U,{checked:o.value,onCheckedChange:o.onChange})})}),e.jsx(E,{})]})}),e.jsxs(Ke,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{m.handleSubmit(o=>{xd(o).then(({data:d})=>{d&&(m.reset(),A.success(r("messages.operationSuccess")),i(!1),s())})})()},children:r("form.submit")})]})]})]})]})}function Su({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(we,{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(ls,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Rs,{children:[e.jsx($s,{placeholder:n}),e.jsxs(Is,{children:[e.jsx(qs,{children:"No results found."}),e.jsx($e,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(De,{onSelect:()=>{i?r.delete(c.value):r.add(c.value);const m=Array.from(r);s?.setFilterValue(m.length?m:void 0)},children:[e.jsx("div",{className:N("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(zs,{className:N("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(et,{}),e.jsx($e,{children:e.jsx(De,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function ku({table:s,refetch:n,saveOrder:a,isSortMode:l}){const r=s.getState().columnFilters.length>0,{t:c}=F("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($r,{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(Su,{column:s.getColumn("category"),title:c("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(i=>i.getValue("category")))).map(i=>({label:i,value:i}))}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[c("toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:l?"default":"outline",onClick:a,size:"sm",children:c(l?"toolbar.saveSort":"toolbar.editSort")})})]})}const Tu=({refetch:s,isSortMode:n=!1})=>{const{t:a}=F("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(zt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:l})=>e.jsx(z,{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(z,{column:l,title:a("columns.status")}),cell:({row:l})=>e.jsx("div",{className:"flex items-center",children:e.jsx(U,{defaultChecked:l.getValue("show"),onCheckedChange:async()=>{fd({id:l.original.id}).then(({data:r})=>{r||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:l})=>e.jsx(z,{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(z,{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(z,{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($r,{refreshData:s,dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(As,{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(qe,{title:a("messages.deleteConfirm"),description:a("messages.deleteDescription"),confirmText:a("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{hd({id:l.original.id}).then(({data:r})=>{r&&(A.success(a("messages.operationSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ts,{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 Pu(){const[s,n]=u.useState([]),[a,l]=u.useState([]),[r,c]=u.useState(!1),[i,m]=u.useState([]),[x,o]=u.useState({"drag-handle":!1}),[d,p]=u.useState({pageSize:20,pageIndex:0}),{refetch:k,isLoading:I,data:f}=ne({queryKey:["knowledge"],queryFn:async()=>{const{data:T}=await md();return m(T||[]),T}});u.useEffect(()=>{o({"drag-handle":r,actions:!r}),p({pageSize:r?99999:10,pageIndex:0})},[r]);const j=(T,S)=>{r&&(T.dataTransfer.setData("text/plain",S.toString()),T.currentTarget.classList.add("opacity-50"))},C=(T,S)=>{if(!r)return;T.preventDefault(),T.currentTarget.classList.remove("bg-muted");const P=parseInt(T.dataTransfer.getData("text/plain"));if(P===S)return;const L=[...i],[G]=L.splice(P,1);L.splice(S,0,G),m(L)},g=async()=>{r?pd({ids:i.map(T=>T.id)}).then(()=>{k(),c(!1),A.success("排序保存成功")}):c(!0)},w=Ye({data:i,columns:Tu({refetch:k,isSortMode:r}),state:{sorting:a,columnFilters:s,columnVisibility:x,pagination:d},onSortingChange:l,onColumnFiltersChange:n,onColumnVisibilityChange:o,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(os,{table:w,toolbar:T=>e.jsx(ku,{table:T,refetch:k,saveOrder:g,isSortMode:r}),draggable:r,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:!r})}function Du(){const{t:s}=F("knowledge");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(Pu,{})})]})]})}const Eu=Object.freeze(Object.defineProperty({__proto__:null,default:Du},Symbol.toStringTag,{value:"Module"}));function Ru(s,n){const[a,l]=u.useState(s);return u.useEffect(()=>{const r=setTimeout(()=>l(s),n);return()=>{clearTimeout(r)}},[s,n]),a}function Jt(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 Iu(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 Vu(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 qr=u.forwardRef(({className:s,...n},a)=>Si(r=>r.filtered.count===0)?e.jsx("div",{ref:a,className:N("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);qr.displayName="CommandEmpty";const xt=u.forwardRef(({value:s,onChange:n,placeholder:a,defaultOptions:l=[],options:r,delay:c,onSearch:i,loadingIndicator:m,emptyIndicator:x,maxSelected:o=Number.MAX_SAFE_INTEGER,onMaxSelected:d,hidePlaceholderWhenSelected:p,disabled:k,groupBy:I,className:f,badgeClassName:j,selectFirstItem:C=!0,creatable:g=!1,triggerSearchOnFocus:w=!1,commandProps:T,inputProps:S,hideClearAllButton:P=!1},L)=>{const G=u.useRef(null),[O,X]=u.useState(!1),Je=u.useRef(!1),[is,Vs]=u.useState(!1),[ee,$]=u.useState(s||[]),[ae,te]=u.useState(Jt(l,I)),[Ue,st]=u.useState(""),tt=Ru(Ue,c||500);u.useImperativeHandle(L,()=>({selectedValue:[...ee],input:G.current,focus:()=>G.current?.focus()}),[ee]);const jt=u.useCallback(Q=>{const ie=ee.filter(Oe=>Oe.value!==Q.value);$(ie),n?.(ie)},[n,ee]),ml=u.useCallback(Q=>{const ie=G.current;ie&&((Q.key==="Delete"||Q.key==="Backspace")&&ie.value===""&&ee.length>0&&(ee[ee.length-1].fixed||jt(ee[ee.length-1])),Q.key==="Escape"&&ie.blur())},[jt,ee]);u.useEffect(()=>{s&&$(s)},[s]),u.useEffect(()=>{if(!r||i)return;const Q=Jt(r||[],I);JSON.stringify(Q)!==JSON.stringify(ae)&&te(Q)},[l,r,I,i,ae]),u.useEffect(()=>{const Q=async()=>{Vs(!0);const Oe=await i?.(tt);te(Jt(Oe||[],I)),Vs(!1)};(async()=>{!i||!O||(w&&await Q(),tt&&await Q())})()},[tt,I,O,w]);const ul=()=>{if(!g||Vu(ae,[{value:Ue,label:Ue}])||ee.find(ie=>ie.value===Ue))return;const Q=e.jsx(De,{value:Ue,className:"cursor-pointer",onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onSelect:ie=>{if(ee.length>=o){d?.(ee.length);return}st("");const Oe=[...ee,{value:ie,label:ie}];$(Oe),n?.(Oe)},children:`Create "${Ue}"`});if(!i&&Ue.length>0||i&&tt.length>0&&!is)return Q},xl=u.useCallback(()=>{if(x)return i&&!g&&Object.keys(ae).length===0?e.jsx(De,{value:"-",disabled:!0,children:x}):e.jsx(qr,{children:x})},[g,x,i,ae]),hl=u.useMemo(()=>Iu(ae,ee),[ae,ee]),fl=u.useCallback(()=>{if(T?.filter)return T.filter;if(g)return(Q,ie)=>Q.toLowerCase().includes(ie.toLowerCase())?1:-1},[g,T?.filter]),pl=u.useCallback(()=>{const Q=ee.filter(ie=>ie.fixed);$(Q),n?.(Q)},[n,ee]);return e.jsxs(Rs,{...T,onKeyDown:Q=>{ml(Q),T?.onKeyDown?.(Q)},className:N("h-auto overflow-visible bg-transparent",T?.className),shouldFilter:T?.shouldFilter!==void 0?T.shouldFilter:!i,filter:fl(),children:[e.jsx("div",{className:N("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":!k&&ee.length!==0},f),onClick:()=>{k||G.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[ee.map(Q=>e.jsxs(K,{className:N("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",j),"data-fixed":Q.fixed,"data-disabled":k||void 0,children:[Q.label,e.jsx("button",{className:N("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(k||Q.fixed)&&"hidden"),onKeyDown:ie=>{ie.key==="Enter"&&jt(Q)},onMouseDown:ie=>{ie.preventDefault(),ie.stopPropagation()},onClick:()=>jt(Q),children:e.jsx(aa,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},Q.value)),e.jsx(Ve.Input,{...S,ref:G,value:Ue,disabled:k,onValueChange:Q=>{st(Q),S?.onValueChange?.(Q)},onBlur:Q=>{Je.current===!1&&X(!1),S?.onBlur?.(Q)},onFocus:Q=>{X(!0),w&&i?.(tt),S?.onFocus?.(Q)},placeholder:p&&ee.length!==0?"":a,className:N("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},S?.className)}),e.jsx("button",{type:"button",onClick:pl,className:N((P||k||ee.length<1||ee.filter(Q=>Q.fixed).length===ee.length)&&"hidden"),children:e.jsx(aa,{})})]})}),e.jsx("div",{className:"relative",children:O&&e.jsx(Is,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Je.current=!1},onMouseEnter:()=>{Je.current=!0},onMouseUp:()=>{G.current?.focus()},children:is?e.jsx(e.Fragment,{children:m}):e.jsxs(e.Fragment,{children:[xl(),ul(),!C&&e.jsx(De,{value:"-",className:"hidden"}),Object.entries(hl).map(([Q,ie])=>e.jsx($e,{heading:Q,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ie.map(Oe=>e.jsx(De,{value:Oe.value,disabled:Oe.disable,onMouseDown:at=>{at.preventDefault(),at.stopPropagation()},onSelect:()=>{if(ee.length>=o){d?.(ee.length);return}st("");const at=[...ee,Oe];$(at),n?.(at)},className:N("cursor-pointer",Oe.disable&&"cursor-default text-muted-foreground"),children:Oe.label},Oe.value))})},Q))]})})})]})});xt.displayName="MultipleSelector";const Fu=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 Kt({refetch:s,dialogTrigger:n,defaultValues:a={name:""},type:l="add"}){const{t:r}=F("group"),c=he({resolver:ge(Fu(r)),defaultValues:a,mode:"onChange"}),[i,m]=u.useState(!1),[x,o]=u.useState(!1),d=async p=>{o(!0),Jc(p).then(()=>{A.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),c.reset(),m(!1)}).finally(()=>{o(!1)})};return e.jsxs(ve,{open:i,onOpenChange:m,children:[e.jsx(He,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Pe,{icon:"ion:add"}),e.jsx("span",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Ee,{children:r(l==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(je,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(d),className:"space-y-4",children:[e.jsx(b,{control:c.control,name:"name",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.name")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("form.namePlaceholder"),...p,className:"w-full"})}),e.jsx(M,{children:r("form.nameDescription")}),e.jsx(E,{})]})}),e.jsxs(Ke,{className:"gap-2",children:[e.jsx(gt,{asChild:!0,children:e.jsx(R,{type:"button",variant:"outline",children:r("form.cancel")})}),e.jsxs(R,{type:"submit",disabled:x||!c.formState.isValid,children:[x&&e.jsx(fa,{className:"mr-2 h-4 w-4 animate-spin"}),r(l==="edit"?"form.update":"form.create")]})]})]})})]})]})}const Hr=u.createContext(void 0);function Mu({children:s,refetch:n}){const[a,l]=u.useState(!1),[r,c]=u.useState(null),[i,m]=u.useState(Ce.Shadowsocks);return e.jsx(Hr.Provider,{value:{isOpen:a,setIsOpen:l,editingServer:r,setEditingServer:c,serverType:i,setServerType:m,refetch:n},children:s})}function Kr(){const s=u.useContext(Hr);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function Zt({dialogTrigger:s,value:n,setValue:a,templateType:l}){const{t:r}=F("server");u.useEffect(()=>{console.log(n)},[n]);const[c,i]=u.useState(!1),[m,x]=u.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[o,d]=u.useState(null),p=g=>{if(!g)return null;try{const w=JSON.parse(g);return typeof w!="object"||w===null?r("network_settings.validation.must_be_object"):null}catch{return r("network_settings.validation.invalid_json")}},k={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"}}}},I=()=>{switch(l){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];default:return[]}},f=()=>{const g=p(m||"");if(g){A.error(g);return}try{if(!m){a(null),i(!1);return}a(JSON.parse(m)),i(!1)}catch{A.error(r("network_settings.errors.save_failed"))}},j=g=>{x(g),d(p(g))},C=g=>{const w=k[g];if(w){const T=JSON.stringify(w.content,null,2);x(T),d(null)}};return u.useEffect(()=>{c&&console.log(n)},[c,n]),u.useEffect(()=>{c&&n&&Object.keys(n).length>0&&x(JSON.stringify(n,null,2))},[c,n]),e.jsxs(ve,{open:c,onOpenChange:g=>{!g&&c&&f(),i(g)},children:[e.jsx(He,{asChild:!0,children:s??e.jsx(B,{variant:"link",children:r("network_settings.edit_protocol")})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(Ne,{children:e.jsx(be,{children:r("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[I().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:I().map(g=>e.jsx(B,{variant:"outline",size:"sm",onClick:()=>C(g),children:r("network_settings.use_template",{template:k[g].label})},g))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_s,{className:`min-h-[200px] font-mono text-sm ${o?"border-red-500 focus-visible:ring-red-500":""}`,value:m,placeholder:I().length>0?r("network_settings.json_config_placeholder_with_template"):r("network_settings.json_config_placeholder"),onChange:g=>j(g.target.value)}),o&&e.jsx("p",{className:"text-sm text-red-500",children:o})]})]}),e.jsxs(Ke,{className:"gap-2",children:[e.jsx(B,{variant:"outline",onClick:()=>i(!1),children:r("common.cancel")}),e.jsx(B,{onClick:f,disabled:!!o,children:r("common.confirm")})]})]})]})}function $h(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 Ou={},zu=Object.freeze(Object.defineProperty({__proto__:null,default:Ou},Symbol.toStringTag,{value:"Module"})),qh=Ai(zu),sn=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),Lu=()=>{try{const s=ki.box.keyPair(),n=sn(Ha.encodeBase64(s.secretKey)),a=sn(Ha.encodeBase64(s.publicKey));return{privateKey:n,publicKey:a}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},Au=()=>{try{return Lu()}catch(s){throw console.error("Error generating key pair:",s),s}},$u=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)},qu=()=>{const s=Math.floor(Math.random()*8)*2+2;return $u(s)},Hu=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({})}),Ku=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({})}),Uu=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({})}),Bu=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({})}),Gu=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("")}),xs={shadowsocks:{schema:Hu,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:Ku,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:Uu,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Bu,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Gu,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"]}},Wu=({serverType:s,value:n,onChange:a})=>{const{t:l}=F("server"),r=s?xs[s]:null,c=r?.schema||h.record(h.any()),i=s?c.parse({}):{},m=he({resolver:ge(c),defaultValues:i,mode:"onChange"});if(u.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const f=c.parse({});m.reset(f)}}else m.reset(n)},[s,n,a,m,c]),u.useEffect(()=>{const f=m.watch(j=>{a(j)});return()=>f.unsubscribe()},[m,a]),!s||!r)return null;const I={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:m.control,name:"cipher",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f.onChange,value:f.value,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:xs.shadowsocks.ciphers.map(j=>e.jsx(q,{value:j,children:j},j))})})]})})]})}),e.jsx(b,{control:m.control,name:"obfs",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.shadowsocks.obfs.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f.onChange,value:f.value,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.shadowsocks.obfs.placeholder")})}),e.jsx(Y,{children:e.jsxs(ws,{children:[e.jsx(q,{value:"0",children:l("dynamic_form.shadowsocks.obfs.none")}),e.jsx(q,{value:"http",children:l("dynamic_form.shadowsocks.obfs.http")})]})})]})})]})}),m.watch("obfs")==="http"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"obfs_settings.path",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:l("dynamic_form.shadowsocks.obfs_settings.path"),...f})}),e.jsx(E,{})]})}),e.jsx(b,{control:m.control,name:"obfs_settings.host",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(_,{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(b,{control:m.control,name:"tls",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:f.value?.toString(),onValueChange:j=>f.onChange(Number(j)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:l("dynamic_form.vmess.tls.disabled")}),e.jsx(q,{value:"1",children:l("dynamic_form.vmess.tls.enabled")})]})]})})]})}),m.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vmess.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(b,{control:m.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(U,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx(b,{control:m.control,name:"network",render:({field:f})=>e.jsxs(v,{children:[e.jsxs(y,{children:[l("dynamic_form.vmess.network.label"),e.jsx(Zt,{value:m.watch("network_settings"),setValue:j=>m.setValue("network_settings",j),templateType:m.watch("network")})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f.onChange,value:f.value,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.vmess.network.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:xs.vmess.networkOptions.map(j=>e.jsx(q,{value:j.value,className:"cursor-pointer",children:j.label},j.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.trojan.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(b,{control:m.control,name:"allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(U,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(b,{control:m.control,name:"network",render:({field:f})=>e.jsxs(v,{children:[e.jsxs(y,{children:[l("dynamic_form.trojan.network.label"),e.jsx(Zt,{value:m.watch("network_settings")||{},setValue:j=>m.setValue("network_settings",j),templateType:m.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f.onChange,value:f.value||"tcp",children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.trojan.network.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:xs.trojan.networkOptions.map(j=>e.jsx(q,{value:j.value,className:"cursor-pointer",children:j.label},j.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"version",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(J,{value:(f.value||2).toString(),onValueChange:j=>f.onChange(Number(j)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.version.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:xs.hysteria.versions.map(j=>e.jsxs(q,{value:j,className:"cursor-pointer",children:["V",j]},j))})})]})})]})}),m.watch("version")==1&&e.jsx(b,{control:m.control,name:"alpn",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(J,{value:f.value||"h2",onValueChange:f.onChange,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:xs.hysteria.alpnOptions.map(j=>e.jsx(q,{value:j,children:j},j))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"obfs.open",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(U,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})}),!!m.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[m.watch("version")=="2"&&e.jsx(b,{control:m.control,name:"obfs.type",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(J,{value:f.value||"salamander",onValueChange:f.onChange,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:e.jsx(q,{value:"salamander",children:l("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(b,{control:m.control,name:"obfs.password",render:({field:f})=>e.jsxs(v,{className:m.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.obfs.password.placeholder"),...f,value:f.value||"",className:"pr-9"})}),e.jsx(B,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",C=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(g=>j[g%j.length]).join("");m.setValue("obfs.password",C),A.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(Pe,{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(b,{control:m.control,name:"tls.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.hysteria.tls.server_name.placeholder"),...f,value:f.value||""})})]})}),e.jsx(b,{control:m.control,name:"tls.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(U,{checked:f.value||!1,onCheckedChange:f.onChange})})})]})})]}),e.jsx(b,{control:m.control,name:"bandwidth.up",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.up.placeholder")+(m.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(b,{control:m.control,name:"bandwidth.down",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:l("dynamic_form.hysteria.bandwidth.down.placeholder")+(m.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(b,{control:m.control,name:"tls",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:f.value?.toString(),onValueChange:j=>f.onChange(Number(j)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:l("dynamic_form.vless.tls.none")}),e.jsx(q,{value:"1",children:l("dynamic_form.vless.tls.tls")}),e.jsx(q,{value:"2",children:l("dynamic_form.vless.tls.reality")})]})]})})]})}),m.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"tls_settings.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.tls_settings.server_name.placeholder"),...f})})]})}),e.jsx(b,{control:m.control,name:"tls_settings.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(U,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),m.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:m.control,name:"reality_settings.server_name",render:({field:f})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_name.placeholder"),...f})})]})}),e.jsx(b,{control:m.control,name:"reality_settings.server_port",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dynamic_form.vless.reality_settings.server_port.placeholder"),...f})})]})}),e.jsx(b,{control:m.control,name:"reality_settings.allow_insecure",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(U,{checked:f.value,onCheckedChange:f.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(b,{control:m.control,name:"reality_settings.private_key",render:({field:f})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{...f,className:"pr-9"})}),e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(B,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const j=Au();m.setValue("reality_settings.private_key",j.privateKey),m.setValue("reality_settings.public_key",j.publicKey),A.success(l("dynamic_form.vless.reality_settings.key_pair.success"))}catch{A.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(Pe,{icon:"ion:key-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Pt,{children:e.jsx(oe,{children:e.jsx("p",{children:l("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(b,{control:m.control,name:"reality_settings.public_key",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(D,{...f})})]})}),e.jsx(b,{control:m.control,name:"reality_settings.short_id",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{...f,className:"pr-9",placeholder:l("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(B,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const j=qu();m.setValue("reality_settings.short_id",j),A.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(Pe,{icon:"ion:refresh-outline",className:"h-4 w-4 transition-transform hover:rotate-180 duration-300"})})}),e.jsx(Pt,{children:e.jsx(oe,{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(b,{control:m.control,name:"network",render:({field:f})=>e.jsxs(v,{children:[e.jsxs(y,{children:[l("dynamic_form.vless.network.label"),e.jsx(Zt,{value:m.watch("network_settings"),setValue:j=>m.setValue("network_settings",j),templateType:m.watch("network")})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f.onChange,value:f.value,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.network.placeholder")})}),e.jsx(Y,{children:e.jsx(ws,{children:xs.vless.networkOptions.map(j=>e.jsx(q,{value:j.value,className:"cursor-pointer",children:j.label},j.value))})})]})})]})}),e.jsx(b,{control:m.control,name:"flow",render:({field:f})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:j=>f.onChange(j==="none"?null:j),value:f.value||"none",children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dynamic_form.vless.flow.placeholder")})}),e.jsx(Y,{children:xs.vless.flowOptions.map(j=>e.jsx(q,{value:j,children:j},j))})]})})]})})]})};return e.jsx(xe,{children:I[s]?.()})},Yu=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()}),yt={id:null,code:"",name:"",rate:"1",tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null};function Qu(){const{t:s}=F("server"),{isOpen:n,setIsOpen:a,editingServer:l,setEditingServer:r,serverType:c,setServerType:i,refetch:m}=Kr(),[x,o]=u.useState([]),[d,p]=u.useState([]),[k,I]=u.useState([]),f=he({resolver:ge(Yu),defaultValues:yt,mode:"onChange"});u.useEffect(()=>{j()},[n]),u.useEffect(()=>{l?.type&&l.type!==c&&i(l.type)},[l,c,i]),u.useEffect(()=>{l?l.type===c&&f.reset({...yt,...l}):f.reset({...yt,protocol_settings:xs[c].schema.parse({})})},[l,f,c]);const j=async()=>{if(!n)return;const[S,P,L]=await Promise.all([qt(),Er(),Dr()]);o(S.data?.map(G=>({label:G.name,value:G.id.toString()}))||[]),p(P.data?.map(G=>({label:G.remarks,value:G.id.toString()}))||[]),I(L.data||[])},C=u.useMemo(()=>k?.filter(S=>(S.parent_id===0||S.parent_id===null)&&S.type===c&&S.id!==f.watch("id")),[c,k,f]),g=()=>e.jsxs(Ds,{children:[e.jsx(Es,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Pe,{icon:"ion:add"}),e.jsx("div",{children:s("form.add_node")})]})}),e.jsx(gs,{align:"start",children:e.jsx(bc,{children:Ms.map(({type:S,label:P})=>e.jsx(ye,{onClick:()=>{i(S),a(!0)},className:"cursor-pointer",children:e.jsx(K,{variant:"outline",className:"text-white",style:{background:fs[S]},children:P})},S))})})]}),w=()=>{a(!1),r(null),f.reset(yt)},T=async()=>{const S=f.getValues();(await Bc({...S,type:c})).data&&(w(),A.success(s("form.success")),m())};return e.jsxs(ve,{open:n,onOpenChange:w,children:[g(),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Ee,{})]}),e.jsxs(je,{...f,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:f.control,name:"name",render:({field:S})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:s("form.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.name.placeholder"),...S})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"rate",render:({field:S})=>e.jsxs(v,{className:"flex-[1]",children:[e.jsx(y,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(_,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...S})})}),e.jsx(E,{})]})})]}),e.jsx(b,{control:f.control,name:"code",render:({field:S})=>e.jsxs(v,{children:[e.jsxs(y,{children:[s("form.code.label"),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:s("form.code.optional")})]}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.code.placeholder"),...S,value:S.value||""})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"tags",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(Ea,{value:S.value,onChange:S.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"group_ids",render:({field:S})=>e.jsxs(v,{children:[e.jsxs(y,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Kt,{dialogTrigger:e.jsx(R,{variant:"link",children:s("form.groups.add")}),refetch:j})]}),e.jsx(_,{children:e.jsx(xt,{options:x,onChange:P=>S.onChange(P.map(L=>L.value)),value:x?.filter(P=>S.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(b,{control:f.control,name:"host",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...S})}),e.jsx(E,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{control:f.control,name:"port",render:({field:S})=>e.jsxs(v,{className:"flex-1",children:[e.jsxs(y,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(Pe,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Pt,{children:e.jsx(oe,{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(_,{children:e.jsx(D,{placeholder:s("form.port.placeholder"),...S})}),e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(R,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const P=S.value;P&&f.setValue("server_port",P)},children:e.jsx(Pe,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(oe,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"server_port",render:({field:S})=>e.jsxs(v,{className:"flex-1",children:[e.jsxs(y,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(Pe,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Pt,{children:e.jsx(oe,{side:"top",sideOffset:8,className:"max-w-80 p-3",children:e.jsx("p",{children:s("form.server_port.tooltip")})})})]})})]}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.server_port.placeholder"),...S})}),e.jsx(E,{})]})})]})]}),n&&e.jsx(Wu,{serverType:c,value:f.watch("protocol_settings"),onChange:S=>f.setValue("protocol_settings",S,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(b,{control:f.control,name:"parent_id",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.parent.label")}),e.jsxs(J,{onValueChange:S.onChange,value:S.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:s("form.parent.none")}),C?.map(P=>e.jsx(q,{value:P.id.toString(),className:"cursor-pointer",children:P.name},P.id))]})]}),e.jsx(E,{})]})}),e.jsx(b,{control:f.control,name:"route_ids",render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(xt,{options:d,onChange:P=>S.onChange(P.map(L=>L.value)),value:d?.filter(P=>S.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(Ke,{className:"mt-6",children:[e.jsx(R,{type:"button",variant:"outline",onClick:w,children:s("form.cancel")}),e.jsx(R,{type:"submit",onClick:T,children:s("form.submit")})]})]})]})]})}function tn({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(we,{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(ls,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Rs,{children:[e.jsx($s,{placeholder:n}),e.jsxs(Is,{children:[e.jsx(qs,{children:"No results found."}),e.jsx($e,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(De,{onSelect:()=>{i?r.delete(c.value):r.add(c.value);const m=Array.from(r);s?.setFilterValue(m.length?m:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:N("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(zs,{className:N("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(et,{}),e.jsx($e,{children:e.jsx(De,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Ju=[{value:Ce.Shadowsocks,label:Ms.find(s=>s.type===Ce.Shadowsocks)?.label,color:fs[Ce.Shadowsocks]},{value:Ce.Vmess,label:Ms.find(s=>s.type===Ce.Vmess)?.label,color:fs[Ce.Vmess]},{value:Ce.Trojan,label:Ms.find(s=>s.type===Ce.Trojan)?.label,color:fs[Ce.Trojan]},{value:Ce.Hysteria,label:Ms.find(s=>s.type===Ce.Hysteria)?.label,color:fs[Ce.Hysteria]},{value:Ce.Vless,label:Ms.find(s=>s.type===Ce.Vless)?.label,color:fs[Ce.Vless]}];function Zu({table:s,saveOrder:n,isSortMode:a,groups:l}){const r=s.getState().columnFilters.length>0,{t:c}=F("server"),i=l.map(m=>({label:m,value:m}));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(Qu,{}),e.jsx(D,{placeholder:c("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:m=>s.getColumn("name")?.setFilterValue(m.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(tn,{column:s.getColumn("type"),title:c("toolbar.type"),options:Ju}),s.getColumn("groups")&&e.jsx(tn,{column:s.getColumn("groups"),title:c("columns.groups.title"),options:i})]}),r&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[c("toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]}),a&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:c("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:c(a?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const ht=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"})}),Nt={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"},Xu=s=>{const{t:n}=F("server");return[{id:"drag-handle",header:({column:a})=>e.jsx(z,{column:a,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(zt,{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(z,{column:a,title:n("columns.nodeId")}),cell:({row:a})=>{const l=a.getValue("id"),r=a.original.code;return e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(K,{variant:"outline",className:N("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:fs[a.original.type]},children:[e.jsx(tr,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:r??l}),a.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:a.original.parent?.code||a.original.parent?.id})]}):""]})]}),e.jsx(R,{variant:"ghost",size:"icon",className:"size-5 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:text-muted-foreground group-hover/id:opacity-100",onClick:c=>{c.stopPropagation(),Rt(r||l.toString()).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(Ka,{className:"size-3"})})]})}),e.jsxs(oe,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ms.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(z,{column:a,title:n("columns.show")}),cell:({row:a})=>{const[l,r]=u.useState(!!a.getValue("show"));return e.jsx(U,{checked:l,onCheckedChange:async c=>{r(c),Yc({id:a.original.id,type:a.original.type,show:c?1:0}).catch(()=>{r(!c),s()})},style:{backgroundColor:l?fs[a.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx("div",{className:"flex items-center",children:e.jsx(z,{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:N("h-2.5 w-2.5 rounded-full",Nt[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:N("h-2.5 w-2.5 rounded-full",Nt[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:N("h-2.5 w-2.5 rounded-full",Nt[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:a})=>e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:N("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",Nt[a.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:a.getValue("name")})]})}),e.jsx(oe,{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(z,{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(xe,{delayDuration:0,children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"icon",className:"size-6 text-muted-foreground/40 opacity-0 transition-all duration-200 hover:bg-muted/50 hover:text-muted-foreground group-hover:opacity-100",onClick:c=>{c.stopPropagation(),Rt(l).then(()=>{A.success(n("common:copy.success"))})},children:e.jsx(Ka,{className:"size-3"})})}),e.jsx(oe,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:a})=>e.jsx(z,{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(ht,{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(z,{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(z,{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:N("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(z,{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:fs[l]},children:l})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:a})=>e.jsx(z,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingServer:r,setServerType:c}=Kr();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(Ds,{modal:!1,children:[e.jsx(Es,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Dt,{className:"size-4"})})}),e.jsxs(gs,{align:"end",className:"w-40",children:[e.jsx(ye,{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(Ti,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(ye,{className:"cursor-pointer",onClick:async()=>{Wc({id:a.original.id}).then(({data:i})=>{i&&(A.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Pi,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(ut,{}),e.jsx(ye,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:i=>i.preventDefault(),children:e.jsx(qe,{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()=>{Gc({id:a.original.id}).then(({data:i})=>{i&&(A.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(ts,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function ex(){const[s,n]=u.useState({}),[a,l]=u.useState({"drag-handle":!1}),[r,c]=u.useState([]),[i,m]=u.useState({pageSize:500,pageIndex:0}),[x,o]=u.useState([]),[d,p]=u.useState(!1),[k,I]=u.useState({}),[f,j]=u.useState([]),{refetch:C}=ne({queryKey:["nodeList"],queryFn:async()=>{const{data:L}=await Dr();return j(L),L}}),g=u.useMemo(()=>{const L=new Set;return f.forEach(G=>{G.groups&&G.groups.forEach(O=>L.add(O.name))}),Array.from(L).sort()},[f]);u.useEffect(()=>{l({"drag-handle":d,show:!d,host:!d,online:!d,rate:!d,groups:!d,type:!1,actions:!d}),I({name:d?2e3:200}),m({pageSize:d?99999:500,pageIndex:0})},[d]);const w=(L,G)=>{d&&(L.dataTransfer.setData("text/plain",G.toString()),L.currentTarget.classList.add("opacity-50"))},T=(L,G)=>{if(!d)return;L.preventDefault(),L.currentTarget.classList.remove("bg-muted");const O=parseInt(L.dataTransfer.getData("text/plain"));if(O===G)return;const X=[...f],[Je]=X.splice(O,1);X.splice(G,0,Je),j(X)},S=async()=>{if(!d){p(!0);return}const L=f?.map((G,O)=>({id:G.id,order:O+1}));Qc(L).then(()=>{A.success("排序保存成功"),p(!1),C()}).finally(()=>{p(!1)})},P=Ye({data:f||[],columns:Xu(C),state:{sorting:x,columnVisibility:a,rowSelection:s,columnFilters:r,columnSizing:k,pagination:i},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:o,onColumnFiltersChange:c,onColumnVisibilityChange:l,onColumnSizingChange:I,onPaginationChange:m,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Mu,{refetch:C,children:e.jsx("div",{className:"space-y-4",children:e.jsx(os,{table:P,toolbar:L=>e.jsx(Zu,{table:L,refetch:C,saveOrder:S,isSortMode:d,groups:g}),draggable:d,onDragStart:w,onDragEnd:L=>L.currentTarget.classList.remove("opacity-50"),onDragOver:L=>{L.preventDefault(),L.currentTarget.classList.add("bg-muted")},onDragLeave:L=>L.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!d})})})}function sx(){const{t:s}=F("server");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(ex,{})})]})]})}const tx=Object.freeze(Object.defineProperty({__proto__:null,default:sx},Symbol.toStringTag,{value:"Module"}));function ax({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=F("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(Kt,{refetch:n}),e.jsx(D,{placeholder:l("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:r=>s.getColumn("name")?.setFilterValue(r.target.value),className:N("h-8 w-[150px] lg:w-[250px]",a&&"border-primary/50 ring-primary/20")}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]})})}const nx=s=>{const{t:n}=F("group");return[{accessorKey:"id",header:({column:a})=>e.jsx(z,{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(z,{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(z,{column:a,title:n("columns.usersCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(ht,{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(z,{column:a,title:n("columns.serverCount")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(tr,{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(z,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Kt,{defaultValues:a.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(As,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Zc({id:a.original.id}).then(({data:l})=>{l&&(A.success(n("messages.updateSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ts,{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 rx(){const[s,n]=u.useState({}),[a,l]=u.useState({}),[r,c]=u.useState([]),[i,m]=u.useState([]),{data:x,refetch:o,isLoading:d}=ne({queryKey:["serverGroupList"],queryFn:async()=>{const{data:k}=await qt();return k}}),p=Ye({data:x||[],columns:nx(o),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:m,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(os,{table:p,toolbar:k=>e.jsx(ax,{table:k,refetch:o}),isLoading:d})}function lx(){const{t:s}=F("group");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(rx,{})})]})]})}const ox=Object.freeze(Object.defineProperty({__proto__:null,default:lx},Symbol.toStringTag,{value:"Module"})),ix=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 Ur({refetch:s,dialogTrigger:n,defaultValues:a={remarks:"",match:[],action:"block",action_value:""},type:l="add"}){const{t:r}=F("route"),c=he({resolver:ge(ix(r)),defaultValues:a,mode:"onChange"}),[i,m]=u.useState(!1);return e.jsxs(ve,{open:i,onOpenChange:m,children:[e.jsx(He,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Pe,{icon:"ion:add"})," ",e.jsx("div",{children:r("form.add")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:r(l==="edit"?"form.edit":"form.create")}),e.jsx(Ee,{})]}),e.jsxs(je,{...c,children:[e.jsx(b,{control:c.control,name:"remarks",render:({field:x})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("form.remarksPlaceholder"),...x})})}),e.jsx(E,{})]})}),e.jsx(b,{control:c.control,name:"match",render:({field:x})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(_s,{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(b,{control:c.control,name:"action",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsxs(W,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("form.actionPlaceholder")})}),e.jsxs(B,{children:[e.jsx(A,{value:"block",children:r("actions.block")}),e.jsx(A,{value:"dns",children:r("actions.dns")})]})]})})}),e.jsx(E,{})]})}),c.watch("action")==="dns"&&e.jsx(b,{control:c.control,name:"action_value",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("form.dnsPlaceholder"),...x})})})]})}),e.jsxs(qe,{children:[e.jsx(pt,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r("form.cancel")})}),e.jsx(V,{type:"submit",onClick:()=>{Xc(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 cx({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=F("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(Ur,{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(He,{className:"ml-2 h-4 w-4"})]})]})})}function dx({columns:s,data:n,refetch:a}){const[l,r]=m.useState({}),[c,i]=m.useState({}),[u,x]=m.useState([]),[o,d]=m.useState([]),p=Be({data:n,columns:s,state:{sorting:o,columnVisibility:c,rowSelection:l,columnFilters:u},enableRowSelection:!0,onRowSelectionChange:r,onSortingChange:d,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(as,{table:p,toolbar:T=>e.jsx(cx,{table:T,refetch:a})})}const mx=s=>{const{t:n}=F("route"),a={block:{icon:Di,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:Ei,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(H,{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(H,{variant:a[r]?.variant||"default",className:N("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(Ur,{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(zs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(We,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{ed({id:l.original.id}).then(({data:r})=>{r&&($.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(os,{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 ux(){const{t:s}=F("route"),[n,a]=m.useState([]);function l(){Er().then(({data:r})=>{a(r)})}return m.useEffect(()=>{l()},[]),e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(dx,{data:n,columns:mx(l),refetch:l})})]})]})}const xx=Object.freeze(Object.defineProperty({__proto__:null,default:ux},Symbol.toStringTag,{value:"Module"})),Br=m.createContext(void 0);function hx({children:s,refreshData:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(null);return e.jsx(Br.Provider,{value:{isOpen:a,setIsOpen:l,editingPlan:r,setEditingPlan:c,refreshData:n},children:s})}function Ra(){const s=m.useContext(Br);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function fx({table:s,saveOrder:n,isSortMode:a}){const{setIsOpen:l}=Ra(),{t:r}=F("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(ke,{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 an={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"}},px=s=>{const{t:n}=F("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(Ot,{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(H,{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(K,{defaultChecked:a.getValue("show"),onCheckedChange:l=>{Bt({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(K,{defaultChecked:a.getValue("sell"),onCheckedChange:l=>{Bt({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(K,{defaultChecked:a.getValue("renew"),onCheckedChange:l=>{Bt({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(xt,{}),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(H,{variant:"secondary",className:N("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(H,{variant:"secondary",className:N("px-2 py-0.5 font-medium transition-colors text-nowrap",an[i].color,an[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}=Ra();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(zs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(We,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{jd({id:a.original.id}).then(({data:c})=>{c&&($.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(os,{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")})]})})]})}}]},gx=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()}),Gr=m.forwardRef(({className:s,...n},a)=>e.jsx(ar,{ref:a,className:N("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(Ri,{className:N("flex items-center justify-center text-current"),children:e.jsx(Ms,{className:"h-4 w-4"})})}));Gr.displayName=ar.displayName;const Nt={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},_t={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}},jx=[{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 vx(){const{isOpen:s,setIsOpen:n,editingPlan:a,setEditingPlan:l,refreshData:r}=Ra(),[c,i]=m.useState(!1),{t:u}=F("subscribe"),x=ue({resolver:he(gx),defaultValues:{...Nt,...a||{}},mode:"onChange"});m.useEffect(()=>{a?x.reset({...Nt,...a}):x.reset(Nt)},[a,x]);const o=new pa({html:!0}),[d,p]=m.useState();async function T(){$t().then(({data:g})=>{p(g)})}m.useEffect(()=>{s&&T()},[s]);const R=g=>{if(isNaN(g))return;const S=Object.entries(_t).reduce((j,[C,P])=>{const w=g*P.months*P.discount;return{...j,[C]:w.toFixed(2)}},{});x.setValue("prices",S,{shouldDirty:!0})},f=()=>{n(!1),l(null),x.reset(Nt)};return e.jsx(je,{open:s,onOpenChange:f,children:e.jsxs(pe,{children:[e.jsxs(ye,{children:[e.jsx(ve,{children:u(a?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ee,{})]}),e.jsxs(fe,{...x,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:x.control,name:"name",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:u("plan.form.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:u("plan.form.name.placeholder"),...g})}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"group_id",render:({field:g})=>e.jsxs(v,{children:[e.jsxs(y,{className:"flex items-center justify-between",children:[u("plan.form.group.label"),e.jsx(Ht,{dialogTrigger:e.jsx(V,{variant:"link",children:u("plan.form.group.add")}),refetch:T})]}),e.jsxs(W,{value:g.value?.toString()??"",onValueChange:S=>g.onChange(S?Number(S):null),children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:u("plan.form.group.placeholder")})})}),e.jsx(B,{children:d?.map(S=>e.jsx(A,{value:S.id.toString(),children:S.name},S.id))})]}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"transfer_enable",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:u("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{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(b,{control:x.control,name:"speed_limit",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:u("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{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(me,{children:e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(V,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const g=Object.keys(_t).reduce((S,j)=>({...S,[j]:""}),{});x.setValue("prices",g,{shouldDirty:!0})},children:u("plan.form.price.clear.button")})}),e.jsx(re,{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(_t).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(b,{control:x.control,name:`prices.${g}`,render:({field:j})=>e.jsxs(v,{children:[e.jsxs(y,{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(_,{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(_t).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(b,{control:x.control,name:`prices.${g}`,render:({field:j})=>e.jsx(v,{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(y,{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(_,{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(b,{control:x.control,name:"device_limit",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:u("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{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(b,{control:x.control,name:"capacity_limit",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:u("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{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(b,{control:x.control,name:"reset_traffic_method",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:u("plan.form.reset_method.label")}),e.jsxs(W,{value:g.value?.toString()??"null",onValueChange:S=>g.onChange(S=="null"?null:Number(S)),children:[e.jsx(_,{children:e.jsx(U,{children:e.jsx(Y,{placeholder:u("plan.form.reset_method.placeholder")})})}),e.jsx(B,{children:jx.map(S=>e.jsx(A,{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(b,{control:x.control,name:"content",render:({field:g})=>{const[S,j]=m.useState(!1);return e.jsxs(v,{className:"space-y-2",children:[e.jsxs(y,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u("plan.form.content.label"),e.jsx(me,{children:e.jsxs(ce,{children:[e.jsx(de,{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(re,{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(me,{children:e.jsxs(ce,{children:[e.jsx(de,{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(re,{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(_,{children:e.jsx(ga,{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(qe,{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(b,{control:x.control,name:"force_update",render:({field:g})=>e.jsxs(v,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Gr,{checked:g.value,onCheckedChange:g.onChange})}),e.jsx("div",{className:"",children:e.jsx(y,{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 gd(g)).data&&($.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 bx(){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}=te({queryKey:["planList"],queryFn:async()=>{const{data:P}=await $s();return R(P),P}});m.useEffect(()=>{l({"drag-handle":x}),p({pageSize:x?99999:10,pageIndex:0})},[x]);const g=(P,w)=>{x&&(P.dataTransfer.setData("text/plain",w.toString()),P.currentTarget.classList.add("opacity-50"))},S=(P,w)=>{if(!x)return;P.preventDefault(),P.currentTarget.classList.remove("bg-muted");const k=parseInt(P.dataTransfer.getData("text/plain"));if(k===w)return;const L=[...T],[J]=L.splice(k,1);L.splice(w,0,J),R(L)},j=async()=>{if(!x){o(!0);return}const P=T?.map(w=>w.id);vd(P).then(()=>{$.success("排序保存成功"),o(!1),f()}).finally(()=>{o(!1)})},C=Be({data:T||[],columns:px(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}},pageCount:x?1:void 0});return e.jsx(hx,{refreshData:f,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(as,{table:C,toolbar:P=>e.jsx(fx,{table:P,refetch:f,saveOrder:j,isSortMode:x}),draggable:x,onDragStart:g,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:S,showPagination:!x}),e.jsx(vx,{})]})})}function yx(){const{t:s}=F("subscribe");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(bx,{})})]})]})}const Nx=Object.freeze(Object.defineProperty({__proto__:null,default:yx},Symbol.toStringTag,{value:"Module"})),Bs=[{value:Z.PENDING,label:nt[Z.PENDING],icon:Vi,color:rt[Z.PENDING]},{value:Z.PROCESSING,label:nt[Z.PROCESSING],icon:nr,color:rt[Z.PROCESSING]},{value:Z.COMPLETED,label:nt[Z.COMPLETED],icon:na,color:rt[Z.COMPLETED]},{value:Z.CANCELLED,label:nt[Z.CANCELLED],icon:rr,color:rt[Z.CANCELLED]},{value:Z.DISCOUNTED,label:nt[Z.DISCOUNTED],icon:na,color:rt[Z.DISCOUNTED]}],ot=[{value:ie.PENDING,label:jt[ie.PENDING],icon:Ii,color:vt[ie.PENDING]},{value:ie.PROCESSING,label:jt[ie.PROCESSING],icon:nr,color:vt[ie.PROCESSING]},{value:ie.VALID,label:jt[ie.VALID],icon:na,color:vt[ie.VALID]},{value:ie.INVALID,label:jt[ie.INVALID],icon:rr,color:vt[ie.INVALID]}];function wt({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(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),n,c?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{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(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[c.size," selected"]}):a.filter(i=>c.has(i.value)).map(i=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(ts,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ps,{children:[e.jsx(Ls,{placeholder:n}),e.jsxs(Ds,{children:[e.jsx(As,{children:"No results found."}),e.jsx(Ae,{children:a.map(i=>{const u=c.has(i.value);return e.jsxs(Te,{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:N("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(Ms,{className:N("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(Xs,{}),e.jsx(Ae,{children:e.jsx(Te,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const _x=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),wx={email:"",plan_id:0,total_amount:0,period:""};function Wr({refetch:s,trigger:n,defaultValues:a}){const{t:l}=F("order"),[r,c]=m.useState(!1),i=ue({resolver:he(_x),defaultValues:{...wx,...a},mode:"onChange"}),[u,x]=m.useState([]);return m.useEffect(()=>{r&&$s().then(({data:o})=>{x(o)})},[r]),e.jsxs(je,{open:r,onOpenChange:c,children:[e.jsx($e,{asChild:!0,children:n||e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(ke,{icon:"ion:add"}),e.jsx("div",{children:l("dialog.addOrder")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:l("dialog.assignOrder")}),e.jsx(Ee,{})]}),e.jsxs(fe,{...i,children:[e.jsx(b,{control:i.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.userEmail")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dialog.placeholders.email"),...o})})]})}),e.jsx(b,{control:i.control,name:"plan_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.subscriptionPlan")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:d.id.toString(),children:d.name},d.id))})]})})]})}),e.jsx(b,{control:i.control,name:"period",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.orderPeriod")}),e.jsx(_,{children:e.jsxs(W,{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(Wd).map(d=>e.jsx(A,{value:d,children:l(`period.${d}`)},d))})]})})]})}),e.jsx(b,{control:i.control,name:"total_amount",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.paymentAmount")}),e.jsx(_,{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(qe,{children:[e.jsx(V,{variant:"outline",onClick:()=>c(!1),children:l("dialog.actions.cancel")}),e.jsx(V,{type:"submit",onClick:()=>{i.handleSubmit(o=>{wd(o).then(({data:d})=>{d&&(s&&s(),i.reset(),c(!1),$.success(l("dialog.messages.addSuccess")))})})()},children:l("dialog.actions.confirm")})]})]})]})]})}function Cx({table:s,refetch:n}){const{t:a}=F("order"),l=s.getState().columnFilters.length>0,r=Object.values(Ze).filter(x=>typeof x=="number").map(x=>({label:a(`type.${Ze[x]}`),value:x,color:x===Ze.NEW?"green-500":x===Ze.RENEWAL?"blue-500":x===Ze.UPGRADE?"purple-500":"orange-500"})),c=Object.values(we).map(x=>({label:a(`period.${x}`),value:x,color:x===we.MONTH_PRICE?"slate-500":x===we.QUARTER_PRICE?"cyan-500":x===we.HALF_YEAR_PRICE?"indigo-500":x===we.YEAR_PRICE?"violet-500":x===we.TWO_YEAR_PRICE?"fuchsia-500":x===we.THREE_YEAR_PRICE?"pink-500":x===we.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?Bs[0].icon:x===Z.PROCESSING?Bs[1].icon:x===Z.COMPLETED?Bs[2].icon:x===Z.CANCELLED?Bs[3].icon:Bs[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(ie).filter(x=>typeof x=="number").map(x=>({label:a(`commission.${ie[x]}`),value:x,icon:x===ie.PENDING?ot[0].icon:x===ie.PROCESSING?ot[1].icon:x===ie.VALID?ot[2].icon:ot[3].icon,color:x===ie.PENDING?"yellow-500":x===ie.PROCESSING?"blue-500":x===ie.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wr,{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(wt,{column:s.getColumn("type"),title:a("table.columns.type"),options:r}),s.getColumn("period")&&e.jsx(wt,{column:s.getColumn("period"),title:a("table.columns.period"),options:c}),s.getColumn("status")&&e.jsx(wt,{column:s.getColumn("status"),title:a("table.columns.status"),options:i}),s.getColumn("commission_status")&&e.jsx(wt,{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(He,{className:"ml-2 h-4 w-4"})]})]})}function Ye({label:s,value:n,className:a,valueClassName:l}){return e.jsxs("div",{className:N("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:N("text-sm",l),children:n||"-"})]})}function Sx({status:s}){const{t:n}=F("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(H,{variant:"secondary",className:N("font-medium",a[s]),children:n(`status.${Z[s]}`)})}function kx({id:s,trigger:n}){const[a,l]=m.useState(!1),[r,c]=m.useState(),{t:i}=F("order");return m.useEffect(()=>{(async()=>{if(a){const{data:x}=await yd({id:s});c(x)}})()},[a,s]),e.jsxs(je,{onOpenChange:l,open:a,children:[e.jsx($e,{asChild:!0,children:n}),e.jsxs(pe,{className:"max-w-xl",children:[e.jsxs(ye,{className:"space-y-2",children:[e.jsx(ve,{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(Sx,{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(Ye,{label:i("dialog.fields.userEmail"),value:r?.user?.email?e.jsxs(Os,{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(lr,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(Ye,{label:i("dialog.fields.orderPeriod"),value:r&&i(`period.${r.period}`)}),e.jsx(Ye,{label:i("dialog.fields.subscriptionPlan"),value:r?.plan?.name,valueClassName:"font-medium"}),e.jsx(Ye,{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(Ye,{label:i("dialog.fields.paymentAmount"),value:Rs(r?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Ne,{className:"my-2"}),e.jsx(Ye,{label:i("dialog.fields.balancePayment"),value:Rs(r?.balance_amount||0)}),e.jsx(Ye,{label:i("dialog.fields.discountAmount"),value:Rs(r?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(Ye,{label:i("dialog.fields.refundAmount"),value:Rs(r?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(Ye,{label:i("dialog.fields.deductionAmount"),value:Rs(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(Ye,{label:i("dialog.fields.createdAt"),value:xe(r?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(Ye,{label:i("dialog.fields.updatedAt"),value:xe(r?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const Tx={[Ze.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Ze.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Px={[we.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[we.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Dx=s=>Z[s],Ex=s=>ie[s],Rx=s=>Ze[s],Vx=s=>{const{t:n}=F("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(kx,{trigger:e.jsxs(G,{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(lr,{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=Tx[l];return e.jsx(H,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",r.color,r.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${Rx(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=Px[l];return e.jsx(H,{variant:"secondary",className:N("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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsx(Lr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(re,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:a})=>{const l=Bs.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.${Dx(l.value)}`)})]}),l.value===Z.PENDING&&e.jsxs(ks,{modal:!0,children:[e.jsx(Ts,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Pt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(xs,{align:"end",className:"w-[140px]",children:[e.jsx(ge,{className:"cursor-pointer",onClick:async()=>{await Nd({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 _d({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=ot.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.${Ex(c.value)}`)})]}),c.value===ie.PENDING&&l===Z.COMPLETED&&e.jsxs(ks,{modal:!0,children:[e.jsx(Ts,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Pt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(xs,{align:"end",className:"w-[120px]",children:[e.jsx(ge,{className:"cursor-pointer",onClick:async()=>{await Ya({trade_no:a.original.trade_no,commission_status:ie.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(ge,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await Ya({trade_no:a.original.trade_no,commission_status:ie.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 Ix(){const[s]=or(),[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 P=s.get(j);return P?{id:j,value:C==="number"?parseInt(P):P}:null}).filter(Boolean);S.length>0&&i(S)},[s]);const{refetch:p,data:T,isLoading:R}=te({queryKey:["orderList",o,c,u],queryFn:()=>bd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:u})}),f=Be({data:T?.data??[],columns:Vx(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),onPaginationChange:d,getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(as,{table:f,toolbar:e.jsx(Cx,{table:f,refetch:p}),showPagination:!0})}function Fx(){const{t:s}=F("order");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(Ix,{})})]})]})}const Mx=Object.freeze(Object.defineProperty({__proto__:null,default:Fx},Symbol.toStringTag,{value:"Module"}));function Ox({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{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(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):a.filter(c=>r.has(c.value)).map(c=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:c.label},c.value))})]})]})}),e.jsx(ts,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ps,{children:[e.jsx(Ls,{placeholder:n}),e.jsxs(Ds,{children:[e.jsx(As,{children:"No results found."}),e.jsx(Ae,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(Te,{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:N("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(Ms,{className:N("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(Xs,{}),e.jsx(Ae,{children:e.jsx(Te,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const zx=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.coerce.number()).default([]).nullable(),limit_period:h.array(h.nativeEnum(ct)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),nn={name:"",code:"",type:ze.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 Yr({defaultValues:s,refetch:n,type:a="create",dialogTrigger:l=null,open:r,onOpenChange:c}){const{t:i}=F("coupon"),[u,x]=m.useState(!1),o=r??u,d=c??x,[p,T]=m.useState([]),R=ue({resolver:he(zx),defaultValues:s||nn});m.useEffect(()=>{s&&R.reset(s)},[s,R]),m.useEffect(()=>{$s().then(({data:j})=>T(j))},[]);const f=j=>{if(!j)return;const C=(P,w)=>{const k=new Date(w*1e3);return P.setHours(k.getHours(),k.getMinutes(),k.getSeconds()),Math.floor(P.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=>{Sd(j).then(()=>{d(!1),a==="create"&&R.reset(nn),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:P=>{const w=new Date(P.target.value);R.setValue(j,Math.floor(w.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(je,{open:o,onOpenChange:d,children:[l&&e.jsx($e,{asChild:!0,children:l}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(ye,{children:e.jsx(ve,{children:i(a==="create"?"form.add":"form.edit")})}),e.jsx(fe,{...R,children:e.jsxs("form",{onSubmit:R.handleSubmit(g),className:"space-y-4",children:[e.jsx(b,{control:R.control,name:"name",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.name.label")}),e.jsx(D,{placeholder:i("form.name.placeholder"),...j}),e.jsx(E,{})]})}),e.jsx(b,{control:R.control,name:"code",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{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(v,{children:[e.jsx(y,{children:i("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(b,{control:R.control,name:"type",render:({field:j})=>e.jsxs(W,{value:j.value.toString(),onValueChange:C=>{const P=j.value,w=parseInt(C);j.onChange(w);const k=R.getValues("value");k&&(P===ze.AMOUNT&&w===ze.PERCENT?R.setValue("value",k/100):P===ze.PERCENT&&w===ze.AMOUNT&&R.setValue("value",k*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(Yd).map(([C,P])=>e.jsx(A,{value:C,children:i(`table.toolbar.types.${C}`)},C))})]})}),e.jsx(b,{control:R.control,name:"value",render:({field:j})=>{const C=j.value===""?"":R.watch("type")===ze.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:P=>{const w=P.target.value;if(w===""){j.onChange("");return}const k=parseFloat(w);isNaN(k)||j.onChange(R.watch("type")===ze.AMOUNT?Math.round(k*100):k)},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")==ze.AMOUNT?"¥":"%"})})]})]}),e.jsxs(v,{children:[e.jsx(y,{children:i("form.validity.label")}),e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(V,{variant:"outline",className:N("w-full justify-start text-left font-normal",!R.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(ht,{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(ts,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(qs,{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(b,{control:R.control,name:"limit_use",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{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(b,{control:R.control,name:"limit_use_with_user",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{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(b,{control:R.control,name:"limit_period",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.limitPeriod.label")}),e.jsx(ut,{options:Object.entries(ct).filter(([C])=>isNaN(Number(C))).map(([C,P])=>({label:i(`coupon:period.${P}`),value:C})),onChange:C=>{if(C.length===0){j.onChange([]);return}const P=C.map(w=>ct[w.value]);j.onChange(P)},value:(j.value||[]).map(C=>({label:i(`coupon:period.${C}`),value:Object.entries(ct).find(([P,w])=>w===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(b,{control:R.control,name:"limit_plan_ids",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.limitPlan.label")}),e.jsx(ut,{options:p?.map(C=>({label:C.name,value:C.id.toString()}))||[],onChange:C=>j.onChange(C.map(P=>Number(P.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(b,{control:R.control,name:"generate_count",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{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(qe,{children:e.jsx(V,{type:"submit",disabled:R.formState.isSubmitting,children:R.formState.isSubmitting?i("form.submit.saving"):i("form.submit.save")})})]})})]})]})}function Lx({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=F("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Yr,{refetch:n,dialogTrigger:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(ke,{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(Ox,{column:s.getColumn("type"),title:l("table.toolbar.type"),options:[{value:ze.AMOUNT,label:l(`table.toolbar.types.${ze.AMOUNT}`)},{value:ze.PERCENTAGE,label:l(`table.toolbar.types.${ze.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(He,{className:"ml-2 h-4 w-4"})]})]})}const Qr=m.createContext(void 0);function Ax({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(Qr.Provider,{value:{isOpen:a,currentCoupon:r,openEdit:i,closeEdit:u},children:[s,r&&e.jsx(Yr,{defaultValues:r,refetch:n,type:"edit",open:a,onOpenChange:l})]})}function $x(){const s=m.useContext(Qr);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const qx=s=>{const{t:n}=F("coupon");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("table.columns.id")}),cell:({row:a})=>e.jsx(H,{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(K,{defaultChecked:a.original.show,onCheckedChange:l=>{Td({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(H,{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(H,{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(H,{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(H,{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}=$x();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(zs,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(We,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{kd({id:a.original.id}).then(({data:r})=>{r&&($.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(os,{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 Hx(){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}=te({queryKey:["couponList",x,r,i],queryFn:()=>Cd({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),T=Be({data:p?.data??[],columns:qx(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ax,{refetch:d,children:e.jsx("div",{className:"space-y-4",children:e.jsx(as,{table:T,toolbar:e.jsx(Lx,{table:T,refetch:d})})})})}function Kx(){const{t:s}=F("coupon");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(Hx,{})})]})]})}const Ux=Object.freeze(Object.defineProperty({__proto__:null,default:Kx},Symbol.toStringTag,{value:"Module"})),Bx=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"]}),Gx={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function Wx({refetch:s}){const{t:n}=F("user"),[a,l]=m.useState(!1),r=ue({resolver:he(Bx),defaultValues:Gx,mode:"onChange"}),[c,i]=m.useState([]);return m.useEffect(()=>{a&&$s().then(({data:u})=>{u&&i(u)})},[a]),e.jsxs(je,{open:a,onOpenChange:l,children:[e.jsx($e,{asChild:!0,children:e.jsxs(G,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(ke,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(ye,{children:[e.jsx(ve,{children:n("generate.title")}),e.jsx(Ee,{})]}),e.jsxs(fe,{...r,children:[e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!r.watch("generate_count")&&e.jsx(b,{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(b,{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(b,{control:r.control,name:"password",render:({field:u})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...u}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"expired_at",render:({field:u})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:n("generate.form.expire_time")}),e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsx(_,{children:e.jsxs(G,{variant:"outline",className:N("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(ht,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(ts,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Mi,{asChild:!0,children:e.jsx(G,{variant:"outline",className:"w-full",onClick:()=>{u.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(qs,{mode:"single",selected:u.value?new Date(u.value*1e3):void 0,onSelect:x=>{x&&u.onChange(x?.getTime()/1e3)}})})]})]})]})}),e.jsx(b,{control:r.control,name:"plan_id",render:({field:u})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.subscription")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:"null",children:n("generate.form.subscription_none")}),c.map(x=>e.jsx(A,{value:x.id.toString(),children:x.name},x.id))]})]})})]})}),!r.watch("email_prefix")&&e.jsx(b,{control:r.control,name:"generate_count",render:({field:u})=>e.jsxs(v,{children:[e.jsx(y,{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(qe,{children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:n("generate.form.cancel")}),e.jsx(G,{onClick:()=>r.handleSubmit(u=>{Rd(u).then(({data:x})=>{x&&($.success(n("generate.form.success")),r.reset(),s(),l(!1))})})(),children:n("generate.form.submit")})]})]})]})}const Jr=cn,Zr=dn,Yx=mn,Xr=m.forwardRef(({className:s,...n},a)=>e.jsx(Vt,{className:N("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}));Xr.displayName=Vt.displayName;const Qx=Fs("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"}}),Va=m.forwardRef(({side:s="right",className:n,children:a,...l},r)=>e.jsxs(Yx,{children:[e.jsx(Xr,{}),e.jsxs(It,{ref:r,className:N(Qx({side:s}),n),...l,children:[e.jsxs(ma,{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(He,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),a]})]}));Va.displayName=It.displayName;const Ia=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ia.displayName="SheetHeader";const el=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});el.displayName="SheetFooter";const Fa=m.forwardRef(({className:s,...n},a)=>e.jsx(Ft,{ref:a,className:N("text-lg font-semibold text-foreground",s),...n}));Fa.displayName=Ft.displayName;const Ma=m.forwardRef(({className:s,...n},a)=>e.jsx(Mt,{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ma.displayName=Mt.displayName;function Jx({table:s,refetch:n,permissionGroups:a=[],subscriptionPlans:l=[]}){const{t:r}=F("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((P,w)=>w!==C))},g=(C,P,w)=>{const k=[...i];if(k[C]={...k[C],[P]:w},P==="field"){const L=d.find(J=>J.value===w);L&&(k[C].operator=L.operators[0].value,k[C].value=L.type==="boolean"?!1:"")}u(k)},S=(C,P)=>{const w=d.find(k=>k.value===C.field);if(!w)return null;switch(w.type){case"text":return e.jsx(D,{placeholder:r("filter.sheet.value"),value:C.value,onChange:k=>g(P,"value",k.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:w.unit}),value:w.unit==="GB"?T(C.value||0):C.value,onChange:k=>{const L=Number(k.target.value);g(P,"value",w.unit==="GB"?p(L):L)}}),w.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:w.unit})]});case"date":return e.jsx(qs,{mode:"single",selected:C.value,onSelect:k=>g(P,"value",k),className:"rounded-md border"});case"select":return e.jsxs(W,{value:C.value,onValueChange:k=>g(P,"value",k),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("filter.sheet.value")})}),e.jsx(B,{children:w.useOptions?l.map(k=>e.jsx(A,{value:k.value.toString(),children:k.label},k.value)):w.options?.map(k=>e.jsx(A,{value:k.value.toString(),children:k.label},k.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(K,{checked:C.value,onCheckedChange:k=>g(P,"value",k)}),e.jsx(Dt,{children:C.value?r("filter.boolean.true"):r("filter.boolean.false")})]});default:return null}},j=()=>{const C=i.filter(P=>P.field&&P.operator&&P.value!=="").map(P=>{const w=d.find(L=>L.value===P.field);let k=P.value;return P.operator==="contains"?{id:P.field,value:k}:(w?.type==="date"&&k instanceof Date&&(k=Math.floor(k.getTime()/1e3)),w?.type==="boolean"&&(k=k?1:0),{id:P.field,value:`${P.operator}:${k}`})});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(Wx,{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(Jr,{open:x,onOpenChange:o,children:[e.jsx(Zr,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Oi,{className:"mr-2 h-4 w-4"}),r("filter.advanced"),i.length>0&&e.jsx(H,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:i.length})]})}),e.jsxs(Va,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(Ia,{children:[e.jsx(Fa,{children:r("filter.sheet.title")}),e.jsx(Ma,{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(Js,{className:"h-[calc(100vh-280px)] pr-4",children:e.jsx("div",{className:"space-y-4",children:i.map((C,P)=>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(Dt,{children:r("filter.sheet.condition",{number:P+1})}),e.jsx(V,{variant:"ghost",size:"sm",onClick:()=>f(P),children:e.jsx(He,{className:"h-4 w-4"})})]}),e.jsxs(W,{value:C.field,onValueChange:w=>g(P,"field",w),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("filter.sheet.field")})}),e.jsx(B,{children:d.map(w=>e.jsx(A,{value:w.value,children:w.label},w.value))})]}),C.field&&e.jsxs(W,{value:C.operator,onValueChange:w=>g(P,"operator",w),children:[e.jsx(U,{children:e.jsx(Y,{placeholder:r("filter.sheet.operator")})}),e.jsx(B,{children:d.find(w=>w.value===C.field)?.operators.map(w=>e.jsx(A,{value:w.value,children:w.label},w.value))})]}),C.field&&C.operator&&S(C,P)]},P))})}),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(He,{className:"ml-2 h-4 w-4"})]})]})})}const Zx=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()}),sl=m.createContext(void 0);function Xx({children:s,defaultValues:n,open:a,onOpenChange:l}){const[r,c]=m.useState(!1),[i,u]=m.useState(!1),[x,o]=m.useState([]),d=ue({resolver:he(Zx),defaultValues:n,mode:"onChange"});m.useEffect(()=>{a!==void 0&&c(a)},[a]);const p=T=>{c(T),l?.(T)};return e.jsx(sl.Provider,{value:{form:d,formOpen:r,setFormOpen:p,datePickerOpen:i,setDatePickerOpen:u,planList:x,setPlanList:o},children:s})}function eh(){const s=m.useContext(sl);if(!s)throw new Error("useUserForm must be used within a UserFormProvider");return s}function sh({refetch:s}){const{t:n}=F("user"),{form:a,formOpen:l,setFormOpen:r,datePickerOpen:c,setDatePickerOpen:i,planList:u,setPlanList:x}=eh();return m.useEffect(()=>{l&&$s().then(({data:o})=>{x(o)})},[l,x]),e.jsxs(fe,{...a,children:[e.jsx(b,{control:a.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.email")}),e.jsx(_,{children:e.jsx(D,{...o,placeholder:n("edit.form.email_placeholder")})}),e.jsx(E,{...o})]})}),e.jsx(b,{control:a.control,name:"invite_user_email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.inviter_email")}),e.jsx(_,{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(b,{control:a.control,name:"password",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.password")}),e.jsx(_,{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(b,{control:a.control,name:"balance",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.balance")}),e.jsx(_,{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(b,{control:a.control,name:"commission_balance",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.commission_balance")}),e.jsx(_,{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(b,{control:a.control,name:"u",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.upload")}),e.jsx(_,{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(b,{control:a.control,name:"d",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.download")}),e.jsx(_,{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(b,{control:a.control,name:"transfer_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.total_traffic")}),e.jsx(_,{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(b,{control:a.control,name:"expired_at",render:({field:o})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:n("edit.form.expire_time")}),e.jsxs(is,{open:c,onOpenChange:i,children:[e.jsx(cs,{asChild:!0,children:e.jsx(_,{children:e.jsxs(V,{type:"button",variant:"outline",className:N("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(ht,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(ts,{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(qs,{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(b,{control:a.control,name:"plan_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.subscription")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:"null",children:n("edit.form.subscription_none")}),u.map(d=>e.jsx(A,{value:d.id.toString(),children:d.name},d.id))]})]})})]})}),e.jsx(b,{control:a.control,name:"banned",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.account_status")}),e.jsx(_,{children:e.jsxs(W,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(U,{children:e.jsx(Y,{})}),e.jsxs(B,{children:[e.jsx(A,{value:"1",children:n("columns.status_text.banned")}),e.jsx(A,{value:"0",children:n("columns.status_text.normal")})]})]})})]})}),e.jsx(b,{control:a.control,name:"commission_type",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.commission_type")}),e.jsx(_,{children:e.jsxs(W,{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(A,{value:"0",children:n("edit.form.commission_type_system")}),e.jsx(A,{value:"1",children:n("edit.form.commission_type_cycle")}),e.jsx(A,{value:"2",children:n("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(b,{control:a.control,name:"commission_rate",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.commission_rate")}),e.jsx(_,{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(b,{control:a.control,name:"discount",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.discount")}),e.jsx(_,{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(b,{control:a.control,name:"speed_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.speed_limit")}),e.jsx(_,{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(b,{control:a.control,name:"device_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.device_limit")}),e.jsx(_,{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(b,{control:a.control,name:"is_admin",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(K,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(b,{control:a.control,name:"is_staff",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(K,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(b,{control:a.control,name:"remarks",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.remarks")}),e.jsx(_,{children:e.jsx(vs,{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(el,{children:[e.jsx(V,{variant:"outline",onClick:()=>r(!1),children:n("edit.form.cancel")}),e.jsx(V,{type:"submit",onClick:()=>{a.handleSubmit(o=>{Dd(o).then(({data:d})=>{d&&($.success(n("edit.form.success")),r(!1),s())})})()},children:n("edit.form.submit")})]})]})}function tl({refetch:s,defaultValues:n,dialogTrigger:a=e.jsxs(V,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),t("edit.button")]})}){const{t:l}=F("user"),[r,c]=m.useState(!1);return e.jsx(Xx,{defaultValues:n,open:r,onOpenChange:c,children:e.jsxs(Jr,{open:r,onOpenChange:c,children:[e.jsx(Zr,{asChild:!0,children:a}),e.jsxs(Va,{className:"max-w-[90%] space-y-4",children:[e.jsxs(Ia,{children:[e.jsx(Fa,{children:l("edit.title")}),e.jsx(Ma,{})]}),e.jsx(sh,{refetch:s})]})]})})}const al=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"})}),nl=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"})}),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:"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"})}),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:"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"})}),Zt=[{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:fc(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(al,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:rs(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(nl,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:rs(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(H,{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:rs(n)})}}];function rl({user_id:s,dialogTrigger:n}){const{t:a}=F(["traffic"]),[l,r]=m.useState(!1),[c,i]=m.useState({pageIndex:0,pageSize:20}),{data:u,isLoading:x}=te({queryKey:["userStats",s,c,l],queryFn:()=>l?Vd({user_id:s,pageSize:c.pageSize,page:c.pageIndex+1}):null}),o=Be({data:u?.data??[],columns:Zt,pageCount:Math.ceil((u?.total??0)/c.pageSize),state:{pagination:c},manualPagination:!0,getCoreRowModel:Ge(),onPaginationChange:i});return e.jsxs(je,{open:l,onOpenChange:r,children:[e.jsx($e,{asChild:!0,children:n}),e.jsxs(pe,{className:"sm:max-w-[700px]",children:[e.jsx(ye,{children:e.jsx(ve,{children:a("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(ba,{children:[e.jsx(ya,{children:o.getHeaderGroups().map(d=>e.jsx(ws,{children:d.headers.map(p=>e.jsx(_a,{className:N("h-10 px-2 text-xs",p.id==="total"&&"text-right"),children:p.isPlaceholder?null:kt(p.column.columnDef.header,p.getContext())},p.id))},d.id))}),e.jsx(Na,{children:x?Array.from({length:c.pageSize}).map((d,p)=>e.jsx(ws,{children:Array.from({length:Zt.length}).map((T,R)=>e.jsx(Ws,{className:"p-2",children:e.jsx(ae,{className:"h-6 w-full"})},R))},p)):o.getRowModel().rows?.length?o.getRowModel().rows.map(d=>e.jsx(ws,{"data-state":d.getIsSelected()&&"selected",className:"h-10",children:d.getVisibleCells().map(p=>e.jsx(Ws,{className:"px-2",children:kt(p.column.columnDef.cell,p.getContext())},p.id))},d.id)):e.jsx(ws,{children:e.jsx(Ws,{colSpan:Zt.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(W,{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(A,{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(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||x,children:e.jsx(th,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||x,children:e.jsx(ah,{className:"h-4 w-4"})})]})]})]})]})]})]})}function nh({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:u}){return e.jsxs(Mr,{children:[e.jsx(Or,{asChild:!0,children:n}),e.jsxs(wa,{className:N("sm:max-w-[425px]",u),children:[e.jsxs(Ca,{children:[e.jsx(ka,{children:a}),e.jsx(Ta,{children:l})]}),e.jsxs(Sa,{children:[e.jsx(Da,{asChild:!0,children:e.jsx(V,{variant:"outline",children:r})}),e.jsx(Pa,{asChild:!0,children:e.jsx(V,{variant:i,onClick:s,children:c})})]})]})]})}const 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:"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"})}),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:"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"})}),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:"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"})}),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:"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"})}),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:"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"})}),dh=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"})}),mh=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"})}),uh=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:"M20 6h-4V5a3 3 0 0 0-3-3h-2a3 3 0 0 0-3 3v1H4a1 1 0 0 0 0 2h1v11a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8h1a1 1 0 0 0 0-2M10 5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1h-4Zm7 14a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V8h10Z"})}),xh=(s,n)=>{const{t:a}=F("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(H,{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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:N("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(re,{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(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(H,{variant:"outline",className:N("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(re,{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(H,{className:N("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(H,{variant:"outline",className:N("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=rs(l.original?.total_used),c=rs(l.original?.transfer_enable),i=l.original?.total_used/l.original?.transfer_enable*100||0;return e.jsx(me,{delayDuration:100,children:e.jsxs(ce,{children:[e.jsx(de,{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:N("h-full rounded-full transition-all",i>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(i,100)}%`}})})]})}),e.jsx(re,{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:rs(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=Gs(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=Gs(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(ks,{modal:!0,children:[e.jsx(Ts,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(G,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Pt,{className:"size-4"})})})}),e.jsxs(xs,{align:"end",className:"min-w-[40px]",children:[e.jsx(ge,{onSelect:c=>{c.preventDefault()},className:"p-0",children:e.jsx(tl,{defaultValues:{...l.original,invite_user_email:l.original.invite_user?.email},refetch:s,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(rh,{className:"mr-2"}),a("columns.actions_menu.edit")]})})}),e.jsx(ge,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(Wr,{defaultValues:{email:l.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(lh,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(ge,{onSelect:()=>{Et(l.original.subscribe_url).then(()=>{$.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(oh,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(ge,{onSelect:()=>{Ed({id:l.original.id}).then(({data:c})=>{c&&$.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(ih,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(ge,{onSelect:()=>{},className:"p-0",children:e.jsxs(Os,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=${l.original?.id}`,children:[e.jsx(ch,{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(dh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(ge,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(rl,{user_id:l.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(mh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(ge,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(nh,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:l.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:c}=await tm.destroy(l.original.id);c&&($.success(a("common:delete.success")),s())}catch{$.error(a("common:delete.failed"))}},children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5 text-destructive hover:text-destructive",children:[e.jsx(uh,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]};function hh(){const[s]=or(),[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 k=s.get("email");k&&i(L=>L.some(z=>z.id==="email")?L:[...L,{id:"email",value:k}])},[s]);const{refetch:p,data:T,isLoading:R}=te({queryKey:["userList",o,c,u],queryFn:()=>Pd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:u})}),[f,g]=m.useState([]),[S,j]=m.useState([]);m.useEffect(()=>{$t().then(({data:k})=>{g(k)}),$s().then(({data:k})=>{j(k)})},[]);const C=f.map(k=>({label:k.name,value:k.id})),P=S.map(k=>({label:k.name,value:k.id})),w=Be({data:T?.data??[],columns:xh(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),onPaginationChange:d,getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),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(as,{table:w,toolbar:e.jsx(Jx,{table:w,refetch:p,serverGroupList:f,permissionGroups:C,subscriptionPlans:P})})}function fh(){const{t:s}=F("user");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(hh,{})})})]})]})}const ph=Object.freeze(Object.defineProperty({__proto__:null,default:fh},Symbol.toStringTag,{value:"Module"}));function gh({column:s,title:n,options:a}){const l=new Set(s?.getFilterValue());return e.jsxs(is,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(zi,{className:"mr-2 h-4 w-4"}),n,l?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(H,{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(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[l.size," selected"]}):a.filter(r=>l.has(r.value)).map(r=>e.jsx(H,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:r.label},`selected-${r.value}`))})]})]})}),e.jsx(ts,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Ps,{children:[e.jsx(Ls,{placeholder:n}),e.jsxs(Ds,{children:[e.jsx(As,{children:"No results found."}),e.jsx(Ae,{children:a.map(r=>{const c=l.has(r.value);return e.jsxs(Te,{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:N("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(Li,{className:N("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(Xs,{}),e.jsx(Ae,{children:e.jsx(Te,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const jh=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 vh({table:s}){const{t:n}=F("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(va,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:a=>s.getColumn("status")?.setFilterValue(a),children:e.jsxs(qt,{className:"grid w-full grid-cols-2",children:[e.jsx(Cs,{value:"0",children:n("status.pending")}),e.jsx(Cs,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(gh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:De.LOW,icon:jh,color:"gray"},{label:n("level.medium"),value:De.MIDDLE,icon:al,color:"yellow"},{label:n("level.high"),value:De.HIGH,icon:nl,color:"red"}]})]})})}function bh(){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 yh=Fs("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"}}),ll=m.forwardRef(({className:s,variant:n,layout:a,children:l,...r},c)=>e.jsx("div",{className:N(yh({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)}));ll.displayName="ChatBubble";const Nh=Fs("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"}}),ol=m.forwardRef(({className:s,variant:n,layout:a,isLoading:l=!1,children:r,...c},i)=>e.jsx("div",{className:N(Nh({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(bh,{})}):r}));ol.displayName="ChatBubbleMessage";const _h=m.forwardRef(({variant:s,className:n,children:a,...l},r)=>e.jsx("div",{ref:r,className:N("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}));_h.displayName="ChatBubbleActionWrapper";const il=m.forwardRef(({className:s,...n},a)=>e.jsx(vs,{autoComplete:"off",ref:a,name:"message",className:N("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}));il.displayName="ChatInput";const cl=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"})}),dl=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"})}),rn=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 12l3.54-3.54a1 1 0 0 0 0-1.41a1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29a1 1 0 0 0 .71-.29a1 1 0 0 0 0-1.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.71 20.29L18 16.61A9 9 0 1 0 16.61 18l3.68 3.68a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.39M11 18a7 7 0 1 1 7-7a7 7 0 0 1-7 7"})}),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:"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"})}),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:"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 kh(){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(ae,{className:"h-8 w-3/4"}),e.jsx(ae,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(ae,{className:"h-20 w-2/3"},s))})]})}function Th(){return e.jsx("div",{className:"space-y-4 p-4",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(ae,{className:"h-5 w-4/5"}),e.jsx(ae,{className:"h-4 w-2/3"}),e.jsx(ae,{className:"h-3 w-1/2"})]},s))})}function Ph({ticket:s,isActive:n,onClick:a}){const{t:l}=F("ticket"),r=c=>{switch(c){case De.HIGH:return"bg-red-50 text-red-600 border-red-200";case De.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case De.LOW:return"bg-green-50 text-green-600 border-green-200";default:return"bg-gray-50 text-gray-600 border-gray-200"}};return e.jsxs("div",{className:N("flex cursor-pointer flex-col border-b p-4 hover:bg-accent/50",n&&"bg-accent"),onClick:a,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 max-w-[280px]",children:[e.jsx("h4",{className:"truncate font-medium flex-1",children:s.subject}),e.jsx(H,{variant:s.status===Ss.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Ss.CLOSED?l("status.closed"):l("status.processing")})]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground truncate max-w-[280px]",children:s.user?.email}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[e.jsx("time",{className:"text-muted-foreground",children:xe(s.updated_at)}),e.jsx("div",{className:N("px-2 py-0.5 rounded-full border text-xs font-medium",r(s.level)),children:l(`level.${s.level===De.LOW?"low":s.level===De.MIDDLE?"medium":"high"}`)})]})]})}function Dh({ticketId:s,dialogTrigger:n}){const{t:a}=F("ticket"),l=hs(),r=m.useRef(null),c=m.useRef(null),[i,u]=m.useState(!1),[x,o]=m.useState(""),[d,p]=m.useState(!1),[T,R]=m.useState(s),[f,g]=m.useState(""),[S,j]=m.useState(!1),{data:C,isLoading:P,refetch:w}=te({queryKey:["tickets",i],queryFn:()=>i?Gt.getList({filter:[{id:"status",value:[Ss.OPENING]}]}):Promise.resolve(null),enabled:i}),{data:k,refetch:L,isLoading:J}=te({queryKey:["ticket",T,i],queryFn:()=>i?Fd(T):Promise.resolve(null),refetchInterval:i?5e3:!1,retry:3}),z=k?.data,bs=(C?.data||[]).filter(se=>se.subject.toLowerCase().includes(f.toLowerCase())||se.user?.email.toLowerCase().includes(f.toLowerCase())),Hs=(se="smooth")=>{if(r.current){const{scrollHeight:ns,clientHeight:st}=r.current;r.current.scrollTo({top:ns-st,behavior:se})}};m.useEffect(()=>{if(!i)return;const se=requestAnimationFrame(()=>{Hs("instant"),setTimeout(()=>Hs(),1e3)});return()=>{cancelAnimationFrame(se)}},[i,z?.messages]);const et=async()=>{const se=x.trim();!se||d||(p(!0),Gt.reply({id:T,message:se}).then(()=>{o(""),L(),Hs(),setTimeout(()=>{c.current?.focus()},0)}).finally(()=>{p(!1)}))},ee=async()=>{Gt.close(T).then(()=>{$.success(a("actions.close_success")),L(),w()})},Es=()=>{z?.user&&l("/finance/order?user_id="+z.user.id)},Fe=z?.status===Ss.CLOSED;return e.jsxs(je,{open:i,onOpenChange:u,children:[e.jsx($e,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:a("actions.view_ticket")})}),e.jsxs(pe,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(ve,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 md:hidden z-50",onClick:()=>j(!S),children:e.jsx(rn,{className:N("h-4 w-4 transition-transform",!S&&"rotate-180")})}),e.jsxs("div",{className:N("absolute md:relative inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out",S?"-translate-x-full":"translate-x-0","w-80 md:w-80 md:translate-x-0"),children:[e.jsxs("div",{className:"space-y-4 border-b p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold",children:a("list.title")}),e.jsx(G,{variant:"ghost",size:"icon",className:"hidden md:flex h-8 w-8",onClick:()=>j(!S),children:e.jsx(rn,{className:N("h-4 w-4 transition-transform",!S&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(wh,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(D,{placeholder:a("list.search_placeholder"),value:f,onChange:se=>g(se.target.value),className:"pl-8"})]})]}),e.jsx(Js,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:P?e.jsx(Th,{}):bs.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground p-4",children:a(f?"list.no_search_results":"list.no_tickets")}):bs.map(se=>e.jsx(Ph,{ticket:se,isActive:se.id===T,onClick:()=>{R(se.id),window.innerWidth<768&&j(!0)}},se.id))})})]}),e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[!S&&e.jsx("div",{className:"absolute inset-0 bg-black/20 z-30 md:hidden",onClick:()=>j(!0)}),J?e.jsx(kh,{}):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:z?.subject}),e.jsx(H,{variant:Fe?"secondary":"default",children:a(Fe?"status.closed":"status.processing")}),!Fe&&e.jsx(We,{title:a("actions.close_confirm_title"),description:a("actions.close_confirm_description"),confirmText:a("actions.close_confirm_button"),variant:"destructive",onConfirm:ee,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(cl,{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(xt,{className:"h-4 w-4"}),e.jsx("span",{children:z?.user?.email})]}),e.jsx(Ne,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(dl,{className:"h-4 w-4"}),e.jsxs("span",{children:[a("detail.created_at")," ",xe(z?.created_at)]})]}),e.jsx(Ne,{orientation:"vertical",className:"h-4"}),e.jsx(H,{variant:"outline",children:z?.level!=null&&a(`level.${z.level===De.LOW?"low":z.level===De.MIDDLE?"medium":"high"}`)})]})]}),z?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(tl,{defaultValues:z.user,refetch:L,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.user_info"),children:e.jsx(xt,{className:"h-4 w-4"})})}),e.jsx(rl,{user_id:z.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.traffic_records"),children:e.jsx(Ch,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.order_records"),onClick:Es,children:e.jsx(Sh,{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:z?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a("detail.no_messages")}):z?.messages?.map(se=>e.jsx(ll,{variant:se.is_me?"sent":"received",className:se.is_me?"ml-auto":"mr-auto",children:e.jsx(ol,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:se.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:xe(se.created_at)})})]})})},se.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(il,{ref:c,disabled:Fe||d,placeholder:a(Fe?"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:x,onChange:se=>o(se.target.value),onKeyDown:se=>{se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),et())}}),e.jsx(G,{disabled:Fe||d||!x.trim(),onClick:et,children:a(d?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const 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:"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"})}),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.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"})}),Vh=s=>{const{t:n}=F("ticket");return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:n("columns.id")}),cell:({row:a})=>e.jsx(H,{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(Eh,{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===De.LOW?"default":l===De.MIDDLE?"secondary":"destructive";return e.jsx(H,{variant:r,className:"whitespace-nowrap",children:n(`level.${l===De.LOW?"low":l===De.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===Ss.CLOSED?n("status.closed"):n(r===0?"status.replied":"status.pending"),i=l===Ss.CLOSED?"default":r===0?"secondary":"destructive";return e.jsx(H,{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(dl,{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!==Ss.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Dh,{ticketId:a.original.id,dialogTrigger:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(Rh,{className:"h-4 w-4"})})}),l&&e.jsx(We,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{Md(a.original.id).then(()=>{$.success(n("actions.close_success")),s()})},children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(cl,{className:"h-4 w-4"})})})]})}}]};function Ih(){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}=te({queryKey:["orderList",x,r,i],queryFn:()=>Id({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),R=Be({data:p?.data??[],columns:Vh(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:Ge(),getFilteredRowModel:Xe(),getPaginationRowModel:es(),onPaginationChange:o,getSortedRowModel:ss(),getFacetedRowModel:fs(),getFacetedUniqueValues:ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(vh,{table:R,refetch:d}),e.jsx(as,{table:R,showPagination:!0})]})}function Fh(){const{t:s}=F("ticket");return e.jsxs(Ce,{children:[e.jsxs(Se,{children:[e.jsx(Oe,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Ve,{}),e.jsx(Ie,{})]})]}),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(Ih,{})})]})]})}const Mh=Object.freeze(Object.defineProperty({__proto__:null,default:Fh},Symbol.toStringTag,{value:"Module"}));export{$h as a,Lh as c,Ah as g,qh as r}; +`))}})})}),e.jsx(E,{})]})}),e.jsx(b,{control:c.control,name:"action",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsxs(J,{onValueChange:x.onChange,defaultValue:x.value,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:r("form.actionPlaceholder")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"block",children:r("actions.block")}),e.jsx(q,{value:"dns",children:r("actions.dns")})]})]})})}),e.jsx(E,{})]})}),c.watch("action")==="dns"&&e.jsx(b,{control:c.control,name:"action_value",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("form.dnsPlaceholder"),...x})})})]})}),e.jsxs(Ke,{children:[e.jsx(gt,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r("form.cancel")})}),e.jsx(R,{type:"submit",onClick:()=>{Xc(c.getValues()).then(({data:x})=>{x&&(m(!1),s&&s(),toast.success(r(l==="edit"?"messages.updateSuccess":"messages.createSuccess")),c.reset())})},children:r("form.submit")})]})]})]})]})}function cx({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=F("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(Ur,{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(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]})})}function dx({columns:s,data:n,refetch:a}){const[l,r]=u.useState({}),[c,i]=u.useState({}),[m,x]=u.useState([]),[o,d]=u.useState([]),p=Ye({data:n,columns:s,state:{sorting:o,columnVisibility:c,rowSelection:l,columnFilters:m},enableRowSelection:!0,onRowSelectionChange:r,onSortingChange:d,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(os,{table:p,toolbar:k=>e.jsx(cx,{table:k,refetch:a})})}const mx=s=>{const{t:n}=F("route"),a={block:{icon:Di,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:Ei,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(z,{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(z,{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(z,{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:N("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(Ur,{defaultValues:l.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(As,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(qe,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{ed({id:l.original.id}).then(({data:r})=>{r&&(A.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ts,{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 ux(){const{t:s}=F("route"),[n,a]=u.useState([]);function l(){Er().then(({data:r})=>{a(r)})}return u.useEffect(()=>{l()},[]),e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(dx,{data:n,columns:mx(l),refetch:l})})]})]})}const xx=Object.freeze(Object.defineProperty({__proto__:null,default:ux},Symbol.toStringTag,{value:"Module"})),Br=u.createContext(void 0);function hx({children:s,refreshData:n}){const[a,l]=u.useState(!1),[r,c]=u.useState(null);return e.jsx(Br.Provider,{value:{isOpen:a,setIsOpen:l,editingPlan:r,setEditingPlan:c,refreshData:n},children:s})}function Ra(){const s=u.useContext(Br);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function fx({table:s,saveOrder:n,isSortMode:a}){const{setIsOpen:l}=Ra(),{t:r}=F("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(R,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>l(!0),children:[e.jsx(Pe,{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(R,{variant:a?"default":"outline",onClick:n,size:"sm",children:r(a?"plan.sort.save":"plan.sort.edit")})})]})}const an={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"}},px=s=>{const{t:n}=F("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(zt,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:a})=>e.jsx(z,{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(z,{column:a,title:n("plan.columns.show")}),cell:({row:a})=>e.jsx(U,{defaultChecked:a.getValue("show"),onCheckedChange:l=>{Gt({id:a.original.id,show:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:a})=>e.jsx(z,{column:a,title:n("plan.columns.sell")}),cell:({row:a})=>e.jsx(U,{defaultChecked:a.getValue("sell"),onCheckedChange:l=>{Gt({id:a.original.id,sell:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:a})=>e.jsx(z,{column:a,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:a})=>e.jsx(U,{defaultChecked:a.getValue("renew"),onCheckedChange:l=>{Gt({id:a.original.id,renew:l}).then(({data:r})=>{!r&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:a})=>e.jsx(z,{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(z,{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(ht,{}),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(z,{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:N("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(z,{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:m})=>l[i]!=null&&e.jsxs(K,{variant:"secondary",className:N("px-2 py-0.5 font-medium transition-colors text-nowrap",an[i].color,an[i].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[c," ¥",l[i],m]},i))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:a})=>e.jsx(z,{className:"justify-end",column:a,title:n("plan.columns.actions")}),cell:({row:a})=>{const{setIsOpen:l,setEditingPlan:r}=Ra();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{r(a.original),l(!0)},children:[e.jsx(As,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(qe,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{jd({id:a.original.id}).then(({data:c})=>{c&&(A.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ts,{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")})]})})]})}}]},gx=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()}),Gr=u.forwardRef(({className:s,...n},a)=>e.jsx(ar,{ref:a,className:N("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(Ri,{className:N("flex items-center justify-center text-current"),children:e.jsx(zs,{className:"h-4 w-4"})})}));Gr.displayName=ar.displayName;const _t={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},wt={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}},jx=[{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 vx(){const{isOpen:s,setIsOpen:n,editingPlan:a,setEditingPlan:l,refreshData:r}=Ra(),[c,i]=u.useState(!1),{t:m}=F("subscribe"),x=he({resolver:ge(gx),defaultValues:{..._t,...a||{}},mode:"onChange"});u.useEffect(()=>{a?x.reset({..._t,...a}):x.reset(_t)},[a,x]);const o=new pa({html:!0}),[d,p]=u.useState();async function k(){qt().then(({data:j})=>{p(j)})}u.useEffect(()=>{s&&k()},[s]);const I=j=>{if(isNaN(j))return;const C=Object.entries(wt).reduce((g,[w,T])=>{const S=j*T.months*T.discount;return{...g,[w]:S.toFixed(2)}},{});x.setValue("prices",C,{shouldDirty:!0})},f=()=>{n(!1),l(null),x.reset(_t)};return e.jsx(ve,{open:s,onOpenChange:f,children:e.jsxs(pe,{children:[e.jsxs(Ne,{children:[e.jsx(be,{children:m(a?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ee,{})]}),e.jsxs(je,{...x,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:x.control,name:"name",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:m("plan.form.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:m("plan.form.name.placeholder"),...j})}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"group_id",render:({field:j})=>e.jsxs(v,{children:[e.jsxs(y,{className:"flex items-center justify-between",children:[m("plan.form.group.label"),e.jsx(Kt,{dialogTrigger:e.jsx(R,{variant:"link",children:m("plan.form.group.add")}),refetch:k})]}),e.jsxs(J,{value:j.value?.toString()??"",onValueChange:C=>j.onChange(C?Number(C):null),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:m("plan.form.group.placeholder")})})}),e.jsx(Y,{children:d?.map(C=>e.jsx(q,{value:C.id.toString(),children:C.name},C.id))})]}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"transfer_enable",render:({field:j})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:m("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:m("plan.form.transfer.placeholder"),className:"rounded-r-none",...j})}),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:m("plan.form.transfer.unit")})]}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"speed_limit",render:({field:j})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:m("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:m("plan.form.speed.placeholder"),className:"rounded-r-none",...j,value:j.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:m("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:m("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:m("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:j=>{const C=parseFloat(j.target.value);I(C)}})]}),e.jsx(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(R,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const j=Object.keys(wt).reduce((C,g)=>({...C,[g]:""}),{});x.setValue("prices",j,{shouldDirty:!0})},children:m("plan.form.price.clear.button")})}),e.jsx(oe,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:m("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(wt).filter(([j])=>!["onetime","reset_traffic"].includes(j)).map(([j,C])=>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(b,{control:x.control,name:`prices.${j}`,render:({field:g})=>e.jsxs(v,{children:[e.jsxs(y,{className:"text-xs font-medium text-muted-foreground",children:[m(`plan.columns.price_period.${j}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",C.months===1?m("plan.form.price.period.monthly"):m("plan.form.price.period.months",{count:C.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(_,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...g,value:g.value??"",onChange:w=>g.onChange(w.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"})})]})]})})},j))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(wt).filter(([j])=>["onetime","reset_traffic"].includes(j)).map(([j,C])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(b,{control:x.control,name:`prices.${j}`,render:({field:g})=>e.jsx(v,{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(y,{className:"text-xs font-medium",children:m(`plan.columns.price_period.${j}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m(j==="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(_,{children:e.jsx(D,{type:"number",placeholder:"0.00",min:0,...g,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"})})]})]})})})},j))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(b,{control:x.control,name:"device_limit",render:({field:j})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:m("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:m("plan.form.device.placeholder"),className:"rounded-r-none",...j,value:j.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:m("plan.form.device.unit")})]}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"capacity_limit",render:({field:j})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:m("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:m("plan.form.capacity.placeholder"),className:"rounded-r-none",...j,value:j.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:m("plan.form.capacity.unit")})]}),e.jsx(E,{})]})})]}),e.jsx(b,{control:x.control,name:"reset_traffic_method",render:({field:j})=>e.jsxs(v,{children:[e.jsx(y,{children:m("plan.form.reset_method.label")}),e.jsxs(J,{value:j.value?.toString()??"null",onValueChange:C=>j.onChange(C=="null"?null:Number(C)),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Z,{placeholder:m("plan.form.reset_method.placeholder")})})}),e.jsx(Y,{children:jx.map(C=>e.jsx(q,{value:C.value?.toString()??"null",children:m(`plan.form.reset_method.options.${C.label}`)},C.value))})]}),e.jsx(M,{className:"text-xs",children:m("plan.form.reset_method.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:x.control,name:"content",render:({field:j})=>{const[C,g]=u.useState(!1);return e.jsxs(v,{className:"space-y-2",children:[e.jsxs(y,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[m("plan.form.content.label"),e.jsx(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(R,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>g(!C),children:C?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(oe,{side:"top",children:e.jsx("p",{className:"text-xs",children:m(C?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(xe,{children:e.jsxs(me,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(R,{variant:"outline",size:"sm",onClick:()=>{j.onChange(m("plan.form.content.template.content"))},children:m("plan.form.content.template.button")})}),e.jsx(oe,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:m("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${C?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(_,{children:e.jsx(ga,{style:{height:"400px"},value:j.value||"",renderHTML:w=>o.render(w),onChange:({text:w})=>j.onChange(w),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:m("plan.form.content.placeholder"),className:"rounded-md border"})})}),C&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:m("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(j.value||"")}})})]})]}),e.jsx(M,{className:"text-xs",children:m("plan.form.content.description")}),e.jsx(E,{})]})}})]}),e.jsx(Ke,{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(b,{control:x.control,name:"force_update",render:({field:j})=>e.jsxs(v,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Gr,{checked:j.value,onCheckedChange:j.onChange})}),e.jsx("div",{className:"",children:e.jsx(y,{className:"text-sm",children:m("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(R,{type:"button",variant:"outline",onClick:f,children:m("plan.form.submit.cancel")}),e.jsx(R,{type:"submit",disabled:c,onClick:()=>{x.handleSubmit(async j=>{i(!0),(await gd(j)).data&&(A.success(m(a?"plan.form.submit.success.update":"plan.form.submit.success.add")),f(),r()),i(!1)})()},children:m(c?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})]})})}function bx(){const[s,n]=u.useState({}),[a,l]=u.useState({"drag-handle":!1}),[r,c]=u.useState([]),[i,m]=u.useState([]),[x,o]=u.useState(!1),[d,p]=u.useState({pageSize:20,pageIndex:0}),[k,I]=u.useState([]),{refetch:f}=ne({queryKey:["planList"],queryFn:async()=>{const{data:T}=await Hs();return I(T),T}});u.useEffect(()=>{l({"drag-handle":x}),p({pageSize:x?99999:10,pageIndex:0})},[x]);const j=(T,S)=>{x&&(T.dataTransfer.setData("text/plain",S.toString()),T.currentTarget.classList.add("opacity-50"))},C=(T,S)=>{if(!x)return;T.preventDefault(),T.currentTarget.classList.remove("bg-muted");const P=parseInt(T.dataTransfer.getData("text/plain"));if(P===S)return;const L=[...k],[G]=L.splice(P,1);L.splice(S,0,G),I(L)},g=async()=>{if(!x){o(!0);return}const T=k?.map(S=>S.id);vd(T).then(()=>{A.success("排序保存成功"),o(!1),f()}).finally(()=>{o(!1)})},w=Ye({data:k||[],columns:px(f),state:{sorting:i,columnVisibility:a,rowSelection:s,columnFilters:r,pagination:d},enableRowSelection:!0,onPaginationChange:p,onRowSelectionChange:n,onSortingChange:m,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}},pageCount:x?1:void 0});return e.jsx(hx,{refreshData:f,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(os,{table:w,toolbar:T=>e.jsx(fx,{table:T,refetch:f,saveOrder:g,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}),e.jsx(vx,{})]})})}function yx(){const{t:s}=F("subscribe");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(bx,{})})]})]})}const Nx=Object.freeze(Object.defineProperty({__proto__:null,default:yx},Symbol.toStringTag,{value:"Module"})),Gs=[{value:se.PENDING,label:nt[se.PENDING],icon:Ii,color:rt[se.PENDING]},{value:se.PROCESSING,label:nt[se.PROCESSING],icon:nr,color:rt[se.PROCESSING]},{value:se.COMPLETED,label:nt[se.COMPLETED],icon:na,color:rt[se.COMPLETED]},{value:se.CANCELLED,label:nt[se.CANCELLED],icon:rr,color:rt[se.CANCELLED]},{value:se.DISCOUNTED,label:nt[se.DISCOUNTED],icon:na,color:rt[se.DISCOUNTED]}],ot=[{value:de.PENDING,label:vt[de.PENDING],icon:Vi,color:bt[de.PENDING]},{value:de.PROCESSING,label:vt[de.PROCESSING],icon:nr,color:bt[de.PROCESSING]},{value:de.VALID,label:vt[de.VALID],icon:na,color:bt[de.VALID]},{value:de.INVALID,label:vt[de.INVALID],icon:rr,color:bt[de.INVALID]}];function Ct({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(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),n,c?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(we,{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(ls,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Rs,{children:[e.jsx($s,{placeholder:n}),e.jsxs(Is,{children:[e.jsx(qs,{children:"No results found."}),e.jsx($e,{children:a.map(i=>{const m=c.has(i.value);return e.jsxs(De,{onSelect:()=>{const x=new Set(c);m?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:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",m?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(zs,{className:N("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(et,{}),e.jsx($e,{children:e.jsx(De,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const _x=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),wx={email:"",plan_id:0,total_amount:0,period:""};function Wr({refetch:s,trigger:n,defaultValues:a}){const{t:l}=F("order"),[r,c]=u.useState(!1),i=he({resolver:ge(_x),defaultValues:{...wx,...a},mode:"onChange"}),[m,x]=u.useState([]);return u.useEffect(()=>{r&&Hs().then(({data:o})=>{x(o)})},[r]),e.jsxs(ve,{open:r,onOpenChange:c,children:[e.jsx(He,{asChild:!0,children:n||e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Pe,{icon:"ion:add"}),e.jsx("div",{children:l("dialog.addOrder")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:l("dialog.assignOrder")}),e.jsx(Ee,{})]}),e.jsxs(je,{...i,children:[e.jsx(b,{control:i.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.userEmail")}),e.jsx(_,{children:e.jsx(D,{placeholder:l("dialog.placeholders.email"),...o})})]})}),e.jsx(b,{control:i.control,name:"plan_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.subscriptionPlan")}),e.jsx(_,{children:e.jsxs(J,{value:o.value?o.value?.toString():void 0,onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dialog.placeholders.plan")})}),e.jsx(Y,{children:m.map(d=>e.jsx(q,{value:d.id.toString(),children:d.name},d.id))})]})})]})}),e.jsx(b,{control:i.control,name:"period",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.orderPeriod")}),e.jsx(_,{children:e.jsxs(J,{value:o.value,onValueChange:o.onChange,children:[e.jsx(W,{children:e.jsx(Z,{placeholder:l("dialog.placeholders.period")})}),e.jsx(Y,{children:Object.keys(Wd).map(d=>e.jsx(q,{value:d,children:l(`period.${d}`)},d))})]})})]})}),e.jsx(b,{control:i.control,name:"total_amount",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:l("dialog.fields.paymentAmount")}),e.jsx(_,{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(Ke,{children:[e.jsx(R,{variant:"outline",onClick:()=>c(!1),children:l("dialog.actions.cancel")}),e.jsx(R,{type:"submit",onClick:()=>{i.handleSubmit(o=>{wd(o).then(({data:d})=>{d&&(s&&s(),i.reset(),c(!1),A.success(l("dialog.messages.addSuccess")))})})()},children:l("dialog.actions.confirm")})]})]})]})]})}function Cx({table:s,refetch:n}){const{t:a}=F("order"),l=s.getState().columnFilters.length>0,r=Object.values(ss).filter(x=>typeof x=="number").map(x=>({label:a(`type.${ss[x]}`),value:x,color:x===ss.NEW?"green-500":x===ss.RENEWAL?"blue-500":x===ss.UPGRADE?"purple-500":"orange-500"})),c=Object.values(Se).map(x=>({label:a(`period.${x}`),value:x,color:x===Se.MONTH_PRICE?"slate-500":x===Se.QUARTER_PRICE?"cyan-500":x===Se.HALF_YEAR_PRICE?"indigo-500":x===Se.YEAR_PRICE?"violet-500":x===Se.TWO_YEAR_PRICE?"fuchsia-500":x===Se.THREE_YEAR_PRICE?"pink-500":x===Se.ONETIME_PRICE?"rose-500":"orange-500"})),i=Object.values(se).filter(x=>typeof x=="number").map(x=>({label:a(`status.${se[x]}`),value:x,icon:x===se.PENDING?Gs[0].icon:x===se.PROCESSING?Gs[1].icon:x===se.COMPLETED?Gs[2].icon:x===se.CANCELLED?Gs[3].icon:Gs[4].icon,color:x===se.PENDING?"yellow-500":x===se.PROCESSING?"blue-500":x===se.COMPLETED?"green-500":x===se.CANCELLED?"red-500":"green-500"})),m=Object.values(de).filter(x=>typeof x=="number").map(x=>({label:a(`commission.${de[x]}`),value:x,icon:x===de.PENDING?ot[0].icon:x===de.PROCESSING?ot[1].icon:x===de.VALID?ot[2].icon:ot[3].icon,color:x===de.PENDING?"yellow-500":x===de.PROCESSING?"blue-500":x===de.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wr,{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(Ct,{column:s.getColumn("type"),title:a("table.columns.type"),options:r}),s.getColumn("period")&&e.jsx(Ct,{column:s.getColumn("period"),title:a("table.columns.period"),options:c}),s.getColumn("status")&&e.jsx(Ct,{column:s.getColumn("status"),title:a("table.columns.status"),options:i}),s.getColumn("commission_status")&&e.jsx(Ct,{column:s.getColumn("commission_status"),title:a("table.columns.commissionStatus"),options:m})]}),l&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[a("actions.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]})}function Ze({label:s,value:n,className:a,valueClassName:l}){return e.jsxs("div",{className:N("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:N("text-sm",l),children:n||"-"})]})}function Sx({status:s}){const{t:n}=F("order"),a={[se.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[se.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[se.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[se.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[se.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(K,{variant:"secondary",className:N("font-medium",a[s]),children:n(`status.${se[s]}`)})}function kx({id:s,trigger:n}){const[a,l]=u.useState(!1),[r,c]=u.useState(),{t:i}=F("order");return u.useEffect(()=>{(async()=>{if(a){const{data:x}=await yd({id:s});c(x)}})()},[a,s]),e.jsxs(ve,{onOpenChange:l,open:a,children:[e.jsx(He,{asChild:!0,children:n}),e.jsxs(pe,{className:"max-w-xl",children:[e.jsxs(Ne,{className:"space-y-2",children:[e.jsx(be,{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(Sx,{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(Ze,{label:i("dialog.fields.userEmail"),value:r?.user?.email?e.jsxs(Ls,{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(lr,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(Ze,{label:i("dialog.fields.orderPeriod"),value:r&&i(`period.${r.period}`)}),e.jsx(Ze,{label:i("dialog.fields.subscriptionPlan"),value:r?.plan?.name,valueClassName:"font-medium"}),e.jsx(Ze,{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(Ze,{label:i("dialog.fields.paymentAmount"),value:Fs(r?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(we,{className:"my-2"}),e.jsx(Ze,{label:i("dialog.fields.balancePayment"),value:Fs(r?.balance_amount||0)}),e.jsx(Ze,{label:i("dialog.fields.discountAmount"),value:Fs(r?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(Ze,{label:i("dialog.fields.refundAmount"),value:Fs(r?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(Ze,{label:i("dialog.fields.deductionAmount"),value:Fs(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(Ze,{label:i("dialog.fields.createdAt"),value:fe(r?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(Ze,{label:i("dialog.fields.updatedAt"),value:fe(r?.updated_at),valueClassName:"font-mono text-xs"})]})]})]})]})]})}const Tx={[ss.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[ss.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[ss.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[ss.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Px={[Se.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Se.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},Dx=s=>se[s],Ex=s=>de[s],Rx=s=>ss[s],Ix=s=>{const{t:n}=F("order");return[{accessorKey:"trade_no",header:({column:a})=>e.jsx(z,{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(kx,{trigger:e.jsxs(B,{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(lr,{className:"h-3.5 w-3.5 opacity-70"})]}),id:a.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:a})=>e.jsx(z,{column:a,title:n("table.columns.type")}),cell:({row:a})=>{const l=a.getValue("type"),r=Tx[l];return e.jsx(K,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",r.color,r.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${Rx(l)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:a})=>e.jsx(z,{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(z,{column:a,title:n("table.columns.period")}),cell:({row:a})=>{const l=a.getValue("period"),r=Px[l];return e.jsx(K,{variant:"secondary",className:N("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(z,{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(z,{column:a,title:n("table.columns.status")}),e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{children:e.jsx(Lr,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(oe,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:a})=>{const l=Gs.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.${Dx(l.value)}`)})]}),l.value===se.PENDING&&e.jsxs(Ds,{modal:!0,children:[e.jsx(Es,{asChild:!0,children:e.jsxs(B,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Dt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(gs,{align:"end",className:"w-[140px]",children:[e.jsx(ye,{className:"cursor-pointer",onClick:async()=>{await Nd({trade_no:a.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(ye,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await _d({trade_no:a.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:a})=>e.jsx(z,{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(z,{column:a,title:n("table.columns.commissionStatus")}),cell:({row:a})=>{const l=a.original.status,r=a.original.commission_balance,c=ot.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.${Ex(c.value)}`)})]}),c.value===de.PENDING&&l===se.COMPLETED&&e.jsxs(Ds,{modal:!0,children:[e.jsx(Es,{asChild:!0,children:e.jsxs(B,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Dt,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(gs,{align:"end",className:"w-[120px]",children:[e.jsx(ye,{className:"cursor-pointer",onClick:async()=>{await Ya({trade_no:a.original.trade_no,commission_status:de.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(ye,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await Ya({trade_no:a.original.trade_no,commission_status:de.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:a})=>e.jsx(z,{column:a,title:n("table.columns.createdAt")}),cell:({row:a})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:fe(a.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function Vx(){const[s]=or(),[n,a]=u.useState({}),[l,r]=u.useState({}),[c,i]=u.useState([]),[m,x]=u.useState([]),[o,d]=u.useState({pageIndex:0,pageSize:20});u.useEffect(()=>{const C=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([g,w])=>{const T=s.get(g);return T?{id:g,value:w==="number"?parseInt(T):T}:null}).filter(Boolean);C.length>0&&i(C)},[s]);const{refetch:p,data:k,isLoading:I}=ne({queryKey:["orderList",o,c,m],queryFn:()=>bd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:m})}),f=Ye({data:k?.data??[],columns:Ix(p),state:{sorting:m,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:o},rowCount:k?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),onPaginationChange:d,getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(os,{table:f,toolbar:e.jsx(Cx,{table:f,refetch:p}),showPagination:!0})}function Fx(){const{t:s}=F("order");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(Vx,{})})]})]})}const Mx=Object.freeze(Object.defineProperty({__proto__:null,default:Fx},Symbol.toStringTag,{value:"Module"}));function Ox({column:s,title:n,options:a}){const l=s?.getFacetedUniqueValues(),r=new Set(s?.getFilterValue());return e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(we,{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(ls,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Rs,{children:[e.jsx($s,{placeholder:n}),e.jsxs(Is,{children:[e.jsx(qs,{children:"No results found."}),e.jsx($e,{children:a.map(c=>{const i=r.has(c.value);return e.jsxs(De,{onSelect:()=>{i?r.delete(c.value):r.add(c.value);const m=Array.from(r);s?.setFilterValue(m.length?m:void 0)},children:[e.jsx("div",{className:N("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(zs,{className:N("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(et,{}),e.jsx($e,{children:e.jsx(De,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const zx=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.coerce.number()).default([]).nullable(),limit_period:h.array(h.nativeEnum(ct)).default([]).nullable()}).refine(s=>s.ended_at>s.started_at,{message:"结束时间必须晚于开始时间",path:["ended_at"]}),nn={name:"",code:"",type:Le.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 Yr({defaultValues:s,refetch:n,type:a="create",dialogTrigger:l=null,open:r,onOpenChange:c}){const{t:i}=F("coupon"),[m,x]=u.useState(!1),o=r??m,d=c??x,[p,k]=u.useState([]),I=he({resolver:ge(zx),defaultValues:s||nn});u.useEffect(()=>{s&&I.reset(s)},[s,I]),u.useEffect(()=>{Hs().then(({data:g})=>k(g))},[]);const f=g=>{if(!g)return;const w=(T,S)=>{const P=new Date(S*1e3);return T.setHours(P.getHours(),P.getMinutes(),P.getSeconds()),Math.floor(T.getTime()/1e3)};g.from&&I.setValue("started_at",w(g.from,I.watch("started_at"))),g.to&&I.setValue("ended_at",w(g.to,I.watch("ended_at")))},j=async g=>{Sd(g).then(()=>{d(!1),a==="create"&&I.reset(nn),n()})},C=(g,w)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:w}),e.jsx(D,{type:"datetime-local",step:"1",value:fe(I.watch(g),"YYYY-MM-DDTHH:mm:ss"),onChange:T=>{const S=new Date(T.target.value);I.setValue(g,Math.floor(S.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(ve,{open:o,onOpenChange:d,children:[l&&e.jsx(He,{asChild:!0,children:l}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsx(Ne,{children:e.jsx(be,{children:i(a==="create"?"form.add":"form.edit")})}),e.jsx(je,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(j),className:"space-y-4",children:[e.jsx(b,{control:I.control,name:"name",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.name.label")}),e.jsx(D,{placeholder:i("form.name.placeholder"),...g}),e.jsx(E,{})]})}),e.jsx(b,{control:I.control,name:"code",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.code.label")}),e.jsx(D,{placeholder:i("form.code.placeholder"),...g,className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.code.description")}),e.jsx(E,{})]})}),e.jsxs(v,{children:[e.jsx(y,{children:i("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(b,{control:I.control,name:"type",render:({field:g})=>e.jsxs(J,{value:g.value.toString(),onValueChange:w=>{const T=g.value,S=parseInt(w);g.onChange(S);const P=I.getValues("value");P&&(T===Le.AMOUNT&&S===Le.PERCENT?I.setValue("value",P/100):T===Le.PERCENT&&S===Le.AMOUNT&&I.setValue("value",P*100))},children:[e.jsx(W,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Z,{placeholder:i("form.type.placeholder")})}),e.jsx(Y,{children:Object.entries(Yd).map(([w,T])=>e.jsx(q,{value:w,children:i(`table.toolbar.types.${w}`)},w))})]})}),e.jsx(b,{control:I.control,name:"value",render:({field:g})=>{const w=g.value===""?"":I.watch("type")===Le.AMOUNT&&typeof g.value=="number"?(g.value/100).toString():g.value.toString();return e.jsx(D,{type:"number",placeholder:i("form.value.placeholder"),...g,value:w,onChange:T=>{const S=T.target.value;if(S===""){g.onChange("");return}const P=parseFloat(S);isNaN(P)||g.onChange(I.watch("type")===Le.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:I.watch("type")==Le.AMOUNT?"¥":"%"})})]})]}),e.jsxs(v,{children:[e.jsx(y,{children:i("form.validity.label")}),e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(R,{variant:"outline",className:N("w-full justify-start text-left font-normal",!I.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(ft,{className:"mr-2 h-4 w-4"}),fe(I.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",i("form.validity.to")," ",fe(I.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})}),e.jsxs(ls,{className:"w-auto p-0",align:"start",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx(Ks,{mode:"range",selected:{from:new Date(I.watch("started_at")*1e3),to:new Date(I.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:[C("started_at",i("table.validity.startTime")),e.jsx("div",{className:"mt-6 text-sm text-muted-foreground",children:i("form.validity.to")}),C("ended_at",i("table.validity.endTime"))]})})]})]}),e.jsx(E,{})]}),e.jsx(b,{control:I.control,name:"limit_use",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.limitUse.placeholder"),...g,value:g.value===void 0?"":g.value,onChange:w=>g.onChange(w.target.value===""?"":w.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.limitUse.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:I.control,name:"limit_use_with_user",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.limitUseWithUser.placeholder"),...g,value:g.value===void 0?"":g.value,onChange:w=>g.onChange(w.target.value===""?"":w.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.limitUseWithUser.description")}),e.jsx(E,{})]})}),e.jsx(b,{control:I.control,name:"limit_period",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.limitPeriod.label")}),e.jsx(xt,{options:Object.entries(ct).filter(([w])=>isNaN(Number(w))).map(([w,T])=>({label:i(`coupon:period.${T}`),value:w})),onChange:w=>{if(w.length===0){g.onChange([]);return}const T=w.map(S=>ct[S.value]);g.onChange(T)},value:(g.value||[]).map(w=>({label:i(`coupon:period.${w}`),value:Object.entries(ct).find(([T,S])=>S===w)?.[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(b,{control:I.control,name:"limit_plan_ids",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.limitPlan.label")}),e.jsx(xt,{options:p?.map(w=>({label:w.name,value:w.id.toString()}))||[],onChange:w=>g.onChange(w.map(T=>Number(T.value))),value:(p||[]).filter(w=>(g.value||[]).includes(w.id)).map(w=>({label:w.name,value:w.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(b,{control:I.control,name:"generate_count",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:i("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:i("form.generateCount.placeholder"),...g,value:g.value===void 0?"":g.value,onChange:w=>g.onChange(w.target.value===""?"":w.target.value),className:"h-9"}),e.jsx(M,{className:"text-xs",children:i("form.generateCount.description")}),e.jsx(E,{})]})})}),e.jsx(Ke,{children:e.jsx(R,{type:"submit",disabled:I.formState.isSubmitting,children:I.formState.isSubmitting?i("form.submit.saving"):i("form.submit.save")})})]})})]})]})}function Lx({table:s,refetch:n}){const a=s.getState().columnFilters.length>0,{t:l}=F("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Yr,{refetch:n,dialogTrigger:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Pe,{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(Ox,{column:s.getColumn("type"),title:l("table.toolbar.type"),options:[{value:Le.AMOUNT,label:l(`table.toolbar.types.${Le.AMOUNT}`)},{value:Le.PERCENTAGE,label:l(`table.toolbar.types.${Le.PERCENTAGE}`)}]}),a&&e.jsxs(R,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[l("table.toolbar.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]})}const Qr=u.createContext(void 0);function Ax({children:s,refetch:n}){const[a,l]=u.useState(!1),[r,c]=u.useState(null),i=x=>{c(x),l(!0)},m=()=>{l(!1),c(null)};return e.jsxs(Qr.Provider,{value:{isOpen:a,currentCoupon:r,openEdit:i,closeEdit:m},children:[s,r&&e.jsx(Yr,{defaultValues:r,refetch:n,type:"edit",open:a,onOpenChange:l})]})}function $x(){const s=u.useContext(Qr);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const qx=s=>{const{t:n}=F("coupon");return[{accessorKey:"id",header:({column:a})=>e.jsx(z,{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(z,{column:a,title:n("table.columns.show")}),cell:({row:a})=>e.jsx(U,{defaultChecked:a.original.show,onCheckedChange:l=>{Td({id:a.original.id,show:l}).then(({data:r})=>!r&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:a})=>e.jsx(z,{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(z,{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(z,{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(z,{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(z,{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(z,{column:a,title:n("table.columns.validity")}),cell:({row:a})=>{const[l,r]=u.useState(!1),c=Date.now(),i=a.original.started_at*1e3,m=a.original.ended_at*1e3,x=c>m,o=ce.jsx(z,{className:"justify-end",column:a,title:n("table.columns.actions")}),cell:({row:a})=>{const{openEdit:l}=$x();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>l(a.original),children:[e.jsx(As,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(qe,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{kd({id:a.original.id}).then(({data:r})=>{r&&(A.success("删除成功"),s())})},children:e.jsxs(R,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(ts,{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 Hx(){const[s,n]=u.useState({}),[a,l]=u.useState({}),[r,c]=u.useState([]),[i,m]=u.useState([]),[x,o]=u.useState({pageIndex:0,pageSize:20}),{refetch:d,data:p}=ne({queryKey:["couponList",x,r,i],queryFn:()=>Cd({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),k=Ye({data:p?.data??[],columns:qx(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:m,onColumnFiltersChange:c,onColumnVisibilityChange:l,onPaginationChange:o,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Ax,{refetch:d,children:e.jsx("div",{className:"space-y-4",children:e.jsx(os,{table:k,toolbar:e.jsx(Lx,{table:k,refetch:d})})})})}function Kx(){const{t:s}=F("coupon");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(Hx,{})})]})]})}const Ux=Object.freeze(Object.defineProperty({__proto__:null,default:Kx},Symbol.toStringTag,{value:"Module"})),Bx=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"]}),Gx={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0};function Wx({refetch:s}){const{t:n}=F("user"),[a,l]=u.useState(!1),r=he({resolver:ge(Bx),defaultValues:Gx,mode:"onChange"}),[c,i]=u.useState([]);return u.useEffect(()=>{a&&Hs().then(({data:m})=>{m&&i(m)})},[a]),e.jsxs(ve,{open:a,onOpenChange:l,children:[e.jsx(He,{asChild:!0,children:e.jsxs(B,{size:"sm",variant:"outline",className:"space-x-2 gap-0",children:[e.jsx(Pe,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(pe,{className:"sm:max-w-[425px]",children:[e.jsxs(Ne,{children:[e.jsx(be,{children:n("generate.title")}),e.jsx(Ee,{})]}),e.jsxs(je,{...r,children:[e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!r.watch("generate_count")&&e.jsx(b,{control:r.control,name:"email_prefix",render:({field:m})=>e.jsx(D,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...m})}),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(b,{control:r.control,name:"email_suffix",render:({field:m})=>e.jsx(D,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...m})})]})]}),e.jsx(b,{control:r.control,name:"password",render:({field:m})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...m}),e.jsx(E,{})]})}),e.jsx(b,{control:r.control,name:"expired_at",render:({field:m})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:n("generate.form.expire_time")}),e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsx(_,{children:e.jsxs(B,{variant:"outline",className:N("w-full pl-3 text-left font-normal",!m.value&&"text-muted-foreground"),children:[m.value?fe(m.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(ft,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(ls,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Mi,{asChild:!0,children:e.jsx(B,{variant:"outline",className:"w-full",onClick:()=>{m.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Ks,{mode:"single",selected:m.value?new Date(m.value*1e3):void 0,onSelect:x=>{x&&m.onChange(x?.getTime()/1e3)}})})]})]})]})}),e.jsx(b,{control:r.control,name:"plan_id",render:({field:m})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.subscription")}),e.jsx(_,{children:e.jsxs(J,{value:m.value?m.value.toString():"null",onValueChange:x=>m.onChange(x==="null"?null:parseInt(x)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"null",children:n("generate.form.subscription_none")}),c.map(x=>e.jsx(q,{value:x.id.toString(),children:x.name},x.id))]})]})})]})}),!r.watch("email_prefix")&&e.jsx(b,{control:r.control,name:"generate_count",render:({field:m})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.generate_count")}),e.jsx(D,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:m.value||"",onChange:x=>m.onChange(x.target.value?parseInt(x.target.value):null)})]})})]}),e.jsxs(Ke,{children:[e.jsx(B,{variant:"outline",onClick:()=>l(!1),children:n("generate.form.cancel")}),e.jsx(B,{onClick:()=>r.handleSubmit(m=>{Rd(m).then(({data:x})=>{x&&(A.success(n("generate.form.success")),r.reset(),s(),l(!1))})})(),children:n("generate.form.submit")})]})]})]})}const Jr=cn,Zr=dn,Yx=mn,Xr=u.forwardRef(({className:s,...n},a)=>e.jsx(Vt,{className:N("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}));Xr.displayName=Vt.displayName;const Qx=Os("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"}}),Ia=u.forwardRef(({side:s="right",className:n,children:a,...l},r)=>e.jsxs(Yx,{children:[e.jsx(Xr,{}),e.jsxs(Ft,{ref:r,className:N(Qx({side:s}),n),...l,children:[e.jsxs(ma,{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(Be,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),a]})]}));Ia.displayName=Ft.displayName;const Va=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Va.displayName="SheetHeader";const el=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});el.displayName="SheetFooter";const Fa=u.forwardRef(({className:s,...n},a)=>e.jsx(Mt,{ref:a,className:N("text-lg font-semibold text-foreground",s),...n}));Fa.displayName=Mt.displayName;const Ma=u.forwardRef(({className:s,...n},a)=>e.jsx(Ot,{ref:a,className:N("text-sm text-muted-foreground",s),...n}));Ma.displayName=Ot.displayName;function Jx({table:s,refetch:n,permissionGroups:a=[],subscriptionPlans:l=[]}){const{t:r}=F("user"),c=s.getState().columnFilters.length>0,[i,m]=u.useState([]),[x,o]=u.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=w=>w*1024*1024*1024,k=w=>w/(1024*1024*1024),I=()=>{m([...i,{field:"",operator:"",value:""}])},f=w=>{m(i.filter((T,S)=>S!==w))},j=(w,T,S)=>{const P=[...i];if(P[w]={...P[w],[T]:S},T==="field"){const L=d.find(G=>G.value===S);L&&(P[w].operator=L.operators[0].value,P[w].value=L.type==="boolean"?!1:"")}m(P)},C=(w,T)=>{const S=d.find(P=>P.value===w.field);if(!S)return null;switch(S.type){case"text":return e.jsx(D,{placeholder:r("filter.sheet.value"),value:w.value,onChange:P=>j(T,"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:S.unit}),value:S.unit==="GB"?k(w.value||0):w.value,onChange:P=>{const L=Number(P.target.value);j(T,"value",S.unit==="GB"?p(L):L)}}),S.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:S.unit})]});case"date":return e.jsx(Ks,{mode:"single",selected:w.value,onSelect:P=>j(T,"value",P),className:"rounded-md border"});case"select":return e.jsxs(J,{value:w.value,onValueChange:P=>j(T,"value",P),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:r("filter.sheet.value")})}),e.jsx(Y,{children:S.useOptions?l.map(P=>e.jsx(q,{value:P.value.toString(),children:P.label},P.value)):S.options?.map(P=>e.jsx(q,{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(U,{checked:w.value,onCheckedChange:P=>j(T,"value",P)}),e.jsx(Et,{children:w.value?r("filter.boolean.true"):r("filter.boolean.false")})]});default:return null}},g=()=>{const w=i.filter(T=>T.field&&T.operator&&T.value!=="").map(T=>{const S=d.find(L=>L.value===T.field);let P=T.value;return T.operator==="contains"?{id:T.field,value:P}:(S?.type==="date"&&P instanceof Date&&(P=Math.floor(P.getTime()/1e3)),S?.type==="boolean"&&(P=P?1:0),{id:T.field,value:`${T.operator}:${P}`})});s.setColumnFilters(w),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(Wx,{refetch:n}),e.jsx(D,{placeholder:r("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:w=>s.getColumn("email")?.setFilterValue(w.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Jr,{open:x,onOpenChange:o,children:[e.jsx(Zr,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Oi,{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(Ia,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(Va,{children:[e.jsx(Fa,{children:r("filter.sheet.title")}),e.jsx(Ma,{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(R,{variant:"outline",size:"sm",onClick:I,children:r("filter.sheet.add")})]}),e.jsx(Zs,{className:"h-[calc(100vh-280px)] pr-4",children:e.jsx("div",{className:"space-y-4",children:i.map((w,T)=>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(Et,{children:r("filter.sheet.condition",{number:T+1})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>f(T),children:e.jsx(Be,{className:"h-4 w-4"})})]}),e.jsxs(J,{value:w.field,onValueChange:S=>j(T,"field",S),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:r("filter.sheet.field")})}),e.jsx(Y,{children:d.map(S=>e.jsx(q,{value:S.value,children:S.label},S.value))})]}),w.field&&e.jsxs(J,{value:w.operator,onValueChange:S=>j(T,"operator",S),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:r("filter.sheet.operator")})}),e.jsx(Y,{children:d.find(S=>S.value===w.field)?.operators.map(S=>e.jsx(q,{value:S.value,children:S.label},S.value))})]}),w.field&&w.operator&&C(w,T)]},T))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(R,{variant:"outline",onClick:()=>{m([]),o(!1)},children:r("filter.sheet.reset")}),e.jsx(R,{onClick:g,children:r("filter.sheet.apply")})]})]})]})]}),c&&e.jsxs(R,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),m([])},className:"h-8 px-2 lg:px-3",children:[r("filter.reset"),e.jsx(Be,{className:"ml-2 h-4 w-4"})]})]})})}const Zx=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()}),sl=u.createContext(void 0);function Xx({children:s,defaultValues:n,open:a,onOpenChange:l}){const[r,c]=u.useState(!1),[i,m]=u.useState(!1),[x,o]=u.useState([]),d=he({resolver:ge(Zx),defaultValues:n,mode:"onChange"});u.useEffect(()=>{a!==void 0&&c(a)},[a]);const p=k=>{c(k),l?.(k)};return e.jsx(sl.Provider,{value:{form:d,formOpen:r,setFormOpen:p,datePickerOpen:i,setDatePickerOpen:m,planList:x,setPlanList:o},children:s})}function eh(){const s=u.useContext(sl);if(!s)throw new Error("useUserForm must be used within a UserFormProvider");return s}function sh({refetch:s}){const{t:n}=F("user"),{form:a,formOpen:l,setFormOpen:r,datePickerOpen:c,setDatePickerOpen:i,planList:m,setPlanList:x}=eh();return u.useEffect(()=>{l&&Hs().then(({data:o})=>{x(o)})},[l,x]),e.jsxs(je,{...a,children:[e.jsx(b,{control:a.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.email")}),e.jsx(_,{children:e.jsx(D,{...o,placeholder:n("edit.form.email_placeholder")})}),e.jsx(E,{...o})]})}),e.jsx(b,{control:a.control,name:"invite_user_email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.inviter_email")}),e.jsx(_,{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(b,{control:a.control,name:"password",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.password")}),e.jsx(_,{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(b,{control:a.control,name:"balance",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.balance")}),e.jsx(_,{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(b,{control:a.control,name:"commission_balance",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.commission_balance")}),e.jsx(_,{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(b,{control:a.control,name:"u",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.upload")}),e.jsx(_,{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(b,{control:a.control,name:"d",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.download")}),e.jsx(_,{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(b,{control:a.control,name:"transfer_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.total_traffic")}),e.jsx(_,{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(b,{control:a.control,name:"expired_at",render:({field:o})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:n("edit.form.expire_time")}),e.jsxs(ms,{open:c,onOpenChange:i,children:[e.jsx(us,{asChild:!0,children:e.jsx(_,{children:e.jsxs(R,{type:"button",variant:"outline",className:N("w-full pl-3 text-left font-normal",!o.value&&"text-muted-foreground"),onClick:()=>i(!0),children:[o.value?fe(o.value):e.jsx("span",{children:n("edit.form.expire_time_placeholder")}),e.jsx(ft,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(ls,{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(R,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{o.onChange(null),i(!1)},children:n("edit.form.expire_time_permanent")}),e.jsx(R,{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(R,{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(Ks,{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:fe(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(R,{type:"button",variant:"outline",onClick:()=>i(!1),children:n("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(E,{})]})}),e.jsx(b,{control:a.control,name:"plan_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.subscription")}),e.jsx(_,{children:e.jsxs(J,{value:o.value?o.value.toString():"null",onValueChange:d=>o.onChange(d==="null"?null:parseInt(d)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"null",children:n("edit.form.subscription_none")}),m.map(d=>e.jsx(q,{value:d.id.toString(),children:d.name},d.id))]})]})})]})}),e.jsx(b,{control:a.control,name:"banned",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.account_status")}),e.jsx(_,{children:e.jsxs(J,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(W,{children:e.jsx(Z,{})}),e.jsxs(Y,{children:[e.jsx(q,{value:"1",children:n("columns.status_text.banned")}),e.jsx(q,{value:"0",children:n("columns.status_text.normal")})]})]})})]})}),e.jsx(b,{control:a.control,name:"commission_type",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.commission_type")}),e.jsx(_,{children:e.jsxs(J,{value:o.value.toString(),onValueChange:d=>o.onChange(parseInt(d)),children:[e.jsx(W,{children:e.jsx(Z,{placeholder:n("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx(q,{value:"0",children:n("edit.form.commission_type_system")}),e.jsx(q,{value:"1",children:n("edit.form.commission_type_cycle")}),e.jsx(q,{value:"2",children:n("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(b,{control:a.control,name:"commission_rate",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.commission_rate")}),e.jsx(_,{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(b,{control:a.control,name:"discount",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.discount")}),e.jsx(_,{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(b,{control:a.control,name:"speed_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.speed_limit")}),e.jsx(_,{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(b,{control:a.control,name:"device_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.device_limit")}),e.jsx(_,{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(b,{control:a.control,name:"is_admin",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(U,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(b,{control:a.control,name:"is_staff",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(U,{checked:o.value===1,onCheckedChange:d=>o.onChange(d?1:0)})})})]})}),e.jsx(b,{control:a.control,name:"remarks",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:n("edit.form.remarks")}),e.jsx(_,{children:e.jsx(_s,{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(el,{children:[e.jsx(R,{variant:"outline",onClick:()=>r(!1),children:n("edit.form.cancel")}),e.jsx(R,{type:"submit",onClick:()=>{a.handleSubmit(o=>{Dd(o).then(({data:d})=>{d&&(A.success(n("edit.form.success")),r(!1),s())})})()},children:n("edit.form.submit")})]})]})}function tl({refetch:s,defaultValues:n,dialogTrigger:a=e.jsxs(R,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(pt,{className:"mr-2 h-4 w-4"}),t("edit.button")]})}){const{t:l}=F("user"),[r,c]=u.useState(!1);return e.jsx(Xx,{defaultValues:n,open:r,onOpenChange:c,children:e.jsxs(Jr,{open:r,onOpenChange:c,children:[e.jsx(Zr,{asChild:!0,children:a}),e.jsxs(Ia,{className:"max-w-[90%] space-y-4",children:[e.jsxs(Va,{children:[e.jsx(Fa,{children:l("edit.title")}),e.jsx(Ma,{})]}),e.jsx(sh,{refetch:s})]})]})})}const al=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"})}),nl=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"})}),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:"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"})}),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:"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"})}),Xt=[{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:fc(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(al,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:cs(s.original.u)})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(nl,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:cs(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:cs(n)})}}];function rl({user_id:s,dialogTrigger:n}){const{t:a}=F(["traffic"]),[l,r]=u.useState(!1),[c,i]=u.useState({pageIndex:0,pageSize:20}),{data:m,isLoading:x}=ne({queryKey:["userStats",s,c,l],queryFn:()=>l?Id({user_id:s,pageSize:c.pageSize,page:c.pageIndex+1}):null}),o=Ye({data:m?.data??[],columns:Xt,pageCount:Math.ceil((m?.total??0)/c.pageSize),state:{pagination:c},manualPagination:!0,getCoreRowModel:Qe(),onPaginationChange:i});return e.jsxs(ve,{open:l,onOpenChange:r,children:[e.jsx(He,{asChild:!0,children:n}),e.jsxs(pe,{className:"sm:max-w-[700px]",children:[e.jsx(Ne,{children:e.jsx(be,{children:a("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(ba,{children:[e.jsx(ya,{children:o.getHeaderGroups().map(d=>e.jsx(ks,{children:d.headers.map(p=>e.jsx(_a,{className:N("h-10 px-2 text-xs",p.id==="total"&&"text-right"),children:p.isPlaceholder?null:Tt(p.column.columnDef.header,p.getContext())},p.id))},d.id))}),e.jsx(Na,{children:x?Array.from({length:c.pageSize}).map((d,p)=>e.jsx(ks,{children:Array.from({length:Xt.length}).map((k,I)=>e.jsx(Ys,{className:"p-2",children:e.jsx(re,{className:"h-6 w-full"})},I))},p)):o.getRowModel().rows?.length?o.getRowModel().rows.map(d=>e.jsx(ks,{"data-state":d.getIsSelected()&&"selected",className:"h-10",children:d.getVisibleCells().map(p=>e.jsx(Ys,{className:"px-2",children:Tt(p.column.columnDef.cell,p.getContext())},p.id))},d.id)):e.jsx(ks,{children:e.jsx(Ys,{colSpan:Xt.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(J,{value:`${o.getState().pagination.pageSize}`,onValueChange:d=>{o.setPageSize(Number(d))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Z,{placeholder:o.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50].map(d=>e.jsx(q,{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(B,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.previousPage(),disabled:!o.getCanPreviousPage()||x,children:e.jsx(th,{className:"h-4 w-4"})}),e.jsx(B,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>o.nextPage(),disabled:!o.getCanNextPage()||x,children:e.jsx(ah,{className:"h-4 w-4"})})]})]})]})]})]})]})}function nh({onConfirm:s,children:n,title:a="确认操作",description:l="确定要执行此操作吗?",cancelText:r="取消",confirmText:c="确认",variant:i="default",className:m}){return e.jsxs(Mr,{children:[e.jsx(Or,{asChild:!0,children:n}),e.jsxs(wa,{className:N("sm:max-w-[425px]",m),children:[e.jsxs(Ca,{children:[e.jsx(ka,{children:a}),e.jsx(Ta,{children:l})]}),e.jsxs(Sa,{children:[e.jsx(Da,{asChild:!0,children:e.jsx(R,{variant:"outline",children:r})}),e.jsx(Pa,{asChild:!0,children:e.jsx(R,{variant:i,onClick:s,children:c})})]})]})]})}const 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:"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"})}),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:"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"})}),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:"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"})}),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:"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"})}),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:"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"})}),dh=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"})}),mh=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"})}),uh=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:"M20 6h-4V5a3 3 0 0 0-3-3h-2a3 3 0 0 0-3 3v1H4a1 1 0 0 0 0 2h1v11a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8h1a1 1 0 0 0 0-2M10 5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1h-4Zm7 14a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V8h10Z"})}),xh=(s,n)=>{const{t:a}=F("user");return[{accessorKey:"is_admin",header:({column:l})=>e.jsx(z,{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(z,{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(z,{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(z,{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 m=c?a("columns.online_status.online"):r===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:fe(r)});if(!c&&r!==0){const x=Math.floor(i/60),o=Math.floor(x/60),d=Math.floor(o/24);d>0?m+=` +`+a("columns.online_status.offline_duration.days",{count:d}):o>0?m+=` +`+a("columns.online_status.offline_duration.hours",{count:o}):x>0?m+=` +`+a("columns.online_status.offline_duration.minutes",{count:x}):m+=` +`+a("columns.online_status.offline_duration.seconds",{count:i})}return e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:N("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(oe,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:m})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:l})=>e.jsx(z,{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(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:N("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(oe,{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(z,{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:N("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(z,{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(z,{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:N("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(z,{column:l,title:a("columns.used_traffic")}),cell:({row:l})=>{const r=cs(l.original?.total_used),c=cs(l.original?.transfer_enable),i=l.original?.total_used/l.original?.transfer_enable*100||0;return e.jsx(xe,{delayDuration:100,children:e.jsxs(me,{children:[e.jsx(ue,{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:N("h-full rounded-full transition-all",i>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(i,100)}%`}})})]})}),e.jsx(oe,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",c]})})]})})}},{accessorKey:"transfer_enable",header:({column:l})=>e.jsx(z,{column:l,title:a("columns.total_traffic")}),cell:({row:l})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:cs(l.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:l})=>e.jsx(z,{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(z,{column:l,title:a("columns.balance")}),cell:({row:l})=>{const r=Ws(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(z,{column:l,title:a("columns.commission")}),cell:({row:l})=>{const r=Ws(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(z,{column:l,title:a("columns.register_time")}),cell:({row:l})=>e.jsx("div",{className:"truncate",children:fe(l.original?.created_at)}),size:1e3},{id:"actions",header:({column:l})=>e.jsx(z,{column:l,className:"justify-end",title:a("columns.actions")}),cell:({row:l,table:r})=>e.jsxs(Ds,{modal:!0,children:[e.jsx(Es,{asChild:!0,children:e.jsx("div",{className:"text-center",children:e.jsx(B,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":a("columns.actions"),children:e.jsx(Dt,{className:"size-4"})})})}),e.jsxs(gs,{align:"end",className:"min-w-[40px]",children:[e.jsx(ye,{onSelect:c=>{c.preventDefault()},className:"p-0",children:e.jsx(tl,{defaultValues:{...l.original,invite_user_email:l.original.invite_user?.email},refetch:s,dialogTrigger:e.jsxs(B,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(rh,{className:"mr-2"}),a("columns.actions_menu.edit")]})})}),e.jsx(ye,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(Wr,{defaultValues:{email:l.original.email},trigger:e.jsxs(B,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(lh,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(ye,{onSelect:()=>{Rt(l.original.subscribe_url).then(()=>{A.success(a("common:copy.success"))})},className:"p-0",children:e.jsxs(B,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(oh,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(ye,{onSelect:()=>{Ed({id:l.original.id}).then(({data:c})=>{c&&A.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(ih,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(ye,{onSelect:()=>{},className:"p-0",children:e.jsxs(Ls,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=${l.original?.id}`,children:[e.jsx(ch,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(ye,{onSelect:()=>{r.setColumnFilters([{id:"invite_user_id",value:l.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(dh,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(ye,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(rl,{user_id:l.original?.id,dialogTrigger:e.jsxs(B,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(mh,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(ye,{onSelect:c=>c.preventDefault(),className:"p-0",children:e.jsx(nh,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:l.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:c}=await tm.destroy(l.original.id);c&&(A.success(a("common:delete.success")),s())}catch{A.error(a("common:delete.failed"))}},children:e.jsxs(B,{variant:"ghost",className:"w-full justify-start px-2 py-1.5 text-destructive hover:text-destructive",children:[e.jsx(uh,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]};function hh(){const[s]=or(),[n,a]=u.useState({}),[l,r]=u.useState({is_admin:!1,is_staff:!1}),[c,i]=u.useState([]),[m,x]=u.useState([]),[o,d]=u.useState({pageIndex:0,pageSize:20});u.useEffect(()=>{const P=s.get("email");P&&i(L=>L.some(O=>O.id==="email")?L:[...L,{id:"email",value:P}])},[s]);const{refetch:p,data:k,isLoading:I}=ne({queryKey:["userList",o,c,m],queryFn:()=>Pd({pageSize:o.pageSize,current:o.pageIndex+1,filter:c,sort:m})}),[f,j]=u.useState([]),[C,g]=u.useState([]);u.useEffect(()=>{qt().then(({data:P})=>{j(P)}),Hs().then(({data:P})=>{g(P)})},[]);const w=f.map(P=>({label:P.name,value:P.id})),T=C.map(P=>({label:P.name,value:P.id})),S=Ye({data:k?.data??[],columns:xh(p),state:{sorting:m,columnVisibility:l,rowSelection:n,columnFilters:c,pagination:o},rowCount:k?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),onPaginationChange:d,getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),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(os,{table:S,toolbar:e.jsx(Jx,{table:S,refetch:p,serverGroupList:f,permissionGroups:w,subscriptionPlans:T})})}function fh(){const{t:s}=F("user");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(hh,{})})})]})]})}const ph=Object.freeze(Object.defineProperty({__proto__:null,default:fh},Symbol.toStringTag,{value:"Module"}));function gh({column:s,title:n,options:a}){const l=new Set(s?.getFilterValue());return e.jsxs(ms,{children:[e.jsx(us,{asChild:!0,children:e.jsxs(B,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(zi,{className:"mr-2 h-4 w-4"}),n,l?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(we,{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(ls,{className:"w-[200px] p-0",align:"start",children:e.jsxs(Rs,{children:[e.jsx($s,{placeholder:n}),e.jsxs(Is,{children:[e.jsx(qs,{children:"No results found."}),e.jsx($e,{children:a.map(r=>{const c=l.has(r.value);return e.jsxs(De,{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:N("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(Li,{className:N("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(et,{}),e.jsx($e,{children:e.jsx(De,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const jh=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 vh({table:s}){const{t:n}=F("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(va,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:a=>s.getColumn("status")?.setFilterValue(a),children:e.jsxs(Ht,{className:"grid w-full grid-cols-2",children:[e.jsx(Ts,{value:"0",children:n("status.pending")}),e.jsx(Ts,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(gh,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:Ie.LOW,icon:jh,color:"gray"},{label:n("level.medium"),value:Ie.MIDDLE,icon:al,color:"yellow"},{label:n("level.high"),value:Ie.HIGH,icon:nl,color:"red"}]})]})})}function bh(){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 yh=Os("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"}}),ll=u.forwardRef(({className:s,variant:n,layout:a,children:l,...r},c)=>e.jsx("div",{className:N(yh({variant:n,layout:a,className:s}),"relative group"),ref:c,...r,children:u.Children.map(l,i=>u.isValidElement(i)&&typeof i.type!="string"?u.cloneElement(i,{variant:n,layout:a}):i)}));ll.displayName="ChatBubble";const Nh=Os("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"}}),ol=u.forwardRef(({className:s,variant:n,layout:a,isLoading:l=!1,children:r,...c},i)=>e.jsx("div",{className:N(Nh({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(bh,{})}):r}));ol.displayName="ChatBubbleMessage";const _h=u.forwardRef(({variant:s,className:n,children:a,...l},r)=>e.jsx("div",{ref:r,className:N("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}));_h.displayName="ChatBubbleActionWrapper";const il=u.forwardRef(({className:s,...n},a)=>e.jsx(_s,{autoComplete:"off",ref:a,name:"message",className:N("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}));il.displayName="ChatInput";const cl=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"})}),dl=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"})}),rn=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 12l3.54-3.54a1 1 0 0 0 0-1.41a1 1 0 0 0-1.42 0l-4.24 4.24a1 1 0 0 0 0 1.42L13.41 17a1 1 0 0 0 .71.29a1 1 0 0 0 .71-.29a1 1 0 0 0 0-1.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.71 20.29L18 16.61A9 9 0 1 0 16.61 18l3.68 3.68a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.39M11 18a7 7 0 1 1 7-7a7 7 0 0 1-7 7"})}),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:"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"})}),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:"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 kh(){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(re,{className:"h-8 w-3/4"}),e.jsx(re,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(re,{className:"h-20 w-2/3"},s))})]})}function Th(){return e.jsx("div",{className:"space-y-4 p-4",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{className:"h-5 w-4/5"}),e.jsx(re,{className:"h-4 w-2/3"}),e.jsx(re,{className:"h-3 w-1/2"})]},s))})}function Ph({ticket:s,isActive:n,onClick:a}){const{t:l}=F("ticket"),r=c=>{switch(c){case Ie.HIGH:return"bg-red-50 text-red-600 border-red-200";case Ie.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case Ie.LOW:return"bg-green-50 text-green-600 border-green-200";default:return"bg-gray-50 text-gray-600 border-gray-200"}};return e.jsxs("div",{className:N("flex cursor-pointer flex-col border-b p-4 hover:bg-accent/50",n&&"bg-accent"),onClick:a,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 max-w-[280px]",children:[e.jsx("h4",{className:"truncate font-medium flex-1",children:s.subject}),e.jsx(K,{variant:s.status===Ps.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Ps.CLOSED?l("status.closed"):l("status.processing")})]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground truncate max-w-[280px]",children:s.user?.email}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-xs",children:[e.jsx("time",{className:"text-muted-foreground",children:fe(s.updated_at)}),e.jsx("div",{className:N("px-2 py-0.5 rounded-full border text-xs font-medium",r(s.level)),children:l(`level.${s.level===Ie.LOW?"low":s.level===Ie.MIDDLE?"medium":"high"}`)})]})]})}function Dh({ticketId:s,dialogTrigger:n}){const{t:a}=F("ticket"),l=js(),r=u.useRef(null),c=u.useRef(null),[i,m]=u.useState(!1),[x,o]=u.useState(""),[d,p]=u.useState(!1),[k,I]=u.useState(s),[f,j]=u.useState(""),[C,g]=u.useState(!1),{data:w,isLoading:T,refetch:S}=ne({queryKey:["tickets",i],queryFn:()=>i?Wt.getList({filter:[{id:"status",value:[Ps.OPENING]}]}):Promise.resolve(null),enabled:i}),{data:P,refetch:L,isLoading:G}=ne({queryKey:["ticket",k,i],queryFn:()=>i?Fd(k):Promise.resolve(null),refetchInterval:i?5e3:!1,retry:3}),O=P?.data,Je=(w?.data||[]).filter(te=>te.subject.toLowerCase().includes(f.toLowerCase())||te.user?.email.toLowerCase().includes(f.toLowerCase())),is=(te="smooth")=>{if(r.current){const{scrollHeight:Ue,clientHeight:st}=r.current;r.current.scrollTo({top:Ue-st,behavior:te})}};u.useEffect(()=>{if(!i)return;const te=requestAnimationFrame(()=>{is("instant"),setTimeout(()=>is(),1e3)});return()=>{cancelAnimationFrame(te)}},[i,O?.messages]);const Vs=async()=>{const te=x.trim();!te||d||(p(!0),Wt.reply({id:k,message:te}).then(()=>{o(""),L(),is(),setTimeout(()=>{c.current?.focus()},0)}).finally(()=>{p(!1)}))},ee=async()=>{Wt.close(k).then(()=>{A.success(a("actions.close_success")),L(),S()})},$=()=>{O?.user&&l("/finance/order?user_id="+O.user.id)},ae=O?.status===Ps.CLOSED;return e.jsxs(ve,{open:i,onOpenChange:m,children:[e.jsx(He,{asChild:!0,children:n??e.jsx(B,{variant:"outline",children:a("actions.view_ticket")})}),e.jsxs(pe,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(be,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(B,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 md:hidden z-50",onClick:()=>g(!C),children:e.jsx(rn,{className:N("h-4 w-4 transition-transform",!C&&"rotate-180")})}),e.jsxs("div",{className:N("absolute md:relative inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out",C?"-translate-x-full":"translate-x-0","w-80 md:w-80 md:translate-x-0"),children:[e.jsxs("div",{className:"space-y-4 border-b p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold",children:a("list.title")}),e.jsx(B,{variant:"ghost",size:"icon",className:"hidden md:flex h-8 w-8",onClick:()=>g(!C),children:e.jsx(rn,{className:N("h-4 w-4 transition-transform",!C&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(wh,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(D,{placeholder:a("list.search_placeholder"),value:f,onChange:te=>j(te.target.value),className:"pl-8"})]})]}),e.jsx(Zs,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:T?e.jsx(Th,{}):Je.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground p-4",children:a(f?"list.no_search_results":"list.no_tickets")}):Je.map(te=>e.jsx(Ph,{ticket:te,isActive:te.id===k,onClick:()=>{I(te.id),window.innerWidth<768&&g(!0)}},te.id))})})]}),e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[!C&&e.jsx("div",{className:"absolute inset-0 bg-black/20 z-30 md:hidden",onClick:()=>g(!0)}),G?e.jsx(kh,{}):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:O?.subject}),e.jsx(K,{variant:ae?"secondary":"default",children:a(ae?"status.closed":"status.processing")}),!ae&&e.jsx(qe,{title:a("actions.close_confirm_title"),description:a("actions.close_confirm_description"),confirmText:a("actions.close_confirm_button"),variant:"destructive",onConfirm:ee,children:e.jsxs(B,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(cl,{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(ht,{className:"h-4 w-4"}),e.jsx("span",{children:O?.user?.email})]}),e.jsx(we,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(dl,{className:"h-4 w-4"}),e.jsxs("span",{children:[a("detail.created_at")," ",fe(O?.created_at)]})]}),e.jsx(we,{orientation:"vertical",className:"h-4"}),e.jsx(K,{variant:"outline",children:O?.level!=null&&a(`level.${O.level===Ie.LOW?"low":O.level===Ie.MIDDLE?"medium":"high"}`)})]})]}),O?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(tl,{defaultValues:O.user,refetch:L,dialogTrigger:e.jsx(B,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.user_info"),children:e.jsx(ht,{className:"h-4 w-4"})})}),e.jsx(rl,{user_id:O.user.id,dialogTrigger:e.jsx(B,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.traffic_records"),children:e.jsx(Ch,{className:"h-4 w-4"})})}),e.jsx(B,{variant:"outline",size:"icon",className:"h-8 w-8",title:a("detail.order_records"),onClick:$,children:e.jsx(Sh,{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:O?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:a("detail.no_messages")}):O?.messages?.map(te=>e.jsx(ll,{variant:te.is_me?"sent":"received",className:te.is_me?"ml-auto":"mr-auto",children:e.jsx(ol,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:te.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:fe(te.created_at)})})]})})},te.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(il,{ref:c,disabled:ae||d,placeholder:a(ae?"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:x,onChange:te=>o(te.target.value),onKeyDown:te=>{te.key==="Enter"&&!te.shiftKey&&(te.preventDefault(),Vs())}}),e.jsx(B,{disabled:ae||d||!x.trim(),onClick:Vs,children:a(d?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const 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:"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"})}),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.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"})}),Ih=s=>{const{t:n}=F("ticket");return[{accessorKey:"id",header:({column:a})=>e.jsx(z,{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(z,{column:a,title:n("columns.subject")}),cell:({row:a})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Eh,{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(z,{column:a,title:n("columns.level")}),cell:({row:a})=>{const l=a.getValue("level"),r=l===Ie.LOW?"default":l===Ie.MIDDLE?"secondary":"destructive";return e.jsx(K,{variant:r,className:"whitespace-nowrap",children:n(`level.${l===Ie.LOW?"low":l===Ie.MIDDLE?"medium":"high"}`)})},filterFn:(a,l,r)=>r.includes(a.getValue(l))},{accessorKey:"status",header:({column:a})=>e.jsx(z,{column:a,title:n("columns.status")}),cell:({row:a})=>{const l=a.getValue("status"),r=a.original.reply_status,c=l===Ps.CLOSED?n("status.closed"):n(r===0?"status.replied":"status.pending"),i=l===Ps.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(z,{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(dl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:fe(a.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:a})=>e.jsx(z,{column:a,title:n("columns.created_at")}),cell:({row:a})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:fe(a.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:a})=>e.jsx(z,{className:"justify-end",column:a,title:n("columns.actions")}),cell:({row:a})=>{const l=a.original.status!==Ps.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Dh,{ticketId:a.original.id,dialogTrigger:e.jsx(B,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(Rh,{className:"h-4 w-4"})})}),l&&e.jsx(qe,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{Md(a.original.id).then(()=>{A.success(n("actions.close_success")),s()})},children:e.jsx(B,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.close_ticket"),children:e.jsx(cl,{className:"h-4 w-4"})})})]})}}]};function Vh(){const[s,n]=u.useState({}),[a,l]=u.useState({}),[r,c]=u.useState([{id:"status",value:"0"}]),[i,m]=u.useState([]),[x,o]=u.useState({pageIndex:0,pageSize:20}),{refetch:d,data:p,isLoading:k}=ne({queryKey:["orderList",x,r,i],queryFn:()=>Vd({pageSize:x.pageSize,current:x.pageIndex+1,filter:r,sort:i})}),I=Ye({data:p?.data??[],columns:Ih(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:m,onColumnFiltersChange:c,onColumnVisibilityChange:l,getCoreRowModel:Qe(),getFilteredRowModel:as(),getPaginationRowModel:ns(),onPaginationChange:o,getSortedRowModel:rs(),getFacetedRowModel:vs(),getFacetedUniqueValues:bs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(vh,{table:I,refetch:d}),e.jsx(os,{table:I,showPagination:!0})]})}function Fh(){const{t:s}=F("ticket");return e.jsxs(ke,{children:[e.jsxs(Te,{children:[e.jsx(ze,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(Fe,{}),e.jsx(Me,{})]})]}),e.jsxs(Re,{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(Vh,{})})]})]})}const Mh=Object.freeze(Object.defineProperty({__proto__:null,default:Fh},Symbol.toStringTag,{value:"Module"}));export{$h as a,Lh as c,Ah as g,qh as r}; diff --git a/public/assets/admin/locales/en-US.js b/public/assets/admin/locales/en-US.js index a7dc046..e78342a 100644 --- a/public/assets/admin/locales/en-US.js +++ b/public/assets/admin/locales/en-US.js @@ -188,7 +188,25 @@ window.XBOARD_TRANSLATIONS['en-US'] = { "install": "Install", "config": "Configure", "enable": "Enable", - "disable": "Disable" + "disable": "Disable", + "uninstall": "Uninstall" + }, + "upload": { + "button": "Upload Plugin", + "title": "Upload Plugin", + "description": "Upload a plugin package (.zip)", + "dragText": "Drag and drop plugin package here, or", + "clickText": "browse", + "supportText": "Supports .zip files only", + "uploading": "Uploading...", + "error": { + "format": "Only .zip files are supported" + } + }, + "delete": { + "title": "Delete Plugin", + "description": "Are you sure you want to delete this plugin? This action cannot be undone.", + "button": "Delete" }, "uninstall": { "title": "Uninstall Plugin", @@ -213,7 +231,11 @@ window.XBOARD_TRANSLATIONS['en-US'] = { "disableError": "Failed to disable plugin", "configLoadError": "Failed to load plugin configuration", "configSaveSuccess": "Configuration saved successfully", - "configSaveError": "Failed to save configuration" + "configSaveError": "Failed to save configuration", + "uploadSuccess": "Plugin uploaded successfully", + "uploadError": "Failed to upload plugin", + "deleteSuccess": "Plugin deleted successfully", + "deleteError": "Failed to delete plugin" } }, "settings": { diff --git a/public/assets/admin/locales/ko-KR.js b/public/assets/admin/locales/ko-KR.js index d540615..d15006f 100644 --- a/public/assets/admin/locales/ko-KR.js +++ b/public/assets/admin/locales/ko-KR.js @@ -188,7 +188,25 @@ window.XBOARD_TRANSLATIONS['ko-KR'] = { "install": "설치", "config": "설정", "enable": "활성화", - "disable": "비활성화" + "disable": "비활성화", + "uninstall": "제거" + }, + "upload": { + "button": "플러그인 업로드", + "title": "플러그인 업로드", + "description": "플러그인 패키지 업로드 (.zip)", + "dragText": "플러그인 패키지를 여기에 끌어다 놓거나", + "clickText": "찾아보기", + "supportText": ".zip 파일만 지원됩니다", + "uploading": "업로드 중...", + "error": { + "format": ".zip 파일만 지원됩니다" + } + }, + "delete": { + "title": "플러그인 삭제", + "description": "이 플러그인을 삭제하시겠습니까? 삭제 후 플러그인 데이터가 삭제됩니다.", + "button": "삭제" }, "uninstall": { "title": "플러그인 제거", @@ -213,7 +231,9 @@ window.XBOARD_TRANSLATIONS['ko-KR'] = { "disableError": "플러그인 비활성화에 실패했습니다", "configLoadError": "플러그인 설정을 불러오는데 실패했습니다", "configSaveSuccess": "설정이 성공적으로 저장되었습니다", - "configSaveError": "설정 저장에 실패했습니다" + "configSaveError": "설정 저장에 실패했습니다", + "uploadSuccess": "플러그인이 성공적으로 업로드되었습니다", + "uploadError": "플러그인 업로드에 실패했습니다" } }, "settings": { diff --git a/public/assets/admin/locales/zh-CN.js b/public/assets/admin/locales/zh-CN.js index fb9fa86..0a305c6 100644 --- a/public/assets/admin/locales/zh-CN.js +++ b/public/assets/admin/locales/zh-CN.js @@ -176,9 +176,9 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "other": "其他" }, "tabs": { - "all": "全部插件", + "all": "所有插件", "installed": "已安装", - "available": "可用插件" + "available": "可用" }, "status": { "enabled": "已启用", @@ -188,11 +188,29 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "install": "安装", "config": "配置", "enable": "启用", - "disable": "禁用" + "disable": "禁用", + "uninstall": "卸载" + }, + "upload": { + "button": "上传插件", + "title": "上传插件", + "description": "上传插件包 (.zip)", + "dragText": "拖拽插件包到此处,或", + "clickText": "浏览", + "supportText": "仅支持 .zip 格式文件", + "uploading": "上传中...", + "error": { + "format": "仅支持 .zip 格式文件" + } + }, + "delete": { + "title": "删除插件", + "description": "确定要删除此插件吗?此操作无法撤销。", + "button": "删除" }, "uninstall": { "title": "卸载插件", - "description": "确定要卸载该插件吗?卸载后插件数据将被清除。", + "description": "确定要卸载此插件吗?卸载后插件数据将被清除。", "button": "卸载" }, "config": { @@ -213,7 +231,11 @@ window.XBOARD_TRANSLATIONS['zh-CN'] = { "disableError": "插件禁用失败", "configLoadError": "加载插件配置失败", "configSaveSuccess": "配置保存成功", - "configSaveError": "配置保存失败" + "configSaveError": "配置保存失败", + "uploadSuccess": "插件上传成功", + "uploadError": "插件上传失败", + "deleteSuccess": "插件删除成功", + "deleteError": "插件删除失败" } }, "settings": { diff --git a/storage/tmp/.gitignore b/storage/tmp/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/storage/tmp/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file