diff --git a/public/assets/admin/assets/index.css b/public/assets/admin/assets/index.css
index e4f7b61..8c07487 100644
--- a/public/assets/admin/assets/index.css
+++ b/public/assets/admin/assets/index.css
@@ -1 +1 @@
-*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--header-height: 4rem;--background: 0 0% 100%;--foreground: 222.2 84% 4.9%;--card: 0 0% 100%;--card-foreground: 222.2 84% 4.9%;--popover: 0 0% 100%;--popover-foreground: 222.2 84% 4.9%;--primary: 222.2 47.4% 11.2%;--primary-foreground: 210 40% 98%;--secondary: 210 40% 96.1%;--secondary-foreground: 222.2 47.4% 11.2%;--muted: 210 40% 96.1%;--muted-foreground: 215.4 16.3% 46.9%;--accent: 210 40% 96.1%;--accent-foreground: 222.2 47.4% 11.2%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;--border: 214.3 31.8% 91.4%;--input: 214.3 31.8% 91.4%;--ring: 222.2 84% 4.9%;--radius: .5rem}.dark{--background: 222.2 84% 4.9%;--foreground: 210 40% 98%;--card: 222.2 84% 4.9%;--card-foreground: 210 40% 98%;--popover: 222.2 84% 4.9%;--popover-foreground: 210 40% 98%;--primary: 210 40% 98%;--primary-foreground: 222.2 47.4% 11.2%;--secondary: 217.2 32.6% 17.5%;--secondary-foreground: 210 40% 98%;--muted: 217.2 32.6% 17.5%;--muted-foreground: 215 20.2% 65.1%;--accent: 217.2 32.6% 17.5%;--accent-foreground: 210 40% 98%;--destructive: 0 62.8% 30.6%;--destructive-foreground: 210 40% 98%;--border: 217.2 32.6% 17.5%;--input: 217.2 32.6% 17.5%;--ring: 212.7 26.8% 83.9%}.collapsibleDropdown{overflow:hidden}.collapsibleDropdown[data-state=open]{animation:slideDown .2s ease-out}.collapsibleDropdown[data-state=closed]{animation:slideUp .2s ease-out}@keyframes slideDown{0%{height:0}to{height:var(--radix-collapsible-content-height)}}@keyframes slideUp{0%{height:var(--radix-collapsible-content-height)}to{height:0}}*{border-color:hsl(var(--border))}body{min-height:100svh;width:100%;background-color:hsl(var(--background));color:hsl(var(--foreground))}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media (min-width: 1400px){.container{max-width:1400px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.invisible{visibility:hidden}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.-left-1{left:-.25rem}.-right-1{right:-.25rem}.-right-5{right:-1.25rem}.-top-1{top:-.25rem}.-top-1\/2{top:-50%}.bottom-0{bottom:0}.bottom-5{bottom:1.25rem}.bottom-full{bottom:100%}.left-0{left:0}.left-1\/2{left:50%}.left-2{left:.5rem}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[50\%\]{left:50%}.right-0{right:0}.right-1{right:.25rem}.right-1\.5{right:.375rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-5{right:1.25rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-2\.5{top:.625rem}.top-4{top:1rem}.top-\[1px\]{top:1px}.top-\[50\%\]{top:50%}.top-\[60\%\]{top:60%}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[-1\]{z-index:-1}.z-\[1\]{z-index:1}.col-span-2{grid-column:span 2 / span 2}.col-span-3{grid-column:span 3 / span 3}.-m-0\.5{margin:-.125rem}.m-1{margin:.25rem}.m-auto{margin:auto}.-mx-1{margin-left:-.25rem;margin-right:-.25rem}.-mx-4{margin-left:-1rem;margin-right:-1rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-4{margin-top:1rem;margin-bottom:1rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.-ml-3{margin-left:-.75rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-8{margin-left:2rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-auto{margin-right:auto}.mt-0{margin-top:0}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-24{margin-top:6rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.\!table{display:table!important}.table{display:table}.grid{display:grid}.hidden{display:none}.aspect-\[16\/9\]{aspect-ratio:16/9}.aspect-square{aspect-ratio:1 / 1}.size-10{width:2.5rem;height:2.5rem}.size-2\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-\[--cell-size\]{width:var(--cell-size);height:var(--cell-size)}.h-0{height:0px}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-40{height:10rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-\[--cell-size\]{height:var(--cell-size)}.h-\[100vh\]{height:100vh}.h-\[180px\]{height:180px}.h-\[1px\]{height:1px}.h-\[200px\]{height:200px}.h-\[300px\]{height:300px}.h-\[400px\]{height:400px}.h-\[85vh\]{height:85vh}.h-\[90vh\]{height:90vh}.h-\[calc\(100\%-var\(--header-height\)\)\]{height:calc(100% - var(--header-height))}.h-\[calc\(100vh-280px\)\]{height:calc(100vh - 280px)}.h-\[var\(--header-height\)\]{height:var(--header-height)}.h-\[var\(--radix-navigation-menu-viewport-height\)\]{height:var(--radix-navigation-menu-viewport-height)}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.h-svh{height:100svh}.max-h-12{max-height:3rem}.max-h-96{max-height:24rem}.max-h-\[150px\]{max-height:150px}.max-h-\[200px\]{max-height:200px}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[95\%\]{max-height:95%}.max-h-\[calc\(85vh-120px\)\]{max-height:calc(85vh - 120px)}.min-h-10{min-height:2.5rem}.min-h-6{min-height:1.5rem}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[200px\]{min-height:200px}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.min-h-svh{min-height:100svh}.w-0{width:0px}.w-1\.5{width:.375rem}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-2\/3{width:66.666667%}.w-20{width:5rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-3\/4{width:75%}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-4\/5{width:80%}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-72{width:18rem}.w-8{width:2rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-\[--cell-size\]{width:var(--cell-size)}.w-\[100px\]{width:100px}.w-\[120px\]{width:120px}.w-\[140px\]{width:140px}.w-\[150px\]{width:150px}.w-\[180px\]{width:180px}.w-\[1px\]{width:1px}.w-\[200px\]{width:200px}.w-\[250px\]{width:250px}.w-\[300px\]{width:300px}.w-\[400px\]{width:400px}.w-\[50px\]{width:50px}.w-\[60px\]{width:60px}.w-\[70px\]{width:70px}.w-\[80px\]{width:80px}.w-\[9\.5rem\]{width:9.5rem}.w-auto{width:auto}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-20{min-width:5rem}.min-w-\[--cell-size\]{min-width:var(--cell-size)}.min-w-\[10em\]{min-width:10em}.min-w-\[200px\]{min-width:200px}.min-w-\[3rem\]{min-width:3rem}.min-w-\[40px\]{min-width:40px}.min-w-\[4rem\]{min-width:4rem}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.max-w-2xl{max-width:42rem}.max-w-32{max-width:8rem}.max-w-4xl{max-width:56rem}.max-w-52{max-width:13rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[150px\]{max-width:150px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[300px\]{max-width:300px}.max-w-\[500px\]{max-width:500px}.max-w-\[60\%\]{max-width:60%}.max-w-\[600px\]{max-width:600px}.max-w-\[90\%\]{max-width:90%}.max-w-\[90vw\]{max-width:90vw}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-max{max-width:-moz-max-content;max-width:max-content}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-\[1\.2\]{flex:1.2}.flex-\[1\]{flex:1}.flex-\[2\]{flex:2}.flex-\[4\]{flex:4}.flex-\[5\]{flex:5}.flex-none{flex:none}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-x-full{--tw-translate-x: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\[-50\%\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-full{--tw-translate-x: 100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-0{--tw-translate-y: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\[-50\%\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-help{cursor:help}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize{resize:both}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-\[100px_1fr\]{grid-template-columns:100px 1fr}.flex-row{flex-direction:row}.flex-row-reverse{flex-direction:row-reverse}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-1{-moz-column-gap:.25rem;column-gap:.25rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-2{row-gap:.5rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2\.5>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.625rem * var(--tw-space-x-reverse));margin-left:calc(.625rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-scroll{overflow-y:scroll}.overscroll-contain{overscroll-behavior:contain}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-wrap{text-wrap:wrap}.text-nowrap{text-wrap:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-\[inherit\]{border-radius:inherit}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:.75rem}.rounded-l-lg{border-top-left-radius:var(--radius);border-bottom-left-radius:var(--radius)}.rounded-l-md{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.rounded-l-none{border-top-left-radius:0;border-bottom-left-radius:0}.rounded-r-lg{border-top-right-radius:var(--radius);border-bottom-right-radius:var(--radius)}.rounded-r-md{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.rounded-r-none{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-t-\[10px\]{border-top-left-radius:10px;border-top-right-radius:10px}.rounded-bl-none{border-bottom-left-radius:0}.rounded-br-none{border-bottom-right-radius:0}.rounded-tl-lg{border-top-left-radius:var(--radius)}.rounded-tl-none{border-top-left-radius:0}.rounded-tl-sm{border-top-left-radius:calc(var(--radius) - 4px)}.rounded-tr-lg{border-top-right-radius:var(--radius)}.rounded-tr-none{border-top-right-radius:0}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-x-0{border-left-width:0px;border-right-width:0px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l{border-left-width:1px}.border-l-0{border-left-width:0px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-r-0{border-right-width:0px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-300{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.border-blue-500\/50{border-color:#3b82f680}.border-border{border-color:hsl(var(--border))}.border-border\/30{border-color:hsl(var(--border) / .3)}.border-border\/50{border-color:hsl(var(--border) / .5)}.border-destructive\/50{border-color:hsl(var(--destructive) / .5)}.border-emerald-200{--tw-border-opacity: 1;border-color:rgb(167 243 208 / var(--tw-border-opacity, 1))}.border-foreground\/10{border-color:hsl(var(--foreground) / .1)}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-indigo-200{--tw-border-opacity: 1;border-color:rgb(199 210 254 / var(--tw-border-opacity, 1))}.border-input{border-color:hsl(var(--input))}.border-muted{border-color:hsl(var(--muted))}.border-muted-foreground\/25{border-color:hsl(var(--muted-foreground) / .25)}.border-orange-200{--tw-border-opacity: 1;border-color:rgb(254 215 170 / var(--tw-border-opacity, 1))}.border-orange-500\/50{border-color:#f9731680}.border-primary{border-color:hsl(var(--primary))}.border-primary\/40{border-color:hsl(var(--primary) / .4)}.border-primary\/50{border-color:hsl(var(--primary) / .5)}.border-purple-200{--tw-border-opacity: 1;border-color:rgb(233 213 255 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-l-slate-500{--tw-border-opacity: 1;border-left-color:rgb(100 116 139 / var(--tw-border-opacity, 1))}.border-l-transparent{border-left-color:transparent}.border-r-muted{border-right-color:hsl(var(--muted))}.border-t-transparent{border-top-color:transparent}.bg-accent{background-color:hsl(var(--accent))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-background{background-color:hsl(var(--background))}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/20{background-color:#0003}.bg-black\/80{background-color:#000c}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-destructive\/15{background-color:hsl(var(--destructive) / .15)}.bg-destructive\/80{background-color:hsl(var(--destructive) / .8)}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\/80{background-color:#10b981cc}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-indigo-100{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1))}.bg-inherit{background-color:inherit}.bg-muted{background-color:hsl(var(--muted))}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-popover{background-color:hsl(var(--popover))}.bg-primary{background-color:hsl(var(--primary))}.bg-primary-foreground{background-color:hsl(var(--primary-foreground))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-primary\/20{background-color:hsl(var(--primary) / .2)}.bg-primary\/5{background-color:hsl(var(--primary) / .05)}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-secondary{background-color:hsl(var(--secondary))}.bg-secondary\/50{background-color:hsl(var(--secondary) / .5)}.bg-slate-100\/80{background-color:#f1f5f9cc}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-yellow-500{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.bg-yellow-500\/80{background-color:#eab308cc}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-background\/95{--tw-gradient-from: hsl(var(--background) / .95) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-background\/80{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .8) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-background\/60{--tw-gradient-to: hsl(var(--background) / .6) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-primary{fill:hsl(var(--primary))}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-\[1px\]{padding:1px}.px-0{padding-left:0;padding-right:0}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.px-\[--cell-size\]{padding-left:var(--cell-size);padding-right:var(--cell-size)}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-0\.5{padding-bottom:.125rem}.pb-16{padding-bottom:4rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-2{padding-left:.5rem}.pl-2\.5{padding-left:.625rem}.pl-3{padding-left:.75rem}.pl-6{padding-left:1.5rem}.pl-8{padding-left:2rem}.pl-9{padding-left:2.25rem}.pr-1{padding-right:.25rem}.pr-10{padding-right:2.5rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-2\.5{padding-right:.625rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-7{padding-right:1.75rem}.pr-8{padding-right:2rem}.pr-9{padding-right:2.25rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\.5{padding-top:.375rem}.pt-16{padding-top:4rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[0\.625rem\]{font-size:.625rem}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.8rem\]{font-size:.8rem}.text-\[10px\]{font-size:10px}.text-\[7rem\]{font-size:7rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-10{line-height:2.5rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-widest{letter-spacing:.1em}.text-accent-foreground{color:hsl(var(--accent-foreground))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-current{color:currentColor}.text-destructive{color:hsl(var(--destructive))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-emerald-500{--tw-text-opacity: 1;color:rgb(16 185 129 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(6 95 70 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--foreground))}.text-foreground\/70{color:hsl(var(--foreground) / .7)}.text-foreground\/90{color:hsl(var(--foreground) / .9)}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-indigo-800{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-muted-foreground\/30{color:hsl(var(--muted-foreground) / .3)}.text-muted-foreground\/40{color:hsl(var(--muted-foreground) / .4)}.text-muted-foreground\/50{color:hsl(var(--muted-foreground) / .5)}.text-muted-foreground\/70{color:hsl(var(--muted-foreground) / .7)}.text-orange-500{--tw-text-opacity: 1;color:rgb(249 115 22 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-orange-800{--tw-text-opacity: 1;color:rgb(154 52 18 / var(--tw-text-opacity, 1))}.text-popover-foreground{color:hsl(var(--popover-foreground))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-primary\/90{color:hsl(var(--primary) / .9)}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--secondary-foreground))}.text-slate-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.underline-offset-4{text-underline-offset:4px}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-destructive\/50{--tw-shadow-color: hsl(var(--destructive) / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-500\/50{--tw-shadow-color: rgb(16 185 129 / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-yellow-500\/50{--tw-shadow-color: rgb(234 179 8 / .5);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-0{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(229 231 235 / var(--tw-ring-opacity, 1))}.ring-gray-300\/20{--tw-ring-color: rgb(209 213 219 / .2)}.ring-green-500\/20{--tw-ring-color: rgb(34 197 94 / .2)}.ring-primary\/20{--tw-ring-color: hsl(var(--primary) / .2)}.ring-offset-2{--tw-ring-offset-width: 2px}.ring-offset-background{--tw-ring-offset-color: hsl(var(--background))}.ring-offset-white{--tw-ring-offset-color: #fff}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[1px\]{--tw-backdrop-blur: blur(1px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[max-height\,padding\]{transition-property:max-height,padding;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[opacity\]{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.delay-100{transition-delay:.1s}.delay-150{transition-delay:.15s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.duration-700{transition-duration:.7s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.duration-500{animation-duration:.5s}.duration-700{animation-duration:.7s}.delay-100{animation-delay:.1s}.delay-150{animation-delay:.15s}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.\[--cell-size\:2rem\]{--cell-size: 2rem}html{overflow-y:scroll}.sticky{position:sticky!important;z-index:2;background-color:hsl(var(--card))}.sticky.before\:right-0:before,.sticky.before\:left-0:before{content:"";position:absolute;top:0;bottom:0;width:2px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent);opacity:1;transition:opacity .3s ease}.sticky.before\:right-0:before{right:-1px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent)}.sticky.before\:right-0:after{content:"";position:absolute;top:0;right:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to right,rgba(0,0,0,.05),transparent)}.sticky.before\:left-0:before{left:-1px;background:linear-gradient(to left,rgba(0,0,0,.08),transparent)}.sticky.before\:left-0:after{content:"";position:absolute;top:0;left:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to left,rgba(0,0,0,.05),transparent)}.sticky:hover:before{opacity:.8}.dark .sticky.before\:right-0:before,.dark .sticky.before\:left-0:before{background:linear-gradient(to right,rgba(255,255,255,.05),transparent)}.dark .sticky.before\:right-0:after,.dark .sticky.before\:left-0:after{background:linear-gradient(to right,rgba(255,255,255,.03),transparent)}.\*\:\!inline-block>*{display:inline-block!important}.file\:border-0::file-selector-button{border-width:0px}.file\:bg-transparent::file-selector-button{background-color:transparent}.file\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\:font-medium::file-selector-button{font-weight:500}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:bottom-0:before{content:var(--tw-content);bottom:0}.before\:left-0:before{content:var(--tw-content);left:0}.before\:right-0:before{content:var(--tw-content);right:0}.before\:top-0:before{content:var(--tw-content);top:0}.before\:w-\[1px\]:before{content:var(--tw-content);width:1px}.before\:bg-border:before{content:var(--tw-content);background-color:hsl(var(--border))}.after\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:inset-y-0:after{content:var(--tw-content);top:0;bottom:0}.after\:bottom-0:after{content:var(--tw-content);bottom:0}.after\:left-0:after{content:var(--tw-content);left:0}.after\:left-1\/2:after{content:var(--tw-content);left:50%}.after\:hidden:after{content:var(--tw-content);display:none}.after\:h-32:after{content:var(--tw-content);height:8rem}.after\:w-1:after{content:var(--tw-content);width:.25rem}.after\:w-full:after{content:var(--tw-content);width:100%}.after\:-translate-x-1\/2:after{content:var(--tw-content);--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.after\:bg-\[linear-gradient\(180deg\,_transparent_10\%\,_hsl\(var\(--background\)\)_70\%\)\]:after{content:var(--tw-content);background-image:linear-gradient(180deg,transparent 10%,hsl(var(--background)) 70%)}.focus-within\:ring-1:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-ring:focus-within{--tw-ring-color: hsl(var(--ring))}.hover\:-translate-y-1:hover{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:rotate-180:hover{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-accent\/50:hover{background-color:hsl(var(--accent) / .5)}.hover\:bg-background:hover{background-color:hsl(var(--background))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-200:hover{--tw-bg-opacity: 1;background-color:rgb(191 219 254 / var(--tw-bg-opacity, 1))}.hover\:bg-card\/80:hover{background-color:hsl(var(--card) / .8)}.hover\:bg-destructive\/10:hover{background-color:hsl(var(--destructive) / .1)}.hover\:bg-destructive\/25:hover{background-color:hsl(var(--destructive) / .25)}.hover\:bg-destructive\/80:hover{background-color:hsl(var(--destructive) / .8)}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-inherit:hover{background-color:inherit}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-muted\/40:hover{background-color:hsl(var(--muted) / .4)}.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted) / .5)}.hover\:bg-muted\/60:hover{background-color:hsl(var(--muted) / .6)}.hover\:bg-muted\/70:hover{background-color:hsl(var(--muted) / .7)}.hover\:bg-orange-100:hover{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.hover\:bg-primary\/10:hover{background-color:hsl(var(--primary) / .1)}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-secondary-foreground\/10:hover{background-color:hsl(var(--secondary-foreground) / .1)}.hover\:bg-secondary\/70:hover{background-color:hsl(var(--secondary) / .7)}.hover\:bg-secondary\/80:hover{background-color:hsl(var(--secondary) / .8)}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-200\/80:hover{background-color:#e2e8f0cc}.hover\:bg-transparent:hover{background-color:transparent}.hover\:bg-yellow-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.hover\:bg-opacity-80:hover{--tw-bg-opacity: .8}.hover\:text-accent-foreground:hover{color:hsl(var(--accent-foreground))}.hover\:text-destructive:hover{color:hsl(var(--destructive))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:text-foreground\/70:hover{color:hsl(var(--foreground) / .7)}.hover\:text-muted-foreground:hover{color:hsl(var(--muted-foreground))}.hover\:text-primary:hover{color:hsl(var(--primary))}.hover\:text-primary\/80:hover{color:hsl(var(--primary) / .8)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-black\/30:hover{--tw-shadow-color: rgb(0 0 0 / .3);--tw-shadow: var(--tw-shadow-colored)}.hover\:ring-primary:hover{--tw-ring-color: hsl(var(--primary))}.focus\:z-10:focus{z-index:10}.focus\:bg-accent:focus{background-color:hsl(var(--accent))}.focus\:text-accent-foreground:focus{color:hsl(var(--accent-foreground))}.focus\:text-destructive:focus{color:hsl(var(--destructive))}.focus\:text-red-600:focus{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-red-600:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(220 38 38 / var(--tw-ring-opacity, 1))}.focus\:ring-ring:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-primary:focus-visible{--tw-ring-color: hsl(var(--primary))}.focus-visible\:ring-red-500:focus-visible{--tw-ring-opacity: 1;--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity, 1))}.focus-visible\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--ring))}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width: 1px}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.focus-visible\:ring-offset-background:focus-visible{--tw-ring-offset-color: hsl(var(--background))}.active\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:via-background\/90{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .9) var(--tw-gradient-via-position), var(--tw-gradient-to)}.group:hover .group-hover\:to-background\/70{--tw-gradient-to: hsl(var(--background) / .7) var(--tw-gradient-to-position)}.group\/id:hover .group-hover\/id\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:justify-center{justify-content:center}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:px-2{padding-left:.5rem;padding-right:.5rem}.peer:disabled~.peer-disabled\:cursor-not-allowed{cursor:not-allowed}.peer:disabled~.peer-disabled\:opacity-70{opacity:.7}.has-\[\:focus-visible\]\:outline-none:has(:focus-visible){outline:2px solid transparent;outline-offset:2px}.has-\[\:focus-visible\]\:ring-1:has(:focus-visible){--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.has-\[\:focus-visible\]\:ring-neutral-950:has(:focus-visible){--tw-ring-opacity: 1;--tw-ring-color: rgb(10 10 10 / var(--tw-ring-opacity, 1))}.aria-disabled\:opacity-50[aria-disabled=true]{opacity:.5}.aria-selected\:bg-accent[aria-selected=true]{background-color:hsl(var(--accent))}.aria-selected\:text-accent-foreground[aria-selected=true]{color:hsl(var(--accent-foreground))}.aria-selected\:text-muted-foreground[aria-selected=true]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[panel-group-direction\=vertical\]\:h-px[data-panel-group-direction=vertical]{height:1px}.data-\[panel-group-direction\=vertical\]\:w-full[data-panel-group-direction=vertical]{width:100%}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=left\]\:-translate-x-1[data-side=left]{--tw-translate-x: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=right\]\:translate-x-1[data-side=right]{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=top\]\:-translate-y-1[data-side=top]{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x: 1rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes accordion-up{0%{height:var(--radix-accordion-content-height)}to{height:0}}.data-\[state\=closed\]\:animate-accordion-up[data-state=closed]{animation:accordion-up .2s ease-out}@keyframes accordion-down{0%{height:0}to{height:var(--radix-accordion-content-height)}}.data-\[state\=open\]\:animate-accordion-down[data-state=open]{animation:accordion-down .2s ease-out}.data-\[state\=dragging\]\:cursor-grabbing[data-state=dragging]{cursor:grabbing}.data-\[panel-group-direction\=vertical\]\:flex-col[data-panel-group-direction=vertical]{flex-direction:column}.data-\[range-end\=true\]\:rounded-md[data-range-end=true]{border-radius:calc(var(--radius) - 2px)}.data-\[range-middle\=true\]\:rounded-none[data-range-middle=true]{border-radius:0}.data-\[range-start\=true\]\:rounded-md[data-range-start=true]{border-radius:calc(var(--radius) - 2px)}.data-\[selected\=true\]\:rounded-none[data-selected=true]{border-radius:0}.data-\[active\]\:bg-accent\/50[data-active]{background-color:hsl(var(--accent) / .5)}.data-\[disabled\]\:bg-muted-foreground[data-disabled],.data-\[fixed\]\:bg-muted-foreground[data-fixed]{background-color:hsl(var(--muted-foreground))}.data-\[range-end\=true\]\:bg-primary[data-range-end=true]{background-color:hsl(var(--primary))}.data-\[range-middle\=true\]\:bg-accent[data-range-middle=true]{background-color:hsl(var(--accent))}.data-\[range-start\=true\]\:bg-primary[data-range-start=true],.data-\[selected-single\=true\]\:bg-primary[data-selected-single=true]{background-color:hsl(var(--primary))}.data-\[state\=active\]\:bg-background[data-state=active]{background-color:hsl(var(--background))}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:hsl(var(--primary))}.data-\[state\=open\]\:bg-accent[data-state=open]{background-color:hsl(var(--accent))}.data-\[state\=open\]\:bg-accent\/50[data-state=open]{background-color:hsl(var(--accent) / .5)}.data-\[state\=open\]\:bg-secondary[data-state=open]{background-color:hsl(var(--secondary))}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:hsl(var(--muted))}.data-\[state\=unchecked\]\:bg-input[data-state=unchecked]{background-color:hsl(var(--input))}.data-\[collapsed\=true\]\:py-2[data-collapsed=true]{padding-top:.5rem;padding-bottom:.5rem}.data-\[disabled\]\:text-muted[data-disabled],.data-\[fixed\]\:text-muted[data-fixed]{color:hsl(var(--muted))}.data-\[range-end\=true\]\:text-primary-foreground[data-range-end=true]{color:hsl(var(--primary-foreground))}.data-\[range-middle\=true\]\:text-accent-foreground[data-range-middle=true]{color:hsl(var(--accent-foreground))}.data-\[range-start\=true\]\:text-primary-foreground[data-range-start=true],.data-\[selected-single\=true\]\:text-primary-foreground[data-selected-single=true]{color:hsl(var(--primary-foreground))}.data-\[state\=active\]\:text-foreground[data-state=active]{color:hsl(var(--foreground))}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:hsl(var(--primary-foreground))}.data-\[state\=open\]\:text-muted-foreground[data-state=open]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{transition-duration:.3s}.data-\[motion\^\=from-\]\:animate-in[data-motion^=from-],.data-\[state\=open\]\:animate-in[data-state=open],.data-\[state\=visible\]\:animate-in[data-state=visible]{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.data-\[motion\^\=to-\]\:animate-out[data-motion^=to-],.data-\[state\=closed\]\:animate-out[data-state=closed],.data-\[state\=hidden\]\:animate-out[data-state=hidden]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\[motion\^\=from-\]\:fade-in[data-motion^=from-]{--tw-enter-opacity: 0}.data-\[motion\^\=to-\]\:fade-out[data-motion^=to-],.data-\[state\=closed\]\:fade-out-0[data-state=closed],.data-\[state\=hidden\]\:fade-out[data-state=hidden]{--tw-exit-opacity: 0}.data-\[state\=open\]\:fade-in-0[data-state=open],.data-\[state\=visible\]\:fade-in[data-state=visible]{--tw-enter-opacity: 0}.data-\[state\=closed\]\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\[state\=open\]\:zoom-in-90[data-state=open]{--tw-enter-scale: .9}.data-\[state\=open\]\:zoom-in-95[data-state=open]{--tw-enter-scale: .95}.data-\[motion\=from-end\]\:slide-in-from-right-52[data-motion=from-end]{--tw-enter-translate-x: 13rem}.data-\[motion\=from-start\]\:slide-in-from-left-52[data-motion=from-start]{--tw-enter-translate-x: -13rem}.data-\[motion\=to-end\]\:slide-out-to-right-52[data-motion=to-end]{--tw-exit-translate-x: 13rem}.data-\[motion\=to-start\]\:slide-out-to-left-52[data-motion=to-start]{--tw-exit-translate-x: -13rem}.data-\[side\=bottom\]\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.data-\[state\=closed\]\:slide-out-to-bottom[data-state=closed]{--tw-exit-translate-y: 100%}.data-\[state\=closed\]\:slide-out-to-left[data-state=closed]{--tw-exit-translate-x: -100%}.data-\[state\=closed\]\:slide-out-to-left-1\/2[data-state=closed]{--tw-exit-translate-x: -50%}.data-\[state\=closed\]\:slide-out-to-right[data-state=closed]{--tw-exit-translate-x: 100%}.data-\[state\=closed\]\:slide-out-to-top[data-state=closed]{--tw-exit-translate-y: -100%}.data-\[state\=closed\]\:slide-out-to-top-\[48\%\][data-state=closed]{--tw-exit-translate-y: -48%}.data-\[state\=open\]\:slide-in-from-bottom[data-state=open]{--tw-enter-translate-y: 100%}.data-\[state\=open\]\:slide-in-from-left[data-state=open]{--tw-enter-translate-x: -100%}.data-\[state\=open\]\:slide-in-from-left-1\/2[data-state=open]{--tw-enter-translate-x: -50%}.data-\[state\=open\]\:slide-in-from-right[data-state=open]{--tw-enter-translate-x: 100%}.data-\[state\=open\]\:slide-in-from-top[data-state=open]{--tw-enter-translate-y: -100%}.data-\[state\=open\]\:slide-in-from-top-\[48\%\][data-state=open]{--tw-enter-translate-y: -48%}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{animation-duration:.3s}.data-\[panel-group-direction\=vertical\]\:after\:left-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);left:0}.data-\[panel-group-direction\=vertical\]\:after\:h-1[data-panel-group-direction=vertical]:after{content:var(--tw-content);height:.25rem}.data-\[panel-group-direction\=vertical\]\:after\:w-full[data-panel-group-direction=vertical]:after{content:var(--tw-content);width:100%}.data-\[panel-group-direction\=vertical\]\:after\:-translate-y-1\/2[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[panel-group-direction\=vertical\]\:after\:translate-x-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[disabled\]\:hover\:bg-muted-foreground:hover[data-disabled],.data-\[fixed\]\:hover\:bg-muted-foreground:hover[data-fixed]{background-color:hsl(var(--muted-foreground))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:relative{position:relative}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:z-10{z-index:10}.group[data-state=open] .group-data-\[state\=\"open\"\]\:-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group[data-state=open] .group-data-\[state\=open\]\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:border-ring{border-color:hsl(var(--ring))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-\[3px\]{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-ring\/50{--tw-ring-color: hsl(var(--ring) / .5)}.dark\:border-amber-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(120 53 15 / var(--tw-border-opacity, 1))}.dark\:border-blue-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(29 78 216 / var(--tw-border-opacity, 1))}.dark\:border-blue-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(30 58 138 / var(--tw-border-opacity, 1))}.dark\:border-gray-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.dark\:border-red-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(127 29 29 / var(--tw-border-opacity, 1))}.dark\:border-yellow-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(113 63 18 / var(--tw-border-opacity, 1))}.dark\:bg-amber-950\/30:is(.dark *){background-color:#451a034d}.dark\:bg-blue-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950\/30:is(.dark *){background-color:#1725544d}.dark\:bg-gray-800\/50:is(.dark *){background-color:#1f293780}.dark\:bg-green-500\/10:is(.dark *){background-color:#22c55e1a}.dark\:bg-red-500\/10:is(.dark *){background-color:#ef44441a}.dark\:bg-red-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-950\/30:is(.dark *){background-color:#450a0a4d}.dark\:bg-yellow-500\/10:is(.dark *){background-color:#eab3081a}.dark\:bg-yellow-950\/30:is(.dark *){background-color:#4220064d}.dark\:text-amber-200:is(.dark *){--tw-text-opacity: 1;color:rgb(253 230 138 / var(--tw-text-opacity, 1))}.dark\:text-blue-300:is(.dark *){--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity, 1))}.dark\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.dark\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-300:is(.dark *){--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-yellow-300:is(.dark *){--tw-text-opacity: 1;color:rgb(253 224 71 / var(--tw-text-opacity, 1))}.dark\:text-yellow-400:is(.dark *){--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}.dark\:ring-gray-700:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity, 1))}.dark\:ring-gray-800:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(31 41 55 / var(--tw-ring-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::-moz-placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:hover\:bg-blue-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-blue-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:hover\:text-red-400:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:has-\[\:focus-visible\]\:ring-neutral-300:has(:focus-visible):is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(212 212 212 / var(--tw-ring-opacity, 1))}@media (min-width: 640px){.sm\:absolute{position:absolute}.sm\:inset-auto{inset:auto}.sm\:bottom-\[calc\(100\%\+10px\)\]{bottom:calc(100% + 10px)}.sm\:left-0{left:0}.sm\:right-0{right:0}.sm\:my-0{margin-top:0;margin-bottom:0}.sm\:my-4{margin-top:1rem;margin-bottom:1rem}.sm\:mt-0{margin-top:0}.sm\:mt-6{margin-top:1.5rem}.sm\:block{display:block}.sm\:hidden{display:none}.sm\:h-\[80vh\]{height:80vh}.sm\:h-full{height:100%}.sm\:max-h-\[500px\]{max-height:500px}.sm\:max-h-\[600px\]{max-height:600px}.sm\:max-h-\[700px\]{max-height:700px}.sm\:max-h-\[800px\]{max-height:800px}.sm\:w-48{width:12rem}.sm\:w-\[350px\]{width:350px}.sm\:w-\[540px\]{width:540px}.sm\:w-\[90vw\]{width:90vw}.sm\:w-auto{width:auto}.sm\:w-full{width:100%}.sm\:max-w-72{max-width:18rem}.sm\:max-w-\[1025px\]{max-width:1025px}.sm\:max-w-\[425px\]{max-width:425px}.sm\:max-w-\[500px\]{max-width:500px}.sm\:max-w-\[700px\]{max-width:700px}.sm\:max-w-lg{max-width:32rem}.sm\:max-w-md{max-width:28rem}.sm\:max-w-sm{max-width:24rem}.sm\:max-w-xl{max-width:36rem}.sm\:translate-y-5{--tw-translate-y: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-end{justify-content:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:gap-0{gap:0px}.sm\:gap-6{gap:1.5rem}.sm\:space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:rounded-lg{border-radius:var(--radius)}.sm\:p-6{padding:1.5rem}.sm\:text-left{text-align:left}.sm\:text-2xl{font-size:1.5rem;line-height:2rem}.sm\:text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width: 768px){.md\:absolute{position:absolute}.md\:relative{position:relative}.md\:bottom-0{bottom:0}.md\:right-8{right:2rem}.md\:right-auto{right:auto}.md\:top-8{top:2rem}.md\:col-span-1{grid-column:span 1 / span 1}.md\:mb-2{margin-bottom:.5rem}.md\:ml-14{margin-left:3.5rem}.md\:ml-64{margin-left:16rem}.md\:mt-2{margin-top:.5rem}.md\:block{display:block}.md\:flex{display:flex}.md\:inline-flex{display:inline-flex}.md\:hidden{display:none}.md\:h-full{height:100%}.md\:h-svh{height:100svh}.md\:w-14{width:3.5rem}.md\:w-32{width:8rem}.md\:w-64{width:16rem}.md\:w-80{width:20rem}.md\:w-\[420px\]{width:420px}.md\:w-\[var\(--radix-navigation-menu-viewport-width\)\]{width:var(--radix-navigation-menu-viewport-width)}.md\:w-auto{width:auto}.md\:max-w-\[31rem\]{max-width:31rem}.md\:translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.md\:overflow-y-hidden{overflow-y:hidden}.md\:border-none{border-style:none}.md\:px-4{padding-left:1rem;padding-right:1rem}.md\:px-8{padding-left:2rem;padding-right:2rem}.md\:py-2{padding-top:.5rem;padding-bottom:.5rem}.md\:pt-0{padding-top:0}.md\:text-2xl{font-size:1.5rem;line-height:2rem}.md\:text-3xl{font-size:1.875rem;line-height:2.25rem}.md\:opacity-0{opacity:0}.after\:md\:block:after{content:var(--tw-content);display:block}}@media (min-width: 1024px){.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:w-1\/5{width:20%}.lg\:w-\[250px\]{width:250px}.lg\:max-w-none{max-width:none}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:flex-col{flex-direction:column}.lg\:gap-8{gap:2rem}.lg\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(0px * var(--tw-space-x-reverse));margin-left:calc(0px * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-x-12>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(3rem * var(--tw-space-x-reverse));margin-left:calc(3rem * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.lg\:space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.lg\:p-8{padding:2rem}.lg\:px-0{padding-left:0;padding-right:0}.lg\:px-3{padding-left:.75rem;padding-right:.75rem}}@media (min-width: 1280px){.xl\:mr-2{margin-right:.5rem}.xl\:flex{display:flex}.xl\:inline-flex{display:inline-flex}.xl\:h-10{height:2.5rem}.xl\:w-60{width:15rem}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:justify-start{justify-content:flex-start}.xl\:px-3{padding-left:.75rem;padding-right:.75rem}.xl\:py-2{padding-top:.5rem;padding-bottom:.5rem}}.\[\&\:\:-webkit-calendar-picker-indicator\]\:hidden::-webkit-calendar-picker-indicator{display:none}.\[\&\:first-child\[data-selected\=true\]_button\]\:rounded-l-md:first-child[data-selected=true] button{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\&\:last-child\[data-selected\=true\]_button\]\:rounded-r-md:last-child[data-selected=true] button{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y: 2px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\>span\]\:line-clamp-1>span{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\[\&\>span\]\:text-xs>span{font-size:.75rem;line-height:1rem}.\[\&\>span\]\:opacity-70>span{opacity:.7}.\[\&\>svg\]\:size-3\.5>svg{width:.875rem;height:.875rem}.\[\&\>svg\]\:text-muted-foreground>svg{color:hsl(var(--muted-foreground))}.\[\&\>tr\]\:last\:border-b-0:last-child>tr{border-bottom-width:0px}.\[\&\[data-panel-group-direction\=vertical\]\>div\]\:rotate-90[data-panel-group-direction=vertical]>div{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\[data-state\=open\]\>svg\]\:rotate-180[data-state=open]>svg{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&_\[cmdk-group-heading\]\]\:px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-group-heading\]\]\:py-1\.5 [cmdk-group-heading]{padding-top:.375rem;padding-bottom:.375rem}.\[\&_\[cmdk-group-heading\]\]\:text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\[\&_\[cmdk-group-heading\]\]\:font-medium [cmdk-group-heading]{font-weight:500}.\[\&_\[cmdk-group-heading\]\]\:text-muted-foreground [cmdk-group-heading]{color:hsl(var(--muted-foreground))}.\[\&_\[cmdk-group\]\:not\(\[hidden\]\)_\~\[cmdk-group\]\]\:pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\[\&_\[cmdk-group\]\]\:px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\[\&_\[cmdk-input\]\]\:h-12 [cmdk-input]{height:3rem}.\[\&_\[cmdk-item\]\]\:px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-item\]\]\:py-3 [cmdk-item]{padding-top:.75rem;padding-bottom:.75rem}.\[\&_\[cmdk-item\]_svg\]\:h-5 [cmdk-item] svg{height:1.25rem}.\[\&_\[cmdk-item\]_svg\]\:w-5 [cmdk-item] svg{width:1.25rem}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:invisible svg{visibility:hidden}.\[\&_svg\]\:size-4 svg{width:1rem;height:1rem}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-width:0px}.\[\&_tr\]\:border-b tr{border-bottom-width:1px}[data-slot=card-content] .\[\[data-slot\=card-content\]_\&\]\:bg-transparent,[data-slot=popover-content] .\[\[data-slot\=popover-content\]_\&\]\:bg-transparent{background-color:transparent}html.dark .markdown-body{color-scheme:dark;--color-prettylights-syntax-comment: #8b949e;--color-prettylights-syntax-constant: #79c0ff;--color-prettylights-syntax-entity: #d2a8ff;--color-prettylights-syntax-storage-modifier-import: #c9d1d9;--color-prettylights-syntax-entity-tag: #7ee787;--color-prettylights-syntax-keyword: #ff7b72;--color-prettylights-syntax-string: #a5d6ff;--color-prettylights-syntax-variable: #ffa657;--color-prettylights-syntax-brackethighlighter-unmatched: #f85149;--color-prettylights-syntax-invalid-illegal-text: #f0f6fc;--color-prettylights-syntax-invalid-illegal-bg: #8e1519;--color-prettylights-syntax-carriage-return-text: #f0f6fc;--color-prettylights-syntax-carriage-return-bg: #b62324;--color-prettylights-syntax-string-regexp: #7ee787;--color-prettylights-syntax-markup-list: #f2cc60;--color-prettylights-syntax-markup-heading: #1f6feb;--color-prettylights-syntax-markup-italic: #c9d1d9;--color-prettylights-syntax-markup-bold: #c9d1d9;--color-prettylights-syntax-markup-deleted-text: #ffdcd7;--color-prettylights-syntax-markup-deleted-bg: #67060c;--color-prettylights-syntax-markup-inserted-text: #aff5b4;--color-prettylights-syntax-markup-inserted-bg: #033a16;--color-prettylights-syntax-markup-changed-text: #ffdfb6;--color-prettylights-syntax-markup-changed-bg: #5a1e02;--color-prettylights-syntax-markup-ignored-text: #c9d1d9;--color-prettylights-syntax-markup-ignored-bg: #1158c7;--color-prettylights-syntax-meta-diff-range: #d2a8ff;--color-prettylights-syntax-brackethighlighter-angle: #8b949e;--color-prettylights-syntax-sublimelinter-gutter-mark: #484f58;--color-prettylights-syntax-constant-other-reference-link: #a5d6ff;--color-fg-default: #e6edf3;--color-fg-muted: #7d8590;--color-fg-subtle: #6e7681;--color-canvas-default: #0d1117;--color-canvas-subtle: #161b22;--color-border-default: #30363d;--color-border-muted: #21262d;--color-neutral-muted: rgba(110,118,129,.4);--color-accent-fg: #2f81f7;--color-accent-emphasis: #1f6feb;--color-attention-fg: #d29922;--color-attention-subtle: rgba(187,128,9,.15);--color-danger-fg: #f85149;--color-done-fg: #a371f7}html:not(.dark) .markdown-body{color-scheme:light;--color-prettylights-syntax-comment: #6e7781;--color-prettylights-syntax-constant: #0550ae;--color-prettylights-syntax-entity: #6639ba;--color-prettylights-syntax-storage-modifier-import: #24292f;--color-prettylights-syntax-entity-tag: #116329;--color-prettylights-syntax-keyword: #cf222e;--color-prettylights-syntax-string: #0a3069;--color-prettylights-syntax-variable: #953800;--color-prettylights-syntax-brackethighlighter-unmatched: #82071e;--color-prettylights-syntax-invalid-illegal-text: #f6f8fa;--color-prettylights-syntax-invalid-illegal-bg: #82071e;--color-prettylights-syntax-carriage-return-text: #f6f8fa;--color-prettylights-syntax-carriage-return-bg: #cf222e;--color-prettylights-syntax-string-regexp: #116329;--color-prettylights-syntax-markup-list: #3b2300;--color-prettylights-syntax-markup-heading: #0550ae;--color-prettylights-syntax-markup-italic: #24292f;--color-prettylights-syntax-markup-bold: #24292f;--color-prettylights-syntax-markup-deleted-text: #82071e;--color-prettylights-syntax-markup-deleted-bg: #ffebe9;--color-prettylights-syntax-markup-inserted-text: #116329;--color-prettylights-syntax-markup-inserted-bg: #dafbe1;--color-prettylights-syntax-markup-changed-text: #953800;--color-prettylights-syntax-markup-changed-bg: #ffd8b5;--color-prettylights-syntax-markup-ignored-text: #eaeef2;--color-prettylights-syntax-markup-ignored-bg: #0550ae;--color-prettylights-syntax-meta-diff-range: #8250df;--color-prettylights-syntax-brackethighlighter-angle: #57606a;--color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f;--color-prettylights-syntax-constant-other-reference-link: #0a3069;--color-fg-default: #1F2328;--color-fg-muted: #656d76;--color-fg-subtle: #6e7781;--color-canvas-default: #ffffff;--color-canvas-subtle: #f6f8fa;--color-border-default: #d0d7de;--color-border-muted: hsla(210,18%,87%,1);--color-neutral-muted: rgba(175,184,193,.2);--color-accent-fg: #0969da;--color-accent-emphasis: #0969da;--color-attention-fg: #9a6700;--color-attention-subtle: #fff8c5;--color-danger-fg: #d1242f;--color-done-fg: #8250df}.markdown-body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;margin:0;color:var(--color-fg-default);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body .octicon{display:inline-block;fill:currentColor;vertical-align:text-bottom}.markdown-body h1:hover .anchor .octicon-link:before,.markdown-body h2:hover .anchor .octicon-link:before,.markdown-body h3:hover .anchor .octicon-link:before,.markdown-body h4:hover .anchor .octicon-link:before,.markdown-body h5:hover .anchor .octicon-link:before,.markdown-body h6:hover .anchor .octicon-link:before{width:16px;height:16px;content:" ";display:inline-block;background-color:currentColor;-webkit-mask-image:url("data:image/svg+xml,");mask-image:url("data:image/svg+xml,")}.markdown-body details,.markdown-body figcaption,.markdown-body figure{display:block}.markdown-body summary{display:list-item}.markdown-body [hidden]{display:none!important}.markdown-body a{background-color:transparent;color:var(--color-accent-fg);text-decoration:none}.markdown-body abbr[title]{border-bottom:none;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.markdown-body b,.markdown-body strong{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dfn{font-style:italic}.markdown-body h1{margin:.67em 0;font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:2em;border-bottom:1px solid var(--color-border-muted)}.markdown-body mark{background-color:var(--color-attention-subtle);color:var(--color-fg-default)}.markdown-body small{font-size:90%}.markdown-body sub,.markdown-body sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.markdown-body sub{bottom:-.25em}.markdown-body sup{top:-.5em}.markdown-body img{border-style:none;max-width:100%;box-sizing:content-box;background-color:var(--color-canvas-default)}.markdown-body code,.markdown-body kbd,.markdown-body pre,.markdown-body samp{font-family:monospace;font-size:1em}.markdown-body figure{margin:1em 40px}.markdown-body hr{box-sizing:content-box;overflow:hidden;background:transparent;border-bottom:1px solid var(--color-border-muted);height:.25em;padding:0;margin:24px 0;background-color:var(--color-border-default);border:0}.markdown-body input{font:inherit;margin:0;overflow:visible;font-family:inherit;font-size:inherit;line-height:inherit}.markdown-body [type=button],.markdown-body [type=reset],.markdown-body [type=submit]{-webkit-appearance:button}.markdown-body [type=checkbox],.markdown-body [type=radio]{box-sizing:border-box;padding:0}.markdown-body [type=number]::-webkit-inner-spin-button,.markdown-body [type=number]::-webkit-outer-spin-button{height:auto}.markdown-body [type=search]::-webkit-search-cancel-button,.markdown-body [type=search]::-webkit-search-decoration{-webkit-appearance:none}.markdown-body ::-webkit-input-placeholder{color:inherit;opacity:.54}.markdown-body ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.markdown-body a:hover{text-decoration:underline}.markdown-body ::-moz-placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body ::placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body hr:before{display:table;content:""}.markdown-body hr:after{display:table;clear:both;content:""}.markdown-body table{border-spacing:0;border-collapse:collapse;display:block;width:-moz-max-content;width:max-content;max-width:100%;overflow:auto}.markdown-body td,.markdown-body th{padding:0}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>*:not(summary){display:none!important}.markdown-body a:focus,.markdown-body [role=button]:focus,.markdown-body input[type=radio]:focus,.markdown-body input[type=checkbox]:focus{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:focus:not(:focus-visible),.markdown-body [role=button]:focus:not(:focus-visible),.markdown-body input[type=radio]:focus:not(:focus-visible),.markdown-body input[type=checkbox]:focus:not(:focus-visible){outline:solid 1px transparent}.markdown-body a:focus-visible,.markdown-body [role=button]:focus-visible,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus-visible{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:not([class]):focus,.markdown-body a:not([class]):focus-visible,.markdown-body input[type=radio]:focus,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus,.markdown-body input[type=checkbox]:focus-visible{outline-offset:0}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;line-height:10px;color:var(--color-fg-default);vertical-align:middle;background-color:var(--color-canvas-subtle);border:solid 1px var(--color-neutral-muted);border-bottom-color:var(--color-neutral-muted);border-radius:6px;box-shadow:inset 0 -1px 0 var(--color-neutral-muted)}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:var(--base-text-weight-semibold, 600);line-height:1.25}.markdown-body h2{font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:1.5em;border-bottom:1px solid var(--color-border-muted)}.markdown-body h3{font-weight:var(--base-text-weight-semibold, 600);font-size:1.25em}.markdown-body h4{font-weight:var(--base-text-weight-semibold, 600);font-size:1em}.markdown-body h5{font-weight:var(--base-text-weight-semibold, 600);font-size:.875em}.markdown-body h6{font-weight:var(--base-text-weight-semibold, 600);font-size:.85em;color:var(--color-fg-muted)}.markdown-body p{margin-top:0;margin-bottom:10px}.markdown-body blockquote{margin:0;padding:0 1em;color:var(--color-fg-muted);border-left:.25em solid var(--color-border-default)}.markdown-body ul,.markdown-body ol{margin-top:0;margin-bottom:0;padding-left:2em}.markdown-body ol ol,.markdown-body ul ol{list-style-type:lower-roman}.markdown-body ul ul ol,.markdown-body ul ol ol,.markdown-body ol ul ol,.markdown-body ol ol ol{list-style-type:lower-alpha}.markdown-body dd{margin-left:0}.markdown-body tt,.markdown-body code,.markdown-body samp{font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px}.markdown-body pre{margin-top:0;margin-bottom:0;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px;word-wrap:normal}.markdown-body .octicon{display:inline-block;overflow:visible!important;vertical-align:text-bottom;fill:currentColor}.markdown-body input::-webkit-outer-spin-button,.markdown-body input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none;appearance:none}.markdown-body .color-fg-accent{color:var(--color-accent-fg)!important}.markdown-body .color-fg-attention{color:var(--color-attention-fg)!important}.markdown-body .color-fg-done{color:var(--color-done-fg)!important}.markdown-body .flex-items-center{align-items:center!important}.markdown-body .mb-1{margin-bottom:var(--base-size-4, 4px)!important}.markdown-body .text-semibold{font-weight:var(--base-text-weight-medium, 500)!important}.markdown-body .d-inline-flex{display:inline-flex!important}.markdown-body:before{display:table;content:""}.markdown-body:after{display:table;clear:both;content:""}.markdown-body>*:first-child{margin-top:0!important}.markdown-body>*:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:var(--color-danger-fg)}.markdown-body .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.markdown-body .anchor:focus{outline:none}.markdown-body p,.markdown-body blockquote,.markdown-body ul,.markdown-body ol,.markdown-body dl,.markdown-body table,.markdown-body pre,.markdown-body details{margin-top:0;margin-bottom:16px}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:var(--color-fg-default);vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 tt,.markdown-body h1 code,.markdown-body h2 tt,.markdown-body h2 code,.markdown-body h3 tt,.markdown-body h3 code,.markdown-body h4 tt,.markdown-body h4 code,.markdown-body h5 tt,.markdown-body h5 code,.markdown-body h6 tt,.markdown-body h6 code{padding:0 .2em;font-size:inherit}.markdown-body summary h1,.markdown-body summary h2,.markdown-body summary h3,.markdown-body summary h4,.markdown-body summary h5,.markdown-body summary h6{display:inline-block}.markdown-body summary h1 .anchor,.markdown-body summary h2 .anchor,.markdown-body summary h3 .anchor,.markdown-body summary h4 .anchor,.markdown-body summary h5 .anchor,.markdown-body summary h6 .anchor{margin-left:-40px}.markdown-body summary h1,.markdown-body summary h2{padding-bottom:0;border-bottom:0}.markdown-body ul.no-list,.markdown-body ol.no-list{padding:0;list-style-type:none}.markdown-body ol[type="a s"]{list-style-type:lower-alpha}.markdown-body ol[type="A s"]{list-style-type:upper-alpha}.markdown-body ol[type="i s"]{list-style-type:lower-roman}.markdown-body ol[type="I s"]{list-style-type:upper-roman}.markdown-body ol[type="1"]{list-style-type:decimal}.markdown-body div>ol:not([type]){list-style-type:decimal}.markdown-body ul ul,.markdown-body ul ol,.markdown-body ol ol,.markdown-body ol ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{margin-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table th{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body table th,.markdown-body table td{padding:6px 13px;border:1px solid var(--color-border-default)}.markdown-body table td>:last-child{margin-bottom:0}.markdown-body table tr{background-color:var(--color-canvas-default);border-top:1px solid var(--color-border-muted)}.markdown-body table tr:nth-child(2n){background-color:var(--color-canvas-subtle)}.markdown-body table img{background-color:transparent}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{max-width:none;vertical-align:text-top;background-color:transparent}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid var(--color-border-default)}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:var(--color-fg-default)}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:.2em .4em;margin:0;font-size:85%;white-space:break-spaces;background-color:var(--color-neutral-muted);border-radius:6px}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body samp{font-size:85%}.markdown-body pre code{font-size:100%}.markdown-body pre>code{padding:0;margin:0;word-break:normal;white-space:pre;background:transparent;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;color:var(--color-fg-default);background-color:var(--color-canvas-subtle);border-radius:6px}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:12px;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-num{padding:10px 8px 9px;text-align:right;background:var(--color-canvas-default);border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:var(--base-text-weight-semibold, 600);background:var(--color-canvas-subtle);border-top:0}.markdown-body [data-footnote-ref]:before{content:"["}.markdown-body [data-footnote-ref]:after{content:"]"}.markdown-body .footnotes{font-size:12px;color:var(--color-fg-muted);border-top:1px solid var(--color-border-default)}.markdown-body .footnotes ol{padding-left:16px}.markdown-body .footnotes ol ul{display:inline-block;padding-left:16px;margin-top:16px}.markdown-body .footnotes li{position:relative}.markdown-body .footnotes li:target:before{position:absolute;inset:-8px -8px -8px -24px;pointer-events:none;content:"";border:2px solid var(--color-accent-emphasis);border-radius:6px}.markdown-body .footnotes li:target{color:var(--color-fg-default)}.markdown-body .footnotes .data-footnote-backref g-emoji{font-family:monospace}.markdown-body .pl-c{color:var(--color-prettylights-syntax-comment)}.markdown-body .pl-c1,.markdown-body .pl-s .pl-v{color:var(--color-prettylights-syntax-constant)}.markdown-body .pl-e,.markdown-body .pl-en{color:var(--color-prettylights-syntax-entity)}.markdown-body .pl-smi,.markdown-body .pl-s .pl-s1{color:var(--color-prettylights-syntax-storage-modifier-import)}.markdown-body .pl-ent{color:var(--color-prettylights-syntax-entity-tag)}.markdown-body .pl-k{color:var(--color-prettylights-syntax-keyword)}.markdown-body .pl-s,.markdown-body .pl-pds,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sre,.markdown-body .pl-sr .pl-sra{color:var(--color-prettylights-syntax-string)}.markdown-body .pl-v,.markdown-body .pl-smw{color:var(--color-prettylights-syntax-variable)}.markdown-body .pl-bu{color:var(--color-prettylights-syntax-brackethighlighter-unmatched)}.markdown-body .pl-ii{color:var(--color-prettylights-syntax-invalid-illegal-text);background-color:var(--color-prettylights-syntax-invalid-illegal-bg)}.markdown-body .pl-c2{color:var(--color-prettylights-syntax-carriage-return-text);background-color:var(--color-prettylights-syntax-carriage-return-bg)}.markdown-body .pl-sr .pl-cce{font-weight:700;color:var(--color-prettylights-syntax-string-regexp)}.markdown-body .pl-ml{color:var(--color-prettylights-syntax-markup-list)}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{font-weight:700;color:var(--color-prettylights-syntax-markup-heading)}.markdown-body .pl-mi{font-style:italic;color:var(--color-prettylights-syntax-markup-italic)}.markdown-body .pl-mb{font-weight:700;color:var(--color-prettylights-syntax-markup-bold)}.markdown-body .pl-md{color:var(--color-prettylights-syntax-markup-deleted-text);background-color:var(--color-prettylights-syntax-markup-deleted-bg)}.markdown-body .pl-mi1{color:var(--color-prettylights-syntax-markup-inserted-text);background-color:var(--color-prettylights-syntax-markup-inserted-bg)}.markdown-body .pl-mc{color:var(--color-prettylights-syntax-markup-changed-text);background-color:var(--color-prettylights-syntax-markup-changed-bg)}.markdown-body .pl-mi2{color:var(--color-prettylights-syntax-markup-ignored-text);background-color:var(--color-prettylights-syntax-markup-ignored-bg)}.markdown-body .pl-mdr{font-weight:700;color:var(--color-prettylights-syntax-meta-diff-range)}.markdown-body .pl-ba{color:var(--color-prettylights-syntax-brackethighlighter-angle)}.markdown-body .pl-sg{color:var(--color-prettylights-syntax-sublimelinter-gutter-mark)}.markdown-body .pl-corl{text-decoration:underline;color:var(--color-prettylights-syntax-constant-other-reference-link)}.markdown-body g-emoji{display:inline-block;min-width:1ch;font-family:"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol;font-size:1em;font-style:normal!important;font-weight:var(--base-text-weight-normal, 400);line-height:1;vertical-align:-.075em}.markdown-body g-emoji img{width:1em;height:1em}.markdown-body .task-list-item{list-style-type:none}.markdown-body .task-list-item label{font-weight:var(--base-text-weight-normal, 400)}.markdown-body .task-list-item.enabled label{cursor:pointer}.markdown-body .task-list-item+.task-list-item{margin-top:4px}.markdown-body .task-list-item .handle{display:none}.markdown-body .task-list-item-checkbox{margin:0 .2em .25em -1.4em;vertical-align:middle}.markdown-body .contains-task-list:dir(rtl) .task-list-item-checkbox{margin:0 -1.6em .25em .2em}.markdown-body .contains-task-list{position:relative}.markdown-body .contains-task-list:hover .task-list-item-convert-container,.markdown-body .contains-task-list:focus-within .task-list-item-convert-container{display:block;width:auto;height:24px;overflow:visible;clip:auto}.markdown-body .QueryBuilder .qb-entity{color:var(--color-prettylights-syntax-entity)}.markdown-body .QueryBuilder .qb-constant{color:var(--color-prettylights-syntax-constant)}.markdown-body ::-webkit-calendar-picker-indicator{filter:invert(50%)}.markdown-body .markdown-alert{padding:0 1em;margin-bottom:16px;color:inherit;border-left:.25em solid var(--color-border-default)}.markdown-body .markdown-alert>:first-child{margin-top:0}.markdown-body .markdown-alert>:last-child{margin-bottom:0}.markdown-body .markdown-alert.markdown-alert-note{border-left-color:var(--color-accent-fg)}.markdown-body .markdown-alert.markdown-alert-important{border-left-color:var(--color-done-fg)}.markdown-body .markdown-alert.markdown-alert-warning{border-left-color:var(--color-attention-fg)}
+*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--header-height: 4rem;--background: 0 0% 100%;--foreground: 222.2 84% 4.9%;--card: 0 0% 100%;--card-foreground: 222.2 84% 4.9%;--popover: 0 0% 100%;--popover-foreground: 222.2 84% 4.9%;--primary: 222.2 47.4% 11.2%;--primary-foreground: 210 40% 98%;--secondary: 210 40% 96.1%;--secondary-foreground: 222.2 47.4% 11.2%;--muted: 210 40% 96.1%;--muted-foreground: 215.4 16.3% 46.9%;--accent: 210 40% 96.1%;--accent-foreground: 222.2 47.4% 11.2%;--destructive: 0 84.2% 60.2%;--destructive-foreground: 210 40% 98%;--border: 214.3 31.8% 91.4%;--input: 214.3 31.8% 91.4%;--ring: 222.2 84% 4.9%;--radius: .5rem}.dark{--background: 222.2 84% 4.9%;--foreground: 210 40% 98%;--card: 222.2 84% 4.9%;--card-foreground: 210 40% 98%;--popover: 222.2 84% 4.9%;--popover-foreground: 210 40% 98%;--primary: 210 40% 98%;--primary-foreground: 222.2 47.4% 11.2%;--secondary: 217.2 32.6% 17.5%;--secondary-foreground: 210 40% 98%;--muted: 217.2 32.6% 17.5%;--muted-foreground: 215 20.2% 65.1%;--accent: 217.2 32.6% 17.5%;--accent-foreground: 210 40% 98%;--destructive: 0 62.8% 30.6%;--destructive-foreground: 210 40% 98%;--border: 217.2 32.6% 17.5%;--input: 217.2 32.6% 17.5%;--ring: 212.7 26.8% 83.9%}.collapsibleDropdown{overflow:hidden}.collapsibleDropdown[data-state=open]{animation:slideDown .2s ease-out}.collapsibleDropdown[data-state=closed]{animation:slideUp .2s ease-out}@keyframes slideDown{0%{height:0}to{height:var(--radix-collapsible-content-height)}}@keyframes slideUp{0%{height:var(--radix-collapsible-content-height)}to{height:0}}*{border-color:hsl(var(--border))}body{min-height:100svh;width:100%;background-color:hsl(var(--background));color:hsl(var(--foreground))}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media (min-width: 1400px){.container{max-width:1400px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.invisible{visibility:hidden}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.-left-1{left:-.25rem}.-right-1{right:-.25rem}.-right-5{right:-1.25rem}.-top-1{top:-.25rem}.-top-1\/2{top:-50%}.bottom-0{bottom:0}.bottom-5{bottom:1.25rem}.bottom-full{bottom:100%}.left-0{left:0}.left-1\/2{left:50%}.left-2{left:.5rem}.left-3{left:.75rem}.left-4{left:1rem}.left-5{left:1.25rem}.left-\[50\%\]{left:50%}.right-0{right:0}.right-1{right:.25rem}.right-1\.5{right:.375rem}.right-2{right:.5rem}.right-3{right:.75rem}.right-4{right:1rem}.right-5{right:1.25rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-2\.5{top:.625rem}.top-4{top:1rem}.top-\[1px\]{top:1px}.top-\[50\%\]{top:50%}.top-\[60\%\]{top:60%}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[-1\]{z-index:-1}.z-\[1\]{z-index:1}.col-span-2{grid-column:span 2 / span 2}.col-span-3{grid-column:span 3 / span 3}.-m-0\.5{margin:-.125rem}.m-1{margin:.25rem}.m-auto{margin:auto}.-mx-1{margin-left:-.25rem;margin-right:-.25rem}.-mx-4{margin-left:-1rem;margin-right:-1rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-4{margin-top:1rem;margin-bottom:1rem}.my-6{margin-top:1.5rem;margin-bottom:1.5rem}.-ml-3{margin-left:-.75rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-8{margin-left:2rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mr-4{margin-right:1rem}.mr-auto{margin-right:auto}.mt-0{margin-top:0}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-24{margin-top:6rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.\!table{display:table!important}.table{display:table}.grid{display:grid}.hidden{display:none}.aspect-\[16\/9\]{aspect-ratio:16/9}.aspect-square{aspect-ratio:1 / 1}.size-10{width:2.5rem;height:2.5rem}.size-2\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-\[--cell-size\]{width:var(--cell-size);height:var(--cell-size)}.h-0{height:0px}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-20{height:5rem}.h-24{height:6rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-40{height:10rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-\[--cell-size\]{height:var(--cell-size)}.h-\[100vh\]{height:100vh}.h-\[180px\]{height:180px}.h-\[1px\]{height:1px}.h-\[200px\]{height:200px}.h-\[300px\]{height:300px}.h-\[400px\]{height:400px}.h-\[85vh\]{height:85vh}.h-\[90vh\]{height:90vh}.h-\[calc\(100\%-var\(--header-height\)\)\]{height:calc(100% - var(--header-height))}.h-\[calc\(100vh-280px\)\]{height:calc(100vh - 280px)}.h-\[var\(--header-height\)\]{height:var(--header-height)}.h-\[var\(--radix-navigation-menu-viewport-height\)\]{height:var(--radix-navigation-menu-viewport-height)}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.h-svh{height:100svh}.max-h-12{max-height:3rem}.max-h-96{max-height:24rem}.max-h-\[150px\]{max-height:150px}.max-h-\[200px\]{max-height:200px}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[95\%\]{max-height:95%}.max-h-\[calc\(85vh-120px\)\]{max-height:calc(85vh - 120px)}.min-h-10{min-height:2.5rem}.min-h-6{min-height:1.5rem}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[200px\]{min-height:200px}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.min-h-svh{min-height:100svh}.w-0{width:0px}.w-1\.5{width:.375rem}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-2\/3{width:66.666667%}.w-20{width:5rem}.w-28{width:7rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-3\/4{width:75%}.w-32{width:8rem}.w-36{width:9rem}.w-4{width:1rem}.w-4\/5{width:80%}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-72{width:18rem}.w-8{width:2rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-\[--cell-size\]{width:var(--cell-size)}.w-\[100px\]{width:100px}.w-\[120px\]{width:120px}.w-\[140px\]{width:140px}.w-\[150px\]{width:150px}.w-\[180px\]{width:180px}.w-\[1px\]{width:1px}.w-\[200px\]{width:200px}.w-\[250px\]{width:250px}.w-\[300px\]{width:300px}.w-\[400px\]{width:400px}.w-\[50px\]{width:50px}.w-\[60px\]{width:60px}.w-\[70px\]{width:70px}.w-\[80px\]{width:80px}.w-\[9\.5rem\]{width:9.5rem}.w-auto{width:auto}.w-fit{width:-moz-fit-content;width:fit-content}.w-full{width:100%}.w-max{width:-moz-max-content;width:max-content}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-20{min-width:5rem}.min-w-\[--cell-size\]{min-width:var(--cell-size)}.min-w-\[10em\]{min-width:10em}.min-w-\[200px\]{min-width:200px}.min-w-\[3rem\]{min-width:3rem}.min-w-\[40px\]{min-width:40px}.min-w-\[4rem\]{min-width:4rem}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.max-w-2xl{max-width:42rem}.max-w-32{max-width:8rem}.max-w-4xl{max-width:56rem}.max-w-52{max-width:13rem}.max-w-6xl{max-width:72rem}.max-w-80{max-width:20rem}.max-w-\[150px\]{max-width:150px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[280px\]{max-width:280px}.max-w-\[300px\]{max-width:300px}.max-w-\[500px\]{max-width:500px}.max-w-\[60\%\]{max-width:60%}.max-w-\[600px\]{max-width:600px}.max-w-\[90\%\]{max-width:90%}.max-w-\[90vw\]{max-width:90vw}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-max{max-width:-moz-max-content;max-width:max-content}.max-w-none{max-width:none}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-\[1\.2\]{flex:1.2}.flex-\[1\]{flex:1}.flex-\[2\]{flex:2}.flex-\[4\]{flex:4}.flex-\[5\]{flex:5}.flex-none{flex:none}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-x-full{--tw-translate-x: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\[-50\%\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-full{--tw-translate-x: 100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-0{--tw-translate-y: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\[-50\%\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-45{--tw-rotate: 45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-100{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-125{--tw-scale-x: 1.25;--tw-scale-y: 1.25;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-help{cursor:help}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.cursor-text{cursor:text}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-\[100px_1fr\]{grid-template-columns:100px 1fr}.flex-row{flex-direction:row}.flex-row-reverse{flex-direction:row-reverse}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-1{-moz-column-gap:.25rem;column-gap:.25rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-2{row-gap:.5rem}.space-x-1>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.25rem * var(--tw-space-x-reverse));margin-left:calc(.25rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-2\.5>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.625rem * var(--tw-space-x-reverse));margin-left:calc(.625rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-3>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1.5rem * var(--tw-space-x-reverse));margin-left:calc(1.5rem * calc(1 - var(--tw-space-x-reverse)))}.space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.space-y-8>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.self-start{align-self:flex-start}.self-end{align-self:flex-end}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-scroll{overflow-y:scroll}.overscroll-contain{overscroll-behavior:contain}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-wrap{text-wrap:wrap}.text-nowrap{text-wrap:nowrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-\[inherit\]{border-radius:inherit}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:.75rem}.rounded-l-lg{border-top-left-radius:var(--radius);border-bottom-left-radius:var(--radius)}.rounded-l-md{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.rounded-l-none{border-top-left-radius:0;border-bottom-left-radius:0}.rounded-r-lg{border-top-right-radius:var(--radius);border-bottom-right-radius:var(--radius)}.rounded-r-md{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.rounded-r-none{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-t-\[10px\]{border-top-left-radius:10px;border-top-right-radius:10px}.rounded-bl-none{border-bottom-left-radius:0}.rounded-br-none{border-bottom-right-radius:0}.rounded-tl-lg{border-top-left-radius:var(--radius)}.rounded-tl-none{border-top-left-radius:0}.rounded-tl-sm{border-top-left-radius:calc(var(--radius) - 4px)}.rounded-tr-lg{border-top-right-radius:var(--radius)}.rounded-tr-none{border-top-right-radius:0}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-x-0{border-left-width:0px;border-right-width:0px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l{border-left-width:1px}.border-l-0{border-left-width:0px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-r-0{border-right-width:0px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-300{--tw-border-opacity: 1;border-color:rgb(147 197 253 / var(--tw-border-opacity, 1))}.border-blue-500\/50{border-color:#3b82f680}.border-border{border-color:hsl(var(--border))}.border-border\/30{border-color:hsl(var(--border) / .3)}.border-border\/50{border-color:hsl(var(--border) / .5)}.border-destructive\/50{border-color:hsl(var(--destructive) / .5)}.border-emerald-200{--tw-border-opacity: 1;border-color:rgb(167 243 208 / var(--tw-border-opacity, 1))}.border-foreground\/10{border-color:hsl(var(--foreground) / .1)}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-indigo-200{--tw-border-opacity: 1;border-color:rgb(199 210 254 / var(--tw-border-opacity, 1))}.border-input{border-color:hsl(var(--input))}.border-muted{border-color:hsl(var(--muted))}.border-muted-foreground\/25{border-color:hsl(var(--muted-foreground) / .25)}.border-orange-200{--tw-border-opacity: 1;border-color:rgb(254 215 170 / var(--tw-border-opacity, 1))}.border-orange-500\/50{border-color:#f9731680}.border-primary{border-color:hsl(var(--primary))}.border-primary\/40{border-color:hsl(var(--primary) / .4)}.border-primary\/50{border-color:hsl(var(--primary) / .5)}.border-purple-200{--tw-border-opacity: 1;border-color:rgb(233 213 255 / var(--tw-border-opacity, 1))}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500{--tw-border-opacity: 1;border-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.border-l-slate-500{--tw-border-opacity: 1;border-left-color:rgb(100 116 139 / var(--tw-border-opacity, 1))}.border-l-transparent{border-left-color:transparent}.border-r-muted{border-right-color:hsl(var(--muted))}.border-t-transparent{border-top-color:transparent}.bg-accent{background-color:hsl(var(--accent))}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-background{background-color:hsl(var(--background))}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-black\/20{background-color:#0003}.bg-black\/80{background-color:#000c}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-destructive\/15{background-color:hsl(var(--destructive) / .15)}.bg-destructive\/80{background-color:hsl(var(--destructive) / .8)}.bg-emerald-100{--tw-bg-opacity: 1;background-color:rgb(209 250 229 / var(--tw-bg-opacity, 1))}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\/80{background-color:#10b981cc}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-indigo-100{--tw-bg-opacity: 1;background-color:rgb(224 231 255 / var(--tw-bg-opacity, 1))}.bg-inherit{background-color:inherit}.bg-muted{background-color:hsl(var(--muted))}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-popover{background-color:hsl(var(--popover))}.bg-primary{background-color:hsl(var(--primary))}.bg-primary-foreground{background-color:hsl(var(--primary-foreground))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-primary\/20{background-color:hsl(var(--primary) / .2)}.bg-primary\/5{background-color:hsl(var(--primary) / .05)}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-purple-50{--tw-bg-opacity: 1;background-color:rgb(250 245 255 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-secondary{background-color:hsl(var(--secondary))}.bg-secondary\/50{background-color:hsl(var(--secondary) / .5)}.bg-slate-100\/80{background-color:#f1f5f9cc}.bg-slate-50{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity, 1))}.bg-transparent{background-color:transparent}.bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.bg-yellow-500{--tw-bg-opacity: 1;background-color:rgb(234 179 8 / var(--tw-bg-opacity, 1))}.bg-yellow-500\/80{background-color:#eab308cc}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-background\/95{--tw-gradient-from: hsl(var(--background) / .95) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-background\/80{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .8) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-background\/60{--tw-gradient-to: hsl(var(--background) / .6) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-primary{fill:hsl(var(--primary))}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-\[1px\]{padding:1px}.px-0{padding-left:0;padding-right:0}.px-0\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.px-\[--cell-size\]{padding-left:var(--cell-size);padding-right:var(--cell-size)}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-0\.5{padding-bottom:.125rem}.pb-16{padding-bottom:4rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pl-2{padding-left:.5rem}.pl-2\.5{padding-left:.625rem}.pl-3{padding-left:.75rem}.pl-6{padding-left:1.5rem}.pl-8{padding-left:2rem}.pl-9{padding-left:2.25rem}.pr-1{padding-right:.25rem}.pr-10{padding-right:2.5rem}.pr-12{padding-right:3rem}.pr-2{padding-right:.5rem}.pr-2\.5{padding-right:.625rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pr-7{padding-right:1.75rem}.pr-8{padding-right:2rem}.pr-9{padding-right:2.25rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\.5{padding-top:.375rem}.pt-16{padding-top:4rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\[0\.625rem\]{font-size:.625rem}.text-\[0\.7rem\]{font-size:.7rem}.text-\[0\.8rem\]{font-size:.8rem}.text-\[10px\]{font-size:10px}.text-\[7rem\]{font-size:7rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-10{line-height:2.5rem}.leading-none{line-height:1}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.tracking-widest{letter-spacing:.1em}.text-accent-foreground{color:hsl(var(--accent-foreground))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-current{color:currentColor}.text-destructive{color:hsl(var(--destructive))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-emerald-500{--tw-text-opacity: 1;color:rgb(16 185 129 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-800{--tw-text-opacity: 1;color:rgb(6 95 70 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--foreground))}.text-foreground\/70{color:hsl(var(--foreground) / .7)}.text-foreground\/90{color:hsl(var(--foreground) / .9)}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-indigo-800{--tw-text-opacity: 1;color:rgb(55 48 163 / var(--tw-text-opacity, 1))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-muted-foreground\/30{color:hsl(var(--muted-foreground) / .3)}.text-muted-foreground\/40{color:hsl(var(--muted-foreground) / .4)}.text-muted-foreground\/50{color:hsl(var(--muted-foreground) / .5)}.text-muted-foreground\/70{color:hsl(var(--muted-foreground) / .7)}.text-orange-500{--tw-text-opacity: 1;color:rgb(249 115 22 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-orange-700{--tw-text-opacity: 1;color:rgb(194 65 12 / var(--tw-text-opacity, 1))}.text-orange-800{--tw-text-opacity: 1;color:rgb(154 52 18 / var(--tw-text-opacity, 1))}.text-popover-foreground{color:hsl(var(--popover-foreground))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-primary\/90{color:hsl(var(--primary) / .9)}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--secondary-foreground))}.text-slate-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity, 1))}.text-slate-700{--tw-text-opacity: 1;color:rgb(51 65 85 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.underline-offset-4{text-underline-offset:4px}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-30{opacity:.3}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-none{--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-destructive\/50{--tw-shadow-color: hsl(var(--destructive) / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-emerald-500\/50{--tw-shadow-color: rgb(16 185 129 / .5);--tw-shadow: var(--tw-shadow-colored)}.shadow-yellow-500\/50{--tw-shadow-color: rgb(234 179 8 / .5);--tw-shadow: var(--tw-shadow-colored)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.ring-0{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-gray-200{--tw-ring-opacity: 1;--tw-ring-color: rgb(229 231 235 / var(--tw-ring-opacity, 1))}.ring-gray-300\/20{--tw-ring-color: rgb(209 213 219 / .2)}.ring-green-500\/20{--tw-ring-color: rgb(34 197 94 / .2)}.ring-primary\/20{--tw-ring-color: hsl(var(--primary) / .2)}.ring-offset-2{--tw-ring-offset-width: 2px}.ring-offset-background{--tw-ring-offset-color: hsl(var(--background))}.ring-offset-white{--tw-ring-offset-color: #fff}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-\[1px\]{--tw-backdrop-blur: blur(1px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[margin\]{transition-property:margin;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[max-height\,padding\]{transition-property:max-height,padding;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[opacity\]{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\[width\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.delay-100{transition-delay:.1s}.delay-150{transition-delay:.15s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.duration-700{transition-duration:.7s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.duration-500{animation-duration:.5s}.duration-700{animation-duration:.7s}.delay-100{animation-delay:.1s}.delay-150{animation-delay:.15s}.ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.no-scrollbar::-webkit-scrollbar{display:none}.no-scrollbar{-ms-overflow-style:none;scrollbar-width:none}.\[--cell-size\:2rem\]{--cell-size: 2rem}html{overflow-y:scroll}.sticky{position:sticky!important;z-index:2;background-color:hsl(var(--card))}.sticky.before\:right-0:before,.sticky.before\:left-0:before{content:"";position:absolute;top:0;bottom:0;width:2px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent);opacity:1;transition:opacity .3s ease}.sticky.before\:right-0:before{right:-1px;background:linear-gradient(to right,rgba(0,0,0,.08),transparent)}.sticky.before\:right-0:after{content:"";position:absolute;top:0;right:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to right,rgba(0,0,0,.05),transparent)}.sticky.before\:left-0:before{left:-1px;background:linear-gradient(to left,rgba(0,0,0,.08),transparent)}.sticky.before\:left-0:after{content:"";position:absolute;top:0;left:-8px;bottom:0;width:8px;pointer-events:none;background:linear-gradient(to left,rgba(0,0,0,.05),transparent)}.sticky:hover:before{opacity:.8}.dark .sticky.before\:right-0:before,.dark .sticky.before\:left-0:before{background:linear-gradient(to right,rgba(255,255,255,.05),transparent)}.dark .sticky.before\:right-0:after,.dark .sticky.before\:left-0:after{background:linear-gradient(to right,rgba(255,255,255,.03),transparent)}.\*\:\!inline-block>*{display:inline-block!important}.file\:border-0::file-selector-button{border-width:0px}.file\:bg-transparent::file-selector-button{background-color:transparent}.file\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\:font-medium::file-selector-button{font-weight:500}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:bottom-0:before{content:var(--tw-content);bottom:0}.before\:left-0:before{content:var(--tw-content);left:0}.before\:right-0:before{content:var(--tw-content);right:0}.before\:top-0:before{content:var(--tw-content);top:0}.before\:w-\[1px\]:before{content:var(--tw-content);width:1px}.before\:bg-border:before{content:var(--tw-content);background-color:hsl(var(--border))}.after\:pointer-events-none:after{content:var(--tw-content);pointer-events:none}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:inset-y-0:after{content:var(--tw-content);top:0;bottom:0}.after\:bottom-0:after{content:var(--tw-content);bottom:0}.after\:left-0:after{content:var(--tw-content);left:0}.after\:left-1\/2:after{content:var(--tw-content);left:50%}.after\:hidden:after{content:var(--tw-content);display:none}.after\:h-32:after{content:var(--tw-content);height:8rem}.after\:w-1:after{content:var(--tw-content);width:.25rem}.after\:w-full:after{content:var(--tw-content);width:100%}.after\:-translate-x-1\/2:after{content:var(--tw-content);--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.after\:bg-\[linear-gradient\(180deg\,_transparent_10\%\,_hsl\(var\(--background\)\)_70\%\)\]:after{content:var(--tw-content);background-image:linear-gradient(180deg,transparent 10%,hsl(var(--background)) 70%)}.focus-within\:ring-1:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-ring:focus-within{--tw-ring-color: hsl(var(--ring))}.hover\:-translate-y-1:hover{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:rotate-180:hover{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-accent\/50:hover{background-color:hsl(var(--accent) / .5)}.hover\:bg-background:hover{background-color:hsl(var(--background))}.hover\:bg-blue-100:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.hover\:bg-blue-200:hover{--tw-bg-opacity: 1;background-color:rgb(191 219 254 / var(--tw-bg-opacity, 1))}.hover\:bg-card\/80:hover{background-color:hsl(var(--card) / .8)}.hover\:bg-destructive\/10:hover{background-color:hsl(var(--destructive) / .1)}.hover\:bg-destructive\/25:hover{background-color:hsl(var(--destructive) / .25)}.hover\:bg-destructive\/80:hover{background-color:hsl(var(--destructive) / .8)}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\:bg-green-100:hover{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.hover\:bg-inherit:hover{background-color:inherit}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-muted\/40:hover{background-color:hsl(var(--muted) / .4)}.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted) / .5)}.hover\:bg-muted\/60:hover{background-color:hsl(var(--muted) / .6)}.hover\:bg-muted\/70:hover{background-color:hsl(var(--muted) / .7)}.hover\:bg-orange-100:hover{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.hover\:bg-primary\/10:hover{background-color:hsl(var(--primary) / .1)}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-red-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.hover\:bg-red-200:hover{--tw-bg-opacity: 1;background-color:rgb(254 202 202 / var(--tw-bg-opacity, 1))}.hover\:bg-red-700:hover{--tw-bg-opacity: 1;background-color:rgb(185 28 28 / var(--tw-bg-opacity, 1))}.hover\:bg-secondary-foreground\/10:hover{background-color:hsl(var(--secondary-foreground) / .1)}.hover\:bg-secondary\/70:hover{background-color:hsl(var(--secondary) / .7)}.hover\:bg-secondary\/80:hover{background-color:hsl(var(--secondary) / .8)}.hover\:bg-slate-100:hover{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-200\/80:hover{background-color:#e2e8f0cc}.hover\:bg-transparent:hover{background-color:transparent}.hover\:bg-yellow-100:hover{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.hover\:bg-opacity-80:hover{--tw-bg-opacity: .8}.hover\:text-accent-foreground:hover{color:hsl(var(--accent-foreground))}.hover\:text-destructive:hover{color:hsl(var(--destructive))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:text-foreground\/70:hover{color:hsl(var(--foreground) / .7)}.hover\:text-muted-foreground:hover{color:hsl(var(--muted-foreground))}.hover\:text-primary:hover{color:hsl(var(--primary))}.hover\:text-primary\/80:hover{color:hsl(var(--primary) / .8)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}.hover\:opacity-80:hover{opacity:.8}.hover\:shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-md:hover{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.hover\:shadow-black\/30:hover{--tw-shadow-color: rgb(0 0 0 / .3);--tw-shadow: var(--tw-shadow-colored)}.hover\:ring-primary:hover{--tw-ring-color: hsl(var(--primary))}.focus\:z-10:focus{z-index:10}.focus\:bg-accent:focus{background-color:hsl(var(--accent))}.focus\:text-accent-foreground:focus{color:hsl(var(--accent-foreground))}.focus\:text-destructive:focus{color:hsl(var(--destructive))}.focus\:text-red-600:focus{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-red-600:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(220 38 38 / var(--tw-ring-opacity, 1))}.focus\:ring-ring:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-primary:focus-visible{--tw-ring-color: hsl(var(--primary))}.focus-visible\:ring-red-500:focus-visible{--tw-ring-opacity: 1;--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity, 1))}.focus-visible\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--ring))}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width: 1px}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.focus-visible\:ring-offset-background:focus-visible{--tw-ring-offset-color: hsl(var(--background))}.active\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group:hover .group-hover\:via-background\/90{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background) / .9) var(--tw-gradient-via-position), var(--tw-gradient-to)}.group:hover .group-hover\:to-background\/70{--tw-gradient-to: hsl(var(--background) / .7) var(--tw-gradient-to-position)}.group\/id:hover .group-hover\/id\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:justify-center{justify-content:center}.group[data-collapsed=true] .group-\[\[data-collapsed\=true\]\]\:px-2{padding-left:.5rem;padding-right:.5rem}.peer:disabled~.peer-disabled\:cursor-not-allowed{cursor:not-allowed}.peer:disabled~.peer-disabled\:opacity-70{opacity:.7}.has-\[\:focus-visible\]\:outline-none:has(:focus-visible){outline:2px solid transparent;outline-offset:2px}.has-\[\:focus-visible\]\:ring-1:has(:focus-visible){--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.has-\[\:focus-visible\]\:ring-neutral-950:has(:focus-visible){--tw-ring-opacity: 1;--tw-ring-color: rgb(10 10 10 / var(--tw-ring-opacity, 1))}.aria-disabled\:opacity-50[aria-disabled=true]{opacity:.5}.aria-selected\:bg-accent[aria-selected=true]{background-color:hsl(var(--accent))}.aria-selected\:text-accent-foreground[aria-selected=true]{color:hsl(var(--accent-foreground))}.aria-selected\:text-muted-foreground[aria-selected=true]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[panel-group-direction\=vertical\]\:h-px[data-panel-group-direction=vertical]{height:1px}.data-\[panel-group-direction\=vertical\]\:w-full[data-panel-group-direction=vertical]{width:100%}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=left\]\:-translate-x-1[data-side=left]{--tw-translate-x: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=right\]\:translate-x-1[data-side=right]{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[side\=top\]\:-translate-y-1[data-side=top]{--tw-translate-y: -.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x: 1rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes accordion-up{0%{height:var(--radix-accordion-content-height)}to{height:0}}.data-\[state\=closed\]\:animate-accordion-up[data-state=closed]{animation:accordion-up .2s ease-out}@keyframes accordion-down{0%{height:0}to{height:var(--radix-accordion-content-height)}}.data-\[state\=open\]\:animate-accordion-down[data-state=open]{animation:accordion-down .2s ease-out}.data-\[state\=dragging\]\:cursor-grabbing[data-state=dragging]{cursor:grabbing}.data-\[panel-group-direction\=vertical\]\:flex-col[data-panel-group-direction=vertical]{flex-direction:column}.data-\[range-end\=true\]\:rounded-md[data-range-end=true]{border-radius:calc(var(--radius) - 2px)}.data-\[range-middle\=true\]\:rounded-none[data-range-middle=true]{border-radius:0}.data-\[range-start\=true\]\:rounded-md[data-range-start=true]{border-radius:calc(var(--radius) - 2px)}.data-\[selected\=true\]\:rounded-none[data-selected=true]{border-radius:0}.data-\[active\]\:bg-accent\/50[data-active]{background-color:hsl(var(--accent) / .5)}.data-\[disabled\]\:bg-muted-foreground[data-disabled],.data-\[fixed\]\:bg-muted-foreground[data-fixed]{background-color:hsl(var(--muted-foreground))}.data-\[range-end\=true\]\:bg-primary[data-range-end=true]{background-color:hsl(var(--primary))}.data-\[range-middle\=true\]\:bg-accent[data-range-middle=true]{background-color:hsl(var(--accent))}.data-\[range-start\=true\]\:bg-primary[data-range-start=true],.data-\[selected-single\=true\]\:bg-primary[data-selected-single=true]{background-color:hsl(var(--primary))}.data-\[state\=active\]\:bg-background[data-state=active]{background-color:hsl(var(--background))}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:hsl(var(--primary))}.data-\[state\=open\]\:bg-accent[data-state=open]{background-color:hsl(var(--accent))}.data-\[state\=open\]\:bg-accent\/50[data-state=open]{background-color:hsl(var(--accent) / .5)}.data-\[state\=open\]\:bg-secondary[data-state=open]{background-color:hsl(var(--secondary))}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:hsl(var(--muted))}.data-\[state\=unchecked\]\:bg-input[data-state=unchecked]{background-color:hsl(var(--input))}.data-\[collapsed\=true\]\:py-2[data-collapsed=true]{padding-top:.5rem;padding-bottom:.5rem}.data-\[disabled\]\:text-muted[data-disabled],.data-\[fixed\]\:text-muted[data-fixed]{color:hsl(var(--muted))}.data-\[range-end\=true\]\:text-primary-foreground[data-range-end=true]{color:hsl(var(--primary-foreground))}.data-\[range-middle\=true\]\:text-accent-foreground[data-range-middle=true]{color:hsl(var(--accent-foreground))}.data-\[range-start\=true\]\:text-primary-foreground[data-range-start=true],.data-\[selected-single\=true\]\:text-primary-foreground[data-selected-single=true]{color:hsl(var(--primary-foreground))}.data-\[state\=active\]\:text-foreground[data-state=active]{color:hsl(var(--foreground))}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:hsl(var(--primary-foreground))}.data-\[state\=open\]\:text-muted-foreground[data-state=open]{color:hsl(var(--muted-foreground))}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{transition-duration:.3s}.data-\[motion\^\=from-\]\:animate-in[data-motion^=from-],.data-\[state\=open\]\:animate-in[data-state=open],.data-\[state\=visible\]\:animate-in[data-state=visible]{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.data-\[motion\^\=to-\]\:animate-out[data-motion^=to-],.data-\[state\=closed\]\:animate-out[data-state=closed],.data-\[state\=hidden\]\:animate-out[data-state=hidden]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\[motion\^\=from-\]\:fade-in[data-motion^=from-]{--tw-enter-opacity: 0}.data-\[motion\^\=to-\]\:fade-out[data-motion^=to-],.data-\[state\=closed\]\:fade-out-0[data-state=closed],.data-\[state\=hidden\]\:fade-out[data-state=hidden]{--tw-exit-opacity: 0}.data-\[state\=open\]\:fade-in-0[data-state=open],.data-\[state\=visible\]\:fade-in[data-state=visible]{--tw-enter-opacity: 0}.data-\[state\=closed\]\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\[state\=open\]\:zoom-in-90[data-state=open]{--tw-enter-scale: .9}.data-\[state\=open\]\:zoom-in-95[data-state=open]{--tw-enter-scale: .95}.data-\[motion\=from-end\]\:slide-in-from-right-52[data-motion=from-end]{--tw-enter-translate-x: 13rem}.data-\[motion\=from-start\]\:slide-in-from-left-52[data-motion=from-start]{--tw-enter-translate-x: -13rem}.data-\[motion\=to-end\]\:slide-out-to-right-52[data-motion=to-end]{--tw-exit-translate-x: 13rem}.data-\[motion\=to-start\]\:slide-out-to-left-52[data-motion=to-start]{--tw-exit-translate-x: -13rem}.data-\[side\=bottom\]\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.data-\[state\=closed\]\:slide-out-to-bottom[data-state=closed]{--tw-exit-translate-y: 100%}.data-\[state\=closed\]\:slide-out-to-left[data-state=closed]{--tw-exit-translate-x: -100%}.data-\[state\=closed\]\:slide-out-to-left-1\/2[data-state=closed]{--tw-exit-translate-x: -50%}.data-\[state\=closed\]\:slide-out-to-right[data-state=closed]{--tw-exit-translate-x: 100%}.data-\[state\=closed\]\:slide-out-to-top[data-state=closed]{--tw-exit-translate-y: -100%}.data-\[state\=closed\]\:slide-out-to-top-\[48\%\][data-state=closed]{--tw-exit-translate-y: -48%}.data-\[state\=open\]\:slide-in-from-bottom[data-state=open]{--tw-enter-translate-y: 100%}.data-\[state\=open\]\:slide-in-from-left[data-state=open]{--tw-enter-translate-x: -100%}.data-\[state\=open\]\:slide-in-from-left-1\/2[data-state=open]{--tw-enter-translate-x: -50%}.data-\[state\=open\]\:slide-in-from-right[data-state=open]{--tw-enter-translate-x: 100%}.data-\[state\=open\]\:slide-in-from-top[data-state=open]{--tw-enter-translate-y: -100%}.data-\[state\=open\]\:slide-in-from-top-\[48\%\][data-state=open]{--tw-enter-translate-y: -48%}.data-\[state\=closed\]\:duration-300[data-state=closed],.data-\[state\=open\]\:duration-300[data-state=open]{animation-duration:.3s}.data-\[panel-group-direction\=vertical\]\:after\:left-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);left:0}.data-\[panel-group-direction\=vertical\]\:after\:h-1[data-panel-group-direction=vertical]:after{content:var(--tw-content);height:.25rem}.data-\[panel-group-direction\=vertical\]\:after\:w-full[data-panel-group-direction=vertical]:after{content:var(--tw-content);width:100%}.data-\[panel-group-direction\=vertical\]\:after\:-translate-y-1\/2[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[panel-group-direction\=vertical\]\:after\:translate-x-0[data-panel-group-direction=vertical]:after{content:var(--tw-content);--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\[disabled\]\:hover\:bg-muted-foreground:hover[data-disabled],.data-\[fixed\]\:hover\:bg-muted-foreground:hover[data-fixed]{background-color:hsl(var(--muted-foreground))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:relative{position:relative}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:z-10{z-index:10}.group[data-state=open] .group-data-\[state\=\"open\"\]\:-rotate-180{--tw-rotate: -180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group[data-state=open] .group-data-\[state\=open\]\:rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:border-ring{border-color:hsl(var(--ring))}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-\[3px\]{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.group\/day[data-focused=true] .group-data-\[focused\=true\]\/day\:ring-ring\/50{--tw-ring-color: hsl(var(--ring) / .5)}.dark\:border-amber-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(120 53 15 / var(--tw-border-opacity, 1))}.dark\:border-blue-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(29 78 216 / var(--tw-border-opacity, 1))}.dark\:border-blue-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(30 58 138 / var(--tw-border-opacity, 1))}.dark\:border-gray-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(55 65 81 / var(--tw-border-opacity, 1))}.dark\:border-red-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(127 29 29 / var(--tw-border-opacity, 1))}.dark\:border-yellow-900:is(.dark *){--tw-border-opacity: 1;border-color:rgb(113 63 18 / var(--tw-border-opacity, 1))}.dark\:bg-amber-950\/30:is(.dark *){background-color:#451a034d}.dark\:bg-blue-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(23 37 84 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-950\/30:is(.dark *){background-color:#1725544d}.dark\:bg-gray-800\/50:is(.dark *){background-color:#1f293780}.dark\:bg-green-500\/10:is(.dark *){background-color:#22c55e1a}.dark\:bg-red-500\/10:is(.dark *){background-color:#ef44441a}.dark\:bg-red-900:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-950\/30:is(.dark *){background-color:#450a0a4d}.dark\:bg-yellow-500\/10:is(.dark *){background-color:#eab3081a}.dark\:bg-yellow-950\/30:is(.dark *){background-color:#4220064d}.dark\:text-amber-200:is(.dark *){--tw-text-opacity: 1;color:rgb(253 230 138 / var(--tw-text-opacity, 1))}.dark\:text-blue-300:is(.dark *){--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity, 1))}.dark\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.dark\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.dark\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-300:is(.dark *){--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-yellow-300:is(.dark *){--tw-text-opacity: 1;color:rgb(253 224 71 / var(--tw-text-opacity, 1))}.dark\:text-yellow-400:is(.dark *){--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}.dark\:ring-gray-700:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity, 1))}.dark\:ring-gray-800:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(31 41 55 / var(--tw-ring-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::-moz-placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:placeholder\:text-gray-500:is(.dark *)::placeholder{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.dark\:hover\:bg-blue-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 64 175 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-blue-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-800:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(153 27 27 / var(--tw-bg-opacity, 1))}.dark\:hover\:bg-red-900:hover:is(.dark *){--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:hover\:text-red-400:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:has-\[\:focus-visible\]\:ring-neutral-300:has(:focus-visible):is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(212 212 212 / var(--tw-ring-opacity, 1))}@media (min-width: 640px){.sm\:absolute{position:absolute}.sm\:inset-auto{inset:auto}.sm\:bottom-\[calc\(100\%\+10px\)\]{bottom:calc(100% + 10px)}.sm\:left-0{left:0}.sm\:right-0{right:0}.sm\:my-0{margin-top:0;margin-bottom:0}.sm\:my-4{margin-top:1rem;margin-bottom:1rem}.sm\:mt-0{margin-top:0}.sm\:mt-6{margin-top:1.5rem}.sm\:block{display:block}.sm\:hidden{display:none}.sm\:h-\[80vh\]{height:80vh}.sm\:h-full{height:100%}.sm\:max-h-\[500px\]{max-height:500px}.sm\:max-h-\[600px\]{max-height:600px}.sm\:max-h-\[700px\]{max-height:700px}.sm\:max-h-\[800px\]{max-height:800px}.sm\:w-48{width:12rem}.sm\:w-\[350px\]{width:350px}.sm\:w-\[540px\]{width:540px}.sm\:w-\[90vw\]{width:90vw}.sm\:w-auto{width:auto}.sm\:w-full{width:100%}.sm\:max-w-72{max-width:18rem}.sm\:max-w-\[1025px\]{max-width:1025px}.sm\:max-w-\[425px\]{max-width:425px}.sm\:max-w-\[500px\]{max-width:500px}.sm\:max-w-\[700px\]{max-width:700px}.sm\:max-w-lg{max-width:32rem}.sm\:max-w-md{max-width:28rem}.sm\:max-w-sm{max-width:24rem}.sm\:max-w-xl{max-width:36rem}.sm\:translate-y-5{--tw-translate-y: 1.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-end{justify-content:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:gap-0{gap:0px}.sm\:gap-6{gap:1.5rem}.sm\:space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(.5rem * var(--tw-space-x-reverse));margin-left:calc(.5rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}.sm\:rounded-lg{border-radius:var(--radius)}.sm\:p-6{padding:1.5rem}.sm\:text-left{text-align:left}.sm\:text-2xl{font-size:1.5rem;line-height:2rem}.sm\:text-3xl{font-size:1.875rem;line-height:2.25rem}}@media (min-width: 768px){.md\:absolute{position:absolute}.md\:relative{position:relative}.md\:bottom-0{bottom:0}.md\:right-8{right:2rem}.md\:right-auto{right:auto}.md\:top-8{top:2rem}.md\:col-span-1{grid-column:span 1 / span 1}.md\:mb-2{margin-bottom:.5rem}.md\:ml-14{margin-left:3.5rem}.md\:ml-64{margin-left:16rem}.md\:mt-2{margin-top:.5rem}.md\:block{display:block}.md\:flex{display:flex}.md\:inline-flex{display:inline-flex}.md\:hidden{display:none}.md\:h-full{height:100%}.md\:h-svh{height:100svh}.md\:w-14{width:3.5rem}.md\:w-32{width:8rem}.md\:w-64{width:16rem}.md\:w-80{width:20rem}.md\:w-\[420px\]{width:420px}.md\:w-\[var\(--radix-navigation-menu-viewport-width\)\]{width:var(--radix-navigation-menu-viewport-width)}.md\:w-auto{width:auto}.md\:max-w-\[31rem\]{max-width:31rem}.md\:translate-x-0{--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.md\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.md\:overflow-y-hidden{overflow-y:hidden}.md\:border-none{border-style:none}.md\:px-4{padding-left:1rem;padding-right:1rem}.md\:px-8{padding-left:2rem;padding-right:2rem}.md\:py-2{padding-top:.5rem;padding-bottom:.5rem}.md\:pt-0{padding-top:0}.md\:text-2xl{font-size:1.5rem;line-height:2rem}.md\:text-3xl{font-size:1.875rem;line-height:2.25rem}.md\:opacity-0{opacity:0}.after\:md\:block:after{content:var(--tw-content);display:block}}@media (min-width: 1024px){.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:w-1\/5{width:20%}.lg\:w-\[250px\]{width:250px}.lg\:max-w-none{max-width:none}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:flex-col{flex-direction:column}.lg\:gap-8{gap:2rem}.lg\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(0px * var(--tw-space-x-reverse));margin-left:calc(0px * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-x-12>:not([hidden])~:not([hidden]){--tw-space-x-reverse: 0;margin-right:calc(3rem * var(--tw-space-x-reverse));margin-left:calc(3rem * calc(1 - var(--tw-space-x-reverse)))}.lg\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(0px * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(0px * var(--tw-space-y-reverse))}.lg\:space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.lg\:p-8{padding:2rem}.lg\:px-0{padding-left:0;padding-right:0}.lg\:px-3{padding-left:.75rem;padding-right:.75rem}}@media (min-width: 1280px){.xl\:mr-2{margin-right:.5rem}.xl\:flex{display:flex}.xl\:inline-flex{display:inline-flex}.xl\:h-10{height:2.5rem}.xl\:w-60{width:15rem}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:justify-start{justify-content:flex-start}.xl\:px-3{padding-left:.75rem;padding-right:.75rem}.xl\:py-2{padding-top:.5rem;padding-bottom:.5rem}}.\[\&\:\:-webkit-calendar-picker-indicator\]\:hidden::-webkit-calendar-picker-indicator{display:none}.\[\&\:first-child\[data-selected\=true\]_button\]\:rounded-l-md:first-child[data-selected=true] button{border-top-left-radius:calc(var(--radius) - 2px);border-bottom-left-radius:calc(var(--radius) - 2px)}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\&\:last-child\[data-selected\=true\]_button\]\:rounded-r-md:last-child[data-selected=true] button{border-top-right-radius:calc(var(--radius) - 2px);border-bottom-right-radius:calc(var(--radius) - 2px)}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y: 2px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\>span\]\:line-clamp-1>span{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\[\&\>span\]\:text-xs>span{font-size:.75rem;line-height:1rem}.\[\&\>span\]\:opacity-70>span{opacity:.7}.\[\&\>svg\]\:size-3\.5>svg{width:.875rem;height:.875rem}.\[\&\>svg\]\:text-muted-foreground>svg{color:hsl(var(--muted-foreground))}.\[\&\>tr\]\:last\:border-b-0:last-child>tr{border-bottom-width:0px}.\[\&\[data-panel-group-direction\=vertical\]\>div\]\:rotate-90[data-panel-group-direction=vertical]>div{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&\[data-state\=open\]\>svg\]\:rotate-180[data-state=open]>svg{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.\[\&_\[cmdk-group-heading\]\]\:px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-group-heading\]\]\:py-1\.5 [cmdk-group-heading]{padding-top:.375rem;padding-bottom:.375rem}.\[\&_\[cmdk-group-heading\]\]\:text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\[\&_\[cmdk-group-heading\]\]\:font-medium [cmdk-group-heading]{font-weight:500}.\[\&_\[cmdk-group-heading\]\]\:text-muted-foreground [cmdk-group-heading]{color:hsl(var(--muted-foreground))}.\[\&_\[cmdk-group\]\:not\(\[hidden\]\)_\~\[cmdk-group\]\]\:pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\[\&_\[cmdk-group\]\]\:px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\[\&_\[cmdk-input-wrapper\]_svg\]\:w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\[\&_\[cmdk-input\]\]\:h-12 [cmdk-input]{height:3rem}.\[\&_\[cmdk-item\]\]\:px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\[\&_\[cmdk-item\]\]\:py-3 [cmdk-item]{padding-top:.75rem;padding-bottom:.75rem}.\[\&_\[cmdk-item\]_svg\]\:h-5 [cmdk-item] svg{height:1.25rem}.\[\&_\[cmdk-item\]_svg\]\:w-5 [cmdk-item] svg{width:1.25rem}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:invisible svg{visibility:hidden}.\[\&_svg\]\:size-4 svg{width:1rem;height:1rem}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-width:0px}.\[\&_tr\]\:border-b tr{border-bottom-width:1px}[data-slot=card-content] .\[\[data-slot\=card-content\]_\&\]\:bg-transparent,[data-slot=popover-content] .\[\[data-slot\=popover-content\]_\&\]\:bg-transparent{background-color:transparent}html.dark .markdown-body{color-scheme:dark;--color-prettylights-syntax-comment: #8b949e;--color-prettylights-syntax-constant: #79c0ff;--color-prettylights-syntax-entity: #d2a8ff;--color-prettylights-syntax-storage-modifier-import: #c9d1d9;--color-prettylights-syntax-entity-tag: #7ee787;--color-prettylights-syntax-keyword: #ff7b72;--color-prettylights-syntax-string: #a5d6ff;--color-prettylights-syntax-variable: #ffa657;--color-prettylights-syntax-brackethighlighter-unmatched: #f85149;--color-prettylights-syntax-invalid-illegal-text: #f0f6fc;--color-prettylights-syntax-invalid-illegal-bg: #8e1519;--color-prettylights-syntax-carriage-return-text: #f0f6fc;--color-prettylights-syntax-carriage-return-bg: #b62324;--color-prettylights-syntax-string-regexp: #7ee787;--color-prettylights-syntax-markup-list: #f2cc60;--color-prettylights-syntax-markup-heading: #1f6feb;--color-prettylights-syntax-markup-italic: #c9d1d9;--color-prettylights-syntax-markup-bold: #c9d1d9;--color-prettylights-syntax-markup-deleted-text: #ffdcd7;--color-prettylights-syntax-markup-deleted-bg: #67060c;--color-prettylights-syntax-markup-inserted-text: #aff5b4;--color-prettylights-syntax-markup-inserted-bg: #033a16;--color-prettylights-syntax-markup-changed-text: #ffdfb6;--color-prettylights-syntax-markup-changed-bg: #5a1e02;--color-prettylights-syntax-markup-ignored-text: #c9d1d9;--color-prettylights-syntax-markup-ignored-bg: #1158c7;--color-prettylights-syntax-meta-diff-range: #d2a8ff;--color-prettylights-syntax-brackethighlighter-angle: #8b949e;--color-prettylights-syntax-sublimelinter-gutter-mark: #484f58;--color-prettylights-syntax-constant-other-reference-link: #a5d6ff;--color-fg-default: #e6edf3;--color-fg-muted: #7d8590;--color-fg-subtle: #6e7681;--color-canvas-default: #0d1117;--color-canvas-subtle: #161b22;--color-border-default: #30363d;--color-border-muted: #21262d;--color-neutral-muted: rgba(110,118,129,.4);--color-accent-fg: #2f81f7;--color-accent-emphasis: #1f6feb;--color-attention-fg: #d29922;--color-attention-subtle: rgba(187,128,9,.15);--color-danger-fg: #f85149;--color-done-fg: #a371f7}html:not(.dark) .markdown-body{color-scheme:light;--color-prettylights-syntax-comment: #6e7781;--color-prettylights-syntax-constant: #0550ae;--color-prettylights-syntax-entity: #6639ba;--color-prettylights-syntax-storage-modifier-import: #24292f;--color-prettylights-syntax-entity-tag: #116329;--color-prettylights-syntax-keyword: #cf222e;--color-prettylights-syntax-string: #0a3069;--color-prettylights-syntax-variable: #953800;--color-prettylights-syntax-brackethighlighter-unmatched: #82071e;--color-prettylights-syntax-invalid-illegal-text: #f6f8fa;--color-prettylights-syntax-invalid-illegal-bg: #82071e;--color-prettylights-syntax-carriage-return-text: #f6f8fa;--color-prettylights-syntax-carriage-return-bg: #cf222e;--color-prettylights-syntax-string-regexp: #116329;--color-prettylights-syntax-markup-list: #3b2300;--color-prettylights-syntax-markup-heading: #0550ae;--color-prettylights-syntax-markup-italic: #24292f;--color-prettylights-syntax-markup-bold: #24292f;--color-prettylights-syntax-markup-deleted-text: #82071e;--color-prettylights-syntax-markup-deleted-bg: #ffebe9;--color-prettylights-syntax-markup-inserted-text: #116329;--color-prettylights-syntax-markup-inserted-bg: #dafbe1;--color-prettylights-syntax-markup-changed-text: #953800;--color-prettylights-syntax-markup-changed-bg: #ffd8b5;--color-prettylights-syntax-markup-ignored-text: #eaeef2;--color-prettylights-syntax-markup-ignored-bg: #0550ae;--color-prettylights-syntax-meta-diff-range: #8250df;--color-prettylights-syntax-brackethighlighter-angle: #57606a;--color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f;--color-prettylights-syntax-constant-other-reference-link: #0a3069;--color-fg-default: #1F2328;--color-fg-muted: #656d76;--color-fg-subtle: #6e7781;--color-canvas-default: #ffffff;--color-canvas-subtle: #f6f8fa;--color-border-default: #d0d7de;--color-border-muted: hsla(210,18%,87%,1);--color-neutral-muted: rgba(175,184,193,.2);--color-accent-fg: #0969da;--color-accent-emphasis: #0969da;--color-attention-fg: #9a6700;--color-attention-subtle: #fff8c5;--color-danger-fg: #d1242f;--color-done-fg: #8250df}.markdown-body{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;margin:0;color:var(--color-fg-default);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Noto Sans,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:16px;line-height:1.5;word-wrap:break-word}.markdown-body .octicon{display:inline-block;fill:currentColor;vertical-align:text-bottom}.markdown-body h1:hover .anchor .octicon-link:before,.markdown-body h2:hover .anchor .octicon-link:before,.markdown-body h3:hover .anchor .octicon-link:before,.markdown-body h4:hover .anchor .octicon-link:before,.markdown-body h5:hover .anchor .octicon-link:before,.markdown-body h6:hover .anchor .octicon-link:before{width:16px;height:16px;content:" ";display:inline-block;background-color:currentColor;-webkit-mask-image:url("data:image/svg+xml,");mask-image:url("data:image/svg+xml,")}.markdown-body details,.markdown-body figcaption,.markdown-body figure{display:block}.markdown-body summary{display:list-item}.markdown-body [hidden]{display:none!important}.markdown-body a{background-color:transparent;color:var(--color-accent-fg);text-decoration:none}.markdown-body abbr[title]{border-bottom:none;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.markdown-body b,.markdown-body strong{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dfn{font-style:italic}.markdown-body h1{margin:.67em 0;font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:2em;border-bottom:1px solid var(--color-border-muted)}.markdown-body mark{background-color:var(--color-attention-subtle);color:var(--color-fg-default)}.markdown-body small{font-size:90%}.markdown-body sub,.markdown-body sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}.markdown-body sub{bottom:-.25em}.markdown-body sup{top:-.5em}.markdown-body img{border-style:none;max-width:100%;box-sizing:content-box;background-color:var(--color-canvas-default)}.markdown-body code,.markdown-body kbd,.markdown-body pre,.markdown-body samp{font-family:monospace;font-size:1em}.markdown-body figure{margin:1em 40px}.markdown-body hr{box-sizing:content-box;overflow:hidden;background:transparent;border-bottom:1px solid var(--color-border-muted);height:.25em;padding:0;margin:24px 0;background-color:var(--color-border-default);border:0}.markdown-body input{font:inherit;margin:0;overflow:visible;font-family:inherit;font-size:inherit;line-height:inherit}.markdown-body [type=button],.markdown-body [type=reset],.markdown-body [type=submit]{-webkit-appearance:button}.markdown-body [type=checkbox],.markdown-body [type=radio]{box-sizing:border-box;padding:0}.markdown-body [type=number]::-webkit-inner-spin-button,.markdown-body [type=number]::-webkit-outer-spin-button{height:auto}.markdown-body [type=search]::-webkit-search-cancel-button,.markdown-body [type=search]::-webkit-search-decoration{-webkit-appearance:none}.markdown-body ::-webkit-input-placeholder{color:inherit;opacity:.54}.markdown-body ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.markdown-body a:hover{text-decoration:underline}.markdown-body ::-moz-placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body ::placeholder{color:var(--color-fg-subtle);opacity:1}.markdown-body hr:before{display:table;content:""}.markdown-body hr:after{display:table;clear:both;content:""}.markdown-body table{border-spacing:0;border-collapse:collapse;display:block;width:-moz-max-content;width:max-content;max-width:100%;overflow:auto}.markdown-body td,.markdown-body th{padding:0}.markdown-body details summary{cursor:pointer}.markdown-body details:not([open])>*:not(summary){display:none!important}.markdown-body a:focus,.markdown-body [role=button]:focus,.markdown-body input[type=radio]:focus,.markdown-body input[type=checkbox]:focus{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:focus:not(:focus-visible),.markdown-body [role=button]:focus:not(:focus-visible),.markdown-body input[type=radio]:focus:not(:focus-visible),.markdown-body input[type=checkbox]:focus:not(:focus-visible){outline:solid 1px transparent}.markdown-body a:focus-visible,.markdown-body [role=button]:focus-visible,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus-visible{outline:2px solid var(--color-accent-fg);outline-offset:-2px;box-shadow:none}.markdown-body a:not([class]):focus,.markdown-body a:not([class]):focus-visible,.markdown-body input[type=radio]:focus,.markdown-body input[type=radio]:focus-visible,.markdown-body input[type=checkbox]:focus,.markdown-body input[type=checkbox]:focus-visible{outline-offset:0}.markdown-body kbd{display:inline-block;padding:3px 5px;font:11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;line-height:10px;color:var(--color-fg-default);vertical-align:middle;background-color:var(--color-canvas-subtle);border:solid 1px var(--color-neutral-muted);border-bottom-color:var(--color-neutral-muted);border-radius:6px;box-shadow:inset 0 -1px 0 var(--color-neutral-muted)}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{margin-top:24px;margin-bottom:16px;font-weight:var(--base-text-weight-semibold, 600);line-height:1.25}.markdown-body h2{font-weight:var(--base-text-weight-semibold, 600);padding-bottom:.3em;font-size:1.5em;border-bottom:1px solid var(--color-border-muted)}.markdown-body h3{font-weight:var(--base-text-weight-semibold, 600);font-size:1.25em}.markdown-body h4{font-weight:var(--base-text-weight-semibold, 600);font-size:1em}.markdown-body h5{font-weight:var(--base-text-weight-semibold, 600);font-size:.875em}.markdown-body h6{font-weight:var(--base-text-weight-semibold, 600);font-size:.85em;color:var(--color-fg-muted)}.markdown-body p{margin-top:0;margin-bottom:10px}.markdown-body blockquote{margin:0;padding:0 1em;color:var(--color-fg-muted);border-left:.25em solid var(--color-border-default)}.markdown-body ul,.markdown-body ol{margin-top:0;margin-bottom:0;padding-left:2em}.markdown-body ol ol,.markdown-body ul ol{list-style-type:lower-roman}.markdown-body ul ul ol,.markdown-body ul ol ol,.markdown-body ol ul ol,.markdown-body ol ol ol{list-style-type:lower-alpha}.markdown-body dd{margin-left:0}.markdown-body tt,.markdown-body code,.markdown-body samp{font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px}.markdown-body pre{margin-top:0;margin-bottom:0;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace;font-size:12px;word-wrap:normal}.markdown-body .octicon{display:inline-block;overflow:visible!important;vertical-align:text-bottom;fill:currentColor}.markdown-body input::-webkit-outer-spin-button,.markdown-body input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none;appearance:none}.markdown-body .color-fg-accent{color:var(--color-accent-fg)!important}.markdown-body .color-fg-attention{color:var(--color-attention-fg)!important}.markdown-body .color-fg-done{color:var(--color-done-fg)!important}.markdown-body .flex-items-center{align-items:center!important}.markdown-body .mb-1{margin-bottom:var(--base-size-4, 4px)!important}.markdown-body .text-semibold{font-weight:var(--base-text-weight-medium, 500)!important}.markdown-body .d-inline-flex{display:inline-flex!important}.markdown-body:before{display:table;content:""}.markdown-body:after{display:table;clear:both;content:""}.markdown-body>*:first-child{margin-top:0!important}.markdown-body>*:last-child{margin-bottom:0!important}.markdown-body a:not([href]){color:inherit;text-decoration:none}.markdown-body .absent{color:var(--color-danger-fg)}.markdown-body .anchor{float:left;padding-right:4px;margin-left:-20px;line-height:1}.markdown-body .anchor:focus{outline:none}.markdown-body p,.markdown-body blockquote,.markdown-body ul,.markdown-body ol,.markdown-body dl,.markdown-body table,.markdown-body pre,.markdown-body details{margin-top:0;margin-bottom:16px}.markdown-body blockquote>:first-child{margin-top:0}.markdown-body blockquote>:last-child{margin-bottom:0}.markdown-body h1 .octicon-link,.markdown-body h2 .octicon-link,.markdown-body h3 .octicon-link,.markdown-body h4 .octicon-link,.markdown-body h5 .octicon-link,.markdown-body h6 .octicon-link{color:var(--color-fg-default);vertical-align:middle;visibility:hidden}.markdown-body h1:hover .anchor,.markdown-body h2:hover .anchor,.markdown-body h3:hover .anchor,.markdown-body h4:hover .anchor,.markdown-body h5:hover .anchor,.markdown-body h6:hover .anchor{text-decoration:none}.markdown-body h1:hover .anchor .octicon-link,.markdown-body h2:hover .anchor .octicon-link,.markdown-body h3:hover .anchor .octicon-link,.markdown-body h4:hover .anchor .octicon-link,.markdown-body h5:hover .anchor .octicon-link,.markdown-body h6:hover .anchor .octicon-link{visibility:visible}.markdown-body h1 tt,.markdown-body h1 code,.markdown-body h2 tt,.markdown-body h2 code,.markdown-body h3 tt,.markdown-body h3 code,.markdown-body h4 tt,.markdown-body h4 code,.markdown-body h5 tt,.markdown-body h5 code,.markdown-body h6 tt,.markdown-body h6 code{padding:0 .2em;font-size:inherit}.markdown-body summary h1,.markdown-body summary h2,.markdown-body summary h3,.markdown-body summary h4,.markdown-body summary h5,.markdown-body summary h6{display:inline-block}.markdown-body summary h1 .anchor,.markdown-body summary h2 .anchor,.markdown-body summary h3 .anchor,.markdown-body summary h4 .anchor,.markdown-body summary h5 .anchor,.markdown-body summary h6 .anchor{margin-left:-40px}.markdown-body summary h1,.markdown-body summary h2{padding-bottom:0;border-bottom:0}.markdown-body ul.no-list,.markdown-body ol.no-list{padding:0;list-style-type:none}.markdown-body ol[type="a s"]{list-style-type:lower-alpha}.markdown-body ol[type="A s"]{list-style-type:upper-alpha}.markdown-body ol[type="i s"]{list-style-type:lower-roman}.markdown-body ol[type="I s"]{list-style-type:upper-roman}.markdown-body ol[type="1"]{list-style-type:decimal}.markdown-body div>ol:not([type]){list-style-type:decimal}.markdown-body ul ul,.markdown-body ul ol,.markdown-body ol ol,.markdown-body ol ul{margin-top:0;margin-bottom:0}.markdown-body li>p{margin-top:16px}.markdown-body li+li{margin-top:.25em}.markdown-body dl{padding:0}.markdown-body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:var(--base-text-weight-semibold, 600)}.markdown-body dl dd{padding:0 16px;margin-bottom:16px}.markdown-body table th{font-weight:var(--base-text-weight-semibold, 600)}.markdown-body table th,.markdown-body table td{padding:6px 13px;border:1px solid var(--color-border-default)}.markdown-body table td>:last-child{margin-bottom:0}.markdown-body table tr{background-color:var(--color-canvas-default);border-top:1px solid var(--color-border-muted)}.markdown-body table tr:nth-child(2n){background-color:var(--color-canvas-subtle)}.markdown-body table img{background-color:transparent}.markdown-body img[align=right]{padding-left:20px}.markdown-body img[align=left]{padding-right:20px}.markdown-body .emoji{max-width:none;vertical-align:text-top;background-color:transparent}.markdown-body span.frame{display:block;overflow:hidden}.markdown-body span.frame>span{display:block;float:left;width:auto;padding:7px;margin:13px 0 0;overflow:hidden;border:1px solid var(--color-border-default)}.markdown-body span.frame span img{display:block;float:left}.markdown-body span.frame span span{display:block;padding:5px 0 0;clear:both;color:var(--color-fg-default)}.markdown-body span.align-center{display:block;overflow:hidden;clear:both}.markdown-body span.align-center>span{display:block;margin:13px auto 0;overflow:hidden;text-align:center}.markdown-body span.align-center span img{margin:0 auto;text-align:center}.markdown-body span.align-right{display:block;overflow:hidden;clear:both}.markdown-body span.align-right>span{display:block;margin:13px 0 0;overflow:hidden;text-align:right}.markdown-body span.align-right span img{margin:0;text-align:right}.markdown-body span.float-left{display:block;float:left;margin-right:13px;overflow:hidden}.markdown-body span.float-left span{margin:13px 0 0}.markdown-body span.float-right{display:block;float:right;margin-left:13px;overflow:hidden}.markdown-body span.float-right>span{display:block;margin:13px auto 0;overflow:hidden;text-align:right}.markdown-body code,.markdown-body tt{padding:.2em .4em;margin:0;font-size:85%;white-space:break-spaces;background-color:var(--color-neutral-muted);border-radius:6px}.markdown-body code br,.markdown-body tt br{display:none}.markdown-body del code{text-decoration:inherit}.markdown-body samp{font-size:85%}.markdown-body pre code{font-size:100%}.markdown-body pre>code{padding:0;margin:0;word-break:normal;white-space:pre;background:transparent;border:0}.markdown-body .highlight{margin-bottom:16px}.markdown-body .highlight pre{margin-bottom:0;word-break:normal}.markdown-body .highlight pre,.markdown-body pre{padding:16px;overflow:auto;font-size:85%;line-height:1.45;color:var(--color-fg-default);background-color:var(--color-canvas-subtle);border-radius:6px}.markdown-body pre code,.markdown-body pre tt{display:inline;max-width:auto;padding:0;margin:0;overflow:visible;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}.markdown-body .csv-data td,.markdown-body .csv-data th{padding:5px;overflow:hidden;font-size:12px;line-height:1;text-align:left;white-space:nowrap}.markdown-body .csv-data .blob-num{padding:10px 8px 9px;text-align:right;background:var(--color-canvas-default);border:0}.markdown-body .csv-data tr{border-top:0}.markdown-body .csv-data th{font-weight:var(--base-text-weight-semibold, 600);background:var(--color-canvas-subtle);border-top:0}.markdown-body [data-footnote-ref]:before{content:"["}.markdown-body [data-footnote-ref]:after{content:"]"}.markdown-body .footnotes{font-size:12px;color:var(--color-fg-muted);border-top:1px solid var(--color-border-default)}.markdown-body .footnotes ol{padding-left:16px}.markdown-body .footnotes ol ul{display:inline-block;padding-left:16px;margin-top:16px}.markdown-body .footnotes li{position:relative}.markdown-body .footnotes li:target:before{position:absolute;inset:-8px -8px -8px -24px;pointer-events:none;content:"";border:2px solid var(--color-accent-emphasis);border-radius:6px}.markdown-body .footnotes li:target{color:var(--color-fg-default)}.markdown-body .footnotes .data-footnote-backref g-emoji{font-family:monospace}.markdown-body .pl-c{color:var(--color-prettylights-syntax-comment)}.markdown-body .pl-c1,.markdown-body .pl-s .pl-v{color:var(--color-prettylights-syntax-constant)}.markdown-body .pl-e,.markdown-body .pl-en{color:var(--color-prettylights-syntax-entity)}.markdown-body .pl-smi,.markdown-body .pl-s .pl-s1{color:var(--color-prettylights-syntax-storage-modifier-import)}.markdown-body .pl-ent{color:var(--color-prettylights-syntax-entity-tag)}.markdown-body .pl-k{color:var(--color-prettylights-syntax-keyword)}.markdown-body .pl-s,.markdown-body .pl-pds,.markdown-body .pl-s .pl-pse .pl-s1,.markdown-body .pl-sr,.markdown-body .pl-sr .pl-cce,.markdown-body .pl-sr .pl-sre,.markdown-body .pl-sr .pl-sra{color:var(--color-prettylights-syntax-string)}.markdown-body .pl-v,.markdown-body .pl-smw{color:var(--color-prettylights-syntax-variable)}.markdown-body .pl-bu{color:var(--color-prettylights-syntax-brackethighlighter-unmatched)}.markdown-body .pl-ii{color:var(--color-prettylights-syntax-invalid-illegal-text);background-color:var(--color-prettylights-syntax-invalid-illegal-bg)}.markdown-body .pl-c2{color:var(--color-prettylights-syntax-carriage-return-text);background-color:var(--color-prettylights-syntax-carriage-return-bg)}.markdown-body .pl-sr .pl-cce{font-weight:700;color:var(--color-prettylights-syntax-string-regexp)}.markdown-body .pl-ml{color:var(--color-prettylights-syntax-markup-list)}.markdown-body .pl-mh,.markdown-body .pl-mh .pl-en,.markdown-body .pl-ms{font-weight:700;color:var(--color-prettylights-syntax-markup-heading)}.markdown-body .pl-mi{font-style:italic;color:var(--color-prettylights-syntax-markup-italic)}.markdown-body .pl-mb{font-weight:700;color:var(--color-prettylights-syntax-markup-bold)}.markdown-body .pl-md{color:var(--color-prettylights-syntax-markup-deleted-text);background-color:var(--color-prettylights-syntax-markup-deleted-bg)}.markdown-body .pl-mi1{color:var(--color-prettylights-syntax-markup-inserted-text);background-color:var(--color-prettylights-syntax-markup-inserted-bg)}.markdown-body .pl-mc{color:var(--color-prettylights-syntax-markup-changed-text);background-color:var(--color-prettylights-syntax-markup-changed-bg)}.markdown-body .pl-mi2{color:var(--color-prettylights-syntax-markup-ignored-text);background-color:var(--color-prettylights-syntax-markup-ignored-bg)}.markdown-body .pl-mdr{font-weight:700;color:var(--color-prettylights-syntax-meta-diff-range)}.markdown-body .pl-ba{color:var(--color-prettylights-syntax-brackethighlighter-angle)}.markdown-body .pl-sg{color:var(--color-prettylights-syntax-sublimelinter-gutter-mark)}.markdown-body .pl-corl{text-decoration:underline;color:var(--color-prettylights-syntax-constant-other-reference-link)}.markdown-body g-emoji{display:inline-block;min-width:1ch;font-family:"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol;font-size:1em;font-style:normal!important;font-weight:var(--base-text-weight-normal, 400);line-height:1;vertical-align:-.075em}.markdown-body g-emoji img{width:1em;height:1em}.markdown-body .task-list-item{list-style-type:none}.markdown-body .task-list-item label{font-weight:var(--base-text-weight-normal, 400)}.markdown-body .task-list-item.enabled label{cursor:pointer}.markdown-body .task-list-item+.task-list-item{margin-top:4px}.markdown-body .task-list-item .handle{display:none}.markdown-body .task-list-item-checkbox{margin:0 .2em .25em -1.4em;vertical-align:middle}.markdown-body .contains-task-list:dir(rtl) .task-list-item-checkbox{margin:0 -1.6em .25em .2em}.markdown-body .contains-task-list{position:relative}.markdown-body .contains-task-list:hover .task-list-item-convert-container,.markdown-body .contains-task-list:focus-within .task-list-item-convert-container{display:block;width:auto;height:24px;overflow:visible;clip:auto}.markdown-body .QueryBuilder .qb-entity{color:var(--color-prettylights-syntax-entity)}.markdown-body .QueryBuilder .qb-constant{color:var(--color-prettylights-syntax-constant)}.markdown-body ::-webkit-calendar-picker-indicator{filter:invert(50%)}.markdown-body .markdown-alert{padding:0 1em;margin-bottom:16px;color:inherit;border-left:.25em solid var(--color-border-default)}.markdown-body .markdown-alert>:first-child{margin-top:0}.markdown-body .markdown-alert>:last-child{margin-bottom:0}.markdown-body .markdown-alert.markdown-alert-note{border-left-color:var(--color-accent-fg)}.markdown-body .markdown-alert.markdown-alert-important{border-left-color:var(--color-done-fg)}.markdown-body .markdown-alert.markdown-alert-warning{border-left-color:var(--color-attention-fg)}
diff --git a/public/assets/admin/assets/index.js b/public/assets/admin/assets/index.js
index ec5ed45..a39cf36 100644
--- a/public/assets/admin/assets/index.js
+++ b/public/assets/admin/assets/index.js
@@ -1,21 +1,21 @@
-import{r as m,j as e,t as eo,c as so,I as Xt,a as xt,S as Tn,u as Bs,b as to,d as Dn,R as kr,e as Tr,f as ao,F as no,C as ro,L as Dr,T as Fr,g as Pr,h as lo,i as io,k as oo,l as co,m as $,z as h,n as M,o as we,p as Te,q as ae,s as Is,v as Ee,w as mo,x as uo,O as Fn,y as xo,A as ho,B as go,D as po,E as fo,G as jo,Q as vo,H as bo,J as yo,K as _o,P as No,M as wo,N as Co,U as So,V as ko,W as Rr,X as Lr,Y as Va,Z as Ia,_ as Pn,$ as os,a0 as Ma,a1 as Oa,a2 as Er,a3 as Vr,a4 as Ir,a5 as Mr,a6 as Or,a7 as To,a8 as zr,a9 as $r,aa as Ar,ab as qr,ac as ht,ad as Ur,ae as Do,af as Hr,ag as Kr,ah as Fo,ai as Po,aj as Ro,ak as Lo,al as Eo,am as Vo,an as Io,ao as Mo,ap as Oo,aq as zo,ar as Br,as as $o,at as Ao,au as Zs,av as Gr,aw as qo,ax as Uo,ay as Wr,az as Rn,aA as Ho,aB as Ko,aC as sr,aD as Bo,aE as Yr,aF as Go,aG as Jr,aH as Wo,aI as Yo,aJ as Jo,aK as Qo,aL as Xo,aM as Zo,aN as ec,aO as Qr,aP as sc,aQ as tc,aR as ac,aS as xs,aT as nc,aU as Ln,aV as rc,aW as lc,aX as Xr,aY as Zr,aZ as el,a_ as ic,a$ as oc,b0 as cc,b1 as sl,b2 as dc,b3 as En,b4 as tl,b5 as mc,b6 as al,b7 as uc,b8 as nl,b9 as xc,ba as rl,bb as ll,bc as hc,bd as gc,be as il,bf as pc,bg as ol,bh as fc,bi as cl,bj as dl,bk as ml,bl as jc,bm as ul,bn as vc,bo as bc,bp as Es,bq as Re,br as ws,bs as yc,bt as _c,bu as Nc,bv as wc,bw as Cc,bx as Sc,by as tr,bz as ar,bA as kc,bB as Tc,bC as Vn,bD as Dc,bE as Fc,bF as wa,bG as Dt,bH as Zt,bI as Pc,bJ as xl,bK as Rc,bL as Lc,bM as hl,bN as Ec,bO as Vc,bP as nr,bQ as jn,bR as vn,bS as Ic,bT as Mc,bU as gl,bV as Oc,bW as zc,bX as $c,bY as Ac,bZ as Ca,b_ as bn,b$ as Be,c0 as Sa,c1 as qc,c2 as nn,c3 as Uc,c4 as yn,c5 as us,c6 as Kt,c7 as Bt,c8 as _n,c9 as pl,ca as Ge,cb as Ze,cc as fl,cd as jl,ce as Hc,cf as Kc,cg as Bc,ch as Gc,ci as Wc,cj as vl,ck as Yc,cl as Jc,cm as Ke,cn as rr,co as Qc,cp as bl,cq as yl,cr as _l,cs as Nl,ct as wl,cu as Cl,cv as Xc,cw as Zc,cx as ed,cy as za,cz as tt,cA as hs,cB as gs,cC as sd,cD as td,cE as ad,cF as nd,cG as rd,cH as ka,cI as ld,cJ as id,cK as Nn,cL as In,cM as Mn,cN as od,cO as Fs,cP as Ps,cQ as $a,cR as cd,cS as Ta,cT as dd,cU as lr,cV as Sl,cW as ir,cX as Da,cY as md,cZ as kl,c_ as ud,c$ as xd,d0 as hd,d1 as Tl,d2 as gd,d3 as pd,d4 as Dl,d5 as wn,d6 as Fl,d7 as fd,d8 as Cn,d9 as Pl,da as jd,db as vd,dc as bd,dd as Rl,de as yd,df as _d,dg as Ll,dh as Gt,di as On,dj as Nd,dk as or,dl as El,dm as wd,dn as cr,dp as Cd,dq as Sd}from"./vendor.js";import"./index.js";var np=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function kd(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var t=function r(){return this instanceof r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return s[r]}})}),t}const Td={theme:"system",setTheme:()=>null},Vl=m.createContext(Td);function Dd({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=m.useState(()=>localStorage.getItem(t)||n);m.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const u=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(u);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(Vl.Provider,{...r,value:l,children:s})}const Fd=()=>{const s=m.useContext(Vl);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Pd=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),Rd=function(s,n){return new URL(s,n).href},dr={},Ne=function(n,t,r){let a=Promise.resolve();if(t&&t.length>0){const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),u=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(x=>{if(x=Rd(x,r),x in dr)return;dr[x]=!0;const o=x.endsWith(".css"),c=o?'[rel="stylesheet"]':"";if(!!r)for(let S=l.length-1;S>=0;S--){const w=l[S];if(w.href===x&&(!o||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${c}`))return;const F=document.createElement("link");if(F.rel=o?"stylesheet":Pd,o||(F.as="script"),F.crossOrigin="",F.href=x,u&&F.setAttribute("nonce",u),document.head.appendChild(F),o)return new Promise((S,w)=>{F.addEventListener("load",S),F.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${x}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function N(...s){return eo(so(s))}const Rt=xt("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"}}),D=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:u,...x},o)=>{const c=r?Tn:"button";return e.jsxs(c,{className:N(Rt({variant:n,size:t,className:s})),disabled:l||i,ref:o,...x,children:[(d&&l||!d&&!u&&l)&&e.jsx(Xt,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&u&&e.jsx("div",{className:"ml-2",children:u}),u&&l&&e.jsx(Xt,{className:"ml-2 h-4 w-4 animate-spin"})]})});D.displayName="Button";function bt({className:s,minimal:n=!1}){const t=Bs(),r=to(),a=r?.message||r?.statusText||"Unknown error occurred";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",{}),a]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(D,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(D,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function mr(){const s=Bs();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(D,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(D,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Ld(){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(D,{variant:"outline",children:"Learn more"})})]})})}function Ed(s){return typeof s>"u"}function Vd(s){return s===null}function Id(s){return Vd(s)||Ed(s)}class Md{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,t,r=null){const a=JSON.stringify({value:t,time:Date.now(),expire:r!==null?new Date().getTime()+r*1e3:null});this.storage.setItem(this.getKey(n),a)}get(n,t=null){const r=this.storage.getItem(this.getKey(n));if(!r)return{value:t,time:0};try{const a=JSON.parse(r),{value:i,time:l,expire:d}=a;return Id(d)||d>new Date().getTime()?{value:i,time:l}:(this.remove(n),{value:t,time:0})}catch{return this.remove(n),{value:t,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function Il({prefixKey:s="",storage:n=sessionStorage}){return new Md({prefixKey:s,storage:n})}const Ml="Xboard_",Od=function(s={}){return Il({prefixKey:s.prefixKey||"",storage:localStorage})},zd=function(s={}){return Il({prefixKey:s.prefixKey||"",storage:sessionStorage})},zn=Od({prefixKey:Ml});zd({prefixKey:Ml});const Ol="access_token";function ea(){return zn.get(Ol)}function zl(){zn.remove(Ol)}const ur=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function $d({children:s}){const n=Bs(),t=Dn(),r=ea();return m.useEffect(()=>{if(!r.value&&!ur.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),ur.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const Ve=m.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(kr,{ref:a,decorative:t,orientation:n,className:N("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));Ve.displayName=kr.displayName;const Ad=xt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Je=m.forwardRef(({className:s,...n},t)=>e.jsx(Tr,{ref:t,className:N(Ad(),s),...n}));Je.displayName=Tr.displayName;const De=no,$l=m.createContext({}),v=({...s})=>e.jsx($l.Provider,{value:{name:s.name},children:e.jsx(ro,{...s})}),Aa=()=>{const s=m.useContext($l),n=m.useContext(Al),{getFieldState:t,formState:r}=ao(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:i}=n;return{id:i,name:s.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},Al=m.createContext({}),j=m.forwardRef(({className:s,...n},t)=>{const r=m.useId();return e.jsx(Al.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:N("space-y-2",s),...n})})});j.displayName="FormItem";const b=m.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Aa();return e.jsx(Je,{ref:t,className:N(r&&"text-destructive",s),htmlFor:a,...n})});b.displayName="FormLabel";const _=m.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Aa();return e.jsx(Tn,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});_.displayName="FormControl";const z=m.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Aa();return e.jsx("p",{ref:t,id:r,className:N("text-[0.8rem] text-muted-foreground",s),...n})});z.displayName="FormDescription";const R=m.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Aa(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:N("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});R.displayName="FormMessage";const gt=lo,at=m.forwardRef(({className:s,...n},t)=>e.jsx(Dr,{ref:t,className:N("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));at.displayName=Dr.displayName;const $e=m.forwardRef(({className:s,...n},t)=>e.jsx(Fr,{ref:t,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}));$e.displayName=Fr.displayName;const ms=m.forwardRef(({className:s,...n},t)=>e.jsx(Pr,{ref:t,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}));ms.displayName=Pr.displayName;function ie(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),io(s).format(n))}function qd(s=void 0,n="YYYY-MM-DD"){return ie(s,n)}function xr(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function qs(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,i=>i.includes(".")?".00":i);return n?`¥${a}`:a}function sa(s){return new Promise(n=>{try{const t=document.createElement("button");t.style.position="fixed",t.style.left="-9999px",t.style.opacity="0",t.setAttribute("data-clipboard-text",s),document.body.appendChild(t);const r=new oo(t);r.on("success",()=>{r.destroy(),document.body.removeChild(t),n(!0)}),r.on("error",a=>{console.error("Clipboard.js failed:",a),r.destroy(),document.body.removeChild(t),n(!1)}),t.click()}catch(t){console.error("copyToClipboard failed:",t),n(!1)}})}function ze(s){if(!s)return"0 B";const n=1024,t=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(s)/Math.log(n));return`${parseFloat((s/Math.pow(n,r)).toFixed(2))} ${t[r]}`}const hr="i18nextLng";function Ud(){return console.log(localStorage.getItem(hr)),localStorage.getItem(hr)}function ql(){zl();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),t=new URL(window.location.href),a=`${t.pathname.split("/")[1]?`/${t.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=a+(n?`?redirect=${s}`:"")}const Hd=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Kd(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const St=co.create({baseURL:Kd(),timeout:12e3,headers:{"Content-Type":"application/json"}});St.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=ea();if(!Hd.includes(s.url?.split("?")[0]||"")){if(!n.value)return ql(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Ud()||"zh-CN",s},s=>Promise.reject(s));St.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,t=s.response?.data?.message;return(n===401||n===403)&&ql(),$.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const I={get:(s,n)=>St.get(s,n),post:(s,n,t)=>St.post(s,n,t),put:(s,n,t)=>St.put(s,n,t),delete:(s,n)=>St.delete(s,n)},Bd="access_token";function Gd(s){zn.set(Bd,s)}const it=window?.settings?.secure_path,Fa={getStats:()=>I.get(it+"/monitor/api/stats"),getOverride:()=>I.get(it+"/stat/getOverride"),getOrderStat:s=>I.get(it+"/stat/getOrder",{params:s}),getStatsData:()=>I.get(it+"/stat/getStats"),getNodeTrafficData:s=>I.get(it+"/stat/getTrafficRank",{params:s}),getServerLastRank:()=>I.get(it+"/stat/getServerLastRank"),getServerYesterdayRank:()=>I.get(it+"/stat/getServerYesterdayRank")},It=window?.settings?.secure_path,Wt={getList:()=>I.get(It+"/theme/getThemes"),getConfig:s=>I.post(It+"/theme/getThemeConfig",{name:s}),updateConfig:(s,n)=>I.post(It+"/theme/saveThemeConfig",{name:s,config:n}),upload:s=>{const n=new FormData;return n.append("file",s),I.post(It+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},drop:s=>I.post(It+"/theme/delete",{name:s})},yt=window?.settings?.secure_path,dt={getList:()=>I.get(yt+"/server/manage/getNodes"),save:s=>I.post(yt+"/server/manage/save",s),drop:s=>I.post(yt+"/server/manage/drop",s),copy:s=>I.post(yt+"/server/manage/copy",s),update:s=>I.post(yt+"/server/manage/update",s),sort:s=>I.post(yt+"/server/manage/sort",s)},rn=window?.settings?.secure_path,pt={getList:()=>I.get(rn+"/server/group/fetch"),save:s=>I.post(rn+"/server/group/save",s),drop:s=>I.post(rn+"/server/group/drop",s)},ln=window?.settings?.secure_path,qa={getList:()=>I.get(ln+"/server/route/fetch"),save:s=>I.post(ln+"/server/route/save",s),drop:s=>I.post(ln+"/server/route/drop",s)},ot=window?.settings?.secure_path,mt={getList:()=>I.get(ot+"/payment/fetch"),getMethodList:()=>I.get(ot+"/payment/getPaymentMethods"),getMethodForm:s=>I.post(ot+"/payment/getPaymentForm",s),save:s=>I.post(ot+"/payment/save",s),drop:s=>I.post(ot+"/payment/drop",s),updateStatus:s=>I.post(ot+"/payment/show",s),sort:s=>I.post(ot+"/payment/sort",s)},Mt=window?.settings?.secure_path,ta={getList:()=>I.get(`${Mt}/notice/fetch`),save:s=>I.post(`${Mt}/notice/save`,s),drop:s=>I.post(`${Mt}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${Mt}/notice/show`,{id:s}),sort:s=>I.post(`${Mt}/notice/sort`,{ids:s})},_t=window?.settings?.secure_path,Ft={getList:()=>I.get(_t+"/knowledge/fetch"),getInfo:s=>I.get(_t+"/knowledge/fetch?id="+s),save:s=>I.post(_t+"/knowledge/save",s),drop:s=>I.post(_t+"/knowledge/drop",s),updateStatus:s=>I.post(_t+"/knowledge/show",s),sort:s=>I.post(_t+"/knowledge/sort",s)},Ot=window?.settings?.secure_path,ys={getList:()=>I.get(Ot+"/plan/fetch"),save:s=>I.post(Ot+"/plan/save",s),update:s=>I.post(Ot+"/plan/update",s),drop:s=>I.post(Ot+"/plan/drop",s),sort:s=>I.post(Ot+"/plan/sort",{ids:s})},Nt=window?.settings?.secure_path,ct={getList:s=>I.post(Nt+"/order/fetch",s),getInfo:s=>I.post(Nt+"/order/detail",s),markPaid:s=>I.post(Nt+"/order/paid",s),makeCancel:s=>I.post(Nt+"/order/cancel",s),update:s=>I.post(Nt+"/order/update",s),assign:s=>I.post(Nt+"/order/assign",s)},ks=window?.settings?.secure_path,Ds={getTemplates:s=>I.post(ks+"/gift-card/templates",s),createTemplate:s=>I.post(ks+"/gift-card/create-template",s),updateTemplate:s=>I.post(ks+"/gift-card/update-template",s),deleteTemplate:s=>I.post(ks+"/gift-card/delete-template",s),getCodes:s=>I.post(ks+"/gift-card/codes",s),generateCodes:s=>s.download_csv?I.post(ks+"/gift-card/generate-codes",s,{responseType:"blob"}):I.post(ks+"/gift-card/generate-codes",s),toggleCode:s=>I.post(ks+"/gift-card/toggle-code",s),exportCodes:s=>I.get(ks+`/gift-card/export-codes?batch_id=${s}`,{responseType:"blob"}),getUsages:s=>I.post(ks+"/gift-card/usages",s),getStatistics:s=>I.post(ks+"/gift-card/statistics",s),getTypes:()=>I.get(ks+"/gift-card/types")},ma=window?.settings?.secure_path,Pa={getList:s=>I.post(ma+"/coupon/fetch",s),save:s=>I.post(ma+"/coupon/generate",s),drop:s=>I.post(ma+"/coupon/drop",s),update:s=>I.post(ma+"/coupon/update",s)},vs=window?.settings?.secure_path,Os={getList:s=>I.post(`${vs}/user/fetch`,s),update:s=>I.post(`${vs}/user/update`,s),resetSecret:s=>I.post(`${vs}/user/resetSecret`,{id:s}),generate:s=>s.download_csv?I.post(`${vs}/user/generate`,s,{responseType:"blob"}):I.post(`${vs}/user/generate`,s),getStats:s=>I.post(`${vs}/stat/getStatUser`,s),destroy:s=>I.post(`${vs}/user/destroy`,{id:s}),sendMail:s=>I.post(`${vs}/user/sendMail`,s),dumpCSV:s=>I.post(`${vs}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>I.post(`${vs}/user/ban`,s)},aa={getLogs:s=>I.get(`${vs}/traffic-reset/logs`,{params:s}),getStats:s=>I.get(`${vs}/traffic-reset/stats`,{params:s}),resetUser:s=>I.post(`${vs}/traffic-reset/reset-user`,s),getUserHistory:(s,n)=>I.get(`${vs}/traffic-reset/user/${s}/history`,{params:n})},ua=window?.settings?.secure_path,kt={getList:s=>I.post(ua+"/ticket/fetch",s),getInfo:s=>I.get(ua+"/ticket/fetch?id= "+s),reply:s=>I.post(ua+"/ticket/reply",s),close:s=>I.post(ua+"/ticket/close",{id:s})},as=window?.settings?.secure_path,ve={getSettings:(s="")=>I.get(as+"/config/fetch?key="+s),saveSettings:s=>I.post(as+"/config/save",s),getEmailTemplate:()=>I.get(as+"/config/getEmailTemplate"),sendTestMail:()=>I.post(as+"/config/testSendMail"),setTelegramWebhook:()=>I.post(as+"/config/setTelegramWebhook"),updateSystemConfig:s=>I.post(as+"/config/save",s),getSystemStatus:()=>I.get(`${as}/system/getSystemStatus`),getQueueStats:()=>I.get(`${as}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${as}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${as}/system/getQueueMasters`),getHorizonFailedJobs:s=>I.get(`${as}/system/getHorizonFailedJobs`,{params:s}),getSystemLog:s=>I.get(`${as}/system/getSystemLog`,{params:s}),getLogFiles:()=>I.get(`${as}/log/files`),getLogContent:s=>I.get(`${as}/log/fetch`,{params:s}),getLogClearStats:s=>I.get(`${as}/system/getLogClearStats`,{params:s}),clearSystemLog:s=>I.post(`${as}/system/clearSystemLog`,s)},As=window?.settings?.secure_path,Us={getPluginList:()=>I.get(`${As}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),I.post(`${As}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>I.post(`${As}/plugin/delete`,{code:s}),installPlugin:s=>I.post(`${As}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${As}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${As}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${As}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${As}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${As}/plugin/config`,{code:s,config:n})};window?.settings?.secure_path;const Wd=h.object({subscribe_template_singbox:h.string().optional().default(""),subscribe_template_clash:h.string().optional().default(""),subscribe_template_clashmeta:h.string().optional().default(""),subscribe_template_stash:h.string().optional().default(""),subscribe_template_surge:h.string().optional().default(""),subscribe_template_surfboard:h.string().optional().default("")}),gr=[{key:"singbox",label:"Sing-box",language:"json"},{key:"clash",label:"Clash",language:"yaml"},{key:"clashmeta",label:"Clash Meta",language:"yaml"},{key:"stash",label:"Stash",language:"yaml"},{key:"surge",label:"Surge",language:"ini"},{key:"surfboard",label:"Surfboard",language:"ini"}],pr={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function Yd(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),[a,i]=m.useState("singbox"),l=we({resolver:Te(Wd),defaultValues:pr,mode:"onChange"}),{data:d,isLoading:u}=ae({queryKey:["settings","client"],queryFn:()=>ve.getSettings("subscribe_template")}),{mutateAsync:x}=Is({mutationFn:ve.saveSettings,onSuccess:()=>{$.success(s("common.autoSaved"))},onError:F=>{console.error("保存失败:",F),$.error(s("common.saveFailed"))}});m.useEffect(()=>{if(d?.data?.subscribe_template){const F=d.data.subscribe_template;Object.entries(F).forEach(([S,w])=>{if(S in pr){const T=typeof w=="string"?w:"";l.setValue(S,T)}}),r.current=l.getValues()}},[d,l]);const o=m.useCallback(Ee.debounce(async F=>{if(!r.current||!Ee.isEqual(F,r.current)){t(!0);try{await x(F),r.current=F}catch(S){console.error("保存设置失败:",S)}finally{t(!1)}}},1500),[x]),c=m.useCallback(()=>{const F=l.getValues();o(F)},[l,o]),f=m.useCallback((F,S)=>e.jsx(v,{control:l.control,name:F,render:({field:w})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s(`subscribe_template.${F.replace("subscribe_template_","")}.title`)}),e.jsx(_,{children:e.jsx(mo,{height:"500px",defaultLanguage:S,value:w.value||"",onChange:T=>{w.onChange(T||""),c()},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})}),e.jsx(z,{children:s(`subscribe_template.${F.replace("subscribe_template_","")}.description`)}),e.jsx(R,{})]})}),[l.control,s,c]);return u?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")})}):e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(gt,{value:a,onValueChange:i,className:"w-full",children:[e.jsx(at,{className:"",children:gr.map(({key:F,label:S})=>e.jsx($e,{value:F,className:"text-xs",children:S},F))}),gr.map(({key:F,language:S})=>e.jsx(ms,{value:F,className:"mt-4",children:f(`subscribe_template_${F}`,S)},F))]}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500"}),s("common.saving")]})]})})}function Jd(){const{t:s}=M("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_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(Ve,{}),e.jsx(Yd,{})]})}const Qd=()=>e.jsx($d,{children:e.jsx(Fn,{})}),Xd=uo([{path:"/sign-in",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>hm);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Qd,{}),children:[{path:"/",lazy:async()=>({Component:(await Ne(()=>Promise.resolve().then(()=>Nm),void 0,import.meta.url)).default}),errorElement:e.jsx(bt,{}),children:[{index:!0,lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Hm);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(bt,{}),children:[{path:"system",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Wm);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Xm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>au);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ou);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>xu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ju);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Nu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Tu);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Lu);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ou);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(Jd,{})}]},{path:"payment",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ku);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Wu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>rx);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>xx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(bt,{}),children:[{path:"manage",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ux);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Wx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>eh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(bt,{}),children:[{path:"plan",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ch);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Nh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Lh);return{default:s}},void 0,import.meta.url)).default})},{path:"gift-card",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Zh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(bt,{}),children:[{path:"manage",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Dg);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Wg);return{default:s}},void 0,import.meta.url)).default})},{path:"traffic-reset-logs",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ep);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:bt},{path:"/404",Component:mr},{path:"/503",Component:Ld},{path:"*",Component:mr}]);function Zd(){return I.get("/user/info")}const on={token:ea()?.value||"",userInfo:null,isLoggedIn:!!ea()?.value,loading:!1,error:null},Yt=xo("user/fetchUserInfo",async()=>(await Zd()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),Ul=ho({name:"user",initialState:on,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>on},extraReducers:s=>{s.addCase(Yt.pending,n=>{n.loading=!0,n.error=null}).addCase(Yt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(Yt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return on})}}),{setToken:em,resetUserState:sm}=Ul.actions,tm=s=>s.user.userInfo,am=Ul.reducer,Hl=go({reducer:{user:am}});ea()?.value&&Hl.dispatch(Yt());po.use(fo).use(jo).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 nm=new vo;bo.createRoot(document.getElementById("root")).render(e.jsx(yo.StrictMode,{children:e.jsx(_o,{client:nm,children:e.jsx(No,{store:Hl,children:e.jsxs(Dd,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(wo,{router:Xd}),e.jsx(Co,{richColors:!0,position:"top-right"})]})})})}));const ke=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("rounded-xl border bg-card text-card-foreground shadow",s),...n}));ke.displayName="Card";const Fe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex flex-col space-y-1.5 p-6",s),...n}));Fe.displayName="CardHeader";const Le=m.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:N("font-semibold leading-none tracking-tight",s),...n}));Le.displayName="CardTitle";const Hs=m.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Hs.displayName="CardDescription";const Pe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("p-6 pt-0",s),...n}));Pe.displayName="CardContent";const rm=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex items-center p-6 pt-0",s),...n}));rm.displayName="CardFooter";const k=m.forwardRef(({className:s,type:n,...t},r)=>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:r,...t}));k.displayName="Input";const Kl=m.forwardRef(({className:s,...n},t)=>{const[r,a]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"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:t,...n}),e.jsx(D,{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:()=>a(i=>!i),children:r?e.jsx(So,{size:18}):e.jsx(ko,{size:18})})]})});Kl.displayName="PasswordInput";const lm=s=>I.post("/passport/auth/login",s);function im({className:s,onForgotPassword:n,...t}){const r=Bs(),a=Rr(),{t:i}=M("auth"),l=h.object({email:h.string().min(1,{message:i("signIn.validation.emailRequired")}),password:h.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=we({resolver:Te(l),defaultValues:{email:"",password:""}});async function u(x){try{const{data:o}=await lm(x);Gd(o.auth_data),a(em(o.auth_data)),await a(Yt()).unwrap(),r("/")}catch(o){console.error("Login failed:",o),o.response?.data?.message&&d.setError("root",{message:o.response.data.message})}}return e.jsx("div",{className:N("grid gap-6",s),...t,children:e.jsx(De,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(u),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[d.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:d.formState.errors.root.message}),e.jsx(v,{control:d.control,name:"email",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:i("signIn.email")}),e.jsx(_,{children:e.jsx(k,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...x})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"password",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:i("signIn.password")}),e.jsx(_,{children:e.jsx(Kl,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...x})}),e.jsx(R,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(D,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const de=Lr,ps=Er,om=Vr,Qs=Pn,Bl=m.forwardRef(({className:s,...n},t)=>e.jsx(Va,{ref:t,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}));Bl.displayName=Va.displayName;const ce=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(om,{children:[e.jsx(Bl,{}),e.jsxs(Ia,{ref:r,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),...t,children:[n,e.jsxs(Pn,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ce.displayName=Ia.displayName;const he=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});he.displayName="DialogHeader";const Me=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Me.displayName="DialogFooter";const me=m.forwardRef(({className:s,...n},t)=>e.jsx(Ma,{ref:t,className:N("text-lg font-semibold leading-none tracking-tight",s),...n}));me.displayName=Ma.displayName;const Ae=m.forwardRef(({className:s,...n},t)=>e.jsx(Oa,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Ae.displayName=Oa.displayName;const Pt=xt("inline-flex items-center justify-center gap-2 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:t,asChild:r=!1,...a},i)=>{const l=r?Tn:"button";return e.jsx(l,{className:N(Pt({variant:n,size:t,className:s})),ref:i,...a})});G.displayName="Button";const zs=Fo,Ks=Po,cm=Ro,dm=m.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Ir,{ref:a,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),...r,children:[t,e.jsx(Mr,{className:"ml-auto h-4 w-4"})]}));dm.displayName=Ir.displayName;const mm=m.forwardRef(({className:s,...n},t)=>e.jsx(Or,{ref:t,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}));mm.displayName=Or.displayName;const Ms=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(To,{children:e.jsx(zr,{ref:r,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),...t})}));Ms.displayName=zr.displayName;const Se=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx($r,{ref:r,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),...t}));Se.displayName=$r.displayName;const Gl=m.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(Ar,{ref:a,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:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(qr,{children:e.jsx(ht,{className:"h-4 w-4"})})}),n]}));Gl.displayName=Ar.displayName;const um=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Ur,{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),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(qr,{children:e.jsx(Do,{className:"h-4 w-4 fill-current"})})}),n]}));um.displayName=Ur.displayName;const Ua=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Hr,{ref:r,className:N("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ua.displayName=Hr.displayName;const et=m.forwardRef(({className:s,...n},t)=>e.jsx(Kr,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));et.displayName=Kr.displayName;const Sn=({className:s,...n})=>e.jsx("span",{className:N("ml-auto text-xs tracking-widest opacity-60",s),...n});Sn.displayName="DropdownMenuShortcut";const cn=[{code:"en-US",name:"English",flag:Lo,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Eo,shortName:"CN"}];function Wl(){const{i18n:s}=M(),n=a=>{s.changeLanguage(a)},t=cn.find(a=>a.code===s.language)||cn[1],r=t.flag;return e.jsxs(zs,{children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(r,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:t.shortName})]})}),e.jsx(Ms,{align:"end",className:"w-[120px]",children:cn.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(Se,{onClick:()=>n(a.code),className:N("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(i,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:N("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function xm(){const[s,n]=m.useState(!1),{t}=M("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative flex min-h-svh flex-col items-center justify-center bg-primary-foreground px-4 py-8 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(Wl,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px] md:w-[420px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold sm:text-3xl",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(ke,{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-tight sm:text-2xl",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(im,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(de,{open:s,onOpenChange:n,children:e.jsx(ce,{className:"max-w-[90vw] sm:max-w-lg",children:e.jsxs(he,{children:[e.jsx(me,{children:t("signIn.resetPassword.title")}),e.jsx(Ae,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"max-w-full overflow-x-auto rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(G,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>sa(r).then(()=>{$.success(t("common:copy.success"))}),children:e.jsx(Vo,{className:"h-4 w-4"})})]})})]})})})]})}const hm=Object.freeze(Object.defineProperty({__proto__:null,default:xm},Symbol.toStringTag,{value:"Module"})),qe=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,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",t&&"md:h-svh",s),...r}));qe.displayName="Layout";const Ue=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:N("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));Ue.displayName="LayoutHeader";const We=m.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:N("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));We.displayName="LayoutBody";const Yl=Io,Jl=Mo,Ql=Oo,be=zo,ge=$o,pe=Ao,ue=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Br,{ref:r,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),...t}));ue.displayName=Br.displayName;function Ha(){const{pathname:s}=Dn();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function Xl({key:s,defaultValue:n}){const[t,r]=m.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function gm(){const[s,n]=Xl({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(i=>i!==a))}}}function pm({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=M(),i=({sub:l,...d})=>{const u=`${a(d.title)}-${d.href}`;return n&&l?m.createElement(vm,{...d,sub:l,key:u,closeNav:r}):n?m.createElement(jm,{...d,key:u,closeNav:r}):l?m.createElement(fm,{...d,sub:l,key:u,closeNav:r}):m.createElement(Zl,{...d,key:u,closeNav:r})};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",t),children:e.jsx(be,{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(i)})})})}function Zl({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Ha(),{t:d}=M();return e.jsxs(Zs,{to:r,onClick:a,className:N(Rt({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",i&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":l(r)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),d(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:d(t)})]})}function fm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ha(),{isExpanded:l,toggleItem:d}=gm(),{t:u}=M(),x=!!r?.find(f=>i(f.href)),o=u(s),c=l(o)||x;return e.jsxs(Yl,{open:c,onOpenChange:()=>d(o),children:[e.jsxs(Jl,{className:N(Rt({variant:x?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),u(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(t)}),e.jsx("span",{className:N('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Gr,{stroke:1})})]}),e.jsx(Ql,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(f=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(Zl,{...f,subLink:!0,closeNav:a})},u(f.title)))})})]})}function jm({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Ha(),{t:l}=M();return e.jsxs(ge,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(Zs,{to:r,onClick:a,className:N(Rt({variant:i(r)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:l(s)})]})}),e.jsxs(ue,{side:"right",className:"flex items-center gap-4",children:[l(s),t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)})]})]})}function vm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ha(),{t:l}=M(),d=!!r?.find(u=>i(u.href));return e.jsxs(zs,{children:[e.jsxs(ge,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ks,{asChild:!0,children:e.jsx(D,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ue,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Gr,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(Ms,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ua,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(et,{}),r.map(({title:u,icon:x,label:o,href:c})=>e.jsx(Se,{asChild:!0,children:e.jsxs(Zs,{to:c,onClick:a,className:`${i(c)?"bg-secondary":""}`,children:[x," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(u)}),o&&e.jsx("span",{className:"ml-auto text-xs",children:l(o)})]})},`${l(u)}-${c}`))]})]})}const ei=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(qo,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Uo,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(Wr,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(Rn,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Ho,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Ko,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(sr,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Bo,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(Yr,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Go,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Jr,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Wo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Yo,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Jo,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(sr,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Qo,{size:18})},{title:"nav:giftCardManagement",label:"",href:"/finance/gift-card",icon:e.jsx(Xo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Zo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(ec,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(Qr,{size:18})}]}];function bm({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=m.useState(!1),{t:i}=M();return m.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:N(`fixed left-0 right-0 top-0 z-50 flex h-auto flex-col 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:()=>a(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${r?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(qe,{className:`flex h-full flex-col ${r?"h-[100vh] md:h-full":""}`,children:[e.jsxs(Ue,{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(D,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(sc,{}):e.jsx(tc,{})})]}),e.jsx(pm,{id:"sidebar-menu",className:N("flex-1 overflow-auto overscroll-contain",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:ei}),e.jsx("div",{className:N("border-t border-border/50 bg-background","px-4 py-2.5 text-xs text-muted-foreground",r?"block":"hidden md:block",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:"h-1.5 w-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:N("whitespace-nowrap tracking-wide","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(D,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(ac,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function ym(){const[s,n]=Xl({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function _m(){const[s,n]=ym();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(bm,{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(Fn,{})})]})}const Nm=Object.freeze(Object.defineProperty({__proto__:null,default:_m},Symbol.toStringTag,{value:"Module"})),nt=m.forwardRef(({className:s,...n},t)=>e.jsx(xs,{ref:t,className:N("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));nt.displayName=xs.displayName;const wm=({children:s,...n})=>e.jsx(de,{...n,children:e.jsx(ce,{className:"overflow-hidden p-0",children:e.jsx(nt,{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})})}),ft=m.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(nc,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(xs.Input,{ref:t,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})]}));ft.displayName=xs.Input.displayName;const rt=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.List,{ref:t,className:N("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));rt.displayName=xs.List.displayName;const jt=m.forwardRef((s,n)=>e.jsx(xs.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));jt.displayName=xs.Empty.displayName;const Ss=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.Group,{ref:t,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}));Ss.displayName=xs.Group.displayName;const Lt=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.Separator,{ref:t,className:N("-mx-1 h-px bg-border",s),...n}));Lt.displayName=xs.Separator.displayName;const rs=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.Item,{ref:t,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}));rs.displayName=xs.Item.displayName;function Cm(){const s=[];for(const n of ei)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function cs(){const[s,n]=m.useState(!1),t=Bs(),r=Cm(),{t:a}=M("search"),{t:i}=M("nav");m.useEffect(()=>{const d=u=>{u.key==="k"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),n(x=>!x))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=m.useCallback(d=>{n(!1),t(d)},[t]);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(Ln,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:a("placeholder")}),e.jsx("span",{className:"sr-only",children:a("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:a("shortcut.key")})]}),e.jsxs(wm,{open:s,onOpenChange:n,children:[e.jsx(ft,{placeholder:a("placeholder")}),e.jsxs(rt,{children:[e.jsx(jt,{children:a("noResults")}),e.jsx(Ss,{heading:a("title"),children:r.map(d=>e.jsxs(rs,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}function es(){const{theme:s,setTheme:n}=Fd();return m.useEffect(()=>{const t=s==="dark"?"#020817":"#fff",r=document.querySelector("meta[name='theme-color']");r&&r.setAttribute("content",t)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(D,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(rc,{size:20}):e.jsx(lc,{size:20})}),e.jsx(Wl,{})]})}const si=m.forwardRef(({className:s,...n},t)=>e.jsx(Xr,{ref:t,className:N("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));si.displayName=Xr.displayName;const ti=m.forwardRef(({className:s,...n},t)=>e.jsx(Zr,{ref:t,className:N("aspect-square h-full w-full",s),...n}));ti.displayName=Zr.displayName;const ai=m.forwardRef(({className:s,...n},t)=>e.jsx(el,{ref:t,className:N("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ai.displayName=el.displayName;function ss(){const s=Bs(),n=Rr(),t=ic(tm),{t:r}=M(["common"]),a=()=>{zl(),n(sm()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(zs,{children:[e.jsx(Ks,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(si,{className:"h-8 w-8",children:[e.jsx(ti,{src:t?.avatar_url,alt:i}),e.jsx(ai,{children:l})]})})}),e.jsxs(Ms,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ua,{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:i}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(et,{}),e.jsx(Se,{asChild:!0,children:e.jsxs(Zs,{to:"/config/system",children:[r("common:settings"),e.jsx(Sn,{children:"⌘S"})]})}),e.jsx(et,{}),e.jsxs(Se,{onClick:a,children:[r("common:logout"),e.jsx(Sn,{children:"⇧⌘Q"})]})]})]})}const J=oc,js=pc,Q=cc,W=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(sl,{ref:r,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),...t,children:[n,e.jsx(dc,{asChild:!0,children:e.jsx(En,{className:"h-4 w-4 opacity-50"})})]}));W.displayName=sl.displayName;const ni=m.forwardRef(({className:s,...n},t)=>e.jsx(tl,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(mc,{className:"h-4 w-4"})}));ni.displayName=tl.displayName;const ri=m.forwardRef(({className:s,...n},t)=>e.jsx(al,{ref:t,className:N("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(En,{className:"h-4 w-4"})}));ri.displayName=al.displayName;const Y=m.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(uc,{children:e.jsxs(nl,{ref:a,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",t==="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:t,...r,children:[e.jsx(ni,{}),e.jsx(xc,{className:N("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(ri,{})]})}));Y.displayName=nl.displayName;const Sm=m.forwardRef(({className:s,...n},t)=>e.jsx(rl,{ref:t,className:N("px-2 py-1.5 text-sm font-semibold",s),...n}));Sm.displayName=rl.displayName;const A=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(ll,{ref:r,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),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(hc,{children:e.jsx(ht,{className:"h-4 w-4"})})}),e.jsx(gc,{children:n})]}));A.displayName=ll.displayName;const km=m.forwardRef(({className:s,...n},t)=>e.jsx(il,{ref:t,className:N("-mx-1 my-1 h-px bg-muted",s),...n}));km.displayName=il.displayName;function Cs({className:s,classNames:n,showOutsideDays:t=!0,captionLayout:r="label",buttonVariant:a="ghost",formatters:i,components:l,...d}){const u=ol();return e.jsx(fc,{showOutsideDays:t,className:N("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,s),captionLayout:r,formatters:{formatMonthDropdown:x=>x.toLocaleString("default",{month:"short"}),...i},classNames:{root:N("w-fit",u.root),months:N("relative flex flex-col gap-4 md:flex-row",u.months),month:N("flex w-full flex-col gap-4",u.month),nav:N("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",u.nav),button_previous:N(Pt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",u.button_previous),button_next:N(Pt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",u.button_next),month_caption:N("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",u.month_caption),dropdowns:N("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",u.dropdowns),dropdown_root:N("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",u.dropdown_root),dropdown:N("absolute inset-0 opacity-0",u.dropdown),caption_label:N("select-none font-medium",r==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",u.caption_label),table:"w-full border-collapse",weekdays:N("flex",u.weekdays),weekday:N("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",u.weekday),week:N("mt-2 flex w-full",u.week),week_number_header:N("w-[--cell-size] select-none",u.week_number_header),week_number:N("text-muted-foreground select-none text-[0.8rem]",u.week_number),day:N("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",u.day),range_start:N("bg-accent rounded-l-md",u.range_start),range_middle:N("rounded-none",u.range_middle),range_end:N("bg-accent rounded-r-md",u.range_end),today:N("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",u.today),outside:N("text-muted-foreground aria-selected:text-muted-foreground",u.outside),disabled:N("text-muted-foreground opacity-50",u.disabled),hidden:N("invisible",u.hidden),...n},components:{Root:({className:x,rootRef:o,...c})=>e.jsx("div",{"data-slot":"calendar",ref:o,className:N(x),...c}),Chevron:({className:x,orientation:o,...c})=>o==="left"?e.jsx(cl,{className:N("size-4",x),...c}):o==="right"?e.jsx(dl,{className:N("size-4",x),...c}):e.jsx(ml,{className:N("size-4",x),...c}),DayButton:Tm,WeekNumber:({children:x,...o})=>e.jsx("td",{...o,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:x})}),...l},...d})}function Tm({className:s,day:n,modifiers:t,...r}){const a=ol(),i=m.useRef(null);return m.useEffect(()=>{t.focused&&i.current?.focus()},[t.focused]),e.jsx(G,{ref:i,variant:"ghost",size:"icon","data-day":n.date.toLocaleDateString(),"data-selected-single":t.selected&&!t.range_start&&!t.range_end&&!t.range_middle,"data-range-start":t.range_start,"data-range-end":t.range_end,"data-range-middle":t.range_middle,className:N("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",a.day,s),...r})}const ls=vc,is=bc,Xe=m.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(jc,{children:e.jsx(ul,{ref:a,align:n,sideOffset:t,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),...r})}));Xe.displayName=ul.displayName;const Ws={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Ut=s=>(s/100).toFixed(2),Dm=({active:s,payload:n,label:t})=>{const{t:r}=M();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:t}),n.map((a,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[r(a.name),":"]}),e.jsx("span",{className:"font-medium",children:a.name.includes(r("dashboard:overview.amount"))?`¥${Ut(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},Fm=[{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"}],Pm=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=Es(t,7);break;case"30d":r=Es(t,30);break;case"90d":r=Es(t,90);break;case"180d":r=Es(t,180);break;case"365d":r=Es(t,365);break;default:r=Es(t,30)}return{startDate:r,endDate:t}};function Rm(){const[s,n]=m.useState("amount"),[t,r]=m.useState("30d"),[a,i]=m.useState({from:Es(new Date,7),to:new Date}),{t:l}=M(),{startDate:d,endDate:u}=Pm(t,a),{data:x}=ae({queryKey:["orderStat",{start_date:Re(d,"yyyy-MM-dd"),end_date:Re(u,"yyyy-MM-dd")}],queryFn:async()=>{const{data:o}=await Fa.getOrderStat({start_date:Re(d,"yyyy-MM-dd"),end_date:Re(u,"yyyy-MM-dd")});return o},refetchInterval:3e4});return e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Le,{children:l("dashboard:overview.title")}),e.jsxs(Hs,{children:[x?.summary.start_date," ",l("dashboard:overview.to")," ",x?.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:t,onValueChange:o=>r(o),children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Q,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(Y,{children:Fm.map(o=>e.jsx(A,{value:o.value,children:l(o.label)},o.value))})]}),t==="custom"&&e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:N("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a?.from?a.to?e.jsxs(e.Fragment,{children:[Re(a.from,"yyyy-MM-dd")," -"," ",Re(a.to,"yyyy-MM-dd")]}):Re(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(Cs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:o=>{o?.from&&o?.to&&i({from:o.from,to:o.to})},captionLayout:"dropdown",numberOfMonths:2})})]})]}),e.jsx(gt,{value:s,onValueChange:o=>n(o),children:e.jsxs(at,{children:[e.jsx($e,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx($e,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(Pe,{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:l("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Ut(x?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:x?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",Ut(x?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Ut(x?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:x?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",x?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(yc,{width:"100%",height:"100%",children:e.jsxs(_c,{data:x?.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:Ws.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Ws.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:Ws.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Ws.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Nc,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:o=>Re(new Date(o),"MM-dd",{locale:kc})}),e.jsx(wc,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:o=>s==="amount"?`¥${Ut(o)}`:l("dashboard:overview.transactions",{count:o})}),e.jsx(Cc,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Sc,{content:e.jsx(Dm,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(tr,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Ws.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(tr,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Ws.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(ar,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Ws.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(ar,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Ws.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function je({className:s,...n}){return e.jsx("div",{className:N("animate-pulse rounded-md bg-primary/10",s),...n})}function Lm(){return e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(je,{className:"h-4 w-[120px]"}),e.jsx(je,{className:"h-4 w-4"})]}),e.jsxs(Pe,{children:[e.jsx(je,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(je,{className:"h-4 w-[100px]"})]})]})]})}function Em(){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(Lm,{},n))})}var le=(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))(le||{});const zt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},$t={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Vs=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Vs||{}),Ce=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(Ce||{});const xa={0:"待确认",1:"发放中",2:"有效",3:"无效"},ha={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Qe=(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))(Qe||{});const Vm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var xe=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s.Tuic="tuic",s.Socks="socks",s.Naive="naive",s.Http="http",s.Mieru="mieru",s.AnyTLS="anytls",s))(xe||{});const Ts=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"},{type:"tuic",label:"TUIC"},{type:"socks",label:"SOCKS"},{type:"naive",label:"Naive"},{type:"http",label:"HTTP"},{type:"mieru",label:"Mieru"},{type:"anytls",label:"AnyTLS"}],bs={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50",anytls:"#7E57C2"};var Ns=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Ns||{});const Im={1:"按金额优惠",2:"按比例优惠"};var Xs=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Xs||{}),ds=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(ds||{}),Jt=(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))(Jt||{});function Ys({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(ke,{className:N("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Le,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(Pe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Pc,{className:N("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:N("ml-1 text-xs",r.isPositive?"text-emerald-500":"text-red-500"),children:[r.isPositive?"+":"-",Math.abs(r.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function Mm({className:s}){const n=Bs(),{t}=M(),{data:r,isLoading:a}=ae({queryKey:["dashboardStats"],queryFn:async()=>(await Fa.getStatsData()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(Em,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",Ce.PENDING.toString()),l.set("status",le.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Ys,{title:t("dashboard:stats.todayIncome"),value:qs(r.todayIncome),icon:e.jsx(Tc,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Ys,{title:t("dashboard:stats.monthlyIncome"),value:qs(r.currentMonthIncome),icon:e.jsx(Vn,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Ys,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(Dc,{className:N("h-4 w-4",r.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:r.ticketPendingTotal>0?t("dashboard:stats.hasPendingTickets"):t("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:r.ticketPendingTotal>0}),e.jsx(Ys,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(Fc,{className:N("h-4 w-4",r.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:r.commissionPendingTotal>0?t("dashboard:stats.hasPendingCommission"):t("dashboard:stats.noPendingCommission"),onClick:i,highlight:r.commissionPendingTotal>0}),e.jsx(Ys,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(wa,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Ys,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(wa,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Ys,{title:t("dashboard:stats.monthlyUpload"),value:ze(r.monthTraffic.upload),icon:e.jsx(Dt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:ze(r.todayTraffic.upload)})}),e.jsx(Ys,{title:t("dashboard:stats.monthlyDownload"),value:ze(r.monthTraffic.download),icon:e.jsx(Zt,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:ze(r.todayTraffic.download)})})]})}const ut=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(xl,{ref:r,className:N("relative overflow-hidden",s),...t,children:[e.jsx(Rc,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Ra,{}),e.jsx(Lc,{})]}));ut.displayName=xl.displayName;const Ra=m.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(hl,{ref:r,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),...t,children:e.jsx(Ec,{className:"relative flex-1 rounded-full bg-border"})}));Ra.displayName=hl.displayName;const kn={today:{getValue:()=>{const s=Ic();return{start:s,end:Mc(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 fr({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=M(),i={today:a("dashboard:trafficRank.today"),last7days:a("dashboard:trafficRank.last7days"),last30days:a("dashboard:trafficRank.last30days"),custom:a("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:t,children:[e.jsx(W,{className:"w-[120px]",children:e.jsx(Q,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(Y,{position:"popper",className:"z-50",children:Object.entries(kn).map(([l])=>e.jsx(A,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(ls,{children:[e.jsx(is,{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(ws,{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:[Re(n.from,"yyyy-MM-dd")," -"," ",Re(n.to,"yyyy-MM-dd")]}):Re(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(Cs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:l=>{l?.from&&l?.to&&r({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const wt=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Om({className:s}){const{t:n}=M(),[t,r]=m.useState("today"),[a,i]=m.useState({from:Es(new Date,7),to:new Date}),[l,d]=m.useState("today"),[u,x]=m.useState({from:Es(new Date,7),to:new Date}),o=m.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:kn[t].getValue(),[t,a]),c=m.useMemo(()=>l==="custom"?{start:u.from,end:u.to}:kn[l].getValue(),[l,u]),{data:f}=ae({queryKey:["nodeTrafficRank",o.start,o.end],queryFn:()=>Fa.getNodeTrafficData({type:"node",start_time:Ee.round(o.start.getTime()/1e3),end_time:Ee.round(o.end.getTime()/1e3)}),refetchInterval:3e4}),{data:F}=ae({queryKey:["userTrafficRank",c.start,c.end],queryFn:()=>Fa.getNodeTrafficData({type:"user",start_time:Ee.round(c.start.getTime()/1e3),end_time:Ee.round(c.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:N("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(ke,{children:[e.jsx(Fe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Le,{className:"flex items-center text-base font-medium",children:[e.jsx(Vc,{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(fr,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(nr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Pe,{className:"flex-1",children:f?.data?e.jsxs(ut,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:f.data.map(S=>e.jsx(be,{delayDuration:200,children:e.jsxs(ge,{children:[e.jsx(pe,{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:S.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?e.jsx(jn,{className:"mr-1 h-3 w-3"}):e.jsx(vn,{className:"mr-1 h-3 w-3"}),Math.abs(S.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:`${S.value/f.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:wt(S.value)})]})]})})}),e.jsx(ue,{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:wt(S.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:wt(S.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?"+":"",S.change,"%"]})]})})]})},S.id))}),e.jsx(Ra,{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(ke,{children:[e.jsx(Fe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Le,{className:"flex items-center text-base font-medium",children:[e.jsx(wa,{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(fr,{selectedRange:l,customDateRange:u,onRangeChange:d,onCustomRangeChange:x}),e.jsx(nr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Pe,{className:"flex-1",children:F?.data?e.jsxs(ut,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:F.data.map(S=>e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:S.name}),e.jsxs("span",{className:N("ml-2 flex items-center text-xs font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?e.jsx(jn,{className:"mr-1 h-3 w-3"}):e.jsx(vn,{className:"mr-1 h-3 w-3"}),Math.abs(S.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:`${S.value/F.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:wt(S.value)})]})]})})}),e.jsx(ue,{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:wt(S.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:wt(S.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:N("font-medium",S.change>=0?"text-green-600":"text-red-600"),children:[S.change>=0?"+":"",S.change,"%"]})]})})]})},S.id))}),e.jsx(Ra,{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 zm=xt("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 U({className:s,variant:n,...t}){return e.jsx("div",{className:N(zm({variant:n}),s),...t})}const ba=m.forwardRef(({className:s,value:n,...t},r)=>e.jsx(gl,{ref:r,className:N("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(Oc,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));ba.displayName=gl.displayName;const $n=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:N("w-full caption-bottom text-sm",s),...n})}));$n.displayName="Table";const An=m.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:N("[&_tr]:border-b",s),...n}));An.displayName="TableHeader";const qn=m.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:N("[&_tr:last-child]:border-0",s),...n}));qn.displayName="TableBody";const $m=m.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:N("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));$m.displayName="TableFooter";const Js=m.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:N("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Js.displayName="TableRow";const Un=m.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,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}));Un.displayName="TableHead";const Tt=m.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:N("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Tt.displayName="TableCell";const Am=m.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:N("mt-4 text-sm text-muted-foreground",s),...n}));Am.displayName="TableCaption";function li({table:s}){const[n,t]=m.useState(""),{t:r}=M("common");m.useEffect(()=>{t((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const a=i=>{const l=parseInt(i);!isNaN(l)&&l>=1&&l<=s.getPageCount()?s.setPageIndex(l-1):t((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:r("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:r("table.pagination.itemsPerPage")}),e.jsxs(J,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:s.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx(A,{value:`${i}`,children:i},i))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(k,{type:"text",value:n,onChange:i=>t(i.target.value),onBlur:i=>a(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a(i.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:r("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(D,{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:r("table.pagination.firstPage")}),e.jsx(zc,{className:"h-4 w-4"})]}),e.jsxs(D,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.previousPage")}),e.jsx($c,{className:"h-4 w-4"})]}),e.jsxs(D,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.nextPage")}),e.jsx(Mr,{className:"h-4 w-4"})]}),e.jsxs(D,{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:r("table.pagination.lastPage")}),e.jsx(Ac,{className:"h-4 w-4"})]})]})]})]})}function ts({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:u=!0,isLoading:x=!1}){const{t:o}=M("common"),c=m.useRef(null),f=s.getAllColumns().filter(T=>T.getIsPinned()==="left"),F=s.getAllColumns().filter(T=>T.getIsPinned()==="right"),S=T=>f.slice(0,T).reduce((y,L)=>y+(L.getSize()??0),0),w=T=>F.slice(T+1).reduce((y,L)=>y+(L.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:c,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs($n,{children:[e.jsx(An,{children:s.getHeaderGroups().map(T=>e.jsx(Js,{className:"hover:bg-transparent",children:T.headers.map((y,L)=>{const C=y.column.getIsPinned()==="left",g=y.column.getIsPinned()==="right",p=C?S(f.indexOf(y.column)):void 0,V=g?w(F.indexOf(y.column)):void 0;return e.jsx(Un,{colSpan:y.colSpan,style:{width:y.getSize(),...C&&{left:p},...g&&{right:V}},className:N("h-11 bg-card px-4 text-muted-foreground",(C||g)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",C&&"before:right-0",g&&"before:left-0"]),children:y.isPlaceholder?null:Ca(y.column.columnDef.header,y.getContext())},y.id)})},T.id))}),e.jsx(qn,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((T,y)=>e.jsx(Js,{"data-state":T.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:L=>r?.(L,y),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:L=>d?.(L,y),children:T.getVisibleCells().map((L,C)=>{const g=L.column.getIsPinned()==="left",p=L.column.getIsPinned()==="right",V=g?S(f.indexOf(L.column)):void 0,E=p?w(F.indexOf(L.column)):void 0;return e.jsx(Tt,{style:{width:L.column.getSize(),...g&&{left:V},...p&&{right:E}},className:N("bg-card",(g||p)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",g&&"before:right-0",p&&"before:left-0"]),children:Ca(L.column.columnDef.cell,L.getContext())},L.id)})},T.id)):e.jsx(Js,{children:e.jsx(Tt,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:o("table.noData")})})})]})})}),u&&e.jsx(li,{table:s})]})}const ya=s=>{if(!s)return"";let n;if(typeof s=="string"){if(n=parseInt(s),isNaN(n))return s}else n=s;return(n.toString().length===10?new Date(n*1e3):new Date(n)).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})},At=pl(),qt=pl();function ga({data:s,isLoading:n,searchKeyword:t,selectedLevel:r,total:a,currentPage:i,pageSize:l,onViewDetail:d,onPageChange:u,onPageSizeChange:x}){const{t:o}=M(),c=S=>{switch(S.toLowerCase()){case"info":return e.jsx(Kt,{className:"h-4 w-4 text-blue-500"});case"warning":return e.jsx(Bt,{className:"h-4 w-4 text-yellow-500"});case"error":return e.jsx(_n,{className:"h-4 w-4 text-red-500"});default:return e.jsx(Kt,{className:"h-4 w-4 text-slate-500"})}},f=m.useMemo(()=>[At.accessor("level",{id:"level",header:()=>o("dashboard:systemLog.level"),size:80,cell:({getValue:S,row:w})=>{const T=S();return e.jsxs("div",{className:"flex items-center gap-1",children:[c(T),e.jsx("span",{className:N(T.toLowerCase()==="error"&&"text-red-600",T.toLowerCase()==="warning"&&"text-yellow-600",T.toLowerCase()==="info"&&"text-blue-600"),children:T})]})}}),At.accessor("created_at",{id:"created_at",header:()=>o("dashboard:systemLog.time"),size:160,cell:({getValue:S})=>ya(S())}),At.accessor(S=>S.title||S.message||"",{id:"title",header:()=>o("dashboard:systemLog.logTitle"),cell:({getValue:S})=>e.jsx("span",{className:"inline-block max-w-[300px] truncate",children:S()})}),At.accessor("method",{id:"method",header:()=>o("dashboard:systemLog.method"),size:100,cell:({getValue:S})=>{const w=S();return w?e.jsx(U,{variant:"outline",className:N(w==="GET"&&"border-blue-200 bg-blue-50 text-blue-700",w==="POST"&&"border-green-200 bg-green-50 text-green-700",w==="PUT"&&"border-amber-200 bg-amber-50 text-amber-700",w==="DELETE"&&"border-red-200 bg-red-50 text-red-700"),children:w}):null}}),At.display({id:"actions",header:()=>o("dashboard:systemLog.action"),size:80,cell:({row:S})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>d(S.original),"aria-label":o("dashboard:systemLog.viewDetail"),children:e.jsx(bn,{className:"h-4 w-4"})})})],[o,d]),F=Be({data:s,columns:f,getCoreRowModel:Ge(),getPaginationRowModel:Ze(),pageCount:Math.ceil(a/l),manualPagination:!0,state:{pagination:m.useMemo(()=>({pageIndex:i-1,pageSize:l}),[i,l])},onPaginationChange:S=>{let w,T;if(typeof S=="function"){const y=S({pageIndex:i-1,pageSize:l});w=y.pageIndex,T=y.pageSize}else w=S.pageIndex,T=S.pageSize;T!==l?x(T):u(w+1)}});return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(ts,{table:F,showPagination:!0,isLoading:n}),(t||r&&r!=="all")&&e.jsx("div",{className:"text-center text-sm text-muted-foreground",children:t&&r&&r!=="all"?o("dashboard:systemLog.filter.searchAndLevel",{keyword:t,level:r,count:a}):t?o("dashboard:systemLog.filter.searchOnly",{keyword:t,count:a}):o("dashboard:systemLog.filter.levelOnly",{level:r,count:a})})]})}function qm(){const{t:s}=M(),[n,t]=m.useState(0),[r,a]=m.useState(!1),[i,l]=m.useState(1),[d]=m.useState(10),[u,x]=m.useState(null),[o,c]=m.useState(!1),[f,F]=m.useState(!1),[S,w]=m.useState(1),[T,y]=m.useState(10),[L,C]=m.useState(null),[g,p]=m.useState(!1),[V,E]=m.useState(""),[P,K]=m.useState(""),[Z,se]=m.useState("all"),[ne,H]=m.useState(!1),[ee,fe]=m.useState(0),[fs,Ie]=m.useState("all"),[re,q]=m.useState(1e3),[oe,lt]=m.useState(!1),[$s,Et]=m.useState(null),[na,Vt]=m.useState(!1);m.useEffect(()=>{const B=setTimeout(()=>{K(V),V!==P&&w(1)},500);return()=>clearTimeout(B)},[V]);const{data:Gs,isLoading:te,refetch:ye,isRefetching:Ye}=ae({queryKey:["systemStatus",n],queryFn:async()=>(await ve.getSystemStatus()).data,refetchInterval:3e4}),{data:_e,isLoading:zi,refetch:sp,isRefetching:Yn}=ae({queryKey:["queueStats",n],queryFn:async()=>(await ve.getQueueStats()).data,refetchInterval:3e4}),{data:Jn,isLoading:$i,refetch:Ai}=ae({queryKey:["failedJobs",i,d],queryFn:async()=>{const B=await ve.getHorizonFailedJobs({current:i,page_size:d});return{data:B.data,total:B.total||0}},enabled:r}),{data:Qn,isLoading:ra,refetch:qi}=ae({queryKey:["systemLogs",S,T,Z,P],queryFn:async()=>{const B={current:S,page_size:T};Z&&Z!=="all"&&(B.level=Z),P.trim()&&(B.keyword=P.trim());const Ls=await ve.getSystemLog(B);return{data:Ls.data,total:Ls.total||0}},enabled:f}),Xn=Jn?.data||[],Ui=Jn?.total||0,la=Qn?.data||[],ia=Qn?.total||0,Hi=m.useMemo(()=>[qt.display({id:"failed_at",header:()=>s("dashboard:queue.details.time"),cell:({row:B})=>ya(B.original.failed_at)}),qt.display({id:"queue",header:()=>s("dashboard:queue.details.queue"),cell:({row:B})=>B.original.queue}),qt.display({id:"name",header:()=>s("dashboard:queue.details.name"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[150px] truncate",children:B.original.name})}),e.jsx(ue,{children:e.jsx("span",{children:B.original.name})})]})})}),qt.display({id:"exception",header:()=>s("dashboard:queue.details.exception"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[200px] truncate",children:B.original.exception.split(`
-`)[0]})}),e.jsx(ue,{className:"max-w-[300px] whitespace-pre-wrap",children:e.jsx("span",{children:B.original.exception})})]})})}),qt.display({id:"actions",header:()=>s("dashboard:queue.details.action"),size:80,cell:({row:B})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Wi(B.original),"aria-label":s("dashboard:queue.details.viewDetail"),children:e.jsx(bn,{className:"h-4 w-4"})})})],[s]),Zn=Be({data:Xn,columns:Hi,getCoreRowModel:Ge(),getPaginationRowModel:Ze(),pageCount:Math.ceil(Ui/d),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:d}},onPaginationChange:B=>{if(typeof B=="function"){const Ls=B({pageIndex:i-1,pageSize:d});er(Ls.pageIndex+1)}else er(B.pageIndex+1)}}),Ki=()=>{t(B=>B+1)},er=B=>{l(B)},oa=B=>{w(B)},ca=B=>{y(B),w(1)},Bi=B=>{se(B),w(1)},Gi=()=>{E(""),K(""),se("all"),w(1)},da=B=>{C(B),p(!0)},Wi=B=>{x(B),c(!0)},Yi=async()=>{try{const B=await ve.getLogClearStats({days:ee,level:fs==="all"?void 0:fs});Et(B.data),Vt(!0)}catch(B){console.error("Failed to get clear stats:",B),$.error(s("dashboard:systemLog.getStatsFailed"))}},Ji=async()=>{lt(!0);try{const{data:B}=await ve.clearSystemLog({days:ee,level:fs==="all"?void 0:fs,limit:re});B&&($.success(s("dashboard:systemLog.clearSuccess",{count:B.cleared_count}),{duration:3e3}),H(!1),Vt(!1),Et(null),ye())}catch(B){console.error("Failed to clear logs:",B),$.error(s("dashboard:systemLog.clearLogsFailed"))}finally{lt(!1)}};if(te||zi)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Sa,{className:"h-6 w-6 animate-spin"})});const Qi=B=>B?e.jsx(fl,{className:"h-5 w-5 text-green-500"}):e.jsx(jl,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Le,{className:"flex items-center gap-2",children:[e.jsx(qc,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Hs,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:Ki,disabled:Ye||Yn,children:e.jsx(nn,{className:N("h-4 w-4",(Ye||Yn)&&"animate-spin")})})]}),e.jsx(Pe,{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:[Qi(_e?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(U,{variant:_e?.status?"secondary":"destructive",children:_e?.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:_e?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:_e?.recentJobs||0}),e.jsx(ba,{value:(_e?.recentJobs||0)/(_e?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ue,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:_e?.periods?.recentJobs||0})})})]})}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:_e?.jobsPerMinute||0}),e.jsx(ba,{value:(_e?.jobsPerMinute||0)/(_e?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ue,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:_e?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsxs(Le,{className:"flex items-center gap-2",children:[e.jsx(Uc,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Hs,{children:s("dashboard:queue.details.description")})]}),e.jsx(Pe,{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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"cursor-pointer text-2xl font-bold text-destructive hover:underline",title:s("dashboard:queue.details.viewFailedJobs"),onClick:()=>a(!0),style:{userSelect:"none"},children:_e?.failedJobs||0}),e.jsx(bn,{className:"h-4 w-4 cursor-pointer text-muted-foreground hover:text-destructive",onClick:()=>a(!0),"aria-label":s("dashboard:queue.details.viewFailedJobs")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:_e?.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:[_e?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:_e?.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:[_e?.processes||0," /"," ",(_e?.processes||0)+(_e?.pausedMasters||0)]})]}),e.jsx(ba,{value:(_e?.processes||0)/((_e?.processes||0)+(_e?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Le,{className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-5 w-5"}),s("dashboard:systemLog.title")]}),e.jsx(Hs,{children:s("dashboard:systemLog.description")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>F(!0),children:s("dashboard:systemLog.viewAll")}),e.jsxs(G,{variant:"outline",onClick:()=>H(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.clearLogs")]})]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-900 dark:bg-blue-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kt,{className:"h-5 w-5 text-blue-500"}),e.jsx("p",{className:"font-medium text-blue-700 dark:text-blue-300",children:s("dashboard:systemLog.tabs.info")})]}),e.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:Gs?.logs?.info||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-900 dark:bg-yellow-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bt,{className:"h-5 w-5 text-yellow-500"}),e.jsx("p",{className:"font-medium text-yellow-700 dark:text-yellow-300",children:s("dashboard:systemLog.tabs.warning")})]}),e.jsx("p",{className:"text-2xl font-bold text-yellow-700 dark:text-yellow-300",children:Gs?.logs?.warning||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-900 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-5 w-5 text-red-500"}),e.jsx("p",{className:"font-medium text-red-700 dark:text-red-300",children:s("dashboard:systemLog.tabs.error")})]}),e.jsx("p",{className:"text-2xl font-bold text-red-700 dark:text-red-300",children:Gs?.logs?.error||0})]})]}),Gs?.logs&&Gs.logs.total>0&&e.jsxs("div",{className:"mt-3 text-center text-sm text-muted-foreground",children:[s("dashboard:systemLog.totalLogs"),": ",Gs.logs.total]})]})})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.failedJobsDetailTitle")})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(ts,{table:Zn,showPagination:!1,isLoading:$i}),e.jsx(li,{table:Zn}),Xn.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:s("dashboard:queue.details.noFailedJobs")})]}),e.jsxs(Me,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Ai(),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(Qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:o,onOpenChange:c,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.jobDetailTitle")})}),u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.id")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:u.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.time")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:u.failed_at})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.queue")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:u.queue})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.connection")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:u.connection})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.name")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:u.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.exception")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-red-700 dark:text-red-300",children:u.exception})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.payload")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(u.payload),null,2)}catch{return u.payload}})()})})]})]}),e.jsx(Me,{children:e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:s("common:close")})})]})}),e.jsx(de,{open:f,onOpenChange:F,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.title")})}),e.jsxs(gt,{value:Z,onValueChange:Bi,className:"w-full overflow-x-auto",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 p-1 md:flex-row md:items-center md:justify-between",children:[e.jsxs(at,{className:"grid w-auto grid-cols-4",children:[e.jsxs($e,{value:"all",className:"flex items-center gap-2",children:[e.jsx(yn,{className:"h-4 w-4"}),s("dashboard:systemLog.tabs.all")]}),e.jsxs($e,{value:"info",className:"flex items-center gap-2",children:[e.jsx(Kt,{className:"h-4 w-4 text-blue-500"}),s("dashboard:systemLog.tabs.info")]}),e.jsxs($e,{value:"warning",className:"flex items-center gap-2",children:[e.jsx(Bt,{className:"h-4 w-4 text-yellow-500"}),s("dashboard:systemLog.tabs.warning")]}),e.jsxs($e,{value:"error",className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-4 w-4 text-red-500"}),s("dashboard:systemLog.tabs.error")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ln,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(k,{placeholder:s("dashboard:systemLog.search"),value:V,onChange:B=>E(B.target.value),className:"w-full md:w-64"})]})]}),e.jsx(ms,{value:"all",className:"mt-0",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:P,selectedLevel:Z,total:ia,currentPage:S,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})}),e.jsx(ms,{value:"info",className:"mt-0 overflow-x-auto",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:P,selectedLevel:Z,total:ia,currentPage:S,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})}),e.jsx(ms,{value:"warning",className:"mt-0",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:P,selectedLevel:Z,total:ia,currentPage:S,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})}),e.jsx(ms,{value:"error",className:"mt-0",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:P,selectedLevel:Z,total:ia,currentPage:S,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})})]}),e.jsxs(Me,{children:[e.jsxs(G,{variant:"outline",onClick:()=>qi(),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(G,{variant:"outline",onClick:Gi,children:s("dashboard:systemLog.filter.reset")}),e.jsx(Qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:g,onOpenChange:p,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.detailTitle")})}),L&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.level")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:L.level})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.time")}),e.jsx("p",{children:ya(L.created_at)||ya(L.updated_at)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.logTitle")}),e.jsx("div",{className:"whitespace-pre-wrap rounded-md bg-muted/50 p-3",children:L.title||L.message||""})]}),(L.host||L.ip)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[L.host&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.host")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:L.host})]}),L.ip&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.ip")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:L.ip})]})]}),L.uri&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.uri")}),e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 p-3",children:e.jsx("code",{className:"text-sm",children:L.uri})})]}),L.method&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.method")}),e.jsx("div",{children:e.jsx(U,{variant:"outline",className:"text-base font-medium",children:L.method})})]}),L.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.requestData")}),e.jsx("div",{className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(L.data),null,2)}catch{return L.data}})()})})]}),L.context&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.exception")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs text-red-700 dark:text-red-300",children:(()=>{try{const B=JSON.parse(L.context);if(B.exception){const Ls=B.exception,vt=Ls["\0*\0message"]||"",Xi=Ls["\0*\0file"]||"",Zi=Ls["\0*\0line"]||"";return`${vt}
+import{r as m,j as e,t as so,c as to,I as Xt,a as xt,S as Dn,u as Bs,b as ao,d as Pn,R as Tr,e as Dr,f as no,F as ro,C as lo,L as Pr,T as Lr,g as Fr,h as io,i as oo,k as co,l as mo,m as $,z as h,n as M,o as we,p as Te,q as ne,s as Is,v as Ee,w as jn,x as uo,O as Ln,y as xo,A as ho,B as go,D as po,E as fo,G as jo,Q as vo,H as bo,J as yo,K as _o,P as No,M as wo,N as Co,U as So,V as ko,W as Rr,X as Er,Y as Va,Z as Ia,_ as Fn,$ as os,a0 as Ma,a1 as Oa,a2 as Vr,a3 as Ir,a4 as Mr,a5 as Or,a6 as zr,a7 as To,a8 as $r,a9 as Ar,aa as qr,ab as Hr,ac as ht,ad as Ur,ae as Do,af as Kr,ag as Br,ah as Po,ai as Lo,aj as Fo,ak as Ro,al as Eo,am as Vo,an as Io,ao as Mo,ap as Oo,aq as zo,ar as Gr,as as $o,at as Ao,au as Zs,av as Yr,aw as qo,ax as Ho,ay as Wr,az as Rn,aA as Uo,aB as Ko,aC as tr,aD as Bo,aE as Jr,aF as Go,aG as Qr,aH as Yo,aI as Wo,aJ as Jo,aK as Qo,aL as Xo,aM as Zo,aN as ec,aO as Xr,aP as sc,aQ as tc,aR as ac,aS as xs,aT as nc,aU as En,aV as rc,aW as lc,aX as Zr,aY as el,aZ as sl,a_ as ic,a$ as oc,b0 as cc,b1 as tl,b2 as dc,b3 as Vn,b4 as al,b5 as mc,b6 as nl,b7 as uc,b8 as rl,b9 as xc,ba as ll,bb as il,bc as hc,bd as gc,be as ol,bf as pc,bg as cl,bh as fc,bi as dl,bj as ml,bk as ul,bl as jc,bm as xl,bn as vc,bo as bc,bp as Es,bq as Fe,br as ws,bs as yc,bt as _c,bu as Nc,bv as wc,bw as Cc,bx as Sc,by as ar,bz as nr,bA as kc,bB as Tc,bC as In,bD as Dc,bE as Pc,bF as wa,bG as Dt,bH as Zt,bI as Lc,bJ as hl,bK as Fc,bL as Rc,bM as gl,bN as Ec,bO as Vc,bP as rr,bQ as vn,bR as bn,bS as Ic,bT as Mc,bU as pl,bV as Oc,bW as zc,bX as $c,bY as Ac,bZ as Ca,b_ as yn,b$ as Be,c0 as Sa,c1 as qc,c2 as nn,c3 as Hc,c4 as _n,c5 as us,c6 as Kt,c7 as Bt,c8 as Nn,c9 as fl,ca as Ge,cb as Ze,cc as jl,cd as vl,ce as Uc,cf as Kc,cg as Bc,ch as Gc,ci as Yc,cj as bl,ck as Wc,cl as Jc,cm as Ke,cn as lr,co as Qc,cp as yl,cq as _l,cr as Nl,cs as wl,ct as Cl,cu as Sl,cv as Xc,cw as Zc,cx as ed,cy as za,cz as tt,cA as hs,cB as gs,cC as sd,cD as td,cE as ad,cF as nd,cG as rd,cH as ka,cI as ld,cJ as id,cK as wn,cL as Mn,cM as On,cN as od,cO as Ps,cP as Ls,cQ as $a,cR as cd,cS as Ta,cT as dd,cU as ir,cV as kl,cW as or,cX as Da,cY as md,cZ as Tl,c_ as ud,c$ as xd,d0 as hd,d1 as Dl,d2 as gd,d3 as pd,d4 as Pl,d5 as Cn,d6 as Ll,d7 as fd,d8 as Sn,d9 as Fl,da as jd,db as vd,dc as bd,dd as Rl,de as yd,df as _d,dg as El,dh as Gt,di as zn,dj as Nd,dk as cr,dl as Vl,dm as wd,dn as dr,dp as Cd,dq as Sd}from"./vendor.js";import"./index.js";var np=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rp(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function kd(s){if(s.__esModule)return s;var n=s.default;if(typeof n=="function"){var t=function r(){return this instanceof r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(r){var a=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return s[r]}})}),t}const Td={theme:"system",setTheme:()=>null},Il=m.createContext(Td);function Dd({children:s,defaultTheme:n="system",storageKey:t="vite-ui-theme",...r}){const[a,i]=m.useState(()=>localStorage.getItem(t)||n);m.useEffect(()=>{const d=window.document.documentElement;if(d.classList.remove("light","dark"),a==="system"){const u=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";d.classList.add(u);return}d.classList.add(a)},[a]);const l={theme:a,setTheme:d=>{localStorage.setItem(t,d),i(d)}};return e.jsx(Il.Provider,{...r,value:l,children:s})}const Pd=()=>{const s=m.useContext(Il);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},Ld=function(){const n=typeof document<"u"&&document.createElement("link").relList;return n&&n.supports&&n.supports("modulepreload")?"modulepreload":"preload"}(),Fd=function(s,n){return new URL(s,n).href},mr={},Ne=function(n,t,r){let a=Promise.resolve();if(t&&t.length>0){const l=document.getElementsByTagName("link"),d=document.querySelector("meta[property=csp-nonce]"),u=d?.nonce||d?.getAttribute("nonce");a=Promise.allSettled(t.map(x=>{if(x=Fd(x,r),x in mr)return;mr[x]=!0;const o=x.endsWith(".css"),c=o?'[rel="stylesheet"]':"";if(!!r)for(let k=l.length-1;k>=0;k--){const C=l[k];if(C.href===x&&(!o||C.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${c}`))return;const P=document.createElement("link");if(P.rel=o?"stylesheet":Ld,o||(P.as="script"),P.crossOrigin="",P.href=x,u&&P.setAttribute("nonce",u),document.head.appendChild(P),o)return new Promise((k,C)=>{P.addEventListener("load",k),P.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${x}`)))})}))}function i(l){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=l,window.dispatchEvent(d),!d.defaultPrevented)throw l}return a.then(l=>{for(const d of l||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};function w(...s){return so(to(s))}const Ft=xt("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"}}),F=m.forwardRef(({className:s,variant:n,size:t,asChild:r=!1,children:a,disabled:i,loading:l=!1,leftSection:d,rightSection:u,...x},o)=>{const c=r?Dn:"button";return e.jsxs(c,{className:w(Ft({variant:n,size:t,className:s})),disabled:l||i,ref:o,...x,children:[(d&&l||!d&&!u&&l)&&e.jsx(Xt,{className:"mr-2 h-4 w-4 animate-spin"}),!l&&d&&e.jsx("div",{className:"mr-2",children:d}),a,!l&&u&&e.jsx("div",{className:"ml-2",children:u}),u&&l&&e.jsx(Xt,{className:"ml-2 h-4 w-4 animate-spin"})]})});F.displayName="Button";function bt({className:s,minimal:n=!1}){const t=Bs(),r=ao(),a=r?.message||r?.statusText||"Unknown error occurred";return e.jsx("div",{className:w("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",{}),a]}),!n&&e.jsxs("div",{className:"mt-6 flex gap-4",children:[e.jsx(F,{variant:"outline",onClick:()=>t(-1),children:"Go Back"}),e.jsx(F,{onClick:()=>t("/"),children:"Back to Home"})]})]})})}function ur(){const s=Bs();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(F,{variant:"outline",onClick:()=>s(-1),children:"Go Back"}),e.jsx(F,{onClick:()=>s("/"),children:"Back to Home"})]})]})})}function Rd(){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(F,{variant:"outline",children:"Learn more"})})]})})}function Ed(s){return typeof s>"u"}function Vd(s){return s===null}function Id(s){return Vd(s)||Ed(s)}class Md{storage;prefixKey;constructor(n){this.storage=n.storage,this.prefixKey=n.prefixKey}getKey(n){return`${this.prefixKey}${n}`.toUpperCase()}set(n,t,r=null){const a=JSON.stringify({value:t,time:Date.now(),expire:r!==null?new Date().getTime()+r*1e3:null});this.storage.setItem(this.getKey(n),a)}get(n,t=null){const r=this.storage.getItem(this.getKey(n));if(!r)return{value:t,time:0};try{const a=JSON.parse(r),{value:i,time:l,expire:d}=a;return Id(d)||d>new Date().getTime()?{value:i,time:l}:(this.remove(n),{value:t,time:0})}catch{return this.remove(n),{value:t,time:0}}}remove(n){this.storage.removeItem(this.getKey(n))}clear(){this.storage.clear()}}function Ml({prefixKey:s="",storage:n=sessionStorage}){return new Md({prefixKey:s,storage:n})}const Ol="Xboard_",Od=function(s={}){return Ml({prefixKey:s.prefixKey||"",storage:localStorage})},zd=function(s={}){return Ml({prefixKey:s.prefixKey||"",storage:sessionStorage})},$n=Od({prefixKey:Ol});zd({prefixKey:Ol});const zl="access_token";function ea(){return $n.get(zl)}function $l(){$n.remove(zl)}const xr=["/sign-in","/sign-in-2","/sign-up","/forgot-password","/otp"];function $d({children:s}){const n=Bs(),t=Pn(),r=ea();return m.useEffect(()=>{if(!r.value&&!xr.includes(t.pathname)){const a=encodeURIComponent(t.pathname+t.search);n(`/sign-in?redirect=${a}`)}},[r.value,t.pathname,t.search,n]),xr.includes(t.pathname)||r.value?e.jsx(e.Fragment,{children:s}):null}const Ve=m.forwardRef(({className:s,orientation:n="horizontal",decorative:t=!0,...r},a)=>e.jsx(Tr,{ref:a,decorative:t,orientation:n,className:w("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...r}));Ve.displayName=Tr.displayName;const Ad=xt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Je=m.forwardRef(({className:s,...n},t)=>e.jsx(Dr,{ref:t,className:w(Ad(),s),...n}));Je.displayName=Dr.displayName;const De=ro,Al=m.createContext({}),b=({...s})=>e.jsx(Al.Provider,{value:{name:s.name},children:e.jsx(lo,{...s})}),Aa=()=>{const s=m.useContext(Al),n=m.useContext(ql),{getFieldState:t,formState:r}=no(),a=t(s.name,r);if(!s)throw new Error("useFormField should be used within ");const{id:i}=n;return{id:i,name:s.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},ql=m.createContext({}),v=m.forwardRef(({className:s,...n},t)=>{const r=m.useId();return e.jsx(ql.Provider,{value:{id:r},children:e.jsx("div",{ref:t,className:w("space-y-2",s),...n})})});v.displayName="FormItem";const y=m.forwardRef(({className:s,...n},t)=>{const{error:r,formItemId:a}=Aa();return e.jsx(Je,{ref:t,className:w(r&&"text-destructive",s),htmlFor:a,...n})});y.displayName="FormLabel";const _=m.forwardRef(({...s},n)=>{const{error:t,formItemId:r,formDescriptionId:a,formMessageId:i}=Aa();return e.jsx(Dn,{ref:n,id:r,"aria-describedby":t?`${a} ${i}`:`${a}`,"aria-invalid":!!t,...s})});_.displayName="FormControl";const z=m.forwardRef(({className:s,...n},t)=>{const{formDescriptionId:r}=Aa();return e.jsx("p",{ref:t,id:r,className:w("text-[0.8rem] text-muted-foreground",s),...n})});z.displayName="FormDescription";const R=m.forwardRef(({className:s,children:n,...t},r)=>{const{error:a,formMessageId:i}=Aa(),l=a?String(a?.message):n;return l?e.jsx("p",{ref:r,id:i,className:w("text-[0.8rem] font-medium text-destructive",s),...t,children:l}):null});R.displayName="FormMessage";const gt=io,at=m.forwardRef(({className:s,...n},t)=>e.jsx(Pr,{ref:t,className:w("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...n}));at.displayName=Pr.displayName;const $e=m.forwardRef(({className:s,...n},t)=>e.jsx(Lr,{ref:t,className:w("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}));$e.displayName=Lr.displayName;const ms=m.forwardRef(({className:s,...n},t)=>e.jsx(Fr,{ref:t,className:w("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...n}));ms.displayName=Fr.displayName;function ie(s=void 0,n="YYYY-MM-DD HH:mm:ss"){return s==null?"":(Math.floor(s).toString().length===10&&(s=s*1e3),oo(s).format(n))}function qd(s=void 0,n="YYYY-MM-DD"){return ie(s,n)}function hr(s){const n=typeof s=="string"?parseFloat(s):s;return isNaN(n)?"0.00":n.toFixed(2)}function qs(s,n=!0){if(s==null)return n?"¥0.00":"0.00";const t=typeof s=="string"?parseFloat(s):s;if(isNaN(t))return n?"¥0.00":"0.00";const a=(t/100).toFixed(2).replace(/\.?0+$/,i=>i.includes(".")?".00":i);return n?`¥${a}`:a}function sa(s){return new Promise(n=>{try{const t=document.createElement("button");t.style.position="fixed",t.style.left="-9999px",t.style.opacity="0",t.setAttribute("data-clipboard-text",s),document.body.appendChild(t);const r=new co(t);r.on("success",()=>{r.destroy(),document.body.removeChild(t),n(!0)}),r.on("error",a=>{console.error("Clipboard.js failed:",a),r.destroy(),document.body.removeChild(t),n(!1)}),t.click()}catch(t){console.error("copyToClipboard failed:",t),n(!1)}})}function ze(s){if(s==null||s<=0)return"0 B";const n=1024,t=["B","KB","MB","GB","TB"];let r=Math.floor(Math.log(s)/Math.log(n));return r<0?r=0:r>=t.length&&(r=t.length-1),`${parseFloat((s/Math.pow(n,r)).toFixed(2))} ${t[r]}`}const gr="i18nextLng";function Hd(){return console.log(localStorage.getItem(gr)),localStorage.getItem(gr)}function Hl(){$l();const s=window.location.pathname,n=s&&!["/404","/sign-in"].includes(s),t=new URL(window.location.href),a=`${t.pathname.split("/")[1]?`/${t.pathname.split("/")[1]}`:""}#/sign-in`;window.location.href=a+(n?`?redirect=${s}`:"")}const Ud=["/passport/auth/login","/passport/auth/token2Login","/passport/auth/register","/guest/comm/config","/passport/comm/sendEmailVerify","/passport/auth/forget"];function Kd(){const s=window.settings?.base_url||"/";return s.endsWith("/")?s+"api/v2":s+"/api/v2"}const St=mo.create({baseURL:Kd(),timeout:12e3,headers:{"Content-Type":"application/json"}});St.interceptors.request.use(s=>{s.method?.toLowerCase()==="get"&&(s.params={...s.params,t:Date.now()});const n=ea();if(!Ud.includes(s.url?.split("?")[0]||"")){if(!n.value)return Hl(),Promise.reject({code:-1,message:"未登录"});s.headers.Authorization=n.value}return s.headers["Content-Language"]=Hd()||"zh-CN",s},s=>Promise.reject(s));St.interceptors.response.use(s=>s?.data||{code:-1,message:"未知错误"},s=>{const n=s.response?.status,t=s.response?.data?.message;return(n===401||n===403)&&Hl(),$.error(t||{401:"登录已过期",403:"没有权限",404:"资源或接口不存在"}[n]||"未知异常"),Promise.reject(s.response?.data||{data:null,code:-1,message:"未知错误"})});const I={get:(s,n)=>St.get(s,n),post:(s,n,t)=>St.post(s,n,t),put:(s,n,t)=>St.put(s,n,t),delete:(s,n)=>St.delete(s,n)},Bd="access_token";function Gd(s){$n.set(Bd,s)}const it=window?.settings?.secure_path,Pa={getStats:()=>I.get(it+"/monitor/api/stats"),getOverride:()=>I.get(it+"/stat/getOverride"),getOrderStat:s=>I.get(it+"/stat/getOrder",{params:s}),getStatsData:()=>I.get(it+"/stat/getStats"),getNodeTrafficData:s=>I.get(it+"/stat/getTrafficRank",{params:s}),getServerLastRank:()=>I.get(it+"/stat/getServerLastRank"),getServerYesterdayRank:()=>I.get(it+"/stat/getServerYesterdayRank")},It=window?.settings?.secure_path,Yt={getList:()=>I.get(It+"/theme/getThemes"),getConfig:s=>I.post(It+"/theme/getThemeConfig",{name:s}),updateConfig:(s,n)=>I.post(It+"/theme/saveThemeConfig",{name:s,config:n}),upload:s=>{const n=new FormData;return n.append("file",s),I.post(It+"/theme/upload",n,{headers:{"Content-Type":"multipart/form-data"}})},drop:s=>I.post(It+"/theme/delete",{name:s})},yt=window?.settings?.secure_path,dt={getList:()=>I.get(yt+"/server/manage/getNodes"),save:s=>I.post(yt+"/server/manage/save",s),drop:s=>I.post(yt+"/server/manage/drop",s),copy:s=>I.post(yt+"/server/manage/copy",s),update:s=>I.post(yt+"/server/manage/update",s),sort:s=>I.post(yt+"/server/manage/sort",s)},rn=window?.settings?.secure_path,pt={getList:()=>I.get(rn+"/server/group/fetch"),save:s=>I.post(rn+"/server/group/save",s),drop:s=>I.post(rn+"/server/group/drop",s)},ln=window?.settings?.secure_path,qa={getList:()=>I.get(ln+"/server/route/fetch"),save:s=>I.post(ln+"/server/route/save",s),drop:s=>I.post(ln+"/server/route/drop",s)},ot=window?.settings?.secure_path,mt={getList:()=>I.get(ot+"/payment/fetch"),getMethodList:()=>I.get(ot+"/payment/getPaymentMethods"),getMethodForm:s=>I.post(ot+"/payment/getPaymentForm",s),save:s=>I.post(ot+"/payment/save",s),drop:s=>I.post(ot+"/payment/drop",s),updateStatus:s=>I.post(ot+"/payment/show",s),sort:s=>I.post(ot+"/payment/sort",s)},Mt=window?.settings?.secure_path,ta={getList:()=>I.get(`${Mt}/notice/fetch`),save:s=>I.post(`${Mt}/notice/save`,s),drop:s=>I.post(`${Mt}/notice/drop`,{id:s}),updateStatus:s=>I.post(`${Mt}/notice/show`,{id:s}),sort:s=>I.post(`${Mt}/notice/sort`,{ids:s})},_t=window?.settings?.secure_path,Pt={getList:()=>I.get(_t+"/knowledge/fetch"),getInfo:s=>I.get(_t+"/knowledge/fetch?id="+s),save:s=>I.post(_t+"/knowledge/save",s),drop:s=>I.post(_t+"/knowledge/drop",s),updateStatus:s=>I.post(_t+"/knowledge/show",s),sort:s=>I.post(_t+"/knowledge/sort",s)},Ot=window?.settings?.secure_path,ys={getList:()=>I.get(Ot+"/plan/fetch"),save:s=>I.post(Ot+"/plan/save",s),update:s=>I.post(Ot+"/plan/update",s),drop:s=>I.post(Ot+"/plan/drop",s),sort:s=>I.post(Ot+"/plan/sort",{ids:s})},Nt=window?.settings?.secure_path,ct={getList:s=>I.post(Nt+"/order/fetch",s),getInfo:s=>I.post(Nt+"/order/detail",s),markPaid:s=>I.post(Nt+"/order/paid",s),makeCancel:s=>I.post(Nt+"/order/cancel",s),update:s=>I.post(Nt+"/order/update",s),assign:s=>I.post(Nt+"/order/assign",s)},ks=window?.settings?.secure_path,Ds={getTemplates:s=>I.post(ks+"/gift-card/templates",s),createTemplate:s=>I.post(ks+"/gift-card/create-template",s),updateTemplate:s=>I.post(ks+"/gift-card/update-template",s),deleteTemplate:s=>I.post(ks+"/gift-card/delete-template",s),getCodes:s=>I.post(ks+"/gift-card/codes",s),generateCodes:s=>s.download_csv?I.post(ks+"/gift-card/generate-codes",s,{responseType:"blob"}):I.post(ks+"/gift-card/generate-codes",s),toggleCode:s=>I.post(ks+"/gift-card/toggle-code",s),exportCodes:s=>I.get(ks+`/gift-card/export-codes?batch_id=${s}`,{responseType:"blob"}),getUsages:s=>I.post(ks+"/gift-card/usages",s),getStatistics:s=>I.post(ks+"/gift-card/statistics",s),getTypes:()=>I.get(ks+"/gift-card/types")},ma=window?.settings?.secure_path,La={getList:s=>I.post(ma+"/coupon/fetch",s),save:s=>I.post(ma+"/coupon/generate",s),drop:s=>I.post(ma+"/coupon/drop",s),update:s=>I.post(ma+"/coupon/update",s)},vs=window?.settings?.secure_path,Os={getList:s=>I.post(`${vs}/user/fetch`,s),update:s=>I.post(`${vs}/user/update`,s),resetSecret:s=>I.post(`${vs}/user/resetSecret`,{id:s}),generate:s=>s.download_csv?I.post(`${vs}/user/generate`,s,{responseType:"blob"}):I.post(`${vs}/user/generate`,s),getStats:s=>I.post(`${vs}/stat/getStatUser`,s),destroy:s=>I.post(`${vs}/user/destroy`,{id:s}),sendMail:s=>I.post(`${vs}/user/sendMail`,s),dumpCSV:s=>I.post(`${vs}/user/dumpCSV`,s,{responseType:"blob"}),batchBan:s=>I.post(`${vs}/user/ban`,s)},aa={getLogs:s=>I.get(`${vs}/traffic-reset/logs`,{params:s}),getStats:s=>I.get(`${vs}/traffic-reset/stats`,{params:s}),resetUser:s=>I.post(`${vs}/traffic-reset/reset-user`,s),getUserHistory:(s,n)=>I.get(`${vs}/traffic-reset/user/${s}/history`,{params:n})},ua=window?.settings?.secure_path,kt={getList:s=>I.post(ua+"/ticket/fetch",s),getInfo:s=>I.get(ua+"/ticket/fetch?id= "+s),reply:s=>I.post(ua+"/ticket/reply",s),close:s=>I.post(ua+"/ticket/close",{id:s})},as=window?.settings?.secure_path,ve={getSettings:(s="")=>I.get(as+"/config/fetch?key="+s),saveSettings:s=>I.post(as+"/config/save",s),getEmailTemplate:()=>I.get(as+"/config/getEmailTemplate"),sendTestMail:()=>I.post(as+"/config/testSendMail"),setTelegramWebhook:()=>I.post(as+"/config/setTelegramWebhook"),updateSystemConfig:s=>I.post(as+"/config/save",s),getSystemStatus:()=>I.get(`${as}/system/getSystemStatus`),getQueueStats:()=>I.get(`${as}/system/getQueueStats`),getQueueWorkload:()=>I.get(`${as}/system/getQueueWorkload`),getQueueMasters:()=>I.get(`${as}/system/getQueueMasters`),getHorizonFailedJobs:s=>I.get(`${as}/system/getHorizonFailedJobs`,{params:s}),getSystemLog:s=>I.get(`${as}/system/getSystemLog`,{params:s}),getLogFiles:()=>I.get(`${as}/log/files`),getLogContent:s=>I.get(`${as}/log/fetch`,{params:s}),getLogClearStats:s=>I.get(`${as}/system/getLogClearStats`,{params:s}),clearSystemLog:s=>I.post(`${as}/system/clearSystemLog`,s)},As=window?.settings?.secure_path,Hs={getPluginList:()=>I.get(`${As}/plugin/getPlugins`),uploadPlugin:s=>{const n=new FormData;return n.append("file",s),I.post(`${As}/plugin/upload`,n,{headers:{"Content-Type":"multipart/form-data"}})},deletePlugin:s=>I.post(`${As}/plugin/delete`,{code:s}),installPlugin:s=>I.post(`${As}/plugin/install`,{code:s}),uninstallPlugin:s=>I.post(`${As}/plugin/uninstall`,{code:s}),enablePlugin:s=>I.post(`${As}/plugin/enable`,{code:s}),disablePlugin:s=>I.post(`${As}/plugin/disable`,{code:s}),getPluginConfig:s=>I.get(`${As}/plugin/config`,{params:{code:s}}),updatePluginConfig:(s,n)=>I.post(`${As}/plugin/config`,{code:s,config:n})};window?.settings?.secure_path;const Yd=h.object({subscribe_template_singbox:h.string().optional().default(""),subscribe_template_clash:h.string().optional().default(""),subscribe_template_clashmeta:h.string().optional().default(""),subscribe_template_stash:h.string().optional().default(""),subscribe_template_surge:h.string().optional().default(""),subscribe_template_surfboard:h.string().optional().default("")}),pr=[{key:"singbox",label:"Sing-box",language:"json"},{key:"clash",label:"Clash",language:"yaml"},{key:"clashmeta",label:"Clash Meta",language:"yaml"},{key:"stash",label:"Stash",language:"yaml"},{key:"surge",label:"Surge",language:"ini"},{key:"surfboard",label:"Surfboard",language:"ini"}],fr={subscribe_template_singbox:"",subscribe_template_clash:"",subscribe_template_clashmeta:"",subscribe_template_stash:"",subscribe_template_surge:"",subscribe_template_surfboard:""};function Wd(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),[a,i]=m.useState("singbox"),l=we({resolver:Te(Yd),defaultValues:fr,mode:"onChange"}),{data:d,isLoading:u}=ne({queryKey:["settings","client"],queryFn:()=>ve.getSettings("subscribe_template")}),{mutateAsync:x}=Is({mutationFn:ve.saveSettings,onSuccess:()=>{$.success(s("common.autoSaved"))},onError:P=>{console.error("保存失败:",P),$.error(s("common.saveFailed"))}});m.useEffect(()=>{if(d?.data?.subscribe_template){const P=d.data.subscribe_template;Object.entries(P).forEach(([k,C])=>{if(k in fr){const T=typeof C=="string"?C:"";l.setValue(k,T)}}),r.current=l.getValues()}},[d,l]);const o=m.useCallback(Ee.debounce(async P=>{if(!r.current||!Ee.isEqual(P,r.current)){t(!0);try{await x(P),r.current=P}catch(k){console.error("保存设置失败:",k)}finally{t(!1)}}},1500),[x]),c=m.useCallback(()=>{const P=l.getValues();o(P)},[l,o]),j=m.useCallback((P,k)=>e.jsx(b,{control:l.control,name:P,render:({field:C})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s(`subscribe_template.${P.replace("subscribe_template_","")}.title`)}),e.jsx(_,{children:e.jsx(jn,{height:"500px",defaultLanguage:k,value:C.value||"",onChange:T=>{C.onChange(T||""),c()},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})}),e.jsx(z,{children:s(`subscribe_template.${P.replace("subscribe_template_","")}.description`)}),e.jsx(R,{})]})}),[l.control,s,c]);return u?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")})}):e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs(gt,{value:a,onValueChange:i,className:"w-full",children:[e.jsx(at,{className:"",children:pr.map(({key:P,label:k})=>e.jsx($e,{value:P,className:"text-xs",children:k},P))}),pr.map(({key:P,language:k})=>e.jsx(ms,{value:P,className:"mt-4",children:j(`subscribe_template_${P}`,k)},P))]}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500"}),s("common.saving")]})]})})}function Jd(){const{t:s}=M("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_template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("subscribe_template.description")})]}),e.jsx(Ve,{}),e.jsx(Wd,{})]})}const Qd=()=>e.jsx($d,{children:e.jsx(Ln,{})}),Xd=uo([{path:"/sign-in",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>hm);return{default:s}},void 0,import.meta.url)).default})},{element:e.jsx(Qd,{}),children:[{path:"/",lazy:async()=>({Component:(await Ne(()=>Promise.resolve().then(()=>Nm),void 0,import.meta.url)).default}),errorElement:e.jsx(bt,{}),children:[{index:!0,lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Um);return{default:s}},void 0,import.meta.url)).default})},{path:"config",errorElement:e.jsx(bt,{}),children:[{path:"system",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ym);return{default:s}},void 0,import.meta.url)).default}),children:[{index:!0,lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Xm);return{default:s}},void 0,import.meta.url)).default})},{path:"safe",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>au);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ou);return{default:s}},void 0,import.meta.url)).default})},{path:"invite",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>xu);return{default:s}},void 0,import.meta.url)).default})},{path:"frontend",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ju);return{default:s}},void 0,import.meta.url)).default})},{path:"server",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Nu);return{default:s}},void 0,import.meta.url)).default})},{path:"email",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Tu);return{default:s}},void 0,import.meta.url)).default})},{path:"telegram",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ru);return{default:s}},void 0,import.meta.url)).default})},{path:"APP",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ou);return{default:s}},void 0,import.meta.url)).default})},{path:"subscribe-template",element:e.jsx(Jd,{})}]},{path:"payment",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Ku);return{default:s}},void 0,import.meta.url)).default})},{path:"plugin",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Yu);return{default:s}},void 0,import.meta.url)).default})},{path:"theme",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Xu);return{default:s}},void 0,import.meta.url)).default})},{path:"notice",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>rx);return{default:s}},void 0,import.meta.url)).default})},{path:"knowledge",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>xx);return{default:s}},void 0,import.meta.url)).default})}]},{path:"server",errorElement:e.jsx(bt,{}),children:[{path:"manage",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Hx);return{default:s}},void 0,import.meta.url)).default})},{path:"group",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Yx);return{default:s}},void 0,import.meta.url)).default})},{path:"route",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>eh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"finance",errorElement:e.jsx(bt,{}),children:[{path:"plan",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ch);return{default:s}},void 0,import.meta.url)).default})},{path:"order",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Nh);return{default:s}},void 0,import.meta.url)).default})},{path:"coupon",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Rh);return{default:s}},void 0,import.meta.url)).default})},{path:"gift-card",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Zh);return{default:s}},void 0,import.meta.url)).default})}]},{path:"user",errorElement:e.jsx(bt,{}),children:[{path:"manage",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Dg);return{default:s}},void 0,import.meta.url)).default})},{path:"ticket",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>Yg);return{default:s}},void 0,import.meta.url)).default})},{path:"traffic-reset-logs",lazy:async()=>({Component:(await Ne(async()=>{const{default:s}=await Promise.resolve().then(()=>ep);return{default:s}},void 0,import.meta.url)).default})}]}]}]},{path:"/500",Component:bt},{path:"/404",Component:ur},{path:"/503",Component:Rd},{path:"*",Component:ur}]);function Zd(){return I.get("/user/info")}const on={token:ea()?.value||"",userInfo:null,isLoggedIn:!!ea()?.value,loading:!1,error:null},Wt=xo("user/fetchUserInfo",async()=>(await Zd()).data,{condition:(s,{getState:n})=>{const{user:t}=n();return!!t.token&&!t.loading}}),Ul=ho({name:"user",initialState:on,reducers:{setToken(s,n){s.token=n.payload,s.isLoggedIn=!!n.payload},resetUserState:()=>on},extraReducers:s=>{s.addCase(Wt.pending,n=>{n.loading=!0,n.error=null}).addCase(Wt.fulfilled,(n,t)=>{n.loading=!1,n.userInfo=t.payload,n.error=null}).addCase(Wt.rejected,(n,t)=>{if(n.loading=!1,n.error=t.error.message||"Failed to fetch user info",!n.token)return on})}}),{setToken:em,resetUserState:sm}=Ul.actions,tm=s=>s.user.userInfo,am=Ul.reducer,Kl=go({reducer:{user:am}});ea()?.value&&Kl.dispatch(Wt());po.use(fo).use(jo).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 nm=new vo;bo.createRoot(document.getElementById("root")).render(e.jsx(yo.StrictMode,{children:e.jsx(_o,{client:nm,children:e.jsx(No,{store:Kl,children:e.jsxs(Dd,{defaultTheme:"light",storageKey:"vite-ui-theme",children:[e.jsx(wo,{router:Xd}),e.jsx(Co,{richColors:!0,position:"top-right"})]})})})}));const ke=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:w("rounded-xl border bg-card text-card-foreground shadow",s),...n}));ke.displayName="Card";const Pe=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:w("flex flex-col space-y-1.5 p-6",s),...n}));Pe.displayName="CardHeader";const Re=m.forwardRef(({className:s,...n},t)=>e.jsx("h3",{ref:t,className:w("font-semibold leading-none tracking-tight",s),...n}));Re.displayName="CardTitle";const Us=m.forwardRef(({className:s,...n},t)=>e.jsx("p",{ref:t,className:w("text-sm text-muted-foreground",s),...n}));Us.displayName="CardDescription";const Le=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:w("p-6 pt-0",s),...n}));Le.displayName="CardContent";const rm=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:w("flex items-center p-6 pt-0",s),...n}));rm.displayName="CardFooter";const D=m.forwardRef(({className:s,type:n,...t},r)=>e.jsx("input",{type:n,className:w("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:r,...t}));D.displayName="Input";const Bl=m.forwardRef(({className:s,...n},t)=>{const[r,a]=m.useState(!1);return e.jsxs("div",{className:"relative rounded-md",children:[e.jsx("input",{type:r?"text":"password",className:w("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:t,...n}),e.jsx(F,{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:()=>a(i=>!i),children:r?e.jsx(So,{size:18}):e.jsx(ko,{size:18})})]})});Bl.displayName="PasswordInput";const lm=s=>I.post("/passport/auth/login",s);function im({className:s,onForgotPassword:n,...t}){const r=Bs(),a=Rr(),{t:i}=M("auth"),l=h.object({email:h.string().min(1,{message:i("signIn.validation.emailRequired")}),password:h.string().min(1,{message:i("signIn.validation.passwordRequired")}).min(7,{message:i("signIn.validation.passwordLength")})}),d=we({resolver:Te(l),defaultValues:{email:"",password:""}});async function u(x){try{const{data:o}=await lm(x);Gd(o.auth_data),a(em(o.auth_data)),await a(Wt()).unwrap(),r("/")}catch(o){console.error("Login failed:",o),o.response?.data?.message&&d.setError("root",{message:o.response.data.message})}}return e.jsx("div",{className:w("grid gap-6",s),...t,children:e.jsx(De,{...d,children:e.jsx("form",{onSubmit:d.handleSubmit(u),className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[d.formState.errors.root&&e.jsx("div",{className:"text-sm text-destructive",children:d.formState.errors.root.message}),e.jsx(b,{control:d.control,name:"email",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:i("signIn.email")}),e.jsx(_,{children:e.jsx(D,{placeholder:i("signIn.emailPlaceholder"),autoComplete:"email",...x})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"password",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:i("signIn.password")}),e.jsx(_,{children:e.jsx(Bl,{placeholder:i("signIn.passwordPlaceholder"),autoComplete:"current-password",...x})}),e.jsx(R,{})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(F,{variant:"link",type:"button",className:"px-0 text-sm font-normal text-muted-foreground hover:text-primary",onClick:n,children:i("signIn.forgotPassword")})}),e.jsx(F,{className:"w-full",size:"lg",loading:d.formState.isSubmitting,children:i("signIn.submit")})]})})})})}const de=Er,ps=Vr,om=Ir,Qs=Fn,Gl=m.forwardRef(({className:s,...n},t)=>e.jsx(Va,{ref:t,className:w("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}));Gl.displayName=Va.displayName;const ce=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(om,{children:[e.jsx(Gl,{}),e.jsxs(Ia,{ref:r,className:w("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),...t,children:[n,e.jsxs(Fn,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ce.displayName=Ia.displayName;const he=({className:s,...n})=>e.jsx("div",{className:w("flex flex-col space-y-1.5 text-center sm:text-left",s),...n});he.displayName="DialogHeader";const Me=({className:s,...n})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Me.displayName="DialogFooter";const me=m.forwardRef(({className:s,...n},t)=>e.jsx(Ma,{ref:t,className:w("text-lg font-semibold leading-none tracking-tight",s),...n}));me.displayName=Ma.displayName;const Ae=m.forwardRef(({className:s,...n},t)=>e.jsx(Oa,{ref:t,className:w("text-sm text-muted-foreground",s),...n}));Ae.displayName=Oa.displayName;const Lt=xt("inline-flex items-center justify-center gap-2 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:t,asChild:r=!1,...a},i)=>{const l=r?Dn:"button";return e.jsx(l,{className:w(Lt({variant:n,size:t,className:s})),ref:i,...a})});G.displayName="Button";const zs=Po,Ks=Lo,cm=Fo,dm=m.forwardRef(({className:s,inset:n,children:t,...r},a)=>e.jsxs(Mr,{ref:a,className:w("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),...r,children:[t,e.jsx(Or,{className:"ml-auto h-4 w-4"})]}));dm.displayName=Mr.displayName;const mm=m.forwardRef(({className:s,...n},t)=>e.jsx(zr,{ref:t,className:w("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}));mm.displayName=zr.displayName;const Ms=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(To,{children:e.jsx($r,{ref:r,sideOffset:n,className:w("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),...t})}));Ms.displayName=$r.displayName;const Se=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Ar,{ref:r,className:w("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),...t}));Se.displayName=Ar.displayName;const Yl=m.forwardRef(({className:s,children:n,checked:t,...r},a)=>e.jsxs(qr,{ref:a,className:w("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:t,...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Hr,{children:e.jsx(ht,{className:"h-4 w-4"})})}),n]}));Yl.displayName=qr.displayName;const um=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(Ur,{ref:r,className:w("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),...t,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Hr,{children:e.jsx(Do,{className:"h-4 w-4 fill-current"})})}),n]}));um.displayName=Ur.displayName;const Ha=m.forwardRef(({className:s,inset:n,...t},r)=>e.jsx(Kr,{ref:r,className:w("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",s),...t}));Ha.displayName=Kr.displayName;const et=m.forwardRef(({className:s,...n},t)=>e.jsx(Br,{ref:t,className:w("-mx-1 my-1 h-px bg-muted",s),...n}));et.displayName=Br.displayName;const kn=({className:s,...n})=>e.jsx("span",{className:w("ml-auto text-xs tracking-widest opacity-60",s),...n});kn.displayName="DropdownMenuShortcut";const cn=[{code:"en-US",name:"English",flag:Ro,shortName:"EN"},{code:"zh-CN",name:"中文",flag:Eo,shortName:"CN"}];function Wl(){const{i18n:s}=M(),n=a=>{s.changeLanguage(a)},t=cn.find(a=>a.code===s.language)||cn[1],r=t.flag;return e.jsxs(zs,{children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",children:[e.jsx(r,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:"text-sm font-medium",children:t.shortName})]})}),e.jsx(Ms,{align:"end",className:"w-[120px]",children:cn.map(a=>{const i=a.flag,l=a.code===s.language;return e.jsxs(Se,{onClick:()=>n(a.code),className:w("flex items-center gap-2 px-2 py-1.5 cursor-pointer",l&&"bg-accent"),children:[e.jsx(i,{className:"h-4 w-5 rounded-sm shadow-sm"}),e.jsx("span",{className:w("text-sm",l&&"font-medium"),children:a.name})]},a.code)})})]})}function xm(){const[s,n]=m.useState(!1),{t}=M("auth"),r=t("signIn.resetPassword.command");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container relative flex min-h-svh flex-col items-center justify-center bg-primary-foreground px-4 py-8 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(Wl,{})}),e.jsxs("div",{className:"mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px] md:w-[420px] lg:p-8",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold sm:text-3xl",children:window?.settings?.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:window?.settings?.description})]}),e.jsxs(ke,{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col space-y-2 text-left",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-tight sm:text-2xl",children:t("signIn.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("signIn.description")})]}),e.jsx(im,{onForgotPassword:()=>n(!0)})]})]})]}),e.jsx(de,{open:s,onOpenChange:n,children:e.jsx(ce,{className:"max-w-[90vw] sm:max-w-lg",children:e.jsxs(he,{children:[e.jsx(me,{children:t("signIn.resetPassword.title")}),e.jsx(Ae,{children:t("signIn.resetPassword.description")}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"max-w-full overflow-x-auto rounded-md bg-secondary p-4 pr-12 text-sm",children:r}),e.jsx(G,{variant:"ghost",size:"icon",className:"absolute right-2 top-2 h-8 w-8 hover:bg-secondary-foreground/10",onClick:()=>sa(r).then(()=>{$.success(t("common:copy.success"))}),children:e.jsx(Vo,{className:"h-4 w-4"})})]})})]})})})]})}const hm=Object.freeze(Object.defineProperty({__proto__:null,default:xm},Symbol.toStringTag,{value:"Module"})),qe=m.forwardRef(({className:s,fadedBelow:n=!1,fixedHeight:t=!1,...r},a)=>e.jsx("div",{ref:a,className:w("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",t&&"md:h-svh",s),...r}));qe.displayName="Layout";const He=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{ref:t,className:w("flex h-[var(--header-height)] flex-none items-center gap-4 bg-background p-4 md:px-8",s),...n}));He.displayName="LayoutHeader";const Ye=m.forwardRef(({className:s,fixedHeight:n,...t},r)=>e.jsx("div",{ref:r,className:w("flex-1 overflow-hidden px-4 py-6 md:px-8",n&&"h-[calc(100%-var(--header-height))]",s),...t}));Ye.displayName="LayoutBody";const Jl=Io,Ql=Mo,Xl=Oo,be=zo,ge=$o,pe=Ao,ue=m.forwardRef(({className:s,sideOffset:n=4,...t},r)=>e.jsx(Gr,{ref:r,sideOffset:n,className:w("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),...t}));ue.displayName=Gr.displayName;function Ua(){const{pathname:s}=Pn();return{checkActiveNav:t=>{if(t==="/"&&s==="/")return!0;const r=t.replace(/^\//,""),a=s.replace(/^\//,"");return r?a.startsWith(r):!1}}}function Zl({key:s,defaultValue:n}){const[t,r]=m.useState(()=>{const a=localStorage.getItem(s);return a!==null?JSON.parse(a):n});return m.useEffect(()=>{localStorage.setItem(s,JSON.stringify(t))},[t,s]),[t,r]}function gm(){const[s,n]=Zl({key:"collapsed-sidebar-items",defaultValue:[]}),t=a=>!s.includes(a);return{isExpanded:t,toggleItem:a=>{t(a)?n([...s,a]):n(s.filter(i=>i!==a))}}}function pm({links:s,isCollapsed:n,className:t,closeNav:r}){const{t:a}=M(),i=({sub:l,...d})=>{const u=`${a(d.title)}-${d.href}`;return n&&l?m.createElement(vm,{...d,sub:l,key:u,closeNav:r}):n?m.createElement(jm,{...d,key:u,closeNav:r}):l?m.createElement(fm,{...d,sub:l,key:u,closeNav:r}):m.createElement(ei,{...d,key:u,closeNav:r})};return e.jsx("div",{"data-collapsed":n,className:w("group border-b bg-background py-2 transition-[max-height,padding] duration-500 data-[collapsed=true]:py-2 md:border-none",t),children:e.jsx(be,{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(i)})})})}function ei({title:s,icon:n,label:t,href:r,closeNav:a,subLink:i=!1}){const{checkActiveNav:l}=Ua(),{t:d}=M();return e.jsxs(Zs,{to:r,onClick:a,className:w(Ft({variant:l(r)?"secondary":"ghost",size:"sm"}),"h-12 justify-start text-wrap rounded-none px-6",i&&"h-10 w-full border-l border-l-slate-500 px-2"),"aria-current":l(r)?"page":void 0,children:[e.jsx("div",{className:"mr-2",children:n}),d(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:d(t)})]})}function fm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ua(),{isExpanded:l,toggleItem:d}=gm(),{t:u}=M(),x=!!r?.find(j=>i(j.href)),o=u(s),c=l(o)||x;return e.jsxs(Jl,{open:c,onOpenChange:()=>d(o),children:[e.jsxs(Ql,{className:w(Ft({variant:x?"secondary":"ghost",size:"sm"}),"group h-12 w-full justify-start rounded-none px-6"),children:[e.jsx("div",{className:"mr-2",children:n}),u(s),t&&e.jsx("div",{className:"ml-2 rounded-lg bg-primary px-1 text-[0.625rem] text-primary-foreground",children:u(t)}),e.jsx("span",{className:w('ml-auto transition-all group-data-[state="open"]:-rotate-180'),children:e.jsx(Yr,{stroke:1})})]}),e.jsx(Xl,{className:"collapsibleDropdown",asChild:!0,children:e.jsx("ul",{children:r.map(j=>e.jsx("li",{className:"my-1 ml-8",children:e.jsx(ei,{...j,subLink:!0,closeNav:a})},u(j.title)))})})]})}function jm({title:s,icon:n,label:t,href:r,closeNav:a}){const{checkActiveNav:i}=Ua(),{t:l}=M();return e.jsxs(ge,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsxs(Zs,{to:r,onClick:a,className:w(Ft({variant:i(r)?"secondary":"ghost",size:"icon"}),"h-12 w-12"),children:[n,e.jsx("span",{className:"sr-only",children:l(s)})]})}),e.jsxs(ue,{side:"right",className:"flex items-center gap-4",children:[l(s),t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)})]})]})}function vm({title:s,icon:n,label:t,sub:r,closeNav:a}){const{checkActiveNav:i}=Ua(),{t:l}=M(),d=!!r?.find(u=>i(u.href));return e.jsxs(zs,{children:[e.jsxs(ge,{delayDuration:0,children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ks,{asChild:!0,children:e.jsx(F,{variant:d?"secondary":"ghost",size:"icon",className:"h-12 w-12",children:n})})}),e.jsxs(ue,{side:"right",className:"flex items-center gap-4",children:[l(s)," ",t&&e.jsx("span",{className:"ml-auto text-muted-foreground",children:l(t)}),e.jsx(Yr,{size:18,className:"-rotate-90 text-muted-foreground"})]})]}),e.jsxs(Ms,{side:"right",align:"start",sideOffset:4,children:[e.jsxs(Ha,{children:[l(s)," ",t?`(${l(t)})`:""]}),e.jsx(et,{}),r.map(({title:u,icon:x,label:o,href:c})=>e.jsx(Se,{asChild:!0,children:e.jsxs(Zs,{to:c,onClick:a,className:`${i(c)?"bg-secondary":""}`,children:[x," ",e.jsx("span",{className:"ml-2 max-w-52 text-wrap",children:l(u)}),o&&e.jsx("span",{className:"ml-auto text-xs",children:l(o)})]})},`${l(u)}-${c}`))]})]})}const si=[{title:"nav:dashboard",label:"",href:"/",icon:e.jsx(qo,{size:18})},{title:"nav:systemManagement",label:"",href:"",icon:e.jsx(Ho,{size:18}),sub:[{title:"nav:systemConfig",label:"",href:"/config/system",icon:e.jsx(Wr,{size:18})},{title:"nav:pluginManagement",label:"",href:"/config/plugin",icon:e.jsx(Rn,{size:18})},{title:"nav:themeConfig",label:"",href:"/config/theme",icon:e.jsx(Uo,{size:18})},{title:"nav:noticeManagement",label:"",href:"/config/notice",icon:e.jsx(Ko,{size:18})},{title:"nav:paymentConfig",label:"",href:"/config/payment",icon:e.jsx(tr,{size:18})},{title:"nav:knowledgeManagement",label:"",href:"/config/knowledge",icon:e.jsx(Bo,{size:18})}]},{title:"nav:nodeManagement",label:"",href:"",icon:e.jsx(Jr,{size:18}),sub:[{title:"nav:nodeManagement",label:"",href:"/server/manage",icon:e.jsx(Go,{size:18})},{title:"nav:permissionGroupManagement",label:"",href:"/server/group",icon:e.jsx(Qr,{size:18})},{title:"nav:routeManagement",label:"",href:"/server/route",icon:e.jsx(Yo,{size:18})}]},{title:"nav:subscriptionManagement",label:"",href:"",icon:e.jsx(Wo,{size:18}),sub:[{title:"nav:planManagement",label:"",href:"/finance/plan",icon:e.jsx(Jo,{size:18})},{title:"nav:orderManagement",label:"",href:"/finance/order",icon:e.jsx(tr,{size:18})},{title:"nav:couponManagement",label:"",href:"/finance/coupon",icon:e.jsx(Qo,{size:18})},{title:"nav:giftCardManagement",label:"",href:"/finance/gift-card",icon:e.jsx(Xo,{size:18})}]},{title:"nav:userManagement",label:"",href:"",icon:e.jsx(Zo,{size:18}),sub:[{title:"nav:userManagement",label:"",href:"/user/manage",icon:e.jsx(ec,{size:18})},{title:"nav:ticketManagement",label:"",href:"/user/ticket",icon:e.jsx(Xr,{size:18})}]}];function bm({className:s,isCollapsed:n,setIsCollapsed:t}){const[r,a]=m.useState(!1),{t:i}=M();return m.useEffect(()=>{r?document.body.classList.add("overflow-hidden"):document.body.classList.remove("overflow-hidden")},[r]),e.jsxs("aside",{className:w(`fixed left-0 right-0 top-0 z-50 flex h-auto flex-col 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:()=>a(!1),className:`absolute inset-0 transition-[opacity] delay-100 duration-700 ${r?"h-svh opacity-50":"h-0 opacity-0"} w-full bg-black md:hidden`}),e.jsxs(qe,{className:`flex h-full flex-col ${r?"h-[100vh] md:h-full":""}`,children:[e.jsxs(He,{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(F,{variant:"ghost",size:"icon",className:"md:hidden","aria-label":i("common:toggleNavigation"),"aria-controls":"sidebar-menu","aria-expanded":r,onClick:()=>a(l=>!l),children:r?e.jsx(sc,{}):e.jsx(tc,{})})]}),e.jsx(pm,{id:"sidebar-menu",className:w("flex-1 overflow-auto overscroll-contain",r?"block":"hidden md:block","md:py-2"),closeNav:()=>a(!1),isCollapsed:n,links:si}),e.jsx("div",{className:w("border-t border-border/50 bg-background","px-4 py-2.5 text-xs text-muted-foreground",r?"block":"hidden md:block",n?"text-center":"text-left"),children:e.jsxs("div",{className:w("flex items-center gap-1.5",n?"justify-center":"justify-start"),children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500"}),e.jsxs("span",{className:w("whitespace-nowrap tracking-wide","transition-opacity duration-200",n&&"md:opacity-0"),children:["v",window?.settings?.version]})]})}),e.jsx(F,{onClick:()=>t(l=>!l),size:"icon",variant:"outline",className:"absolute -right-5 top-1/2 hidden rounded-full md:inline-flex","aria-label":i("common:toggleSidebar"),children:e.jsx(ac,{stroke:1.5,className:`h-5 w-5 ${n?"rotate-180":""}`})})]})]})}function ym(){const[s,n]=Zl({key:"collapsed-sidebar",defaultValue:!1});return m.useEffect(()=>{const t=()=>{n(window.innerWidth<768?!1:s)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[s,n]),[s,n]}function _m(){const[s,n]=ym();return e.jsxs("div",{className:"relative h-full overflow-hidden bg-background",children:[e.jsx(bm,{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(Ln,{})})]})}const Nm=Object.freeze(Object.defineProperty({__proto__:null,default:_m},Symbol.toStringTag,{value:"Module"})),nt=m.forwardRef(({className:s,...n},t)=>e.jsx(xs,{ref:t,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...n}));nt.displayName=xs.displayName;const wm=({children:s,...n})=>e.jsx(de,{...n,children:e.jsx(ce,{className:"overflow-hidden p-0",children:e.jsx(nt,{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})})}),ft=m.forwardRef(({className:s,...n},t)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(nc,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(xs.Input,{ref:t,className:w("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})]}));ft.displayName=xs.Input.displayName;const rt=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.List,{ref:t,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...n}));rt.displayName=xs.List.displayName;const jt=m.forwardRef((s,n)=>e.jsx(xs.Empty,{ref:n,className:"py-6 text-center text-sm",...s}));jt.displayName=xs.Empty.displayName;const Ss=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.Group,{ref:t,className:w("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}));Ss.displayName=xs.Group.displayName;const Rt=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.Separator,{ref:t,className:w("-mx-1 h-px bg-border",s),...n}));Rt.displayName=xs.Separator.displayName;const rs=m.forwardRef(({className:s,...n},t)=>e.jsx(xs.Item,{ref:t,className:w("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}));rs.displayName=xs.Item.displayName;function Cm(){const s=[];for(const n of si)if(n.href&&s.push(n),n.sub)for(const t of n.sub)s.push({...t,parent:n.title});return s}function cs(){const[s,n]=m.useState(!1),t=Bs(),r=Cm(),{t:a}=M("search"),{t:i}=M("nav");m.useEffect(()=>{const d=u=>{u.key==="k"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),n(x=>!x))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]);const l=m.useCallback(d=>{n(!1),t(d)},[t]);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(En,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex",children:a("placeholder")}),e.jsx("span",{className:"sr-only",children:a("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:a("shortcut.key")})]}),e.jsxs(wm,{open:s,onOpenChange:n,children:[e.jsx(ft,{placeholder:a("placeholder")}),e.jsxs(rt,{children:[e.jsx(jt,{children:a("noResults")}),e.jsx(Ss,{heading:a("title"),children:r.map(d=>e.jsxs(rs,{value:`${d.parent?d.parent+" ":""}${d.title}`,onSelect:()=>l(d.href),children:[e.jsx("div",{className:"mr-2",children:d.icon}),e.jsx("span",{children:i(d.title)}),d.parent&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:i(d.parent)})]},d.href))})]})]})]})}function es(){const{theme:s,setTheme:n}=Pd();return m.useEffect(()=>{const t=s==="dark"?"#020817":"#fff",r=document.querySelector("meta[name='theme-color']");r&&r.setAttribute("content",t)},[s]),e.jsxs(e.Fragment,{children:[e.jsx(F,{size:"icon",variant:"ghost",className:"rounded-full",onClick:()=>n(s==="light"?"dark":"light"),children:s==="light"?e.jsx(rc,{size:20}):e.jsx(lc,{size:20})}),e.jsx(Wl,{})]})}const ti=m.forwardRef(({className:s,...n},t)=>e.jsx(Zr,{ref:t,className:w("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",s),...n}));ti.displayName=Zr.displayName;const ai=m.forwardRef(({className:s,...n},t)=>e.jsx(el,{ref:t,className:w("aspect-square h-full w-full",s),...n}));ai.displayName=el.displayName;const ni=m.forwardRef(({className:s,...n},t)=>e.jsx(sl,{ref:t,className:w("flex h-full w-full items-center justify-center rounded-full bg-muted",s),...n}));ni.displayName=sl.displayName;function ss(){const s=Bs(),n=Rr(),t=ic(tm),{t:r}=M(["common"]),a=()=>{$l(),n(sm()),s("/sign-in")},i=t?.email?.split("@")[0]||r("common:user"),l=i.substring(0,2).toUpperCase();return e.jsxs(zs,{children:[e.jsx(Ks,{asChild:!0,children:e.jsx(F,{variant:"ghost",className:"relative h-8 w-8 rounded-full",children:e.jsxs(ti,{className:"h-8 w-8",children:[e.jsx(ai,{src:t?.avatar_url,alt:i}),e.jsx(ni,{children:l})]})})}),e.jsxs(Ms,{className:"w-56",align:"end",forceMount:!0,children:[e.jsx(Ha,{className:"font-normal",children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:i}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:t?.email||r("common:defaultEmail")})]})}),e.jsx(et,{}),e.jsx(Se,{asChild:!0,children:e.jsxs(Zs,{to:"/config/system",children:[r("common:settings"),e.jsx(kn,{children:"⌘S"})]})}),e.jsx(et,{}),e.jsxs(Se,{onClick:a,children:[r("common:logout"),e.jsx(kn,{children:"⇧⌘Q"})]})]})]})}const J=oc,js=pc,Q=cc,Y=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(tl,{ref:r,className:w("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),...t,children:[n,e.jsx(dc,{asChild:!0,children:e.jsx(Vn,{className:"h-4 w-4 opacity-50"})})]}));Y.displayName=tl.displayName;const ri=m.forwardRef(({className:s,...n},t)=>e.jsx(al,{ref:t,className:w("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(mc,{className:"h-4 w-4"})}));ri.displayName=al.displayName;const li=m.forwardRef(({className:s,...n},t)=>e.jsx(nl,{ref:t,className:w("flex cursor-default items-center justify-center py-1",s),...n,children:e.jsx(Vn,{className:"h-4 w-4"})}));li.displayName=nl.displayName;const W=m.forwardRef(({className:s,children:n,position:t="popper",...r},a)=>e.jsx(uc,{children:e.jsxs(rl,{ref:a,className:w("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",t==="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:t,...r,children:[e.jsx(ri,{}),e.jsx(xc,{className:w("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(li,{})]})}));W.displayName=rl.displayName;const Sm=m.forwardRef(({className:s,...n},t)=>e.jsx(ll,{ref:t,className:w("px-2 py-1.5 text-sm font-semibold",s),...n}));Sm.displayName=ll.displayName;const A=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(il,{ref:r,className:w("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),...t,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(hc,{children:e.jsx(ht,{className:"h-4 w-4"})})}),e.jsx(gc,{children:n})]}));A.displayName=il.displayName;const km=m.forwardRef(({className:s,...n},t)=>e.jsx(ol,{ref:t,className:w("-mx-1 my-1 h-px bg-muted",s),...n}));km.displayName=ol.displayName;function Cs({className:s,classNames:n,showOutsideDays:t=!0,captionLayout:r="label",buttonVariant:a="ghost",formatters:i,components:l,...d}){const u=cl();return e.jsx(fc,{showOutsideDays:t,className:w("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,s),captionLayout:r,formatters:{formatMonthDropdown:x=>x.toLocaleString("default",{month:"short"}),...i},classNames:{root:w("w-fit",u.root),months:w("relative flex flex-col gap-4 md:flex-row",u.months),month:w("flex w-full flex-col gap-4",u.month),nav:w("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",u.nav),button_previous:w(Lt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",u.button_previous),button_next:w(Lt({variant:a}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",u.button_next),month_caption:w("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",u.month_caption),dropdowns:w("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",u.dropdowns),dropdown_root:w("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",u.dropdown_root),dropdown:w("absolute inset-0 opacity-0",u.dropdown),caption_label:w("select-none font-medium",r==="label"?"text-sm":"[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",u.caption_label),table:"w-full border-collapse",weekdays:w("flex",u.weekdays),weekday:w("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",u.weekday),week:w("mt-2 flex w-full",u.week),week_number_header:w("w-[--cell-size] select-none",u.week_number_header),week_number:w("text-muted-foreground select-none text-[0.8rem]",u.week_number),day:w("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",u.day),range_start:w("bg-accent rounded-l-md",u.range_start),range_middle:w("rounded-none",u.range_middle),range_end:w("bg-accent rounded-r-md",u.range_end),today:w("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",u.today),outside:w("text-muted-foreground aria-selected:text-muted-foreground",u.outside),disabled:w("text-muted-foreground opacity-50",u.disabled),hidden:w("invisible",u.hidden),...n},components:{Root:({className:x,rootRef:o,...c})=>e.jsx("div",{"data-slot":"calendar",ref:o,className:w(x),...c}),Chevron:({className:x,orientation:o,...c})=>o==="left"?e.jsx(dl,{className:w("size-4",x),...c}):o==="right"?e.jsx(ml,{className:w("size-4",x),...c}):e.jsx(ul,{className:w("size-4",x),...c}),DayButton:Tm,WeekNumber:({children:x,...o})=>e.jsx("td",{...o,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:x})}),...l},...d})}function Tm({className:s,day:n,modifiers:t,...r}){const a=cl(),i=m.useRef(null);return m.useEffect(()=>{t.focused&&i.current?.focus()},[t.focused]),e.jsx(G,{ref:i,variant:"ghost",size:"icon","data-day":n.date.toLocaleDateString(),"data-selected-single":t.selected&&!t.range_start&&!t.range_end&&!t.range_middle,"data-range-start":t.range_start,"data-range-end":t.range_end,"data-range-middle":t.range_middle,className:w("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",a.day,s),...r})}const ls=vc,is=bc,Xe=m.forwardRef(({className:s,align:n="center",sideOffset:t=4,...r},a)=>e.jsx(jc,{children:e.jsx(xl,{ref:a,align:n,sideOffset:t,className:w("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),...r})}));Xe.displayName=xl.displayName;const Ys={income:{main:"hsl(var(--primary))",gradient:{start:"hsl(var(--primary))",end:"transparent"}},commission:{main:"hsl(var(--secondary))",gradient:{start:"hsl(var(--secondary))",end:"transparent"}}},Ht=s=>(s/100).toFixed(2),Dm=({active:s,payload:n,label:t})=>{const{t:r}=M();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:t}),n.map((a,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e.jsxs("span",{className:"text-muted-foreground",children:[r(a.name),":"]}),e.jsx("span",{className:"font-medium",children:a.name.includes(r("dashboard:overview.amount"))?`¥${Ht(a.value)}`:r("dashboard:overview.transactions",{count:a.value})})]},i))]}):null},Pm=[{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"}],Lm=(s,n)=>{const t=new Date;if(s==="custom"&&n)return{startDate:n.from,endDate:n.to};let r;switch(s){case"7d":r=Es(t,7);break;case"30d":r=Es(t,30);break;case"90d":r=Es(t,90);break;case"180d":r=Es(t,180);break;case"365d":r=Es(t,365);break;default:r=Es(t,30)}return{startDate:r,endDate:t}};function Fm(){const[s,n]=m.useState("amount"),[t,r]=m.useState("30d"),[a,i]=m.useState({from:Es(new Date,7),to:new Date}),{t:l}=M(),{startDate:d,endDate:u}=Lm(t,a),{data:x}=ne({queryKey:["orderStat",{start_date:Fe(d,"yyyy-MM-dd"),end_date:Fe(u,"yyyy-MM-dd")}],queryFn:async()=>{const{data:o}=await Pa.getOrderStat({start_date:Fe(d,"yyyy-MM-dd"),end_date:Fe(u,"yyyy-MM-dd")});return o},refetchInterval:3e4});return e.jsxs(ke,{children:[e.jsx(Pe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Re,{children:l("dashboard:overview.title")}),e.jsxs(Us,{children:[x?.summary.start_date," ",l("dashboard:overview.to")," ",x?.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:t,onValueChange:o=>r(o),children:[e.jsx(Y,{className:"w-[120px]",children:e.jsx(Q,{placeholder:l("dashboard:overview.selectTimeRange")})}),e.jsx(W,{children:Pm.map(o=>e.jsx(A,{value:o.value,children:l(o.label)},o.value))})]}),t==="custom"&&e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:w("min-w-0 justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a?.from?a.to?e.jsxs(e.Fragment,{children:[Fe(a.from,"yyyy-MM-dd")," -"," ",Fe(a.to,"yyyy-MM-dd")]}):Fe(a.from,"yyyy-MM-dd"):l("dashboard:overview.selectDate")})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(Cs,{mode:"range",defaultMonth:a?.from,selected:{from:a?.from,to:a?.to},onSelect:o=>{o?.from&&o?.to&&i({from:o.from,to:o.to})},captionLayout:"dropdown",numberOfMonths:2})})]})]}),e.jsx(gt,{value:s,onValueChange:o=>n(o),children:e.jsxs(at,{children:[e.jsx($e,{value:"amount",children:l("dashboard:overview.amount")}),e.jsx($e,{value:"count",children:l("dashboard:overview.count")})]})})]})]})}),e.jsxs(Le,{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:l("dashboard:overview.totalIncome")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Ht(x?.summary?.paid_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:x?.summary?.paid_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.avgOrderAmount")," ¥",Ht(x?.summary?.avg_paid_amount||0)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:l("dashboard:overview.totalCommission")}),e.jsxs("div",{className:"text-2xl font-bold",children:["¥",Ht(x?.summary?.commission_total||0)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:l("dashboard:overview.totalTransactions",{count:x?.summary?.commission_count||0})}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l("dashboard:overview.commissionRate")," ",x?.summary?.commission_rate.toFixed(2)||0,"%"]})]})]}),e.jsx("div",{className:"h-[400px] w-full",children:e.jsx(yc,{width:"100%",height:"100%",children:e.jsxs(_c,{data:x?.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:Ys.income.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Ys.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:Ys.commission.gradient.start,stopOpacity:.2}),e.jsx("stop",{offset:"100%",stopColor:Ys.commission.gradient.end,stopOpacity:.1})]})]}),e.jsx(Nc,{dataKey:"date",axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:o=>Fe(new Date(o),"MM-dd",{locale:kc})}),e.jsx(wc,{axisLine:!1,tickLine:!1,tick:{fill:"hsl(var(--muted-foreground))",fontSize:12},tickFormatter:o=>s==="amount"?`¥${Ht(o)}`:l("dashboard:overview.transactions",{count:o})}),e.jsx(Cc,{strokeDasharray:"3 3",vertical:!1,stroke:"hsl(var(--border))",opacity:.3}),e.jsx(Sc,{content:e.jsx(Dm,{})}),s==="amount"?e.jsxs(e.Fragment,{children:[e.jsx(ar,{type:"monotone",dataKey:"paid_total",name:l("dashboard:overview.orderAmount"),stroke:Ys.income.main,fill:"url(#incomeGradient)",strokeWidth:2}),e.jsx(ar,{type:"monotone",dataKey:"commission_total",name:l("dashboard:overview.commissionAmount"),stroke:Ys.commission.main,fill:"url(#commissionGradient)",strokeWidth:2})]}):e.jsxs(e.Fragment,{children:[e.jsx(nr,{dataKey:"paid_count",name:l("dashboard:overview.orderCount"),fill:Ys.income.main,radius:[4,4,0,0],maxBarSize:40}),e.jsx(nr,{dataKey:"commission_count",name:l("dashboard:overview.commissionCount"),fill:Ys.commission.main,radius:[4,4,0,0],maxBarSize:40})]})]})})})]})]})}function je({className:s,...n}){return e.jsx("div",{className:w("animate-pulse rounded-md bg-primary/10",s),...n})}function Rm(){return e.jsxs(ke,{children:[e.jsxs(Pe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(je,{className:"h-4 w-[120px]"}),e.jsx(je,{className:"h-4 w-4"})]}),e.jsxs(Le,{children:[e.jsx(je,{className:"h-8 w-[140px] mb-2"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-4 w-4"}),e.jsx(je,{className:"h-4 w-[100px]"})]})]})]})}function Em(){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(Rm,{},n))})}var le=(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))(le||{});const zt={0:"待支付",1:"开通中",2:"已取消",3:"已完成",4:"已折抵"},$t={0:"yellow-500",1:"blue-500",2:"red-500",3:"green-500",4:"green-500"};var Vs=(s=>(s[s.NEW=1]="NEW",s[s.RENEWAL=2]="RENEWAL",s[s.UPGRADE=3]="UPGRADE",s[s.RESET_FLOW=4]="RESET_FLOW",s))(Vs||{}),Ce=(s=>(s[s.PENDING=0]="PENDING",s[s.PROCESSING=1]="PROCESSING",s[s.VALID=2]="VALID",s[s.INVALID=3]="INVALID",s))(Ce||{});const xa={0:"待确认",1:"发放中",2:"有效",3:"无效"},ha={0:"yellow-500",1:"blue-500",2:"green-500",3:"red-500"};var Qe=(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))(Qe||{});const Vm={month_price:"月付",quarter_price:"季付",half_year_price:"半年付",year_price:"年付",two_year_price:"两年付",three_year_price:"三年付",onetime_price:"一次性",reset_price:"流量重置包"};var xe=(s=>(s.Shadowsocks="shadowsocks",s.Vmess="vmess",s.Trojan="trojan",s.Hysteria="hysteria",s.Vless="vless",s.Tuic="tuic",s.Socks="socks",s.Naive="naive",s.Http="http",s.Mieru="mieru",s.AnyTLS="anytls",s))(xe||{});const Ts=[{type:"shadowsocks",label:"Shadowsocks"},{type:"vmess",label:"VMess"},{type:"trojan",label:"Trojan"},{type:"hysteria",label:"Hysteria"},{type:"vless",label:"VLess"},{type:"tuic",label:"TUIC"},{type:"socks",label:"SOCKS"},{type:"naive",label:"Naive"},{type:"http",label:"HTTP"},{type:"mieru",label:"Mieru"},{type:"anytls",label:"AnyTLS"}],bs={shadowsocks:"#489851",vmess:"#CB3180",trojan:"#EBB749",hysteria:"#5684e6",vless:"#1a1a1a",tuic:"#00C853",socks:"#2196F3",naive:"#9C27B0",http:"#FF5722",mieru:"#4CAF50",anytls:"#7E57C2"};var Ns=(s=>(s[s.AMOUNT=1]="AMOUNT",s[s.PERCENTAGE=2]="PERCENTAGE",s))(Ns||{});const Im={1:"按金额优惠",2:"按比例优惠"};var Xs=(s=>(s[s.OPENING=0]="OPENING",s[s.CLOSED=1]="CLOSED",s))(Xs||{}),ds=(s=>(s[s.LOW=0]="LOW",s[s.MIDDLE=1]="MIDDLE",s[s.HIGH=2]="HIGH",s))(ds||{}),Jt=(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))(Jt||{});function Ws({title:s,value:n,icon:t,trend:r,description:a,onClick:i,highlight:l,className:d}){return e.jsxs(ke,{className:w("transition-colors",i&&"cursor-pointer hover:bg-muted/50",l&&"border-primary/50",d),onClick:i,children:[e.jsxs(Pe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:s}),t]}),e.jsxs(Le,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),r?e.jsxs("div",{className:"flex items-center pt-1",children:[e.jsx(Lc,{className:w("h-4 w-4",r.isPositive?"text-emerald-500":"text-red-500")}),e.jsxs("span",{className:w("ml-1 text-xs",r.isPositive?"text-emerald-500":"text-red-500"),children:[r.isPositive?"+":"-",Math.abs(r.value),"%"]}),e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:r.label})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a})]})]})}function Mm({className:s}){const n=Bs(),{t}=M(),{data:r,isLoading:a}=ne({queryKey:["dashboardStats"],queryFn:async()=>(await Pa.getStatsData()).data,refetchInterval:1e3*60*5});if(a||!r)return e.jsx(Em,{});const i=()=>{const l=new URLSearchParams;l.set("commission_status",Ce.PENDING.toString()),l.set("status",le.COMPLETED.toString()),l.set("commission_balance","gt:0"),n(`/finance/order?${l.toString()}`)};return e.jsxs("div",{className:w("grid gap-4 md:grid-cols-2 lg:grid-cols-4",s),children:[e.jsx(Ws,{title:t("dashboard:stats.todayIncome"),value:qs(r.todayIncome),icon:e.jsx(Tc,{className:"h-4 w-4 text-emerald-500"}),trend:{value:r.dayIncomeGrowth,label:t("dashboard:stats.vsYesterday"),isPositive:r.dayIncomeGrowth>0}}),e.jsx(Ws,{title:t("dashboard:stats.monthlyIncome"),value:qs(r.currentMonthIncome),icon:e.jsx(In,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.monthIncomeGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.monthIncomeGrowth>0}}),e.jsx(Ws,{title:t("dashboard:stats.pendingTickets"),value:r.ticketPendingTotal,icon:e.jsx(Dc,{className:w("h-4 w-4",r.ticketPendingTotal>0?"text-orange-500":"text-muted-foreground")}),description:r.ticketPendingTotal>0?t("dashboard:stats.hasPendingTickets"):t("dashboard:stats.noPendingTickets"),onClick:()=>n("/user/ticket"),highlight:r.ticketPendingTotal>0}),e.jsx(Ws,{title:t("dashboard:stats.pendingCommission"),value:r.commissionPendingTotal,icon:e.jsx(Pc,{className:w("h-4 w-4",r.commissionPendingTotal>0?"text-blue-500":"text-muted-foreground")}),description:r.commissionPendingTotal>0?t("dashboard:stats.hasPendingCommission"):t("dashboard:stats.noPendingCommission"),onClick:i,highlight:r.commissionPendingTotal>0}),e.jsx(Ws,{title:t("dashboard:stats.monthlyNewUsers"),value:r.currentMonthNewUsers,icon:e.jsx(wa,{className:"h-4 w-4 text-blue-500"}),trend:{value:r.userGrowth,label:t("dashboard:stats.vsLastMonth"),isPositive:r.userGrowth>0}}),e.jsx(Ws,{title:t("dashboard:stats.totalUsers"),value:r.totalUsers,icon:e.jsx(wa,{className:"h-4 w-4 text-muted-foreground"}),description:t("dashboard:stats.activeUsers",{count:r.activeUsers})}),e.jsx(Ws,{title:t("dashboard:stats.monthlyUpload"),value:ze(r.monthTraffic.upload),icon:e.jsx(Dt,{className:"h-4 w-4 text-emerald-500"}),description:t("dashboard:stats.todayTraffic",{value:ze(r.todayTraffic.upload)})}),e.jsx(Ws,{title:t("dashboard:stats.monthlyDownload"),value:ze(r.monthTraffic.download),icon:e.jsx(Zt,{className:"h-4 w-4 text-blue-500"}),description:t("dashboard:stats.todayTraffic",{value:ze(r.todayTraffic.download)})})]})}const ut=m.forwardRef(({className:s,children:n,...t},r)=>e.jsxs(hl,{ref:r,className:w("relative overflow-hidden",s),...t,children:[e.jsx(Fc,{className:"h-full w-full rounded-[inherit]",children:n}),e.jsx(Fa,{}),e.jsx(Rc,{})]}));ut.displayName=hl.displayName;const Fa=m.forwardRef(({className:s,orientation:n="vertical",...t},r)=>e.jsx(gl,{ref:r,orientation:n,className:w("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),...t,children:e.jsx(Ec,{className:"relative flex-1 rounded-full bg-border"})}));Fa.displayName=gl.displayName;const Tn={today:{getValue:()=>{const s=Ic();return{start:s,end:Mc(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 jr({selectedRange:s,customDateRange:n,onRangeChange:t,onCustomRangeChange:r}){const{t:a}=M(),i={today:a("dashboard:trafficRank.today"),last7days:a("dashboard:trafficRank.last7days"),last30days:a("dashboard:trafficRank.last30days"),custom:a("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:t,children:[e.jsx(Y,{className:"w-[120px]",children:e.jsx(Q,{placeholder:a("dashboard:trafficRank.selectTimeRange")})}),e.jsx(W,{position:"popper",className:"z-50",children:Object.entries(Tn).map(([l])=>e.jsx(A,{value:l,children:i[l]},l))})]}),s==="custom"&&e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(G,{variant:"outline",className:w("min-w-0 justify-start text-left font-normal",!n&&"text-muted-foreground"),children:[e.jsx(ws,{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:[Fe(n.from,"yyyy-MM-dd")," -"," ",Fe(n.to,"yyyy-MM-dd")]}):Fe(n.from,"yyyy-MM-dd"):e.jsx("span",{children:a("dashboard:trafficRank.selectDateRange")})})]})}),e.jsx(Xe,{className:"w-auto p-0",align:"end",children:e.jsx(Cs,{mode:"range",defaultMonth:n?.from,selected:{from:n?.from,to:n?.to},onSelect:l=>{l?.from&&l?.to&&r({from:l.from,to:l.to})},numberOfMonths:2})})]})]})}const wt=s=>`${(s/1024/1024/1024).toFixed(2)} GB`;function Om({className:s}){const{t:n}=M(),[t,r]=m.useState("today"),[a,i]=m.useState({from:Es(new Date,7),to:new Date}),[l,d]=m.useState("today"),[u,x]=m.useState({from:Es(new Date,7),to:new Date}),o=m.useMemo(()=>t==="custom"?{start:a.from,end:a.to}:Tn[t].getValue(),[t,a]),c=m.useMemo(()=>l==="custom"?{start:u.from,end:u.to}:Tn[l].getValue(),[l,u]),{data:j}=ne({queryKey:["nodeTrafficRank",o.start,o.end],queryFn:()=>Pa.getNodeTrafficData({type:"node",start_time:Ee.round(o.start.getTime()/1e3),end_time:Ee.round(o.end.getTime()/1e3)}),refetchInterval:3e4}),{data:P}=ne({queryKey:["userTrafficRank",c.start,c.end],queryFn:()=>Pa.getNodeTrafficData({type:"user",start_time:Ee.round(c.start.getTime()/1e3),end_time:Ee.round(c.end.getTime()/1e3)}),refetchInterval:3e4});return e.jsxs("div",{className:w("grid gap-4 md:grid-cols-2",s),children:[e.jsxs(ke,{children:[e.jsx(Pe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Re,{className:"flex items-center text-base font-medium",children:[e.jsx(Vc,{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(jr,{selectedRange:t,customDateRange:a,onRangeChange:r,onCustomRangeChange:i}),e.jsx(rr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Le,{className:"flex-1",children:j?.data?e.jsxs(ut,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:j.data.map(k=>e.jsx(be,{delayDuration:200,children:e.jsxs(ge,{children:[e.jsx(pe,{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:k.name}),e.jsxs("span",{className:w("ml-2 flex items-center text-xs font-medium",k.change>=0?"text-green-600":"text-red-600"),children:[k.change>=0?e.jsx(vn,{className:"mr-1 h-3 w-3"}):e.jsx(bn,{className:"mr-1 h-3 w-3"}),Math.abs(k.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:`${k.value/j.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:wt(k.value)})]})]})})}),e.jsx(ue,{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:wt(k.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:wt(k.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:w("font-medium",k.change>=0?"text-green-600":"text-red-600"),children:[k.change>=0?"+":"",k.change,"%"]})]})})]})},k.id))}),e.jsx(Fa,{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(ke,{children:[e.jsx(Pe,{className:"flex-none pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs(Re,{className:"flex items-center text-base font-medium",children:[e.jsx(wa,{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(jr,{selectedRange:l,customDateRange:u,onRangeChange:d,onCustomRangeChange:x}),e.jsx(rr,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"})]})]})}),e.jsx(Le,{className:"flex-1",children:P?.data?e.jsxs(ut,{className:"h-[400px] pr-4",children:[e.jsx("div",{className:"space-y-3",children:P.data.map(k=>e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:k.name}),e.jsxs("span",{className:w("ml-2 flex items-center text-xs font-medium",k.change>=0?"text-green-600":"text-red-600"),children:[k.change>=0?e.jsx(vn,{className:"mr-1 h-3 w-3"}):e.jsx(bn,{className:"mr-1 h-3 w-3"}),Math.abs(k.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:`${k.value/P.data[0].value*100}%`}})}),e.jsx("span",{className:"text-xs text-muted-foreground",children:wt(k.value)})]})]})})}),e.jsx(ue,{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:wt(k.value)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.previousTraffic"),":"]}),e.jsx("span",{className:"font-medium",children:wt(k.previousValue)}),e.jsxs("span",{className:"text-muted-foreground",children:[n("dashboard:trafficRank.changeRate"),":"]}),e.jsxs("span",{className:w("font-medium",k.change>=0?"text-green-600":"text-red-600"),children:[k.change>=0?"+":"",k.change,"%"]})]})})]})},k.id))}),e.jsx(Fa,{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 zm=xt("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 U({className:s,variant:n,...t}){return e.jsx("div",{className:w(zm({variant:n}),s),...t})}const ba=m.forwardRef(({className:s,value:n,...t},r)=>e.jsx(pl,{ref:r,className:w("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...t,children:e.jsx(Oc,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));ba.displayName=pl.displayName;const An=m.forwardRef(({className:s,...n},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:w("w-full caption-bottom text-sm",s),...n})}));An.displayName="Table";const qn=m.forwardRef(({className:s,...n},t)=>e.jsx("thead",{ref:t,className:w("[&_tr]:border-b",s),...n}));qn.displayName="TableHeader";const Hn=m.forwardRef(({className:s,...n},t)=>e.jsx("tbody",{ref:t,className:w("[&_tr:last-child]:border-0",s),...n}));Hn.displayName="TableBody";const $m=m.forwardRef(({className:s,...n},t)=>e.jsx("tfoot",{ref:t,className:w("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...n}));$m.displayName="TableFooter";const Js=m.forwardRef(({className:s,...n},t)=>e.jsx("tr",{ref:t,className:w("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...n}));Js.displayName="TableRow";const Un=m.forwardRef(({className:s,...n},t)=>e.jsx("th",{ref:t,className:w("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}));Un.displayName="TableHead";const Tt=m.forwardRef(({className:s,...n},t)=>e.jsx("td",{ref:t,className:w("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...n}));Tt.displayName="TableCell";const Am=m.forwardRef(({className:s,...n},t)=>e.jsx("caption",{ref:t,className:w("mt-4 text-sm text-muted-foreground",s),...n}));Am.displayName="TableCaption";function ii({table:s}){const[n,t]=m.useState(""),{t:r}=M("common");m.useEffect(()=>{t((s.getState().pagination.pageIndex+1).toString())},[s.getState().pagination.pageIndex]);const a=i=>{const l=parseInt(i);!isNaN(l)&&l>=1&&l<=s.getPageCount()?s.setPageIndex(l-1):t((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:r("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:r("table.pagination.itemsPerPage")}),e.jsxs(J,{value:`${s.getState().pagination.pageSize}`,onValueChange:i=>{s.setPageSize(Number(i))},children:[e.jsx(Y,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:s.getState().pagination.pageSize})}),e.jsx(W,{side:"top",children:[10,20,30,40,50,100,500].map(i=>e.jsx(A,{value:`${i}`,children:i},i))})]})]}),e.jsxs("div",{className:"flex items-center justify-center space-x-2 text-sm font-medium",children:[e.jsx("span",{children:r("table.pagination.page")}),e.jsx(D,{type:"text",value:n,onChange:i=>t(i.target.value),onBlur:i=>a(i.target.value),onKeyDown:i=>{i.key==="Enter"&&a(i.currentTarget.value)},className:"h-8 w-[50px] text-center"}),e.jsx("span",{children:r("table.pagination.pageOf",{total:s.getPageCount()})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(F,{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:r("table.pagination.firstPage")}),e.jsx(zc,{className:"h-4 w-4"})]}),e.jsxs(F,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.previousPage")}),e.jsx($c,{className:"h-4 w-4"})]}),e.jsxs(F,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:r("table.pagination.nextPage")}),e.jsx(Or,{className:"h-4 w-4"})]}),e.jsxs(F,{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:r("table.pagination.lastPage")}),e.jsx(Ac,{className:"h-4 w-4"})]})]})]})]})}function ts({table:s,toolbar:n,draggable:t=!1,onDragStart:r,onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:d,showPagination:u=!0,isLoading:x=!1}){const{t:o}=M("common"),c=m.useRef(null),j=s.getAllColumns().filter(T=>T.getIsPinned()==="left"),P=s.getAllColumns().filter(T=>T.getIsPinned()==="right"),k=T=>j.slice(0,T).reduce((p,S)=>p+(S.getSize()??0),0),C=T=>P.slice(T+1).reduce((p,S)=>p+(S.getSize()??0),0);return e.jsxs("div",{className:"space-y-4",children:[typeof n=="function"?n(s):n,e.jsx("div",{ref:c,className:"relative overflow-auto rounded-md border bg-card",children:e.jsx("div",{className:"overflow-auto",children:e.jsxs(An,{children:[e.jsx(qn,{children:s.getHeaderGroups().map(T=>e.jsx(Js,{className:"hover:bg-transparent",children:T.headers.map((p,S)=>{const N=p.column.getIsPinned()==="left",g=p.column.getIsPinned()==="right",f=N?k(j.indexOf(p.column)):void 0,V=g?C(P.indexOf(p.column)):void 0;return e.jsx(Un,{colSpan:p.colSpan,style:{width:p.getSize(),...N&&{left:f},...g&&{right:V}},className:w("h-11 bg-card px-4 text-muted-foreground",(N||g)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",N&&"before:right-0",g&&"before:left-0"]),children:p.isPlaceholder?null:Ca(p.column.columnDef.header,p.getContext())},p.id)})},T.id))}),e.jsx(Hn,{children:s.getRowModel().rows?.length?s.getRowModel().rows.map((T,p)=>e.jsx(Js,{"data-state":T.getIsSelected()&&"selected",className:"hover:bg-muted/50",draggable:t,onDragStart:S=>r?.(S,p),onDragEnd:a,onDragOver:i,onDragLeave:l,onDrop:S=>d?.(S,p),children:T.getVisibleCells().map((S,N)=>{const g=S.column.getIsPinned()==="left",f=S.column.getIsPinned()==="right",V=g?k(j.indexOf(S.column)):void 0,E=f?C(P.indexOf(S.column)):void 0;return e.jsx(Tt,{style:{width:S.column.getSize(),...g&&{left:V},...f&&{right:E}},className:w("bg-card",(g||f)&&["sticky z-20","before:absolute before:bottom-0 before:top-0 before:w-[1px] before:bg-border",g&&"before:right-0",f&&"before:left-0"]),children:Ca(S.column.columnDef.cell,S.getContext())},S.id)})},T.id)):e.jsx(Js,{children:e.jsx(Tt,{colSpan:s.getAllColumns().length,className:"h-24 text-center",children:o("table.noData")})})})]})})}),u&&e.jsx(ii,{table:s})]})}const ya=s=>{if(!s)return"";let n;if(typeof s=="string"){if(n=parseInt(s),isNaN(n))return s}else n=s;return(n.toString().length===10?new Date(n*1e3):new Date(n)).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})},At=fl(),qt=fl();function ga({data:s,isLoading:n,searchKeyword:t,selectedLevel:r,total:a,currentPage:i,pageSize:l,onViewDetail:d,onPageChange:u,onPageSizeChange:x}){const{t:o}=M(),c=k=>{switch(k.toLowerCase()){case"info":return e.jsx(Kt,{className:"h-4 w-4 text-blue-500"});case"warning":return e.jsx(Bt,{className:"h-4 w-4 text-yellow-500"});case"error":return e.jsx(Nn,{className:"h-4 w-4 text-red-500"});default:return e.jsx(Kt,{className:"h-4 w-4 text-slate-500"})}},j=m.useMemo(()=>[At.accessor("level",{id:"level",header:()=>o("dashboard:systemLog.level"),size:80,cell:({getValue:k,row:C})=>{const T=k();return e.jsxs("div",{className:"flex items-center gap-1",children:[c(T),e.jsx("span",{className:w(T.toLowerCase()==="error"&&"text-red-600",T.toLowerCase()==="warning"&&"text-yellow-600",T.toLowerCase()==="info"&&"text-blue-600"),children:T})]})}}),At.accessor("created_at",{id:"created_at",header:()=>o("dashboard:systemLog.time"),size:160,cell:({getValue:k})=>ya(k())}),At.accessor(k=>k.title||k.message||"",{id:"title",header:()=>o("dashboard:systemLog.logTitle"),cell:({getValue:k})=>e.jsx("span",{className:"inline-block max-w-[300px] truncate",children:k()})}),At.accessor("method",{id:"method",header:()=>o("dashboard:systemLog.method"),size:100,cell:({getValue:k})=>{const C=k();return C?e.jsx(U,{variant:"outline",className:w(C==="GET"&&"border-blue-200 bg-blue-50 text-blue-700",C==="POST"&&"border-green-200 bg-green-50 text-green-700",C==="PUT"&&"border-amber-200 bg-amber-50 text-amber-700",C==="DELETE"&&"border-red-200 bg-red-50 text-red-700"),children:C}):null}}),At.display({id:"actions",header:()=>o("dashboard:systemLog.action"),size:80,cell:({row:k})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>d(k.original),"aria-label":o("dashboard:systemLog.viewDetail"),children:e.jsx(yn,{className:"h-4 w-4"})})})],[o,d]),P=Be({data:s,columns:j,getCoreRowModel:Ge(),getPaginationRowModel:Ze(),pageCount:Math.ceil(a/l),manualPagination:!0,state:{pagination:m.useMemo(()=>({pageIndex:i-1,pageSize:l}),[i,l])},onPaginationChange:k=>{let C,T;if(typeof k=="function"){const p=k({pageIndex:i-1,pageSize:l});C=p.pageIndex,T=p.pageSize}else C=k.pageIndex,T=k.pageSize;T!==l?x(T):u(C+1)}});return e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(ts,{table:P,showPagination:!0,isLoading:n}),(t||r&&r!=="all")&&e.jsx("div",{className:"text-center text-sm text-muted-foreground",children:t&&r&&r!=="all"?o("dashboard:systemLog.filter.searchAndLevel",{keyword:t,level:r,count:a}):t?o("dashboard:systemLog.filter.searchOnly",{keyword:t,count:a}):o("dashboard:systemLog.filter.levelOnly",{level:r,count:a})})]})}function qm(){const{t:s}=M(),[n,t]=m.useState(0),[r,a]=m.useState(!1),[i,l]=m.useState(1),[d]=m.useState(10),[u,x]=m.useState(null),[o,c]=m.useState(!1),[j,P]=m.useState(!1),[k,C]=m.useState(1),[T,p]=m.useState(10),[S,N]=m.useState(null),[g,f]=m.useState(!1),[V,E]=m.useState(""),[L,K]=m.useState(""),[X,se]=m.useState("all"),[te,q]=m.useState(!1),[ee,fe]=m.useState(0),[fs,Ie]=m.useState("all"),[re,H]=m.useState(1e3),[oe,lt]=m.useState(!1),[$s,Et]=m.useState(null),[na,Vt]=m.useState(!1);m.useEffect(()=>{const B=setTimeout(()=>{K(V),V!==L&&C(1)},500);return()=>clearTimeout(B)},[V]);const{data:Gs,isLoading:ae,refetch:ye,isRefetching:We}=ne({queryKey:["systemStatus",n],queryFn:async()=>(await ve.getSystemStatus()).data,refetchInterval:3e4}),{data:_e,isLoading:$i,refetch:sp,isRefetching:Jn}=ne({queryKey:["queueStats",n],queryFn:async()=>(await ve.getQueueStats()).data,refetchInterval:3e4}),{data:Qn,isLoading:Ai,refetch:qi}=ne({queryKey:["failedJobs",i,d],queryFn:async()=>{const B=await ve.getHorizonFailedJobs({current:i,page_size:d});return{data:B.data,total:B.total||0}},enabled:r}),{data:Xn,isLoading:ra,refetch:Hi}=ne({queryKey:["systemLogs",k,T,X,L],queryFn:async()=>{const B={current:k,page_size:T};X&&X!=="all"&&(B.level=X),L.trim()&&(B.keyword=L.trim());const Rs=await ve.getSystemLog(B);return{data:Rs.data,total:Rs.total||0}},enabled:j}),Zn=Qn?.data||[],Ui=Qn?.total||0,la=Xn?.data||[],ia=Xn?.total||0,Ki=m.useMemo(()=>[qt.display({id:"failed_at",header:()=>s("dashboard:queue.details.time"),cell:({row:B})=>ya(B.original.failed_at)}),qt.display({id:"queue",header:()=>s("dashboard:queue.details.queue"),cell:({row:B})=>B.original.queue}),qt.display({id:"name",header:()=>s("dashboard:queue.details.name"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[150px] truncate",children:B.original.name})}),e.jsx(ue,{children:e.jsx("span",{children:B.original.name})})]})})}),qt.display({id:"exception",header:()=>s("dashboard:queue.details.exception"),cell:({row:B})=>e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("span",{className:"inline-block max-w-[200px] truncate",children:B.original.exception.split(`
+`)[0]})}),e.jsx(ue,{className:"max-w-[300px] whitespace-pre-wrap",children:e.jsx("span",{children:B.original.exception})})]})})}),qt.display({id:"actions",header:()=>s("dashboard:queue.details.action"),size:80,cell:({row:B})=>e.jsx(G,{variant:"ghost",size:"sm",onClick:()=>Wi(B.original),"aria-label":s("dashboard:queue.details.viewDetail"),children:e.jsx(yn,{className:"h-4 w-4"})})})],[s]),er=Be({data:Zn,columns:Ki,getCoreRowModel:Ge(),getPaginationRowModel:Ze(),pageCount:Math.ceil(Ui/d),manualPagination:!0,state:{pagination:{pageIndex:i-1,pageSize:d}},onPaginationChange:B=>{if(typeof B=="function"){const Rs=B({pageIndex:i-1,pageSize:d});sr(Rs.pageIndex+1)}else sr(B.pageIndex+1)}}),Bi=()=>{t(B=>B+1)},sr=B=>{l(B)},oa=B=>{C(B)},ca=B=>{p(B),C(1)},Gi=B=>{se(B),C(1)},Yi=()=>{E(""),K(""),se("all"),C(1)},da=B=>{N(B),f(!0)},Wi=B=>{x(B),c(!0)},Ji=async()=>{try{const B=await ve.getLogClearStats({days:ee,level:fs==="all"?void 0:fs});Et(B.data),Vt(!0)}catch(B){console.error("Failed to get clear stats:",B),$.error(s("dashboard:systemLog.getStatsFailed"))}},Qi=async()=>{lt(!0);try{const{data:B}=await ve.clearSystemLog({days:ee,level:fs==="all"?void 0:fs,limit:re});B&&($.success(s("dashboard:systemLog.clearSuccess",{count:B.cleared_count}),{duration:3e3}),q(!1),Vt(!1),Et(null),ye())}catch(B){console.error("Failed to clear logs:",B),$.error(s("dashboard:systemLog.clearLogsFailed"))}finally{lt(!1)}};if(ae||$i)return e.jsx("div",{className:"flex items-center justify-center p-6",children:e.jsx(Sa,{className:"h-6 w-6 animate-spin"})});const Xi=B=>B?e.jsx(jl,{className:"h-5 w-5 text-green-500"}):e.jsx(vl,{className:"h-5 w-5 text-red-500"});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(ke,{children:[e.jsxs(Pe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx(qc,{className:"h-5 w-5"}),s("dashboard:queue.title")]}),e.jsx(Us,{children:s("dashboard:queue.status.description")})]}),e.jsx(G,{variant:"outline",size:"icon",onClick:Bi,disabled:We||Jn,children:e.jsx(nn,{className:w("h-4 w-4",(We||Jn)&&"animate-spin")})})]}),e.jsx(Le,{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:[Xi(_e?.status||!1),e.jsx("span",{className:"font-medium",children:s("dashboard:queue.status.running")})]}),e.jsx(U,{variant:_e?.status?"secondary":"destructive",children:_e?.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:_e?.wait?.default||0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:_e?.recentJobs||0}),e.jsx(ba,{value:(_e?.recentJobs||0)/(_e?.periods?.recentJobs||1)*100,className:"h-1"})]})}),e.jsx(ue,{children:e.jsx("p",{children:s("dashboard:queue.details.statisticsPeriod",{hours:_e?.periods?.recentJobs||0})})})]})}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:_e?.jobsPerMinute||0}),e.jsx(ba,{value:(_e?.jobsPerMinute||0)/(_e?.queueWithMaxThroughput?.throughput||1)*100,className:"h-1"})]})}),e.jsx(ue,{children:e.jsx("p",{children:s("dashboard:queue.details.maxThroughput",{value:_e?.queueWithMaxThroughput?.throughput||0})})})]})})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Pe,{children:[e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx(Hc,{className:"h-5 w-5"}),s("dashboard:queue.jobDetails")]}),e.jsx(Us,{children:s("dashboard:queue.details.description")})]}),e.jsx(Le,{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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"cursor-pointer text-2xl font-bold text-destructive hover:underline",title:s("dashboard:queue.details.viewFailedJobs"),onClick:()=>a(!0),style:{userSelect:"none"},children:_e?.failedJobs||0}),e.jsx(yn,{className:"h-4 w-4 cursor-pointer text-muted-foreground hover:text-destructive",onClick:()=>a(!0),"aria-label":s("dashboard:queue.details.viewFailedJobs")})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("dashboard:queue.details.retentionPeriod",{hours:_e?.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:[_e?.queueWithMaxRuntime?.runtime||0,"s"]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:_e?.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:[_e?.processes||0," /"," ",(_e?.processes||0)+(_e?.pausedMasters||0)]})]}),e.jsx(ba,{value:(_e?.processes||0)/((_e?.processes||0)+(_e?.pausedMasters||0))*100,className:"mt-2 h-1"})]})]})})]})]}),e.jsxs(ke,{children:[e.jsxs(Pe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-5 w-5"}),s("dashboard:systemLog.title")]}),e.jsx(Us,{children:s("dashboard:systemLog.description")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>P(!0),children:s("dashboard:systemLog.viewAll")}),e.jsxs(G,{variant:"outline",onClick:()=>q(!0),className:"text-destructive hover:text-destructive",children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.clearLogs")]})]})]}),e.jsx(Le,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2 rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-900 dark:bg-blue-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kt,{className:"h-5 w-5 text-blue-500"}),e.jsx("p",{className:"font-medium text-blue-700 dark:text-blue-300",children:s("dashboard:systemLog.tabs.info")})]}),e.jsx("p",{className:"text-2xl font-bold text-blue-700 dark:text-blue-300",children:Gs?.logs?.info||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-yellow-200 bg-yellow-50 p-3 dark:border-yellow-900 dark:bg-yellow-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bt,{className:"h-5 w-5 text-yellow-500"}),e.jsx("p",{className:"font-medium text-yellow-700 dark:text-yellow-300",children:s("dashboard:systemLog.tabs.warning")})]}),e.jsx("p",{className:"text-2xl font-bold text-yellow-700 dark:text-yellow-300",children:Gs?.logs?.warning||0})]}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-red-200 bg-red-50 p-3 dark:border-red-900 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5 text-red-500"}),e.jsx("p",{className:"font-medium text-red-700 dark:text-red-300",children:s("dashboard:systemLog.tabs.error")})]}),e.jsx("p",{className:"text-2xl font-bold text-red-700 dark:text-red-300",children:Gs?.logs?.error||0})]})]}),Gs?.logs&&Gs.logs.total>0&&e.jsxs("div",{className:"mt-3 text-center text-sm text-muted-foreground",children:[s("dashboard:systemLog.totalLogs"),": ",Gs.logs.total]})]})})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.failedJobsDetailTitle")})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(ts,{table:er,showPagination:!1,isLoading:Ai}),e.jsx(ii,{table:er}),Zn.length===0&&e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:s("dashboard:queue.details.noFailedJobs")})]}),e.jsxs(Me,{children:[e.jsxs(G,{variant:"outline",onClick:()=>qi(),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(Qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:o,onOpenChange:c,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:queue.details.jobDetailTitle")})}),u&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.id")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:u.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.time")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:u.failed_at})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.queue")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:u.queue})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.connection")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:u.connection})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.name")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:u.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.exception")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-red-700 dark:text-red-300",children:u.exception})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:queue.details.payload")}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(u.payload),null,2)}catch{return u.payload}})()})})]})]}),e.jsx(Me,{children:e.jsx(G,{variant:"outline",onClick:()=>c(!1),children:s("common:close")})})]})}),e.jsx(de,{open:j,onOpenChange:P,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.title")})}),e.jsxs(gt,{value:X,onValueChange:Gi,className:"w-full overflow-x-auto",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 p-1 md:flex-row md:items-center md:justify-between",children:[e.jsxs(at,{className:"grid w-auto grid-cols-4",children:[e.jsxs($e,{value:"all",className:"flex items-center gap-2",children:[e.jsx(_n,{className:"h-4 w-4"}),s("dashboard:systemLog.tabs.all")]}),e.jsxs($e,{value:"info",className:"flex items-center gap-2",children:[e.jsx(Kt,{className:"h-4 w-4 text-blue-500"}),s("dashboard:systemLog.tabs.info")]}),e.jsxs($e,{value:"warning",className:"flex items-center gap-2",children:[e.jsx(Bt,{className:"h-4 w-4 text-yellow-500"}),s("dashboard:systemLog.tabs.warning")]}),e.jsxs($e,{value:"error",className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-4 w-4 text-red-500"}),s("dashboard:systemLog.tabs.error")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(D,{placeholder:s("dashboard:systemLog.search"),value:V,onChange:B=>E(B.target.value),className:"w-full md:w-64"})]})]}),e.jsx(ms,{value:"all",className:"mt-0",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:L,selectedLevel:X,total:ia,currentPage:k,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})}),e.jsx(ms,{value:"info",className:"mt-0 overflow-x-auto",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:L,selectedLevel:X,total:ia,currentPage:k,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})}),e.jsx(ms,{value:"warning",className:"mt-0",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:L,selectedLevel:X,total:ia,currentPage:k,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})}),e.jsx(ms,{value:"error",className:"mt-0",children:e.jsx(ga,{data:la,isLoading:ra,searchKeyword:L,selectedLevel:X,total:ia,currentPage:k,pageSize:T,onViewDetail:da,onPageChange:oa,onPageSizeChange:ca})})]}),e.jsxs(Me,{children:[e.jsxs(G,{variant:"outline",onClick:()=>Hi(),children:[e.jsx(nn,{className:"mr-2 h-4 w-4"}),s("dashboard:common.refresh")]}),e.jsx(G,{variant:"outline",onClick:Yi,children:s("dashboard:systemLog.filter.reset")}),e.jsx(Qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})]})]})}),e.jsx(de,{open:g,onOpenChange:f,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:s("dashboard:systemLog.detailTitle")})}),S&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.level")}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:"h-4 w-4"}),e.jsx("p",{className:"font-medium",children:S.level})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.time")}),e.jsx("p",{children:ya(S.created_at)||ya(S.updated_at)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.logTitle")}),e.jsx("div",{className:"whitespace-pre-wrap rounded-md bg-muted/50 p-3",children:S.title||S.message||""})]}),(S.host||S.ip)&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[S.host&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.host")}),e.jsx("p",{className:"break-all rounded-md bg-muted/50 p-2 text-sm",children:S.host})]}),S.ip&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.ip")}),e.jsx("p",{className:"rounded-md bg-muted/50 p-2 text-sm",children:S.ip})]})]}),S.uri&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.uri")}),e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 p-3",children:e.jsx("code",{className:"text-sm",children:S.uri})})]}),S.method&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.method")}),e.jsx("div",{children:e.jsx(U,{variant:"outline",className:"text-base font-medium",children:S.method})})]}),S.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.requestData")}),e.jsx("div",{className:"max-h-[150px] overflow-y-auto rounded-md bg-muted/50 p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs",children:(()=>{try{return JSON.stringify(JSON.parse(S.data),null,2)}catch{return S.data}})()})})]}),S.context&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:s("dashboard:systemLog.exception")}),e.jsx("div",{className:"max-h-[250px] overflow-y-auto rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-xs text-red-700 dark:text-red-300",children:(()=>{try{const B=JSON.parse(S.context);if(B.exception){const Rs=B.exception,vt=Rs["\0*\0message"]||"",Zi=Rs["\0*\0file"]||"",eo=Rs["\0*\0line"]||"";return`${vt}
-File: ${Xi}
-Line: ${Zi}`}return JSON.stringify(B,null,2)}catch{return L.context}})()})})]})]}),e.jsx(Me,{children:e.jsx(Qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})})]})}),e.jsx(de,{open:ne,onOpenChange:H,children:e.jsxs(ce,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-5 w-5 text-destructive"}),s("dashboard:systemLog.clearLogs")]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"clearDays",children:s("dashboard:systemLog.clearDays")}),e.jsx(k,{id:"clearDays",type:"number",min:"0",max:"365",value:ee,onChange:B=>{const Ls=B.target.value;if(Ls==="")fe(0);else{const vt=parseInt(Ls);!isNaN(vt)&&vt>=0&&vt<=365&&fe(vt)}},placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearDaysDesc")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"clearLevel",children:s("dashboard:systemLog.clearLevel")}),e.jsxs(J,{value:fs,onValueChange:Ie,children:[e.jsx(W,{children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx(A,{value:"all",children:s("dashboard:systemLog.tabs.all")}),e.jsx(A,{value:"info",children:s("dashboard:systemLog.tabs.info")}),e.jsx(A,{value:"warning",children:s("dashboard:systemLog.tabs.warning")}),e.jsx(A,{value:"error",children:s("dashboard:systemLog.tabs.error")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"clearLimit",children:s("dashboard:systemLog.clearLimit")}),e.jsx(k,{id:"clearLimit",type:"number",min:"100",max:"10000",value:re,onChange:B=>q(parseInt(B.target.value)||1e3),placeholder:"1000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearLimitDesc")})]})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vn,{className:"h-5 w-5 text-amber-600"}),e.jsx("span",{className:"font-medium text-amber-800 dark:text-amber-200",children:s("dashboard:systemLog.clearPreview")})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:Yi,disabled:oe,children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.getStats")]})]}),na&&$s&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.cutoffDate")}),e.jsx("p",{className:"font-mono text-sm",children:$s.cutoff_date})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.totalLogs")}),e.jsx("p",{className:"font-mono text-sm font-medium",children:$s.total_logs.toLocaleString()})]})]}),e.jsxs("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bt,{className:"h-4 w-4 text-red-600"}),e.jsxs("span",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:[s("dashboard:systemLog.willClear"),":",e.jsx("span",{className:"ml-1 font-bold",children:$s.logs_to_clear.toLocaleString()}),s("dashboard:systemLog.logsUnit")]})]}),e.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-300",children:s("dashboard:systemLog.clearWarning")})]})]})]})]}),e.jsxs(Me,{children:[e.jsx(G,{variant:"outline",onClick:()=>{H(!1),Vt(!1),Et(null)},children:s("common:cancel")}),e.jsx(G,{variant:"destructive",onClick:Ji,disabled:oe||!na||!$s,children:oe?e.jsxs(e.Fragment,{children:[e.jsx(Sa,{className:"mr-2 h-4 w-4 animate-spin"}),s("dashboard:systemLog.clearing")]}):e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.confirmClear")]})})]})]})})]})}function Um(){const{t:s}=M();return e.jsxs(qe,{children:[e.jsxs(Ue,{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(cs,{}),e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsx(We,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Mm,{}),e.jsx(Rm,{}),e.jsx(Om,{}),e.jsx(qm,{})]})})})]})}const Hm=Object.freeze(Object.defineProperty({__proto__:null,default:Um},Symbol.toStringTag,{value:"Module"}));function Km({className:s,items:n,...t}){const{pathname:r}=Dn(),a=Bs(),[i,l]=m.useState(r??"/settings"),d=x=>{l(x),a(x)},{t:u}=M("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(J,{value:i,onValueChange:d,children:[e.jsx(W,{className:"h-12 sm:w-48",children:e.jsx(Q,{placeholder:"Theme"})}),e.jsx(Y,{children:n.map(x=>e.jsx(A,{value:x.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:x.icon}),e.jsx("span",{className:"text-md",children:u(x.title)})]})},x.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),...t,children:n.map(x=>e.jsxs(Zs,{to:x.href,className:N(Rt({variant:"ghost"}),r===x.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:x.icon}),u(x.title)]},x.href))})})]})}const Bm=[{title:"site.title",key:"site",icon:e.jsx(Hc,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Jr,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Qr,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Kc,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(Yr,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Bc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Gc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Wr,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(Wc,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Gm(){const{t:s}=M("settings");return e.jsxs(qe,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Ve,{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(Km,{items:Bm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(Fn,{})})})]})]})]})}const Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"})),X=m.forwardRef(({className:s,...n},t)=>e.jsx(vl,{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:t,children:e.jsx(Yc,{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")})}));X.displayName=vl.displayName;const Rs=m.forwardRef(({className:s,...n},t)=>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:t,...n}));Rs.displayName="Textarea";const Ym=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 Jm(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),{data:a}=ae({queryKey:["settings","site"],queryFn:()=>ve.getSettings("site")}),{data:i}=ae({queryKey:["plans"],queryFn:()=>ys.getList()}),l=we({resolver:Te(Ym),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=Is({mutationFn:ve.saveSettings,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(a?.data?.site){const o=a?.data?.site;Object.entries(o).forEach(([c,f])=>{l.setValue(c,f)}),r.current=o}},[a]);const u=m.useCallback(Ee.debounce(async o=>{if(!Ee.isEqual(o,r.current)){t(!0);try{const c=Object.entries(o).reduce((f,[F,S])=>(f[F]=S===null?"":S,f),{});await d(c),r.current=o}finally{t(!1)}}},1e3),[d]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=l.watch(c=>{x(c)});return()=>o.unsubscribe()},[l.watch,x]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:l.control,name:"app_name",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.siteName.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.siteName.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.siteName.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"app_description",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.siteDescription.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.siteDescription.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.siteDescription.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"app_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.siteUrl.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.siteUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.siteUrl.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"force_https",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("site.form.forceHttps.label")}),e.jsx(z,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:!!o.value,onCheckedChange:c=>{o.onChange(Number(c)),x(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"logo",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.logo.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.logo.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.logo.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"subscribe_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(Rs,{placeholder:s("site.form.subscribeUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.subscribeUrl.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"tos_url",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.tosUrl.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.tosUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.tosUrl.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"stop_register",render:({field:o})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("site.form.stopRegister.label")}),e.jsx(z,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:!!o.value,onCheckedChange:c=>{o.onChange(Number(c)),x(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"try_out_plan_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(J,{value:o.value?.toString(),onValueChange:c=>{o.onChange(Number(c)),x(l.getValues())},children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(c=>e.jsx(A,{value:c.id.toString(),children:c.name},c.id.toString()))]})]})}),e.jsx(z,{children:s("site.form.tryOut.description")}),e.jsx(R,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(v,{control:l.control,name:"try_out_hour",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"",children:s("site.form.tryOut.duration.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.tryOut.duration.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.tryOut.duration.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"currency",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.currency.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.currency.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.currency.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"currency_symbol",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("site.form.currencySymbol.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("site.form.currencySymbol.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.currencySymbol.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Qm(){const{t:s}=M("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(Ve,{}),e.jsx(Jm,{})]})}const Xm=Object.freeze(Object.defineProperty({__proto__:null,default:Qm},Symbol.toStringTag,{value:"Module"})),Zm=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(),captcha_enable:h.boolean().nullable(),captcha_type:h.string().nullable(),recaptcha_key:h.string().nullable(),recaptcha_site_key:h.string().nullable(),recaptcha_v3_secret_key:h.string().nullable(),recaptcha_v3_site_key:h.string().nullable(),recaptcha_v3_score_threshold:h.coerce.string().transform(s=>s===""?null:s).nullable(),turnstile_secret_key:h.string().nullable(),turnstile_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()}),eu={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,captcha_enable:!1,captcha_type:"recaptcha",recaptcha_key:"",recaptcha_site_key:"",recaptcha_v3_secret_key:"",recaptcha_v3_site_key:"",recaptcha_v3_score_threshold:"0.5",turnstile_secret_key:"",turnstile_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 su(){const{t:s}=M("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),i=m.useRef(null),l=we({resolver:Te(Zm),defaultValues:eu,mode:"onBlur"}),{data:d}=ae({queryKey:["settings","safe"],queryFn:()=>ve.getSettings("safe")}),{mutateAsync:u}=Is({mutationFn:ve.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data.safe){const c=d.data.safe,f={};Object.entries(c).forEach(([F,S])=>{if(typeof S=="number"){const w=String(S);l.setValue(F,w),f[F]=w}else l.setValue(F,S),f[F]=S}),i.current=f,a(!0)}},[d]);const x=m.useCallback(Ee.debounce(async c=>{if(!Ee.isEqual(c,i.current)){t(!0);try{const f={...c,email_whitelist_suffix:c.email_whitelist_suffix?.filter(Boolean)||[]};await u(f),i.current=c}finally{t(!1)}}},1e3),[u]),o=m.useCallback(c=>{r&&x(c)},[x,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(f=>{o(f)});return()=>c.unsubscribe()},[l.watch,o,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:l.control,name:"email_verify",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.emailVerify.label")}),e.jsx(z,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"email_gmail_limit_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.gmailLimit.label")}),e.jsx(z,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"safe_mode_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.safeMode.label")}),e.jsx(z,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"secure_path",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.securePath.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.securePath.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.securePath.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"email_whitelist_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.emailWhitelist.label")}),e.jsx(z,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),l.watch("email_whitelist_enable")&&e.jsx(v,{control:l.control,name:"email_whitelist_suffix",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(Rs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...c,value:(c.value||[]).join(`
-`),onChange:f=>{const F=f.target.value.split(`
-`).filter(Boolean);c.onChange(F),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"captcha_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.enable.label")}),e.jsx(z,{children:s("safe.form.captcha.enable.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),l.watch("captcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"captcha_type",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.type.label")}),e.jsxs(J,{onValueChange:f=>{c.onChange(f),o(l.getValues())},value:c.value||"recaptcha",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("safe.form.captcha.type.description")})})}),e.jsxs(Y,{children:[e.jsx(A,{value:"recaptcha",children:s("safe.form.captcha.type.options.recaptcha")}),e.jsx(A,{value:"recaptcha-v3",children:s("safe.form.captcha.type.options.recaptcha-v3")}),e.jsx(A,{value:"turnstile",children:s("safe.form.captcha.type.options.turnstile")})]})]}),e.jsx(z,{children:s("safe.form.captcha.type.description")}),e.jsx(R,{})]})}),l.watch("captcha_type")==="recaptcha"&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"recaptcha_site_key",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.recaptcha.siteKey.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.captcha.recaptcha.siteKey.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"recaptcha_key",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.recaptcha.key.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.captcha.recaptcha.key.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha.key.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="recaptcha-v3"&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"recaptcha_v3_site_key",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.siteKey.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.captcha.recaptcha_v3.siteKey.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha_v3.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"recaptcha_v3_secret_key",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.secretKey.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.captcha.recaptcha_v3.secretKey.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha_v3.secretKey.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"recaptcha_v3_score_threshold",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",step:"0.1",min:"0",max:"1",placeholder:s("safe.form.captcha.recaptcha_v3.scoreThreshold.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="turnstile"&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"turnstile_site_key",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.turnstile.siteKey.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.captcha.turnstile.siteKey.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.turnstile.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"turnstile_secret_key",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.captcha.turnstile.secretKey.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.captcha.turnstile.secretKey.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.turnstile.secretKey.description")}),e.jsx(R,{})]})})]})]}),e.jsx(v,{control:l.control,name:"register_limit_by_ip_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.enable.label")}),e.jsx(z,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),l.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"register_limit_count",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.count.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.registerLimit.count.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.registerLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"register_limit_expire",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.registerLimit.expire.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.registerLimit.expire.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(R,{})]})})]}),e.jsx(v,{control:l.control,name:"password_limit_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.enable.label")}),e.jsx(z,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),l.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"password_limit_count",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.count.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.passwordLimit.count.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"password_limit_expire",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("safe.form.passwordLimit.expire.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("safe.form.passwordLimit.expire.placeholder"),...c,value:c.value||"",onChange:f=>{c.onChange(f),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function tu(){const{t:s}=M("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(Ve,{}),e.jsx(su,{})]})}const au=Object.freeze(Object.defineProperty({__proto__:null,default:tu},Symbol.toStringTag,{value:"Module"})),nu=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")}),ru={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 lu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(nu),defaultValues:ru,mode:"onBlur"}),{data:i}=ae({queryKey:["settings","subscribe"],queryFn:()=>ve.getSettings("subscribe")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:x=>{x.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.subscribe){const x=i?.data?.subscribe;Object.entries(x).forEach(([o,c])=>{a.setValue(o,c)}),r.current=x}},[i]);const d=m.useCallback(Ee.debounce(async x=>{if(!Ee.isEqual(x,r.current)){t(!0);try{await l(x),r.current=x}finally{t(!1)}}},1e3),[l]),u=m.useCallback(x=>{d(x)},[d]);return m.useEffect(()=>{const x=a.watch(o=>{u(o)});return()=>x.unsubscribe()},[a.watch,u]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"plan_change_enable",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(z,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(X,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"reset_traffic_method",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(J,{onValueChange:x.onChange,value:x.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择重置方式"})})}),e.jsxs(Y,{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(z,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"surplus_enable",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(z,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(X,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"new_order_event_id",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{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:x.onChange,value:x.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{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(z,{children:s("subscribe.new_order_event.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"renew_order_event_id",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{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:x.onChange,value:x.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{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(z,{children:s("subscribe.renew_order_event.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"change_order_event_id",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{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:x.onChange,value:x.value?.toString(),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(Y,{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(z,{children:s("subscribe.change_order_event.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"subscribe_path",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:"subscribe",...x,value:x.value||"",onChange:o=>{x.onChange(o),u(a.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:x.value||"s"}),e.jsx("br",{}),s("subscribe.subscribe_path.restart_tip")]}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"show_info_to_server_enable",render:({field:x})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("subscribe.show_info_to_server.title")}),e.jsx(z,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})})]})}),e.jsx(v,{control:a.control,name:"show_protocol_to_server_enable",render:({field:x})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("subscribe.show_protocol_to_server.title")}),e.jsx(z,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function iu(){const{t:s}=M("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(Ve,{}),e.jsx(lu,{})]})}const ou=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),cu=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)}),du={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 mu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),i=m.useRef(null),l=we({resolver:Te(cu),defaultValues:du,mode:"onBlur"}),{data:d}=ae({queryKey:["settings","invite"],queryFn:()=>ve.getSettings("invite")}),{mutateAsync:u}=Is({mutationFn:ve.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data?.invite){const c=d?.data?.invite,f={};Object.entries(c).forEach(([F,S])=>{if(typeof S=="number"){const w=String(S);l.setValue(F,w),f[F]=w}else l.setValue(F,S),f[F]=S}),i.current=f,a(!0)}},[d]);const x=m.useCallback(Ee.debounce(async c=>{if(!Ee.isEqual(c,i.current)){t(!0);try{await u(c),i.current=c}finally{t(!1)}}},1e3),[u]),o=m.useCallback(c=>{r&&x(c)},[x,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(f=>{o(f)});return()=>c.unsubscribe()},[l.watch,o,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:l.control,name:"invite_force",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.invite_force.title")}),e.jsx(z,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"invite_commission",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("invite.invite_commission.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("invite.invite_commission.placeholder"),...c,value:c.value||""})}),e.jsx(z,{children:s("invite.invite_commission.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"invite_gen_limit",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("invite.invite_gen_limit.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("invite.invite_gen_limit.placeholder"),...c,value:c.value||""})}),e.jsx(z,{children:s("invite.invite_gen_limit.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"invite_never_expire",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.invite_never_expire.title")}),e.jsx(z,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"commission_first_time_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_first_time.title")}),e.jsx(z,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"commission_auto_check_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_auto_check.title")}),e.jsx(z,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"commission_withdraw_limit",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("invite.commission_withdraw_limit.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("invite.commission_withdraw_limit.placeholder"),...c,value:c.value||""})}),e.jsx(z,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"commission_withdraw_method",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("invite.commission_withdraw_method.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("invite.commission_withdraw_method.placeholder"),...c,value:Array.isArray(c.value)?c.value.join(","):"",onChange:f=>{const F=f.target.value.split(",").filter(Boolean);c.onChange(F),o(l.getValues())}})}),e.jsx(z,{children:s("invite.commission_withdraw_method.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"withdraw_close_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.withdraw_close.title")}),e.jsx(z,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),e.jsx(v,{control:l.control,name:"commission_distribution_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("invite.commission_distribution.title")}),e.jsx(z,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:c.value,onCheckedChange:f=>{c.onChange(f),o(l.getValues())}})})]})}),l.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(v,{control:l.control,name:"commission_distribution_l1",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{children:s("invite.commission_distribution.l1")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:f=>{const F=f.target.value?Number(f.target.value):0;c.onChange(F),o(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"commission_distribution_l2",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{children:s("invite.commission_distribution.l2")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:f=>{const F=f.target.value?Number(f.target.value):0;c.onChange(F),o(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(v,{control:l.control,name:"commission_distribution_l3",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{children:s("invite.commission_distribution.l3")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:s("invite.commission_distribution.placeholder"),...c,value:c.value||"",onChange:f=>{const F=f.target.value?Number(f.target.value):0;c.onChange(F),o(l.getValues())}})}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function uu(){const{t:s}=M("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(Ve,{}),e.jsx(mu,{})]})}const xu=Object.freeze(Object.defineProperty({__proto__:null,default:uu},Symbol.toStringTag,{value:"Module"})),hu=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()}),gu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function pu(){const{data:s}=ae({queryKey:["settings","frontend"],queryFn:()=>ve.getSettings("frontend")}),n=we({resolver:Te(hu),defaultValues:gu,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,i])=>{n.setValue(a,i)})}},[s]);function t(r){ve.saveSettings(r).then(({data:a})=>{a&&$.success("更新成功")})}return e.jsx(De,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(v,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:"边栏风格"}),e.jsx(z,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(X,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(v,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:"头部风格"}),e.jsx(z,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(X,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(v,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:N(Rt({variant:"outline"}),"w-[200px] appearance-none font-normal"),...r,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(En,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(z,{children:"主题色"}),e.jsx(R,{})]})}),e.jsx(v,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(j,{children:[e.jsx(b,{children:"背景"}),e.jsx(_,{children:e.jsx(k,{placeholder:"请输入图片地址",...r})}),e.jsx(z,{children:"将会在后台登录页面进行展示。"}),e.jsx(R,{})]})}),e.jsx(D,{type:"submit",children:"保存设置"})]})})}function fu(){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(Ve,{}),e.jsx(pu,{})]})}const ju=Object.freeze(Object.defineProperty({__proto__:null,default:fu},Symbol.toStringTag,{value:"Module"})),vu=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()}),bu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function yu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(vu),defaultValues:bu,mode:"onBlur"}),{data:i}=ae({queryKey:["settings","server"],queryFn:()=>ve.getSettings("server")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:o=>{o.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(i?.data.server){const o=i.data.server;Object.entries(o).forEach(([c,f])=>{a.setValue(c,f)}),r.current=o}},[i]);const d=m.useCallback(Ee.debounce(async o=>{if(!Ee.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]);const x=()=>{const o=Math.floor(Math.random()*17)+16,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let f="";for(let F=0;Fe.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("server.server_token.title")}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(k,{placeholder:s("server.server_token.placeholder"),...o,value:o.value||"",className:"pr-10"}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:c=>{c.preventDefault(),x()},children:e.jsx(Jc,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ue,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(z,{children:s("server.server_token.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"server_pull_interval",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("server.server_pull_interval.title")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:s("server.server_pull_interval.placeholder"),...o,value:o.value||"",onChange:c=>{const f=c.target.value?Number(c.target.value):null;o.onChange(f)}})}),e.jsx(z,{children:s("server.server_pull_interval.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"server_push_interval",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("server.server_push_interval.title")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:s("server.server_push_interval.placeholder"),...o,value:o.value||"",onChange:c=>{const f=c.target.value?Number(c.target.value):null;o.onChange(f)}})}),e.jsx(z,{children:s("server.server_push_interval.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"device_limit_mode",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(Y,{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(z,{children:s("server.device_limit_mode.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function _u(){const{t:s}=M("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(Ve,{}),e.jsx(yu,{})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"}));function wu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(fl,{className:"h-5 w-5 text-green-500"}):e.jsx(jl,{className:"h-5 w-5 text-destructive"}),e.jsx(me,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ae,{children:r?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),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:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.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:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(ut,{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:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const Cu=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 Su(){const{t:s}=M("settings"),[n,t]=m.useState(null),[r,a]=m.useState(!1),i=m.useRef(null),[l,d]=m.useState(!1),u=we({resolver:Te(Cu),defaultValues:{},mode:"onBlur"}),{data:x}=ae({queryKey:["settings","email"],queryFn:()=>ve.getSettings("email")}),{data:o}=ae({queryKey:["emailTemplate"],queryFn:()=>ve.getEmailTemplate()}),{mutateAsync:c}=Is({mutationFn:ve.saveSettings,onSuccess:T=>{T.data&&$.success(s("common.autoSaved"))}}),{mutate:f,isPending:F}=Is({mutationFn:ve.sendTestMail,onMutate:()=>{t(null),a(!1)},onSuccess:T=>{t(T.data),a(!0),T.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(x?.data.email){const T=x.data.email;Object.entries(T).forEach(([y,L])=>{u.setValue(y,L)}),i.current=T}},[x]);const S=m.useCallback(Ee.debounce(async T=>{if(!Ee.isEqual(T,i.current)){d(!0);try{await c(T),i.current=T}finally{d(!1)}}},1e3),[c]),w=m.useCallback(T=>{S(T)},[S]);return m.useEffect(()=>{const T=u.watch(y=>{w(y)});return()=>T.unsubscribe()},[u.watch,w]),e.jsxs(e.Fragment,{children:[e.jsx(De,{...u,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"email_host",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_host.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_host.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"email_port",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_port.title")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:s("common.placeholder"),...T,value:T.value||"",onChange:y=>{const L=y.target.value?Number(y.target.value):null;T.onChange(L)}})}),e.jsx(z,{children:s("email.email_port.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"email_encryption",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(J,{onValueChange:y=>{const L=y==="none"?"":y;T.onChange(L)},value:T.value===""||T.value===null||T.value===void 0?"none":T.value,children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:"请选择加密方式"})})}),e.jsxs(Y,{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(z,{children:s("email.email_encryption.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"email_username",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_username.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),autoComplete:"off",...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_username.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"email_password",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_password.title")}),e.jsx(_,{children:e.jsx(k,{type:"password",placeholder:s("common.placeholder"),autoComplete:"off",...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_password.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"email_from_address",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_from.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_from.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"email_template",render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(J,{onValueChange:y=>{T.onChange(y),w(u.getValues())},value:T.value||void 0,children:[e.jsx(_,{children:e.jsx(W,{className:"w-[200px]",children:e.jsx(Q,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(Y,{children:o?.data?.map(y=>e.jsx(A,{value:y,children:y},y))})]}),e.jsx(z,{children:s("email.email_template.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"remind_mail_enable",render:({field:T})=>e.jsxs(j,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:s("email.remind_mail.title")}),e.jsx(z,{children:s("email.remind_mail.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:T.value||!1,onCheckedChange:y=>{T.onChange(y),w(u.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{onClick:()=>f(),loading:F,disabled:F,children:s(F?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(wu,{open:r,onOpenChange:a,result:n})]})}function ku(){const{t:s}=M("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(Ve,{}),e.jsx(Su,{})]})}const Tu=Object.freeze(Object.defineProperty({__proto__:null,default:ku},Symbol.toStringTag,{value:"Module"})),Du=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Fu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Pu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(Du),defaultValues:Fu,mode:"onBlur"}),{data:i}=ae({queryKey:["settings","telegram"],queryFn:()=>ve.getSettings("telegram")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}}),{mutate:d,isPending:u}=Is({mutationFn:ve.setTelegramWebhook,onSuccess:c=>{c.data&&$.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(i?.data.telegram){const c=i.data.telegram;Object.entries(c).forEach(([f,F])=>{a.setValue(f,F)}),r.current=c}},[i]);const x=m.useCallback(Ee.debounce(async c=>{if(!Ee.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),o=m.useCallback(c=>{x(c)},[x]);return m.useEffect(()=>{const c=a.watch(f=>{o(f)});return()=>c.unsubscribe()},[a.watch,o]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"telegram_bot_token",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("telegram.bot_token.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("telegram.bot_token.placeholder"),...c,value:c.value||""})}),e.jsx(z,{children:s("telegram.bot_token.description")}),e.jsx(R,{})]})}),a.watch("telegram_bot_token")&&e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("telegram.webhook.title")}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(D,{loading:u,disabled:u,onClick:()=>d(),children:s(u?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(z,{children:s("telegram.webhook.description")}),e.jsx(R,{})]}),e.jsx(v,{control:a.control,name:"telegram_bot_enable",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(z,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(X,{checked:c.value||!1,onCheckedChange:f=>{c.onChange(f),o(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"telegram_discuss_link",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("telegram.discuss_link.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("telegram.discuss_link.placeholder"),...c,value:c.value||""})}),e.jsx(z,{children:s("telegram.discuss_link.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Ru(){const{t:s}=M("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(Ve,{}),e.jsx(Pu,{})]})}const Lu=Object.freeze(Object.defineProperty({__proto__:null,default:Ru},Symbol.toStringTag,{value:"Module"})),Eu=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()}),Vu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Iu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(Eu),defaultValues:Vu,mode:"onBlur"}),{data:i}=ae({queryKey:["settings","app"],queryFn:()=>ve.getSettings("app")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:x=>{x.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(i?.data.app){const x=i.data.app;Object.entries(x).forEach(([o,c])=>{a.setValue(o,c)}),r.current=x}},[i]);const d=m.useCallback(Ee.debounce(async x=>{if(!Ee.isEqual(x,r.current)){t(!0);try{await l(x),r.current=x}finally{t(!1)}}},1e3),[l]),u=m.useCallback(x=>{d(x)},[d]);return m.useEffect(()=>{const x=a.watch(o=>{u(o)});return()=>x.unsubscribe()},[a.watch,u]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:a.control,name:"windows_version",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("app.windows.version.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.windows.version.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"windows_download_url",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("app.windows.download.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.windows.download.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"macos_version",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("app.macos.version.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.macos.version.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"macos_download_url",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("app.macos.download.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.macos.download.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"android_version",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("app.android.version.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.android.version.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"android_download_url",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-base",children:s("app.android.download.title")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("common.placeholder"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.android.download.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Mu(){const{t:s}=M("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(Ve,{}),e.jsx(Iu,{})]})}const Ou=Object.freeze(Object.defineProperty({__proto__:null,default:Mu},Symbol.toStringTag,{value:"Module"})),zu=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(t=>!t||/^https?:\/\/\S+/.test(t),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())}),jr={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function ii({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=jr}){const{t:a}=M("payment"),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[x,o]=m.useState([]),[c,f]=m.useState([]),F=zu(a),S=we({resolver:Te(F),defaultValues:r,mode:"onChange"}),w=S.watch("payment");m.useEffect(()=>{i&&(async()=>{const{data:L}=await mt.getMethodList();o(L)})()},[i]),m.useEffect(()=>{if(!w||!i)return;(async()=>{const L={payment:w,...t==="edit"&&{id:Number(S.getValues("id"))}};mt.getMethodForm(L).then(({data:C})=>{f(C);const g=C.reduce((p,V)=>(V.field_name&&(p[V.field_name]=V.value??""),p),{});S.setValue("config",g)})})()},[w,i,S,t]);const T=async y=>{u(!0);try{(await mt.save(y)).data&&($.success(a("form.messages.success")),S.reset(jr),s(),l(!1))}finally{u(!1)}};return e.jsxs(de,{open:i,onOpenChange:l,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(De,{...S,children:e.jsxs("form",{onSubmit:S.handleSubmit(T),className:"space-y-4",children:[e.jsx(v,{control:S.control,name:"name",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:a("form.fields.name.placeholder"),...y})}),e.jsx(z,{children:a("form.fields.name.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:S.control,name:"icon",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.icon.label")}),e.jsx(_,{children:e.jsx(k,{...y,value:y.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(z,{children:a("form.fields.icon.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:S.control,name:"notify_domain",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.notify_domain.label")}),e.jsx(_,{children:e.jsx(k,{...y,value:y.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(z,{children:a("form.fields.notify_domain.description")}),e.jsx(R,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:S.control,name:"handling_fee_percent",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",...y,value:y.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(R,{})]})}),e.jsx(v,{control:S.control,name:"handling_fee_fixed",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",...y,value:y.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(R,{})]})})]}),e.jsx(v,{control:S.control,name:"payment",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.payment.label")}),e.jsxs(J,{onValueChange:y.onChange,defaultValue:y.value,children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(Y,{children:x.map(L=>e.jsx(A,{value:L,children:L},L))})]}),e.jsx(z,{children:a("form.fields.payment.description")}),e.jsx(R,{})]})}),c.length>0&&e.jsx("div",{className:"space-y-4",children:c.map(y=>e.jsx(v,{control:S.control,name:`config.${y.field_name}`,render:({field:L})=>e.jsxs(j,{children:[e.jsx(b,{children:y.label}),e.jsx(_,{children:e.jsx(k,{...L,value:L.value||""})}),e.jsx(R,{})]})},y.field_name))}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(D,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:t,className:r}){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(D,{variant:"ghost",size:"default",className:N("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",r),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(rr,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ue,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(jn,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(vn,{className:"h-4 w-4 text-foreground/70"}):e.jsx(Qc,{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",r),children:[e.jsx("span",{children:n}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsx(rr,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ue,{children:t})]})})]})}const Hn=Xc,oi=Zc,$u=ed,ci=m.forwardRef(({className:s,...n},t)=>e.jsx(bl,{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:t}));ci.displayName=bl.displayName;const Ka=m.forwardRef(({className:s,...n},t)=>e.jsxs($u,{children:[e.jsx(ci,{}),e.jsx(yl,{ref:t,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})]}));Ka.displayName=yl.displayName;const Ba=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ba.displayName="AlertDialogHeader";const Ga=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ga.displayName="AlertDialogFooter";const Wa=m.forwardRef(({className:s,...n},t)=>e.jsx(_l,{ref:t,className:N("text-lg font-semibold",s),...n}));Wa.displayName=_l.displayName;const Ya=m.forwardRef(({className:s,...n},t)=>e.jsx(Nl,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));Ya.displayName=Nl.displayName;const Ja=m.forwardRef(({className:s,...n},t)=>e.jsx(wl,{ref:t,className:N(Pt(),s),...n}));Ja.displayName=wl.displayName;const Qa=m.forwardRef(({className:s,...n},t)=>e.jsx(Cl,{ref:t,className:N(Pt({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Qa.displayName=Cl.displayName;function _s({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Hn,{children:[e.jsx(oi,{asChild:!0,children:n}),e.jsxs(Ka,{className:N("sm:max-w-[425px]",d),children:[e.jsxs(Ba,{children:[e.jsx(Wa,{children:t}),e.jsx(Ya,{children:r})]}),e.jsxs(Ga,{children:[e.jsx(Qa,{asChild:!0,children:e.jsx(D,{variant:"outline",children:a})}),e.jsx(Ja,{asChild:!0,children:e.jsx(D,{variant:l,onClick:s,children:i})})]})]})]})}const di=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),Au=({refetch:s,isSortMode:n=!1})=>{const{t}=M("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(za,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(X,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await mt.updateStatus({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.name")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.payment")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:r})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:r,title:t("table.columns.notify_url")}),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{className:"ml-1",children:e.jsx(di,{className:"h-4 w-4"})}),e.jsx(ue,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:r.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("table.columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(ii,{refetch:s,dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(_s,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await mt.drop({id:r.original.id});a&&s()},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(us,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function qu({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=M("payment"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ii,{refetch:n}),e.jsx(k,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),i&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Uu(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,x]=m.useState({"drag-handle":!1}),[o,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:f}=ae({queryKey:["paymentList"],queryFn:async()=>{const{data:y}=await mt.getList();return d(y?.map(L=>({...L,enable:!!L.enable}))||[]),y}});m.useEffect(()=>{x({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const F=(y,L)=>{a&&(y.dataTransfer.setData("text/plain",L.toString()),y.currentTarget.classList.add("opacity-50"))},S=(y,L)=>{if(!a)return;y.preventDefault(),y.currentTarget.classList.remove("bg-muted");const C=parseInt(y.dataTransfer.getData("text/plain"));if(C===L)return;const g=[...l],[p]=g.splice(C,1);g.splice(L,0,p),d(g)},w=async()=>{a?mt.sort({ids:l.map(y=>y.id)}).then(()=>{f(),i(!1),$.success("排序保存成功")}):i(!0)},T=Be({data:l,columns:Au({refetch:f,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:o},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(ts,{table:T,toolbar:y=>e.jsx(qu,{table:y,refetch:f,saveOrder:w,isSortMode:a}),draggable:a,onDragStart:F,onDragEnd:y=>y.currentTarget.classList.remove("opacity-50"),onDragOver:y=>{y.preventDefault(),y.currentTarget.classList.add("bg-muted")},onDragLeave:y=>y.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!a})}function Hu(){const{t:s}=M("payment");return e.jsxs(qe,{children:[e.jsxs(Ue,{className:"flex items-center justify-between",children:[e.jsx(cs,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Uu,{})})]})]})}const Ku=Object.freeze(Object.defineProperty({__proto__:null,default:Hu},Symbol.toStringTag,{value:"Module"}));function Bu({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=M("plugin"),[a,i]=m.useState(!0),[l,d]=m.useState(!1),[u,x]=m.useState(null),o=sd({config:td(ad())}),c=we({resolver:Te(o),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:w}=await Us.getPluginConfig(s);x(w),c.reset({config:Object.fromEntries(Object.entries(w).map(([T,y])=>[T,y.value]))})}catch{$.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const f=async S=>{d(!0);try{await Us.updatePluginConfig(s,S.config),$.success(r("messages.configSaveSuccess")),t()}catch{$.error(r("messages.configSaveError"))}finally{d(!1)}},F=(S,w)=>{switch(w.type){case"string":return e.jsx(v,{control:c.control,name:`config.${S}`,render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{children:w.label||w.description}),e.jsx(_,{children:e.jsx(k,{placeholder:w.placeholder,...T})}),w.description&&w.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),e.jsx(R,{})]})},S);case"number":case"percentage":return e.jsx(v,{control:c.control,name:`config.${S}`,render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{children:w.label||w.description}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(k,{type:"number",placeholder:w.placeholder,...T,onChange:y=>{const L=Number(y.target.value);w.type==="percentage"?T.onChange(Math.min(100,Math.max(0,L))):T.onChange(L)},className:w.type==="percentage"?"pr-8":"",min:w.type==="percentage"?0:void 0,max:w.type==="percentage"?100:void 0,step:w.type==="percentage"?1:void 0}),w.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(nd,{className:"h-4 w-4 text-muted-foreground"})})]})}),w.description&&w.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),e.jsx(R,{})]})},S);case"select":return e.jsx(v,{control:c.control,name:`config.${S}`,render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{children:w.label||w.description}),e.jsxs(J,{onValueChange:T.onChange,defaultValue:T.value,children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:w.placeholder})})}),e.jsx(Y,{children:w.options?.map(y=>e.jsx(A,{value:y.value,children:y.label},y.value))})]}),w.description&&w.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),e.jsx(R,{})]})},S);case"boolean":return e.jsx(v,{control:c.control,name:`config.${S}`,render:({field:T})=>e.jsxs(j,{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(b,{className:"text-base",children:w.label||w.description}),w.description&&w.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:w.description})]}),e.jsx(_,{children:e.jsx(X,{checked:T.value,onCheckedChange:T.onChange})})]})},S);case"text":return e.jsx(v,{control:c.control,name:`config.${S}`,render:({field:T})=>e.jsxs(j,{children:[e.jsx(b,{children:w.label||w.description}),e.jsx(_,{children:e.jsx(Rs,{placeholder:w.placeholder,...T})}),w.description&&w.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:w.description}),e.jsx(R,{})]})},S);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"})]}):e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(f),className:"space-y-4",children:[u&&Object.entries(u).map(([S,w])=>F(S,w)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(D,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(D,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function Gu(){const{t:s}=M("plugin"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(null),[d,u]=m.useState(""),[x,o]=m.useState("all"),[c,f]=m.useState(!1),[F,S]=m.useState(!1),[w,T]=m.useState(!1),y=m.useRef(null),[L,C]=m.useState(!1),[g,p]=m.useState(""),{data:V,isLoading:E,refetch:P}=ae({queryKey:["pluginList"],queryFn:async()=>{const{data:q}=await Us.getPluginList();return q}});V&&[...new Set(V.map(q=>q.category||"other"))];const K=V?.filter(q=>{const oe=q.name.toLowerCase().includes(d.toLowerCase())||q.description.toLowerCase().includes(d.toLowerCase())||q.code.toLowerCase().includes(d.toLowerCase()),lt=x==="all"||q.category===x;return oe&<}),Z=async q=>{t(q),Us.installPlugin(q).then(()=>{$.success(s("messages.installSuccess")),P()}).catch(oe=>{$.error(oe.message||s("messages.installError"))}).finally(()=>{t(null)})},se=async q=>{t(q),Us.uninstallPlugin(q).then(()=>{$.success(s("messages.uninstallSuccess")),P()}).catch(oe=>{$.error(oe.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},ne=async(q,oe)=>{t(q),(oe?Us.disablePlugin:Us.enablePlugin)(q).then(()=>{$.success(s(oe?"messages.disableSuccess":"messages.enableSuccess")),P()}).catch($s=>{$.error($s.message||s(oe?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},H=q=>{V?.find(oe=>oe.code===q),l(q),a(!0)},ee=async q=>{if(!q.name.endsWith(".zip")){$.error(s("upload.error.format"));return}f(!0),Us.uploadPlugin(q).then(()=>{$.success(s("messages.uploadSuccess")),S(!1),P()}).catch(oe=>{$.error(oe.message||s("messages.uploadError"))}).finally(()=>{f(!1),y.current&&(y.current.value="")})},fe=q=>{q.preventDefault(),q.stopPropagation(),q.type==="dragenter"||q.type==="dragover"?T(!0):q.type==="dragleave"&&T(!1)},fs=q=>{q.preventDefault(),q.stopPropagation(),T(!1),q.dataTransfer.files&&q.dataTransfer.files[0]&&ee(q.dataTransfer.files[0])},Ie=async q=>{t(q),Us.deletePlugin(q).then(()=>{$.success(s("messages.deleteSuccess")),P()}).catch(oe=>{$.error(oe.message||s("messages.deleteError"))}).finally(()=>{t(null)})},re=q=>rd(q||"",{walkTokens(oe){(oe.type==="image"||oe.type==="link")&&(oe.type="text",oe.raw="",oe.text="")}});return e.jsxs(qe,{children:[e.jsxs(Ue,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Rn,{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(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Ln,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(k,{placeholder:s("search.placeholder"),value:d,onChange:q=>u(q.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(D,{onClick:()=>S(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(Dt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(gt,{defaultValue:"all",className:"w-full",children:[e.jsxs(at,{children:[e.jsx($e,{value:"all",children:s("tabs.all")}),e.jsx($e,{value:"installed",children:s("tabs.installed")}),e.jsx($e,{value:"available",children:s("tabs.available")})]}),e.jsx(ms,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:E?e.jsxs(e.Fragment,{children:[e.jsx(mn,{}),e.jsx(mn,{}),e.jsx(mn,{})]}):K?.map(q=>e.jsx(dn,{plugin:q,onInstall:Z,onUninstall:se,onToggleEnable:ne,onOpenConfig:H,onDelete:Ie,isLoading:n===q.name,onShowReadme:q.readme?()=>{p(q.readme),C(!0)}:void 0},q.name))})}),e.jsx(ms,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:K?.filter(q=>q.is_installed).map(q=>e.jsx(dn,{plugin:q,onInstall:Z,onUninstall:se,onToggleEnable:ne,onOpenConfig:H,onDelete:Ie,isLoading:n===q.name,onShowReadme:q.readme?()=>{p(q.readme),C(!0)}:void 0},q.name))})}),e.jsx(ms,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:K?.filter(q=>!q.is_installed).map(q=>e.jsx(dn,{plugin:q,onInstall:Z,onUninstall:se,onToggleEnable:ne,onOpenConfig:H,onDelete:Ie,isLoading:n===q.name,onShowReadme:q.readme?()=>{p(q.readme),C(!0)}:void 0},q.code))})})]})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(ce,{className:"sm:max-w-lg",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[V?.find(q=>q.code===i)?.name," ",s("config.title")]}),e.jsx(Ae,{children:s("config.description")})]}),i&&e.jsx(Bu,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),P()}})]})}),e.jsx(de,{open:F,onOpenChange:S,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(Ae,{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",w&&"border-primary/50 bg-muted/50"),onDragEnter:fe,onDragLeave:fe,onDragOver:fe,onDrop:fs,children:[e.jsx("input",{type:"file",ref:y,className:"hidden",accept:".zip",onChange:q=>{const oe=q.target.files?.[0];oe&&ee(oe)}}),c?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:()=>y.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(de,{open:L,onOpenChange:C,children:e.jsxs(ce,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsx(me,{children:s("readme.title",{defaultValue:"插件文档"})})}),e.jsx("div",{className:"markdown-body max-h-[60vh] overflow-y-auto",dangerouslySetInnerHTML:{__html:re(g)}})]})})]})]})}function dn({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l,onShowReadme:d}){const{t:u}=M("plugin");return e.jsxs(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(Fe,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{children:s.name}),s.is_installed&&e.jsx(U,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?u("status.enabled"):u("status.disabled")}),s.readme&&e.jsx("button",{type:"button",onClick:d,className:"ml-1 flex items-center justify-center rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-primary",title:u("button.readme",{defaultValue:"查看文档"}),style:{lineHeight:0},children:e.jsx(yn,{className:"h-4 w-4"})})]}),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(Rn,{className:"h-4 w-4"}),e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:s.code})]}),e.jsxs("div",{children:["v",s.version]})]})]})}),e.jsx(Hs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"mt-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-1",children:[u("author"),": ",s.author]})})]})})]}),e.jsx(Pe,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[s.is_installed&&s.config&&Object.keys(s.config).length>0&&e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),u("button.config")]}),e.jsxs(D,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(ld,{className:"mr-2 h-4 w-4"}),s.is_enabled?u("button.disable"):u("button.enable")]}),e.jsx(_s,{title:u("uninstall.title"),description:u("uninstall.description"),cancelText:u("common:cancel"),confirmText:u("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(D,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),u("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(D,{onClick:()=>n(s.code),disabled:l,loading:l,children:u("button.install")}),e.jsx(_s,{title:u("delete.title"),description:u("delete.description"),cancelText:u("common:cancel"),confirmText:u("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(D,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(us,{className:"h-4 w-4"})})})]})})})]})}function mn(){return e.jsxs(ke,{children:[e.jsxs(Fe,{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(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(je,{className:"h-5 w-[120px]"}),e.jsx(je,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(je,{className:"h-4 w-[300px]"}),e.jsx(je,{className:"h-4 w-[150px]"})]})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-8 w-8"})]})})]})}const Wu=Object.freeze(Object.defineProperty({__proto__:null,default:Gu},Symbol.toStringTag,{value:"Module"})),Yu=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(k,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(Rs,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:N(Pt({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Ju({themeKey:s,themeInfo:n}){const{t}=M("theme"),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),x=we({defaultValues:n.configs.reduce((f,F)=>(f[F.field_name]="",f),{})}),o=async()=>{l(!0),Wt.getConfig(s).then(({data:f})=>{Object.entries(f).forEach(([F,S])=>{x.setValue(F,S)})}).finally(()=>{l(!1)})},c=async f=>{u(!0),Wt.updateConfig(s,f).then(()=>{$.success(t("config.success")),a(!1)}).finally(()=>{u(!1)})};return e.jsxs(de,{open:r,onOpenChange:f=>{a(f),f?o():x.reset()},children:[e.jsx(ps,{asChild:!0,children:e.jsx(D,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(ce,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:t("config.title",{name:n.name})}),e.jsx(Ae,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Sa,{className:"h-6 w-6 animate-spin"})}):e.jsx(De,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(c),className:"space-y-4",children:[n.configs.map(f=>e.jsx(v,{control:x.control,name:f.field_name,render:({field:F})=>e.jsxs(j,{children:[e.jsx(b,{children:f.label}),e.jsx(_,{children:Yu(f,F)}),e.jsx(R,{})]})},f.field_name)),e.jsxs(Me,{className:"mt-6 gap-2",children:[e.jsx(D,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(D,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function Qu(){const{t:s}=M("theme"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[x,o]=m.useState(null),c=m.useRef(null),[f,F]=m.useState(0),{data:S,isLoading:w,refetch:T}=ae({queryKey:["themeList"],queryFn:async()=>{const{data:P}=await Wt.getList();return P}}),y=async P=>{t(P),ve.updateSystemConfig({frontend_theme:P}).then(()=>{$.success("主题切换成功"),T()}).finally(()=>{t(null)})},L=async P=>{if(!P.name.endsWith(".zip")){$.error(s("upload.error.format"));return}a(!0),Wt.upload(P).then(()=>{$.success("主题上传成功"),l(!1),T()}).finally(()=>{a(!1),c.current&&(c.current.value="")})},C=P=>{P.preventDefault(),P.stopPropagation(),P.type==="dragenter"||P.type==="dragover"?u(!0):P.type==="dragleave"&&u(!1)},g=P=>{P.preventDefault(),P.stopPropagation(),u(!1),P.dataTransfer.files&&P.dataTransfer.files[0]&&L(P.dataTransfer.files[0])},p=()=>{x&&F(P=>P===0?x.images.length-1:P-1)},V=()=>{x&&F(P=>P===x.images.length-1?0:P+1)},E=(P,K)=>{F(0),o({name:P,images:K})};return e.jsxs(qe,{children:[e.jsxs(Ue,{className:"flex items-center justify-between",children:[e.jsx(cs,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(D,{onClick:()=>l(!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:w?e.jsxs(e.Fragment,{children:[e.jsx(vr,{}),e.jsx(vr,{})]}):S?.themes&&Object.entries(S.themes).map(([P,K])=>e.jsx(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:K.background_url?`url(${K.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:N("relative z-10 h-full transition-colors",K.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:[!!K.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(_s,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(P===S?.active){$.error(s("card.delete.error.active"));return}t(P),Wt.drop(P).then(()=>{$.success("主题删除成功"),T()}).finally(()=>{t(null)})},children:e.jsx(D,{disabled:n===P,loading:n===P,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(us,{className:"h-4 w-4"})})})}),e.jsxs(Fe,{children:[e.jsx(Le,{children:K.name}),e.jsx(Hs,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:K.description}),K.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:K.version})})]})})]}),e.jsxs(Pe,{className:"flex items-center justify-end space-x-3",children:[K.images&&Array.isArray(K.images)&&K.images.length>0&&e.jsx(D,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>E(K.name,K.images),children:e.jsx(id,{className:"h-4 w-4"})}),e.jsx(Ju,{themeKey:P,themeInfo:K}),e.jsx(D,{onClick:()=>y(P),disabled:n===P||P===S.active,loading:n===P,variant:P===S.active?"secondary":"default",children:P===S.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},P))}),e.jsx(de,{open:i,onOpenChange:l,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(Ae,{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",d&&"border-primary/50 bg-muted/50"),onDragEnter:C,onDragLeave:C,onDragOver:C,onDrop:g,children:[e.jsx("input",{type:"file",ref:c,className:"hidden",accept:".zip",onChange:P=>{const K=P.target.files?.[0];K&&L(K)}}),r?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:()=>c.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(de,{open:!!x,onOpenChange:P=>{P||(o(null),F(0))},children:e.jsxs(ce,{className:"max-w-4xl",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[x?.name," ",s("preview.title")]}),e.jsx(Ae,{className:"text-center",children:x&&s("preview.imageCount",{current:f+1,total:x.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:x?.images[f]&&e.jsx("img",{src:x.images[f],alt:`${x.name} 预览图 ${f+1}`,className:"h-full w-full object-contain"})}),x&&x.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(D,{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(cl,{className:"h-4 w-4"})}),e.jsx(D,{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:V,children:e.jsx(dl,{className:"h-4 w-4"})})]})]}),x&&x.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:x.images.map((P,K)=>e.jsx("button",{onClick:()=>F(K),className:N("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",f===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:P,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function vr(){return e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsx(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-4 w-[300px]"})]}),e.jsxs(Pe,{className:"flex items-center justify-end space-x-3",children:[e.jsx(je,{className:"h-10 w-[100px]"}),e.jsx(je,{className:"h-10 w-[100px]"})]})]})}const Xu=Object.freeze(Object.defineProperty({__proto__:null,default:Qu},Symbol.toStringTag,{value:"Module"})),Xa=m.forwardRef(({className:s,value:n=[],onChange:t,...r},a)=>{const[i,l]=m.useState("");m.useEffect(()=>{if(i.includes(",")){const u=new Set([...n,...i.split(",").map(x=>x.trim())]);t(Array.from(u)),l("")}},[i,t,n]);const d=()=>{if(i){const u=new Set([...n,i]);t(Array.from(u)),l("")}};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(u=>e.jsxs(U,{variant:"secondary",children:[u,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(x=>x!==u))},children:e.jsx(Nn,{className:"w-3"})})]},u)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"||u.key===","?(u.preventDefault(),d()):u.key==="Backspace"&&i.length===0&&n.length>0&&(u.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});Xa.displayName="InputTags";const Zu=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()}),ex={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function mi({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=ex}){const{t:a}=M("notice"),[i,l]=m.useState(!1),d=we({resolver:Te(Zu),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new In({html:!0});return e.jsx(De,{...d,children:e.jsxs(de,{onOpenChange:l,open:i,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(ce,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ae,{})]}),e.jsx(v,{control:d.control,name:"title",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(k,{placeholder:a("form.fields.title.placeholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"content",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.content.label")}),e.jsx(_,{children:e.jsx(Mn,{style:{height:"500px"},value:x.value,renderHTML:o=>u.render(o),onChange:({text:o})=>{x.onChange(o)}})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"img_url",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(k,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...x,value:x.value||""})})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"show",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(X,{checked:x.value,onCheckedChange:x.onChange})})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"tags",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(Xa,{value:x.value,onChange:x.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(D,{type:"submit",onClick:x=>{x.preventDefault(),d.handleSubmit(async o=>{ta.save(o).then(({data:c})=>{c&&($.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function sx({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=M("notice"),i=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:[!r&&e.jsx(mi,{refetch:n}),!r&&e.jsx(k,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),i&&!r&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(D,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const tx=s=>{const{t:n}=M("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(od,{className:"h-4 w-4 cursor-move text-muted-foreground"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(X,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await ta.updateStatus(t.original.id);r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(mi,{refetch:s,dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{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:t.original}),e.jsx(_s,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{ta.drop(t.original.id).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 ax(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState(!1),[o,c]=m.useState({}),[f,F]=m.useState({pageSize:50,pageIndex:0}),[S,w]=m.useState([]),{refetch:T}=ae({queryKey:["notices"],queryFn:async()=>{const{data:p}=await ta.getList();return w(p),p}});m.useEffect(()=>{r({"drag-handle":u,content:!u,created_at:!u,actions:!u}),F({pageSize:u?99999:50,pageIndex:0})},[u]);const y=(p,V)=>{u&&(p.dataTransfer.setData("text/plain",V.toString()),p.currentTarget.classList.add("opacity-50"))},L=(p,V)=>{if(!u)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const E=parseInt(p.dataTransfer.getData("text/plain"));if(E===V)return;const P=[...S],[K]=P.splice(E,1);P.splice(V,0,K),w(P)},C=async()=>{if(!u){x(!0);return}ta.sort(S.map(p=>p.id)).then(()=>{$.success("排序保存成功"),x(!1),T()}).finally(()=>{x(!1)})},g=Be({data:S??[],columns:tx(T),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:o,pagination:f},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:c,onPaginationChange:F,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:g,toolbar:p=>e.jsx(sx,{table:p,refetch:T,saveOrder:C,isSortMode:u}),draggable:u,onDragStart:y,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:L,showPagination:!u})})}function nx(){const{t:s}=M("notice");return e.jsxs(qe,{children:[e.jsxs(Ue,{className:"flex items-center justify-between",children:[e.jsx(cs,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(ax,{})})]})]})}const rx=Object.freeze(Object.defineProperty({__proto__:null,default:nx},Symbol.toStringTag,{value:"Module"})),lx=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()}),ix={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function ui({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=ix}){const{t:a}=M("knowledge"),[i,l]=m.useState(!1),d=we({resolver:Te(lx),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new In({html:!0});return m.useEffect(()=>{i&&r.id&&Ft.getInfo(r.id).then(({data:x})=>{d.reset(x)})},[r.id,d,i]),e.jsxs(de,{onOpenChange:l,open:i,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(ce,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Ae,{})]}),e.jsxs(De,{...d,children:[e.jsx(v,{control:d.control,name:"title",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(k,{placeholder:a("form.titlePlaceholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"category",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(k,{placeholder:a("form.categoryPlaceholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"language",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.language")}),e.jsx(_,{children:e.jsxs(J,{value:x.value,onValueChange:x.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("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(o=>e.jsx(A,{value:o.value,className:"cursor-pointer",children:a(`languages.${o.value}`)},o.value))})]})})]})}),e.jsx(v,{control:d.control,name:"body",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.content")}),e.jsx(_,{children:e.jsx(Mn,{style:{height:"500px"},value:x.value,renderHTML:o=>u.render(o),onChange:({text:o})=>{x.onChange(o)}})}),e.jsx(R,{})]})}),e.jsx(v,{control:d.control,name:"show",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(X,{checked:x.value,onCheckedChange:x.onChange})})}),e.jsx(R,{})]})}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(D,{type:"submit",onClick:()=>{d.handleSubmit(x=>{Ft.save(x).then(({data:o})=>{o&&(d.reset(),$.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function ox({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(rs,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{className:N("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Lt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function cx({table:s,refetch:n,saveOrder:t,isSortMode:r}){const a=s.getState().columnFilters.length>0,{t:i}=M("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ui,{refreshData:n}),e.jsx(k,{placeholder:i("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(ox,{column:s.getColumn("category"),title:i("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const dx=({refetch:s,isSortMode:n=!1})=>{const{t}=M("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(za,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(X,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Ft.updateStatus({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.title")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:r.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(U,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(ui,{refreshData:s,dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(_s,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Ft.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(t("messages.operationSuccess")),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function mx(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,x]=m.useState({"drag-handle":!1}),[o,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:f,isLoading:F,data:S}=ae({queryKey:["knowledge"],queryFn:async()=>{const{data:C}=await Ft.getList();return d(C||[]),C}});m.useEffect(()=>{x({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const w=(C,g)=>{a&&(C.dataTransfer.setData("text/plain",g.toString()),C.currentTarget.classList.add("opacity-50"))},T=(C,g)=>{if(!a)return;C.preventDefault(),C.currentTarget.classList.remove("bg-muted");const p=parseInt(C.dataTransfer.getData("text/plain"));if(p===g)return;const V=[...l],[E]=V.splice(p,1);V.splice(g,0,E),d(V)},y=async()=>{a?Ft.sort({ids:l.map(C=>C.id)}).then(()=>{f(),i(!1),$.success("排序保存成功")}):i(!0)},L=Be({data:l,columns:dx({refetch:f,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:o},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:x,onPaginationChange:c,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:L,toolbar:C=>e.jsx(cx,{table:C,refetch:f,saveOrder:y,isSortMode:a}),draggable:a,onDragStart:w,onDragEnd:C=>C.currentTarget.classList.remove("opacity-50"),onDragOver:C=>{C.preventDefault(),C.currentTarget.classList.add("bg-muted")},onDragLeave:C=>C.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!a})}function ux(){const{t:s}=M("knowledge");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(mx,{})})]})]})}const xx=Object.freeze(Object.defineProperty({__proto__:null,default:ux},Symbol.toStringTag,{value:"Module"}));function hx(s,n){const[t,r]=m.useState(s);return m.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function un(s,n){if(s.length===0)return{};if(!n)return{"":s};const t={};return s.forEach(r=>{const a=r[n]||"";t[a]||(t[a]=[]),t[a].push(r)}),t}function gx(s,n){const t=JSON.parse(JSON.stringify(s));for(const[r,a]of Object.entries(t))t[r]=a.filter(i=>!n.find(l=>l.value===i.value));return t}function px(s,n){for(const[,t]of Object.entries(s))if(t.some(r=>n.find(a=>a.value===r.value)))return!0;return!1}const xi=m.forwardRef(({className:s,...n},t)=>cd(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:N("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);xi.displayName="CommandEmpty";const st=m.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:u,maxSelected:x=Number.MAX_SAFE_INTEGER,onMaxSelected:o,hidePlaceholderWhenSelected:c,disabled:f,groupBy:F,className:S,badgeClassName:w,selectFirstItem:T=!0,creatable:y=!1,triggerSearchOnFocus:L=!1,commandProps:C,inputProps:g,hideClearAllButton:p=!1},V)=>{const E=m.useRef(null),[P,K]=m.useState(!1),Z=m.useRef(!1),[se,ne]=m.useState(!1),[H,ee]=m.useState(s||[]),[fe,fs]=m.useState(un(r,F)),[Ie,re]=m.useState(""),q=hx(Ie,i||500);m.useImperativeHandle(V,()=>({selectedValue:[...H],input:E.current,focus:()=>E.current?.focus()}),[H]);const oe=m.useCallback(te=>{const ye=H.filter(Ye=>Ye.value!==te.value);ee(ye),n?.(ye)},[n,H]),lt=m.useCallback(te=>{const ye=E.current;ye&&((te.key==="Delete"||te.key==="Backspace")&&ye.value===""&&H.length>0&&(H[H.length-1].fixed||oe(H[H.length-1])),te.key==="Escape"&&ye.blur())},[oe,H]);m.useEffect(()=>{s&&ee(s)},[s]),m.useEffect(()=>{if(!a||l)return;const te=un(a||[],F);JSON.stringify(te)!==JSON.stringify(fe)&&fs(te)},[r,a,F,l,fe]),m.useEffect(()=>{const te=async()=>{ne(!0);const Ye=await l?.(q);fs(un(Ye||[],F)),ne(!1)};(async()=>{!l||!P||(L&&await te(),q&&await te())})()},[q,F,P,L]);const $s=()=>{if(!y||px(fe,[{value:Ie,label:Ie}])||H.find(ye=>ye.value===Ie))return;const te=e.jsx(rs,{value:Ie,className:"cursor-pointer",onMouseDown:ye=>{ye.preventDefault(),ye.stopPropagation()},onSelect:ye=>{if(H.length>=x){o?.(H.length);return}re("");const Ye=[...H,{value:ye,label:ye}];ee(Ye),n?.(Ye)},children:`Create "${Ie}"`});if(!l&&Ie.length>0||l&&q.length>0&&!se)return te},Et=m.useCallback(()=>{if(u)return l&&!y&&Object.keys(fe).length===0?e.jsx(rs,{value:"-",disabled:!0,children:u}):e.jsx(xi,{children:u})},[y,u,l,fe]),na=m.useMemo(()=>gx(fe,H),[fe,H]),Vt=m.useCallback(()=>{if(C?.filter)return C.filter;if(y)return(te,ye)=>te.toLowerCase().includes(ye.toLowerCase())?1:-1},[y,C?.filter]),Gs=m.useCallback(()=>{const te=H.filter(ye=>ye.fixed);ee(te),n?.(te)},[n,H]);return e.jsxs(nt,{...C,onKeyDown:te=>{lt(te),C?.onKeyDown?.(te)},className:N("h-auto overflow-visible bg-transparent",C?.className),shouldFilter:C?.shouldFilter!==void 0?C.shouldFilter:!l,filter:Vt(),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":H.length!==0,"cursor-text":!f&&H.length!==0},S),onClick:()=>{f||E.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[H.map(te=>e.jsxs(U,{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",w),"data-fixed":te.fixed,"data-disabled":f||void 0,children:[te.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",(f||te.fixed)&&"hidden"),onKeyDown:ye=>{ye.key==="Enter"&&oe(te)},onMouseDown:ye=>{ye.preventDefault(),ye.stopPropagation()},onClick:()=>oe(te),children:e.jsx(Nn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},te.value)),e.jsx(xs.Input,{...g,ref:E,value:Ie,disabled:f,onValueChange:te=>{re(te),g?.onValueChange?.(te)},onBlur:te=>{Z.current===!1&&K(!1),g?.onBlur?.(te)},onFocus:te=>{K(!0),L&&l?.(q),g?.onFocus?.(te)},placeholder:c&&H.length!==0?"":t,className:N("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":c,"px-3 py-2":H.length===0,"ml-1":H.length!==0},g?.className)}),e.jsx("button",{type:"button",onClick:Gs,className:N((p||f||H.length<1||H.filter(te=>te.fixed).length===H.length)&&"hidden"),children:e.jsx(Nn,{})})]})}),e.jsx("div",{className:"relative",children:P&&e.jsx(rt,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{Z.current=!1},onMouseEnter:()=>{Z.current=!0},onMouseUp:()=>{E.current?.focus()},children:se?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Et(),$s(),!T&&e.jsx(rs,{value:"-",className:"hidden"}),Object.entries(na).map(([te,ye])=>e.jsx(Ss,{heading:te,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ye.map(Ye=>e.jsx(rs,{value:Ye.value,disabled:Ye.disable,onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation()},onSelect:()=>{if(H.length>=x){o?.(H.length);return}re("");const _e=[...H,Ye];ee(_e),n?.(_e)},className:N("cursor-pointer",Ye.disable&&"cursor-default text-muted-foreground"),children:Ye.label},Ye.value))})},te))]})})})]})});st.displayName="MultipleSelector";const fx=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 Za({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=M("group"),i=we({resolver:Te(fx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1),[u,x]=m.useState(!1),o=async c=>{x(!0),pt.save(c).then(()=>{$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{x(!1)})};return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ae,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(De,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(o),className:"space-y-4",children:[e.jsx(v,{control:i.control,name:"name",render:({field:c})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.name")}),e.jsx(_,{children:e.jsx(k,{placeholder:a("form.namePlaceholder"),...c,className:"w-full"})}),e.jsx(z,{children:a("form.nameDescription")}),e.jsx(R,{})]})}),e.jsxs(Me,{className:"gap-2",children:[e.jsx(Qs,{asChild:!0,children:e.jsx(D,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(D,{type:"submit",disabled:u||!i.formState.isValid,children:[u&&e.jsx(Sa,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const hi=m.createContext(void 0);function jx({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),[l,d]=m.useState(xe.Shadowsocks);return e.jsx(hi.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function gi(){const s=m.useContext(hi);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function xn({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=M("server");m.useEffect(()=>{console.log(n)},[n]);const[i,l]=m.useState(!1),[d,u]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[x,o]=m.useState(null),c=y=>{if(!y)return null;try{const L=JSON.parse(y);return typeof L!="object"||L===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},f={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"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},F=()=>{switch(r){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},S=()=>{const y=c(d||"");if(y){$.error(y);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{$.error(a("network_settings.errors.save_failed"))}},w=y=>{u(y),o(c(y))},T=y=>{const L=f[y];if(L){const C=JSON.stringify(L.content,null,2);u(C),o(null)}};return m.useEffect(()=>{i&&console.log(n)},[i,n]),m.useEffect(()=>{i&&n&&Object.keys(n).length>0&&u(JSON.stringify(n,null,2))},[i,n]),e.jsxs(de,{open:i,onOpenChange:y=>{!y&&i&&S(),l(y)},children:[e.jsx(ps,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[F().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:F().map(y=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>T(y),children:a("network_settings.use_template",{template:f[y].label})},y))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Rs,{className:`min-h-[200px] font-mono text-sm ${x?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:F().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:y=>w(y.target.value)}),x&&e.jsx("p",{className:"text-sm text-red-500",children:x})]})]}),e.jsxs(Me,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(G,{onClick:S,disabled:!!x,children:a("common.confirm")})]})]})]})}function lp(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 vx={},bx=Object.freeze(Object.defineProperty({__proto__:null,default:vx},Symbol.toStringTag,{value:"Module"})),ip=kd(bx),br=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),yx=()=>{try{const s=dd.box.keyPair(),n=br(lr.encodeBase64(s.secretKey)),t=br(lr.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},_x=()=>{try{return yx()}catch(s){throw console.error("Error generating key pair:",s),s}},Nx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},wx=()=>{const s=Math.floor(Math.random()*8)*2+2;return Nx(s)},Cx=h.object({cipher:h.string().default("aes-128-gcm"),plugin:h.string().optional().default(""),plugin_opts:h.string().optional().default(""),client_fingerprint:h.string().optional().default("chrome")}),Sx=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({})}),kx=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({})}),Tx=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({}),hop_interval:h.number().optional(),port_range:h.string().optional()}),Dx=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("")}),Fx=h.object({version:h.coerce.number().default(5),congestion_control:h.string().default("bbr"),alpn:h.array(h.string()).default(["h3"]),udp_relay_mode:h.string().default("native"),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Px=h.object({}),Rx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Lx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ex=h.object({transport:h.string().default("tcp"),multiplexing:h.string().default("MULTIPLEXING_LOW")}),Vx=h.object({padding_scheme:h.array(h.string()).optional().default([]),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Oe={shadowsocks:{schema:Cx,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"],plugins:[{value:"none",label:"None"},{value:"obfs",label:"Simple Obfs"},{value:"v2ray-plugin",label:"V2Ray Plugin"}],clientFingerprints:[{value:"chrome",label:"Chrome"},{value:"firefox",label:"Firefox"},{value:"safari",label:"Safari"},{value:"ios",label:"iOS"}]},vmess:{schema:Sx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:kx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Tx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Dx,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"]},tuic:{schema:Fx,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:Px},naive:{schema:Lx},http:{schema:Rx},mieru:{schema:Ex,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:Vx,defaultPaddingScheme:["stop=8","0=30-30","1=100-400","2=400-500,c,500-1000,c,500-1000,c,500-1000,c,500-1000","3=9-9,500-1000","4=500-1000","5=500-1000","6=500-1000","7=500-1000"]}},Ix=({serverType:s,value:n,onChange:t})=>{const{t:r}=M("server"),a=s?Oe[s]:null,i=a?.schema||h.record(h.any()),l=s?i.parse({}):{},d=we({resolver:Te(i),defaultValues:l,mode:"onChange"});if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const g=i.parse({});d.reset(g)}}else d.reset(n)},[s,n,t,d,i]),m.useEffect(()=>{const g=d.watch(p=>{t(p)});return()=>g.unsubscribe()},[d,t]),!s||!a)return null;const C={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"cipher",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.shadowsocks.ciphers.map(p=>e.jsx(A,{value:p,children:p},p))})})]})})]})}),e.jsx(v,{control:d.control,name:"plugin",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.shadowsocks.plugin.label","插件")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:p=>g.onChange(p==="none"?"":p),value:g.value===""?"none":g.value||"none",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.plugin.placeholder","选择插件")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.shadowsocks.plugins.map(p=>e.jsx(A,{value:p.value,children:p.label},p.value))})})]})}),e.jsx(z,{children:g.value&&g.value!=="none"&&g.value!==""&&e.jsxs(e.Fragment,{children:[g.value==="obfs"&&r("dynamic_form.shadowsocks.plugin.obfs_hint","提示:配置格式如 obfs=http;obfs-host=www.bing.com;path=/"),g.value==="v2ray-plugin"&&r("dynamic_form.shadowsocks.plugin.v2ray_hint","提示:WebSocket模式格式为 mode=websocket;host=mydomain.me;path=/;tls=true,QUIC模式格式为 mode=quic;host=mydomain.me")]})})]})}),d.watch("plugin")&&d.watch("plugin")!=="none"&&d.watch("plugin")!==""&&e.jsx(v,{control:d.control,name:"plugin_opts",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.shadowsocks.plugin_opts.label","插件选项")}),e.jsx(z,{children:r("dynamic_form.shadowsocks.plugin_opts.description","按照 key=value;key2=value2 格式输入插件选项")}),e.jsx(_,{children:e.jsx(k,{type:"text",placeholder:r("dynamic_form.shadowsocks.plugin_opts.placeholder","例如: mode=tls;host=bing.com"),...g})})]})}),(d.watch("plugin")==="shadow-tls"||d.watch("plugin")==="restls")&&e.jsx(v,{control:d.control,name:"client_fingerprint",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.shadowsocks.client_fingerprint","客户端指纹")}),e.jsx(_,{children:e.jsxs(J,{value:g.value||"chrome",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.client_fingerprint_placeholder","选择客户端指纹")})}),e.jsx(Y,{children:Oe.shadowsocks.clientFingerprints.map(p=>e.jsx(A,{value:p.value,children:p.label},p.value))})]})}),e.jsx(z,{children:r("dynamic_form.shadowsocks.client_fingerprint_description","客户端伪装指纹,用于降低被识别风险")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:p=>g.onChange(Number(p)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(A,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"network",render:({field:g})=>e.jsxs(j,{children:[e.jsxs(b,{children:[r("dynamic_form.vmess.network.label"),e.jsx(xn,{value:d.watch("network_settings"),setValue:p=>d.setValue("network_settings",p),templateType:d.watch("network")})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.vmess.networkOptions.map(p=>e.jsx(A,{value:p.value,className:"cursor-pointer",children:p.label},p.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(v,{control:d.control,name:"allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"network",render:({field:g})=>e.jsxs(j,{children:[e.jsxs(b,{children:[r("dynamic_form.trojan.network.label"),e.jsx(xn,{value:d.watch("network_settings")||{},setValue:p=>d.setValue("network_settings",p),templateType:d.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value||"tcp",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.trojan.networkOptions.map(p=>e.jsx(A,{value:p.value,className:"cursor-pointer",children:p.label},p.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"version",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(J,{value:(g.value||2).toString(),onValueChange:p=>g.onChange(Number(p)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.hysteria.versions.map(p=>e.jsxs(A,{value:p,className:"cursor-pointer",children:["V",p]},p))})})]})})]})}),d.watch("version")==1&&e.jsx(v,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value||"h2",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.hysteria.alpnOptions.map(p=>e.jsx(A,{value:p,children:p},p))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"obfs.open",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(v,{control:d.control,name:"obfs.type",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value||"salamander",onValueChange:g.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:e.jsx(A,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(v,{control:d.control,name:"obfs.password",render:({field:g})=>e.jsxs(j,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...g,value:g.value||"",className:"pr-9"})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",V=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(E=>p[E%p.length]).join("");d.setValue("obfs.password",V),$.success(r("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(v,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(v,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"bandwidth.up",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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:r("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(v,{control:d.control,name:"bandwidth.down",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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:r("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})}),e.jsx(e.Fragment,{children:e.jsx(v,{control:d.control,name:"hop_interval",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:r("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...g,value:g.value||"",onChange:p=>{const V=p.target.value?parseInt(p.target.value):void 0;g.onChange(V)}})}),e.jsx(z,{children:r("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:p=>g.onChange(Number(p)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(A,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(A,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"reality_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"reality_settings.server_port",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"reality_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(v,{control:d.control,name:"reality_settings.private_key",render:({field:g})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(k,{...g,className:"pr-9"})}),e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const p=_x();d.setValue("reality_settings.private_key",p.privateKey),d.setValue("reality_settings.public_key",p.publicKey),$.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(r("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(Ta,{children:e.jsx(ue,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(v,{control:d.control,name:"reality_settings.public_key",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(k,{...g})})]})}),e.jsx(v,{control:d.control,name:"reality_settings.short_id",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(k,{...g,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const p=wx();d.setValue("reality_settings.short_id",p),$.success(r("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(Ta,{children:e.jsx(ue,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(z,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(v,{control:d.control,name:"network",render:({field:g})=>e.jsxs(j,{children:[e.jsxs(b,{children:[r("dynamic_form.vless.network.label"),e.jsx(xn,{value:d.watch("network_settings"),setValue:p=>d.setValue("network_settings",p),templateType:d.watch("network")})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.vless.networkOptions.map(p=>e.jsx(A,{value:p.value,className:"cursor-pointer",children:p.label},p.value))})})]})})]})}),e.jsx(v,{control:d.control,name:"flow",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:p=>g.onChange(p==="none"?null:p),value:g.value||"none",children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(Y,{children:Oe.vless.flowOptions.map(p=>e.jsx(A,{value:p,children:p},p))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"version",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.tuic.version.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:p=>g.onChange(Number(p)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.tuic.versions.map(p=>e.jsxs(A,{value:p,children:["V",p]},p))})})]})})]})}),e.jsx(v,{control:d.control,name:"congestion_control",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.tuic.congestionControls.map(p=>e.jsx(A,{value:p,children:p.toUpperCase()},p))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(v,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(_,{children:e.jsx(st,{options:Oe.tuic.alpnOptions,onChange:p=>g.onChange(p.map(V=>V.value)),value:Oe.tuic.alpnOptions.filter(p=>g.value?.includes(p.value)),placeholder:r("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:r("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(v,{control:d.control,name:"udp_relay_mode",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.tuic.udpRelayModes.map(p=>e.jsx(A,{value:p.value,children:p.label},p.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.naive.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:p=>g.onChange(Number(p)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(A,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.http.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:p=>g.onChange(Number(p)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(A,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(v,{control:d.control,name:"transport",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.mieru.transportOptions.map(p=>e.jsx(A,{value:p.value,children:p.label},p.value))})})]})})]})}),e.jsx(v,{control:d.control,name:"multiplexing",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(Y,{children:e.jsx(js,{children:Oe.mieru.multiplexingOptions.map(p=>e.jsx(A,{value:p.value,children:p.label},p.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:d.control,name:"padding_scheme",render:({field:g})=>e.jsxs(j,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:r("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{d.setValue("padding_scheme",Oe.anytls.defaultPaddingScheme),$.success(r("dynamic_form.anytls.padding_scheme.default_success","已设置默认填充方案"))},className:"h-7 px-2",children:r("dynamic_form.anytls.padding_scheme.use_default","使用默认方案")})]}),e.jsx(z,{children:r("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(_,{children:e.jsx("textarea",{className:"flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:r("dynamic_form.anytls.padding_scheme.placeholder",`例如:
+File: ${Zi}
+Line: ${eo}`}return JSON.stringify(B,null,2)}catch{return S.context}})()})})]})]}),e.jsx(Me,{children:e.jsx(Qs,{asChild:!0,children:e.jsx(G,{variant:"outline",children:s("common:close")})})})]})}),e.jsx(de,{open:te,onOpenChange:q,children:e.jsxs(ce,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-5 w-5 text-destructive"}),s("dashboard:systemLog.clearLogs")]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"clearDays",children:s("dashboard:systemLog.clearDays")}),e.jsx(D,{id:"clearDays",type:"number",min:"0",max:"365",value:ee,onChange:B=>{const Rs=B.target.value;if(Rs==="")fe(0);else{const vt=parseInt(Rs);!isNaN(vt)&&vt>=0&&vt<=365&&fe(vt)}},placeholder:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearDaysDesc")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"clearLevel",children:s("dashboard:systemLog.clearLevel")}),e.jsxs(J,{value:fs,onValueChange:Ie,children:[e.jsx(Y,{children:e.jsx(Q,{})}),e.jsxs(W,{children:[e.jsx(A,{value:"all",children:s("dashboard:systemLog.tabs.all")}),e.jsx(A,{value:"info",children:s("dashboard:systemLog.tabs.info")}),e.jsx(A,{value:"warning",children:s("dashboard:systemLog.tabs.warning")}),e.jsx(A,{value:"error",children:s("dashboard:systemLog.tabs.error")})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"clearLimit",children:s("dashboard:systemLog.clearLimit")}),e.jsx(D,{id:"clearLimit",type:"number",min:"100",max:"10000",value:re,onChange:B=>H(parseInt(B.target.value)||1e3),placeholder:"1000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("dashboard:systemLog.clearLimitDesc")})]})]}),e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5 text-amber-600"}),e.jsx("span",{className:"font-medium text-amber-800 dark:text-amber-200",children:s("dashboard:systemLog.clearPreview")})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:Ji,disabled:oe,children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.getStats")]})]}),na&&$s&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.cutoffDate")}),e.jsx("p",{className:"font-mono text-sm",children:$s.cutoff_date})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:s("dashboard:systemLog.totalLogs")}),e.jsx("p",{className:"font-mono text-sm font-medium",children:$s.total_logs.toLocaleString()})]})]}),e.jsxs("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bt,{className:"h-4 w-4 text-red-600"}),e.jsxs("span",{className:"text-sm font-medium text-red-800 dark:text-red-200",children:[s("dashboard:systemLog.willClear"),":",e.jsx("span",{className:"ml-1 font-bold",children:$s.logs_to_clear.toLocaleString()}),s("dashboard:systemLog.logsUnit")]})]}),e.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-300",children:s("dashboard:systemLog.clearWarning")})]})]})]})]}),e.jsxs(Me,{children:[e.jsx(G,{variant:"outline",onClick:()=>{q(!1),Vt(!1),Et(null)},children:s("common:cancel")}),e.jsx(G,{variant:"destructive",onClick:Qi,disabled:oe||!na||!$s,children:oe?e.jsxs(e.Fragment,{children:[e.jsx(Sa,{className:"mr-2 h-4 w-4 animate-spin"}),s("dashboard:systemLog.clearing")]}):e.jsxs(e.Fragment,{children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),s("dashboard:systemLog.confirmClear")]})})]})]})})]})}function Hm(){const{t:s}=M();return e.jsxs(qe,{children:[e.jsxs(He,{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(cs,{}),e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsx(Ye,{children:e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Mm,{}),e.jsx(Fm,{}),e.jsx(Om,{}),e.jsx(qm,{})]})})})]})}const Um=Object.freeze(Object.defineProperty({__proto__:null,default:Hm},Symbol.toStringTag,{value:"Module"}));function Km({className:s,items:n,...t}){const{pathname:r}=Pn(),a=Bs(),[i,l]=m.useState(r??"/settings"),d=x=>{l(x),a(x)},{t:u}=M("settings");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-1 md:hidden",children:e.jsxs(J,{value:i,onValueChange:d,children:[e.jsx(Y,{className:"h-12 sm:w-48",children:e.jsx(Q,{placeholder:"Theme"})}),e.jsx(W,{children:n.map(x=>e.jsx(A,{value:x.href,children:e.jsxs("div",{className:"flex gap-x-4 px-2 py-1",children:[e.jsx("span",{className:"scale-125",children:x.icon}),e.jsx("span",{className:"text-md",children:u(x.title)})]})},x.href))})]})}),e.jsx("div",{className:"hidden w-full overflow-x-auto bg-background px-1 py-2 md:block",children:e.jsx("nav",{className:w("flex space-x-2 lg:flex-col lg:space-x-0 lg:space-y-1",s),...t,children:n.map(x=>e.jsxs(Zs,{to:x.href,className:w(Ft({variant:"ghost"}),r===x.href?"bg-muted hover:bg-muted":"hover:bg-transparent hover:underline","justify-start"),children:[e.jsx("span",{className:"mr-2",children:x.icon}),u(x.title)]},x.href))})})]})}const Bm=[{title:"site.title",key:"site",icon:e.jsx(Uc,{size:18}),href:"/config/system",description:"site.description"},{title:"safe.title",key:"safe",icon:e.jsx(Qr,{size:18}),href:"/config/system/safe",description:"safe.description"},{title:"subscribe.title",key:"subscribe",icon:e.jsx(Xr,{size:18}),href:"/config/system/subscribe",description:"subscribe.description"},{title:"invite.title",key:"invite",icon:e.jsx(Kc,{size:18}),href:"/config/system/invite",description:"invite.description"},{title:"server.title",key:"server",icon:e.jsx(Jr,{size:18}),href:"/config/system/server",description:"server.description"},{title:"email.title",key:"email",icon:e.jsx(Bc,{size:18}),href:"/config/system/email",description:"email.description"},{title:"telegram.title",key:"telegram",icon:e.jsx(Gc,{size:18}),href:"/config/system/telegram",description:"telegram.description"},{title:"app.title",key:"app",icon:e.jsx(Wr,{size:18}),href:"/config/system/app",description:"app.description"},{title:"subscribe_template.title",key:"subscribe_template",icon:e.jsx(Yc,{size:18}),href:"/config/system/subscribe-template",description:"subscribe_template.description"}];function Gm(){const{t:s}=M("settings");return e.jsxs(qe,{fadedBelow:!0,fixedHeight:!0,children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Ve,{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(Km,{items:Bm})}),e.jsx("div",{className:"flex-1 w-full p-1 pr-4",children:e.jsx("div",{className:"pb-16",children:e.jsx(Ln,{})})})]})]})]})}const Ym=Object.freeze(Object.defineProperty({__proto__:null,default:Gm},Symbol.toStringTag,{value:"Module"})),Z=m.forwardRef(({className:s,...n},t)=>e.jsx(bl,{className:w("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:t,children:e.jsx(Wc,{className:w("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")})}));Z.displayName=bl.displayName;const Fs=m.forwardRef(({className:s,...n},t)=>e.jsx("textarea",{className:w("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:t,...n}));Fs.displayName="Textarea";const Wm=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 Jm(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),{data:a}=ne({queryKey:["settings","site"],queryFn:()=>ve.getSettings("site")}),{data:i}=ne({queryKey:["plans"],queryFn:()=>ys.getList()}),l=we({resolver:Te(Wm),defaultValues:{},mode:"onBlur"}),{mutateAsync:d}=Is({mutationFn:ve.saveSettings,onSuccess:o=>{o.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(a?.data?.site){const o=a?.data?.site;Object.entries(o).forEach(([c,j])=>{l.setValue(c,j)}),r.current=o}},[a]);const u=m.useCallback(Ee.debounce(async o=>{if(!Ee.isEqual(o,r.current)){t(!0);try{const c=Object.entries(o).reduce((j,[P,k])=>(j[P]=k===null?"":k,j),{});await d(c),r.current=o}finally{t(!1)}}},1e3),[d]),x=m.useCallback(o=>{u(o)},[u]);return m.useEffect(()=>{const o=l.watch(c=>{x(c)});return()=>o.unsubscribe()},[l.watch,x]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:l.control,name:"app_name",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.siteName.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"app_description",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.siteDescription.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"app_url",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.siteUrl.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"force_https",render:({field:o})=>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(z,{children:s("site.form.forceHttps.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:!!o.value,onCheckedChange:c=>{o.onChange(Number(c)),x(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"logo",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.logo.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"subscribe_url",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.subscribeUrl.label")}),e.jsx(_,{children:e.jsx(Fs,{placeholder:s("site.form.subscribeUrl.placeholder"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.subscribeUrl.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"tos_url",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.tosUrl.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"stop_register",render:({field:o})=>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(z,{children:s("site.form.stopRegister.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:!!o.value,onCheckedChange:c=>{o.onChange(Number(c)),x(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"try_out_plan_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("site.form.tryOut.label")}),e.jsx(_,{children:e.jsxs(J,{value:o.value?.toString(),onValueChange:c=>{o.onChange(Number(c)),x(l.getValues())},children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:s("site.form.tryOut.placeholder")})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:s("site.form.tryOut.placeholder")}),i?.data?.map(c=>e.jsx(A,{value:c.id.toString(),children:c.name},c.id.toString()))]})]})}),e.jsx(z,{children:s("site.form.tryOut.description")}),e.jsx(R,{})]})}),!!l.watch("try_out_plan_id")&&e.jsx(b,{control:l.control,name:"try_out_hour",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.tryOut.duration.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"currency",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.currency.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"currency_symbol",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{o.onChange(c),x(l.getValues())}})}),e.jsx(z,{children:s("site.form.currencySymbol.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("site.form.saving")})]})})}function Qm(){const{t:s}=M("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(Ve,{}),e.jsx(Jm,{})]})}const Xm=Object.freeze(Object.defineProperty({__proto__:null,default:Qm},Symbol.toStringTag,{value:"Module"})),Zm=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(),captcha_enable:h.boolean().nullable(),captcha_type:h.string().nullable(),recaptcha_key:h.string().nullable(),recaptcha_site_key:h.string().nullable(),recaptcha_v3_secret_key:h.string().nullable(),recaptcha_v3_site_key:h.string().nullable(),recaptcha_v3_score_threshold:h.coerce.string().transform(s=>s===""?null:s).nullable(),turnstile_secret_key:h.string().nullable(),turnstile_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()}),eu={email_verify:!1,safe_mode_enable:!1,secure_path:"",email_whitelist_enable:!1,email_whitelist_suffix:[],email_gmail_limit_enable:!1,captcha_enable:!1,captcha_type:"recaptcha",recaptcha_key:"",recaptcha_site_key:"",recaptcha_v3_secret_key:"",recaptcha_v3_site_key:"",recaptcha_v3_score_threshold:"0.5",turnstile_secret_key:"",turnstile_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 su(){const{t:s}=M("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),i=m.useRef(null),l=we({resolver:Te(Zm),defaultValues:eu,mode:"onBlur"}),{data:d}=ne({queryKey:["settings","safe"],queryFn:()=>ve.getSettings("safe")}),{mutateAsync:u}=Is({mutationFn:ve.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data.safe){const c=d.data.safe,j={};Object.entries(c).forEach(([P,k])=>{if(typeof k=="number"){const C=String(k);l.setValue(P,C),j[P]=C}else l.setValue(P,k),j[P]=k}),i.current=j,a(!0)}},[d]);const x=m.useCallback(Ee.debounce(async c=>{if(!Ee.isEqual(c,i.current)){t(!0);try{const j={...c,email_whitelist_suffix:c.email_whitelist_suffix?.filter(Boolean)||[]};await u(j),i.current=c}finally{t(!1)}}},1e3),[u]),o=m.useCallback(c=>{r&&x(c)},[x,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(j=>{o(j)});return()=>c.unsubscribe()},[l.watch,o,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:l.control,name:"email_verify",render:({field:c})=>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(z,{children:s("safe.form.emailVerify.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"email_gmail_limit_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("safe.form.gmailLimit.label")}),e.jsx(z,{children:s("safe.form.gmailLimit.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"safe_mode_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("safe.form.safeMode.label")}),e.jsx(z,{children:s("safe.form.safeMode.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"secure_path",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.securePath.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"email_whitelist_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("safe.form.emailWhitelist.label")}),e.jsx(z,{children:s("safe.form.emailWhitelist.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),l.watch("email_whitelist_enable")&&e.jsx(b,{control:l.control,name:"email_whitelist_suffix",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.emailWhitelist.suffixes.label")}),e.jsx(_,{children:e.jsx(Fs,{placeholder:s("safe.form.emailWhitelist.suffixes.placeholder"),...c,value:(c.value||[]).join(`
+`),onChange:j=>{const P=j.target.value.split(`
+`).filter(Boolean);c.onChange(P),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.emailWhitelist.suffixes.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"captcha_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("safe.form.captcha.enable.label")}),e.jsx(z,{children:s("safe.form.captcha.enable.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),l.watch("captcha_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"captcha_type",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.type.label")}),e.jsxs(J,{onValueChange:j=>{c.onChange(j),o(l.getValues())},value:c.value||"recaptcha",children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:s("safe.form.captcha.type.description")})})}),e.jsxs(W,{children:[e.jsx(A,{value:"recaptcha",children:s("safe.form.captcha.type.options.recaptcha")}),e.jsx(A,{value:"recaptcha-v3",children:s("safe.form.captcha.type.options.recaptcha-v3")}),e.jsx(A,{value:"turnstile",children:s("safe.form.captcha.type.options.turnstile")})]})]}),e.jsx(z,{children:s("safe.form.captcha.type.description")}),e.jsx(R,{})]})}),l.watch("captcha_type")==="recaptcha"&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"recaptcha_site_key",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.recaptcha.siteKey.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha.siteKey.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"recaptcha_key",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.recaptcha.key.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha.key.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha.key.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="recaptcha-v3"&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"recaptcha_v3_site_key",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.siteKey.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha_v3.siteKey.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha_v3.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"recaptcha_v3_secret_key",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.secretKey.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("safe.form.captcha.recaptcha_v3.secretKey.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha_v3.secretKey.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"recaptcha_v3_score_threshold",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",step:"0.1",min:"0",max:"1",placeholder:s("safe.form.captcha.recaptcha_v3.scoreThreshold.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.recaptcha_v3.scoreThreshold.description")}),e.jsx(R,{})]})})]}),l.watch("captcha_type")==="turnstile"&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"turnstile_site_key",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.turnstile.siteKey.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("safe.form.captcha.turnstile.siteKey.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.turnstile.siteKey.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"turnstile_secret_key",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("safe.form.captcha.turnstile.secretKey.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("safe.form.captcha.turnstile.secretKey.placeholder"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.captcha.turnstile.secretKey.description")}),e.jsx(R,{})]})})]})]}),e.jsx(b,{control:l.control,name:"register_limit_by_ip_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("safe.form.registerLimit.enable.label")}),e.jsx(z,{children:s("safe.form.registerLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),l.watch("register_limit_by_ip_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"register_limit_count",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.registerLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"register_limit_expire",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.registerLimit.expire.description")}),e.jsx(R,{})]})})]}),e.jsx(b,{control:l.control,name:"password_limit_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("safe.form.passwordLimit.enable.label")}),e.jsx(z,{children:s("safe.form.passwordLimit.enable.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),l.watch("password_limit_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"password_limit_count",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.passwordLimit.count.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"password_limit_expire",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{c.onChange(j),o(l.getValues())}})}),e.jsx(z,{children:s("safe.form.passwordLimit.expire.description")}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("safe.form.saving")})]})})}function tu(){const{t:s}=M("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(Ve,{}),e.jsx(su,{})]})}const au=Object.freeze(Object.defineProperty({__proto__:null,default:tu},Symbol.toStringTag,{value:"Module"})),nu=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")}),ru={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 lu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(nu),defaultValues:ru,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","subscribe"],queryFn:()=>ve.getSettings("subscribe")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:x=>{x.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(i?.data?.subscribe){const x=i?.data?.subscribe;Object.entries(x).forEach(([o,c])=>{a.setValue(o,c)}),r.current=x}},[i]);const d=m.useCallback(Ee.debounce(async x=>{if(!Ee.isEqual(x,r.current)){t(!0);try{await l(x),r.current=x}finally{t(!1)}}},1e3),[l]),u=m.useCallback(x=>{d(x)},[d]);return m.useEffect(()=>{const x=a.watch(o=>{u(o)});return()=>x.unsubscribe()},[a.watch,u]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"plan_change_enable",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.plan_change_enable.title")}),e.jsx(z,{children:s("subscribe.plan_change_enable.description")}),e.jsx(_,{children:e.jsx(Z,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"reset_traffic_method",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.reset_traffic_method.title")}),e.jsxs(J,{onValueChange:x.onChange,value:x.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:"请选择重置方式"})})}),e.jsxs(W,{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(z,{children:s("subscribe.reset_traffic_method.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"surplus_enable",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.surplus_enable.title")}),e.jsx(z,{children:s("subscribe.surplus_enable.description")}),e.jsx(_,{children:e.jsx(Z,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"new_order_event_id",render:({field:x})=>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:x.onChange,value:x.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(W,{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(z,{children:s("subscribe.new_order_event.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"renew_order_event_id",render:({field:x})=>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:x.onChange,value:x.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(W,{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(z,{children:s("subscribe.renew_order_event.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"change_order_event_id",render:({field:x})=>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:x.onChange,value:x.value?.toString(),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:"请选择"})}),e.jsxs(W,{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(z,{children:s("subscribe.change_order_event.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"subscribe_path",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("subscribe.subscribe_path.title")}),e.jsx(_,{children:e.jsx(D,{placeholder:"subscribe",...x,value:x.value||"",onChange:o=>{x.onChange(o),u(a.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:x.value||"s"}),e.jsx("br",{}),s("subscribe.subscribe_path.restart_tip")]}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"show_info_to_server_enable",render:({field:x})=>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(z,{children:s("subscribe.show_info_to_server.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})})]})}),e.jsx(b,{control:a.control,name:"show_protocol_to_server_enable",render:({field:x})=>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(z,{children:s("subscribe.show_protocol_to_server.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:x.value||!1,onCheckedChange:o=>{x.onChange(o),u(a.getValues())}})})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function iu(){const{t:s}=M("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(Ve,{}),e.jsx(lu,{})]})}const ou=Object.freeze(Object.defineProperty({__proto__:null,default:iu},Symbol.toStringTag,{value:"Module"})),cu=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)}),du={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 mu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),[r,a]=m.useState(!1),i=m.useRef(null),l=we({resolver:Te(cu),defaultValues:du,mode:"onBlur"}),{data:d}=ne({queryKey:["settings","invite"],queryFn:()=>ve.getSettings("invite")}),{mutateAsync:u}=Is({mutationFn:ve.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}});m.useEffect(()=>{if(d?.data?.invite){const c=d?.data?.invite,j={};Object.entries(c).forEach(([P,k])=>{if(typeof k=="number"){const C=String(k);l.setValue(P,C),j[P]=C}else l.setValue(P,k),j[P]=k}),i.current=j,a(!0)}},[d]);const x=m.useCallback(Ee.debounce(async c=>{if(!Ee.isEqual(c,i.current)){t(!0);try{await u(c),i.current=c}finally{t(!1)}}},1e3),[u]),o=m.useCallback(c=>{r&&x(c)},[x,r]);return m.useEffect(()=>{if(!r)return;const c=l.watch(j=>{o(j)});return()=>c.unsubscribe()},[l.watch,o,r]),e.jsx(De,{...l,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:l.control,name:"invite_force",render:({field:c})=>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(z,{children:s("invite.invite_force.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"invite_commission",render:({field:c})=>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"),...c,value:c.value||""})}),e.jsx(z,{children:s("invite.invite_commission.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"invite_gen_limit",render:({field:c})=>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"),...c,value:c.value||""})}),e.jsx(z,{children:s("invite.invite_gen_limit.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"invite_never_expire",render:({field:c})=>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(z,{children:s("invite.invite_never_expire.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"commission_first_time_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("invite.commission_first_time.title")}),e.jsx(z,{children:s("invite.commission_first_time.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"commission_auto_check_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("invite.commission_auto_check.title")}),e.jsx(z,{children:s("invite.commission_auto_check.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"commission_withdraw_limit",render:({field:c})=>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"),...c,value:c.value||""})}),e.jsx(z,{children:s("invite.commission_withdraw_limit.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"commission_withdraw_method",render:({field:c})=>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"),...c,value:Array.isArray(c.value)?c.value.join(","):"",onChange:j=>{const P=j.target.value.split(",").filter(Boolean);c.onChange(P),o(l.getValues())}})}),e.jsx(z,{children:s("invite.commission_withdraw_method.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"withdraw_close_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("invite.withdraw_close.title")}),e.jsx(z,{children:s("invite.withdraw_close.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),e.jsx(b,{control:l.control,name:"commission_distribution_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("invite.commission_distribution.title")}),e.jsx(z,{children:s("invite.commission_distribution.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:c.value,onCheckedChange:j=>{c.onChange(j),o(l.getValues())}})})]})}),l.watch("commission_distribution_enable")&&e.jsxs(e.Fragment,{children:[e.jsx(b,{control:l.control,name:"commission_distribution_l1",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{const P=j.target.value?Number(j.target.value):0;c.onChange(P),o(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"commission_distribution_l2",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{const P=j.target.value?Number(j.target.value):0;c.onChange(P),o(l.getValues())}})}),e.jsx(R,{})]})}),e.jsx(b,{control:l.control,name:"commission_distribution_l3",render:({field:c})=>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"),...c,value:c.value||"",onChange:j=>{const P=j.target.value?Number(j.target.value):0;c.onChange(P),o(l.getValues())}})}),e.jsx(R,{})]})})]}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("invite.saving")})]})})}function uu(){const{t:s}=M("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(Ve,{}),e.jsx(mu,{})]})}const xu=Object.freeze(Object.defineProperty({__proto__:null,default:uu},Symbol.toStringTag,{value:"Module"})),hu=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()}),gu={frontend_theme:"",frontend_theme_sidebar:"",frontend_theme_header:"",frontend_theme_color:"",frontend_background_url:""};function pu(){const{data:s}=ne({queryKey:["settings","frontend"],queryFn:()=>ve.getSettings("frontend")}),n=we({resolver:Te(hu),defaultValues:gu,mode:"onChange"});m.useEffect(()=>{if(s?.data?.frontend){const r=s?.data?.frontend;Object.entries(r).forEach(([a,i])=>{n.setValue(a,i)})}},[s]);function t(r){ve.saveSettings(r).then(({data:a})=>{a&&$.success("更新成功")})}return e.jsx(De,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(t),className:"space-y-8",children:[e.jsx(b,{control:n.control,name:"frontend_theme_sidebar",render:({field:r})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:"边栏风格"}),e.jsx(z,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(Z,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_header",render:({field:r})=>e.jsxs(v,{children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{className:"text-base",children:"头部风格"}),e.jsx(z,{children:"边栏风格"})]}),e.jsx(_,{children:e.jsx(Z,{checked:r.value,onCheckedChange:r.onChange})})]})}),e.jsx(b,{control:n.control,name:"frontend_theme_color",render:({field:r})=>e.jsxs(v,{children:[e.jsx(y,{children:"主题色"}),e.jsxs("div",{className:"relative w-max",children:[e.jsx(_,{children:e.jsxs("select",{className:w(Ft({variant:"outline"}),"w-[200px] appearance-none font-normal"),...r,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(Vn,{className:"absolute right-3 top-2.5 h-4 w-4 opacity-50"})]}),e.jsx(z,{children:"主题色"}),e.jsx(R,{})]})}),e.jsx(b,{control:n.control,name:"frontend_background_url",render:({field:r})=>e.jsxs(v,{children:[e.jsx(y,{children:"背景"}),e.jsx(_,{children:e.jsx(D,{placeholder:"请输入图片地址",...r})}),e.jsx(z,{children:"将会在后台登录页面进行展示。"}),e.jsx(R,{})]})}),e.jsx(F,{type:"submit",children:"保存设置"})]})})}function fu(){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(Ve,{}),e.jsx(pu,{})]})}const ju=Object.freeze(Object.defineProperty({__proto__:null,default:fu},Symbol.toStringTag,{value:"Module"})),vu=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()}),bu={server_pull_interval:0,server_push_interval:0,server_token:"",device_limit_mode:0};function yu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(vu),defaultValues:bu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","server"],queryFn:()=>ve.getSettings("server")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:o=>{o.data&&$.success(s("common.AutoSaved"))}});m.useEffect(()=>{if(i?.data.server){const o=i.data.server;Object.entries(o).forEach(([c,j])=>{a.setValue(c,j)}),r.current=o}},[i]);const d=m.useCallback(Ee.debounce(async o=>{if(!Ee.isEqual(o,r.current)){t(!0);try{await l(o),r.current=o}finally{t(!1)}}},1e3),[l]),u=m.useCallback(o=>{d(o)},[d]);m.useEffect(()=>{const o=a.watch(c=>{u(c)});return()=>o.unsubscribe()},[a.watch,u]);const x=()=>{const o=Math.floor(Math.random()*17)+16,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let j="";for(let P=0;Pe.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"),...o,value:o.value||"",className:"pr-10"}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{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:c=>{c.preventDefault(),x()},children:e.jsx(Jc,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(ue,{children:e.jsx("p",{children:s("server.server_token.generate_tooltip")})})]})})]})}),e.jsx(z,{children:s("server.server_token.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"server_pull_interval",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{const j=c.target.value?Number(c.target.value):null;o.onChange(j)}})}),e.jsx(z,{children:s("server.server_pull_interval.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"server_push_interval",render:({field:o})=>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"),...o,value:o.value||"",onChange:c=>{const j=c.target.value?Number(c.target.value):null;o.onChange(j)}})}),e.jsx(z,{children:s("server.server_push_interval.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"device_limit_mode",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("server.device_limit_mode.title")}),e.jsxs(J,{onValueChange:o.onChange,value:o.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:s("server.device_limit_mode.placeholder")})})}),e.jsxs(W,{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(z,{children:s("server.device_limit_mode.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("server.saving")})]})})}function _u(){const{t:s}=M("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(Ve,{}),e.jsx(yu,{})]})}const Nu=Object.freeze(Object.defineProperty({__proto__:null,default:_u},Symbol.toStringTag,{value:"Module"}));function wu({open:s,onOpenChange:n,result:t}){const r=!t.error;return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(jl,{className:"h-5 w-5 text-green-500"}):e.jsx(vl,{className:"h-5 w-5 text-destructive"}),e.jsx(me,{children:r?"邮件发送成功":"邮件发送失败"})]}),e.jsx(Ae,{children:r?"测试邮件已成功发送,请检查收件箱":"发送测试邮件时遇到错误"})]}),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:t.email}),e.jsx("div",{className:"text-muted-foreground",children:"邮件主题"}),e.jsx("div",{children:t.subject}),e.jsx("div",{className:"text-muted-foreground",children:"模板名称"}),e.jsx("div",{children:t.template_name})]})]}),t.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:t.error})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"font-medium",children:"配置信息"}),e.jsx(ut,{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:t.config.driver}),e.jsx("div",{className:"text-muted-foreground",children:"服务器"}),e.jsx("div",{children:t.config.host}),e.jsx("div",{className:"text-muted-foreground",children:"端口"}),e.jsx("div",{children:t.config.port}),e.jsx("div",{className:"text-muted-foreground",children:"加密方式"}),e.jsx("div",{children:t.config.encryption||"无"}),e.jsx("div",{className:"text-muted-foreground",children:"发件人"}),e.jsx("div",{children:t.config.from.address?`${t.config.from.address}${t.config.from.name?` (${t.config.from.name})`:""}`:"未设置"}),e.jsx("div",{className:"text-muted-foreground",children:"用户名"}),e.jsx("div",{children:t.config.username||"未设置"})]})})})]})]})]})})}const Cu=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 Su(){const{t:s}=M("settings"),[n,t]=m.useState(null),[r,a]=m.useState(!1),i=m.useRef(null),[l,d]=m.useState(!1),u=we({resolver:Te(Cu),defaultValues:{},mode:"onBlur"}),{data:x}=ne({queryKey:["settings","email"],queryFn:()=>ve.getSettings("email")}),{data:o}=ne({queryKey:["emailTemplate"],queryFn:()=>ve.getEmailTemplate()}),{mutateAsync:c}=Is({mutationFn:ve.saveSettings,onSuccess:T=>{T.data&&$.success(s("common.autoSaved"))}}),{mutate:j,isPending:P}=Is({mutationFn:ve.sendTestMail,onMutate:()=>{t(null),a(!1)},onSuccess:T=>{t(T.data),a(!0),T.data.error?$.error(s("email.test.error")):$.success(s("email.test.success"))}});m.useEffect(()=>{if(x?.data.email){const T=x.data.email;Object.entries(T).forEach(([p,S])=>{u.setValue(p,S)}),i.current=T}},[x]);const k=m.useCallback(Ee.debounce(async T=>{if(!Ee.isEqual(T,i.current)){d(!0);try{await c(T),i.current=T}finally{d(!1)}}},1e3),[c]),C=m.useCallback(T=>{k(T)},[k]);return m.useEffect(()=>{const T=u.watch(p=>{C(p)});return()=>T.unsubscribe()},[u.watch,C]),e.jsxs(e.Fragment,{children:[e.jsx(De,{...u,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:u.control,name:"email_host",render:({field:T})=>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"),...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_host.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"email_port",render:({field:T})=>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"),...T,value:T.value||"",onChange:p=>{const S=p.target.value?Number(p.target.value):null;T.onChange(S)}})}),e.jsx(z,{children:s("email.email_port.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"email_encryption",render:({field:T})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_encryption.title")}),e.jsxs(J,{onValueChange:p=>{const S=p==="none"?"":p;T.onChange(S)},value:T.value===""||T.value===null||T.value===void 0?"none":T.value,children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:"请选择加密方式"})})}),e.jsxs(W,{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(z,{children:s("email.email_encryption.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"email_username",render:({field:T})=>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"),autoComplete:"off",...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_username.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"email_password",render:({field:T})=>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"),autoComplete:"off",...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_password.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"email_from_address",render:({field:T})=>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"),...T,value:T.value||""})}),e.jsx(z,{children:s("email.email_from.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"email_template",render:({field:T})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("email.email_template.title")}),e.jsxs(J,{onValueChange:p=>{T.onChange(p),C(u.getValues())},value:T.value||void 0,children:[e.jsx(_,{children:e.jsx(Y,{className:"w-[200px]",children:e.jsx(Q,{placeholder:s("email.email_template.placeholder")})})}),e.jsx(W,{children:o?.data?.map(p=>e.jsx(A,{value:p,children:p},p))})]}),e.jsx(z,{children:s("email.email_template.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"remind_mail_enable",render:({field:T})=>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(z,{children:s("email.remind_mail.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:T.value||!1,onCheckedChange:p=>{T.onChange(p),C(u.getValues())}})})]})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(F,{onClick:()=>j(),loading:P,disabled:P,children:s(P?"email.test.sending":"email.test.title")})})]})}),l&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("saving")}),n&&e.jsx(wu,{open:r,onOpenChange:a,result:n})]})}function ku(){const{t:s}=M("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(Ve,{}),e.jsx(Su,{})]})}const Tu=Object.freeze(Object.defineProperty({__proto__:null,default:ku},Symbol.toStringTag,{value:"Module"})),Du=h.object({telegram_bot_enable:h.boolean().nullable(),telegram_bot_token:h.string().nullable(),telegram_discuss_link:h.string().nullable()}),Pu={telegram_bot_enable:!1,telegram_bot_token:"",telegram_discuss_link:""};function Lu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(Du),defaultValues:Pu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","telegram"],queryFn:()=>ve.getSettings("telegram")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:c=>{c.data&&$.success(s("common.autoSaved"))}}),{mutate:d,isPending:u}=Is({mutationFn:ve.setTelegramWebhook,onSuccess:c=>{c.data&&$.success(s("telegram.webhook.success"))}});m.useEffect(()=>{if(i?.data.telegram){const c=i.data.telegram;Object.entries(c).forEach(([j,P])=>{a.setValue(j,P)}),r.current=c}},[i]);const x=m.useCallback(Ee.debounce(async c=>{if(!Ee.isEqual(c,r.current)){t(!0);try{await l(c),r.current=c}finally{t(!1)}}},1e3),[l]),o=m.useCallback(c=>{x(c)},[x]);return m.useEffect(()=>{const c=a.watch(j=>{o(j)});return()=>c.unsubscribe()},[a.watch,o]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"telegram_bot_token",render:({field:c})=>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"),...c,value:c.value||""})}),e.jsx(z,{children:s("telegram.bot_token.description")}),e.jsx(R,{})]})}),a.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(F,{loading:u,disabled:u,onClick:()=>d(),children:s(u?"telegram.webhook.setting":"telegram.webhook.button")}),n&&e.jsx("span",{className:"text-sm text-muted-foreground",children:s("common.saving")})]}),e.jsx(z,{children:s("telegram.webhook.description")}),e.jsx(R,{})]}),e.jsx(b,{control:a.control,name:"telegram_bot_enable",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-base",children:s("telegram.bot_enable.title")}),e.jsx(z,{children:s("telegram.bot_enable.description")}),e.jsx(_,{children:e.jsx(Z,{checked:c.value||!1,onCheckedChange:j=>{c.onChange(j),o(a.getValues())}})}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"telegram_discuss_link",render:({field:c})=>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"),...c,value:c.value||""})}),e.jsx(z,{children:s("telegram.discuss_link.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Fu(){const{t:s}=M("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(Ve,{}),e.jsx(Lu,{})]})}const Ru=Object.freeze(Object.defineProperty({__proto__:null,default:Fu},Symbol.toStringTag,{value:"Module"})),Eu=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()}),Vu={windows_version:"",windows_download_url:"",macos_version:"",macos_download_url:"",android_version:"",android_download_url:""};function Iu(){const{t:s}=M("settings"),[n,t]=m.useState(!1),r=m.useRef(null),a=we({resolver:Te(Eu),defaultValues:Vu,mode:"onBlur"}),{data:i}=ne({queryKey:["settings","app"],queryFn:()=>ve.getSettings("app")}),{mutateAsync:l}=Is({mutationFn:ve.saveSettings,onSuccess:x=>{x.data&&$.success(s("app.save_success"))}});m.useEffect(()=>{if(i?.data.app){const x=i.data.app;Object.entries(x).forEach(([o,c])=>{a.setValue(o,c)}),r.current=x}},[i]);const d=m.useCallback(Ee.debounce(async x=>{if(!Ee.isEqual(x,r.current)){t(!0);try{await l(x),r.current=x}finally{t(!1)}}},1e3),[l]),u=m.useCallback(x=>{d(x)},[d]);return m.useEffect(()=>{const x=a.watch(o=>{u(o)});return()=>x.unsubscribe()},[a.watch,u]),e.jsx(De,{...a,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:a.control,name:"windows_version",render:({field:x})=>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"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.windows.version.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"windows_download_url",render:({field:x})=>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"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.windows.download.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"macos_version",render:({field:x})=>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"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.macos.version.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"macos_download_url",render:({field:x})=>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"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.macos.download.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"android_version",render:({field:x})=>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"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.android.version.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"android_download_url",render:({field:x})=>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"),...x,value:x.value||""})}),e.jsx(z,{children:s("app.android.download.description")}),e.jsx(R,{})]})}),n&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.saving")})]})})}function Mu(){const{t:s}=M("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(Ve,{}),e.jsx(Iu,{})]})}const Ou=Object.freeze(Object.defineProperty({__proto__:null,default:Mu},Symbol.toStringTag,{value:"Module"})),zu=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(t=>!t||/^https?:\/\/\S+/.test(t),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())}),vr={id:null,name:"",icon:"",notify_domain:"",handling_fee_fixed:0,handling_fee_percent:0,payment:"",config:{}};function oi({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=vr}){const{t:a}=M("payment"),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[x,o]=m.useState([]),[c,j]=m.useState([]),P=zu(a),k=we({resolver:Te(P),defaultValues:r,mode:"onChange"}),C=k.watch("payment");m.useEffect(()=>{i&&(async()=>{const{data:S}=await mt.getMethodList();o(S)})()},[i]),m.useEffect(()=>{if(!C||!i)return;(async()=>{const S={payment:C,...t==="edit"&&{id:Number(k.getValues("id"))}};mt.getMethodForm(S).then(({data:N})=>{j(N);const g=N.reduce((f,V)=>(V.field_name&&(f[V.field_name]=V.value??""),f),{});k.setValue("config",g)})})()},[C,i,k,t]);const T=async p=>{u(!0);try{(await mt.save(p)).data&&($.success(a("form.messages.success")),k.reset(vr),s(),l(!1))}finally{u(!1)}};return e.jsxs(de,{open:i,onOpenChange:l,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(F,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")})}),e.jsx(De,{...k,children:e.jsxs("form",{onSubmit:k.handleSubmit(T),className:"space-y-4",children:[e.jsx(b,{control:k.control,name:"name",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:a("form.fields.name.placeholder"),...p})}),e.jsx(z,{children:a("form.fields.name.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:k.control,name:"icon",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.icon.label")}),e.jsx(_,{children:e.jsx(D,{...p,value:p.value||"",placeholder:a("form.fields.icon.placeholder")})}),e.jsx(z,{children:a("form.fields.icon.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:k.control,name:"notify_domain",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.notify_domain.label")}),e.jsx(_,{children:e.jsx(D,{...p,value:p.value||"",placeholder:a("form.fields.notify_domain.placeholder")})}),e.jsx(z,{children:a("form.fields.notify_domain.description")}),e.jsx(R,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:k.control,name:"handling_fee_percent",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.handling_fee_percent.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...p,value:p.value||"",placeholder:a("form.fields.handling_fee_percent.placeholder")})}),e.jsx(R,{})]})}),e.jsx(b,{control:k.control,name:"handling_fee_fixed",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.handling_fee_fixed.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...p,value:p.value||"",placeholder:a("form.fields.handling_fee_fixed.placeholder")})}),e.jsx(R,{})]})})]}),e.jsx(b,{control:k.control,name:"payment",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.payment.label")}),e.jsxs(J,{onValueChange:p.onChange,defaultValue:p.value,children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:a("form.fields.payment.placeholder")})})}),e.jsx(W,{children:x.map(S=>e.jsx(A,{value:S,children:S},S))})]}),e.jsx(z,{children:a("form.fields.payment.description")}),e.jsx(R,{})]})}),c.length>0&&e.jsx("div",{className:"space-y-4",children:c.map(p=>e.jsx(b,{control:k.control,name:`config.${p.field_name}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:p.label}),e.jsx(_,{children:e.jsx(D,{...S,value:S.value||""})}),e.jsx(R,{})]})},p.field_name))}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(F,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(F,{type:"submit",disabled:d,children:a("form.buttons.submit")})]})]})})]})]})}function O({column:s,title:n,tooltip:t,className:r}){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(F,{variant:"ghost",size:"default",className:w("-ml-3 flex h-8 items-center gap-2 text-nowrap font-medium hover:bg-muted/60",r),onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:[e.jsx("span",{children:n}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(lr,{className:"h-4 w-4 cursor-pointer text-muted-foreground"})}),e.jsx(ue,{children:t})]})}),s.getIsSorted()==="asc"?e.jsx(vn,{className:"h-4 w-4 text-foreground/70"}):s.getIsSorted()==="desc"?e.jsx(bn,{className:"h-4 w-4 text-foreground/70"}):e.jsx(Qc,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-foreground/70"})]})})}):e.jsxs("div",{className:w("flex items-center space-x-1 text-nowrap py-2 font-medium text-muted-foreground",r),children:[e.jsx("span",{children:n}),t&&e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsx(lr,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx(ue,{children:t})]})})]})}const Kn=Xc,ci=Zc,$u=ed,di=m.forwardRef(({className:s,...n},t)=>e.jsx(yl,{className:w("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:t}));di.displayName=yl.displayName;const Ka=m.forwardRef(({className:s,...n},t)=>e.jsxs($u,{children:[e.jsx(di,{}),e.jsx(_l,{ref:t,className:w("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})]}));Ka.displayName=_l.displayName;const Ba=({className:s,...n})=>e.jsx("div",{className:w("flex flex-col space-y-2 text-center sm:text-left",s),...n});Ba.displayName="AlertDialogHeader";const Ga=({className:s,...n})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ga.displayName="AlertDialogFooter";const Ya=m.forwardRef(({className:s,...n},t)=>e.jsx(Nl,{ref:t,className:w("text-lg font-semibold",s),...n}));Ya.displayName=Nl.displayName;const Wa=m.forwardRef(({className:s,...n},t)=>e.jsx(wl,{ref:t,className:w("text-sm text-muted-foreground",s),...n}));Wa.displayName=wl.displayName;const Ja=m.forwardRef(({className:s,...n},t)=>e.jsx(Cl,{ref:t,className:w(Lt(),s),...n}));Ja.displayName=Cl.displayName;const Qa=m.forwardRef(({className:s,...n},t)=>e.jsx(Sl,{ref:t,className:w(Lt({variant:"outline"}),"mt-2 sm:mt-0",s),...n}));Qa.displayName=Sl.displayName;function _s({onConfirm:s,children:n,title:t="确认操作",description:r="确定要执行此操作吗?",cancelText:a="取消",confirmText:i="确认",variant:l="default",className:d}){return e.jsxs(Kn,{children:[e.jsx(ci,{asChild:!0,children:n}),e.jsxs(Ka,{className:w("sm:max-w-[425px]",d),children:[e.jsxs(Ba,{children:[e.jsx(Ya,{children:t}),e.jsx(Wa,{children:r})]}),e.jsxs(Ga,{children:[e.jsx(Qa,{asChild:!0,children:e.jsx(F,{variant:"outline",children:a})}),e.jsx(Ja,{asChild:!0,children:e.jsx(F,{variant:l,onClick:s,children:i})})]})]})]})}const mi=s=>e.jsx("svg",{className:"inline-block",viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",...s,children:e.jsx("path",{fill:"currentColor",d:"M11.29 15.29a2 2 0 0 0-.12.15a.8.8 0 0 0-.09.18a.6.6 0 0 0-.06.18a1.4 1.4 0 0 0 0 .2a.84.84 0 0 0 .08.38a.9.9 0 0 0 .54.54a.94.94 0 0 0 .76 0a.9.9 0 0 0 .54-.54A1 1 0 0 0 13 16a1 1 0 0 0-.29-.71a1 1 0 0 0-1.42 0M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m0 18a8 8 0 1 1 8-8a8 8 0 0 1-8 8m0-13a3 3 0 0 0-2.6 1.5a1 1 0 1 0 1.73 1A1 1 0 0 1 12 9a1 1 0 0 1 0 2a1 1 0 0 0-1 1v1a1 1 0 0 0 2 0v-.18A3 3 0 0 0 12 7"})}),Au=({refetch:s,isSortMode:n=!1})=>{const{t}=M("payment");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(za,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",children:r.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"enable",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.enable")}),cell:({row:r})=>e.jsx(Z,{defaultChecked:r.getValue("enable"),onCheckedChange:async()=>{const{data:a}=await mt.updateStatus({id:r.original.id});a||s()}}),enableSorting:!1,size:100},{accessorKey:"name",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.name")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("name")})}),enableSorting:!1,size:200},{accessorKey:"payment",header:({column:r})=>e.jsx(O,{column:r,title:t("table.columns.payment")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r.getValue("payment")})}),enableSorting:!1,size:200},{accessorKey:"notify_url",header:({column:r})=>e.jsxs("div",{className:"flex items-center",children:[e.jsx(O,{column:r,title:t("table.columns.notify_url")}),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{className:"ml-1",children:e.jsx(mi,{className:"h-4 w-4"})}),e.jsx(ue,{children:t("table.columns.notify_url_tooltip")})]})})]}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{className:"max-w-[300px] truncate font-medium",children:r.getValue("notify_url")})}),enableSorting:!1,size:3e3},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("table.columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(oi,{refetch:s,dialogTrigger:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("table.actions.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(_s,{title:t("table.actions.delete.title"),description:t("table.actions.delete.description"),onConfirm:async()=>{const{data:a}=await mt.drop({id:r.original.id});a&&s()},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-destructive/10",children:[e.jsx(us,{className:"h-4 w-4 text-muted-foreground hover:text-destructive"}),e.jsx("span",{className:"sr-only",children:t("table.actions.delete.title")})]})})]}),size:100}]};function qu({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=M("payment"),i=s.getState().columnFilters.length>0;return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("table.toolbar.sort.hint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oi,{refetch:n}),e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),i&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{variant:r?"default":"outline",onClick:t,size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}function Hu(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,x]=m.useState({"drag-handle":!1}),[o,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:j}=ne({queryKey:["paymentList"],queryFn:async()=>{const{data:p}=await mt.getList();return d(p?.map(S=>({...S,enable:!!S.enable}))||[]),p}});m.useEffect(()=>{x({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const P=(p,S)=>{a&&(p.dataTransfer.setData("text/plain",S.toString()),p.currentTarget.classList.add("opacity-50"))},k=(p,S)=>{if(!a)return;p.preventDefault(),p.currentTarget.classList.remove("bg-muted");const N=parseInt(p.dataTransfer.getData("text/plain"));if(N===S)return;const g=[...l],[f]=g.splice(N,1);g.splice(S,0,f),d(g)},C=async()=>{a?mt.sort({ids:l.map(p=>p.id)}).then(()=>{j(),i(!1),$.success("排序保存成功")}):i(!0)},T=Be({data:l,columns:Au({refetch:j,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:o},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),initialState:{columnPinning:{right:["actions"]}},pageCount:a?1:void 0});return e.jsx(ts,{table:T,toolbar:p=>e.jsx(qu,{table:p,refetch:j,saveOrder:C,isSortMode:a}),draggable:a,onDragStart:P,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:k,showPagination:!a})}function Uu(){const{t:s}=M("payment");return e.jsxs(qe,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsx(cs,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Hu,{})})]})]})}const Ku=Object.freeze(Object.defineProperty({__proto__:null,default:Uu},Symbol.toStringTag,{value:"Module"}));function Bu({pluginName:s,onClose:n,onSuccess:t}){const{t:r}=M("plugin"),[a,i]=m.useState(!0),[l,d]=m.useState(!1),[u,x]=m.useState(null),[o,c]=m.useState({}),j=sd({config:td(ad())}),P=we({resolver:Te(j),defaultValues:{config:{}}});m.useEffect(()=>{(async()=>{try{const{data:p}=await Hs.getPluginConfig(s);x(p);const S=Object.fromEntries(Object.entries(p).map(([N,g])=>{const f=g;let V=f.value;if(f.type==="yaml"||f.type==="json"){if(V==null)V="";else if(typeof V!="string")try{V=JSON.stringify(V,null,2)}catch{V=String(V)}}return[N,V]}));P.reset({config:S})}catch{$.error(r("messages.configLoadError"))}finally{i(!1)}})()},[s]);const k=async T=>{d(!0);try{await Hs.updatePluginConfig(s,T.config),$.success(r("messages.configSaveSuccess")),t()}catch{$.error(r("messages.configSaveError"))}finally{d(!1)}},C=(T,p)=>{switch(p.type){case"string":return e.jsx(b,{control:P.control,name:`config.${T}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:p.label||p.description}),e.jsx(_,{children:e.jsx(D,{placeholder:p.placeholder,...S})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(R,{})]})},T);case"number":case"percentage":return e.jsx(b,{control:P.control,name:`config.${T}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:p.label||p.description}),e.jsx(_,{children:e.jsxs("div",{className:"relative",children:[e.jsx(D,{type:"number",placeholder:p.placeholder,...S,onChange:N=>{const g=Number(N.target.value);p.type==="percentage"?S.onChange(Math.min(100,Math.max(0,g))):S.onChange(g)},className:p.type==="percentage"?"pr-8":"",min:p.type==="percentage"?0:void 0,max:p.type==="percentage"?100:void 0,step:p.type==="percentage"?1:void 0}),p.type==="percentage"&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx(nd,{className:"h-4 w-4 text-muted-foreground"})})]})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(R,{})]})},T);case"select":return e.jsx(b,{control:P.control,name:`config.${T}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:p.label||p.description}),e.jsxs(J,{onValueChange:S.onChange,defaultValue:S.value,children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:p.placeholder})})}),e.jsx(W,{children:p.options?.map(N=>e.jsx(A,{value:N.value,children:N.label},N.value))})]}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(R,{})]})},T);case"boolean":return e.jsx(b,{control:P.control,name:`config.${T}`,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:p.label||p.description}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description})]}),e.jsx(_,{children:e.jsx(Z,{checked:S.value,onCheckedChange:S.onChange})})]})},T);case"text":return e.jsx(b,{control:P.control,name:`config.${T}`,render:({field:S})=>e.jsxs(v,{children:[e.jsx(y,{children:p.label||p.description}),e.jsx(_,{children:e.jsx(Fs,{placeholder:p.placeholder,...S})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(R,{})]})},T);case"yaml":return e.jsx(b,{control:P.control,name:`config.${T}`,render:({field:S})=>{const N=(()=>{if(S.value===null||S.value===void 0)return"";if(typeof S.value=="string")return S.value;try{return JSON.stringify(S.value,null,2)}catch{return String(S.value)}})(),g=o[T]||150;return e.jsxs(v,{children:[e.jsx(y,{children:p.label||p.description}),e.jsx(_,{children:e.jsx("div",{className:"resize-y overflow-hidden rounded-md border",style:{height:`${g}px`},onMouseDown:f=>{const V=f.clientY,E=g,L=X=>{const se=X.clientY-V,te=Math.max(100,E+se);c(q=>({...q,[T]:te}))},K=()=>{document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",K)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",K)},children:e.jsx(jn,{height:"100%",defaultLanguage:"yaml",value:N,onChange:f=>{S.onChange(f||"")},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(R,{})]})}},T);case"json":return e.jsx(b,{control:P.control,name:`config.${T}`,render:({field:S})=>{const N=(()=>{if(S.value===null||S.value===void 0)return"";if(typeof S.value=="string")return S.value;try{return JSON.stringify(S.value,null,2)}catch{return String(S.value)}})(),g=o[T]||150;return e.jsxs(v,{children:[e.jsx(y,{children:p.label||p.description}),e.jsx(_,{children:e.jsx("div",{className:"resize-y overflow-hidden rounded-md border",style:{height:`${g}px`},onMouseDown:f=>{const V=f.clientY,E=g,L=X=>{const se=X.clientY-V,te=Math.max(100,E+se);c(q=>({...q,[T]:te}))},K=()=>{document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",K)};document.addEventListener("mousemove",L),document.addEventListener("mouseup",K)},children:e.jsx(jn,{height:"100%",defaultLanguage:"json",value:N,onChange:f=>{S.onChange(f||"")},options:{minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,formatOnPaste:!0,formatOnType:!0}})})}),p.description&&p.label&&e.jsx("p",{className:"text-sm text-muted-foreground",children:p.description}),e.jsx(R,{})]})}},T);default:return null}};return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-4 w-[200px]"}),e.jsx(je,{className:"h-10 w-full"})]}):e.jsx(De,{...P,children:e.jsxs("form",{onSubmit:P.handleSubmit(k),className:"space-y-4",children:[u&&Object.entries(u).map(([T,p])=>C(T,p)),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(F,{type:"button",variant:"outline",onClick:n,disabled:l,children:r("config.cancel")}),e.jsx(F,{type:"submit",loading:l,disabled:l,children:r("config.save")})]})]})})}function Gu(){const{t:s}=M("plugin"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(null),[d,u]=m.useState(""),[x,o]=m.useState("all"),[c,j]=m.useState(!1),[P,k]=m.useState(!1),[C,T]=m.useState(!1),p=m.useRef(null),[S,N]=m.useState(!1),[g,f]=m.useState(""),{data:V,isLoading:E,refetch:L}=ne({queryKey:["pluginList"],queryFn:async()=>{const{data:H}=await Hs.getPluginList();return H}});V&&[...new Set(V.map(H=>H.category||"other"))];const K=V?.filter(H=>{const oe=H.name.toLowerCase().includes(d.toLowerCase())||H.description.toLowerCase().includes(d.toLowerCase())||H.code.toLowerCase().includes(d.toLowerCase()),lt=x==="all"||H.category===x;return oe&<}),X=async H=>{t(H),Hs.installPlugin(H).then(()=>{$.success(s("messages.installSuccess")),L()}).catch(oe=>{$.error(oe.message||s("messages.installError"))}).finally(()=>{t(null)})},se=async H=>{t(H),Hs.uninstallPlugin(H).then(()=>{$.success(s("messages.uninstallSuccess")),L()}).catch(oe=>{$.error(oe.message||s("messages.uninstallError"))}).finally(()=>{t(null)})},te=async(H,oe)=>{t(H),(oe?Hs.disablePlugin:Hs.enablePlugin)(H).then(()=>{$.success(s(oe?"messages.disableSuccess":"messages.enableSuccess")),L()}).catch($s=>{$.error($s.message||s(oe?"messages.disableError":"messages.enableError"))}).finally(()=>{t(null)})},q=H=>{V?.find(oe=>oe.code===H),l(H),a(!0)},ee=async H=>{if(!H.name.endsWith(".zip")){$.error(s("upload.error.format"));return}j(!0),Hs.uploadPlugin(H).then(()=>{$.success(s("messages.uploadSuccess")),k(!1),L()}).catch(oe=>{$.error(oe.message||s("messages.uploadError"))}).finally(()=>{j(!1),p.current&&(p.current.value="")})},fe=H=>{H.preventDefault(),H.stopPropagation(),H.type==="dragenter"||H.type==="dragover"?T(!0):H.type==="dragleave"&&T(!1)},fs=H=>{H.preventDefault(),H.stopPropagation(),T(!1),H.dataTransfer.files&&H.dataTransfer.files[0]&&ee(H.dataTransfer.files[0])},Ie=async H=>{t(H),Hs.deletePlugin(H).then(()=>{$.success(s("messages.deleteSuccess")),L()}).catch(oe=>{$.error(oe.message||s("messages.deleteError"))}).finally(()=>{t(null)})},re=H=>rd(H||"",{walkTokens(oe){(oe.type==="image"||oe.type==="link")&&(oe.type="text",oe.raw="",oe.text="")}});return e.jsxs(qe,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(Rn,{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(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(En,{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:d,onChange:H=>u(H.target.value),className:"pl-9"})]}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(F,{onClick:()=>k(!0),variant:"outline",className:"shrink-0",size:"sm",children:[e.jsx(Dt,{className:"mr-2 h-4 w-4"}),s("upload.button")]})})]}),e.jsxs(gt,{defaultValue:"all",className:"w-full",children:[e.jsxs(at,{children:[e.jsx($e,{value:"all",children:s("tabs.all")}),e.jsx($e,{value:"installed",children:s("tabs.installed")}),e.jsx($e,{value:"available",children:s("tabs.available")})]}),e.jsx(ms,{value:"all",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:E?e.jsxs(e.Fragment,{children:[e.jsx(mn,{}),e.jsx(mn,{}),e.jsx(mn,{})]}):K?.map(H=>e.jsx(dn,{plugin:H,onInstall:X,onUninstall:se,onToggleEnable:te,onOpenConfig:q,onDelete:Ie,isLoading:n===H.name,onShowReadme:H.readme?()=>{f(H.readme),N(!0)}:void 0},H.name))})}),e.jsx(ms,{value:"installed",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:K?.filter(H=>H.is_installed).map(H=>e.jsx(dn,{plugin:H,onInstall:X,onUninstall:se,onToggleEnable:te,onOpenConfig:q,onDelete:Ie,isLoading:n===H.name,onShowReadme:H.readme?()=>{f(H.readme),N(!0)}:void 0},H.name))})}),e.jsx(ms,{value:"available",className:"mt-6",children:e.jsx("div",{className:"space-y-4",children:K?.filter(H=>!H.is_installed).map(H=>e.jsx(dn,{plugin:H,onInstall:X,onUninstall:se,onToggleEnable:te,onOpenConfig:q,onDelete:Ie,isLoading:n===H.name,onShowReadme:H.readme?()=>{f(H.readme),N(!0)}:void 0},H.code))})})]})]}),e.jsx(de,{open:r,onOpenChange:a,children:e.jsxs(ce,{className:"sm:max-w-lg",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[V?.find(H=>H.code===i)?.name," ",s("config.title")]}),e.jsx(Ae,{children:s("config.description")})]}),i&&e.jsx(Bu,{pluginName:i,onClose:()=>a(!1),onSuccess:()=>{a(!1),L()}})]})}),e.jsx(de,{open:P,onOpenChange:k,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(Ae,{children:s("upload.description")})]}),e.jsxs("div",{className:w("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",C&&"border-primary/50 bg-muted/50"),onDragEnter:fe,onDragLeave:fe,onDragOver:fe,onDrop:fs,children:[e.jsx("input",{type:"file",ref:p,className:"hidden",accept:".zip",onChange:H=>{const oe=H.target.files?.[0];oe&&ee(oe)}}),c?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(de,{open:S,onOpenChange:N,children:e.jsxs(ce,{className:"max-w-2xl",children:[e.jsx(he,{children:e.jsx(me,{children:s("readme.title",{defaultValue:"插件文档"})})}),e.jsx("div",{className:"markdown-body max-h-[60vh] overflow-y-auto",dangerouslySetInnerHTML:{__html:re(g)}})]})})]})]})}function dn({plugin:s,onInstall:n,onUninstall:t,onToggleEnable:r,onOpenConfig:a,onDelete:i,isLoading:l,onShowReadme:d}){const{t:u}=M("plugin");return e.jsxs(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",children:[e.jsxs(Pe,{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,{children:s.name}),s.is_installed&&e.jsx(U,{variant:s.is_enabled?"success":"secondary",children:s.is_enabled?u("status.enabled"):u("status.disabled")}),s.readme&&e.jsx("button",{type:"button",onClick:d,className:"ml-1 flex items-center justify-center rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-primary",title:u("button.readme",{defaultValue:"查看文档"}),style:{lineHeight:0},children:e.jsx(_n,{className:"h-4 w-4"})})]}),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(Rn,{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(Us,{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:[u("author"),": ",s.author]})})]})})]}),e.jsx(Le,{children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.is_installed?e.jsxs(e.Fragment,{children:[s.is_installed&&s.config&&Object.keys(s.config).length>0&&e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>a(s.code),disabled:!s.is_enabled||l,children:[e.jsx(ka,{className:"mr-2 h-4 w-4"}),u("button.config")]}),e.jsxs(F,{variant:s.is_enabled?"destructive":"default",size:"sm",onClick:()=>r(s.code,s.is_enabled),disabled:l,children:[e.jsx(ld,{className:"mr-2 h-4 w-4"}),s.is_enabled?u("button.disable"):u("button.enable")]}),e.jsx(_s,{title:u("uninstall.title"),description:u("uninstall.description"),cancelText:u("common:cancel"),confirmText:u("uninstall.button"),variant:"destructive",onConfirm:()=>t(s.code),children:e.jsxs(F,{variant:"outline",size:"sm",className:"text-muted-foreground hover:text-destructive",disabled:l,children:[e.jsx(us,{className:"mr-2 h-4 w-4"}),u("button.uninstall")]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{onClick:()=>n(s.code),disabled:l,loading:l,children:u("button.install")}),e.jsx(_s,{title:u("delete.title"),description:u("delete.description"),cancelText:u("common:cancel"),confirmText:u("delete.button"),variant:"destructive",onConfirm:()=>i(s.code),children:e.jsx(F,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",disabled:l,children:e.jsx(us,{className:"h-4 w-4"})})})]})})})]})}function mn(){return e.jsxs(ke,{children:[e.jsxs(Pe,{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(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-6 w-[80px]"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(je,{className:"h-5 w-[120px]"}),e.jsx(je,{className:"h-5 w-[60px]"})]})]})}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(je,{className:"h-4 w-[300px]"}),e.jsx(je,{className:"h-4 w-[150px]"})]})]}),e.jsx(Le,{children:e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-9 w-[100px]"}),e.jsx(je,{className:"h-8 w-8"})]})})]})}const Yu=Object.freeze(Object.defineProperty({__proto__:null,default:Gu},Symbol.toStringTag,{value:"Module"})),Wu=(s,n)=>{let t=null;switch(s.field_type){case"input":t=e.jsx(D,{placeholder:s.placeholder,...n});break;case"textarea":t=e.jsx(Fs,{placeholder:s.placeholder,...n});break;case"select":t=e.jsx("select",{className:w(Lt({variant:"outline"}),"w-full appearance-none font-normal"),...n,children:s.select_options&&Object.keys(s.select_options).map(r=>e.jsx("option",{value:r,children:s.select_options?.[r]},r))});break;default:t=null;break}return t};function Ju({themeKey:s,themeInfo:n}){const{t}=M("theme"),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),x=we({defaultValues:n.configs.reduce((j,P)=>(j[P.field_name]="",j),{})}),o=async()=>{l(!0),Yt.getConfig(s).then(({data:j})=>{Object.entries(j).forEach(([P,k])=>{x.setValue(P,k)})}).finally(()=>{l(!1)})},c=async j=>{u(!0),Yt.updateConfig(s,j).then(()=>{$.success(t("config.success")),a(!1)}).finally(()=>{u(!1)})};return e.jsxs(de,{open:r,onOpenChange:j=>{a(j),j?o():x.reset()},children:[e.jsx(ps,{asChild:!0,children:e.jsx(F,{variant:"outline",children:t("card.configureTheme")})}),e.jsxs(ce,{className:"max-h-[90vh] overflow-auto sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:t("config.title",{name:n.name})}),e.jsx(Ae,{children:t("config.description")})]}),i?e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(Sa,{className:"h-6 w-6 animate-spin"})}):e.jsx(De,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(c),className:"space-y-4",children:[n.configs.map(j=>e.jsx(b,{control:x.control,name:j.field_name,render:({field:P})=>e.jsxs(v,{children:[e.jsx(y,{children:j.label}),e.jsx(_,{children:Wu(j,P)}),e.jsx(R,{})]})},j.field_name)),e.jsxs(Me,{className:"mt-6 gap-2",children:[e.jsx(F,{type:"button",variant:"secondary",onClick:()=>a(!1),children:t("config.cancel")}),e.jsx(F,{type:"submit",loading:d,children:t("config.save")})]})]})})]})]})}function Qu(){const{t:s}=M("theme"),[n,t]=m.useState(null),[r,a]=m.useState(!1),[i,l]=m.useState(!1),[d,u]=m.useState(!1),[x,o]=m.useState(null),c=m.useRef(null),[j,P]=m.useState(0),{data:k,isLoading:C,refetch:T}=ne({queryKey:["themeList"],queryFn:async()=>{const{data:L}=await Yt.getList();return L}}),p=async L=>{t(L),ve.updateSystemConfig({frontend_theme:L}).then(()=>{$.success("主题切换成功"),T()}).finally(()=>{t(null)})},S=async L=>{if(!L.name.endsWith(".zip")){$.error(s("upload.error.format"));return}a(!0),Yt.upload(L).then(()=>{$.success("主题上传成功"),l(!1),T()}).finally(()=>{a(!1),c.current&&(c.current.value="")})},N=L=>{L.preventDefault(),L.stopPropagation(),L.type==="dragenter"||L.type==="dragover"?u(!0):L.type==="dragleave"&&u(!1)},g=L=>{L.preventDefault(),L.stopPropagation(),u(!1),L.dataTransfer.files&&L.dataTransfer.files[0]&&S(L.dataTransfer.files[0])},f=()=>{x&&P(L=>L===0?x.images.length-1:L-1)},V=()=>{x&&P(L=>L===x.images.length-1?0:L+1)},E=(L,K)=>{P(0),o({name:L,images:K})};return e.jsxs(qe,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsx(cs,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(F,{onClick:()=>l(!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:C?e.jsxs(e.Fragment,{children:[e.jsx(br,{}),e.jsx(br,{})]}):k?.themes&&Object.entries(k.themes).map(([L,K])=>e.jsx(ke,{className:"group relative overflow-hidden transition-all hover:shadow-md",style:{backgroundImage:K.background_url?`url(${K.background_url})`:"none",backgroundSize:"cover",backgroundPosition:"center"},children:e.jsxs("div",{className:w("relative z-10 h-full transition-colors",K.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:[!!K.can_delete&&e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(_s,{title:s("card.delete.title"),description:s("card.delete.description"),confirmText:s("card.delete.button"),variant:"destructive",onConfirm:async()=>{if(L===k?.active){$.error(s("card.delete.error.active"));return}t(L),Yt.drop(L).then(()=>{$.success("主题删除成功"),T()}).finally(()=>{t(null)})},children:e.jsx(F,{disabled:n===L,loading:n===L,variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",children:e.jsx(us,{className:"h-4 w-4"})})})}),e.jsxs(Pe,{children:[e.jsx(Re,{children:K.name}),e.jsx(Us,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{children:K.description}),K.version&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("card.version",{version:K.version})})]})})]}),e.jsxs(Le,{className:"flex items-center justify-end space-x-3",children:[K.images&&Array.isArray(K.images)&&K.images.length>0&&e.jsx(F,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>E(K.name,K.images),children:e.jsx(id,{className:"h-4 w-4"})}),e.jsx(Ju,{themeKey:L,themeInfo:K}),e.jsx(F,{onClick:()=>p(L),disabled:n===L||L===k.active,loading:n===L,variant:L===k.active?"secondary":"default",children:L===k.active?s("card.currentTheme"):s("card.activateTheme")})]})]})},L))}),e.jsx(de,{open:i,onOpenChange:l,children:e.jsxs(ce,{className:"sm:max-w-md",children:[e.jsxs(he,{children:[e.jsx(me,{children:s("upload.title")}),e.jsx(Ae,{children:s("upload.description")})]}),e.jsxs("div",{className:w("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",d&&"border-primary/50 bg-muted/50"),onDragEnter:N,onDragLeave:N,onDragOver:N,onDrop:g,children:[e.jsx("input",{type:"file",ref:c,className:"hidden",accept:".zip",onChange:L=>{const K=L.target.files?.[0];K&&S(K)}}),r?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:()=>c.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(de,{open:!!x,onOpenChange:L=>{L||(o(null),P(0))},children:e.jsxs(ce,{className:"max-w-4xl",children:[e.jsxs(he,{children:[e.jsxs(me,{children:[x?.name," ",s("preview.title")]}),e.jsx(Ae,{className:"text-center",children:x&&s("preview.imageCount",{current:j+1,total:x.images.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-lg border bg-muted",children:x?.images[j]&&e.jsx("img",{src:x.images[j],alt:`${x.name} 预览图 ${j+1}`,className:"h-full w-full object-contain"})}),x&&x.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(F,{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:f,children:e.jsx(dl,{className:"h-4 w-4"})}),e.jsx(F,{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:V,children:e.jsx(ml,{className:"h-4 w-4"})})]})]}),x&&x.images.length>1&&e.jsx("div",{className:"mt-4 flex gap-2 overflow-x-auto pb-2",children:x.images.map((L,K)=>e.jsx("button",{onClick:()=>P(K),className:w("relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border-2",j===K?"border-primary":"border-transparent"),children:e.jsx("img",{src:L,alt:`缩略图 ${K+1}`,className:"h-full w-full object-cover"})},K))})]})})]})]})}function br(){return e.jsxs(ke,{children:[e.jsxs(Pe,{children:[e.jsx(je,{className:"h-6 w-[200px]"}),e.jsx(je,{className:"h-4 w-[300px]"})]}),e.jsxs(Le,{className:"flex items-center justify-end space-x-3",children:[e.jsx(je,{className:"h-10 w-[100px]"}),e.jsx(je,{className:"h-10 w-[100px]"})]})]})}const Xu=Object.freeze(Object.defineProperty({__proto__:null,default:Qu},Symbol.toStringTag,{value:"Module"})),Xa=m.forwardRef(({className:s,value:n=[],onChange:t,...r},a)=>{const[i,l]=m.useState("");m.useEffect(()=>{if(i.includes(",")){const u=new Set([...n,...i.split(",").map(x=>x.trim())]);t(Array.from(u)),l("")}},[i,t,n]);const d=()=>{if(i){const u=new Set([...n,i]);t(Array.from(u)),l("")}};return e.jsxs("div",{className:w(" 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(u=>e.jsxs(U,{variant:"secondary",children:[u,e.jsx(G,{variant:"ghost",size:"icon",className:"ml-2 h-3 w-3",onClick:()=>{t(n.filter(x=>x!==u))},children:e.jsx(wn,{className:"w-3"})})]},u)),e.jsx("input",{className:"flex-1 outline-none placeholder:text-muted-foreground bg-transparent",value:i,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"||u.key===","?(u.preventDefault(),d()):u.key==="Backspace"&&i.length===0&&n.length>0&&(u.preventDefault(),t(n.slice(0,-1)))},...r,ref:a})]})});Xa.displayName="InputTags";const Zu=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()}),ex={id:null,show:!1,tags:[],img_url:"",title:"",content:""};function ui({refetch:s,dialogTrigger:n,type:t="add",defaultFormValues:r=ex}){const{t:a}=M("notice"),[i,l]=m.useState(!1),d=we({resolver:Te(Zu),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new Mn({html:!0});return e.jsx(De,{...d,children:e.jsxs(de,{onOpenChange:l,open:i,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(F,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add.button")})]})}),e.jsxs(ce,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add.title":"form.edit.title")}),e.jsx(Ae,{})]}),e.jsx(b,{control:d.control,name:"title",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.title.label")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:a("form.fields.title.placeholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"content",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.content.label")}),e.jsx(_,{children:e.jsx(On,{style:{height:"500px"},value:x.value,renderHTML:o=>u.render(o),onChange:({text:o})=>{x.onChange(o)}})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"img_url",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.img_url.label")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:a("form.fields.img_url.placeholder"),...x,value:x.value||""})})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"show",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.show.label")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(Z,{checked:x.value,onCheckedChange:x.onChange})})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"tags",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.fields.tags.label")}),e.jsx(_,{children:e.jsx(Xa,{value:x.value,onChange:x.onChange,placeholder:a("form.fields.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(F,{type:"button",variant:"outline",children:a("form.buttons.cancel")})}),e.jsx(F,{type:"submit",onClick:x=>{x.preventDefault(),d.handleSubmit(async o=>{ta.save(o).then(({data:c})=>{c&&($.success(a("form.buttons.success")),s(),l(!1))})})()},children:a("form.buttons.submit")})]})]})]})})}function sx({table:s,refetch:n,saveOrder:t,isSortMode:r}){const{t:a}=M("notice"),i=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:[!r&&e.jsx(ui,{refetch:n}),!r&&e.jsx(D,{placeholder:a("table.toolbar.search"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),i&&!r&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-9 px-2 lg:px-3",children:[a("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(F,{variant:r?"default":"outline",onClick:t,className:"h-8",size:"sm",children:a(r?"table.toolbar.sort.save":"table.toolbar.sort.edit")})})]})}const tx=s=>{const{t:n}=M("notice");return[{id:"drag-handle",header:"",cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(od,{className:"h-4 w-4 cursor-move text-muted-foreground"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",className:"font-mono",children:t.getValue("id")}),enableSorting:!0,size:60},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Z,{defaultChecked:t.getValue("show"),onCheckedChange:async()=>{const{data:r}=await ta.updateStatus(t.original.id);r||s()}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.title")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[500px] items-center",children:e.jsx("span",{className:"truncate font-medium",children:t.getValue("title")})}),enableSorting:!1,size:6e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[e.jsx(ui,{refetch:s,dialogTrigger:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{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:t.original}),e.jsx(_s,{title:n("table.actions.delete.title"),description:n("table.actions.delete.description"),onConfirm:async()=>{ta.drop(t.original.id).then(()=>{$.success(n("table.actions.delete.success")),s()})},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 ax(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState(!1),[o,c]=m.useState({}),[j,P]=m.useState({pageSize:50,pageIndex:0}),[k,C]=m.useState([]),{refetch:T}=ne({queryKey:["notices"],queryFn:async()=>{const{data:f}=await ta.getList();return C(f),f}});m.useEffect(()=>{r({"drag-handle":u,content:!u,created_at:!u,actions:!u}),P({pageSize:u?99999:50,pageIndex:0})},[u]);const p=(f,V)=>{u&&(f.dataTransfer.setData("text/plain",V.toString()),f.currentTarget.classList.add("opacity-50"))},S=(f,V)=>{if(!u)return;f.preventDefault(),f.currentTarget.classList.remove("bg-muted");const E=parseInt(f.dataTransfer.getData("text/plain"));if(E===V)return;const L=[...k],[K]=L.splice(E,1);L.splice(V,0,K),C(L)},N=async()=>{if(!u){x(!0);return}ta.sort(k.map(f=>f.id)).then(()=>{$.success("排序保存成功"),x(!1),T()}).finally(()=>{x(!1)})},g=Be({data:k??[],columns:tx(T),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:o,pagination:j},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:c,onPaginationChange:P,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:g,toolbar:f=>e.jsx(sx,{table:f,refetch:T,saveOrder:N,isSortMode:u}),draggable:u,onDragStart:p,onDragEnd:f=>f.currentTarget.classList.remove("opacity-50"),onDragOver:f=>{f.preventDefault(),f.currentTarget.classList.add("bg-muted")},onDragLeave:f=>f.currentTarget.classList.remove("bg-muted"),onDrop:S,showPagination:!u})})}function nx(){const{t:s}=M("notice");return e.jsxs(qe,{children:[e.jsxs(He,{className:"flex items-center justify-between",children:[e.jsx(cs,{}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(ax,{})})]})]})}const rx=Object.freeze(Object.defineProperty({__proto__:null,default:nx},Symbol.toStringTag,{value:"Module"})),lx=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()}),ix={id:null,language:"zh-CN",category:"",title:"",body:"",show:!1};function xi({refreshData:s,dialogTrigger:n,type:t="add",defaultFormValues:r=ix}){const{t:a}=M("knowledge"),[i,l]=m.useState(!1),d=we({resolver:Te(lx),defaultValues:r,mode:"onChange",shouldFocusError:!0}),u=new Mn({html:!0});return m.useEffect(()=>{i&&r.id&&Pt.getInfo(r.id).then(({data:x})=>{d.reset(x)})},[r.id,d,i]),e.jsxs(de,{onOpenChange:l,open:i,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(F,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(ce,{className:"sm:max-w-[1025px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(t==="add"?"form.add":"form.edit")}),e.jsx(Ae,{})]}),e.jsxs(De,{...d,children:[e.jsx(b,{control:d.control,name:"title",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.title")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:a("form.titlePlaceholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"category",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.category")}),e.jsx("div",{className:"relative ",children:e.jsx(_,{children:e.jsx(D,{placeholder:a("form.categoryPlaceholder"),...x})})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"language",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.language")}),e.jsx(_,{children:e.jsxs(J,{value:x.value,onValueChange:x.onChange,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:a("form.languagePlaceholder")})}),e.jsx(W,{children:[{value:"en-US"},{value:"ja-JP"},{value:"ko-KR"},{value:"vi-VN"},{value:"zh-CN"},{value:"zh-TW"}].map(o=>e.jsx(A,{value:o.value,className:"cursor-pointer",children:a(`languages.${o.value}`)},o.value))})]})})]})}),e.jsx(b,{control:d.control,name:"body",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.content")}),e.jsx(_,{children:e.jsx(On,{style:{height:"500px"},value:x.value,renderHTML:o=>u.render(o),onChange:({text:o})=>{x.onChange(o)}})}),e.jsx(R,{})]})}),e.jsx(b,{control:d.control,name:"show",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.show")}),e.jsx("div",{className:"relative py-2",children:e.jsx(_,{children:e.jsx(Z,{checked:x.value,onCheckedChange:x.onChange})})}),e.jsx(R,{})]})}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(F,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsx(F,{type:"submit",onClick:()=>{d.handleSubmit(x=>{Pt.save(x).then(({data:o})=>{o&&(d.reset(),$.success(a("messages.operationSuccess")),l(!1),s())})})()},children:a("form.submit")})]})]})]})]})}function ox({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(rs,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:w("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{className:w("h-4 w-4")})}),i.icon&&e.jsx(i.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:i.label}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Rt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function cx({table:s,refetch:n,saveOrder:t,isSortMode:r}){const a=s.getState().columnFilters.length>0,{t:i}=M("knowledge");return e.jsxs("div",{className:"flex items-center justify-between",children:[r?e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sortModeHint")}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xi,{refreshData:n}),e.jsx(D,{placeholder:i("toolbar.searchPlaceholder"),value:s.getColumn("title")?.getFilterValue()??"",onChange:l=>s.getColumn("title")?.setFilterValue(l.target.value),className:"h-8 w-[250px]"}),s.getColumn("category")&&e.jsx(ox,{column:s.getColumn("category"),title:i("columns.category"),options:Array.from(new Set(s.getCoreRowModel().rows.map(l=>l.getValue("category")))).map(l=>({label:l,value:l}))}),a&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),children:[i("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{variant:r?"default":"outline",onClick:t,size:"sm",children:i(r?"toolbar.saveSort":"toolbar.editSort")})})]})}const dx=({refetch:s,isSortMode:n=!1})=>{const{t}=M("knowledge");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:n?"cursor-move":"opacity-0",children:e.jsx(za,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.id")}),cell:({row:r})=>e.jsx(U,{variant:"outline",className:"justify-center",children:r.getValue("id")}),enableSorting:!0,size:70},{accessorKey:"show",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.status")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center",children:e.jsx(Z,{defaultChecked:r.getValue("show"),onCheckedChange:async()=>{Pt.updateStatus({id:r.original.id}).then(({data:a})=>{a||s()})}})}),enableSorting:!1,size:100},{accessorKey:"title",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.title")}),cell:({row:r})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"line-clamp-2 font-medium",children:r.getValue("title")})}),enableSorting:!0,size:600},{accessorKey:"category",header:({column:r})=>e.jsx(O,{column:r,title:t("columns.category")}),cell:({row:r})=>e.jsx(U,{variant:"secondary",className:"max-w-[180px] truncate",children:r.getValue("category")}),enableSorting:!0,size:1800},{id:"actions",header:({column:r})=>e.jsx(O,{className:"justify-end",column:r,title:t("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-end space-x-1",children:[e.jsx(xi,{refreshData:s,dialogTrigger:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:t("form.edit")})]}),type:"edit",defaultFormValues:r.original}),e.jsx(_s,{title:t("messages.deleteConfirm"),description:t("messages.deleteDescription"),confirmText:t("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{Pt.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(t("messages.operationSuccess")),s())})},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{className:"h-4 w-4 text-muted-foreground hover:text-red-600 dark:hover:text-red-400"}),e.jsx("span",{className:"sr-only",children:t("messages.deleteButton")})]})})]}),size:100}]};function mx(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState(!1),[l,d]=m.useState([]),[u,x]=m.useState({"drag-handle":!1}),[o,c]=m.useState({pageSize:20,pageIndex:0}),{refetch:j,isLoading:P,data:k}=ne({queryKey:["knowledge"],queryFn:async()=>{const{data:N}=await Pt.getList();return d(N||[]),N}});m.useEffect(()=>{x({"drag-handle":a,actions:!a}),c({pageSize:a?99999:10,pageIndex:0})},[a]);const C=(N,g)=>{a&&(N.dataTransfer.setData("text/plain",g.toString()),N.currentTarget.classList.add("opacity-50"))},T=(N,g)=>{if(!a)return;N.preventDefault(),N.currentTarget.classList.remove("bg-muted");const f=parseInt(N.dataTransfer.getData("text/plain"));if(f===g)return;const V=[...l],[E]=V.splice(f,1);V.splice(g,0,E),d(V)},p=async()=>{a?Pt.sort({ids:l.map(N=>N.id)}).then(()=>{j(),i(!1),$.success("排序保存成功")}):i(!0)},S=Be({data:l,columns:dx({refetch:j,isSortMode:a}),state:{sorting:t,columnFilters:s,columnVisibility:u,pagination:o},onSortingChange:r,onColumnFiltersChange:n,onColumnVisibilityChange:x,onPaginationChange:c,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:S,toolbar:N=>e.jsx(cx,{table:N,refetch:j,saveOrder:p,isSortMode:a}),draggable:a,onDragStart:C,onDragEnd:N=>N.currentTarget.classList.remove("opacity-50"),onDragOver:N=>{N.preventDefault(),N.currentTarget.classList.add("bg-muted")},onDragLeave:N=>N.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!a})}function ux(){const{t:s}=M("knowledge");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(mx,{})})]})]})}const xx=Object.freeze(Object.defineProperty({__proto__:null,default:ux},Symbol.toStringTag,{value:"Module"}));function hx(s,n){const[t,r]=m.useState(s);return m.useEffect(()=>{const a=setTimeout(()=>r(s),n);return()=>{clearTimeout(a)}},[s,n]),t}function un(s,n){if(s.length===0)return{};if(!n)return{"":s};const t={};return s.forEach(r=>{const a=r[n]||"";t[a]||(t[a]=[]),t[a].push(r)}),t}function gx(s,n){const t=JSON.parse(JSON.stringify(s));for(const[r,a]of Object.entries(t))t[r]=a.filter(i=>!n.find(l=>l.value===i.value));return t}function px(s,n){for(const[,t]of Object.entries(s))if(t.some(r=>n.find(a=>a.value===r.value)))return!0;return!1}const hi=m.forwardRef(({className:s,...n},t)=>cd(a=>a.filtered.count===0)?e.jsx("div",{ref:t,className:w("py-6 text-center text-sm",s),"cmdk-empty":"",role:"presentation",...n}):null);hi.displayName="CommandEmpty";const st=m.forwardRef(({value:s,onChange:n,placeholder:t,defaultOptions:r=[],options:a,delay:i,onSearch:l,loadingIndicator:d,emptyIndicator:u,maxSelected:x=Number.MAX_SAFE_INTEGER,onMaxSelected:o,hidePlaceholderWhenSelected:c,disabled:j,groupBy:P,className:k,badgeClassName:C,selectFirstItem:T=!0,creatable:p=!1,triggerSearchOnFocus:S=!1,commandProps:N,inputProps:g,hideClearAllButton:f=!1},V)=>{const E=m.useRef(null),[L,K]=m.useState(!1),X=m.useRef(!1),[se,te]=m.useState(!1),[q,ee]=m.useState(s||[]),[fe,fs]=m.useState(un(r,P)),[Ie,re]=m.useState(""),H=hx(Ie,i||500);m.useImperativeHandle(V,()=>({selectedValue:[...q],input:E.current,focus:()=>E.current?.focus()}),[q]);const oe=m.useCallback(ae=>{const ye=q.filter(We=>We.value!==ae.value);ee(ye),n?.(ye)},[n,q]),lt=m.useCallback(ae=>{const ye=E.current;ye&&((ae.key==="Delete"||ae.key==="Backspace")&&ye.value===""&&q.length>0&&(q[q.length-1].fixed||oe(q[q.length-1])),ae.key==="Escape"&&ye.blur())},[oe,q]);m.useEffect(()=>{s&&ee(s)},[s]),m.useEffect(()=>{if(!a||l)return;const ae=un(a||[],P);JSON.stringify(ae)!==JSON.stringify(fe)&&fs(ae)},[r,a,P,l,fe]),m.useEffect(()=>{const ae=async()=>{te(!0);const We=await l?.(H);fs(un(We||[],P)),te(!1)};(async()=>{!l||!L||(S&&await ae(),H&&await ae())})()},[H,P,L,S]);const $s=()=>{if(!p||px(fe,[{value:Ie,label:Ie}])||q.find(ye=>ye.value===Ie))return;const ae=e.jsx(rs,{value:Ie,className:"cursor-pointer",onMouseDown:ye=>{ye.preventDefault(),ye.stopPropagation()},onSelect:ye=>{if(q.length>=x){o?.(q.length);return}re("");const We=[...q,{value:ye,label:ye}];ee(We),n?.(We)},children:`Create "${Ie}"`});if(!l&&Ie.length>0||l&&H.length>0&&!se)return ae},Et=m.useCallback(()=>{if(u)return l&&!p&&Object.keys(fe).length===0?e.jsx(rs,{value:"-",disabled:!0,children:u}):e.jsx(hi,{children:u})},[p,u,l,fe]),na=m.useMemo(()=>gx(fe,q),[fe,q]),Vt=m.useCallback(()=>{if(N?.filter)return N.filter;if(p)return(ae,ye)=>ae.toLowerCase().includes(ye.toLowerCase())?1:-1},[p,N?.filter]),Gs=m.useCallback(()=>{const ae=q.filter(ye=>ye.fixed);ee(ae),n?.(ae)},[n,q]);return e.jsxs(nt,{...N,onKeyDown:ae=>{lt(ae),N?.onKeyDown?.(ae)},className:w("h-auto overflow-visible bg-transparent",N?.className),shouldFilter:N?.shouldFilter!==void 0?N.shouldFilter:!l,filter:Vt(),children:[e.jsx("div",{className:w("rounded-md border border-input text-sm ring-offset-background focus-within:ring-1 focus-within:ring-ring ",{"px-3 py-2":q.length!==0,"cursor-text":!j&&q.length!==0},k),onClick:()=>{j||E.current?.focus()},children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[q.map(ae=>e.jsxs(U,{className:w("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",C),"data-fixed":ae.fixed,"data-disabled":j||void 0,children:[ae.label,e.jsx("button",{className:w("ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2",(j||ae.fixed)&&"hidden"),onKeyDown:ye=>{ye.key==="Enter"&&oe(ae)},onMouseDown:ye=>{ye.preventDefault(),ye.stopPropagation()},onClick:()=>oe(ae),children:e.jsx(wn,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},ae.value)),e.jsx(xs.Input,{...g,ref:E,value:Ie,disabled:j,onValueChange:ae=>{re(ae),g?.onValueChange?.(ae)},onBlur:ae=>{X.current===!1&&K(!1),g?.onBlur?.(ae)},onFocus:ae=>{K(!0),S&&l?.(H),g?.onFocus?.(ae)},placeholder:c&&q.length!==0?"":t,className:w("flex-1 bg-transparent outline-none placeholder:text-muted-foreground",{"w-full":c,"px-3 py-2":q.length===0,"ml-1":q.length!==0},g?.className)}),e.jsx("button",{type:"button",onClick:Gs,className:w((f||j||q.length<1||q.filter(ae=>ae.fixed).length===q.length)&&"hidden"),children:e.jsx(wn,{})})]})}),e.jsx("div",{className:"relative",children:L&&e.jsx(rt,{className:"absolute top-1 z-10 w-full rounded-md border bg-popover text-popover-foreground shadow-md outline-none animate-in",onMouseLeave:()=>{X.current=!1},onMouseEnter:()=>{X.current=!0},onMouseUp:()=>{E.current?.focus()},children:se?e.jsx(e.Fragment,{children:d}):e.jsxs(e.Fragment,{children:[Et(),$s(),!T&&e.jsx(rs,{value:"-",className:"hidden"}),Object.entries(na).map(([ae,ye])=>e.jsx(Ss,{heading:ae,className:"h-full overflow-auto",children:e.jsx(e.Fragment,{children:ye.map(We=>e.jsx(rs,{value:We.value,disabled:We.disable,onMouseDown:_e=>{_e.preventDefault(),_e.stopPropagation()},onSelect:()=>{if(q.length>=x){o?.(q.length);return}re("");const _e=[...q,We];ee(_e),n?.(_e)},className:w("cursor-pointer",We.disable&&"cursor-default text-muted-foreground"),children:We.label},We.value))})},ae))]})})})]})});st.displayName="MultipleSelector";const fx=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 Za({refetch:s,dialogTrigger:n,defaultValues:t={name:""},type:r="add"}){const{t:a}=M("group"),i=we({resolver:Te(fx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1),[u,x]=m.useState(!1),o=async c=>{x(!0),pt.save(c).then(()=>{$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),s&&s(),i.reset(),d(!1)}).finally(()=>{x(!1)})};return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(F,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("span",{children:a("form.add")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ae,{children:a(r==="edit"?"form.editDescription":"form.createDescription")})]}),e.jsx(De,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(o),className:"space-y-4",children:[e.jsx(b,{control:i.control,name:"name",render:({field:c})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.name")}),e.jsx(_,{children:e.jsx(D,{placeholder:a("form.namePlaceholder"),...c,className:"w-full"})}),e.jsx(z,{children:a("form.nameDescription")}),e.jsx(R,{})]})}),e.jsxs(Me,{className:"gap-2",children:[e.jsx(Qs,{asChild:!0,children:e.jsx(F,{type:"button",variant:"outline",children:a("form.cancel")})}),e.jsxs(F,{type:"submit",disabled:u||!i.formState.isValid,children:[u&&e.jsx(Sa,{className:"mr-2 h-4 w-4 animate-spin"}),a(r==="edit"?"form.update":"form.create")]})]})]})})]})]})}const gi=m.createContext(void 0);function jx({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),[l,d]=m.useState(xe.Shadowsocks);return e.jsx(gi.Provider,{value:{isOpen:t,setIsOpen:r,editingServer:a,setEditingServer:i,serverType:l,setServerType:d,refetch:n},children:s})}function pi(){const s=m.useContext(gi);if(s===void 0)throw new Error("useServerEdit must be used within a ServerEditProvider");return s}function xn({dialogTrigger:s,value:n,setValue:t,templateType:r}){const{t:a}=M("server");m.useEffect(()=>{console.log(n)},[n]);const[i,l]=m.useState(!1),[d,u]=m.useState(()=>{if(!n||Object.keys(n).length===0)return"";try{return JSON.stringify(n,null,2)}catch{return""}}),[x,o]=m.useState(null),c=p=>{if(!p)return null;try{const S=JSON.parse(p);return typeof S!="object"||S===null?a("network_settings.validation.must_be_object"):null}catch{return a("network_settings.validation.invalid_json")}},j={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"}}},httpupgrade:{label:"HttpUpgrade",content:{acceptProxyProtocol:!1,path:"/",host:"xray.com",headers:{key:"value"}}},xhttp:{label:"XHTTP",content:{host:"example.com",path:"/yourpath",mode:"auto",extra:{headers:{},xPaddingBytes:"100-1000",noGRPCHeader:!1,noSSEHeader:!1,scMaxEachPostBytes:1e6,scMinPostsIntervalMs:30,scMaxBufferedPosts:30,xmux:{maxConcurrency:"16-32",maxConnections:0,cMaxReuseTimes:"64-128",cMaxLifetimeMs:0,hMaxRequestTimes:"800-900",hKeepAlivePeriod:0},downloadSettings:{address:"",port:443,network:"xhttp",security:"tls",tlsSettings:{},xhttpSettings:{path:"/yourpath"},sockopt:{}}}}}},P=()=>{switch(r){case"tcp":return["tcp","tcp-http"];case"grpc":return["grpc"];case"ws":return["ws"];case"httpupgrade":return["httpupgrade"];case"xhttp":return["xhttp"];default:return[]}},k=()=>{const p=c(d||"");if(p){$.error(p);return}try{if(!d){t(null),l(!1);return}t(JSON.parse(d)),l(!1)}catch{$.error(a("network_settings.errors.save_failed"))}},C=p=>{u(p),o(c(p))},T=p=>{const S=j[p];if(S){const N=JSON.stringify(S.content,null,2);u(N),o(null)}};return m.useEffect(()=>{i&&console.log(n)},[i,n]),m.useEffect(()=>{i&&n&&Object.keys(n).length>0&&u(JSON.stringify(n,null,2))},[i,n]),e.jsxs(de,{open:i,onOpenChange:p=>{!p&&i&&k(),l(p)},children:[e.jsx(ps,{asChild:!0,children:s??e.jsx(G,{variant:"link",children:a("network_settings.edit_protocol")})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:a("network_settings.edit_protocol_config")})}),e.jsxs("div",{className:"space-y-4",children:[P().length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:P().map(p=>e.jsx(G,{variant:"outline",size:"sm",onClick:()=>T(p),children:a("network_settings.use_template",{template:j[p].label})},p))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fs,{className:`min-h-[200px] font-mono text-sm ${x?"border-red-500 focus-visible:ring-red-500":""}`,value:d,placeholder:P().length>0?a("network_settings.json_config_placeholder_with_template"):a("network_settings.json_config_placeholder"),onChange:p=>C(p.target.value)}),x&&e.jsx("p",{className:"text-sm text-red-500",children:x})]})]}),e.jsxs(Me,{className:"gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>l(!1),children:a("common.cancel")}),e.jsx(G,{onClick:k,disabled:!!x,children:a("common.confirm")})]})]})]})}function lp(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 vx={},bx=Object.freeze(Object.defineProperty({__proto__:null,default:vx},Symbol.toStringTag,{value:"Module"})),ip=kd(bx),yr=s=>s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),yx=()=>{try{const s=dd.box.keyPair(),n=yr(ir.encodeBase64(s.secretKey)),t=yr(ir.encodeBase64(s.publicKey));return{privateKey:n,publicKey:t}}catch(s){throw console.error("Error generating x25519 key pair:",s),s}},_x=()=>{try{return yx()}catch(s){throw console.error("Error generating key pair:",s),s}},Nx=s=>{const n=new Uint8Array(Math.ceil(s/2));return window.crypto.getRandomValues(n),Array.from(n).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,s)},wx=()=>{const s=Math.floor(Math.random()*8)*2+2;return Nx(s)},Cx=h.object({cipher:h.string().default("aes-128-gcm"),plugin:h.string().optional().default(""),plugin_opts:h.string().optional().default(""),client_fingerprint:h.string().optional().default("chrome")}),Sx=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({})}),kx=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({})}),Tx=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({}),hop_interval:h.number().optional(),port_range:h.string().optional()}),Dx=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("")}),Px=h.object({version:h.coerce.number().default(5),congestion_control:h.string().default("bbr"),alpn:h.array(h.string()).default(["h3"]),udp_relay_mode:h.string().default("native"),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Lx=h.object({}),Fx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Rx=h.object({tls:h.coerce.number().default(0),tls_settings:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Ex=h.object({transport:h.string().default("tcp"),multiplexing:h.string().default("MULTIPLEXING_LOW")}),Vx=h.object({padding_scheme:h.array(h.string()).optional().default([]),tls:h.object({server_name:h.string().default(""),allow_insecure:h.boolean().default(!1)}).default({})}),Oe={shadowsocks:{schema:Cx,ciphers:["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"],plugins:[{value:"none",label:"None"},{value:"obfs",label:"Simple Obfs"},{value:"v2ray-plugin",label:"V2Ray Plugin"}],clientFingerprints:[{value:"chrome",label:"Chrome"},{value:"firefox",label:"Firefox"},{value:"safari",label:"Safari"},{value:"ios",label:"iOS"}]},vmess:{schema:Sx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},trojan:{schema:kx,networkOptions:[{value:"tcp",label:"TCP"},{value:"ws",label:"Websocket"},{value:"grpc",label:"gRPC"}]},hysteria:{schema:Tx,versions:["1","2"],alpnOptions:["hysteria","http/1.1","h2","h3"]},vless:{schema:Dx,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"]},tuic:{schema:Px,versions:["5","4"],congestionControls:["bbr","cubic","new_reno"],alpnOptions:[{value:"h3",label:"HTTP/3"},{value:"h2",label:"HTTP/2"},{value:"http/1.1",label:"HTTP/1.1"}],udpRelayModes:[{value:"native",label:"Native"},{value:"quic",label:"QUIC"}]},socks:{schema:Lx},naive:{schema:Rx},http:{schema:Fx},mieru:{schema:Ex,transportOptions:[{value:"tcp",label:"TCP"},{value:"udp",label:"UDP"}],multiplexingOptions:[{value:"MULTIPLEXING_OFF",label:"Off"},{value:"MULTIPLEXING_LOW",label:"Low"},{value:"MULTIPLEXING_MIDDLE",label:"Middle"},{value:"MULTIPLEXING_HIGH",label:"High"}]},anytls:{schema:Vx,defaultPaddingScheme:["stop=8","0=30-30","1=100-400","2=400-500,c,500-1000,c,500-1000,c,500-1000,c,500-1000","3=9-9,500-1000","4=500-1000","5=500-1000","6=500-1000","7=500-1000"]}},Ix=({serverType:s,value:n,onChange:t})=>{const{t:r}=M("server"),a=s?Oe[s]:null,i=a?.schema||h.record(h.any()),l=s?i.parse({}):{},d=we({resolver:Te(i),defaultValues:l,mode:"onChange"});if(m.useEffect(()=>{if(!n||Object.keys(n).length===0){if(s){const g=i.parse({});d.reset(g)}}else d.reset(n)},[s,n,t,d,i]),m.useEffect(()=>{const g=d.watch(f=>{t(f)});return()=>g.unsubscribe()},[d,t]),!s||!a)return null;const N={shadowsocks:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"cipher",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.shadowsocks.cipher.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.cipher.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.shadowsocks.ciphers.map(f=>e.jsx(A,{value:f,children:f},f))})})]})})]})}),e.jsx(b,{control:d.control,name:"plugin",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.shadowsocks.plugin.label","插件")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f=>g.onChange(f==="none"?"":f),value:g.value===""?"none":g.value||"none",children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.plugin.placeholder","选择插件")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.shadowsocks.plugins.map(f=>e.jsx(A,{value:f.value,children:f.label},f.value))})})]})}),e.jsx(z,{children:g.value&&g.value!=="none"&&g.value!==""&&e.jsxs(e.Fragment,{children:[g.value==="obfs"&&r("dynamic_form.shadowsocks.plugin.obfs_hint","提示:配置格式如 obfs=http;obfs-host=www.bing.com;path=/"),g.value==="v2ray-plugin"&&r("dynamic_form.shadowsocks.plugin.v2ray_hint","提示:WebSocket模式格式为 mode=websocket;host=mydomain.me;path=/;tls=true,QUIC模式格式为 mode=quic;host=mydomain.me")]})})]})}),d.watch("plugin")&&d.watch("plugin")!=="none"&&d.watch("plugin")!==""&&e.jsx(b,{control:d.control,name:"plugin_opts",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.shadowsocks.plugin_opts.label","插件选项")}),e.jsx(z,{children:r("dynamic_form.shadowsocks.plugin_opts.description","按照 key=value;key2=value2 格式输入插件选项")}),e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:r("dynamic_form.shadowsocks.plugin_opts.placeholder","例如: mode=tls;host=bing.com"),...g})})]})}),(d.watch("plugin")==="shadow-tls"||d.watch("plugin")==="restls")&&e.jsx(b,{control:d.control,name:"client_fingerprint",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.shadowsocks.client_fingerprint","客户端指纹")}),e.jsx(_,{children:e.jsxs(J,{value:g.value||"chrome",onValueChange:g.onChange,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.shadowsocks.client_fingerprint_placeholder","选择客户端指纹")})}),e.jsx(W,{children:Oe.shadowsocks.clientFingerprints.map(f=>e.jsx(A,{value:f.value,children:f.label},f.value))})]})}),e.jsx(z,{children:r("dynamic_form.shadowsocks.client_fingerprint_description","客户端伪装指纹,用于降低被识别风险")})]})})]}),vmess:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vmess.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:f=>g.onChange(Number(f)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.tls.placeholder")})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.vmess.tls.disabled")}),e.jsx(A,{value:"1",children:r("dynamic_form.vmess.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.vmess.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.vmess.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vmess.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"network",render:({field:g})=>e.jsxs(v,{children:[e.jsxs(y,{children:[r("dynamic_form.vmess.network.label"),e.jsx(xn,{value:d.watch("network_settings"),setValue:f=>d.setValue("network_settings",f),templateType:d.watch("network")})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.vmess.network.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.vmess.networkOptions.map(f=>e.jsx(A,{value:f.value,className:"cursor-pointer",children:f.label},f.value))})})]})})]})})]}),trojan:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.trojan.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.trojan.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(b,{control:d.control,name:"allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.trojan.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"network",render:({field:g})=>e.jsxs(v,{children:[e.jsxs(y,{children:[r("dynamic_form.trojan.network.label"),e.jsx(xn,{value:d.watch("network_settings")||{},setValue:f=>d.setValue("network_settings",f),templateType:d.watch("network")||"tcp"})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value||"tcp",children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.trojan.network.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.trojan.networkOptions.map(f=>e.jsx(A,{value:f.value,className:"cursor-pointer",children:f.label},f.value))})})]})})]})})]}),hysteria:()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"version",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:r("dynamic_form.hysteria.version.label")}),e.jsx(_,{children:e.jsxs(J,{value:(g.value||2).toString(),onValueChange:f=>g.onChange(Number(f)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.version.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.hysteria.versions.map(f=>e.jsxs(A,{value:f,className:"cursor-pointer",children:["V",f]},f))})})]})})]})}),d.watch("version")==1&&e.jsx(b,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.hysteria.alpn.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value||"h2",onValueChange:g.onChange,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.alpn.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.hysteria.alpnOptions.map(f=>e.jsx(A,{value:f,children:f},f))})})]})})]})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"obfs.open",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.hysteria.obfs.label")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})}),!!d.watch("obfs.open")&&e.jsxs(e.Fragment,{children:[d.watch("version")=="2"&&e.jsx(b,{control:d.control,name:"obfs.type",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:r("dynamic_form.hysteria.obfs.type.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value||"salamander",onValueChange:g.onChange,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.hysteria.obfs.type.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:e.jsx(A,{value:"salamander",children:r("dynamic_form.hysteria.obfs.type.salamander")})})})]})})]})}),e.jsx(b,{control:d.control,name:"obfs.password",render:({field:g})=>e.jsxs(v,{className:d.watch("version")==2?"w-full":"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.hysteria.obfs.password.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.obfs.password.placeholder"),...g,value:g.value||"",className:"pr-9"})}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",V=Array.from(crypto.getRandomValues(new Uint8Array(16))).map(E=>f[E%f.length]).join("");d.setValue("obfs.password",V),$.success(r("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:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.hysteria.tls.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.hysteria.tls.server_name.placeholder"),...g,value:g.value||""})})]})}),e.jsx(b,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.hysteria.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value||!1,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"bandwidth.up",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.hysteria.bandwidth.up.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.up.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.up.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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:r("dynamic_form.hysteria.bandwidth.up.suffix")})})]})]})}),e.jsx(b,{control:d.control,name:"bandwidth.down",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.hysteria.bandwidth.down.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.bandwidth.down.placeholder")+(d.watch("version")==2?r("dynamic_form.hysteria.bandwidth.down.bbr_tip"):""),className:"rounded-br-none rounded-tr-none",...g,value:g.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:r("dynamic_form.hysteria.bandwidth.down.suffix")})})]})]})}),e.jsx(e.Fragment,{children:e.jsx(b,{control:d.control,name:"hop_interval",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.hysteria.hop_interval.label","Hop 间隔 (秒)")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:r("dynamic_form.hysteria.hop_interval.placeholder","例如: 30"),...g,value:g.value||"",onChange:f=>{const V=f.target.value?parseInt(f.target.value):void 0;g.onChange(V)}})}),e.jsx(z,{children:r("dynamic_form.hysteria.hop_interval.description","Hop 间隔时间,单位为秒")})]})})})]}),vless:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vless.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:f=>g.onChange(Number(f)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.tls.placeholder")})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.vless.tls.none")}),e.jsx(A,{value:"1",children:r("dynamic_form.vless.tls.tls")}),e.jsx(A,{value:"2",children:r("dynamic_form.vless.tls.reality")})]})]})})]})}),d.watch("tls")=="1"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.vless.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vless.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),d.watch("tls")==2&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"reality_settings.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.vless.reality_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"reality_settings.server_port",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:r("dynamic_form.vless.reality_settings.server_port.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.vless.reality_settings.server_port.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"reality_settings.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vless.reality_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsx(b,{control:d.control,name:"reality_settings.private_key",render:({field:g})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:r("dynamic_form.vless.reality_settings.private_key.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{...g,className:"pr-9"})}),e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{try{const f=_x();d.setValue("reality_settings.private_key",f.privateKey),d.setValue("reality_settings.public_key",f.publicKey),$.success(r("dynamic_form.vless.reality_settings.key_pair.success"))}catch{$.error(r("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(Ta,{children:e.jsx(ue,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.key_pair.generate")})})})]})]})]})})}),e.jsx(b,{control:d.control,name:"reality_settings.public_key",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vless.reality_settings.public_key.label")}),e.jsx(_,{children:e.jsx(D,{...g})})]})}),e.jsx(b,{control:d.control,name:"reality_settings.short_id",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vless.reality_settings.short_id.label")}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{children:e.jsx(D,{...g,className:"pr-9",placeholder:r("dynamic_form.vless.reality_settings.short_id.placeholder")})}),e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{const f=wx();d.setValue("reality_settings.short_id",f),$.success(r("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(Ta,{children:e.jsx(ue,{children:e.jsx("p",{children:r("dynamic_form.vless.reality_settings.short_id.generate")})})})]})]}),e.jsx(z,{className:"text-xs text-muted-foreground",children:r("dynamic_form.vless.reality_settings.short_id.description")})]})})]}),e.jsx(b,{control:d.control,name:"network",render:({field:g})=>e.jsxs(v,{children:[e.jsxs(y,{children:[r("dynamic_form.vless.network.label"),e.jsx(xn,{value:d.watch("network_settings"),setValue:f=>d.setValue("network_settings",f),templateType:d.watch("network")})]}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.network.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.vless.networkOptions.map(f=>e.jsx(A,{value:f.value,className:"cursor-pointer",children:f.label},f.value))})})]})})]})}),e.jsx(b,{control:d.control,name:"flow",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.vless.flow.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:f=>g.onChange(f==="none"?null:f),value:g.value||"none",children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.vless.flow.placeholder")})}),e.jsx(W,{children:Oe.vless.flowOptions.map(f=>e.jsx(A,{value:f,children:f},f))})]})})]})})]}),tuic:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"version",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.tuic.version.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:f=>g.onChange(Number(f)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.version.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.tuic.versions.map(f=>e.jsxs(A,{value:f,children:["V",f]},f))})})]})})]})}),e.jsx(b,{control:d.control,name:"congestion_control",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.tuic.congestion_control.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.congestion_control.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.tuic.congestionControls.map(f=>e.jsx(A,{value:f,children:f.toUpperCase()},f))})})]})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.tuic.tls.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.tuic.tls.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.tuic.tls.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]}),e.jsx(b,{control:d.control,name:"alpn",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.tuic.tls.alpn.label")}),e.jsx(_,{children:e.jsx(st,{options:Oe.tuic.alpnOptions,onChange:f=>g.onChange(f.map(V=>V.value)),value:Oe.tuic.alpnOptions.filter(f=>g.value?.includes(f.value)),placeholder:r("dynamic_form.tuic.tls.alpn.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-lg leading-10 text-gray-600 dark:text-gray-400",children:r("dynamic_form.tuic.tls.alpn.empty")})})})]})}),e.jsx(b,{control:d.control,name:"udp_relay_mode",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.tuic.udp_relay_mode.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.tuic.udp_relay_mode.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.tuic.udpRelayModes.map(f=>e.jsx(A,{value:f.value,children:f.label},f.value))})})]})})]})})]}),socks:()=>e.jsx(e.Fragment,{}),naive:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.naive.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:f=>g.onChange(Number(f)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.naive.tls.placeholder")})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.naive.tls.disabled")}),e.jsx(A,{value:"1",children:r("dynamic_form.naive.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.naive.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.naive.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.naive.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),http:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"tls",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.http.tls.label")}),e.jsx(_,{children:e.jsxs(J,{value:g.value?.toString(),onValueChange:f=>g.onChange(Number(f)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.http.tls.placeholder")})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:r("dynamic_form.http.tls.disabled")}),e.jsx(A,{value:"1",children:r("dynamic_form.http.tls.enabled")})]})]})})]})}),d.watch("tls")==1&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls_settings.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.http.tls_settings.server_name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.http.tls_settings.server_name.placeholder"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls_settings.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.http.tls_settings.allow_insecure")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]}),mieru:()=>e.jsxs(e.Fragment,{children:[e.jsx(b,{control:d.control,name:"transport",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.mieru.transport.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.transport.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.mieru.transportOptions.map(f=>e.jsx(A,{value:f.value,children:f.label},f.value))})})]})})]})}),e.jsx(b,{control:d.control,name:"multiplexing",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.mieru.multiplexing.label")}),e.jsx(_,{children:e.jsxs(J,{onValueChange:g.onChange,value:g.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dynamic_form.mieru.multiplexing.placeholder")})}),e.jsx(W,{children:e.jsx(js,{children:Oe.mieru.multiplexingOptions.map(f=>e.jsx(A,{value:f.value,children:f.label},f.value))})})]})})]})})]}),anytls:()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:d.control,name:"padding_scheme",render:({field:g})=>e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{children:r("dynamic_form.anytls.padding_scheme.label","AnyTLS 填充方案")}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{d.setValue("padding_scheme",Oe.anytls.defaultPaddingScheme),$.success(r("dynamic_form.anytls.padding_scheme.default_success","已设置默认填充方案"))},className:"h-7 px-2",children:r("dynamic_form.anytls.padding_scheme.use_default","使用默认方案")})]}),e.jsx(z,{children:r("dynamic_form.anytls.padding_scheme.description","每行一个填充规则,格式如: stop=8, 0=30-30")}),e.jsx(_,{children:e.jsx("textarea",{className:"flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:r("dynamic_form.anytls.padding_scheme.placeholder",`例如:
stop=8
0=30-30
1=100-400
2=400-500,c,500-1000`),...g,value:Array.isArray(g.value)?g.value.join(`
-`):"",onChange:p=>{const E=p.target.value.split(`
-`).filter(P=>P.trim()!=="");g.onChange(E)}})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:r("dynamic_form.anytls.tls.server_name.label","SNI")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dynamic_form.anytls.tls.server_name.placeholder","服务器名称"),...g})})]})}),e.jsx(v,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dynamic_form.anytls.tls.allow_insecure","允许不安全连接")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(X,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]})})};return e.jsx(be,{children:C[s]?.()})};function Mx(){const{t:s}=M("server"),n=h.object({start:h.string().min(1,s("form.dynamic_rate.start_time_error")),end:h.string().min(1,s("form.dynamic_rate.end_time_error")),rate:h.string().min(1,s("form.dynamic_rate.multiplier_error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.dynamic_rate.multiplier_error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.dynamic_rate.multiplier_error_gte_zero")})}),t=h.object({id:h.number().optional().nullable(),specific_key:h.string().optional().nullable(),code:h.string().optional(),show:h.boolean().optional().nullable(),name:h.string().min(1,s("form.name.error")),rate:h.string().min(1,s("form.rate.error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.rate.error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.rate.error_gte_zero")}),rate_time_enable:h.boolean().default(!1),rate_time_ranges:h.array(n).default([]),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,s("form.host.error")),port:h.string().min(1,s("form.port.error")),server_port:h.string().min(1,s("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()}),r={id:null,specific_key:null,code:"",show:!1,name:"",rate:"1",rate_time_enable:!1,rate_time_ranges:[],tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null},{isOpen:a,setIsOpen:i,editingServer:l,setEditingServer:d,serverType:u,setServerType:x,refetch:o}=gi(),[c,f]=m.useState([]),[F,S]=m.useState([]),[w,T]=m.useState([]),y=we({resolver:Te(t),defaultValues:r,mode:"onChange"});m.useEffect(()=>{L()},[a]),m.useEffect(()=>{l?.type&&l.type!==u&&x(l.type)},[l,u,x]),m.useEffect(()=>{l?l.type===u&&y.reset({...r,...l}):y.reset({...r,protocol_settings:Oe[u].schema.parse({})})},[l,y,u]);const L=async()=>{if(!a)return;const[E,P,K]=await Promise.all([pt.getList(),qa.getList(),dt.getList()]);f(E.data?.map(Z=>({label:Z.name,value:Z.id.toString()}))||[]),S(P.data?.map(Z=>({label:Z.remarks,value:Z.id.toString()}))||[]),T(K.data||[])},C=m.useMemo(()=>w?.filter(E=>(E.parent_id===0||E.parent_id===null)&&E.type===u&&E.id!==y.watch("id")),[u,w,y]),g=()=>e.jsxs(zs,{children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(D,{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(Ms,{align:"start",children:e.jsx(cm,{children:Ts.map(({type:E,label:P})=>e.jsx(Se,{onClick:()=>{x(E),i(!0)},className:"cursor-pointer",children:e.jsx(U,{variant:"outline",className:"text-white",style:{background:bs[E]},children:P})},E))})})]}),p=()=>{i(!1),d(null),y.reset(r)},V=async()=>{const E=y.getValues();(await dt.save({...E,type:u})).data&&(p(),$.success(s("form.success")),o())};return e.jsxs(de,{open:a,onOpenChange:p,children:[g(),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Ae,{})]}),e.jsxs(De,{...y,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(v,{control:y.control,name:"name",render:({field:E})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:s("form.name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("form.name.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:"rate",render:({field:E})=>e.jsxs(j,{className:"flex-[1]",children:[e.jsx(b,{children:s("form.rate.label")}),e.jsx("div",{className:"relative flex",children:e.jsx(_,{children:e.jsx(k,{type:"number",min:"0",step:"0.1",...E})})}),e.jsx(R,{})]})})]}),e.jsx(v,{control:y.control,name:"rate_time_enable",render:({field:E})=>e.jsxs(j,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{children:s("form.dynamic_rate.enable_label")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("form.dynamic_rate.enable_description")})]}),e.jsx(_,{children:e.jsx(X,{checked:E.value,onCheckedChange:E.onChange})})]}),e.jsx(R,{})]})}),y.watch("rate_time_enable")&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{className:"",children:s("form.dynamic_rate.rules_label")}),e.jsxs(D,{type:"button",variant:"outline",size:"sm",onClick:()=>{const E=y.getValues("rate_time_ranges")||[];y.setValue("rate_time_ranges",[...E,{start:"00:00",end:"23:59",rate:"1"}])},children:[e.jsx(Ke,{icon:"ion:add",className:"mr-1 size-4"}),s("form.dynamic_rate.add_rule")]})]}),(y.watch("rate_time_ranges")||[]).map((E,P)=>e.jsxs("div",{className:"space-y-2 rounded border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:s("form.dynamic_rate.rule_title",{index:P+1})}),e.jsx(D,{type:"button",variant:"ghost",size:"sm",onClick:()=>{const K=y.getValues("rate_time_ranges")||[];K.splice(P,1),y.setValue("rate_time_ranges",[...K])},children:e.jsx(Ke,{icon:"ion:trash-outline",className:"size-4"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(v,{control:y.control,name:`rate_time_ranges.${P}.start`,render:({field:K})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-xs",children:s("form.dynamic_rate.start_time")}),e.jsx(_,{children:e.jsx(k,{type:"time",...K,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:`rate_time_ranges.${P}.end`,render:({field:K})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-xs",children:s("form.dynamic_rate.end_time")}),e.jsx(_,{children:e.jsx(k,{type:"time",...K,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:`rate_time_ranges.${P}.rate`,render:({field:K})=>e.jsxs(j,{children:[e.jsx(b,{className:"text-xs",children:s("form.dynamic_rate.multiplier")}),e.jsx(_,{children:e.jsx(k,{type:"number",min:"0",step:"0.1",...K,className:"text-sm",placeholder:"1.0"})}),e.jsx(R,{})]})})]})]},P)),(y.watch("rate_time_ranges")||[]).length===0&&e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:s("form.dynamic_rate.no_rules")})]}),e.jsx(v,{control:y.control,name:"code",render:({field:E})=>e.jsxs(j,{children:[e.jsxs(b,{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(k,{placeholder:s("form.code.placeholder"),...E,value:E.value||""})}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:"tags",render:({field:E})=>e.jsxs(j,{children:[e.jsx(b,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(Xa,{value:E.value,onChange:E.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:"group_ids",render:({field:E})=>e.jsxs(j,{children:[e.jsxs(b,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Za,{dialogTrigger:e.jsx(D,{variant:"link",children:s("form.groups.add")}),refetch:L})]}),e.jsx(_,{children:e.jsx(st,{options:c,onChange:P=>E.onChange(P.map(K=>K.value)),value:c?.filter(P=>E.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(R,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:y.control,name:"host",render:({field:E})=>e.jsxs(j,{children:[e.jsx(b,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:s("form.host.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(v,{control:y.control,name:"port",render:({field:E})=>e.jsxs(j,{className:"flex-1",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ke,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Ta,{children:e.jsx(ue,{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(k,{placeholder:s("form.port.placeholder"),...E})}),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(D,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const P=E.value;P&&y.setValue("server_port",P)},children:e.jsx(Ke,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ue,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:"server_port",render:({field:E})=>e.jsxs(j,{className:"flex-1",children:[e.jsxs(b,{className:"flex items-center gap-1.5",children:[s("form.server_port.label"),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ke,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Ta,{children:e.jsx(ue,{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(k,{placeholder:s("form.server_port.placeholder"),...E})}),e.jsx(R,{})]})})]})]}),a&&e.jsx(Ix,{serverType:u,value:y.watch("protocol_settings"),onChange:E=>y.setValue("protocol_settings",E,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(v,{control:y.control,name:"parent_id",render:({field:E})=>e.jsxs(j,{children:[e.jsx(b,{children:s("form.parent.label")}),e.jsxs(J,{onValueChange:E.onChange,value:E.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:s("form.parent.none")}),C?.map(P=>e.jsx(A,{value:P.id.toString(),className:"cursor-pointer",children:P.name},P.id))]})]}),e.jsx(R,{})]})}),e.jsx(v,{control:y.control,name:"route_ids",render:({field:E})=>e.jsxs(j,{children:[e.jsx(b,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(st,{options:F,onChange:P=>E.onChange(P.map(K=>K.value)),value:F?.filter(P=>E.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(R,{})]})})]}),e.jsxs(Me,{className:"mt-6 flex flex-col gap-2 sm:flex-row sm:gap-0",children:[e.jsx(D,{type:"button",variant:"outline",onClick:p,className:"w-full sm:w-auto",children:s("form.cancel")}),e.jsx(D,{type:"submit",onClick:V,className:"w-full sm:w-auto",children:s("form.submit")})]})]})]})]})}function yr({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(rs,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d: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",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{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}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Lt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Ox=[{value:xe.Shadowsocks,label:Ts.find(s=>s.type===xe.Shadowsocks)?.label,color:bs[xe.Shadowsocks]},{value:xe.Vmess,label:Ts.find(s=>s.type===xe.Vmess)?.label,color:bs[xe.Vmess]},{value:xe.Trojan,label:Ts.find(s=>s.type===xe.Trojan)?.label,color:bs[xe.Trojan]},{value:xe.Hysteria,label:Ts.find(s=>s.type===xe.Hysteria)?.label,color:bs[xe.Hysteria]},{value:xe.Vless,label:Ts.find(s=>s.type===xe.Vless)?.label,color:bs[xe.Vless]},{value:xe.Tuic,label:Ts.find(s=>s.type===xe.Tuic)?.label,color:bs[xe.Tuic]},{value:xe.Socks,label:Ts.find(s=>s.type===xe.Socks)?.label,color:bs[xe.Socks]},{value:xe.Naive,label:Ts.find(s=>s.type===xe.Naive)?.label,color:bs[xe.Naive]},{value:xe.Http,label:Ts.find(s=>s.type===xe.Http)?.label,color:bs[xe.Http]},{value:xe.Mieru,label:Ts.find(s=>s.type===xe.Mieru)?.label,color:bs[xe.Mieru]}];function zx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=M("server");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:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(Mx,{}),e.jsx(k,{placeholder:i("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(yr,{column:s.getColumn("type"),title:i("toolbar.type"),options:Ox}),s.getColumn("group_ids")&&e.jsx(yr,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),t&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const La=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"})}),pa={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"},He=(s,n)=>n>0?Math.round(s/n*100):0,$x=s=>{const{t:n}=M("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(za,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(U,{variant:"outline",className:N("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:bs[t.original.type]},children:[e.jsx(Sl,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:a??r}),t.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:t.original.parent?.code||t.original.parent?.id})]}):""]})]}),e.jsx(D,{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:i=>{i.stopPropagation(),sa(a||r.toString()).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(ir,{className:"size-3"})})]})}),e.jsxs(ue,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ts.find(i=>i.type===t.original.type)?.label,t.original.parent?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=m.useState(!!t.getValue("show"));return e.jsx(X,{checked:r,onCheckedChange:async i=>{a(i),dt.update({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?bs[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:t,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",pa[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",pa[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",pa[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{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",pa[t.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:t.getValue("name")})]})}),e.jsx(ue,{children:e.jsxs("div",{className:" space-y-3",children:[e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)}),t.original.load_status&&e.jsxs("div",{className:"border-t border-border/50 pt-3",children:[e.jsx("p",{className:"mb-3 text-sm font-medium",children:n("columns.loadStatus.details")}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsx("div",{children:e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.cpu"),":"]}),e.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:N("h-full transition-all duration-300",t.original.load_status.cpu>=90?"bg-destructive":t.original.load_status.cpu>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Math.min(100,t.original.load_status.cpu)}%`}})}),e.jsxs("span",{className:N("min-w-[3rem] text-right font-semibold",t.original.load_status.cpu>=90?"text-destructive":t.original.load_status.cpu>=70?"text-yellow-600":"text-emerald-600"),children:[Math.round(t.original.load_status.cpu),"%"]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.memory"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:N("h-full transition-all duration-300",He(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"bg-destructive":He(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${He(t.original.load_status.mem.used,t.original.load_status.mem.total)}%`}})}),e.jsxs("span",{className:N("min-w-[3rem] text-right font-semibold",He(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"text-destructive":He(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"text-yellow-600":"text-emerald-600"),children:[He(t.original.load_status.mem.used,t.original.load_status.mem.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[ze(t.original.load_status.mem.used)," ","/"," ",ze(t.original.load_status.mem.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.swap"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:N("h-full transition-all duration-300",He(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"bg-destructive":He(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"bg-yellow-500":"bg-emerald-500"),style:{width:`${He(t.original.load_status.swap.used,t.original.load_status.swap.total)}%`}})}),e.jsxs("span",{className:N("min-w-[3rem] text-right font-semibold",He(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"text-destructive":He(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"text-yellow-600":"text-emerald-600"),children:[He(t.original.load_status.swap.used,t.original.load_status.swap.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[ze(t.original.load_status.swap.used)," ","/"," ",ze(t.original.load_status.swap.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.disk"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:N("h-full transition-all duration-300",He(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"bg-destructive":He(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${He(t.original.load_status.disk.used,t.original.load_status.disk.total)}%`}})}),e.jsxs("span",{className:N("min-w-[3rem] text-right font-semibold",He(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"text-destructive":He(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"text-yellow-600":"text-emerald-600"),children:[He(t.original.load_status.disk.used,t.original.load_status.disk.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[ze(t.original.load_status.disk.used)," ","/"," ",ze(t.original.load_status.disk.total)]})]})]})]})]})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.address")}),cell:({row:t})=>{const r=`${t.original.host}:${t.original.port}`,a=t.original.port!==t.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:[t.original.host,":",t.original.port]})}),a&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",t.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(be,{delayDuration:0,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(D,{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:i=>{i.stopPropagation(),sa(r).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(ir,{className:"size-3"})})}),e.jsx(ue,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(La,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(U,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:t})=>{const r=t.original.groups||[];return e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[r.map((a,i)=>e.jsx(U,{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.name},i)),r.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})]})},enableSorting:!1,filterFn:(t,r,a)=>{const i=t.getValue(r);return i?a.some(l=>i.includes(l)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(U,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:bs[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:i}=gi();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(zs,{modal:!1,children:[e.jsx(Ks,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Da,{className:"size-4"})})}),e.jsxs(Ms,{align:"end",className:"w-40",children:[e.jsx(Se,{className:"cursor-pointer",onClick:()=>{i(t.original.type),a(t.original),r(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(md,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(Se,{className:"cursor-pointer",onClick:async()=>{dt.copy({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(kl,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(et,{}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(_s,{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()=>{dt.drop({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(us,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Ax(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState({pageSize:500,pageIndex:0}),[u,x]=m.useState([]),[o,c]=m.useState(!1),[f,F]=m.useState({}),[S,w]=m.useState([]),{refetch:T}=ae({queryKey:["nodeList"],queryFn:async()=>{const{data:V}=await dt.getList();return w(V),V}}),{data:y}=ae({queryKey:["groups"],queryFn:async()=>{const{data:V}=await pt.getList();return V}});m.useEffect(()=>{r({"drag-handle":o,show:!o,host:!o,online:!o,rate:!o,groups:!o,type:!1,actions:!o}),F({name:o?2e3:200}),d({pageSize:o?99999:500,pageIndex:0})},[o]);const L=(V,E)=>{o&&(V.dataTransfer.setData("text/plain",E.toString()),V.currentTarget.classList.add("opacity-50"))},C=(V,E)=>{if(!o)return;V.preventDefault(),V.currentTarget.classList.remove("bg-muted");const P=parseInt(V.dataTransfer.getData("text/plain"));if(P===E)return;const K=[...S],[Z]=K.splice(P,1);K.splice(E,0,Z),w(K)},g=async()=>{if(!o){c(!0);return}const V=S?.map((E,P)=>({id:E.id,order:P+1}));dt.sort(V).then(()=>{$.success("排序保存成功"),c(!1),T()}).finally(()=>{c(!1)})},p=Be({data:S||[],columns:$x(T),state:{sorting:u,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:f,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:F,onPaginationChange:d,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(jx,{refetch:T,children:e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:p,toolbar:V=>e.jsx(zx,{table:V,refetch:T,saveOrder:g,isSortMode:o,groups:y||[]}),draggable:o,onDragStart:L,onDragEnd:V=>V.currentTarget.classList.remove("opacity-50"),onDragOver:V=>{V.preventDefault(),V.currentTarget.classList.add("bg-muted")},onDragLeave:V=>V.currentTarget.classList.remove("bg-muted"),onDrop:C,showPagination:!o})})})}function qx(){const{t:s}=M("server");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Ax,{})})]})]})}const Ux=Object.freeze(Object.defineProperty({__proto__:null,default:qx},Symbol.toStringTag,{value:"Module"}));function Hx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=M("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(Za,{refetch:n}),e.jsx(k,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:N("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}const Kx=s=>{const{t:n}=M("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:t.getValue("name")})})},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(La,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Sl,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Za,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(_s,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{pt.drop({id:t.original.id}).then(({data:r})=>{r&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 Bx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),{data:u,refetch:x,isLoading:o}=ae({queryKey:["serverGroupList"],queryFn:async()=>{const{data:f}=await pt.getList();return f}}),c=Be({data:u||[],columns:Kx(x),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:c,toolbar:f=>e.jsx(Hx,{table:f,refetch:x}),isLoading:o})}function Gx(){const{t:s}=M("group");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Bx,{})})]})]})}const Wx=Object.freeze(Object.defineProperty({__proto__:null,default:Gx},Symbol.toStringTag,{value:"Module"})),Yx=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 pi({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="create"}){const{t:a}=M("route"),i=we({resolver:Te(Yx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1);return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(D,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ae,{})]}),e.jsxs(De,{...i,children:[e.jsx(v,{control:i.control,name:"remarks",render:({field:u})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(k,{type:"text",placeholder:a("form.remarksPlaceholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(v,{control:i.control,name:"match",render:({field:u})=>e.jsxs(j,{className:"flex-[2]",children:[e.jsx(b,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(Rs,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:Array.isArray(u.value)?u.value.join(`
+`):"",onChange:f=>{const E=f.target.value.split(`
+`).filter(L=>L.trim()!=="");g.onChange(E)}})})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:d.control,name:"tls.server_name",render:({field:g})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:r("dynamic_form.anytls.tls.server_name.label","SNI")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dynamic_form.anytls.tls.server_name.placeholder","服务器名称"),...g})})]})}),e.jsx(b,{control:d.control,name:"tls.allow_insecure",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dynamic_form.anytls.tls.allow_insecure","允许不安全连接")}),e.jsx("div",{className:"py-2 text-center",children:e.jsx(_,{children:e.jsx(Z,{checked:g.value,onCheckedChange:g.onChange})})})]})})]})]})})};return e.jsx(be,{children:N[s]?.()})};function Mx(){const{t:s}=M("server"),n=h.object({start:h.string().min(1,s("form.dynamic_rate.start_time_error")),end:h.string().min(1,s("form.dynamic_rate.end_time_error")),rate:h.string().min(1,s("form.dynamic_rate.multiplier_error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.dynamic_rate.multiplier_error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.dynamic_rate.multiplier_error_gte_zero")})}),t=h.object({id:h.number().optional().nullable(),specific_key:h.string().optional().nullable(),code:h.string().optional(),show:h.boolean().optional().nullable(),name:h.string().min(1,s("form.name.error")),rate:h.string().min(1,s("form.rate.error")).refine(E=>!isNaN(parseFloat(E))&&isFinite(Number(E)),{message:s("form.rate.error_numeric")}).refine(E=>parseFloat(E)>=0,{message:s("form.rate.error_gte_zero")}),rate_time_enable:h.boolean().default(!1),rate_time_ranges:h.array(n).default([]),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,s("form.host.error")),port:h.string().min(1,s("form.port.error")),server_port:h.string().min(1,s("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()}),r={id:null,specific_key:null,code:"",show:!1,name:"",rate:"1",rate_time_enable:!1,rate_time_ranges:[],tags:[],excludes:[],ips:[],group_ids:[],host:"",port:"",server_port:"",parent_id:"0",route_ids:[],protocol_settings:null},{isOpen:a,setIsOpen:i,editingServer:l,setEditingServer:d,serverType:u,setServerType:x,refetch:o}=pi(),[c,j]=m.useState([]),[P,k]=m.useState([]),[C,T]=m.useState([]),p=we({resolver:Te(t),defaultValues:r,mode:"onChange"});m.useEffect(()=>{S()},[a]),m.useEffect(()=>{l?.type&&l.type!==u&&x(l.type)},[l,u,x]),m.useEffect(()=>{l?l.type===u&&p.reset({...r,...l}):p.reset({...r,protocol_settings:Oe[u].schema.parse({})})},[l,p,u]);const S=async()=>{if(!a)return;const[E,L,K]=await Promise.all([pt.getList(),qa.getList(),dt.getList()]);j(E.data?.map(X=>({label:X.name,value:X.id.toString()}))||[]),k(L.data?.map(X=>({label:X.remarks,value:X.id.toString()}))||[]),T(K.data||[])},N=m.useMemo(()=>C?.filter(E=>(E.parent_id===0||E.parent_id===null)&&E.type===u&&E.id!==p.watch("id")),[u,C,p]),g=()=>e.jsxs(zs,{children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(F,{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(Ms,{align:"start",children:e.jsx(cm,{children:Ts.map(({type:E,label:L})=>e.jsx(Se,{onClick:()=>{x(E),i(!0)},className:"cursor-pointer",children:e.jsx(U,{variant:"outline",className:"text-white",style:{background:bs[E]},children:L})},E))})})]}),f=()=>{i(!1),d(null),p.reset(r)},V=async()=>{const E=p.getValues();(await dt.save({...E,type:u})).data&&(f(),$.success(s("form.success")),o())};return e.jsxs(de,{open:a,onOpenChange:f,children:[g(),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:s(l?"form.edit_node":"form.new_node")}),e.jsx(Ae,{})]}),e.jsxs(De,{...p,children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{control:p.control,name:"name",render:({field:E})=>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"),...E})}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:"rate",render:({field:E})=>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",...E})})}),e.jsx(R,{})]})})]}),e.jsx(b,{control:p.control,name:"rate_time_enable",render:({field:E})=>e.jsxs(v,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(y,{children:s("form.dynamic_rate.enable_label")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("form.dynamic_rate.enable_description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:E.value,onCheckedChange:E.onChange})})]}),e.jsx(R,{})]})}),p.watch("rate_time_enable")&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{className:"",children:s("form.dynamic_rate.rules_label")}),e.jsxs(F,{type:"button",variant:"outline",size:"sm",onClick:()=>{const E=p.getValues("rate_time_ranges")||[];p.setValue("rate_time_ranges",[...E,{start:"00:00",end:"23:59",rate:"1"}])},children:[e.jsx(Ke,{icon:"ion:add",className:"mr-1 size-4"}),s("form.dynamic_rate.add_rule")]})]}),(p.watch("rate_time_ranges")||[]).map((E,L)=>e.jsxs("div",{className:"space-y-2 rounded border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:s("form.dynamic_rate.rule_title",{index:L+1})}),e.jsx(F,{type:"button",variant:"ghost",size:"sm",onClick:()=>{const K=p.getValues("rate_time_ranges")||[];K.splice(L,1),p.setValue("rate_time_ranges",[...K])},children:e.jsx(Ke,{icon:"ion:trash-outline",className:"size-4"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(b,{control:p.control,name:`rate_time_ranges.${L}.start`,render:({field:K})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-xs",children:s("form.dynamic_rate.start_time")}),e.jsx(_,{children:e.jsx(D,{type:"time",...K,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:`rate_time_ranges.${L}.end`,render:({field:K})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-xs",children:s("form.dynamic_rate.end_time")}),e.jsx(_,{children:e.jsx(D,{type:"time",...K,className:"text-sm"})}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:`rate_time_ranges.${L}.rate`,render:({field:K})=>e.jsxs(v,{children:[e.jsx(y,{className:"text-xs",children:s("form.dynamic_rate.multiplier")}),e.jsx(_,{children:e.jsx(D,{type:"number",min:"0",step:"0.1",...K,className:"text-sm",placeholder:"1.0"})}),e.jsx(R,{})]})})]})]},L)),(p.watch("rate_time_ranges")||[]).length===0&&e.jsx("div",{className:"py-4 text-center text-sm text-muted-foreground",children:s("form.dynamic_rate.no_rules")})]}),e.jsx(b,{control:p.control,name:"code",render:({field:E})=>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"),...E,value:E.value||""})}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:"tags",render:({field:E})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.tags.label")}),e.jsx(_,{children:e.jsx(Xa,{value:E.value,onChange:E.onChange,placeholder:s("form.tags.placeholder"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:"group_ids",render:({field:E})=>e.jsxs(v,{children:[e.jsxs(y,{className:"flex items-center justify-between",children:[s("form.groups.label"),e.jsx(Za,{dialogTrigger:e.jsx(F,{variant:"link",children:s("form.groups.add")}),refetch:S})]}),e.jsx(_,{children:e.jsx(st,{options:c,onChange:L=>E.onChange(L.map(K=>K.value)),value:c?.filter(L=>E.value.includes(L.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(R,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:p.control,name:"host",render:({field:E})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.host.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:s("form.host.placeholder"),...E})}),e.jsx(R,{})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{control:p.control,name:"port",render:({field:E})=>e.jsxs(v,{className:"flex-1",children:[e.jsxs(y,{className:"flex items-center gap-1.5",children:[s("form.port.label"),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ke,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Ta,{children:e.jsx(ue,{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"),...E})}),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(F,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>{const L=E.value;L&&p.setValue("server_port",L)},children:e.jsx(Ke,{icon:"tabler:arrows-right",className:"size-3"})})}),e.jsx(ue,{side:"right",children:e.jsx("p",{children:s("form.port.sync")})})]})})]}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:"server_port",render:({field:E})=>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(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(Ke,{icon:"ph:info-light",className:"size-3.5 cursor-help text-muted-foreground"})}),e.jsx(Ta,{children:e.jsx(ue,{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"),...E})}),e.jsx(R,{})]})})]})]}),a&&e.jsx(Ix,{serverType:u,value:p.watch("protocol_settings"),onChange:E=>p.setValue("protocol_settings",E,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})}),e.jsx(b,{control:p.control,name:"parent_id",render:({field:E})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.parent.label")}),e.jsxs(J,{onValueChange:E.onChange,value:E.value?.toString()||"0",children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:s("form.parent.placeholder")})})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:s("form.parent.none")}),N?.map(L=>e.jsx(A,{value:L.id.toString(),className:"cursor-pointer",children:L.name},L.id))]})]}),e.jsx(R,{})]})}),e.jsx(b,{control:p.control,name:"route_ids",render:({field:E})=>e.jsxs(v,{children:[e.jsx(y,{children:s("form.route.label")}),e.jsx(_,{children:e.jsx(st,{options:P,onChange:L=>E.onChange(L.map(K=>K.value)),value:P?.filter(L=>E.value.includes(L.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(R,{})]})})]}),e.jsxs(Me,{className:"mt-6 flex flex-col gap-2 sm:flex-row sm:gap-0",children:[e.jsx(F,{type:"button",variant:"outline",onClick:f,className:"w-full sm:w-auto",children:s("form.cancel")}),e.jsx(F,{type:"submit",onClick:V,className:"w-full sm:w-auto",children:s("form.submit")})]})]})]})]})}function _r({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(rs,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},className:"cursor-pointer",children:[e.jsx("div",{className:w("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{className:w("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}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Rt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center cursor-pointer",children:"Clear filters"})})]})]})]})})]})}const Ox=[{value:xe.Shadowsocks,label:Ts.find(s=>s.type===xe.Shadowsocks)?.label,color:bs[xe.Shadowsocks]},{value:xe.Vmess,label:Ts.find(s=>s.type===xe.Vmess)?.label,color:bs[xe.Vmess]},{value:xe.Trojan,label:Ts.find(s=>s.type===xe.Trojan)?.label,color:bs[xe.Trojan]},{value:xe.Hysteria,label:Ts.find(s=>s.type===xe.Hysteria)?.label,color:bs[xe.Hysteria]},{value:xe.Vless,label:Ts.find(s=>s.type===xe.Vless)?.label,color:bs[xe.Vless]},{value:xe.Tuic,label:Ts.find(s=>s.type===xe.Tuic)?.label,color:bs[xe.Tuic]},{value:xe.Socks,label:Ts.find(s=>s.type===xe.Socks)?.label,color:bs[xe.Socks]},{value:xe.Naive,label:Ts.find(s=>s.type===xe.Naive)?.label,color:bs[xe.Naive]},{value:xe.Http,label:Ts.find(s=>s.type===xe.Http)?.label,color:bs[xe.Http]},{value:xe.Mieru,label:Ts.find(s=>s.type===xe.Mieru)?.label,color:bs[xe.Mieru]}];function zx({table:s,saveOrder:n,isSortMode:t,groups:r}){const a=s.getState().columnFilters.length>0,{t:i}=M("server");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:[!t&&e.jsxs(e.Fragment,{children:[e.jsx(Mx,{}),e.jsx(D,{placeholder:i("toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:l=>s.getColumn("name")?.setFilterValue(l.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs("div",{className:"flex gap-x-2",children:[s.getColumn("type")&&e.jsx(_r,{column:s.getColumn("type"),title:i("toolbar.type"),options:Ox}),s.getColumn("group_ids")&&e.jsx(_r,{column:s.getColumn("group_ids"),title:i("columns.groups.title"),options:r.map(l=>({label:l.name,value:l.id.toString()}))})]}),a&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[i("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),t&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:i("toolbar.sort.tip")})})]}),s.getRowCount()>0&&e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(F,{variant:t?"default":"outline",onClick:n,size:"sm",children:i(t?"toolbar.sort.save":"toolbar.sort.edit")})})]})}const Ra=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"})}),pa={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"},Ue=(s,n)=>n>0?Math.round(s/n*100):0,$x=s=>{const{t:n}=M("server");return[{id:"drag-handle",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.sort")}),cell:()=>e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(za,{className:"size-4 cursor-move text-muted-foreground transition-colors hover:text-primary","aria-hidden":"true"})}),size:50},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.nodeId")}),cell:({row:t})=>{const r=t.getValue("id"),a=t.original.code;return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"group/id flex items-center space-x-2",children:[e.jsxs(U,{variant:"outline",className:w("border-2 font-medium transition-all duration-200 hover:opacity-80","flex items-center gap-1.5"),style:{borderColor:bs[t.original.type]},children:[e.jsx(kl,{className:"size-3"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"flex items-center gap-0.5",children:a??r}),t.original.parent?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm text-muted-foreground/30",children:"→"}),e.jsx("span",{children:t.original.parent?.code||t.original.parent?.id})]}):""]})]}),e.jsx(F,{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:i=>{i.stopPropagation(),sa(a||r.toString()).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(or,{className:"size-3"})})]})}),e.jsxs(ue,{side:"top",className:"flex flex-col gap-1 p-3",children:[e.jsxs("p",{className:"font-medium",children:[Ts.find(i=>i.type===t.original.type)?.label,t.original.parent?" (子节点)":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a?"点击括号内容或复制按钮可复制节点代码":"点击复制按钮可复制节点ID"})]})]})})},size:50,enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.show")}),cell:({row:t})=>{const[r,a]=m.useState(!!t.getValue("show"));return e.jsx(Z,{checked:r,onCheckedChange:async i=>{a(i),dt.update({id:t.original.id,type:t.original.type,show:i?1:0}).catch(()=>{a(!i),s()})},style:{backgroundColor:r?bs[t.original.type]:void 0}})},size:50,enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx(O,{column:t,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:w("h-2.5 w-2.5 rounded-full",pa[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:w("h-2.5 w-2.5 rounded-full",pa[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:w("h-2.5 w-2.5 rounded-full",pa[2])}),e.jsx("span",{className:"text-sm font-medium",children:n("columns.status.2")})]})]})})}),cell:({row:t})=>e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center space-x-2.5",children:[e.jsx("span",{className:w("size-2.5 flex-shrink-0 rounded-full transition-all duration-200",pa[t.original.available_status])}),e.jsx("span",{className:"text-left font-medium transition-colors hover:text-primary",children:t.getValue("name")})]})}),e.jsx(ue,{children:e.jsxs("div",{className:" space-y-3",children:[e.jsx("p",{className:"font-medium",children:n(`columns.status.${t.original.available_status}`)}),t.original.load_status&&e.jsxs("div",{className:"border-t border-border/50 pt-3",children:[e.jsx("p",{className:"mb-3 text-sm font-medium",children:n("columns.loadStatus.details")}),e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsx("div",{children:e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.cpu"),":"]}),e.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:w("h-full transition-all duration-300",t.original.load_status.cpu>=90?"bg-destructive":t.original.load_status.cpu>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Math.min(100,t.original.load_status.cpu)}%`}})}),e.jsxs("span",{className:w("min-w-[3rem] text-right font-semibold",t.original.load_status.cpu>=90?"text-destructive":t.original.load_status.cpu>=70?"text-yellow-600":"text-emerald-600"),children:[Math.round(t.original.load_status.cpu),"%"]})]})]})}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.memory"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:w("h-full transition-all duration-300",Ue(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"bg-destructive":Ue(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Ue(t.original.load_status.mem.used,t.original.load_status.mem.total)}%`}})}),e.jsxs("span",{className:w("min-w-[3rem] text-right font-semibold",Ue(t.original.load_status.mem.used,t.original.load_status.mem.total)>=90?"text-destructive":Ue(t.original.load_status.mem.used,t.original.load_status.mem.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Ue(t.original.load_status.mem.used,t.original.load_status.mem.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[ze(t.original.load_status.mem.used)," ","/"," ",ze(t.original.load_status.mem.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.swap"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:w("h-full transition-all duration-300",Ue(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"bg-destructive":Ue(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Ue(t.original.load_status.swap.used,t.original.load_status.swap.total)}%`}})}),e.jsxs("span",{className:w("min-w-[3rem] text-right font-semibold",Ue(t.original.load_status.swap.used,t.original.load_status.swap.total)>=80?"text-destructive":Ue(t.original.load_status.swap.used,t.original.load_status.swap.total)>=50?"text-yellow-600":"text-emerald-600"),children:[Ue(t.original.load_status.swap.used,t.original.load_status.swap.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[ze(t.original.load_status.swap.used)," ","/"," ",ze(t.original.load_status.swap.total)]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium",children:[n("columns.loadStatus.disk"),":"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2 w-20 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:w("h-full transition-all duration-300",Ue(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"bg-destructive":Ue(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"bg-yellow-500":"bg-emerald-500"),style:{width:`${Ue(t.original.load_status.disk.used,t.original.load_status.disk.total)}%`}})}),e.jsxs("span",{className:w("min-w-[3rem] text-right font-semibold",Ue(t.original.load_status.disk.used,t.original.load_status.disk.total)>=90?"text-destructive":Ue(t.original.load_status.disk.used,t.original.load_status.disk.total)>=70?"text-yellow-600":"text-emerald-600"),children:[Ue(t.original.load_status.disk.used,t.original.load_status.disk.total),"%"]})]})]}),e.jsxs("div",{className:"ml-auto w-[9.5rem] text-right text-xs text-muted-foreground",children:[ze(t.original.load_status.disk.used)," ","/"," ",ze(t.original.load_status.disk.total)]})]})]})]})]})})]})}),enableSorting:!1,size:200},{accessorKey:"host",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.address")}),cell:({row:t})=>{const r=`${t.original.host}:${t.original.port}`,a=t.original.port!==t.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:[t.original.host,":",t.original.port]})}),a&&e.jsxs("span",{className:"whitespace-nowrap text-[0.7rem] tracking-tight text-muted-foreground/40",children:["(",n("columns.internalPort")," ",t.original.server_port,")"]})]}),e.jsx("div",{className:"absolute right-0 top-0",children:e.jsx(be,{delayDuration:0,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(F,{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:i=>{i.stopPropagation(),sa(r).then(()=>{$.success(n("common:copy.success"))})},children:e.jsx(or,{className:"size-3"})})}),e.jsx(ue,{side:"top",sideOffset:10,children:n("columns.copyAddress")})]})})})]})},enableSorting:!1,enableHiding:!0},{accessorKey:"online",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.onlineUsers.title"),tooltip:n("columns.onlineUsers.tooltip")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Ra,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("online")})]}),size:80,enableSorting:!0,enableHiding:!0},{accessorKey:"rate",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.rate.title"),tooltip:n("columns.rate.tooltip")}),cell:({row:t})=>e.jsxs(U,{variant:"secondary",className:"font-medium",children:[t.getValue("rate")," x"]}),size:80,enableSorting:!1,enableHiding:!0},{accessorKey:"group_ids",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.groups.title"),tooltip:n("columns.groups.tooltip")}),cell:({row:t})=>{const r=t.original.groups||[];return e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[r.map((a,i)=>e.jsx(U,{variant:"secondary",className:w("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.name},i)),r.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:n("columns.groups.empty")})]})},enableSorting:!1,filterFn:(t,r,a)=>{const i=t.getValue(r);return i?a.some(l=>i.includes(l)):!1}},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.type")}),cell:({row:t})=>{const r=t.getValue("type");return e.jsx(U,{variant:"outline",className:"border-2 font-medium transition-colors",style:{borderColor:bs[r]},children:r})},enableSorting:!1,enableHiding:!0,enableColumnFilter:!1,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingServer:a,setServerType:i}=pi();return e.jsx("div",{className:"flex justify-center",children:e.jsxs(zs,{modal:!1,children:[e.jsx(Ks,{asChild:!0,children:e.jsx(F,{variant:"ghost",className:"h-8 w-8 p-0 hover:bg-muted","aria-label":n("columns.actions"),children:e.jsx(Da,{className:"size-4"})})}),e.jsxs(Ms,{align:"end",className:"w-40",children:[e.jsx(Se,{className:"cursor-pointer",onClick:()=>{i(t.original.type),a(t.original),r(!0)},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(md,{className:"mr-2 size-4"}),n("columns.actions_dropdown.edit")]})}),e.jsxs(Se,{className:"cursor-pointer",onClick:async()=>{dt.copy({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.copy_success")),s())})},children:[e.jsx(Tl,{className:"mr-2 size-4"}),n("columns.actions_dropdown.copy")]}),e.jsx(et,{}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onSelect:l=>l.preventDefault(),children:e.jsx(_s,{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()=>{dt.drop({id:t.original.id}).then(({data:l})=>{l&&($.success(n("columns.actions_dropdown.delete_success")),s())})},children:e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx(us,{className:"mr-2 size-4"}),n("columns.actions_dropdown.delete.confirm")]})})})]})]})})},size:50}]};function Ax(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState({pageSize:500,pageIndex:0}),[u,x]=m.useState([]),[o,c]=m.useState(!1),[j,P]=m.useState({}),[k,C]=m.useState([]),{refetch:T}=ne({queryKey:["nodeList"],queryFn:async()=>{const{data:V}=await dt.getList();return C(V),V}}),{data:p}=ne({queryKey:["groups"],queryFn:async()=>{const{data:V}=await pt.getList();return V}});m.useEffect(()=>{r({"drag-handle":o,show:!o,host:!o,online:!o,rate:!o,groups:!o,type:!1,actions:!o}),P({name:o?2e3:200}),d({pageSize:o?99999:500,pageIndex:0})},[o]);const S=(V,E)=>{o&&(V.dataTransfer.setData("text/plain",E.toString()),V.currentTarget.classList.add("opacity-50"))},N=(V,E)=>{if(!o)return;V.preventDefault(),V.currentTarget.classList.remove("bg-muted");const L=parseInt(V.dataTransfer.getData("text/plain"));if(L===E)return;const K=[...k],[X]=K.splice(L,1);K.splice(E,0,X),C(K)},g=async()=>{if(!o){c(!0);return}const V=k?.map((E,L)=>({id:E.id,order:L+1}));dt.sort(V).then(()=>{$.success("排序保存成功"),c(!1),T()}).finally(()=>{c(!1)})},f=Be({data:k||[],columns:$x(T),state:{sorting:u,columnVisibility:t,rowSelection:s,columnFilters:a,columnSizing:j,pagination:l},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:x,onColumnFiltersChange:i,onColumnVisibilityChange:r,onColumnSizingChange:P,onPaginationChange:d,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(jx,{refetch:T,children:e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:f,toolbar:V=>e.jsx(zx,{table:V,refetch:T,saveOrder:g,isSortMode:o,groups:p||[]}),draggable:o,onDragStart:S,onDragEnd:V=>V.currentTarget.classList.remove("opacity-50"),onDragOver:V=>{V.preventDefault(),V.currentTarget.classList.add("bg-muted")},onDragLeave:V=>V.currentTarget.classList.remove("bg-muted"),onDrop:N,showPagination:!o})})})}function qx(){const{t:s}=M("server");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Ax,{})})]})]})}const Hx=Object.freeze(Object.defineProperty({__proto__:null,default:qx},Symbol.toStringTag,{value:"Module"}));function Ux({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=M("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(Za,{refetch:n}),e.jsx(D,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:w("h-8 w-[150px] lg:w-[250px]",t&&"border-primary/50 ring-primary/20")}),t&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}const Kx=s=>{const{t:n}=M("group");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex space-x-2",children:e.jsx("span",{className:"max-w-32 truncate font-medium",children:t.getValue("name")})})},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.usersCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(Ra,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("users_count")})]}),enableSorting:!0},{accessorKey:"server_count",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.serverCount")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 px-4",children:[e.jsx(kl,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:t.getValue("server_count")})]}),enableSorting:!0,size:8e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(Za,{defaultValues:t.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(_s,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{pt.drop({id:t.original.id}).then(({data:r})=>{r&&($.success(n("messages.updateSuccess")),s())})},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 Bx(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),{data:u,refetch:x,isLoading:o}=ne({queryKey:["serverGroupList"],queryFn:async()=>{const{data:j}=await pt.getList();return j}}),c=Be({data:u||[],columns:Kx(x),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a},enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:c,toolbar:j=>e.jsx(Ux,{table:j,refetch:x}),isLoading:o})}function Gx(){const{t:s}=M("group");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Bx,{})})]})]})}const Yx=Object.freeze(Object.defineProperty({__proto__:null,default:Gx},Symbol.toStringTag,{value:"Module"})),Wx=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 fi({refetch:s,dialogTrigger:n,defaultValues:t={remarks:"",match:[],action:"block",action_value:""},type:r="create"}){const{t:a}=M("route"),i=we({resolver:Te(Wx(a)),defaultValues:t,mode:"onChange"}),[l,d]=m.useState(!1);return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(F,{variant:"outline",size:"sm",className:"space-x-2",children:[e.jsx(Ke,{icon:"ion:add"})," ",e.jsx("div",{children:a("form.add")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:a(r==="edit"?"form.edit":"form.create")}),e.jsx(Ae,{})]}),e.jsxs(De,{...i,children:[e.jsx(b,{control:i.control,name:"remarks",render:({field:u})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:a("form.remarks")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:a("form.remarksPlaceholder"),...u})})}),e.jsx(R,{})]})}),e.jsx(b,{control:i.control,name:"match",render:({field:u})=>e.jsxs(v,{className:"flex-[2]",children:[e.jsx(y,{children:a("form.match")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(Fs,{className:"min-h-[120px]",placeholder:a("form.matchPlaceholder"),value:Array.isArray(u.value)?u.value.join(`
`):"",onChange:x=>{const o=x.target.value.split(`
-`);u.onChange(o)}})})}),e.jsx(R,{})]})}),e.jsx(v,{control:i.control,name:"action",render:({field:u})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsxs(J,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"block",children:a("actions.block")}),e.jsx(A,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(R,{})]})}),i.watch("action")==="dns"&&e.jsx(v,{control:i.control,name:"action_value",render:({field:u})=>e.jsxs(j,{children:[e.jsx(b,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(k,{type:"text",placeholder:a("form.dnsPlaceholder"),...u})})})]})}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(D,{variant:"outline",children:a("form.cancel")})}),e.jsx(D,{type:"submit",onClick:()=>{const u=i.getValues(),x={...u,match:Array.isArray(u.match)?u.match.filter(o=>o.trim()!==""):[]};qa.save(x).then(({data:o})=>{o&&(d(!1),s&&s(),$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function Jx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=M("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(pi,{refetch:n}),e.jsx(k,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:a=>s.getColumn("remarks")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),t&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}function Qx({columns:s,data:n,refetch:t}){const[r,a]=m.useState({}),[i,l]=m.useState({}),[d,u]=m.useState([]),[x,o]=m.useState([]),c=Be({data:n,columns:s,state:{sorting:x,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:o,onColumnFiltersChange:u,onColumnVisibilityChange:l,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:c,toolbar:f=>e.jsx(Jx,{table:f,refetch:t})})}const Xx=s=>{const{t:n}=M("route"),t={block:{icon:ud,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:xd,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:r})=>e.jsx(O,{column:r,title:n("columns.id")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:r.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.remarks")}),cell:({row:r})=>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:r.original.remarks})}),enableHiding:!1,enableSorting:!1},{accessorKey:"action_value",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action_value.title")}),cell:({row:r})=>{const a=r.original.action,i=r.original.action_value,l=r.original.match?.length||0;return e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("span",{className:"text-sm font-medium",children:a==="dns"&&i?n("columns.action_value.dns",{value:i}):a==="block"?e.jsx("span",{className:"text-destructive",children:n("columns.action_value.block")}):n("columns.action_value.direct")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("columns.matchRules",{count:l})})]})},enableHiding:!1,enableSorting:!1,size:300},{accessorKey:"action",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action")}),cell:({row:r})=>{const a=r.getValue("action"),i=t[a]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(U,{variant:t[a]?.variant||"default",className:N("flex items-center gap-1.5 px-3 py-1 capitalize",t[a]?.className),children:[i&&e.jsx(i,{className:"h-3.5 w-3.5"}),n(`actions.${a}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(pi,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(_s,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{qa.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 Zx(){const{t:s}=M("route"),[n,t]=m.useState([]);function r(){qa.getList().then(({data:a})=>{t(a)})}return m.useEffect(()=>{r()},[]),e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Qx,{data:n,columns:Xx(r),refetch:r})})]})]})}const eh=Object.freeze(Object.defineProperty({__proto__:null,default:Zx},Symbol.toStringTag,{value:"Module"})),fi=m.createContext(void 0);function sh({children:s,refreshData:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null);return e.jsx(fi.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function Kn(){const s=m.useContext(fi);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function th({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=Kn(),{t:a}=M("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(D,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:a("plan.add")})]}),e.jsx(k,{placeholder:a("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:i=>s.getColumn("name")?.setFilterValue(i.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(D,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const _r={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"}},ah=s=>{const{t:n}=M("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(za,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.show")}),cell:({row:t})=>e.jsx(X,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{ys.update({id:t.original.id,show:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.sell")}),cell:({row:t})=>e.jsx(X,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{ys.update({id:t.original.id,sell:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:t})=>e.jsx(X,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{ys.update({id:t.original.id,renew:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.name")}),cell:({row:t})=>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:t.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.stats")}),cell:({row:t})=>{const r=t.getValue("users_count")||0,a=t.original.active_users_count||0,i=r>0?Math.round(a/r*100):0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-slate-50 px-2 py-1 hover:bg-slate-100 transition-colors cursor-help",children:[e.jsx(wa,{className:"h-3.5 w-3.5 text-slate-500"}),e.jsx("span",{className:"text-sm font-medium text-slate-700",children:r})]})}),e.jsx(ue,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"总用户数"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"所有使用该套餐的用户(包括已过期)"})]})})]})}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-green-50 px-2 py-1 hover:bg-green-100 transition-colors cursor-help",children:[e.jsx(hd,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:a})]})}),e.jsx(ue,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"有效期内用户"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"当前仍在有效期内的活跃用户"}),r>0&&e.jsxs("p",{className:"text-xs font-medium text-green-600",children:["活跃率:",i,"%"]})]})})]})})]})},enableSorting:!0,size:120},{accessorKey:"group",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.group")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(U,{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:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.price")}),cell:({row:t})=>{const r=t.getValue("prices"),a=[{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:a.map(({period:i,key:l,unit:d})=>r[l]!=null&&e.jsxs(U,{variant:"secondary",className:N("px-2 py-0.5 font-medium transition-colors text-nowrap",_r[l].color,_r[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=Kn();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(_s,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{ys.drop({id:t.original.id}).then(({data:i})=>{i&&($.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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")})]})})]})}}]},nh=h.object({id:h.number().nullable(),group_id:h.union([h.number(),h.string()]).nullable().optional(),name:h.string().min(1).max(250),tags:h.array(h.string()).nullable().optional(),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(),active_users_count:h.number().optional()}),Bn=m.forwardRef(({className:s,...n},t)=>e.jsx(Tl,{ref:t,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(gd,{className:N("flex items-center justify-center text-current"),children:e.jsx(ht,{className:"h-4 w-4"})})}));Bn.displayName=Tl.displayName;const fa={id:null,group_id:null,name:"",tags:[],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},ja={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}},rh=[{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 lh(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=Kn(),[i,l]=m.useState(!1),{t:d}=M("subscribe"),u=we({resolver:Te(nh),defaultValues:{...fa,...t||{}},mode:"onChange"});m.useEffect(()=>{t?u.reset({...fa,...t}):u.reset(fa)},[t,u]);const x=new In({html:!0}),[o,c]=m.useState();async function f(){pt.getList().then(({data:y})=>{c(y)})}m.useEffect(()=>{s&&f()},[s]);const F=async y=>{l(!0),ys.save(y).then(({data:L})=>{L&&($.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),T(),a())}).finally(()=>{l(!1)})},S=y=>{const L=Object.values(y).map(C=>C?.message).filter(Boolean);$.error(L.join(`
-`)||d("plan.form.submit.error.validation","表单校验失败"))},w=y=>{if(isNaN(y))return;const L=Object.entries(ja).reduce((C,[g,p])=>{const V=y*p.months*p.discount;return{...C,[g]:V.toFixed(2)}},{});u.setValue("prices",L,{shouldDirty:!0})},T=()=>{n(!1),r(null),u.reset(fa)};return e.jsx(de,{open:s,onOpenChange:T,children:e.jsxs(ce,{children:[e.jsxs(he,{children:[e.jsx(me,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ae,{})]}),e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(F,S),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"name",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:d("plan.form.name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:d("plan.form.name.placeholder"),...y})}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"tags",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:d("plan.form.tags.label","标签")}),e.jsx(_,{children:e.jsx(Xa,{value:y.value||[],onChange:y.onChange,placeholder:d("plan.form.tags.placeholder","输入标签后按回车确认"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"group_id",render:({field:y})=>e.jsxs(j,{children:[e.jsxs(b,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(Za,{dialogTrigger:e.jsx(D,{variant:"link",children:d("plan.form.group.add")}),refetch:f})]}),e.jsxs(J,{value:y.value?.toString()??"",onValueChange:L=>y.onChange(L?Number(L):null),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(Y,{children:o?.map(L=>e.jsx(A,{value:L.id.toString(),children:L.name},L.id))})]}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"transfer_enable",render:({field:y})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(k,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...y})}),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:d("plan.form.transfer.unit")})]}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"speed_limit",render:({field:y})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(k,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...y,value:y.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:d("plan.form.speed.unit")})]}),e.jsx(R,{})]})}),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:d("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(k,{type:"number",step:"0.01",placeholder:d("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:y=>{const L=parseFloat(y.target.value);w(L)}})]}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const y=Object.keys(ja).reduce((L,C)=>({...L,[C]:""}),{});u.setValue("prices",y,{shouldDirty:!0})},children:d("plan.form.price.clear.button")})}),e.jsx(ue,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:d("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(ja).filter(([y])=>!["onetime","reset_traffic"].includes(y)).map(([y,L])=>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(v,{control:u.control,name:`prices.${y}`,render:({field:C})=>e.jsxs(j,{children:[e.jsxs(b,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${y}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",L.months===1?d("plan.form.price.period.monthly"):d("plan.form.price.period.months",{count:L.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(k,{type:"number",placeholder:"0.00",min:0,step:"0.01",...C,value:C.value??"",onChange:g=>C.onChange(g.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"})})]})]})})},y))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(ja).filter(([y])=>["onetime","reset_traffic"].includes(y)).map(([y,L])=>e.jsx("div",{className:"rounded-md border border-dashed border-gray-200 bg-muted/30 p-3 dark:border-gray-700",children:e.jsx(v,{control:u.control,name:`prices.${y}`,render:({field:C})=>e.jsx(j,{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(b,{className:"text-xs font-medium",children:d(`plan.columns.price_period.${y}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(y==="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(k,{type:"number",placeholder:"0.00",min:0,step:"0.01",...C,value:C.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"})})]})]})})})},y))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(v,{control:u.control,name:"device_limit",render:({field:y})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(k,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...y,value:y.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:d("plan.form.device.unit")})]}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"capacity_limit",render:({field:y})=>e.jsxs(j,{className:"flex-1",children:[e.jsx(b,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(k,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...y,value:y.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:d("plan.form.capacity.unit")})]}),e.jsx(R,{})]})})]}),e.jsx(v,{control:u.control,name:"reset_traffic_method",render:({field:y})=>e.jsxs(j,{children:[e.jsx(b,{children:d("plan.form.reset_method.label")}),e.jsxs(J,{value:y.value?.toString()??"null",onValueChange:L=>y.onChange(L=="null"?null:Number(L)),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(Y,{children:rh.map(L=>e.jsx(A,{value:L.value?.toString()??"null",children:d(`plan.form.reset_method.options.${L.label}`)},L.value))})]}),e.jsx(z,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"content",render:({field:y})=>{const[L,C]=m.useState(!1);return e.jsxs(j,{className:"space-y-2",children:[e.jsxs(b,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d("plan.form.content.label"),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>C(!L),children:L?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(ue,{side:"top",children:e.jsx("p",{className:"text-xs",children:d(L?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",onClick:()=>{y.onChange(d("plan.form.content.template.content"))},children:d("plan.form.content.template.button")})}),e.jsx(ue,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:d("plan.form.content.template.tooltip")})})]})})]}),e.jsxs("div",{className:`grid gap-4 ${L?"grid-cols-1 lg:grid-cols-2":"grid-cols-1"}`,children:[e.jsx("div",{className:"space-y-2",children:e.jsx(_,{children:e.jsx(Mn,{style:{height:"400px"},value:y.value||"",renderHTML:g=>x.render(g),onChange:({text:g})=>y.onChange(g),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:d("plan.form.content.placeholder"),className:"rounded-md border"})})}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:d("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:x.render(y.value||"")}})})]})]}),e.jsx(z,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(R,{})]})}})]}),e.jsx(Me,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:t&&e.jsx(v,{control:u.control,name:"force_update",render:({field:y})=>e.jsxs(j,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Bn,{checked:y.value,onCheckedChange:y.onChange})}),e.jsx("div",{className:"",children:e.jsx(b,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(D,{type:"button",variant:"outline",onClick:T,children:d("plan.form.submit.cancel")}),e.jsx(D,{type:"submit",disabled:i,children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})})]})})}function ih(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState(!1),[o,c]=m.useState({pageSize:20,pageIndex:0}),[f,F]=m.useState([]),{refetch:S}=ae({queryKey:["planList"],queryFn:async()=>{const{data:C}=await ys.getList();return F(C),C}});m.useEffect(()=>{r({"drag-handle":u}),c({pageSize:u?99999:10,pageIndex:0})},[u]);const w=(C,g)=>{u&&(C.dataTransfer.setData("text/plain",g.toString()),C.currentTarget.classList.add("opacity-50"))},T=(C,g)=>{if(!u)return;C.preventDefault(),C.currentTarget.classList.remove("bg-muted");const p=parseInt(C.dataTransfer.getData("text/plain"));if(p===g)return;const V=[...f],[E]=V.splice(p,1);V.splice(g,0,E),F(V)},y=async()=>{if(!u){x(!0);return}const C=f?.map(g=>g.id);ys.sort(C).then(()=>{$.success("排序保存成功"),x(!1),S()}).finally(()=>{x(!1)})},L=Be({data:f||[],columns:ah(S),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:o},enableRowSelection:!0,onPaginationChange:c,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}},pageCount:u?1:void 0});return e.jsx(sh,{refreshData:S,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ts,{table:L,toolbar:C=>e.jsx(th,{table:C,refetch:S,saveOrder:y,isSortMode:u}),draggable:u,onDragStart:w,onDragEnd:C=>C.currentTarget.classList.remove("opacity-50"),onDragOver:C=>{C.preventDefault(),C.currentTarget.classList.add("bg-muted")},onDragLeave:C=>C.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!u}),e.jsx(lh,{})]})})}function oh(){const{t:s}=M("subscribe");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(ih,{})})]})]})}const ch=Object.freeze(Object.defineProperty({__proto__:null,default:oh},Symbol.toStringTag,{value:"Module"})),Ct=[{value:le.PENDING,label:zt[le.PENDING],icon:pd,color:$t[le.PENDING]},{value:le.PROCESSING,label:zt[le.PROCESSING],icon:Dl,color:$t[le.PROCESSING]},{value:le.COMPLETED,label:zt[le.COMPLETED],icon:wn,color:$t[le.COMPLETED]},{value:le.CANCELLED,label:zt[le.CANCELLED],icon:Fl,color:$t[le.CANCELLED]},{value:le.DISCOUNTED,label:zt[le.DISCOUNTED],icon:wn,color:$t[le.DISCOUNTED]}],Ht=[{value:Ce.PENDING,label:xa[Ce.PENDING],icon:fd,color:ha[Ce.PENDING]},{value:Ce.PROCESSING,label:xa[Ce.PROCESSING],icon:Dl,color:ha[Ce.PROCESSING]},{value:Ce.VALID,label:xa[Ce.VALID],icon:wn,color:ha[Ce.VALID]},{value:Ce.INVALID,label:xa[Ce.INVALID],icon:Fl,color:ha[Ce.INVALID]}];function va({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=s?.getFilterValue(),i=Array.isArray(a)?new Set(a):a!==void 0?new Set([a]):new Set;return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:i.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:i.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[i.size," selected"]}):t.filter(l=>i.has(l.value)).map(l=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:l.label},l.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(rs,{onSelect:()=>{const u=new Set(i);d?u.delete(l.value):u.add(l.value);const x=Array.from(u);s?.setFilterValue(x.length?x:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{className:N("h-4 w-4")})}),l.icon&&e.jsx(l.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${l.color}`}),e.jsx("span",{children:l.label}),r?.get(l.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(l.value)})]},l.value)})}),i.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Lt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const dh=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),mh={email:"",plan_id:0,total_amount:0,period:""};function ji({refetch:s,trigger:n,defaultValues:t}){const{t:r}=M("order"),[a,i]=m.useState(!1),l=we({resolver:Te(dh),defaultValues:{...mh,...t},mode:"onChange"}),[d,u]=m.useState([]);return m.useEffect(()=>{a&&ys.getList().then(({data:x})=>{u(x)})},[a]),e.jsxs(de,{open:a,onOpenChange:i,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:r("dialog.addOrder")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("dialog.assignOrder")}),e.jsx(Ae,{})]}),e.jsxs(De,{...l,children:[e.jsx(v,{control:l.control,name:"email",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dialog.fields.userEmail")}),e.jsx(_,{children:e.jsx(k,{placeholder:r("dialog.placeholders.email"),...x})})]})}),e.jsx(v,{control:l.control,name:"plan_id",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(_,{children:e.jsxs(J,{value:x.value?x.value?.toString():void 0,onValueChange:o=>x.onChange(parseInt(o)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(Y,{children:d.map(o=>e.jsx(A,{value:o.id.toString(),children:o.name},o.id))})]})})]})}),e.jsx(v,{control:l.control,name:"period",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dialog.fields.orderPeriod")}),e.jsx(_,{children:e.jsxs(J,{value:x.value,onValueChange:x.onChange,children:[e.jsx(W,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.period")})}),e.jsx(Y,{children:Object.keys(Vm).map(o=>e.jsx(A,{value:o,children:r(`period.${o}`)},o))})]})})]})}),e.jsx(v,{control:l.control,name:"total_amount",render:({field:x})=>e.jsxs(j,{children:[e.jsx(b,{children:r("dialog.fields.paymentAmount")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:r("dialog.placeholders.amount"),value:x.value/100,onChange:o=>x.onChange(parseFloat(o.currentTarget.value)*100)})}),e.jsx(R,{})]})}),e.jsxs(Me,{children:[e.jsx(D,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(D,{type:"submit",onClick:()=>{l.handleSubmit(x=>{ct.assign(x).then(({data:o})=>{o&&(s&&s(),l.reset(),i(!1),$.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function uh({table:s,refetch:n}){const{t}=M("order"),r=s.getState().columnFilters.length>0,a=Object.values(Vs).filter(u=>typeof u=="number").map(u=>({label:t(`type.${Vs[u]}`),value:u,color:u===Vs.NEW?"green-500":u===Vs.RENEWAL?"blue-500":u===Vs.UPGRADE?"purple-500":"orange-500"})),i=Object.values(Qe).map(u=>({label:t(`period.${u}`),value:u,color:u===Qe.MONTH_PRICE?"slate-500":u===Qe.QUARTER_PRICE?"cyan-500":u===Qe.HALF_YEAR_PRICE?"indigo-500":u===Qe.YEAR_PRICE?"violet-500":u===Qe.TWO_YEAR_PRICE?"fuchsia-500":u===Qe.THREE_YEAR_PRICE?"pink-500":u===Qe.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(le).filter(u=>typeof u=="number").map(u=>({label:t(`status.${le[u]}`),value:u,icon:u===le.PENDING?Ct[0].icon:u===le.PROCESSING?Ct[1].icon:u===le.COMPLETED?Ct[2].icon:u===le.CANCELLED?Ct[3].icon:Ct[4].icon,color:u===le.PENDING?"yellow-500":u===le.PROCESSING?"blue-500":u===le.COMPLETED?"green-500":u===le.CANCELLED?"red-500":"green-500"})),d=Object.values(Ce).filter(u=>typeof u=="number").map(u=>({label:t(`commission.${Ce[u]}`),value:u,icon:u===Ce.PENDING?Ht[0].icon:u===Ce.PROCESSING?Ht[1].icon:u===Ce.VALID?Ht[2].icon:Ht[3].icon,color:u===Ce.PENDING?"yellow-500":u===Ce.PROCESSING?"blue-500":u===Ce.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ji,{refetch:n}),e.jsx(k,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:u=>s.getColumn("trade_no")?.setFilterValue(u.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(va,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(va,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(va,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(va,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}function ns({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:N("flex items-center py-1.5",t),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:N("text-sm",r),children:n||"-"})]})}function xh({status:s}){const{t:n}=M("order"),t={[le.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[le.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[le.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[le.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[le.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(U,{variant:"secondary",className:N("font-medium",t[s]),children:n(`status.${le[s]}`)})}function hh({id:s,trigger:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(),{t:l}=M("order");return m.useEffect(()=>{(async()=>{if(t){const{data:u}=await ct.getInfo({id:s});i(u)}})()},[t,s]),e.jsxs(de,{onOpenChange:r,open:t,children:[e.jsx(ps,{asChild:!0,children:n}),e.jsxs(ce,{className:"max-w-xl",children:[e.jsxs(he,{className:"space-y-2",children:[e.jsx(me,{className:"text-lg font-medium",children:l("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:[l("table.columns.tradeNo"),":",a?.trade_no]}),!!a?.status&&e.jsx(xh,{status:a.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:l("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Zs,{to:`/user/manage?email=${a.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.user.email,e.jsx(Cn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(ns,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(ns,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(ns,{label:l("dialog.fields.callbackNo"),value:a?.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:l("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.paymentAmount"),value:qs(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Ve,{className:"my-2"}),e.jsx(ns,{label:l("dialog.fields.balancePayment"),value:qs(a?.balance_amount||0)}),e.jsx(ns,{label:l("dialog.fields.discountAmount"),value:qs(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(ns,{label:l("dialog.fields.refundAmount"),value:qs(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(ns,{label:l("dialog.fields.deductionAmount"),value:qs(a?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.createdAt"),value:ie(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(ns,{label:l("dialog.fields.updatedAt"),value:ie(a?.updated_at),valueClassName:"font-mono text-xs"})]})]}),a?.commission_status===1&&a?.commission_balance&&e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.commissionInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.commissionStatus"),value:e.jsx(U,{variant:"secondary",className:"bg-orange-100 font-medium text-orange-800 hover:bg-orange-100",children:l("dialog.commissionStatusActive")})}),e.jsx(ns,{label:l("dialog.fields.commissionAmount"),value:qs(a?.commission_balance||0),valueClassName:"font-medium text-orange-600"}),a?.actual_commission_balance&&e.jsx(ns,{label:l("dialog.fields.actualCommissionAmount"),value:qs(a?.actual_commission_balance||0),valueClassName:"font-medium text-orange-700"}),a?.invite_user&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"my-2"}),e.jsx(ns,{label:l("dialog.fields.inviteUser"),value:e.jsxs(Zs,{to:`/user/manage?email=${a.invite_user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.invite_user.email,e.jsx(Cn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})}),e.jsx(ns,{label:l("dialog.fields.inviteUserId"),value:a?.invite_user?.id,valueClassName:"font-mono text-xs"})]})]})]})]})]})]})}const gh={[Vs.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Vs.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Vs.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Vs.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},ph={[Qe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},fh=s=>le[s],jh=s=>Ce[s],vh=s=>Vs[s],bh=s=>{const{t:n}=M("order");return[{accessorKey:"trade_no",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.tradeNo")}),cell:({row:t})=>{const r=t.original.trade_no,a=r.length>6?`${r.slice(0,3)}...${r.slice(-3)}`:r;return e.jsx("div",{className:"flex items-center",children:e.jsx(hh,{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:a}),e.jsx(Cn,{className:"h-3.5 w-3.5 opacity-70"})]}),id:t.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>{const r=t.getValue("type"),a=gh[r];return e.jsx(U,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",a.color,a.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${vh(r)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.plan")}),cell:({row:t})=>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:t.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.period")}),cell:({row:t})=>{const r=t.getValue("period"),a=ph[r];return e.jsx(U,{variant:"secondary",className:N("font-medium transition-colors text-nowrap",a?.color,a?.bgColor,"hover:bg-opacity-80"),children:n(`period.${r}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.amount")}),cell:({row:t})=>{const r=t.getValue("total_amount"),a=typeof r=="number"?(r/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",a]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:t})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:t,title:n("table.columns.status")}),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsx(di,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(ue,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:t})=>{const r=Ct.find(a=>a.value===t.getValue("status"));return r?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.icon&&e.jsx(r.icon,{className:`h-4 w-4 text-${r.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${fh(r.value)}`)})]}),r.value===le.PENDING&&e.jsxs(zs,{modal:!0,children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ms,{align:"end",className:"w-[140px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await ct.markPaid({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await ct.makeCancel({trade_no:t.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commission")}),cell:({row:t})=>{const r=t.getValue("commission_balance"),a=r?(r/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:r?`¥${a}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commissionStatus")}),cell:({row:t})=>{const r=t.original.status,a=t.original.commission_balance,i=Ht.find(l=>l.value===t.getValue("commission_status"));return a==0||!i?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:[i.icon&&e.jsx(i.icon,{className:`h-4 w-4 text-${i.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${jh(i.value)}`)})]}),i.value===Ce.PENDING&&r===le.COMPLETED&&e.jsxs(zs,{modal:!0,children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ms,{align:"end",className:"w-[120px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await ct.update({trade_no:t.original.trade_no,commission_status:Ce.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await ct.update({trade_no:t.original.trade_no,commission_status:Ce.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.createdAt")}),cell:({row:t})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:ie(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function yh(){const[s]=Pl(),[n,t]=m.useState({}),[r,a]=m.useState({}),[i,l]=m.useState([]),[d,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const T=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([y,L])=>{const C=s.get(y);return C?{id:y,value:L==="number"?parseInt(C):C}:null}).filter(Boolean);T.length>0&&l(T)},[s]);const{refetch:c,data:f,isLoading:F}=ae({queryKey:["orderList",x,i,d],queryFn:()=>ct.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:i,sort:d})}),S=Be({data:f?.data??[],columns:bh(c),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:x},rowCount:f?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:u,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:o,getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:S,toolbar:e.jsx(uh,{table:S,refetch:c}),showPagination:!0})}function _h(){const{t:s}=M("order");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(yh,{})})]})]})}const Nh=Object.freeze(Object.defineProperty({__proto__:null,default:_h},Symbol.toStringTag,{value:"Module"}));function wh({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(rs,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:N("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{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}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Lt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Ch=s=>h.object({id:h.coerce.number().nullable().optional(),name:h.string().min(1,s("form.name.required")),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(Jt)).default([]).nullable()}).refine(n=>n.ended_at>n.started_at,{message:s("form.validity.endTimeError"),path:["ended_at"]}),Nr={name:"",code:null,type:Ns.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:null,limit_use_with_user:null,limit_plan_ids:[],limit_period:[],generate_count:null},Sh=s=>[{label:s("form.timeRange.presets.1week"),days:7},{label:s("form.timeRange.presets.2weeks"),days:14},{label:s("form.timeRange.presets.1month"),days:30},{label:s("form.timeRange.presets.3months"),days:90},{label:s("form.timeRange.presets.6months"),days:180},{label:s("form.timeRange.presets.1year"),days:365}];function vi({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=M("coupon"),[d,u]=m.useState(!1),x=a??d,o=i??u,[c,f]=m.useState([]),F=Ch(l),S=Sh(l),w=we({resolver:Te(F),defaultValues:s||Nr});m.useEffect(()=>{s&&w.reset(s)},[s,w]),m.useEffect(()=>{ys.getList().then(({data:g})=>f(g))},[]);const T=g=>{if(!g)return;const p=(V,E)=>{const P=new Date(E*1e3);return V.setHours(P.getHours(),P.getMinutes(),P.getSeconds()),Math.floor(V.getTime()/1e3)};g.from&&w.setValue("started_at",p(g.from,w.watch("started_at"))),g.to&&w.setValue("ended_at",p(g.to,w.watch("ended_at")))},y=g=>{const p=new Date,V=Math.floor(p.getTime()/1e3),E=Math.floor((p.getTime()+g*24*60*60*1e3)/1e3);w.setValue("started_at",V),w.setValue("ended_at",E)},L=async g=>{const p=await Pa.save(g);if(g.generate_count&&typeof p=="string"){const V=new Blob([p],{type:"text/csv;charset=utf-8;"}),E=document.createElement("a");E.href=window.URL.createObjectURL(V),E.download=`coupons_${new Date().getTime()}.csv`,E.click(),window.URL.revokeObjectURL(E.href)}o(!1),t==="create"&&w.reset(Nr),n()},C=(g,p)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:p}),e.jsx(k,{type:"datetime-local",step:"1",value:ie(w.watch(g),"YYYY-MM-DDTHH:mm:ss"),onChange:V=>{const E=new Date(V.target.value);w.setValue(g,Math.floor(E.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(de,{open:x,onOpenChange:o,children:[r&&e.jsx(ps,{asChild:!0,children:r}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(De,{...w,children:e.jsxs("form",{onSubmit:w.handleSubmit(L),className:"space-y-4",children:[e.jsx(v,{control:w.control,name:"name",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.name.label")}),e.jsx(k,{placeholder:l("form.name.placeholder"),...g}),e.jsx(R,{})]})}),t==="create"&&e.jsx(v,{control:w.control,name:"generate_count",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.generateCount.label")}),e.jsx(k,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...g,value:g.value??"",onChange:p=>g.onChange(p.target.value===""?null:parseInt(p.target.value)),className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(R,{})]})}),(!w.watch("generate_count")||w.watch("generate_count")==null)&&e.jsx(v,{control:w.control,name:"code",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.code.label")}),e.jsx(k,{placeholder:l("form.code.placeholder"),...g,value:g.value??"",className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.code.description")}),e.jsx(R,{})]})}),e.jsxs(j,{children:[e.jsx(b,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(v,{control:w.control,name:"type",render:({field:g})=>e.jsxs(J,{value:g.value.toString(),onValueChange:p=>{const V=g.value,E=parseInt(p);g.onChange(E);const P=w.getValues("value");P&&(V===Ns.AMOUNT&&E===Ns.PERCENTAGE?w.setValue("value",P/100):V===Ns.PERCENTAGE&&E===Ns.AMOUNT&&w.setValue("value",P*100))},children:[e.jsx(W,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Q,{placeholder:l("form.type.placeholder")})}),e.jsx(Y,{children:Object.entries(Im).map(([p,V])=>e.jsx(A,{value:p,children:l(`table.toolbar.types.${p}`)},p))})]})}),e.jsx(v,{control:w.control,name:"value",render:({field:g})=>{const p=g.value==null?"":w.watch("type")===Ns.AMOUNT&&typeof g.value=="number"?(g.value/100).toString():g.value.toString();return e.jsx(k,{type:"number",placeholder:l("form.value.placeholder"),...g,value:p,onChange:V=>{const E=V.target.value;if(E===""){g.onChange("");return}const P=parseFloat(E);isNaN(P)||g.onChange(w.watch("type")===Ns.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:w.watch("type")==Ns.AMOUNT?"¥":"%"})})]})]}),e.jsxs(j,{children:[e.jsx(b,{children:l("form.validity.label")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",className:N("w-full justify-start text-left font-normal",!w.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"truncate",children:[ie(w.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",ie(w.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})]})}),e.jsxs(Xe,{className:"w-auto p-0",align:"start",children:[e.jsxs("div",{className:"border-b border-border p-3",children:[e.jsx("div",{className:"mb-2 text-sm font-medium text-muted-foreground",children:l("form.timeRange.quickSet")}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-6",children:S.map(g=>e.jsx(D,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>y(g.days),type:"button",children:g.label},g.days))})]}),e.jsx("div",{className:"hidden border-b border-border sm:block",children:e.jsx(Cs,{mode:"range",selected:{from:new Date(w.watch("started_at")*1e3),to:new Date(w.watch("ended_at")*1e3)},onSelect:T,numberOfMonths:2})}),e.jsx("div",{className:"border-b border-border sm:hidden",children:e.jsx(Cs,{mode:"range",selected:{from:new Date(w.watch("started_at")*1e3),to:new Date(w.watch("ended_at")*1e3)},onSelect:T,numberOfMonths:1})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center",children:[C("started_at",l("table.validity.startTime")),e.jsx("div",{className:"text-center text-sm text-muted-foreground sm:mt-6",children:l("form.validity.to")}),C("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(R,{})]}),e.jsx(v,{control:w.control,name:"limit_use",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.limitUse.label")}),e.jsx(k,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...g,value:g.value??"",onChange:p=>g.onChange(p.target.value===""?null:parseInt(p.target.value)),className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:w.control,name:"limit_use_with_user",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.limitUseWithUser.label")}),e.jsx(k,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...g,value:g.value??"",onChange:p=>g.onChange(p.target.value===""?null:parseInt(p.target.value)),className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:w.control,name:"limit_period",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.limitPeriod.label")}),e.jsx(st,{options:Object.entries(Jt).filter(([p])=>isNaN(Number(p))).map(([p,V])=>({label:l(`coupon:period.${V}`),value:p})),onChange:p=>{if(p.length===0){g.onChange([]);return}const V=p.map(E=>Jt[E.value]);g.onChange(V)},value:(g.value||[]).map(p=>({label:l(`coupon:period.${p}`),value:Object.entries(Jt).find(([V,E])=>E===p)?.[0]||""})),placeholder:l("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPeriod.empty")})}),e.jsx(z,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(R,{})]})}),e.jsx(v,{control:w.control,name:"limit_plan_ids",render:({field:g})=>e.jsxs(j,{children:[e.jsx(b,{children:l("form.limitPlan.label")}),e.jsx(st,{options:c?.map(p=>({label:p.name,value:p.id.toString()}))||[],onChange:p=>g.onChange(p.map(V=>Number(V.value))),value:(c||[]).filter(p=>(g.value||[]).includes(p.id)).map(p=>({label:p.name,value:p.id.toString()})),placeholder:l("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPlan.empty")})}),e.jsx(R,{})]})}),e.jsx(Me,{children:e.jsx(D,{type:"submit",disabled:w.formState.isSubmitting,children:w.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function kh({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=M("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(vi,{refetch:n,dialogTrigger:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:r("form.add")})]})}),e.jsx(k,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(wh,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:Ns.AMOUNT,label:r(`table.toolbar.types.${Ns.AMOUNT}`)},{value:Ns.PERCENTAGE,label:r(`table.toolbar.types.${Ns.PERCENTAGE}`)}]}),t&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}const bi=m.createContext(void 0);function Th({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=u=>{i(u),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(bi.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(vi,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function Dh(){const s=m.useContext(bi);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Fh=s=>{const{t:n}=M("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx(X,{defaultChecked:t.original.show,onCheckedChange:r=>{Pa.update({id:t.original.id,show:r}).then(({data:a})=>!a&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`table.toolbar.types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.code")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUse")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.limit_use===null?n("table.validity.unlimited"):t.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUseWithUser")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.limit_use_with_user===null?n("table.validity.noLimit"):t.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.validity")}),cell:({row:t})=>{const[r,a]=m.useState(!1),i=Date.now(),l=t.original.started_at*1e3,d=t.original.ended_at*1e3,u=i>d,x=ie.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=Dh();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(_s,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{Pa.drop({id:t.original.id}).then(({data:a})=>{a&&($.success("删除成功"),s())})},children:e.jsxs(D,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 Ph(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ae({queryKey:["couponList",u,a,l],queryFn:()=>Pa.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),f=Be({data:c?.data??[],columns:Fh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((c?.total??0)/u.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Th,{refetch:o,children:e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:f,toolbar:e.jsx(kh,{table:f,refetch:o})})})})}function Rh(){const{t:s}=M("coupon");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Ph,{})})]})]})}const Lh=Object.freeze(Object.defineProperty({__proto__:null,default:Rh},Symbol.toStringTag,{value:"Module"})),Eh=h.object({name:h.string().min(1,"请输入模板名称"),description:h.string().optional(),type:h.number().min(1).max(4),status:h.boolean(),sort:h.number().min(0),icon:h.string().optional(),background_image:h.string().optional(),conditions:h.object({allowed_plans:h.array(h.number()).optional(),disallowed_plans:h.array(h.number()).optional(),new_user_only:h.boolean().optional(),new_user_max_days:h.number().optional(),paid_user_only:h.boolean().optional(),require_invite:h.boolean().optional()}).optional(),limits:h.object({max_use_per_user:h.number().optional(),cooldown_hours:h.number().optional(),invite_reward_rate:h.number().optional()}).optional(),rewards:h.object({balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional(),reset_package:h.boolean().optional(),plan_id:h.number().optional(),plan_validity_days:h.number().optional(),random_rewards:h.array(h.object({weight:h.number(),balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional()})).optional()}),special_config:h.object({start_time:h.number().optional(),end_time:h.number().optional(),festival_bonus:h.number().optional()}).optional()});function yi({template:s,refetch:n,open:t,onOpenChange:r}){const{t:a}=M("giftCard"),[i,l]=m.useState(!1),[d,u]=m.useState([]),[x,o]=m.useState([]),c=we({resolver:Te(Eh),defaultValues:{name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{},special_config:{}}}),{fields:f,append:F,remove:S}=jd({control:c.control,name:"rewards.random_rewards"});m.useEffect(()=>{t&&(async()=>{try{const p=(await ys.getList()).data||[];u(p),o(p.map(V=>({label:V.name,value:V.id.toString()})))}catch(g){console.error("Failed to fetch plans:",g),$.error("Failed to load plan list")}})()},[t]),m.useEffect(()=>{if(s){const C=s.rewards||{};c.reset({name:s.name,description:s.description||"",type:s.type,status:s.status,sort:s.sort,icon:s.icon||"",background_image:s.background_image||"",conditions:s.conditions&&!Array.isArray(s.conditions)?s.conditions:{},limits:s.limits&&!Array.isArray(s.limits)?{...s.limits,invite_reward_rate:s.limits.invite_reward_rate||void 0}:{},rewards:{balance:C.balance?C.balance/100:void 0,transfer_enable:typeof C.transfer_enable=="number"?C.transfer_enable/1024/1024/1024:void 0,expire_days:C.expire_days,device_limit:C.device_limit,reset_package:C.reset_package,plan_id:C.plan_id,plan_validity_days:C.plan_validity_days,random_rewards:C.random_rewards?.map(g=>({weight:g.weight,balance:g.balance?g.balance/100:void 0,transfer_enable:typeof g.transfer_enable=="number"?g.transfer_enable/1024/1024/1024:void 0,expire_days:g.expire_days,device_limit:g.device_limit}))||[]},special_config:s.special_config&&!Array.isArray(s.special_config)?s.special_config:{}})}else c.reset({name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{random_rewards:[]},special_config:{}})},[s,c]);const w=C=>{console.error("Form validation failed:",C),$.error(a("messages.formInvalid"))},T=async C=>{l(!0);const g=JSON.parse(JSON.stringify(C));g.rewards&&(typeof g.rewards.balance=="number"&&(g.rewards.balance=Math.round(g.rewards.balance*100)),typeof g.rewards.transfer_enable=="number"&&(g.rewards.transfer_enable=Math.round(g.rewards.transfer_enable*1024*1024*1024)),g.rewards.random_rewards&&g.rewards.random_rewards.forEach(V=>{typeof V.balance=="number"&&(V.balance=Math.round(V.balance*100)),typeof V.transfer_enable=="number"&&(V.transfer_enable=Math.round(V.transfer_enable*1024*1024*1024))}));const p={...g,conditions:g.conditions||{},limits:g.limits||{},rewards:g.rewards||{},special_config:g.special_config||{}};try{s?(await Ds.updateTemplate({id:s.id,...p}),$.success(a("messages.templateUpdated"))):(await Ds.createTemplate(p),$.success(a("messages.templateCreated"))),n(),r(!1)}catch(V){const E=V?.response?.data?.errors;E&&Object.keys(E).forEach(P=>{c.setError(P,{type:"manual",message:E[P][0]})}),$.error(a(s?"messages.updateTemplateFailed":"messages.createTemplateFailed"))}finally{l(!1)}},y=c.watch("type"),L=y===1;return e.jsx(de,{open:t,onOpenChange:r,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:a(s?"template.form.edit":"template.form.add")})}),e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(T,w),className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:c.control,name:"name",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.name.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:a("template.form.name.placeholder"),...C})}),e.jsx(R,{})]})}),e.jsx(v,{control:c.control,name:"type",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.type.label")}),e.jsxs(J,{value:C.value.toString(),onValueChange:g=>C.onChange(parseInt(g)),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:a("template.form.type.placeholder")})})}),e.jsx(Y,{children:[1,2,3].map(g=>e.jsx(A,{value:g.toString(),children:a(`types.${g}`)},g))})]}),e.jsx(R,{})]})})]}),e.jsx(v,{control:c.control,name:"description",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.description.label")}),e.jsx(_,{children:e.jsx(Rs,{placeholder:a("template.form.description.placeholder"),...C})}),e.jsx(R,{})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:e.jsx(v,{control:c.control,name:"status",render:({field:C})=>e.jsxs(j,{className:"col-span-3 flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{className:"text-base",children:a("template.form.status.label")}),e.jsx(z,{children:a("template.form.status.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:C.value,onCheckedChange:C.onChange})})]})})}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Le,{children:a("template.form.rewards.title")})}),e.jsxs(Pe,{className:"space-y-4",children:[L&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:c.control,name:"rewards.balance",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.rewards.balance.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.balance.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})}),e.jsx(v,{control:c.control,name:"rewards.transfer_enable",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.rewards.transfer_enable.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.placeholder"),value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})}),e.jsx(v,{control:c.control,name:"rewards.expire_days",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.rewards.expire_days.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.expire_days.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})}),e.jsx(v,{control:c.control,name:"rewards.device_limit",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.rewards.device_limit.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.device_limit.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})})]}),e.jsx(v,{control:c.control,name:"rewards.reset_package",render:({field:C})=>e.jsxs(j,{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(b,{children:a("template.form.rewards.reset_package.label")}),e.jsx(z,{children:a("template.form.rewards.reset_package.description")})]}),e.jsx(_,{children:e.jsx(X,{checked:C.value,onCheckedChange:C.onChange})})]})})]}),y===4&&e.jsx("p",{children:a("template.form.rewards.task_card.description")}),y===2&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:c.control,name:"rewards.plan_id",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.rewards.plan_id.label")}),e.jsxs(J,{value:C.value?.toString(),onValueChange:g=>C.onChange(parseInt(g,10)),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:a("template.form.rewards.plan_id.placeholder")})})}),e.jsx(Y,{children:d.map(g=>e.jsx(A,{value:g.id.toString(),children:g.name},g.id))})]}),e.jsx(R,{})]})}),e.jsx(v,{control:c.control,name:"rewards.plan_validity_days",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.rewards.plan_validity_days.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.plan_validity_days.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})})]}),y===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{children:a("template.form.rewards.random_rewards.label")}),f.map((C,g)=>e.jsxs("div",{className:"flex items-center space-x-2 rounded-md border p-2",children:[e.jsx(v,{control:c.control,name:`rewards.random_rewards.${g}.weight`,render:({field:p})=>e.jsx(j,{children:e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.random_rewards.weight"),...p,value:p.value??"",onChange:V=>{const E=V.target.valueAsNumber;p.onChange(isNaN(E)?0:E)}})})})}),e.jsx(v,{control:c.control,name:`rewards.random_rewards.${g}.balance`,render:({field:p})=>e.jsx(j,{children:e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.balance.label"),...p,value:p.value??"",onChange:V=>{const E=V.target.valueAsNumber;p.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(v,{control:c.control,name:`rewards.random_rewards.${g}.transfer_enable`,render:({field:p})=>e.jsx(j,{children:e.jsx(_,{children:e.jsx(k,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.label")+" (GB)",value:p.value??"",onChange:V=>{const E=V.target.valueAsNumber;p.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(v,{control:c.control,name:`rewards.random_rewards.${g}.expire_days`,render:({field:p})=>e.jsx(j,{children:e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.expire_days.label"),...p,value:p.value??"",onChange:V=>{const E=V.target.valueAsNumber;p.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(v,{control:c.control,name:`rewards.random_rewards.${g}.device_limit`,render:({field:p})=>e.jsx(j,{children:e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.rewards.device_limit.label"),...p,value:p.value??"",onChange:V=>{const E=V.target.valueAsNumber;p.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(D,{type:"button",variant:"ghost",size:"icon",onClick:()=>S(g),children:e.jsx(vd,{className:"h-4 w-4"})})]},C.id)),e.jsx(D,{type:"button",variant:"outline",onClick:()=>F({weight:10,balance:void 0,transfer_enable:void 0,expire_days:void 0,device_limit:void 0}),children:a("template.form.rewards.random_rewards.add")})]})]})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Le,{children:a("template.form.conditions.title")})}),e.jsxs(Pe,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsx(v,{control:c.control,name:"conditions.new_user_max_days",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.conditions.new_user_max_days.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.conditions.new_user_max_days.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(v,{control:c.control,name:"conditions.new_user_only",render:({field:C})=>e.jsxs(j,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:a("template.form.conditions.new_user_only.label")})}),e.jsx(_,{children:e.jsx(X,{checked:C.value,onCheckedChange:C.onChange})})]})}),e.jsx(v,{control:c.control,name:"conditions.paid_user_only",render:({field:C})=>e.jsxs(j,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:a("template.form.conditions.paid_user_only.label")})}),e.jsx(_,{children:e.jsx(X,{checked:C.value,onCheckedChange:C.onChange})})]})}),e.jsx(v,{control:c.control,name:"conditions.require_invite",render:({field:C})=>e.jsxs(j,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:a("template.form.conditions.require_invite.label")})}),e.jsx(_,{children:e.jsx(X,{checked:C.value,onCheckedChange:C.onChange})})]})})]}),e.jsx(v,{control:c.control,name:"conditions.allowed_plans",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.conditions.allowed_plans.label")}),e.jsx(_,{children:e.jsx(st,{value:C.value?.map(g=>({label:d.find(p=>p.id===g)?.name||`ID: ${g}`,value:g.toString()}))??[],onChange:g=>C.onChange(g.map(p=>parseInt(p.value))),options:x,placeholder:a("template.form.conditions.allowed_plans.placeholder")})})]})}),e.jsx(v,{control:c.control,name:"conditions.disallowed_plans",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.conditions.disallowed_plans.label")}),e.jsx(_,{children:e.jsx(st,{value:C.value?.map(g=>({label:d.find(p=>p.id===g)?.name||`ID: ${g}`,value:g.toString()}))??[],onChange:g=>C.onChange(g.map(p=>parseInt(p.value))),options:x,placeholder:a("template.form.conditions.disallowed_plans.placeholder")})})]})})]})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Le,{children:a("template.form.limits.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:c.control,name:"limits.max_use_per_user",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.limits.max_use_per_user.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.limits.max_use_per_user.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})}),e.jsx(v,{control:c.control,name:"limits.cooldown_hours",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.limits.cooldown_hours.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",placeholder:a("template.form.limits.cooldown_hours.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})}),e.jsx(v,{control:c.control,name:"limits.invite_reward_rate",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.limits.invite_reward_rate.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",step:"0.01",placeholder:a("template.form.limits.invite_reward_rate.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})}),e.jsx(z,{children:a("template.form.limits.invite_reward_rate.description")})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Le,{children:a("template.form.special_config.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-3 items-end gap-4",children:[e.jsx(v,{control:c.control,name:"special_config.start_time",render:({field:C})=>e.jsxs(j,{className:"flex flex-col",children:[e.jsx(b,{children:a("template.form.special_config.start_time.label")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(D,{variant:"outline",className:N("w-full pl-3 text-left font-normal",!C.value&&"text-muted-foreground"),children:[C.value?Re(new Date(C.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.start_time.placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:C.value?new Date(C.value*1e3):void 0,onSelect:g=>C.onChange(g?Math.floor(g.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(v,{control:c.control,name:"special_config.end_time",render:({field:C})=>e.jsxs(j,{className:"flex flex-col",children:[e.jsx(b,{children:a("template.form.special_config.end_time.label")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(D,{variant:"outline",className:N("w-full pl-3 text-left font-normal",!C.value&&"text-muted-foreground"),children:[C.value?Re(new Date(C.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.end_time.placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:C.value?new Date(C.value*1e3):void 0,onSelect:g=>C.onChange(g?Math.floor(g.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(v,{control:c.control,name:"special_config.festival_bonus",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.special_config.festival_bonus.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",step:"0.1",placeholder:a("template.form.special_config.festival_bonus.placeholder"),...C,value:C.value??"",onChange:g=>{const p=g.target.valueAsNumber;C.onChange(isNaN(p)?void 0:p)}})})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Fe,{children:e.jsx(Le,{children:a("template.form.display.title")})}),e.jsx(Pe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(v,{control:c.control,name:"icon",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.icon.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:a("template.form.icon.placeholder"),...C})}),e.jsx(R,{})]})}),e.jsx(v,{control:c.control,name:"background_image",render:({field:C})=>e.jsxs(j,{children:[e.jsx(b,{children:a("template.form.background_image.label")}),e.jsx(_,{children:e.jsx(k,{placeholder:a("template.form.background_image.placeholder"),...C})}),e.jsx(R,{})]})})]})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(D,{type:"button",variant:"outline",onClick:()=>r(!1),children:a("common:cancel")}),e.jsx(D,{type:"submit",disabled:i,children:a(i?"common:saving":"common:submit")})]})]})})]})})}const _i=m.createContext(void 0);function Vh({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=u=>{i(u),r(!!u)},d=()=>{r(!1),i(null)};return e.jsxs(_i.Provider,{value:{isOpen:t,editingTemplate:a,setEditingTemplate:l,closeEdit:d},children:[s,e.jsx(yi,{template:a,refetch:n,open:t,onOpenChange:r})]})}function Ih(){const s=m.useContext(_i);if(s===void 0)throw new Error("useTemplateEdit must be used within a TemplateEditProvider");return s}function Mh({rewards:s,type:n}){const{t}=M(["giftCard","common"]),r=[];return s&&(s.balance&&r.push(`${t("template.form.rewards.balance.short_label")}: ${s.balance/100} ${t("common:currency.yuan","元")}`),s.transfer_enable&&r.push(`${t("template.form.rewards.transfer_enable.short_label")}: ${ze(s.transfer_enable)}`),s.expire_days&&r.push(`${t("template.form.rewards.expire_days.short_label")}: ${s.expire_days}${t("common:time.day","天")}`),s.device_limit&&r.push(`${t("template.form.rewards.device_limit.short_label")}: ${s.device_limit}`),n===2&&s.plan_id&&r.push(`${t("template.form.rewards.plan_id.short_label")}: ${s.plan_id}`),n===2&&s.plan_validity_days&&r.push(`${t("template.form.rewards.plan_validity_days.short_label")}: ${s.plan_validity_days}${t("common:time.day","天")}`),n===3&&s.random_rewards?.length&&r.push(t("types.3"))),r.length===0?e.jsx(U,{variant:"secondary",children:t("template.table.columns.no_rewards")}):e.jsx("div",{className:"flex flex-col space-y-1",children:r.map((a,i)=>e.jsx(U,{variant:"outline",className:"whitespace-nowrap",children:a},i))})}const Oh=s=>{const{t:n}=M("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.status")}),cell:({row:t})=>{const[r,a]=m.useState(!1);return e.jsx(X,{checked:t.original.status,disabled:r,onCheckedChange:async i=>{a(!0);try{const{data:l}=await Ds.updateTemplate({id:t.original.id,status:i});l?($.success(n("messages.templateUpdated")),s()):$.error(n("messages.updateTemplateFailed"))}catch{$.error(n("messages.updateTemplateFailed"))}finally{a(!1)}}})},enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:300},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"rewards",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.rewards")}),cell:({row:t})=>e.jsx(Mh,{rewards:t.original.rewards,type:t.original.type}),enableSorting:!1},{accessorKey:"sort",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.sort")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.sort}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.original.created_at)}),enableSorting:!0},{id:"actions",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.actions")}),cell:({row:t})=>{const{setEditingTemplate:r}=Ih();return e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>r(t.original),children:[e.jsx(tt,{className:"h-4 w-4"}),n("template.actions.edit")]}),e.jsx(_s,{title:n("template.actions.deleteConfirm.title"),description:n("template.actions.deleteConfirm.description"),confirmText:n("template.actions.deleteConfirm.confirmText"),onConfirm:async()=>{try{const{data:a}=await Ds.deleteTemplate({id:t.original.id});a?($.success(n("messages.templateDeleted")),s()):$.error(n("messages.deleteTemplateFailed"))}catch{$.error(n("messages.deleteTemplateFailed"))}},children:e.jsxs(D,{variant:"outline",size:"sm",children:[e.jsx(us,{className:"h-4 w-4"}),n("template.actions.delete")]})})]})},enableSorting:!1}]};function Ni({table:s}){return e.jsxs(zs,{children:[e.jsx(bd,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),"显示列"]})}),e.jsxs(Ms,{align:"end",className:"w-[150px]",children:[e.jsx(Ua,{children:"切换显示列"}),e.jsx(et,{}),s.getAllColumns().filter(n=>typeof n.accessorFn<"u"&&n.getCanHide()).map(n=>e.jsx(Gl,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:t=>n.toggleVisibility(!!t),children:n.id},n.id))]})]})}function Ea({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(yd,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):t.filter(a=>r.has(a.value)).map(a=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:a.label},`selected-${a.value}`))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(rs,{onSelect:()=>{i?r.delete(a.value):r.add(a.value);const l=Array.from(r);s?.setFilterValue(l.length?l: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(_d,{className:N("h-4 w-4")})}),a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:a.label})]},`option-${a.value}`)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Lt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function zh({table:s,refetch:n}){const{t}=M("giftCard"),[r,a]=m.useState(!1),i=s.getState().columnFilters.length>0,l=[{label:t("types.1"),value:"1"},{label:t("types.2"),value:"2"},{label:t("types.3"),value:"3"},{label:t("types.4"),value:"4"},{label:t("types.5"),value:"5"},{label:t("types.6"),value:"6"},{label:t("types.7"),value:"7"},{label:t("types.8"),value:"8"},{label:t("types.9"),value:"9"},{label:t("types.10"),value:"10"}],d=[{label:t("common.enabled"),value:"true"},{label:t("common.disabled"),value:"false"}];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.jsx(k,{placeholder:t("common.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:u=>s.getColumn("name")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(Ea,{column:s.getColumn("type"),title:t("template.table.columns.type"),options:l}),s.getColumn("status")&&e.jsx(Ea,{column:s.getColumn("status"),title:t("template.table.columns.status"),options:d}),i&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(Ll,{className:"h-4 w-4 mr-2"}),t("template.form.add")]}),e.jsx(Ni,{table:s})]}),e.jsx(yi,{template:null,refetch:n,open:r,onOpenChange:a})]})}function $h(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ae({queryKey:["giftCardTemplates",u,a,l],queryFn:()=>Ds.getTemplates({per_page:u.pageSize,page:u.pageIndex+1,filter:a,sort:l})});console.log(c);const f=Be({data:c?.data??[],columns:Oh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((c?.total??0)/u.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Vh,{refetch:o,children:e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:f,toolbar:e.jsx(zh,{table:f,refetch:o})})})})}const Ah=h.object({template_id:h.number().min(1,"请选择一个模板"),count:h.number().min(1,"生成数量必须大于0").max(1e4,"单次最多生成10000个"),prefix:h.string().optional(),expires_hours:h.number().min(1,"有效期必须大于0"),max_usage:h.number().min(1,"最大使用次数必须大于0"),download_csv:h.boolean().optional()});function qh({refetch:s,open:n,onOpenChange:t}){const{t:r}=M("giftCard"),[a,i]=m.useState(!1),[l,d]=m.useState([]);m.useEffect(()=>{n&&Ds.getTemplates({per_page:1e3,page:1}).then(({data:o})=>{d(o||[])})},[n]);const u=we({resolver:Te(Ah),defaultValues:{count:10,prefix:"",expires_hours:24*30,max_usage:1,download_csv:!1}}),x=async o=>{i(!0);try{if(o.download_csv){const c=await Ds.generateCodes(o);if(c&&c instanceof Blob){const f=window.URL.createObjectURL(c),F=document.createElement("a");F.href=f,F.download=`gift_codes_${new Date().getTime()}.csv`,document.body.appendChild(F),F.click(),F.remove(),window.URL.revokeObjectURL(f),$.success(r("messages.codesGenerated")),s(),t(!1),u.reset()}}else await Ds.generateCodes(o),$.success(r("messages.codesGenerated")),s(),t(!1),u.reset()}catch{$.error(r("messages.generateCodesFailed"))}finally{i(!1)}};return e.jsx(de,{open:n,onOpenChange:t,children:e.jsxs(ce,{children:[e.jsx(he,{children:e.jsx(me,{children:r("code.form.generate")})}),e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(x),className:"space-y-4",children:[e.jsx(v,{control:u.control,name:"template_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:r("code.form.template_id.label")}),e.jsxs(J,{onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(_,{children:e.jsx(W,{children:e.jsx(Q,{placeholder:r("code.form.template_id.placeholder")})})}),e.jsx(Y,{children:l.map(c=>e.jsx(A,{value:c.id.toString(),children:c.name},c.id))})]}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"count",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:r("code.form.count.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"prefix",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:r("code.form.prefix.label")}),e.jsx(_,{children:e.jsx(k,{...o})}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"expires_hours",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:r("code.form.expires_hours.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"max_usage",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:r("code.form.max_usage.label")}),e.jsx(_,{children:e.jsx(k,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(v,{control:u.control,name:"download_csv",render:({field:o})=>e.jsxs(j,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx("input",{type:"checkbox",checked:o.value,onChange:c=>o.onChange(c.target.checked)})}),e.jsx(b,{children:r("code.form.download_csv")})]})}),e.jsxs(Me,{children:[e.jsx(D,{type:"button",variant:"outline",onClick:()=>t(!1),children:r("common.cancel")}),e.jsx(D,{type:"submit",disabled:a,children:r(a?"code.form.submit.generating":"code.form.submit.generate")})]})]})})]})})}function Uh({table:s,refetch:n}){const{t}=M("giftCard"),[r,a]=m.useState(!1),i=s.getState().columnFilters.length>0,l=Object.entries(t("code.status",{returnObjects:!0})).map(([d,u])=>({value:d,label:u}));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.jsx(k,{placeholder:t("common.search"),value:s.getColumn("code")?.getFilterValue()??"",onChange:d=>s.getColumn("code")?.setFilterValue(d.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("status")&&e.jsx(Ea,{column:s.getColumn("status"),title:t("code.table.columns.status"),options:l}),i&&e.jsxs(D,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(D,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(Ll,{className:"h-4 w-4 mr-2"}),t("code.form.generate")]}),e.jsxs(D,{variant:"outline",size:"sm",disabled:!0,children:[e.jsx(Zt,{className:"h-4 w-4 mr-2"}),t("common.export")]}),e.jsx(Ni,{table:s})]}),e.jsx(qh,{refetch:n,open:r,onOpenChange:a})]})}const Hh=0,Kh=1,Bh=2,hn=3,Gh=s=>{const{t:n}=M("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id})},{accessorKey:"code",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.code")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:"secondary",children:t.original.code}),e.jsx(D,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>sa(t.original.code).then(()=>{$.success(n("common:copy.success"))}),children:e.jsx(kl,{className:"h-4 w-4"})})]})},{accessorKey:"template_name",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.template_name")})},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.status")}),cell:({row:t})=>{const r=t.original.status,a=r===hn,i=r===Hh||r===hn;return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:r===Kh?"secondary":r===Bh||r===hn?"destructive":"default",children:n(`code.status.${r}`)}),i&&e.jsx(X,{checked:!a,onCheckedChange:async l=>{const d=l?"enable":"disable";try{const{data:u}=await Ds.toggleCode({id:t.original.id,action:d});u?($.success(n("messages.codeStatusUpdated")),s()):$.error(n("messages.updateCodeStatusFailed"))}catch{$.error(n("messages.updateCodeStatusFailed"))}}})]})}},{accessorKey:"expires_at",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.expires_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.original.expires_at)})},{accessorKey:"usage_count",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.usage_count")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.usage_count})},{accessorKey:"max_usage",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.max_usage")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.max_usage})},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.original.created_at)})}]};function Wh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ae({queryKey:["giftCardCodes",u,a,l],queryFn:()=>Ds.getCodes({per_page:u.pageSize,page:u.pageIndex+1,filter:a,sort:l})}),f=Be({data:c?.data??[],columns:Gh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((c?.total??0)/u.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:f,toolbar:e.jsx(Uh,{table:f,refetch:o})})})}const Yh=()=>{const{t:s}=M("giftCard");return[{accessorKey:"id",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.id")}),cell:({row:n})=>e.jsx(U,{children:n.original.id})},{accessorKey:"code",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.code")}),cell:({row:n})=>e.jsx(U,{variant:"secondary",children:n.original.code})},{accessorKey:"user_email",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.user_email")})},{accessorKey:"template_name",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.template_name")})},{accessorKey:"created_at",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.created_at")}),cell:({row:n})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(n.original.created_at)})}]};function Jh(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState({pageIndex:0,pageSize:20}),{data:l}=ae({queryKey:["giftCardUsages",a,s,t],queryFn:()=>Ds.getUsages({per_page:a.pageSize,page:a.pageIndex+1,filter:s,sort:t})}),d=Be({data:l?.data??[],columns:Yh(),state:{sorting:t,columnFilters:s,pagination:a},pageCount:Math.ceil((l?.total??0)/a.pageSize),rowCount:l?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,onSortingChange:r,onColumnFiltersChange:n,onPaginationChange:i,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs()});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(k,{placeholder:"搜索用户邮箱...",value:d.getColumn("user_email")?.getFilterValue()??"",onChange:u=>d.getColumn("user_email")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"})}),e.jsx(ts,{table:d})]})}function Qh(){const{t:s}=M("giftCard"),{data:n,isLoading:t}=ae({queryKey:["giftCardStats"],queryFn:()=>Ds.getStatistics({})}),r=n?.data?.total_stats,a=[{title:s("statistics.total.templates_count"),value:r?.templates_count},{title:s("statistics.total.active_templates_count"),value:r?.active_templates_count},{title:s("statistics.total.codes_count"),value:r?.codes_count},{title:s("statistics.total.used_codes_count"),value:r?.used_codes_count}];return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:a.map((i,l)=>e.jsxs(ke,{children:[e.jsx(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:e.jsx(Le,{className:"text-sm font-medium",children:i.title})}),e.jsx(Pe,{children:t?e.jsx(je,{className:"h-8 w-1/2"}):e.jsx("div",{className:"text-2xl font-bold",children:i.value??0})})]},l))})}function Xh(){const{t:s}=M("giftCard"),[n,t]=m.useState("templates");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-6 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.jsxs(gt,{value:n,onValueChange:t,className:"flex-1",children:[e.jsxs(at,{className:"grid w-full grid-cols-4",children:[e.jsx($e,{value:"templates",children:s("tabs.templates")}),e.jsx($e,{value:"codes",children:s("tabs.codes")}),e.jsx($e,{value:"usages",children:s("tabs.usages")}),e.jsx($e,{value:"statistics",children:s("tabs.statistics")})]}),e.jsx(ms,{value:"templates",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("template.description")})]})}),e.jsx($h,{})]})}),e.jsx(ms,{value:"codes",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("code.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("code.description")})]})}),e.jsx(Wh,{})]})}),e.jsx(ms,{value:"usages",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("usage.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("usage.description")})]})}),e.jsx(Jh,{})]})}),e.jsx(ms,{value:"statistics",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("statistics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("statistics.description")})]})}),e.jsx(Qh,{})]})})]})]})]})}const Zh=Object.freeze(Object.defineProperty({__proto__:null,default:Xh},Symbol.toStringTag,{value:"Module"})),eg=1,sg=1e6;let gn=0;function tg(){return gn=(gn+1)%Number.MAX_SAFE_INTEGER,gn.toString()}const pn=new Map,wr=s=>{if(pn.has(s))return;const n=setTimeout(()=>{pn.delete(s),Qt({type:"REMOVE_TOAST",toastId:s})},sg);pn.set(s,n)},ag=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,eg)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(t=>t.id===n.toast.id?{...t,...n.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=n;return t?wr(t):s.toasts.forEach(r=>{wr(r.id)}),{...s,toasts:s.toasts.map(r=>r.id===t||t===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return n.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(t=>t.id!==n.toastId)}}},_a=[];let Na={toasts:[]};function Qt(s){Na=ag(Na,s),_a.forEach(n=>{n(Na)})}function ng({...s}){const n=tg(),t=a=>Qt({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>Qt({type:"DISMISS_TOAST",toastId:n});return Qt({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function wi(){const[s,n]=m.useState(Na);return m.useEffect(()=>(_a.push(n),()=>{const t=_a.indexOf(n);t>-1&&_a.splice(t,1)}),[s]),{...s,toast:ng,dismiss:t=>Qt({type:"DISMISS_TOAST",toastId:t})}}function rg({open:s,onOpenChange:n,table:t}){const{t:r}=M("user"),{toast:a}=wi(),[i,l]=m.useState(!1),[d,u]=m.useState(""),[x,o]=m.useState(""),c=async()=>{if(!d||!x){a({title:r("messages.error"),description:r("messages.send_mail.required_fields"),variant:"destructive"});return}try{l(!0),await Os.sendMail({subject:d,content:x,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),a({title:r("messages.success"),description:r("messages.send_mail.success")}),n(!1),u(""),o("")}catch{a({title:r("messages.error"),description:r("messages.send_mail.failed"),variant:"destructive"})}finally{l(!1)}};return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(ce,{className:"sm:max-w-[500px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("send_mail.title")}),e.jsx(Ae,{children:r("send_mail.description")})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"subject",className:"text-right",children:r("send_mail.subject")}),e.jsx(k,{id:"subject",value:d,onChange:f=>u(f.target.value),className:"col-span-3"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"content",className:"text-right",children:r("send_mail.content")}),e.jsx(Rs,{id:"content",value:x,onChange:f=>o(f.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(Me,{children:e.jsx(G,{type:"submit",onClick:c,disabled:i,children:r(i?"send_mail.sending":"send_mail.send")})})]})})}function lg({trigger:s}){const{t:n}=M("user"),[t,r]=m.useState(!1),[a,i]=m.useState(30),{data:l,isLoading:d}=ae({queryKey:["trafficResetStats",a],queryFn:()=>aa.getStats({days:a}),enabled:t}),u=[{title:n("traffic_reset.stats.total_resets"),value:l?.data?.total_resets||0,icon:Gt,color:"text-blue-600",bgColor:"bg-blue-100"},{title:n("traffic_reset.stats.auto_resets"),value:l?.data?.auto_resets||0,icon:ka,color:"text-green-600",bgColor:"bg-green-100"},{title:n("traffic_reset.stats.manual_resets"),value:l?.data?.manual_resets||0,icon:ws,color:"text-orange-600",bgColor:"bg-orange-100"},{title:n("traffic_reset.stats.cron_resets"),value:l?.data?.cron_resets||0,icon:On,color:"text-purple-600",bgColor:"bg-purple-100"}],x=[{value:7,label:n("traffic_reset.stats.days_options.week")},{value:30,label:n("traffic_reset.stats.days_options.month")},{value:90,label:n("traffic_reset.stats.days_options.quarter")},{value:365,label:n("traffic_reset.stats.days_options.year")}];return e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(ps,{asChild:!0,children:s}),e.jsxs(ce,{className:"max-w-2xl",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(Vn,{className:"h-5 w-5"}),n("traffic_reset.stats.title")]}),e.jsx(Ae,{children:n("traffic_reset.stats.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium",children:n("traffic_reset.stats.time_range")}),e.jsxs(J,{value:a.toString(),onValueChange:o=>i(Number(o)),children:[e.jsx(W,{className:"w-[180px]",children:e.jsx(Q,{})}),e.jsx(Y,{children:x.map(o=>e.jsx(A,{value:o.value.toString(),children:o.label},o.value))})]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Xt,{className:"h-6 w-6 animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.map((o,c)=>e.jsxs(ke,{className:"relative overflow-hidden",children:[e.jsxs(Fe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Le,{className:"text-sm font-medium text-muted-foreground",children:o.title}),e.jsx("div",{className:`rounded-lg p-2 ${o.bgColor}`,children:e.jsx(o.icon,{className:`h-4 w-4 ${o.color}`})})]}),e.jsxs(Pe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:o.value.toLocaleString()}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n("traffic_reset.stats.in_period",{days:a})})]})]},c))}),l?.data&&e.jsxs(ke,{children:[e.jsxs(Fe,{children:[e.jsx(Le,{className:"text-lg",children:n("traffic_reset.stats.breakdown")}),e.jsx(Hs,{children:n("traffic_reset.stats.breakdown_description")})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.auto_percentage")}),e.jsxs(U,{variant:"outline",className:"border-green-200 bg-green-50 text-green-700",children:[l.data.total_resets>0?(l.data.auto_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.manual_percentage")}),e.jsxs(U,{variant:"outline",className:"border-orange-200 bg-orange-50 text-orange-700",children:[l.data.total_resets>0?(l.data.manual_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.cron_percentage")}),e.jsxs(U,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:[l.data.total_resets>0?(l.data.cron_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]})]})})]})]})]})]})}const ig=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(),download_csv:h.boolean().optional()}).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"]}),og={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0,download_csv:!1};function cg({refetch:s}){const{t:n}=M("user"),[t,r]=m.useState(!1),a=we({resolver:Te(ig),defaultValues:og,mode:"onChange"}),[i,l]=m.useState([]);return m.useEffect(()=>{t&&ys.getList().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(ps,{asChild:!0,children:e.jsxs(G,{size:"sm",variant:"outline",className:"gap-0 space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:n("generate.title")}),e.jsx(Ae,{})]}),e.jsxs(De,{...a,children:[e.jsxs(j,{children:[e.jsx(b,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(v,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(k,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...d})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${a.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(v,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(k,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(v,{control:a.control,name:"password",render:({field:d})=>e.jsxs(j,{children:[e.jsx(b,{children:n("generate.form.password")}),e.jsx(k,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(R,{})]})}),e.jsx(v,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(j,{className:"flex flex-col",children:[e.jsx(b,{children:n("generate.form.expire_time")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(G,{variant:"outline",className:N("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?ie(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(Xe,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Nd,{asChild:!0,children:e.jsx(G,{variant:"outline",className:"w-full",onClick:()=>{d.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Cs,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:u=>{u&&d.onChange(u?.getTime()/1e3)}})})]})]})]})}),e.jsx(v,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(j,{children:[e.jsx(b,{children:n("generate.form.subscription")}),e.jsx(_,{children:e.jsxs(J,{value:d.value?d.value.toString():"null",onValueChange:u=>d.onChange(u==="null"?null:parseInt(u)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"null",children:n("generate.form.subscription_none")}),i.map(u=>e.jsx(A,{value:u.id.toString(),children:u.name},u.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(v,{control:a.control,name:"generate_count",render:({field:d})=>e.jsxs(j,{children:[e.jsx(b,{children:n("generate.form.generate_count")}),e.jsx(k,{type:"number",placeholder:n("generate.form.generate_count_placeholder"),value:d.value||"",onChange:u=>d.onChange(u.target.value?parseInt(u.target.value):null)})]})}),a.watch("generate_count")&&e.jsx(v,{control:a.control,name:"download_csv",render:({field:d})=>e.jsxs(j,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Bn,{checked:d.value,onCheckedChange:d.onChange})}),e.jsx(b,{children:n("generate.form.download_csv")})]})})]}),e.jsxs(Me,{children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:n("generate.form.cancel")}),e.jsx(G,{onClick:()=>a.handleSubmit(async d=>{if(d.download_csv){const u=await Os.generate(d);if(u&&u instanceof Blob){const x=window.URL.createObjectURL(u),o=document.createElement("a");o.href=x,o.download=`users_${new Date().getTime()}.csv`,document.body.appendChild(o),o.click(),o.remove(),window.URL.revokeObjectURL(x),$.success(n("generate.form.success")),a.reset(),s(),r(!1)}}else{const{data:u}=await Os.generate(d);u&&($.success(n("generate.form.success")),a.reset(),s(),r(!1))}})(),children:n("generate.form.submit")})]})]})]})}const Gn=Lr,Ci=Er,dg=Vr,Si=m.forwardRef(({className:s,...n},t)=>e.jsx(Va,{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:t}));Si.displayName=Va.displayName;const mg=xt("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"}}),en=m.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(dg,{children:[e.jsx(Si,{}),e.jsxs(Ia,{ref:a,className:N(mg({side:s}),n),...r,children:[e.jsxs(Pn,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));en.displayName=Ia.displayName;const sn=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col space-y-2 text-center sm:text-left",s),...n});sn.displayName="SheetHeader";const ki=({className:s,...n})=>e.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});ki.displayName="SheetFooter";const tn=m.forwardRef(({className:s,...n},t)=>e.jsx(Ma,{ref:t,className:N("text-lg font-semibold text-foreground",s),...n}));tn.displayName=Ma.displayName;const an=m.forwardRef(({className:s,...n},t)=>e.jsx(Oa,{ref:t,className:N("text-sm text-muted-foreground",s),...n}));an.displayName=Oa.displayName;function ug({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=M("user"),{toast:i}=wi(),l=s.getState().columnFilters.length>0,[d,u]=m.useState([]),[x,o]=m.useState(!1),[c,f]=m.useState(!1),[F,S]=m.useState(!1),[w,T]=m.useState(!1),y=async()=>{try{const se=await Os.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),ne=se;console.log(se);const H=new Blob([ne],{type:"text/csv;charset=utf-8;"}),ee=window.URL.createObjectURL(H),fe=document.createElement("a");fe.href=ee,fe.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(fe),fe.click(),fe.remove(),window.URL.revokeObjectURL(ee),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},L=async()=>{try{T(!0),await Os.batchBan({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),i({title:a("messages.success"),description:a("messages.batch_ban.success")}),n()}catch{i({title:a("messages.error"),description:a("messages.batch_ban.failed"),variant:"destructive"})}finally{T(!1),S(!1)}},C=[{label:a("filter.fields.email"),value:"email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.id"),value:"id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:a("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{label:a("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.token"),value:"token",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.banned"),value:"banned",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],options:[{label:a("filter.status.normal"),value:"0"},{label:a("filter.status.banned"),value:"1"}]},{label:a("filter.fields.remark"),value:"remarks",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.inviter_email"),value:"invite_user.email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]}],g=se=>se*1024*1024*1024,p=se=>se/(1024*1024*1024),V=()=>{u([...d,{field:"",operator:"",value:""}])},E=se=>{u(d.filter((ne,H)=>H!==se))},P=(se,ne,H)=>{const ee=[...d];if(ee[se]={...ee[se],[ne]:H},ne==="field"){const fe=C.find(fs=>fs.value===H);fe&&(ee[se].operator=fe.operators[0].value,ee[se].value=fe.type==="boolean"?!1:"")}u(ee)},K=(se,ne)=>{const H=C.find(ee=>ee.value===se.field);if(!H)return null;switch(H.type){case"text":return e.jsx(k,{placeholder:a("filter.sheet.value"),value:se.value,onChange:ee=>P(ne,"value",ee.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(k,{type:"number",placeholder:a("filter.sheet.value_number",{unit:H.unit}),value:H.unit==="GB"?p(se.value||0):se.value,onChange:ee=>{const fe=Number(ee.target.value);P(ne,"value",H.unit==="GB"?g(fe):fe)}}),H.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:H.unit})]});case"date":return e.jsx(Cs,{mode:"single",selected:se.value,onSelect:ee=>P(ne,"value",ee),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(J,{value:se.value,onValueChange:ee=>P(ne,"value",ee),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.value")})}),e.jsx(Y,{children:H.useOptions?r.map(ee=>e.jsx(A,{value:ee.value.toString(),children:ee.label},ee.value)):H.options?.map(ee=>e.jsx(A,{value:ee.value.toString(),children:ee.label},ee.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(X,{checked:se.value,onCheckedChange:ee=>P(ne,"value",ee)}),e.jsx(Je,{children:se.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},Z=()=>{const se=d.filter(ne=>ne.field&&ne.operator&&ne.value!=="").map(ne=>{const H=C.find(fe=>fe.value===ne.field);let ee=ne.value;return ne.operator==="contains"?{id:ne.field,value:ee}:(H?.type==="date"&&ee instanceof Date&&(ee=Math.floor(ee.getTime()/1e3)),H?.type==="boolean"&&(ee=ee?1:0),{id:ne.field,value:`${ne.operator}:${ee}`})});s.setColumnFilters(se),o(!1)};return e.jsxs("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(cg,{refetch:n}),e.jsx(k,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:se=>s.getColumn("email")?.setFilterValue(se.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Gn,{open:x,onOpenChange:o,children:[e.jsx(Ci,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),a("filter.advanced"),d.length>0&&e.jsx(U,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:d.length})]})}),e.jsxs(en,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(sn,{children:[e.jsx(tn,{children:a("filter.sheet.title")}),e.jsx(an,{children:a("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:a("filter.sheet.conditions")}),e.jsx(D,{variant:"outline",size:"sm",onClick:V,children:a("filter.sheet.add")})]}),e.jsx(ut,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((se,ne)=>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(Je,{children:a("filter.sheet.condition",{number:ne+1})}),e.jsx(D,{variant:"ghost",size:"sm",onClick:()=>E(ne),children:e.jsx(os,{className:"h-4 w-4"})})]}),e.jsxs(J,{value:se.field,onValueChange:H=>P(ne,"field",H),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.field")})}),e.jsx(Y,{children:e.jsx(js,{children:C.map(H=>e.jsx(A,{value:H.value,className:"cursor-pointer",children:H.label},H.value))})})]}),se.field&&e.jsxs(J,{value:se.operator,onValueChange:H=>P(ne,"operator",H),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:a("filter.sheet.operator")})}),e.jsx(Y,{children:C.find(H=>H.value===se.field)?.operators.map(H=>e.jsx(A,{value:H.value,children:H.label},H.value))})]}),se.field&&se.operator&&K(se,ne)]},ne))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(D,{variant:"outline",onClick:()=>{u([]),o(!1)},children:a("filter.sheet.reset")}),e.jsx(D,{onClick:Z,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(D,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[a("filter.sheet.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]}),e.jsxs(zs,{modal:!1,children:[e.jsx(Ks,{asChild:!0,children:e.jsx(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(Ms,{children:[e.jsx(Se,{onClick:()=>f(!0),children:a("actions.send_email")}),e.jsx(Se,{onClick:y,children:a("actions.export_csv")}),e.jsx(et,{}),e.jsx(Se,{asChild:!0,children:e.jsx(lg,{trigger:e.jsx("div",{className:"w-full cursor-pointer px-2 py-1.5 text-sm",children:a("actions.traffic_reset_stats")})})}),e.jsx(et,{}),e.jsx(Se,{onClick:()=>S(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(rg,{open:c,onOpenChange:f,table:s}),e.jsx(Hn,{open:F,onOpenChange:S,children:e.jsxs(Ka,{children:[e.jsxs(Ba,{children:[e.jsx(Wa,{children:a("actions.confirm_ban.title")}),e.jsx(Ya,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs(Ga,{children:[e.jsx(Qa,{disabled:w,children:a("actions.confirm_ban.cancel")}),e.jsx(Ja,{onClick:L,disabled:w,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(w?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const Ti=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"})}),Di=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"})}),xg=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"})}),hg=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"})}),fn=[{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:qd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ti,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:ze(s.original.u/parseFloat(s.original.server_rate))})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Di,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:ze(s.original.d/parseFloat(s.original.server_rate))})]})},{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(U,{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:ze(n)})}}];function Fi({user_id:s,dialogTrigger:n}){const{t}=M(["traffic"]),[r,a]=m.useState(!1),[i,l]=m.useState({pageIndex:0,pageSize:20}),{data:d,isLoading:u}=ae({queryKey:["userStats",s,i,r],queryFn:()=>r?Os.getStats({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),x=Be({data:d?.data??[],columns:fn,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:Ge(),onPaginationChange:l});return e.jsxs(de,{open:r,onOpenChange:a,children:[e.jsx(ps,{asChild:!0,children:n}),e.jsxs(ce,{className:"sm:max-w-[700px]",children:[e.jsx(he,{children:e.jsx(me,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs($n,{children:[e.jsx(An,{children:x.getHeaderGroups().map(o=>e.jsx(Js,{children:o.headers.map(c=>e.jsx(Un,{className:N("h-10 px-2 text-xs",c.id==="total"&&"text-right"),children:c.isPlaceholder?null:Ca(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsx(qn,{children:u?Array.from({length:i.pageSize}).map((o,c)=>e.jsx(Js,{children:Array.from({length:fn.length}).map((f,F)=>e.jsx(Tt,{className:"p-2",children:e.jsx(je,{className:"h-6 w-full"})},F))},c)):x.getRowModel().rows?.length?x.getRowModel().rows.map(o=>e.jsx(Js,{"data-state":o.getIsSelected()&&"selected",className:"h-10",children:o.getVisibleCells().map(c=>e.jsx(Tt,{className:"px-2",children:Ca(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsx(Js,{children:e.jsx(Tt,{colSpan:fn.length,className:"h-24 text-center",children:t("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:t("trafficRecord.perPage")}),e.jsxs(J,{value:`${x.getState().pagination.pageSize}`,onValueChange:o=>{x.setPageSize(Number(o))},children:[e.jsx(W,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:x.getState().pagination.pageSize})}),e.jsx(Y,{side:"top",children:[10,20,30,40,50].map(o=>e.jsx(A,{value:`${o}`,children:o},o))})]}),e.jsx("p",{className:"text-sm font-medium",children:t("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:t("trafficRecord.page",{current:x.getState().pagination.pageIndex+1,total:x.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:()=>x.previousPage(),disabled:!x.getCanPreviousPage()||u,children:e.jsx(xg,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>x.nextPage(),disabled:!x.getCanNextPage()||u,children:e.jsx(hg,{className:"h-4 w-4"})})]})]})]})]})]})]})}function gg({user:s,trigger:n,onSuccess:t}){const{t:r}=M("user"),[a,i]=m.useState(!1),[l,d]=m.useState(""),[u,x]=m.useState(!1),{data:o,isLoading:c}=ae({queryKey:["trafficResetHistory",s.id],queryFn:()=>aa.getUserHistory(s.id,{limit:10}),enabled:a}),f=async()=>{try{x(!0);const{data:w}=await aa.resetUser({user_id:s.id,reason:l.trim()||void 0});w&&($.success(r("traffic_reset.reset_success")),i(!1),d(""),t?.())}finally{x(!1)}},F=w=>{switch(w){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},S=w=>{switch(w){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}};return e.jsxs(de,{open:a,onOpenChange:i,children:[e.jsx(ps,{asChild:!0,children:n}),e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-hidden",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(Gt,{className:"h-5 w-5"}),r("traffic_reset.title")]}),e.jsx(Ae,{children:r("traffic_reset.description",{email:s.email})})]}),e.jsxs(gt,{defaultValue:"reset",className:"w-full",children:[e.jsxs(at,{className:"grid w-full grid-cols-2",children:[e.jsxs($e,{value:"reset",className:"flex items-center gap-2",children:[e.jsx(Gt,{className:"h-4 w-4"}),r("traffic_reset.tabs.reset")]}),e.jsxs($e,{value:"history",className:"flex items-center gap-2",children:[e.jsx(or,{className:"h-4 w-4"}),r("traffic_reset.tabs.history")]})]}),e.jsxs(ms,{value:"reset",className:"space-y-4",children:[e.jsxs(ke,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Le,{className:"flex items-center gap-2 text-lg",children:[e.jsx(El,{className:"h-5 w-5"}),r("traffic_reset.user_info")]})}),e.jsx(Pe,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.email")}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.used_traffic")}),e.jsx("p",{className:"font-medium",children:ze(s.total_used)})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.total_traffic")}),e.jsx("p",{className:"font-medium",children:ze(s.transfer_enable)})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.expire_time")}),e.jsx("p",{className:"font-medium",children:s.expired_at?ie(s.expired_at):r("columns.expire_status.permanent")})]})]})})]}),e.jsxs(ke,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Fe,{className:"pb-3",children:e.jsxs(Le,{className:"flex items-center gap-2 text-lg text-amber-800",children:[e.jsx(Bt,{className:"h-5 w-5"}),r("traffic_reset.warning.title")]})}),e.jsx(Pe,{children:e.jsxs("ul",{className:"space-y-2 text-sm text-amber-700",children:[e.jsxs("li",{children:["• ",r("traffic_reset.warning.irreversible")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.reset_to_zero")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.logged")]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"reason",children:r("traffic_reset.reason.label")}),e.jsx(Rs,{id:"reason",placeholder:r("traffic_reset.reason.placeholder"),value:l,onChange:w=>d(w.target.value),className:"min-h-[80px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("traffic_reset.reason.optional")})]}),e.jsxs(Me,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:r("common:cancel")}),e.jsx(G,{onClick:f,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Xt,{className:"mr-2 h-4 w-4 animate-spin"}),r("traffic_reset.resetting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),r("traffic_reset.confirm_reset")]})})]})]}),e.jsx(ms,{value:"history",className:"space-y-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Xt,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[o?.data?.user&&e.jsxs(ke,{children:[e.jsx(Fe,{className:"pb-3",children:e.jsx(Le,{className:"text-lg",children:r("traffic_reset.history.summary")})}),e.jsx(Pe,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.reset_count")}),e.jsx("p",{className:"font-medium",children:o.data.user.reset_count})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.last_reset")}),e.jsx("p",{className:"font-medium",children:o.data.user.last_reset_at?ie(o.data.user.last_reset_at):r("traffic_reset.history.never")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.next_reset")}),e.jsx("p",{className:"font-medium",children:o.data.user.next_reset_at?ie(o.data.user.next_reset_at):r("traffic_reset.history.no_schedule")})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Fe,{className:"pb-3",children:[e.jsx(Le,{className:"text-lg",children:r("traffic_reset.history.records")}),e.jsx(Hs,{children:r("traffic_reset.history.recent_records")})]}),e.jsx(Pe,{children:e.jsx(ut,{className:"h-[300px]",children:o?.data?.history?.length?e.jsx("div",{className:"space-y-3",children:o.data.history.map((w,T)=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between rounded-lg border bg-card p-3",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:F(w.reset_type),children:w.reset_type_name}),e.jsx(U,{variant:"outline",className:S(w.trigger_source),children:w.trigger_source_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs(Je,{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(On,{className:"h-3 w-3"}),r("traffic_reset.history.reset_time")]}),e.jsx("p",{className:"font-medium",children:ie(w.reset_time)})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.traffic_cleared")}),e.jsx("p",{className:"font-medium text-destructive",children:w.old_traffic.formatted})]})]})]})}),Te.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"})}),jg=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"})}),vg=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"})}),Cr=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"})}),bg=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"})}),yg=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"})}),_g=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"})}),Ng=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"})}),wg=(s,n,t,r)=>{const{t:a}=M("user");return[{accessorKey:"is_admin",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"is_staff",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.id")}),cell:({row:i})=>e.jsx(U,{variant:"outline",children:i.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.email")}),cell:({row:i})=>{const l=i.original.t||0,d=Date.now()/1e3-l<120,u=Math.floor(Date.now()/1e3-l);let x=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:ie(l)});if(!d&&l!==0){const o=Math.floor(u/60),c=Math.floor(o/60),f=Math.floor(c/24);f>0?x+=`
-`+a("columns.online_status.offline_duration.days",{count:f}):c>0?x+=`
+`);u.onChange(o)}})})}),e.jsx(R,{})]})}),e.jsx(b,{control:i.control,name:"action",render:({field:u})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.action")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsxs(J,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:a("form.actionPlaceholder")})}),e.jsxs(W,{children:[e.jsx(A,{value:"block",children:a("actions.block")}),e.jsx(A,{value:"dns",children:a("actions.dns")})]})]})})}),e.jsx(R,{})]})}),i.watch("action")==="dns"&&e.jsx(b,{control:i.control,name:"action_value",render:({field:u})=>e.jsxs(v,{children:[e.jsx(y,{children:a("form.dns")}),e.jsx("div",{className:"relative",children:e.jsx(_,{children:e.jsx(D,{type:"text",placeholder:a("form.dnsPlaceholder"),...u})})})]})}),e.jsxs(Me,{children:[e.jsx(Qs,{asChild:!0,children:e.jsx(F,{variant:"outline",children:a("form.cancel")})}),e.jsx(F,{type:"submit",onClick:()=>{const u=i.getValues(),x={...u,match:Array.isArray(u.match)?u.match.filter(o=>o.trim()!==""):[]};qa.save(x).then(({data:o})=>{o&&(d(!1),s&&s(),$.success(a(r==="edit"?"messages.updateSuccess":"messages.createSuccess")),i.reset())})},children:a("form.submit")})]})]})]})]})}function Jx({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=M("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(fi,{refetch:n}),e.jsx(D,{placeholder:r("toolbar.searchPlaceholder"),value:s.getColumn("remarks")?.getFilterValue()??"",onChange:a=>s.getColumn("remarks")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),t&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})})}function Qx({columns:s,data:n,refetch:t}){const[r,a]=m.useState({}),[i,l]=m.useState({}),[d,u]=m.useState([]),[x,o]=m.useState([]),c=Be({data:n,columns:s,state:{sorting:x,columnVisibility:i,rowSelection:r,columnFilters:d},enableRowSelection:!0,onRowSelectionChange:a,onSortingChange:o,onColumnFiltersChange:u,onColumnVisibilityChange:l,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:c,toolbar:j=>e.jsx(Jx,{table:j,refetch:t})})}const Xx=s=>{const{t:n}=M("route"),t={block:{icon:ud,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:xd,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:r})=>e.jsx(O,{column:r,title:n("columns.id")}),cell:({row:r})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:r.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"remarks",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.remarks")}),cell:({row:r})=>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:r.original.remarks})}),enableHiding:!1,enableSorting:!1},{accessorKey:"action_value",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action_value.title")}),cell:({row:r})=>{const a=r.original.action,i=r.original.action_value,l=r.original.match?.length||0;return e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("span",{className:"text-sm font-medium",children:a==="dns"&&i?n("columns.action_value.dns",{value:i}):a==="block"?e.jsx("span",{className:"text-destructive",children:n("columns.action_value.block")}):n("columns.action_value.direct")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:n("columns.matchRules",{count:l})})]})},enableHiding:!1,enableSorting:!1,size:300},{accessorKey:"action",header:({column:r})=>e.jsx(O,{column:r,title:n("columns.action")}),cell:({row:r})=>{const a=r.getValue("action"),i=t[a]?.icon;return e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(U,{variant:t[a]?.variant||"default",className:w("flex items-center gap-1.5 px-3 py-1 capitalize",t[a]?.className),children:[i&&e.jsx(i,{className:"h-3.5 w-3.5"}),n(`actions.${a}`)]})})},enableSorting:!1,size:9e3},{id:"actions",header:()=>e.jsx("div",{className:"text-right",children:n("columns.actions")}),cell:({row:r})=>e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(fi,{defaultValues:r.original,refetch:s,type:"edit",dialogTrigger:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("form.edit")})]})}),e.jsx(_s,{title:n("messages.deleteConfirm"),description:n("messages.deleteDescription"),confirmText:n("messages.deleteButton"),variant:"destructive",onConfirm:async()=>{qa.drop({id:r.original.id}).then(({data:a})=>{a&&($.success(n("messages.deleteSuccess")),s())})},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 Zx(){const{t:s}=M("route"),[n,t]=m.useState([]);function r(){qa.getList().then(({data:a})=>{t(a)})}return m.useEffect(()=>{r()},[]),e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Qx,{data:n,columns:Xx(r),refetch:r})})]})]})}const eh=Object.freeze(Object.defineProperty({__proto__:null,default:Zx},Symbol.toStringTag,{value:"Module"})),ji=m.createContext(void 0);function sh({children:s,refreshData:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null);return e.jsx(ji.Provider,{value:{isOpen:t,setIsOpen:r,editingPlan:a,setEditingPlan:i,refreshData:n},children:s})}function Bn(){const s=m.useContext(ji);if(s===void 0)throw new Error("usePlanEdit must be used within a PlanEditProvider");return s}function th({table:s,saveOrder:n,isSortMode:t}){const{setIsOpen:r}=Bn(),{t:a}=M("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(F,{variant:"outline",className:"space-x-2",size:"sm",onClick:()=>r(!0),children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:a("plan.add")})]}),e.jsx(D,{placeholder:a("plan.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:i=>s.getColumn("name")?.setFilterValue(i.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(F,{variant:t?"default":"outline",onClick:n,size:"sm",children:a(t?"plan.sort.save":"plan.sort.edit")})})]})}const Nr={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"}},ah=s=>{const{t:n}=M("subscribe");return[{id:"drag-handle",header:()=>null,cell:()=>e.jsx("div",{className:"cursor-move",children:e.jsx(za,{className:"size-4"})}),size:40,enableSorting:!1},{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.id")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(U,{variant:"outline",children:t.getValue("id")})}),enableSorting:!0,enableHiding:!1},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.show")}),cell:({row:t})=>e.jsx(Z,{defaultChecked:t.getValue("show"),onCheckedChange:r=>{ys.update({id:t.original.id,show:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"sell",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.sell")}),cell:({row:t})=>e.jsx(Z,{defaultChecked:t.getValue("sell"),onCheckedChange:r=>{ys.update({id:t.original.id,sell:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"renew",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.renew"),tooltip:n("plan.columns.renew_tooltip")}),cell:({row:t})=>e.jsx(Z,{defaultChecked:t.getValue("renew"),onCheckedChange:r=>{ys.update({id:t.original.id,renew:r}).then(({data:a})=>{!a&&s()})}}),enableSorting:!1,enableHiding:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.name")}),cell:({row:t})=>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:t.getValue("name")})}),enableSorting:!1,enableHiding:!1,size:900},{accessorKey:"users_count",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.stats")}),cell:({row:t})=>{const r=t.getValue("users_count")||0,a=t.original.active_users_count||0,i=r>0?Math.round(a/r*100):0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-slate-50 px-2 py-1 hover:bg-slate-100 transition-colors cursor-help",children:[e.jsx(wa,{className:"h-3.5 w-3.5 text-slate-500"}),e.jsx("span",{className:"text-sm font-medium text-slate-700",children:r})]})}),e.jsx(ue,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"总用户数"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"所有使用该套餐的用户(包括已过期)"})]})})]})}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 rounded-md bg-green-50 px-2 py-1 hover:bg-green-100 transition-colors cursor-help",children:[e.jsx(hd,{className:"h-3.5 w-3.5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:a})]})}),e.jsx(ue,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"有效期内用户"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"当前仍在有效期内的活跃用户"}),r>0&&e.jsxs("p",{className:"text-xs font-medium text-green-600",children:["活跃率:",i,"%"]})]})})]})})]})},enableSorting:!0,size:120},{accessorKey:"group",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.group")}),cell:({row:t})=>e.jsx("div",{className:"flex max-w-[600px] flex-wrap items-center gap-1.5 text-nowrap",children:e.jsx(U,{variant:"secondary",className:w("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:t.getValue("group")?.name})}),enableSorting:!1,enableHiding:!1},{accessorKey:"prices",header:({column:t})=>e.jsx(O,{column:t,title:n("plan.columns.price")}),cell:({row:t})=>{const r=t.getValue("prices"),a=[{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:a.map(({period:i,key:l,unit:d})=>r[l]!=null&&e.jsxs(U,{variant:"secondary",className:w("px-2 py-0.5 font-medium transition-colors text-nowrap",Nr[l].color,Nr[l].bgColor,"border border-border/50","hover:bg-slate-200/80"),children:[i," ¥",r[l],d]},l))})},enableSorting:!1,size:9e3},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("plan.columns.actions")}),cell:({row:t})=>{const{setIsOpen:r,setEditingPlan:a}=Bn();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>{a(t.original),r(!0)},children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("plan.columns.edit")})]}),e.jsx(_s,{title:n("plan.columns.delete_confirm.title"),description:n("plan.columns.delete_confirm.description"),confirmText:n("plan.columns.delete"),variant:"destructive",onConfirm:async()=>{ys.drop({id:t.original.id}).then(({data:i})=>{i&&($.success(n("plan.columns.delete_confirm.success")),s())})},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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")})]})})]})}}]},nh=h.object({id:h.number().nullable(),group_id:h.union([h.number(),h.string()]).nullable().optional(),name:h.string().min(1).max(250),tags:h.array(h.string()).nullable().optional(),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(),active_users_count:h.number().optional()}),Gn=m.forwardRef(({className:s,...n},t)=>e.jsx(Dl,{ref:t,className:w("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(gd,{className:w("flex items-center justify-center text-current"),children:e.jsx(ht,{className:"h-4 w-4"})})}));Gn.displayName=Dl.displayName;const fa={id:null,group_id:null,name:"",tags:[],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},ja={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}},rh=[{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 lh(){const{isOpen:s,setIsOpen:n,editingPlan:t,setEditingPlan:r,refreshData:a}=Bn(),[i,l]=m.useState(!1),{t:d}=M("subscribe"),u=we({resolver:Te(nh),defaultValues:{...fa,...t||{}},mode:"onChange"});m.useEffect(()=>{t?u.reset({...fa,...t}):u.reset(fa)},[t,u]);const x=new Mn({html:!0}),[o,c]=m.useState();async function j(){pt.getList().then(({data:p})=>{c(p)})}m.useEffect(()=>{s&&j()},[s]);const P=async p=>{l(!0),ys.save(p).then(({data:S})=>{S&&($.success(d(t?"plan.form.submit.success.update":"plan.form.submit.success.add")),T(),a())}).finally(()=>{l(!1)})},k=p=>{const S=Object.values(p).map(N=>N?.message).filter(Boolean);$.error(S.join(`
+`)||d("plan.form.submit.error.validation","表单校验失败"))},C=p=>{if(isNaN(p))return;const S=Object.entries(ja).reduce((N,[g,f])=>{const V=p*f.months*f.discount;return{...N,[g]:V.toFixed(2)}},{});u.setValue("prices",S,{shouldDirty:!0})},T=()=>{n(!1),r(null),u.reset(fa)};return e.jsx(de,{open:s,onOpenChange:T,children:e.jsxs(ce,{children:[e.jsxs(he,{children:[e.jsx(me,{children:d(t?"plan.form.edit_title":"plan.form.add_title")}),e.jsx(Ae,{})]}),e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(P,k),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{control:u.control,name:"name",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:d("plan.form.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:d("plan.form.name.placeholder"),...p})}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"tags",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:d("plan.form.tags.label","标签")}),e.jsx(_,{children:e.jsx(Xa,{value:p.value||[],onChange:p.onChange,placeholder:d("plan.form.tags.placeholder","输入标签后按回车确认"),className:"w-full"})}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"group_id",render:({field:p})=>e.jsxs(v,{children:[e.jsxs(y,{className:"flex items-center justify-between",children:[d("plan.form.group.label"),e.jsx(Za,{dialogTrigger:e.jsx(F,{variant:"link",children:d("plan.form.group.add")}),refetch:j})]}),e.jsxs(J,{value:p.value?.toString()??"",onValueChange:S=>p.onChange(S?Number(S):null),children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:d("plan.form.group.placeholder")})})}),e.jsx(W,{children:o?.map(S=>e.jsx(A,{value:S.id.toString(),children:S.name},S.id))})]}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"transfer_enable",render:({field:p})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:d("plan.form.transfer.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.transfer.placeholder"),className:"rounded-r-none",...p})}),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:d("plan.form.transfer.unit")})]}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"speed_limit",render:({field:p})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:d("plan.form.speed.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.speed.placeholder"),className:"rounded-r-none",...p,value:p.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:d("plan.form.speed.unit")})]}),e.jsx(R,{})]})}),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:d("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",step:"0.01",placeholder:d("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:p=>{const S=parseFloat(p.target.value);C(S)}})]}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{const p=Object.keys(ja).reduce((S,N)=>({...S,[N]:""}),{});u.setValue("prices",p,{shouldDirty:!0})},children:d("plan.form.price.clear.button")})}),e.jsx(ue,{side:"top",align:"end",children:e.jsx("p",{className:"text-xs",children:d("plan.form.price.clear.tooltip")})})]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:Object.entries(ja).filter(([p])=>!["onetime","reset_traffic"].includes(p)).map(([p,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:u.control,name:`prices.${p}`,render:({field:N})=>e.jsxs(v,{children:[e.jsxs(y,{className:"text-xs font-medium text-muted-foreground",children:[d(`plan.columns.price_period.${p}`),e.jsxs("span",{className:"ml-1 text-[10px] text-gray-400",children:["(",S.months===1?d("plan.form.price.period.monthly"):d("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,step:"0.01",...N,value:N.value??"",onChange:g=>N.onChange(g.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"})})]})]})})},p))}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:Object.entries(ja).filter(([p])=>["onetime","reset_traffic"].includes(p)).map(([p,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:u.control,name:`prices.${p}`,render:({field:N})=>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:d(`plan.columns.price_period.${p}`)}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:d(p==="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,step:"0.01",...N,value:N.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"})})]})]})})})},p))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(b,{control:u.control,name:"device_limit",render:({field:p})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:d("plan.form.device.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.device.placeholder"),className:"rounded-r-none",...p,value:p.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:d("plan.form.device.unit")})]}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"capacity_limit",render:({field:p})=>e.jsxs(v,{className:"flex-1",children:[e.jsx(y,{children:d("plan.form.capacity.label")}),e.jsxs("div",{className:"relative flex",children:[e.jsx(_,{children:e.jsx(D,{type:"number",min:0,placeholder:d("plan.form.capacity.placeholder"),className:"rounded-r-none",...p,value:p.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:d("plan.form.capacity.unit")})]}),e.jsx(R,{})]})})]}),e.jsx(b,{control:u.control,name:"reset_traffic_method",render:({field:p})=>e.jsxs(v,{children:[e.jsx(y,{children:d("plan.form.reset_method.label")}),e.jsxs(J,{value:p.value?.toString()??"null",onValueChange:S=>p.onChange(S=="null"?null:Number(S)),children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:d("plan.form.reset_method.placeholder")})})}),e.jsx(W,{children:rh.map(S=>e.jsx(A,{value:S.value?.toString()??"null",children:d(`plan.form.reset_method.options.${S.label}`)},S.value))})]}),e.jsx(z,{className:"text-xs",children:d("plan.form.reset_method.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"content",render:({field:p})=>{const[S,N]=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:[d("plan.form.content.label"),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(F,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",type:"button",onClick:()=>N(!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(ue,{side:"top",children:e.jsx("p",{className:"text-xs",children:d(S?"plan.form.content.preview_button.hide":"plan.form.content.preview_button.show")})})]})})]}),e.jsx(be,{children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"sm",type:"button",onClick:()=>{p.onChange(d("plan.form.content.template.content"))},children:d("plan.form.content.template.button")})}),e.jsx(ue,{side:"left",align:"center",children:e.jsx("p",{className:"text-xs",children:d("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(On,{style:{height:"400px"},value:p.value||"",renderHTML:g=>x.render(g),onChange:({text:g})=>p.onChange(g),config:{view:{menu:!0,md:!0,html:!1},canView:{menu:!0,md:!0,html:!1,fullScreen:!1,hideMenu:!1}},placeholder:d("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:d("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:x.render(p.value||"")}})})]})]}),e.jsx(z,{className:"text-xs",children:d("plan.form.content.description")}),e.jsx(R,{})]})}})]}),e.jsx(Me,{className:"mt-6",children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("div",{className:"flex-shrink-0",children:t&&e.jsx(b,{control:u.control,name:"force_update",render:({field:p})=>e.jsxs(v,{className:"flex flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Gn,{checked:p.value,onCheckedChange:p.onChange})}),e.jsx("div",{className:"",children:e.jsx(y,{className:"text-sm",children:d("plan.form.force_update.label")})})]})})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(F,{type:"button",variant:"outline",onClick:T,children:d("plan.form.submit.cancel")}),e.jsx(F,{type:"submit",disabled:i,children:d(i?"plan.form.submit.submitting":"plan.form.submit.submit")})]})]})})]})})]})})}function ih(){const[s,n]=m.useState({}),[t,r]=m.useState({"drag-handle":!1}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState(!1),[o,c]=m.useState({pageSize:20,pageIndex:0}),[j,P]=m.useState([]),{refetch:k}=ne({queryKey:["planList"],queryFn:async()=>{const{data:N}=await ys.getList();return P(N),N}});m.useEffect(()=>{r({"drag-handle":u}),c({pageSize:u?99999:10,pageIndex:0})},[u]);const C=(N,g)=>{u&&(N.dataTransfer.setData("text/plain",g.toString()),N.currentTarget.classList.add("opacity-50"))},T=(N,g)=>{if(!u)return;N.preventDefault(),N.currentTarget.classList.remove("bg-muted");const f=parseInt(N.dataTransfer.getData("text/plain"));if(f===g)return;const V=[...j],[E]=V.splice(f,1);V.splice(g,0,E),P(V)},p=async()=>{if(!u){x(!0);return}const N=j?.map(g=>g.id);ys.sort(N).then(()=>{$.success("排序保存成功"),x(!1),k()}).finally(()=>{x(!1)})},S=Be({data:j||[],columns:ah(k),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:o},enableRowSelection:!0,onPaginationChange:c,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}},pageCount:u?1:void 0});return e.jsx(sh,{refreshData:k,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ts,{table:S,toolbar:N=>e.jsx(th,{table:N,refetch:k,saveOrder:p,isSortMode:u}),draggable:u,onDragStart:C,onDragEnd:N=>N.currentTarget.classList.remove("opacity-50"),onDragOver:N=>{N.preventDefault(),N.currentTarget.classList.add("bg-muted")},onDragLeave:N=>N.currentTarget.classList.remove("bg-muted"),onDrop:T,showPagination:!u}),e.jsx(lh,{})]})})}function oh(){const{t:s}=M("subscribe");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(ih,{})})]})]})}const ch=Object.freeze(Object.defineProperty({__proto__:null,default:oh},Symbol.toStringTag,{value:"Module"})),Ct=[{value:le.PENDING,label:zt[le.PENDING],icon:pd,color:$t[le.PENDING]},{value:le.PROCESSING,label:zt[le.PROCESSING],icon:Pl,color:$t[le.PROCESSING]},{value:le.COMPLETED,label:zt[le.COMPLETED],icon:Cn,color:$t[le.COMPLETED]},{value:le.CANCELLED,label:zt[le.CANCELLED],icon:Ll,color:$t[le.CANCELLED]},{value:le.DISCOUNTED,label:zt[le.DISCOUNTED],icon:Cn,color:$t[le.DISCOUNTED]}],Ut=[{value:Ce.PENDING,label:xa[Ce.PENDING],icon:fd,color:ha[Ce.PENDING]},{value:Ce.PROCESSING,label:xa[Ce.PROCESSING],icon:Pl,color:ha[Ce.PROCESSING]},{value:Ce.VALID,label:xa[Ce.VALID],icon:Cn,color:ha[Ce.VALID]},{value:Ce.INVALID,label:xa[Ce.INVALID],icon:Ll,color:ha[Ce.INVALID]}];function va({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=s?.getFilterValue(),i=Array.isArray(a)?new Set(a):a!==void 0?new Set([a]):new Set;return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,i?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:i.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:i.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[i.size," selected"]}):t.filter(l=>i.has(l.value)).map(l=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:l.label},l.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(l=>{const d=i.has(l.value);return e.jsxs(rs,{onSelect:()=>{const u=new Set(i);d?u.delete(l.value):u.add(l.value);const x=Array.from(u);s?.setFilterValue(x.length?x:void 0)},children:[e.jsx("div",{className:w("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",d?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{className:w("h-4 w-4")})}),l.icon&&e.jsx(l.icon,{className:`mr-2 h-4 w-4 text-muted-foreground text-${l.color}`}),e.jsx("span",{children:l.label}),r?.get(l.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(l.value)})]},l.value)})}),i.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Rt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const dh=h.object({email:h.string().min(1),plan_id:h.number(),period:h.string(),total_amount:h.number()}),mh={email:"",plan_id:0,total_amount:0,period:""};function vi({refetch:s,trigger:n,defaultValues:t}){const{t:r}=M("order"),[a,i]=m.useState(!1),l=we({resolver:Te(dh),defaultValues:{...mh,...t},mode:"onChange"}),[d,u]=m.useState([]);return m.useEffect(()=>{a&&ys.getList().then(({data:x})=>{u(x)})},[a]),e.jsxs(de,{open:a,onOpenChange:i,children:[e.jsx(ps,{asChild:!0,children:n||e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:r("dialog.addOrder")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("dialog.assignOrder")}),e.jsx(Ae,{})]}),e.jsxs(De,{...l,children:[e.jsx(b,{control:l.control,name:"email",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dialog.fields.userEmail")}),e.jsx(_,{children:e.jsx(D,{placeholder:r("dialog.placeholders.email"),...x})})]})}),e.jsx(b,{control:l.control,name:"plan_id",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dialog.fields.subscriptionPlan")}),e.jsx(_,{children:e.jsxs(J,{value:x.value?x.value?.toString():void 0,onValueChange:o=>x.onChange(parseInt(o)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.plan")})}),e.jsx(W,{children:d.map(o=>e.jsx(A,{value:o.id.toString(),children:o.name},o.id))})]})})]})}),e.jsx(b,{control:l.control,name:"period",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dialog.fields.orderPeriod")}),e.jsx(_,{children:e.jsxs(J,{value:x.value,onValueChange:x.onChange,children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:r("dialog.placeholders.period")})}),e.jsx(W,{children:Object.keys(Vm).map(o=>e.jsx(A,{value:o,children:r(`period.${o}`)},o))})]})})]})}),e.jsx(b,{control:l.control,name:"total_amount",render:({field:x})=>e.jsxs(v,{children:[e.jsx(y,{children:r("dialog.fields.paymentAmount")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:r("dialog.placeholders.amount"),value:x.value/100,onChange:o=>x.onChange(parseFloat(o.currentTarget.value)*100)})}),e.jsx(R,{})]})}),e.jsxs(Me,{children:[e.jsx(F,{variant:"outline",onClick:()=>i(!1),children:r("dialog.actions.cancel")}),e.jsx(F,{type:"submit",onClick:()=>{l.handleSubmit(x=>{ct.assign(x).then(({data:o})=>{o&&(s&&s(),l.reset(),i(!1),$.success(r("dialog.messages.addSuccess")))})})()},children:r("dialog.actions.confirm")})]})]})]})]})}function uh({table:s,refetch:n}){const{t}=M("order"),r=s.getState().columnFilters.length>0,a=Object.values(Vs).filter(u=>typeof u=="number").map(u=>({label:t(`type.${Vs[u]}`),value:u,color:u===Vs.NEW?"green-500":u===Vs.RENEWAL?"blue-500":u===Vs.UPGRADE?"purple-500":"orange-500"})),i=Object.values(Qe).map(u=>({label:t(`period.${u}`),value:u,color:u===Qe.MONTH_PRICE?"slate-500":u===Qe.QUARTER_PRICE?"cyan-500":u===Qe.HALF_YEAR_PRICE?"indigo-500":u===Qe.YEAR_PRICE?"violet-500":u===Qe.TWO_YEAR_PRICE?"fuchsia-500":u===Qe.THREE_YEAR_PRICE?"pink-500":u===Qe.ONETIME_PRICE?"rose-500":"orange-500"})),l=Object.values(le).filter(u=>typeof u=="number").map(u=>({label:t(`status.${le[u]}`),value:u,icon:u===le.PENDING?Ct[0].icon:u===le.PROCESSING?Ct[1].icon:u===le.COMPLETED?Ct[2].icon:u===le.CANCELLED?Ct[3].icon:Ct[4].icon,color:u===le.PENDING?"yellow-500":u===le.PROCESSING?"blue-500":u===le.COMPLETED?"green-500":u===le.CANCELLED?"red-500":"green-500"})),d=Object.values(Ce).filter(u=>typeof u=="number").map(u=>({label:t(`commission.${Ce[u]}`),value:u,icon:u===Ce.PENDING?Ut[0].icon:u===Ce.PROCESSING?Ut[1].icon:u===Ce.VALID?Ut[2].icon:Ut[3].icon,color:u===Ce.PENDING?"yellow-500":u===Ce.PROCESSING?"blue-500":u===Ce.VALID?"green-500":"red-500"}));return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(vi,{refetch:n}),e.jsx(D,{placeholder:t("search.placeholder"),value:s.getColumn("trade_no")?.getFilterValue()??"",onChange:u=>s.getColumn("trade_no")?.setFilterValue(u.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(va,{column:s.getColumn("type"),title:t("table.columns.type"),options:a}),s.getColumn("period")&&e.jsx(va,{column:s.getColumn("period"),title:t("table.columns.period"),options:i}),s.getColumn("status")&&e.jsx(va,{column:s.getColumn("status"),title:t("table.columns.status"),options:l}),s.getColumn("commission_status")&&e.jsx(va,{column:s.getColumn("commission_status"),title:t("table.columns.commissionStatus"),options:d})]}),r&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("actions.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}function ns({label:s,value:n,className:t,valueClassName:r}){return e.jsxs("div",{className:w("flex items-center py-1.5",t),children:[e.jsx("div",{className:"w-28 shrink-0 text-sm text-muted-foreground",children:s}),e.jsx("div",{className:w("text-sm",r),children:n||"-"})]})}function xh({status:s}){const{t:n}=M("order"),t={[le.PENDING]:"bg-yellow-100 text-yellow-800 hover:bg-yellow-100",[le.PROCESSING]:"bg-blue-100 text-blue-800 hover:bg-blue-100",[le.CANCELLED]:"bg-red-100 text-red-800 hover:bg-red-100",[le.COMPLETED]:"bg-green-100 text-green-800 hover:bg-green-100",[le.DISCOUNTED]:"bg-gray-100 text-gray-800 hover:bg-gray-100"};return e.jsx(U,{variant:"secondary",className:w("font-medium",t[s]),children:n(`status.${le[s]}`)})}function hh({id:s,trigger:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(),{t:l}=M("order");return m.useEffect(()=>{(async()=>{if(t){const{data:u}=await ct.getInfo({id:s});i(u)}})()},[t,s]),e.jsxs(de,{onOpenChange:r,open:t,children:[e.jsx(ps,{asChild:!0,children:n}),e.jsxs(ce,{className:"max-w-xl",children:[e.jsxs(he,{className:"space-y-2",children:[e.jsx(me,{className:"text-lg font-medium",children:l("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:[l("table.columns.tradeNo"),":",a?.trade_no]}),!!a?.status&&e.jsx(xh,{status:a.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:l("dialog.basicInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.userEmail"),value:a?.user?.email?e.jsxs(Zs,{to:`/user/manage?email=${a.user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.user.email,e.jsx(Sn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]}):"-"}),e.jsx(ns,{label:l("dialog.fields.orderPeriod"),value:a&&l(`period.${a.period}`)}),e.jsx(ns,{label:l("dialog.fields.subscriptionPlan"),value:a?.plan?.name,valueClassName:"font-medium"}),e.jsx(ns,{label:l("dialog.fields.callbackNo"),value:a?.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:l("dialog.amountInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.paymentAmount"),value:qs(a?.total_amount||0),valueClassName:"font-medium text-primary"}),e.jsx(Ve,{className:"my-2"}),e.jsx(ns,{label:l("dialog.fields.balancePayment"),value:qs(a?.balance_amount||0)}),e.jsx(ns,{label:l("dialog.fields.discountAmount"),value:qs(a?.discount_amount||0),valueClassName:"text-green-600"}),e.jsx(ns,{label:l("dialog.fields.refundAmount"),value:qs(a?.refund_amount||0),valueClassName:"text-red-600"}),e.jsx(ns,{label:l("dialog.fields.deductionAmount"),value:qs(a?.surplus_amount||0)})]})]}),e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.timeInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.createdAt"),value:ie(a?.created_at),valueClassName:"font-mono text-xs"}),e.jsx(ns,{label:l("dialog.fields.updatedAt"),value:ie(a?.updated_at),valueClassName:"font-mono text-xs"})]})]}),(a?.commission_status===1||a?.commission_status===2)&&a?.commission_balance&&e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsx("div",{className:"mb-2 text-sm font-medium",children:l("dialog.commissionInfo")}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ns,{label:l("dialog.fields.commissionStatus"),value:e.jsx(U,{variant:"secondary",className:"bg-orange-100 font-medium text-orange-800 hover:bg-orange-100",children:l("dialog.commissionStatusActive")})}),e.jsx(ns,{label:l("dialog.fields.commissionAmount"),value:qs(a?.commission_balance||0),valueClassName:"font-medium text-orange-600"}),a?.actual_commission_balance&&e.jsx(ns,{label:l("dialog.fields.actualCommissionAmount"),value:qs(a?.actual_commission_balance||0),valueClassName:"font-medium text-orange-700"}),a?.invite_user&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"my-2"}),e.jsx(ns,{label:l("dialog.fields.inviteUser"),value:e.jsxs(Zs,{to:`/user/manage?email=${a.invite_user.email}`,className:"group inline-flex items-center gap-1 text-primary hover:underline",children:[a.invite_user.email,e.jsx(Sn,{className:"h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-100"})]})}),e.jsx(ns,{label:l("dialog.fields.inviteUserId"),value:a?.invite_user?.id,valueClassName:"font-mono text-xs"})]})]})]})]})]})]})}const gh={[Vs.NEW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Vs.RENEWAL]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Vs.UPGRADE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Vs.RESET_FLOW]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},ph={[Qe.MONTH_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.QUARTER_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.HALF_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.TWO_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.THREE_YEAR_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.ONETIME_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"},[Qe.RESET_PRICE]:{color:"text-slate-700",bgColor:"bg-slate-100/80"}},fh=s=>le[s],jh=s=>Ce[s],vh=s=>Vs[s],bh=s=>{const{t:n}=M("order");return[{accessorKey:"trade_no",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.tradeNo")}),cell:({row:t})=>{const r=t.original.trade_no,a=r.length>6?`${r.slice(0,3)}...${r.slice(-3)}`:r;return e.jsx("div",{className:"flex items-center",children:e.jsx(hh,{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:a}),e.jsx(Sn,{className:"h-3.5 w-3.5 opacity-70"})]}),id:t.original.id})})},enableSorting:!1,enableHiding:!1},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>{const r=t.getValue("type"),a=gh[r];return e.jsx(U,{variant:"secondary",className:w("font-medium transition-colors text-nowrap",a.color,a.bgColor,"border border-border/50","hover:bg-slate-200/80"),children:n(`type.${vh(r)}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"plan.name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.plan")}),cell:({row:t})=>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:t.original.plan?.name||"-"})}),enableSorting:!1,enableHiding:!1},{accessorKey:"period",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.period")}),cell:({row:t})=>{const r=t.getValue("period"),a=ph[r];return e.jsx(U,{variant:"secondary",className:w("font-medium transition-colors text-nowrap",a?.color,a?.bgColor,"hover:bg-opacity-80"),children:n(`period.${r}`)})},enableSorting:!1,enableHiding:!1},{accessorKey:"total_amount",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.amount")}),cell:({row:t})=>{const r=t.getValue("total_amount"),a=typeof r=="number"?(r/100).toFixed(2):"N/A";return e.jsxs("div",{className:"flex items-center font-mono text-foreground/90",children:["¥",a]})},enableSorting:!0,enableHiding:!1},{accessorKey:"status",header:({column:t})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{column:t,title:n("table.columns.status")}),e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsx(mi,{className:"h-4 w-4 text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsx(ue,{side:"top",className:"max-w-[200px] text-sm",children:n("status.tooltip")})]})})]}),cell:({row:t})=>{const r=Ct.find(a=>a.value===t.getValue("status"));return r?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.icon&&e.jsx(r.icon,{className:`h-4 w-4 text-${r.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`status.${fh(r.value)}`)})]}),r.value===le.PENDING&&e.jsxs(zs,{modal:!0,children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ms,{align:"end",className:"w-[140px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await ct.markPaid({trade_no:t.original.trade_no}),s()},children:n("actions.markAsPaid")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await ct.makeCancel({trade_no:t.original.trade_no}),s()},children:n("actions.cancel")})]})]})]}):null},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_balance",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commission")}),cell:({row:t})=>{const r=t.getValue("commission_balance"),a=r?(r/100).toFixed(2):"-";return e.jsx("div",{className:"flex items-center font-mono text-foreground/90",children:r?`¥${a}`:"-"})},enableSorting:!0,enableHiding:!1},{accessorKey:"commission_status",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.commissionStatus")}),cell:({row:t})=>{const r=t.original.status,a=t.original.commission_balance,i=Ut.find(l=>l.value===t.getValue("commission_status"));return a==0||!i?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:[i.icon&&e.jsx(i.icon,{className:`h-4 w-4 text-${i.color}`}),e.jsx("span",{className:"text-sm font-medium",children:n(`commission.${jh(i.value)}`)})]}),i.value===Ce.PENDING&&r===le.COMPLETED&&e.jsxs(zs,{modal:!0,children:[e.jsx(Ks,{asChild:!0,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 hover:bg-muted/60",children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:n("actions.openMenu")})]})}),e.jsxs(Ms,{align:"end",className:"w-[120px]",children:[e.jsx(Se,{className:"cursor-pointer",onClick:async()=>{await ct.update({trade_no:t.original.trade_no,commission_status:Ce.PROCESSING}),s()},children:n("commission.PROCESSING")}),e.jsx(Se,{className:"cursor-pointer text-destructive focus:text-destructive",onClick:async()=>{await ct.update({trade_no:t.original.trade_no,commission_status:Ce.INVALID}),s()},children:n("commission.INVALID")})]})]})]})},enableSorting:!0,enableHiding:!1},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.createdAt")}),cell:({row:t})=>e.jsx("div",{className:"text-nowrap font-mono text-sm text-muted-foreground",children:ie(t.getValue("created_at"),"YYYY/MM/DD HH:mm:ss")}),enableSorting:!0,enableHiding:!1}]};function yh(){const[s]=Fl(),[n,t]=m.useState({}),[r,a]=m.useState({}),[i,l]=m.useState([]),[d,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const T=Object.entries({user_id:"string",order_id:"string",commission_status:"number",status:"number",commission_balance:"string"}).map(([p,S])=>{const N=s.get(p);return N?{id:p,value:S==="number"?parseInt(N):N}:null}).filter(Boolean);T.length>0&&l(T)},[s]);const{refetch:c,data:j,isLoading:P}=ne({queryKey:["orderList",x,i,d],queryFn:()=>ct.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:i,sort:d})}),k=Be({data:j?.data??[],columns:bh(c),state:{sorting:d,columnVisibility:r,rowSelection:n,columnFilters:i,pagination:x},rowCount:j?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:t,onSortingChange:u,onColumnFiltersChange:l,onColumnVisibilityChange:a,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:o,getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(ts,{table:k,toolbar:e.jsx(uh,{table:k,refetch:c}),showPagination:!0})}function _h(){const{t:s}=M("order");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(yh,{})})]})]})}const Nh=Object.freeze(Object.defineProperty({__proto__:null,default:_h},Symbol.toStringTag,{value:"Module"}));function wh({column:s,title:n,options:t}){const r=s?.getFacetedUniqueValues(),a=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx($a,{className:"mr-2 h-4 w-4"}),n,a?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal lg:hidden",children:a.size}),e.jsx("div",{className:"hidden space-x-1 lg:flex",children:a.size>2?e.jsxs(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[a.size," selected"]}):t.filter(i=>a.has(i.value)).map(i=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:i.label},i.value))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(i=>{const l=a.has(i.value);return e.jsxs(rs,{onSelect:()=>{l?a.delete(i.value):a.add(i.value);const d=Array.from(a);s?.setFilterValue(d.length?d:void 0)},children:[e.jsx("div",{className:w("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(ht,{className:w("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}),r?.get(i.value)&&e.jsx("span",{className:"ml-auto flex h-4 w-4 items-center justify-center font-mono text-xs",children:r.get(i.value)})]},i.value)})}),a.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Rt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}const Ch=s=>h.object({id:h.coerce.number().nullable().optional(),name:h.string().min(1,s("form.name.required")),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(Jt)).default([]).nullable()}).refine(n=>n.ended_at>n.started_at,{message:s("form.validity.endTimeError"),path:["ended_at"]}),wr={name:"",code:null,type:Ns.AMOUNT,value:0,started_at:Math.floor(Date.now()/1e3),ended_at:Math.floor(Date.now()/1e3)+7*24*60*60,limit_use:null,limit_use_with_user:null,limit_plan_ids:[],limit_period:[],generate_count:null},Sh=s=>[{label:s("form.timeRange.presets.1week"),days:7},{label:s("form.timeRange.presets.2weeks"),days:14},{label:s("form.timeRange.presets.1month"),days:30},{label:s("form.timeRange.presets.3months"),days:90},{label:s("form.timeRange.presets.6months"),days:180},{label:s("form.timeRange.presets.1year"),days:365}];function bi({defaultValues:s,refetch:n,type:t="create",dialogTrigger:r=null,open:a,onOpenChange:i}){const{t:l}=M("coupon"),[d,u]=m.useState(!1),x=a??d,o=i??u,[c,j]=m.useState([]),P=Ch(l),k=Sh(l),C=we({resolver:Te(P),defaultValues:s||wr});m.useEffect(()=>{s&&C.reset(s)},[s,C]),m.useEffect(()=>{ys.getList().then(({data:g})=>j(g))},[]);const T=g=>{if(!g)return;const f=(V,E)=>{const L=new Date(E*1e3);return V.setHours(L.getHours(),L.getMinutes(),L.getSeconds()),Math.floor(V.getTime()/1e3)};g.from&&C.setValue("started_at",f(g.from,C.watch("started_at"))),g.to&&C.setValue("ended_at",f(g.to,C.watch("ended_at")))},p=g=>{const f=new Date,V=Math.floor(f.getTime()/1e3),E=Math.floor((f.getTime()+g*24*60*60*1e3)/1e3);C.setValue("started_at",V),C.setValue("ended_at",E)},S=async g=>{const f=await La.save(g);if(g.generate_count&&typeof f=="string"){const V=new Blob([f],{type:"text/csv;charset=utf-8;"}),E=document.createElement("a");E.href=window.URL.createObjectURL(V),E.download=`coupons_${new Date().getTime()}.csv`,E.click(),window.URL.revokeObjectURL(E.href)}o(!1),t==="create"&&C.reset(wr),n()},N=(g,f)=>e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:f}),e.jsx(D,{type:"datetime-local",step:"1",value:ie(C.watch(g),"YYYY-MM-DDTHH:mm:ss"),onChange:V=>{const E=new Date(V.target.value);C.setValue(g,Math.floor(E.getTime()/1e3))},className:"h-8 [&::-webkit-calendar-picker-indicator]:hidden"})]});return e.jsxs(de,{open:x,onOpenChange:o,children:[r&&e.jsx(ps,{asChild:!0,children:r}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsx(he,{children:e.jsx(me,{children:l(t==="create"?"form.add":"form.edit")})}),e.jsx(De,{...C,children:e.jsxs("form",{onSubmit:C.handleSubmit(S),className:"space-y-4",children:[e.jsx(b,{control:C.control,name:"name",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.name.label")}),e.jsx(D,{placeholder:l("form.name.placeholder"),...g}),e.jsx(R,{})]})}),t==="create"&&e.jsx(b,{control:C.control,name:"generate_count",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.generateCount.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.generateCount.placeholder"),...g,value:g.value??"",onChange:f=>g.onChange(f.target.value===""?null:parseInt(f.target.value)),className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.generateCount.description")}),e.jsx(R,{})]})}),(!C.watch("generate_count")||C.watch("generate_count")==null)&&e.jsx(b,{control:C.control,name:"code",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.code.label")}),e.jsx(D,{placeholder:l("form.code.placeholder"),...g,value:g.value??"",className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.code.description")}),e.jsx(R,{})]})}),e.jsxs(v,{children:[e.jsx(y,{children:l("form.type.label")}),e.jsxs("div",{className:"flex",children:[e.jsx(b,{control:C.control,name:"type",render:({field:g})=>e.jsxs(J,{value:g.value.toString(),onValueChange:f=>{const V=g.value,E=parseInt(f);g.onChange(E);const L=C.getValues("value");L&&(V===Ns.AMOUNT&&E===Ns.PERCENTAGE?C.setValue("value",L/100):V===Ns.PERCENTAGE&&E===Ns.AMOUNT&&C.setValue("value",L*100))},children:[e.jsx(Y,{className:"flex-[1.2] rounded-r-none border-r-0 focus:z-10",children:e.jsx(Q,{placeholder:l("form.type.placeholder")})}),e.jsx(W,{children:Object.entries(Im).map(([f,V])=>e.jsx(A,{value:f,children:l(`table.toolbar.types.${f}`)},f))})]})}),e.jsx(b,{control:C.control,name:"value",render:({field:g})=>{const f=g.value==null?"":C.watch("type")===Ns.AMOUNT&&typeof g.value=="number"?(g.value/100).toString():g.value.toString();return e.jsx(D,{type:"number",placeholder:l("form.value.placeholder"),...g,value:f,onChange:V=>{const E=V.target.value;if(E===""){g.onChange("");return}const L=parseFloat(E);isNaN(L)||g.onChange(C.watch("type")===Ns.AMOUNT?Math.round(L*100):L)},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:C.watch("type")==Ns.AMOUNT?"¥":"%"})})]})]}),e.jsxs(v,{children:[e.jsx(y,{children:l("form.validity.label")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",className:w("w-full justify-start text-left font-normal",!C.watch("started_at")&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"truncate",children:[ie(C.watch("started_at"),"YYYY-MM-DD HH:mm:ss")," ",l("form.validity.to")," ",ie(C.watch("ended_at"),"YYYY-MM-DD HH:mm:ss")]})]})}),e.jsxs(Xe,{className:"w-auto p-0",align:"start",children:[e.jsxs("div",{className:"border-b border-border p-3",children:[e.jsx("div",{className:"mb-2 text-sm font-medium text-muted-foreground",children:l("form.timeRange.quickSet")}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:grid-cols-6",children:k.map(g=>e.jsx(F,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>p(g.days),type:"button",children:g.label},g.days))})]}),e.jsx("div",{className:"hidden border-b border-border sm:block",children:e.jsx(Cs,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:T,numberOfMonths:2})}),e.jsx("div",{className:"border-b border-border sm:hidden",children:e.jsx(Cs,{mode:"range",selected:{from:new Date(C.watch("started_at")*1e3),to:new Date(C.watch("ended_at")*1e3)},onSelect:T,numberOfMonths:1})}),e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center",children:[N("started_at",l("table.validity.startTime")),e.jsx("div",{className:"text-center text-sm text-muted-foreground sm:mt-6",children:l("form.validity.to")}),N("ended_at",l("table.validity.endTime"))]})})]})]}),e.jsx(R,{})]}),e.jsx(b,{control:C.control,name:"limit_use",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.limitUse.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUse.placeholder"),...g,value:g.value??"",onChange:f=>g.onChange(f.target.value===""?null:parseInt(f.target.value)),className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.limitUse.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:C.control,name:"limit_use_with_user",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.limitUseWithUser.label")}),e.jsx(D,{type:"number",min:0,placeholder:l("form.limitUseWithUser.placeholder"),...g,value:g.value??"",onChange:f=>g.onChange(f.target.value===""?null:parseInt(f.target.value)),className:"h-9"}),e.jsx(z,{className:"text-xs",children:l("form.limitUseWithUser.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:C.control,name:"limit_period",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.limitPeriod.label")}),e.jsx(st,{options:Object.entries(Jt).filter(([f])=>isNaN(Number(f))).map(([f,V])=>({label:l(`coupon:period.${V}`),value:f})),onChange:f=>{if(f.length===0){g.onChange([]);return}const V=f.map(E=>Jt[E.value]);g.onChange(V)},value:(g.value||[]).map(f=>({label:l(`coupon:period.${f}`),value:Object.entries(Jt).find(([V,E])=>E===f)?.[0]||""})),placeholder:l("form.limitPeriod.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPeriod.empty")})}),e.jsx(z,{className:"text-xs",children:l("form.limitPeriod.description")}),e.jsx(R,{})]})}),e.jsx(b,{control:C.control,name:"limit_plan_ids",render:({field:g})=>e.jsxs(v,{children:[e.jsx(y,{children:l("form.limitPlan.label")}),e.jsx(st,{options:c?.map(f=>({label:f.name,value:f.id.toString()}))||[],onChange:f=>g.onChange(f.map(V=>Number(V.value))),value:(c||[]).filter(f=>(g.value||[]).includes(f.id)).map(f=>({label:f.name,value:f.id.toString()})),placeholder:l("form.limitPlan.placeholder"),emptyIndicator:e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:l("form.limitPlan.empty")})}),e.jsx(R,{})]})}),e.jsx(Me,{children:e.jsx(F,{type:"submit",disabled:C.formState.isSubmitting,children:C.formState.isSubmitting?l("form.submit.saving"):l("form.submit.save")})})]})})]})]})}function kh({table:s,refetch:n}){const t=s.getState().columnFilters.length>0,{t:r}=M("coupon");return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(bi,{refetch:n,dialogTrigger:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:r("form.add")})]})}),e.jsx(D,{placeholder:r("table.toolbar.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:a=>s.getColumn("name")?.setFilterValue(a.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(wh,{column:s.getColumn("type"),title:r("table.toolbar.type"),options:[{value:Ns.AMOUNT,label:r(`table.toolbar.types.${Ns.AMOUNT}`)},{value:Ns.PERCENTAGE,label:r(`table.toolbar.types.${Ns.PERCENTAGE}`)}]}),t&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[r("table.toolbar.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]})}const yi=m.createContext(void 0);function Th({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=u=>{i(u),r(!0)},d=()=>{r(!1),i(null)};return e.jsxs(yi.Provider,{value:{isOpen:t,currentCoupon:a,openEdit:l,closeEdit:d},children:[s,a&&e.jsx(bi,{defaultValues:a,refetch:n,type:"edit",open:t,onOpenChange:r})]})}function Dh(){const s=m.useContext(yi);if(s===void 0)throw new Error("useCouponEdit must be used within a CouponEditProvider");return s}const Ph=s=>{const{t:n}=M("coupon");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"show",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.show")}),cell:({row:t})=>e.jsx(Z,{defaultChecked:t.original.show,onCheckedChange:r=>{La.update({id:t.original.id,show:r}).then(({data:a})=>!a&&s())}}),enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:800},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`table.toolbar.types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"code",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.code")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.code}),enableSorting:!0},{accessorKey:"limit_use",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUse")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.limit_use===null?n("table.validity.unlimited"):t.original.limit_use}),enableSorting:!0},{accessorKey:"limit_use_with_user",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.limitUseWithUser")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.limit_use_with_user===null?n("table.validity.noLimit"):t.original.limit_use_with_user}),enableSorting:!0},{accessorKey:"#",header:({column:t})=>e.jsx(O,{column:t,title:n("table.columns.validity")}),cell:({row:t})=>{const[r,a]=m.useState(!1),i=Date.now(),l=t.original.started_at*1e3,d=t.original.ended_at*1e3,u=i>d,x=ie.jsx(O,{className:"justify-end",column:t,title:n("table.columns.actions")}),cell:({row:t})=>{const{openEdit:r}=Dh();return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-muted",onClick:()=>r(t.original),children:[e.jsx(tt,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"sr-only",children:n("table.actions.edit")})]}),e.jsx(_s,{title:n("table.actions.deleteConfirm.title"),description:n("table.actions.deleteConfirm.description"),confirmText:n("table.actions.deleteConfirm.confirmText"),variant:"destructive",onConfirm:async()=>{La.drop({id:t.original.id}).then(({data:a})=>{a&&($.success("删除成功"),s())})},children:e.jsxs(F,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-red-100 dark:hover:bg-red-900",children:[e.jsx(us,{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 Lh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ne({queryKey:["couponList",u,a,l],queryFn:()=>La.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),j=Be({data:c?.data??[],columns:Ph(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((c?.total??0)/u.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Th,{refetch:o,children:e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:j,toolbar:e.jsx(kh,{table:j,refetch:o})})})})}function Fh(){const{t:s}=M("coupon");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Lh,{})})]})]})}const Rh=Object.freeze(Object.defineProperty({__proto__:null,default:Fh},Symbol.toStringTag,{value:"Module"})),Eh=h.object({name:h.string().min(1,"请输入模板名称"),description:h.string().optional(),type:h.number().min(1).max(4),status:h.boolean(),sort:h.number().min(0),icon:h.string().optional(),background_image:h.string().optional(),conditions:h.object({allowed_plans:h.array(h.number()).optional(),disallowed_plans:h.array(h.number()).optional(),new_user_only:h.boolean().optional(),new_user_max_days:h.number().optional(),paid_user_only:h.boolean().optional(),require_invite:h.boolean().optional()}).optional(),limits:h.object({max_use_per_user:h.number().optional(),cooldown_hours:h.number().optional(),invite_reward_rate:h.number().optional()}).optional(),rewards:h.object({balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional(),reset_package:h.boolean().optional(),plan_id:h.number().optional(),plan_validity_days:h.number().optional(),random_rewards:h.array(h.object({weight:h.number(),balance:h.number().optional(),transfer_enable:h.number().optional(),expire_days:h.number().optional(),device_limit:h.number().optional()})).optional()}),special_config:h.object({start_time:h.number().optional(),end_time:h.number().optional(),festival_bonus:h.number().optional()}).optional()});function _i({template:s,refetch:n,open:t,onOpenChange:r}){const{t:a}=M("giftCard"),[i,l]=m.useState(!1),[d,u]=m.useState([]),[x,o]=m.useState([]),c=we({resolver:Te(Eh),defaultValues:{name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{},special_config:{}}}),{fields:j,append:P,remove:k}=jd({control:c.control,name:"rewards.random_rewards"});m.useEffect(()=>{t&&(async()=>{try{const f=(await ys.getList()).data||[];u(f),o(f.map(V=>({label:V.name,value:V.id.toString()})))}catch(g){console.error("Failed to fetch plans:",g),$.error("Failed to load plan list")}})()},[t]),m.useEffect(()=>{if(s){const N=s.rewards||{};c.reset({name:s.name,description:s.description||"",type:s.type,status:s.status,sort:s.sort,icon:s.icon||"",background_image:s.background_image||"",conditions:s.conditions&&!Array.isArray(s.conditions)?s.conditions:{},limits:s.limits&&!Array.isArray(s.limits)?{...s.limits,invite_reward_rate:s.limits.invite_reward_rate||void 0}:{},rewards:{balance:N.balance?N.balance/100:void 0,transfer_enable:typeof N.transfer_enable=="number"?N.transfer_enable/1024/1024/1024:void 0,expire_days:N.expire_days,device_limit:N.device_limit,reset_package:N.reset_package,plan_id:N.plan_id,plan_validity_days:N.plan_validity_days,random_rewards:N.random_rewards?.map(g=>({weight:g.weight,balance:g.balance?g.balance/100:void 0,transfer_enable:typeof g.transfer_enable=="number"?g.transfer_enable/1024/1024/1024:void 0,expire_days:g.expire_days,device_limit:g.device_limit}))||[]},special_config:s.special_config&&!Array.isArray(s.special_config)?s.special_config:{}})}else c.reset({name:"",description:"",type:1,status:!0,sort:0,icon:"",background_image:"",conditions:{},limits:{},rewards:{random_rewards:[]},special_config:{}})},[s,c]);const C=N=>{console.error("Form validation failed:",N),$.error(a("messages.formInvalid"))},T=async N=>{l(!0);const g=JSON.parse(JSON.stringify(N));g.rewards&&(typeof g.rewards.balance=="number"&&(g.rewards.balance=Math.round(g.rewards.balance*100)),typeof g.rewards.transfer_enable=="number"&&(g.rewards.transfer_enable=Math.round(g.rewards.transfer_enable*1024*1024*1024)),g.rewards.random_rewards&&g.rewards.random_rewards.forEach(V=>{typeof V.balance=="number"&&(V.balance=Math.round(V.balance*100)),typeof V.transfer_enable=="number"&&(V.transfer_enable=Math.round(V.transfer_enable*1024*1024*1024))}));const f={...g,conditions:g.conditions||{},limits:g.limits||{},rewards:g.rewards||{},special_config:g.special_config||{}};try{s?(await Ds.updateTemplate({id:s.id,...f}),$.success(a("messages.templateUpdated"))):(await Ds.createTemplate(f),$.success(a("messages.templateCreated"))),n(),r(!1)}catch(V){const E=V?.response?.data?.errors;E&&Object.keys(E).forEach(L=>{c.setError(L,{type:"manual",message:E[L][0]})}),$.error(a(s?"messages.updateTemplateFailed":"messages.createTemplateFailed"))}finally{l(!1)}},p=c.watch("type"),S=p===1;return e.jsx(de,{open:t,onOpenChange:r,children:e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:[e.jsx(he,{children:e.jsx(me,{children:a(s?"template.form.edit":"template.form.add")})}),e.jsx(De,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(T,C),className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:c.control,name:"name",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.name.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:a("template.form.name.placeholder"),...N})}),e.jsx(R,{})]})}),e.jsx(b,{control:c.control,name:"type",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.type.label")}),e.jsxs(J,{value:N.value.toString(),onValueChange:g=>N.onChange(parseInt(g)),children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:a("template.form.type.placeholder")})})}),e.jsx(W,{children:[1,2,3].map(g=>e.jsx(A,{value:g.toString(),children:a(`types.${g}`)},g))})]}),e.jsx(R,{})]})})]}),e.jsx(b,{control:c.control,name:"description",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.description.label")}),e.jsx(_,{children:e.jsx(Fs,{placeholder:a("template.form.description.placeholder"),...N})}),e.jsx(R,{})]})}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:e.jsx(b,{control:c.control,name:"status",render:({field:N})=>e.jsxs(v,{className:"col-span-3 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:a("template.form.status.label")}),e.jsx(z,{children:a("template.form.status.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:N.value,onCheckedChange:N.onChange})})]})})}),e.jsxs(ke,{children:[e.jsx(Pe,{children:e.jsx(Re,{children:a("template.form.rewards.title")})}),e.jsxs(Le,{className:"space-y-4",children:[S&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:c.control,name:"rewards.balance",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.rewards.balance.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.balance.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})}),e.jsx(b,{control:c.control,name:"rewards.transfer_enable",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.rewards.transfer_enable.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.placeholder"),value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})}),e.jsx(b,{control:c.control,name:"rewards.expire_days",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.rewards.expire_days.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.expire_days.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})}),e.jsx(b,{control:c.control,name:"rewards.device_limit",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.rewards.device_limit.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.device_limit.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})})]}),e.jsx(b,{control:c.control,name:"rewards.reset_package",render:({field:N})=>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,{children:a("template.form.rewards.reset_package.label")}),e.jsx(z,{children:a("template.form.rewards.reset_package.description")})]}),e.jsx(_,{children:e.jsx(Z,{checked:N.value,onCheckedChange:N.onChange})})]})})]}),p===4&&e.jsx("p",{children:a("template.form.rewards.task_card.description")}),p===2&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:c.control,name:"rewards.plan_id",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.rewards.plan_id.label")}),e.jsxs(J,{value:N.value?.toString(),onValueChange:g=>N.onChange(parseInt(g,10)),children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:a("template.form.rewards.plan_id.placeholder")})})}),e.jsx(W,{children:d.map(g=>e.jsx(A,{value:g.id.toString(),children:g.name},g.id))})]}),e.jsx(R,{})]})}),e.jsx(b,{control:c.control,name:"rewards.plan_validity_days",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.rewards.plan_validity_days.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.plan_validity_days.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})})]}),p===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(y,{children:a("template.form.rewards.random_rewards.label")}),j.map((N,g)=>e.jsxs("div",{className:"flex items-center space-x-2 rounded-md border p-2",children:[e.jsx(b,{control:c.control,name:`rewards.random_rewards.${g}.weight`,render:({field:f})=>e.jsx(v,{children:e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.random_rewards.weight"),...f,value:f.value??"",onChange:V=>{const E=V.target.valueAsNumber;f.onChange(isNaN(E)?0:E)}})})})}),e.jsx(b,{control:c.control,name:`rewards.random_rewards.${g}.balance`,render:({field:f})=>e.jsx(v,{children:e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.balance.label"),...f,value:f.value??"",onChange:V=>{const E=V.target.valueAsNumber;f.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(b,{control:c.control,name:`rewards.random_rewards.${g}.transfer_enable`,render:({field:f})=>e.jsx(v,{children:e.jsx(_,{children:e.jsx(D,{type:"number",min:"0",step:"0.01",placeholder:a("template.form.rewards.transfer_enable.label")+" (GB)",value:f.value??"",onChange:V=>{const E=V.target.valueAsNumber;f.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(b,{control:c.control,name:`rewards.random_rewards.${g}.expire_days`,render:({field:f})=>e.jsx(v,{children:e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.expire_days.label"),...f,value:f.value??"",onChange:V=>{const E=V.target.valueAsNumber;f.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(b,{control:c.control,name:`rewards.random_rewards.${g}.device_limit`,render:({field:f})=>e.jsx(v,{children:e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.rewards.device_limit.label"),...f,value:f.value??"",onChange:V=>{const E=V.target.valueAsNumber;f.onChange(isNaN(E)?void 0:E)}})})})}),e.jsx(F,{type:"button",variant:"ghost",size:"icon",onClick:()=>k(g),children:e.jsx(vd,{className:"h-4 w-4"})})]},N.id)),e.jsx(F,{type:"button",variant:"outline",onClick:()=>P({weight:10,balance:void 0,transfer_enable:void 0,expire_days:void 0,device_limit:void 0}),children:a("template.form.rewards.random_rewards.add")})]})]})]}),e.jsxs(ke,{children:[e.jsx(Pe,{children:e.jsx(Re,{children:a("template.form.conditions.title")})}),e.jsxs(Le,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 gap-4",children:e.jsx(b,{control:c.control,name:"conditions.new_user_max_days",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.conditions.new_user_max_days.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.conditions.new_user_max_days.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(b,{control:c.control,name:"conditions.new_user_only",render:({field:N})=>e.jsxs(v,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(y,{children:a("template.form.conditions.new_user_only.label")})}),e.jsx(_,{children:e.jsx(Z,{checked:N.value,onCheckedChange:N.onChange})})]})}),e.jsx(b,{control:c.control,name:"conditions.paid_user_only",render:({field:N})=>e.jsxs(v,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(y,{children:a("template.form.conditions.paid_user_only.label")})}),e.jsx(_,{children:e.jsx(Z,{checked:N.value,onCheckedChange:N.onChange})})]})}),e.jsx(b,{control:c.control,name:"conditions.require_invite",render:({field:N})=>e.jsxs(v,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(y,{children:a("template.form.conditions.require_invite.label")})}),e.jsx(_,{children:e.jsx(Z,{checked:N.value,onCheckedChange:N.onChange})})]})})]}),e.jsx(b,{control:c.control,name:"conditions.allowed_plans",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.conditions.allowed_plans.label")}),e.jsx(_,{children:e.jsx(st,{value:N.value?.map(g=>({label:d.find(f=>f.id===g)?.name||`ID: ${g}`,value:g.toString()}))??[],onChange:g=>N.onChange(g.map(f=>parseInt(f.value))),options:x,placeholder:a("template.form.conditions.allowed_plans.placeholder")})})]})}),e.jsx(b,{control:c.control,name:"conditions.disallowed_plans",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.conditions.disallowed_plans.label")}),e.jsx(_,{children:e.jsx(st,{value:N.value?.map(g=>({label:d.find(f=>f.id===g)?.name||`ID: ${g}`,value:g.toString()}))??[],onChange:g=>N.onChange(g.map(f=>parseInt(f.value))),options:x,placeholder:a("template.form.conditions.disallowed_plans.placeholder")})})]})})]})]}),e.jsxs(ke,{children:[e.jsx(Pe,{children:e.jsx(Re,{children:a("template.form.limits.title")})}),e.jsx(Le,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:c.control,name:"limits.max_use_per_user",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.limits.max_use_per_user.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.limits.max_use_per_user.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})}),e.jsx(b,{control:c.control,name:"limits.cooldown_hours",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.limits.cooldown_hours.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",placeholder:a("template.form.limits.cooldown_hours.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})}),e.jsx(b,{control:c.control,name:"limits.invite_reward_rate",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.limits.invite_reward_rate.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",step:"0.01",placeholder:a("template.form.limits.invite_reward_rate.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})}),e.jsx(z,{children:a("template.form.limits.invite_reward_rate.description")})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Pe,{children:e.jsx(Re,{children:a("template.form.special_config.title")})}),e.jsx(Le,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-3 items-end gap-4",children:[e.jsx(b,{control:c.control,name:"special_config.start_time",render:({field:N})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:a("template.form.special_config.start_time.label")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(F,{variant:"outline",className:w("w-full pl-3 text-left font-normal",!N.value&&"text-muted-foreground"),children:[N.value?Fe(new Date(N.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.start_time.placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:N.value?new Date(N.value*1e3):void 0,onSelect:g=>N.onChange(g?Math.floor(g.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(b,{control:c.control,name:"special_config.end_time",render:({field:N})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:a("template.form.special_config.end_time.label")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(F,{variant:"outline",className:w("w-full pl-3 text-left font-normal",!N.value&&"text-muted-foreground"),children:[N.value?Fe(new Date(N.value*1e3),"PPP"):e.jsx("span",{children:a("template.form.special_config.end_time.placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:N.value?new Date(N.value*1e3):void 0,onSelect:g=>N.onChange(g?Math.floor(g.getTime()/1e3):void 0),initialFocus:!0})})]}),e.jsx(R,{})]})}),e.jsx(b,{control:c.control,name:"special_config.festival_bonus",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.special_config.festival_bonus.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",step:"0.1",placeholder:a("template.form.special_config.festival_bonus.placeholder"),...N,value:N.value??"",onChange:g=>{const f=g.target.valueAsNumber;N.onChange(isNaN(f)?void 0:f)}})})]})})]})})]}),e.jsxs(ke,{children:[e.jsx(Pe,{children:e.jsx(Re,{children:a("template.form.display.title")})}),e.jsx(Le,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{control:c.control,name:"icon",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.icon.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:a("template.form.icon.placeholder"),...N})}),e.jsx(R,{})]})}),e.jsx(b,{control:c.control,name:"background_image",render:({field:N})=>e.jsxs(v,{children:[e.jsx(y,{children:a("template.form.background_image.label")}),e.jsx(_,{children:e.jsx(D,{placeholder:a("template.form.background_image.placeholder"),...N})}),e.jsx(R,{})]})})]})})]}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(F,{type:"button",variant:"outline",onClick:()=>r(!1),children:a("common:cancel")}),e.jsx(F,{type:"submit",disabled:i,children:a(i?"common:saving":"common:submit")})]})]})})]})})}const Ni=m.createContext(void 0);function Vh({children:s,refetch:n}){const[t,r]=m.useState(!1),[a,i]=m.useState(null),l=u=>{i(u),r(!!u)},d=()=>{r(!1),i(null)};return e.jsxs(Ni.Provider,{value:{isOpen:t,editingTemplate:a,setEditingTemplate:l,closeEdit:d},children:[s,e.jsx(_i,{template:a,refetch:n,open:t,onOpenChange:r})]})}function Ih(){const s=m.useContext(Ni);if(s===void 0)throw new Error("useTemplateEdit must be used within a TemplateEditProvider");return s}function Mh({rewards:s,type:n}){const{t}=M(["giftCard","common"]),r=[];return s&&(s.balance&&r.push(`${t("template.form.rewards.balance.short_label")}: ${s.balance/100} ${t("common:currency.yuan","元")}`),s.transfer_enable&&r.push(`${t("template.form.rewards.transfer_enable.short_label")}: ${ze(s.transfer_enable)}`),s.expire_days&&r.push(`${t("template.form.rewards.expire_days.short_label")}: ${s.expire_days}${t("common:time.day","天")}`),s.device_limit&&r.push(`${t("template.form.rewards.device_limit.short_label")}: ${s.device_limit}`),n===2&&s.plan_id&&r.push(`${t("template.form.rewards.plan_id.short_label")}: ${s.plan_id}`),n===2&&s.plan_validity_days&&r.push(`${t("template.form.rewards.plan_validity_days.short_label")}: ${s.plan_validity_days}${t("common:time.day","天")}`),n===3&&s.random_rewards?.length&&r.push(t("types.3"))),r.length===0?e.jsx(U,{variant:"secondary",children:t("template.table.columns.no_rewards")}):e.jsx("div",{className:"flex flex-col space-y-1",children:r.map((a,i)=>e.jsx(U,{variant:"outline",className:"whitespace-nowrap",children:a},i))})}const Oh=s=>{const{t:n}=M("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id}),enableSorting:!0},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.status")}),cell:({row:t})=>{const[r,a]=m.useState(!1);return e.jsx(Z,{checked:t.original.status,disabled:r,onCheckedChange:async i=>{a(!0);try{const{data:l}=await Ds.updateTemplate({id:t.original.id,status:i});l?($.success(n("messages.templateUpdated")),s()):$.error(n("messages.updateTemplateFailed"))}catch{$.error(n("messages.updateTemplateFailed"))}finally{a(!1)}}})},enableSorting:!1},{accessorKey:"name",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.name")}),cell:({row:t})=>e.jsx("div",{className:"flex items-center",children:e.jsx("span",{children:t.original.name})}),enableSorting:!1,size:300},{accessorKey:"type",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.type")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:n(`types.${t.original.type}`)}),enableSorting:!0},{accessorKey:"rewards",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.rewards")}),cell:({row:t})=>e.jsx(Mh,{rewards:t.original.rewards,type:t.original.type}),enableSorting:!1},{accessorKey:"sort",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.sort")}),cell:({row:t})=>e.jsx(U,{variant:"secondary",children:t.original.sort}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.original.created_at)}),enableSorting:!0},{id:"actions",header:({column:t})=>e.jsx(O,{column:t,title:n("template.table.columns.actions")}),cell:({row:t})=>{const{setEditingTemplate:r}=Ih();return e.jsxs("div",{className:"flex space-x-2",children:[e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>r(t.original),children:[e.jsx(tt,{className:"h-4 w-4"}),n("template.actions.edit")]}),e.jsx(_s,{title:n("template.actions.deleteConfirm.title"),description:n("template.actions.deleteConfirm.description"),confirmText:n("template.actions.deleteConfirm.confirmText"),onConfirm:async()=>{try{const{data:a}=await Ds.deleteTemplate({id:t.original.id});a?($.success(n("messages.templateDeleted")),s()):$.error(n("messages.deleteTemplateFailed"))}catch{$.error(n("messages.deleteTemplateFailed"))}},children:e.jsxs(F,{variant:"outline",size:"sm",children:[e.jsx(us,{className:"h-4 w-4"}),n("template.actions.delete")]})})]})},enableSorting:!1}]};function wi({table:s}){return e.jsxs(zs,{children:[e.jsx(bd,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"ml-auto hidden h-8 lg:flex",children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),"显示列"]})}),e.jsxs(Ms,{align:"end",className:"w-[150px]",children:[e.jsx(Ha,{children:"切换显示列"}),e.jsx(et,{}),s.getAllColumns().filter(n=>typeof n.accessorFn<"u"&&n.getCanHide()).map(n=>e.jsx(Yl,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:t=>n.toggleVisibility(!!t),children:n.id},n.id))]})]})}function Ea({column:s,title:n,options:t}){const r=new Set(s?.getFilterValue());return e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(G,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(yd,{className:"mr-2 h-4 w-4"}),n,r?.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ve,{orientation:"vertical",className:"mx-2 h-4"}),e.jsx(U,{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(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:[r.size," selected"]}):t.filter(a=>r.has(a.value)).map(a=>e.jsx(U,{variant:"secondary",className:"rounded-sm px-1 font-normal",children:a.label},`selected-${a.value}`))})]})]})}),e.jsx(Xe,{className:"w-[200px] p-0",align:"start",children:e.jsxs(nt,{children:[e.jsx(ft,{placeholder:n}),e.jsxs(rt,{children:[e.jsx(jt,{children:"No results found."}),e.jsx(Ss,{children:t.map(a=>{const i=r.has(a.value);return e.jsxs(rs,{onSelect:()=>{i?r.delete(a.value):r.add(a.value);const l=Array.from(r);s?.setFilterValue(l.length?l:void 0)},children:[e.jsx("div",{className:w("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(_d,{className:w("h-4 w-4")})}),a.icon&&e.jsx(a.icon,{className:"mr-2 h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:a.label})]},`option-${a.value}`)})}),r.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Rt,{}),e.jsx(Ss,{children:e.jsx(rs,{onSelect:()=>s?.setFilterValue(void 0),className:"justify-center text-center",children:"Clear filters"})})]})]})]})})]})}function zh({table:s,refetch:n}){const{t}=M("giftCard"),[r,a]=m.useState(!1),i=s.getState().columnFilters.length>0,l=[{label:t("types.1"),value:"1"},{label:t("types.2"),value:"2"},{label:t("types.3"),value:"3"},{label:t("types.4"),value:"4"},{label:t("types.5"),value:"5"},{label:t("types.6"),value:"6"},{label:t("types.7"),value:"7"},{label:t("types.8"),value:"8"},{label:t("types.9"),value:"9"},{label:t("types.10"),value:"10"}],d=[{label:t("common.enabled"),value:"true"},{label:t("common.disabled"),value:"false"}];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.jsx(D,{placeholder:t("common.search"),value:s.getColumn("name")?.getFilterValue()??"",onChange:u=>s.getColumn("name")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("type")&&e.jsx(Ea,{column:s.getColumn("type"),title:t("template.table.columns.type"),options:l}),s.getColumn("status")&&e.jsx(Ea,{column:s.getColumn("status"),title:t("template.table.columns.status"),options:d}),i&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(El,{className:"h-4 w-4 mr-2"}),t("template.form.add")]}),e.jsx(wi,{table:s})]}),e.jsx(_i,{template:null,refetch:n,open:r,onOpenChange:a})]})}function $h(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ne({queryKey:["giftCardTemplates",u,a,l],queryFn:()=>Ds.getTemplates({per_page:u.pageSize,page:u.pageIndex+1,filter:a,sort:l})});console.log(c);const j=Be({data:c?.data??[],columns:Oh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((c?.total??0)/u.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx(Vh,{refetch:o,children:e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:j,toolbar:e.jsx(zh,{table:j,refetch:o})})})})}const Ah=h.object({template_id:h.number().min(1,"请选择一个模板"),count:h.number().min(1,"生成数量必须大于0").max(1e4,"单次最多生成10000个"),prefix:h.string().optional(),expires_hours:h.number().min(1,"有效期必须大于0"),max_usage:h.number().min(1,"最大使用次数必须大于0"),download_csv:h.boolean().optional()});function qh({refetch:s,open:n,onOpenChange:t}){const{t:r}=M("giftCard"),[a,i]=m.useState(!1),[l,d]=m.useState([]);m.useEffect(()=>{n&&Ds.getTemplates({per_page:1e3,page:1}).then(({data:o})=>{d(o||[])})},[n]);const u=we({resolver:Te(Ah),defaultValues:{count:10,prefix:"",expires_hours:24*30,max_usage:1,download_csv:!1}}),x=async o=>{i(!0);try{if(o.download_csv){const c=await Ds.generateCodes(o);if(c&&c instanceof Blob){const j=window.URL.createObjectURL(c),P=document.createElement("a");P.href=j,P.download=`gift_codes_${new Date().getTime()}.csv`,document.body.appendChild(P),P.click(),P.remove(),window.URL.revokeObjectURL(j),$.success(r("messages.codesGenerated")),s(),t(!1),u.reset()}}else await Ds.generateCodes(o),$.success(r("messages.codesGenerated")),s(),t(!1),u.reset()}catch{$.error(r("messages.generateCodesFailed"))}finally{i(!1)}};return e.jsx(de,{open:n,onOpenChange:t,children:e.jsxs(ce,{children:[e.jsx(he,{children:e.jsx(me,{children:r("code.form.generate")})}),e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(x),className:"space-y-4",children:[e.jsx(b,{control:u.control,name:"template_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("code.form.template_id.label")}),e.jsxs(J,{onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(_,{children:e.jsx(Y,{children:e.jsx(Q,{placeholder:r("code.form.template_id.placeholder")})})}),e.jsx(W,{children:l.map(c=>e.jsx(A,{value:c.id.toString(),children:c.name},c.id))})]}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"count",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("code.form.count.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"prefix",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("code.form.prefix.label")}),e.jsx(_,{children:e.jsx(D,{...o})}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"expires_hours",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("code.form.expires_hours.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"max_usage",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:r("code.form.max_usage.label")}),e.jsx(_,{children:e.jsx(D,{type:"number",...o,onChange:c=>o.onChange(parseInt(c.target.value)||0)})}),e.jsx(R,{})]})}),e.jsx(b,{control:u.control,name:"download_csv",render:({field:o})=>e.jsxs(v,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx("input",{type:"checkbox",checked:o.value,onChange:c=>o.onChange(c.target.checked)})}),e.jsx(y,{children:r("code.form.download_csv")})]})}),e.jsxs(Me,{children:[e.jsx(F,{type:"button",variant:"outline",onClick:()=>t(!1),children:r("common.cancel")}),e.jsx(F,{type:"submit",disabled:a,children:r(a?"code.form.submit.generating":"code.form.submit.generate")})]})]})})]})})}function Hh({table:s,refetch:n}){const{t}=M("giftCard"),[r,a]=m.useState(!1),i=s.getState().columnFilters.length>0,l=Object.entries(t("code.status",{returnObjects:!0})).map(([d,u])=>({value:d,label:u}));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.jsx(D,{placeholder:t("common.search"),value:s.getColumn("code")?.getFilterValue()??"",onChange:d=>s.getColumn("code")?.setFilterValue(d.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),s.getColumn("status")&&e.jsx(Ea,{column:s.getColumn("status"),title:t("code.table.columns.status"),options:l}),i&&e.jsxs(F,{variant:"ghost",onClick:()=>s.resetColumnFilters(),className:"h-8 px-2 lg:px-3",children:[t("common.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(F,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[e.jsx(El,{className:"h-4 w-4 mr-2"}),t("code.form.generate")]}),e.jsxs(F,{variant:"outline",size:"sm",disabled:!0,children:[e.jsx(Zt,{className:"h-4 w-4 mr-2"}),t("common.export")]}),e.jsx(wi,{table:s})]}),e.jsx(qh,{refetch:n,open:r,onOpenChange:a})]})}const Uh=0,Kh=1,Bh=2,hn=3,Gh=s=>{const{t:n}=M("giftCard");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.id")}),cell:({row:t})=>e.jsx(U,{children:t.original.id})},{accessorKey:"code",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.code")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:"secondary",children:t.original.code}),e.jsx(F,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>sa(t.original.code).then(()=>{$.success(n("common:copy.success"))}),children:e.jsx(Tl,{className:"h-4 w-4"})})]})},{accessorKey:"template_name",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.template_name")})},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.status")}),cell:({row:t})=>{const r=t.original.status,a=r===hn,i=r===Uh||r===hn;return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(U,{variant:r===Kh?"secondary":r===Bh||r===hn?"destructive":"default",children:n(`code.status.${r}`)}),i&&e.jsx(Z,{checked:!a,onCheckedChange:async l=>{const d=l?"enable":"disable";try{const{data:u}=await Ds.toggleCode({id:t.original.id,action:d});u?($.success(n("messages.codeStatusUpdated")),s()):$.error(n("messages.updateCodeStatusFailed"))}catch{$.error(n("messages.updateCodeStatusFailed"))}}})]})}},{accessorKey:"expires_at",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.expires_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.original.expires_at)})},{accessorKey:"usage_count",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.usage_count")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.usage_count})},{accessorKey:"max_usage",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.max_usage")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.original.max_usage})},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("code.table.columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.original.created_at)})}]};function Yh(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ne({queryKey:["giftCardCodes",u,a,l],queryFn:()=>Ds.getCodes({per_page:u.pageSize,page:u.pageIndex+1,filter:a,sort:l})}),j=Be({data:c?.data??[],columns:Gh(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},pageCount:Math.ceil((c?.total??0)/u.pageSize),rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,onPaginationChange:x,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsx("div",{className:"space-y-4",children:e.jsx(ts,{table:j,toolbar:e.jsx(Hh,{table:j,refetch:o})})})}const Wh=()=>{const{t:s}=M("giftCard");return[{accessorKey:"id",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.id")}),cell:({row:n})=>e.jsx(U,{children:n.original.id})},{accessorKey:"code",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.code")}),cell:({row:n})=>e.jsx(U,{variant:"secondary",children:n.original.code})},{accessorKey:"user_email",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.user_email")})},{accessorKey:"template_name",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.template_name")})},{accessorKey:"created_at",header:({column:n})=>e.jsx(O,{column:n,title:s("usage.table.columns.created_at")}),cell:({row:n})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(n.original.created_at)})}]};function Jh(){const[s,n]=m.useState([]),[t,r]=m.useState([]),[a,i]=m.useState({pageIndex:0,pageSize:20}),{data:l}=ne({queryKey:["giftCardUsages",a,s,t],queryFn:()=>Ds.getUsages({per_page:a.pageSize,page:a.pageIndex+1,filter:s,sort:t})}),d=Be({data:l?.data??[],columns:Wh(),state:{sorting:t,columnFilters:s,pagination:a},pageCount:Math.ceil((l?.total??0)/a.pageSize),rowCount:l?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,onSortingChange:r,onColumnFiltersChange:n,onPaginationChange:i,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),getSortedRowModel:gs()});return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(D,{placeholder:"搜索用户邮箱...",value:d.getColumn("user_email")?.getFilterValue()??"",onChange:u=>d.getColumn("user_email")?.setFilterValue(u.target.value),className:"h-8 w-[150px] lg:w-[250px]"})}),e.jsx(ts,{table:d})]})}function Qh(){const{t:s}=M("giftCard"),{data:n,isLoading:t}=ne({queryKey:["giftCardStats"],queryFn:()=>Ds.getStatistics({})}),r=n?.data?.total_stats,a=[{title:s("statistics.total.templates_count"),value:r?.templates_count},{title:s("statistics.total.active_templates_count"),value:r?.active_templates_count},{title:s("statistics.total.codes_count"),value:r?.codes_count},{title:s("statistics.total.used_codes_count"),value:r?.used_codes_count}];return e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:a.map((i,l)=>e.jsxs(ke,{children:[e.jsx(Pe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:e.jsx(Re,{className:"text-sm font-medium",children:i.title})}),e.jsx(Le,{children:t?e.jsx(je,{className:"h-8 w-1/2"}):e.jsx("div",{className:"text-2xl font-bold",children:i.value??0})})]},l))})}function Xh(){const{t:s}=M("giftCard"),[n,t]=m.useState("templates");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-6 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.jsxs(gt,{value:n,onValueChange:t,className:"flex-1",children:[e.jsxs(at,{className:"grid w-full grid-cols-4",children:[e.jsx($e,{value:"templates",children:s("tabs.templates")}),e.jsx($e,{value:"codes",children:s("tabs.codes")}),e.jsx($e,{value:"usages",children:s("tabs.usages")}),e.jsx($e,{value:"statistics",children:s("tabs.statistics")})]}),e.jsx(ms,{value:"templates",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("template.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("template.description")})]})}),e.jsx($h,{})]})}),e.jsx(ms,{value:"codes",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("code.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("code.description")})]})}),e.jsx(Yh,{})]})}),e.jsx(ms,{value:"usages",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("usage.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("usage.description")})]})}),e.jsx(Jh,{})]})}),e.jsx(ms,{value:"statistics",className:"mt-6 flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:s("statistics.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("statistics.description")})]})}),e.jsx(Qh,{})]})})]})]})]})}const Zh=Object.freeze(Object.defineProperty({__proto__:null,default:Xh},Symbol.toStringTag,{value:"Module"})),eg=1,sg=1e6;let gn=0;function tg(){return gn=(gn+1)%Number.MAX_SAFE_INTEGER,gn.toString()}const pn=new Map,Cr=s=>{if(pn.has(s))return;const n=setTimeout(()=>{pn.delete(s),Qt({type:"REMOVE_TOAST",toastId:s})},sg);pn.set(s,n)},ag=(s,n)=>{switch(n.type){case"ADD_TOAST":return{...s,toasts:[n.toast,...s.toasts].slice(0,eg)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(t=>t.id===n.toast.id?{...t,...n.toast}:t)};case"DISMISS_TOAST":{const{toastId:t}=n;return t?Cr(t):s.toasts.forEach(r=>{Cr(r.id)}),{...s,toasts:s.toasts.map(r=>r.id===t||t===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return n.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(t=>t.id!==n.toastId)}}},_a=[];let Na={toasts:[]};function Qt(s){Na=ag(Na,s),_a.forEach(n=>{n(Na)})}function ng({...s}){const n=tg(),t=a=>Qt({type:"UPDATE_TOAST",toast:{...a,id:n}}),r=()=>Qt({type:"DISMISS_TOAST",toastId:n});return Qt({type:"ADD_TOAST",toast:{...s,id:n,open:!0,onOpenChange:a=>{a||r()}}}),{id:n,dismiss:r,update:t}}function Ci(){const[s,n]=m.useState(Na);return m.useEffect(()=>(_a.push(n),()=>{const t=_a.indexOf(n);t>-1&&_a.splice(t,1)}),[s]),{...s,toast:ng,dismiss:t=>Qt({type:"DISMISS_TOAST",toastId:t})}}function rg({open:s,onOpenChange:n,table:t}){const{t:r}=M("user"),{toast:a}=Ci(),[i,l]=m.useState(!1),[d,u]=m.useState(""),[x,o]=m.useState(""),c=async()=>{if(!d||!x){a({title:r("messages.error"),description:r("messages.send_mail.required_fields"),variant:"destructive"});return}try{l(!0),await Os.sendMail({subject:d,content:x,filter:t.getState().columnFilters,sort:t.getState().sorting[0]?.id,sort_type:t.getState().sorting[0]?.desc?"DESC":"ASC"}),a({title:r("messages.success"),description:r("messages.send_mail.success")}),n(!1),u(""),o("")}catch{a({title:r("messages.error"),description:r("messages.send_mail.failed"),variant:"destructive"})}finally{l(!1)}};return e.jsx(de,{open:s,onOpenChange:n,children:e.jsxs(ce,{className:"sm:max-w-[500px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:r("send_mail.title")}),e.jsx(Ae,{children:r("send_mail.description")})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"subject",className:"text-right",children:r("send_mail.subject")}),e.jsx(D,{id:"subject",value:d,onChange:j=>u(j.target.value),className:"col-span-3"})]}),e.jsxs("div",{className:"grid grid-cols-4 items-center gap-4",children:[e.jsx("label",{htmlFor:"content",className:"text-right",children:r("send_mail.content")}),e.jsx(Fs,{id:"content",value:x,onChange:j=>o(j.target.value),className:"col-span-3",rows:6})]})]}),e.jsx(Me,{children:e.jsx(G,{type:"submit",onClick:c,disabled:i,children:r(i?"send_mail.sending":"send_mail.send")})})]})})}function lg({trigger:s}){const{t:n}=M("user"),[t,r]=m.useState(!1),[a,i]=m.useState(30),{data:l,isLoading:d}=ne({queryKey:["trafficResetStats",a],queryFn:()=>aa.getStats({days:a}),enabled:t}),u=[{title:n("traffic_reset.stats.total_resets"),value:l?.data?.total_resets||0,icon:Gt,color:"text-blue-600",bgColor:"bg-blue-100"},{title:n("traffic_reset.stats.auto_resets"),value:l?.data?.auto_resets||0,icon:ka,color:"text-green-600",bgColor:"bg-green-100"},{title:n("traffic_reset.stats.manual_resets"),value:l?.data?.manual_resets||0,icon:ws,color:"text-orange-600",bgColor:"bg-orange-100"},{title:n("traffic_reset.stats.cron_resets"),value:l?.data?.cron_resets||0,icon:zn,color:"text-purple-600",bgColor:"bg-purple-100"}],x=[{value:7,label:n("traffic_reset.stats.days_options.week")},{value:30,label:n("traffic_reset.stats.days_options.month")},{value:90,label:n("traffic_reset.stats.days_options.quarter")},{value:365,label:n("traffic_reset.stats.days_options.year")}];return e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(ps,{asChild:!0,children:s}),e.jsxs(ce,{className:"max-w-2xl",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5"}),n("traffic_reset.stats.title")]}),e.jsx(Ae,{children:n("traffic_reset.stats.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-medium",children:n("traffic_reset.stats.time_range")}),e.jsxs(J,{value:a.toString(),onValueChange:o=>i(Number(o)),children:[e.jsx(Y,{className:"w-[180px]",children:e.jsx(Q,{})}),e.jsx(W,{children:x.map(o=>e.jsx(A,{value:o.value.toString(),children:o.label},o.value))})]})]}),d?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Xt,{className:"h-6 w-6 animate-spin"})}):e.jsx("div",{className:"grid grid-cols-2 gap-4",children:u.map((o,c)=>e.jsxs(ke,{className:"relative overflow-hidden",children:[e.jsxs(Pe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium text-muted-foreground",children:o.title}),e.jsx("div",{className:`rounded-lg p-2 ${o.bgColor}`,children:e.jsx(o.icon,{className:`h-4 w-4 ${o.color}`})})]}),e.jsxs(Le,{children:[e.jsx("div",{className:"text-2xl font-bold",children:o.value.toLocaleString()}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n("traffic_reset.stats.in_period",{days:a})})]})]},c))}),l?.data&&e.jsxs(ke,{children:[e.jsxs(Pe,{children:[e.jsx(Re,{className:"text-lg",children:n("traffic_reset.stats.breakdown")}),e.jsx(Us,{children:n("traffic_reset.stats.breakdown_description")})]}),e.jsx(Le,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.auto_percentage")}),e.jsxs(U,{variant:"outline",className:"border-green-200 bg-green-50 text-green-700",children:[l.data.total_resets>0?(l.data.auto_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.manual_percentage")}),e.jsxs(U,{variant:"outline",className:"border-orange-200 bg-orange-50 text-orange-700",children:[l.data.total_resets>0?(l.data.manual_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:n("traffic_reset.stats.cron_percentage")}),e.jsxs(U,{variant:"outline",className:"border-purple-200 bg-purple-50 text-purple-700",children:[l.data.total_resets>0?(l.data.cron_resets/l.data.total_resets*100).toFixed(1):0,"%"]})]})]})})]})]})]})]})}const ig=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(),download_csv:h.boolean().optional()}).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"]}),og={email_prefix:"",email_suffix:"",password:"",expired_at:null,plan_id:null,generate_count:void 0,download_csv:!1};function cg({refetch:s}){const{t:n}=M("user"),[t,r]=m.useState(!1),a=we({resolver:Te(ig),defaultValues:og,mode:"onChange"}),[i,l]=m.useState([]);return m.useEffect(()=>{t&&ys.getList().then(({data:d})=>{d&&l(d)})},[t]),e.jsxs(de,{open:t,onOpenChange:r,children:[e.jsx(ps,{asChild:!0,children:e.jsxs(G,{size:"sm",variant:"outline",className:"gap-0 space-x-2",children:[e.jsx(Ke,{icon:"ion:add"}),e.jsx("div",{children:n("generate.button")})]})}),e.jsxs(ce,{className:"sm:max-w-[425px]",children:[e.jsxs(he,{children:[e.jsx(me,{children:n("generate.title")}),e.jsx(Ae,{})]}),e.jsxs(De,{...a,children:[e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.email")}),e.jsxs("div",{className:"flex",children:[!a.watch("generate_count")&&e.jsx(b,{control:a.control,name:"email_prefix",render:({field:d})=>e.jsx(D,{className:"flex-[5] rounded-r-none",placeholder:n("generate.form.email_prefix"),...d})}),e.jsx("div",{className:`z-[-1] border border-r-0 border-input px-3 py-1 shadow-sm ${a.watch("generate_count")?"rounded-l-md":"border-l-0"}`,children:"@"}),e.jsx(b,{control:a.control,name:"email_suffix",render:({field:d})=>e.jsx(D,{className:"flex-[4] rounded-l-none",placeholder:n("generate.form.email_domain"),...d})})]})]}),e.jsx(b,{control:a.control,name:"password",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.password")}),e.jsx(D,{placeholder:n("generate.form.password_placeholder"),...d}),e.jsx(R,{})]})}),e.jsx(b,{control:a.control,name:"expired_at",render:({field:d})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:n("generate.form.expire_time")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(G,{variant:"outline",className:w("w-full pl-3 text-left font-normal",!d.value&&"text-muted-foreground"),children:[d.value?ie(d.value):e.jsx("span",{children:n("generate.form.expire_time_placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsxs(Xe,{className:"flex w-auto flex-col space-y-2 p-2",children:[e.jsx(Nd,{asChild:!0,children:e.jsx(G,{variant:"outline",className:"w-full",onClick:()=>{d.onChange(null)},children:n("generate.form.permanent")})}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Cs,{mode:"single",selected:d.value?new Date(d.value*1e3):void 0,onSelect:u=>{u&&d.onChange(u?.getTime()/1e3)}})})]})]})]})}),e.jsx(b,{control:a.control,name:"plan_id",render:({field:d})=>e.jsxs(v,{children:[e.jsx(y,{children:n("generate.form.subscription")}),e.jsx(_,{children:e.jsxs(J,{value:d.value?d.value.toString():"null",onValueChange:u=>d.onChange(u==="null"?null:parseInt(u)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:n("generate.form.subscription_none")})}),e.jsxs(W,{children:[e.jsx(A,{value:"null",children:n("generate.form.subscription_none")}),i.map(u=>e.jsx(A,{value:u.id.toString(),children:u.name},u.id))]})]})})]})}),!a.watch("email_prefix")&&e.jsx(b,{control:a.control,name:"generate_count",render:({field:d})=>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:d.value||"",onChange:u=>d.onChange(u.target.value?parseInt(u.target.value):null)})]})}),a.watch("generate_count")&&e.jsx(b,{control:a.control,name:"download_csv",render:({field:d})=>e.jsxs(v,{className:"flex cursor-pointer flex-row items-center space-x-2 space-y-0",children:[e.jsx(_,{children:e.jsx(Gn,{checked:d.value,onCheckedChange:d.onChange})}),e.jsx(y,{children:n("generate.form.download_csv")})]})})]}),e.jsxs(Me,{children:[e.jsx(G,{variant:"outline",onClick:()=>r(!1),children:n("generate.form.cancel")}),e.jsx(G,{onClick:()=>a.handleSubmit(async d=>{if(d.download_csv){const u=await Os.generate(d);if(u&&u instanceof Blob){const x=window.URL.createObjectURL(u),o=document.createElement("a");o.href=x,o.download=`users_${new Date().getTime()}.csv`,document.body.appendChild(o),o.click(),o.remove(),window.URL.revokeObjectURL(x),$.success(n("generate.form.success")),a.reset(),s(),r(!1)}}else{const{data:u}=await Os.generate(d);u&&($.success(n("generate.form.success")),a.reset(),s(),r(!1))}})(),children:n("generate.form.submit")})]})]})]})}const Yn=Er,Si=Vr,dg=Ir,ki=m.forwardRef(({className:s,...n},t)=>e.jsx(Va,{className:w("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:t}));ki.displayName=Va.displayName;const mg=xt("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"}}),en=m.forwardRef(({side:s="right",className:n,children:t,...r},a)=>e.jsxs(dg,{children:[e.jsx(ki,{}),e.jsxs(Ia,{ref:a,className:w(mg({side:s}),n),...r,children:[e.jsxs(Fn,{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(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]}),t]})]}));en.displayName=Ia.displayName;const sn=({className:s,...n})=>e.jsx("div",{className:w("flex flex-col space-y-2 text-center sm:text-left",s),...n});sn.displayName="SheetHeader";const Ti=({className:s,...n})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...n});Ti.displayName="SheetFooter";const tn=m.forwardRef(({className:s,...n},t)=>e.jsx(Ma,{ref:t,className:w("text-lg font-semibold text-foreground",s),...n}));tn.displayName=Ma.displayName;const an=m.forwardRef(({className:s,...n},t)=>e.jsx(Oa,{ref:t,className:w("text-sm text-muted-foreground",s),...n}));an.displayName=Oa.displayName;function ug({table:s,refetch:n,permissionGroups:t=[],subscriptionPlans:r=[]}){const{t:a}=M("user"),{toast:i}=Ci(),l=s.getState().columnFilters.length>0,[d,u]=m.useState([]),[x,o]=m.useState(!1),[c,j]=m.useState(!1),[P,k]=m.useState(!1),[C,T]=m.useState(!1),p=async()=>{try{const se=await Os.dumpCSV({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),te=se;console.log(se);const q=new Blob([te],{type:"text/csv;charset=utf-8;"}),ee=window.URL.createObjectURL(q),fe=document.createElement("a");fe.href=ee,fe.setAttribute("download",`users_${new Date().toISOString()}.csv`),document.body.appendChild(fe),fe.click(),fe.remove(),window.URL.revokeObjectURL(ee),i({title:a("messages.success"),description:a("messages.export.success")})}catch{i({title:a("messages.error"),description:a("messages.export.failed"),variant:"destructive"})}},S=async()=>{try{T(!0),await Os.batchBan({filter:s.getState().columnFilters,sort:s.getState().sorting[0]?.id,sort_type:s.getState().sorting[0]?.desc?"DESC":"ASC"}),i({title:a("messages.success"),description:a("messages.batch_ban.success")}),n()}catch{i({title:a("messages.error"),description:a("messages.batch_ban.failed"),variant:"destructive"})}finally{T(!1),k(!1)}},N=[{label:a("filter.fields.email"),value:"email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.id"),value:"id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.plan_id"),value:"plan_id",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],useOptions:!0},{label:a("filter.fields.transfer_enable"),value:"transfer_enable",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.total_used"),value:"total_used",type:"number",unit:"GB",operators:[{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.online_count"),value:"online_count",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.lt"),value:"lt"}]},{label:a("filter.fields.expired_at"),value:"expired_at",type:"date",operators:[{label:a("filter.operators.lt"),value:"lt"},{label:a("filter.operators.gt"),value:"gt"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.uuid"),value:"uuid",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.token"),value:"token",type:"text",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.banned"),value:"banned",type:"select",operators:[{label:a("filter.operators.eq"),value:"eq"}],options:[{label:a("filter.status.normal"),value:"0"},{label:a("filter.status.banned"),value:"1"}]},{label:a("filter.fields.remark"),value:"remarks",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.inviter_email"),value:"invite_user.email",type:"text",operators:[{label:a("filter.operators.contains"),value:"contains"},{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.invite_user_id"),value:"invite_user_id",type:"number",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_admin"),value:"is_admin",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]},{label:a("filter.fields.is_staff"),value:"is_staff",type:"boolean",operators:[{label:a("filter.operators.eq"),value:"eq"}]}],g=se=>se*1024*1024*1024,f=se=>se/(1024*1024*1024),V=()=>{u([...d,{field:"",operator:"",value:""}])},E=se=>{u(d.filter((te,q)=>q!==se))},L=(se,te,q)=>{const ee=[...d];if(ee[se]={...ee[se],[te]:q},te==="field"){const fe=N.find(fs=>fs.value===q);fe&&(ee[se].operator=fe.operators[0].value,ee[se].value=fe.type==="boolean"?!1:"")}u(ee)},K=(se,te)=>{const q=N.find(ee=>ee.value===se.field);if(!q)return null;switch(q.type){case"text":return e.jsx(D,{placeholder:a("filter.sheet.value"),value:se.value,onChange:ee=>L(te,"value",ee.target.value)});case"number":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(D,{type:"number",placeholder:a("filter.sheet.value_number",{unit:q.unit}),value:q.unit==="GB"?f(se.value||0):se.value,onChange:ee=>{const fe=Number(ee.target.value);L(te,"value",q.unit==="GB"?g(fe):fe)}}),q.unit&&e.jsx("span",{className:"text-sm text-muted-foreground",children:q.unit})]});case"date":return e.jsx(Cs,{mode:"single",selected:se.value,onSelect:ee=>L(te,"value",ee),className:"flex flex-1 justify-center rounded-md border"});case"select":return e.jsxs(J,{value:se.value,onValueChange:ee=>L(te,"value",ee),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:a("filter.sheet.value")})}),e.jsx(W,{children:q.useOptions?r.map(ee=>e.jsx(A,{value:ee.value.toString(),children:ee.label},ee.value)):q.options?.map(ee=>e.jsx(A,{value:ee.value.toString(),children:ee.label},ee.value))})]});case"boolean":return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Z,{checked:se.value,onCheckedChange:ee=>L(te,"value",ee)}),e.jsx(Je,{children:se.value?a("filter.boolean.true"):a("filter.boolean.false")})]});default:return null}},X=()=>{const se=d.filter(te=>te.field&&te.operator&&te.value!=="").map(te=>{const q=N.find(fe=>fe.value===te.field);let ee=te.value;return te.operator==="contains"?{id:te.field,value:ee}:(q?.type==="date"&&ee instanceof Date&&(ee=Math.floor(ee.getTime()/1e3)),q?.type==="boolean"&&(ee=ee?1:0),{id:te.field,value:`${te.operator}:${ee}`})});s.setColumnFilters(se),o(!1)};return e.jsxs("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(cg,{refetch:n}),e.jsx(D,{placeholder:a("filter.email_search"),value:s.getColumn("email")?.getFilterValue()??"",onChange:se=>s.getColumn("email")?.setFilterValue(se.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(Yn,{open:x,onOpenChange:o,children:[e.jsx(Si,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:[e.jsx(Rl,{className:"mr-2 h-4 w-4"}),a("filter.advanced"),d.length>0&&e.jsx(U,{variant:"secondary",className:"ml-2 rounded-sm px-1",children:d.length})]})}),e.jsxs(en,{className:"w-[400px] sm:w-[540px]",children:[e.jsxs(sn,{children:[e.jsx(tn,{children:a("filter.sheet.title")}),e.jsx(an,{children:a("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:a("filter.sheet.conditions")}),e.jsx(F,{variant:"outline",size:"sm",onClick:V,children:a("filter.sheet.add")})]}),e.jsx(ut,{className:"h-[calc(100vh-280px)] ",children:e.jsx("div",{className:"space-y-4",children:d.map((se,te)=>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(Je,{children:a("filter.sheet.condition",{number:te+1})}),e.jsx(F,{variant:"ghost",size:"sm",onClick:()=>E(te),children:e.jsx(os,{className:"h-4 w-4"})})]}),e.jsxs(J,{value:se.field,onValueChange:q=>L(te,"field",q),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:a("filter.sheet.field")})}),e.jsx(W,{children:e.jsx(js,{children:N.map(q=>e.jsx(A,{value:q.value,className:"cursor-pointer",children:q.label},q.value))})})]}),se.field&&e.jsxs(J,{value:se.operator,onValueChange:q=>L(te,"operator",q),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:a("filter.sheet.operator")})}),e.jsx(W,{children:N.find(q=>q.value===se.field)?.operators.map(q=>e.jsx(A,{value:q.value,children:q.label},q.value))})]}),se.field&&se.operator&&K(se,te)]},te))})}),e.jsxs("div",{className:"flex justify-end space-x-2",children:[e.jsx(F,{variant:"outline",onClick:()=>{u([]),o(!1)},children:a("filter.sheet.reset")}),e.jsx(F,{onClick:X,children:a("filter.sheet.apply")})]})]})]})]}),l&&e.jsxs(F,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),u([])},className:"h-8 px-2 lg:px-3",children:[a("filter.sheet.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]}),e.jsxs(zs,{modal:!1,children:[e.jsx(Ks,{asChild:!0,children:e.jsx(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",children:a("actions.title")})}),e.jsxs(Ms,{children:[e.jsx(Se,{onClick:()=>j(!0),children:a("actions.send_email")}),e.jsx(Se,{onClick:p,children:a("actions.export_csv")}),e.jsx(et,{}),e.jsx(Se,{asChild:!0,children:e.jsx(lg,{trigger:e.jsx("div",{className:"w-full cursor-pointer px-2 py-1.5 text-sm",children:a("actions.traffic_reset_stats")})})}),e.jsx(et,{}),e.jsx(Se,{onClick:()=>k(!0),className:"text-red-600 focus:text-red-600",children:a("actions.batch_ban")})]})]})]}),e.jsx(rg,{open:c,onOpenChange:j,table:s}),e.jsx(Kn,{open:P,onOpenChange:k,children:e.jsxs(Ka,{children:[e.jsxs(Ba,{children:[e.jsx(Ya,{children:a("actions.confirm_ban.title")}),e.jsx(Wa,{children:a(l?"actions.confirm_ban.filtered_description":"actions.confirm_ban.all_description")})]}),e.jsxs(Ga,{children:[e.jsx(Qa,{disabled:C,children:a("actions.confirm_ban.cancel")}),e.jsx(Ja,{onClick:S,disabled:C,className:"bg-red-600 hover:bg-red-700 focus:ring-red-600",children:a(C?"actions.confirm_ban.banning":"actions.confirm_ban.confirm")})]})]})})]})}const Di=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"})}),Pi=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"})}),xg=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"})}),hg=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"})}),fn=[{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:qd(s.original.record_at)})})},{accessorKey:"u",header:"上行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Di,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-mono text-sm",children:ze(s.original.u/parseFloat(s.original.server_rate))})]})},{accessorKey:"d",header:"下行流量",cell:({row:s})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Pi,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-mono text-sm",children:ze(s.original.d/parseFloat(s.original.server_rate))})]})},{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(U,{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:ze(n)})}}];function Li({user_id:s,dialogTrigger:n}){const{t}=M(["traffic"]),[r,a]=m.useState(!1),[i,l]=m.useState({pageIndex:0,pageSize:20}),{data:d,isLoading:u}=ne({queryKey:["userStats",s,i,r],queryFn:()=>r?Os.getStats({user_id:s,pageSize:i.pageSize,page:i.pageIndex+1}):null}),x=Be({data:d?.data??[],columns:fn,pageCount:Math.ceil((d?.total??0)/i.pageSize),state:{pagination:i},manualPagination:!0,getCoreRowModel:Ge(),onPaginationChange:l});return e.jsxs(de,{open:r,onOpenChange:a,children:[e.jsx(ps,{asChild:!0,children:n}),e.jsxs(ce,{className:"sm:max-w-[700px]",children:[e.jsx(he,{children:e.jsx(me,{children:t("trafficRecord.title")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(qn,{children:x.getHeaderGroups().map(o=>e.jsx(Js,{children:o.headers.map(c=>e.jsx(Un,{className:w("h-10 px-2 text-xs",c.id==="total"&&"text-right"),children:c.isPlaceholder?null:Ca(c.column.columnDef.header,c.getContext())},c.id))},o.id))}),e.jsx(Hn,{children:u?Array.from({length:i.pageSize}).map((o,c)=>e.jsx(Js,{children:Array.from({length:fn.length}).map((j,P)=>e.jsx(Tt,{className:"p-2",children:e.jsx(je,{className:"h-6 w-full"})},P))},c)):x.getRowModel().rows?.length?x.getRowModel().rows.map(o=>e.jsx(Js,{"data-state":o.getIsSelected()&&"selected",className:"h-10",children:o.getVisibleCells().map(c=>e.jsx(Tt,{className:"px-2",children:Ca(c.column.columnDef.cell,c.getContext())},c.id))},o.id)):e.jsx(Js,{children:e.jsx(Tt,{colSpan:fn.length,className:"h-24 text-center",children:t("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:t("trafficRecord.perPage")}),e.jsxs(J,{value:`${x.getState().pagination.pageSize}`,onValueChange:o=>{x.setPageSize(Number(o))},children:[e.jsx(Y,{className:"h-8 w-[70px]",children:e.jsx(Q,{placeholder:x.getState().pagination.pageSize})}),e.jsx(W,{side:"top",children:[10,20,30,40,50].map(o=>e.jsx(A,{value:`${o}`,children:o},o))})]}),e.jsx("p",{className:"text-sm font-medium",children:t("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:t("trafficRecord.page",{current:x.getState().pagination.pageIndex+1,total:x.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:()=>x.previousPage(),disabled:!x.getCanPreviousPage()||u,children:e.jsx(xg,{className:"h-4 w-4"})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>x.nextPage(),disabled:!x.getCanNextPage()||u,children:e.jsx(hg,{className:"h-4 w-4"})})]})]})]})]})]})]})}function gg({user:s,trigger:n,onSuccess:t}){const{t:r}=M("user"),[a,i]=m.useState(!1),[l,d]=m.useState(""),[u,x]=m.useState(!1),{data:o,isLoading:c}=ne({queryKey:["trafficResetHistory",s.id],queryFn:()=>aa.getUserHistory(s.id,{limit:10}),enabled:a}),j=async()=>{try{x(!0);const{data:C}=await aa.resetUser({user_id:s.id,reason:l.trim()||void 0});C&&($.success(r("traffic_reset.reset_success")),i(!1),d(""),t?.())}finally{x(!1)}},P=C=>{switch(C){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},k=C=>{switch(C){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}};return e.jsxs(de,{open:a,onOpenChange:i,children:[e.jsx(ps,{asChild:!0,children:n}),e.jsxs(ce,{className:"max-h-[90vh] max-w-4xl overflow-hidden",children:[e.jsxs(he,{children:[e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(Gt,{className:"h-5 w-5"}),r("traffic_reset.title")]}),e.jsx(Ae,{children:r("traffic_reset.description",{email:s.email})})]}),e.jsxs(gt,{defaultValue:"reset",className:"w-full",children:[e.jsxs(at,{className:"grid w-full grid-cols-2",children:[e.jsxs($e,{value:"reset",className:"flex items-center gap-2",children:[e.jsx(Gt,{className:"h-4 w-4"}),r("traffic_reset.tabs.reset")]}),e.jsxs($e,{value:"history",className:"flex items-center gap-2",children:[e.jsx(cr,{className:"h-4 w-4"}),r("traffic_reset.tabs.history")]})]}),e.jsxs(ms,{value:"reset",className:"space-y-4",children:[e.jsxs(ke,{children:[e.jsx(Pe,{className:"pb-3",children:e.jsxs(Re,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Vl,{className:"h-5 w-5"}),r("traffic_reset.user_info")]})}),e.jsx(Le,{className:"space-y-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.email")}),e.jsx("p",{className:"font-medium",children:s.email})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.used_traffic")}),e.jsx("p",{className:"font-medium",children:ze(s.total_used)})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.total_traffic")}),e.jsx("p",{className:"font-medium",children:ze(s.transfer_enable)})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("columns.expire_time")}),e.jsx("p",{className:"font-medium",children:s.expired_at?ie(s.expired_at):r("columns.expire_status.permanent")})]})]})})]}),e.jsxs(ke,{className:"border-amber-200 bg-amber-50",children:[e.jsx(Pe,{className:"pb-3",children:e.jsxs(Re,{className:"flex items-center gap-2 text-lg text-amber-800",children:[e.jsx(Bt,{className:"h-5 w-5"}),r("traffic_reset.warning.title")]})}),e.jsx(Le,{children:e.jsxs("ul",{className:"space-y-2 text-sm text-amber-700",children:[e.jsxs("li",{children:["• ",r("traffic_reset.warning.irreversible")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.reset_to_zero")]}),e.jsxs("li",{children:["• ",r("traffic_reset.warning.logged")]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Je,{htmlFor:"reason",children:r("traffic_reset.reason.label")}),e.jsx(Fs,{id:"reason",placeholder:r("traffic_reset.reason.placeholder"),value:l,onChange:C=>d(C.target.value),className:"min-h-[80px]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("traffic_reset.reason.optional")})]}),e.jsxs(Me,{children:[e.jsx(G,{variant:"outline",onClick:()=>i(!1),children:r("common:cancel")}),e.jsx(G,{onClick:j,disabled:u,className:"bg-destructive hover:bg-destructive/90",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Xt,{className:"mr-2 h-4 w-4 animate-spin"}),r("traffic_reset.resetting")]}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),r("traffic_reset.confirm_reset")]})})]})]}),e.jsx(ms,{value:"history",className:"space-y-4",children:c?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Xt,{className:"h-6 w-6 animate-spin"})}):e.jsxs("div",{className:"space-y-4",children:[o?.data?.user&&e.jsxs(ke,{children:[e.jsx(Pe,{className:"pb-3",children:e.jsx(Re,{className:"text-lg",children:r("traffic_reset.history.summary")})}),e.jsx(Le,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.reset_count")}),e.jsx("p",{className:"font-medium",children:o.data.user.reset_count})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.last_reset")}),e.jsx("p",{className:"font-medium",children:o.data.user.last_reset_at?ie(o.data.user.last_reset_at):r("traffic_reset.history.never")})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.next_reset")}),e.jsx("p",{className:"font-medium",children:o.data.user.next_reset_at?ie(o.data.user.next_reset_at):r("traffic_reset.history.no_schedule")})]})]})})]}),e.jsxs(ke,{children:[e.jsxs(Pe,{className:"pb-3",children:[e.jsx(Re,{className:"text-lg",children:r("traffic_reset.history.records")}),e.jsx(Us,{children:r("traffic_reset.history.recent_records")})]}),e.jsx(Le,{children:e.jsx(ut,{className:"h-[300px]",children:o?.data?.history?.length?e.jsx("div",{className:"space-y-3",children:o.data.history.map((C,T)=>e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between rounded-lg border bg-card p-3",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:P(C.reset_type),children:C.reset_type_name}),e.jsx(U,{variant:"outline",className:k(C.trigger_source),children:C.trigger_source_name})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs(Je,{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(zn,{className:"h-3 w-3"}),r("traffic_reset.history.reset_time")]}),e.jsx("p",{className:"font-medium",children:ie(C.reset_time)})]}),e.jsxs("div",{children:[e.jsx(Je,{className:"text-muted-foreground",children:r("traffic_reset.history.traffic_cleared")}),e.jsx("p",{className:"font-medium text-destructive",children:C.old_traffic.formatted})]})]})]})}),Te.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"})}),jg=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"})}),vg=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"})}),Sr=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"})}),bg=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"})}),yg=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"})}),_g=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"})}),Ng=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"})}),wg=(s,n,t,r)=>{const{t:a}=M("user");return[{accessorKey:"is_admin",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_admin")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"is_staff",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.is_staff")}),enableSorting:!1,enableHiding:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l)),size:0},{accessorKey:"id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.id")}),cell:({row:i})=>e.jsx(U,{variant:"outline",children:i.original.id}),enableSorting:!0,enableHiding:!1},{accessorKey:"email",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.email")}),cell:({row:i})=>{const l=i.original.t||0,d=Date.now()/1e3-l<120,u=Math.floor(Date.now()/1e3-l);let x=d?a("columns.online_status.online"):l===0?a("columns.online_status.never"):a("columns.online_status.last_online",{time:ie(l)});if(!d&&l!==0){const o=Math.floor(u/60),c=Math.floor(o/60),j=Math.floor(c/24);j>0?x+=`
+`+a("columns.online_status.offline_duration.days",{count:j}):c>0?x+=`
`+a("columns.online_status.offline_duration.hours",{count:c}):o>0?x+=`
`+a("columns.online_status.offline_duration.minutes",{count:o}):x+=`
-`+a("columns.online_status.offline_duration.seconds",{count:u})}return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{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",d?"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:i.original.email})]})}),e.jsx(ue,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:x})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.online_count")}),cell:({row:i})=>{const l=i.original.device_limit,d=i.original.online_count||0;return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(U,{variant:"outline",className:N("min-w-[4rem] justify-center",l!==null&&d>=l?"border-destructive/50 bg-destructive/10 text-destructive":"border-primary/40 bg-primary/5 text-primary/90"),children:[d," / ",l===null?"∞":l]})})}),e.jsx(ue,{side:"bottom",children:e.jsx("p",{className:"text-sm",children:l===null?a("columns.device_limit.unlimited"):a("columns.device_limit.limited",{count:l})})})]})})},enableSorting:!0,enableHiding:!1},{accessorKey:"banned",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.status")}),cell:({row:i})=>{const l=i.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(U,{className:N("min-w-20 justify-center transition-colors",l?"bg-destructive/15 text-destructive hover:bg-destructive/25":"bg-success/15 text-success hover:bg-success/25"),children:a(l?"columns.status_text.banned":"columns.status_text.normal")})})},enableSorting:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l))},{accessorKey:"plan_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.subscription")}),cell:({row:i})=>e.jsx("div",{className:"min-w-[10em] break-all",children:i.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.group")}),cell:({row:i})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(U,{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:i.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.used_traffic")}),cell:({row:i})=>{const l=ze(i.original?.total_used),d=ze(i.original?.transfer_enable),u=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{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:l}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.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",u>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(u,100)}%`}})})]})}),e.jsx(ue,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",d]})})]})})}},{accessorKey:"transfer_enable",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.total_traffic")}),cell:({row:i})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:ze(i.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.expire_time")}),cell:({row:i})=>{const l=i.original.expired_at,d=Date.now()/1e3,u=l!=null&&le.jsx(O,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=xr(i.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:l})]})}},{accessorKey:"commission_balance",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.commission")}),cell:({row:i})=>{const l=xr(i.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:l})]})}},{accessorKey:"created_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.register_time")}),cell:({row:i})=>e.jsx("div",{className:"truncate",children:ie(i.original?.created_at)}),size:1e3},{id:"actions",header:({column:i})=>e.jsx(O,{column:i,className:"justify-end",title:a("columns.actions")}),cell:({row:i,table:l})=>e.jsxs(zs,{modal:!1,children:[e.jsx(Ks,{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(Da,{className:"size-4"})})})}),e.jsxs(Ms,{align:"end",className:"min-w-[40px]",children:[e.jsx(Se,{onSelect:d=>{d.preventDefault(),t(i.original),r(!0)},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(fg,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(ji,{defaultValues:{email:i.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(jg,{className:"mr-2 "}),a("columns.actions_menu.assign_order")]})})}),e.jsx(Se,{onSelect:()=>{sa(i.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(vg,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsx(Se,{onSelect:()=>{Os.resetSecret(i.original.id).then(({data:d})=>{d&&$.success("重置成功")})},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(Cr,{className:"mr-2 "}),a("columns.actions_menu.reset_secret")]})}),e.jsx(Se,{onSelect:()=>{},className:"p-0",children:e.jsxs(Zs,{className:"flex items-center px-2 py-1.5",to:`/finance/order?user_id=eq:${i.original?.id}`,children:[e.jsx(bg,{className:"mr-2"}),a("columns.actions_menu.orders")]})}),e.jsx(Se,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(yg,{className:"mr-2 "}),a("columns.actions_menu.invites")]})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Fi,{user_id:i.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(_g,{className:"mr-2 "}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(gg,{user:i.original,onSuccess:s,trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Cr,{className:"mr-2"}),a("columns.actions_menu.reset_traffic")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(pg,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:i.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:d}=await Os.destroy(i.original.id);d&&($.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(Ng,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},Pi=m.createContext(void 0),Wn=()=>{const s=m.useContext(Pi);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},Ri=({children:s,refreshData:n})=>{const[t,r]=m.useState(!1),[a,i]=m.useState(null),l={isOpen:t,setIsOpen:r,editingUser:a,setEditingUser:i,refreshData:n};return e.jsx(Pi.Provider,{value:l,children:s})},Cg=h.object({id:h.number().default(0),email:h.string().email().default(""),invite_user_email:h.string().email().nullable().optional().default(null),password:h.string().optional().nullable().default(null),balance:h.coerce.number().default(0),commission_balance:h.coerce.number().default(0),u:h.coerce.number().default(0),d:h.coerce.number().default(0),transfer_enable:h.number().default(0),expired_at:h.number().nullable().default(null),plan_id:h.number().nullable().default(null),banned:h.boolean().default(!1),commission_type:h.number().default(0),commission_rate:h.number().nullable().default(null),discount:h.number().nullable().default(null),speed_limit:h.number().nullable().default(null),device_limit:h.number().nullable().default(null),is_admin:h.boolean().default(!1),is_staff:h.boolean().default(!1),remarks:h.string().nullable().default(null)});function Li(){const{t:s}=M("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=Wn(),[i,l]=m.useState(!1),[d,u]=m.useState([]),x=we({resolver:Te(Cg)});return m.useEffect(()=>{n&&ys.getList().then(({data:o})=>{u(o)})},[n]),m.useEffect(()=>{if(r){const o=r.invite_user?.email,{invite_user:c,...f}=r;x.reset({...f,invite_user_email:o||null,password:null,u:f.u?(f.u/1024/1024/1024).toFixed(3):"",d:f.d?(f.d/1024/1024/1024).toFixed(3):""})}},[r,x]),e.jsx(Gn,{open:n,onOpenChange:t,children:e.jsxs(en,{className:"max-w-[90%] space-y-4",children:[e.jsxs(sn,{children:[e.jsx(tn,{children:s("edit.title")}),e.jsx(an,{})]}),e.jsxs(De,{...x,children:[e.jsx(v,{control:x.control,name:"email",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.email")}),e.jsx(_,{children:e.jsx(k,{...o,placeholder:s("edit.form.email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsx(v,{control:x.control,name:"invite_user_email",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.inviter_email")}),e.jsx(_,{children:e.jsx(k,{value:o.value||"",onChange:c=>o.onChange(c.target.value?c.target.value:null),placeholder:s("edit.form.inviter_email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsx(v,{control:x.control,name:"password",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.password")}),e.jsx(_,{children:e.jsx(k,{type:"password",value:o.value||"",onChange:o.onChange,placeholder:s("edit.form.password_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(v,{control:x.control,name:"balance",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.balance")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:s("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(R,{...o})]})}),e.jsx(v,{control:x.control,name:"commission_balance",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.commission_balance")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:s("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(R,{...o})]})}),e.jsx(v,{control:x.control,name:"u",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.upload")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",step:"any",value:o.value??"",onChange:c=>o.onChange(c.target.value),placeholder:s("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(R,{...o})]})}),e.jsx(v,{control:x.control,name:"d",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.download")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",step:"any",value:o.value??"",onChange:c=>o.onChange(c.target.value),placeholder:s("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(R,{...o})]})})]}),e.jsx(v,{control:x.control,name:"transfer_enable",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.total_traffic")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value/1024/1024/1024||"",onChange:c=>o.onChange(parseInt(c.target.value)*1024*1024*1024),placeholder:s("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(R,{})]})}),e.jsx(v,{control:x.control,name:"expired_at",render:({field:o})=>e.jsxs(j,{className:"flex flex-col",children:[e.jsx(b,{children:s("edit.form.expire_time")}),e.jsxs(ls,{open:i,onOpenChange:l,children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(D,{type:"button",variant:"outline",className:N("w-full pl-3 text-left font-normal",!o.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[o.value?ie(o.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:c=>{c.preventDefault()},onEscapeKeyDown:c=>{c.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(D,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{o.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(D,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+1),c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(D,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+3),c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Cs,{mode:"single",selected:o.value?new Date(o.value*1e3):void 0,onSelect:c=>{if(c){const f=new Date(o.value?o.value*1e3:Date.now());c.setHours(f.getHours(),f.getMinutes(),f.getSeconds()),o.onChange(Math.floor(c.getTime()/1e3))}},disabled:c=>c{const c=new Date;c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3))},className:"h-6 px-2 text-xs",children:s("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{type:"datetime-local",step:"1",value:ie(o.value,"YYYY-MM-DDTHH:mm:ss"),onChange:c=>{const f=new Date(c.target.value);isNaN(f.getTime())||o.onChange(Math.floor(f.getTime()/1e3))},className:"flex-1"}),e.jsx(D,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(R,{})]})}),e.jsx(v,{control:x.control,name:"plan_id",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.subscription")}),e.jsx(_,{children:e.jsxs(J,{value:o.value!==null?String(o.value):"null",onValueChange:c=>o.onChange(c==="null"?null:parseInt(c)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"null",children:s("edit.form.subscription_none")}),d.map(c=>e.jsx(A,{value:String(c.id),children:c.name},c.id))]})]})})]})}),e.jsx(v,{control:x.control,name:"banned",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.account_status")}),e.jsx(_,{children:e.jsxs(J,{value:o.value.toString(),onValueChange:c=>o.onChange(c==="true"),children:[e.jsx(W,{children:e.jsx(Q,{})}),e.jsxs(Y,{children:[e.jsx(A,{value:"true",children:s("columns.status_text.banned")}),e.jsx(A,{value:"false",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(v,{control:x.control,name:"commission_type",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.commission_type")}),e.jsx(_,{children:e.jsxs(J,{value:o.value.toString(),onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(W,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx(A,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx(A,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(v,{control:x.control,name:"commission_rate",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.commission_rate")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(v,{control:x.control,name:"discount",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.discount")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(R,{})]})}),e.jsx(v,{control:x.control,name:"speed_limit",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.speed_limit")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(R,{})]})}),e.jsx(v,{control:x.control,name:"device_limit",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.device_limit")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(k,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(R,{})]})}),e.jsx(v,{control:x.control,name:"is_admin",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(X,{checked:o.value,onCheckedChange:c=>o.onChange(c)})})}),e.jsx(R,{})]})}),e.jsx(v,{control:x.control,name:"is_staff",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(X,{checked:o.value,onCheckedChange:c=>o.onChange(c)})})})]})}),e.jsx(v,{control:x.control,name:"remarks",render:({field:o})=>e.jsxs(j,{children:[e.jsx(b,{children:s("edit.form.remarks")}),e.jsx(_,{children:e.jsx(Rs,{className:"h-24",value:o.value||"",onChange:c=>o.onChange(c.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(R,{})]})}),e.jsxs(ki,{children:[e.jsx(D,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(D,{type:"submit",onClick:()=>{x.handleSubmit(o=>{const c={id:o.id};x.formState.dirtyFields.u&&(c.u=Math.round(parseFloat(o.u)*1024*1024*1024)),x.formState.dirtyFields.d&&(c.d=Math.round(parseFloat(o.d)*1024*1024*1024)),Object.keys(o).forEach(f=>{f!=="u"&&f!=="d"&&f!=="id"&&x.formState.dirtyFields[f]&&(c[f]=o[f])}),Os.update(c).then(({data:f})=>{f&&($.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function Sg(){const[s]=Pl(),[n,t]=m.useState({}),[r,a]=m.useState({is_admin:!1,is_staff:!1}),[i,l]=m.useState([]),[d,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const g=s.get("email");g&&l(p=>p.some(E=>E.id==="email")?p:[...p,{id:"email",value:g}])},[s]);const{refetch:c,data:f,isLoading:F}=ae({queryKey:["userList",x,i,d],queryFn:()=>Os.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:i,sort:d})}),[S,w]=m.useState([]),[T,y]=m.useState([]);m.useEffect(()=>{pt.getList().then(({data:g})=>{w(g)}),ys.getList().then(({data:g})=>{y(g)})},[]);const L=S.map(g=>({label:g.name,value:g.id})),C=T.map(g=>({label:g.name,value:g.id}));return e.jsxs(Ri,{refreshData:c,children:[e.jsx(kg,{data:f?.data??[],rowCount:f?.total??0,sorting:d,setSorting:u,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:x,setPagination:o,refetch:c,serverGroupList:S,permissionGroups:L,subscriptionPlans:C,isLoading:F}),e.jsx(Li,{})]})}function kg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:x,pagination:o,setPagination:c,refetch:f,serverGroupList:F,permissionGroups:S,subscriptionPlans:w,isLoading:T}){const{setIsOpen:y,setEditingUser:L}=Wn(),C=Be({data:s,columns:wg(f,F,L,y),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:o},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:c,getSortedRowModel:gs(),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.jsxs("div",{className:"space-y-4",children:[e.jsx(ug,{table:C,refetch:f,serverGroupList:F,permissionGroups:S,subscriptionPlans:w}),e.jsx(ts,{table:C,isLoading:T})]})}function Tg(){const{t:s}=M("user");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Sg,{})})})]})]})}const Dg=Object.freeze(Object.defineProperty({__proto__:null,default:Tg},Symbol.toStringTag,{value:"Module"})),Fg=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 Pg({table:s}){const{t:n}=M("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(gt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(at,{className:"grid w-full grid-cols-2",children:[e.jsx($e,{value:"0",children:n("status.pending")}),e.jsx($e,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(Ea,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:ds.LOW,icon:Fg,color:"gray"},{label:n("level.medium"),value:ds.MIDDLE,icon:Ti,color:"yellow"},{label:n("level.high"),value:ds.HIGH,icon:Di,color:"red"}]})]})})}function Rg(){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 Lg=xt("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"}}),Ei=m.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:N(Lg({variant:n,layout:t,className:s}),"relative group"),ref:i,...a,children:m.Children.map(r,l=>m.isValidElement(l)&&typeof l.type!="string"?m.cloneElement(l,{variant:n,layout:t}):l)}));Ei.displayName="ChatBubble";const Eg=xt("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"}}),Vi=m.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:N(Eg({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...i,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(Rg,{})}):a}));Vi.displayName="ChatBubbleMessage";const Vg=m.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,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),...r,children:t}));Vg.displayName="ChatBubbleActionWrapper";const Ii=m.forwardRef(({className:s,...n},t)=>e.jsx(Rs,{autoComplete:"off",ref:t,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}));Ii.displayName="ChatInput";const Mi=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"})}),Oi=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"})}),Sr=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"})}),Ig=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"})}),Mg=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"})}),Og=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 zg(){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(je,{className:"h-8 w-3/4"}),e.jsx(je,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(je,{className:"h-20 w-2/3"},s))})]})}function $g(){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(je,{className:"h-5 w-4/5"}),e.jsx(je,{className:"h-4 w-2/3"}),e.jsx(je,{className:"h-3 w-1/2"})]},s))})}function Ag({ticket:s,isActive:n,onClick:t}){const{t:r}=M("ticket"),a=i=>{switch(i){case ds.HIGH:return"bg-red-50 text-red-600 border-red-200";case ds.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case ds.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:t,children:[e.jsxs("div",{className:"flex max-w-[280px] items-center justify-between gap-2",children:[e.jsx("h4",{className:"flex-1 truncate font-medium",children:s.subject}),e.jsx(U,{variant:s.status===Xs.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Xs.CLOSED?r("status.closed"):r("status.processing")})]}),e.jsx("div",{className:"mt-1 max-w-[280px] truncate text-sm text-muted-foreground",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:ie(s.updated_at)}),e.jsx("div",{className:N("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===ds.LOW?"low":s.level===ds.MIDDLE?"medium":"high"}`)})]})]})}function qg({ticketId:s,dialogTrigger:n}){const{t}=M("ticket"),r=Bs(),a=m.useRef(null),i=m.useRef(null),[l,d]=m.useState(!1),[u,x]=m.useState(""),[o,c]=m.useState(!1),[f,F]=m.useState(s),[S,w]=m.useState(""),[T,y]=m.useState(!1),{setIsOpen:L,setEditingUser:C}=Wn(),{data:g,isLoading:p,refetch:V}=ae({queryKey:["tickets",l],queryFn:()=>l?kt.getList({filter:[{id:"status",value:[Xs.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:E,refetch:P,isLoading:K}=ae({queryKey:["ticket",f,l],queryFn:()=>l?kt.getInfo(f):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),Z=E?.data,ne=(g?.data||[]).filter(re=>re.subject.toLowerCase().includes(S.toLowerCase())||re.user?.email.toLowerCase().includes(S.toLowerCase())),H=(re="smooth")=>{if(a.current){const{scrollHeight:q,clientHeight:oe}=a.current;a.current.scrollTo({top:q-oe,behavior:re})}};m.useEffect(()=>{if(!l)return;const re=requestAnimationFrame(()=>{H("instant"),setTimeout(()=>H(),1e3)});return()=>{cancelAnimationFrame(re)}},[l,Z?.messages]);const ee=async()=>{const re=u.trim();!re||o||(c(!0),kt.reply({id:f,message:re}).then(()=>{x(""),P(),H(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{c(!1)}))},fe=async()=>{kt.close(f).then(()=>{$.success(t("actions.close_success")),P(),V()})},fs=()=>{Z?.user&&r("/finance/order?user_id="+Z.user.id)},Ie=Z?.status===Xs.CLOSED;return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(ps,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(ce,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(me,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 z-50 md:hidden",onClick:()=>y(!T),children:e.jsx(Sr,{className:N("h-4 w-4 transition-transform",!T&&"rotate-180")})}),e.jsxs("div",{className:N("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",T?"-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:t("list.title")}),e.jsx(G,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 md:flex",onClick:()=>y(!T),children:e.jsx(Sr,{className:N("h-4 w-4 transition-transform",!T&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ig,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(k,{placeholder:t("list.search_placeholder"),value:S,onChange:re=>w(re.target.value),className:"pl-8"})]})]}),e.jsx(ut,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:p?e.jsx($g,{}):ne.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(S?"list.no_search_results":"list.no_tickets")}):ne.map(re=>e.jsx(Ag,{ticket:re,isActive:re.id===f,onClick:()=>{F(re.id),window.innerWidth<768&&y(!0)}},re.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!T&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>y(!0)}),K?e.jsx(zg,{}):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(U,{variant:Ie?"secondary":"default",children:t(Ie?"status.closed":"status.processing")}),!Ie&&e.jsx(_s,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:fe,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(Mi,{className:"h-4 w-4"}),t("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(La,{className:"h-4 w-4"}),e.jsx("span",{children:Z?.user?.email})]}),e.jsx(Ve,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(Oi,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",ie(Z?.created_at)]})]}),e.jsx(Ve,{orientation:"vertical",className:"h-4"}),e.jsx(U,{variant:"outline",children:Z?.level!=null&&t(`level.${Z.level===ds.LOW?"low":Z.level===ds.MIDDLE?"medium":"high"}`)})]})]}),Z?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.user_info"),onClick:()=>{C(Z.user),L(!0)},children:e.jsx(La,{className:"h-4 w-4"})}),e.jsx(Fi,{user_id:Z.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Mg,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:fs,children:e.jsx(Og,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{ref:a,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:t("detail.no_messages")}):Z?.messages?.map(re=>e.jsx(Ei,{variant:re.is_from_admin?"sent":"received",className:re.is_from_admin?"ml-auto":"mr-auto",children:e.jsx(Vi,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:re.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:ie(re.created_at)})})]})})},re.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(Ii,{ref:i,disabled:Ie||o,placeholder:t(Ie?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:u,onChange:re=>x(re.target.value),onKeyDown:re=>{re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),ee())}}),e.jsx(G,{disabled:Ie||o||!u.trim(),onClick:ee,children:t(o?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const Ug=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"})}),Hg=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"})}),Kg=s=>{const{t:n}=M("ticket");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.subject")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ug,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[500px] truncate font-medium",children:t.getValue("subject")})]}),enableSorting:!1,enableHiding:!1,size:4e3},{accessorKey:"level",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.level")}),cell:({row:t})=>{const r=t.getValue("level"),a=r===ds.LOW?"default":r===ds.MIDDLE?"secondary":"destructive";return e.jsx(U,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===ds.LOW?"low":r===ds.MIDDLE?"medium":"high"}`)})},filterFn:(t,r,a)=>a.includes(t.getValue(r))},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.status")}),cell:({row:t})=>{const r=t.getValue("status"),a=t.original.reply_status,i=r===Xs.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===Xs.CLOSED?"default":a===0?"secondary":"destructive";return e.jsx(U,{variant:l,className:"whitespace-nowrap",children:i})}},{accessorKey:"updated_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.updated_at")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[e.jsx(Oi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ie(t.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const r=t.original.status!==Xs.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(qg,{ticketId:t.original.id,dialogTrigger:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(Hg,{className:"h-4 w-4"})})}),r&&e.jsx(_s,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{kt.close(t.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(Mi,{className:"h-4 w-4"})})})]})}}]};function Bg(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([{id:"status",value:"0"}]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ae({queryKey:["orderList",u,a,l],queryFn:()=>kt.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),f=Be({data:c?.data??[],columns:Kg(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:x,getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Pg,{table:f,refetch:o}),e.jsx(ts,{table:f,showPagination:!0})]})}function Gg(){const{t:s}=M("ticket");return e.jsxs(Ri,{refreshData:()=>{},children:[e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{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(Bg,{})})]})]}),e.jsx(Li,{})]})}const Wg=Object.freeze(Object.defineProperty({__proto__:null,default:Gg},Symbol.toStringTag,{value:"Module"}));function Yg({table:s,refetch:n}){const{t}=M("user"),r=s.getState().columnFilters.length>0,[a,i]=m.useState(),[l,d]=m.useState(),[u,x]=m.useState(!1),o=[{value:"monthly",label:t("traffic_reset_logs.filters.reset_types.monthly")},{value:"first_day_month",label:t("traffic_reset_logs.filters.reset_types.first_day_month")},{value:"yearly",label:t("traffic_reset_logs.filters.reset_types.yearly")},{value:"first_day_year",label:t("traffic_reset_logs.filters.reset_types.first_day_year")},{value:"manual",label:t("traffic_reset_logs.filters.reset_types.manual")}],c=[{value:"auto",label:t("traffic_reset_logs.filters.trigger_sources.auto")},{value:"manual",label:t("traffic_reset_logs.filters.trigger_sources.manual")},{value:"cron",label:t("traffic_reset_logs.filters.trigger_sources.cron")}],f=()=>{let T=s.getState().columnFilters.filter(y=>y.id!=="date_range");(a||l)&&T.push({id:"date_range",value:{start:a?Re(a,"yyyy-MM-dd"):null,end:l?Re(l,"yyyy-MM-dd"):null}}),s.setColumnFilters(T)},F=async()=>{try{x(!0);const T=s.getState().columnFilters.reduce((P,K)=>{if(K.value)if(K.id==="date_range"){const Z=K.value;Z.start&&(P.start_date=Z.start),Z.end&&(P.end_date=Z.end)}else P[K.id]=K.value;return P},{}),L=(await aa.getLogs({...T,page:1,per_page:1e4})).data.map(P=>({ID:P.id,用户邮箱:P.user_email,用户ID:P.user_id,重置类型:P.reset_type_name,触发源:P.trigger_source_name,清零流量:P.old_traffic.formatted,"上传流量(GB)":(P.old_traffic.upload/1024**3).toFixed(2),"下载流量(GB)":(P.old_traffic.download/1024**3).toFixed(2),重置时间:Re(new Date(P.reset_time),"yyyy-MM-dd HH:mm:ss"),记录时间:Re(new Date(P.created_at),"yyyy-MM-dd HH:mm:ss"),原因:P.reason||""})),C=Object.keys(L[0]||{}),g=[C.join(","),...L.map(P=>C.map(K=>{const Z=P[K];return typeof Z=="string"&&Z.includes(",")?`"${Z}"`:Z}).join(","))].join(`
-`),p=new Blob([g],{type:"text/csv;charset=utf-8;"}),V=document.createElement("a"),E=URL.createObjectURL(p);V.setAttribute("href",E),V.setAttribute("download",`traffic-reset-logs-${Re(new Date,"yyyy-MM-dd")}.csv`),V.style.visibility="hidden",document.body.appendChild(V),V.click(),document.body.removeChild(V),$.success(t("traffic_reset_logs.actions.export_success"))}catch(w){console.error("导出失败:",w),$.error(t("traffic_reset_logs.actions.export_failed"))}finally{x(!1)}},S=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.search_user")}),e.jsx(k,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:w=>s.getColumn("user_email")?.setFilterValue(w.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.reset_type")}),e.jsxs(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:w=>s.getColumn("reset_type")?.setFilterValue(w==="all"?"":w),children:[e.jsx(W,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),o.map(w=>e.jsx(A,{value:w.value,children:w.label},w.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.trigger_source")}),e.jsxs(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:w=>s.getColumn("trigger_source")?.setFilterValue(w==="all"?"":w),children:[e.jsx(W,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(w=>e.jsx(A,{value:w.value,children:w.label},w.value))]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.start_date")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",className:N("h-9 w-full justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),a?Re(a,"MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.end_date")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",className:N("h-9 w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),l?Re(l,"MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]})]})]}),(a||l)&&e.jsxs(D,{variant:"outline",className:"w-full",onClick:f,children:[e.jsx(cr,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]}),r&&e.jsxs(D,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"w-full",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between md:hidden",children:[e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(Gn,{children:[e.jsx(Ci,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(wd,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.reset_type"),r&&e.jsx("div",{className:"ml-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:s.getState().columnFilters.length})]})}),e.jsxs(en,{side:"bottom",className:"h-[85vh]",children:[e.jsxs(sn,{className:"mb-4",children:[e.jsx(tn,{children:t("traffic_reset_logs.filters.filter_title")}),e.jsx(an,{children:t("traffic_reset_logs.filters.filter_description")})]}),e.jsx("div",{className:"max-h-[calc(85vh-120px)] overflow-y-auto",children:e.jsx(S,{})})]})]})}),e.jsxs(D,{variant:"outline",size:"sm",className:"h-8",onClick:F,disabled:u,children:[e.jsx(Zt,{className:"mr-2 h-4 w-4"}),t(u?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})]}),e.jsxs("div",{className:"hidden items-center justify-between md:flex",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(k,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:w=>s.getColumn("user_email")?.setFilterValue(w.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:w=>s.getColumn("reset_type")?.setFilterValue(w==="all"?"":w),children:[e.jsx(W,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),o.map(w=>e.jsx(A,{value:w.value,children:w.label},w.value))]})]}),e.jsxs(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:w=>s.getColumn("trigger_source")?.setFilterValue(w==="all"?"":w),children:[e.jsx(W,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(Y,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(w=>e.jsx(A,{value:w.value,children:w.label},w.value))]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:N("h-8 w-[140px] justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),a?Re(a,"yyyy-MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(D,{variant:"outline",size:"sm",className:N("h-8 w-[140px] justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),l?Re(l,"yyyy-MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]}),(a||l)&&e.jsxs(D,{variant:"outline",size:"sm",className:"h-8",onClick:f,children:[e.jsx(cr,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]})]}),r&&e.jsxs(D,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"h-8 px-2 lg:px-3",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(D,{variant:"outline",size:"sm",className:"h-8 border-dashed",onClick:F,disabled:u,children:[e.jsx(Zt,{className:"mr-2 h-4 w-4"}),t(u?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})})]})]})}const Jg=()=>{const{t:s}=M("user"),n=a=>{switch(a){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";case"first_day_month":return"bg-orange-100 text-orange-800 border-orange-200";case"first_day_year":return"bg-indigo-100 text-indigo-800 border-indigo-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},t=a=>{switch(a){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},r=a=>{switch(a){case"manual":return e.jsx(ka,{className:"h-3 w-3"});case"cron":return e.jsx(Sd,{className:"h-3 w-3"});case"auto":return e.jsx(Cd,{className:"h-3 w-3"});default:return e.jsx(ka,{className:"h-3 w-3"})}};return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.id"),className:"w-[60px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[60px]",children:e.jsx(U,{variant:"outline",className:"text-xs",children:a.original.id})}),enableSorting:!0,enableHiding:!0,size:60},{accessorKey:"user_email",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.user"),className:"min-w-[200px]"}),cell:({row:a})=>e.jsxs("div",{className:"flex min-w-[200px] items-start gap-2",children:[e.jsx(El,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:a.original.user_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",a.original.user_id]})]})]}),enableSorting:!1,enableHiding:!1,size:100},{accessorKey:"trigger_source",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.trigger_source"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:e.jsxs(U,{variant:"outline",className:N("flex items-center gap-1.5 border text-xs",t(a.original.trigger_source)),children:[r(a.original.trigger_source),e.jsx("span",{className:"truncate",children:a.original.trigger_source_name})]})})}),e.jsx(ue,{side:"bottom",className:"max-w-[200px]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:a.original.trigger_source_name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[a.original.trigger_source==="manual"&&s("traffic_reset_logs.trigger_descriptions.manual"),a.original.trigger_source==="cron"&&s("traffic_reset_logs.trigger_descriptions.cron"),a.original.trigger_source==="auto"&&s("traffic_reset_logs.trigger_descriptions.auto"),!["manual","cron","auto"].includes(a.original.trigger_source)&&s("traffic_reset_logs.trigger_descriptions.other")]})]})})]})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,i,l)=>l.includes(a.getValue(i)),size:120},{accessorKey:"reset_type",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.reset_type"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(U,{className:N("border text-xs",n(a.original.reset_type)),children:e.jsx("span",{className:"truncate",children:a.original.reset_type_name})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,i,l)=>l.includes(a.getValue(i)),size:120},{accessorKey:"old_traffic",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.cleared_traffic"),className:"w-[120px]"}),cell:({row:a})=>{const i=a.original.old_traffic;return e.jsx("div",{className:"w-[120px]",children:e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"cursor-pointer text-center",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:i.formatted}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("traffic_reset_logs.columns.cleared")})]})}),e.jsxs(ue,{side:"bottom",className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Dt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.upload"),":"," ",(i.upload/1024**3).toFixed(2)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Zt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.download"),":"," ",(i.download/1024**3).toFixed(2)," GB"]})]})]})]})})})},enableSorting:!1,enableHiding:!1,size:120},{accessorKey:"reset_time",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.reset_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Gt,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ie(a.original.reset_time,"MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie(a.original.reset_time,"HH:mm")})]})]})}),enableSorting:!0,enableHiding:!0,size:140},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.log_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(On,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ie(a.original.created_at,"YYYY-MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie(a.original.created_at,"H:m:s")})]})]})}),enableSorting:!0,enableHiding:!1,size:1400}]};function Qg(){const[s,n]=m.useState({}),[t,r]=m.useState({reset_time:!1}),[a,i]=m.useState([]),[l,d]=m.useState([{id:"created_at",desc:!0}]),[u,x]=m.useState({pageIndex:0,pageSize:20}),o={page:u.pageIndex+1,per_page:u.pageSize,...a.reduce((S,w)=>{if(w.value)if(w.id==="date_range"){const T=w.value;T.start&&(S.start_date=T.start),T.end&&(S.end_date=T.end)}else S[w.id]=w.value;return S},{})},{refetch:c,data:f,isLoading:F}=ae({queryKey:["trafficResetLogs",u,a,l],queryFn:()=>aa.getLogs(o)});return e.jsx(Xg,{data:f?.data??[],rowCount:f?.total??0,sorting:l,setSorting:d,columnVisibility:t,setColumnVisibility:r,rowSelection:s,setRowSelection:n,columnFilters:a,setColumnFilters:i,pagination:u,setPagination:x,refetch:c,isLoading:F})}function Xg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:x,pagination:o,setPagination:c,refetch:f,isLoading:F}){const S=Be({data:s,columns:Jg(),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:o},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:c,getSortedRowModel:gs(),getFacetedRowModel:Fs(),getFacetedUniqueValues:Ps(),initialState:{columnVisibility:{reset_time:!1}}});return e.jsxs("div",{className:"h-full space-y-4",children:[e.jsx(Yg,{table:S,refetch:f}),e.jsx(ts,{table:S,isLoading:F})]})}function Zg(){const{t:s}=M("user");return e.jsxs(qe,{children:[e.jsxs(Ue,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(cs,{})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(We,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-4 space-y-2 md:mb-2 md:flex md:items-center md:justify-between md:space-y-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight md:text-2xl",children:s("traffic_reset_logs.title")}),e.jsx("p",{className:"text-sm text-muted-foreground md:mt-2",children:s("traffic_reset_logs.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-hidden px-4 py-1",children:e.jsx("div",{className:"h-full w-full",children:e.jsx(Qg,{})})})]})]})}const ep=Object.freeze(Object.defineProperty({__proto__:null,default:Zg},Symbol.toStringTag,{value:"Module"}));export{lp as a,np as c,rp as g,ip as r};
+`+a("columns.online_status.offline_duration.seconds",{count:u})}return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:w("size-2.5 rounded-full ring-2 ring-offset-2",d?"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:i.original.email})]})}),e.jsx(ue,{side:"bottom",className:"max-w-[280px]",children:e.jsx("p",{className:"whitespace-pre-line text-sm",children:x})})]})})},enableSorting:!1,enableHiding:!1},{accessorKey:"online_count",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.online_count")}),cell:({row:i})=>{const l=i.original.device_limit,d=i.original.online_count||0;return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(U,{variant:"outline",className:w("min-w-[4rem] justify-center",l!==null&&d>=l?"border-destructive/50 bg-destructive/10 text-destructive":"border-primary/40 bg-primary/5 text-primary/90"),children:[d," / ",l===null?"∞":l]})})}),e.jsx(ue,{side:"bottom",children:e.jsx("p",{className:"text-sm",children:l===null?a("columns.device_limit.unlimited"):a("columns.device_limit.limited",{count:l})})})]})})},enableSorting:!0,enableHiding:!1},{accessorKey:"banned",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.status")}),cell:({row:i})=>{const l=i.original.banned;return e.jsx("div",{className:"flex justify-center",children:e.jsx(U,{className:w("min-w-20 justify-center transition-colors",l?"bg-destructive/15 text-destructive hover:bg-destructive/25":"bg-success/15 text-success hover:bg-success/25"),children:a(l?"columns.status_text.banned":"columns.status_text.normal")})})},enableSorting:!0,filterFn:(i,l,d)=>d.includes(i.getValue(l))},{accessorKey:"plan_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.subscription")}),cell:({row:i})=>e.jsx("div",{className:"min-w-[10em] break-all",children:i.original?.plan?.name||"-"}),enableSorting:!1,enableHiding:!1},{accessorKey:"group_id",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.group")}),cell:({row:i})=>e.jsx("div",{className:"flex flex-wrap gap-1",children:e.jsx(U,{variant:"outline",className:w("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:i.original?.group?.name||"-"})}),enableSorting:!1},{accessorKey:"total_used",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.used_traffic")}),cell:({row:i})=>{const l=ze(i.original?.total_used),d=ze(i.original?.transfer_enable),u=i.original?.total_used/i.original?.transfer_enable*100||0;return e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{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:l}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.toFixed(1),"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-secondary",children:e.jsx("div",{className:w("h-full rounded-full transition-all",u>90?"bg-destructive":"bg-primary"),style:{width:`${Math.min(u,100)}%`}})})]})}),e.jsx(ue,{side:"bottom",children:e.jsxs("p",{className:"text-sm",children:[a("columns.total_traffic"),": ",d]})})]})})}},{accessorKey:"transfer_enable",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.total_traffic")}),cell:({row:i})=>e.jsx("div",{className:"font-medium text-muted-foreground",children:ze(i.original?.transfer_enable)})},{accessorKey:"expired_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.expire_time")}),cell:({row:i})=>{const l=i.original.expired_at,d=Date.now()/1e3,u=l!=null&&le.jsx(O,{column:i,title:a("columns.balance")}),cell:({row:i})=>{const l=hr(i.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:l})]})}},{accessorKey:"commission_balance",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.commission")}),cell:({row:i})=>{const l=hr(i.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:l})]})}},{accessorKey:"created_at",header:({column:i})=>e.jsx(O,{column:i,title:a("columns.register_time")}),cell:({row:i})=>e.jsx("div",{className:"truncate",children:ie(i.original?.created_at)}),size:1e3},{id:"actions",header:({column:i})=>e.jsx(O,{column:i,className:"justify-end",title:a("columns.actions")}),cell:({row:i,table:l})=>e.jsxs(zs,{modal:!1,children:[e.jsx(Ks,{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(Da,{className:"size-4"})})})}),e.jsxs(Ms,{align:"end",className:"min-w-[40px]",children:[e.jsx(Se,{onSelect:d=>{d.preventDefault(),t(i.original),r(!0)},className:"p-0",children:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(fg,{className:"mr-2"}),a("columns.actions_menu.edit")]})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(vi,{defaultValues:{email:i.original.email},trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(jg,{className:"mr-2"}),a("columns.actions_menu.assign_order")]})})}),e.jsx(Se,{onSelect:()=>{sa(i.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(vg,{className:"mr-2"}),a("columns.actions_menu.copy_url")]})}),e.jsxs(Se,{className:"",onSelect:()=>{Os.resetSecret(i.original.id).then(({data:d})=>{d&&$.success("重置成功")})},children:[e.jsx(Sr,{className:"mr-4"}),a("columns.actions_menu.reset_secret")]}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(G,{variant:"ghost",className:"h-auto w-full justify-start px-2 py-1.5 font-normal",asChild:!0,children:e.jsxs(Zs,{to:`/finance/order?user_id=eq:${i.original.id}`,children:[e.jsx(bg,{className:"mr-2"}),a("columns.actions_menu.orders")]})})}),e.jsxs(Se,{onSelect:()=>{l.setColumnFilters([{id:"invite_user_id",value:"eq:"+i.original?.id}])},children:[e.jsx(yg,{className:"mr-4"}),a("columns.actions_menu.invites")]}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(Li,{user_id:i.original?.id,dialogTrigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(_g,{className:"mr-2"}),a("columns.actions_menu.traffic_records")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(gg,{user:i.original,onSuccess:s,trigger:e.jsxs(G,{variant:"ghost",className:"w-full justify-start px-2 py-1.5",children:[e.jsx(Sr,{className:"mr-2"}),a("columns.actions_menu.reset_traffic")]})})}),e.jsx(Se,{onSelect:d=>d.preventDefault(),className:"p-0",children:e.jsx(pg,{title:a("columns.actions_menu.delete_confirm_title"),description:a("columns.actions_menu.delete_confirm_description",{email:i.original.email}),cancelText:a("common:cancel"),confirmText:a("common:confirm"),variant:"destructive",onConfirm:async()=>{try{const{data:d}=await Os.destroy(i.original.id);d&&($.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(Ng,{className:"mr-2"}),a("columns.actions_menu.delete")]})})})]})]})}]},Fi=m.createContext(void 0),Wn=()=>{const s=m.useContext(Fi);if(!s)throw new Error("useUserEdit must be used within an UserEditProvider");return s},Ri=({children:s,refreshData:n})=>{const[t,r]=m.useState(!1),[a,i]=m.useState(null),l={isOpen:t,setIsOpen:r,editingUser:a,setEditingUser:i,refreshData:n};return e.jsx(Fi.Provider,{value:l,children:s})},Cg=h.object({id:h.number().default(0),email:h.string().email().default(""),invite_user_email:h.string().email().nullable().optional().default(null),password:h.string().optional().nullable().default(null),balance:h.coerce.number().default(0),commission_balance:h.coerce.number().default(0),u:h.coerce.number().default(0),d:h.coerce.number().default(0),transfer_enable:h.number().default(0),expired_at:h.number().nullable().default(null),plan_id:h.number().nullable().default(null),banned:h.boolean().default(!1),commission_type:h.number().default(0),commission_rate:h.number().nullable().default(null),discount:h.number().nullable().default(null),speed_limit:h.number().nullable().default(null),device_limit:h.number().nullable().default(null),is_admin:h.boolean().default(!1),is_staff:h.boolean().default(!1),remarks:h.string().nullable().default(null)});function Ei(){const{t:s}=M("user"),{isOpen:n,setIsOpen:t,editingUser:r,refreshData:a}=Wn(),[i,l]=m.useState(!1),[d,u]=m.useState([]),x=we({resolver:Te(Cg)});return m.useEffect(()=>{n&&ys.getList().then(({data:o})=>{u(o)})},[n]),m.useEffect(()=>{if(r){const o=r.invite_user?.email,{invite_user:c,...j}=r;x.reset({...j,invite_user_email:o||null,password:null,u:j.u?(j.u/1024/1024/1024).toFixed(3):"",d:j.d?(j.d/1024/1024/1024).toFixed(3):""})}},[r,x]),e.jsx(Yn,{open:n,onOpenChange:t,children:e.jsxs(en,{className:"max-w-[90%] space-y-4",children:[e.jsxs(sn,{children:[e.jsx(tn,{children:s("edit.title")}),e.jsx(an,{})]}),e.jsxs(De,{...x,children:[e.jsx(b,{control:x.control,name:"email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.email")}),e.jsx(_,{children:e.jsx(D,{...o,placeholder:s("edit.form.email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsx(b,{control:x.control,name:"invite_user_email",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.inviter_email")}),e.jsx(_,{children:e.jsx(D,{value:o.value||"",onChange:c=>o.onChange(c.target.value?c.target.value:null),placeholder:s("edit.form.inviter_email_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsx(b,{control:x.control,name:"password",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.password")}),e.jsx(_,{children:e.jsx(D,{type:"password",value:o.value||"",onChange:o.onChange,placeholder:s("edit.form.password_placeholder"),autoComplete:"off","data-form-type":"other"})}),e.jsx(R,{...o})]})}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(b,{control:x.control,name:"balance",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.balance")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:o.onChange,placeholder:s("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(R,{...o})]})}),e.jsx(b,{control:x.control,name:"commission_balance",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("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:s("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(R,{...o})]})}),e.jsx(b,{control:x.control,name:"u",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.upload")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",step:"any",value:o.value??"",onChange:c=>o.onChange(c.target.value),placeholder:s("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(R,{...o})]})}),e.jsx(b,{control:x.control,name:"d",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.download")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",step:"any",value:o.value??"",onChange:c=>o.onChange(c.target.value),placeholder:s("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(R,{...o})]})})]}),e.jsx(b,{control:x.control,name:"transfer_enable",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("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:c=>o.onChange(parseInt(c.target.value)*1024*1024*1024),placeholder:s("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(R,{})]})}),e.jsx(b,{control:x.control,name:"expired_at",render:({field:o})=>e.jsxs(v,{className:"flex flex-col",children:[e.jsx(y,{children:s("edit.form.expire_time")}),e.jsxs(ls,{open:i,onOpenChange:l,children:[e.jsx(is,{asChild:!0,children:e.jsx(_,{children:e.jsxs(F,{type:"button",variant:"outline",className:w("w-full pl-3 text-left font-normal",!o.value&&"text-muted-foreground"),onClick:()=>l(!0),children:[o.value?ie(o.value):e.jsx("span",{children:s("edit.form.expire_time_placeholder")}),e.jsx(ws,{className:"ml-auto h-4 w-4 opacity-50"})]})})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",side:"top",sideOffset:4,onInteractOutside:c=>{c.preventDefault()},onEscapeKeyDown:c=>{c.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(F,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{o.onChange(null),l(!1)},children:s("edit.form.expire_time_permanent")}),e.jsx(F,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+1),c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_1month")}),e.jsx(F,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;c.setMonth(c.getMonth()+3),c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3)),l(!1)},children:s("edit.form.expire_time_3months")})]}),e.jsx("div",{className:"rounded-md border",children:e.jsx(Cs,{mode:"single",selected:o.value?new Date(o.value*1e3):void 0,onSelect:c=>{if(c){const j=new Date(o.value?o.value*1e3:Date.now());c.setHours(j.getHours(),j.getMinutes(),j.getSeconds()),o.onChange(Math.floor(c.getTime()/1e3))}},disabled:c=>c{const c=new Date;c.setHours(23,59,59,999),o.onChange(Math.floor(c.getTime()/1e3))},className:"h-6 px-2 text-xs",children:s("edit.form.expire_time_today")})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"datetime-local",step:"1",value:ie(o.value,"YYYY-MM-DDTHH:mm:ss"),onChange:c=>{const j=new Date(c.target.value);isNaN(j.getTime())||o.onChange(Math.floor(j.getTime()/1e3))},className:"flex-1"}),e.jsx(F,{type:"button",variant:"outline",onClick:()=>l(!1),children:s("edit.form.expire_time_confirm")})]})]})]})})]}),e.jsx(R,{})]})}),e.jsx(b,{control:x.control,name:"plan_id",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.subscription")}),e.jsx(_,{children:e.jsxs(J,{value:o.value!==null?String(o.value):"null",onValueChange:c=>o.onChange(c==="null"?null:parseInt(c)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(W,{children:[e.jsx(A,{value:"null",children:s("edit.form.subscription_none")}),d.map(c=>e.jsx(A,{value:String(c.id),children:c.name},c.id))]})]})})]})}),e.jsx(b,{control:x.control,name:"banned",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.account_status")}),e.jsx(_,{children:e.jsxs(J,{value:o.value.toString(),onValueChange:c=>o.onChange(c==="true"),children:[e.jsx(Y,{children:e.jsx(Q,{})}),e.jsxs(W,{children:[e.jsx(A,{value:"true",children:s("columns.status_text.banned")}),e.jsx(A,{value:"false",children:s("columns.status_text.normal")})]})]})})]})}),e.jsx(b,{control:x.control,name:"commission_type",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.commission_type")}),e.jsx(_,{children:e.jsxs(J,{value:o.value.toString(),onValueChange:c=>o.onChange(parseInt(c)),children:[e.jsx(Y,{children:e.jsx(Q,{placeholder:s("edit.form.subscription_none")})}),e.jsxs(W,{children:[e.jsx(A,{value:"0",children:s("edit.form.commission_type_system")}),e.jsx(A,{value:"1",children:s("edit.form.commission_type_cycle")}),e.jsx(A,{value:"2",children:s("edit.form.commission_type_onetime")})]})]})})]})}),e.jsx(b,{control:x.control,name:"commission_rate",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.commission_rate")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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:x.control,name:"discount",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.discount")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(R,{})]})}),e.jsx(b,{control:x.control,name:"speed_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.speed_limit")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(R,{})]})}),e.jsx(b,{control:x.control,name:"device_limit",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.device_limit")}),e.jsx(_,{children:e.jsxs("div",{className:"flex",children:[e.jsx(D,{type:"number",value:o.value||"",onChange:c=>o.onChange(parseInt(c.currentTarget.value)||null),placeholder:s("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(R,{})]})}),e.jsx(b,{control:x.control,name:"is_admin",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.is_admin")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>o.onChange(c)})})}),e.jsx(R,{})]})}),e.jsx(b,{control:x.control,name:"is_staff",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.is_staff")}),e.jsx("div",{className:"py-2",children:e.jsx(_,{children:e.jsx(Z,{checked:o.value,onCheckedChange:c=>o.onChange(c)})})})]})}),e.jsx(b,{control:x.control,name:"remarks",render:({field:o})=>e.jsxs(v,{children:[e.jsx(y,{children:s("edit.form.remarks")}),e.jsx(_,{children:e.jsx(Fs,{className:"h-24",value:o.value||"",onChange:c=>o.onChange(c.currentTarget.value??null),placeholder:s("edit.form.remarks_placeholder")})}),e.jsx(R,{})]})}),e.jsxs(Ti,{children:[e.jsx(F,{variant:"outline",onClick:()=>t(!1),children:s("edit.form.cancel")}),e.jsx(F,{type:"submit",onClick:()=>{x.handleSubmit(o=>{const c={id:o.id};x.formState.dirtyFields.u&&(c.u=Math.round(parseFloat(o.u)*1024*1024*1024)),x.formState.dirtyFields.d&&(c.d=Math.round(parseFloat(o.d)*1024*1024*1024)),Object.keys(o).forEach(j=>{j!=="u"&&j!=="d"&&j!=="id"&&x.formState.dirtyFields[j]&&(c[j]=o[j])}),Os.update(c).then(({data:j})=>{j&&($.success(s("edit.form.success")),t(!1),a())})})()},children:s("edit.form.submit")})]})]})]})})}function Sg(){const[s]=Fl(),[n,t]=m.useState({}),[r,a]=m.useState({is_admin:!1,is_staff:!1}),[i,l]=m.useState([]),[d,u]=m.useState([]),[x,o]=m.useState({pageIndex:0,pageSize:20});m.useEffect(()=>{const g=s.get("email");g&&l(f=>f.some(E=>E.id==="email")?f:[...f,{id:"email",value:g}])},[s]);const{refetch:c,data:j,isLoading:P}=ne({queryKey:["userList",x,i,d],queryFn:()=>Os.getList({pageSize:x.pageSize,current:x.pageIndex+1,filter:i,sort:d})}),[k,C]=m.useState([]),[T,p]=m.useState([]);m.useEffect(()=>{pt.getList().then(({data:g})=>{C(g)}),ys.getList().then(({data:g})=>{p(g)})},[]);const S=k.map(g=>({label:g.name,value:g.id})),N=T.map(g=>({label:g.name,value:g.id}));return e.jsxs(Ri,{refreshData:c,children:[e.jsx(kg,{data:j?.data??[],rowCount:j?.total??0,sorting:d,setSorting:u,columnVisibility:r,setColumnVisibility:a,rowSelection:n,setRowSelection:t,columnFilters:i,setColumnFilters:l,pagination:x,setPagination:o,refetch:c,serverGroupList:k,permissionGroups:S,subscriptionPlans:N,isLoading:P}),e.jsx(Ei,{})]})}function kg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:x,pagination:o,setPagination:c,refetch:j,serverGroupList:P,permissionGroups:k,subscriptionPlans:C,isLoading:T}){const{setIsOpen:p,setEditingUser:S}=Wn(),N=Be({data:s,columns:wg(j,P,S,p),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:o},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:c,getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),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.jsxs("div",{className:"space-y-4",children:[e.jsx(ug,{table:N,refetch:j,serverGroupList:P,permissionGroups:k,subscriptionPlans:C}),e.jsx(ts,{table:N,isLoading:T})]})}function Tg(){const{t:s}=M("user");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Sg,{})})})]})]})}const Dg=Object.freeze(Object.defineProperty({__proto__:null,default:Tg},Symbol.toStringTag,{value:"Module"})),Pg=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 Lg({table:s}){const{t:n}=M("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(gt,{defaultValue:s.getColumn("status")?.getFilterValue(),onValueChange:t=>s.getColumn("status")?.setFilterValue(t),children:e.jsxs(at,{className:"grid w-full grid-cols-2",children:[e.jsx($e,{value:"0",children:n("status.pending")}),e.jsx($e,{value:"1",children:n("status.closed")})]})}),s.getColumn("level")&&e.jsx(Ea,{column:s.getColumn("level"),title:n("columns.level"),options:[{label:n("level.low"),value:ds.LOW,icon:Pg,color:"gray"},{label:n("level.medium"),value:ds.MIDDLE,icon:Di,color:"yellow"},{label:n("level.high"),value:ds.HIGH,icon:Pi,color:"red"}]})]})})}function Fg(){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 Rg=xt("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"}}),Vi=m.forwardRef(({className:s,variant:n,layout:t,children:r,...a},i)=>e.jsx("div",{className:w(Rg({variant:n,layout:t,className:s}),"relative group"),ref:i,...a,children:m.Children.map(r,l=>m.isValidElement(l)&&typeof l.type!="string"?m.cloneElement(l,{variant:n,layout:t}):l)}));Vi.displayName="ChatBubble";const Eg=xt("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"}}),Ii=m.forwardRef(({className:s,variant:n,layout:t,isLoading:r=!1,children:a,...i},l)=>e.jsx("div",{className:w(Eg({variant:n,layout:t,className:s}),"break-words max-w-full whitespace-pre-wrap"),ref:l,...i,children:r?e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(Fg,{})}):a}));Ii.displayName="ChatBubbleMessage";const Vg=m.forwardRef(({variant:s,className:n,children:t,...r},a)=>e.jsx("div",{ref:a,className:w("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),...r,children:t}));Vg.displayName="ChatBubbleActionWrapper";const Mi=m.forwardRef(({className:s,...n},t)=>e.jsx(Fs,{autoComplete:"off",ref:t,name:"message",className:w("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}));Mi.displayName="ChatInput";const Oi=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"})}),zi=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"})}),kr=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"})}),Ig=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"})}),Mg=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"})}),Og=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 zg(){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(je,{className:"h-8 w-3/4"}),e.jsx(je,{className:"h-4 w-1/2"})]}),e.jsx("div",{className:"flex-1 space-y-4",children:[1,2,3].map(s=>e.jsx(je,{className:"h-20 w-2/3"},s))})]})}function $g(){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(je,{className:"h-5 w-4/5"}),e.jsx(je,{className:"h-4 w-2/3"}),e.jsx(je,{className:"h-3 w-1/2"})]},s))})}function Ag({ticket:s,isActive:n,onClick:t}){const{t:r}=M("ticket"),a=i=>{switch(i){case ds.HIGH:return"bg-red-50 text-red-600 border-red-200";case ds.MIDDLE:return"bg-yellow-50 text-yellow-600 border-yellow-200";case ds.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:w("flex cursor-pointer flex-col border-b p-4 hover:bg-accent/50",n&&"bg-accent"),onClick:t,children:[e.jsxs("div",{className:"flex max-w-[280px] items-center justify-between gap-2",children:[e.jsx("h4",{className:"flex-1 truncate font-medium",children:s.subject}),e.jsx(U,{variant:s.status===Xs.CLOSED?"secondary":"default",className:"shrink-0",children:s.status===Xs.CLOSED?r("status.closed"):r("status.processing")})]}),e.jsx("div",{className:"mt-1 max-w-[280px] truncate text-sm text-muted-foreground",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:ie(s.updated_at)}),e.jsx("div",{className:w("rounded-full border px-2 py-0.5 text-xs font-medium",a(s.level)),children:r(`level.${s.level===ds.LOW?"low":s.level===ds.MIDDLE?"medium":"high"}`)})]})]})}function qg({ticketId:s,dialogTrigger:n}){const{t}=M("ticket"),r=Bs(),a=m.useRef(null),i=m.useRef(null),[l,d]=m.useState(!1),[u,x]=m.useState(""),[o,c]=m.useState(!1),[j,P]=m.useState(s),[k,C]=m.useState(""),[T,p]=m.useState(!1),{setIsOpen:S,setEditingUser:N}=Wn(),{data:g,isLoading:f,refetch:V}=ne({queryKey:["tickets",l],queryFn:()=>l?kt.getList({filter:[{id:"status",value:[Xs.OPENING]}]}):Promise.resolve(null),enabled:l}),{data:E,refetch:L,isLoading:K}=ne({queryKey:["ticket",j,l],queryFn:()=>l?kt.getInfo(j):Promise.resolve(null),refetchInterval:l?5e3:!1,retry:3}),X=E?.data,te=(g?.data||[]).filter(re=>re.subject.toLowerCase().includes(k.toLowerCase())||re.user?.email.toLowerCase().includes(k.toLowerCase())),q=(re="smooth")=>{if(a.current){const{scrollHeight:H,clientHeight:oe}=a.current;a.current.scrollTo({top:H-oe,behavior:re})}};m.useEffect(()=>{if(!l)return;const re=requestAnimationFrame(()=>{q("instant"),setTimeout(()=>q(),1e3)});return()=>{cancelAnimationFrame(re)}},[l,X?.messages]);const ee=async()=>{const re=u.trim();!re||o||(c(!0),kt.reply({id:j,message:re}).then(()=>{x(""),L(),q(),setTimeout(()=>{i.current?.focus()},0)}).finally(()=>{c(!1)}))},fe=async()=>{kt.close(j).then(()=>{$.success(t("actions.close_success")),L(),V()})},fs=()=>{X?.user&&r("/finance/order?user_id="+X.user.id)},Ie=X?.status===Xs.CLOSED;return e.jsxs(de,{open:l,onOpenChange:d,children:[e.jsx(ps,{asChild:!0,children:n??e.jsx(G,{variant:"outline",children:t("actions.view_ticket")})}),e.jsxs(ce,{className:"flex h-[90vh] max-w-6xl flex-col gap-0 p-0",children:[e.jsx(me,{}),e.jsxs("div",{className:"flex h-full",children:[e.jsx(G,{variant:"ghost",size:"icon",className:"absolute left-2 top-2 z-50 md:hidden",onClick:()=>p(!T),children:e.jsx(kr,{className:w("h-4 w-4 transition-transform",!T&&"rotate-180")})}),e.jsxs("div",{className:w("absolute inset-y-0 left-0 z-40 flex flex-col border-r bg-background transition-transform duration-200 ease-in-out md:relative",T?"-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:t("list.title")}),e.jsx(G,{variant:"ghost",size:"icon",className:"hidden h-8 w-8 md:flex",onClick:()=>p(!T),children:e.jsx(kr,{className:w("h-4 w-4 transition-transform",!T&&"rotate-180")})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ig,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground"}),e.jsx(D,{placeholder:t("list.search_placeholder"),value:k,onChange:re=>C(re.target.value),className:"pl-8"})]})]}),e.jsx(ut,{className:"flex-1",children:e.jsx("div",{className:"w-full",children:f?e.jsx($g,{}):te.length===0?e.jsx("div",{className:"flex h-full items-center justify-center p-4 text-muted-foreground",children:t(k?"list.no_search_results":"list.no_tickets")}):te.map(re=>e.jsx(Ag,{ticket:re,isActive:re.id===j,onClick:()=>{P(re.id),window.innerWidth<768&&p(!0)}},re.id))})})]}),e.jsxs("div",{className:"relative flex flex-1 flex-col",children:[!T&&e.jsx("div",{className:"absolute inset-0 z-30 bg-black/20 md:hidden",onClick:()=>p(!0)}),K?e.jsx(zg,{}):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:X?.subject}),e.jsx(U,{variant:Ie?"secondary":"default",children:t(Ie?"status.closed":"status.processing")}),!Ie&&e.jsx(_s,{title:t("actions.close_confirm_title"),description:t("actions.close_confirm_description"),confirmText:t("actions.close_confirm_button"),variant:"destructive",onConfirm:fe,children:e.jsxs(G,{variant:"ghost",size:"sm",className:"gap-1 text-muted-foreground hover:text-destructive",children:[e.jsx(Oi,{className:"h-4 w-4"}),t("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(Ra,{className:"h-4 w-4"}),e.jsx("span",{children:X?.user?.email})]}),e.jsx(Ve,{orientation:"vertical",className:"h-4"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(zi,{className:"h-4 w-4"}),e.jsxs("span",{children:[t("detail.created_at")," ",ie(X?.created_at)]})]}),e.jsx(Ve,{orientation:"vertical",className:"h-4"}),e.jsx(U,{variant:"outline",children:X?.level!=null&&t(`level.${X.level===ds.LOW?"low":X.level===ds.MIDDLE?"medium":"high"}`)})]})]}),X?.user&&e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.user_info"),onClick:()=>{N(X.user),S(!0)},children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx(Li,{user_id:X.user.id,dialogTrigger:e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.traffic_records"),children:e.jsx(Mg,{className:"h-4 w-4"})})}),e.jsx(G,{variant:"outline",size:"icon",className:"h-8 w-8",title:t("detail.order_records"),onClick:fs,children:e.jsx(Og,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx("div",{ref:a,className:"h-full space-y-4 overflow-y-auto p-6",children:X?.messages?.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:t("detail.no_messages")}):X?.messages?.map(re=>e.jsx(Vi,{variant:re.is_from_admin?"sent":"received",className:re.is_from_admin?"ml-auto":"mr-auto",children:e.jsx(Ii,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",children:re.message}),e.jsx("div",{className:"text-right",children:e.jsx("time",{className:"text-[10px] text-muted-foreground",children:ie(re.created_at)})})]})})},re.id))})}),e.jsx("div",{className:"border-t p-4",children:e.jsxs("div",{className:"relative flex items-center space-x-2",children:[e.jsx(Mi,{ref:i,disabled:Ie||o,placeholder:t(Ie?"detail.input.closed_placeholder":"detail.input.reply_placeholder"),className:"flex-1 resize-none rounded-lg border bg-background p-3 focus-visible:ring-1",value:u,onChange:re=>x(re.target.value),onKeyDown:re=>{re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),ee())}}),e.jsx(G,{disabled:Ie||o||!u.trim(),onClick:ee,children:t(o?"detail.input.sending":"detail.input.send")})]})})]})]})]})]})]})}const Hg=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"})}),Ug=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"})}),Kg=s=>{const{t:n}=M("ticket");return[{accessorKey:"id",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.id")}),cell:({row:t})=>e.jsx(U,{variant:"outline",children:t.getValue("id")}),enableSorting:!1,enableHiding:!1},{accessorKey:"subject",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.subject")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Hg,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"max-w-[500px] truncate font-medium",children:t.getValue("subject")})]}),enableSorting:!1,enableHiding:!1,size:4e3},{accessorKey:"level",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.level")}),cell:({row:t})=>{const r=t.getValue("level"),a=r===ds.LOW?"default":r===ds.MIDDLE?"secondary":"destructive";return e.jsx(U,{variant:a,className:"whitespace-nowrap",children:n(`level.${r===ds.LOW?"low":r===ds.MIDDLE?"medium":"high"}`)})},filterFn:(t,r,a)=>a.includes(t.getValue(r))},{accessorKey:"status",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.status")}),cell:({row:t})=>{const r=t.getValue("status"),a=t.original.reply_status,i=r===Xs.CLOSED?n("status.closed"):n(a===0?"status.replied":"status.pending"),l=r===Xs.CLOSED?"default":a===0?"secondary":"destructive";return e.jsx(U,{variant:l,className:"whitespace-nowrap",children:i})}},{accessorKey:"updated_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.updated_at")}),cell:({row:t})=>e.jsxs("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[e.jsx(zi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:ie(t.getValue("updated_at"))})]}),enableSorting:!0},{accessorKey:"created_at",header:({column:t})=>e.jsx(O,{column:t,title:n("columns.created_at")}),cell:({row:t})=>e.jsx("div",{className:"text-sm text-muted-foreground",children:ie(t.getValue("created_at"))}),enableSorting:!0,meta:{isFlexGrow:!0}},{id:"actions",header:({column:t})=>e.jsx(O,{className:"justify-end",column:t,title:n("columns.actions")}),cell:({row:t})=>{const r=t.original.status!==Xs.CLOSED;return e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(qg,{ticketId:t.original.id,dialogTrigger:e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8",title:n("actions.view_details"),children:e.jsx(Ug,{className:"h-4 w-4"})})}),r&&e.jsx(_s,{title:n("actions.close_confirm_title"),description:n("actions.close_confirm_description"),confirmText:n("actions.close_confirm_button"),variant:"destructive",onConfirm:async()=>{kt.close(t.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(Oi,{className:"h-4 w-4"})})})]})}}]};function Bg(){const[s,n]=m.useState({}),[t,r]=m.useState({}),[a,i]=m.useState([{id:"status",value:"0"}]),[l,d]=m.useState([]),[u,x]=m.useState({pageIndex:0,pageSize:20}),{refetch:o,data:c}=ne({queryKey:["orderList",u,a,l],queryFn:()=>kt.getList({pageSize:u.pageSize,current:u.pageIndex+1,filter:a,sort:l})}),j=Be({data:c?.data??[],columns:Kg(o),state:{sorting:l,columnVisibility:t,rowSelection:s,columnFilters:a,pagination:u},rowCount:c?.total??0,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:n,onSortingChange:d,onColumnFiltersChange:i,onColumnVisibilityChange:r,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:x,getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnPinning:{right:["actions"]}}});return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Lg,{table:j,refetch:o}),e.jsx(ts,{table:j,showPagination:!0})]})}function Gg(){const{t:s}=M("ticket");return e.jsxs(Ri,{refreshData:()=>{},children:[e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx(cs,{}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{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(Bg,{})})]})]}),e.jsx(Ei,{})]})}const Yg=Object.freeze(Object.defineProperty({__proto__:null,default:Gg},Symbol.toStringTag,{value:"Module"}));function Wg({table:s,refetch:n}){const{t}=M("user"),r=s.getState().columnFilters.length>0,[a,i]=m.useState(),[l,d]=m.useState(),[u,x]=m.useState(!1),o=[{value:"monthly",label:t("traffic_reset_logs.filters.reset_types.monthly")},{value:"first_day_month",label:t("traffic_reset_logs.filters.reset_types.first_day_month")},{value:"yearly",label:t("traffic_reset_logs.filters.reset_types.yearly")},{value:"first_day_year",label:t("traffic_reset_logs.filters.reset_types.first_day_year")},{value:"manual",label:t("traffic_reset_logs.filters.reset_types.manual")}],c=[{value:"auto",label:t("traffic_reset_logs.filters.trigger_sources.auto")},{value:"manual",label:t("traffic_reset_logs.filters.trigger_sources.manual")},{value:"cron",label:t("traffic_reset_logs.filters.trigger_sources.cron")}],j=()=>{let T=s.getState().columnFilters.filter(p=>p.id!=="date_range");(a||l)&&T.push({id:"date_range",value:{start:a?Fe(a,"yyyy-MM-dd"):null,end:l?Fe(l,"yyyy-MM-dd"):null}}),s.setColumnFilters(T)},P=async()=>{try{x(!0);const T=s.getState().columnFilters.reduce((L,K)=>{if(K.value)if(K.id==="date_range"){const X=K.value;X.start&&(L.start_date=X.start),X.end&&(L.end_date=X.end)}else L[K.id]=K.value;return L},{}),S=(await aa.getLogs({...T,page:1,per_page:1e4})).data.map(L=>({ID:L.id,用户邮箱:L.user_email,用户ID:L.user_id,重置类型:L.reset_type_name,触发源:L.trigger_source_name,清零流量:L.old_traffic.formatted,"上传流量(GB)":(L.old_traffic.upload/1024**3).toFixed(2),"下载流量(GB)":(L.old_traffic.download/1024**3).toFixed(2),重置时间:Fe(new Date(L.reset_time),"yyyy-MM-dd HH:mm:ss"),记录时间:Fe(new Date(L.created_at),"yyyy-MM-dd HH:mm:ss"),原因:L.reason||""})),N=Object.keys(S[0]||{}),g=[N.join(","),...S.map(L=>N.map(K=>{const X=L[K];return typeof X=="string"&&X.includes(",")?`"${X}"`:X}).join(","))].join(`
+`),f=new Blob([g],{type:"text/csv;charset=utf-8;"}),V=document.createElement("a"),E=URL.createObjectURL(f);V.setAttribute("href",E),V.setAttribute("download",`traffic-reset-logs-${Fe(new Date,"yyyy-MM-dd")}.csv`),V.style.visibility="hidden",document.body.appendChild(V),V.click(),document.body.removeChild(V),$.success(t("traffic_reset_logs.actions.export_success"))}catch(C){console.error("导出失败:",C),$.error(t("traffic_reset_logs.actions.export_failed"))}finally{x(!1)}},k=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.search_user")}),e.jsx(D,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:C=>s.getColumn("user_email")?.setFilterValue(C.target.value),className:"h-9"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.reset_type")}),e.jsxs(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:C=>s.getColumn("reset_type")?.setFilterValue(C==="all"?"":C),children:[e.jsx(Y,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(W,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),o.map(C=>e.jsx(A,{value:C.value,children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.trigger_source")}),e.jsxs(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:C=>s.getColumn("trigger_source")?.setFilterValue(C==="all"?"":C),children:[e.jsx(Y,{className:"h-9",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(W,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(C=>e.jsx(A,{value:C.value,children:C.label},C.value))]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.start_date")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",className:w("h-9 w-full justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),a?Fe(a,"MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:t("traffic_reset_logs.filters.end_date")}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",className:w("h-9 w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),l?Fe(l,"MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]})]})]}),(a||l)&&e.jsxs(F,{variant:"outline",className:"w-full",onClick:j,children:[e.jsx(dr,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]}),r&&e.jsxs(F,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"w-full",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between md:hidden",children:[e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(Yn,{children:[e.jsx(Si,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8",children:[e.jsx(wd,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.reset_type"),r&&e.jsx("div",{className:"ml-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-xs text-primary-foreground",children:s.getState().columnFilters.length})]})}),e.jsxs(en,{side:"bottom",className:"h-[85vh]",children:[e.jsxs(sn,{className:"mb-4",children:[e.jsx(tn,{children:t("traffic_reset_logs.filters.filter_title")}),e.jsx(an,{children:t("traffic_reset_logs.filters.filter_description")})]}),e.jsx("div",{className:"max-h-[calc(85vh-120px)] overflow-y-auto",children:e.jsx(k,{})})]})]})}),e.jsxs(F,{variant:"outline",size:"sm",className:"h-8",onClick:P,disabled:u,children:[e.jsx(Zt,{className:"mr-2 h-4 w-4"}),t(u?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})]}),e.jsxs("div",{className:"hidden items-center justify-between md:flex",children:[e.jsxs("div",{className:"flex flex-1 items-center space-x-2",children:[e.jsx(D,{placeholder:t("traffic_reset_logs.filters.search_user"),value:s.getColumn("user_email")?.getFilterValue()??"",onChange:C=>s.getColumn("user_email")?.setFilterValue(C.target.value),className:"h-8 w-[150px] lg:w-[250px]"}),e.jsxs(J,{value:s.getColumn("reset_type")?.getFilterValue()??"",onValueChange:C=>s.getColumn("reset_type")?.setFilterValue(C==="all"?"":C),children:[e.jsx(Y,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.reset_type")})}),e.jsxs(W,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_types")}),o.map(C=>e.jsx(A,{value:C.value,children:C.label},C.value))]})]}),e.jsxs(J,{value:s.getColumn("trigger_source")?.getFilterValue()??"",onValueChange:C=>s.getColumn("trigger_source")?.setFilterValue(C==="all"?"":C),children:[e.jsx(Y,{className:"h-8 w-[180px]",children:e.jsx(Q,{placeholder:t("traffic_reset_logs.filters.trigger_source")})}),e.jsxs(W,{children:[e.jsx(A,{value:"all",children:t("traffic_reset_logs.filters.all_sources")}),c.map(C=>e.jsx(A,{value:C.value,children:C.label},C.value))]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:w("h-8 w-[140px] justify-start text-left font-normal",!a&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),a?Fe(a,"yyyy-MM-dd"):t("traffic_reset_logs.filters.start_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:a,onSelect:i,initialFocus:!0})})]}),e.jsxs(ls,{children:[e.jsx(is,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:w("h-8 w-[140px] justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),l?Fe(l,"yyyy-MM-dd"):t("traffic_reset_logs.filters.end_date")]})}),e.jsx(Xe,{className:"w-auto p-0",align:"start",children:e.jsx(Cs,{mode:"single",selected:l,onSelect:d,initialFocus:!0})})]}),(a||l)&&e.jsxs(F,{variant:"outline",size:"sm",className:"h-8",onClick:j,children:[e.jsx(dr,{className:"mr-2 h-4 w-4"}),t("traffic_reset_logs.filters.apply_date")]})]}),r&&e.jsxs(F,{variant:"ghost",onClick:()=>{s.resetColumnFilters(),i(void 0),d(void 0)},className:"h-8 px-2 lg:px-3",children:[t("traffic_reset_logs.filters.reset"),e.jsx(os,{className:"ml-2 h-4 w-4"})]})]}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs(F,{variant:"outline",size:"sm",className:"h-8 border-dashed",onClick:P,disabled:u,children:[e.jsx(Zt,{className:"mr-2 h-4 w-4"}),t(u?"traffic_reset_logs.actions.exporting":"traffic_reset_logs.actions.export")]})})]})]})}const Jg=()=>{const{t:s}=M("user"),n=a=>{switch(a){case"manual":return"bg-blue-100 text-blue-800 border-blue-200";case"monthly":return"bg-green-100 text-green-800 border-green-200";case"yearly":return"bg-purple-100 text-purple-800 border-purple-200";case"first_day_month":return"bg-orange-100 text-orange-800 border-orange-200";case"first_day_year":return"bg-indigo-100 text-indigo-800 border-indigo-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},t=a=>{switch(a){case"manual":return"bg-orange-100 text-orange-800 border-orange-200";case"cron":return"bg-indigo-100 text-indigo-800 border-indigo-200";case"auto":return"bg-emerald-100 text-emerald-800 border-emerald-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},r=a=>{switch(a){case"manual":return e.jsx(ka,{className:"h-3 w-3"});case"cron":return e.jsx(Sd,{className:"h-3 w-3"});case"auto":return e.jsx(Cd,{className:"h-3 w-3"});default:return e.jsx(ka,{className:"h-3 w-3"})}};return[{accessorKey:"id",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.id"),className:"w-[60px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[60px]",children:e.jsx(U,{variant:"outline",className:"text-xs",children:a.original.id})}),enableSorting:!0,enableHiding:!0,size:60},{accessorKey:"user_email",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.user"),className:"min-w-[200px]"}),cell:({row:a})=>e.jsxs("div",{className:"flex min-w-[200px] items-start gap-2",children:[e.jsx(Vl,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:a.original.user_email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",a.original.user_id]})]})]}),enableSorting:!1,enableHiding:!1,size:100},{accessorKey:"trigger_source",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.trigger_source"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:e.jsxs(U,{variant:"outline",className:w("flex items-center gap-1.5 border text-xs",t(a.original.trigger_source)),children:[r(a.original.trigger_source),e.jsx("span",{className:"truncate",children:a.original.trigger_source_name})]})})}),e.jsx(ue,{side:"bottom",className:"max-w-[200px]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:a.original.trigger_source_name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[a.original.trigger_source==="manual"&&s("traffic_reset_logs.trigger_descriptions.manual"),a.original.trigger_source==="cron"&&s("traffic_reset_logs.trigger_descriptions.cron"),a.original.trigger_source==="auto"&&s("traffic_reset_logs.trigger_descriptions.auto"),!["manual","cron","auto"].includes(a.original.trigger_source)&&s("traffic_reset_logs.trigger_descriptions.other")]})]})})]})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,i,l)=>l.includes(a.getValue(i)),size:120},{accessorKey:"reset_type",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.reset_type"),className:"w-[120px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[120px]",children:e.jsx(U,{className:w("border text-xs",n(a.original.reset_type)),children:e.jsx("span",{className:"truncate",children:a.original.reset_type_name})})}),enableSorting:!0,enableHiding:!1,filterFn:(a,i,l)=>l.includes(a.getValue(i)),size:120},{accessorKey:"old_traffic",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.cleared_traffic"),className:"w-[120px]"}),cell:({row:a})=>{const i=a.original.old_traffic;return e.jsx("div",{className:"w-[120px]",children:e.jsx(be,{delayDuration:100,children:e.jsxs(ge,{children:[e.jsx(pe,{asChild:!0,children:e.jsxs("div",{className:"cursor-pointer text-center",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:i.formatted}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("traffic_reset_logs.columns.cleared")})]})}),e.jsxs(ue,{side:"bottom",className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Dt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.upload"),":"," ",(i.upload/1024**3).toFixed(2)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Zt,{className:"h-3 w-3"}),e.jsxs("span",{children:[s("traffic_reset_logs.columns.download"),":"," ",(i.download/1024**3).toFixed(2)," GB"]})]})]})]})})})},enableSorting:!1,enableHiding:!1,size:120},{accessorKey:"reset_time",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.reset_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Gt,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ie(a.original.reset_time,"MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie(a.original.reset_time,"HH:mm")})]})]})}),enableSorting:!0,enableHiding:!0,size:140},{accessorKey:"created_at",header:({column:a})=>e.jsx(O,{column:a,title:s("traffic_reset_logs.columns.log_time"),className:"w-[140px]"}),cell:({row:a})=>e.jsx("div",{className:"w-[140px]",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(zn,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium",children:ie(a.original.created_at,"YYYY-MM-DD")}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ie(a.original.created_at,"H:m:s")})]})]})}),enableSorting:!0,enableHiding:!1,size:1400}]};function Qg(){const[s,n]=m.useState({}),[t,r]=m.useState({reset_time:!1}),[a,i]=m.useState([]),[l,d]=m.useState([{id:"created_at",desc:!0}]),[u,x]=m.useState({pageIndex:0,pageSize:20}),o={page:u.pageIndex+1,per_page:u.pageSize,...a.reduce((k,C)=>{if(C.value)if(C.id==="date_range"){const T=C.value;T.start&&(k.start_date=T.start),T.end&&(k.end_date=T.end)}else k[C.id]=C.value;return k},{})},{refetch:c,data:j,isLoading:P}=ne({queryKey:["trafficResetLogs",u,a,l],queryFn:()=>aa.getLogs(o)});return e.jsx(Xg,{data:j?.data??[],rowCount:j?.total??0,sorting:l,setSorting:d,columnVisibility:t,setColumnVisibility:r,rowSelection:s,setRowSelection:n,columnFilters:a,setColumnFilters:i,pagination:u,setPagination:x,refetch:c,isLoading:P})}function Xg({data:s,rowCount:n,sorting:t,setSorting:r,columnVisibility:a,setColumnVisibility:i,rowSelection:l,setRowSelection:d,columnFilters:u,setColumnFilters:x,pagination:o,setPagination:c,refetch:j,isLoading:P}){const k=Be({data:s,columns:Jg(),state:{sorting:t,columnVisibility:a,rowSelection:l,columnFilters:u,pagination:o},rowCount:n,manualPagination:!0,manualFiltering:!0,manualSorting:!0,enableRowSelection:!0,onRowSelectionChange:d,onSortingChange:r,onColumnFiltersChange:x,onColumnVisibilityChange:i,getCoreRowModel:Ge(),getFilteredRowModel:hs(),getPaginationRowModel:Ze(),onPaginationChange:c,getSortedRowModel:gs(),getFacetedRowModel:Ps(),getFacetedUniqueValues:Ls(),initialState:{columnVisibility:{reset_time:!1}}});return e.jsxs("div",{className:"h-full space-y-4",children:[e.jsx(Wg,{table:k,refetch:j}),e.jsx(ts,{table:k,isLoading:P})]})}function Zg(){const{t:s}=M("user");return e.jsxs(qe,{children:[e.jsxs(He,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(cs,{})}),e.jsxs("div",{className:"ml-auto flex items-center space-x-4",children:[e.jsx(es,{}),e.jsx(ss,{})]})]}),e.jsxs(Ye,{className:"flex flex-col",fixedHeight:!0,children:[e.jsx("div",{className:"mb-4 space-y-2 md:mb-2 md:flex md:items-center md:justify-between md:space-y-0",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight md:text-2xl",children:s("traffic_reset_logs.title")}),e.jsx("p",{className:"text-sm text-muted-foreground md:mt-2",children:s("traffic_reset_logs.description")})]})}),e.jsx("div",{className:"-mx-4 flex-1 overflow-hidden px-4 py-1",children:e.jsx("div",{className:"h-full w-full",children:e.jsx(Qg,{})})})]})]})}const ep=Object.freeze(Object.defineProperty({__proto__:null,default:Zg},Symbol.toStringTag,{value:"Module"}));export{lp as a,np as c,rp as g,ip as r};