MaiBot/webui/dist/assets/index-Bsha1Gbw.js

55 lines
776 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import{r as u,j as e,L as Yn,e as ja,R as pt,b as Hb,f as qb,g as Gb,h as Fb,k as lt,l as Vb,m as $b,O as Tp,n as Qb}from"./router-CWhjJi2n.js";import{a as Ib,b as Yb,g as Xb}from"./react-vendor-Dtc2IqVY.js";import{I as Kb,c as Jb,J as si,K as Ac,L as vu,M as Pb,N as Pi,O as Zi,P as Zb,n as bu}from"./utils-CCeOswSm.js";import{L as Ep,T as zp,C as Mp,R as Wb,a as Ap,V as eN,b as sN,S as Dp,c as tN,d as Op,I as aN,e as Rp,f as lN,g as Lp,h as nN,i as iN,j as rN,O as Up,P as cN,k as Bp,l as Hp,D as qp,A as Gp,m as Fp,n as oN,o as dN,p as Vp,q as uN,r as $p,s as mN,t as xN,u as hN,v as fN,w as pN,x as Qp,y as Ip,F as Yp,z as Xp,B as gN,E as jN}from"./radix-extra-DnIxMvW0.js";import{aj as vN,ak as bN,al as NN,am as yN,an as Dc,ao as Oc,ap as Wi,aq as wN,ar as Nu,as as Rc,at as _N,au as SN,av as CN}from"./charts-Dhri-zxi.js";import{S as kN,G as Kp,O as Jp,o as TN,C as Pp,p as EN,T as Zp,D as Wp,R as zN,q as MN,H as eg,I as AN,J as sg,K as tg,L as DN,M as ag,V as ON,N as lg,Q as ng,U as RN,X as LN,Y as ig,Z as UN,_ as BN,$ as rg,a0 as HN,e as qN,f as GN,c as cg,P as Jc,d as Qu,b as Ru,h as FN,l as VN,m as $N,a1 as QN,a2 as og,a3 as IN,a4 as YN,a5 as XN,a6 as dg,a7 as ug,a8 as mg,a9 as xg,aa as hg,ab as fg,ac as KN}from"./radix-core-C3XKqQJw.js";import{R as zt,P as pr,C as aa,a as Mt,Z as sn,b as Vc,F as _a,c as JN,S as ti,d as PN,M as Dl,A as ZN,D as WN,e as $c,f as Pn,T as ey,X as il,g as sy,h as ty,I as Oa,i as Sa,j as Qt,k as Qc,E as or,l as Rt,m as pg,H as ay,n as Ze,o as nl,U as dr,p as gg,q as jg,L as Wf,K as vg,r as bg,s as ly,t as qc,u as Js,v as ny,B as ar,w as Ic,x as Iu,y as iy,z as ry,G as At,J as Pc,N as Wn,O as rt,Q as Ol,V as ur,W as Yu,Y as gr,_ as cy,$ as oy,a0 as an,a1 as ai,a2 as rl,a3 as Ua,a4 as li,a5 as Xu,a6 as dy,a7 as uy,a8 as my,a9 as tn,aa as xy,ab as Ng,ac as Lu,ad as ln,ae as hy,af as ei,ag as fy,ah as Uu,ai as Bu,aj as yg,ak as ep,al as py,am as gy,an as jy,ao as ll,ap as yu,aq as sp,ar as vy,as as wu,at as by,au as Ny,av as yy,aw as wy,ax as _y,ay as wg,az as _g,aA as Sg,aB as Cg,aC as Sy,aD as tp,aE as Cy,aF as ky,aG as Ty,aH as Ey}from"./icons-Dkibu3bQ.js";import{S as zy,p as My,j as Ay,a as Dy,E as ap,R as Oy,o as Ry}from"./codemirror-BHeANvwm.js";import{_ as Xt,c as Ly,g as kg,D as Uy}from"./misc-DyBU7ISD.js";import{u as By,a as lp,D as Hy,c as qy,S as Gy,h as Fy,b as Vy,s as $y,K as Qy,P as Iy,d as Yy,C as Xy}from"./dnd-Dyi3CnuX.js";import{D as Ky,U as Jy}from"./uppy-DUr9_tfX.js";import{M as Py,r as Zy,a as Wy,b as e0}from"./markdown-A1ShuLvG.js";import{r as s0,H as Yc,P as Xc,u as t0,a as a0,R as l0,B as n0,b as i0,C as r0,M as c0,c as o0}from"./reactflow-B3n3_Vkw.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))d(m);new MutationObserver(m=>{for(const x of m)if(x.type==="childList")for(const f of x.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&d(f)}).observe(document,{childList:!0,subtree:!0});function r(m){const x={};return m.integrity&&(x.integrity=m.integrity),m.referrerPolicy&&(x.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?x.credentials="include":m.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function d(m){if(m.ep)return;m.ep=!0;const x=r(m);fetch(m.href,x)}})();var _u={exports:{}},er={},Su={exports:{}},Cu={};var np;function d0(){return np||(np=1,(function(n){function i(O,G){var H=O.length;O.push(G);e:for(;0<H;){var ee=H-1>>>1,v=O[ee];if(0<m(v,G))O[ee]=G,O[H]=v,H=ee;else break e}}function r(O){return O.length===0?null:O[0]}function d(O){if(O.length===0)return null;var G=O[0],H=O.pop();if(H!==G){O[0]=H;e:for(var ee=0,v=O.length,X=v>>>1;ee<X;){var me=2*(ee+1)-1,ce=O[me],xe=me+1,we=O[xe];if(0>m(ce,H))xe<v&&0>m(we,ce)?(O[ee]=we,O[xe]=H,ee=xe):(O[ee]=ce,O[me]=H,ee=me);else if(xe<v&&0>m(we,H))O[ee]=we,O[xe]=H,ee=xe;else break e}}return G}function m(O,G){var H=O.sortIndex-G.sortIndex;return H!==0?H:O.id-G.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var x=performance;n.unstable_now=function(){return x.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var g=[],N=[],j=1,w=null,y=3,k=!1,_=!1,L=!1,D=!1,U=typeof setTimeout=="function"?setTimeout:null,Q=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function z(O){for(var G=r(N);G!==null;){if(G.callback===null)d(N);else if(G.startTime<=O)d(N),G.sortIndex=G.expirationTime,i(g,G);else break;G=r(N)}}function I(O){if(L=!1,z(O),!_)if(r(g)!==null)_=!0,$||($=!0,Ne());else{var G=r(N);G!==null&&Se(I,G.startTime-O)}}var $=!1,E=-1,M=5,se=-1;function fe(){return D?!0:!(n.unstable_now()-se<M)}function ve(){if(D=!1,$){var O=n.unstable_now();se=O;var G=!0;try{e:{_=!1,L&&(L=!1,Q(E),E=-1),k=!0;var H=y;try{s:{for(z(O),w=r(g);w!==null&&!(w.expirationTime>O&&fe());){var ee=w.callback;if(typeof ee=="function"){w.callback=null,y=w.priorityLevel;var v=ee(w.expirationTime<=O);if(O=n.unstable_now(),typeof v=="function"){w.callback=v,z(O),G=!0;break s}w===r(g)&&d(g),z(O)}else d(g);w=r(g)}if(w!==null)G=!0;else{var X=r(N);X!==null&&Se(I,X.startTime-O),G=!1}}break e}finally{w=null,y=H,k=!1}G=void 0}}finally{G?Ne():$=!1}}}var Ne;if(typeof R=="function")Ne=function(){R(ve)};else if(typeof MessageChannel<"u"){var je=new MessageChannel,ye=je.port2;je.port1.onmessage=ve,Ne=function(){ye.postMessage(null)}}else Ne=function(){U(ve,0)};function Se(O,G){E=U(function(){O(n.unstable_now())},G)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(O){O.callback=null},n.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<O?Math.floor(1e3/O):5},n.unstable_getCurrentPriorityLevel=function(){return y},n.unstable_next=function(O){switch(y){case 1:case 2:case 3:var G=3;break;default:G=y}var H=y;y=G;try{return O()}finally{y=H}},n.unstable_requestPaint=function(){D=!0},n.unstable_runWithPriority=function(O,G){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var H=y;y=O;try{return G()}finally{y=H}},n.unstable_scheduleCallback=function(O,G,H){var ee=n.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?ee+H:ee):H=ee,O){case 1:var v=-1;break;case 2:v=250;break;case 5:v=1073741823;break;case 4:v=1e4;break;default:v=5e3}return v=H+v,O={id:j++,callback:G,priorityLevel:O,startTime:H,expirationTime:v,sortIndex:-1},H>ee?(O.sortIndex=H,i(N,O),r(g)===null&&O===r(N)&&(L?(Q(E),E=-1):L=!0,Se(I,H-ee))):(O.sortIndex=v,i(g,O),_||k||(_=!0,$||($=!0,Ne()))),O},n.unstable_shouldYield=fe,n.unstable_wrapCallback=function(O){var G=y;return function(){var H=y;y=G;try{return O.apply(this,arguments)}finally{y=H}}}})(Cu)),Cu}var ip;function u0(){return ip||(ip=1,Su.exports=d0()),Su.exports}var rp;function m0(){if(rp)return er;rp=1;var n=u0(),i=Ib(),r=Yb();function d(s){var t="https://react.dev/errors/"+s;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+s+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function m(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function x(s){var t=s,a=s;if(s.alternate)for(;t.return;)t=t.return;else{s=t;do t=s,(t.flags&4098)!==0&&(a=t.return),s=t.return;while(s)}return t.tag===3?a:null}function f(s){if(s.tag===13){var t=s.memoizedState;if(t===null&&(s=s.alternate,s!==null&&(t=s.memoizedState)),t!==null)return t.dehydrated}return null}function p(s){if(s.tag===31){var t=s.memoizedState;if(t===null&&(s=s.alternate,s!==null&&(t=s.memoizedState)),t!==null)return t.dehydrated}return null}function g(s){if(x(s)!==s)throw Error(d(188))}function N(s){var t=s.alternate;if(!t){if(t=x(s),t===null)throw Error(d(188));return t!==s?null:s}for(var a=s,l=t;;){var c=a.return;if(c===null)break;var o=c.alternate;if(o===null){if(l=c.return,l!==null){a=l;continue}break}if(c.child===o.child){for(o=c.child;o;){if(o===a)return g(c),s;if(o===l)return g(c),t;o=o.sibling}throw Error(d(188))}if(a.return!==l.return)a=c,l=o;else{for(var h=!1,b=c.child;b;){if(b===a){h=!0,a=c,l=o;break}if(b===l){h=!0,l=c,a=o;break}b=b.sibling}if(!h){for(b=o.child;b;){if(b===a){h=!0,a=o,l=c;break}if(b===l){h=!0,l=o,a=c;break}b=b.sibling}if(!h)throw Error(d(189))}}if(a.alternate!==l)throw Error(d(190))}if(a.tag!==3)throw Error(d(188));return a.stateNode.current===a?s:t}function j(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s;for(s=s.child;s!==null;){if(t=j(s),t!==null)return t;s=s.sibling}return null}var w=Object.assign,y=Symbol.for("react.element"),k=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),R=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),se=Symbol.for("react.activity"),fe=Symbol.for("react.memo_cache_sentinel"),ve=Symbol.iterator;function Ne(s){return s===null||typeof s!="object"?null:(s=ve&&s[ve]||s["@@iterator"],typeof s=="function"?s:null)}var je=Symbol.for("react.client.reference");function ye(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===je?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case L:return"Fragment";case U:return"Profiler";case D:return"StrictMode";case I:return"Suspense";case $:return"SuspenseList";case se:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case _:return"Portal";case R:return s.displayName||"Context";case Q:return(s._context.displayName||"Context")+".Consumer";case z:var t=s.render;return s=s.displayName,s||(s=t.displayName||t.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case E:return t=s.displayName||null,t!==null?t:ye(s.type)||"Memo";case M:t=s._payload,s=s._init;try{return ye(s(t))}catch{}}return null}var Se=Array.isArray,O=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},ee=[],v=-1;function X(s){return{current:s}}function me(s){0>v||(s.current=ee[v],ee[v]=null,v--)}function ce(s,t){v++,ee[v]=s.current,s.current=t}var xe=X(null),we=X(null),oe=X(null),Z=X(null);function te(s,t){switch(ce(oe,t),ce(we,s),ce(xe,null),t.nodeType){case 9:case 11:s=(s=t.documentElement)&&(s=s.namespaceURI)?yf(s):0;break;default:if(s=t.tagName,t=t.namespaceURI)t=yf(t),s=wf(t,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}me(xe),ce(xe,s)}function V(){me(xe),me(we),me(oe)}function P(s){s.memoizedState!==null&&ce(Z,s);var t=xe.current,a=wf(t,s.type);t!==a&&(ce(we,s),ce(xe,a))}function ke(s){we.current===s&&(me(xe),me(we)),Z.current===s&&(me(Z),Yi._currentValue=H)}var He,pe;function Te(s){if(He===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);He=t&&t[1]||"",pe=-1<a.stack.indexOf(`
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
`+He+s+pe}var Qs=!1;function vt(s,t){if(!s||Qs)return"";Qs=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var l={DetermineComponentFrameRoot:function(){try{if(t){var he=function(){throw Error()};if(Object.defineProperty(he.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(he,[])}catch(ae){var W=ae}Reflect.construct(s,[],he)}else{try{he.call()}catch(ae){W=ae}s.call(he.prototype)}}else{try{throw Error()}catch(ae){W=ae}(he=s())&&typeof he.catch=="function"&&he.catch(function(){})}}catch(ae){if(ae&&W&&typeof ae.stack=="string")return[ae.stack,W.stack]}return[null,null]}};l.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var c=Object.getOwnPropertyDescriptor(l.DetermineComponentFrameRoot,"name");c&&c.configurable&&Object.defineProperty(l.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=l.DetermineComponentFrameRoot(),h=o[0],b=o[1];if(h&&b){var A=h.split(`
`),J=b.split(`
`);for(c=l=0;l<A.length&&!A[l].includes("DetermineComponentFrameRoot");)l++;for(;c<J.length&&!J[c].includes("DetermineComponentFrameRoot");)c++;if(l===A.length||c===J.length)for(l=A.length-1,c=J.length-1;1<=l&&0<=c&&A[l]!==J[c];)c--;for(;1<=l&&0<=c;l--,c--)if(A[l]!==J[c]){if(l!==1||c!==1)do if(l--,c--,0>c||A[l]!==J[c]){var re=`
`+A[l].replace(" at new "," at ");return s.displayName&&re.includes("<anonymous>")&&(re=re.replace("<anonymous>",s.displayName)),re}while(1<=l&&0<=c);break}}}finally{Qs=!1,Error.prepareStackTrace=a}return(a=s?s.displayName||s.name:"")?Te(a):""}function de(s,t){switch(s.tag){case 26:case 27:case 5:return Te(s.type);case 16:return Te("Lazy");case 13:return s.child!==t&&t!==null?Te("Suspense Fallback"):Te("Suspense");case 19:return Te("SuspenseList");case 0:case 15:return vt(s.type,!1);case 11:return vt(s.type.render,!1);case 1:return vt(s.type,!0);case 31:return Te("Activity");default:return""}}function qe(s){try{var t="",a=null;do t+=de(s,a),a=s,s=s.return;while(s);return t}catch(l){return`
Error generating stack: `+l.message+`
`+l.stack}}var Ie=Object.prototype.hasOwnProperty,Ys=n.unstable_scheduleCallback,Hs=n.unstable_cancelCallback,bt=n.unstable_shouldYield,ot=n.unstable_requestPaint,Ds=n.unstable_now,ks=n.unstable_getCurrentPriorityLevel,va=n.unstable_ImmediatePriority,Y=n.unstable_UserBlockingPriority,Be=n.unstable_NormalPriority,Ee=n.unstable_LowPriority,Ye=n.unstable_IdlePriority,Xs=n.log,Je=n.unstable_setDisableYieldValue,qs=null,be=null;function _s(s){if(typeof Xs=="function"&&Je(s),be&&typeof be.setStrictMode=="function")try{be.setStrictMode(qs,s)}catch{}}var Ae=Math.clz32?Math.clz32:xs,Fs=Math.log,dt=Math.LN2;function xs(s){return s>>>=0,s===0?32:31-(Fs(s)/dt|0)|0}var gs=256,Nt=262144,Lt=4194304;function Dt(s){var t=s&42;if(t!==0)return t;switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return s&261888;case 262144:case 524288:case 1048576:case 2097152:return s&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return s&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return s}}function Ba(s,t,a){var l=s.pendingLanes;if(l===0)return 0;var c=0,o=s.suspendedLanes,h=s.pingedLanes;s=s.warmLanes;var b=l&134217727;return b!==0?(l=b&~o,l!==0?c=Dt(l):(h&=b,h!==0?c=Dt(h):a||(a=b&~s,a!==0&&(c=Dt(a))))):(b=l&~o,b!==0?c=Dt(b):h!==0?c=Dt(h):a||(a=l&~s,a!==0&&(c=Dt(a)))),c===0?0:t!==0&&t!==c&&(t&o)===0&&(o=c&-c,a=t&-t,o>=a||o===32&&(a&4194048)!==0)?t:c}function ne(s,t){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&t)===0}function T(s,t){switch(s){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ge(){var s=Lt;return Lt<<=1,(Lt&62914560)===0&&(Lt=4194304),s}function ze(s){for(var t=[],a=0;31>a;a++)t.push(s);return t}function Ns(s,t){s.pendingLanes|=t,t!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function io(s,t,a,l,c,o){var h=s.pendingLanes;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=a,s.entangledLanes&=a,s.errorRecoveryDisabledLanes&=a,s.shellSuspendCounter=0;var b=s.entanglements,A=s.expirationTimes,J=s.hiddenUpdates;for(a=h&~a;0<a;){var re=31-Ae(a),he=1<<re;b[re]=0,A[re]=-1;var W=J[re];if(W!==null)for(J[re]=null,re=0;re<W.length;re++){var ae=W[re];ae!==null&&(ae.lane&=-536870913)}a&=~he}l!==0&&ri(s,l,0),o!==0&&c===0&&s.tag!==0&&(s.suspendedLanes|=o&~(h&~t))}function ri(s,t,a){s.pendingLanes|=t,s.suspendedLanes&=~t;var l=31-Ae(t);s.entangledLanes|=t,s.entanglements[l]=s.entanglements[l]|1073741824|a&261930}function lm(s,t){var a=s.entangledLanes|=t;for(s=s.entanglements;a;){var l=31-Ae(a),c=1<<l;c&t|s[l]&t&&(s[l]|=t),a&=~c}}function nm(s,t){var a=t&-t;return a=(a&42)!==0?1:ro(a),(a&(s.suspendedLanes|t))!==0?0:a}function ro(s){switch(s){case 2:s=1;break;case 8:s=4;break;case 32:s=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:s=128;break;case 268435456:s=134217728;break;default:s=0}return s}function co(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function im(){var s=G.p;return s!==0?s:(s=window.event,s===void 0?32:If(s.type))}function rm(s,t){var a=G.p;try{return G.p=s,t()}finally{G.p=a}}var ol=Math.random().toString(36).slice(2),St="__reactFiber$"+ol,Ut="__reactProps$"+ol,on="__reactContainer$"+ol,oo="__reactEvents$"+ol,Tj="__reactListeners$"+ol,Ej="__reactHandles$"+ol,cm="__reactResources$"+ol,ci="__reactMarker$"+ol;function uo(s){delete s[St],delete s[Ut],delete s[oo],delete s[Tj],delete s[Ej]}function dn(s){var t=s[St];if(t)return t;for(var a=s.parentNode;a;){if(t=a[on]||a[St]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(s=zf(s);s!==null;){if(a=s[St])return a;s=zf(s)}return t}s=a,a=s.parentNode}return null}function un(s){if(s=s[St]||s[on]){var t=s.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return s}return null}function oi(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s.stateNode;throw Error(d(33))}function mn(s){var t=s[cm];return t||(t=s[cm]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function yt(s){s[ci]=!0}var om=new Set,dm={};function Ul(s,t){xn(s,t),xn(s+"Capture",t)}function xn(s,t){for(dm[s]=t,s=0;s<t.length;s++)om.add(t[s])}var zj=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),um={},mm={};function Mj(s){return Ie.call(mm,s)?!0:Ie.call(um,s)?!1:zj.test(s)?mm[s]=!0:(um[s]=!0,!1)}function br(s,t,a){if(Mj(t))if(a===null)s.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":s.removeAttribute(t);return;case"boolean":var l=t.toLowerCase().slice(0,5);if(l!=="data-"&&l!=="aria-"){s.removeAttribute(t);return}}s.setAttribute(t,""+a)}}function Nr(s,t,a){if(a===null)s.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(t);return}s.setAttribute(t,""+a)}}function Ha(s,t,a,l){if(l===null)s.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(a);return}s.setAttributeNS(t,a,""+l)}}function la(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function xm(s){var t=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Aj(s,t,a){var l=Object.getOwnPropertyDescriptor(s.constructor.prototype,t);if(!s.hasOwnProperty(t)&&typeof l<"u"&&typeof l.get=="function"&&typeof l.set=="function"){var c=l.get,o=l.set;return Object.defineProperty(s,t,{configurable:!0,get:function(){return c.call(this)},set:function(h){a=""+h,o.call(this,h)}}),Object.defineProperty(s,t,{enumerable:l.enumerable}),{getValue:function(){return a},setValue:function(h){a=""+h},stopTracking:function(){s._valueTracker=null,delete s[t]}}}}function mo(s){if(!s._valueTracker){var t=xm(s)?"checked":"value";s._valueTracker=Aj(s,t,""+s[t])}}function hm(s){if(!s)return!1;var t=s._valueTracker;if(!t)return!0;var a=t.getValue(),l="";return s&&(l=xm(s)?s.checked?"true":"false":s.value),s=l,s!==a?(t.setValue(s),!0):!1}function yr(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}var Dj=/[\n"\\]/g;function na(s){return s.replace(Dj,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function xo(s,t,a,l,c,o,h,b){s.name="",h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?s.type=h:s.removeAttribute("type"),t!=null?h==="number"?(t===0&&s.value===""||s.value!=t)&&(s.value=""+la(t)):s.value!==""+la(t)&&(s.value=""+la(t)):h!=="submit"&&h!=="reset"||s.removeAttribute("value"),t!=null?ho(s,h,la(t)):a!=null?ho(s,h,la(a)):l!=null&&s.removeAttribute("value"),c==null&&o!=null&&(s.defaultChecked=!!o),c!=null&&(s.checked=c&&typeof c!="function"&&typeof c!="symbol"),b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?s.name=""+la(b):s.removeAttribute("name")}function fm(s,t,a,l,c,o,h,b){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(s.type=o),t!=null||a!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){mo(s);return}a=a!=null?""+la(a):"",t=t!=null?""+la(t):a,b||t===s.value||(s.value=t),s.defaultValue=t}l=l??c,l=typeof l!="function"&&typeof l!="symbol"&&!!l,s.checked=b?s.checked:!!l,s.defaultChecked=!!l,h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(s.name=h),mo(s)}function ho(s,t,a){t==="number"&&yr(s.ownerDocument)===s||s.defaultValue===""+a||(s.defaultValue=""+a)}function hn(s,t,a,l){if(s=s.options,t){t={};for(var c=0;c<a.length;c++)t["$"+a[c]]=!0;for(a=0;a<s.length;a++)c=t.hasOwnProperty("$"+s[a].value),s[a].selected!==c&&(s[a].selected=c),c&&l&&(s[a].defaultSelected=!0)}else{for(a=""+la(a),t=null,c=0;c<s.length;c++){if(s[c].value===a){s[c].selected=!0,l&&(s[c].defaultSelected=!0);return}t!==null||s[c].disabled||(t=s[c])}t!==null&&(t.selected=!0)}}function pm(s,t,a){if(t!=null&&(t=""+la(t),t!==s.value&&(s.value=t),a==null)){s.defaultValue!==t&&(s.defaultValue=t);return}s.defaultValue=a!=null?""+la(a):""}function gm(s,t,a,l){if(t==null){if(l!=null){if(a!=null)throw Error(d(92));if(Se(l)){if(1<l.length)throw Error(d(93));l=l[0]}a=l}a==null&&(a=""),t=a}a=la(t),s.defaultValue=a,l=s.textContent,l===a&&l!==""&&l!==null&&(s.value=l),mo(s)}function fn(s,t){if(t){var a=s.firstChild;if(a&&a===s.lastChild&&a.nodeType===3){a.nodeValue=t;return}}s.textContent=t}var Oj=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function jm(s,t,a){var l=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?l?s.setProperty(t,""):t==="float"?s.cssFloat="":s[t]="":l?s.setProperty(t,a):typeof a!="number"||a===0||Oj.has(t)?t==="float"?s.cssFloat=a:s[t]=(""+a).trim():s[t]=a+"px"}function vm(s,t,a){if(t!=null&&typeof t!="object")throw Error(d(62));if(s=s.style,a!=null){for(var l in a)!a.hasOwnProperty(l)||t!=null&&t.hasOwnProperty(l)||(l.indexOf("--")===0?s.setProperty(l,""):l==="float"?s.cssFloat="":s[l]="");for(var c in t)l=t[c],t.hasOwnProperty(c)&&a[c]!==l&&jm(s,c,l)}else for(var o in t)t.hasOwnProperty(o)&&jm(s,o,t[o])}function fo(s){if(s.indexOf("-")===-1)return!1;switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rj=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Lj=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function wr(s){return Lj.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function qa(){}var po=null;function go(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var pn=null,gn=null;function bm(s){var t=un(s);if(t&&(s=t.stateNode)){var a=s[Ut]||null;e:switch(s=t.stateNode,t.type){case"input":if(xo(s,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=s;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+na(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var l=a[t];if(l!==s&&l.form===s.form){var c=l[Ut]||null;if(!c)throw Error(d(90));xo(l,c.value,c.defaultValue,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name)}}for(t=0;t<a.length;t++)l=a[t],l.form===s.form&&hm(l)}break e;case"textarea":pm(s,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&hn(s,!!a.multiple,t,!1)}}}var jo=!1;function Nm(s,t,a){if(jo)return s(t,a);jo=!0;try{var l=s(t);return l}finally{if(jo=!1,(pn!==null||gn!==null)&&(dc(),pn&&(t=pn,s=gn,gn=pn=null,bm(t),s)))for(t=0;t<s.length;t++)bm(s[t])}}function di(s,t){var a=s.stateNode;if(a===null)return null;var l=a[Ut]||null;if(l===null)return null;a=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(s=s.type,l=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!l;break e;default:s=!1}if(s)return null;if(a&&typeof a!="function")throw Error(d(231,t,typeof a));return a}var Ga=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vo=!1;if(Ga)try{var ui={};Object.defineProperty(ui,"passive",{get:function(){vo=!0}}),window.addEventListener("test",ui,ui),window.removeEventListener("test",ui,ui)}catch{vo=!1}var dl=null,bo=null,_r=null;function ym(){if(_r)return _r;var s,t=bo,a=t.length,l,c="value"in dl?dl.value:dl.textContent,o=c.length;for(s=0;s<a&&t[s]===c[s];s++);var h=a-s;for(l=1;l<=h&&t[a-l]===c[o-l];l++);return _r=c.slice(s,1<l?1-l:void 0)}function Sr(s){var t=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&t===13&&(s=13)):s=t,s===10&&(s=13),32<=s||s===13?s:0}function Cr(){return!0}function wm(){return!1}function Bt(s){function t(a,l,c,o,h){this._reactName=a,this._targetInst=c,this.type=l,this.nativeEvent=o,this.target=h,this.currentTarget=null;for(var b in s)s.hasOwnProperty(b)&&(a=s[b],this[b]=a?a(o):o[b]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Cr:wm,this.isPropagationStopped=wm,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=Cr)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=Cr)},persist:function(){},isPersistent:Cr}),t}var Bl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kr=Bt(Bl),mi=w({},Bl,{view:0,detail:0}),Uj=Bt(mi),No,yo,xi,Tr=w({},mi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_o,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==xi&&(xi&&s.type==="mousemove"?(No=s.screenX-xi.screenX,yo=s.screenY-xi.screenY):yo=No=0,xi=s),No)},movementY:function(s){return"movementY"in s?s.movementY:yo}}),_m=Bt(Tr),Bj=w({},Tr,{dataTransfer:0}),Hj=Bt(Bj),qj=w({},mi,{relatedTarget:0}),wo=Bt(qj),Gj=w({},Bl,{animationName:0,elapsedTime:0,pseudoElement:0}),Fj=Bt(Gj),Vj=w({},Bl,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),$j=Bt(Vj),Qj=w({},Bl,{data:0}),Sm=Bt(Qj),Ij={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Yj={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Xj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Kj(s){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(s):(s=Xj[s])?!!t[s]:!1}function _o(){return Kj}var Jj=w({},mi,{key:function(s){if(s.key){var t=Ij[s.key]||s.key;if(t!=="Unidentified")return t}return s.type==="keypress"?(s=Sr(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Yj[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_o,charCode:function(s){return s.type==="keypress"?Sr(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Sr(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Pj=Bt(Jj),Zj=w({},Tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cm=Bt(Zj),Wj=w({},mi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_o}),ev=Bt(Wj),sv=w({},Bl,{propertyName:0,elapsedTime:0,pseudoElement:0}),tv=Bt(sv),av=w({},Tr,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),lv=Bt(av),nv=w({},Bl,{newState:0,oldState:0}),iv=Bt(nv),rv=[9,13,27,32],So=Ga&&"CompositionEvent"in window,hi=null;Ga&&"documentMode"in document&&(hi=document.documentMode);var cv=Ga&&"TextEvent"in window&&!hi,km=Ga&&(!So||hi&&8<hi&&11>=hi),Tm=" ",Em=!1;function zm(s,t){switch(s){case"keyup":return rv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mm(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var jn=!1;function ov(s,t){switch(s){case"compositionend":return Mm(t);case"keypress":return t.which!==32?null:(Em=!0,Tm);case"textInput":return s=t.data,s===Tm&&Em?null:s;default:return null}}function dv(s,t){if(jn)return s==="compositionend"||!So&&zm(s,t)?(s=ym(),_r=bo=dl=null,jn=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return km&&t.locale!=="ko"?null:t.data;default:return null}}var uv={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Am(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t==="input"?!!uv[s.type]:t==="textarea"}function Dm(s,t,a,l){pn?gn?gn.push(l):gn=[l]:pn=l,t=gc(t,"onChange"),0<t.length&&(a=new kr("onChange","change",null,a,l),s.push({event:a,listeners:t}))}var fi=null,pi=null;function mv(s){pf(s,0)}function Er(s){var t=oi(s);if(hm(t))return s}function Om(s,t){if(s==="change")return t}var Rm=!1;if(Ga){var Co;if(Ga){var ko="oninput"in document;if(!ko){var Lm=document.createElement("div");Lm.setAttribute("oninput","return;"),ko=typeof Lm.oninput=="function"}Co=ko}else Co=!1;Rm=Co&&(!document.documentMode||9<document.documentMode)}function Um(){fi&&(fi.detachEvent("onpropertychange",Bm),pi=fi=null)}function Bm(s){if(s.propertyName==="value"&&Er(pi)){var t=[];Dm(t,pi,s,go(s)),Nm(mv,t)}}function xv(s,t,a){s==="focusin"?(Um(),fi=t,pi=a,fi.attachEvent("onpropertychange",Bm)):s==="focusout"&&Um()}function hv(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Er(pi)}function fv(s,t){if(s==="click")return Er(t)}function pv(s,t){if(s==="input"||s==="change")return Er(t)}function gv(s,t){return s===t&&(s!==0||1/s===1/t)||s!==s&&t!==t}var Kt=typeof Object.is=="function"?Object.is:gv;function gi(s,t){if(Kt(s,t))return!0;if(typeof s!="object"||s===null||typeof t!="object"||t===null)return!1;var a=Object.keys(s),l=Object.keys(t);if(a.length!==l.length)return!1;for(l=0;l<a.length;l++){var c=a[l];if(!Ie.call(t,c)||!Kt(s[c],t[c]))return!1}return!0}function Hm(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function qm(s,t){var a=Hm(s);s=0;for(var l;a;){if(a.nodeType===3){if(l=s+a.textContent.length,s<=t&&l>=t)return{node:a,offset:t-s};s=l}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Hm(a)}}function Gm(s,t){return s&&t?s===t?!0:s&&s.nodeType===3?!1:t&&t.nodeType===3?Gm(s,t.parentNode):"contains"in s?s.contains(t):s.compareDocumentPosition?!!(s.compareDocumentPosition(t)&16):!1:!1}function Fm(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var t=yr(s.document);t instanceof s.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)s=t.contentWindow;else break;t=yr(s.document)}return t}function To(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t&&(t==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||t==="textarea"||s.contentEditable==="true")}var jv=Ga&&"documentMode"in document&&11>=document.documentMode,vn=null,Eo=null,ji=null,zo=!1;function Vm(s,t,a){var l=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;zo||vn==null||vn!==yr(l)||(l=vn,"selectionStart"in l&&To(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),ji&&gi(ji,l)||(ji=l,l=gc(Eo,"onSelect"),0<l.length&&(t=new kr("onSelect","select",null,t,a),s.push({event:t,listeners:l}),t.target=vn)))}function Hl(s,t){var a={};return a[s.toLowerCase()]=t.toLowerCase(),a["Webkit"+s]="webkit"+t,a["Moz"+s]="moz"+t,a}var bn={animationend:Hl("Animation","AnimationEnd"),animationiteration:Hl("Animation","AnimationIteration"),animationstart:Hl("Animation","AnimationStart"),transitionrun:Hl("Transition","TransitionRun"),transitionstart:Hl("Transition","TransitionStart"),transitioncancel:Hl("Transition","TransitionCancel"),transitionend:Hl("Transition","TransitionEnd")},Mo={},$m={};Ga&&($m=document.createElement("div").style,"AnimationEvent"in window||(delete bn.animationend.animation,delete bn.animationiteration.animation,delete bn.animationstart.animation),"TransitionEvent"in window||delete bn.transitionend.transition);function ql(s){if(Mo[s])return Mo[s];if(!bn[s])return s;var t=bn[s],a;for(a in t)if(t.hasOwnProperty(a)&&a in $m)return Mo[s]=t[a];return s}var Qm=ql("animationend"),Im=ql("animationiteration"),Ym=ql("animationstart"),vv=ql("transitionrun"),bv=ql("transitionstart"),Nv=ql("transitioncancel"),Xm=ql("transitionend"),Km=new Map,Ao="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ao.push("scrollEnd");function ba(s,t){Km.set(s,t),Ul(t,[s])}var zr=typeof reportError=="function"?reportError:function(s){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof s=="object"&&s!==null&&typeof s.message=="string"?String(s.message):String(s),error:s});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",s);return}console.error(s)},ia=[],Nn=0,Do=0;function Mr(){for(var s=Nn,t=Do=Nn=0;t<s;){var a=ia[t];ia[t++]=null;var l=ia[t];ia[t++]=null;var c=ia[t];ia[t++]=null;var o=ia[t];if(ia[t++]=null,l!==null&&c!==null){var h=l.pending;h===null?c.next=c:(c.next=h.next,h.next=c),l.pending=c}o!==0&&Jm(a,c,o)}}function Ar(s,t,a,l){ia[Nn++]=s,ia[Nn++]=t,ia[Nn++]=a,ia[Nn++]=l,Do|=l,s.lanes|=l,s=s.alternate,s!==null&&(s.lanes|=l)}function Oo(s,t,a,l){return Ar(s,t,a,l),Dr(s)}function Gl(s,t){return Ar(s,null,null,t),Dr(s)}function Jm(s,t,a){s.lanes|=a;var l=s.alternate;l!==null&&(l.lanes|=a);for(var c=!1,o=s.return;o!==null;)o.childLanes|=a,l=o.alternate,l!==null&&(l.childLanes|=a),o.tag===22&&(s=o.stateNode,s===null||s._visibility&1||(c=!0)),s=o,o=o.return;return s.tag===3?(o=s.stateNode,c&&t!==null&&(c=31-Ae(a),s=o.hiddenUpdates,l=s[c],l===null?s[c]=[t]:l.push(t),t.lane=a|536870912),o):null}function Dr(s){if(50<qi)throw qi=0,Vd=null,Error(d(185));for(var t=s.return;t!==null;)s=t,t=s.return;return s.tag===3?s.stateNode:null}var yn={};function yv(s,t,a,l){this.tag=s,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jt(s,t,a,l){return new yv(s,t,a,l)}function Ro(s){return s=s.prototype,!(!s||!s.isReactComponent)}function Fa(s,t){var a=s.alternate;return a===null?(a=Jt(s.tag,t,s.key,s.mode),a.elementType=s.elementType,a.type=s.type,a.stateNode=s.stateNode,a.alternate=s,s.alternate=a):(a.pendingProps=t,a.type=s.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=s.flags&65011712,a.childLanes=s.childLanes,a.lanes=s.lanes,a.child=s.child,a.memoizedProps=s.memoizedProps,a.memoizedState=s.memoizedState,a.updateQueue=s.updateQueue,t=s.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=s.sibling,a.index=s.index,a.ref=s.ref,a.refCleanup=s.refCleanup,a}function Pm(s,t){s.flags&=65011714;var a=s.alternate;return a===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=a.childLanes,s.lanes=a.lanes,s.child=a.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=a.memoizedProps,s.memoizedState=a.memoizedState,s.updateQueue=a.updateQueue,s.type=a.type,t=a.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),s}function Or(s,t,a,l,c,o){var h=0;if(l=s,typeof s=="function")Ro(s)&&(h=1);else if(typeof s=="string")h=kb(s,a,xe.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case se:return s=Jt(31,a,t,c),s.elementType=se,s.lanes=o,s;case L:return Fl(a.children,c,o,t);case D:h=8,c|=24;break;case U:return s=Jt(12,a,t,c|2),s.elementType=U,s.lanes=o,s;case I:return s=Jt(13,a,t,c),s.elementType=I,s.lanes=o,s;case $:return s=Jt(19,a,t,c),s.elementType=$,s.lanes=o,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case R:h=10;break e;case Q:h=9;break e;case z:h=11;break e;case E:h=14;break e;case M:h=16,l=null;break e}h=29,a=Error(d(130,s===null?"null":typeof s,"")),l=null}return t=Jt(h,a,t,c),t.elementType=s,t.type=l,t.lanes=o,t}function Fl(s,t,a,l){return s=Jt(7,s,l,t),s.lanes=a,s}function Lo(s,t,a){return s=Jt(6,s,null,t),s.lanes=a,s}function Zm(s){var t=Jt(18,null,null,0);return t.stateNode=s,t}function Uo(s,t,a){return t=Jt(4,s.children!==null?s.children:[],s.key,t),t.lanes=a,t.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},t}var Wm=new WeakMap;function ra(s,t){if(typeof s=="object"&&s!==null){var a=Wm.get(s);return a!==void 0?a:(t={value:s,source:t,stack:qe(t)},Wm.set(s,t),t)}return{value:s,source:t,stack:qe(t)}}var wn=[],_n=0,Rr=null,vi=0,ca=[],oa=0,ul=null,Ta=1,Ea="";function Va(s,t){wn[_n++]=vi,wn[_n++]=Rr,Rr=s,vi=t}function ex(s,t,a){ca[oa++]=Ta,ca[oa++]=Ea,ca[oa++]=ul,ul=s;var l=Ta;s=Ea;var c=32-Ae(l)-1;l&=~(1<<c),a+=1;var o=32-Ae(t)+c;if(30<o){var h=c-c%5;o=(l&(1<<h)-1).toString(32),l>>=h,c-=h,Ta=1<<32-Ae(t)+c|a<<c|l,Ea=o+s}else Ta=1<<o|a<<c|l,Ea=s}function Bo(s){s.return!==null&&(Va(s,1),ex(s,1,0))}function Ho(s){for(;s===Rr;)Rr=wn[--_n],wn[_n]=null,vi=wn[--_n],wn[_n]=null;for(;s===ul;)ul=ca[--oa],ca[oa]=null,Ea=ca[--oa],ca[oa]=null,Ta=ca[--oa],ca[oa]=null}function sx(s,t){ca[oa++]=Ta,ca[oa++]=Ea,ca[oa++]=ul,Ta=t.id,Ea=t.overflow,ul=s}var Ct=null,Vs=null,js=!1,ml=null,da=!1,qo=Error(d(519));function xl(s){var t=Error(d(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw bi(ra(t,s)),qo}function tx(s){var t=s.stateNode,a=s.type,l=s.memoizedProps;switch(t[St]=s,t[Ut]=l,a){case"dialog":us("cancel",t),us("close",t);break;case"iframe":case"object":case"embed":us("load",t);break;case"video":case"audio":for(a=0;a<Fi.length;a++)us(Fi[a],t);break;case"source":us("error",t);break;case"img":case"image":case"link":us("error",t),us("load",t);break;case"details":us("toggle",t);break;case"input":us("invalid",t),fm(t,l.value,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name,!0);break;case"select":us("invalid",t);break;case"textarea":us("invalid",t),gm(t,l.value,l.defaultValue,l.children)}a=l.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||l.suppressHydrationWarning===!0||bf(t.textContent,a)?(l.popover!=null&&(us("beforetoggle",t),us("toggle",t)),l.onScroll!=null&&us("scroll",t),l.onScrollEnd!=null&&us("scrollend",t),l.onClick!=null&&(t.onclick=qa),t=!0):t=!1,t||xl(s,!0)}function ax(s){for(Ct=s.return;Ct;)switch(Ct.tag){case 5:case 31:case 13:da=!1;return;case 27:case 3:da=!0;return;default:Ct=Ct.return}}function Sn(s){if(s!==Ct)return!1;if(!js)return ax(s),js=!0,!1;var t=s.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=s.type,a=!(a!=="form"&&a!=="button")||lu(s.type,s.memoizedProps)),a=!a),a&&Vs&&xl(s),ax(s),t===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(d(317));Vs=Ef(s)}else if(t===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(d(317));Vs=Ef(s)}else t===27?(t=Vs,kl(s.type)?(s=ou,ou=null,Vs=s):Vs=t):Vs=Ct?ma(s.stateNode.nextSibling):null;return!0}function Vl(){Vs=Ct=null,js=!1}function Go(){var s=ml;return s!==null&&(Ft===null?Ft=s:Ft.push.apply(Ft,s),ml=null),s}function bi(s){ml===null?ml=[s]:ml.push(s)}var Fo=X(null),$l=null,$a=null;function hl(s,t,a){ce(Fo,t._currentValue),t._currentValue=a}function Qa(s){s._currentValue=Fo.current,me(Fo)}function Vo(s,t,a){for(;s!==null;){var l=s.alternate;if((s.childLanes&t)!==t?(s.childLanes|=t,l!==null&&(l.childLanes|=t)):l!==null&&(l.childLanes&t)!==t&&(l.childLanes|=t),s===a)break;s=s.return}}function $o(s,t,a,l){var c=s.child;for(c!==null&&(c.return=s);c!==null;){var o=c.dependencies;if(o!==null){var h=c.child;o=o.firstContext;e:for(;o!==null;){var b=o;o=c;for(var A=0;A<t.length;A++)if(b.context===t[A]){o.lanes|=a,b=o.alternate,b!==null&&(b.lanes|=a),Vo(o.return,a,s),l||(h=null);break e}o=b.next}}else if(c.tag===18){if(h=c.return,h===null)throw Error(d(341));h.lanes|=a,o=h.alternate,o!==null&&(o.lanes|=a),Vo(h,a,s),h=null}else h=c.child;if(h!==null)h.return=c;else for(h=c;h!==null;){if(h===s){h=null;break}if(c=h.sibling,c!==null){c.return=h.return,h=c;break}h=h.return}c=h}}function Cn(s,t,a,l){s=null;for(var c=t,o=!1;c!==null;){if(!o){if((c.flags&524288)!==0)o=!0;else if((c.flags&262144)!==0)break}if(c.tag===10){var h=c.alternate;if(h===null)throw Error(d(387));if(h=h.memoizedProps,h!==null){var b=c.type;Kt(c.pendingProps.value,h.value)||(s!==null?s.push(b):s=[b])}}else if(c===Z.current){if(h=c.alternate,h===null)throw Error(d(387));h.memoizedState.memoizedState!==c.memoizedState.memoizedState&&(s!==null?s.push(Yi):s=[Yi])}c=c.return}s!==null&&$o(t,s,a,l),t.flags|=262144}function Lr(s){for(s=s.firstContext;s!==null;){if(!Kt(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function Ql(s){$l=s,$a=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function kt(s){return lx($l,s)}function Ur(s,t){return $l===null&&Ql(s),lx(s,t)}function lx(s,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},$a===null){if(s===null)throw Error(d(308));$a=t,s.dependencies={lanes:0,firstContext:t},s.flags|=524288}else $a=$a.next=t;return a}var wv=typeof AbortController<"u"?AbortController:function(){var s=[],t=this.signal={aborted:!1,addEventListener:function(a,l){s.push(l)}};this.abort=function(){t.aborted=!0,s.forEach(function(a){return a()})}},_v=n.unstable_scheduleCallback,Sv=n.unstable_NormalPriority,ut={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qo(){return{controller:new wv,data:new Map,refCount:0}}function Ni(s){s.refCount--,s.refCount===0&&_v(Sv,function(){s.controller.abort()})}var yi=null,Io=0,kn=0,Tn=null;function Cv(s,t){if(yi===null){var a=yi=[];Io=0,kn=Kd(),Tn={status:"pending",value:void 0,then:function(l){a.push(l)}}}return Io++,t.then(nx,nx),t}function nx(){if(--Io===0&&yi!==null){Tn!==null&&(Tn.status="fulfilled");var s=yi;yi=null,kn=0,Tn=null;for(var t=0;t<s.length;t++)(0,s[t])()}}function kv(s,t){var a=[],l={status:"pending",value:null,reason:null,then:function(c){a.push(c)}};return s.then(function(){l.status="fulfilled",l.value=t;for(var c=0;c<a.length;c++)(0,a[c])(t)},function(c){for(l.status="rejected",l.reason=c,c=0;c<a.length;c++)(0,a[c])(void 0)}),l}var ix=O.S;O.S=function(s,t){Vh=Ds(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Cv(s,t),ix!==null&&ix(s,t)};var Il=X(null);function Yo(){var s=Il.current;return s!==null?s:Os.pooledCache}function Br(s,t){t===null?ce(Il,Il.current):ce(Il,t.pool)}function rx(){var s=Yo();return s===null?null:{parent:ut._currentValue,pool:s}}var En=Error(d(460)),Xo=Error(d(474)),Hr=Error(d(542)),qr={then:function(){}};function cx(s){return s=s.status,s==="fulfilled"||s==="rejected"}function ox(s,t,a){switch(a=s[a],a===void 0?s.push(t):a!==t&&(t.then(qa,qa),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,ux(s),s;default:if(typeof t.status=="string")t.then(qa,qa);else{if(s=Os,s!==null&&100<s.shellSuspendCounter)throw Error(d(482));s=t,s.status="pending",s.then(function(l){if(t.status==="pending"){var c=t;c.status="fulfilled",c.value=l}},function(l){if(t.status==="pending"){var c=t;c.status="rejected",c.reason=l}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,ux(s),s}throw Xl=t,En}}function Yl(s){try{var t=s._init;return t(s._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(Xl=a,En):a}}var Xl=null;function dx(){if(Xl===null)throw Error(d(459));var s=Xl;return Xl=null,s}function ux(s){if(s===En||s===Hr)throw Error(d(483))}var zn=null,wi=0;function Gr(s){var t=wi;return wi+=1,zn===null&&(zn=[]),ox(zn,s,t)}function _i(s,t){t=t.props.ref,s.ref=t!==void 0?t:null}function Fr(s,t){throw t.$$typeof===y?Error(d(525)):(s=Object.prototype.toString.call(t),Error(d(31,s==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":s)))}function mx(s){function t(F,B){if(s){var K=F.deletions;K===null?(F.deletions=[B],F.flags|=16):K.push(B)}}function a(F,B){if(!s)return null;for(;B!==null;)t(F,B),B=B.sibling;return null}function l(F){for(var B=new Map;F!==null;)F.key!==null?B.set(F.key,F):B.set(F.index,F),F=F.sibling;return B}function c(F,B){return F=Fa(F,B),F.index=0,F.sibling=null,F}function o(F,B,K){return F.index=K,s?(K=F.alternate,K!==null?(K=K.index,K<B?(F.flags|=67108866,B):K):(F.flags|=67108866,B)):(F.flags|=1048576,B)}function h(F){return s&&F.alternate===null&&(F.flags|=67108866),F}function b(F,B,K,ue){return B===null||B.tag!==6?(B=Lo(K,F.mode,ue),B.return=F,B):(B=c(B,K),B.return=F,B)}function A(F,B,K,ue){var Ue=K.type;return Ue===L?re(F,B,K.props.children,ue,K.key):B!==null&&(B.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===M&&Yl(Ue)===B.type)?(B=c(B,K.props),_i(B,K),B.return=F,B):(B=Or(K.type,K.key,K.props,null,F.mode,ue),_i(B,K),B.return=F,B)}function J(F,B,K,ue){return B===null||B.tag!==4||B.stateNode.containerInfo!==K.containerInfo||B.stateNode.implementation!==K.implementation?(B=Uo(K,F.mode,ue),B.return=F,B):(B=c(B,K.children||[]),B.return=F,B)}function re(F,B,K,ue,Ue){return B===null||B.tag!==7?(B=Fl(K,F.mode,ue,Ue),B.return=F,B):(B=c(B,K),B.return=F,B)}function he(F,B,K){if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return B=Lo(""+B,F.mode,K),B.return=F,B;if(typeof B=="object"&&B!==null){switch(B.$$typeof){case k:return K=Or(B.type,B.key,B.props,null,F.mode,K),_i(K,B),K.return=F,K;case _:return B=Uo(B,F.mode,K),B.return=F,B;case M:return B=Yl(B),he(F,B,K)}if(Se(B)||Ne(B))return B=Fl(B,F.mode,K,null),B.return=F,B;if(typeof B.then=="function")return he(F,Gr(B),K);if(B.$$typeof===R)return he(F,Ur(F,B),K);Fr(F,B)}return null}function W(F,B,K,ue){var Ue=B!==null?B.key:null;if(typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint")return Ue!==null?null:b(F,B,""+K,ue);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case k:return K.key===Ue?A(F,B,K,ue):null;case _:return K.key===Ue?J(F,B,K,ue):null;case M:return K=Yl(K),W(F,B,K,ue)}if(Se(K)||Ne(K))return Ue!==null?null:re(F,B,K,ue,null);if(typeof K.then=="function")return W(F,B,Gr(K),ue);if(K.$$typeof===R)return W(F,B,Ur(F,K),ue);Fr(F,K)}return null}function ae(F,B,K,ue,Ue){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return F=F.get(K)||null,b(B,F,""+ue,Ue);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case k:return F=F.get(ue.key===null?K:ue.key)||null,A(B,F,ue,Ue);case _:return F=F.get(ue.key===null?K:ue.key)||null,J(B,F,ue,Ue);case M:return ue=Yl(ue),ae(F,B,K,ue,Ue)}if(Se(ue)||Ne(ue))return F=F.get(K)||null,re(B,F,ue,Ue,null);if(typeof ue.then=="function")return ae(F,B,K,Gr(ue),Ue);if(ue.$$typeof===R)return ae(F,B,K,Ur(B,ue),Ue);Fr(B,ue)}return null}function Ce(F,B,K,ue){for(var Ue=null,vs=null,Me=B,We=B=0,fs=null;Me!==null&&We<K.length;We++){Me.index>We?(fs=Me,Me=null):fs=Me.sibling;var bs=W(F,Me,K[We],ue);if(bs===null){Me===null&&(Me=fs);break}s&&Me&&bs.alternate===null&&t(F,Me),B=o(bs,B,We),vs===null?Ue=bs:vs.sibling=bs,vs=bs,Me=fs}if(We===K.length)return a(F,Me),js&&Va(F,We),Ue;if(Me===null){for(;We<K.length;We++)Me=he(F,K[We],ue),Me!==null&&(B=o(Me,B,We),vs===null?Ue=Me:vs.sibling=Me,vs=Me);return js&&Va(F,We),Ue}for(Me=l(Me);We<K.length;We++)fs=ae(Me,F,We,K[We],ue),fs!==null&&(s&&fs.alternate!==null&&Me.delete(fs.key===null?We:fs.key),B=o(fs,B,We),vs===null?Ue=fs:vs.sibling=fs,vs=fs);return s&&Me.forEach(function(Al){return t(F,Al)}),js&&Va(F,We),Ue}function $e(F,B,K,ue){if(K==null)throw Error(d(151));for(var Ue=null,vs=null,Me=B,We=B=0,fs=null,bs=K.next();Me!==null&&!bs.done;We++,bs=K.next()){Me.index>We?(fs=Me,Me=null):fs=Me.sibling;var Al=W(F,Me,bs.value,ue);if(Al===null){Me===null&&(Me=fs);break}s&&Me&&Al.alternate===null&&t(F,Me),B=o(Al,B,We),vs===null?Ue=Al:vs.sibling=Al,vs=Al,Me=fs}if(bs.done)return a(F,Me),js&&Va(F,We),Ue;if(Me===null){for(;!bs.done;We++,bs=K.next())bs=he(F,bs.value,ue),bs!==null&&(B=o(bs,B,We),vs===null?Ue=bs:vs.sibling=bs,vs=bs);return js&&Va(F,We),Ue}for(Me=l(Me);!bs.done;We++,bs=K.next())bs=ae(Me,F,We,bs.value,ue),bs!==null&&(s&&bs.alternate!==null&&Me.delete(bs.key===null?We:bs.key),B=o(bs,B,We),vs===null?Ue=bs:vs.sibling=bs,vs=bs);return s&&Me.forEach(function(Bb){return t(F,Bb)}),js&&Va(F,We),Ue}function zs(F,B,K,ue){if(typeof K=="object"&&K!==null&&K.type===L&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case k:e:{for(var Ue=K.key;B!==null;){if(B.key===Ue){if(Ue=K.type,Ue===L){if(B.tag===7){a(F,B.sibling),ue=c(B,K.props.children),ue.return=F,F=ue;break e}}else if(B.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===M&&Yl(Ue)===B.type){a(F,B.sibling),ue=c(B,K.props),_i(ue,K),ue.return=F,F=ue;break e}a(F,B);break}else t(F,B);B=B.sibling}K.type===L?(ue=Fl(K.props.children,F.mode,ue,K.key),ue.return=F,F=ue):(ue=Or(K.type,K.key,K.props,null,F.mode,ue),_i(ue,K),ue.return=F,F=ue)}return h(F);case _:e:{for(Ue=K.key;B!==null;){if(B.key===Ue)if(B.tag===4&&B.stateNode.containerInfo===K.containerInfo&&B.stateNode.implementation===K.implementation){a(F,B.sibling),ue=c(B,K.children||[]),ue.return=F,F=ue;break e}else{a(F,B);break}else t(F,B);B=B.sibling}ue=Uo(K,F.mode,ue),ue.return=F,F=ue}return h(F);case M:return K=Yl(K),zs(F,B,K,ue)}if(Se(K))return Ce(F,B,K,ue);if(Ne(K)){if(Ue=Ne(K),typeof Ue!="function")throw Error(d(150));return K=Ue.call(K),$e(F,B,K,ue)}if(typeof K.then=="function")return zs(F,B,Gr(K),ue);if(K.$$typeof===R)return zs(F,B,Ur(F,K),ue);Fr(F,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,B!==null&&B.tag===6?(a(F,B.sibling),ue=c(B,K),ue.return=F,F=ue):(a(F,B),ue=Lo(K,F.mode,ue),ue.return=F,F=ue),h(F)):a(F,B)}return function(F,B,K,ue){try{wi=0;var Ue=zs(F,B,K,ue);return zn=null,Ue}catch(Me){if(Me===En||Me===Hr)throw Me;var vs=Jt(29,Me,null,F.mode);return vs.lanes=ue,vs.return=F,vs}finally{}}}var Kl=mx(!0),xx=mx(!1),fl=!1;function Ko(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Jo(s,t){s=s.updateQueue,t.updateQueue===s&&(t.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,callbacks:null})}function pl(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function gl(s,t,a){var l=s.updateQueue;if(l===null)return null;if(l=l.shared,(ys&2)!==0){var c=l.pending;return c===null?t.next=t:(t.next=c.next,c.next=t),l.pending=t,t=Dr(s),Jm(s,null,a),t}return Ar(s,l,t,a),Dr(s)}function Si(s,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var l=t.lanes;l&=s.pendingLanes,a|=l,t.lanes=a,lm(s,a)}}function Po(s,t){var a=s.updateQueue,l=s.alternate;if(l!==null&&(l=l.updateQueue,a===l)){var c=null,o=null;if(a=a.firstBaseUpdate,a!==null){do{var h={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};o===null?c=o=h:o=o.next=h,a=a.next}while(a!==null);o===null?c=o=t:o=o.next=t}else c=o=t;a={baseState:l.baseState,firstBaseUpdate:c,lastBaseUpdate:o,shared:l.shared,callbacks:l.callbacks},s.updateQueue=a;return}s=a.lastBaseUpdate,s===null?a.firstBaseUpdate=t:s.next=t,a.lastBaseUpdate=t}var Zo=!1;function Ci(){if(Zo){var s=Tn;if(s!==null)throw s}}function ki(s,t,a,l){Zo=!1;var c=s.updateQueue;fl=!1;var o=c.firstBaseUpdate,h=c.lastBaseUpdate,b=c.shared.pending;if(b!==null){c.shared.pending=null;var A=b,J=A.next;A.next=null,h===null?o=J:h.next=J,h=A;var re=s.alternate;re!==null&&(re=re.updateQueue,b=re.lastBaseUpdate,b!==h&&(b===null?re.firstBaseUpdate=J:b.next=J,re.lastBaseUpdate=A))}if(o!==null){var he=c.baseState;h=0,re=J=A=null,b=o;do{var W=b.lane&-536870913,ae=W!==b.lane;if(ae?(hs&W)===W:(l&W)===W){W!==0&&W===kn&&(Zo=!0),re!==null&&(re=re.next={lane:0,tag:b.tag,payload:b.payload,callback:null,next:null});e:{var Ce=s,$e=b;W=t;var zs=a;switch($e.tag){case 1:if(Ce=$e.payload,typeof Ce=="function"){he=Ce.call(zs,he,W);break e}he=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=$e.payload,W=typeof Ce=="function"?Ce.call(zs,he,W):Ce,W==null)break e;he=w({},he,W);break e;case 2:fl=!0}}W=b.callback,W!==null&&(s.flags|=64,ae&&(s.flags|=8192),ae=c.callbacks,ae===null?c.callbacks=[W]:ae.push(W))}else ae={lane:W,tag:b.tag,payload:b.payload,callback:b.callback,next:null},re===null?(J=re=ae,A=he):re=re.next=ae,h|=W;if(b=b.next,b===null){if(b=c.shared.pending,b===null)break;ae=b,b=ae.next,ae.next=null,c.lastBaseUpdate=ae,c.shared.pending=null}}while(!0);re===null&&(A=he),c.baseState=A,c.firstBaseUpdate=J,c.lastBaseUpdate=re,o===null&&(c.shared.lanes=0),yl|=h,s.lanes=h,s.memoizedState=he}}function hx(s,t){if(typeof s!="function")throw Error(d(191,s));s.call(t)}function fx(s,t){var a=s.callbacks;if(a!==null)for(s.callbacks=null,s=0;s<a.length;s++)hx(a[s],t)}var Mn=X(null),Vr=X(0);function px(s,t){s=el,ce(Vr,s),ce(Mn,t),el=s|t.baseLanes}function Wo(){ce(Vr,el),ce(Mn,Mn.current)}function ed(){el=Vr.current,me(Mn),me(Vr)}var Pt=X(null),ua=null;function jl(s){var t=s.alternate;ce(nt,nt.current&1),ce(Pt,s),ua===null&&(t===null||Mn.current!==null||t.memoizedState!==null)&&(ua=s)}function sd(s){ce(nt,nt.current),ce(Pt,s),ua===null&&(ua=s)}function gx(s){s.tag===22?(ce(nt,nt.current),ce(Pt,s),ua===null&&(ua=s)):vl()}function vl(){ce(nt,nt.current),ce(Pt,Pt.current)}function Zt(s){me(Pt),ua===s&&(ua=null),me(nt)}var nt=X(0);function $r(s){for(var t=s;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||ru(a)||cu(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break;for(;t.sibling===null;){if(t.return===null||t.return===s)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Ia=0,Pe=null,Ts=null,mt=null,Qr=!1,An=!1,Jl=!1,Ir=0,Ti=0,Dn=null,Tv=0;function Zs(){throw Error(d(321))}function td(s,t){if(t===null)return!1;for(var a=0;a<t.length&&a<s.length;a++)if(!Kt(s[a],t[a]))return!1;return!0}function ad(s,t,a,l,c,o){return Ia=o,Pe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=s===null||s.memoizedState===null?eh:jd,Jl=!1,o=a(l,c),Jl=!1,An&&(o=vx(t,a,l,c)),jx(s),o}function jx(s){O.H=Mi;var t=Ts!==null&&Ts.next!==null;if(Ia=0,mt=Ts=Pe=null,Qr=!1,Ti=0,Dn=null,t)throw Error(d(300));s===null||xt||(s=s.dependencies,s!==null&&Lr(s)&&(xt=!0))}function vx(s,t,a,l){Pe=s;var c=0;do{if(An&&(Dn=null),Ti=0,An=!1,25<=c)throw Error(d(301));if(c+=1,mt=Ts=null,s.updateQueue!=null){var o=s.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}O.H=sh,o=t(a,l)}while(An);return o}function Ev(){var s=O.H,t=s.useState()[0];return t=typeof t.then=="function"?Ei(t):t,s=s.useState()[0],(Ts!==null?Ts.memoizedState:null)!==s&&(Pe.flags|=1024),t}function ld(){var s=Ir!==0;return Ir=0,s}function nd(s,t,a){t.updateQueue=s.updateQueue,t.flags&=-2053,s.lanes&=~a}function id(s){if(Qr){for(s=s.memoizedState;s!==null;){var t=s.queue;t!==null&&(t.pending=null),s=s.next}Qr=!1}Ia=0,mt=Ts=Pe=null,An=!1,Ti=Ir=0,Dn=null}function Ot(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mt===null?Pe.memoizedState=mt=s:mt=mt.next=s,mt}function it(){if(Ts===null){var s=Pe.alternate;s=s!==null?s.memoizedState:null}else s=Ts.next;var t=mt===null?Pe.memoizedState:mt.next;if(t!==null)mt=t,Ts=s;else{if(s===null)throw Pe.alternate===null?Error(d(467)):Error(d(310));Ts=s,s={memoizedState:Ts.memoizedState,baseState:Ts.baseState,baseQueue:Ts.baseQueue,queue:Ts.queue,next:null},mt===null?Pe.memoizedState=mt=s:mt=mt.next=s}return mt}function Yr(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ei(s){var t=Ti;return Ti+=1,Dn===null&&(Dn=[]),s=ox(Dn,s,t),t=Pe,(mt===null?t.memoizedState:mt.next)===null&&(t=t.alternate,O.H=t===null||t.memoizedState===null?eh:jd),s}function Xr(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Ei(s);if(s.$$typeof===R)return kt(s)}throw Error(d(438,String(s)))}function rd(s){var t=null,a=Pe.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var l=Pe.alternate;l!==null&&(l=l.updateQueue,l!==null&&(l=l.memoCache,l!=null&&(t={data:l.data.map(function(c){return c.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=Yr(),Pe.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(s),l=0;l<s;l++)a[l]=fe;return t.index++,a}function Ya(s,t){return typeof t=="function"?t(s):t}function Kr(s){var t=it();return cd(t,Ts,s)}function cd(s,t,a){var l=s.queue;if(l===null)throw Error(d(311));l.lastRenderedReducer=a;var c=s.baseQueue,o=l.pending;if(o!==null){if(c!==null){var h=c.next;c.next=o.next,o.next=h}t.baseQueue=c=o,l.pending=null}if(o=s.baseState,c===null)s.memoizedState=o;else{t=c.next;var b=h=null,A=null,J=t,re=!1;do{var he=J.lane&-536870913;if(he!==J.lane?(hs&he)===he:(Ia&he)===he){var W=J.revertLane;if(W===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null}),he===kn&&(re=!0);else if((Ia&W)===W){J=J.next,W===kn&&(re=!0);continue}else he={lane:0,revertLane:J.revertLane,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},A===null?(b=A=he,h=o):A=A.next=he,Pe.lanes|=W,yl|=W;he=J.action,Jl&&a(o,he),o=J.hasEagerState?J.eagerState:a(o,he)}else W={lane:he,revertLane:J.revertLane,gesture:J.gesture,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},A===null?(b=A=W,h=o):A=A.next=W,Pe.lanes|=he,yl|=he;J=J.next}while(J!==null&&J!==t);if(A===null?h=o:A.next=b,!Kt(o,s.memoizedState)&&(xt=!0,re&&(a=Tn,a!==null)))throw a;s.memoizedState=o,s.baseState=h,s.baseQueue=A,l.lastRenderedState=o}return c===null&&(l.lanes=0),[s.memoizedState,l.dispatch]}function od(s){var t=it(),a=t.queue;if(a===null)throw Error(d(311));a.lastRenderedReducer=s;var l=a.dispatch,c=a.pending,o=t.memoizedState;if(c!==null){a.pending=null;var h=c=c.next;do o=s(o,h.action),h=h.next;while(h!==c);Kt(o,t.memoizedState)||(xt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),a.lastRenderedState=o}return[o,l]}function bx(s,t,a){var l=Pe,c=it(),o=js;if(o){if(a===void 0)throw Error(d(407));a=a()}else a=t();var h=!Kt((Ts||c).memoizedState,a);if(h&&(c.memoizedState=a,xt=!0),c=c.queue,md(wx.bind(null,l,c,s),[s]),c.getSnapshot!==t||h||mt!==null&&mt.memoizedState.tag&1){if(l.flags|=2048,On(9,{destroy:void 0},yx.bind(null,l,c,a,t),null),Os===null)throw Error(d(349));o||(Ia&127)!==0||Nx(l,t,a)}return a}function Nx(s,t,a){s.flags|=16384,s={getSnapshot:t,value:a},t=Pe.updateQueue,t===null?(t=Yr(),Pe.updateQueue=t,t.stores=[s]):(a=t.stores,a===null?t.stores=[s]:a.push(s))}function yx(s,t,a,l){t.value=a,t.getSnapshot=l,_x(t)&&Sx(s)}function wx(s,t,a){return a(function(){_x(t)&&Sx(s)})}function _x(s){var t=s.getSnapshot;s=s.value;try{var a=t();return!Kt(s,a)}catch{return!0}}function Sx(s){var t=Gl(s,2);t!==null&&Vt(t,s,2)}function dd(s){var t=Ot();if(typeof s=="function"){var a=s;if(s=a(),Jl){_s(!0);try{a()}finally{_s(!1)}}}return t.memoizedState=t.baseState=s,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ya,lastRenderedState:s},t}function Cx(s,t,a,l){return s.baseState=a,cd(s,Ts,typeof l=="function"?l:Ya)}function zv(s,t,a,l,c){if(Zr(s))throw Error(d(485));if(s=t.action,s!==null){var o={payload:c,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(h){o.listeners.push(h)}};O.T!==null?a(!0):o.isTransition=!1,l(o),a=t.pending,a===null?(o.next=t.pending=o,kx(t,o)):(o.next=a.next,t.pending=a.next=o)}}function kx(s,t){var a=t.action,l=t.payload,c=s.state;if(t.isTransition){var o=O.T,h={};O.T=h;try{var b=a(c,l),A=O.S;A!==null&&A(h,b),Tx(s,t,b)}catch(J){ud(s,t,J)}finally{o!==null&&h.types!==null&&(o.types=h.types),O.T=o}}else try{o=a(c,l),Tx(s,t,o)}catch(J){ud(s,t,J)}}function Tx(s,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(l){Ex(s,t,l)},function(l){return ud(s,t,l)}):Ex(s,t,a)}function Ex(s,t,a){t.status="fulfilled",t.value=a,zx(t),s.state=a,t=s.pending,t!==null&&(a=t.next,a===t?s.pending=null:(a=a.next,t.next=a,kx(s,a)))}function ud(s,t,a){var l=s.pending;if(s.pending=null,l!==null){l=l.next;do t.status="rejected",t.reason=a,zx(t),t=t.next;while(t!==l)}s.action=null}function zx(s){s=s.listeners;for(var t=0;t<s.length;t++)(0,s[t])()}function Mx(s,t){return t}function Ax(s,t){if(js){var a=Os.formState;if(a!==null){e:{var l=Pe;if(js){if(Vs){s:{for(var c=Vs,o=da;c.nodeType!==8;){if(!o){c=null;break s}if(c=ma(c.nextSibling),c===null){c=null;break s}}o=c.data,c=o==="F!"||o==="F"?c:null}if(c){Vs=ma(c.nextSibling),l=c.data==="F!";break e}}xl(l)}l=!1}l&&(t=a[0])}}return a=Ot(),a.memoizedState=a.baseState=t,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mx,lastRenderedState:t},a.queue=l,a=Px.bind(null,Pe,l),l.dispatch=a,l=dd(!1),o=gd.bind(null,Pe,!1,l.queue),l=Ot(),c={state:t,dispatch:null,action:s,pending:null},l.queue=c,a=zv.bind(null,Pe,c,o,a),c.dispatch=a,l.memoizedState=s,[t,a,!1]}function Dx(s){var t=it();return Ox(t,Ts,s)}function Ox(s,t,a){if(t=cd(s,t,Mx)[0],s=Kr(Ya)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var l=Ei(t)}catch(h){throw h===En?Hr:h}else l=t;t=it();var c=t.queue,o=c.dispatch;return a!==t.memoizedState&&(Pe.flags|=2048,On(9,{destroy:void 0},Mv.bind(null,c,a),null)),[l,o,s]}function Mv(s,t){s.action=t}function Rx(s){var t=it(),a=Ts;if(a!==null)return Ox(t,a,s);it(),t=t.memoizedState,a=it();var l=a.queue.dispatch;return a.memoizedState=s,[t,l,!1]}function On(s,t,a,l){return s={tag:s,create:a,deps:l,inst:t,next:null},t=Pe.updateQueue,t===null&&(t=Yr(),Pe.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=s.next=s:(l=a.next,a.next=s,s.next=l,t.lastEffect=s),s}function Lx(){return it().memoizedState}function Jr(s,t,a,l){var c=Ot();Pe.flags|=s,c.memoizedState=On(1|t,{destroy:void 0},a,l===void 0?null:l)}function Pr(s,t,a,l){var c=it();l=l===void 0?null:l;var o=c.memoizedState.inst;Ts!==null&&l!==null&&td(l,Ts.memoizedState.deps)?c.memoizedState=On(t,o,a,l):(Pe.flags|=s,c.memoizedState=On(1|t,o,a,l))}function Ux(s,t){Jr(8390656,8,s,t)}function md(s,t){Pr(2048,8,s,t)}function Av(s){Pe.flags|=4;var t=Pe.updateQueue;if(t===null)t=Yr(),Pe.updateQueue=t,t.events=[s];else{var a=t.events;a===null?t.events=[s]:a.push(s)}}function Bx(s){var t=it().memoizedState;return Av({ref:t,nextImpl:s}),function(){if((ys&2)!==0)throw Error(d(440));return t.impl.apply(void 0,arguments)}}function Hx(s,t){return Pr(4,2,s,t)}function qx(s,t){return Pr(4,4,s,t)}function Gx(s,t){if(typeof t=="function"){s=s();var a=t(s);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return s=s(),t.current=s,function(){t.current=null}}function Fx(s,t,a){a=a!=null?a.concat([s]):null,Pr(4,4,Gx.bind(null,t,s),a)}function xd(){}function Vx(s,t){var a=it();t=t===void 0?null:t;var l=a.memoizedState;return t!==null&&td(t,l[1])?l[0]:(a.memoizedState=[s,t],s)}function $x(s,t){var a=it();t=t===void 0?null:t;var l=a.memoizedState;if(t!==null&&td(t,l[1]))return l[0];if(l=s(),Jl){_s(!0);try{s()}finally{_s(!1)}}return a.memoizedState=[l,t],l}function hd(s,t,a){return a===void 0||(Ia&1073741824)!==0&&(hs&261930)===0?s.memoizedState=t:(s.memoizedState=a,s=Qh(),Pe.lanes|=s,yl|=s,a)}function Qx(s,t,a,l){return Kt(a,t)?a:Mn.current!==null?(s=hd(s,a,l),Kt(s,t)||(xt=!0),s):(Ia&42)===0||(Ia&1073741824)!==0&&(hs&261930)===0?(xt=!0,s.memoizedState=a):(s=Qh(),Pe.lanes|=s,yl|=s,t)}function Ix(s,t,a,l,c){var o=G.p;G.p=o!==0&&8>o?o:8;var h=O.T,b={};O.T=b,gd(s,!1,t,a);try{var A=c(),J=O.S;if(J!==null&&J(b,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var re=kv(A,l);zi(s,t,re,sa(s))}else zi(s,t,l,sa(s))}catch(he){zi(s,t,{then:function(){},status:"rejected",reason:he},sa())}finally{G.p=o,h!==null&&b.types!==null&&(h.types=b.types),O.T=h}}function Dv(){}function fd(s,t,a,l){if(s.tag!==5)throw Error(d(476));var c=Yx(s).queue;Ix(s,c,t,H,a===null?Dv:function(){return Xx(s),a(l)})}function Yx(s){var t=s.memoizedState;if(t!==null)return t;t={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ya,lastRenderedState:H},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ya,lastRenderedState:a},next:null},s.memoizedState=t,s=s.alternate,s!==null&&(s.memoizedState=t),t}function Xx(s){var t=Yx(s);t.next===null&&(t=s.alternate.memoizedState),zi(s,t.next.queue,{},sa())}function pd(){return kt(Yi)}function Kx(){return it().memoizedState}function Jx(){return it().memoizedState}function Ov(s){for(var t=s.return;t!==null;){switch(t.tag){case 24:case 3:var a=sa();s=pl(a);var l=gl(t,s,a);l!==null&&(Vt(l,t,a),Si(l,t,a)),t={cache:Qo()},s.payload=t;return}t=t.return}}function Rv(s,t,a){var l=sa();a={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Zr(s)?Zx(t,a):(a=Oo(s,t,a,l),a!==null&&(Vt(a,s,l),Wx(a,t,l)))}function Px(s,t,a){var l=sa();zi(s,t,a,l)}function zi(s,t,a,l){var c={lane:l,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Zr(s))Zx(t,c);else{var o=s.alternate;if(s.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var h=t.lastRenderedState,b=o(h,a);if(c.hasEagerState=!0,c.eagerState=b,Kt(b,h))return Ar(s,t,c,0),Os===null&&Mr(),!1}catch{}finally{}if(a=Oo(s,t,c,l),a!==null)return Vt(a,s,l),Wx(a,t,l),!0}return!1}function gd(s,t,a,l){if(l={lane:2,revertLane:Kd(),gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Zr(s)){if(t)throw Error(d(479))}else t=Oo(s,a,l,2),t!==null&&Vt(t,s,2)}function Zr(s){var t=s.alternate;return s===Pe||t!==null&&t===Pe}function Zx(s,t){An=Qr=!0;var a=s.pending;a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t}function Wx(s,t,a){if((a&4194048)!==0){var l=t.lanes;l&=s.pendingLanes,a|=l,t.lanes=a,lm(s,a)}}var Mi={readContext:kt,use:Xr,useCallback:Zs,useContext:Zs,useEffect:Zs,useImperativeHandle:Zs,useLayoutEffect:Zs,useInsertionEffect:Zs,useMemo:Zs,useReducer:Zs,useRef:Zs,useState:Zs,useDebugValue:Zs,useDeferredValue:Zs,useTransition:Zs,useSyncExternalStore:Zs,useId:Zs,useHostTransitionStatus:Zs,useFormState:Zs,useActionState:Zs,useOptimistic:Zs,useMemoCache:Zs,useCacheRefresh:Zs};Mi.useEffectEvent=Zs;var eh={readContext:kt,use:Xr,useCallback:function(s,t){return Ot().memoizedState=[s,t===void 0?null:t],s},useContext:kt,useEffect:Ux,useImperativeHandle:function(s,t,a){a=a!=null?a.concat([s]):null,Jr(4194308,4,Gx.bind(null,t,s),a)},useLayoutEffect:function(s,t){return Jr(4194308,4,s,t)},useInsertionEffect:function(s,t){Jr(4,2,s,t)},useMemo:function(s,t){var a=Ot();t=t===void 0?null:t;var l=s();if(Jl){_s(!0);try{s()}finally{_s(!1)}}return a.memoizedState=[l,t],l},useReducer:function(s,t,a){var l=Ot();if(a!==void 0){var c=a(t);if(Jl){_s(!0);try{a(t)}finally{_s(!1)}}}else c=t;return l.memoizedState=l.baseState=c,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:c},l.queue=s,s=s.dispatch=Rv.bind(null,Pe,s),[l.memoizedState,s]},useRef:function(s){var t=Ot();return s={current:s},t.memoizedState=s},useState:function(s){s=dd(s);var t=s.queue,a=Px.bind(null,Pe,t);return t.dispatch=a,[s.memoizedState,a]},useDebugValue:xd,useDeferredValue:function(s,t){var a=Ot();return hd(a,s,t)},useTransition:function(){var s=dd(!1);return s=Ix.bind(null,Pe,s.queue,!0,!1),Ot().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,t,a){var l=Pe,c=Ot();if(js){if(a===void 0)throw Error(d(407));a=a()}else{if(a=t(),Os===null)throw Error(d(349));(hs&127)!==0||Nx(l,t,a)}c.memoizedState=a;var o={value:a,getSnapshot:t};return c.queue=o,Ux(wx.bind(null,l,o,s),[s]),l.flags|=2048,On(9,{destroy:void 0},yx.bind(null,l,o,a,t),null),a},useId:function(){var s=Ot(),t=Os.identifierPrefix;if(js){var a=Ea,l=Ta;a=(l&~(1<<32-Ae(l)-1)).toString(32)+a,t="_"+t+"R_"+a,a=Ir++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=Tv++,t="_"+t+"r_"+a.toString(32)+"_";return s.memoizedState=t},useHostTransitionStatus:pd,useFormState:Ax,useActionState:Ax,useOptimistic:function(s){var t=Ot();t.memoizedState=t.baseState=s;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=gd.bind(null,Pe,!0,a),a.dispatch=t,[s,t]},useMemoCache:rd,useCacheRefresh:function(){return Ot().memoizedState=Ov.bind(null,Pe)},useEffectEvent:function(s){var t=Ot(),a={impl:s};return t.memoizedState=a,function(){if((ys&2)!==0)throw Error(d(440));return a.impl.apply(void 0,arguments)}}},jd={readContext:kt,use:Xr,useCallback:Vx,useContext:kt,useEffect:md,useImperativeHandle:Fx,useInsertionEffect:Hx,useLayoutEffect:qx,useMemo:$x,useReducer:Kr,useRef:Lx,useState:function(){return Kr(Ya)},useDebugValue:xd,useDeferredValue:function(s,t){var a=it();return Qx(a,Ts.memoizedState,s,t)},useTransition:function(){var s=Kr(Ya)[0],t=it().memoizedState;return[typeof s=="boolean"?s:Ei(s),t]},useSyncExternalStore:bx,useId:Kx,useHostTransitionStatus:pd,useFormState:Dx,useActionState:Dx,useOptimistic:function(s,t){var a=it();return Cx(a,Ts,s,t)},useMemoCache:rd,useCacheRefresh:Jx};jd.useEffectEvent=Bx;var sh={readContext:kt,use:Xr,useCallback:Vx,useContext:kt,useEffect:md,useImperativeHandle:Fx,useInsertionEffect:Hx,useLayoutEffect:qx,useMemo:$x,useReducer:od,useRef:Lx,useState:function(){return od(Ya)},useDebugValue:xd,useDeferredValue:function(s,t){var a=it();return Ts===null?hd(a,s,t):Qx(a,Ts.memoizedState,s,t)},useTransition:function(){var s=od(Ya)[0],t=it().memoizedState;return[typeof s=="boolean"?s:Ei(s),t]},useSyncExternalStore:bx,useId:Kx,useHostTransitionStatus:pd,useFormState:Rx,useActionState:Rx,useOptimistic:function(s,t){var a=it();return Ts!==null?Cx(a,Ts,s,t):(a.baseState=s,[s,a.queue.dispatch])},useMemoCache:rd,useCacheRefresh:Jx};sh.useEffectEvent=Bx;function vd(s,t,a,l){t=s.memoizedState,a=a(l,t),a=a==null?t:w({},t,a),s.memoizedState=a,s.lanes===0&&(s.updateQueue.baseState=a)}var bd={enqueueSetState:function(s,t,a){s=s._reactInternals;var l=sa(),c=pl(l);c.payload=t,a!=null&&(c.callback=a),t=gl(s,c,l),t!==null&&(Vt(t,s,l),Si(t,s,l))},enqueueReplaceState:function(s,t,a){s=s._reactInternals;var l=sa(),c=pl(l);c.tag=1,c.payload=t,a!=null&&(c.callback=a),t=gl(s,c,l),t!==null&&(Vt(t,s,l),Si(t,s,l))},enqueueForceUpdate:function(s,t){s=s._reactInternals;var a=sa(),l=pl(a);l.tag=2,t!=null&&(l.callback=t),t=gl(s,l,a),t!==null&&(Vt(t,s,a),Si(t,s,a))}};function th(s,t,a,l,c,o,h){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(l,o,h):t.prototype&&t.prototype.isPureReactComponent?!gi(a,l)||!gi(c,o):!0}function ah(s,t,a,l){s=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,l),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,l),t.state!==s&&bd.enqueueReplaceState(t,t.state,null)}function Pl(s,t){var a=t;if("ref"in t){a={};for(var l in t)l!=="ref"&&(a[l]=t[l])}if(s=s.defaultProps){a===t&&(a=w({},a));for(var c in s)a[c]===void 0&&(a[c]=s[c])}return a}function lh(s){zr(s)}function nh(s){console.error(s)}function ih(s){zr(s)}function Wr(s,t){try{var a=s.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(l){setTimeout(function(){throw l})}}function rh(s,t,a){try{var l=s.onCaughtError;l(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(c){setTimeout(function(){throw c})}}function Nd(s,t,a){return a=pl(a),a.tag=3,a.payload={element:null},a.callback=function(){Wr(s,t)},a}function ch(s){return s=pl(s),s.tag=3,s}function oh(s,t,a,l){var c=a.type.getDerivedStateFromError;if(typeof c=="function"){var o=l.value;s.payload=function(){return c(o)},s.callback=function(){rh(t,a,l)}}var h=a.stateNode;h!==null&&typeof h.componentDidCatch=="function"&&(s.callback=function(){rh(t,a,l),typeof c!="function"&&(wl===null?wl=new Set([this]):wl.add(this));var b=l.stack;this.componentDidCatch(l.value,{componentStack:b!==null?b:""})})}function Lv(s,t,a,l,c){if(a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){if(t=a.alternate,t!==null&&Cn(t,a,c,!0),a=Pt.current,a!==null){switch(a.tag){case 31:case 13:return ua===null?uc():a.alternate===null&&Ws===0&&(Ws=3),a.flags&=-257,a.flags|=65536,a.lanes=c,l===qr?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([l]):t.add(l),Id(s,l,c)),!1;case 22:return a.flags|=65536,l===qr?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([l])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([l]):a.add(l)),Id(s,l,c)),!1}throw Error(d(435,a.tag))}return Id(s,l,c),uc(),!1}if(js)return t=Pt.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=c,l!==qo&&(s=Error(d(422),{cause:l}),bi(ra(s,a)))):(l!==qo&&(t=Error(d(423),{cause:l}),bi(ra(t,a))),s=s.current.alternate,s.flags|=65536,c&=-c,s.lanes|=c,l=ra(l,a),c=Nd(s.stateNode,l,c),Po(s,c),Ws!==4&&(Ws=2)),!1;var o=Error(d(520),{cause:l});if(o=ra(o,a),Hi===null?Hi=[o]:Hi.push(o),Ws!==4&&(Ws=2),t===null)return!0;l=ra(l,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,s=c&-c,a.lanes|=s,s=Nd(a.stateNode,l,s),Po(a,s),!1;case 1:if(t=a.type,o=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(wl===null||!wl.has(o))))return a.flags|=65536,c&=-c,a.lanes|=c,c=ch(c),oh(c,s,a,l),Po(a,c),!1}a=a.return}while(a!==null);return!1}var yd=Error(d(461)),xt=!1;function Tt(s,t,a,l){t.child=s===null?xx(t,null,a,l):Kl(t,s.child,a,l)}function dh(s,t,a,l,c){a=a.render;var o=t.ref;if("ref"in l){var h={};for(var b in l)b!=="ref"&&(h[b]=l[b])}else h=l;return Ql(t),l=ad(s,t,a,h,o,c),b=ld(),s!==null&&!xt?(nd(s,t,c),Xa(s,t,c)):(js&&b&&Bo(t),t.flags|=1,Tt(s,t,l,c),t.child)}function uh(s,t,a,l,c){if(s===null){var o=a.type;return typeof o=="function"&&!Ro(o)&&o.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=o,mh(s,t,o,l,c)):(s=Or(a.type,null,l,t,t.mode,c),s.ref=t.ref,s.return=t,t.child=s)}if(o=s.child,!zd(s,c)){var h=o.memoizedProps;if(a=a.compare,a=a!==null?a:gi,a(h,l)&&s.ref===t.ref)return Xa(s,t,c)}return t.flags|=1,s=Fa(o,l),s.ref=t.ref,s.return=t,t.child=s}function mh(s,t,a,l,c){if(s!==null){var o=s.memoizedProps;if(gi(o,l)&&s.ref===t.ref)if(xt=!1,t.pendingProps=l=o,zd(s,c))(s.flags&131072)!==0&&(xt=!0);else return t.lanes=s.lanes,Xa(s,t,c)}return wd(s,t,a,l,c)}function xh(s,t,a,l){var c=l.children,o=s!==null?s.memoizedState:null;if(s===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),l.mode==="hidden"){if((t.flags&128)!==0){if(o=o!==null?o.baseLanes|a:a,s!==null){for(l=t.child=s.child,c=0;l!==null;)c=c|l.lanes|l.childLanes,l=l.sibling;l=c&~o}else l=0,t.child=null;return hh(s,t,o,a,l)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},s!==null&&Br(t,o!==null?o.cachePool:null),o!==null?px(t,o):Wo(),gx(t);else return l=t.lanes=536870912,hh(s,t,o!==null?o.baseLanes|a:a,a,l)}else o!==null?(Br(t,o.cachePool),px(t,o),vl(),t.memoizedState=null):(s!==null&&Br(t,null),Wo(),vl());return Tt(s,t,c,a),t.child}function Ai(s,t){return s!==null&&s.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function hh(s,t,a,l,c){var o=Yo();return o=o===null?null:{parent:ut._currentValue,pool:o},t.memoizedState={baseLanes:a,cachePool:o},s!==null&&Br(t,null),Wo(),gx(t),s!==null&&Cn(s,t,l,!0),t.childLanes=c,null}function ec(s,t){return t=tc({mode:t.mode,children:t.children},s.mode),t.ref=s.ref,s.child=t,t.return=s,t}function fh(s,t,a){return Kl(t,s.child,null,a),s=ec(t,t.pendingProps),s.flags|=2,Zt(t),t.memoizedState=null,s}function Uv(s,t,a){var l=t.pendingProps,c=(t.flags&128)!==0;if(t.flags&=-129,s===null){if(js){if(l.mode==="hidden")return s=ec(t,l),t.lanes=536870912,Ai(null,s);if(sd(t),(s=Vs)?(s=Tf(s,da),s=s!==null&&s.data==="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:ul!==null?{id:Ta,overflow:Ea}:null,retryLane:536870912,hydrationErrors:null},a=Zm(s),a.return=t,t.child=a,Ct=t,Vs=null)):s=null,s===null)throw xl(t);return t.lanes=536870912,null}return ec(t,l)}var o=s.memoizedState;if(o!==null){var h=o.dehydrated;if(sd(t),c)if(t.flags&256)t.flags&=-257,t=fh(s,t,a);else if(t.memoizedState!==null)t.child=s.child,t.flags|=128,t=null;else throw Error(d(558));else if(xt||Cn(s,t,a,!1),c=(a&s.childLanes)!==0,xt||c){if(l=Os,l!==null&&(h=nm(l,a),h!==0&&h!==o.retryLane))throw o.retryLane=h,Gl(s,h),Vt(l,s,h),yd;uc(),t=fh(s,t,a)}else s=o.treeContext,Vs=ma(h.nextSibling),Ct=t,js=!0,ml=null,da=!1,s!==null&&sx(t,s),t=ec(t,l),t.flags|=4096;return t}return s=Fa(s.child,{mode:l.mode,children:l.children}),s.ref=t.ref,t.child=s,s.return=t,s}function sc(s,t){var a=t.ref;if(a===null)s!==null&&s.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(d(284));(s===null||s.ref!==a)&&(t.flags|=4194816)}}function wd(s,t,a,l,c){return Ql(t),a=ad(s,t,a,l,void 0,c),l=ld(),s!==null&&!xt?(nd(s,t,c),Xa(s,t,c)):(js&&l&&Bo(t),t.flags|=1,Tt(s,t,a,c),t.child)}function ph(s,t,a,l,c,o){return Ql(t),t.updateQueue=null,a=vx(t,l,a,c),jx(s),l=ld(),s!==null&&!xt?(nd(s,t,o),Xa(s,t,o)):(js&&l&&Bo(t),t.flags|=1,Tt(s,t,a,o),t.child)}function gh(s,t,a,l,c){if(Ql(t),t.stateNode===null){var o=yn,h=a.contextType;typeof h=="object"&&h!==null&&(o=kt(h)),o=new a(l,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=bd,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=l,o.state=t.memoizedState,o.refs={},Ko(t),h=a.contextType,o.context=typeof h=="object"&&h!==null?kt(h):yn,o.state=t.memoizedState,h=a.getDerivedStateFromProps,typeof h=="function"&&(vd(t,a,h,l),o.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(h=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),h!==o.state&&bd.enqueueReplaceState(o,o.state,null),ki(t,l,o,c),Ci(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),l=!0}else if(s===null){o=t.stateNode;var b=t.memoizedProps,A=Pl(a,b);o.props=A;var J=o.context,re=a.contextType;h=yn,typeof re=="object"&&re!==null&&(h=kt(re));var he=a.getDerivedStateFromProps;re=typeof he=="function"||typeof o.getSnapshotBeforeUpdate=="function",b=t.pendingProps!==b,re||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(b||J!==h)&&ah(t,o,l,h),fl=!1;var W=t.memoizedState;o.state=W,ki(t,l,o,c),Ci(),J=t.memoizedState,b||W!==J||fl?(typeof he=="function"&&(vd(t,a,he,l),J=t.memoizedState),(A=fl||th(t,a,A,l,W,J,h))?(re||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=l,t.memoizedState=J),o.props=l,o.state=J,o.context=h,l=A):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),l=!1)}else{o=t.stateNode,Jo(s,t),h=t.memoizedProps,re=Pl(a,h),o.props=re,he=t.pendingProps,W=o.context,J=a.contextType,A=yn,typeof J=="object"&&J!==null&&(A=kt(J)),b=a.getDerivedStateFromProps,(J=typeof b=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(h!==he||W!==A)&&ah(t,o,l,A),fl=!1,W=t.memoizedState,o.state=W,ki(t,l,o,c),Ci();var ae=t.memoizedState;h!==he||W!==ae||fl||s!==null&&s.dependencies!==null&&Lr(s.dependencies)?(typeof b=="function"&&(vd(t,a,b,l),ae=t.memoizedState),(re=fl||th(t,a,re,l,W,ae,A)||s!==null&&s.dependencies!==null&&Lr(s.dependencies))?(J||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(l,ae,A),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(l,ae,A)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||h===s.memoizedProps&&W===s.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||h===s.memoizedProps&&W===s.memoizedState||(t.flags|=1024),t.memoizedProps=l,t.memoizedState=ae),o.props=l,o.state=ae,o.context=A,l=re):(typeof o.componentDidUpdate!="function"||h===s.memoizedProps&&W===s.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||h===s.memoizedProps&&W===s.memoizedState||(t.flags|=1024),l=!1)}return o=l,sc(s,t),l=(t.flags&128)!==0,o||l?(o=t.stateNode,a=l&&typeof a.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,s!==null&&l?(t.child=Kl(t,s.child,null,c),t.child=Kl(t,null,a,c)):Tt(s,t,a,c),t.memoizedState=o.state,s=t.child):s=Xa(s,t,c),s}function jh(s,t,a,l){return Vl(),t.flags|=256,Tt(s,t,a,l),t.child}var _d={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Sd(s){return{baseLanes:s,cachePool:rx()}}function Cd(s,t,a){return s=s!==null?s.childLanes&~a:0,t&&(s|=ea),s}function vh(s,t,a){var l=t.pendingProps,c=!1,o=(t.flags&128)!==0,h;if((h=o)||(h=s!==null&&s.memoizedState===null?!1:(nt.current&2)!==0),h&&(c=!0,t.flags&=-129),h=(t.flags&32)!==0,t.flags&=-33,s===null){if(js){if(c?jl(t):vl(),(s=Vs)?(s=Tf(s,da),s=s!==null&&s.data!=="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:ul!==null?{id:Ta,overflow:Ea}:null,retryLane:536870912,hydrationErrors:null},a=Zm(s),a.return=t,t.child=a,Ct=t,Vs=null)):s=null,s===null)throw xl(t);return cu(s)?t.lanes=32:t.lanes=536870912,null}var b=l.children;return l=l.fallback,c?(vl(),c=t.mode,b=tc({mode:"hidden",children:b},c),l=Fl(l,c,a,null),b.return=t,l.return=t,b.sibling=l,t.child=b,l=t.child,l.memoizedState=Sd(a),l.childLanes=Cd(s,h,a),t.memoizedState=_d,Ai(null,l)):(jl(t),kd(t,b))}var A=s.memoizedState;if(A!==null&&(b=A.dehydrated,b!==null)){if(o)t.flags&256?(jl(t),t.flags&=-257,t=Td(s,t,a)):t.memoizedState!==null?(vl(),t.child=s.child,t.flags|=128,t=null):(vl(),b=l.fallback,c=t.mode,l=tc({mode:"visible",children:l.children},c),b=Fl(b,c,a,null),b.flags|=2,l.return=t,b.return=t,l.sibling=b,t.child=l,Kl(t,s.child,null,a),l=t.child,l.memoizedState=Sd(a),l.childLanes=Cd(s,h,a),t.memoizedState=_d,t=Ai(null,l));else if(jl(t),cu(b)){if(h=b.nextSibling&&b.nextSibling.dataset,h)var J=h.dgst;h=J,l=Error(d(419)),l.stack="",l.digest=h,bi({value:l,source:null,stack:null}),t=Td(s,t,a)}else if(xt||Cn(s,t,a,!1),h=(a&s.childLanes)!==0,xt||h){if(h=Os,h!==null&&(l=nm(h,a),l!==0&&l!==A.retryLane))throw A.retryLane=l,Gl(s,l),Vt(h,s,l),yd;ru(b)||uc(),t=Td(s,t,a)}else ru(b)?(t.flags|=192,t.child=s.child,t=null):(s=A.treeContext,Vs=ma(b.nextSibling),Ct=t,js=!0,ml=null,da=!1,s!==null&&sx(t,s),t=kd(t,l.children),t.flags|=4096);return t}return c?(vl(),b=l.fallback,c=t.mode,A=s.child,J=A.sibling,l=Fa(A,{mode:"hidden",children:l.children}),l.subtreeFlags=A.subtreeFlags&65011712,J!==null?b=Fa(J,b):(b=Fl(b,c,a,null),b.flags|=2),b.return=t,l.return=t,l.sibling=b,t.child=l,Ai(null,l),l=t.child,b=s.child.memoizedState,b===null?b=Sd(a):(c=b.cachePool,c!==null?(A=ut._currentValue,c=c.parent!==A?{parent:A,pool:A}:c):c=rx(),b={baseLanes:b.baseLanes|a,cachePool:c}),l.memoizedState=b,l.childLanes=Cd(s,h,a),t.memoizedState=_d,Ai(s.child,l)):(jl(t),a=s.child,s=a.sibling,a=Fa(a,{mode:"visible",children:l.children}),a.return=t,a.sibling=null,s!==null&&(h=t.deletions,h===null?(t.deletions=[s],t.flags|=16):h.push(s)),t.child=a,t.memoizedState=null,a)}function kd(s,t){return t=tc({mode:"visible",children:t},s.mode),t.return=s,s.child=t}function tc(s,t){return s=Jt(22,s,null,t),s.lanes=0,s}function Td(s,t,a){return Kl(t,s.child,null,a),s=kd(t,t.pendingProps.children),s.flags|=2,t.memoizedState=null,s}function bh(s,t,a){s.lanes|=t;var l=s.alternate;l!==null&&(l.lanes|=t),Vo(s.return,t,a)}function Ed(s,t,a,l,c,o){var h=s.memoizedState;h===null?s.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:l,tail:a,tailMode:c,treeForkCount:o}:(h.isBackwards=t,h.rendering=null,h.renderingStartTime=0,h.last=l,h.tail=a,h.tailMode=c,h.treeForkCount=o)}function Nh(s,t,a){var l=t.pendingProps,c=l.revealOrder,o=l.tail;l=l.children;var h=nt.current,b=(h&2)!==0;if(b?(h=h&1|2,t.flags|=128):h&=1,ce(nt,h),Tt(s,t,l,a),l=js?vi:0,!b&&s!==null&&(s.flags&128)!==0)e:for(s=t.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&bh(s,a,t);else if(s.tag===19)bh(s,a,t);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(c){case"forwards":for(a=t.child,c=null;a!==null;)s=a.alternate,s!==null&&$r(s)===null&&(c=a),a=a.sibling;a=c,a===null?(c=t.child,t.child=null):(c=a.sibling,a.sibling=null),Ed(t,!1,c,a,o,l);break;case"backwards":case"unstable_legacy-backwards":for(a=null,c=t.child,t.child=null;c!==null;){if(s=c.alternate,s!==null&&$r(s)===null){t.child=c;break}s=c.sibling,c.sibling=a,a=c,c=s}Ed(t,!0,a,null,o,l);break;case"together":Ed(t,!1,null,null,void 0,l);break;default:t.memoizedState=null}return t.child}function Xa(s,t,a){if(s!==null&&(t.dependencies=s.dependencies),yl|=t.lanes,(a&t.childLanes)===0)if(s!==null){if(Cn(s,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(s!==null&&t.child!==s.child)throw Error(d(153));if(t.child!==null){for(s=t.child,a=Fa(s,s.pendingProps),t.child=a,a.return=t;s.sibling!==null;)s=s.sibling,a=a.sibling=Fa(s,s.pendingProps),a.return=t;a.sibling=null}return t.child}function zd(s,t){return(s.lanes&t)!==0?!0:(s=s.dependencies,!!(s!==null&&Lr(s)))}function Bv(s,t,a){switch(t.tag){case 3:te(t,t.stateNode.containerInfo),hl(t,ut,s.memoizedState.cache),Vl();break;case 27:case 5:P(t);break;case 4:te(t,t.stateNode.containerInfo);break;case 10:hl(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,sd(t),null;break;case 13:var l=t.memoizedState;if(l!==null)return l.dehydrated!==null?(jl(t),t.flags|=128,null):(a&t.child.childLanes)!==0?vh(s,t,a):(jl(t),s=Xa(s,t,a),s!==null?s.sibling:null);jl(t);break;case 19:var c=(s.flags&128)!==0;if(l=(a&t.childLanes)!==0,l||(Cn(s,t,a,!1),l=(a&t.childLanes)!==0),c){if(l)return Nh(s,t,a);t.flags|=128}if(c=t.memoizedState,c!==null&&(c.rendering=null,c.tail=null,c.lastEffect=null),ce(nt,nt.current),l)break;return null;case 22:return t.lanes=0,xh(s,t,a,t.pendingProps);case 24:hl(t,ut,s.memoizedState.cache)}return Xa(s,t,a)}function yh(s,t,a){if(s!==null)if(s.memoizedProps!==t.pendingProps)xt=!0;else{if(!zd(s,a)&&(t.flags&128)===0)return xt=!1,Bv(s,t,a);xt=(s.flags&131072)!==0}else xt=!1,js&&(t.flags&1048576)!==0&&ex(t,vi,t.index);switch(t.lanes=0,t.tag){case 16:e:{var l=t.pendingProps;if(s=Yl(t.elementType),t.type=s,typeof s=="function")Ro(s)?(l=Pl(s,l),t.tag=1,t=gh(null,t,s,l,a)):(t.tag=0,t=wd(null,t,s,l,a));else{if(s!=null){var c=s.$$typeof;if(c===z){t.tag=11,t=dh(null,t,s,l,a);break e}else if(c===E){t.tag=14,t=uh(null,t,s,l,a);break e}}throw t=ye(s)||s,Error(d(306,t,""))}}return t;case 0:return wd(s,t,t.type,t.pendingProps,a);case 1:return l=t.type,c=Pl(l,t.pendingProps),gh(s,t,l,c,a);case 3:e:{if(te(t,t.stateNode.containerInfo),s===null)throw Error(d(387));l=t.pendingProps;var o=t.memoizedState;c=o.element,Jo(s,t),ki(t,l,null,a);var h=t.memoizedState;if(l=h.cache,hl(t,ut,l),l!==o.cache&&$o(t,[ut],a,!0),Ci(),l=h.element,o.isDehydrated)if(o={element:l,isDehydrated:!1,cache:h.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=jh(s,t,l,a);break e}else if(l!==c){c=ra(Error(d(424)),t),bi(c),t=jh(s,t,l,a);break e}else{switch(s=t.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(Vs=ma(s.firstChild),Ct=t,js=!0,ml=null,da=!0,a=xx(t,null,l,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Vl(),l===c){t=Xa(s,t,a);break e}Tt(s,t,l,a)}t=t.child}return t;case 26:return sc(s,t),s===null?(a=Of(t.type,null,t.pendingProps,null))?t.memoizedState=a:js||(a=t.type,s=t.pendingProps,l=jc(oe.current).createElement(a),l[St]=t,l[Ut]=s,Et(l,a,s),yt(l),t.stateNode=l):t.memoizedState=Of(t.type,s.memoizedProps,t.pendingProps,s.memoizedState),null;case 27:return P(t),s===null&&js&&(l=t.stateNode=Mf(t.type,t.pendingProps,oe.current),Ct=t,da=!0,c=Vs,kl(t.type)?(ou=c,Vs=ma(l.firstChild)):Vs=c),Tt(s,t,t.pendingProps.children,a),sc(s,t),s===null&&(t.flags|=4194304),t.child;case 5:return s===null&&js&&((c=l=Vs)&&(l=hb(l,t.type,t.pendingProps,da),l!==null?(t.stateNode=l,Ct=t,Vs=ma(l.firstChild),da=!1,c=!0):c=!1),c||xl(t)),P(t),c=t.type,o=t.pendingProps,h=s!==null?s.memoizedProps:null,l=o.children,lu(c,o)?l=null:h!==null&&lu(c,h)&&(t.flags|=32),t.memoizedState!==null&&(c=ad(s,t,Ev,null,null,a),Yi._currentValue=c),sc(s,t),Tt(s,t,l,a),t.child;case 6:return s===null&&js&&((s=a=Vs)&&(a=fb(a,t.pendingProps,da),a!==null?(t.stateNode=a,Ct=t,Vs=null,s=!0):s=!1),s||xl(t)),null;case 13:return vh(s,t,a);case 4:return te(t,t.stateNode.containerInfo),l=t.pendingProps,s===null?t.child=Kl(t,null,l,a):Tt(s,t,l,a),t.child;case 11:return dh(s,t,t.type,t.pendingProps,a);case 7:return Tt(s,t,t.pendingProps,a),t.child;case 8:return Tt(s,t,t.pendingProps.children,a),t.child;case 12:return Tt(s,t,t.pendingProps.children,a),t.child;case 10:return l=t.pendingProps,hl(t,t.type,l.value),Tt(s,t,l.children,a),t.child;case 9:return c=t.type._context,l=t.pendingProps.children,Ql(t),c=kt(c),l=l(c),t.flags|=1,Tt(s,t,l,a),t.child;case 14:return uh(s,t,t.type,t.pendingProps,a);case 15:return mh(s,t,t.type,t.pendingProps,a);case 19:return Nh(s,t,a);case 31:return Uv(s,t,a);case 22:return xh(s,t,a,t.pendingProps);case 24:return Ql(t),l=kt(ut),s===null?(c=Yo(),c===null&&(c=Os,o=Qo(),c.pooledCache=o,o.refCount++,o!==null&&(c.pooledCacheLanes|=a),c=o),t.memoizedState={parent:l,cache:c},Ko(t),hl(t,ut,c)):((s.lanes&a)!==0&&(Jo(s,t),ki(t,null,null,a),Ci()),c=s.memoizedState,o=t.memoizedState,c.parent!==l?(c={parent:l,cache:l},t.memoizedState=c,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=c),hl(t,ut,l)):(l=o.cache,hl(t,ut,l),l!==c.cache&&$o(t,[ut],a,!0))),Tt(s,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(d(156,t.tag))}function Ka(s){s.flags|=4}function Md(s,t,a,l,c){if((t=(s.mode&32)!==0)&&(t=!1),t){if(s.flags|=16777216,(c&335544128)===c)if(s.stateNode.complete)s.flags|=8192;else if(Kh())s.flags|=8192;else throw Xl=qr,Xo}else s.flags&=-16777217}function wh(s,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!Hf(t))if(Kh())s.flags|=8192;else throw Xl=qr,Xo}function ac(s,t){t!==null&&(s.flags|=4),s.flags&16384&&(t=s.tag!==22?ge():536870912,s.lanes|=t,Bn|=t)}function Di(s,t){if(!js)switch(s.tailMode){case"hidden":t=s.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?s.tail=null:a.sibling=null;break;case"collapsed":a=s.tail;for(var l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t||s.tail===null?s.tail=null:s.tail.sibling=null:l.sibling=null}}function $s(s){var t=s.alternate!==null&&s.alternate.child===s.child,a=0,l=0;if(t)for(var c=s.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags&65011712,l|=c.flags&65011712,c.return=s,c=c.sibling;else for(c=s.child;c!==null;)a|=c.lanes|c.childLanes,l|=c.subtreeFlags,l|=c.flags,c.return=s,c=c.sibling;return s.subtreeFlags|=l,s.childLanes=a,t}function Hv(s,t,a){var l=t.pendingProps;switch(Ho(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $s(t),null;case 1:return $s(t),null;case 3:return a=t.stateNode,l=null,s!==null&&(l=s.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Qa(ut),V(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(s===null||s.child===null)&&(Sn(t)?Ka(t):s===null||s.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Go())),$s(t),null;case 26:var c=t.type,o=t.memoizedState;return s===null?(Ka(t),o!==null?($s(t),wh(t,o)):($s(t),Md(t,c,null,l,a))):o?o!==s.memoizedState?(Ka(t),$s(t),wh(t,o)):($s(t),t.flags&=-16777217):(s=s.memoizedProps,s!==l&&Ka(t),$s(t),Md(t,c,s,l,a)),null;case 27:if(ke(t),a=oe.current,c=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==l&&Ka(t);else{if(!l){if(t.stateNode===null)throw Error(d(166));return $s(t),null}s=xe.current,Sn(t)?tx(t):(s=Mf(c,l,a),t.stateNode=s,Ka(t))}return $s(t),null;case 5:if(ke(t),c=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==l&&Ka(t);else{if(!l){if(t.stateNode===null)throw Error(d(166));return $s(t),null}if(o=xe.current,Sn(t))tx(t);else{var h=jc(oe.current);switch(o){case 1:o=h.createElementNS("http://www.w3.org/2000/svg",c);break;case 2:o=h.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;default:switch(c){case"svg":o=h.createElementNS("http://www.w3.org/2000/svg",c);break;case"math":o=h.createElementNS("http://www.w3.org/1998/Math/MathML",c);break;case"script":o=h.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof l.is=="string"?h.createElement("select",{is:l.is}):h.createElement("select"),l.multiple?o.multiple=!0:l.size&&(o.size=l.size);break;default:o=typeof l.is=="string"?h.createElement(c,{is:l.is}):h.createElement(c)}}o[St]=t,o[Ut]=l;e:for(h=t.child;h!==null;){if(h.tag===5||h.tag===6)o.appendChild(h.stateNode);else if(h.tag!==4&&h.tag!==27&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}t.stateNode=o;e:switch(Et(o,c,l),c){case"button":case"input":case"select":case"textarea":l=!!l.autoFocus;break e;case"img":l=!0;break e;default:l=!1}l&&Ka(t)}}return $s(t),Md(t,t.type,s===null?null:s.memoizedProps,t.pendingProps,a),null;case 6:if(s&&t.stateNode!=null)s.memoizedProps!==l&&Ka(t);else{if(typeof l!="string"&&t.stateNode===null)throw Error(d(166));if(s=oe.current,Sn(t)){if(s=t.stateNode,a=t.memoizedProps,l=null,c=Ct,c!==null)switch(c.tag){case 27:case 5:l=c.memoizedProps}s[St]=t,s=!!(s.nodeValue===a||l!==null&&l.suppressHydrationWarning===!0||bf(s.nodeValue,a)),s||xl(t,!0)}else s=jc(s).createTextNode(l),s[St]=t,t.stateNode=s}return $s(t),null;case 31:if(a=t.memoizedState,s===null||s.memoizedState!==null){if(l=Sn(t),a!==null){if(s===null){if(!l)throw Error(d(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(d(557));s[St]=t}else Vl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;$s(t),s=!1}else a=Go(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=a),s=!0;if(!s)return t.flags&256?(Zt(t),t):(Zt(t),null);if((t.flags&128)!==0)throw Error(d(558))}return $s(t),null;case 13:if(l=t.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(c=Sn(t),l!==null&&l.dehydrated!==null){if(s===null){if(!c)throw Error(d(318));if(c=t.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(d(317));c[St]=t}else Vl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;$s(t),c=!1}else c=Go(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=c),c=!0;if(!c)return t.flags&256?(Zt(t),t):(Zt(t),null)}return Zt(t),(t.flags&128)!==0?(t.lanes=a,t):(a=l!==null,s=s!==null&&s.memoizedState!==null,a&&(l=t.child,c=null,l.alternate!==null&&l.alternate.memoizedState!==null&&l.alternate.memoizedState.cachePool!==null&&(c=l.alternate.memoizedState.cachePool.pool),o=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(o=l.memoizedState.cachePool.pool),o!==c&&(l.flags|=2048)),a!==s&&a&&(t.child.flags|=8192),ac(t,t.updateQueue),$s(t),null);case 4:return V(),s===null&&Wd(t.stateNode.containerInfo),$s(t),null;case 10:return Qa(t.type),$s(t),null;case 19:if(me(nt),l=t.memoizedState,l===null)return $s(t),null;if(c=(t.flags&128)!==0,o=l.rendering,o===null)if(c)Di(l,!1);else{if(Ws!==0||s!==null&&(s.flags&128)!==0)for(s=t.child;s!==null;){if(o=$r(s),o!==null){for(t.flags|=128,Di(l,!1),s=o.updateQueue,t.updateQueue=s,ac(t,s),t.subtreeFlags=0,s=a,a=t.child;a!==null;)Pm(a,s),a=a.sibling;return ce(nt,nt.current&1|2),js&&Va(t,l.treeForkCount),t.child}s=s.sibling}l.tail!==null&&Ds()>cc&&(t.flags|=128,c=!0,Di(l,!1),t.lanes=4194304)}else{if(!c)if(s=$r(o),s!==null){if(t.flags|=128,c=!0,s=s.updateQueue,t.updateQueue=s,ac(t,s),Di(l,!0),l.tail===null&&l.tailMode==="hidden"&&!o.alternate&&!js)return $s(t),null}else 2*Ds()-l.renderingStartTime>cc&&a!==536870912&&(t.flags|=128,c=!0,Di(l,!1),t.lanes=4194304);l.isBackwards?(o.sibling=t.child,t.child=o):(s=l.last,s!==null?s.sibling=o:t.child=o,l.last=o)}return l.tail!==null?(s=l.tail,l.rendering=s,l.tail=s.sibling,l.renderingStartTime=Ds(),s.sibling=null,a=nt.current,ce(nt,c?a&1|2:a&1),js&&Va(t,l.treeForkCount),s):($s(t),null);case 22:case 23:return Zt(t),ed(),l=t.memoizedState!==null,s!==null?s.memoizedState!==null!==l&&(t.flags|=8192):l&&(t.flags|=8192),l?(a&536870912)!==0&&(t.flags&128)===0&&($s(t),t.subtreeFlags&6&&(t.flags|=8192)):$s(t),a=t.updateQueue,a!==null&&ac(t,a.retryQueue),a=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),l=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),l!==a&&(t.flags|=2048),s!==null&&me(Il),null;case 24:return a=null,s!==null&&(a=s.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Qa(ut),$s(t),null;case 25:return null;case 30:return null}throw Error(d(156,t.tag))}function qv(s,t){switch(Ho(t),t.tag){case 1:return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 3:return Qa(ut),V(),s=t.flags,(s&65536)!==0&&(s&128)===0?(t.flags=s&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(Zt(t),t.alternate===null)throw Error(d(340));Vl()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 13:if(Zt(t),s=t.memoizedState,s!==null&&s.dehydrated!==null){if(t.alternate===null)throw Error(d(340));Vl()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 19:return me(nt),null;case 4:return V(),null;case 10:return Qa(t.type),null;case 22:case 23:return Zt(t),ed(),s!==null&&me(Il),s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 24:return Qa(ut),null;case 25:return null;default:return null}}function _h(s,t){switch(Ho(t),t.tag){case 3:Qa(ut),V();break;case 26:case 27:case 5:ke(t);break;case 4:V();break;case 31:t.memoizedState!==null&&Zt(t);break;case 13:Zt(t);break;case 19:me(nt);break;case 10:Qa(t.type);break;case 22:case 23:Zt(t),ed(),s!==null&&me(Il);break;case 24:Qa(ut)}}function Oi(s,t){try{var a=t.updateQueue,l=a!==null?a.lastEffect:null;if(l!==null){var c=l.next;a=c;do{if((a.tag&s)===s){l=void 0;var o=a.create,h=a.inst;l=o(),h.destroy=l}a=a.next}while(a!==c)}}catch(b){Cs(t,t.return,b)}}function bl(s,t,a){try{var l=t.updateQueue,c=l!==null?l.lastEffect:null;if(c!==null){var o=c.next;l=o;do{if((l.tag&s)===s){var h=l.inst,b=h.destroy;if(b!==void 0){h.destroy=void 0,c=t;var A=a,J=b;try{J()}catch(re){Cs(c,A,re)}}}l=l.next}while(l!==o)}}catch(re){Cs(t,t.return,re)}}function Sh(s){var t=s.updateQueue;if(t!==null){var a=s.stateNode;try{fx(t,a)}catch(l){Cs(s,s.return,l)}}}function Ch(s,t,a){a.props=Pl(s.type,s.memoizedProps),a.state=s.memoizedState;try{a.componentWillUnmount()}catch(l){Cs(s,t,l)}}function Ri(s,t){try{var a=s.ref;if(a!==null){switch(s.tag){case 26:case 27:case 5:var l=s.stateNode;break;case 30:l=s.stateNode;break;default:l=s.stateNode}typeof a=="function"?s.refCleanup=a(l):a.current=l}}catch(c){Cs(s,t,c)}}function za(s,t){var a=s.ref,l=s.refCleanup;if(a!==null)if(typeof l=="function")try{l()}catch(c){Cs(s,t,c)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(c){Cs(s,t,c)}else a.current=null}function kh(s){var t=s.type,a=s.memoizedProps,l=s.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&l.focus();break e;case"img":a.src?l.src=a.src:a.srcSet&&(l.srcset=a.srcSet)}}catch(c){Cs(s,s.return,c)}}function Ad(s,t,a){try{var l=s.stateNode;cb(l,s.type,a,t),l[Ut]=t}catch(c){Cs(s,s.return,c)}}function Th(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&kl(s.type)||s.tag===4}function Dd(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Th(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.tag===27&&kl(s.type)||s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function Od(s,t,a){var l=s.tag;if(l===5||l===6)s=s.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(s,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(s),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=qa));else if(l!==4&&(l===27&&kl(s.type)&&(a=s.stateNode,t=null),s=s.child,s!==null))for(Od(s,t,a),s=s.sibling;s!==null;)Od(s,t,a),s=s.sibling}function lc(s,t,a){var l=s.tag;if(l===5||l===6)s=s.stateNode,t?a.insertBefore(s,t):a.appendChild(s);else if(l!==4&&(l===27&&kl(s.type)&&(a=s.stateNode),s=s.child,s!==null))for(lc(s,t,a),s=s.sibling;s!==null;)lc(s,t,a),s=s.sibling}function Eh(s){var t=s.stateNode,a=s.memoizedProps;try{for(var l=s.type,c=t.attributes;c.length;)t.removeAttributeNode(c[0]);Et(t,l,a),t[St]=s,t[Ut]=a}catch(o){Cs(s,s.return,o)}}var Ja=!1,ht=!1,Rd=!1,zh=typeof WeakSet=="function"?WeakSet:Set,wt=null;function Gv(s,t){if(s=s.containerInfo,tu=Sc,s=Fm(s),To(s)){if("selectionStart"in s)var a={start:s.selectionStart,end:s.selectionEnd};else e:{a=(a=s.ownerDocument)&&a.defaultView||window;var l=a.getSelection&&a.getSelection();if(l&&l.rangeCount!==0){a=l.anchorNode;var c=l.anchorOffset,o=l.focusNode;l=l.focusOffset;try{a.nodeType,o.nodeType}catch{a=null;break e}var h=0,b=-1,A=-1,J=0,re=0,he=s,W=null;s:for(;;){for(var ae;he!==a||c!==0&&he.nodeType!==3||(b=h+c),he!==o||l!==0&&he.nodeType!==3||(A=h+l),he.nodeType===3&&(h+=he.nodeValue.length),(ae=he.firstChild)!==null;)W=he,he=ae;for(;;){if(he===s)break s;if(W===a&&++J===c&&(b=h),W===o&&++re===l&&(A=h),(ae=he.nextSibling)!==null)break;he=W,W=he.parentNode}he=ae}a=b===-1||A===-1?null:{start:b,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(au={focusedElem:s,selectionRange:a},Sc=!1,wt=t;wt!==null;)if(t=wt,s=t.child,(t.subtreeFlags&1028)!==0&&s!==null)s.return=t,wt=s;else for(;wt!==null;){switch(t=wt,o=t.alternate,s=t.flags,t.tag){case 0:if((s&4)!==0&&(s=t.updateQueue,s=s!==null?s.events:null,s!==null))for(a=0;a<s.length;a++)c=s[a],c.ref.impl=c.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&o!==null){s=void 0,a=t,c=o.memoizedProps,o=o.memoizedState,l=a.stateNode;try{var Ce=Pl(a.type,c);s=l.getSnapshotBeforeUpdate(Ce,o),l.__reactInternalSnapshotBeforeUpdate=s}catch($e){Cs(a,a.return,$e)}}break;case 3:if((s&1024)!==0){if(s=t.stateNode.containerInfo,a=s.nodeType,a===9)iu(s);else if(a===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":iu(s);break;default:s.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((s&1024)!==0)throw Error(d(163))}if(s=t.sibling,s!==null){s.return=t.return,wt=s;break}wt=t.return}}function Mh(s,t,a){var l=a.flags;switch(a.tag){case 0:case 11:case 15:Za(s,a),l&4&&Oi(5,a);break;case 1:if(Za(s,a),l&4)if(s=a.stateNode,t===null)try{s.componentDidMount()}catch(h){Cs(a,a.return,h)}else{var c=Pl(a.type,t.memoizedProps);t=t.memoizedState;try{s.componentDidUpdate(c,t,s.__reactInternalSnapshotBeforeUpdate)}catch(h){Cs(a,a.return,h)}}l&64&&Sh(a),l&512&&Ri(a,a.return);break;case 3:if(Za(s,a),l&64&&(s=a.updateQueue,s!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{fx(s,t)}catch(h){Cs(a,a.return,h)}}break;case 27:t===null&&l&4&&Eh(a);case 26:case 5:Za(s,a),t===null&&l&4&&kh(a),l&512&&Ri(a,a.return);break;case 12:Za(s,a);break;case 31:Za(s,a),l&4&&Oh(s,a);break;case 13:Za(s,a),l&4&&Rh(s,a),l&64&&(s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(a=Jv.bind(null,a),pb(s,a))));break;case 22:if(l=a.memoizedState!==null||Ja,!l){t=t!==null&&t.memoizedState!==null||ht,c=Ja;var o=ht;Ja=l,(ht=t)&&!o?Wa(s,a,(a.subtreeFlags&8772)!==0):Za(s,a),Ja=c,ht=o}break;case 30:break;default:Za(s,a)}}function Ah(s){var t=s.alternate;t!==null&&(s.alternate=null,Ah(t)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(t=s.stateNode,t!==null&&uo(t)),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}var Is=null,Ht=!1;function Pa(s,t,a){for(a=a.child;a!==null;)Dh(s,t,a),a=a.sibling}function Dh(s,t,a){if(be&&typeof be.onCommitFiberUnmount=="function")try{be.onCommitFiberUnmount(qs,a)}catch{}switch(a.tag){case 26:ht||za(a,t),Pa(s,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:ht||za(a,t);var l=Is,c=Ht;kl(a.type)&&(Is=a.stateNode,Ht=!1),Pa(s,t,a),$i(a.stateNode),Is=l,Ht=c;break;case 5:ht||za(a,t);case 6:if(l=Is,c=Ht,Is=null,Pa(s,t,a),Is=l,Ht=c,Is!==null)if(Ht)try{(Is.nodeType===9?Is.body:Is.nodeName==="HTML"?Is.ownerDocument.body:Is).removeChild(a.stateNode)}catch(o){Cs(a,t,o)}else try{Is.removeChild(a.stateNode)}catch(o){Cs(a,t,o)}break;case 18:Is!==null&&(Ht?(s=Is,Cf(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,a.stateNode),In(s)):Cf(Is,a.stateNode));break;case 4:l=Is,c=Ht,Is=a.stateNode.containerInfo,Ht=!0,Pa(s,t,a),Is=l,Ht=c;break;case 0:case 11:case 14:case 15:bl(2,a,t),ht||bl(4,a,t),Pa(s,t,a);break;case 1:ht||(za(a,t),l=a.stateNode,typeof l.componentWillUnmount=="function"&&Ch(a,t,l)),Pa(s,t,a);break;case 21:Pa(s,t,a);break;case 22:ht=(l=ht)||a.memoizedState!==null,Pa(s,t,a),ht=l;break;default:Pa(s,t,a)}}function Oh(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{In(s)}catch(a){Cs(t,t.return,a)}}}function Rh(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{In(s)}catch(a){Cs(t,t.return,a)}}function Fv(s){switch(s.tag){case 31:case 13:case 19:var t=s.stateNode;return t===null&&(t=s.stateNode=new zh),t;case 22:return s=s.stateNode,t=s._retryCache,t===null&&(t=s._retryCache=new zh),t;default:throw Error(d(435,s.tag))}}function nc(s,t){var a=Fv(s);t.forEach(function(l){if(!a.has(l)){a.add(l);var c=Pv.bind(null,s,l);l.then(c,c)}})}function qt(s,t){var a=t.deletions;if(a!==null)for(var l=0;l<a.length;l++){var c=a[l],o=s,h=t,b=h;e:for(;b!==null;){switch(b.tag){case 27:if(kl(b.type)){Is=b.stateNode,Ht=!1;break e}break;case 5:Is=b.stateNode,Ht=!1;break e;case 3:case 4:Is=b.stateNode.containerInfo,Ht=!0;break e}b=b.return}if(Is===null)throw Error(d(160));Dh(o,h,c),Is=null,Ht=!1,o=c.alternate,o!==null&&(o.return=null),c.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Lh(t,s),t=t.sibling}var Na=null;function Lh(s,t){var a=s.alternate,l=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:qt(t,s),Gt(s),l&4&&(bl(3,s,s.return),Oi(3,s),bl(5,s,s.return));break;case 1:qt(t,s),Gt(s),l&512&&(ht||a===null||za(a,a.return)),l&64&&Ja&&(s=s.updateQueue,s!==null&&(l=s.callbacks,l!==null&&(a=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=a===null?l:a.concat(l))));break;case 26:var c=Na;if(qt(t,s),Gt(s),l&512&&(ht||a===null||za(a,a.return)),l&4){var o=a!==null?a.memoizedState:null;if(l=s.memoizedState,a===null)if(l===null)if(s.stateNode===null){e:{l=s.type,a=s.memoizedProps,c=c.ownerDocument||c;s:switch(l){case"title":o=c.getElementsByTagName("title")[0],(!o||o[ci]||o[St]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=c.createElement(l),c.head.insertBefore(o,c.querySelector("head > title"))),Et(o,l,a),o[St]=s,yt(o),l=o;break e;case"link":var h=Uf("link","href",c).get(l+(a.href||""));if(h){for(var b=0;b<h.length;b++)if(o=h[b],o.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&o.getAttribute("rel")===(a.rel==null?null:a.rel)&&o.getAttribute("title")===(a.title==null?null:a.title)&&o.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){h.splice(b,1);break s}}o=c.createElement(l),Et(o,l,a),c.head.appendChild(o);break;case"meta":if(h=Uf("meta","content",c).get(l+(a.content||""))){for(b=0;b<h.length;b++)if(o=h[b],o.getAttribute("content")===(a.content==null?null:""+a.content)&&o.getAttribute("name")===(a.name==null?null:a.name)&&o.getAttribute("property")===(a.property==null?null:a.property)&&o.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&o.getAttribute("charset")===(a.charSet==null?null:a.charSet)){h.splice(b,1);break s}}o=c.createElement(l),Et(o,l,a),c.head.appendChild(o);break;default:throw Error(d(468,l))}o[St]=s,yt(o),l=o}s.stateNode=l}else Bf(c,s.type,s.stateNode);else s.stateNode=Lf(c,l,s.memoizedProps);else o!==l?(o===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):o.count--,l===null?Bf(c,s.type,s.stateNode):Lf(c,l,s.memoizedProps)):l===null&&s.stateNode!==null&&Ad(s,s.memoizedProps,a.memoizedProps)}break;case 27:qt(t,s),Gt(s),l&512&&(ht||a===null||za(a,a.return)),a!==null&&l&4&&Ad(s,s.memoizedProps,a.memoizedProps);break;case 5:if(qt(t,s),Gt(s),l&512&&(ht||a===null||za(a,a.return)),s.flags&32){c=s.stateNode;try{fn(c,"")}catch(Ce){Cs(s,s.return,Ce)}}l&4&&s.stateNode!=null&&(c=s.memoizedProps,Ad(s,c,a!==null?a.memoizedProps:c)),l&1024&&(Rd=!0);break;case 6:if(qt(t,s),Gt(s),l&4){if(s.stateNode===null)throw Error(d(162));l=s.memoizedProps,a=s.stateNode;try{a.nodeValue=l}catch(Ce){Cs(s,s.return,Ce)}}break;case 3:if(Nc=null,c=Na,Na=vc(t.containerInfo),qt(t,s),Na=c,Gt(s),l&4&&a!==null&&a.memoizedState.isDehydrated)try{In(t.containerInfo)}catch(Ce){Cs(s,s.return,Ce)}Rd&&(Rd=!1,Uh(s));break;case 4:l=Na,Na=vc(s.stateNode.containerInfo),qt(t,s),Gt(s),Na=l;break;case 12:qt(t,s),Gt(s);break;case 31:qt(t,s),Gt(s),l&4&&(l=s.updateQueue,l!==null&&(s.updateQueue=null,nc(s,l)));break;case 13:qt(t,s),Gt(s),s.child.flags&8192&&s.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(rc=Ds()),l&4&&(l=s.updateQueue,l!==null&&(s.updateQueue=null,nc(s,l)));break;case 22:c=s.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,J=Ja,re=ht;if(Ja=J||c,ht=re||A,qt(t,s),ht=re,Ja=J,Gt(s),l&8192)e:for(t=s.stateNode,t._visibility=c?t._visibility&-2:t._visibility|1,c&&(a===null||A||Ja||ht||Zl(s)),a=null,t=s;;){if(t.tag===5||t.tag===26){if(a===null){A=a=t;try{if(o=A.stateNode,c)h=o.style,typeof h.setProperty=="function"?h.setProperty("display","none","important"):h.display="none";else{b=A.stateNode;var he=A.memoizedProps.style,W=he!=null&&he.hasOwnProperty("display")?he.display:null;b.style.display=W==null||typeof W=="boolean"?"":(""+W).trim()}}catch(Ce){Cs(A,A.return,Ce)}}}else if(t.tag===6){if(a===null){A=t;try{A.stateNode.nodeValue=c?"":A.memoizedProps}catch(Ce){Cs(A,A.return,Ce)}}}else if(t.tag===18){if(a===null){A=t;try{var ae=A.stateNode;c?kf(ae,!0):kf(A.stateNode,!1)}catch(Ce){Cs(A,A.return,Ce)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===s)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}l&4&&(l=s.updateQueue,l!==null&&(a=l.retryQueue,a!==null&&(l.retryQueue=null,nc(s,a))));break;case 19:qt(t,s),Gt(s),l&4&&(l=s.updateQueue,l!==null&&(s.updateQueue=null,nc(s,l)));break;case 30:break;case 21:break;default:qt(t,s),Gt(s)}}function Gt(s){var t=s.flags;if(t&2){try{for(var a,l=s.return;l!==null;){if(Th(l)){a=l;break}l=l.return}if(a==null)throw Error(d(160));switch(a.tag){case 27:var c=a.stateNode,o=Dd(s);lc(s,o,c);break;case 5:var h=a.stateNode;a.flags&32&&(fn(h,""),a.flags&=-33);var b=Dd(s);lc(s,b,h);break;case 3:case 4:var A=a.stateNode.containerInfo,J=Dd(s);Od(s,J,A);break;default:throw Error(d(161))}}catch(re){Cs(s,s.return,re)}s.flags&=-3}t&4096&&(s.flags&=-4097)}function Uh(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var t=s;Uh(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),s=s.sibling}}function Za(s,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Mh(s,t.alternate,t),t=t.sibling}function Zl(s){for(s=s.child;s!==null;){var t=s;switch(t.tag){case 0:case 11:case 14:case 15:bl(4,t,t.return),Zl(t);break;case 1:za(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Ch(t,t.return,a),Zl(t);break;case 27:$i(t.stateNode);case 26:case 5:za(t,t.return),Zl(t);break;case 22:t.memoizedState===null&&Zl(t);break;case 30:Zl(t);break;default:Zl(t)}s=s.sibling}}function Wa(s,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var l=t.alternate,c=s,o=t,h=o.flags;switch(o.tag){case 0:case 11:case 15:Wa(c,o,a),Oi(4,o);break;case 1:if(Wa(c,o,a),l=o,c=l.stateNode,typeof c.componentDidMount=="function")try{c.componentDidMount()}catch(J){Cs(l,l.return,J)}if(l=o,c=l.updateQueue,c!==null){var b=l.stateNode;try{var A=c.shared.hiddenCallbacks;if(A!==null)for(c.shared.hiddenCallbacks=null,c=0;c<A.length;c++)hx(A[c],b)}catch(J){Cs(l,l.return,J)}}a&&h&64&&Sh(o),Ri(o,o.return);break;case 27:Eh(o);case 26:case 5:Wa(c,o,a),a&&l===null&&h&4&&kh(o),Ri(o,o.return);break;case 12:Wa(c,o,a);break;case 31:Wa(c,o,a),a&&h&4&&Oh(c,o);break;case 13:Wa(c,o,a),a&&h&4&&Rh(c,o);break;case 22:o.memoizedState===null&&Wa(c,o,a),Ri(o,o.return);break;case 30:break;default:Wa(c,o,a)}t=t.sibling}}function Ld(s,t){var a=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==a&&(s!=null&&s.refCount++,a!=null&&Ni(a))}function Ud(s,t){s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&Ni(s))}function ya(s,t,a,l){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Bh(s,t,a,l),t=t.sibling}function Bh(s,t,a,l){var c=t.flags;switch(t.tag){case 0:case 11:case 15:ya(s,t,a,l),c&2048&&Oi(9,t);break;case 1:ya(s,t,a,l);break;case 3:ya(s,t,a,l),c&2048&&(s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&Ni(s)));break;case 12:if(c&2048){ya(s,t,a,l),s=t.stateNode;try{var o=t.memoizedProps,h=o.id,b=o.onPostCommit;typeof b=="function"&&b(h,t.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(A){Cs(t,t.return,A)}}else ya(s,t,a,l);break;case 31:ya(s,t,a,l);break;case 13:ya(s,t,a,l);break;case 23:break;case 22:o=t.stateNode,h=t.alternate,t.memoizedState!==null?o._visibility&2?ya(s,t,a,l):Li(s,t):o._visibility&2?ya(s,t,a,l):(o._visibility|=2,Rn(s,t,a,l,(t.subtreeFlags&10256)!==0||!1)),c&2048&&Ld(h,t);break;case 24:ya(s,t,a,l),c&2048&&Ud(t.alternate,t);break;default:ya(s,t,a,l)}}function Rn(s,t,a,l,c){for(c=c&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var o=s,h=t,b=a,A=l,J=h.flags;switch(h.tag){case 0:case 11:case 15:Rn(o,h,b,A,c),Oi(8,h);break;case 23:break;case 22:var re=h.stateNode;h.memoizedState!==null?re._visibility&2?Rn(o,h,b,A,c):Li(o,h):(re._visibility|=2,Rn(o,h,b,A,c)),c&&J&2048&&Ld(h.alternate,h);break;case 24:Rn(o,h,b,A,c),c&&J&2048&&Ud(h.alternate,h);break;default:Rn(o,h,b,A,c)}t=t.sibling}}function Li(s,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=s,l=t,c=l.flags;switch(l.tag){case 22:Li(a,l),c&2048&&Ld(l.alternate,l);break;case 24:Li(a,l),c&2048&&Ud(l.alternate,l);break;default:Li(a,l)}t=t.sibling}}var Ui=8192;function Ln(s,t,a){if(s.subtreeFlags&Ui)for(s=s.child;s!==null;)Hh(s,t,a),s=s.sibling}function Hh(s,t,a){switch(s.tag){case 26:Ln(s,t,a),s.flags&Ui&&s.memoizedState!==null&&Tb(a,Na,s.memoizedState,s.memoizedProps);break;case 5:Ln(s,t,a);break;case 3:case 4:var l=Na;Na=vc(s.stateNode.containerInfo),Ln(s,t,a),Na=l;break;case 22:s.memoizedState===null&&(l=s.alternate,l!==null&&l.memoizedState!==null?(l=Ui,Ui=16777216,Ln(s,t,a),Ui=l):Ln(s,t,a));break;default:Ln(s,t,a)}}function qh(s){var t=s.alternate;if(t!==null&&(s=t.child,s!==null)){t.child=null;do t=s.sibling,s.sibling=null,s=t;while(s!==null)}}function Bi(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];wt=l,Fh(l,s)}qh(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Gh(s),s=s.sibling}function Gh(s){switch(s.tag){case 0:case 11:case 15:Bi(s),s.flags&2048&&bl(9,s,s.return);break;case 3:Bi(s);break;case 12:Bi(s);break;case 22:var t=s.stateNode;s.memoizedState!==null&&t._visibility&2&&(s.return===null||s.return.tag!==13)?(t._visibility&=-3,ic(s)):Bi(s);break;default:Bi(s)}}function ic(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var l=t[a];wt=l,Fh(l,s)}qh(s)}for(s=s.child;s!==null;){switch(t=s,t.tag){case 0:case 11:case 15:bl(8,t,t.return),ic(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,ic(t));break;default:ic(t)}s=s.sibling}}function Fh(s,t){for(;wt!==null;){var a=wt;switch(a.tag){case 0:case 11:case 15:bl(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var l=a.memoizedState.cachePool.pool;l!=null&&l.refCount++}break;case 24:Ni(a.memoizedState.cache)}if(l=a.child,l!==null)l.return=a,wt=l;else e:for(a=s;wt!==null;){l=wt;var c=l.sibling,o=l.return;if(Ah(l),l===a){wt=null;break e}if(c!==null){c.return=o,wt=c;break e}wt=o}}}var Vv={getCacheForType:function(s){var t=kt(ut),a=t.data.get(s);return a===void 0&&(a=s(),t.data.set(s,a)),a},cacheSignal:function(){return kt(ut).controller.signal}},$v=typeof WeakMap=="function"?WeakMap:Map,ys=0,Os=null,ds=null,hs=0,Ss=0,Wt=null,Nl=!1,Un=!1,Bd=!1,el=0,Ws=0,yl=0,Wl=0,Hd=0,ea=0,Bn=0,Hi=null,Ft=null,qd=!1,rc=0,Vh=0,cc=1/0,oc=null,wl=null,gt=0,_l=null,Hn=null,sl=0,Gd=0,Fd=null,$h=null,qi=0,Vd=null;function sa(){return(ys&2)!==0&&hs!==0?hs&-hs:O.T!==null?Kd():im()}function Qh(){if(ea===0)if((hs&536870912)===0||js){var s=Nt;Nt<<=1,(Nt&3932160)===0&&(Nt=262144),ea=s}else ea=536870912;return s=Pt.current,s!==null&&(s.flags|=32),ea}function Vt(s,t,a){(s===Os&&(Ss===2||Ss===9)||s.cancelPendingCommit!==null)&&(qn(s,0),Sl(s,hs,ea,!1)),Ns(s,a),((ys&2)===0||s!==Os)&&(s===Os&&((ys&2)===0&&(Wl|=a),Ws===4&&Sl(s,hs,ea,!1)),Ma(s))}function Ih(s,t,a){if((ys&6)!==0)throw Error(d(327));var l=!a&&(t&127)===0&&(t&s.expiredLanes)===0||ne(s,t),c=l?Yv(s,t):Qd(s,t,!0),o=l;do{if(c===0){Un&&!l&&Sl(s,t,0,!1);break}else{if(a=s.current.alternate,o&&!Qv(a)){c=Qd(s,t,!1),o=!1;continue}if(c===2){if(o=t,s.errorRecoveryDisabledLanes&o)var h=0;else h=s.pendingLanes&-536870913,h=h!==0?h:h&536870912?536870912:0;if(h!==0){t=h;e:{var b=s;c=Hi;var A=b.current.memoizedState.isDehydrated;if(A&&(qn(b,h).flags|=256),h=Qd(b,h,!1),h!==2){if(Bd&&!A){b.errorRecoveryDisabledLanes|=o,Wl|=o,c=4;break e}o=Ft,Ft=c,o!==null&&(Ft===null?Ft=o:Ft.push.apply(Ft,o))}c=h}if(o=!1,c!==2)continue}}if(c===1){qn(s,0),Sl(s,t,0,!0);break}e:{switch(l=s,o=c,o){case 0:case 1:throw Error(d(345));case 4:if((t&4194048)!==t)break;case 6:Sl(l,t,ea,!Nl);break e;case 2:Ft=null;break;case 3:case 5:break;default:throw Error(d(329))}if((t&62914560)===t&&(c=rc+300-Ds(),10<c)){if(Sl(l,t,ea,!Nl),Ba(l,0,!0)!==0)break e;sl=t,l.timeoutHandle=_f(Yh.bind(null,l,a,Ft,oc,qd,t,ea,Wl,Bn,Nl,o,"Throttled",-0,0),c);break e}Yh(l,a,Ft,oc,qd,t,ea,Wl,Bn,Nl,o,null,-0,0)}}break}while(!0);Ma(s)}function Yh(s,t,a,l,c,o,h,b,A,J,re,he,W,ae){if(s.timeoutHandle=-1,he=t.subtreeFlags,he&8192||(he&16785408)===16785408){he={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:qa},Hh(t,o,he);var Ce=(o&62914560)===o?rc-Ds():(o&4194048)===o?Vh-Ds():0;if(Ce=Eb(he,Ce),Ce!==null){sl=o,s.cancelPendingCommit=Ce(sf.bind(null,s,t,o,a,l,c,h,b,A,re,he,null,W,ae)),Sl(s,o,h,!J);return}}sf(s,t,o,a,l,c,h,b,A)}function Qv(s){for(var t=s;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var l=0;l<a.length;l++){var c=a[l],o=c.getSnapshot;c=c.value;try{if(!Kt(o(),c))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===s)break;for(;t.sibling===null;){if(t.return===null||t.return===s)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Sl(s,t,a,l){t&=~Hd,t&=~Wl,s.suspendedLanes|=t,s.pingedLanes&=~t,l&&(s.warmLanes|=t),l=s.expirationTimes;for(var c=t;0<c;){var o=31-Ae(c),h=1<<o;l[o]=-1,c&=~h}a!==0&&ri(s,a,t)}function dc(){return(ys&6)===0?(Gi(0),!1):!0}function $d(){if(ds!==null){if(Ss===0)var s=ds.return;else s=ds,$a=$l=null,id(s),zn=null,wi=0,s=ds;for(;s!==null;)_h(s.alternate,s),s=s.return;ds=null}}function qn(s,t){var a=s.timeoutHandle;a!==-1&&(s.timeoutHandle=-1,ub(a)),a=s.cancelPendingCommit,a!==null&&(s.cancelPendingCommit=null,a()),sl=0,$d(),Os=s,ds=a=Fa(s.current,null),hs=t,Ss=0,Wt=null,Nl=!1,Un=ne(s,t),Bd=!1,Bn=ea=Hd=Wl=yl=Ws=0,Ft=Hi=null,qd=!1,(t&8)!==0&&(t|=t&32);var l=s.entangledLanes;if(l!==0)for(s=s.entanglements,l&=t;0<l;){var c=31-Ae(l),o=1<<c;t|=s[c],l&=~o}return el=t,Mr(),a}function Xh(s,t){Pe=null,O.H=Mi,t===En||t===Hr?(t=dx(),Ss=3):t===Xo?(t=dx(),Ss=4):Ss=t===yd?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Wt=t,ds===null&&(Ws=1,Wr(s,ra(t,s.current)))}function Kh(){var s=Pt.current;return s===null?!0:(hs&4194048)===hs?ua===null:(hs&62914560)===hs||(hs&536870912)!==0?s===ua:!1}function Jh(){var s=O.H;return O.H=Mi,s===null?Mi:s}function Ph(){var s=O.A;return O.A=Vv,s}function uc(){Ws=4,Nl||(hs&4194048)!==hs&&Pt.current!==null||(Un=!0),(yl&134217727)===0&&(Wl&134217727)===0||Os===null||Sl(Os,hs,ea,!1)}function Qd(s,t,a){var l=ys;ys|=2;var c=Jh(),o=Ph();(Os!==s||hs!==t)&&(oc=null,qn(s,t)),t=!1;var h=Ws;e:do try{if(Ss!==0&&ds!==null){var b=ds,A=Wt;switch(Ss){case 8:$d(),h=6;break e;case 3:case 2:case 9:case 6:Pt.current===null&&(t=!0);var J=Ss;if(Ss=0,Wt=null,Gn(s,b,A,J),a&&Un){h=0;break e}break;default:J=Ss,Ss=0,Wt=null,Gn(s,b,A,J)}}Iv(),h=Ws;break}catch(re){Xh(s,re)}while(!0);return t&&s.shellSuspendCounter++,$a=$l=null,ys=l,O.H=c,O.A=o,ds===null&&(Os=null,hs=0,Mr()),h}function Iv(){for(;ds!==null;)Zh(ds)}function Yv(s,t){var a=ys;ys|=2;var l=Jh(),c=Ph();Os!==s||hs!==t?(oc=null,cc=Ds()+500,qn(s,t)):Un=ne(s,t);e:do try{if(Ss!==0&&ds!==null){t=ds;var o=Wt;s:switch(Ss){case 1:Ss=0,Wt=null,Gn(s,t,o,1);break;case 2:case 9:if(cx(o)){Ss=0,Wt=null,Wh(t);break}t=function(){Ss!==2&&Ss!==9||Os!==s||(Ss=7),Ma(s)},o.then(t,t);break e;case 3:Ss=7;break e;case 4:Ss=5;break e;case 7:cx(o)?(Ss=0,Wt=null,Wh(t)):(Ss=0,Wt=null,Gn(s,t,o,7));break;case 5:var h=null;switch(ds.tag){case 26:h=ds.memoizedState;case 5:case 27:var b=ds;if(h?Hf(h):b.stateNode.complete){Ss=0,Wt=null;var A=b.sibling;if(A!==null)ds=A;else{var J=b.return;J!==null?(ds=J,mc(J)):ds=null}break s}}Ss=0,Wt=null,Gn(s,t,o,5);break;case 6:Ss=0,Wt=null,Gn(s,t,o,6);break;case 8:$d(),Ws=6;break e;default:throw Error(d(462))}}Xv();break}catch(re){Xh(s,re)}while(!0);return $a=$l=null,O.H=l,O.A=c,ys=a,ds!==null?0:(Os=null,hs=0,Mr(),Ws)}function Xv(){for(;ds!==null&&!bt();)Zh(ds)}function Zh(s){var t=yh(s.alternate,s,el);s.memoizedProps=s.pendingProps,t===null?mc(s):ds=t}function Wh(s){var t=s,a=t.alternate;switch(t.tag){case 15:case 0:t=ph(a,t,t.pendingProps,t.type,void 0,hs);break;case 11:t=ph(a,t,t.pendingProps,t.type.render,t.ref,hs);break;case 5:id(t);default:_h(a,t),t=ds=Pm(t,el),t=yh(a,t,el)}s.memoizedProps=s.pendingProps,t===null?mc(s):ds=t}function Gn(s,t,a,l){$a=$l=null,id(t),zn=null,wi=0;var c=t.return;try{if(Lv(s,c,t,a,hs)){Ws=1,Wr(s,ra(a,s.current)),ds=null;return}}catch(o){if(c!==null)throw ds=c,o;Ws=1,Wr(s,ra(a,s.current)),ds=null;return}t.flags&32768?(js||l===1?s=!0:Un||(hs&536870912)!==0?s=!1:(Nl=s=!0,(l===2||l===9||l===3||l===6)&&(l=Pt.current,l!==null&&l.tag===13&&(l.flags|=16384))),ef(t,s)):mc(t)}function mc(s){var t=s;do{if((t.flags&32768)!==0){ef(t,Nl);return}s=t.return;var a=Hv(t.alternate,t,el);if(a!==null){ds=a;return}if(t=t.sibling,t!==null){ds=t;return}ds=t=s}while(t!==null);Ws===0&&(Ws=5)}function ef(s,t){do{var a=qv(s.alternate,s);if(a!==null){a.flags&=32767,ds=a;return}if(a=s.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(s=s.sibling,s!==null)){ds=s;return}ds=s=a}while(s!==null);Ws=6,ds=null}function sf(s,t,a,l,c,o,h,b,A){s.cancelPendingCommit=null;do xc();while(gt!==0);if((ys&6)!==0)throw Error(d(327));if(t!==null){if(t===s.current)throw Error(d(177));if(o=t.lanes|t.childLanes,o|=Do,io(s,a,o,h,b,A),s===Os&&(ds=Os=null,hs=0),Hn=t,_l=s,sl=a,Gd=o,Fd=c,$h=l,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,Zv(Be,function(){return rf(),null})):(s.callbackNode=null,s.callbackPriority=0),l=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||l){l=O.T,O.T=null,c=G.p,G.p=2,h=ys,ys|=4;try{Gv(s,t,a)}finally{ys=h,G.p=c,O.T=l}}gt=1,tf(),af(),lf()}}function tf(){if(gt===1){gt=0;var s=_l,t=Hn,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=O.T,O.T=null;var l=G.p;G.p=2;var c=ys;ys|=4;try{Lh(t,s);var o=au,h=Fm(s.containerInfo),b=o.focusedElem,A=o.selectionRange;if(h!==b&&b&&b.ownerDocument&&Gm(b.ownerDocument.documentElement,b)){if(A!==null&&To(b)){var J=A.start,re=A.end;if(re===void 0&&(re=J),"selectionStart"in b)b.selectionStart=J,b.selectionEnd=Math.min(re,b.value.length);else{var he=b.ownerDocument||document,W=he&&he.defaultView||window;if(W.getSelection){var ae=W.getSelection(),Ce=b.textContent.length,$e=Math.min(A.start,Ce),zs=A.end===void 0?$e:Math.min(A.end,Ce);!ae.extend&&$e>zs&&(h=zs,zs=$e,$e=h);var F=qm(b,$e),B=qm(b,zs);if(F&&B&&(ae.rangeCount!==1||ae.anchorNode!==F.node||ae.anchorOffset!==F.offset||ae.focusNode!==B.node||ae.focusOffset!==B.offset)){var K=he.createRange();K.setStart(F.node,F.offset),ae.removeAllRanges(),$e>zs?(ae.addRange(K),ae.extend(B.node,B.offset)):(K.setEnd(B.node,B.offset),ae.addRange(K))}}}}for(he=[],ae=b;ae=ae.parentNode;)ae.nodeType===1&&he.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;b<he.length;b++){var ue=he[b];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Sc=!!tu,au=tu=null}finally{ys=c,G.p=l,O.T=a}}s.current=t,gt=2}}function af(){if(gt===2){gt=0;var s=_l,t=Hn,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=O.T,O.T=null;var l=G.p;G.p=2;var c=ys;ys|=4;try{Mh(s,t.alternate,t)}finally{ys=c,G.p=l,O.T=a}}gt=3}}function lf(){if(gt===4||gt===3){gt=0,ot();var s=_l,t=Hn,a=sl,l=$h;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?gt=5:(gt=0,Hn=_l=null,nf(s,s.pendingLanes));var c=s.pendingLanes;if(c===0&&(wl=null),co(a),t=t.stateNode,be&&typeof be.onCommitFiberRoot=="function")try{be.onCommitFiberRoot(qs,t,void 0,(t.current.flags&128)===128)}catch{}if(l!==null){t=O.T,c=G.p,G.p=2,O.T=null;try{for(var o=s.onRecoverableError,h=0;h<l.length;h++){var b=l[h];o(b.value,{componentStack:b.stack})}}finally{O.T=t,G.p=c}}(sl&3)!==0&&xc(),Ma(s),c=s.pendingLanes,(a&261930)!==0&&(c&42)!==0?s===Vd?qi++:(qi=0,Vd=s):qi=0,Gi(0)}}function nf(s,t){(s.pooledCacheLanes&=t)===0&&(t=s.pooledCache,t!=null&&(s.pooledCache=null,Ni(t)))}function xc(){return tf(),af(),lf(),rf()}function rf(){if(gt!==5)return!1;var s=_l,t=Gd;Gd=0;var a=co(sl),l=O.T,c=G.p;try{G.p=32>a?32:a,O.T=null,a=Fd,Fd=null;var o=_l,h=sl;if(gt=0,Hn=_l=null,sl=0,(ys&6)!==0)throw Error(d(331));var b=ys;if(ys|=4,Gh(o.current),Bh(o,o.current,h,a),ys=b,Gi(0,!1),be&&typeof be.onPostCommitFiberRoot=="function")try{be.onPostCommitFiberRoot(qs,o)}catch{}return!0}finally{G.p=c,O.T=l,nf(s,t)}}function cf(s,t,a){t=ra(a,t),t=Nd(s.stateNode,t,2),s=gl(s,t,2),s!==null&&(Ns(s,2),Ma(s))}function Cs(s,t,a){if(s.tag===3)cf(s,s,a);else for(;t!==null;){if(t.tag===3){cf(t,s,a);break}else if(t.tag===1){var l=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof l.componentDidCatch=="function"&&(wl===null||!wl.has(l))){s=ra(a,s),a=ch(2),l=gl(t,a,2),l!==null&&(oh(a,l,t,s),Ns(l,2),Ma(l));break}}t=t.return}}function Id(s,t,a){var l=s.pingCache;if(l===null){l=s.pingCache=new $v;var c=new Set;l.set(t,c)}else c=l.get(t),c===void 0&&(c=new Set,l.set(t,c));c.has(a)||(Bd=!0,c.add(a),s=Kv.bind(null,s,t,a),t.then(s,s))}function Kv(s,t,a){var l=s.pingCache;l!==null&&l.delete(t),s.pingedLanes|=s.suspendedLanes&a,s.warmLanes&=~a,Os===s&&(hs&a)===a&&(Ws===4||Ws===3&&(hs&62914560)===hs&&300>Ds()-rc?(ys&2)===0&&qn(s,0):Hd|=a,Bn===hs&&(Bn=0)),Ma(s)}function of(s,t){t===0&&(t=ge()),s=Gl(s,t),s!==null&&(Ns(s,t),Ma(s))}function Jv(s){var t=s.memoizedState,a=0;t!==null&&(a=t.retryLane),of(s,a)}function Pv(s,t){var a=0;switch(s.tag){case 31:case 13:var l=s.stateNode,c=s.memoizedState;c!==null&&(a=c.retryLane);break;case 19:l=s.stateNode;break;case 22:l=s.stateNode._retryCache;break;default:throw Error(d(314))}l!==null&&l.delete(t),of(s,a)}function Zv(s,t){return Ys(s,t)}var hc=null,Fn=null,Yd=!1,fc=!1,Xd=!1,Cl=0;function Ma(s){s!==Fn&&s.next===null&&(Fn===null?hc=Fn=s:Fn=Fn.next=s),fc=!0,Yd||(Yd=!0,eb())}function Gi(s,t){if(!Xd&&fc){Xd=!0;do for(var a=!1,l=hc;l!==null;){if(s!==0){var c=l.pendingLanes;if(c===0)var o=0;else{var h=l.suspendedLanes,b=l.pingedLanes;o=(1<<31-Ae(42|s)+1)-1,o&=c&~(h&~b),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(a=!0,xf(l,o))}else o=hs,o=Ba(l,l===Os?o:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),(o&3)===0||ne(l,o)||(a=!0,xf(l,o));l=l.next}while(a);Xd=!1}}function Wv(){df()}function df(){fc=Yd=!1;var s=0;Cl!==0&&db()&&(s=Cl);for(var t=Ds(),a=null,l=hc;l!==null;){var c=l.next,o=uf(l,t);o===0?(l.next=null,a===null?hc=c:a.next=c,c===null&&(Fn=a)):(a=l,(s!==0||(o&3)!==0)&&(fc=!0)),l=c}gt!==0&&gt!==5||Gi(s),Cl!==0&&(Cl=0)}function uf(s,t){for(var a=s.suspendedLanes,l=s.pingedLanes,c=s.expirationTimes,o=s.pendingLanes&-62914561;0<o;){var h=31-Ae(o),b=1<<h,A=c[h];A===-1?((b&a)===0||(b&l)!==0)&&(c[h]=T(b,t)):A<=t&&(s.expiredLanes|=b),o&=~b}if(t=Os,a=hs,a=Ba(s,s===t?a:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),l=s.callbackNode,a===0||s===t&&(Ss===2||Ss===9)||s.cancelPendingCommit!==null)return l!==null&&l!==null&&Hs(l),s.callbackNode=null,s.callbackPriority=0;if((a&3)===0||ne(s,a)){if(t=a&-a,t===s.callbackPriority)return t;switch(l!==null&&Hs(l),co(a)){case 2:case 8:a=Y;break;case 32:a=Be;break;case 268435456:a=Ye;break;default:a=Be}return l=mf.bind(null,s),a=Ys(a,l),s.callbackPriority=t,s.callbackNode=a,t}return l!==null&&l!==null&&Hs(l),s.callbackPriority=2,s.callbackNode=null,2}function mf(s,t){if(gt!==0&&gt!==5)return s.callbackNode=null,s.callbackPriority=0,null;var a=s.callbackNode;if(xc()&&s.callbackNode!==a)return null;var l=hs;return l=Ba(s,s===Os?l:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),l===0?null:(Ih(s,l,t),uf(s,Ds()),s.callbackNode!=null&&s.callbackNode===a?mf.bind(null,s):null)}function xf(s,t){if(xc())return null;Ih(s,t,!0)}function eb(){mb(function(){(ys&6)!==0?Ys(va,Wv):df()})}function Kd(){if(Cl===0){var s=kn;s===0&&(s=gs,gs<<=1,(gs&261888)===0&&(gs=256)),Cl=s}return Cl}function hf(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:wr(""+s)}function ff(s,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,s.id&&a.setAttribute("form",s.id),t.parentNode.insertBefore(a,t),s=new FormData(s),a.parentNode.removeChild(a),s}function sb(s,t,a,l,c){if(t==="submit"&&a&&a.stateNode===c){var o=hf((c[Ut]||null).action),h=l.submitter;h&&(t=(t=h[Ut]||null)?hf(t.formAction):h.getAttribute("formAction"),t!==null&&(o=t,h=null));var b=new kr("action","action",null,l,c);s.push({event:b,listeners:[{instance:null,listener:function(){if(l.defaultPrevented){if(Cl!==0){var A=h?ff(c,h):new FormData(c);fd(a,{pending:!0,data:A,method:c.method,action:o},null,A)}}else typeof o=="function"&&(b.preventDefault(),A=h?ff(c,h):new FormData(c),fd(a,{pending:!0,data:A,method:c.method,action:o},o,A))},currentTarget:c}]})}}for(var Jd=0;Jd<Ao.length;Jd++){var Pd=Ao[Jd],tb=Pd.toLowerCase(),ab=Pd[0].toUpperCase()+Pd.slice(1);ba(tb,"on"+ab)}ba(Qm,"onAnimationEnd"),ba(Im,"onAnimationIteration"),ba(Ym,"onAnimationStart"),ba("dblclick","onDoubleClick"),ba("focusin","onFocus"),ba("focusout","onBlur"),ba(vv,"onTransitionRun"),ba(bv,"onTransitionStart"),ba(Nv,"onTransitionCancel"),ba(Xm,"onTransitionEnd"),xn("onMouseEnter",["mouseout","mouseover"]),xn("onMouseLeave",["mouseout","mouseover"]),xn("onPointerEnter",["pointerout","pointerover"]),xn("onPointerLeave",["pointerout","pointerover"]),Ul("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ul("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ul("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ul("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ul("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ul("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fi="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),lb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Fi));function pf(s,t){t=(t&4)!==0;for(var a=0;a<s.length;a++){var l=s[a],c=l.event;l=l.listeners;e:{var o=void 0;if(t)for(var h=l.length-1;0<=h;h--){var b=l[h],A=b.instance,J=b.currentTarget;if(b=b.listener,A!==o&&c.isPropagationStopped())break e;o=b,c.currentTarget=J;try{o(c)}catch(re){zr(re)}c.currentTarget=null,o=A}else for(h=0;h<l.length;h++){if(b=l[h],A=b.instance,J=b.currentTarget,b=b.listener,A!==o&&c.isPropagationStopped())break e;o=b,c.currentTarget=J;try{o(c)}catch(re){zr(re)}c.currentTarget=null,o=A}}}}function us(s,t){var a=t[oo];a===void 0&&(a=t[oo]=new Set);var l=s+"__bubble";a.has(l)||(gf(t,s,2,!1),a.add(l))}function Zd(s,t,a){var l=0;t&&(l|=4),gf(a,s,l,t)}var pc="_reactListening"+Math.random().toString(36).slice(2);function Wd(s){if(!s[pc]){s[pc]=!0,om.forEach(function(a){a!=="selectionchange"&&(lb.has(a)||Zd(a,!1,s),Zd(a,!0,s))});var t=s.nodeType===9?s:s.ownerDocument;t===null||t[pc]||(t[pc]=!0,Zd("selectionchange",!1,t))}}function gf(s,t,a,l){switch(If(t)){case 2:var c=Ab;break;case 8:c=Db;break;default:c=hu}a=c.bind(null,t,a,s),c=void 0,!vo||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(c=!0),l?c!==void 0?s.addEventListener(t,a,{capture:!0,passive:c}):s.addEventListener(t,a,!0):c!==void 0?s.addEventListener(t,a,{passive:c}):s.addEventListener(t,a,!1)}function eu(s,t,a,l,c){var o=l;if((t&1)===0&&(t&2)===0&&l!==null)e:for(;;){if(l===null)return;var h=l.tag;if(h===3||h===4){var b=l.stateNode.containerInfo;if(b===c)break;if(h===4)for(h=l.return;h!==null;){var A=h.tag;if((A===3||A===4)&&h.stateNode.containerInfo===c)return;h=h.return}for(;b!==null;){if(h=dn(b),h===null)return;if(A=h.tag,A===5||A===6||A===26||A===27){l=o=h;continue e}b=b.parentNode}}l=l.return}Nm(function(){var J=o,re=go(a),he=[];e:{var W=Km.get(s);if(W!==void 0){var ae=kr,Ce=s;switch(s){case"keypress":if(Sr(a)===0)break e;case"keydown":case"keyup":ae=Pj;break;case"focusin":Ce="focus",ae=wo;break;case"focusout":Ce="blur",ae=wo;break;case"beforeblur":case"afterblur":ae=wo;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=_m;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=Hj;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=ev;break;case Qm:case Im:case Ym:ae=Fj;break;case Xm:ae=tv;break;case"scroll":case"scrollend":ae=Uj;break;case"wheel":ae=lv;break;case"copy":case"cut":case"paste":ae=$j;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=Cm;break;case"toggle":case"beforetoggle":ae=iv}var $e=(t&4)!==0,zs=!$e&&(s==="scroll"||s==="scrollend"),F=$e?W!==null?W+"Capture":null:W;$e=[];for(var B=J,K;B!==null;){var ue=B;if(K=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||K===null||F===null||(ue=di(B,F),ue!=null&&$e.push(Vi(B,ue,K))),zs)break;B=B.return}0<$e.length&&(W=new ae(W,Ce,null,a,re),he.push({event:W,listeners:$e}))}}if((t&7)===0){e:{if(W=s==="mouseover"||s==="pointerover",ae=s==="mouseout"||s==="pointerout",W&&a!==po&&(Ce=a.relatedTarget||a.fromElement)&&(dn(Ce)||Ce[on]))break e;if((ae||W)&&(W=re.window===re?re:(W=re.ownerDocument)?W.defaultView||W.parentWindow:window,ae?(Ce=a.relatedTarget||a.toElement,ae=J,Ce=Ce?dn(Ce):null,Ce!==null&&(zs=x(Ce),$e=Ce.tag,Ce!==zs||$e!==5&&$e!==27&&$e!==6)&&(Ce=null)):(ae=null,Ce=J),ae!==Ce)){if($e=_m,ue="onMouseLeave",F="onMouseEnter",B="mouse",(s==="pointerout"||s==="pointerover")&&($e=Cm,ue="onPointerLeave",F="onPointerEnter",B="pointer"),zs=ae==null?W:oi(ae),K=Ce==null?W:oi(Ce),W=new $e(ue,B+"leave",ae,a,re),W.target=zs,W.relatedTarget=K,ue=null,dn(re)===J&&($e=new $e(F,B+"enter",Ce,a,re),$e.target=K,$e.relatedTarget=zs,ue=$e),zs=ue,ae&&Ce)s:{for($e=nb,F=ae,B=Ce,K=0,ue=F;ue;ue=$e(ue))K++;ue=0;for(var Ue=B;Ue;Ue=$e(Ue))ue++;for(;0<K-ue;)F=$e(F),K--;for(;0<ue-K;)B=$e(B),ue--;for(;K--;){if(F===B||B!==null&&F===B.alternate){$e=F;break s}F=$e(F),B=$e(B)}$e=null}else $e=null;ae!==null&&jf(he,W,ae,$e,!1),Ce!==null&&zs!==null&&jf(he,zs,Ce,$e,!0)}}e:{if(W=J?oi(J):window,ae=W.nodeName&&W.nodeName.toLowerCase(),ae==="select"||ae==="input"&&W.type==="file")var vs=Om;else if(Am(W))if(Rm)vs=pv;else{vs=hv;var Me=xv}else ae=W.nodeName,!ae||ae.toLowerCase()!=="input"||W.type!=="checkbox"&&W.type!=="radio"?J&&fo(J.elementType)&&(vs=Om):vs=fv;if(vs&&(vs=vs(s,J))){Dm(he,vs,a,re);break e}Me&&Me(s,W,J),s==="focusout"&&J&&W.type==="number"&&J.memoizedProps.value!=null&&ho(W,"number",W.value)}switch(Me=J?oi(J):window,s){case"focusin":(Am(Me)||Me.contentEditable==="true")&&(vn=Me,Eo=J,ji=null);break;case"focusout":ji=Eo=vn=null;break;case"mousedown":zo=!0;break;case"contextmenu":case"mouseup":case"dragend":zo=!1,Vm(he,a,re);break;case"selectionchange":if(jv)break;case"keydown":case"keyup":Vm(he,a,re)}var We;if(So)e:{switch(s){case"compositionstart":var fs="onCompositionStart";break e;case"compositionend":fs="onCompositionEnd";break e;case"compositionupdate":fs="onCompositionUpdate";break e}fs=void 0}else jn?zm(s,a)&&(fs="onCompositionEnd"):s==="keydown"&&a.keyCode===229&&(fs="onCompositionStart");fs&&(km&&a.locale!=="ko"&&(jn||fs!=="onCompositionStart"?fs==="onCompositionEnd"&&jn&&(We=ym()):(dl=re,bo="value"in dl?dl.value:dl.textContent,jn=!0)),Me=gc(J,fs),0<Me.length&&(fs=new Sm(fs,s,null,a,re),he.push({event:fs,listeners:Me}),We?fs.data=We:(We=Mm(a),We!==null&&(fs.data=We)))),(We=cv?ov(s,a):dv(s,a))&&(fs=gc(J,"onBeforeInput"),0<fs.length&&(Me=new Sm("onBeforeInput","beforeinput",null,a,re),he.push({event:Me,listeners:fs}),Me.data=We)),sb(he,s,J,a,re)}pf(he,t)})}function Vi(s,t,a){return{instance:s,listener:t,currentTarget:a}}function gc(s,t){for(var a=t+"Capture",l=[];s!==null;){var c=s,o=c.stateNode;if(c=c.tag,c!==5&&c!==26&&c!==27||o===null||(c=di(s,a),c!=null&&l.unshift(Vi(s,c,o)),c=di(s,t),c!=null&&l.push(Vi(s,c,o))),s.tag===3)return l;s=s.return}return[]}function nb(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function jf(s,t,a,l,c){for(var o=t._reactName,h=[];a!==null&&a!==l;){var b=a,A=b.alternate,J=b.stateNode;if(b=b.tag,A!==null&&A===l)break;b!==5&&b!==26&&b!==27||J===null||(A=J,c?(J=di(a,o),J!=null&&h.unshift(Vi(a,J,A))):c||(J=di(a,o),J!=null&&h.push(Vi(a,J,A)))),a=a.return}h.length!==0&&s.push({event:t,listeners:h})}var ib=/\r\n?/g,rb=/\u0000|\uFFFD/g;function vf(s){return(typeof s=="string"?s:""+s).replace(ib,`
`).replace(rb,"")}function bf(s,t){return t=vf(t),vf(s)===t}function Es(s,t,a,l,c,o){switch(a){case"children":typeof l=="string"?t==="body"||t==="textarea"&&l===""||fn(s,l):(typeof l=="number"||typeof l=="bigint")&&t!=="body"&&fn(s,""+l);break;case"className":Nr(s,"class",l);break;case"tabIndex":Nr(s,"tabindex",l);break;case"dir":case"role":case"viewBox":case"width":case"height":Nr(s,a,l);break;case"style":vm(s,l,o);break;case"data":if(t!=="object"){Nr(s,"data",l);break}case"src":case"href":if(l===""&&(t!=="a"||a!=="href")){s.removeAttribute(a);break}if(l==null||typeof l=="function"||typeof l=="symbol"||typeof l=="boolean"){s.removeAttribute(a);break}l=wr(""+l),s.setAttribute(a,l);break;case"action":case"formAction":if(typeof l=="function"){s.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(a==="formAction"?(t!=="input"&&Es(s,t,"name",c.name,c,null),Es(s,t,"formEncType",c.formEncType,c,null),Es(s,t,"formMethod",c.formMethod,c,null),Es(s,t,"formTarget",c.formTarget,c,null)):(Es(s,t,"encType",c.encType,c,null),Es(s,t,"method",c.method,c,null),Es(s,t,"target",c.target,c,null)));if(l==null||typeof l=="symbol"||typeof l=="boolean"){s.removeAttribute(a);break}l=wr(""+l),s.setAttribute(a,l);break;case"onClick":l!=null&&(s.onclick=qa);break;case"onScroll":l!=null&&us("scroll",s);break;case"onScrollEnd":l!=null&&us("scrollend",s);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(d(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(d(60));s.innerHTML=a}}break;case"multiple":s.multiple=l&&typeof l!="function"&&typeof l!="symbol";break;case"muted":s.muted=l&&typeof l!="function"&&typeof l!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(l==null||typeof l=="function"||typeof l=="boolean"||typeof l=="symbol"){s.removeAttribute("xlink:href");break}a=wr(""+l),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":l!=null&&typeof l!="function"&&typeof l!="symbol"?s.setAttribute(a,""+l):s.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":l&&typeof l!="function"&&typeof l!="symbol"?s.setAttribute(a,""):s.removeAttribute(a);break;case"capture":case"download":l===!0?s.setAttribute(a,""):l!==!1&&l!=null&&typeof l!="function"&&typeof l!="symbol"?s.setAttribute(a,l):s.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":l!=null&&typeof l!="function"&&typeof l!="symbol"&&!isNaN(l)&&1<=l?s.setAttribute(a,l):s.removeAttribute(a);break;case"rowSpan":case"start":l==null||typeof l=="function"||typeof l=="symbol"||isNaN(l)?s.removeAttribute(a):s.setAttribute(a,l);break;case"popover":us("beforetoggle",s),us("toggle",s),br(s,"popover",l);break;case"xlinkActuate":Ha(s,"http://www.w3.org/1999/xlink","xlink:actuate",l);break;case"xlinkArcrole":Ha(s,"http://www.w3.org/1999/xlink","xlink:arcrole",l);break;case"xlinkRole":Ha(s,"http://www.w3.org/1999/xlink","xlink:role",l);break;case"xlinkShow":Ha(s,"http://www.w3.org/1999/xlink","xlink:show",l);break;case"xlinkTitle":Ha(s,"http://www.w3.org/1999/xlink","xlink:title",l);break;case"xlinkType":Ha(s,"http://www.w3.org/1999/xlink","xlink:type",l);break;case"xmlBase":Ha(s,"http://www.w3.org/XML/1998/namespace","xml:base",l);break;case"xmlLang":Ha(s,"http://www.w3.org/XML/1998/namespace","xml:lang",l);break;case"xmlSpace":Ha(s,"http://www.w3.org/XML/1998/namespace","xml:space",l);break;case"is":br(s,"is",l);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=Rj.get(a)||a,br(s,a,l))}}function su(s,t,a,l,c,o){switch(a){case"style":vm(s,l,o);break;case"dangerouslySetInnerHTML":if(l!=null){if(typeof l!="object"||!("__html"in l))throw Error(d(61));if(a=l.__html,a!=null){if(c.children!=null)throw Error(d(60));s.innerHTML=a}}break;case"children":typeof l=="string"?fn(s,l):(typeof l=="number"||typeof l=="bigint")&&fn(s,""+l);break;case"onScroll":l!=null&&us("scroll",s);break;case"onScrollEnd":l!=null&&us("scrollend",s);break;case"onClick":l!=null&&(s.onclick=qa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!dm.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(c=a.endsWith("Capture"),t=a.slice(2,c?a.length-7:void 0),o=s[Ut]||null,o=o!=null?o[a]:null,typeof o=="function"&&s.removeEventListener(t,o,c),typeof l=="function")){typeof o!="function"&&o!==null&&(a in s?s[a]=null:s.hasAttribute(a)&&s.removeAttribute(a)),s.addEventListener(t,l,c);break e}a in s?s[a]=l:l===!0?s.setAttribute(a,""):br(s,a,l)}}}function Et(s,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":us("error",s),us("load",s);var l=!1,c=!1,o;for(o in a)if(a.hasOwnProperty(o)){var h=a[o];if(h!=null)switch(o){case"src":l=!0;break;case"srcSet":c=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(d(137,t));default:Es(s,t,o,h,a,null)}}c&&Es(s,t,"srcSet",a.srcSet,a,null),l&&Es(s,t,"src",a.src,a,null);return;case"input":us("invalid",s);var b=o=h=c=null,A=null,J=null;for(l in a)if(a.hasOwnProperty(l)){var re=a[l];if(re!=null)switch(l){case"name":c=re;break;case"type":h=re;break;case"checked":A=re;break;case"defaultChecked":J=re;break;case"value":o=re;break;case"defaultValue":b=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(d(137,t));break;default:Es(s,t,l,re,a,null)}}fm(s,o,b,A,J,h,c,!1);return;case"select":us("invalid",s),l=h=o=null;for(c in a)if(a.hasOwnProperty(c)&&(b=a[c],b!=null))switch(c){case"value":o=b;break;case"defaultValue":h=b;break;case"multiple":l=b;default:Es(s,t,c,b,a,null)}t=o,a=h,s.multiple=!!l,t!=null?hn(s,!!l,t,!1):a!=null&&hn(s,!!l,a,!0);return;case"textarea":us("invalid",s),o=c=l=null;for(h in a)if(a.hasOwnProperty(h)&&(b=a[h],b!=null))switch(h){case"value":l=b;break;case"defaultValue":c=b;break;case"children":o=b;break;case"dangerouslySetInnerHTML":if(b!=null)throw Error(d(91));break;default:Es(s,t,h,b,a,null)}gm(s,l,c,o);return;case"option":for(A in a)if(a.hasOwnProperty(A)&&(l=a[A],l!=null))switch(A){case"selected":s.selected=l&&typeof l!="function"&&typeof l!="symbol";break;default:Es(s,t,A,l,a,null)}return;case"dialog":us("beforetoggle",s),us("toggle",s),us("cancel",s),us("close",s);break;case"iframe":case"object":us("load",s);break;case"video":case"audio":for(l=0;l<Fi.length;l++)us(Fi[l],s);break;case"image":us("error",s),us("load",s);break;case"details":us("toggle",s);break;case"embed":case"source":case"link":us("error",s),us("load",s);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(J in a)if(a.hasOwnProperty(J)&&(l=a[J],l!=null))switch(J){case"children":case"dangerouslySetInnerHTML":throw Error(d(137,t));default:Es(s,t,J,l,a,null)}return;default:if(fo(t)){for(re in a)a.hasOwnProperty(re)&&(l=a[re],l!==void 0&&su(s,t,re,l,a,void 0));return}}for(b in a)a.hasOwnProperty(b)&&(l=a[b],l!=null&&Es(s,t,b,l,a,null))}function cb(s,t,a,l){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var c=null,o=null,h=null,b=null,A=null,J=null,re=null;for(ae in a){var he=a[ae];if(a.hasOwnProperty(ae)&&he!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":A=he;default:l.hasOwnProperty(ae)||Es(s,t,ae,null,l,he)}}for(var W in l){var ae=l[W];if(he=a[W],l.hasOwnProperty(W)&&(ae!=null||he!=null))switch(W){case"type":o=ae;break;case"name":c=ae;break;case"checked":J=ae;break;case"defaultChecked":re=ae;break;case"value":h=ae;break;case"defaultValue":b=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(d(137,t));break;default:ae!==he&&Es(s,t,W,ae,l,he)}}xo(s,h,b,A,J,re,o,c);return;case"select":ae=h=b=W=null;for(o in a)if(A=a[o],a.hasOwnProperty(o)&&A!=null)switch(o){case"value":break;case"multiple":ae=A;default:l.hasOwnProperty(o)||Es(s,t,o,null,l,A)}for(c in l)if(o=l[c],A=a[c],l.hasOwnProperty(c)&&(o!=null||A!=null))switch(c){case"value":W=o;break;case"defaultValue":b=o;break;case"multiple":h=o;default:o!==A&&Es(s,t,c,o,l,A)}t=b,a=h,l=ae,W!=null?hn(s,!!a,W,!1):!!l!=!!a&&(t!=null?hn(s,!!a,t,!0):hn(s,!!a,a?[]:"",!1));return;case"textarea":ae=W=null;for(b in a)if(c=a[b],a.hasOwnProperty(b)&&c!=null&&!l.hasOwnProperty(b))switch(b){case"value":break;case"children":break;default:Es(s,t,b,null,l,c)}for(h in l)if(c=l[h],o=a[h],l.hasOwnProperty(h)&&(c!=null||o!=null))switch(h){case"value":W=c;break;case"defaultValue":ae=c;break;case"children":break;case"dangerouslySetInnerHTML":if(c!=null)throw Error(d(91));break;default:c!==o&&Es(s,t,h,c,l,o)}pm(s,W,ae);return;case"option":for(var Ce in a)if(W=a[Ce],a.hasOwnProperty(Ce)&&W!=null&&!l.hasOwnProperty(Ce))switch(Ce){case"selected":s.selected=!1;break;default:Es(s,t,Ce,null,l,W)}for(A in l)if(W=l[A],ae=a[A],l.hasOwnProperty(A)&&W!==ae&&(W!=null||ae!=null))switch(A){case"selected":s.selected=W&&typeof W!="function"&&typeof W!="symbol";break;default:Es(s,t,A,W,l,ae)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var $e in a)W=a[$e],a.hasOwnProperty($e)&&W!=null&&!l.hasOwnProperty($e)&&Es(s,t,$e,null,l,W);for(J in l)if(W=l[J],ae=a[J],l.hasOwnProperty(J)&&W!==ae&&(W!=null||ae!=null))switch(J){case"children":case"dangerouslySetInnerHTML":if(W!=null)throw Error(d(137,t));break;default:Es(s,t,J,W,l,ae)}return;default:if(fo(t)){for(var zs in a)W=a[zs],a.hasOwnProperty(zs)&&W!==void 0&&!l.hasOwnProperty(zs)&&su(s,t,zs,void 0,l,W);for(re in l)W=l[re],ae=a[re],!l.hasOwnProperty(re)||W===ae||W===void 0&&ae===void 0||su(s,t,re,W,l,ae);return}}for(var F in a)W=a[F],a.hasOwnProperty(F)&&W!=null&&!l.hasOwnProperty(F)&&Es(s,t,F,null,l,W);for(he in l)W=l[he],ae=a[he],!l.hasOwnProperty(he)||W===ae||W==null&&ae==null||Es(s,t,he,W,l,ae)}function Nf(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ob(){if(typeof performance.getEntriesByType=="function"){for(var s=0,t=0,a=performance.getEntriesByType("resource"),l=0;l<a.length;l++){var c=a[l],o=c.transferSize,h=c.initiatorType,b=c.duration;if(o&&b&&Nf(h)){for(h=0,b=c.responseEnd,l+=1;l<a.length;l++){var A=a[l],J=A.startTime;if(J>b)break;var re=A.transferSize,he=A.initiatorType;re&&Nf(he)&&(A=A.responseEnd,h+=re*(A<b?1:(b-J)/(A-J)))}if(--l,t+=8*(o+h)/(c.duration/1e3),s++,10<s)break}}if(0<s)return t/s/1e6}return navigator.connection&&(s=navigator.connection.downlink,typeof s=="number")?s:5}var tu=null,au=null;function jc(s){return s.nodeType===9?s:s.ownerDocument}function yf(s){switch(s){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function wf(s,t){if(s===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return s===1&&t==="foreignObject"?0:s}function lu(s,t){return s==="textarea"||s==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var nu=null;function db(){var s=window.event;return s&&s.type==="popstate"?s===nu?!1:(nu=s,!0):(nu=null,!1)}var _f=typeof setTimeout=="function"?setTimeout:void 0,ub=typeof clearTimeout=="function"?clearTimeout:void 0,Sf=typeof Promise=="function"?Promise:void 0,mb=typeof queueMicrotask=="function"?queueMicrotask:typeof Sf<"u"?function(s){return Sf.resolve(null).then(s).catch(xb)}:_f;function xb(s){setTimeout(function(){throw s})}function kl(s){return s==="head"}function Cf(s,t){var a=t,l=0;do{var c=a.nextSibling;if(s.removeChild(a),c&&c.nodeType===8)if(a=c.data,a==="/$"||a==="/&"){if(l===0){s.removeChild(c),In(t);return}l--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")l++;else if(a==="html")$i(s.ownerDocument.documentElement);else if(a==="head"){a=s.ownerDocument.head,$i(a);for(var o=a.firstChild;o;){var h=o.nextSibling,b=o.nodeName;o[ci]||b==="SCRIPT"||b==="STYLE"||b==="LINK"&&o.rel.toLowerCase()==="stylesheet"||a.removeChild(o),o=h}}else a==="body"&&$i(s.ownerDocument.body);a=c}while(a);In(t)}function kf(s,t){var a=s;s=0;do{var l=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),l&&l.nodeType===8)if(a=l.data,a==="/$"){if(s===0)break;s--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||s++;a=l}while(a)}function iu(s){var t=s.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":iu(a),uo(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}s.removeChild(a)}}function hb(s,t,a,l){for(;s.nodeType===1;){var c=a;if(s.nodeName.toLowerCase()!==t.toLowerCase()){if(!l&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(l){if(!s[ci])switch(t){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(o=s.getAttribute("rel"),o==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(o!==c.rel||s.getAttribute("href")!==(c.href==null||c.href===""?null:c.href)||s.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin)||s.getAttribute("title")!==(c.title==null?null:c.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(o=s.getAttribute("src"),(o!==(c.src==null?null:c.src)||s.getAttribute("type")!==(c.type==null?null:c.type)||s.getAttribute("crossorigin")!==(c.crossOrigin==null?null:c.crossOrigin))&&o&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(t==="input"&&s.type==="hidden"){var o=c.name==null?null:""+c.name;if(c.type==="hidden"&&s.getAttribute("name")===o)return s}else return s;if(s=ma(s.nextSibling),s===null)break}return null}function fb(s,t,a){if(t==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!a||(s=ma(s.nextSibling),s===null))return null;return s}function Tf(s,t){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!t||(s=ma(s.nextSibling),s===null))return null;return s}function ru(s){return s.data==="$?"||s.data==="$~"}function cu(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function pb(s,t){var a=s.ownerDocument;if(s.data==="$~")s._reactRetry=t;else if(s.data!=="$?"||a.readyState!=="loading")t();else{var l=function(){t(),a.removeEventListener("DOMContentLoaded",l)};a.addEventListener("DOMContentLoaded",l),s._reactRetry=l}}function ma(s){for(;s!=null;s=s.nextSibling){var t=s.nodeType;if(t===1||t===3)break;if(t===8){if(t=s.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return s}var ou=null;function Ef(s){s=s.nextSibling;for(var t=0;s;){if(s.nodeType===8){var a=s.data;if(a==="/$"||a==="/&"){if(t===0)return ma(s.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}s=s.nextSibling}return null}function zf(s){s=s.previousSibling;for(var t=0;s;){if(s.nodeType===8){var a=s.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return s;t--}else a!=="/$"&&a!=="/&"||t++}s=s.previousSibling}return null}function Mf(s,t,a){switch(t=jc(a),s){case"html":if(s=t.documentElement,!s)throw Error(d(452));return s;case"head":if(s=t.head,!s)throw Error(d(453));return s;case"body":if(s=t.body,!s)throw Error(d(454));return s;default:throw Error(d(451))}}function $i(s){for(var t=s.attributes;t.length;)s.removeAttributeNode(t[0]);uo(s)}var xa=new Map,Af=new Set;function vc(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var tl=G.d;G.d={f:gb,r:jb,D:vb,C:bb,L:Nb,m:yb,X:_b,S:wb,M:Sb};function gb(){var s=tl.f(),t=dc();return s||t}function jb(s){var t=un(s);t!==null&&t.tag===5&&t.type==="form"?Xx(t):tl.r(s)}var Vn=typeof document>"u"?null:document;function Df(s,t,a){var l=Vn;if(l&&typeof t=="string"&&t){var c=na(t);c='link[rel="'+s+'"][href="'+c+'"]',typeof a=="string"&&(c+='[crossorigin="'+a+'"]'),Af.has(c)||(Af.add(c),s={rel:s,crossOrigin:a,href:t},l.querySelector(c)===null&&(t=l.createElement("link"),Et(t,"link",s),yt(t),l.head.appendChild(t)))}}function vb(s){tl.D(s),Df("dns-prefetch",s,null)}function bb(s,t){tl.C(s,t),Df("preconnect",s,t)}function Nb(s,t,a){tl.L(s,t,a);var l=Vn;if(l&&s&&t){var c='link[rel="preload"][as="'+na(t)+'"]';t==="image"&&a&&a.imageSrcSet?(c+='[imagesrcset="'+na(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(c+='[imagesizes="'+na(a.imageSizes)+'"]')):c+='[href="'+na(s)+'"]';var o=c;switch(t){case"style":o=$n(s);break;case"script":o=Qn(s)}xa.has(o)||(s=w({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:s,as:t},a),xa.set(o,s),l.querySelector(c)!==null||t==="style"&&l.querySelector(Qi(o))||t==="script"&&l.querySelector(Ii(o))||(t=l.createElement("link"),Et(t,"link",s),yt(t),l.head.appendChild(t)))}}function yb(s,t){tl.m(s,t);var a=Vn;if(a&&s){var l=t&&typeof t.as=="string"?t.as:"script",c='link[rel="modulepreload"][as="'+na(l)+'"][href="'+na(s)+'"]',o=c;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=Qn(s)}if(!xa.has(o)&&(s=w({rel:"modulepreload",href:s},t),xa.set(o,s),a.querySelector(c)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ii(o)))return}l=a.createElement("link"),Et(l,"link",s),yt(l),a.head.appendChild(l)}}}function wb(s,t,a){tl.S(s,t,a);var l=Vn;if(l&&s){var c=mn(l).hoistableStyles,o=$n(s);t=t||"default";var h=c.get(o);if(!h){var b={loading:0,preload:null};if(h=l.querySelector(Qi(o)))b.loading=5;else{s=w({rel:"stylesheet",href:s,"data-precedence":t},a),(a=xa.get(o))&&du(s,a);var A=h=l.createElement("link");yt(A),Et(A,"link",s),A._p=new Promise(function(J,re){A.onload=J,A.onerror=re}),A.addEventListener("load",function(){b.loading|=1}),A.addEventListener("error",function(){b.loading|=2}),b.loading|=4,bc(h,t,l)}h={type:"stylesheet",instance:h,count:1,state:b},c.set(o,h)}}}function _b(s,t){tl.X(s,t);var a=Vn;if(a&&s){var l=mn(a).hoistableScripts,c=Qn(s),o=l.get(c);o||(o=a.querySelector(Ii(c)),o||(s=w({src:s,async:!0},t),(t=xa.get(c))&&uu(s,t),o=a.createElement("script"),yt(o),Et(o,"link",s),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(c,o))}}function Sb(s,t){tl.M(s,t);var a=Vn;if(a&&s){var l=mn(a).hoistableScripts,c=Qn(s),o=l.get(c);o||(o=a.querySelector(Ii(c)),o||(s=w({src:s,async:!0,type:"module"},t),(t=xa.get(c))&&uu(s,t),o=a.createElement("script"),yt(o),Et(o,"link",s),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},l.set(c,o))}}function Of(s,t,a,l){var c=(c=oe.current)?vc(c):null;if(!c)throw Error(d(446));switch(s){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=$n(a.href),a=mn(c).hoistableStyles,l=a.get(t),l||(l={type:"style",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){s=$n(a.href);var o=mn(c).hoistableStyles,h=o.get(s);if(h||(c=c.ownerDocument||c,h={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(s,h),(o=c.querySelector(Qi(s)))&&!o._p&&(h.instance=o,h.state.loading=5),xa.has(s)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},xa.set(s,a),o||Cb(c,s,a,h.state))),t&&l===null)throw Error(d(528,""));return h}if(t&&l!==null)throw Error(d(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Qn(a),a=mn(c).hoistableScripts,l=a.get(t),l||(l={type:"script",instance:null,count:0,state:null},a.set(t,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(d(444,s))}}function $n(s){return'href="'+na(s)+'"'}function Qi(s){return'link[rel="stylesheet"]['+s+"]"}function Rf(s){return w({},s,{"data-precedence":s.precedence,precedence:null})}function Cb(s,t,a,l){s.querySelector('link[rel="preload"][as="style"]['+t+"]")?l.loading=1:(t=s.createElement("link"),l.preload=t,t.addEventListener("load",function(){return l.loading|=1}),t.addEventListener("error",function(){return l.loading|=2}),Et(t,"link",a),yt(t),s.head.appendChild(t))}function Qn(s){return'[src="'+na(s)+'"]'}function Ii(s){return"script[async]"+s}function Lf(s,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var l=s.querySelector('style[data-href~="'+na(a.href)+'"]');if(l)return t.instance=l,yt(l),l;var c=w({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return l=(s.ownerDocument||s).createElement("style"),yt(l),Et(l,"style",c),bc(l,a.precedence,s),t.instance=l;case"stylesheet":c=$n(a.href);var o=s.querySelector(Qi(c));if(o)return t.state.loading|=4,t.instance=o,yt(o),o;l=Rf(a),(c=xa.get(c))&&du(l,c),o=(s.ownerDocument||s).createElement("link"),yt(o);var h=o;return h._p=new Promise(function(b,A){h.onload=b,h.onerror=A}),Et(o,"link",l),t.state.loading|=4,bc(o,a.precedence,s),t.instance=o;case"script":return o=Qn(a.src),(c=s.querySelector(Ii(o)))?(t.instance=c,yt(c),c):(l=a,(c=xa.get(o))&&(l=w({},a),uu(l,c)),s=s.ownerDocument||s,c=s.createElement("script"),yt(c),Et(c,"link",l),s.head.appendChild(c),t.instance=c);case"void":return null;default:throw Error(d(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(l=t.instance,t.state.loading|=4,bc(l,a.precedence,s));return t.instance}function bc(s,t,a){for(var l=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),c=l.length?l[l.length-1]:null,o=c,h=0;h<l.length;h++){var b=l[h];if(b.dataset.precedence===t)o=b;else if(o!==c)break}o?o.parentNode.insertBefore(s,o.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(s,t.firstChild))}function du(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.title==null&&(s.title=t.title)}function uu(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.integrity==null&&(s.integrity=t.integrity)}var Nc=null;function Uf(s,t,a){if(Nc===null){var l=new Map,c=Nc=new Map;c.set(a,l)}else c=Nc,l=c.get(a),l||(l=new Map,c.set(a,l));if(l.has(s))return l;for(l.set(s,null),a=a.getElementsByTagName(s),c=0;c<a.length;c++){var o=a[c];if(!(o[ci]||o[St]||s==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var h=o.getAttribute(t)||"";h=s+h;var b=l.get(h);b?b.push(o):l.set(h,[o])}}return l}function Bf(s,t,a){s=s.ownerDocument||s,s.head.insertBefore(a,t==="title"?s.querySelector("head > title"):null)}function kb(s,t,a){if(a===1||t.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return s=t.disabled,typeof t.precedence=="string"&&s==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Hf(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function Tb(s,t,a,l){if(a.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var c=$n(l.href),o=t.querySelector(Qi(c));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(s.count++,s=yc.bind(s),t.then(s,s)),a.state.loading|=4,a.instance=o,yt(o);return}o=t.ownerDocument||t,l=Rf(l),(c=xa.get(c))&&du(l,c),o=o.createElement("link"),yt(o);var h=o;h._p=new Promise(function(b,A){h.onload=b,h.onerror=A}),Et(o,"link",l),a.instance=o}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(s.count++,a=yc.bind(s),t.addEventListener("load",a),t.addEventListener("error",a))}}var mu=0;function Eb(s,t){return s.stylesheets&&s.count===0&&_c(s,s.stylesheets),0<s.count||0<s.imgCount?function(a){var l=setTimeout(function(){if(s.stylesheets&&_c(s,s.stylesheets),s.unsuspend){var o=s.unsuspend;s.unsuspend=null,o()}},6e4+t);0<s.imgBytes&&mu===0&&(mu=62500*ob());var c=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&_c(s,s.stylesheets),s.unsuspend)){var o=s.unsuspend;s.unsuspend=null,o()}},(s.imgBytes>mu?50:800)+t);return s.unsuspend=a,function(){s.unsuspend=null,clearTimeout(l),clearTimeout(c)}}:null}function yc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_c(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var wc=null;function _c(s,t){s.stylesheets=null,s.unsuspend!==null&&(s.count++,wc=new Map,t.forEach(zb,s),wc=null,yc.call(s))}function zb(s,t){if(!(t.state.loading&4)){var a=wc.get(s);if(a)var l=a.get(null);else{a=new Map,wc.set(s,a);for(var c=s.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<c.length;o++){var h=c[o];(h.nodeName==="LINK"||h.getAttribute("media")!=="not all")&&(a.set(h.dataset.precedence,h),l=h)}l&&a.set(null,l)}c=t.instance,h=c.getAttribute("data-precedence"),o=a.get(h)||l,o===l&&a.set(null,c),a.set(h,c),this.count++,l=yc.bind(this),c.addEventListener("load",l),c.addEventListener("error",l),o?o.parentNode.insertBefore(c,o.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(c,s.firstChild)),t.state.loading|=4}}var Yi={$$typeof:R,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function Mb(s,t,a,l,c,o,h,b,A){this.tag=1,this.containerInfo=s,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ze(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ze(0),this.hiddenUpdates=ze(null),this.identifierPrefix=l,this.onUncaughtError=c,this.onCaughtError=o,this.onRecoverableError=h,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function qf(s,t,a,l,c,o,h,b,A,J,re,he){return s=new Mb(s,t,a,h,A,J,re,he,b),t=1,o===!0&&(t|=24),o=Jt(3,null,null,t),s.current=o,o.stateNode=s,t=Qo(),t.refCount++,s.pooledCache=t,t.refCount++,o.memoizedState={element:l,isDehydrated:a,cache:t},Ko(o),s}function Gf(s){return s?(s=yn,s):yn}function Ff(s,t,a,l,c,o){c=Gf(c),l.context===null?l.context=c:l.pendingContext=c,l=pl(t),l.payload={element:a},o=o===void 0?null:o,o!==null&&(l.callback=o),a=gl(s,l,t),a!==null&&(Vt(a,s,t),Si(a,s,t))}function Vf(s,t){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var a=s.retryLane;s.retryLane=a!==0&&a<t?a:t}}function xu(s,t){Vf(s,t),(s=s.alternate)&&Vf(s,t)}function $f(s){if(s.tag===13||s.tag===31){var t=Gl(s,67108864);t!==null&&Vt(t,s,67108864),xu(s,67108864)}}function Qf(s){if(s.tag===13||s.tag===31){var t=sa();t=ro(t);var a=Gl(s,t);a!==null&&Vt(a,s,t),xu(s,t)}}var Sc=!0;function Ab(s,t,a,l){var c=O.T;O.T=null;var o=G.p;try{G.p=2,hu(s,t,a,l)}finally{G.p=o,O.T=c}}function Db(s,t,a,l){var c=O.T;O.T=null;var o=G.p;try{G.p=8,hu(s,t,a,l)}finally{G.p=o,O.T=c}}function hu(s,t,a,l){if(Sc){var c=fu(l);if(c===null)eu(s,t,l,Cc,a),Yf(s,l);else if(Rb(c,s,t,a,l))l.stopPropagation();else if(Yf(s,l),t&4&&-1<Ob.indexOf(s)){for(;c!==null;){var o=un(c);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var h=Dt(o.pendingLanes);if(h!==0){var b=o;for(b.pendingLanes|=2,b.entangledLanes|=2;h;){var A=1<<31-Ae(h);b.entanglements[1]|=A,h&=~A}Ma(o),(ys&6)===0&&(cc=Ds()+500,Gi(0))}}break;case 31:case 13:b=Gl(o,2),b!==null&&Vt(b,o,2),dc(),xu(o,2)}if(o=fu(l),o===null&&eu(s,t,l,Cc,a),o===c)break;c=o}c!==null&&l.stopPropagation()}else eu(s,t,l,null,a)}}function fu(s){return s=go(s),pu(s)}var Cc=null;function pu(s){if(Cc=null,s=dn(s),s!==null){var t=x(s);if(t===null)s=null;else{var a=t.tag;if(a===13){if(s=f(t),s!==null)return s;s=null}else if(a===31){if(s=p(t),s!==null)return s;s=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;s=null}else t!==s&&(s=null)}}return Cc=s,null}function If(s){switch(s){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ks()){case va:return 2;case Y:return 8;case Be:case Ee:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var gu=!1,Tl=null,El=null,zl=null,Xi=new Map,Ki=new Map,Ml=[],Ob="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Yf(s,t){switch(s){case"focusin":case"focusout":Tl=null;break;case"dragenter":case"dragleave":El=null;break;case"mouseover":case"mouseout":zl=null;break;case"pointerover":case"pointerout":Xi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ki.delete(t.pointerId)}}function Ji(s,t,a,l,c,o){return s===null||s.nativeEvent!==o?(s={blockedOn:t,domEventName:a,eventSystemFlags:l,nativeEvent:o,targetContainers:[c]},t!==null&&(t=un(t),t!==null&&$f(t)),s):(s.eventSystemFlags|=l,t=s.targetContainers,c!==null&&t.indexOf(c)===-1&&t.push(c),s)}function Rb(s,t,a,l,c){switch(t){case"focusin":return Tl=Ji(Tl,s,t,a,l,c),!0;case"dragenter":return El=Ji(El,s,t,a,l,c),!0;case"mouseover":return zl=Ji(zl,s,t,a,l,c),!0;case"pointerover":var o=c.pointerId;return Xi.set(o,Ji(Xi.get(o)||null,s,t,a,l,c)),!0;case"gotpointercapture":return o=c.pointerId,Ki.set(o,Ji(Ki.get(o)||null,s,t,a,l,c)),!0}return!1}function Xf(s){var t=dn(s.target);if(t!==null){var a=x(t);if(a!==null){if(t=a.tag,t===13){if(t=f(a),t!==null){s.blockedOn=t,rm(s.priority,function(){Qf(a)});return}}else if(t===31){if(t=p(a),t!==null){s.blockedOn=t,rm(s.priority,function(){Qf(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){s.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}s.blockedOn=null}function kc(s){if(s.blockedOn!==null)return!1;for(var t=s.targetContainers;0<t.length;){var a=fu(s.nativeEvent);if(a===null){a=s.nativeEvent;var l=new a.constructor(a.type,a);po=l,a.target.dispatchEvent(l),po=null}else return t=un(a),t!==null&&$f(t),s.blockedOn=a,!1;t.shift()}return!0}function Kf(s,t,a){kc(s)&&a.delete(t)}function Lb(){gu=!1,Tl!==null&&kc(Tl)&&(Tl=null),El!==null&&kc(El)&&(El=null),zl!==null&&kc(zl)&&(zl=null),Xi.forEach(Kf),Ki.forEach(Kf)}function Tc(s,t){s.blockedOn===t&&(s.blockedOn=null,gu||(gu=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Lb)))}var Ec=null;function Jf(s){Ec!==s&&(Ec=s,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Ec===s&&(Ec=null);for(var t=0;t<s.length;t+=3){var a=s[t],l=s[t+1],c=s[t+2];if(typeof l!="function"){if(pu(l||a)===null)continue;break}var o=un(a);o!==null&&(s.splice(t,3),t-=3,fd(o,{pending:!0,data:c,method:a.method,action:l},l,c))}}))}function In(s){function t(A){return Tc(A,s)}Tl!==null&&Tc(Tl,s),El!==null&&Tc(El,s),zl!==null&&Tc(zl,s),Xi.forEach(t),Ki.forEach(t);for(var a=0;a<Ml.length;a++){var l=Ml[a];l.blockedOn===s&&(l.blockedOn=null)}for(;0<Ml.length&&(a=Ml[0],a.blockedOn===null);)Xf(a),a.blockedOn===null&&Ml.shift();if(a=(s.ownerDocument||s).$$reactFormReplay,a!=null)for(l=0;l<a.length;l+=3){var c=a[l],o=a[l+1],h=c[Ut]||null;if(typeof o=="function")h||Jf(a);else if(h){var b=null;if(o&&o.hasAttribute("formAction")){if(c=o,h=o[Ut]||null)b=h.formAction;else if(pu(c)!==null)continue}else b=h.action;typeof b=="function"?a[l+1]=b:(a.splice(l,3),l-=3),Jf(a)}}}function Pf(){function s(o){o.canIntercept&&o.info==="react-transition"&&o.intercept({handler:function(){return new Promise(function(h){return c=h})},focusReset:"manual",scroll:"manual"})}function t(){c!==null&&(c(),c=null),l||setTimeout(a,20)}function a(){if(!l&&!navigation.transition){var o=navigation.currentEntry;o&&o.url!=null&&navigation.navigate(o.url,{state:o.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var l=!1,c=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){l=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),c!==null&&(c(),c=null)}}}function ju(s){this._internalRoot=s}zc.prototype.render=ju.prototype.render=function(s){var t=this._internalRoot;if(t===null)throw Error(d(409));var a=t.current,l=sa();Ff(a,l,s,t,null,null)},zc.prototype.unmount=ju.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var t=s.containerInfo;Ff(s.current,2,null,s,null,null),dc(),t[on]=null}};function zc(s){this._internalRoot=s}zc.prototype.unstable_scheduleHydration=function(s){if(s){var t=im();s={blockedOn:null,target:s,priority:t};for(var a=0;a<Ml.length&&t!==0&&t<Ml[a].priority;a++);Ml.splice(a,0,s),a===0&&Xf(s)}};var Zf=i.version;if(Zf!=="19.2.0")throw Error(d(527,Zf,"19.2.0"));G.findDOMNode=function(s){var t=s._reactInternals;if(t===void 0)throw typeof s.render=="function"?Error(d(188)):(s=Object.keys(s).join(","),Error(d(268,s)));return s=N(t),s=s!==null?j(s):null,s=s===null?null:s.stateNode,s};var Ub={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Mc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mc.isDisabled&&Mc.supportsFiber)try{qs=Mc.inject(Ub),be=Mc}catch{}}return er.createRoot=function(s,t){if(!m(s))throw Error(d(299));var a=!1,l="",c=lh,o=nh,h=ih;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(l=t.identifierPrefix),t.onUncaughtError!==void 0&&(c=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(h=t.onRecoverableError)),t=qf(s,1,!1,null,null,a,l,null,c,o,h,Pf),s[on]=t.current,Wd(s),new ju(t)},er.hydrateRoot=function(s,t,a){if(!m(s))throw Error(d(299));var l=!1,c="",o=lh,h=nh,b=ih,A=null;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(c=a.identifierPrefix),a.onUncaughtError!==void 0&&(o=a.onUncaughtError),a.onCaughtError!==void 0&&(h=a.onCaughtError),a.onRecoverableError!==void 0&&(b=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),t=qf(s,1,!0,t,a??null,l,c,A,o,h,b,Pf),t.context=Gf(null),a=t.current,l=sa(),l=ro(l),c=pl(l),c.callback=null,gl(a,c,l),a=l,t.current.lanes=a,Ns(t,a),Ma(t),s[on]=t.current,Wd(s),new zc(t)},er.version="19.2.0",er}var cp;function x0(){if(cp)return _u.exports;cp=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(i){console.error(i)}}return n(),_u.exports=m0(),_u.exports}var h0=x0();function q(...n){return Kb(Jb(n))}const Qe=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("rounded-xl border bg-card text-card-foreground shadow",n),...i}));Qe.displayName="Card";const ss=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("flex flex-col space-y-1.5 p-6",n),...i}));ss.displayName="CardHeader";const ts=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("font-semibold leading-none tracking-tight",n),...i}));ts.displayName="CardTitle";const st=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("text-sm text-muted-foreground",n),...i}));st.displayName="CardDescription";const ps=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("p-6 pt-0",n),...i}));ps.displayName="CardContent";const Tg=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("flex items-center p-6 pt-0",n),...i}));Tg.displayName="CardFooter";const Ca=Wb,pa=u.forwardRef(({className:n,...i},r)=>e.jsx(Ep,{ref:r,className:q("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n),...i}));pa.displayName=Ep.displayName;const es=u.forwardRef(({className:n,...i},r)=>e.jsx(zp,{ref:r,className:q("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all duration-300 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",n),...i}));es.displayName=zp.displayName;const ws=u.forwardRef(({className:n,...i},r)=>e.jsx(Mp,{ref:r,className:q("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[state=active]:animate-in data-[state=active]:fade-in data-[state=active]:duration-300",n),...i}));ws.displayName=Mp.displayName;const Ke=u.forwardRef(({className:n,children:i,viewportRef:r,...d},m)=>e.jsxs(Ap,{ref:m,className:q("relative overflow-hidden",n),...d,children:[e.jsx(eN,{ref:r,className:"h-full w-full rounded-[inherit]",children:i}),e.jsx(Hu,{}),e.jsx(Hu,{orientation:"horizontal"}),e.jsx(sN,{})]}));Ke.displayName=Ap.displayName;const Hu=u.forwardRef(({className:n,orientation:i="vertical",...r},d)=>e.jsx(Dp,{ref:d,orientation:i,className:q("flex touch-none select-none transition-colors",i==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",i==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...r,children:e.jsx(tN,{className:"relative flex-1 rounded-full bg-border"})}));Hu.displayName=Dp.displayName;function Eg({className:n,...i}){return e.jsx("div",{className:q("animate-pulse rounded-md bg-primary/10",n),...i})}const ni=u.forwardRef(({className:n,value:i,...r},d)=>e.jsx(Op,{ref:d,className:q("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",n),...r,children:e.jsx(aN,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(i||0)}%)`}})}));ni.displayName=Op.displayName;const f0={light:"",dark:".dark"},zg=u.createContext(null);function Mg(){const n=u.useContext(zg);if(!n)throw new Error("useChart must be used within a <ChartContainer />");return n}const Xn=u.forwardRef(({id:n,className:i,children:r,config:d,...m},x)=>{const f=u.useId(),p=`chart-${n||f.replace(/:/g,"")}`;return e.jsx(zg.Provider,{value:{config:d},children:e.jsxs("div",{"data-chart":p,ref:x,className:q("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",i),...m,children:[e.jsx(p0,{id:p,config:d}),e.jsx(vN,{children:r})]})})});Xn.displayName="Chart";const p0=({id:n,config:i})=>{const r=Object.entries(i).filter(([,d])=>d.theme||d.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(f0).map(([d,m])=>`
${m} [data-chart=${n}] {
${r.map(([x,f])=>{const p=f.theme?.[d]||f.color;return p?` --color-${x}: ${p};`:null}).join(`
`)}
}
`).join(`
`)}}):null},sr=bN,Kn=u.forwardRef(({active:n,payload:i,className:r,indicator:d="dot",hideLabel:m=!1,hideIndicator:x=!1,label:f,labelFormatter:p,labelClassName:g,formatter:N,color:j,nameKey:w,labelKey:y},k)=>{const{config:_}=Mg(),L=u.useMemo(()=>{if(m||!i?.length)return null;const[U]=i,Q=`${y||U?.dataKey||U?.name||"value"}`,R=qu(_,U,Q),z=!y&&typeof f=="string"?_[f]?.label||f:R?.label;return p?e.jsx("div",{className:q("font-medium",g),children:p(z,i)}):z?e.jsx("div",{className:q("font-medium",g),children:z}):null},[f,p,i,m,g,_,y]);if(!n||!i?.length)return null;const D=i.length===1&&d!=="dot";return e.jsxs("div",{ref:k,className:q("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[D?null:L,e.jsx("div",{className:"grid gap-1.5",children:i.filter(U=>U.type!=="none").map((U,Q)=>{const R=`${w||U.name||U.dataKey||"value"}`,z=qu(_,U,R),I=j||U.payload.fill||U.color;return e.jsx("div",{className:q("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",d==="dot"&&"items-center"),children:N&&U?.value!==void 0&&U.name?N(U.value,U.name,U,Q,U.payload):e.jsxs(e.Fragment,{children:[z?.icon?e.jsx(z.icon,{}):!x&&e.jsx("div",{className:q("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":d==="dot","w-1":d==="line","w-0 border-[1.5px] border-dashed bg-transparent":d==="dashed","my-0.5":D&&d==="dashed"}),style:{"--color-bg":I,"--color-border":I}}),e.jsxs("div",{className:q("flex flex-1 justify-between leading-none",D?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[D?L:null,e.jsx("span",{className:"text-muted-foreground",children:z?.label||U.name})]}),U.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:U.value.toLocaleString()})]})]})},U.dataKey)})})]})});Kn.displayName="ChartTooltip";const g0=NN,Ag=u.forwardRef(({className:n,hideIcon:i=!1,payload:r,verticalAlign:d="bottom",nameKey:m},x)=>{const{config:f}=Mg();return r?.length?e.jsx("div",{ref:x,className:q("flex items-center justify-center gap-4",d==="top"?"pb-3":"pt-3",n),children:r.filter(p=>p.type!=="none").map(p=>{const g=`${m||p.dataKey||"value"}`,N=qu(f,p,g);return e.jsxs("div",{className:q("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[N?.icon&&!i?e.jsx(N.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:p.color}}),N?.label]},p.value)})}):null});Ag.displayName="ChartLegend";function qu(n,i,r){if(typeof i!="object"||i===null)return;const d="payload"in i&&typeof i.payload=="object"&&i.payload!==null?i.payload:void 0;let m=r;return r in i&&typeof i[r]=="string"?m=i[r]:d&&r in d&&typeof d[r]=="string"&&(m=d[r]),m in n?n[m]:n[r]}const mr=si("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"}}),S=u.forwardRef(({className:n,variant:i,size:r,asChild:d=!1,...m},x)=>{const f=d?kN:"button";return e.jsx(f,{className:q(mr({variant:i,size:r,className:n})),ref:x,...m})});S.displayName="Button";const j0=si("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/80",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 Fe({className:n,variant:i,...r}){return e.jsx("div",{className:q(j0({variant:i}),n),...r})}const v0=5,b0=5e3;let ku=0;function N0(){return ku=(ku+1)%Number.MAX_SAFE_INTEGER,ku.toString()}const Tu=new Map,op=n=>{if(Tu.has(n))return;const i=setTimeout(()=>{Tu.delete(n),cr({type:"REMOVE_TOAST",toastId:n})},b0);Tu.set(n,i)},y0=(n,i)=>{switch(i.type){case"ADD_TOAST":return{...n,toasts:[i.toast,...n.toasts].slice(0,v0)};case"UPDATE_TOAST":return{...n,toasts:n.toasts.map(r=>r.id===i.toast.id?{...r,...i.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=i;return r?op(r):n.toasts.forEach(d=>{op(d.id)}),{...n,toasts:n.toasts.map(d=>d.id===r||r===void 0?{...d,open:!1}:d)}}case"REMOVE_TOAST":return i.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(r=>r.id!==i.toastId)}}},Gc=[];let Fc={toasts:[]};function cr(n){Fc=y0(Fc,n),Gc.forEach(i=>{i(Fc)})}function w0({...n}){const i=N0(),r=m=>cr({type:"UPDATE_TOAST",toast:{...m,id:i}}),d=()=>cr({type:"DISMISS_TOAST",toastId:i});return cr({type:"ADD_TOAST",toast:{...n,id:i,open:!0,onOpenChange:m=>{m||d()}}}),{id:i,dismiss:d,update:r}}function Bs(){const[n,i]=u.useState(Fc);return u.useEffect(()=>(Gc.push(i),()=>{const r=Gc.indexOf(i);r>-1&&Gc.splice(r,1)}),[n]),{...n,toast:w0,dismiss:r=>cr({type:"DISMISS_TOAST",toastId:r})}}const _0=n=>{const i=[];for(let r=0;r<n;r++){const d=r*137.508%360;i.push(`hsl(${d}, 70%, 55%)`)}return i};function S0(){const[n,i]=u.useState(null),[r,d]=u.useState(!0),[m,x]=u.useState(0),[f,p]=u.useState(24),[g,N]=u.useState(!0),[j,w]=u.useState(null),[y,k]=u.useState(!0),[_,L]=u.useState(null),[D,U]=u.useState(!1),{toast:Q}=Bs(),R=u.useCallback(async()=>{try{k(!0);const v=await Ac.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");w({hitokoto:v.data.hitokoto,from:v.data.from||v.data.from_who||"未知"})}catch(v){console.error("获取一言失败:",v),w({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{k(!1)}},[]),z=u.useCallback(async()=>{try{const v=localStorage.getItem("access-token"),X=await Ac.get("/api/webui/system/status",{headers:{Authorization:`Bearer ${v}`}});L(X.data)}catch(v){console.error("获取机器人状态失败:",v),L(null)}},[]),I=async()=>{if(!D)try{U(!0);const v=localStorage.getItem("access-token");await Ac.post("/api/webui/system/restart",{},{headers:{Authorization:`Bearer ${v}`}}),Q({title:"重启中",description:"麦麦正在重启,请稍候..."}),setTimeout(()=>{z(),U(!1)},3e3)}catch(v){console.error("重启失败:",v),Q({title:"重启失败",description:"无法重启麦麦,请检查控制台",variant:"destructive"}),U(!1)}},$=u.useCallback(async()=>{try{const v=localStorage.getItem("access-token"),X=await Ac.get(`/api/webui/statistics/dashboard?hours=${f}`,{headers:{Authorization:`Bearer ${v}`}});i(X.data),d(!1),x(100)}catch(v){console.error("Failed to fetch dashboard data:",v),d(!1),x(100)}},[f]);if(u.useEffect(()=>{if(!r)return;x(0);const v=setTimeout(()=>x(15),200),X=setTimeout(()=>x(30),800),me=setTimeout(()=>x(45),2e3),ce=setTimeout(()=>x(60),4e3),xe=setTimeout(()=>x(75),6500),we=setTimeout(()=>x(85),9e3),oe=setTimeout(()=>x(92),11e3);return()=>{clearTimeout(v),clearTimeout(X),clearTimeout(me),clearTimeout(ce),clearTimeout(xe),clearTimeout(we),clearTimeout(oe)}},[r]),u.useEffect(()=>{$(),R(),z()},[$,R,z]),u.useEffect(()=>{if(!g)return;const v=setInterval(()=>{$(),z()},3e4);return()=>clearInterval(v)},[g,$,z]),r||!n)return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:e.jsxs("div",{className:"text-center space-y-6 w-full max-w-md px-4",children:[e.jsx(zt,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-lg font-medium",children:"加载统计数据中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取麦麦运行数据"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ni,{value:m,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[m,"%"]})]})]})});const{summary:E,model_stats:M=[],hourly_data:se=[],daily_data:fe=[],recent_activity:ve=[]}=n,Ne=E??{total_requests:0,total_cost:0,total_tokens:0,online_time:0,total_messages:0,total_replies:0,avg_response_time:0,cost_per_hour:0,tokens_per_hour:0},je=v=>{const X=Math.floor(v/3600),me=Math.floor(v%3600/60);return`${X}小时${me}分钟`},ye=v=>{const X=v.toLocaleString("zh-CN");return v>=1e9?{display:`${(v/1e9).toFixed(2)}B`,exact:X,needsExact:!0}:v>=1e6?{display:`${(v/1e6).toFixed(2)}M`,exact:X,needsExact:!0}:v>=1e4?{display:`${(v/1e3).toFixed(1)}K`,exact:X,needsExact:!0}:v>=1e3?{display:`${(v/1e3).toFixed(2)}K`,exact:X,needsExact:!0}:{display:X,exact:X,needsExact:!1}},Se=v=>{const X=`¥${v.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`;return v>=1e6?{display:`¥${(v/1e6).toFixed(2)}M`,exact:X,needsExact:!0}:v>=1e4?{display:`¥${(v/1e3).toFixed(1)}K`,exact:X,needsExact:!0}:v>=1e3?{display:`¥${(v/1e3).toFixed(2)}K`,exact:X,needsExact:!0}:{display:X,exact:X,needsExact:!1}},O=v=>new Date(v).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),G=_0(M.length),H=M.map((v,X)=>({name:v.model_name,value:v.request_count,fill:G[X]})),ee={requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"},tokens:{label:"Tokens",color:"hsl(var(--chart-3))"}};return e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"实时监控面板"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"麦麦运行状态和统计数据一览"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ca,{value:f.toString(),onValueChange:v=>p(Number(v)),children:e.jsxs(pa,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(es,{value:"24",children:"24小时"}),e.jsx(es,{value:"168",children:"7天"}),e.jsx(es,{value:"720",children:"30天"})]})}),e.jsxs(S,{variant:g?"default":"outline",size:"sm",onClick:()=>N(!g),className:"gap-2",children:[e.jsx(zt,{className:`h-4 w-4 ${g?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:$,children:e.jsx(zt,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20",children:[y?e.jsx(Eg,{className:"h-5 flex-1"}):j?e.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',j.hitokoto,'" —— ',j.from]}):null,e.jsx(S,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:R,disabled:y,children:e.jsx(zt,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Qe,{className:"lg:col-span-1",children:[e.jsx(ss,{className:"pb-3",children:e.jsxs(ts,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pr,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(ps,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:_?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Fe,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(aa,{className:"h-3 w-3 mr-1"}),"运行中"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-red-500"}),e.jsxs(Fe,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Mt,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),_&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",_.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",je(_.uptime)]})]})]})})]}),e.jsxs(Qe,{children:[e.jsx(ss,{className:"pb-3",children:e.jsxs(ts,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(sn,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(ps,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:I,disabled:D,className:"gap-2",children:[e.jsx(Vc,{className:`h-4 w-4 ${D?"animate-spin":""}`}),D?"重启中...":"重启麦麦"]}),e.jsx(S,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yn,{to:"/logs",children:[e.jsx(_a,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(S,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yn,{to:"/plugins",children:[e.jsx(JN,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(S,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yn,{to:"/settings",children:[e.jsx(ti,{className:"h-4 w-4"}),"系统设置"]})})]})})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"pb-3",children:[e.jsxs(ts,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(PN,{className:"h-4 w-4"}),"反馈问卷"]}),e.jsx(st,{className:"text-xs",children:"帮助我们改进产品体验"})]}),e.jsx(ps,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yn,{to:"/survey/webui-feedback",children:[e.jsx(_a,{className:"h-4 w-4"}),"WebUI 反馈"]})}),e.jsx(S,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Yn,{to:"/survey/maibot-feedback",children:[e.jsx(Dl,{className:"h-4 w-4"}),"麦麦反馈"]})})]})})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(ZN,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[ye(Ne.total_requests).display,ye(Ne.total_requests).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",ye(Ne.total_requests).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",f<48?f+"小时":Math.floor(f/24)+"天"]})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"总花费"}),e.jsx(WN,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[Se(Ne.total_cost).display,Se(Ne.total_cost).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",Se(Ne.total_cost).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Ne.cost_per_hour>0?`¥${Ne.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx($c,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[ye(Ne.total_tokens).display,ye(Ne.total_tokens).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",ye(Ne.total_tokens).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Ne.tokens_per_hour>0?`${ye(Ne.tokens_per_hour).display}/小时`:"暂无数据"})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(sn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[Ne.avg_response_time.toFixed(2),"s"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"API平均耗时"})]})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-3",children:[e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(Pn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ps,{children:e.jsxs("div",{className:"text-xl font-bold",children:[je(Ne.online_time),e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",Ne.online_time.toLocaleString(),"秒)"]})]})})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(Dl,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsxs("div",{className:"text-xl font-bold",children:[ye(Ne.total_messages).display,ye(Ne.total_messages).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",ye(Ne.total_messages).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",ye(Ne.total_replies).display,ye(Ne.total_replies).needsExact&&e.jsxs("span",{children:["(",ye(Ne.total_replies).exact,")"]})," 条"]})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(ey,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsx("div",{className:"text-xl font-bold",children:Ne.total_messages>0?`¥${(Ne.total_cost/Ne.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(Ca,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(es,{value:"trends",children:"趋势"}),e.jsx(es,{value:"models",children:"模型"}),e.jsx(es,{value:"activity",children:"活动"}),e.jsx(es,{value:"daily",children:"日统计"})]}),e.jsxs(ws,{value:"trends",className:"space-y-4",children:[e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"请求趋势"}),e.jsxs(st,{children:["最近",f,"小时的请求量变化"]})]}),e.jsx(ps,{children:e.jsx(Xn,{config:ee,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(yN,{data:se,children:[e.jsx(Dc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Oc,{dataKey:"timestamp",tickFormatter:v=>O(v),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Wi,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(sr,{content:e.jsx(Kn,{labelFormatter:v=>O(v)})}),e.jsx(wN,{type:"monotone",dataKey:"requests",stroke:"var(--color-requests)",strokeWidth:2})]})})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"花费趋势"}),e.jsx(st,{children:"API调用成本变化"})]}),e.jsx(ps,{children:e.jsx(Xn,{config:ee,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Nu,{data:se,children:[e.jsx(Dc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Oc,{dataKey:"timestamp",tickFormatter:v=>O(v),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Wi,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(sr,{content:e.jsx(Kn,{labelFormatter:v=>O(v)})}),e.jsx(Rc,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"Token消耗"}),e.jsx(st,{children:"Token使用量变化"})]}),e.jsx(ps,{children:e.jsx(Xn,{config:ee,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Nu,{data:se,children:[e.jsx(Dc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Oc,{dataKey:"timestamp",tickFormatter:v=>O(v),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Wi,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(sr,{content:e.jsx(Kn,{labelFormatter:v=>O(v)})}),e.jsx(Rc,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(ws,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"模型请求分布"}),e.jsxs(st,{children:["各模型使用占比 (共 ",M.length," 个模型)"]})]}),e.jsx(ps,{children:e.jsx(Xn,{config:Object.fromEntries(M.map((v,X)=>[v.model_name,{label:v.model_name,color:G[X]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(_N,{children:[e.jsx(sr,{content:e.jsx(Kn,{})}),e.jsx(SN,{data:H,cx:"50%",cy:"50%",labelLine:!1,label:({name:v,percent:X})=>X&&X<.05?"":`${v} ${X?(X*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:H.map((v,X)=>e.jsx(CN,{fill:v.fill},`cell-${X}`))})]})})})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"模型详细统计"}),e.jsx(st,{children:"请求数、花费和性能"})]}),e.jsx(ps,{children:e.jsx(Ke,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:M.map((v,X)=>e.jsxs("div",{className:"p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h4",{className:"font-semibold text-sm truncate flex-1 min-w-0",children:v.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${X%5+1}))`}})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"请求数:"}),e.jsx("span",{className:"ml-1 font-medium",children:v.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",v.total_cost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[(v.total_tokens/1e3).toFixed(1),"K"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"平均耗时:"}),e.jsxs("span",{className:"ml-1 font-medium",children:[v.avg_response_time.toFixed(2),"s"]})]})]})]},X))})})})]})]})}),e.jsx(ws,{value:"activity",children:e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"最近活动"}),e.jsx(st,{children:"最新的API调用记录"})]}),e.jsx(ps,{children:e.jsx(Ke,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:ve.map((v,X)=>e.jsxs("div",{className:"p-3 sm:p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:v.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:v.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:O(v.timestamp)})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),e.jsx("span",{className:"ml-1",children:v.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",v.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[v.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${v.status==="success"?"text-green-600":"text-red-600"}`,children:v.status})]})]})]},X))})})})]})}),e.jsx(ws,{value:"daily",children:e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"每日统计"}),e.jsx(st,{children:"最近7天的数据汇总"})]}),e.jsx(ps,{children:e.jsx(Xn,{config:{requests:{label:"请求数",color:"hsl(var(--chart-1))"},cost:{label:"花费(¥)",color:"hsl(var(--chart-2))"}},className:"h-[400px] sm:h-[500px] w-full aspect-auto",children:e.jsxs(Nu,{data:fe,children:[e.jsx(Dc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Oc,{dataKey:"timestamp",tickFormatter:v=>{const X=new Date(v);return`${X.getMonth()+1}/${X.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Wi,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Wi,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(sr,{content:e.jsx(Kn,{labelFormatter:v=>new Date(v).toLocaleDateString("zh-CN")})}),e.jsx(g0,{content:e.jsx(Ag,{})}),e.jsx(Rc,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Rc,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]})]})})}const C0={theme:"system",setTheme:()=>null},Dg=u.createContext(C0),Ku=()=>{const n=u.useContext(Dg);if(n===void 0)throw new Error("useTheme must be used within a ThemeProvider");return n},k0=(n,i,r)=>{const d=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||d){i(n);return}const m=r.clientX,x=r.clientY,f=Math.hypot(Math.max(m,innerWidth-m),Math.max(x,innerHeight-x));document.startViewTransition(()=>{i(n)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${m}px ${x}px)`,`circle(${f}px at ${m}px ${x}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},Og=u.createContext(void 0),Rg=()=>{const n=u.useContext(Og);if(n===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return n},Ve=u.forwardRef(({className:n,...i},r)=>e.jsx(Rp,{className:q("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",n),...i,ref:r,children:e.jsx(lN,{className:q("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")})}));Ve.displayName=Rp.displayName;const T0=si("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),C=u.forwardRef(({className:n,...i},r)=>e.jsx(Kp,{ref:r,className:q(T0(),n),...i}));C.displayName=Kp.displayName;const ie=u.forwardRef(({className:n,type:i,...r},d)=>e.jsx("input",{type:i,className:q("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",n),ref:d,...r}));ie.displayName="Input";const E0=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:n=>n.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:n=>/[A-Z]/.test(n)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:n=>/[a-z]/.test(n)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:n=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(n)}];function z0(n){const i=E0.map(d=>({id:d.id,label:d.label,description:d.description,passed:d.validate(n)}));return{isValid:i.every(d=>d.passed),rules:i}}const Zc="0.11.7 Beta",Ju="MaiBot Dashboard",M0=`${Ju} v${Zc}`,A0=(n="v")=>`${n}${Zc}`,$t={THEME:"maibot-ui-theme",ACCENT_COLOR:"accent-color",ENABLE_ANIMATIONS:"maibot-animations",ENABLE_WAVES_BACKGROUND:"maibot-waves-background",LOG_CACHE_SIZE:"maibot-log-cache-size",LOG_AUTO_SCROLL:"maibot-log-auto-scroll",LOG_FONT_SIZE:"maibot-log-font-size",LOG_LINE_SPACING:"maibot-log-line-spacing",DATA_SYNC_INTERVAL:"maibot-data-sync-interval",WS_RECONNECT_INTERVAL:"maibot-ws-reconnect-interval",WS_MAX_RECONNECT_ATTEMPTS:"maibot-ws-max-reconnect-attempts",COMPLETED_TOURS:"maibot-completed-tours"},Da={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function et(n){const i=Lg(n),r=localStorage.getItem(i);if(r===null)return Da[n];const d=Da[n];if(typeof d=="boolean")return r==="true";if(typeof d=="number"){const m=parseFloat(r);return isNaN(m)?d:m}return r}function Jn(n,i){const r=Lg(n);localStorage.setItem(r,String(i)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:n,value:i}}))}function D0(){return{theme:et("theme"),accentColor:et("accentColor"),enableAnimations:et("enableAnimations"),enableWavesBackground:et("enableWavesBackground"),logCacheSize:et("logCacheSize"),logAutoScroll:et("logAutoScroll"),logFontSize:et("logFontSize"),logLineSpacing:et("logLineSpacing"),dataSyncInterval:et("dataSyncInterval"),wsReconnectInterval:et("wsReconnectInterval"),wsMaxReconnectAttempts:et("wsMaxReconnectAttempts")}}function O0(){const n=D0(),i=localStorage.getItem($t.COMPLETED_TOURS),r=i?JSON.parse(i):[];return{...n,completedTours:r}}function R0(n){const i=[],r=[];for(const[d,m]of Object.entries(n)){if(d==="completedTours"){Array.isArray(m)?(localStorage.setItem($t.COMPLETED_TOURS,JSON.stringify(m)),i.push("completedTours")):r.push("completedTours");continue}if(d in Da){const x=d,f=Da[x];if(typeof m==typeof f){if(x==="theme"&&!["light","dark","system"].includes(m)){r.push(d);continue}if(x==="logFontSize"&&!["xs","sm","base"].includes(m)){r.push(d);continue}Jn(x,m),i.push(d)}else r.push(d)}else r.push(d)}return{success:i.length>0,imported:i,skipped:r}}function L0(){for(const n of Object.keys(Da))Jn(n,Da[n]);localStorage.removeItem($t.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function U0(){const n=[],i=[],r=[];for(let d=0;d<localStorage.length;d++){const m=localStorage.key(d);m&&(m.startsWith("maibot")||m.startsWith("accent-color")||m==="access-token")&&r.push(m)}for(const d of r)localStorage.removeItem(d),n.push(d);return{clearedKeys:n,preservedKeys:i}}function dp(){let n=0;const i=[];for(let r=0;r<localStorage.length;r++){const d=localStorage.key(r);if(d){const m=localStorage.getItem(d)||"",x=(d.length+m.length)*2;n+=x,i.push({key:d,size:x})}}return i.sort((r,d)=>d.size-r.size),{used:n,items:localStorage.length,details:i}}function B0(n){if(n===0)return"0 B";const i=1024,r=["B","KB","MB"],d=Math.floor(Math.log(n)/Math.log(i));return parseFloat((n/Math.pow(i,d)).toFixed(2))+" "+r[d]}function Lg(n){return{theme:$t.THEME,accentColor:$t.ACCENT_COLOR,enableAnimations:$t.ENABLE_ANIMATIONS,enableWavesBackground:$t.ENABLE_WAVES_BACKGROUND,logCacheSize:$t.LOG_CACHE_SIZE,logAutoScroll:$t.LOG_AUTO_SCROLL,logFontSize:$t.LOG_FONT_SIZE,logLineSpacing:$t.LOG_LINE_SPACING,dataSyncInterval:$t.DATA_SYNC_INTERVAL,wsReconnectInterval:$t.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:$t.WS_MAX_RECONNECT_ATTEMPTS}[n]}const fa=u.forwardRef(({className:n,...i},r)=>e.jsxs(Lp,{ref:r,className:q("relative flex w-full touch-none select-none items-center",n),...i,children:[e.jsx(nN,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(iN,{className:"absolute h-full bg-primary"})}),e.jsx(rN,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));fa.displayName=Lp.displayName;class H0{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return et("logCacheSize")}getMaxReconnectAttempts(){return et("wsMaxReconnectAttempts")}getReconnectInterval(){return et("wsReconnectInterval")}getWebSocketUrl(){{const i=window.location.protocol==="https:"?"wss:":"ws:",r=window.location.host;return`${i}//${r}/ws/logs`}}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;const i=this.getWebSocketUrl();try{this.ws=new WebSocket(i),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=r=>{try{if(r.data==="pong")return;const d=JSON.parse(r.data);this.notifyLog(d)}catch(d){console.error("解析日志消息失败:",d)}},this.ws.onerror=r=>{console.error("❌ WebSocket 错误:",r),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(r){console.error("创建 WebSocket 连接失败:",r),this.attemptReconnect()}}attemptReconnect(){const i=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=i)return;this.reconnectAttempts+=1;const r=this.getReconnectInterval(),d=Math.min(r*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},d)}startHeartbeat(){this.heartbeatInterval=window.setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send("ping")},3e4)}stopHeartbeat(){this.heartbeatInterval!==null&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}disconnect(){this.reconnectTimeout!==null&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.stopHeartbeat(),this.ws&&(this.ws.close(),this.ws=null),this.isConnected=!1,this.reconnectAttempts=0}onLog(i){return this.logCallbacks.add(i),()=>this.logCallbacks.delete(i)}onConnectionChange(i){return this.connectionCallbacks.add(i),i(this.isConnected),()=>this.connectionCallbacks.delete(i)}notifyLog(i){if(!this.logCache.some(d=>d.id===i.id)){this.logCache.push(i);const d=this.getMaxCacheSize();this.logCache.length>d&&(this.logCache=this.logCache.slice(-d)),this.logCallbacks.forEach(m=>{try{m(i)}catch(x){console.error("日志回调执行失败:",x)}})}}notifyConnection(i){this.connectionCallbacks.forEach(r=>{try{r(i)}catch(d){console.error("连接状态回调执行失败:",d)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const en=new H0;typeof window<"u"&&en.connect();const Gs=zN,Pu=MN,q0=TN,Ug=u.forwardRef(({className:n,...i},r)=>e.jsx(Jp,{ref:r,className:q("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",n),...i}));Ug.displayName=Jp.displayName;const Rs=u.forwardRef(({className:n,children:i,preventOutsideClose:r=!1,...d},m)=>e.jsxs(q0,{children:[e.jsx(Ug,{}),e.jsxs(Pp,{ref:m,className:q("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",n),onPointerDownOutside:r?x=>x.preventDefault():void 0,onInteractOutside:r?x=>x.preventDefault():void 0,...d,children:[i,e.jsxs(EN,{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(il,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Rs.displayName=Pp.displayName;const Ls=({className:n,...i})=>e.jsx("div",{className:q("flex flex-col space-y-1.5 text-center sm:text-left",n),...i});Ls.displayName="DialogHeader";const at=({className:n,...i})=>e.jsx("div",{className:q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...i});at.displayName="DialogFooter";const Us=u.forwardRef(({className:n,...i},r)=>e.jsx(Zp,{ref:r,className:q("text-lg font-semibold leading-none tracking-tight",n),...i}));Us.displayName=Zp.displayName;const Ps=u.forwardRef(({className:n,...i},r)=>e.jsx(Wp,{ref:r,className:q("text-sm text-muted-foreground",n),...i}));Ps.displayName=Wp.displayName;const ms=oN,tt=dN,G0=cN,Bg=u.forwardRef(({className:n,...i},r)=>e.jsx(Up,{className:q("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",n),...i,ref:r}));Bg.displayName=Up.displayName;const as=u.forwardRef(({className:n,...i},r)=>e.jsxs(G0,{children:[e.jsx(Bg,{}),e.jsx(Bp,{ref:r,className:q("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",n),...i})]}));as.displayName=Bp.displayName;const ls=({className:n,...i})=>e.jsx("div",{className:q("flex flex-col space-y-2 text-center sm:text-left",n),...i});ls.displayName="AlertDialogHeader";const ns=({className:n,...i})=>e.jsx("div",{className:q("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",n),...i});ns.displayName="AlertDialogFooter";const is=u.forwardRef(({className:n,...i},r)=>e.jsx(Hp,{ref:r,className:q("text-lg font-semibold",n),...i}));is.displayName=Hp.displayName;const rs=u.forwardRef(({className:n,...i},r)=>e.jsx(qp,{ref:r,className:q("text-sm text-muted-foreground",n),...i}));rs.displayName=qp.displayName;const cs=u.forwardRef(({className:n,...i},r)=>e.jsx(Gp,{ref:r,className:q(mr(),n),...i}));cs.displayName=Gp.displayName;const os=u.forwardRef(({className:n,...i},r)=>e.jsx(Fp,{ref:r,className:q(mr({variant:"outline"}),"mt-2 sm:mt-0",n),...i}));os.displayName=Fp.displayName;function F0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"系统设置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理您的应用偏好设置"})]})}),e.jsxs(Ca,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(es,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(sy,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(es,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(ty,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(es,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(ti,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(es,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Oa,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(Ke,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(ws,{value:"appearance",className:"mt-0",children:e.jsx(V0,{})}),e.jsx(ws,{value:"security",className:"mt-0",children:e.jsx($0,{})}),e.jsx(ws,{value:"other",className:"mt-0",children:e.jsx(Q0,{})}),e.jsx(ws,{value:"about",className:"mt-0",children:e.jsx(I0,{})})]})]})]})}function up(n){const i=document.documentElement,d={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[n];if(d)i.style.setProperty("--primary",d.hsl),d.gradient?(i.style.setProperty("--primary-gradient",d.gradient),i.classList.add("has-gradient")):(i.style.removeProperty("--primary-gradient"),i.classList.remove("has-gradient"));else if(n.startsWith("#")){const m=x=>{x=x.replace("#","");const f=parseInt(x.substring(0,2),16)/255,p=parseInt(x.substring(2,4),16)/255,g=parseInt(x.substring(4,6),16)/255,N=Math.max(f,p,g),j=Math.min(f,p,g);let w=0,y=0;const k=(N+j)/2;if(N!==j){const _=N-j;switch(y=k>.5?_/(2-N-j):_/(N+j),N){case f:w=((p-g)/_+(p<g?6:0))/6;break;case p:w=((g-f)/_+2)/6;break;case g:w=((f-p)/_+4)/6;break}}return`${Math.round(w*360)} ${Math.round(y*100)}% ${Math.round(k*100)}%`};i.style.setProperty("--primary",m(n)),i.style.removeProperty("--primary-gradient"),i.classList.remove("has-gradient")}}function V0(){const{theme:n,setTheme:i}=Ku(),{enableAnimations:r,setEnableAnimations:d,enableWavesBackground:m,setEnableWavesBackground:x}=Rg(),[f,p]=u.useState(()=>localStorage.getItem("accent-color")||"blue");u.useEffect(()=>{const N=localStorage.getItem("accent-color")||"blue";up(N)},[]);const g=N=>{p(N),localStorage.setItem("accent-color",N),up(N)};return e.jsxs("div",{className:"space-y-6 sm:space-y-8",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题模式"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsx(Eu,{value:"light",current:n,onChange:i,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Eu,{value:"dark",current:n,onChange:i,label:"深色",description:"始终使用深色主题"}),e.jsx(Eu,{value:"system",current:n,onChange:i,label:"跟随系统",description:"根据系统设置自动切换"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"主题色"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"单色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(ha,{value:"blue",current:f,onChange:g,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(ha,{value:"purple",current:f,onChange:g,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(ha,{value:"green",current:f,onChange:g,label:"绿色",colorClass:"bg-green-500"}),e.jsx(ha,{value:"orange",current:f,onChange:g,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(ha,{value:"pink",current:f,onChange:g,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(ha,{value:"red",current:f,onChange:g,label:"红色",colorClass:"bg-red-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"渐变色"}),e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-6 gap-2 sm:gap-3",children:[e.jsx(ha,{value:"gradient-sunset",current:f,onChange:g,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(ha,{value:"gradient-ocean",current:f,onChange:g,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(ha,{value:"gradient-forest",current:f,onChange:g,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(ha,{value:"gradient-aurora",current:f,onChange:g,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(ha,{value:"gradient-fire",current:f,onChange:g,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(ha,{value:"gradient-twilight",current:f,onChange:g,label:"暮光",colorClass:"bg-gradient-to-r from-indigo-500 to-purple-500"})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs sm:text-sm font-medium mb-2 sm:mb-3",children:"自定义颜色"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsx("input",{type:"color",value:f.startsWith("#")?f:"#3b82f6",onChange:N=>g(N.target.value),className:"h-10 sm:h-12 w-full rounded-lg border-2 border-border cursor-pointer",title:"选择自定义颜色"})}),e.jsx("div",{className:"flex-1",children:e.jsx(ie,{type:"text",value:f,onChange:N=>g(N.target.value),placeholder:"#3b82f6",className:"font-mono text-sm"})})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground mt-2",children:"点击色块选择颜色,或手动输入 HEX 颜色代码"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"动画效果"}),e.jsxs("div",{className:"space-y-2 sm:space-y-3",children:[e.jsx("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(C,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Ve,{id:"animations",checked:r,onCheckedChange:d})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5 flex-1",children:[e.jsx(C,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Ve,{id:"waves-background",checked:m,onCheckedChange:x})]})})]})]})]})}function $0(){const n=ja(),[i,r]=u.useState(""),[d,m]=u.useState(""),[x,f]=u.useState(!1),[p,g]=u.useState(!1),[N,j]=u.useState(!1),[w,y]=u.useState(!1),[k,_]=u.useState(!1),[L,D]=u.useState(!1),[U,Q]=u.useState(""),[R,z]=u.useState(!1),{toast:I}=Bs(),$=u.useMemo(()=>z0(d),[d]),E=async je=>{if(!i){I({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(je),_(!0),I({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>_(!1),2e3)}catch{I({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},M=async()=>{if(!d.trim()){I({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!$.isValid){const je=$.rules.filter(ye=>!ye.passed).map(ye=>ye.label).join(", ");I({title:"格式错误",description:`Token 不符合要求: ${je}`,variant:"destructive"});return}j(!0);try{const je=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:d.trim()})}),ye=await je.json();je.ok&&ye.success?(m(""),r(d.trim()),I({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{n({to:"/auth"})},1500)):I({title:"更新失败",description:ye.message||"无法更新 Token",variant:"destructive"})}catch(je){console.error("更新 Token 错误:",je),I({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{j(!1)}},se=async()=>{y(!0);try{const je=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),ye=await je.json();je.ok&&ye.success?(r(ye.token),Q(ye.token),D(!0),z(!1),I({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):I({title:"生成失败",description:ye.message||"无法生成新 Token",variant:"destructive"})}catch(je){console.error("生成 Token 错误:",je),I({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{y(!1)}},fe=async()=>{try{await navigator.clipboard.writeText(U),z(!0),I({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{I({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},ve=()=>{D(!1),setTimeout(()=>{Q(""),z(!1)},300),setTimeout(()=>{n({to:"/auth"})},500)},Ne=je=>{je||ve()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Gs,{open:L,onOpenChange:Ne,children:e.jsxs(Rs,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Us,{className:"flex items-center gap-2",children:[e.jsx(Sa,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(Ps,{children:"这是您的新 Token请立即保存。关闭此窗口后将跳转到登录页面。"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border-2 border-primary/20 bg-primary/5 p-4",children:[e.jsx(C,{className:"text-xs text-muted-foreground mb-2 block",children:"您的新 Token (64位安全令牌)"}),e.jsx("div",{className:"font-mono text-sm break-all select-all bg-background p-3 rounded border",children:U})]}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Sa,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"重要提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"此 Token 仅显示一次,关闭后无法再查看"}),e.jsx("li",{children:"请立即复制并保存到安全的位置"}),e.jsx("li",{children:"关闭窗口后将自动跳转到登录页面"}),e.jsx("li",{children:"请使用新 Token 重新登录系统"})]})]})]})})]}),e.jsxs(at,{className:"gap-2 sm:gap-0",children:[e.jsx(S,{variant:"outline",onClick:fe,className:"gap-2",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Qt,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qc,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(S,{onClick:ve,children:"我已保存,关闭"})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"当前 Access Token"}),e.jsx("div",{className:"space-y-3 sm:space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"current-token",className:"text-sm",children:"您的访问令牌"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ie,{id:"current-token",type:x?"text":"password",value:i||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{i?f(!x):I({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:x?"隐藏":"显示",children:x?e.jsx(or,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Rt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(S,{variant:"outline",size:"icon",onClick:()=>E(i),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!i,children:k?e.jsx(Qt,{className:"h-4 w-4 text-green-500"}):e.jsx(Qc,{className:"h-4 w-4"})}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{variant:"outline",disabled:w,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(zt,{className:q("h-4 w-4",w&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认重新生成 Token"}),e.jsx(rs,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:se,children:"确认生成"})]})]})]})]})]}),e.jsx("p",{className:"text-[10px] sm:text-xs text-muted-foreground",children:"请妥善保管您的 Access Token不要泄露给他人"})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"自定义 Access Token"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(ie,{id:"new-token",type:p?"text":"password",value:d,onChange:je=>m(je.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>g(!p),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:p?"隐藏":"显示",children:p?e.jsx(or,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Rt,{className:"h-4 w-4 text-muted-foreground"})})]}),d&&e.jsxs("div",{className:"mt-3 space-y-2 p-3 rounded-lg bg-muted/50",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Token 安全要求:"}),e.jsx("div",{className:"space-y-1.5",children:$.rules.map(je=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[je.passed?e.jsx(aa,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(pg,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:q(je.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:je.label})]},je.id))}),$.isValid&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400",children:[e.jsx(Qt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(S,{onClick:M,disabled:N||!$.isValid||!d,className:"w-full sm:w-auto",children:N?"更新中...":"更新自定义 Token"})]})]}),e.jsxs("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3 sm:p-4",children:[e.jsx("h4",{className:"text-sm sm:text-base font-semibold text-yellow-900 dark:text-yellow-200 mb-2",children:"安全提示"}),e.jsxs("ul",{className:"text-xs sm:text-sm text-yellow-800 dark:text-yellow-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"重新生成 Token 会创建系统随机生成的 64 位安全令牌"}),e.jsx("li",{children:"自定义 Token 必须满足所有安全要求才能使用"}),e.jsx("li",{children:"更新 Token 后,旧的 Token 将立即失效"}),e.jsx("li",{children:"请在安全的环境下查看和复制 Token"}),e.jsx("li",{children:"如果怀疑 Token 泄露,请立即重新生成或更新"}),e.jsx("li",{children:"建议使用系统生成的 Token 以获得最高安全性"})]})]})]})}function Q0(){const n=ja(),{toast:i}=Bs(),[r,d]=u.useState(!1),[m,x]=u.useState(!1),[f,p]=u.useState(()=>et("logCacheSize")),[g,N]=u.useState(()=>et("wsReconnectInterval")),[j,w]=u.useState(()=>et("wsMaxReconnectAttempts")),[y,k]=u.useState(()=>et("dataSyncInterval")),[_,L]=u.useState(()=>dp()),[D,U]=u.useState(!1),[Q,R]=u.useState(!1),z=u.useRef(null);if(m)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const I=()=>{L(dp())},$=O=>{const G=O[0];p(G),Jn("logCacheSize",G)},E=O=>{const G=O[0];N(G),Jn("wsReconnectInterval",G)},M=O=>{const G=O[0];w(G),Jn("wsMaxReconnectAttempts",G)},se=O=>{const G=O[0];k(G),Jn("dataSyncInterval",G)},fe=()=>{en.clearLogs(),i({title:"日志已清除",description:"日志缓存已清空"})},ve=()=>{const O=U0();I(),i({title:"缓存已清除",description:`已清除 ${O.clearedKeys.length} 项缓存数据`})},Ne=()=>{U(!0);try{const O=O0(),G=JSON.stringify(O,null,2),H=new Blob([G],{type:"application/json"}),ee=URL.createObjectURL(H),v=document.createElement("a");v.href=ee,v.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(v),v.click(),document.body.removeChild(v),URL.revokeObjectURL(ee),i({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(O){console.error("导出设置失败:",O),i({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{U(!1)}},je=O=>{const G=O.target.files?.[0];if(!G)return;R(!0);const H=new FileReader;H.onload=ee=>{try{const v=ee.target?.result,X=JSON.parse(v),me=R0(X);me.success?(p(et("logCacheSize")),N(et("wsReconnectInterval")),w(et("wsMaxReconnectAttempts")),k(et("dataSyncInterval")),I(),i({title:"导入成功",description:`成功导入 ${me.imported.length} 项设置${me.skipped.length>0?`,跳过 ${me.skipped.length}`:""}`}),(me.imported.includes("theme")||me.imported.includes("accentColor"))&&i({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):i({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(v){console.error("导入设置失败:",v),i({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{R(!1),z.current&&(z.current.value="")}},H.readAsText(G)},ye=()=>{L0(),p(Da.logCacheSize),N(Da.wsReconnectInterval),w(Da.wsMaxReconnectAttempts),k(Da.dataSyncInterval),I(),i({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},Se=async()=>{d(!0);try{const O=localStorage.getItem("access-token"),G=await fetch("/api/webui/setup/reset",{method:"POST",headers:{Authorization:`Bearer ${O}`}}),H=await G.json();G.ok&&H.success?(i({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{n({to:"/setup"})},1e3)):i({title:"重置失败",description:H.message||"无法重置配置状态",variant:"destructive"})}catch(O){console.error("重置配置状态错误:",O),i({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{d(!1)}};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx($c,{className:"h-5 w-5"}),"性能与存储"]}),e.jsxs("div",{className:"space-y-4 sm:space-y-5",children:[e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ay,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(S,{variant:"ghost",size:"sm",onClick:I,className:"h-7 px-2",children:e.jsx(zt,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:B0(_.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[_.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f," 条"]})]}),e.jsx(fa,{value:[f],onValueChange:$,min:100,max:5e3,step:100,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制日志查看器最多缓存的日志条数,较大的值会占用更多内存"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[y," 秒"]})]}),e.jsx(fa,{value:[y],onValueChange:se,min:10,max:120,step:5,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制首页统计数据的自动刷新间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[g/1e3," 秒"]})]}),e.jsx(fa,{value:[g],onValueChange:E,min:1e3,max:1e4,step:500,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"日志 WebSocket 连接断开后的重连基础间隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[j," 次"]})]}),e.jsx(fa,{value:[j],onValueChange:M,min:3,max:30,step:1,className:"w-full"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"连接失败后的最大重连尝试次数"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-2",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:fe,className:"gap-2",children:[e.jsx(Ze,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Ze,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认清除本地缓存"}),e.jsx(rs,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:ve,children:"确认清除"})]})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(nl,{className:"h-5 w-5"}),"导入/导出设置"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"导出当前的界面设置以便备份,或从之前导出的文件中恢复设置。"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(S,{variant:"outline",onClick:Ne,disabled:D,className:"gap-2",children:[e.jsx(nl,{className:"h-4 w-4"}),D?"导出中...":"导出设置"]}),e.jsx("input",{ref:z,type:"file",accept:".json",onChange:je,className:"hidden"}),e.jsxs(S,{variant:"outline",onClick:()=>z.current?.click(),disabled:Q,className:"gap-2",children:[e.jsx(dr,{className:"h-4 w-4"}),Q?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Vc,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认重置所有设置"}),e.jsx(rs,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:ye,children:"确认重置"})]})]})]})})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"配置向导"}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"重新进行初次配置向导,可以帮助您重新设置系统的基础配置。"})}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{variant:"outline",disabled:r,className:"gap-2",children:[e.jsx(Vc,{className:q("h-4 w-4",r&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认重新配置"}),e.jsx(rs,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:Se,children:"确认重置"})]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-dashed border-yellow-500/50 bg-yellow-500/5 p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4 flex items-center gap-2",children:[e.jsx(Sa,{className:"h-5 w-5 text-yellow-500"}),"开发者工具"]}),e.jsxs("div",{className:"space-y-3 sm:space-y-4",children:[e.jsx("div",{className:"space-y-2",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"以下功能仅供开发调试使用,可能会导致页面崩溃或异常。"})}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{variant:"destructive",className:"gap-2",children:[e.jsx(Sa,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认触发错误"}),e.jsx(rs,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>x(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function I0(){return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx("div",{className:"rounded-lg border-2 border-primary/30 bg-gradient-to-r from-primary/5 to-primary/10 p-4 sm:p-6",children:e.jsxs("div",{className:"flex items-start gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex-shrink-0 rounded-lg bg-primary/10 p-2 sm:p-3",children:e.jsx("svg",{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg sm:text-xl font-bold text-foreground mb-2",children:"开源项目"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground mb-3",children:"本项目在 GitHub 开源,欢迎 Star ⭐ 支持!"}),e.jsxs("a",{href:"https://github.com/Mai-with-u/MaiBot-Dashboard",target:"_blank",rel:"noopener noreferrer",className:q("inline-flex items-center gap-2 px-4 py-2 rounded-lg","bg-primary text-primary-foreground font-medium text-sm","hover:bg-primary/90 transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:[e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",clipRule:"evenodd"})}),"前往 GitHub",e.jsx("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsxs("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:["关于 ",Ju]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Zc]}),e.jsx("p",{children:"麦麦MaiBot的现代化 Web 管理界面"})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"作者"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"MaiBot 核心"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Mai-with-u"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"WebUI"}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground",children:["Mai-with-u ",e.jsx("a",{href:"https://github.com/DrSmoothl",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"@MotricSeven"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"技术栈"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"前端框架"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"React 19.2.0"}),e.jsx("li",{children:"TypeScript 5.7.2"}),e.jsx("li",{children:"Vite 6.0.7"}),e.jsx("li",{children:"TanStack Router 1.94.2"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"UI 组件"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"shadcn/ui"}),e.jsx("li",{children:"Radix UI"}),e.jsx("li",{children:"Tailwind CSS 3.4.17"}),e.jsx("li",{children:"Lucide Icons"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"后端"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Python 3.12+"}),e.jsx("li",{children:"FastAPI"}),e.jsx("li",{children:"Uvicorn"}),e.jsx("li",{children:"WebSocket"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-foreground",children:"构建工具"}),e.jsxs("ul",{className:"space-y-0.5 list-disc list-inside",children:[e.jsx("li",{children:"Bun / npm"}),e.jsx("li",{children:"ESLint 9.17.0"}),e.jsx("li",{children:"PostCSS"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源库感谢"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mb-3",children:"本项目使用了以下优秀的开源库,感谢他们的贡献:"}),e.jsx(Ke,{className:"h-[300px] sm:h-[400px]",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"UI 框架与组件"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(Ks,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(Ks,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(Ks,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(Ks,{name:"Lucide React",description:"精美的图标库",license:"ISC"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"路由与状态管理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(Ks,{name:"Zustand",description:"轻量级状态管理",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"表单处理"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(Ks,{name:"Zod",description:"TypeScript 优先的 schema 验证",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"工具库"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(Ks,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(Ks,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(Ks,{name:"date-fns",description:"现代化日期处理库",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"动画效果"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(Ks,{name:"vaul",description:"抽屉组件动画",license:"MIT"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"后端框架"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(Ks,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(Ks,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(Ks,{name:"python-multipart",description:"文件上传支持",license:"Apache-2.0"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"开发工具"}),e.jsxs("div",{className:"grid gap-2 text-xs sm:text-sm",children:[e.jsx(Ks,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(Ks,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(Ks,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(Ks,{name:"PostCSS",description:"CSS 转换工具",license:"MIT"})]})]})]})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"开源许可"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"rounded-lg bg-primary/5 border border-primary/20 p-3 sm:p-4",children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:"rounded-md bg-primary/10 px-2 py-1",children:e.jsx("span",{className:"text-xs sm:text-sm font-bold text-primary",children:"GPLv3"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm sm:text-base font-semibold text-foreground mb-1",children:"MaiBot WebUI"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目采用 GNU General Public License v3.0 开源许可证。 您可以自由地使用、修改和分发本软件,但必须保持相同的开源许可。"})]})]})}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"本项目依赖的所有开源库均遵循各自的开源许可证MIT、Apache-2.0、BSD 等)。 感谢所有开源贡献者的无私奉献。"})]})]})]})}function Ks({name:n,description:i,license:r}){return e.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-lg border bg-muted/30 p-2.5 sm:p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:n}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:i})]}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium text-primary flex-shrink-0",children:r})]})}function Eu({value:n,current:i,onChange:r,label:d,description:m}){const x=i===n;return e.jsxs("button",{onClick:()=>r(n),className:q("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3 h-2 w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm sm:text-base font-medium",children:d}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:m})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[n==="light"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-200"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-300"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-400"})]}),n==="dark"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-slate-900"})]}),n==="system"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-200 to-slate-700"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-300 to-slate-800"}),e.jsx("div",{className:"h-2 w-2 rounded-full bg-gradient-to-r from-slate-400 to-slate-900"})]})]})]})}function ha({value:n,current:i,onChange:r,label:d,colorClass:m}){const x=i===n;return e.jsxs("button",{onClick:()=>r(n),className:q("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 h-1.5 w-1.5 sm:h-2 sm:w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[e.jsx("div",{className:q("h-8 w-8 sm:h-10 sm:w-10 rounded-full",m)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:d})]})]})}class Y0{grad3;p;perm;constructor(i=0){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.p=[];for(let r=0;r<256;r++)this.p[r]=Math.floor(Math.random()*256);this.perm=[];for(let r=0;r<512;r++)this.perm[r]=this.p[r&255]}dot(i,r,d){return i[0]*r+i[1]*d}mix(i,r,d){return(1-d)*i+d*r}fade(i){return i*i*i*(i*(i*6-15)+10)}perlin2(i,r){const d=Math.floor(i)&255,m=Math.floor(r)&255;i-=Math.floor(i),r-=Math.floor(r);const x=this.fade(i),f=this.fade(r),p=this.perm[d]+m,g=this.perm[p],N=this.perm[p+1],j=this.perm[d+1]+m,w=this.perm[j],y=this.perm[j+1];return this.mix(this.mix(this.dot(this.grad3[g%12],i,r),this.dot(this.grad3[w%12],i-1,r),x),this.mix(this.dot(this.grad3[N%12],i,r-1),this.dot(this.grad3[y%12],i-1,r-1),x),f)}}function mp(){const n=u.useRef(null),i=u.useRef(null),r=u.useRef(void 0),d=u.useRef({mouse:{x:-10,y:0,lx:0,ly:0,sx:0,sy:0,v:0,vs:0,a:0,set:!1},lines:[],paths:[],noise:new Y0(Math.random()),bounding:null});return u.useEffect(()=>{const m=i.current,x=n.current;if(!m||!x)return;const f=d.current,p=()=>{const L=m.getBoundingClientRect();f.bounding=L,x.style.width=`${L.width}px`,x.style.height=`${L.height}px`},g=()=>{if(!f.bounding)return;const{width:L,height:D}=f.bounding;f.lines=[],f.paths.forEach(se=>se.remove()),f.paths=[];const U=10,Q=32,R=L+200,z=D+30,I=Math.ceil(R/U),$=Math.ceil(z/Q),E=(L-U*I)/2,M=(D-Q*$)/2;for(let se=0;se<=I;se++){const fe=[];for(let Ne=0;Ne<=$;Ne++){const je={x:E+U*se,y:M+Q*Ne,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};fe.push(je)}const ve=document.createElementNS("http://www.w3.org/2000/svg","path");x.appendChild(ve),f.paths.push(ve),f.lines.push(fe)}},N=L=>{const{lines:D,mouse:U,noise:Q}=f;D.forEach(R=>{R.forEach(z=>{const I=Q.perlin2((z.x+L*.0125)*.002,(z.y+L*.005)*.0015)*12;z.wave.x=Math.cos(I)*32,z.wave.y=Math.sin(I)*16;const $=z.x-U.sx,E=z.y-U.sy,M=Math.hypot($,E),se=Math.max(175,U.vs);if(M<se){const fe=1-M/se,ve=Math.cos(M*.001)*fe;z.cursor.vx+=Math.cos(U.a)*ve*se*U.vs*65e-5,z.cursor.vy+=Math.sin(U.a)*ve*se*U.vs*65e-5}z.cursor.vx+=(0-z.cursor.x)*.005,z.cursor.vy+=(0-z.cursor.y)*.005,z.cursor.vx*=.925,z.cursor.vy*=.925,z.cursor.x+=z.cursor.vx*2,z.cursor.y+=z.cursor.vy*2,z.cursor.x=Math.min(100,Math.max(-100,z.cursor.x)),z.cursor.y=Math.min(100,Math.max(-100,z.cursor.y))})})},j=(L,D=!0)=>{const U={x:L.x+L.wave.x+(D?L.cursor.x:0),y:L.y+L.wave.y+(D?L.cursor.y:0)};return U.x=Math.round(U.x*10)/10,U.y=Math.round(U.y*10)/10,U},w=()=>{const{lines:L,paths:D}=f;L.forEach((U,Q)=>{let R=j(U[0],!1),z=`M ${R.x} ${R.y}`;U.forEach((I,$)=>{const E=$===U.length-1;R=j(I,!E),z+=`L ${R.x} ${R.y}`}),D[Q].setAttribute("d",z)})},y=L=>{const{mouse:D}=f;D.sx+=(D.x-D.sx)*.1,D.sy+=(D.y-D.sy)*.1;const U=D.x-D.lx,Q=D.y-D.ly,R=Math.hypot(U,Q);D.v=R,D.vs+=(R-D.vs)*.1,D.vs=Math.min(100,D.vs),D.lx=D.x,D.ly=D.y,D.a=Math.atan2(Q,U),m&&(m.style.setProperty("--x",`${D.sx}px`),m.style.setProperty("--y",`${D.sy}px`)),N(L),w(),r.current=requestAnimationFrame(y)},k=L=>{if(!f.bounding)return;const{mouse:D}=f;D.x=L.pageX-f.bounding.left,D.y=L.pageY-f.bounding.top+window.scrollY,D.set||(D.sx=D.x,D.sy=D.y,D.lx=D.x,D.ly=D.y,D.set=!0)},_=()=>{p(),g()};return p(),g(),window.addEventListener("resize",_),window.addEventListener("mousemove",k),r.current=requestAnimationFrame(y),()=>{window.removeEventListener("resize",_),window.removeEventListener("mousemove",k),r.current&&cancelAnimationFrame(r.current)}},[]),e.jsxs("div",{ref:i,className:"waves-background",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"},children:[e.jsx("div",{className:"waves-cursor",style:{position:"absolute",top:0,left:0,width:"0.5rem",height:"0.5rem",background:"hsl(var(--primary) / 0.3)",borderRadius:"50%",transform:"translate3d(calc(var(--x, -0.5rem) - 50%), calc(var(--y, 50%) - 50%), 0)",willChange:"transform",pointerEvents:"none"}}),e.jsx("svg",{ref:n,style:{display:"block",width:"100%",height:"100%"},children:e.jsx("style",{children:`
path {
fill: none;
stroke: hsl(var(--primary) / 0.20);
stroke-width: 1px;
}
`})})]})}async function _e(n,i){const r={...i,credentials:"include",headers:{"Content-Type":"application/json",...i?.headers}},d=await fetch(n,r);if(d.status===401)throw window.location.href="/auth",new Error("认证失败,请重新登录");return d}function As(){return{"Content-Type":"application/json"}}async function X0(){try{await fetch("/api/webui/auth/logout",{method:"POST",credentials:"include"})}catch(n){console.error("登出请求失败:",n)}window.location.href="/auth"}async function Zu(){try{return(await(await fetch("/api/webui/auth/check",{method:"GET",credentials:"include"})).json()).authenticated===!0}catch{return!1}}function K0(){const[n,i]=u.useState(""),[r,d]=u.useState(!1),[m,x]=u.useState(""),[f,p]=u.useState(!0),g=ja(),{enableWavesBackground:N,setEnableWavesBackground:j}=Rg(),{theme:w,setTheme:y}=Ku();u.useEffect(()=>{(async()=>{try{await Zu()&&g({to:"/"})}catch{}finally{p(!1)}})()},[g]);const _=w==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":w,L=()=>{y(_==="dark"?"light":"dark")},D=async U=>{if(U.preventDefault(),x(""),!n.trim()){x("请输入 Access Token");return}d(!0);try{const Q=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:n.trim()})}),R=await Q.json();Q.ok&&R.valid?R.is_first_setup?g({to:"/setup"}):g({to:"/"}):x(R.message||"Token 验证失败,请检查后重试")}catch(Q){console.error("Token 验证错误:",Q),x("连接服务器失败,请检查网络连接")}finally{d(!1)}};return f?e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[N&&e.jsx(mp,{}),e.jsx("div",{className:"text-muted-foreground",children:"正在检查登录状态..."})]}):e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[N&&e.jsx(mp,{}),e.jsxs(Qe,{className:"relative z-10 w-full max-w-md shadow-2xl backdrop-blur-xl bg-card/80 border-border/50",children:[e.jsx("button",{onClick:L,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:_==="dark"?"切换到浅色模式":"切换到深色模式",children:_==="dark"?e.jsx(gg,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(jg,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(ss,{className:"space-y-4 text-center",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-primary/10",children:e.jsx(Wf,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ts,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(st,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(ps,{children:e.jsxs("form",{onSubmit:D,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"token",className:"text-sm font-medium",children:"Access Token"}),e.jsxs("div",{className:"relative",children:[e.jsx(vg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground",strokeWidth:2,fill:"none"}),e.jsx(ie,{id:"token",type:"password",placeholder:"请输入您的 Access Token",value:n,onChange:U=>i(U.target.value),className:q("pl-10",m&&"border-red-500 focus-visible:ring-red-500"),disabled:r,autoFocus:!0,autoComplete:"off"})]})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-red-50 p-3 text-sm text-red-600 dark:bg-red-950/50 dark:text-red-400",children:[e.jsx(Mt,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:m})]}),e.jsx(S,{type:"submit",className:"w-full",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"验证中..."]}):"验证并进入"}),e.jsxs(Gs,{children:[e.jsx(Pu,{asChild:!0,children:e.jsxs("button",{className:"w-full text-center text-sm text-primary hover:text-primary/80 transition-colors underline-offset-4 hover:underline flex items-center justify-center gap-1",children:[e.jsx(bg,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token我该去哪里获得 Token"]})}),e.jsxs(Rs,{className:"sm:max-w-md",children:[e.jsxs(Ls,{children:[e.jsxs(Us,{className:"flex items-center gap-2",children:[e.jsx(Wf,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"如何获取 Access Token"]}),e.jsx(Ps,{children:"Access Token 是访问 MaiBot WebUI 的唯一凭证,请按以下方式获取"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ly,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"方式一:查看启动日志"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"在 MaiBot 启动时,控制台会显示 WebUI Access Token。"}),e.jsxs("div",{className:"rounded bg-background p-2 font-mono text-xs",children:[e.jsx("p",{className:"text-muted-foreground",children:"🔑 WebUI Access Token: abc123..."}),e.jsx("p",{className:"text-muted-foreground",children:"💡 请使用此 Token 登录 WebUI"})]})]})]})}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(_a,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"方式二:查看配置文件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Token 保存在项目根目录的配置文件中:"}),e.jsx("div",{className:"rounded bg-background p-2 font-mono text-xs break-all",children:e.jsx("code",{className:"text-primary",children:"data/webui.json"})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["打开此文件,复制 ",e.jsx("code",{className:"px-1 py-0.5 bg-background rounded",children:"access_token"})," 字段的值"]})]})]})}),e.jsx("div",{className:"rounded-lg border border-yellow-200 dark:border-yellow-900 bg-yellow-50 dark:bg-yellow-950/30 p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Mt,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-500 flex-shrink-0 mt-0.5",strokeWidth:2,fill:"none"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-300 space-y-1",children:[e.jsx("p",{className:"font-semibold",children:"安全提示"}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-xs",children:[e.jsx("li",{children:"请妥善保管您的 Token不要泄露给他人"}),e.jsx("li",{children:"如需重置 Token请在登录后前往系统设置"})]})]})]})})]})]})]}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs("button",{className:"w-full text-center text-sm text-muted-foreground hover:text-foreground transition-colors underline-offset-4 hover:underline flex items-center justify-center gap-1",children:[e.jsx(sn,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsxs(is,{className:"flex items-center gap-2",children:[e.jsx(sn,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(rs,{children:"背景动画可能会在低性能设备上造成卡顿。关闭动画可以显著提升界面流畅度。"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4 space-y-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭动画后,背景将变为纯色,但不影响任何功能的使用。您可以随时在系统设置中重新开启动画。"})}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>j(!1),children:"关闭动画"})]})]})]})]})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 text-center text-xs text-muted-foreground",children:e.jsx("p",{children:M0})})]})}const Ms=u.forwardRef(({className:n,...i},r)=>e.jsx("textarea",{className:q("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base 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 md:text-sm",n),ref:r,...i}));Ms.displayName="Textarea";const xr=u.forwardRef(({className:n,orientation:i="horizontal",decorative:r=!0,...d},m)=>e.jsx(Vp,{ref:m,decorative:r,orientation:i,className:q("shrink-0 bg-border",i==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",n),...d}));xr.displayName=Vp.displayName;function J0({config:n,onChange:i}){const r=m=>{m.trim()&&!n.alias_names.includes(m.trim())&&i({...n,alias_names:[...n.alias_names,m.trim()]})},d=m=>{i({...n,alias_names:n.alias_names.filter((x,f)=>f!==m)})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"qq_account",children:"QQ账号 *"}),e.jsx(ie,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:n.qq_account||"",onChange:m=>i({...n,qq_account:Number(m.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人登录使用的QQ账号"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"nickname",children:"昵称 *"}),e.jsx(ie,{id:"nickname",placeholder:"请输入机器人的昵称",value:n.nickname,onChange:m=>i({...n,nickname:m.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的主要称呼名称"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{children:"别名"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:n.alias_names.map((m,x)=>e.jsxs(Fe,{variant:"secondary",className:"gap-1",children:[m,e.jsx("button",{type:"button",onClick:()=>d(x),className:"ml-1 hover:text-destructive",children:e.jsx(il,{className:"h-3 w-3"})})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:m=>{m.key==="Enter"&&(r(m.target.value),m.target.value="")}}),e.jsx(S,{type:"button",variant:"outline",onClick:()=>{const m=document.getElementById("alias_input");m&&(r(m.value),m.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function P0({config:n,onChange:i}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"personality",children:"人格特征 *"}),e.jsx(Ms,{id:"personality",placeholder:"描述机器人的人格特质和身份特征建议120字以内",value:n.personality,onChange:r=>i({...n,personality:r.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:是一个女大学生,现在在读大二,会刷贴吧"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"reply_style",children:"表达风格 *"}),e.jsx(Ms,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:n.reply_style,onChange:r=>i({...n,reply_style:r.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:回复平淡一些,简短一些,说中文,参考贴吧、知乎和微博的回复风格"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"interest",children:"兴趣 *"}),e.jsx(Ms,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:n.interest,onChange:r=>i({...n,interest:r.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(xr,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(Ms,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:n.plan_style,onChange:r=>i({...n,plan_style:r.target.value}),rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在群聊中如何行动,例如回复频率、条件等"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"private_plan_style",children:"私聊说话规则 *"}),e.jsx(Ms,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:n.private_plan_style,onChange:r=>i({...n,private_plan_style:r.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function Z0({config:n,onChange:i}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(n.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(ie,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:n.emoji_chance,onChange:r=>i({...n,emoji_chance:Number(r.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人发送表情包的概率"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"max_reg_num",children:"最大表情包数量"}),e.jsx(ie,{id:"max_reg_num",type:"number",min:"1",max:"200",value:n.max_reg_num,onChange:r=>i({...n,max_reg_num:Number(r.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人最多保存的表情包数量"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"do_replace",children:"达到最大数量时替换"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后会删除旧表情包,关闭则不再收集新表情包"})]}),e.jsx(Ve,{id:"do_replace",checked:n.do_replace,onCheckedChange:r=>i({...n,do_replace:r})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ie,{id:"check_interval",type:"number",min:"1",max:"120",value:n.check_interval,onChange:r=>i({...n,check_interval:Number(r.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(xr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"steal_emoji",children:"偷取表情包"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人将一些表情包据为己有"})]}),e.jsx(Ve,{id:"steal_emoji",checked:n.steal_emoji,onCheckedChange:r=>i({...n,steal_emoji:r})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"content_filtration",children:"启用表情包过滤"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只保存符合要求的表情包"})]}),e.jsx(Ve,{id:"content_filtration",checked:n.content_filtration,onCheckedChange:r=>i({...n,content_filtration:r})})]}),n.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ie,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:n.filtration_prompt,onChange:r=>i({...n,filtration_prompt:r.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function W0({config:n,onChange:i}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"enable_tool",children:"启用工具系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人使用各种工具增强功能"})]}),e.jsx(Ve,{id:"enable_tool",checked:n.enable_tool,onCheckedChange:r=>i({...n,enable_tool:r})})]}),e.jsx(xr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"enable_mood",children:"启用情绪系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"让机器人具有情绪变化能力"})]}),e.jsx(Ve,{id:"enable_mood",checked:n.enable_mood,onCheckedChange:r=>i({...n,enable_mood:r})})]}),n.enable_mood&&e.jsxs("div",{className:"ml-6 space-y-6 border-l-2 border-primary/20 pl-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"mood_update_threshold",children:"情绪更新阈值"}),e.jsx(ie,{id:"mood_update_threshold",type:"number",min:"0.1",max:"10",step:"0.1",value:n.mood_update_threshold||1,onChange:r=>i({...n,mood_update_threshold:Number(r.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"值越高,情绪更新越慢"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"emotion_style",children:"情感特征"}),e.jsx(Ms,{id:"emotion_style",placeholder:"描述情绪的变化情况,例如:情绪较为稳定,但遭遇特定事件时起伏较大",value:n.emotion_style||"",onChange:r=>i({...n,emotion_style:r.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响机器人的情绪变化方式"})]})]}),e.jsx(xr,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"all_global",children:"启用全局黑话模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人学习和使用群组黑话"})]}),e.jsx(Ve,{id:"all_global",checked:n.all_global,onCheckedChange:r=>i({...n,all_global:r})})]})]})}function ew({config:n,onChange:i}){const[r,d]=u.useState(!1);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("svg",{className:"h-5 w-5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"font-medium text-blue-900 dark:text-blue-100 mb-1",children:"关于硅基流动 (SiliconFlow)"}),e.jsx("p",{className:"text-blue-700 dark:text-blue-300 mb-2",children:"硅基流动提供了完整的模型覆盖,包括 DeepSeek V3、Qwen、视觉模型、语音识别和嵌入模型。 只需一个 API Key 即可使用麦麦的所有功能!"}),e.jsxs("a",{href:"https://cloud.siliconflow.cn",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-blue-600 dark:text-blue-400 hover:underline font-medium",children:["前往硅基流动获取 API Key",e.jsx(qc,{className:"h-3 w-3"})]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{htmlFor:"siliconflow_api_key",children:"SiliconFlow API Key *"}),e.jsxs("div",{className:"relative",children:[e.jsx(ie,{id:"siliconflow_api_key",type:r?"text":"password",placeholder:"sk-...",value:n.api_key,onChange:m=>i({api_key:m.target.value}),className:"font-mono pr-10"}),e.jsx(S,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>d(!r),children:r?e.jsx(or,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Rt,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"请输入您的硅基流动 API 密钥。获取后,麦麦将自动配置所有必需的模型。"})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-4 text-sm space-y-2",children:[e.jsx("p",{className:"font-medium",children:"将自动配置以下模型:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground ml-2",children:[e.jsx("li",{children:"DeepSeek V3 - 主要对话和工具模型"}),e.jsx("li",{children:"Qwen3 30B - 高频小任务和工具调用"}),e.jsx("li",{children:"Qwen3 VL 30B - 图像识别"}),e.jsx("li",{children:"SenseVoice - 语音识别"}),e.jsx("li",{children:"BGE-M3 - 文本嵌入"}),e.jsx("li",{children:"知识库相关模型 (LPMM)"})]})]}),e.jsx("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 p-4",children:e.jsxs("p",{className:"text-sm text-amber-900 dark:text-amber-100",children:[e.jsx("span",{className:"font-medium",children:"💡 提示:"}),'完成向导后,您可以在"系统设置 → 模型配置"中添加更多 API 提供商和模型。']})})]})}async function sw(){const n=await _e("/api/webui/config/bot",{method:"GET",headers:As()});if(!n.ok)throw new Error("读取Bot配置失败");const r=(await n.json()).config.bot||{};return{qq_account:r.qq_account||0,nickname:r.nickname||"",alias_names:r.alias_names||[]}}async function tw(){const n=await _e("/api/webui/config/bot",{method:"GET",headers:As()});if(!n.ok)throw new Error("读取人格配置失败");const r=(await n.json()).config.personality||{};return{personality:r.personality||"",reply_style:r.reply_style||"",interest:r.interest||"",plan_style:r.plan_style||"",private_plan_style:r.private_plan_style||""}}async function aw(){const n=await _e("/api/webui/config/bot",{method:"GET",headers:As()});if(!n.ok)throw new Error("读取表情包配置失败");const r=(await n.json()).config.emoji||{};return{emoji_chance:r.emoji_chance??.4,max_reg_num:r.max_reg_num??40,do_replace:r.do_replace??!0,check_interval:r.check_interval??10,steal_emoji:r.steal_emoji??!0,content_filtration:r.content_filtration??!1,filtration_prompt:r.filtration_prompt||""}}async function lw(){const n=await _e("/api/webui/config/bot",{method:"GET",headers:As()});if(!n.ok)throw new Error("读取其他配置失败");const r=(await n.json()).config,d=r.tool||{},m=r.mood||{},x=r.jargon||{};return{enable_tool:d.enable_tool??!0,enable_mood:m.enable_mood??!1,mood_update_threshold:m.mood_update_threshold,emotion_style:m.emotion_style,all_global:x.all_global??!0}}async function nw(){const n=await _e("/api/webui/config/model",{method:"GET",headers:As()});if(!n.ok)throw new Error("读取模型配置失败");return{api_key:((await n.json()).config.api_providers||[]).find(x=>x.name==="SiliconFlow")?.api_key||""}}async function iw(n){const i=await _e("/api/webui/config/bot/section/bot",{method:"POST",headers:As(),body:JSON.stringify(n)});if(!i.ok){const r=await i.json();throw new Error(r.detail||"保存Bot基础配置失败")}return await i.json()}async function rw(n){const i=await _e("/api/webui/config/bot/section/personality",{method:"POST",headers:As(),body:JSON.stringify(n)});if(!i.ok){const r=await i.json();throw new Error(r.detail||"保存人格配置失败")}return await i.json()}async function cw(n){const i=await _e("/api/webui/config/bot/section/emoji",{method:"POST",headers:As(),body:JSON.stringify(n)});if(!i.ok){const r=await i.json();throw new Error(r.detail||"保存表情包配置失败")}return await i.json()}async function ow(n){const i=[];i.push(_e("/api/webui/config/bot/section/tool",{method:"POST",headers:As(),body:JSON.stringify({enable_tool:n.enable_tool})})),i.push(_e("/api/webui/config/bot/section/jargon",{method:"POST",headers:As(),body:JSON.stringify({all_global:n.all_global})}));const r={enable_mood:n.enable_mood};n.enable_mood&&(r.mood_update_threshold=n.mood_update_threshold||1,r.emotion_style=n.emotion_style||""),i.push(_e("/api/webui/config/bot/section/mood",{method:"POST",headers:As(),body:JSON.stringify(r)}));const d=await Promise.all(i);for(const m of d)if(!m.ok){const x=await m.json();throw new Error(x.detail||"保存其他配置失败")}return{success:!0}}async function dw(n){const i=await _e("/api/webui/config/model",{method:"GET",headers:As()});if(!i.ok)throw new Error("读取模型配置失败");const d=(await i.json()).config,m=d.api_providers||[],x=m.findIndex(g=>g.name==="SiliconFlow");x>=0?m[x]={...m[x],api_key:n.api_key}:m.push({name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",api_key:n.api_key,client_type:"openai",max_retry:3,timeout:120,retry_interval:5});const f={...d,api_providers:m},p=await _e("/api/webui/config/model",{method:"POST",headers:As(),body:JSON.stringify(f)});if(!p.ok){const g=await p.json();throw new Error(g.detail||"保存模型配置失败")}return await p.json()}async function xp(){const n=localStorage.getItem("access-token"),i=await _e("/api/webui/setup/complete",{method:"POST",headers:{Authorization:`Bearer ${n}`}});if(!i.ok){const r=await i.json();throw new Error(r.message||"标记配置完成失败")}return await i.json()}async function Wc(){const n=await _e("/api/webui/system/restart",{method:"POST",headers:As()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"重启失败")}return await n.json()}async function Hg(){const n=await _e("/api/webui/system/status",{method:"GET",headers:As()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取状态失败")}return await n.json()}function uw(){const n=ja(),{toast:i}=Bs(),[r,d]=u.useState(0),[m,x]=u.useState(!1),[f,p]=u.useState(!1),[g,N]=u.useState(!0),[j,w]=u.useState({qq_account:0,nickname:"",alias_names:[]}),[y,k]=u.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
2.如果相同的内容已经被执行,请不要重复执行
3.请控制你的发言频率,不要太过频繁的发言
4.如果有人对你感到厌烦,请减少回复
5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
2.如果相同的内容已经被执行,请不要重复执行
3.某句话如果已经被回复过,不要重复回复`}),[_,L]=u.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[D,U]=u.useState({enable_tool:!0,enable_mood:!1,mood_update_threshold:1,emotion_style:"情绪较为稳定,但遇遇特定事件的时候起伏较大",all_global:!0}),[Q,R]=u.useState({api_key:""}),[z,I]=u.useState(!1),[$,E]=u.useState(""),M=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:ar},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:Ic},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:Iu},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:ti},{id:"siliconflow",title:"API配置",description:"配置硅基流动API密钥",icon:vg}],se=(r+1)/M.length*100;u.useEffect(()=>{(async()=>{try{N(!0);const[G,H,ee,v,X]=await Promise.all([sw(),tw(),aw(),lw(),nw()]);w(G),k(H),L(ee),U(v),R(X)}catch(G){i({title:"加载配置失败",description:G instanceof Error?G.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{N(!1)}})()},[i]);const fe=async()=>{p(!0);try{switch(r){case 0:await iw(j);break;case 1:await rw(y);break;case 2:await cw(_);break;case 3:await ow(D);break;case 4:await dw(Q);break}return i({title:"保存成功",description:`${M[r].title}配置已保存`}),!0}catch(O){return i({title:"保存失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"}),!1}finally{p(!1)}},ve=async()=>{await fe()&&r<M.length-1&&d(r+1)},Ne=()=>{r>0&&d(r-1)},je=async()=>{x(!0),I(!0);try{if(E("正在保存API配置..."),!await fe()){x(!1),I(!1);return}E("正在完成初始化..."),await xp(),E("正在重启麦麦..."),await Wc(),i({title:"配置完成",description:"麦麦正在重启以应用新配置..."}),E("等待麦麦重启完成...");const G=60;let H=0,ee=!1;for(;H<G&&!ee;){await new Promise(v=>setTimeout(v,1e3));try{(await Hg()).running&&(ee=!0,E("重启成功!正在跳转..."))}catch{H++}}if(!ee)throw new Error("重启超时,请手动检查麦麦状态");setTimeout(()=>{n({to:"/"})},1e3)}catch(O){I(!1),i({title:"配置失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}finally{x(!1)}},ye=async()=>{try{await xp(),n({to:"/"})}catch(O){i({title:"跳过失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}},Se=()=>{switch(r){case 0:return e.jsx(J0,{config:j,onChange:w});case 1:return e.jsx(P0,{config:y,onChange:k});case 2:return e.jsx(Z0,{config:_,onChange:L});case 3:return e.jsx(W0,{config:D,onChange:U});case 4:return e.jsx(ew,{config:Q,onChange:R});default:return null}};return e.jsxs("div",{className:"relative flex min-h-screen flex-col items-center justify-center overflow-hidden bg-gradient-to-br from-primary/5 via-background to-secondary/5 p-4 md:p-6",children:[z&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm",children:e.jsxs("div",{className:"mx-auto flex max-w-md flex-col items-center space-y-6 rounded-lg border bg-card p-8 text-center shadow-lg",children:[e.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Js,{className:"h-10 w-10 animate-spin text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground",children:$})]}),e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:e.jsx("div",{className:"h-full w-full animate-pulse bg-primary",style:{animation:"pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"请稍候,这可能需要一分钟..."})]})}),e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute left-1/4 top-1/4 h-64 w-64 md:h-96 md:w-96 rounded-full bg-primary/5 blur-3xl"}),e.jsx("div",{className:"absolute right-1/4 bottom-1/4 h-64 w-64 md:h-96 md:w-96 rounded-full bg-secondary/5 blur-3xl"})]}),g?e.jsxs("div",{className:"relative z-10 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center",children:e.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-4 border-primary border-t-transparent"})}),e.jsx("p",{className:"text-lg font-medium",children:"加载配置中..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"正在读取现有配置"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative z-10 w-full max-w-4xl",children:[e.jsxs("div",{className:"mb-6 md:mb-8 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 md:h-16 md:w-16 items-center justify-center rounded-2xl bg-primary/10",children:e.jsx(ny,{className:"h-6 w-6 md:h-8 md:w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsx("h1",{className:"mb-2 text-2xl md:text-3xl font-bold",children:"首次配置向导"}),e.jsxs("p",{className:"text-sm md:text-base text-muted-foreground",children:["让我们一起完成 ",Ju," 的初始配置"]})]}),e.jsxs("div",{className:"mb-6 md:mb-8",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs md:text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:["步骤 ",r+1," / ",M.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(se),"%"]})]}),e.jsx(ni,{value:se,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:M.map((O,G)=>{const H=O.icon;return e.jsxs("div",{className:q("flex flex-1 flex-col items-center gap-1 md:gap-2",G<M.length-1&&"relative"),children:[G<M.length-1&&e.jsx("div",{className:q("absolute left-1/2 top-3 md:top-4 h-0.5 w-full",G<r?"bg-primary":"bg-border")}),e.jsx("div",{className:q("relative z-10 flex h-6 w-6 md:h-8 md:w-8 items-center justify-center rounded-full border-2 transition-all",G===r||G<r?"border-primary bg-primary text-primary-foreground":"border-border bg-background text-muted-foreground"),children:G<r?e.jsx(aa,{className:"h-3 w-3 md:h-4 md:w-4",strokeWidth:2.5,fill:"none"}):e.jsx(H,{className:"h-3 w-3 md:h-4 md:w-4"})}),e.jsx("span",{className:q("text-[10px] md:text-xs text-center max-w-[60px] md:max-w-none truncate md:whitespace-normal",G===r?"font-medium text-foreground":"text-muted-foreground"),title:O.title,children:O.title})]},O.id)})}),e.jsx(Qe,{className:"mb-6 md:mb-8 shadow-lg",children:e.jsx(ps,{className:"p-4 md:p-8",children:e.jsxs("div",{className:"min-h-[300px] md:min-h-[400px]",children:[e.jsxs("div",{className:"mb-4 md:mb-6",children:[e.jsx("h2",{className:"mb-2 text-xl md:text-2xl font-semibold",children:M[r].title}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:M[r].description})]}),e.jsx(Ke,{className:"h-[400px] md:h-[500px]",children:e.jsx("div",{className:"pr-2",children:Se()})})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 sm:gap-0",children:[e.jsx(S,{variant:"outline",onClick:Ne,disabled:r===0||f,className:"w-full sm:w-auto order-2 sm:order-1",children:"上一步"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto order-1 sm:order-2",children:[e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{variant:"ghost",className:"flex-1 sm:flex-none gap-2",disabled:f||m,children:[e.jsx(iy,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"跳过向导"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认跳过配置向导"}),e.jsx(rs,{children:"您可以随时在系统设置中重新进入配置向导。确定要跳过吗?"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:ye,children:"确认跳过"})]})]})]}),r===M.length-1?e.jsx(S,{onClick:je,disabled:m||f,className:"flex-1 sm:flex-none",children:m||f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),f?"保存中...":"完成中..."]}):e.jsxs(e.Fragment,{children:["完成配置",e.jsx(aa,{className:"ml-2 h-4 w-4",strokeWidth:2,fill:"none"})]})}):e.jsx(S,{onClick:ve,disabled:f,className:"flex-1 sm:flex-none",children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"保存中..."]}):e.jsxs(e.Fragment,{children:["下一步",e.jsx(ry,{className:"ml-2 h-4 w-4",strokeWidth:2,fill:"none"})]})})]})]})]}),e.jsx("div",{className:"relative z-10 mt-6 md:mt-8 text-center text-xs text-muted-foreground",children:e.jsx("p",{children:"您可以随时在设置中修改这些配置"})})]})]})}function qg(){const n=ja();return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs("div",{className:"w-full max-w-2xl text-center",children:[e.jsxs("div",{className:"relative mb-8",children:[e.jsx("h1",{className:"text-[150px] font-black leading-none text-primary/10 select-none sm:text-[200px]",children:"404"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(At,{className:"h-20 w-20 text-primary/30 sm:h-24 sm:w-24"})})]}),e.jsxs("div",{className:"space-y-4 mb-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground sm:text-3xl",children:"页面未找到"}),e.jsx("p",{className:"text-base text-muted-foreground sm:text-lg max-w-md mx-auto",children:"抱歉,您访问的页面不存在或已被移除。请检查 URL 是否正确,或返回首页继续浏览。"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-4",children:[e.jsxs(S,{size:"lg",onClick:()=>n({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(Pc,{className:"h-4 w-4"}),"返回首页"]}),e.jsxs(S,{size:"lg",variant:"outline",onClick:()=>window.history.back(),className:"gap-2 w-full sm:w-auto",children:[e.jsx(Wn,{className:"h-4 w-4"}),"返回上一页"]})]}),e.jsx("div",{className:"mt-12 pt-8 border-t border-border",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"如果您认为这是一个错误,请联系系统管理员"})})]})})}const mw=pt.memo(function({config:i,onChange:r}){const d=()=>{r({...i,platforms:[...i.platforms,""]})},m=N=>{r({...i,platforms:i.platforms.filter((j,w)=>w!==N)})},x=(N,j)=>{const w=[...i.platforms];w[N]=j,r({...i,platforms:w})},f=()=>{r({...i,alias_names:[...i.alias_names,""]})},p=N=>{r({...i,alias_names:i.alias_names.filter((j,w)=>w!==N)})},g=(N,j)=>{const w=[...i.alias_names];w[N]=j,r({...i,alias_names:w})};return e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"基本信息"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"platform",children:"平台"}),e.jsx(ie,{id:"platform",value:i.platform,onChange:N=>r({...i,platform:N.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(ie,{id:"qq_account",value:i.qq_account,onChange:N=>r({...i,qq_account:N.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"nickname",children:"昵称"}),e.jsx(ie,{id:"nickname",value:i.nickname,onChange:N=>r({...i,nickname:N.target.value}),placeholder:"麦麦"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"其他平台账号"}),e.jsxs(S,{onClick:d,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[i.platforms.map((N,j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{value:N,onChange:w=>x(j,w.target.value),placeholder:"wx:114514"}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除平台账号 "',N||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>m(j),children:"删除"})]})]})]})]},j)),i.platforms.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无其他平台账号"})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"别名"}),e.jsxs(S,{onClick:f,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[i.alias_names.map((N,j)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{value:N,onChange:w=>g(j,w.target.value),placeholder:"小麦"}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除别名 "',N||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>p(j),children:"删除"})]})]})]})]},j)),i.alias_names.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无别名"})]})]})]})]})})}),xw=pt.memo(function({config:i,onChange:r}){const d=()=>{r({...i,states:[...i.states,""]})},m=f=>{r({...i,states:i.states.filter((p,g)=>g!==f)})},x=(f,p)=>{const g=[...i.states];g[f]=p,r({...i,states:g})};return e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"人格设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"personality",children:"人格特质"}),e.jsx(Ms,{id:"personality",value:i.personality,onChange:f=>r({...i,personality:f.target.value}),placeholder:"描述人格特质和身份特征建议120字以内",rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"建议120字以内描述人格特质和身份特征"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"reply_style",children:"表达风格"}),e.jsx(Ms,{id:"reply_style",value:i.reply_style,onChange:f=>r({...i,reply_style:f.target.value}),placeholder:"描述说话的表达风格和习惯",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"interest",children:"兴趣"}),e.jsx(Ms,{id:"interest",value:i.interest,onChange:f=>r({...i,interest:f.target.value}),placeholder:"会影响麦麦对什么话题进行回复",rows:2})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"plan_style",children:"说话规则与行为风格"}),e.jsx(Ms,{id:"plan_style",value:i.plan_style,onChange:f=>r({...i,plan_style:f.target.value}),placeholder:"麦麦的说话规则和行为风格",rows:5})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"visual_style",children:"识图规则"}),e.jsx(Ms,{id:"visual_style",value:i.visual_style,onChange:f=>r({...i,visual_style:f.target.value}),placeholder:"识图时的处理规则",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"private_plan_style",children:"私聊规则"}),e.jsx(Ms,{id:"private_plan_style",value:i.private_plan_style,onChange:f=>r({...i,private_plan_style:f.target.value}),placeholder:"私聊的说话规则和行为风格",rows:4})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"状态列表(人格多样性)"}),e.jsxs(S,{onClick:d,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加状态"]})]}),e.jsx("div",{className:"space-y-2",children:i.states.map((f,p)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ms,{value:f,onChange:g=>x(p,g.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsx(rs,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>m(p),children:"删除"})]})]})]})]},p))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"state_probability",children:"状态替换概率"}),e.jsx(ie,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:i.state_probability,onChange:f=>r({...i,state_probability:parseFloat(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次构建人格时替换 personality 的概率0.0-1.0"})]})]})]})})}),Re=UN,Le=BN,De=u.forwardRef(({className:n,children:i,...r},d)=>e.jsxs(eg,{ref:d,className:q("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 data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",n),...r,children:[i,e.jsx(AN,{asChild:!0,children:e.jsx(Ol,{className:"h-4 w-4 opacity-50"})})]}));De.displayName=eg.displayName;const Gg=u.forwardRef(({className:n,...i},r)=>e.jsx(sg,{ref:r,className:q("flex cursor-default items-center justify-center py-1",n),...i,children:e.jsx(ur,{className:"h-4 w-4"})}));Gg.displayName=sg.displayName;const Fg=u.forwardRef(({className:n,...i},r)=>e.jsx(tg,{ref:r,className:q("flex cursor-default items-center justify-center py-1",n),...i,children:e.jsx(Ol,{className:"h-4 w-4"})}));Fg.displayName=tg.displayName;const Oe=u.forwardRef(({className:n,children:i,position:r="popper",...d},m)=>e.jsx(DN,{children:e.jsxs(ag,{ref:m,className:q("relative z-[100] max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-hidden rounded-md border border-border bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100 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 origin-[--radix-select-content-transform-origin]",r==="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",n),position:r,...d,children:[e.jsx(Gg,{}),e.jsx(ON,{className:q("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:i}),e.jsx(Fg,{})]})}));Oe.displayName=ag.displayName;const hw=u.forwardRef(({className:n,...i},r)=>e.jsx(lg,{ref:r,className:q("px-2 py-1.5 text-sm font-semibold",n),...i}));hw.displayName=lg.displayName;const le=u.forwardRef(({className:n,children:i,...r},d)=>e.jsxs(ng,{ref:d,className:q("relative flex w-full cursor-default select-none items-center rounded-sm py-2 pl-2 pr-8 text-sm outline-none bg-white dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 focus:bg-gray-100 dark:focus:bg-gray-800 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...r,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(RN,{children:e.jsx(Qt,{className:"h-4 w-4"})})}),e.jsx(LN,{children:i})]}));le.displayName=ng.displayName;const fw=u.forwardRef(({className:n,...i},r)=>e.jsx(ig,{ref:r,className:q("-mx-1 my-1 h-px bg-muted",n),...i}));fw.displayName=ig.displayName;const Ra=mN,La=xN,ka=u.forwardRef(({className:n,align:i="center",sideOffset:r=4,...d},m)=>e.jsx(uN,{children:e.jsx($p,{ref:m,align:i,sideOffset:r,className:q("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 origin-[--radix-popover-content-transform-origin]",n),...d})}));ka.displayName=$p.displayName;const pw=pt.memo(function({value:i,onChange:r}){const[d,m]=u.useState("00"),[x,f]=u.useState("00"),[p,g]=u.useState("23"),[N,j]=u.useState("59");u.useEffect(()=>{const y=i.split("-");if(y.length===2){const[k,_]=y,[L,D]=k.split(":"),[U,Q]=_.split(":");L&&m(L.padStart(2,"0")),D&&f(D.padStart(2,"0")),U&&g(U.padStart(2,"0")),Q&&j(Q.padStart(2,"0"))}},[i]);const w=(y,k,_,L)=>{const D=`${y}:${k}-${_}:${L}`;r(D)};return e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(Pn,{className:"h-4 w-4 mr-2"}),i||"选择时间段"]})}),e.jsx(ka,{className:"w-72 sm:w-80",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"开始时间"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-xs",children:"小时"}),e.jsxs(Re,{value:d,onValueChange:y=>{m(y),w(y,x,p,N)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:Array.from({length:24},(y,k)=>k).map(y=>e.jsx(le,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs",children:"分钟"}),e.jsxs(Re,{value:x,onValueChange:y=>{f(y),w(d,y,p,N)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:Array.from({length:60},(y,k)=>k).map(y=>e.jsx(le,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"结束时间"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:gap-3",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-xs",children:"小时"}),e.jsxs(Re,{value:p,onValueChange:y=>{g(y),w(d,x,y,N)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:Array.from({length:24},(y,k)=>k).map(y=>e.jsx(le,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-xs",children:"分钟"}),e.jsxs(Re,{value:N,onValueChange:y=>{j(y),w(d,x,p,y)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:Array.from({length:60},(y,k)=>k).map(y=>e.jsx(le,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]})]})]})]})})]})}),gw=pt.memo(function({rule:i}){const r=`{ target = "${i.target}", time = "${i.time}", value = ${i.value.toFixed(1)} }`;return e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",children:[e.jsx(Rt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(ka,{className:"w-80 sm:w-96",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:r}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})}),jw=pt.memo(function({config:i,onChange:r}){const d=()=>{r({...i,talk_value_rules:[...i.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},m=f=>{r({...i,talk_value_rules:i.talk_value_rules.filter((p,g)=>g!==f)})},x=(f,p,g)=>{const N=[...i.talk_value_rules];N[f]={...N[f],[p]:g},r({...i,talk_value_rules:N})};return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"聊天设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"talk_value",children:"聊天频率(基础值)"}),e.jsx(ie,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:i.talk_value,onChange:f=>r({...i,talk_value:parseFloat(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越小越沉默,范围 0-1"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"mentioned_bot_reply",checked:i.mentioned_bot_reply,onCheckedChange:f=>r({...i,mentioned_bot_reply:f})}),e.jsx(C,{htmlFor:"mentioned_bot_reply",className:"cursor-pointer",children:"启用提及必回复"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"max_context_size",children:"上下文长度"}),e.jsx(ie,{id:"max_context_size",type:"number",min:"1",value:i.max_context_size,onChange:f=>r({...i,max_context_size:parseInt(f.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(ie,{id:"planner_smooth",type:"number",step:"1",min:"0",value:i.planner_smooth,onChange:f=>r({...i,planner_smooth:parseFloat(f.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"增大数值会减小 planner 负荷,推荐 1-50 为关闭"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_talk_value_rules",checked:i.enable_talk_value_rules,onCheckedChange:f=>r({...i,enable_talk_value_rules:f})}),e.jsx(C,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"include_planner_reasoning",checked:i.include_planner_reasoning,onCheckedChange:f=>r({...i,include_planner_reasoning:f})}),e.jsx(C,{htmlFor:"include_planner_reasoning",className:"cursor-pointer",children:"将 planner 推理加入 replyer"})]})]})]}),i.enable_talk_value_rules&&e.jsxs("div",{className:"border-t pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"动态发言频率规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"按时段或聊天流ID调整发言频率优先匹配具体聊天再匹配全局规则"})]}),e.jsxs(S,{onClick:d,size:"sm",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),i.talk_value_rules&&i.talk_value_rules.length>0?e.jsx("div",{className:"space-y-4",children:i.talk_value_rules.map((f,p)=>e.jsxs("div",{className:"rounded-lg border p-4 bg-muted/50 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["规则 #",p+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(gw,{rule:f}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{variant:"ghost",size:"sm",children:e.jsx(Ze,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除规则 #",p+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>m(p),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(Re,{value:f.target===""?"global":"specific",onValueChange:g=>{g==="global"?x(p,"target",""):x(p,"target","qq::group")},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"global",children:"全局配置"}),e.jsx(le,{value:"specific",children:"详细配置"})]})]})]}),f.target!==""&&(()=>{const g=f.target.split(":"),N=g[0]||"qq",j=g[1]||"",w=g[2]||"group";return e.jsxs("div",{className:"grid gap-4 p-3 sm:p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Re,{value:N,onValueChange:y=>{x(p,"target",`${y}:${j}:${w}`)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ie,{value:j,onChange:y=>{x(p,"target",`${N}:${y.target.value}:${w}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Re,{value:w,onValueChange:y=>{x(p,"target",`${N}:${j}:${y}`)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"group",children:"群组group"}),e.jsx(le,{value:"private",children:"私聊private"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID",f.target||"(未设置)"]})]})})(),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"时间段 (Time)"}),e.jsx(pw,{value:f.time,onChange:g=>x(p,"time",g)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持跨夜区间,例如 23:00-02:00"})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{htmlFor:`rule-value-${p}`,className:"text-xs font-medium",children:"发言频率值 (Value)"}),e.jsx(ie,{id:`rule-value-${p}`,type:"number",step:"0.01",min:"0.01",max:"1",value:f.value,onChange:g=>{const N=parseFloat(g.target.value);isNaN(N)||x(p,"value",Math.max(.01,Math.min(1,N)))},className:"w-20 h-8 text-xs"})]}),e.jsx(fa,{value:[f.value],onValueChange:g=>x(p,"value",g[0]),min:.01,max:1,step:.01,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.01 (极少发言)"}),e.jsx("span",{children:"0.5"}),e.jsx("span",{children:"1.0 (正常)"})]})]})]})]},p))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:'暂无规则,点击"添加规则"按钮创建'})}),e.jsxs("div",{className:"mt-4 p-4 bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[e.jsx("h5",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"📝 规则说明"}),e.jsxs("ul",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 为空"}),":全局规则,对所有聊天生效"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 指定"}),"仅对特定聊天流生效格式platform:id:type"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"优先级"}),":先匹配具体聊天流规则,再匹配全局规则"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"时间支持跨夜"}),":例如 23:00-02:00 表示晚上11点到次日凌晨2点"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"数值范围"}),":建议 0-10 表示完全沉默1 表示正常发言"]})]})]})]})]})}),vw=pt.memo(function({config:i,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"情绪设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:i.enable_mood,onCheckedChange:d=>r({...i,enable_mood:d})}),e.jsx(C,{className:"cursor-pointer",children:"启用情绪系统"})]}),i.enable_mood&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"情绪更新阈值"}),e.jsx(ie,{type:"number",min:"1",value:i.mood_update_threshold,onChange:d=>r({...i,mood_update_threshold:parseInt(d.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越高,更新越慢"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"情感特征"}),e.jsx(Ms,{value:i.emotion_style,onChange:d=>r({...i,emotion_style:d.target.value}),placeholder:"影响情绪的变化情况",rows:2})]})]})]})]})}),bw=pt.memo(function({config:i,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"语音设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:i.enable_asr,onCheckedChange:d=>r({...i,enable_asr:d})}),e.jsx(C,{className:"cursor-pointer",children:"启用语音识别"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后麦麦可以识别语音消息,需要配置语音识别模型"})]})}),Nw=pt.memo(function({config:i,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:i.enable,onCheckedChange:d=>r({...i,enable:d})}),e.jsx(C,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),i.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"LPMM 模式"}),e.jsxs(Re,{value:i.lpmm_mode,onValueChange:d=>r({...i,lpmm_mode:d}),children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"选择 LPMM 模式"})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"classic",children:"经典模式"}),e.jsx(le,{value:"agent",children:"Agent 模式"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"同义词搜索 TopK"}),e.jsx(ie,{type:"number",min:"1",value:i.rag_synonym_search_top_k,onChange:d=>r({...i,rag_synonym_search_top_k:parseInt(d.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"同义词阈值"}),e.jsx(ie,{type:"number",step:"0.1",min:"0",max:"1",value:i.rag_synonym_threshold,onChange:d=>r({...i,rag_synonym_threshold:parseFloat(d.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"实体提取线程数"}),e.jsx(ie,{type:"number",min:"1",value:i.info_extraction_workers,onChange:d=>r({...i,info_extraction_workers:parseInt(d.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"嵌入向量维度"}),e.jsx(ie,{type:"number",min:"1",value:i.embedding_dimension,onChange:d=>r({...i,embedding_dimension:parseInt(d.target.value)})})]})]})]})]})]})}),yw=pt.memo(function({config:i,onChange:r}){const[d,m]=u.useState(""),[x,f]=u.useState("WARNING"),p=()=>{d&&!i.suppress_libraries.includes(d)&&(r({...i,suppress_libraries:[...i.suppress_libraries,d]}),m(""))},g=_=>{r({...i,suppress_libraries:i.suppress_libraries.filter(L=>L!==_)})},N=()=>{d&&!i.library_log_levels[d]&&(r({...i,library_log_levels:{...i.library_log_levels,[d]:x}}),m(""),f("WARNING"))},j=_=>{const L={...i.library_log_levels};delete L[_],r({...i,library_log_levels:L})},w=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],y=["FULL","compact","lite"],k=["none","title","full"];return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"日志配置"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"日期格式"}),e.jsx(ie,{value:i.date_style,onChange:_=>r({...i,date_style:_.target.value}),placeholder:"例如: m-d H:i:s"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"m=月, d=日, H=时, i=分, s=秒"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"日志级别样式"}),e.jsxs(Re,{value:i.log_level_style,onValueChange:_=>r({...i,log_level_style:_}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:y.map(_=>e.jsx(le,{value:_,children:_},_))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"日志文本颜色"}),e.jsxs(Re,{value:i.color_text,onValueChange:_=>r({...i,color_text:_}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:k.map(_=>e.jsx(le,{value:_,children:_},_))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"全局日志级别"}),e.jsxs(Re,{value:i.log_level,onValueChange:_=>r({...i,log_level:_}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:w.map(_=>e.jsx(le,{value:_,children:_},_))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"控制台日志级别"}),e.jsxs(Re,{value:i.console_log_level,onValueChange:_=>r({...i,console_log_level:_}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:w.map(_=>e.jsx(le,{value:_,children:_},_))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"文件日志级别"}),e.jsxs(Re,{value:i.file_log_level,onValueChange:_=>r({...i,file_log_level:_}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsx(Oe,{children:w.map(_=>e.jsx(le,{value:_,children:_},_))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ie,{value:d,onChange:_=>m(_.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),p())}}),e.jsx(S,{onClick:p,size:"sm",className:"flex-shrink-0",children:e.jsx(rt,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.suppress_libraries.map(_=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-3 py-1 rounded-md",children:[e.jsx("span",{className:"text-sm",children:_}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>g(_),children:e.jsx(Ze,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},_))})]}),e.jsxs("div",{children:[e.jsx(C,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ie,{value:d,onChange:_=>m(_.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs(Re,{value:x,onValueChange:f,children:[e.jsx(De,{className:"w-32",children:e.jsx(Le,{})}),e.jsx(Oe,{children:w.map(_=>e.jsx(le,{value:_,children:_},_))})]}),e.jsx(S,{onClick:N,size:"sm",children:e.jsx(rt,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(i.library_log_levels).map(([_,L])=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-medium",children:_}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:L}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>j(_),children:e.jsx(Ze,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},_))})]})]})}),ww=pt.memo(function({config:i,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"调试配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否在日志中显示提示词"})]}),e.jsx(Ve,{checked:i.show_prompt,onCheckedChange:d=>r({...i,show_prompt:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示回复器 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的提示词"})]}),e.jsx(Ve,{checked:i.show_replyer_prompt,onCheckedChange:d=>r({...i,show_replyer_prompt:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示回复器推理"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的推理过程"})]}),e.jsx(Ve,{checked:i.show_replyer_reasoning,onCheckedChange:d=>r({...i,show_replyer_reasoning:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示 Jargon Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示术语相关的提示词"})]}),e.jsx(Ve,{checked:i.show_jargon_prompt,onCheckedChange:d=>r({...i,show_jargon_prompt:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示记忆检索 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示记忆检索相关的提示词"})]}),e.jsx(Ve,{checked:i.show_memory_prompt,onCheckedChange:d=>r({...i,show_memory_prompt:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示 Planner Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 Planner 的提示词和原始返回结果"})]}),e.jsx(Ve,{checked:i.show_planner_prompt,onCheckedChange:d=>r({...i,show_planner_prompt:d})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"显示 LPMM 相关文段"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 LPMM 知识库找到的相关文段日志"})]}),e.jsx(Ve,{checked:i.show_lpmm_paragraph,onCheckedChange:d=>r({...i,show_lpmm_paragraph:d})})]})]})]})}),_w=pt.memo(function({config:i,onChange:r}){const[d,m]=u.useState(""),x=()=>{d&&!i.auth_token.includes(d)&&(r({...i,auth_token:[...i.auth_token,d]}),m(""))},f=p=>{r({...i,auth_token:i.auth_token.filter((g,N)=>N!==p)})};return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"MaimMessage 服务配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"启用自定义服务器"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否使用自定义的 MaimMessage 服务器"})]}),e.jsx(Ve,{checked:i.use_custom,onCheckedChange:p=>r({...i,use_custom:p})})]}),i.use_custom&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"主机地址"}),e.jsx(ie,{value:i.host,onChange:p=>r({...i,host:p.target.value}),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"端口号"}),e.jsx(ie,{type:"number",value:i.port,onChange:p=>r({...i,port:parseInt(p.target.value)}),placeholder:"8090"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"连接模式"}),e.jsxs(Re,{value:i.mode,onValueChange:p=>r({...i,mode:p}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"ws",children:"WebSocket (ws)"}),e.jsx(le,{value:"tcp",children:"TCP"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{checked:i.use_wss,onCheckedChange:p=>r({...i,use_wss:p}),disabled:i.mode!=="ws"}),e.jsx(C,{children:"使用 WSS 安全连接"})]})]}),i.use_wss&&i.mode==="ws"&&e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"SSL 证书文件路径"}),e.jsx(ie,{value:i.cert_file,onChange:p=>r({...i,cert_file:p.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"SSL 密钥文件路径"}),e.jsx(ie,{value:i.key_file,onChange:p=>r({...i,key_file:p.target.value}),placeholder:"key.pem"})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"mb-2 block",children:"认证令牌"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"用于 API 验证,为空则不启用验证"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ie,{value:d,onChange:p=>m(p.target.value),placeholder:"输入认证令牌",onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),x())}}),e.jsx(S,{onClick:x,size:"sm",children:e.jsx(rt,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:i.auth_token.map((p,g)=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-mono",children:p}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>f(g),children:e.jsx(Ze,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},g))})]})]})}),Sw=pt.memo(function({config:i,onChange:r}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"统计信息"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"启用统计信息发送"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"发送匿名统计信息,帮助我们了解全球有多少只麦麦在运行"})]}),e.jsx(Ve,{checked:i.enable,onCheckedChange:d=>r({...i,enable:d})})]})]})}),Cw=pt.memo(function({emojiConfig:i,memoryConfig:r,toolConfig:d,onEmojiChange:m,onMemoryChange:x,onToolChange:f}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"工具设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_tool",checked:d.enable_tool,onCheckedChange:p=>f({...d,enable_tool:p})}),e.jsx(C,{htmlFor:"enable_tool",className:"cursor-pointer",children:"启用工具系统"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"允许麦麦使用各种工具来增强功能"})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"记忆设置"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"max_agent_iterations",children:"记忆思考深度"}),e.jsx(ie,{id:"max_agent_iterations",type:"number",min:"1",value:r.max_agent_iterations,onChange:p=>x({...r,max_agent_iterations:parseInt(p.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"最低为 1不深入思考"})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"表情包设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsx(ie,{id:"emoji_chance",type:"number",step:"0.1",min:"0",max:"1",value:i.emoji_chance,onChange:p=>m({...i,emoji_chance:parseFloat(p.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"范围 0-1越大越容易发送表情包"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"max_reg_num",children:"最大注册数量"}),e.jsx(ie,{id:"max_reg_num",type:"number",min:"1",value:i.max_reg_num,onChange:p=>m({...i,max_reg_num:parseInt(p.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦最多可以注册的表情包数量"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ie,{id:"check_interval",type:"number",min:"1",value:i.check_interval,onChange:p=>m({...i,check_interval:parseInt(p.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包(注册、破损、删除)的时间间隔"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"do_replace",checked:i.do_replace,onCheckedChange:p=>m({...i,do_replace:p})}),e.jsx(C,{htmlFor:"do_replace",className:"cursor-pointer",children:"达到最大数量时替换表情包"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"steal_emoji",checked:i.steal_emoji,onCheckedChange:p=>m({...i,steal_emoji:p})}),e.jsx(C,{htmlFor:"steal_emoji",className:"cursor-pointer",children:"偷取表情包"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"允许麦麦将看到的表情包据为己有"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"content_filtration",checked:i.content_filtration,onCheckedChange:p=>m({...i,content_filtration:p})}),e.jsx(C,{htmlFor:"content_filtration",className:"cursor-pointer",children:"启用表情包过滤"})]}),i.content_filtration&&e.jsxs("div",{className:"grid gap-2 pl-6 border-l-2 border-primary/20",children:[e.jsx(C,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ie,{id:"filtration_prompt",value:i.filtration_prompt,onChange:p=>m({...i,filtration_prompt:p.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}),kw=pt.memo(function({member:i,groupIndex:r,memberIndex:d,availableChatIds:m,onUpdate:x,onRemove:f}){const p=m.includes(i)||i==="*",[g,N]=u.useState(!p);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 flex gap-2",children:g?e.jsxs(e.Fragment,{children:[e.jsx(ie,{value:i,onChange:j=>x(r,d,j.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),m.length>0&&e.jsx(S,{size:"sm",variant:"outline",onClick:()=>N(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Re,{value:i,onValueChange:j=>x(r,d,j),children:[e.jsx(De,{className:"flex-1",children:e.jsx(Le,{placeholder:"选择聊天流"})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"*",children:"* (全局共享)"}),m.map((j,w)=>e.jsx(le,{value:j,children:j},w))]})]}),e.jsx(S,{size:"sm",variant:"outline",onClick:()=>N(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除组成员 "',i||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>f(r,d),children:"删除"})]})]})]})]})}),Tw=pt.memo(function({config:i,onChange:r}){const d=()=>{r({...i,learning_list:[...i.learning_list,["","enable","enable","1.0"]]})},m=y=>{r({...i,learning_list:i.learning_list.filter((k,_)=>_!==y)})},x=(y,k,_)=>{const L=[...i.learning_list];L[y][k]=_,r({...i,learning_list:L})},f=({rule:y})=>{const k=`["${y[0]}", "${y[1]}", "${y[2]}", "${y[3]}"]`;return e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",children:[e.jsx(Rt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(ka,{className:"w-80 sm:w-96",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:k}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},p=()=>{r({...i,expression_groups:[...i.expression_groups,[]]})},g=y=>{r({...i,expression_groups:i.expression_groups.filter((k,_)=>_!==y)})},N=y=>{const k=[...i.expression_groups];k[y]=[...k[y],""],r({...i,expression_groups:k})},j=(y,k)=>{const _=[...i.expression_groups];_[y]=_[y].filter((L,D)=>D!==k),r({...i,expression_groups:_})},w=(y,k,_)=>{const L=[...i.expression_groups];L[y][k]=_,r({...i,expression_groups:L})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达学习配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置麦麦如何学习和使用表达方式"})]}),e.jsxs(S,{onClick:d,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[i.learning_list.map((y,k)=>{const _=i.learning_list.some((z,I)=>I!==k&&z[0]===""),L=y[0]==="",D=y[0].split(":"),U=D[0]||"qq",Q=D[1]||"",R=D[2]||"group";return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["规则 ",k+1," ",L&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{rule:y}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"sm",variant:"ghost",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除学习规则 ",k+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>m(k),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(Re,{value:L?"global":"specific",onValueChange:z=>{z==="global"?x(k,0,""):x(k,0,"qq::group")},disabled:_&&!L,children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"global",children:"全局配置"}),e.jsx(le,{value:"specific",disabled:_&&!L,children:"详细配置"})]})]}),_&&!L&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!L&&e.jsxs("div",{className:"grid gap-4 p-3 sm:p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Re,{value:U,onValueChange:z=>{x(k,0,`${z}:${Q}:${R}`)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ie,{value:Q,onChange:z=>{x(k,0,`${U}:${z.target.value}:${R}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Re,{value:R,onValueChange:z=>{x(k,0,`${U}:${Q}:${z}`)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"group",children:"群组group"}),e.jsx(le,{value:"private",children:"私聊private"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID",y[0]||"(未设置)"]})]}),e.jsx("div",{className:"grid gap-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-xs font-medium",children:"使用学到的表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦使用从聊天中学到的表达方式"})]}),e.jsx(Ve,{checked:y[1]==="enable",onCheckedChange:z=>x(k,1,z?"enable":"disable")})]})}),e.jsx("div",{className:"grid gap-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-xs font-medium",children:"学习表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦从聊天中学习新的表达方式"})]}),e.jsx(Ve,{checked:y[2]==="enable",onCheckedChange:z=>x(k,2,z?"enable":"disable")})]})}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-xs font-medium",children:"学习强度"}),e.jsx(ie,{type:"number",step:"0.1",min:"0",max:"5",value:y[3],onChange:z=>{const I=parseFloat(z.target.value);isNaN(I)||x(k,3,Math.max(0,Math.min(5,I)).toFixed(1))},className:"w-20 h-8 text-xs"})]}),e.jsx(fa,{value:[parseFloat(y[3])||1],onValueChange:z=>x(k,3,z[0].toFixed(1)),min:0,max:5,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0 (不学习)"}),e.jsx("span",{children:"2.5"}),e.jsx("span",{children:"5.0 (快速学习)"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响学习频率,最短学习间隔 = 300/学习强度(秒)"})]})]})]},k)}),i.learning_list.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无学习规则,点击"添加规则"开始配置'})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达反思配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置麦麦主动向管理员询问表达方式是否合适的功能"})]}),e.jsx(Ve,{checked:i.reflect,onCheckedChange:y=>r({...i,reflect:y})})]}),i.reflect&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("span",{className:"text-sm font-medium",children:"反思操作员"})}),e.jsx("div",{className:"space-y-4",children:(()=>{const k=(i.reflect_operator_id||"").split(":"),_=k[0]||"qq",L=k[1]||"",D=k[2]||"private";return e.jsxs("div",{className:"grid gap-4 p-3 sm:p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Re,{value:_,onValueChange:U=>{r({...i,reflect_operator_id:`${U}:${L}:${D}`})},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"用户/群 ID"}),e.jsx(ie,{value:L,onChange:U=>{r({...i,reflect_operator_id:`${_}:${U.target.value}:${D}`})},placeholder:"输入 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Re,{value:D,onValueChange:U=>{r({...i,reflect_operator_id:`${_}:${L}:${U}`})},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"private",children:"私聊private"}),e.jsx(le,{value:"group",children:"群组group"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前操作员 ID",i.reflect_operator_id||"(未设置)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦会向此操作员询问表达方式是否合适"})]})})()})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium",children:"允许反思的聊天流"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"只有在此列表中的聊天流才会提出问题并跟踪。如果列表为空,则所有聊天流都可以进行表达反思"})]}),e.jsxs(S,{onClick:()=>{r({...i,allow_reflect:[...i.allow_reflect||[],"qq::group"]})},size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加聊天流"]})]}),e.jsxs("div",{className:"space-y-2",children:[(i.allow_reflect||[]).map((y,k)=>{const _=y.split(":"),L=_[0]||"qq",D=_[1]||"",U=_[2]||"group";return e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50",children:[e.jsxs(Re,{value:L,onValueChange:Q=>{const R=[...i.allow_reflect];R[k]=`${Q}:${D}:${U}`,r({...i,allow_reflect:R})},children:[e.jsx(De,{className:"w-24",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"qq",children:"QQ"}),e.jsx(le,{value:"wx",children:"微信"})]})]}),e.jsx(ie,{value:D,onChange:Q=>{const R=[...i.allow_reflect];R[k]=`${L}:${Q.target.value}:${U}`,r({...i,allow_reflect:R})},placeholder:"ID",className:"flex-1 font-mono text-sm"}),e.jsxs(Re,{value:U,onValueChange:Q=>{const R=[...i.allow_reflect];R[k]=`${L}:${D}:${Q}`,r({...i,allow_reflect:R})},children:[e.jsx(De,{className:"w-32",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"group",children:"群组"}),e.jsx(le,{value:"private",children:"私聊"})]})]}),e.jsx(S,{onClick:()=>{r({...i,allow_reflect:i.allow_reflect.filter((Q,R)=>R!==k)})},size:"sm",variant:"ghost",children:e.jsx(Ze,{className:"h-4 w-4"})})]},k)}),(!i.allow_reflect||i.allow_reflect.length===0)&&e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"列表为空,所有聊天流都可以进行表达反思"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"表达共享组配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"配置不同聊天流之间如何共享学到的表达方式"})]}),e.jsxs(S,{onClick:p,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[i.expression_groups.map((y,k)=>{const _=i.learning_list.map(L=>L[0]).filter(L=>L!=="");return e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["共享组 ",k+1,y.length===1&&y[0]==="*"&&"(全局共享)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{onClick:()=>N(k),size:"sm",variant:"outline",children:e.jsx(rt,{className:"h-4 w-4"})}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"sm",variant:"ghost",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除共享组 ",k+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>g(k),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:y.map((L,D)=>e.jsx(kw,{member:L,groupIndex:k,memberIndex:D,availableChatIds:_,onUpdate:w,onRemove:j},`${k}-${D}`))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},k)}),i.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})})]})});function Ew({regex:n,reaction:i,onRegexChange:r,onReactionChange:d}){const[m,x]=u.useState(!1),[f,p]=u.useState(""),[g,N]=u.useState(null),[j,w]=u.useState(""),[y,k]=u.useState({}),[_,L]=u.useState(""),D=u.useRef(null),[U,Q]=u.useState("build"),R=E=>E.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),z=(E,M=0)=>{const se=D.current;if(!se)return;const fe=se.selectionStart||0,ve=se.selectionEnd||0,Ne=n.substring(0,fe)+E+n.substring(ve);r(Ne),setTimeout(()=>{const je=fe+E.length+M;se.setSelectionRange(je,je),se.focus()},0)};u.useEffect(()=>{if(!n||!f){N(null),k({}),L(i),w("");return}try{const E=R(n),M=new RegExp(E,"g"),se=f.match(M);N(se),w("");const ve=new RegExp(E).exec(f);if(ve&&ve.groups){k(ve.groups);let Ne=i;Object.entries(ve.groups).forEach(([je,ye])=>{Ne=Ne.replace(new RegExp(`\\[${je}\\]`,"g"),ye||"")}),L(Ne)}else k({}),L(i)}catch(E){w(E.message),N(null),k({}),L(i)}},[n,f,i]);const I=()=>{if(!f||!g||g.length===0)return e.jsx("span",{className:"text-muted-foreground",children:f||"请输入测试文本"});try{const E=R(n),M=new RegExp(E,"g");let se=0;const fe=[];let ve;for(;(ve=M.exec(f))!==null;)ve.index>se&&fe.push(e.jsx("span",{children:f.substring(se,ve.index)},`text-${se}`)),fe.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:ve[0]},`match-${ve.index}`)),se=ve.index+ve[0].length;return se<f.length&&fe.push(e.jsx("span",{children:f.substring(se)},`text-${se}`)),e.jsx(e.Fragment,{children:fe})}catch{return e.jsx("span",{children:f})}},$=[{category:"基础匹配",items:[{label:"任意字符",pattern:".",desc:"匹配除换行符外的任意字符"},{label:"数字",pattern:"\\d",desc:"匹配 0-9"},{label:"非数字",pattern:"\\D",desc:"匹配非数字字符"},{label:"字母数字",pattern:"\\w",desc:"匹配字母、数字、下划线"},{label:"非字母数字",pattern:"\\W",desc:"匹配非字母数字字符"},{label:"空白符",pattern:"\\s",desc:"匹配空格、制表符等"},{label:"非空白符",pattern:"\\S",desc:"匹配非空白字符"}]},{category:"位置锚点",items:[{label:"行首",pattern:"^",desc:"匹配行的开始"},{label:"行尾",pattern:"$",desc:"匹配行的结束"},{label:"单词边界",pattern:"\\b",desc:"匹配单词边界"}]},{category:"重复次数",items:[{label:"0或多次",pattern:"*",desc:"匹配前面的元素0次或多次"},{label:"1或多次",pattern:"+",desc:"匹配前面的元素1次或多次"},{label:"0或1次",pattern:"?",desc:"匹配前面的元素0次或1次"},{label:"指定次数",pattern:"{n}",desc:"匹配n次将n替换为数字"},{label:"次数范围",pattern:"{m,n}",desc:"匹配m到n次"}]},{category:"分组和捕获",items:[{label:"普通分组",pattern:"()",desc:"分组但不捕获",moveCursor:-1},{label:"命名捕获",pattern:"(?P<name>)",desc:"Python风格命名捕获组",moveCursor:-1},{label:"非捕获组",pattern:"(?:)",desc:"分组但不保存匹配结果",moveCursor:-1}]},{category:"字符类",items:[{label:"字符集",pattern:"[]",desc:"匹配括号内的任意字符",moveCursor:-1},{label:"排除字符",pattern:"[^]",desc:"匹配不在括号内的字符",moveCursor:-1},{label:"范围",pattern:"[a-z]",desc:"匹配a到z的字符"},{label:"中文字符",pattern:"[\\u4e00-\\u9fa5]",desc:"匹配中文汉字"}]},{category:"常用模板",items:[{label:"捕获词语",pattern:"(?P<word>\\S+)",desc:"捕获一个词语"},{label:"捕获句子",pattern:"(?P<sentence>.+)",desc:"捕获整个句子"},{label:"捕获数字",pattern:"(?P<num>\\d+)",desc:"捕获一个或多个数字"},{label:"可选词语",pattern:"(?:词语1|词语2)",desc:"匹配多个可选项之一"}]}];return e.jsxs(Gs,{open:m,onOpenChange:x,children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",children:[e.jsx(Yu,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(Rs,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"正则表达式编辑器"}),e.jsx(Ps,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(Ke,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(Ca,{value:U,onValueChange:E=>Q(E),className:"w-full",children:[e.jsxs(pa,{className:"grid w-full grid-cols-2",children:[e.jsx(es,{value:"build",children:"🔧 构建器"}),e.jsx(es,{value:"test",children:"🧪 测试器"})]}),e.jsxs(ws,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(ie,{ref:D,value:n,onChange:E=>r(E.target.value),className:"font-mono text-sm",placeholder:"点击下方按钮构建正则表达式..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"Reaction 内容"}),e.jsx(Ms,{value:i,onChange:E=>d(E.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[$.map(E=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:E.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:E.items.map(M=>e.jsx(S,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>z(M.pattern,M.moveCursor||0),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("span",{className:"text-xs font-medium",children:M.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:M.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:M.desc})]})},M.label))})]},E.category)),e.jsxs("div",{className:"space-y-2 border-t pt-4",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:"完整示例模板"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>r("^(?P<n>\\S{1,20})是这样的$"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsxs("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:["^(?P<n>\\S","{1,20}",")是这样的$"]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「某事物是这样的」并捕获事物名称"})]})}),e.jsx(S,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>r("(?:[^,。.\\s]+\\s*)?我(?:也)?[没沒]要求你\\s*(?P<action>.+?)[.。,]?$"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?:[^,。.\\s]+\\s*)?我(?:也)?[没沒]要求你\\s*(?P<action>.+?)[.。,]?$"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「我没要求你做某事」并捕获具体行为"})]})}),e.jsx(S,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>r("(?P<subject>.+?)(?:是|为什么|怎么)"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?P<subject>.+?)(?:是|为什么|怎么)"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"捕获问题主题词"})]})})]})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 使用提示"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"点击输入框设置光标位置,然后点击按钮插入模式"}),e.jsxs("li",{children:["命名捕获组格式:",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"(?P<名称>模式)"})]}),e.jsxs("li",{children:["在 reaction 中使用 ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"[名称]"})," 引用捕获的内容"]}),e.jsx("li",{children:"切换到测试器标签页验证正则表达式效果"})]})]})]}),e.jsxs(ws,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:n||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(Ms,{id:"test-text",value:f,onChange:E=>p(E.target.value),placeholder:`在此输入要测试的文本...
例如:打游戏是这样的`,className:"min-h-[100px] text-sm"})]}),j&&e.jsxs("div",{className:"rounded-md bg-destructive/10 border border-destructive/20 p-3",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:"正则表达式错误"}),e.jsx("p",{className:"text-xs text-destructive/80 mt-1",children:j})]}),!j&&f&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:g&&g.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500"}),e.jsxs("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:["匹配成功 (",g.length," 处)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-gray-400"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"无匹配"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"匹配高亮"}),e.jsx(Ke,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:I()})})]}),Object.keys(y).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(Ke,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(y).map(([E,M])=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsxs("span",{className:"font-mono font-semibold text-primary min-w-[80px]",children:["[",E,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:M})]},E))})})]}),Object.keys(y).length>0&&i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(Ke,{className:"h-48 rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3",children:e.jsx("div",{className:"text-sm break-words",children:_})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"reaction 中的 [name] 已被替换为对应的捕获组值"})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 测试说明"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"匹配的文本会以黄色背景高亮显示"}),e.jsx("li",{children:"命名捕获组的值会显示在下方列表中"}),e.jsx("li",{children:"Reaction 替换预览显示最终生成的反应内容"}),e.jsx("li",{children:"如需修改正则,切换回构建器标签页"})]})]})]})]})})]})]})}const zw=pt.memo(function({keywordReactionConfig:i,responsePostProcessConfig:r,chineseTypoConfig:d,responseSplitterConfig:m,onKeywordReactionChange:x,onResponsePostProcessChange:f,onChineseTypoChange:p,onResponseSplitterChange:g}){const N=()=>{x({...i,regex_rules:[...i.regex_rules,{regex:[""],reaction:""}]})},j=z=>{x({...i,regex_rules:i.regex_rules.filter((I,$)=>$!==z)})},w=(z,I,$)=>{const E=[...i.regex_rules];I==="regex"&&typeof $=="string"?E[z]={...E[z],regex:[$]}:I==="reaction"&&typeof $=="string"&&(E[z]={...E[z],reaction:$}),x({...i,regex_rules:E})},y=()=>{x({...i,keyword_rules:[...i.keyword_rules,{keywords:[],reaction:""}]})},k=z=>{x({...i,keyword_rules:i.keyword_rules.filter((I,$)=>$!==z)})},_=(z,I,$)=>{const E=[...i.keyword_rules];typeof $=="string"&&(E[z]={...E[z],reaction:$}),x({...i,keyword_rules:E})},L=z=>{const I=[...i.keyword_rules];I[z]={...I[z],keywords:[...I[z].keywords||[],""]},x({...i,keyword_rules:I})},D=(z,I)=>{const $=[...i.keyword_rules];$[z]={...$[z],keywords:($[z].keywords||[]).filter((E,M)=>M!==I)},x({...i,keyword_rules:$})},U=(z,I,$)=>{const E=[...i.keyword_rules],M=[...E[z].keywords||[]];M[I]=$,E[z]={...E[z],keywords:M},x({...i,keyword_rules:E})},Q=({rule:z})=>{const I=`{ regex = [${(z.regex||[]).map($=>`"${$}"`).join(", ")}], reaction = "${z.reaction}" }`;return e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",children:[e.jsx(Rt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(ka,{className:"w-[95vw] sm:w-[500px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx(Ke,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:I})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},R=({rule:z})=>{const I=`[[keyword_reaction.keyword_rules]]
keywords = [${(z.keywords||[]).map($=>`"${$}"`).join(", ")}]
reaction = "${z.reaction}"`;return e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",children:[e.jsx(Rt,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(ka,{className:"w-[95vw] sm:w-[500px]",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"配置预览"}),e.jsx(Ke,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:I})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"关键词反应配置"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置触发特定反应的关键词和正则表达式规则"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"正则表达式规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"使用正则表达式匹配消息内容"})]}),e.jsxs(S,{onClick:N,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[i.regex_rules.map((z,I)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["正则规则 ",I+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ew,{regex:z.regex&&z.regex[0]||"",reaction:z.reaction,onRegexChange:$=>w(I,"regex",$),onReactionChange:$=>w(I,"reaction",$)}),e.jsx(Q,{rule:z}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"sm",variant:"ghost",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除正则规则 ",I+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>j(I),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"正则表达式Python 语法)"}),e.jsx(ie,{value:z.regex&&z.regex[0]||"",onChange:$=>w(I,"regex",$.target.value),placeholder:"例如:^(?P<n>\\\\S{1,20})是这样的$ (点击正则编辑器按钮可视化构建)",className:"font-mono text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'支持命名捕获组 (?P<name>pattern),可在 reaction 中使用 [name] 引用。点击"正则编辑器"可视化构建和测试!'})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Ms,{value:z.reaction,onChange:$=>w(I,"reaction",$.target.value),placeholder:`触发后麦麦的反应...
可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},I)),i.regex_rules.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无正则规则,点击"添加正则规则"开始配置'})]})]}),e.jsxs("div",{className:"space-y-4 border-t pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-semibold",children:"关键词规则"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"使用关键词列表匹配消息内容"})]}),e.jsxs(S,{onClick:y,size:"sm",variant:"outline",children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[i.keyword_rules.map((z,I)=>e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["关键词规则 ",I+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{rule:z}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"sm",variant:"ghost",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除关键词规则 ",I+1," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>k(I),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-xs font-medium",children:"关键词列表"}),e.jsxs(S,{onClick:()=>L(I),size:"sm",variant:"ghost",children:[e.jsx(rt,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(z.keywords||[]).map(($,E)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{value:$,onChange:M=>U(I,E,M.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(S,{onClick:()=>D(I,E),size:"sm",variant:"ghost",children:e.jsx(Ze,{className:"h-4 w-4"})})]},E)),(!z.keywords||z.keywords.length===0)&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:'暂无关键词,点击"添加关键词"开始配置'})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Ms,{value:z.reaction,onChange:$=>_(I,"reaction",$.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},I)),i.keyword_rules.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无关键词规则,点击"添加关键词规则"开始配置'})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"回复后处理配置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_response_post_process",checked:r.enable_response_post_process,onCheckedChange:z=>f({...r,enable_response_post_process:z})}),e.jsx(C,{htmlFor:"enable_response_post_process",className:"cursor-pointer",children:"启用回复后处理"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"包括错别字生成器和回复分割器"})]}),r.enable_response_post_process&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t pt-6 space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(Ve,{id:"enable_chinese_typo",checked:d.enable,onCheckedChange:z=>p({...d,enable:z})}),e.jsx(C,{htmlFor:"enable_chinese_typo",className:"cursor-pointer font-semibold",children:"中文错别字生成器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"为回复添加随机错别字,让麦麦的回复更自然"}),d.enable&&e.jsxs("div",{className:"grid gap-4 pl-6 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"error_rate",className:"text-xs font-medium",children:"单字替换概率"}),e.jsx(ie,{id:"error_rate",type:"number",step:"0.001",min:"0",max:"1",value:d.error_rate,onChange:z=>p({...d,error_rate:parseFloat(z.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"min_freq",className:"text-xs font-medium",children:"最小字频阈值"}),e.jsx(ie,{id:"min_freq",type:"number",min:"0",value:d.min_freq,onChange:z=>p({...d,min_freq:parseInt(z.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"tone_error_rate",className:"text-xs font-medium",children:"声调错误概率"}),e.jsx(ie,{id:"tone_error_rate",type:"number",step:"0.01",min:"0",max:"1",value:d.tone_error_rate,onChange:z=>p({...d,tone_error_rate:parseFloat(z.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"word_replace_rate",className:"text-xs font-medium",children:"整词替换概率"}),e.jsx(ie,{id:"word_replace_rate",type:"number",step:"0.001",min:"0",max:"1",value:d.word_replace_rate,onChange:z=>p({...d,word_replace_rate:parseFloat(z.target.value)})})]})]})]})}),e.jsx("div",{className:"border-t pt-6 space-y-4",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[e.jsx(Ve,{id:"enable_response_splitter",checked:m.enable,onCheckedChange:z=>g({...m,enable:z})}),e.jsx(C,{htmlFor:"enable_response_splitter",className:"cursor-pointer font-semibold",children:"回复分割器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"控制回复的长度和句子数量"}),m.enable&&e.jsxs("div",{className:"grid gap-4 pl-6 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"max_length",className:"text-xs font-medium",children:"最大长度"}),e.jsx(ie,{id:"max_length",type:"number",min:"1",value:m.max_length,onChange:z=>g({...m,max_length:parseInt(z.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大字符数"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"max_sentence_num",className:"text-xs font-medium",children:"最大句子数"}),e.jsx(ie,{id:"max_sentence_num",type:"number",min:"1",value:m.max_sentence_num,onChange:z=>g({...m,max_sentence_num:parseInt(z.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大句子数量"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_kaomoji_protection",checked:m.enable_kaomoji_protection,onCheckedChange:z=>g({...m,enable_kaomoji_protection:z})}),e.jsx(C,{htmlFor:"enable_kaomoji_protection",className:"cursor-pointer",children:"启用颜文字保护"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"enable_overflow_return_all",checked:m.enable_overflow_return_all,onCheckedChange:z=>g({...m,enable_overflow_return_all:z})}),e.jsx(C,{htmlFor:"enable_overflow_return_all",className:"cursor-pointer",children:"超出时一次性返回全部"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})}),Rl="/api/webui/config";async function hp(){const i=await(await _e(`${Rl}/bot`)).json();if(!i.success)throw new Error("获取配置数据失败");return i.config}async function Zn(){const i=await(await _e(`${Rl}/model`)).json();if(!i.success)throw new Error("获取模型配置数据失败");return i.config}async function fp(n){const r=await(await _e(`${Rl}/bot`,{method:"POST",body:JSON.stringify(n)})).json();if(!r.success)throw new Error(r.message||"保存配置失败")}async function Mw(){const i=await(await _e(`${Rl}/bot/raw`)).json();if(!i.success)throw new Error("获取配置源代码失败");return i.content}async function Aw(n){const r=await(await _e(`${Rl}/bot/raw`,{method:"POST",body:JSON.stringify({raw_content:n})})).json();if(!r.success)throw new Error(r.message||"保存配置失败")}async function Kc(n){const r=await(await _e(`${Rl}/model`,{method:"POST",body:JSON.stringify(n)})).json();if(!r.success)throw new Error(r.message||"保存配置失败")}async function Dw(n,i){const d=await(await _e(`${Rl}/bot/section/${n}`,{method:"POST",body:JSON.stringify(i)})).json();if(!d.success)throw new Error(d.message||`保存配置节 ${n} 失败`)}async function Gu(n,i){const d=await(await _e(`${Rl}/model/section/${n}`,{method:"POST",body:JSON.stringify(i)})).json();if(!d.success)throw new Error(d.message||`保存配置节 ${n} 失败`)}async function Ow(n,i="openai",r="/models"){const d=new URLSearchParams({provider_name:n,parser:i,endpoint:r}),m=await _e(`/api/webui/models/list?${d}`);if(!m.ok){const f=await m.json().catch(()=>({}));throw new Error(f.detail||`获取模型列表失败 (${m.status})`)}const x=await m.json();if(!x.success)throw new Error("获取模型列表失败");return x.models}async function Rw(n){const i=new URLSearchParams({provider_name:n}),r=await _e(`/api/webui/models/test-connection-by-name?${i}`,{method:"POST"});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`测试连接失败 (${r.status})`)}return await r.json()}const Lw=si("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),It=u.forwardRef(({className:n,variant:i,...r},d)=>e.jsx("div",{ref:d,role:"alert",className:q(Lw({variant:i}),n),...r}));It.displayName="Alert";const Uw=u.forwardRef(({className:n,...i},r)=>e.jsx("h5",{ref:r,className:q("mb-1 font-medium leading-none tracking-tight",n),...i}));Uw.displayName="AlertTitle";const Yt=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{ref:r,className:q("text-sm [&_p]:leading-relaxed",n),...i}));Yt.displayName="AlertDescription";function Wu({onRestartComplete:n,onRestartFailed:i}){const[r,d]=u.useState(0),[m,x]=u.useState("restarting"),[f,p]=u.useState(0),[g,N]=u.useState(0);u.useEffect(()=>{const y=setInterval(()=>{d(L=>L>=90?L:L+1)},200),k=setInterval(()=>{p(L=>L+1)},1e3),_=setTimeout(()=>{x("checking"),j()},3e3);return()=>{clearInterval(y),clearInterval(k),clearTimeout(_)}},[]);const j=()=>{const k=async()=>{try{if(N(L=>L+1),(await fetch("/api/webui/system/status",{method:"GET",headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(3e3)})).ok)d(100),x("success"),setTimeout(()=>{n?.()},1500);else throw new Error("Status check failed")}catch{g<60?setTimeout(k,2e3):(x("failed"),i?.())}};k()},w=y=>{const k=Math.floor(y/60),_=y%60;return`${k}:${_.toString().padStart(2,"0")}`};return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsxs("div",{className:"max-w-md w-full mx-4 space-y-8",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[m==="restarting"&&e.jsxs(e.Fragment,{children:[e.jsx(Js,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"请稍候,麦麦正在重启中..."})]}),m==="checking"&&e.jsxs(e.Fragment,{children:[e.jsx(Js,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"检查服务状态"}),e.jsxs("p",{className:"text-muted-foreground text-center",children:["等待服务恢复... (尝试 ",g,"/60)"]})]}),m==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(aa,{className:"h-16 w-16 text-green-500"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启成功"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"正在跳转到登录页面..."})]}),m==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx(Mt,{className:"h-16 w-16 text-destructive"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启超时"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"服务未能在预期时间内恢复,请手动检查或刷新页面"})]})]}),m!=="failed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ni,{value:r,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[r,"%"]}),e.jsxs("span",{children:["已用时: ",w(f)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[m==="restarting"&&"🔄 配置已保存,正在重启主程序...",m==="checking"&&"⏳ 正在等待服务恢复,请勿关闭页面...",m==="success"&&"✅ 配置已生效,服务运行正常",m==="failed"&&"⚠️ 如果长时间无响应,请尝试手动重启"]})}),m==="failed"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"刷新页面"}),e.jsx("button",{onClick:()=>{x("checking"),N(0),j()},className:"flex-1 px-4 py-2 bg-secondary text-secondary-foreground rounded-md hover:bg-secondary/90",children:"重试检测"})]})]})})}const Bw={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(n,i){let r;if(!i.inString&&(r=n.match(/^('''|"""|'|")/))&&(i.stringType=r[0],i.inString=!0),n.sol()&&!i.inString&&i.inArray===0&&(i.lhs=!0),i.inString){for(;i.inString;)if(n.match(i.stringType))i.inString=!1;else if(n.peek()==="\\")n.next(),n.next();else{if(n.eol())break;n.match(/^.[^\\\"\']*/)}return i.lhs?"property":"string"}else{if(i.inArray&&n.peek()==="]")return n.next(),i.inArray--,"bracket";if(i.lhs&&n.peek()==="["&&n.skipTo("]"))return n.next(),n.peek()==="]"&&n.next(),"atom";if(n.peek()==="#")return n.skipToEnd(),"comment";if(n.eatSpace())return null;if(i.lhs&&n.eatWhile(function(d){return d!="="&&d!=" "}))return"property";if(i.lhs&&n.peek()==="=")return n.next(),i.lhs=!1,null;if(!i.lhs&&n.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!i.lhs&&(n.match("true")||n.match("false")))return"atom";if(!i.lhs&&n.peek()==="[")return i.inArray++,n.next(),"bracket";if(!i.lhs&&n.match(/^\-?\d+(?:\.\d+)?/))return"number";n.eatSpace()||n.next()}return null},languageData:{commentTokens:{line:"#"}}},Hw={python:[My()],json:[Ay(),Dy()],toml:[zy.define(Bw)],text:[]};function qw({value:n,onChange:i,language:r="text",readOnly:d=!1,height:m="400px",minHeight:x,maxHeight:f,placeholder:p,theme:g="dark",className:N=""}){const[j,w]=u.useState(!1);if(u.useEffect(()=>{w(!0)},[]),!j)return e.jsx("div",{className:`rounded-md border bg-muted animate-pulse ${N}`,style:{height:m,minHeight:x,maxHeight:f}});const y=[...Hw[r]||[],ap.lineWrapping];return d&&y.push(ap.editable.of(!1)),e.jsx("div",{className:`rounded-md overflow-hidden border ${N}`,children:e.jsx(Oy,{value:n,height:m,minHeight:x,maxHeight:f,theme:g==="dark"?Ry:void 0,extensions:y,onChange:i,placeholder:p,basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightSpecialChars:!0,history:!0,foldGutter:!0,drawSelection:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,syntaxHighlighting:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,rectangularSelection:!0,crosshairCursor:!0,highlightActiveLine:!0,highlightSelectionMatches:!0,closeBracketsKeymap:!0,defaultKeymap:!0,searchKeymap:!0,historyKeymap:!0,foldKeymap:!0,completionKeymap:!0,lintKeymap:!0}})})}function Gw(n,i,r,d={}){const{debounceMs:m=2e3,onSaveSuccess:x,onSaveError:f}=d,p=u.useRef(null),g=u.useCallback(async(y,k)=>{try{i(!0),await Dw(y,k),r(!1),x?.()}catch(_){console.error(`自动保存 ${y} 失败:`,_),r(!0),f?.(_ instanceof Error?_:new Error(String(_)))}finally{i(!1)}},[i,r,x,f]),N=u.useCallback((y,k)=>{n||(r(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{g(y,k)},m))},[n,r,g,m]),j=u.useCallback(async(y,k)=>{p.current&&(clearTimeout(p.current),p.current=null),await g(y,k)},[g]),w=u.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]);return u.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]),{triggerAutoSave:N,saveNow:j,cancelPendingAutoSave:w}}function _t(n,i,r,d){u.useEffect(()=>{n&&!r&&d(i,n)},[n])}const Fw=500;function Vw(){const[n,i]=u.useState(!0),[r,d]=u.useState(!1),[m,x]=u.useState(!1),[f,p]=u.useState(!1),[g,N]=u.useState(!1),[j,w]=u.useState(!1),[y,k]=u.useState("visual"),[_,L]=u.useState(""),[D,U]=u.useState(!1),{toast:Q}=Bs(),[R,z]=u.useState(null),[I,$]=u.useState(null),[E,M]=u.useState(null),[se,fe]=u.useState(null),[ve,Ne]=u.useState(null),[je,ye]=u.useState(null),[Se,O]=u.useState(null),[G,H]=u.useState(null),[ee,v]=u.useState(null),[X,me]=u.useState(null),[ce,xe]=u.useState(null),[we,oe]=u.useState(null),[Z,te]=u.useState(null),[V,P]=u.useState(null),[ke,He]=u.useState(null),[pe,Te]=u.useState(null),[Qs,vt]=u.useState(null),[de,qe]=u.useState(null),Ie=u.useRef(!0),Ys=u.useRef({}),Hs=u.useCallback(be=>{Ys.current=be,z(be.bot),$(be.personality);const _s=be.chat;_s.talk_value_rules||(_s.talk_value_rules=[]),M(_s),fe(be.expression),Ne(be.emoji),ye(be.memory),O(be.tool),H(be.mood),v(be.voice),me(be.lpmm_knowledge),xe(be.keyword_reaction),oe(be.response_post_process),te(be.chinese_typo),P(be.response_splitter),He(be.log),Te(be.debug),vt(be.maim_message),qe(be.telemetry)},[]),bt=u.useCallback(()=>({...Ys.current,bot:R,personality:I,chat:E,expression:se,emoji:ve,memory:je,tool:Se,mood:G,voice:ee,lpmm_knowledge:X,keyword_reaction:ce,response_post_process:we,chinese_typo:Z,response_splitter:V,log:ke,debug:pe,maim_message:Qs,telemetry:de}),[R,I,E,se,ve,je,Se,G,ee,X,ce,we,Z,V,ke,pe,Qs,de]),ot=u.useCallback(async()=>{try{const be=await Mw();L(be),U(!1)}catch(be){Q({variant:"destructive",title:"加载失败",description:be instanceof Error?be.message:"加载源代码失败"})}},[Q]),Ds=u.useCallback(async()=>{try{i(!0);const be=await hp();Hs(be),p(!1),Ie.current=!1,await ot()}catch(be){console.error("加载配置失败:",be),Q({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{i(!1)}},[Q,ot,Hs]);u.useEffect(()=>{Ds()},[Ds]);const{triggerAutoSave:ks,cancelPendingAutoSave:va}=Gw(Ie.current,x,p);_t(R,"bot",Ie.current,ks),_t(I,"personality",Ie.current,ks),_t(E,"chat",Ie.current,ks),_t(se,"expression",Ie.current,ks),_t(ve,"emoji",Ie.current,ks),_t(je,"memory",Ie.current,ks),_t(Se,"tool",Ie.current,ks),_t(G,"mood",Ie.current,ks),_t(ee,"voice",Ie.current,ks),_t(X,"lpmm_knowledge",Ie.current,ks),_t(ce,"keyword_reaction",Ie.current,ks),_t(we,"response_post_process",Ie.current,ks),_t(Z,"chinese_typo",Ie.current,ks),_t(V,"response_splitter",Ie.current,ks),_t(ke,"log",Ie.current,ks),_t(pe,"debug",Ie.current,ks),_t(Qs,"maim_message",Ie.current,ks),_t(de,"telemetry",Ie.current,ks);const Y=async()=>{try{d(!0),await Aw(_),p(!1),U(!1),Q({title:"保存成功",description:"配置已保存"}),await Ds()}catch(be){U(!0),Q({variant:"destructive",title:"保存失败",description:be instanceof Error?be.message:"保存配置失败"})}finally{d(!1)}},Be=async be=>{if(f){Q({variant:"destructive",title:"切换失败",description:"请先保存当前更改"});return}if(k(be),be==="source")await ot();else try{const _s=await hp();Hs(_s),p(!1)}catch(_s){console.error("加载配置失败:",_s),Q({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}},Ee=async()=>{try{d(!0),va(),await fp(bt()),p(!1),Q({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(be){console.error("保存配置失败:",be),Q({title:"保存失败",description:be.message,variant:"destructive"})}finally{d(!1)}},Ye=async()=>{try{N(!0),Wc().catch(()=>{}),w(!0)}catch(be){console.error("重启失败:",be),w(!1),Q({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),N(!1)}},Xs=async()=>{try{d(!0),va(),await fp(bt()),p(!1),Q({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(be=>setTimeout(be,Fw)),await Ye()}catch(be){console.error("保存失败:",be),Q({title:"保存失败",description:be.message,variant:"destructive"})}finally{d(!1)}},Je=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},qs=()=>{w(!1),N(!1),Q({title:"重启失败",description:"服务器未能在预期时间内恢复,请手动检查",variant:"destructive"})};return n?e.jsx(Ke,{className:"h-full",children:e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})})}):e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl md:text-3xl font-bold",children:"麦麦主程序配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-xs sm:text-sm",children:"管理麦麦的核心功能和行为设置"})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs(S,{onClick:y==="visual"?Ee:Y,disabled:r||m||!f||g,size:"sm",variant:"outline",className:"w-20 sm:w-24",children:[e.jsx(gr,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{className:"ml-1 truncate text-xs sm:text-sm",children:r?"保存中":m?"自动":f?"保存":"已保存"})]}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{disabled:r||m||g,size:"sm",className:"w-20 sm:w-28",children:[e.jsx(pr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"ml-1 truncate text-xs sm:text-sm",children:g?"重启中":f?"保存重启":"重启"})]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认重启麦麦?"}),e.jsx(rs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:f?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:f?Xs:Ye,children:f?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsx("div",{className:"flex",children:e.jsx(Ca,{value:y,onValueChange:be=>Be(be),className:"w-full",children:e.jsxs(pa,{className:"h-8 sm:h-9 w-full grid grid-cols-2",children:[e.jsxs(es,{value:"visual",className:"text-xs sm:text-sm",children:[e.jsx(cy,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"可视化编辑"]}),e.jsxs(es,{value:"source",className:"text-xs sm:text-sm",children:[e.jsx(oy,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"源代码编辑"]})]})})})]}),e.jsxs(It,{children:[e.jsx(Oa,{className:"h-4 w-4"}),e.jsxs(Yt,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),y==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(It,{children:[e.jsx(Oa,{className:"h-4 w-4"}),e.jsxs(Yt,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。此功能仅适用于熟悉 TOML 语法的高级用户。保存时会在后端验证格式,只有格式完全正确才能保存。",D&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(qw,{value:_,onChange:be=>{L(be),p(!0),D&&U(!1)},language:"toml",theme:"dark",height:"calc(100vh - 280px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),y==="visual"&&e.jsx(e.Fragment,{children:e.jsxs(Ca,{defaultValue:"bot",className:"w-full",children:[e.jsxs(pa,{className:"flex flex-wrap h-auto gap-1 p-1 sm:grid sm:grid-cols-5 lg:grid-cols-10",children:[e.jsx(es,{value:"bot",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"基本信息"}),e.jsx(es,{value:"personality",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"人格"}),e.jsx(es,{value:"chat",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"聊天"}),e.jsx(es,{value:"expression",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"表达"}),e.jsx(es,{value:"features",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"功能"}),e.jsx(es,{value:"processing",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"处理"}),e.jsx(es,{value:"mood",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"情绪"}),e.jsx(es,{value:"voice",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"语音"}),e.jsx(es,{value:"lpmm",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"知识库"}),e.jsx(es,{value:"other",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"其他"})]}),e.jsx(ws,{value:"bot",className:"space-y-4",children:R&&e.jsx(mw,{config:R,onChange:z})}),e.jsx(ws,{value:"personality",className:"space-y-4",children:I&&e.jsx(xw,{config:I,onChange:$})}),e.jsx(ws,{value:"chat",className:"space-y-4",children:E&&e.jsx(jw,{config:E,onChange:M})}),e.jsx(ws,{value:"expression",className:"space-y-4",children:se&&e.jsx(Tw,{config:se,onChange:fe})}),e.jsx(ws,{value:"features",className:"space-y-4",children:ve&&je&&Se&&e.jsx(Cw,{emojiConfig:ve,memoryConfig:je,toolConfig:Se,onEmojiChange:Ne,onMemoryChange:ye,onToolChange:O})}),e.jsx(ws,{value:"processing",className:"space-y-4",children:ce&&we&&Z&&V&&e.jsx(zw,{keywordReactionConfig:ce,responsePostProcessConfig:we,chineseTypoConfig:Z,responseSplitterConfig:V,onKeywordReactionChange:xe,onResponsePostProcessChange:oe,onChineseTypoChange:te,onResponseSplitterChange:P})}),e.jsx(ws,{value:"mood",className:"space-y-4",children:G&&e.jsx(vw,{config:G,onChange:H})}),e.jsx(ws,{value:"voice",className:"space-y-4",children:ee&&e.jsx(bw,{config:ee,onChange:v})}),e.jsx(ws,{value:"lpmm",className:"space-y-4",children:X&&e.jsx(Nw,{config:X,onChange:me})}),e.jsxs(ws,{value:"other",className:"space-y-4",children:[ke&&e.jsx(yw,{config:ke,onChange:He}),pe&&e.jsx(ww,{config:pe,onChange:Te}),Qs&&e.jsx(_w,{config:Qs,onChange:vt}),de&&e.jsx(Sw,{config:de,onChange:qe})]})]})}),j&&e.jsx(Wu,{onRestartComplete:Je,onRestartFailed:qs})]})})}const nn=u.forwardRef(({className:n,...i},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:q("w-full caption-bottom text-sm",n),...i})}));nn.displayName="Table";const rn=u.forwardRef(({className:n,...i},r)=>e.jsx("thead",{ref:r,className:q("[&_tr]:border-b",n),...i}));rn.displayName="TableHeader";const cn=u.forwardRef(({className:n,...i},r)=>e.jsx("tbody",{ref:r,className:q("[&_tr:last-child]:border-0",n),...i}));cn.displayName="TableBody";const $w=u.forwardRef(({className:n,...i},r)=>e.jsx("tfoot",{ref:r,className:q("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",n),...i}));$w.displayName="TableFooter";const ct=u.forwardRef(({className:n,...i},r)=>e.jsx("tr",{ref:r,className:q("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",n),...i}));ct.displayName="TableRow";const Xe=u.forwardRef(({className:n,...i},r)=>e.jsx("th",{ref:r,className:q("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n),...i}));Xe.displayName="TableHead";const Ge=u.forwardRef(({className:n,...i},r)=>e.jsx("td",{ref:r,className:q("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",n),...i}));Ge.displayName="TableCell";const Qw=u.forwardRef(({className:n,...i},r)=>e.jsx("caption",{ref:r,className:q("mt-4 text-sm text-muted-foreground",n),...i}));Qw.displayName="TableCaption";const eo=u.forwardRef(({className:n,...i},r)=>e.jsx(Xt,{ref:r,className:q("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",n),...i}));eo.displayName=Xt.displayName;const so=u.forwardRef(({className:n,...i},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(At,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Xt.Input,{ref:r,className:q("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",n),...i})]}));so.displayName=Xt.Input.displayName;const to=u.forwardRef(({className:n,...i},r)=>e.jsx(Xt.List,{ref:r,className:q("max-h-[300px] overflow-y-auto overflow-x-hidden",n),...i}));to.displayName=Xt.List.displayName;const ao=u.forwardRef((n,i)=>e.jsx(Xt.Empty,{ref:i,className:"py-6 text-center text-sm",...n}));ao.displayName=Xt.Empty.displayName;const hr=u.forwardRef(({className:n,...i},r)=>e.jsx(Xt.Group,{ref:r,className:q("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",n),...i}));hr.displayName=Xt.Group.displayName;const Iw=u.forwardRef(({className:n,...i},r)=>e.jsx(Xt.Separator,{ref:r,className:q("-mx-1 h-px bg-border",n),...i}));Iw.displayName=Xt.Separator.displayName;const fr=u.forwardRef(({className:n,...i},r)=>e.jsx(Xt.Item,{ref:r,className:q("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n),...i}));fr.displayName=Xt.Item.displayName;const ft=u.forwardRef(({className:n,...i},r)=>e.jsx(rg,{ref:r,className:q("grid place-content-center 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",n),...i,children:e.jsx(HN,{className:q("grid place-content-center text-current"),children:e.jsx(Qt,{className:"h-4 w-4"})})}));ft.displayName=rg.displayName;const Vg=u.createContext(null),$g="maibot-completed-tours";function Yw(){try{const n=localStorage.getItem($g);return n?new Set(JSON.parse(n)):new Set}catch{return new Set}}function pp(n){localStorage.setItem($g,JSON.stringify([...n]))}function Xw({children:n}){const[i,r]=u.useState({activeTourId:null,stepIndex:0,isRunning:!1}),d=u.useRef(new Map),[,m]=u.useState(0),[x,f]=u.useState(Yw),p=u.useCallback((R,z)=>{d.current.set(R,z),m(I=>I+1)},[]),g=u.useCallback(R=>{d.current.delete(R),r(z=>z.activeTourId===R?{...z,activeTourId:null,isRunning:!1,stepIndex:0}:z)},[]),N=u.useCallback((R,z=0)=>{d.current.has(R)&&r({activeTourId:R,stepIndex:z,isRunning:!0})},[]),j=u.useCallback(()=>{r(R=>({...R,isRunning:!1}))},[]),w=u.useCallback(R=>{r(z=>({...z,stepIndex:R}))},[]),y=u.useCallback(()=>{r(R=>({...R,stepIndex:R.stepIndex+1}))},[]),k=u.useCallback(()=>{r(R=>({...R,stepIndex:Math.max(0,R.stepIndex-1)}))},[]),_=u.useCallback(()=>i.activeTourId?d.current.get(i.activeTourId)||[]:[],[i.activeTourId]),L=u.useCallback(R=>{f(z=>{const I=new Set(z);return I.add(R),pp(I),I})},[]),D=u.useCallback(R=>{const{action:z,index:I,status:$,type:E}=R,M=["finished","skipped"];if(z==="close"){r(se=>({...se,isRunning:!1,stepIndex:0}));return}M.includes($)?r(se=>($==="finished"&&se.activeTourId&&setTimeout(()=>L(se.activeTourId),0),{...se,isRunning:!1,stepIndex:0})):E==="step:after"&&(z==="next"?r(se=>({...se,stepIndex:I+1})):z==="prev"&&r(se=>({...se,stepIndex:I-1})))},[L]),U=u.useCallback(R=>x.has(R),[x]),Q=u.useCallback(R=>{f(z=>{const I=new Set(z);return I.delete(R),pp(I),I})},[]);return e.jsx(Vg.Provider,{value:{state:i,tours:d.current,registerTour:p,unregisterTour:g,startTour:N,stopTour:j,goToStep:w,nextStep:y,prevStep:k,getCurrentSteps:_,handleJoyrideCallback:D,isTourCompleted:U,markTourCompleted:L,resetTourCompleted:Q},children:n})}function em(){const n=u.useContext(Vg);if(!n)throw new Error("useTour must be used within a TourProvider");return n}const Kw={options:{zIndex:1e4,primaryColor:"hsl(var(--primary))",textColor:"hsl(var(--foreground))",backgroundColor:"hsl(var(--background))",arrowColor:"hsl(var(--background))",overlayColor:"rgba(0, 0, 0, 0.5)"},tooltip:{borderRadius:"var(--radius)",padding:"1rem"},tooltipContainer:{textAlign:"left"},tooltipTitle:{fontSize:"1rem",fontWeight:600,marginBottom:"0.5rem"},tooltipContent:{fontSize:"0.875rem",padding:"0.5rem 0"},buttonNext:{backgroundColor:"hsl(var(--primary))",color:"hsl(var(--primary-foreground))",borderRadius:"calc(var(--radius) - 2px)",fontSize:"0.875rem",padding:"0.5rem 1rem"},buttonBack:{color:"hsl(var(--muted-foreground))",fontSize:"0.875rem",marginRight:"0.5rem"},buttonSkip:{color:"hsl(var(--muted-foreground))",fontSize:"0.875rem"},buttonClose:{color:"hsl(var(--muted-foreground))"},spotlight:{borderRadius:"var(--radius)"}},Jw={back:"上一步",close:"关闭",last:"完成",next:"下一步",nextLabelWithProgress:"下一步 ({step}/{steps})",open:"打开对话框",skip:"跳过"};function Pw(){const{state:n,getCurrentSteps:i,handleJoyrideCallback:r}=em(),d=i(),[m,x]=u.useState(!1),f=u.useRef(n.stepIndex),p=u.useRef(null);u.useEffect(()=>{f.current!==n.stepIndex&&(x(!1),f.current=n.stepIndex)},[n.stepIndex]),u.useEffect(()=>{if(!n.isRunning||d.length===0){x(!1);return}const j=d[n.stepIndex];if(!j){x(!1);return}const w=j.target;if(w==="body"){x(!0);return}x(!1);const y=setTimeout(()=>{const k=()=>{const U=document.querySelector(w);if(U){const Q=U.getBoundingClientRect();if(Q.width>0&&Q.height>0)return!0}return!1};if(k()){setTimeout(()=>x(!0),100);return}const _=setInterval(()=>{k()&&(clearInterval(_),setTimeout(()=>x(!0),100))},100),L=setTimeout(()=>{clearInterval(_),x(!0)},5e3),D=()=>{clearInterval(_),clearTimeout(L)};p.current=D},150);return()=>{clearTimeout(y),p.current&&(p.current(),p.current=null)}},[n.isRunning,n.stepIndex,d]);const g=u.useRef(null);if(u.useEffect(()=>{let j=document.getElementById("tour-portal-container");return j||(j=document.createElement("div"),j.id="tour-portal-container",j.style.cssText="position: fixed; top: 0; left: 0; z-index: 99999; pointer-events: none;",document.body.appendChild(j)),g.current=j,()=>{}},[]),!n.isRunning||d.length===0||!m)return null;const N=e.jsx(Ly,{steps:d,stepIndex:n.stepIndex,run:n.isRunning,continuous:!0,showSkipButton:!0,showProgress:!0,disableOverlayClose:!0,disableScrolling:!1,disableScrollParentFix:!1,callback:r,styles:Kw,locale:Jw,scrollOffset:80,scrollToFirstStep:!0,floaterProps:{styles:{floater:{zIndex:99999}},disableAnimation:!0}},`tour-step-${n.stepIndex}`);return g.current?Hb.createPortal(N,g.current):N}const Aa="model-assignment-tour",Qg=[{target:"body",content:"本引导旨在帮助你配置模型提供商和对应的模型,并为麦麦的各个组件分配合适的模型。",placement:"center",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="sidebar-model-provider"]',content:'第一步,你需要配置模型提供商。模型提供商决定了你要使用谁家的模型,无论是单一厂商(如 DeepSeek还是模型平台如 Siliconflow都可以在这里进行配置。点击"下一步"进入配置页面。',placement:"right",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="add-provider-button"]',content:'点击"添加提供商"按钮,开始配置你的模型提供商。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="provider-dialog"]',content:"在这里,你可以选择你想要配置的模型提供商,填写相关信息后保存即可。",placement:"left",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-name-input"]',content:"这里的名称是你为这个模型提供商起的一个名字,方便你在后续使用时识别它。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-apikey-input"]',content:"这里需要填写你从模型提供商那里获取的 API 密钥,用于验证和调用模型服务。对于不同的提供商,获取 API 密钥的方式可能有所不同,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-url-input"]',content:"这里需要填写模型提供商的 API 访问地址确保填写正确以便系统能够连接到模型服务。对于不同的提供商API 地址可能有所不同,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-template-select"]',content:"当然,如果你不知道如何填写这些信息,很多模型提供商在这里都提供了预设的模板供你选择,选择对应的模板后,相关信息会自动填充。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-save-button"]',content:"填写完所有信息后,点击保存按钮,模型提供商就配置完成了。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="provider-cancel-button"]',content:"因为这次咱们什么都没有填写,所以点击取消按钮退出吧。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="sidebar-model-management"]',content:'配置好模型提供商后,接下来我们需要为麦麦添加模型并分配功能。点击"下一步"进入模型管理页面。',placement:"right",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="add-model-button"]',content:'在为麦麦的组件分配模型之前,首先需要添加你想要分配的模型,点击"添加模型"按钮开始添加。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="model-dialog"]',content:"在这里,你可以选择你之前配置好的模型提供商,然后选择对应的模型来添加。",placement:"left",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-name-input"]',content:"这里的模型名称是你为这个模型起的一个名字,方便你在后续使用时识别它。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-provider-select"]',content:"在这里选择你之前配置好的模型提供商,这样系统才能知道你要添加哪个提供商的模型。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-identifier-input"]',content:"这里需要填写你想要添加的模型的标识符,不同的模型提供商可能有不同的标识符格式,请参考对应提供商的文档。",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-save-button"]',content:"填写完所有信息后,点击保存按钮,模型就添加完成了。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1},{target:'[data-tour="model-cancel-button"]',content:"当然,因为这次咱们什么都没有填写,所以直接点击取消按钮退出吧,等你准备好了再来添加模型。",placement:"top",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="tasks-tab-trigger"]',content:'最后一步,添加好模型后,切换到"为模型分配功能"标签页,为麦麦的各个组件分配合适的模型。',placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!0,hideFooter:!0},{target:'[data-tour="task-model-select"]',content:"在这里,你可以为每个组件选择一个或多个合适的模型,选择完成后配置会自动保存。恭喜你完成了模型配置的学习!",placement:"bottom",disableBeacon:!0,disableOverlayClose:!0,hideCloseButton:!1,spotlightClicks:!1}],Ig={0:"/config/model",1:"/config/model",2:"/config/modelProvider",3:"/config/modelProvider",4:"/config/modelProvider",5:"/config/modelProvider",6:"/config/modelProvider",7:"/config/modelProvider",8:"/config/modelProvider",9:"/config/modelProvider",10:"/config/modelProvider",11:"/config/model",12:"/config/model",13:"/config/model",14:"/config/model",15:"/config/model",16:"/config/model",17:"/config/model",18:"/config/model",19:"/config/model"},lr=[{id:"siliconflow",name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",client_type:"openai",display_name:"硅基流动 (SiliconFlow)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"deepseek",name:"DeepSeek",base_url:"https://api.deepseek.com",client_type:"openai",display_name:"DeepSeek",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"rinkoai",name:"RinkoAI",base_url:"https://rinkoai.com/v1",client_type:"openai",display_name:"RinkoAI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"zhipu",name:"ZhipuAI",base_url:"https://open.bigmodel.cn/api/paas/v4",client_type:"openai",display_name:"智谱 AI (ZhipuAI / GLM)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"moonshot",name:"Moonshot",base_url:"https://api.moonshot.cn/v1",client_type:"openai",display_name:"月之暗面 (Moonshot / Kimi)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"doubao",name:"Doubao",base_url:"https://ark.cn-beijing.volces.com/api/v3",client_type:"openai",display_name:"字节豆包 (Doubao)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"alibaba",name:"Alibaba",base_url:"https://dashscope.aliyuncs.com/compatible-mode/v1",client_type:"openai",display_name:"阿里云百炼 (Alibaba Qwen)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"baichuan",name:"Baichuan",base_url:"https://api.baichuan-ai.com/v1",client_type:"openai",display_name:"百川智能 (Baichuan)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"minimax",name:"MiniMax",base_url:"https://api.minimax.chat/v1",client_type:"openai",display_name:"MiniMax (海螺 AI)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"stepfun",name:"StepFun",base_url:"https://api.stepfun.com/v1",client_type:"openai",display_name:"阶跃星辰 (StepFun)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"lingyi",name:"Lingyi",base_url:"https://api.lingyiwanwu.com/v1",client_type:"openai",display_name:"零一万物 (Lingyi / Yi)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"openai",name:"OpenAI",base_url:"https://api.openai.com/v1",client_type:"openai",display_name:"OpenAI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"xai",name:"xAI",base_url:"https://api.x.ai/v1",client_type:"openai",display_name:"xAI (Grok)",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"anthropic",name:"Anthropic",base_url:"https://api.anthropic.com/v1",client_type:"openai",display_name:"Anthropic (Claude)"},{id:"gemini",name:"Gemini",base_url:"https://generativelanguage.googleapis.com/v1beta",client_type:"gemini",display_name:"Google Gemini",modelFetcher:{endpoint:"/models",parser:"gemini"}},{id:"cohere",name:"Cohere",base_url:"https://api.cohere.ai/v1",client_type:"openai",display_name:"Cohere"},{id:"groq",name:"Groq",base_url:"https://api.groq.com/openai/v1",client_type:"openai",display_name:"Groq",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"together",name:"Together AI",base_url:"https://api.together.xyz/v1",client_type:"openai",display_name:"Together AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"fireworks",name:"Fireworks",base_url:"https://api.fireworks.ai/inference/v1",client_type:"openai",display_name:"Fireworks AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"mistral",name:"Mistral",base_url:"https://api.mistral.ai/v1",client_type:"openai",display_name:"Mistral AI",modelFetcher:{endpoint:"/models",parser:"openai"}},{id:"perplexity",name:"Perplexity",base_url:"https://api.perplexity.ai",client_type:"openai",display_name:"Perplexity AI"},{id:"custom",name:"",base_url:"",client_type:"openai",display_name:"自定义"}];function gp(n){return n?n.replace(/\/+$/,"").toLowerCase():""}function Zw(n){if(!n)return null;const i=gp(n);return lr.find(r=>r.id!=="custom"&&gp(r.base_url)===i)||null}function Ww(){const[n,i]=u.useState([]),[r,d]=u.useState(!0),[m,x]=u.useState(!1),[f,p]=u.useState(!1),[g,N]=u.useState(!1),[j,w]=u.useState(!1),[y,k]=u.useState(!1),[_,L]=u.useState(!1),[D,U]=u.useState(null),[Q,R]=u.useState(null),[z,I]=u.useState("custom"),[$,E]=u.useState(!1),[M,se]=u.useState(!1),[fe,ve]=u.useState(null),[Ne,je]=u.useState(!1),[ye,Se]=u.useState(""),[O,G]=u.useState(new Set),[H,ee]=u.useState(!1),[v,X]=u.useState(1),[me,ce]=u.useState(20),[xe,we]=u.useState(""),[oe,Z]=u.useState({}),[te,V]=u.useState(new Set),[P,ke]=u.useState(new Map),{toast:He}=Bs(),pe=ja(),{state:Te,goToStep:Qs,registerTour:vt}=em(),de=u.useRef(null),qe=u.useRef(!0);u.useEffect(()=>{vt(Aa,Qg)},[vt]),u.useEffect(()=>{if(Te.activeTourId===Aa&&Te.isRunning){const T=Ig[Te.stepIndex];T&&!window.location.pathname.endsWith(T.replace("/config/",""))&&pe({to:T})}},[Te.stepIndex,Te.activeTourId,Te.isRunning,pe]);const Ie=u.useRef(Te.stepIndex);u.useEffect(()=>{if(Te.activeTourId===Aa&&Te.isRunning){const T=Ie.current,ge=Te.stepIndex;T>=3&&T<=9&&ge<3&&L(!1),T>=10&&ge>=3&&ge<=9&&(Z({}),I("custom"),U({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),R(null),je(!1),L(!0)),Ie.current=ge}},[Te.stepIndex,Te.activeTourId,Te.isRunning]),u.useEffect(()=>{if(Te.activeTourId!==Aa||!Te.isRunning)return;const T=ge=>{const ze=ge.target,Ns=Te.stepIndex;Ns===2&&ze.closest('[data-tour="add-provider-button"]')?setTimeout(()=>Qs(3),300):Ns===9&&ze.closest('[data-tour="provider-cancel-button"]')&&setTimeout(()=>Qs(10),300)};return document.addEventListener("click",T,!0),()=>document.removeEventListener("click",T,!0)},[Te,Qs]),u.useEffect(()=>{Ys()},[]);const Ys=async()=>{try{d(!0);const T=await Zn();i(T.api_providers||[]),N(!1),qe.current=!1}catch(T){console.error("加载配置失败:",T)}finally{d(!1)}},Hs=async()=>{try{w(!0),Wc().catch(()=>{}),k(!0)}catch(T){console.error("重启失败:",T),k(!1),He({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),w(!1)}},bt=async()=>{try{x(!0),de.current&&clearTimeout(de.current);const T=await Zn();T.api_providers=n,await Kc(T),N(!1),He({title:"保存成功",description:"正在重启麦麦..."}),await Hs()}catch(T){console.error("保存配置失败:",T),He({title:"保存失败",description:T.message,variant:"destructive"}),x(!1)}},ot=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},Ds=()=>{k(!1),w(!1),He({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},ks=u.useCallback(async T=>{if(!qe.current)try{p(!0),await Gu("api_providers",T),N(!1)}catch(ge){console.error("自动保存失败:",ge),N(!0)}finally{p(!1)}},[]);u.useEffect(()=>{if(!qe.current)return N(!0),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{ks(n)},2e3),()=>{de.current&&clearTimeout(de.current)}},[n,ks]);const va=async()=>{try{x(!0),de.current&&clearTimeout(de.current);const T=await Zn();T.api_providers=n,await Kc(T),N(!1),He({title:"保存成功",description:"模型提供商配置已保存"})}catch(T){console.error("保存配置失败:",T),He({title:"保存失败",description:T.message,variant:"destructive"})}finally{x(!1)}},Y=(T,ge)=>{if(Z({}),T){const ze=lr.find(Ns=>Ns.base_url===T.base_url&&Ns.client_type===T.client_type);I(ze?.id||"custom"),U(T)}else I("custom"),U({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10});R(ge),je(!1),L(!0)},Be=T=>{I(T),E(!1);const ge=lr.find(ze=>ze.id===T);ge&&ge.id!=="custom"?U(ze=>({...ze,name:ge.name,base_url:ge.base_url,client_type:ge.client_type})):ge?.id==="custom"&&U(ze=>({...ze,name:"",base_url:"",client_type:"openai"}))},Ee=u.useMemo(()=>z!=="custom",[z]),Ye=async()=>{if(D?.api_key)try{await navigator.clipboard.writeText(D.api_key),He({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{He({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},Xs=()=>{if(!D)return;const T={};if(D.name?.trim()||(T.name="请输入提供商名称"),D.base_url?.trim()||(T.base_url="请输入基础 URL"),D.api_key?.trim()||(T.api_key="请输入 API Key"),Object.keys(T).length>0){Z(T);return}Z({});const ge={...D,max_retry:D.max_retry??2,timeout:D.timeout??30,retry_interval:D.retry_interval??10};if(Q!==null){const ze=[...n];ze[Q]=ge,i(ze)}else i([...n,ge]);L(!1),U(null),R(null)},Je=T=>{if(!T&&D){const ge={...D,max_retry:D.max_retry??2,timeout:D.timeout??30,retry_interval:D.retry_interval??10};U(ge)}L(T)},qs=T=>{ve(T),se(!0)},be=()=>{if(fe!==null){const T=n.filter((ge,ze)=>ze!==fe);i(T),He({title:"删除成功",description:"提供商已从列表中移除"})}se(!1),ve(null)},_s=T=>{const ge=new Set(O);ge.has(T)?ge.delete(T):ge.add(T),G(ge)},Ae=()=>{if(O.size===xs.length)G(new Set);else{const T=xs.map((ge,ze)=>n.findIndex(Ns=>Ns===xs[ze]));G(new Set(T))}},Fs=()=>{if(O.size===0){He({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}ee(!0)},dt=()=>{const T=n.filter((ge,ze)=>!O.has(ze));i(T),G(new Set),ee(!1),He({title:"批量删除成功",description:`已删除 ${O.size} 个提供商`})},xs=n.filter(T=>{if(!ye)return!0;const ge=ye.toLowerCase();return T.name.toLowerCase().includes(ge)||T.base_url.toLowerCase().includes(ge)||T.client_type.toLowerCase().includes(ge)}),gs=Math.ceil(xs.length/me),Nt=xs.slice((v-1)*me,v*me),Lt=()=>{const T=parseInt(xe);T>=1&&T<=gs&&(X(T),we(""))},Dt=async T=>{V(ge=>new Set(ge).add(T));try{const ge=await Rw(T);ke(ze=>new Map(ze).set(T,ge)),ge.network_ok?ge.api_key_valid===!0?He({title:"连接正常",description:`${T} 网络连接正常API Key 有效 (${ge.latency_ms}ms)`}):ge.api_key_valid===!1?He({title:"连接正常但 Key 无效",description:`${T} 网络连接正常,但 API Key 无效或已过期`,variant:"destructive"}):He({title:"网络连接正常",description:`${T} 可以访问 (${ge.latency_ms}ms)`}):He({title:"连接失败",description:ge.error||"无法连接到提供商",variant:"destructive"})}catch(ge){He({title:"测试失败",description:ge.message,variant:"destructive"})}finally{V(ge=>{const ze=new Set(ge);return ze.delete(T),ze})}},Ba=async()=>{for(const T of n)await Dt(T.name)},ne=T=>{const ge=te.has(T),ze=P.get(T);return ge?e.jsxs(Fe,{variant:"secondary",className:"gap-1",children:[e.jsx(Js,{className:"h-3 w-3 animate-spin"}),"测试中"]}):ze?ze.network_ok?ze.api_key_valid===!0?e.jsxs(Fe,{className:"gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(aa,{className:"h-3 w-3"}),"正常"]}):ze.api_key_valid===!1?e.jsxs(Fe,{variant:"destructive",className:"gap-1",children:[e.jsx(Mt,{className:"h-3 w-3"}),"Key无效"]}):e.jsxs(Fe,{className:"gap-1 bg-blue-600 hover:bg-blue-700",children:[e.jsx(aa,{className:"h-3 w-3"}),"可访问"]}):e.jsxs(Fe,{variant:"destructive",className:"gap-1",children:[e.jsx(pg,{className:"h-3 w-3"}),"离线"]}):null};return r?e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})}):e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"AI模型厂商配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理 AI 模型厂商的 API 配置"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[O.size>0&&e.jsxs(S,{onClick:Fs,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(Ze,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",O.size,")"]}),e.jsxs(S,{onClick:Ba,size:"sm",variant:"outline",className:"w-full sm:w-auto",disabled:n.length===0||te.size>0,children:[e.jsx(sn,{className:"mr-2 h-4 w-4"}),te.size>0?`测试中 (${te.size})`:"测试全部"]}),e.jsxs(S,{onClick:()=>Y(null,null),size:"sm",className:"w-full sm:w-auto","data-tour":"add-provider-button",children:[e.jsx(rt,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(S,{onClick:va,disabled:m||f||!g||j,size:"sm",variant:"outline",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(gr,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),m?"保存中...":f?"自动保存中...":g?"保存配置":"已保存"]}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{disabled:m||f||j,size:"sm",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(pr,{className:"mr-2 h-4 w-4"}),j?"重启中...":g?"保存并重启":"重启麦麦"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认重启麦麦?"}),e.jsx(rs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:g?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:g?bt:Hs,children:g?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(It,{children:[e.jsx(Oa,{className:"h-4 w-4"}),e.jsxs(Yt,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Ke,{className:"h-[calc(100vh-260px)]",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative w-full sm:flex-1 sm:max-w-sm",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{placeholder:"搜索提供商名称、URL 或类型...",value:ye,onChange:T=>Se(T.target.value),className:"pl-9"})]}),ye&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",xs.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:xs.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:ye?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):Nt.map((T,ge)=>{const ze=n.findIndex(Ns=>Ns===T);return e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-base truncate",children:T.name}),ne(T.name)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:T.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>Dt(T.name),disabled:te.has(T.name),title:"测试连接",children:te.has(T.name)?e.jsx(Js,{className:"h-4 w-4 animate-spin"}):e.jsx(sn,{className:"h-4 w-4"})}),e.jsx(S,{variant:"default",size:"sm",onClick:()=>Y(T,ze),children:e.jsx(an,{className:"h-4 w-4",strokeWidth:2,fill:"none"})}),e.jsx(S,{size:"sm",onClick:()=>qs(ze),className:"bg-red-600 hover:bg-red-700 text-white",children:e.jsx(Ze,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"客户端类型"}),e.jsx("p",{className:"font-medium",children:T.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:T.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:T.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:T.retry_interval})]})]})]},ge)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs(ct,{children:[e.jsx(Xe,{className:"w-12",children:e.jsx(ft,{checked:O.size===xs.length&&xs.length>0,onCheckedChange:Ae})}),e.jsx(Xe,{children:"状态"}),e.jsx(Xe,{children:"名称"}),e.jsx(Xe,{children:"基础URL"}),e.jsx(Xe,{children:"客户端类型"}),e.jsx(Xe,{className:"text-right",children:"最大重试"}),e.jsx(Xe,{className:"text-right",children:"超时(秒)"}),e.jsx(Xe,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(Xe,{className:"text-right",children:"操作"})]})}),e.jsx(cn,{children:Nt.length===0?e.jsx(ct,{children:e.jsx(Ge,{colSpan:9,className:"text-center text-muted-foreground py-8",children:ye?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):Nt.map((T,ge)=>{const ze=n.findIndex(Ns=>Ns===T);return e.jsxs(ct,{children:[e.jsx(Ge,{children:e.jsx(ft,{checked:O.has(ze),onCheckedChange:()=>_s(ze)})}),e.jsx(Ge,{children:ne(T.name)||e.jsx(Fe,{variant:"outline",className:"text-muted-foreground",children:"未测试"})}),e.jsx(Ge,{className:"font-medium",children:T.name}),e.jsx(Ge,{className:"max-w-xs truncate",title:T.base_url,children:T.base_url}),e.jsx(Ge,{children:T.client_type}),e.jsx(Ge,{className:"text-right",children:T.max_retry}),e.jsx(Ge,{className:"text-right",children:T.timeout}),e.jsx(Ge,{className:"text-right",children:T.retry_interval}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>Dt(T.name),disabled:te.has(T.name),title:"测试连接",children:te.has(T.name)?e.jsx(Js,{className:"h-4 w-4 animate-spin"}):e.jsx(sn,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"default",size:"sm",onClick:()=>Y(T,ze),children:[e.jsx(an,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(S,{size:"sm",onClick:()=>qs(ze),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(Ze,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},ge)})})]})})}),xs.length>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{htmlFor:"page-size-provider",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Re,{value:me.toString(),onValueChange:T=>{ce(parseInt(T)),X(1),G(new Set)},children:[e.jsx(De,{id:"page-size-provider",className:"w-20",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(v-1)*me+1," 到"," ",Math.min(v*me,xs.length)," 条,共 ",xs.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>X(1),disabled:v===1,className:"hidden sm:flex",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>X(T=>Math.max(1,T-1)),disabled:v===1,children:[e.jsx(rl,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{type:"number",value:xe,onChange:T=>we(T.target.value),onKeyDown:T=>T.key==="Enter"&&Lt(),placeholder:v.toString(),className:"w-16 h-8 text-center",min:1,max:gs}),e.jsx(S,{variant:"outline",size:"sm",onClick:Lt,disabled:!xe,className:"h-8",children:"跳转"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>X(T=>T+1),disabled:v>=gs,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Ua,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>X(gs),disabled:v>=gs,className:"hidden sm:flex",children:e.jsx(li,{className:"h-4 w-4"})})]})]})]}),e.jsx(Gs,{open:_,onOpenChange:Je,children:e.jsxs(Rs,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"provider-dialog",preventOutsideClose:Te.isRunning,children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:Q!==null?"编辑提供商":"添加提供商"}),e.jsx(Ps,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("form",{onSubmit:T=>{T.preventDefault(),Xs()},autoComplete:"off",children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":"provider-template-select",children:[e.jsx(C,{htmlFor:"template",children:"提供商模板"}),e.jsxs(Ra,{open:$,onOpenChange:E,children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",role:"combobox","aria-expanded":$,className:"w-full justify-between",children:[z?lr.find(T=>T.id===z)?.display_name:"选择提供商模板...",e.jsx(Xu,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ka,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(eo,{children:[e.jsx(so,{placeholder:"搜索提供商模板..."}),e.jsx(Ke,{className:"h-[300px]",children:e.jsxs(to,{className:"max-h-none overflow-visible",children:[e.jsx(ao,{children:"未找到匹配的模板"}),e.jsx(hr,{children:lr.map(T=>e.jsxs(fr,{value:T.display_name,onSelect:()=>Be(T.id),children:[e.jsx(Qt,{className:`mr-2 h-4 w-4 ${z===T.id?"opacity-100":"opacity-0"}`}),T.display_name]},T.id))})]})})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"选择预设模板可自动填充 URL 和客户端类型,支持搜索"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-name-input",children:[e.jsx(C,{htmlFor:"name",className:oe.name?"text-destructive":"",children:"名称 *"}),e.jsx(ie,{id:"name",value:D?.name||"",onChange:T=>{U(ge=>ge?{...ge,name:T.target.value}:null),oe.name&&Z(ge=>({...ge,name:void 0}))},placeholder:"例如: DeepSeek, SiliconFlow",className:oe.name?"border-destructive focus-visible:ring-destructive":""}),oe.name&&e.jsx("p",{className:"text-xs text-destructive",children:oe.name})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-url-input",children:[e.jsx(C,{htmlFor:"base_url",className:oe.base_url?"text-destructive":"",children:"基础 URL *"}),e.jsx(ie,{id:"base_url",value:D?.base_url||"",onChange:T=>{U(ge=>ge?{...ge,base_url:T.target.value}:null),oe.base_url&&Z(ge=>({...ge,base_url:void 0}))},placeholder:"https://api.example.com/v1",disabled:Ee,className:`${Ee?"bg-muted cursor-not-allowed":""} ${oe.base_url?"border-destructive focus-visible:ring-destructive":""}`}),oe.base_url&&e.jsx("p",{className:"text-xs text-destructive",children:oe.base_url}),Ee&&!oe.base_url&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时 URL 不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-apikey-input",children:[e.jsx(C,{htmlFor:"api_key",className:oe.api_key?"text-destructive":"",children:"API Key *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{id:"api_key",type:Ne?"text":"password",value:D?.api_key||"",onChange:T=>{U(ge=>ge?{...ge,api_key:T.target.value}:null),oe.api_key&&Z(ge=>({...ge,api_key:void 0}))},placeholder:"sk-...",className:`flex-1 ${oe.api_key?"border-destructive focus-visible:ring-destructive":""}`}),e.jsx(S,{type:"button",variant:"outline",size:"icon",onClick:()=>je(!Ne),title:Ne?"隐藏密钥":"显示密钥",children:Ne?e.jsx(or,{className:"h-4 w-4"}):e.jsx(Rt,{className:"h-4 w-4"})}),e.jsx(S,{type:"button",variant:"outline",size:"icon",onClick:Ye,title:"复制密钥",children:e.jsx(Qc,{className:"h-4 w-4"})})]}),oe.api_key&&e.jsx("p",{className:"text-xs text-destructive",children:oe.api_key})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"client_type",children:"客户端类型"}),e.jsxs(Re,{value:D?.client_type||"openai",onValueChange:T=>U(ge=>ge?{...ge,client_type:T}:null),disabled:Ee,children:[e.jsx(De,{id:"client_type",className:Ee?"bg-muted cursor-not-allowed":"",children:e.jsx(Le,{placeholder:"选择客户端类型"})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"openai",children:"OpenAI"}),e.jsx(le,{value:"gemini",children:"Gemini"})]})]}),Ee&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时客户端类型不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(ie,{id:"max_retry",type:"number",min:"0",value:D?.max_retry??"",onChange:T=>{const ge=T.target.value===""?null:parseInt(T.target.value);U(ze=>ze?{...ze,max_retry:ge}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(ie,{id:"timeout",type:"number",min:"1",value:D?.timeout??"",onChange:T=>{const ge=T.target.value===""?null:parseInt(T.target.value);U(ze=>ze?{...ze,timeout:ge}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(ie,{id:"retry_interval",type:"number",min:"1",value:D?.retry_interval??"",onChange:T=>{const ge=T.target.value===""?null:parseInt(T.target.value);U(ze=>ze?{...ze,retry_interval:ge}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs(at,{children:[e.jsx(S,{type:"button",variant:"outline",onClick:()=>L(!1),"data-tour":"provider-cancel-button",children:"取消"}),e.jsx(S,{type:"submit","data-tour":"provider-save-button",children:"保存"})]})]})]})}),e.jsx(ms,{open:M,onOpenChange:se,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除提供商 "',fe!==null?n[fe]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:be,children:"删除"})]})]})}),e.jsx(ms,{open:H,onOpenChange:ee,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认批量删除"}),e.jsxs(rs,{children:["确定要删除选中的 ",O.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),y&&e.jsx(Wu,{onRestartComplete:ot,onRestartFailed:Ds})]})}function Yg(n){return typeof n=="boolean"?"boolean":typeof n=="number"?"number":"string"}function e1(n,i){switch(i){case"boolean":return n==="true";case"number":{const r=parseFloat(n);return isNaN(r)?0:r}default:return n}}function zu(n){return Object.entries(n).map(([i,r])=>({id:crypto.randomUUID(),key:i,value:r,type:Yg(r)}))}function Mu(n){const i={};for(const r of n)r.key.trim()&&(i[r.key.trim()]=r.value);return i}function Au(n){if(!n.trim())return{valid:!0,parsed:{}};try{const i=JSON.parse(n);if(typeof i!="object"||i===null||Array.isArray(i))return{valid:!1,error:"必须是一个 JSON 对象 {}"};for(const[r,d]of Object.entries(i))if(d!==null&&!["string","number","boolean"].includes(typeof d))return{valid:!1,error:`键 "${r}" 的值类型不支持(仅支持 string/number/boolean`};return{valid:!0,parsed:i}}catch{return{valid:!1,error:"JSON 格式错误"}}}function s1(n){switch(n){case"boolean":return"布尔";case"number":return"数字";default:return"字符串"}}function t1(n){switch(n){case"boolean":return"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400";case"number":return"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400";default:return"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"}}function a1({value:n,onChange:i,className:r,placeholder:d="添加额外参数..."}){const[m,x]=u.useState("list"),[f,p]=u.useState(()=>zu(n||{})),[g,N]=u.useState(()=>Object.keys(n||{}).length>0?JSON.stringify(n,null,2):""),[j,w]=u.useState(null);u.useEffect(()=>{const Q=zu(n||{});p(Q),N(Object.keys(n||{}).length>0?JSON.stringify(n,null,2):"")},[n]);const y=u.useMemo(()=>{const Q=Au(g);return Q.valid&&Q.parsed?{success:!0,data:Q.parsed}:{success:!1,data:{}}},[g]),k=u.useCallback(Q=>{const R=Q;if(R==="json"&&m==="list"){const z=Mu(f);N(Object.keys(z).length>0?JSON.stringify(z,null,2):""),w(null)}else if(R==="list"&&m==="json"){const z=Au(g);z.valid&&z.parsed&&(p(zu(z.parsed)),w(null))}x(R)},[m,f,g]),_=u.useCallback(()=>{const Q={id:crypto.randomUUID(),key:"",value:"",type:"string"},R=[...f,Q];p(R)},[f]),L=u.useCallback(Q=>{const R=f.filter(z=>z.id!==Q);p(R),i(Mu(R))},[f,i]),D=u.useCallback((Q,R,z)=>{const I=f.map($=>{if($.id!==Q)return $;if(R==="type"){const E=z;let M;return E==="boolean"?M=$.value==="true"||$.value===!0:E==="number"?M=typeof $.value=="number"?$.value:parseFloat(String($.value))||0:M=String($.value),{...$,type:E,value:M}}else return R==="value"?{...$,value:e1(z,$.type)}:{...$,[R]:z}});p(I),i(Mu(I))},[f,i]),U=u.useCallback(Q=>{N(Q);const R=Au(Q);R.valid&&R.parsed?(w(null),i(R.parsed)):w(R.error||"JSON 格式错误")},[i]);return e.jsxs("div",{className:q("space-y-3",r),children:[e.jsx(C,{className:"text-sm font-medium",children:"额外参数"}),e.jsxs(Ca,{value:m,onValueChange:k,className:"w-full",children:[e.jsxs(pa,{className:"h-8 p-0.5 bg-muted/60",children:[e.jsx(es,{value:"list",className:"h-7 px-3 text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"键值对"}),e.jsx(es,{value:"json",className:"h-7 px-3 text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"JSON"})]}),e.jsxs(ws,{value:"list",className:"mt-3 space-y-2",children:[f.length===0?e.jsx("div",{className:"text-sm text-muted-foreground text-center py-4 border border-dashed rounded-md",children:d}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_90px_32px] gap-2 text-xs text-muted-foreground px-1",children:[e.jsx("span",{children:"键名"}),e.jsx("span",{children:"值"}),e.jsx("span",{children:"类型"}),e.jsx("span",{})]}),f.map(Q=>e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_90px_32px] gap-2 items-center",children:[e.jsx(ie,{value:Q.key,onChange:R=>D(Q.id,"key",R.target.value),placeholder:"key",className:"h-8 text-sm"}),Q.type==="boolean"?e.jsxs("div",{className:"flex items-center h-8 px-3 border rounded-md bg-background",children:[e.jsx(Ve,{checked:Q.value===!0,onCheckedChange:R=>D(Q.id,"value",String(R))}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:Q.value?"true":"false"})]}):e.jsx(ie,{type:Q.type==="number"?"number":"text",value:Q.value,onChange:R=>D(Q.id,"value",R.target.value),placeholder:"value",className:"h-8 text-sm",step:Q.type==="number"?"any":void 0}),e.jsxs(Re,{value:Q.type,onValueChange:R=>D(Q.id,"type",R),children:[e.jsx(De,{className:"h-8 text-xs",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"string",children:"字符串"}),e.jsx(le,{value:"number",children:"数字"}),e.jsx(le,{value:"boolean",children:"布尔"})]})]}),e.jsx(S,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>L(Q.id),children:e.jsx(Ze,{className:"h-4 w-4"})})]},Q.id))]}),e.jsxs(S,{type:"button",variant:"outline",size:"sm",className:"w-full h-8",onClick:_,children:[e.jsx(rt,{className:"h-4 w-4 mr-1"}),"添加参数"]})]}),e.jsx(ws,{value:"json",className:"mt-3",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"编辑"}),j?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[e.jsx(Mt,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[150px]",children:j})]}):g.trim()&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[e.jsx(Qt,{className:"h-3 w-3"}),e.jsx("span",{children:"有效"})]})]}),e.jsx(Ms,{value:g,onChange:Q=>U(Q.target.value),placeholder:`{
"key": "value"
}`,className:q("font-mono text-sm min-h-[140px] h-[140px] resize-y flex-1",j&&"border-destructive focus-visible:ring-destructive")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持 string、number、boolean 类型"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"预览"}),e.jsx("div",{className:"min-h-[140px] h-[140px] flex-1 rounded-md border bg-muted/30 p-3 overflow-auto",children:y.success&&Object.keys(y.data).length>0?e.jsx("div",{className:"space-y-2",children:Object.entries(y.data).map(([Q,R])=>{const z=Yg(R);return e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("code",{className:"px-1.5 py-0.5 bg-background rounded text-xs font-medium",children:Q}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:q("font-mono",z==="boolean"&&(R?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),z==="number"&&"text-blue-600 dark:text-blue-400",z==="string"&&"text-amber-600 dark:text-amber-400"),children:z==="string"?`"${R}"`:String(R)}),e.jsx(Fe,{variant:"secondary",className:q("h-5 text-[10px] px-1.5",t1(z)),children:s1(z)})]},Q)})}):y.success?e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"暂无参数"}):e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-destructive",children:"JSON 格式错误"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"实时预览解析结果"})]})]})})]})]})}function l1({value:n,label:i,onRemove:r}){const{attributes:d,listeners:m,setNodeRef:x,transform:f,transition:p,isDragging:g}=Yy({id:n}),N={transform:Xy.Transform.toString(f),transition:p,opacity:g?.5:1},j=y=>{y.preventDefault(),y.stopPropagation(),r(n)},w=y=>{y.stopPropagation()};return e.jsx("div",{ref:x,style:N,className:q("inline-flex items-center gap-1",g&&"shadow-lg"),children:e.jsxs(Fe,{variant:"secondary",className:"cursor-move hover:bg-secondary/80 flex items-center gap-1",children:[e.jsx("div",{...d,...m,className:"cursor-grab active:cursor-grabbing flex items-center",children:e.jsx(dy,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("span",{children:i}),e.jsx("button",{type:"button",className:"ml-1 rounded-sm hover:bg-destructive/20 focus:outline-none focus:ring-1 focus:ring-destructive",onClick:j,onPointerDown:w,onMouseDown:y=>y.stopPropagation(),children:e.jsx(il,{className:"h-3 w-3 cursor-pointer hover:text-destructive",strokeWidth:2,fill:"none"})})]})})}function n1({options:n,selected:i,onChange:r,placeholder:d="选择选项...",emptyText:m="未找到选项",className:x}){const[f,p]=u.useState(!1),g=By(lp(Iy,{activationConstraint:{distance:8}}),lp(Qy,{coordinateGetter:$y})),N=y=>{i.includes(y)?r(i.filter(k=>k!==y)):r([...i,y])},j=y=>{r(i.filter(k=>k!==y))},w=y=>{const{active:k,over:_}=y;if(_&&k.id!==_.id){const L=i.indexOf(k.id),D=i.indexOf(_.id);r(Vy(i,L,D))}};return e.jsxs(Ra,{open:f,onOpenChange:p,children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",role:"combobox","aria-expanded":f,className:q("w-full justify-between min-h-10 h-auto",x),children:[e.jsx(Hy,{sensors:g,collisionDetection:qy,onDragEnd:w,children:e.jsx(Gy,{items:i,strategy:Fy,children:e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:i.length===0?e.jsx("span",{className:"text-muted-foreground",children:d}):i.map(y=>{const k=n.find(_=>_.value===y);return e.jsx(l1,{value:y,label:k?.label||y,onRemove:j},y)})})})}),e.jsx(Xu,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(ka,{className:"w-full p-0",align:"start",children:e.jsxs(eo,{children:[e.jsx(so,{placeholder:"搜索...",className:"h-9"}),e.jsxs(to,{children:[e.jsx(ao,{children:m}),e.jsx(hr,{children:n.map(y=>{const k=i.includes(y.value);return e.jsxs(fr,{value:y.value,onSelect:()=>N(y.value),children:[e.jsx("div",{className:q("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",k?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Qt,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:y.label})]},y.value)})})]})]})})]})}const wa=pt.memo(function({title:i,description:r,taskConfig:d,modelNames:m,onChange:x,hideTemperature:f=!1,hideMaxTokens:p=!1,dataTour:g}){const N=j=>{x("model_list",j)};return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-base sm:text-lg",children:i}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:r})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":g,children:[e.jsx(C,{children:"模型列表"}),e.jsx(n1,{options:m.map(j=>({label:j,value:j})),selected:d.model_list||[],onChange:N,placeholder:"选择模型...",emptyText:"暂无可用模型"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[!f&&e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"温度"}),e.jsx(ie,{type:"number",step:"0.1",min:"0",max:"1",value:d.temperature??.3,onChange:j=>{const w=parseFloat(j.target.value);!isNaN(w)&&w>=0&&w<=1&&x("temperature",w)},className:"w-20 h-8 text-sm"})]}),e.jsx(fa,{value:[d.temperature??.3],onValueChange:j=>x("temperature",j[0]),min:0,max:1,step:.1,className:"w-full"})]}),!p&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{children:"最大 Token"}),e.jsx(ie,{type:"number",step:"1",min:"1",value:d.max_tokens??1024,onChange:j=>x("max_tokens",parseInt(j.target.value))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"慢请求阈值 (秒)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"超时警告"})]}),e.jsx(ie,{type:"number",step:"1",min:"1",value:d.slow_threshold??15,onChange:j=>{const w=parseInt(j.target.value);!isNaN(w)&&w>=1&&x("slow_threshold",w)},placeholder:"15"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"模型响应时间超过此阈值将输出警告日志"})]})]})]})}),i1=pt.memo(function({paginatedModels:i,allModels:r,onEdit:d,onDelete:m,isModelUsed:x,searchQuery:f}){return i.length===0?e.jsx("div",{className:"md:hidden text-center text-muted-foreground py-8 rounded-lg border bg-card",children:f?"未找到匹配的模型":"暂无模型配置"}):e.jsx("div",{className:"md:hidden space-y-3",children:i.map((p,g)=>{const N=r.findIndex(w=>w===p),j=x(p.name);return e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-base",children:p.name}),e.jsx(Fe,{variant:j?"default":"secondary",className:j?"bg-green-600 hover:bg-green-700":"",children:j?"已使用":"未使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",title:p.model_identifier,children:p.model_identifier})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(S,{variant:"default",size:"sm",onClick:()=>d(p,N),children:[e.jsx(an,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(S,{size:"sm",onClick:()=>m(N),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(Ze,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"提供商"}),e.jsx("p",{className:"font-medium",children:p.api_provider})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"模型温度"}),e.jsx("p",{className:"font-medium",children:p.temperature!=null?p.temperature:e.jsx("span",{className:"text-muted-foreground",children:"默认"})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输入价格"}),e.jsxs("p",{className:"font-medium",children:["¥",p.price_in,"/M"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输出价格"}),e.jsxs("p",{className:"font-medium",children:["¥",p.price_out,"/M"]})]})]})]},g)})})}),r1=pt.memo(function({paginatedModels:i,allModels:r,filteredModels:d,selectedModels:m,onEdit:x,onDelete:f,onToggleSelection:p,onToggleSelectAll:g,isModelUsed:N,searchQuery:j}){return e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs(ct,{children:[e.jsx(Xe,{className:"w-12",children:e.jsx(ft,{checked:m.size===d.length&&d.length>0,onCheckedChange:g})}),e.jsx(Xe,{className:"w-24",children:"使用状态"}),e.jsx(Xe,{children:"模型名称"}),e.jsx(Xe,{children:"模型标识符"}),e.jsx(Xe,{children:"提供商"}),e.jsx(Xe,{className:"text-center",children:"温度"}),e.jsx(Xe,{className:"text-right",children:"输入价格"}),e.jsx(Xe,{className:"text-right",children:"输出价格"}),e.jsx(Xe,{className:"text-right",children:"操作"})]})}),e.jsx(cn,{children:i.length===0?e.jsx(ct,{children:e.jsx(Ge,{colSpan:9,className:"text-center text-muted-foreground py-8",children:j?"未找到匹配的模型":"暂无模型配置"})}):i.map((w,y)=>{const k=r.findIndex(L=>L===w),_=N(w.name);return e.jsxs(ct,{children:[e.jsx(Ge,{children:e.jsx(ft,{checked:m.has(k),onCheckedChange:()=>p(k)})}),e.jsx(Ge,{children:e.jsx(Fe,{variant:_?"default":"secondary",className:_?"bg-green-600 hover:bg-green-700":"",children:_?"已使用":"未使用"})}),e.jsx(Ge,{className:"font-medium",children:w.name}),e.jsx(Ge,{className:"max-w-xs truncate",title:w.model_identifier,children:w.model_identifier}),e.jsx(Ge,{children:w.api_provider}),e.jsx(Ge,{className:"text-center",children:w.temperature!=null?w.temperature:e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsxs(Ge,{className:"text-right",children:["¥",w.price_in,"/M"]}),e.jsxs(Ge,{className:"text-right",children:["¥",w.price_out,"/M"]}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(S,{variant:"default",size:"sm",onClick:()=>x(w,k),children:[e.jsx(an,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(S,{size:"sm",onClick:()=>f(k),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(Ze,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},y)})})]})})})}),c1=300*1e3,jp=new Map,o1=[10,20,50,100],d1=pt.memo(function({page:i,pageSize:r,totalItems:d,jumpToPage:m,onPageChange:x,onPageSizeChange:f,onJumpToPageChange:p,onJumpToPage:g,onSelectionClear:N}){const j=Math.ceil(d/r),w=k=>{f(parseInt(k)),x(1),N?.()},y=k=>{k.key==="Enter"&&g()};return d===0?null:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{htmlFor:"page-size-model",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Re,{value:r.toString(),onValueChange:w,children:[e.jsx(De,{id:"page-size-model",className:"w-20",children:e.jsx(Le,{})}),e.jsx(Oe,{children:o1.map(k=>e.jsx(le,{value:k.toString(),children:k},k))})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(i-1)*r+1," 到"," ",Math.min(i*r,d)," 条,共 ",d," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>x(1),disabled:i===1,className:"hidden sm:flex",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>x(Math.max(1,i-1)),disabled:i===1,children:[e.jsx(rl,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{type:"number",value:m,onChange:k=>p(k.target.value),onKeyDown:y,placeholder:i.toString(),className:"w-16 h-8 text-center",min:1,max:j}),e.jsx(S,{variant:"outline",size:"sm",onClick:g,disabled:!m,className:"h-8",children:"跳转"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>x(i+1),disabled:i>=j,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Ua,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>x(j),disabled:i>=j,className:"hidden sm:flex",children:e.jsx(li,{className:"h-4 w-4"})})]})]})});function u1(n){const{models:i,taskConfig:r,debounceMs:d=2e3,onSavingChange:m,onUnsavedChange:x}=n,f=u.useRef(null),p=u.useRef(null),g=u.useRef(!0),N=u.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null),p.current&&(clearTimeout(p.current),p.current=null)},[]),j=u.useCallback(async y=>{try{m?.(!0),await Gu("models",y),x?.(!1)}catch(k){console.error("自动保存模型列表失败:",k),x?.(!0)}finally{m?.(!1)}},[m,x]),w=u.useCallback(async y=>{try{m?.(!0),await Gu("model_task_config",y),x?.(!1)}catch(k){console.error("自动保存任务配置失败:",k),x?.(!0)}finally{m?.(!1)}},[m,x]);return u.useEffect(()=>{if(!g.current)return x?.(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{j(i)},d),()=>{f.current&&clearTimeout(f.current)}},[i,j,d,x]),u.useEffect(()=>{if(!(g.current||!r))return x?.(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{w(r)},d),()=>{p.current&&clearTimeout(p.current)}},[r,w,d,x]),u.useEffect(()=>()=>{N()},[N]),{clearTimers:N,initialLoadRef:g}}function m1(n={}){const{onCloseEditDialog:i}=n,r=ja(),{registerTour:d,startTour:m,state:x,goToStep:f}=em(),p=u.useRef(x.stepIndex);return u.useEffect(()=>{d(Aa,Qg)},[d]),u.useEffect(()=>{if(x.activeTourId===Aa&&x.isRunning){const N=Ig[x.stepIndex];N&&!window.location.pathname.endsWith(N.replace("/config/",""))&&r({to:N})}},[x.stepIndex,x.activeTourId,x.isRunning,r]),u.useEffect(()=>{if(x.activeTourId===Aa&&x.isRunning){const N=p.current,j=x.stepIndex;N>=12&&N<=17&&j<12&&i?.(),p.current=j}},[x.stepIndex,x.activeTourId,x.isRunning,i]),u.useEffect(()=>{if(x.activeTourId!==Aa||!x.isRunning)return;const N=j=>{const w=j.target,y=x.stepIndex;y===2&&w.closest('[data-tour="add-provider-button"]')?setTimeout(()=>f(3),300):y===9&&w.closest('[data-tour="provider-cancel-button"]')?setTimeout(()=>f(10),300):y===11&&w.closest('[data-tour="add-model-button"]')?setTimeout(()=>f(12),300):y===17&&w.closest('[data-tour="model-cancel-button"]')?setTimeout(()=>f(18),300):y===18&&w.closest('[data-tour="tasks-tab-trigger"]')&&setTimeout(()=>f(19),300)};return document.addEventListener("click",N,!0),()=>document.removeEventListener("click",N,!0)},[x,f]),{startTour:u.useCallback(()=>{m(Aa)},[m]),isRunning:x.isRunning&&x.activeTourId===Aa,stepIndex:x.stepIndex}}function x1(n){const{getProviderConfig:i}=n,[r,d]=u.useState([]),[m,x]=u.useState(!1),[f,p]=u.useState(null),[g,N]=u.useState(null),j=u.useCallback(()=>{d([]),p(null),N(null)},[]),w=u.useCallback(async(y,k=!1)=>{const _=i(y);if(!_?.base_url){d([]),N(null),p('提供商配置不完整,请先在"模型提供商配置"中配置');return}if(!_.api_key){d([]),N(null),p('该提供商未配置 API Key请先在"模型提供商配置"中填写');return}const L=Zw(_.base_url);if(N(L),!L?.modelFetcher){d([]),p(null);return}const D=`${y}:${_.base_url}`,U=jp.get(D);if(!k&&U&&Date.now()-U.timestamp<c1){d(U.models),p(null);return}x(!0),p(null);try{const Q=await Ow(y,L.modelFetcher.parser,L.modelFetcher.endpoint);d(Q),jp.set(D,{models:Q,timestamp:Date.now()})}catch(Q){console.error("获取模型列表失败:",Q);const R=Q.message||"获取模型列表失败";R.includes("无效")||R.includes("过期")||R.includes("API Key")?p('API Key 无效或已过期,请检查"模型提供商配置"中的密钥'):R.includes("权限")?p("没有权限获取模型列表,请检查 API Key 权限"):R.includes("timeout")||R.includes("超时")?p("请求超时,请检查网络连接后重试"):R.includes("不支持")?p("该提供商不支持自动获取模型列表,请手动输入"):p(R),d([])}finally{x(!1)}},[i]);return{availableModels:r,fetchingModels:m,modelFetchError:f,matchedTemplate:g,fetchModelsForProvider:w,clearModels:j}}function h1(){const[n,i]=u.useState([]),[r,d]=u.useState([]),[m,x]=u.useState([]),[f,p]=u.useState([]),[g,N]=u.useState(null),[j,w]=u.useState(!0),[y,k]=u.useState(!1),[_,L]=u.useState(!1),[D,U]=u.useState(!1),[Q,R]=u.useState(!1),[z,I]=u.useState(!1),[$,E]=u.useState(!1),[M,se]=u.useState(null),[fe,ve]=u.useState(null),[Ne,je]=u.useState(!1),[ye,Se]=u.useState(null),[O,G]=u.useState(""),[H,ee]=u.useState(new Set),[v,X]=u.useState(!1),[me,ce]=u.useState(1),[xe,we]=u.useState(20),[oe,Z]=u.useState(""),[te,V]=u.useState(!1),[P,ke]=u.useState({}),{toast:He}=Bs(),{startTour:pe,isRunning:Te}=m1({onCloseEditDialog:()=>E(!1)}),{clearTimers:Qs,initialLoadRef:vt}=u1({models:n,taskConfig:g,onSavingChange:L,onUnsavedChange:U}),de=u.useCallback(async()=>{try{w(!0);const ne=await Zn(),T=ne.models||[];i(T),p(T.map(ze=>ze.name));const ge=ne.api_providers||[];d(ge.map(ze=>ze.name)),x(ge),N(ne.model_task_config||null),U(!1),vt.current=!1}catch(ne){console.error("加载配置失败:",ne)}finally{w(!1)}},[vt]);u.useEffect(()=>{de()},[de]);const qe=u.useCallback(ne=>m.find(T=>T.name===ne),[m]),{availableModels:Ie,fetchingModels:Ys,modelFetchError:Hs,matchedTemplate:bt,fetchModelsForProvider:ot,clearModels:Ds}=x1({getProviderConfig:qe});u.useEffect(()=>{$&&M?.api_provider&&ot(M.api_provider)},[$,M?.api_provider,ot]);const ks=async()=>{try{R(!0),Wc().catch(()=>{}),I(!0)}catch(ne){console.error("重启失败:",ne),I(!1),He({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),R(!1)}},va=async()=>{try{k(!0),Qs();const ne=await Zn();ne.models=n,ne.model_task_config=g,await Kc(ne),U(!1),He({title:"保存成功",description:"正在重启麦麦..."}),await ks()}catch(ne){console.error("保存配置失败:",ne),He({title:"保存失败",description:ne.message,variant:"destructive"}),k(!1)}},Y=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},Be=()=>{I(!1),R(!1),He({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},Ee=async()=>{try{k(!0),Qs();const ne=await Zn();ne.models=n,ne.model_task_config=g,await Kc(ne),U(!1),He({title:"保存成功",description:"模型配置已保存"}),await de()}catch(ne){console.error("保存配置失败:",ne),He({title:"保存失败",description:ne.message,variant:"destructive"})}finally{k(!1)}},Ye=(ne,T)=>{ke({}),se(ne||{model_identifier:"",name:"",api_provider:r[0]||"",price_in:0,price_out:0,temperature:null,max_tokens:null,force_stream_mode:!1,extra_params:{}}),ve(T),E(!0)},Xs=()=>{if(!M)return;const ne={};if(M.name?.trim()||(ne.name="请输入模型名称"),M.api_provider?.trim()||(ne.api_provider="请选择 API 提供商"),M.model_identifier?.trim()||(ne.model_identifier="请输入模型标识符"),Object.keys(ne).length>0){ke(ne);return}ke({});const T={...M,price_in:M.price_in??0,price_out:M.price_out??0};let ge,ze=null;if(fe!==null?(ze=n[fe].name,ge=[...n],ge[fe]=T):ge=[...n,T],i(ge),p(ge.map(Ns=>Ns.name)),ze&&ze!==T.name&&g){const Ns=io=>io.map(ri=>ri===ze?T.name:ri);N({...g,utils:{...g.utils,model_list:Ns(g.utils?.model_list||[])},utils_small:{...g.utils_small,model_list:Ns(g.utils_small?.model_list||[])},tool_use:{...g.tool_use,model_list:Ns(g.tool_use?.model_list||[])},replyer:{...g.replyer,model_list:Ns(g.replyer?.model_list||[])},planner:{...g.planner,model_list:Ns(g.planner?.model_list||[])},vlm:{...g.vlm,model_list:Ns(g.vlm?.model_list||[])},voice:{...g.voice,model_list:Ns(g.voice?.model_list||[])},embedding:{...g.embedding,model_list:Ns(g.embedding?.model_list||[])},lpmm_entity_extract:{...g.lpmm_entity_extract,model_list:Ns(g.lpmm_entity_extract?.model_list||[])},lpmm_rdf_build:{...g.lpmm_rdf_build,model_list:Ns(g.lpmm_rdf_build?.model_list||[])},lpmm_qa:{...g.lpmm_qa,model_list:Ns(g.lpmm_qa?.model_list||[])}})}E(!1),se(null),ve(null)},Je=ne=>{if(!ne&&M){const T={...M,price_in:M.price_in??0,price_out:M.price_out??0};se(T)}E(ne)},qs=ne=>{Se(ne),je(!0)},be=()=>{if(ye!==null){const ne=n.filter((T,ge)=>ge!==ye);i(ne),p(ne.map(T=>T.name)),He({title:"删除成功",description:"模型已从列表中移除"})}je(!1),Se(null)},_s=ne=>{const T=new Set(H);T.has(ne)?T.delete(ne):T.add(ne),ee(T)},Ae=()=>{if(H.size===gs.length)ee(new Set);else{const ne=gs.map((T,ge)=>n.findIndex(ze=>ze===gs[ge]));ee(new Set(ne))}},Fs=()=>{if(H.size===0){He({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}X(!0)},dt=()=>{const ne=n.filter((T,ge)=>!H.has(ge));i(ne),p(ne.map(T=>T.name)),ee(new Set),X(!1),He({title:"批量删除成功",description:`已删除 ${H.size} 个模型`})},xs=(ne,T,ge)=>{g&&N({...g,[ne]:{...g[ne],[T]:ge}})},gs=n.filter(ne=>{if(!O)return!0;const T=O.toLowerCase();return ne.name.toLowerCase().includes(T)||ne.model_identifier.toLowerCase().includes(T)||ne.api_provider.toLowerCase().includes(T)}),Nt=Math.ceil(gs.length/xe),Lt=gs.slice((me-1)*xe,me*xe),Dt=()=>{const ne=parseInt(oe);ne>=1&&ne<=Nt&&(ce(ne),Z(""))},Ba=ne=>g?[g.utils?.model_list||[],g.utils_small?.model_list||[],g.tool_use?.model_list||[],g.replyer?.model_list||[],g.planner?.model_list||[],g.vlm?.model_list||[],g.voice?.model_list||[],g.embedding?.model_list||[],g.lpmm_entity_extract?.model_list||[],g.lpmm_rdf_build?.model_list||[],g.lpmm_qa?.model_list||[]].some(ge=>ge.includes(ne)):!1;return j?e.jsx(Ke,{className:"h-full",children:e.jsx("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})})})}):e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"模型管理与分配"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"添加模型并为模型分配功能"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs(S,{onClick:Ee,disabled:y||_||!D||Q,size:"sm",variant:"outline",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(gr,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),y?"保存中...":_?"自动保存中...":D?"保存配置":"已保存"]}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsxs(S,{disabled:y||_||Q,size:"sm",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(pr,{className:"mr-2 h-4 w-4"}),Q?"重启中...":D?"保存并重启":"重启麦麦"]})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认重启麦麦?"}),e.jsx(rs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:D?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:D?va:ks,children:D?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(It,{children:[e.jsx(Oa,{className:"h-4 w-4"}),e.jsxs(Yt,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(It,{className:"hidden lg:flex border-primary/30 bg-primary/5 cursor-pointer hover:bg-primary/10 transition-colors",onClick:pe,children:[e.jsx(uy,{className:"h-4 w-4 text-primary"}),e.jsxs(Yt,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:"新手引导:"}),"不知道如何配置模型?点击这里开始学习如何为麦麦的组件分配模型。"]}),e.jsx(S,{variant:"outline",size:"sm",className:"ml-4 shrink-0",children:"开始引导"})]})]}),e.jsxs(Ca,{defaultValue:"models",className:"w-full",children:[e.jsxs(pa,{className:"grid w-full max-w-full sm:max-w-md grid-cols-2",children:[e.jsx(es,{value:"models",children:"添加模型"}),e.jsx(es,{value:"tasks","data-tour":"tasks-tab-trigger",children:"为模型分配功能"})]}),e.jsxs(ws,{value:"models",className:"space-y-4 mt-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置可用的模型列表"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[H.size>0&&e.jsxs(S,{onClick:Fs,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(Ze,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",H.size,")"]}),e.jsxs(S,{onClick:()=>Ye(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto","data-tour":"add-model-button",children:[e.jsx(rt,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加模型"]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2",children:[e.jsxs("div",{className:"relative w-full sm:flex-1 sm:max-w-sm",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{placeholder:"搜索模型名称、标识符或提供商...",value:O,onChange:ne=>G(ne.target.value),className:"pl-9"})]}),O&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",gs.length," 个结果"]})]}),e.jsx(i1,{paginatedModels:Lt,allModels:n,onEdit:Ye,onDelete:qs,isModelUsed:Ba,searchQuery:O}),e.jsx(r1,{paginatedModels:Lt,allModels:n,filteredModels:gs,selectedModels:H,onEdit:Ye,onDelete:qs,onToggleSelection:_s,onToggleSelectAll:Ae,isModelUsed:Ba,searchQuery:O}),e.jsx(d1,{page:me,pageSize:xe,totalItems:gs.length,jumpToPage:oe,onPageChange:ce,onPageSizeChange:we,onJumpToPageChange:Z,onJumpToPage:Dt,onSelectionClear:()=>ee(new Set)})]}),e.jsxs(ws,{value:"tasks",className:"space-y-6 mt-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"为不同的任务配置使用的模型和参数"}),g&&e.jsxs("div",{className:"grid gap-4 sm:gap-6",children:[e.jsx(wa,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:g.utils,modelNames:f,onChange:(ne,T)=>xs("utils",ne,T),dataTour:"task-model-select"}),e.jsx(wa,{title:"组件小模型 (utils_small)",description:"消耗量较大的组件,建议使用速度较快的小模型",taskConfig:g.utils_small,modelNames:f,onChange:(ne,T)=>xs("utils_small",ne,T)}),e.jsx(wa,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:g.tool_use,modelNames:f,onChange:(ne,T)=>xs("tool_use",ne,T)}),e.jsx(wa,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:g.replyer,modelNames:f,onChange:(ne,T)=>xs("replyer",ne,T)}),e.jsx(wa,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:g.planner,modelNames:f,onChange:(ne,T)=>xs("planner",ne,T)}),e.jsx(wa,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:g.vlm,modelNames:f,onChange:(ne,T)=>xs("vlm",ne,T),hideTemperature:!0}),e.jsx(wa,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:g.voice,modelNames:f,onChange:(ne,T)=>xs("voice",ne,T),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(wa,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:g.embedding,modelNames:f,onChange:(ne,T)=>xs("embedding",ne,T),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(wa,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:g.lpmm_entity_extract,modelNames:f,onChange:(ne,T)=>xs("lpmm_entity_extract",ne,T)}),e.jsx(wa,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:g.lpmm_rdf_build,modelNames:f,onChange:(ne,T)=>xs("lpmm_rdf_build",ne,T)}),e.jsx(wa,{title:"问答模型 (lpmm_qa)",description:"知识库问答",taskConfig:g.lpmm_qa,modelNames:f,onChange:(ne,T)=>xs("lpmm_qa",ne,T)})]})]})]})]}),e.jsx(Gs,{open:$,onOpenChange:Je,children:e.jsxs(Rs,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"model-dialog",preventOutsideClose:Te,children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:fe!==null?"编辑模型":"添加模型"}),e.jsx(Ps,{children:"配置模型的基本信息和参数"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2","data-tour":"model-name-input",children:[e.jsx(C,{htmlFor:"model_name",className:P.name?"text-destructive":"",children:"模型名称 *"}),e.jsx(ie,{id:"model_name",value:M?.name||"",onChange:ne=>{se(T=>T?{...T,name:ne.target.value}:null),P.name&&ke(T=>({...T,name:void 0}))},placeholder:"例如: qwen3-30b",className:P.name?"border-destructive focus-visible:ring-destructive":""}),P.name?e.jsx("p",{className:"text-xs text-destructive",children:P.name}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于在任务配置中引用此模型"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"model-provider-select",children:[e.jsx(C,{htmlFor:"api_provider",className:P.api_provider?"text-destructive":"",children:"API 提供商 *"}),e.jsxs(Re,{value:M?.api_provider||"",onValueChange:ne=>{se(T=>T?{...T,api_provider:ne}:null),Ds(),P.api_provider&&ke(T=>({...T,api_provider:void 0}))},children:[e.jsx(De,{id:"api_provider",className:P.api_provider?"border-destructive focus-visible:ring-destructive":"",children:e.jsx(Le,{placeholder:"选择提供商"})}),e.jsx(Oe,{children:r.map(ne=>e.jsx(le,{value:ne,children:ne},ne))})]}),P.api_provider&&e.jsx("p",{className:"text-xs text-destructive",children:P.api_provider})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"model-identifier-input",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{htmlFor:"model_identifier",className:P.model_identifier?"text-destructive":"",children:"模型标识符 *"}),bt?.modelFetcher&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{variant:"secondary",className:"text-xs",children:bt.display_name}),e.jsx(S,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>M?.api_provider&&ot(M.api_provider,!0),disabled:Ys,children:Ys?e.jsx(Js,{className:"h-3 w-3 animate-spin"}):e.jsx(zt,{className:"h-3 w-3"})})]})]}),bt?.modelFetcher?e.jsxs(Ra,{open:te,onOpenChange:V,children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",role:"combobox","aria-expanded":te,className:"w-full justify-between font-normal",disabled:Ys||!!Hs,children:[Ys?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Js,{className:"h-4 w-4 animate-spin"}),"正在获取模型列表..."]}):Hs?e.jsx("span",{className:"text-muted-foreground text-sm",children:"点击下方输入框手动填写"}):M?.model_identifier?e.jsx("span",{className:"truncate",children:M.model_identifier}):e.jsx("span",{className:"text-muted-foreground",children:"搜索或选择模型..."}),e.jsx(Xu,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ka,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(eo,{children:[e.jsx(so,{placeholder:"搜索模型..."}),e.jsx(Ke,{className:"h-[300px]",children:e.jsxs(to,{className:"max-h-none overflow-visible",children:[e.jsx(ao,{children:Hs?e.jsxs("div",{className:"py-4 px-2 text-center space-y-2",children:[e.jsx("p",{className:"text-sm text-destructive",children:Hs}),!Hs.includes("API Key")&&e.jsx(S,{variant:"link",size:"sm",onClick:()=>M?.api_provider&&ot(M.api_provider,!0),children:"重试"})]}):"未找到匹配的模型"}),e.jsx(hr,{heading:"可用模型",children:Ie.map(ne=>e.jsxs(fr,{value:ne.id,onSelect:()=>{se(T=>T?{...T,model_identifier:ne.id}:null),V(!1)},children:[e.jsx(Qt,{className:`mr-2 h-4 w-4 ${M?.model_identifier===ne.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:ne.id}),ne.name!==ne.id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ne.name})]})]},ne.id))}),e.jsx(hr,{heading:"手动输入",children:e.jsxs(fr,{value:"__manual_input__",onSelect:()=>{V(!1)},children:[e.jsx(an,{className:"mr-2 h-4 w-4"}),"手动输入模型标识符..."]})})]})})]})})]}):e.jsx(ie,{id:"model_identifier",value:M?.model_identifier||"",onChange:ne=>{se(T=>T?{...T,model_identifier:ne.target.value}:null),P.model_identifier&&ke(T=>({...T,model_identifier:void 0}))},placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507",className:P.model_identifier?"border-destructive focus-visible:ring-destructive":""}),P.model_identifier&&e.jsx("p",{className:"text-xs text-destructive",children:P.model_identifier}),Hs&&bt?.modelFetcher&&!P.model_identifier&&e.jsxs(It,{variant:"destructive",className:"mt-2 py-2",children:[e.jsx(Oa,{className:"h-4 w-4"}),e.jsx(Yt,{className:"text-xs",children:Hs})]}),bt?.modelFetcher&&e.jsx(ie,{value:M?.model_identifier||"",onChange:ne=>{se(T=>T?{...T,model_identifier:ne.target.value}:null),P.model_identifier&&ke(T=>({...T,model_identifier:void 0}))},placeholder:"或手动输入模型标识符",className:`mt-2 ${P.model_identifier?"border-destructive focus-visible:ring-destructive":""}`}),!P.model_identifier&&e.jsx("p",{className:"text-xs text-muted-foreground",children:Hs?'请手动输入模型标识符,或前往"模型提供商配置"检查 API Key':bt?.modelFetcher?`已识别为 ${bt.display_name},支持自动获取模型列表`:"API 提供商提供的模型 ID"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"price_in",children:"输入价格 (¥/M token)"}),e.jsx(ie,{id:"price_in",type:"number",step:"0.1",min:"0",value:M?.price_in??"",onChange:ne=>{const T=ne.target.value===""?null:parseFloat(ne.target.value);se(ge=>ge?{...ge,price_in:T}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(ie,{id:"price_out",type:"number",step:"0.1",min:"0",value:M?.price_out??"",onChange:ne=>{const T=ne.target.value===""?null:parseFloat(ne.target.value);se(ge=>ge?{...ge,price_out:T}:null)},placeholder:"默认: 0"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"enable_model_temperature",className:"cursor-pointer",children:"自定义模型温度"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务温度配置"})]}),e.jsx(Ve,{id:"enable_model_temperature",checked:M?.temperature!=null,onCheckedChange:ne=>{se(ne?T=>T?{...T,temperature:.5}:null:T=>T?{...T,temperature:null}:null)}})]}),M?.temperature!=null&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-sm",children:"温度值"}),e.jsx("span",{className:"text-sm font-medium tabular-nums",children:M.temperature.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"0"}),e.jsx(fa,{value:[M.temperature],onValueChange:ne=>se(T=>T?{...T,temperature:ne[0]}:null),min:0,max:1,step:.1,className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"较低的温度0.1-0.3产生更确定的输出较高的温度0.7-1.0)产生更多样化的输出"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{htmlFor:"enable_model_max_tokens",className:"cursor-pointer",children:"自定义最大 Token"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务最大 Token 配置"})]}),e.jsx(Ve,{id:"enable_model_max_tokens",checked:M?.max_tokens!=null,onCheckedChange:ne=>{se(ne?T=>T?{...T,max_tokens:2048}:null:T=>T?{...T,max_tokens:null}:null)}})]}),M?.max_tokens!=null&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{className:"text-sm",children:"最大 Token 数"}),e.jsx(ie,{type:"number",min:"1",max:"128000",value:M.max_tokens,onChange:ne=>{const T=parseInt(ne.target.value);!isNaN(T)&&T>=1&&se(ge=>ge?{...ge,max_tokens:T}:null)},className:"w-28 h-8 text-sm"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"限制模型单次输出的最大 token 数量,不同模型支持的上限不同"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"force_stream_mode",checked:M?.force_stream_mode||!1,onCheckedChange:ne=>se(T=>T?{...T,force_stream_mode:ne}:null)}),e.jsx(C,{htmlFor:"force_stream_mode",className:"cursor-pointer",children:"强制流式输出模式"})]}),e.jsx(a1,{value:M?.extra_params||{},onChange:ne=>se(T=>T?{...T,extra_params:ne}:null),placeholder:"添加额外参数(如 enable_thinking、top_p 等)..."})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>E(!1),"data-tour":"model-cancel-button",children:"取消"}),e.jsx(S,{onClick:Xs,"data-tour":"model-save-button",children:"保存"})]})]})}),e.jsx(ms,{open:Ne,onOpenChange:je,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除模型 "',ye!==null?n[ye]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:be,children:"删除"})]})]})}),e.jsx(ms,{open:v,onOpenChange:X,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认批量删除"}),e.jsxs(rs,{children:["确定要删除选中的 ",H.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),z&&e.jsx(Wu,{onRestartComplete:Y,onRestartFailed:Be})]})})}const lo="/api/webui/config";async function f1(){const i=await(await _e(`${lo}/adapter-config/path`)).json();return!i.success||!i.path?null:{path:i.path,lastModified:i.lastModified}}async function vp(n){const r=await(await _e(`${lo}/adapter-config/path`,{method:"POST",headers:As(),body:JSON.stringify({path:n})})).json();if(!r.success)throw new Error(r.message||"保存路径失败")}async function bp(n){const r=await(await _e(`${lo}/adapter-config?path=${encodeURIComponent(n)}`)).json();if(!r.success)throw new Error("读取配置文件失败");return r.content}async function Np(n,i){const d=await(await _e(`${lo}/adapter-config`,{method:"POST",headers:As(),body:JSON.stringify({path:n,content:i})})).json();if(!d.success)throw new Error(d.message||"保存配置失败")}const ta={inner:{version:"0.1.2"},nickname:{nickname:""},napcat_server:{host:"localhost",port:8095,token:"",heartbeat_interval:30},maibot_server:{host:"localhost",port:8e3},chat:{group_list_type:"whitelist",group_list:[],private_list_type:"whitelist",private_list:[],ban_user_id:[],ban_qq_bot:!1,enable_poke:!0},voice:{use_tts:!1},debug:{level:"INFO"}},Du={oneclick:{name:"一键包",description:"使用一键包部署的适配器配置",path:"../MaiBot-Napcat-Adapter/config.toml",icon:tn},docker:{name:"Docker",description:"Docker Compose 部署的适配器配置",path:"/MaiMBot/adapters-config/config.toml",icon:my}};function p1(){const[n,i]=u.useState("upload"),[r,d]=u.useState(null),[m,x]=u.useState(""),[f,p]=u.useState(""),[g,N]=u.useState("oneclick"),[j,w]=u.useState(""),[y,k]=u.useState(!1),[_,L]=u.useState(!1),[D,U]=u.useState(!1),[Q,R]=u.useState(!1),[z,I]=u.useState(null),$=u.useRef(null),{toast:E}=Bs(),M=u.useRef(null),se=Z=>{if(!Z.trim())return{valid:!1,error:"路径不能为空"};if(!Z.toLowerCase().endsWith(".toml"))return{valid:!1,error:"文件必须是 .toml 格式"};const te=/^([a-zA-Z]:\\|\\\\[^\\]+\\[^\\]+\\).+\.toml$/i,V=/^(\/|~\/).+\.toml$/i,P=/^(\.{1,2}[\\/]|[^:\\/]).+\.toml$/i,ke=te.test(Z),He=V.test(Z),pe=P.test(Z);return!ke&&!He&&!pe?{valid:!1,error:"路径格式错误"}:/[<>"|?*\x00-\x1F]/.test(Z)?{valid:!1,error:"路径包含非法字符"}:{valid:!0,error:""}},fe=Z=>{if(p(Z),Z.trim()){const te=se(Z);w(te.error)}else w("")},ve=u.useCallback(async Z=>{const te=Du[Z];L(!0);try{const V=await bp(te.path),P=me(V);d(P),N(Z),p(te.path),await vp(te.path),E({title:"加载成功",description:`已从${te.name}预设加载配置`})}catch(V){console.error("加载预设配置失败:",V),E({title:"加载失败",description:V instanceof Error?V.message:"无法读取预设配置文件",variant:"destructive"})}finally{L(!1)}},[E]),Ne=u.useCallback(async Z=>{const te=se(Z);if(!te.valid){w(te.error),E({title:"路径无效",description:te.error,variant:"destructive"});return}w(""),L(!0);try{const V=await bp(Z),P=me(V);d(P),p(Z),await vp(Z),E({title:"加载成功",description:"已从配置文件加载"})}catch(V){console.error("加载配置失败:",V),E({title:"加载失败",description:V instanceof Error?V.message:"无法读取配置文件",variant:"destructive"})}finally{L(!1)}},[E]);u.useEffect(()=>{(async()=>{try{const te=await f1();if(te&&te.path){p(te.path);const V=Object.entries(Du).find(([,P])=>P.path===te.path);V?(i("preset"),N(V[0]),await ve(V[0])):(i("path"),await Ne(te.path))}}catch(te){console.error("加载保存的路径失败:",te)}})()},[Ne,ve]);const je=u.useCallback(Z=>{n!=="path"&&n!=="preset"||!f||(M.current&&clearTimeout(M.current),M.current=setTimeout(async()=>{k(!0);try{const te=ce(Z);await Np(f,te),E({title:"自动保存成功",description:"配置已保存到文件"})}catch(te){console.error("自动保存失败:",te),E({title:"自动保存失败",description:te instanceof Error?te.message:"保存配置失败",variant:"destructive"})}finally{k(!1)}},1e3))},[n,f,E]),ye=async()=>{if(!r||!f)return;const Z=se(f);if(!Z.valid){E({title:"保存失败",description:Z.error,variant:"destructive"});return}k(!0);try{const te=ce(r);await Np(f,te),E({title:"保存成功",description:"配置已保存到文件"})}catch(te){console.error("保存失败:",te),E({title:"保存失败",description:te instanceof Error?te.message:"保存配置失败",variant:"destructive"})}finally{k(!1)}},Se=async()=>{f&&await Ne(f)},O=Z=>{if(Z!==n){if(r){I(Z),U(!0);return}G(Z)}},G=Z=>{d(null),x(""),w(""),i(Z),Z==="preset"&&ve("oneclick"),E({title:"已切换模式",description:{upload:"现在可以上传配置文件",path:"现在可以指定配置文件路径",preset:"现在可以使用预设配置"}[Z]})},H=()=>{z&&(G(z),I(null)),U(!1)},ee=()=>{if(r){R(!0);return}v()},v=()=>{p(""),d(null),w(""),E({title:"已清空",description:"路径和配置已清空"})},X=()=>{v(),R(!1)},me=Z=>{const te=JSON.parse(JSON.stringify(ta)),V=Z.split(`
`);let P="";for(const ke of V){const He=ke.trim();if(!He||He.startsWith("#"))continue;const pe=He.match(/^\[(\w+)\]/);if(pe){P=pe[1];continue}const Te=He.match(/^(\w+)\s*=\s*(.+)$/);if(Te&&P){const[,Qs,vt]=Te;let de=vt.trim();const qe=de.match(/^("[^"]*")/);if(qe)de=qe[1];else{const Ys=de.indexOf("#");Ys!==-1&&(de=de.substring(0,Ys).trim())}let Ie;if(de==="true")Ie=!0;else if(de==="false")Ie=!1;else if(de.startsWith("[")&&de.endsWith("]")){const Ys=de.slice(1,-1).trim();if(Ys){const Hs=Ys.split(",").map(ot=>{const Ds=ot.trim();return isNaN(Number(Ds))?Ds.replace(/"/g,""):Number(Ds)}),bt=typeof Hs[0];Ie=Hs.every(ot=>typeof ot===bt)?Hs:Hs.filter(ot=>typeof ot=="number")}else Ie=[]}else de.startsWith('"')&&de.endsWith('"')?Ie=de.slice(1,-1):isNaN(Number(de))?Ie=de.replace(/"/g,""):Ie=Number(de);if(P in te){const Ys=te[P];Ys[Qs]=Ie}}}return te},ce=Z=>{const te=[],V=(P,ke)=>P===""||P===null||P===void 0?ke:P;return te.push("[inner]"),te.push(`version = "${V(Z.inner.version,ta.inner.version)}" # 版本号`),te.push("# 请勿修改版本号,除非你知道自己在做什么"),te.push(""),te.push("[nickname] # 现在没用"),te.push(`nickname = "${V(Z.nickname.nickname,ta.nickname.nickname)}"`),te.push(""),te.push("[napcat_server] # Napcat连接的ws服务设置"),te.push(`host = "${V(Z.napcat_server.host,ta.napcat_server.host)}" # Napcat设定的主机地址`),te.push(`port = ${V(Z.napcat_server.port||0,ta.napcat_server.port)} # Napcat设定的端口`),te.push(`token = "${V(Z.napcat_server.token,ta.napcat_server.token)}" # Napcat设定的访问令牌若无则留空`),te.push(`heartbeat_interval = ${V(Z.napcat_server.heartbeat_interval||0,ta.napcat_server.heartbeat_interval)} # 与Napcat设置的心跳相同按秒计`),te.push(""),te.push("[maibot_server] # 连接麦麦的ws服务设置"),te.push(`host = "${V(Z.maibot_server.host,ta.maibot_server.host)}" # 麦麦在.env文件中设置的主机地址即HOST字段`),te.push(`port = ${V(Z.maibot_server.port||0,ta.maibot_server.port)} # 麦麦在.env文件中设置的端口即PORT字段`),te.push(""),te.push("[chat] # 黑白名单功能"),te.push(`group_list_type = "${V(Z.chat.group_list_type,ta.chat.group_list_type)}" # 群组名单类型可选为whitelist, blacklist`),te.push(`group_list = [${Z.chat.group_list.join(", ")}] # 群组名单`),te.push("# 当group_list_type为whitelist时只有群组名单中的群组可以聊天"),te.push("# 当group_list_type为blacklist时群组名单中的任何群组无法聊天"),te.push(`private_list_type = "${V(Z.chat.private_list_type,ta.chat.private_list_type)}" # 私聊名单类型可选为whitelist, blacklist`),te.push(`private_list = [${Z.chat.private_list.join(", ")}] # 私聊名单`),te.push("# 当private_list_type为whitelist时只有私聊名单中的用户可以聊天"),te.push("# 当private_list_type为blacklist时私聊名单中的任何用户无法聊天"),te.push(`ban_user_id = [${Z.chat.ban_user_id.join(", ")}] # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)`),te.push(`ban_qq_bot = ${Z.chat.ban_qq_bot} # 是否屏蔽QQ官方机器人`),te.push(`enable_poke = ${Z.chat.enable_poke} # 是否启用戳一戳功能`),te.push(""),te.push("[voice] # 发送语音设置"),te.push(`use_tts = ${Z.voice.use_tts} # 是否使用tts语音请确保你配置了tts并有对应的adapter`),te.push(""),te.push("[debug]"),te.push(`level = "${V(Z.debug.level,ta.debug.level)}" # 日志等级DEBUG, INFO, WARNING, ERROR, CRITICAL`),te.join(`
`)},xe=Z=>{const te=Z.target.files?.[0];if(!te)return;const V=new FileReader;V.onload=P=>{try{const ke=P.target?.result,He=me(ke);d(He),x(te.name),E({title:"上传成功",description:`已加载配置文件:${te.name}`})}catch(ke){console.error("解析配置文件失败:",ke),E({title:"解析失败",description:"配置文件格式错误,请检查文件内容",variant:"destructive"})}},V.readAsText(te)},we=()=>{if(!r)return;const Z=ce(r),te=new Blob([Z],{type:"text/plain;charset=utf-8"}),V=URL.createObjectURL(te),P=document.createElement("a");P.href=V,P.download=m||"config.toml",document.body.appendChild(P),P.click(),document.body.removeChild(P),URL.revokeObjectURL(V),E({title:"下载成功",description:"配置文件已下载,请手动覆盖并重启适配器"})},oe=()=>{d(JSON.parse(JSON.stringify(ta))),x("config.toml"),E({title:"已加载默认配置",description:"可以开始编辑配置"})};return e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦适配器配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理麦麦的 QQ 适配器的配置文件"})]})}),e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg border border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-400",children:[e.jsx(Mt,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:"适配器配置保存之后使用 WebUI 的重启功能适配器并不会重启,需要手动重启适配器。"})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"工作模式"}),e.jsx(st,{children:"选择配置文件的管理方式"})]}),e.jsxs(ps,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 md:gap-4",children:[e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="preset"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>O("preset"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(tn,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"预设模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"使用预设的部署配置"})]})]})}),e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="upload"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>O("upload"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(dr,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"上传文件模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"上传配置文件,编辑后下载并手动覆盖"})]})]})}),e.jsx("div",{className:`border-2 rounded-lg p-3 md:p-4 cursor-pointer transition-all ${n==="path"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>O("path"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(xy,{className:"h-4 w-4 md:h-5 md:w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm md:text-base",children:"指定路径模式"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-1 line-clamp-2",children:"指定配置文件路径,自动加载和保存"})]})]})})]}),n==="preset"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsx(C,{className:"text-sm md:text-base",children:"选择部署方式"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(Du).map(([Z,te])=>{const V=te.icon,P=g===Z;return e.jsx("div",{className:`border-2 rounded-lg p-3 cursor-pointer transition-all ${P?"border-primary bg-primary/5":"border-muted hover:border-primary/50"}`,onClick:()=>{N(Z),ve(Z)},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(V,{className:"h-5 w-5 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"font-semibold text-sm",children:te.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:te.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:te.path})]})]})},Z)})})]}),n==="path"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"config-path",className:"text-sm md:text-base",children:"配置文件路径"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(ie,{id:"config-path",value:f,onChange:Z=>fe(Z.target.value),placeholder:"例: C:\\Adapter\\config.toml",className:`text-sm ${j?"border-destructive":""}`}),j&&e.jsx("p",{className:"text-xs text-destructive",children:j})]}),e.jsx(S,{onClick:()=>Ne(f),disabled:_||!f||!!j,className:"w-full sm:w-auto",children:_?e.jsxs(e.Fragment,{children:[e.jsx(zt,{className:"h-4 w-4 animate-spin mr-2"}),e.jsx("span",{className:"sm:hidden",children:"加载中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sm:hidden",children:"加载配置"}),e.jsx("span",{className:"hidden sm:inline",children:"加载"})]})})]})]}),e.jsxs("details",{className:"rounded-lg bg-muted/50 p-3 group",children:[e.jsxs("summary",{className:"text-xs font-medium cursor-pointer select-none list-none flex items-center justify-between",children:[e.jsx("span",{children:"路径格式说明"}),e.jsx("svg",{className:"h-4 w-4 transition-transform group-open:rotate-180",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsxs("div",{className:"mt-2 space-y-2 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-[10px] md:text-xs whitespace-nowrap",children:"Windows"})}),e.jsxs("div",{className:"pl-2 space-y-0.5 text-[10px] md:text-xs break-all",children:[e.jsx("div",{children:"C:\\Adapter\\config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"D:\\MaiBot\\adapter\\config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"\\\\server\\share\\config.toml"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-mono bg-background px-1.5 py-0.5 rounded text-[10px] md:text-xs whitespace-nowrap",children:"Linux"})}),e.jsxs("div",{className:"pl-2 space-y-0.5 text-[10px] md:text-xs break-all",children:[e.jsx("div",{children:"/opt/adapter/config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"/home/user/adapter/config.toml"}),e.jsx("div",{className:"hidden sm:block",children:"~/adapter/config.toml"})]})]}),e.jsx("p",{className:"pt-1 border-t text-[10px] md:text-xs",children:"💡 配置会自动保存到指定文件,修改后 1 秒自动保存"})]})]})]})]})]}),e.jsxs(It,{children:[e.jsx(Oa,{className:"h-4 w-4"}),e.jsx(Yt,{children:n==="preset"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"预设模式:"}),"选择预设的部署方式,配置会自动加载,修改后 1 秒自动保存",y&&" (正在保存...)"]}):n==="upload"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"上传文件模式:"}),"上传配置文件 → 在线编辑 → 下载文件 → 手动覆盖并重启适配器"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"指定路径模式:"}),"指定配置文件路径后,配置会自动加载,修改后 1 秒自动保存",y&&" (正在保存...)"]})})]}),n==="upload"&&!r&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsx("input",{ref:$,type:"file",accept:".toml",className:"hidden",onChange:xe}),e.jsxs(S,{onClick:()=>$.current?.click(),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(dr,{className:"mr-2 h-4 w-4"}),"上传配置"]}),e.jsxs(S,{onClick:oe,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(_a,{className:"mr-2 h-4 w-4"}),"使用默认配置"]})]}),n==="upload"&&r&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(S,{onClick:we,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(nl,{className:"mr-2 h-4 w-4"}),"下载配置"]})}),(n==="preset"||n==="path")&&r&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(S,{onClick:ye,size:"sm",disabled:y||!!j,className:"w-full sm:w-auto",children:[e.jsx(gr,{className:"mr-2 h-4 w-4"}),y?"保存中...":"立即保存"]}),e.jsxs(S,{onClick:Se,size:"sm",variant:"outline",disabled:_,className:"w-full sm:w-auto",children:[e.jsx(zt,{className:`mr-2 h-4 w-4 ${_?"animate-spin":""}`}),"刷新"]}),n==="path"&&e.jsxs(S,{onClick:ee,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(Ze,{className:"mr-2 h-4 w-4"}),"清空路径"]})]}),r?e.jsxs(Ca,{defaultValue:"napcat",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0",children:e.jsxs(pa,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5",children:[e.jsxs(es,{value:"napcat",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"Napcat 连接"}),e.jsx("span",{className:"sm:hidden",children:"Napcat"})]}),e.jsxs(es,{value:"maibot",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"麦麦连接"}),e.jsx("span",{className:"sm:hidden",children:"麦麦"})]}),e.jsxs(es,{value:"chat",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"聊天控制"}),e.jsx("span",{className:"sm:hidden",children:"聊天"})]}),e.jsxs(es,{value:"voice",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:[e.jsx("span",{className:"hidden sm:inline",children:"语音设置"}),e.jsx("span",{className:"sm:hidden",children:"语音"})]}),e.jsx(es,{value:"debug",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:"调试"})]})}),e.jsx(ws,{value:"napcat",className:"space-y-4",children:e.jsx(g1,{config:r,onChange:Z=>{d(Z),je(Z)}})}),e.jsx(ws,{value:"maibot",className:"space-y-4",children:e.jsx(j1,{config:r,onChange:Z=>{d(Z),je(Z)}})}),e.jsx(ws,{value:"chat",className:"space-y-4",children:e.jsx(v1,{config:r,onChange:Z=>{d(Z),je(Z)}})}),e.jsx(ws,{value:"voice",className:"space-y-4",children:e.jsx(b1,{config:r,onChange:Z=>{d(Z),je(Z)}})}),e.jsx(ws,{value:"debug",className:"space-y-4",children:e.jsx(N1,{config:r,onChange:Z=>{d(Z),je(Z)}})})]}):e.jsx("div",{className:"rounded-lg border bg-card p-6 md:p-12",children:e.jsxs("div",{className:"text-center space-y-3 md:space-y-4",children:[e.jsx(_a,{className:"h-12 w-12 md:h-16 md:w-16 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold",children:"尚未加载配置"}),e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground mt-2 px-4",children:n==="preset"?"请选择预设的部署方式":n==="upload"?"请上传现有配置文件,或使用默认配置开始编辑":"请指定配置文件路径并点击加载按钮"})]})]})}),e.jsx(ms,{open:D,onOpenChange:U,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认切换模式"}),e.jsxs(rs,{children:["切换模式将清空当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-destructive font-medium",children:"请确保已保存重要配置"})]})]}),e.jsxs(ns,{children:[e.jsx(os,{onClick:()=>{U(!1),I(null)},children:"取消"}),e.jsx(cs,{onClick:H,children:"确认切换"})]})]})}),e.jsx(ms,{open:Q,onOpenChange:R,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认清空路径"}),e.jsxs(rs,{children:["清空路径将清除当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"此操作不会删除配置文件,只是清除界面中的配置"})]})]}),e.jsxs(ns,{children:[e.jsx(os,{onClick:()=>R(!1),children:"取消"}),e.jsx(cs,{onClick:X,className:"bg-destructive hover:bg-destructive/90",children:"确认清空"})]})]})})]})})}function g1({config:n,onChange:i}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"Napcat WebSocket 服务设置"}),e.jsxs("div",{className:"grid gap-3 md:gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"napcat-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ie,{id:"napcat-host",value:n.napcat_server.host,onChange:r=>i({...n,napcat_server:{...n.napcat_server,host:r.target.value}}),placeholder:"localhost",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的主机地址"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"napcat-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ie,{id:"napcat-port",type:"number",value:n.napcat_server.port||"",onChange:r=>i({...n,napcat_server:{...n.napcat_server,port:r.target.value?parseInt(r.target.value):0}}),placeholder:"8095",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的端口(留空使用默认值 8095"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"napcat-token",className:"text-sm md:text-base",children:"访问令牌Token"}),e.jsx(ie,{id:"napcat-token",type:"password",value:n.napcat_server.token,onChange:r=>i({...n,napcat_server:{...n.napcat_server,token:r.target.value}}),placeholder:"留空表示无需令牌",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Napcat 设定的访问令牌,若无则留空"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"napcat-heartbeat",className:"text-sm md:text-base",children:"心跳间隔(秒)"}),e.jsx(ie,{id:"napcat-heartbeat",type:"number",value:n.napcat_server.heartbeat_interval||"",onChange:r=>i({...n,napcat_server:{...n.napcat_server,heartbeat_interval:r.target.value?parseInt(r.target.value):0}}),placeholder:"30",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"与 Napcat 设置的心跳间隔保持一致(留空使用默认值 30"})]})]})]})})}function j1({config:n,onChange:i}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"麦麦 WebSocket 服务设置"}),e.jsxs("div",{className:"grid gap-3 md:gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"maibot-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ie,{id:"maibot-host",value:n.maibot_server.host,onChange:r=>i({...n,maibot_server:{...n.maibot_server,host:r.target.value}}),placeholder:"localhost",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦在 .env 文件中设置的 HOST 字段"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"maibot-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ie,{id:"maibot-port",type:"number",value:n.maibot_server.port||"",onChange:r=>i({...n,maibot_server:{...n.maibot_server,port:r.target.value?parseInt(r.target.value):0}}),placeholder:"8000",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦在 .env 文件中设置的 PORT 字段(留空使用默认值 8000"})]})]})]})})}function v1({config:n,onChange:i}){const r=x=>{const f={...n};x==="group"?f.chat.group_list=[...f.chat.group_list,0]:x==="private"?f.chat.private_list=[...f.chat.private_list,0]:f.chat.ban_user_id=[...f.chat.ban_user_id,0],i(f)},d=(x,f)=>{const p={...n};x==="group"?p.chat.group_list=p.chat.group_list.filter((g,N)=>N!==f):x==="private"?p.chat.private_list=p.chat.private_list.filter((g,N)=>N!==f):p.chat.ban_user_id=p.chat.ban_user_id.filter((g,N)=>N!==f),i(p)},m=(x,f,p)=>{const g={...n};x==="group"?g.chat.group_list[f]=p:x==="private"?g.chat.private_list[f]=p:g.chat.ban_user_id[f]=p,i(g)};return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"聊天黑白名单功能"}),e.jsxs("div",{className:"grid gap-4 md:gap-6",children:[e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-sm md:text-base",children:"群组名单类型"}),e.jsxs(Re,{value:n.chat.group_list_type,onValueChange:x=>i({...n,chat:{...n.chat,group_list_type:x}}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(le,{value:"blacklist",children:"黑名单(名单内禁止聊天)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsx(C,{className:"text-sm md:text-base",children:"群组列表"}),e.jsxs(S,{onClick:()=>r("group"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(_a,{className:"mr-1 h-4 w-4"}),"添加群号"]})]}),n.chat.group_list.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{type:"number",value:x,onChange:p=>m("group",f,parseInt(p.target.value)||0),placeholder:"输入群号",className:"text-sm md:text-base"}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除群号 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>d("group",f),children:"删除"})]})]})]})]},f)),n.chat.group_list.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无群组"})]})]}),e.jsxs("div",{className:"space-y-3 md:space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-sm md:text-base",children:"私聊名单类型"}),e.jsxs(Re,{value:n.chat.private_list_type,onValueChange:x=>i({...n,chat:{...n.chat,private_list_type:x}}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(le,{value:"blacklist",children:"黑名单(名单内禁止聊天)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsx(C,{className:"text-sm md:text-base",children:"私聊列表"}),e.jsxs(S,{onClick:()=>r("private"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(_a,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),n.chat.private_list.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{type:"number",value:x,onChange:p=>m("private",f,parseInt(p.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>d("private",f),children:"删除"})]})]})]})]},f)),n.chat.private_list.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无用户"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-sm md:text-base",children:"全局禁止名单"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"名单中的用户无法进行任何聊天"})]}),e.jsxs(S,{onClick:()=>r("ban"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(_a,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),n.chat.ban_user_id.map((x,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{type:"number",value:x,onChange:p=>m("ban",f,parseInt(p.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(ms,{children:[e.jsx(tt,{asChild:!0,children:e.jsx(S,{size:"icon",variant:"outline",children:e.jsx(Ze,{className:"h-4 w-4"})})}),e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:["确定要从全局禁止名单中删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>d("ban",f),children:"删除"})]})]})]})]},f)),n.chat.ban_user_id.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无禁止用户"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-sm md:text-base",children:"屏蔽QQ官方机器人"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否屏蔽来自QQ官方机器人的消息"})]}),e.jsx(Ve,{checked:n.chat.ban_qq_bot,onCheckedChange:x=>i({...n,chat:{...n.chat,ban_qq_bot:x}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-sm md:text-base",children:"启用戳一戳功能"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否响应戳一戳消息"})]}),e.jsx(Ve,{checked:n.chat.enable_poke,onCheckedChange:x=>i({...n,chat:{...n.chat,enable_poke:x}})})]})]})]})})}function b1({config:n,onChange:i}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"发送语音设置"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-sm md:text-base",children:"使用 TTS 语音"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"请确保已配置 TTS 并有对应的适配器"})]}),e.jsx(Ve,{checked:n.voice.use_tts,onCheckedChange:r=>i({...n,voice:{use_tts:r}})})]})]})})}function N1({config:n,onChange:i}){return e.jsx("div",{className:"rounded-lg border bg-card p-4 md:p-6 space-y-4 md:space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base md:text-lg font-semibold mb-3 md:mb-4",children:"调试设置"}),e.jsx("div",{className:"grid gap-3 md:gap-4",children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{className:"text-sm md:text-base",children:"日志等级"}),e.jsxs(Re,{value:n.debug.level,onValueChange:r=>i({...n,debug:{level:r}}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"DEBUG",children:"DEBUG调试"}),e.jsx(le,{value:"INFO",children:"INFO信息"}),e.jsx(le,{value:"WARNING",children:"WARNING警告"}),e.jsx(le,{value:"ERROR",children:"ERROR错误"}),e.jsx(le,{value:"CRITICAL",children:"CRITICAL严重"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置适配器的日志输出等级"})]})})]})})}const y1=["defaultChecked","defaultValue","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML","accessKey","className","contentEditable","contextMenu","dir","draggable","hidden","id","lang","placeholder","slot","spellCheck","style","tabIndex","title","translate","radioGroup","role","about","datatype","inlist","prefix","property","resource","typeof","vocab","autoCapitalize","autoCorrect","autoSave","color","itemProp","itemScope","itemType","itemID","itemRef","results","security","unselectable","inputMode","is","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],w1=/^(aria-|data-)/,Xg=n=>Object.fromEntries(Object.entries(n).filter(([i])=>w1.test(i)||y1.includes(i)));function _1(n,i){const r=Xg(n);return Object.keys(n).some(d=>!Object.hasOwn(r,d)&&n[d]!==i[d])}class S1 extends u.Component{container;plugin;componentDidMount(){this.installPlugin()}componentDidUpdate(i){if(i.uppy!==this.props.uppy)this.uninstallPlugin(i),this.installPlugin();else if(_1(this.props,i)){const{uppy:r,...d}={...this.props,target:this.container};this.plugin.setOptions(d)}}componentWillUnmount(){this.uninstallPlugin()}installPlugin(){const{uppy:i,...r}={id:"Dashboard",...this.props,inline:!0,target:this.container};i.use(Ky,r),this.plugin=i.getPlugin(r.id)}uninstallPlugin(i=this.props){const{uppy:r}=i;r.removePlugin(this.plugin)}render(){return u.createElement("div",{className:"uppy-Container",ref:i=>{this.container=i},...Xg(this.props)})}}function C1({src:n,alt:i="表情包",className:r,maxRetries:d=5,retryInterval:m=1500}){const[x,f]=u.useState("loading"),[p,g]=u.useState(0),[N,j]=u.useState(null),w=u.useCallback(async()=>{try{const y=await fetch(n,{credentials:"include"});if(y.status===202){f("generating"),p<d?setTimeout(()=>{g(L=>L+1)},m):f("error");return}if(!y.ok){f("error");return}const k=await y.blob(),_=URL.createObjectURL(k);j(_),f("loaded")}catch(y){console.error("加载缩略图失败:",y),f("error")}},[n,p,d,m]);return u.useEffect(()=>{f("loading"),g(0),j(null)},[n]),u.useEffect(()=>{w()},[w]),u.useEffect(()=>()=>{N&&URL.revokeObjectURL(N)},[N]),x==="loading"||x==="generating"?e.jsx(Eg,{className:q("w-full h-full",r)}):x==="error"||!N?e.jsx("div",{className:q("w-full h-full flex items-center justify-center bg-muted",r),children:e.jsx(Ng,{className:"h-8 w-8 text-muted-foreground"})}):e.jsx("img",{src:N,alt:i,className:q("w-full h-full object-contain",r)})}function Kg({content:n,className:i=""}){return e.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none ${i}`,children:e.jsx(Py,{remarkPlugins:[Wy,e0],rehypePlugins:[Zy],components:{code({inline:r,className:d,children:m,...x}){return r?e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",...x,children:m}):e.jsx("code",{className:`${d} block bg-muted p-4 rounded-lg overflow-x-auto`,...x,children:m})},table({children:r,...d}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"border-collapse border border-border",...d,children:r})})},th({children:r,...d}){return e.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-semibold",...d,children:r})},td({children:r,...d}){return e.jsx("td",{className:"border border-border px-4 py-2",...d,children:r})},a({children:r,...d}){return e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...d,children:r})},blockquote({children:r,...d}){return e.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",...d,children:r})},h1({children:r,...d}){return e.jsx("h1",{className:"text-3xl font-bold mt-6 mb-4",...d,children:r})},h2({children:r,...d}){return e.jsx("h2",{className:"text-2xl font-bold mt-5 mb-3",...d,children:r})},h3({children:r,...d}){return e.jsx("h3",{className:"text-xl font-bold mt-4 mb-2",...d,children:r})},h4({children:r,...d}){return e.jsx("h4",{className:"text-lg font-semibold mt-3 mb-2",...d,children:r})},ul({children:r,...d}){return e.jsx("ul",{className:"list-disc list-inside space-y-1 my-2",...d,children:r})},ol({children:r,...d}){return e.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2",...d,children:r})},p({children:r,...d}){return e.jsx("p",{className:"my-2 leading-relaxed",...d,children:r})},hr({...r}){return e.jsx("hr",{className:"my-4 border-border",...r})}},children:n})})}function k1({children:n,className:i}){return e.jsx(Kg,{content:n,className:i})}const ga="/api/webui/emoji";async function T1(n){const i=new URLSearchParams;n.page&&i.append("page",n.page.toString()),n.page_size&&i.append("page_size",n.page_size.toString()),n.search&&i.append("search",n.search),n.is_registered!==void 0&&i.append("is_registered",n.is_registered.toString()),n.is_banned!==void 0&&i.append("is_banned",n.is_banned.toString()),n.format&&i.append("format",n.format),n.sort_by&&i.append("sort_by",n.sort_by),n.sort_order&&i.append("sort_order",n.sort_order);const r=await _e(`${ga}/list?${i}`,{});if(!r.ok)throw new Error(`获取表情包列表失败: ${r.statusText}`);return r.json()}async function E1(n){const i=await _e(`${ga}/${n}`,{});if(!i.ok)throw new Error(`获取表情包详情失败: ${i.statusText}`);return i.json()}async function z1(n,i){const r=await _e(`${ga}/${n}`,{method:"PATCH",body:JSON.stringify(i)});if(!r.ok)throw new Error(`更新表情包失败: ${r.statusText}`);return r.json()}async function M1(n){const i=await _e(`${ga}/${n}`,{method:"DELETE"});if(!i.ok)throw new Error(`删除表情包失败: ${i.statusText}`);return i.json()}async function A1(){const n=await _e(`${ga}/stats/summary`,{});if(!n.ok)throw new Error(`获取统计数据失败: ${n.statusText}`);return n.json()}async function D1(n){const i=await _e(`${ga}/${n}/register`,{method:"POST"});if(!i.ok)throw new Error(`注册表情包失败: ${i.statusText}`);return i.json()}async function O1(n){const i=await _e(`${ga}/${n}/ban`,{method:"POST"});if(!i.ok)throw new Error(`封禁表情包失败: ${i.statusText}`);return i.json()}function R1(n,i=!1){return i?`${ga}/${n}/thumbnail?original=true`:`${ga}/${n}/thumbnail`}function L1(n){return`${ga}/${n}/thumbnail?original=true`}async function U1(n){const i=await _e(`${ga}/batch/delete`,{method:"POST",body:JSON.stringify({emoji_ids:n})});if(!i.ok){const r=await i.json();throw new Error(r.detail||"批量删除失败")}return i.json()}function B1(){return`${ga}/upload`}function H1(){const[n,i]=u.useState([]),[r,d]=u.useState(null),[m,x]=u.useState(!1),[f,p]=u.useState(1),[g,N]=u.useState(0),[j,w]=u.useState(20),[y,k]=u.useState("all"),[_,L]=u.useState("all"),[D,U]=u.useState("all"),[Q,R]=u.useState("usage_count"),[z,I]=u.useState("desc"),[$,E]=u.useState(null),[M,se]=u.useState(!1),[fe,ve]=u.useState(!1),[Ne,je]=u.useState(!1),[ye,Se]=u.useState(new Set),[O,G]=u.useState(!1),[H,ee]=u.useState(""),[v,X]=u.useState("medium"),[me,ce]=u.useState(!1),{toast:xe}=Bs(),we=u.useCallback(async()=>{try{x(!0);const de=await T1({page:f,page_size:j,is_registered:y==="all"?void 0:y==="registered",is_banned:_==="all"?void 0:_==="banned",format:D==="all"?void 0:D,sort_by:Q,sort_order:z});i(de.data),N(de.total)}catch(de){const qe=de instanceof Error?de.message:"加载表情包列表失败";xe({title:"错误",description:qe,variant:"destructive"})}finally{x(!1)}},[f,j,y,_,D,Q,z,xe]),oe=async()=>{try{const de=await A1();d(de.data)}catch(de){console.error("加载统计数据失败:",de)}};u.useEffect(()=>{we()},[we]),u.useEffect(()=>{oe()},[]);const Z=async de=>{try{const qe=await E1(de.id);E(qe.data),se(!0)}catch(qe){const Ie=qe instanceof Error?qe.message:"加载详情失败";xe({title:"错误",description:Ie,variant:"destructive"})}},te=de=>{E(de),ve(!0)},V=de=>{E(de),je(!0)},P=async()=>{if($)try{await M1($.id),xe({title:"成功",description:"表情包已删除"}),je(!1),E(null),we(),oe()}catch(de){const qe=de instanceof Error?de.message:"删除失败";xe({title:"错误",description:qe,variant:"destructive"})}},ke=async de=>{try{await D1(de.id),xe({title:"成功",description:"表情包已注册"}),we(),oe()}catch(qe){const Ie=qe instanceof Error?qe.message:"注册失败";xe({title:"错误",description:Ie,variant:"destructive"})}},He=async de=>{try{await O1(de.id),xe({title:"成功",description:"表情包已封禁"}),we(),oe()}catch(qe){const Ie=qe instanceof Error?qe.message:"封禁失败";xe({title:"错误",description:Ie,variant:"destructive"})}},pe=de=>{const qe=new Set(ye);qe.has(de)?qe.delete(de):qe.add(de),Se(qe)},Te=async()=>{try{const de=await U1(Array.from(ye));xe({title:"批量删除完成",description:de.message}),Se(new Set),G(!1),we(),oe()}catch(de){xe({title:"批量删除失败",description:de instanceof Error?de.message:"批量删除失败",variant:"destructive"})}},Qs=()=>{const de=parseInt(H),qe=Math.ceil(g/j);de>=1&&de<=qe?(p(de),ee("")):xe({title:"无效的页码",description:`请输入1-${qe}之间的页码`,variant:"destructive"})},vt=r?.formats?Object.keys(r.formats):[];return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-4 sm:mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"表情包管理"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"管理麦麦的表情包资源"})]}),e.jsxs(S,{onClick:()=>ce(!0),className:"gap-2",children:[e.jsx(dr,{className:"h-4 w-4"}),"上传表情包"]})]}),e.jsx(Ke,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[r&&e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(Qe,{children:e.jsxs(ss,{className:"pb-2",children:[e.jsx(st,{children:"总数"}),e.jsx(ts,{className:"text-2xl",children:r.total})]})}),e.jsx(Qe,{children:e.jsxs(ss,{className:"pb-2",children:[e.jsx(st,{children:"已注册"}),e.jsx(ts,{className:"text-2xl text-green-600",children:r.registered})]})}),e.jsx(Qe,{children:e.jsxs(ss,{className:"pb-2",children:[e.jsx(st,{children:"已封禁"}),e.jsx(ts,{className:"text-2xl text-red-600",children:r.banned})]})}),e.jsx(Qe,{children:e.jsxs(ss,{className:"pb-2",children:[e.jsx(st,{children:"未注册"}),e.jsx(ts,{className:"text-2xl text-gray-600",children:r.unregistered})]})})]}),e.jsxs(Qe,{children:[e.jsx(ss,{children:e.jsxs(ts,{className:"flex items-center gap-2",children:[e.jsx(Lu,{className:"h-5 w-5"}),"筛选和排序"]})}),e.jsxs(ps,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"排序方式"}),e.jsxs(Re,{value:`${Q}-${z}`,onValueChange:de=>{const[qe,Ie]=de.split("-");R(qe),I(Ie),p(1)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"usage_count-desc",children:"使用次数 (多→少)"}),e.jsx(le,{value:"usage_count-asc",children:"使用次数 (少→多)"}),e.jsx(le,{value:"register_time-desc",children:"注册时间 (新→旧)"}),e.jsx(le,{value:"register_time-asc",children:"注册时间 (旧→新)"}),e.jsx(le,{value:"record_time-desc",children:"记录时间 (新→旧)"}),e.jsx(le,{value:"record_time-asc",children:"记录时间 (旧→新)"}),e.jsx(le,{value:"last_used_time-desc",children:"最后使用 (新→旧)"}),e.jsx(le,{value:"last_used_time-asc",children:"最后使用 (旧→新)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"注册状态"}),e.jsxs(Re,{value:y,onValueChange:de=>{k(de),p(1)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部"}),e.jsx(le,{value:"registered",children:"已注册"}),e.jsx(le,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"封禁状态"}),e.jsxs(Re,{value:_,onValueChange:de=>{L(de),p(1)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部"}),e.jsx(le,{value:"banned",children:"已封禁"}),e.jsx(le,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"格式"}),e.jsxs(Re,{value:D,onValueChange:de=>{U(de),p(1)},children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部"}),vt.map(de=>e.jsxs(le,{value:de,children:[de.toUpperCase()," (",r?.formats[de],")"]},de))]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[ye.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",ye.size," 个表情包"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{className:"text-sm whitespace-nowrap",children:"卡片大小"}),e.jsxs(Re,{value:v,onValueChange:de=>X(de),children:[e.jsx(De,{className:"w-24",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"small",children:"小"}),e.jsx(le,{value:"medium",children:"中"}),e.jsx(le,{value:"large",children:"大"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{htmlFor:"emoji-page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Re,{value:j.toString(),onValueChange:de=>{w(parseInt(de)),p(1),Se(new Set)},children:[e.jsx(De,{id:"emoji-page-size",className:"w-20",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"40",children:"40"}),e.jsx(le,{value:"60",children:"60"}),e.jsx(le,{value:"100",children:"100"})]})]}),ye.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>Se(new Set),children:"取消选择"}),e.jsxs(S,{variant:"destructive",size:"sm",onClick:()=>G(!0),children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(S,{variant:"outline",size:"sm",onClick:we,disabled:m,children:[e.jsx(zt,{className:`h-4 w-4 mr-2 ${m?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"表情包列表"}),e.jsxs(st,{children:["共 ",g," 个表情包,当前第 ",f," 页"]})]}),e.jsxs(ps,{children:[n.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"暂无数据"}):e.jsx("div",{className:`grid gap-3 ${v==="small"?"grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10":v==="medium"?"grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8":"grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5"}`,children:n.map(de=>e.jsxs("div",{className:`group relative rounded-lg border bg-card overflow-hidden hover:ring-2 hover:ring-primary transition-all cursor-pointer ${ye.has(de.id)?"ring-2 ring-primary bg-primary/5":""}`,onClick:()=>pe(de.id),children:[e.jsx("div",{className:`absolute top-1 left-1 z-10 transition-opacity ${ye.has(de.id)?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:e.jsx("div",{className:`w-5 h-5 rounded-full border-2 flex items-center justify-center ${ye.has(de.id)?"bg-primary border-primary text-primary-foreground":"bg-background/80 border-muted-foreground/50"}`,children:ye.has(de.id)&&e.jsx(aa,{className:"h-3 w-3"})})}),e.jsxs("div",{className:"absolute top-1 right-1 z-10 flex flex-col gap-0.5",children:[de.is_registered&&e.jsx(Fe,{variant:"default",className:"bg-green-600 text-[10px] px-1 py-0",children:"已注册"}),de.is_banned&&e.jsx(Fe,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"已封禁"})]}),e.jsx("div",{className:`aspect-square bg-muted flex items-center justify-center overflow-hidden ${v==="small"?"p-1":v==="medium"?"p-2":"p-3"}`,children:e.jsx(C1,{src:R1(de.id),alt:"表情包"})}),e.jsxs("div",{className:`border-t bg-card ${v==="small"?"p-1":"p-2"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1 text-xs text-muted-foreground mb-1",children:[e.jsx(Fe,{variant:"outline",className:"text-[10px] px-1 py-0",children:de.format.toUpperCase()}),e.jsxs("span",{className:"font-mono",children:[de.usage_count,"次"]})]}),e.jsxs("div",{className:`flex gap-1 justify-center opacity-0 group-hover:opacity-100 transition-opacity ${v==="small"?"flex-wrap":""}`,children:[e.jsx(S,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:qe=>{qe.stopPropagation(),te(de)},title:"编辑",children:e.jsx(ln,{className:"h-3 w-3"})}),e.jsx(S,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:qe=>{qe.stopPropagation(),Z(de)},title:"详情",children:e.jsx(Oa,{className:"h-3 w-3"})}),!de.is_registered&&e.jsx(S,{variant:"ghost",size:"icon",className:"h-6 w-6 text-green-600 hover:text-green-700",onClick:qe=>{qe.stopPropagation(),ke(de)},title:"注册",children:e.jsx(aa,{className:"h-3 w-3"})}),!de.is_banned&&e.jsx(S,{variant:"ghost",size:"icon",className:"h-6 w-6 text-orange-600 hover:text-orange-700",onClick:qe=>{qe.stopPropagation(),He(de)},title:"封禁",children:e.jsx(hy,{className:"h-3 w-3"})}),e.jsx(S,{variant:"ghost",size:"icon",className:"h-6 w-6 text-red-600 hover:text-red-700",onClick:qe=>{qe.stopPropagation(),V(de)},title:"删除",children:e.jsx(Ze,{className:"h-3 w-3"})})]})]})]},de.id))}),g>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 mt-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["显示 ",(f-1)*j+1," 到"," ",Math.min(f*j,g)," 条,共 ",g," 条"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(de=>Math.max(1,de-1)),disabled:f===1,children:[e.jsx(rl,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{type:"number",value:H,onChange:de=>ee(de.target.value),onKeyDown:de=>de.key==="Enter"&&Qs(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(g/j)}),e.jsx(S,{variant:"outline",size:"sm",onClick:Qs,disabled:!H,className:"h-8",children:"跳转"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(de=>de+1),disabled:f>=Math.ceil(g/j),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Ua,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(Math.ceil(g/j)),disabled:f>=Math.ceil(g/j),className:"hidden sm:flex",children:e.jsx(li,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(q1,{emoji:$,open:M,onOpenChange:se}),e.jsx(G1,{emoji:$,open:fe,onOpenChange:ve,onSuccess:()=>{we(),oe()}}),e.jsx(F1,{open:me,onOpenChange:ce,onSuccess:()=>{we(),oe()}})]})}),e.jsx(ms,{open:O,onOpenChange:G,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认批量删除"}),e.jsxs(rs,{children:["你确定要删除选中的 ",ye.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:Te,children:"确认删除"})]})]})}),e.jsx(Gs,{open:Ne,onOpenChange:je,children:e.jsxs(Rs,{children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"确认删除"}),e.jsx(Ps,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>je(!1),children:"取消"}),e.jsx(S,{variant:"destructive",onClick:P,children:"删除"})]})]})})]})}function q1({emoji:n,open:i,onOpenChange:r}){if(!n)return null;const d=m=>m?new Date(m*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(Ls,{children:e.jsx(Us,{children:"表情包详情"})}),e.jsx(Ke,{className:"max-h-[calc(90vh-8rem)] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-32 h-32 bg-muted rounded-lg flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:L1(n.id),alt:n.description||"表情包",className:"w-full h-full object-cover",onError:m=>{const x=m.target;x.style.display="none";const f=x.parentElement;f&&(f.innerHTML='<svg class="h-16 w-16 text-muted-foreground" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>')}})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"ID"}),e.jsx("div",{className:"mt-1 font-mono",children:n.id})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(Fe,{variant:"outline",children:n.format.toUpperCase()})})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"文件路径"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:n.full_path})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"哈希值"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:n.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"描述"}),n.description?e.jsx("div",{className:"mt-1 rounded-lg border bg-muted/50 p-3",children:e.jsx(k1,{className:"prose-sm",children:n.description})}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"-"})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"情绪"}),e.jsx("div",{className:"mt-1",children:n.emotion?e.jsx("span",{className:"text-sm",children:n.emotion}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"-"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[n.is_registered&&e.jsx(Fe,{variant:"default",className:"bg-green-600",children:"已注册"}),n.is_banned&&e.jsx(Fe,{variant:"destructive",children:"已封禁"}),!n.is_registered&&!n.is_banned&&e.jsx(Fe,{variant:"outline",children:"未注册"})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"使用次数"}),e.jsx("div",{className:"mt-1 font-mono text-lg",children:n.usage_count})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"记录时间"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.record_time)})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(C,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:d(n.last_used_time)})]})]})})]})})}function G1({emoji:n,open:i,onOpenChange:r,onSuccess:d}){const[m,x]=u.useState(""),[f,p]=u.useState(!1),[g,N]=u.useState(!1),[j,w]=u.useState(!1),{toast:y}=Bs();u.useEffect(()=>{n&&(x(n.emotion||""),p(n.is_registered),N(n.is_banned))},[n]);const k=async()=>{if(n)try{w(!0);const _=m.split(/[,,]/).map(L=>L.trim()).filter(Boolean).join(",");await z1(n.id,{emotion:_||void 0,is_registered:f,is_banned:g}),y({title:"成功",description:"表情包信息已更新"}),r(!1),d()}catch(_){const L=_ instanceof Error?_.message:"保存失败";y({title:"错误",description:L,variant:"destructive"})}finally{w(!1)}};return n?e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"编辑表情包"}),e.jsx(Ps,{children:"修改表情包的情绪和状态信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(C,{children:"情绪"}),e.jsx(Ms,{value:m,onChange:_=>x(_.target.value),placeholder:"输入情绪描述...",rows:2,className:"mt-1"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入情绪相关的文本描述"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ft,{id:"is_registered",checked:f,onCheckedChange:_=>{_===!0?(p(!0),N(!1)):p(!1)}}),e.jsx(C,{htmlFor:"is_registered",className:"cursor-pointer",children:"已注册"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ft,{id:"is_banned",checked:g,onCheckedChange:_=>{_===!0?(N(!0),p(!1)):N(!1)}}),e.jsx(C,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(S,{onClick:k,disabled:j,children:j?"保存中...":"保存"})]})]})}):null}function F1({open:n,onOpenChange:i,onSuccess:r}){const[d,m]=u.useState("select"),[x,f]=u.useState([]),[p,g]=u.useState(null),[N,j]=u.useState(!1),{toast:w}=Bs(),y=u.useMemo(()=>new Jy({id:"emoji-uploader",autoProceed:!1,restrictions:{maxFileSize:10485760,allowedFileTypes:["image/jpeg","image/png","image/gif","image/webp"],maxNumberOfFiles:20},locale:{pluralize:()=>0,strings:{addMoreFiles:"添加更多文件",addingMoreFiles:"正在添加更多文件",allowedFileTypes:"允许的文件类型:%{types}",cancel:"取消",closeModal:"关闭",complete:"完成",connectedToInternet:"已连接到互联网",copyLink:"复制链接",copyLinkToClipboardFallback:"复制下方链接",copyLinkToClipboardSuccess:"链接已复制到剪贴板",dashboardTitle:"选择文件",dashboardWindowTitle:"文件选择窗口(按 ESC 关闭)",done:"完成",dropHereOr:"拖放文件到这里或 %{browse}",dropHint:"将文件拖放到此处",dropPasteFiles:"将文件拖放到这里或 %{browseFiles}",dropPasteFolders:"将文件拖放到这里或 %{browseFolders}",dropPasteBoth:"将文件拖放到这里,%{browseFiles} 或 %{browseFolders}",dropPasteImportFiles:"将文件拖放到这里,%{browseFiles} 或从以下位置导入:",dropPasteImportFolders:"将文件拖放到这里,%{browseFolders} 或从以下位置导入:",dropPasteImportBoth:"将文件拖放到这里,%{browseFiles}%{browseFolders} 或从以下位置导入:",editFile:"编辑文件",editing:"正在编辑 %{file}",emptyFolderAdded:"未从空文件夹添加文件",exceedsSize:"%{file} 超过了最大允许大小 %{size}",failedToUpload:"上传 %{file} 失败",fileSource:"文件来源:%{name}",filesUploadedOfTotal:{0:"已上传 %{complete} / %{smart_count} 个文件",1:"已上传 %{complete} / %{smart_count} 个文件"},filter:"筛选",finishEditingFile:"完成编辑文件",folderAdded:{0:"已从 %{folder} 添加 %{smart_count} 个文件",1:"已从 %{folder} 添加 %{smart_count} 个文件"},generatingThumbnails:"正在生成缩略图...",import:"导入",importFiles:"从以下位置导入文件:",importFrom:"从 %{name} 导入",loading:"加载中...",logOut:"登出",myDevice:"我的设备",noFilesFound:"这里没有文件或文件夹",noInternetConnection:"无网络连接",openFolderNamed:"打开文件夹 %{name}",pause:"暂停",pauseUpload:"暂停上传",paused:"已暂停",poweredBy:"技术支持:%{uppy}",processingXFiles:{0:"正在处理 %{smart_count} 个文件",1:"正在处理 %{smart_count} 个文件"},recording:"录制中",removeFile:"移除文件",resetFilter:"重置筛选",resume:"继续",resumeUpload:"继续上传",retry:"重试",retryUpload:"重试上传",save:"保存",saveChanges:"保存更改",selectFileNamed:"选择文件 %{name}",selectX:{0:"选择 %{smart_count}",1:"选择 %{smart_count}"},smile:"笑一个!",startRecording:"开始录制视频",stopRecording:"停止录制视频",takePicture:"拍照",timedOut:"上传已停滞 %{seconds} 秒,正在中止。",upload:"下一步",uploadComplete:"上传完成",uploadFailed:"上传失败",uploadPaused:"上传已暂停",uploadXFiles:{0:"下一步(%{smart_count} 个文件)",1:"下一步(%{smart_count} 个文件)"},uploadXNewFiles:{0:"下一步(+%{smart_count} 个文件)",1:"下一步(+%{smart_count} 个文件)"},uploading:"正在上传",uploadingXFiles:{0:"正在上传 %{smart_count} 个文件",1:"正在上传 %{smart_count} 个文件"},xFilesSelected:{0:"已选择 %{smart_count} 个文件",1:"已选择 %{smart_count} 个文件"},xMoreFilesAdded:{0:"又添加了 %{smart_count} 个文件",1:"又添加了 %{smart_count} 个文件"},xTimeLeft:"剩余 %{time}",youCanOnlyUploadFileTypes:"您只能上传:%{types}",youCanOnlyUploadX:{0:"您只能上传 %{smart_count} 个文件",1:"您只能上传 %{smart_count} 个文件"},youHaveToAtLeastSelectX:{0:"您至少需要选择 %{smart_count} 个文件",1:"您至少需要选择 %{smart_count} 个文件"},browseFiles:"浏览文件",browseFolders:"浏览文件夹",cancelUpload:"取消上传",addMore:"添加更多",back:"返回",editFileWithFilename:"编辑文件 %{file}"}}}),[]);u.useEffect(()=>{const $=()=>{const E=y.getFiles();if(E.length===0)return;const M=E.map(se=>({id:se.id,name:se.name,previewUrl:se.preview||URL.createObjectURL(se.data),emotion:"",description:"",isRegistered:!0,file:se.data}));f(M),E.length===1?(g(M[0].id),m("edit-single")):m("edit-multiple")};return y.on("upload",$),()=>{y.off("upload",$)}},[y]),u.useEffect(()=>{n||(y.cancelAll(),m("select"),f([]),g(null),j(!1))},[n,y]);const k=u.useCallback(($,E)=>{f(M=>M.map(se=>se.id===$?{...se,...E}:se))},[]),_=u.useCallback($=>$.emotion.trim().length>0,[]),L=u.useMemo(()=>x.length>0&&x.every(_),[x,_]),D=u.useMemo(()=>x.find($=>$.id===p)||null,[x,p]),U=u.useCallback(()=>{(d==="edit-single"||d==="edit-multiple")&&(m("select"),f([]),g(null))},[d]),Q=u.useCallback(async()=>{if(!L){w({title:"请填写必填项",description:"每个表情包的情感标签都是必填的",variant:"destructive"});return}j(!0);const $=localStorage.getItem("access-token")||"";let E=0,M=0;try{for(const se of x){const fe=new FormData;fe.append("file",se.file),fe.append("emotion",se.emotion),fe.append("description",se.description),fe.append("is_registered",se.isRegistered.toString());try{(await fetch(B1(),{method:"POST",headers:{Authorization:`Bearer ${$}`},body:fe})).ok?E++:M++}catch{M++}}M===0?(w({title:"上传成功",description:`成功上传 ${E} 个表情包`}),i(!1),r()):(w({title:"部分上传失败",description:`成功 ${E} 个,失败 ${M}`,variant:"destructive"}),r())}finally{j(!1)}},[L,x,w,i,r]),R=()=>e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"border rounded-lg overflow-hidden w-full",children:e.jsx(S1,{uppy:y,proudlyDisplayPoweredByUppy:!1,hideProgressDetails:!0,height:350,width:"100%",theme:"auto",note:"支持 JPG、PNG、GIF、WebP 格式,最多 20 个文件"})})}),z=()=>{const $=x[0];return $?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(S,{variant:"ghost",size:"sm",onClick:U,children:[e.jsx(Wn,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"编辑表情包信息"})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-shrink-0",children:[e.jsx("div",{className:"w-32 h-32 rounded-lg border overflow-hidden bg-muted flex items-center justify-center",children:e.jsx("img",{src:$.previewUrl,alt:$.name,className:"max-w-full max-h-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate max-w-32",children:$.name})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{htmlFor:"single-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"single-emotion",value:$.emotion,onChange:E=>k($.id,{emotion:E.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:$.emotion.trim()?"":"border-destructive"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于情感匹配,多个标签用逗号分隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"single-description",children:"描述"}),e.jsx(ie,{id:"single-description",value:$.description,onChange:E=>k($.id,{description:E.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ft,{id:"single-is-registered",checked:$.isRegistered,onCheckedChange:E=>k($.id,{isRegistered:E===!0})}),e.jsx(C,{htmlFor:"single-is-registered",className:"cursor-pointer",children:"上传后立即注册(可被麦麦使用)"})]})]})]}),e.jsx(at,{children:e.jsx(S,{onClick:Q,disabled:!L||N,children:N?"上传中...":"上传"})})]}):null},I=()=>{const $=x.filter(_).length,E=x.length;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(S,{variant:"ghost",size:"sm",onClick:U,children:[e.jsx(Wn,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["编辑表情包信息(",$,"/",E," 已完成)"]})]}),e.jsx(Fe,{variant:L?"default":"secondary",children:L?e.jsxs(e.Fragment,{children:[e.jsx(Qt,{className:"h-3 w-3 mr-1"}),"全部完成"]}):e.jsxs(e.Fragment,{children:[e.jsx(il,{className:"h-3 w-3 mr-1"}),"未完成"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ke,{className:"h-[350px] pr-2",children:e.jsx("div",{className:"space-y-2",children:x.map(M=>{const se=_(M),fe=p===M.id;return e.jsxs("div",{onClick:()=>g(M.id),className:`
flex items-center gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all
${fe?"ring-2 ring-primary":""}
${se?"border-green-500 bg-green-50 dark:bg-green-950/20":"border-border hover:border-muted-foreground/50"}
`,children:[e.jsx("div",{className:"w-12 h-12 rounded border overflow-hidden bg-muted flex-shrink-0 flex items-center justify-center",children:e.jsx("img",{src:M.previewUrl,alt:M.name,className:"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:M.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:M.emotion||"未填写情感标签"})]}),se?e.jsx(aa,{className:"h-5 w-5 text-green-500 flex-shrink-0"}):e.jsx("div",{className:"h-5 w-5 rounded-full border-2 border-muted-foreground/30 flex-shrink-0"})]},M.id)})})}),e.jsx("div",{className:"border rounded-lg p-4",children:D?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded border overflow-hidden bg-muted flex items-center justify-center",children:e.jsx("img",{src:D.previewUrl,alt:D.name,className:"max-w-full max-h-full object-contain"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:D.name}),_(D)&&e.jsxs(Fe,{variant:"outline",className:"text-green-600 border-green-600",children:[e.jsx(Qt,{className:"h-3 w-3 mr-1"}),"已完成"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{htmlFor:"multi-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"multi-emotion",value:D.emotion,onChange:M=>k(D.id,{emotion:M.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:D.emotion.trim()?"":"border-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"multi-description",children:"描述"}),e.jsx(ie,{id:"multi-description",value:D.description,onChange:M=>k(D.id,{description:M.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ft,{id:"multi-is-registered",checked:D.isRegistered,onCheckedChange:M=>k(D.id,{isRegistered:M===!0})}),e.jsx(C,{htmlFor:"multi-is-registered",className:"cursor-pointer text-sm",children:"上传后立即注册"})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ng,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"点击左侧卡片编辑"})]})})})]}),e.jsx(at,{children:e.jsx(S,{onClick:Q,disabled:!L||N,children:N?"上传中...":`上传全部 (${E})`})})]})};return e.jsx(Gs,{open:n,onOpenChange:i,children:e.jsxs(Rs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsxs(Ls,{children:[e.jsxs(Us,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"h-5 w-5"}),d==="select"&&"上传表情包 - 选择文件",d==="edit-single"&&"上传表情包 - 填写信息",d==="edit-multiple"&&"上传表情包 - 批量编辑"]}),e.jsxs(Ps,{children:[d==="select"&&"支持 JPG、PNG、GIF、WebP 格式,单个文件最大 10MB可同时上传多个文件",d==="edit-single"&&"请填写表情包的情感标签(必填)和描述",d==="edit-multiple"&&"点击左侧卡片编辑每个表情包的信息,情感标签为必填项"]})]}),e.jsxs("div",{className:"overflow-y-auto pr-1",children:[d==="select"&&R(),d==="edit-single"&&z(),d==="edit-multiple"&&I()]})]})})}const Ll="/api/webui/expression";async function V1(){const n=await _e(`${Ll}/chats`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取聊天列表失败")}return n.json()}async function $1(n){const i=new URLSearchParams;n.page&&i.append("page",n.page.toString()),n.page_size&&i.append("page_size",n.page_size.toString()),n.search&&i.append("search",n.search),n.chat_id&&i.append("chat_id",n.chat_id);const r=await _e(`${Ll}/list?${i}`,{});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取表达方式列表失败")}return r.json()}async function Q1(n){const i=await _e(`${Ll}/${n}`,{});if(!i.ok){const r=await i.json();throw new Error(r.detail||"获取表达方式详情失败")}return i.json()}async function I1(n){const i=await _e(`${Ll}/`,{method:"POST",body:JSON.stringify(n)});if(!i.ok){const r=await i.json();throw new Error(r.detail||"创建表达方式失败")}return i.json()}async function Y1(n,i){const r=await _e(`${Ll}/${n}`,{method:"PATCH",body:JSON.stringify(i)});if(!r.ok){const d=await r.json();throw new Error(d.detail||"更新表达方式失败")}return r.json()}async function X1(n){const i=await _e(`${Ll}/${n}`,{method:"DELETE"});if(!i.ok){const r=await i.json();throw new Error(r.detail||"删除表达方式失败")}return i.json()}async function K1(n){const i=await _e(`${Ll}/batch/delete`,{method:"POST",body:JSON.stringify({ids:n})});if(!i.ok){const r=await i.json();throw new Error(r.detail||"批量删除表达方式失败")}return i.json()}async function J1(){const n=await _e(`${Ll}/stats/summary`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取统计数据失败")}return n.json()}function P1(){const[n,i]=u.useState([]),[r,d]=u.useState(!0),[m,x]=u.useState(0),[f,p]=u.useState(1),[g,N]=u.useState(20),[j,w]=u.useState(""),[y,k]=u.useState(null),[_,L]=u.useState(!1),[D,U]=u.useState(!1),[Q,R]=u.useState(!1),[z,I]=u.useState(null),[$,E]=u.useState(new Set),[M,se]=u.useState(!1),[fe,ve]=u.useState(""),[Ne,je]=u.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),[ye,Se]=u.useState([]),[O,G]=u.useState(new Map),{toast:H}=Bs(),ee=async()=>{try{d(!0);const P=await $1({page:f,page_size:g,search:j||void 0});i(P.data),x(P.total)}catch(P){H({title:"加载失败",description:P instanceof Error?P.message:"无法加载表达方式",variant:"destructive"})}finally{d(!1)}},v=async()=>{try{const P=await J1();P?.data&&je(P.data)}catch(P){console.error("加载统计数据失败:",P)}},X=async()=>{try{const P=await V1();if(P?.data){Se(P.data);const ke=new Map;P.data.forEach(He=>{ke.set(He.chat_id,He.chat_name)}),G(ke)}}catch(P){console.error("加载聊天列表失败:",P)}},me=P=>O.get(P)||P;u.useEffect(()=>{ee(),v(),X()},[f,g,j]);const ce=async P=>{try{const ke=await Q1(P.id);k(ke.data),L(!0)}catch(ke){H({title:"加载详情失败",description:ke instanceof Error?ke.message:"无法加载表达方式详情",variant:"destructive"})}},xe=P=>{k(P),U(!0)},we=async P=>{try{await X1(P.id),H({title:"删除成功",description:`已删除表达方式: ${P.situation}`}),I(null),ee(),v()}catch(ke){H({title:"删除失败",description:ke instanceof Error?ke.message:"无法删除表达方式",variant:"destructive"})}},oe=P=>{const ke=new Set($);ke.has(P)?ke.delete(P):ke.add(P),E(ke)},Z=()=>{$.size===n.length&&n.length>0?E(new Set):E(new Set(n.map(P=>P.id)))},te=async()=>{try{await K1(Array.from($)),H({title:"批量删除成功",description:`已删除 ${$.size} 个表达方式`}),E(new Set),se(!1),ee(),v()}catch(P){H({title:"批量删除失败",description:P instanceof Error?P.message:"无法批量删除表达方式",variant:"destructive"})}},V=()=>{const P=parseInt(fe),ke=Math.ceil(m/g);P>=1&&P<=ke?(p(P),ve("")):H({title:"无效的页码",description:`请输入1-${ke}之间的页码`,variant:"destructive"})};return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(Dl,{className:"h-8 w-8",strokeWidth:2}),"表达方式管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦的表达方式和话术模板"})]}),e.jsxs(S,{onClick:()=>R(!0),className:"gap-2",children:[e.jsx(rt,{className:"h-4 w-4"}),"新增表达方式"]})]})}),e.jsx(Ke,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总数量"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:Ne.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"近7天新增"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-green-600",children:Ne.recent_7days})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"关联聊天数"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-blue-600",children:Ne.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx(C,{htmlFor:"search",children:"搜索"}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-2 mt-1.5",children:e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(At,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{id:"search",placeholder:"搜索情境、风格或上下文...",value:j,onChange:P=>w(P.target.value),className:"pl-9"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:$.size>0&&e.jsxs("span",{children:["已选择 ",$.size," 个表达方式"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Re,{value:g.toString(),onValueChange:P=>{N(parseInt(P)),p(1),E(new Set)},children:[e.jsx(De,{id:"page-size",className:"w-20",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]}),$.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>E(new Set),children:"取消选择"}),e.jsxs(S,{variant:"destructive",size:"sm",onClick:()=>se(!0),children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs(ct,{children:[e.jsx(Xe,{className:"w-12",children:e.jsx(ft,{checked:$.size===n.length&&n.length>0,onCheckedChange:Z})}),e.jsx(Xe,{children:"情境"}),e.jsx(Xe,{children:"风格"}),e.jsx(Xe,{children:"聊天"}),e.jsx(Xe,{className:"text-right",children:"操作"})]})}),e.jsx(cn,{children:r?e.jsx(ct,{children:e.jsx(Ge,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(ct,{children:e.jsx(Ge,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(P=>e.jsxs(ct,{children:[e.jsx(Ge,{children:e.jsx(ft,{checked:$.has(P.id),onCheckedChange:()=>oe(P.id)})}),e.jsx(Ge,{className:"font-medium max-w-xs truncate",children:P.situation}),e.jsx(Ge,{className:"max-w-xs truncate",children:P.style}),e.jsx(Ge,{className:"max-w-[200px] truncate",title:me(P.chat_id),style:{wordBreak:"keep-all"},children:e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis block",children:me(P.chat_id)})}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(S,{variant:"default",size:"sm",onClick:()=>xe(P),children:[e.jsx(ln,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>ce(P),title:"查看详情",children:e.jsx(Rt,{className:"h-4 w-4"})}),e.jsxs(S,{size:"sm",onClick:()=>I(P),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},P.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:r?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(P=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ft,{checked:$.has(P.id),onCheckedChange:()=>oe(P.id),className:"mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden space-y-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"情境"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-2 w-full break-all",title:P.situation,children:P.situation})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"风格"}),e.jsx("p",{className:"text-sm line-clamp-2 w-full break-all",title:P.style,children:P.style})]})]})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"聊天"}),e.jsx("p",{className:"text-sm truncate",title:me(P.chat_id),style:{wordBreak:"keep-all"},children:me(P.chat_id)})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>xe(P),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(ln,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>ce(P),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:e.jsx(Rt,{className:"h-3 w-3"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>I(P),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(Ze,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},P.id))}),m>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",m," 条记录,第 ",f," / ",Math.ceil(m/g)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(f-1),disabled:f===1,children:[e.jsx(rl,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{type:"number",value:fe,onChange:P=>ve(P.target.value),onKeyDown:P=>P.key==="Enter"&&V(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(m/g)}),e.jsx(S,{variant:"outline",size:"sm",onClick:V,disabled:!fe,className:"h-8",children:"跳转"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(f+1),disabled:f>=Math.ceil(m/g),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Ua,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(Math.ceil(m/g)),disabled:f>=Math.ceil(m/g),className:"hidden sm:flex",children:e.jsx(li,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(Z1,{expression:y,open:_,onOpenChange:L,chatNameMap:O}),e.jsx(W1,{open:Q,onOpenChange:R,chatList:ye,onSuccess:()=>{ee(),v(),R(!1)}}),e.jsx(e2,{expression:y,open:D,onOpenChange:U,chatList:ye,onSuccess:()=>{ee(),v(),U(!1)}}),e.jsx(ms,{open:!!z,onOpenChange:()=>I(null),children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除表达方式 "',z?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>z&&we(z),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(s2,{open:M,onOpenChange:se,onConfirm:te,count:$.size})]})}function Z1({expression:n,open:i,onOpenChange:r,chatNameMap:d}){if(!n)return null;const m=f=>f?new Date(f*1e3).toLocaleString("zh-CN"):"-",x=f=>d.get(f)||f;return e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"表达方式详情"}),e.jsx(Ps,{children:"查看表达方式的完整信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(tr,{label:"情境",value:n.situation}),e.jsx(tr,{label:"风格",value:n.style}),e.jsx(tr,{label:"聊天",value:x(n.chat_id)}),e.jsx(tr,{icon:ei,label:"记录ID",value:n.id.toString(),mono:!0})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsx(tr,{icon:Pn,label:"创建时间",value:m(n.create_date)})})]}),e.jsx(at,{children:e.jsx(S,{onClick:()=>r(!1),children:"关闭"})})]})})}function tr({icon:n,label:i,value:r,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),i]}),e.jsx("div",{className:q("text-sm",d&&"font-mono",!r&&"text-muted-foreground"),children:r||"-"})]})}function W1({open:n,onOpenChange:i,chatList:r,onSuccess:d}){const[m,x]=u.useState({situation:"",style:"",chat_id:""}),[f,p]=u.useState(!1),{toast:g}=Bs(),N=async()=>{if(!m.situation||!m.style||!m.chat_id){g({title:"验证失败",description:"请填写必填字段:情境、风格和聊天",variant:"destructive"});return}try{p(!0),await I1(m),g({title:"创建成功",description:"表达方式已创建"}),x({situation:"",style:"",chat_id:""}),d()}catch(j){g({title:"创建失败",description:j instanceof Error?j.message:"无法创建表达方式",variant:"destructive"})}finally{p(!1)}};return e.jsx(Gs,{open:n,onOpenChange:i,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"新增表达方式"}),e.jsx(Ps,{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",children:[e.jsxs(C,{htmlFor:"situation",children:["情境 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"situation",value:m.situation,onChange:j=>x({...m,situation:j.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{htmlFor:"style",children:["风格 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"style",value:m.style,onChange:j=>x({...m,style:j.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Re,{value:m.chat_id,onValueChange:j=>x({...m,chat_id:j}),children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"选择关联的聊天"})}),e.jsx(Oe,{children:r.map(j=>e.jsx(le,{value:j.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[j.chat_name,j.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},j.chat_id))})]})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(S,{onClick:N,disabled:f,children:f?"创建中...":"创建"})]})]})})}function e2({expression:n,open:i,onOpenChange:r,chatList:d,onSuccess:m}){const[x,f]=u.useState({}),[p,g]=u.useState(!1),{toast:N}=Bs();u.useEffect(()=>{n&&f({situation:n.situation,style:n.style,chat_id:n.chat_id})},[n]);const j=async()=>{if(n)try{g(!0),await Y1(n.id,x),N({title:"保存成功",description:"表达方式已更新"}),m()}catch(w){N({title:"保存失败",description:w instanceof Error?w.message:"无法更新表达方式",variant:"destructive"})}finally{g(!1)}};return n?e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"编辑表达方式"}),e.jsx(Ps,{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",children:[e.jsx(C,{htmlFor:"edit_situation",children:"情境"}),e.jsx(ie,{id:"edit_situation",value:x.situation||"",onChange:w=>f({...x,situation:w.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit_style",children:"风格"}),e.jsx(ie,{id:"edit_style",value:x.style||"",onChange:w=>f({...x,style:w.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Re,{value:x.chat_id||"",onValueChange:w=>f({...x,chat_id:w}),children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"选择关联的聊天"})}),e.jsx(Oe,{children:d.map(w=>e.jsx(le,{value:w.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[w.chat_name,w.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},w.chat_id))})]})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(S,{onClick:j,disabled:p,children:p?"保存中...":"保存"})]})]})}):null}function s2({open:n,onOpenChange:i,onConfirm:r,count:d}){return e.jsx(ms,{open:n,onOpenChange:i,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认批量删除"}),e.jsxs(rs,{children:["您即将删除 ",d," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:r,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const cl="/api/webui/jargon";async function t2(){const n=await _e(`${cl}/chats`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取聊天列表失败")}return n.json()}async function a2(n){const i=new URLSearchParams;n.page&&i.append("page",n.page.toString()),n.page_size&&i.append("page_size",n.page_size.toString()),n.search&&i.append("search",n.search),n.chat_id&&i.append("chat_id",n.chat_id),n.is_jargon!==void 0&&n.is_jargon!==null&&i.append("is_jargon",n.is_jargon.toString()),n.is_global!==void 0&&i.append("is_global",n.is_global.toString());const r=await _e(`${cl}/list?${i}`,{});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取黑话列表失败")}return r.json()}async function l2(n){const i=await _e(`${cl}/${n}`,{});if(!i.ok){const r=await i.json();throw new Error(r.detail||"获取黑话详情失败")}return i.json()}async function n2(n){const i=await _e(`${cl}/`,{method:"POST",body:JSON.stringify(n)});if(!i.ok){const r=await i.json();throw new Error(r.detail||"创建黑话失败")}return i.json()}async function i2(n,i){const r=await _e(`${cl}/${n}`,{method:"PATCH",body:JSON.stringify(i)});if(!r.ok){const d=await r.json();throw new Error(d.detail||"更新黑话失败")}return r.json()}async function r2(n){const i=await _e(`${cl}/${n}`,{method:"DELETE"});if(!i.ok){const r=await i.json();throw new Error(r.detail||"删除黑话失败")}return i.json()}async function c2(n){const i=await _e(`${cl}/batch/delete`,{method:"POST",body:JSON.stringify({ids:n})});if(!i.ok){const r=await i.json();throw new Error(r.detail||"批量删除黑话失败")}return i.json()}async function o2(){const n=await _e(`${cl}/stats/summary`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取黑话统计失败")}return n.json()}async function d2(n,i){const r=new URLSearchParams;n.forEach(m=>r.append("ids",m.toString())),r.append("is_jargon",i.toString());const d=await _e(`${cl}/batch/set-jargon?${r}`,{method:"POST"});if(!d.ok){const m=await d.json();throw new Error(m.detail||"批量设置黑话状态失败")}return d.json()}function u2(){const[n,i]=u.useState([]),[r,d]=u.useState(!0),[m,x]=u.useState(0),[f,p]=u.useState(1),[g,N]=u.useState(20),[j,w]=u.useState(""),[y,k]=u.useState("all"),[_,L]=u.useState("all"),[D,U]=u.useState(null),[Q,R]=u.useState(!1),[z,I]=u.useState(!1),[$,E]=u.useState(!1),[M,se]=u.useState(null),[fe,ve]=u.useState(new Set),[Ne,je]=u.useState(!1),[ye,Se]=u.useState(""),[O,G]=u.useState({total:0,confirmed_jargon:0,confirmed_not_jargon:0,pending:0,global_count:0,complete_count:0,chat_count:0,top_chats:{}}),[H,ee]=u.useState([]),{toast:v}=Bs(),X=async()=>{try{d(!0);const pe=await a2({page:f,page_size:g,search:j||void 0,chat_id:y==="all"?void 0:y,is_jargon:_==="all"?void 0:_==="true"?!0:_==="false"?!1:void 0});i(pe.data),x(pe.total)}catch(pe){v({title:"加载失败",description:pe instanceof Error?pe.message:"无法加载黑话列表",variant:"destructive"})}finally{d(!1)}},me=async()=>{try{const pe=await o2();pe?.data&&G(pe.data)}catch(pe){console.error("加载统计数据失败:",pe)}},ce=async()=>{try{const pe=await t2();pe?.data&&ee(pe.data)}catch(pe){console.error("加载聊天列表失败:",pe)}};u.useEffect(()=>{X(),me(),ce()},[f,g,j,y,_]);const xe=async pe=>{try{const Te=await l2(pe.id);U(Te.data),R(!0)}catch(Te){v({title:"加载详情失败",description:Te instanceof Error?Te.message:"无法加载黑话详情",variant:"destructive"})}},we=pe=>{U(pe),I(!0)},oe=async pe=>{try{await r2(pe.id),v({title:"删除成功",description:`已删除黑话: ${pe.content}`}),se(null),X(),me()}catch(Te){v({title:"删除失败",description:Te instanceof Error?Te.message:"无法删除黑话",variant:"destructive"})}},Z=pe=>{const Te=new Set(fe);Te.has(pe)?Te.delete(pe):Te.add(pe),ve(Te)},te=()=>{fe.size===n.length&&n.length>0?ve(new Set):ve(new Set(n.map(pe=>pe.id)))},V=async()=>{try{await c2(Array.from(fe)),v({title:"批量删除成功",description:`已删除 ${fe.size} 个黑话`}),ve(new Set),je(!1),X(),me()}catch(pe){v({title:"批量删除失败",description:pe instanceof Error?pe.message:"无法批量删除黑话",variant:"destructive"})}},P=async pe=>{try{await d2(Array.from(fe),pe),v({title:"操作成功",description:`已将 ${fe.size} 个词条设为${pe?"黑话":"非黑话"}`}),ve(new Set),X(),me()}catch(Te){v({title:"操作失败",description:Te instanceof Error?Te.message:"批量设置失败",variant:"destructive"})}},ke=()=>{const pe=parseInt(ye),Te=Math.ceil(m/g);pe>=1&&pe<=Te?(p(pe),Se("")):v({title:"无效的页码",description:`请输入1-${Te}之间的页码`,variant:"destructive"})},He=pe=>pe===!0?e.jsxs(Fe,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Qt,{className:"h-3 w-3 mr-1"}),"是黑话"]}):pe===!1?e.jsxs(Fe,{variant:"secondary",children:[e.jsx(il,{className:"h-3 w-3 mr-1"}),"非黑话"]}):e.jsxs(Fe,{variant:"outline",children:[e.jsx(bg,{className:"h-3 w-3 mr-1"}),"未判定"]});return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(fy,{className:"h-8 w-8",strokeWidth:2}),"黑话管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦学习到的黑话和俚语"})]}),e.jsxs(S,{onClick:()=>E(!0),className:"gap-2",children:[e.jsx(rt,{className:"h-4 w-4"}),"新增黑话"]})]})}),e.jsx(Ke,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 gap-3",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"总数量"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1",children:O.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"已确认黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-green-600",children:O.confirmed_jargon})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"确认非黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-gray-500",children:O.confirmed_not_jargon})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"待判定"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-yellow-600",children:O.pending})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"全局黑话"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-blue-600",children:O.global_count})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"推断完成"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1 text-purple-600",children:O.complete_count})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 sm:p-4",children:[e.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground",children:"关联聊天数"}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold mt-1",children:O.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{id:"search",placeholder:"搜索内容、含义...",value:j,onChange:pe=>w(pe.target.value),className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"聊天筛选"}),e.jsxs(Re,{value:y,onValueChange:k,children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"全部聊天"})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部聊天"}),H.map(pe=>e.jsx(le,{value:pe.chat_id,children:pe.chat_name},pe.chat_id))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"状态筛选"}),e.jsxs(Re,{value:_,onValueChange:L,children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"全部状态"})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部状态"}),e.jsx(le,{value:"true",children:"是黑话"}),e.jsx(le,{value:"false",children:"非黑话"}),e.jsx(le,{value:"null",children:"未判定"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"page-size",children:"每页显示"}),e.jsxs(Re,{value:g.toString(),onValueChange:pe=>{N(parseInt(pe)),p(1),ve(new Set)},children:[e.jsx(De,{id:"page-size",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]})]})]}),fe.size>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-4 pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",fe.size," 个"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>P(!0),children:[e.jsx(Qt,{className:"h-4 w-4 mr-1"}),"标记为黑话"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>P(!1),children:[e.jsx(il,{className:"h-4 w-4 mr-1"}),"标记为非黑话"]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>ve(new Set),children:"取消选择"}),e.jsxs(S,{variant:"destructive",size:"sm",onClick:()=>je(!0),children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs(ct,{children:[e.jsx(Xe,{className:"w-12",children:e.jsx(ft,{checked:fe.size===n.length&&n.length>0,onCheckedChange:te})}),e.jsx(Xe,{children:"内容"}),e.jsx(Xe,{children:"含义"}),e.jsx(Xe,{children:"聊天"}),e.jsx(Xe,{children:"状态"}),e.jsx(Xe,{className:"text-center",children:"次数"}),e.jsx(Xe,{className:"text-right",children:"操作"})]})}),e.jsx(cn,{children:r?e.jsx(ct,{children:e.jsx(Ge,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(ct,{children:e.jsx(Ge,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(pe=>e.jsxs(ct,{children:[e.jsx(Ge,{children:e.jsx(ft,{checked:fe.has(pe.id),onCheckedChange:()=>Z(pe.id)})}),e.jsx(Ge,{className:"font-medium max-w-[200px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[pe.is_global&&e.jsx("span",{title:"全局黑话",children:e.jsx(Uu,{className:"h-4 w-4 text-blue-500 flex-shrink-0"})}),e.jsx("span",{className:"truncate",title:pe.content,children:pe.content})]})}),e.jsx(Ge,{className:"max-w-[200px] truncate",title:pe.meaning||"",children:pe.meaning||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ge,{className:"max-w-[150px] truncate",title:pe.chat_name||pe.chat_id,children:pe.chat_name||pe.chat_id}),e.jsx(Ge,{children:He(pe.is_jargon)}),e.jsx(Ge,{className:"text-center",children:pe.count}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(S,{variant:"default",size:"sm",onClick:()=>we(pe),children:[e.jsx(ln,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(S,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>xe(pe),title:"查看详情",children:e.jsx(Rt,{className:"h-4 w-4"})}),e.jsxs(S,{size:"sm",onClick:()=>se(pe),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},pe.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:r?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(pe=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ft,{checked:fe.has(pe.id),onCheckedChange:()=>Z(pe.id),className:"mt-1"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[pe.is_global&&e.jsx(Uu,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-sm break-all",children:pe.content})]}),pe.meaning&&e.jsx("p",{className:"text-sm text-muted-foreground break-all",children:pe.meaning}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[He(pe.is_jargon),e.jsxs("span",{className:"text-muted-foreground",children:["次数: ",pe.count]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["聊天: ",pe.chat_name||pe.chat_id]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>we(pe),className:"text-xs px-2 py-1 h-auto",children:[e.jsx(ln,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>xe(pe),className:"text-xs px-2 py-1 h-auto",children:e.jsx(Rt,{className:"h-3 w-3"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>se(pe),className:"text-xs px-2 py-1 h-auto text-destructive hover:text-destructive",children:[e.jsx(Ze,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},pe.id))}),m>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",m," 条记录,第 ",f," / ",Math.ceil(m/g)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(f-1),disabled:f===1,children:[e.jsx(rl,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{type:"number",value:ye,onChange:pe=>Se(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&ke(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(m/g)}),e.jsx(S,{variant:"outline",size:"sm",onClick:ke,disabled:!ye,className:"h-8",children:"跳转"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(f+1),disabled:f>=Math.ceil(m/g),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Ua,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(Math.ceil(m/g)),disabled:f>=Math.ceil(m/g),className:"hidden sm:flex",children:e.jsx(li,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(m2,{jargon:D,open:Q,onOpenChange:R}),e.jsx(x2,{open:$,onOpenChange:E,chatList:H,onSuccess:()=>{X(),me(),E(!1)}}),e.jsx(h2,{jargon:D,open:z,onOpenChange:I,chatList:H,onSuccess:()=>{X(),me(),I(!1)}}),e.jsx(ms,{open:!!M,onOpenChange:()=>se(null),children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除黑话 "',M?.content,'" 吗?此操作不可撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>M&&oe(M),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(ms,{open:Ne,onOpenChange:je,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认批量删除"}),e.jsxs(rs,{children:["您即将删除 ",fe.size," 个黑话,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})]})}function m2({jargon:n,open:i,onOpenChange:r}){return n?e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"黑话详情"}),e.jsx(Ps,{children:"查看黑话的完整信息"})]}),e.jsx(Ke,{className:"h-full pr-4",children:e.jsxs("div",{className:"space-y-4 pb-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ou,{icon:ei,label:"记录ID",value:n.id.toString(),mono:!0}),e.jsx(Ou,{label:"使用次数",value:n.count.toString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all whitespace-pre-wrap",children:n.content})]}),n.raw_content&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"原始内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:(()=>{try{const d=JSON.parse(n.raw_content);return Array.isArray(d)?d.map((m,x)=>e.jsxs("div",{children:[x>0&&e.jsx("hr",{className:"my-3 border-border"}),e.jsx("div",{className:"whitespace-pre-wrap",children:m})]},x)):e.jsx("div",{className:"whitespace-pre-wrap",children:n.raw_content})}catch{return e.jsx("div",{className:"whitespace-pre-wrap",children:n.raw_content})}})()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"含义"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:n.meaning?e.jsx(Kg,{content:n.meaning}):"-"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Ou,{label:"聊天",value:n.chat_name||n.chat_id}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"flex items-center gap-2",children:[n.is_jargon===!0&&e.jsx(Fe,{variant:"default",className:"bg-green-600",children:"是黑话"}),n.is_jargon===!1&&e.jsx(Fe,{variant:"secondary",children:"非黑话"}),n.is_jargon===null&&e.jsx(Fe,{variant:"outline",children:"未判定"}),n.is_global&&e.jsx(Fe,{variant:"outline",className:"border-blue-500 text-blue-500",children:"全局"}),n.is_complete&&e.jsx(Fe,{variant:"outline",className:"border-purple-500 text-purple-500",children:"推断完成"})]})]})]}),n.inference_with_context&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"上下文推断结果"}),e.jsx("div",{className:"p-2 bg-muted rounded break-all whitespace-pre-wrap font-mono text-xs max-h-[200px] overflow-y-auto",children:n.inference_with_context})]}),n.inference_content_only&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"纯词条推断结果"}),e.jsx("div",{className:"p-2 bg-muted rounded break-all whitespace-pre-wrap font-mono text-xs max-h-[200px] overflow-y-auto",children:n.inference_content_only})]})]})}),e.jsx(at,{className:"flex-shrink-0",children:e.jsx(S,{onClick:()=>r(!1),children:"关闭"})})]})}):null}function Ou({icon:n,label:i,value:r,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),i]}),e.jsx("div",{className:q("text-sm",d&&"font-mono",!r&&"text-muted-foreground"),children:r||"-"})]})}function x2({open:n,onOpenChange:i,chatList:r,onSuccess:d}){const[m,x]=u.useState({content:"",meaning:"",chat_id:"",is_global:!1}),[f,p]=u.useState(!1),{toast:g}=Bs(),N=async()=>{if(!m.content||!m.chat_id){g({title:"验证失败",description:"请填写必填字段:内容和聊天",variant:"destructive"});return}try{p(!0),await n2(m),g({title:"创建成功",description:"黑话已创建"}),x({content:"",meaning:"",chat_id:"",is_global:!1}),d()}catch(j){g({title:"创建失败",description:j instanceof Error?j.message:"无法创建黑话",variant:"destructive"})}finally{p(!1)}};return e.jsx(Gs,{open:n,onOpenChange:i,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"新增黑话"}),e.jsx(Ps,{children:"创建新的黑话记录"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{htmlFor:"content",children:["内容 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"content",value:m.content,onChange:j=>x({...m,content:j.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"meaning",children:"含义"}),e.jsx(Ms,{id:"meaning",value:m.meaning||"",onChange:j=>x({...m,meaning:j.target.value}),placeholder:"输入黑话含义(可选)",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Re,{value:m.chat_id,onValueChange:j=>x({...m,chat_id:j}),children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"选择关联的聊天"})}),e.jsx(Oe,{children:r.map(j=>e.jsx(le,{value:j.chat_id,children:j.chat_name},j.chat_id))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"is_global",checked:m.is_global,onCheckedChange:j=>x({...m,is_global:j})}),e.jsx(C,{htmlFor:"is_global",children:"设为全局黑话"})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(S,{onClick:N,disabled:f,children:f?"创建中...":"创建"})]})]})})}function h2({jargon:n,open:i,onOpenChange:r,chatList:d,onSuccess:m}){const[x,f]=u.useState({}),[p,g]=u.useState(!1),{toast:N}=Bs();u.useEffect(()=>{n&&f({content:n.content,meaning:n.meaning||"",chat_id:n.stream_id||n.chat_id,is_global:n.is_global,is_jargon:n.is_jargon})},[n]);const j=async()=>{if(n)try{g(!0),await i2(n.id,x),N({title:"保存成功",description:"黑话已更新"}),m()}catch(w){N({title:"保存失败",description:w instanceof Error?w.message:"无法更新黑话",variant:"destructive"})}finally{g(!1)}};return n?e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"编辑黑话"}),e.jsx(Ps,{children:"修改黑话的信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit_content",children:"内容"}),e.jsx(ie,{id:"edit_content",value:x.content||"",onChange:w=>f({...x,content:w.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit_meaning",children:"含义"}),e.jsx(Ms,{id:"edit_meaning",value:x.meaning||"",onChange:w=>f({...x,meaning:w.target.value}),placeholder:"输入黑话含义",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Re,{value:x.chat_id||"",onValueChange:w=>f({...x,chat_id:w}),children:[e.jsx(De,{children:e.jsx(Le,{placeholder:"选择关联的聊天"})}),e.jsx(Oe,{children:d.map(w=>e.jsx(le,{value:w.chat_id,children:w.chat_name},w.chat_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"黑话状态"}),e.jsxs(Re,{value:x.is_jargon===null?"null":x.is_jargon?.toString()||"null",onValueChange:w=>f({...x,is_jargon:w==="null"?null:w==="true"}),children:[e.jsx(De,{children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"null",children:"未判定"}),e.jsx(le,{value:"true",children:"是黑话"}),e.jsx(le,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"edit_is_global",checked:x.is_global,onCheckedChange:w=>f({...x,is_global:w})}),e.jsx(C,{htmlFor:"edit_is_global",children:"全局黑话"})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(S,{onClick:j,disabled:p,children:p?"保存中...":"保存"})]})]})}):null}const ii="/api/webui/person";async function f2(n){const i=new URLSearchParams;n.page&&i.append("page",n.page.toString()),n.page_size&&i.append("page_size",n.page_size.toString()),n.search&&i.append("search",n.search),n.is_known!==void 0&&i.append("is_known",n.is_known.toString()),n.platform&&i.append("platform",n.platform);const r=await _e(`${ii}/list?${i}`,{headers:As()});if(!r.ok){const d=await r.json();throw new Error(d.detail||"获取人物列表失败")}return r.json()}async function p2(n){const i=await _e(`${ii}/${n}`,{headers:As()});if(!i.ok){const r=await i.json();throw new Error(r.detail||"获取人物详情失败")}return i.json()}async function g2(n,i){const r=await _e(`${ii}/${n}`,{method:"PATCH",headers:As(),body:JSON.stringify(i)});if(!r.ok){const d=await r.json();throw new Error(d.detail||"更新人物信息失败")}return r.json()}async function j2(n){const i=await _e(`${ii}/${n}`,{method:"DELETE",headers:As()});if(!i.ok){const r=await i.json();throw new Error(r.detail||"删除人物信息失败")}return i.json()}async function v2(){const n=await _e(`${ii}/stats/summary`,{headers:As()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取统计数据失败")}return n.json()}async function b2(n){const i=await _e(`${ii}/batch/delete`,{method:"POST",headers:As(),body:JSON.stringify({person_ids:n})});if(!i.ok){const r=await i.json();throw new Error(r.detail||"批量删除失败")}return i.json()}function N2(){const[n,i]=u.useState([]),[r,d]=u.useState(!0),[m,x]=u.useState(0),[f,p]=u.useState(1),[g,N]=u.useState(20),[j,w]=u.useState(""),[y,k]=u.useState(void 0),[_,L]=u.useState(void 0),[D,U]=u.useState(null),[Q,R]=u.useState(!1),[z,I]=u.useState(!1),[$,E]=u.useState(null),[M,se]=u.useState({total:0,known:0,unknown:0,platforms:{}}),[fe,ve]=u.useState(new Set),[Ne,je]=u.useState(!1),[ye,Se]=u.useState(""),{toast:O}=Bs(),G=async()=>{try{d(!0);const V=await f2({page:f,page_size:g,search:j||void 0,is_known:y,platform:_});i(V.data),x(V.total)}catch(V){O({title:"加载失败",description:V instanceof Error?V.message:"无法加载人物信息",variant:"destructive"})}finally{d(!1)}},H=async()=>{try{const V=await v2();V?.data&&se(V.data)}catch(V){console.error("加载统计数据失败:",V)}};u.useEffect(()=>{G(),H()},[f,g,j,y,_]);const ee=async V=>{try{const P=await p2(V.person_id);U(P.data),R(!0)}catch(P){O({title:"加载详情失败",description:P instanceof Error?P.message:"无法加载人物详情",variant:"destructive"})}},v=V=>{U(V),I(!0)},X=async V=>{try{await j2(V.person_id),O({title:"删除成功",description:`已删除人物信息: ${V.person_name||V.nickname||V.user_id}`}),E(null),G(),H()}catch(P){O({title:"删除失败",description:P instanceof Error?P.message:"无法删除人物信息",variant:"destructive"})}},me=u.useMemo(()=>Object.keys(M.platforms),[M.platforms]),ce=V=>{const P=new Set(fe);P.has(V)?P.delete(V):P.add(V),ve(P)},xe=()=>{fe.size===n.length&&n.length>0?ve(new Set):ve(new Set(n.map(V=>V.person_id)))},we=()=>{if(fe.size===0){O({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}je(!0)},oe=async()=>{try{const V=await b2(Array.from(fe));O({title:"批量删除完成",description:V.message}),ve(new Set),je(!1),G(),H()}catch(V){O({title:"批量删除失败",description:V instanceof Error?V.message:"批量删除失败",variant:"destructive"})}},Z=()=>{const V=parseInt(ye),P=Math.ceil(m/g);V>=1&&V<=P?(p(V),Se("")):O({title:"无效的页码",description:`请输入1-${P}之间的页码`,variant:"destructive"})},te=V=>V?new Date(V*1e3).toLocaleString("zh-CN"):"-";return e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsx("div",{className:"mb-4 sm:mb-6",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(Bu,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(Ke,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"总人数"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:M.total})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"已认识"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-green-600",children:M.known})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"未认识"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-muted-foreground",children:M.unknown})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(C,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(At,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{id:"search",placeholder:"搜索名称、昵称或用户ID...",value:j,onChange:V=>w(V.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(C,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs(Re,{value:y===void 0?"all":y.toString(),onValueChange:V=>{k(V==="all"?void 0:V==="true"),p(1)},children:[e.jsx(De,{id:"filter-known",className:"mt-1.5",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部"}),e.jsx(le,{value:"true",children:"已认识"}),e.jsx(le,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(C,{htmlFor:"filter-platform",children:"平台"}),e.jsxs(Re,{value:_||"all",onValueChange:V=>{L(V==="all"?void 0:V),p(1)},children:[e.jsx(De,{id:"filter-platform",className:"mt-1.5",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部平台"}),me.map(V=>e.jsxs(le,{value:V,children:[V," (",M.platforms[V],")"]},V))]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:fe.size>0&&e.jsxs("span",{children:["已选择 ",fe.size," 个人物"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Re,{value:g.toString(),onValueChange:V=>{N(parseInt(V)),p(1),ve(new Set)},children:[e.jsx(De,{id:"page-size",className:"w-20",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"10",children:"10"}),e.jsx(le,{value:"20",children:"20"}),e.jsx(le,{value:"50",children:"50"}),e.jsx(le,{value:"100",children:"100"})]})]}),fe.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>ve(new Set),children:"取消选择"}),e.jsxs(S,{variant:"destructive",size:"sm",onClick:we,children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card",children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs(ct,{children:[e.jsx(Xe,{className:"w-12",children:e.jsx(ft,{checked:n.length>0&&fe.size===n.length,onCheckedChange:xe,"aria-label":"全选"})}),e.jsx(Xe,{children:"状态"}),e.jsx(Xe,{children:"名称"}),e.jsx(Xe,{children:"昵称"}),e.jsx(Xe,{children:"平台"}),e.jsx(Xe,{children:"用户ID"}),e.jsx(Xe,{children:"最后更新"}),e.jsx(Xe,{className:"text-right",children:"操作"})]})}),e.jsx(cn,{children:r?e.jsx(ct,{children:e.jsx(Ge,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):n.length===0?e.jsx(ct,{children:e.jsx(Ge,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):n.map(V=>e.jsxs(ct,{children:[e.jsx(Ge,{children:e.jsx(ft,{checked:fe.has(V.person_id),onCheckedChange:()=>ce(V.person_id),"aria-label":`选择 ${V.person_name||V.nickname||V.user_id}`})}),e.jsx(Ge,{children:e.jsx("div",{className:q("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",V.is_known?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"),children:V.is_known?"已认识":"未认识"})}),e.jsx(Ge,{className:"font-medium",children:V.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ge,{children:V.nickname||"-"}),e.jsx(Ge,{children:V.platform}),e.jsx(Ge,{className:"font-mono text-sm",children:V.user_id}),e.jsx(Ge,{className:"text-sm text-muted-foreground",children:te(V.last_know)}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(S,{variant:"default",size:"sm",onClick:()=>ee(V),children:[e.jsx(Rt,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(S,{variant:"default",size:"sm",onClick:()=>v(V),children:[e.jsx(ln,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(S,{size:"sm",onClick:()=>E(V),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},V.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:r?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):n.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):n.map(V=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ft,{checked:fe.has(V.person_id),onCheckedChange:()=>ce(V.person_id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:q("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium mb-2",V.is_known?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"),children:V.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:V.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),V.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",V.nickname]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"平台"}),e.jsx("p",{className:"font-medium text-xs",children:V.platform})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"用户ID"}),e.jsx("p",{className:"font-mono text-xs truncate",title:V.user_id,children:V.user_id})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"最后更新"}),e.jsx("p",{className:"text-xs",children:te(V.last_know)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>ee(V),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Rt,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>v(V),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(ln,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>E(V),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(Ze,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},V.id))}),m>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-4 py-3 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",m," 条记录,第 ",f," / ",Math.ceil(m/g)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(1),disabled:f===1,className:"hidden sm:flex",children:e.jsx(ai,{className:"h-4 w-4"})}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(f-1),disabled:f===1,children:[e.jsx(rl,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"上一页"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{type:"number",value:ye,onChange:V=>Se(V.target.value),onKeyDown:V=>V.key==="Enter"&&Z(),placeholder:f.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(m/g)}),e.jsx(S,{variant:"outline",size:"sm",onClick:Z,disabled:!ye,className:"h-8",children:"跳转"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>p(f+1),disabled:f>=Math.ceil(m/g),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Ua,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>p(Math.ceil(m/g)),disabled:f>=Math.ceil(m/g),className:"hidden sm:flex",children:e.jsx(li,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(y2,{person:D,open:Q,onOpenChange:R}),e.jsx(w2,{person:D,open:z,onOpenChange:I,onSuccess:()=>{G(),H(),I(!1)}}),e.jsx(ms,{open:!!$,onOpenChange:()=>E(null),children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认删除"}),e.jsxs(rs,{children:['确定要删除人物信息 "',$?.person_name||$?.nickname||$?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:()=>$&&X($),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(ms,{open:Ne,onOpenChange:je,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"确认批量删除"}),e.jsxs(rs,{children:["确定要删除选中的 ",fe.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(ns,{children:[e.jsx(os,{children:"取消"}),e.jsx(cs,{onClick:oe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function y2({person:n,open:i,onOpenChange:r}){if(!n)return null;const d=m=>m?new Date(m*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"人物详情"}),e.jsxs(Ps,{children:["查看 ",n.person_name||n.nickname||n.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(al,{icon:Ic,label:"人物名称",value:n.person_name}),e.jsx(al,{icon:Dl,label:"昵称",value:n.nickname}),e.jsx(al,{icon:ei,label:"用户ID",value:n.user_id,mono:!0}),e.jsx(al,{icon:ei,label:"人物ID",value:n.person_id,mono:!0}),e.jsx(al,{label:"平台",value:n.platform}),e.jsx(al,{label:"状态",value:n.is_known?"已认识":"未认识"})]}),n.name_reason&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"名称设定原因"}),e.jsx("p",{className:"mt-1 text-sm",children:n.name_reason})]}),n.memory_points&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"个人印象"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:n.memory_points})]}),n.group_nick_name&&n.group_nick_name.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(C,{className:"text-xs text-muted-foreground",children:"群昵称"}),e.jsx("div",{className:"mt-2 space-y-1",children:n.group_nick_name.map((m,x)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:m.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:m.group_nick_name})]},x))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(al,{icon:Pn,label:"认识时间",value:d(n.know_times)}),e.jsx(al,{icon:Pn,label:"首次记录",value:d(n.know_since)}),e.jsx(al,{icon:Pn,label:"最后更新",value:d(n.last_know)})]})]}),e.jsx(at,{children:e.jsx(S,{onClick:()=>r(!1),children:"关闭"})})]})})}function al({icon:n,label:i,value:r,mono:d=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n&&e.jsx(n,{className:"h-3 w-3"}),i]}),e.jsx("div",{className:q("text-sm",d&&"font-mono",!r&&"text-muted-foreground"),children:r||"-"})]})}function w2({person:n,open:i,onOpenChange:r,onSuccess:d}){const[m,x]=u.useState({}),[f,p]=u.useState(!1),{toast:g}=Bs();u.useEffect(()=>{n&&x({person_name:n.person_name||"",name_reason:n.name_reason||"",nickname:n.nickname||"",memory_points:n.memory_points||"",is_known:n.is_known})},[n]);const N=async()=>{if(n)try{p(!0),await g2(n.person_id,m),g({title:"保存成功",description:"人物信息已更新"}),d()}catch(j){g({title:"保存失败",description:j instanceof Error?j.message:"无法更新人物信息",variant:"destructive"})}finally{p(!1)}};return n?e.jsx(Gs,{open:i,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"编辑人物信息"}),e.jsxs(Ps,{children:["修改 ",n.person_name||n.nickname||n.user_id," 的信息"]})]}),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",children:[e.jsx(C,{htmlFor:"person_name",children:"人物名称"}),e.jsx(ie,{id:"person_name",value:m.person_name||"",onChange:j=>x({...m,person_name:j.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"nickname",children:"昵称"}),e.jsx(ie,{id:"nickname",value:m.nickname||"",onChange:j=>x({...m,nickname:j.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(Ms,{id:"name_reason",value:m.name_reason||"",onChange:j=>x({...m,name_reason:j.target.value}),placeholder:"为什么这样称呼这个人?",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"memory_points",children:"个人印象"}),e.jsx(Ms,{id:"memory_points",value:m.memory_points||"",onChange:j=>x({...m,memory_points:j.target.value}),placeholder:"对这个人的印象和记忆点...",rows:4})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx(C,{htmlFor:"is_known",className:"text-base font-medium",children:"已认识"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"标记是否已经认识这个人"})]}),e.jsx(Ve,{id:"is_known",checked:m.is_known,onCheckedChange:j=>x({...m,is_known:j})})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(S,{onClick:N,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}var _2=s0();const yp=Xb(_2),sm="/api/webui";async function S2(n=100,i="all"){const r=`${sm}/knowledge/graph?limit=${n}&node_type=${i}`,d=await fetch(r);if(!d.ok)throw new Error(`获取知识图谱失败: ${d.status}`);return d.json()}async function C2(){const n=await fetch(`${sm}/knowledge/stats`);if(!n.ok)throw new Error("获取知识图谱统计信息失败");return n.json()}async function k2(n){const i=await fetch(`${sm}/knowledge/search?query=${encodeURIComponent(n)}`);if(!i.ok)throw new Error("搜索知识节点失败");return i.json()}const Jg=u.memo(({data:n})=>e.jsxs("div",{className:"px-4 py-2 shadow-md rounded-lg bg-gradient-to-br from-blue-500 to-blue-600 border-2 border-blue-700 min-w-[120px]",children:[e.jsx(Yc,{type:"target",position:Xc.Top}),e.jsx("div",{className:"font-semibold text-white text-sm truncate max-w-[200px]",title:n.content,children:n.label}),e.jsx(Yc,{type:"source",position:Xc.Bottom})]}));Jg.displayName="EntityNode";const Pg=u.memo(({data:n})=>e.jsxs("div",{className:"px-3 py-2 shadow-md rounded-md bg-gradient-to-br from-green-500 to-green-600 border-2 border-green-700 min-w-[100px]",children:[e.jsx(Yc,{type:"target",position:Xc.Top}),e.jsx("div",{className:"font-medium text-white text-xs truncate max-w-[150px]",title:n.content,children:n.label}),e.jsx(Yc,{type:"source",position:Xc.Bottom})]}));Pg.displayName="ParagraphNode";const T2={entity:Jg,paragraph:Pg};function E2(n,i){const r=new yp.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:"TB",ranksep:100,nodesep:80});const d=[],m=[];return n.forEach(x=>{r.setNode(x.id,{width:150,height:50})}),i.forEach(x=>{r.setEdge(x.source,x.target)}),yp.layout(r),n.forEach(x=>{const f=r.node(x.id);d.push({id:x.id,type:x.type,position:{x:f.x-75,y:f.y-25},data:{label:x.content.slice(0,20)+(x.content.length>20?"...":""),content:x.content}})}),i.forEach((x,f)=>{const p={id:`edge-${f}`,source:x.source,target:x.target,animated:n.length<=200&&x.weight>5,style:{strokeWidth:Math.min(x.weight/2,5),opacity:.6}};x.weight>10&&n.length<100&&(p.label=`${x.weight.toFixed(0)}`),m.push(p)}),{nodes:d,edges:m}}function z2(){const n=ja(),[i,r]=u.useState(!1),[d,m]=u.useState(null),[x,f]=u.useState(""),[p,g]=u.useState("all"),[N,j]=u.useState(50),[w,y]=u.useState("50"),[k,_]=u.useState(!1),[L,D]=u.useState(!0),[U,Q]=u.useState(!1),[R,z]=u.useState(!1),[I,$,E]=t0([]),[M,se,fe]=a0([]),[ve,Ne]=u.useState(0),[je,ye]=u.useState(null),[Se,O]=u.useState(null),{toast:G}=Bs(),H=u.useCallback(oe=>oe.type==="entity"?"#6366f1":oe.type==="paragraph"?"#10b981":"#6b7280",[]),ee=u.useCallback(async(oe=!1)=>{try{if(!oe&&N>200){z(!0);return}r(!0);const[Z,te]=await Promise.all([S2(N,p),C2()]);if(m(te),Z.nodes.length===0){G({title:"提示",description:"知识库为空,请先导入知识数据"}),$([]),se([]);return}const{nodes:V,edges:P}=E2(Z.nodes,Z.edges);$(V),se(P),Ne(V.length),te&&te.total_nodes>N&&G({title:"提示",description:`知识图谱包含 ${te.total_nodes} 个节点,当前显示 ${V.length}`}),G({title:"加载成功",description:`已加载 ${V.length} 个节点,${P.length} 条边`})}catch(Z){console.error("加载知识图谱失败:",Z),G({title:"加载失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}finally{r(!1)}},[N,p,G]),v=u.useCallback(async()=>{if(!x.trim()){G({title:"提示",description:"请输入搜索关键词"});return}try{const oe=await k2(x);if(oe.length===0){G({title:"未找到",description:"没有找到匹配的节点"});return}const Z=new Set(oe.map(te=>te.id));$(te=>te.map(V=>({...V,style:{...V.style,opacity:Z.has(V.id)?1:.3,filter:Z.has(V.id)?"brightness(1.2)":"brightness(0.8)"}}))),G({title:"搜索完成",description:`找到 ${oe.length} 个匹配节点`})}catch(oe){console.error("搜索失败:",oe),G({title:"搜索失败",description:oe instanceof Error?oe.message:"未知错误",variant:"destructive"})}},[x,G]),X=u.useCallback(()=>{$(oe=>oe.map(Z=>({...Z,style:{...Z.style,opacity:1,filter:"brightness(1)"}})))},[]),me=u.useCallback(()=>{D(!1),Q(!0),ee()},[ee]),ce=u.useCallback(()=>{z(!1),setTimeout(()=>{ee(!0)},0)},[ee]),xe=u.useCallback((oe,Z)=>{I.find(V=>V.id===Z.id)&&ye({id:Z.id,type:Z.type,content:Z.data.content})},[I]);u.useEffect(()=>{L||U&&ee()},[N,p,L,U]);const we=u.useCallback((oe,Z)=>{const te=I.find(ke=>ke.id===Z.source),V=I.find(ke=>ke.id===Z.target),P=M.find(ke=>ke.id===Z.id);te&&V&&P&&O({source:{id:te.id,type:te.type,content:te.data.content},target:{id:V.id,type:V.type,content:V.data.content},edge:{source:Z.source,target:Z.target,weight:parseFloat(Z.label||"0")}})},[I,M]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-shrink-0 p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦知识库图谱"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"可视化知识实体与关系网络"})]}),d&&e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Fe,{variant:"outline",className:"gap-1",children:[e.jsx($c,{className:"h-3 w-3"}),"节点: ",d.total_nodes]}),e.jsxs(Fe,{variant:"outline",className:"gap-1",children:[e.jsx(yg,{className:"h-3 w-3"}),"边: ",d.total_edges]}),e.jsxs(Fe,{variant:"outline",className:"gap-1",children:[e.jsx(Oa,{className:"h-3 w-3"}),"实体: ",d.entity_nodes]}),e.jsxs(Fe,{variant:"outline",className:"gap-1",children:[e.jsx(_a,{className:"h-3 w-3"}),"段落: ",d.paragraph_nodes]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mt-4",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(ie,{placeholder:"搜索节点内容...",value:x,onChange:oe=>f(oe.target.value),onKeyDown:oe=>oe.key==="Enter"&&v(),className:"flex-1"}),e.jsx(S,{onClick:v,size:"sm",children:e.jsx(At,{className:"h-4 w-4"})}),e.jsx(S,{onClick:X,variant:"outline",size:"sm",children:"重置"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Re,{value:p,onValueChange:oe=>g(oe),children:[e.jsx(De,{className:"w-[120px]",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部节点"}),e.jsx(le,{value:"entity",children:"仅实体"}),e.jsx(le,{value:"paragraph",children:"仅段落"})]})]}),e.jsxs(Re,{value:N===1e4?"all":k?"custom":N.toString(),onValueChange:oe=>{oe==="custom"?(_(!0),y(N.toString())):oe==="all"?(_(!1),j(1e4)):(_(!1),j(Number(oe)))},children:[e.jsx(De,{className:"w-[120px]",children:e.jsx(Le,{})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"50",children:"50 节点"}),e.jsx(le,{value:"100",children:"100 节点"}),e.jsx(le,{value:"200",children:"200 节点"}),e.jsx(le,{value:"500",children:"500 节点"}),e.jsx(le,{value:"1000",children:"1000 节点"}),e.jsx(le,{value:"all",children:"全部 (最多10000)"}),e.jsx(le,{value:"custom",children:"自定义..."})]})]}),k&&e.jsx(ie,{type:"number",min:"50",value:w,onChange:oe=>y(oe.target.value),onBlur:()=>{const oe=parseInt(w);!isNaN(oe)&&oe>=50?j(oe):(y("50"),j(50))},onKeyDown:oe=>{if(oe.key==="Enter"){const Z=parseInt(w);!isNaN(Z)&&Z>=50?j(Z):(y("50"),j(50))}},placeholder:"最少50个",className:"w-[120px]"}),e.jsx(S,{onClick:()=>ee(),variant:"outline",size:"sm",disabled:i,children:e.jsx(zt,{className:q("h-4 w-4",i&&"animate-spin")})})]})]})]}),e.jsx("div",{className:"flex-1 relative",children:i?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(zt,{className:"h-8 w-8 animate-spin mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"加载知识图谱中..."})]})}):I.length===0?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx($c,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"知识库为空"}),e.jsx("p",{className:"text-muted-foreground",children:"请先导入知识数据"})]})}):e.jsxs(l0,{nodes:I,edges:M,onNodesChange:E,onEdgesChange:fe,onNodeClick:xe,onEdgeClick:we,nodeTypes:T2,fitView:!0,minZoom:.05,maxZoom:1.5,defaultViewport:{x:0,y:0,zoom:.5},elevateNodesOnSelect:ve<=500,nodesDraggable:ve<=1e3,attributionPosition:"bottom-left",children:[e.jsx(n0,{variant:i0.Dots,gap:12,size:1}),e.jsx(r0,{}),ve<=500&&e.jsx(c0,{nodeColor:H,nodeBorderRadius:8,pannable:!0,zoomable:!0}),e.jsxs(o0,{position:"top-right",className:"bg-background/95 backdrop-blur-sm rounded-lg border p-3 shadow-lg",children:[e.jsx("div",{className:"text-sm font-semibold mb-2",children:"图例"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-gradient-to-br from-blue-500 to-blue-600 border-2 border-blue-700"}),e.jsx("span",{children:"实体节点"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-gradient-to-br from-green-500 to-green-600 border-2 border-green-700"}),e.jsx("span",{children:"段落节点"})]}),ve>200&&e.jsxs("div",{className:"mt-2 pt-2 border-t text-yellow-600 dark:text-yellow-500",children:[e.jsx("div",{className:"font-semibold",children:"性能模式"}),e.jsx("div",{children:"已禁用动画"}),ve>500&&e.jsx("div",{children:"已禁用缩略图"})]})]})]})]})}),e.jsx(Gs,{open:!!je,onOpenChange:oe=>!oe&&ye(null),children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(Ls,{children:e.jsx(Us,{children:"节点详情"})}),je&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"类型"}),e.jsx("div",{className:"mt-1",children:e.jsx(Fe,{variant:je.type==="entity"?"default":"secondary",children:je.type==="entity"?"🏷️ 实体":"📄 段落"})})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"ID"}),e.jsx("code",{className:"mt-1 block p-2 bg-muted rounded text-xs break-all",children:je.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"内容"}),e.jsx(Ke,{className:"mt-1 h-40 p-3 bg-muted rounded",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:je.content})})]})]})]})}),e.jsx(Gs,{open:!!Se,onOpenChange:oe=>!oe&&O(null),children:e.jsxs(Rs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Ls,{children:e.jsx(Us,{children:"边详情"})}),Se&&e.jsx(Ke,{className:"flex-1 pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0 p-3 bg-blue-50 dark:bg-blue-950 rounded border-2 border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"源节点"}),e.jsx("div",{className:"font-medium text-sm mb-2 truncate",children:Se.source.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[Se.source.id.slice(0,40),"..."]})]}),e.jsx("div",{className:"text-2xl text-muted-foreground flex-shrink-0",children:"→"}),e.jsxs("div",{className:"flex-1 min-w-0 p-3 bg-green-50 dark:bg-green-950 rounded border-2 border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"目标节点"}),e.jsx("div",{className:"font-medium text-sm mb-2 truncate",children:Se.target.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[Se.target.id.slice(0,40),"..."]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"权重"}),e.jsx("div",{className:"mt-1",children:e.jsx(Fe,{variant:"outline",className:"text-base font-mono",children:Se.edge.weight.toFixed(4)})})]})]})})]})}),e.jsx(ms,{open:L,onOpenChange:D,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"加载知识图谱"}),e.jsxs(rs,{children:["知识图谱的动态展示会消耗较多系统资源。",e.jsx("br",{}),"确定要加载知识图谱吗?"]})]}),e.jsxs(ns,{children:[e.jsx(os,{onClick:()=>n({to:"/"}),children:"取消 (返回首页)"}),e.jsx(cs,{onClick:me,children:"确认加载"})]})]})}),e.jsx(ms,{open:R,onOpenChange:z,children:e.jsxs(as,{children:[e.jsxs(ls,{children:[e.jsx(is,{children:"⚠️ 节点数量较多"}),e.jsx(rs,{asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["您正在尝试加载 ",e.jsx("strong",{className:"text-orange-600",children:N>=1e4?"全部 (最多10000个)":N})," 个节点。"]}),e.jsx("p",{className:"mt-4",children:"节点数量过多可能导致:"}),e.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[e.jsx("li",{children:"页面加载时间较长"}),e.jsx("li",{children:"浏览器卡顿或崩溃"}),e.jsx("li",{children:"系统资源占用过高"})]}),e.jsx("p",{className:"mt-4",children:"建议先选择较少的节点数量 (50-200 个)。"})]})})]}),e.jsxs(ns,{children:[e.jsx(os,{onClick:()=>{z(!1),N>200&&(j(50),_(!1))},children:"取消"}),e.jsx(cs,{onClick:ce,className:"bg-orange-600 hover:bg-orange-700",children:"我了解风险,继续加载"})]})]})})]})}function wp({className:n,classNames:i,showOutsideDays:r=!0,captionLayout:d="label",buttonVariant:m="ghost",formatters:x,components:f,...p}){const g=kg();return e.jsx(Uy,{showOutsideDays:r,className:q("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`,n),captionLayout:d,formatters:{formatMonthDropdown:N=>N.toLocaleString("default",{month:"short"}),...x},classNames:{root:q("w-fit",g.root),months:q("relative flex flex-col gap-4 md:flex-row",g.months),month:q("flex w-full flex-col gap-4",g.month),nav:q("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",g.nav),button_previous:q(mr({variant:m}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",g.button_previous),button_next:q(mr({variant:m}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",g.button_next),month_caption:q("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",g.month_caption),dropdowns:q("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",g.dropdowns),dropdown_root:q("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",g.dropdown_root),dropdown:q("bg-popover absolute inset-0 opacity-0",g.dropdown),caption_label:q("select-none font-medium",d==="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",g.caption_label),table:"w-full border-collapse",weekdays:q("flex",g.weekdays),weekday:q("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",g.weekday),week:q("mt-2 flex w-full",g.week),week_number_header:q("w-[--cell-size] select-none",g.week_number_header),week_number:q("text-muted-foreground select-none text-[0.8rem]",g.week_number),day:q("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",g.day),range_start:q("bg-accent rounded-l-md",g.range_start),range_middle:q("rounded-none",g.range_middle),range_end:q("bg-accent rounded-r-md",g.range_end),today:q("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",g.today),outside:q("text-muted-foreground aria-selected:text-muted-foreground",g.outside),disabled:q("text-muted-foreground opacity-50",g.disabled),hidden:q("invisible",g.hidden),...i},components:{Root:({className:N,rootRef:j,...w})=>e.jsx("div",{"data-slot":"calendar",ref:j,className:q(N),...w}),Chevron:({className:N,orientation:j,...w})=>j==="left"?e.jsx(rl,{className:q("size-4",N),...w}):j==="right"?e.jsx(Ua,{className:q("size-4",N),...w}):e.jsx(Ol,{className:q("size-4",N),...w}),DayButton:M2,WeekNumber:({children:N,...j})=>e.jsx("td",{...j,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:N})}),...f},...p})}function M2({className:n,day:i,modifiers:r,...d}){const m=kg(),x=u.useRef(null);return u.useEffect(()=>{r.focused&&x.current?.focus()},[r.focused]),e.jsx(S,{ref:x,variant:"ghost",size:"icon","data-day":i.date.toLocaleDateString(),"data-selected-single":r.selected&&!r.range_start&&!r.range_end&&!r.range_middle,"data-range-start":r.range_start,"data-range-end":r.range_end,"data-range-middle":r.range_middle,className:q("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",m.day,n),...d})}const A2={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},D2=(n,i,r)=>{let d;const m=A2[n];return typeof m=="string"?d=m:i===1?d=m.one:d=m.other.replace("{{count}}",String(i)),r?.addSuffix?r.comparison&&r.comparison>0?d+"内":d+"前":d},O2={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},R2={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},L2={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},U2={date:vu({formats:O2,defaultWidth:"full"}),time:vu({formats:R2,defaultWidth:"full"}),dateTime:vu({formats:L2,defaultWidth:"full"})};function _p(n,i,r){const d="eeee p";return Pb(n,i,r)?d:n.getTime()>i.getTime()?"'下个'"+d:"'上个'"+d}const B2={lastWeek:_p,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:_p,other:"PP p"},H2=(n,i,r,d)=>{const m=B2[n];return typeof m=="function"?m(i,r,d):m},q2={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},G2={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},F2={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},V2={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},$2={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},Q2={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},I2=(n,i)=>{const r=Number(n);switch(i?.unit){case"date":return r.toString()+"日";case"hour":return r.toString()+"时";case"minute":return r.toString()+"分";case"second":return r.toString()+"秒";default:return"第 "+r.toString()}},Y2={ordinalNumber:I2,era:Pi({values:q2,defaultWidth:"wide"}),quarter:Pi({values:G2,defaultWidth:"wide",argumentCallback:n=>n-1}),month:Pi({values:F2,defaultWidth:"wide"}),day:Pi({values:V2,defaultWidth:"wide"}),dayPeriod:Pi({values:$2,defaultWidth:"wide",formattingValues:Q2,defaultFormattingWidth:"wide"})},X2=/^(第\s*)?\d+(日|时|分|秒)?/i,K2=/\d+/i,J2={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},P2={any:[/^(前)/i,/^(公元)/i]},Z2={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},W2={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},e_={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},s_={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},t_={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},a_={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},l_={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},n_={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},i_={ordinalNumber:Zb({matchPattern:X2,parsePattern:K2,valueCallback:n=>parseInt(n,10)}),era:Zi({matchPatterns:J2,defaultMatchWidth:"wide",parsePatterns:P2,defaultParseWidth:"any"}),quarter:Zi({matchPatterns:Z2,defaultMatchWidth:"wide",parsePatterns:W2,defaultParseWidth:"any",valueCallback:n=>n+1}),month:Zi({matchPatterns:e_,defaultMatchWidth:"wide",parsePatterns:s_,defaultParseWidth:"any"}),day:Zi({matchPatterns:t_,defaultMatchWidth:"wide",parsePatterns:a_,defaultParseWidth:"any"}),dayPeriod:Zi({matchPatterns:l_,defaultMatchWidth:"any",parsePatterns:n_,defaultParseWidth:"any"})},Lc={code:"zh-CN",formatDistance:D2,formatLong:U2,formatRelative:H2,localize:Y2,match:i_,options:{weekStartsOn:1,firstWeekContainsDate:4}},Uc={xs:{label:"小",rowHeight:28,class:"text-[10px] sm:text-xs"},sm:{label:"中",rowHeight:36,class:"text-xs sm:text-sm"},base:{label:"大",rowHeight:44,class:"text-sm sm:text-base"}};function r_(){const[n,i]=u.useState([]),[r,d]=u.useState(""),[m,x]=u.useState("all"),[f,p]=u.useState("all"),[g,N]=u.useState(void 0),[j,w]=u.useState(void 0),[y,k]=u.useState(!0),[_,L]=u.useState(!1),[D,U]=u.useState("xs"),[Q,R]=u.useState(4),z=u.useRef(null);u.useEffect(()=>{const H=en.getAllLogs();i(H);const ee=en.onLog(()=>{i(en.getAllLogs())}),v=en.onConnectionChange(X=>{L(X)});return()=>{ee(),v()}},[]);const I=u.useMemo(()=>{const H=new Set(n.map(ee=>ee.module).filter(ee=>ee&&ee.trim()!==""));return Array.from(H).sort()},[n]),$=H=>{switch(H){case"DEBUG":return"text-muted-foreground";case"INFO":return"text-blue-500 dark:text-blue-400";case"WARNING":return"text-yellow-600 dark:text-yellow-500";case"ERROR":return"text-red-600 dark:text-red-500";case"CRITICAL":return"text-red-700 dark:text-red-400 font-bold";default:return"text-foreground"}},E=H=>{switch(H){case"DEBUG":return"bg-gray-800/30 dark:bg-gray-800/50";case"INFO":return"bg-blue-900/20 dark:bg-blue-500/20";case"WARNING":return"bg-yellow-900/20 dark:bg-yellow-500/20";case"ERROR":return"bg-red-900/20 dark:bg-red-500/20";case"CRITICAL":return"bg-red-900/30 dark:bg-red-600/30";default:return"bg-gray-800/20 dark:bg-gray-800/30"}},M=()=>{window.location.reload()},se=()=>{en.clearLogs(),i([])},fe=()=>{const H=je.map(me=>`${me.timestamp} [${me.level.padEnd(8)}] [${me.module}] ${me.message}`).join(`
`),ee=new Blob([H],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(ee),X=document.createElement("a");X.href=v,X.download=`logs-${bu(new Date,"yyyy-MM-dd-HHmmss")}.txt`,X.click(),URL.revokeObjectURL(v)},ve=()=>{k(!y)},Ne=()=>{N(void 0),w(void 0)},je=u.useMemo(()=>n.filter(H=>{const ee=r===""||H.message.toLowerCase().includes(r.toLowerCase())||H.module.toLowerCase().includes(r.toLowerCase()),v=m==="all"||H.level===m,X=f==="all"||H.module===f;let me=!0;if(g||j){const ce=new Date(H.timestamp);if(g){const xe=new Date(g);xe.setHours(0,0,0,0),me=me&&ce>=xe}if(j){const xe=new Date(j);xe.setHours(23,59,59,999),me=me&&ce<=xe}}return ee&&v&&X&&me}),[n,r,m,f,g,j]),ye=Uc[D].rowHeight+Q,Se=qb({count:je.length,getScrollElement:()=>z.current,estimateSize:()=>ye,overscan:15}),O=u.useRef(!1),G=u.useRef(je.length);return u.useEffect(()=>{const H=z.current;if(!H)return;const ee=()=>{if(O.current)return;const{scrollTop:v,scrollHeight:X,clientHeight:me}=H,ce=X-v-me;ce>100&&y?k(!1):ce<50&&!y&&k(!0)};return H.addEventListener("scroll",ee,{passive:!0}),()=>H.removeEventListener("scroll",ee)},[y]),u.useEffect(()=>{const H=je.length>G.current;G.current=je.length,y&&je.length>0&&H&&(O.current=!0,Se.scrollToIndex(je.length-1,{align:"end",behavior:"auto"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{O.current=!1})}))},[je.length,y,Se]),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 space-y-4 p-3 sm:p-4 lg:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold",children:"日志查看器"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"实时查看和分析麦麦运行日志"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:q("h-2.5 w-2.5 sm:h-3 sm:w-3 rounded-full",_?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:_?"已连接":"未连接"})]})]}),e.jsx(Qe,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{placeholder:"搜索日志...",value:r,onChange:H=>d(H.target.value),className:"pl-9 h-9 text-sm"})]}),e.jsxs(Re,{value:m,onValueChange:x,children:[e.jsxs(De,{className:"w-full sm:w-[140px] lg:w-[180px] h-9 text-sm",children:[e.jsx(Lu,{className:"h-4 w-4 mr-2"}),e.jsx(Le,{placeholder:"级别"})]}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部级别"}),e.jsx(le,{value:"DEBUG",children:"DEBUG"}),e.jsx(le,{value:"INFO",children:"INFO"}),e.jsx(le,{value:"WARNING",children:"WARNING"}),e.jsx(le,{value:"ERROR",children:"ERROR"}),e.jsx(le,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs(Re,{value:f,onValueChange:p,children:[e.jsxs(De,{className:"w-full sm:w-[160px] lg:w-[200px] h-9 text-sm",children:[e.jsx(Lu,{className:"h-4 w-4 mr-2"}),e.jsx(Le,{placeholder:"模块"})]}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部模块"}),I.map(H=>e.jsx(le,{value:H,children:H},H))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",className:q("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!g&&"text-muted-foreground"),children:[e.jsx(ep,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:g?bu(g,"PPP",{locale:Lc}):"开始日期"})]})}),e.jsx(ka,{className:"w-auto p-0",align:"start",children:e.jsx(wp,{mode:"single",selected:g,onSelect:N,initialFocus:!0,locale:Lc})})]}),e.jsxs(Ra,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(S,{variant:"outline",size:"sm",className:q("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!j&&"text-muted-foreground"),children:[e.jsx(ep,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:j?bu(j,"PPP",{locale:Lc}):"结束日期"})]})}),e.jsx(ka,{className:"w-auto p-0",align:"start",children:e.jsx(wp,{mode:"single",selected:j,onSelect:w,initialFocus:!0,locale:Lc})})]}),(g||j)&&e.jsxs(S,{variant:"outline",size:"sm",onClick:Ne,className:"w-full sm:w-auto h-9",children:[e.jsx(il,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline text-sm",children:"清除时间筛选"}),e.jsx("span",{className:"sm:hidden text-sm",children:"清除"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(S,{variant:y?"default":"outline",size:"sm",onClick:ve,className:"flex-1 sm:flex-none h-9",children:[y?e.jsx(py,{className:"h-4 w-4"}):e.jsx(gy,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:y?"自动滚动":"已暂停"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:M,className:"flex-1 sm:flex-none h-9",children:[e.jsx(zt,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"刷新"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:se,className:"flex-1 sm:flex-none h-9",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"清空"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:fe,className:"flex-1 sm:flex-none h-9",children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"导出"})]})]}),e.jsx("div",{className:"flex-1 hidden sm:block"}),e.jsxs("div",{className:"text-xs sm:text-sm text-muted-foreground flex items-center justify-center sm:justify-end",children:[e.jsxs("span",{className:"font-mono",children:[je.length," / ",n.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-6 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(jy,{className:"h-4 w-4"}),e.jsx("span",{children:"字号"})]}),e.jsx("div",{className:"flex gap-1",children:Object.keys(Uc).map(H=>e.jsx(S,{variant:D===H?"default":"outline",size:"sm",onClick:()=>U(H),className:"h-7 px-3 text-xs",children:Uc[H].label},H))})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-1 max-w-xs",children:[e.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"行距"}),e.jsx(fa,{value:[Q],onValueChange:([H])=>R(H),min:0,max:12,step:2,className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground w-8",children:[Q,"px"]})]})]})]})})]}),e.jsx("div",{className:"flex-1 min-h-0 px-3 sm:px-4 lg:px-6 pb-3 sm:pb-4 lg:pb-6",children:e.jsx(Qe,{className:"bg-black dark:bg-gray-950 border-gray-800 dark:border-gray-900 h-full",children:e.jsx(Ke,{viewportRef:z,className:"h-full",children:e.jsx("div",{className:q("p-2 sm:p-3 font-mono relative",Uc[D].class),style:{height:`${Se.getTotalSize()}px`},children:je.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-sm",children:"暂无日志数据"}):Se.getVirtualItems().map(H=>{const ee=je[H.index];return e.jsxs("div",{"data-index":H.index,ref:Se.measureElement,className:q("absolute top-0 left-0 w-full px-2 sm:px-3 rounded hover:bg-white/5 transition-colors group",E(ee.level)),style:{transform:`translateY(${H.start}px)`,paddingTop:`${Q/2}px`,paddingBottom:`${Q/2}px`},children:[e.jsxs("div",{className:"flex flex-col gap-0.5 sm:hidden",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600",children:ee.timestamp}),e.jsxs("span",{className:q("font-semibold",$(ee.level)),children:["[",ee.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 truncate",children:ee.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 whitespace-pre-wrap break-words",children:ee.message})]}),e.jsxs("div",{className:"hidden sm:flex gap-2 items-start",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600 flex-shrink-0 w-[130px] lg:w-[160px]",children:ee.timestamp}),e.jsxs("span",{className:q("flex-shrink-0 w-[65px] lg:w-[75px] font-semibold",$(ee.level)),children:["[",ee.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[100px] lg:w-[130px] truncate",children:ee.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 whitespace-pre-wrap break-words",children:ee.message})]})]},H.key)})})})})})]})}const c_="Mai-with-u",o_="plugin-repo",d_="main",u_="plugin_details.json";async function m_(){try{const n=await _e("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:c_,repo:o_,branch:d_,file_path:u_})});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const i=await n.json();if(!i.success||!i.data)throw new Error(i.error||"获取插件列表失败");return JSON.parse(i.data).filter(m=>!m?.id||!m?.manifest?(console.warn("跳过无效插件数据:",m),!1):!m.manifest.name||!m.manifest.version?(console.warn("跳过缺少必需字段的插件:",m.id),!1):!0).map(m=>({id:m.id,manifest:{manifest_version:m.manifest.manifest_version||1,name:m.manifest.name,version:m.manifest.version,description:m.manifest.description||"",author:m.manifest.author||{name:"Unknown"},license:m.manifest.license||"Unknown",host_application:m.manifest.host_application||{min_version:"0.0.0"},homepage_url:m.manifest.homepage_url,repository_url:m.manifest.repository_url,keywords:m.manifest.keywords||[],categories:m.manifest.categories||[],default_locale:m.manifest.default_locale||"zh-CN",locales_path:m.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(n){throw console.error("Failed to fetch plugin list:",n),n}}async function x_(){try{const n=await _e("/api/webui/plugins/git-status");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to check Git status:",n),{installed:!1,error:"无法检测 Git 安装状态"}}}async function h_(){try{const n=await _e("/api/webui/plugins/version");if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}catch(n){return console.error("Failed to get Maimai version:",n),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function f_(n,i,r){const d=n.split(".").map(p=>parseInt(p)||0),m=d[0]||0,x=d[1]||0,f=d[2]||0;if(r.version_major<m||r.version_major===m&&r.version_minor<x||r.version_major===m&&r.version_minor===x&&r.version_patch<f)return!1;if(i){const p=i.split(".").map(w=>parseInt(w)||0),g=p[0]||0,N=p[1]||0,j=p[2]||0;if(r.version_major>g||r.version_major===g&&r.version_minor>N||r.version_major===g&&r.version_minor===N&&r.version_patch>j)return!1}return!0}function p_(n,i){const r=window.location.protocol==="https:"?"wss:":"ws:",d=window.location.host,m=new WebSocket(`${r}//${d}/api/webui/ws/plugin-progress`);return m.onopen=()=>{console.log("Plugin progress WebSocket connected");const x=setInterval(()=>{m.readyState===WebSocket.OPEN?m.send("ping"):clearInterval(x)},3e4)},m.onmessage=x=>{try{if(x.data==="pong")return;const f=JSON.parse(x.data);n(f)}catch(f){console.error("Failed to parse progress data:",f)}},m.onerror=x=>{console.error("Plugin progress WebSocket error:",x),i?.(x)},m.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},m}async function nr(){try{const n=await _e("/api/webui/plugins/installed",{headers:As()});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const i=await n.json();if(!i.success)throw new Error(i.message||"获取已安装插件列表失败");return i.plugins||[]}catch(n){return console.error("Failed to get installed plugins:",n),[]}}function Bc(n,i){return i.some(r=>r.id===n)}function Hc(n,i){const r=i.find(d=>d.id===n);if(r)return r.manifest?.version||r.version}async function g_(n,i,r="main"){const d=await _e("/api/webui/plugins/install",{method:"POST",body:JSON.stringify({plugin_id:n,repository_url:i,branch:r})});if(!d.ok){const m=await d.json();throw new Error(m.detail||"安装失败")}return await d.json()}async function j_(n){const i=await _e("/api/webui/plugins/uninstall",{method:"POST",body:JSON.stringify({plugin_id:n})});if(!i.ok){const r=await i.json();throw new Error(r.detail||"卸载失败")}return await i.json()}async function v_(n,i,r="main"){const d=await _e("/api/webui/plugins/update",{method:"POST",body:JSON.stringify({plugin_id:n,repository_url:i,branch:r})});if(!d.ok){const m=await d.json();throw new Error(m.detail||"更新失败")}return await d.json()}async function b_(n){const i=await _e(`/api/webui/plugins/config/${n}/schema`,{headers:As()});if(!i.ok){const d=await i.json();throw new Error(d.detail||"获取配置 Schema 失败")}const r=await i.json();if(!r.success)throw new Error(r.message||"获取配置 Schema 失败");return r.schema}async function N_(n){const i=await _e(`/api/webui/plugins/config/${n}`,{headers:As()});if(!i.ok){const d=await i.json();throw new Error(d.detail||"获取配置失败")}const r=await i.json();if(!r.success)throw new Error(r.message||"获取配置失败");return r.config}async function y_(n,i){const r=await _e(`/api/webui/plugins/config/${n}`,{method:"PUT",body:JSON.stringify({config:i})});if(!r.ok){const d=await r.json();throw new Error(d.detail||"保存配置失败")}return await r.json()}async function w_(n){const i=await _e(`/api/webui/plugins/config/${n}/reset`,{method:"POST",headers:As()});if(!i.ok){const r=await i.json();throw new Error(r.detail||"重置配置失败")}return await i.json()}async function __(n){const i=await _e(`/api/webui/plugins/config/${n}/toggle`,{method:"POST",headers:As()});if(!i.ok){const r=await i.json();throw new Error(r.detail||"切换状态失败")}return await i.json()}const jr="https://maibot-plugin-stats.maibot-webui.workers.dev";async function Zg(n){try{const i=await fetch(`${jr}/stats/${n}`);return i.ok?await i.json():(console.error("Failed to fetch plugin stats:",i.statusText),null)}catch(i){return console.error("Error fetching plugin stats:",i),null}}async function S_(n,i){try{const r=i||tm(),d=await fetch(`${jr}/stats/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,user_id:r})}),m=await d.json();return d.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:d.ok?{success:!0,...m}:{success:!1,error:m.error||"点赞失败"}}catch(r){return console.error("Error liking plugin:",r),{success:!1,error:"网络错误"}}}async function C_(n,i){try{const r=i||tm(),d=await fetch(`${jr}/stats/dislike`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,user_id:r})}),m=await d.json();return d.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:d.ok?{success:!0,...m}:{success:!1,error:m.error||"点踩失败"}}catch(r){return console.error("Error disliking plugin:",r),{success:!1,error:"网络错误"}}}async function k_(n,i,r,d){if(i<1||i>5)return{success:!1,error:"评分必须在 1-5 之间"};try{const m=d||tm(),x=await fetch(`${jr}/stats/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n,rating:i,comment:r,user_id:m})}),f=await x.json();return x.status===429?{success:!1,error:"每天最多评分 3 次"}:x.ok?{success:!0,...f}:{success:!1,error:f.error||"评分失败"}}catch(m){return console.error("Error rating plugin:",m),{success:!1,error:"网络错误"}}}async function T_(n){try{const i=await fetch(`${jr}/stats/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:n})}),r=await i.json();return i.status===429?(console.warn("Download recording rate limited"),{success:!0}):i.ok?{success:!0,...r}:(console.error("Failed to record download:",r.error),{success:!1,error:r.error})}catch(i){return console.error("Error recording download:",i),{success:!1,error:"网络错误"}}}function E_(){const n=navigator,i=[navigator.userAgent,navigator.language,navigator.languages?.join(",")||"",navigator.platform,navigator.hardwareConcurrency||0,screen.width,screen.height,screen.colorDepth,screen.pixelDepth,new Date().getTimezoneOffset(),Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.maxTouchPoints||0,n.deviceMemory||0].join("|");let r=0;for(let d=0;d<i.length;d++){const m=i.charCodeAt(d);r=(r<<5)-r+m,r=r&r}return`fp_${Math.abs(r).toString(36)}`}function tm(){const n="maibot_user_id";let i=localStorage.getItem(n);if(!i){const r=E_(),d=Date.now().toString(36),m=Math.random().toString(36).substring(2,15);i=`${r}_${d}_${m}`,localStorage.setItem(n,i)}return i}function z_({pluginId:n,compact:i=!1}){const[r,d]=u.useState(null),[m,x]=u.useState(!0),[f,p]=u.useState(0),[g,N]=u.useState(""),[j,w]=u.useState(!1),{toast:y}=Bs(),k=async()=>{x(!0);const U=await Zg(n);U&&d(U),x(!1)};u.useEffect(()=>{k()},[n]);const _=async()=>{const U=await S_(n);U.success?(y({title:"已点赞",description:"感谢你的支持!"}),k()):y({title:"点赞失败",description:U.error||"未知错误",variant:"destructive"})},L=async()=>{const U=await C_(n);U.success?(y({title:"已反馈",description:"感谢你的反馈!"}),k()):y({title:"操作失败",description:U.error||"未知错误",variant:"destructive"})},D=async()=>{if(f===0){y({title:"请选择评分",description:"至少选择 1 颗星",variant:"destructive"});return}const U=await k_(n,f,g||void 0);U.success?(y({title:"评分成功",description:"感谢你的评价!"}),w(!1),p(0),N(""),k()):y({title:"评分失败",description:U.error||"未知错误",variant:"destructive"})};return m?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(nl,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ll,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]})]}):r?i?e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",title:`下载量: ${r.downloads.toLocaleString()}`,children:[e.jsx(nl,{className:"h-4 w-4"}),e.jsx("span",{children:r.downloads.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`评分: ${r.rating.toFixed(1)} (${r.rating_count} 条评价)`,children:[e.jsx(ll,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:r.rating.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`点赞数: ${r.likes}`,children:[e.jsx(yu,{className:"h-4 w-4"}),e.jsx("span",{children:r.likes})]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(nl,{className:"h-5 w-5 text-muted-foreground mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:r.downloads.toLocaleString()}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"下载量"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(ll,{className:"h-5 w-5 text-yellow-400 mb-1 fill-yellow-400"}),e.jsx("span",{className:"text-2xl font-bold",children:r.rating.toFixed(1)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.rating_count," 条评价"]})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(yu,{className:"h-5 w-5 text-green-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:r.likes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点赞"})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(sp,{className:"h-5 w-5 text-red-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:r.dislikes}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"点踩"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:_,children:[e.jsx(yu,{className:"h-4 w-4 mr-1"}),"点赞"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:L,children:[e.jsx(sp,{className:"h-4 w-4 mr-1"}),"点踩"]}),e.jsxs(Gs,{open:j,onOpenChange:w,children:[e.jsx(Pu,{asChild:!0,children:e.jsxs(S,{variant:"default",size:"sm",children:[e.jsx(ll,{className:"h-4 w-4 mr-1"}),"评分"]})}),e.jsxs(Rs,{children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"为插件评分"}),e.jsx(Ps,{children:"分享你的使用体验,帮助其他用户"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"flex gap-2",children:[1,2,3,4,5].map(U=>e.jsx("button",{onClick:()=>p(U),className:"focus:outline-none",children:e.jsx(ll,{className:`h-8 w-8 transition-colors ${U<=f?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-300"}`})},U))}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f===0&&"点击星星进行评分",f===1&&"很差",f===2&&"一般",f===3&&"还行",f===4&&"不错",f===5&&"非常好"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"评论(可选)"}),e.jsx(Ms,{value:g,onChange:U=>N(U.target.value),placeholder:"分享你的使用体验...",rows:4,maxLength:500}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 text-right",children:[g.length," / 500"]})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>w(!1),children:"取消"}),e.jsx(S,{onClick:D,disabled:f===0,children:"提交评分"})]})]})]})]}),r.recent_ratings&&r.recent_ratings.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold",children:"最近评价"}),e.jsx("div",{className:"space-y-3",children:r.recent_ratings.map((U,Q)=>e.jsxs("div",{className:"p-3 rounded-lg border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(R=>e.jsx(ll,{className:`h-3 w-3 ${R<=U.rating?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},R))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(U.created_at).toLocaleDateString()})]}),U.comment&&e.jsx("p",{className:"text-sm text-muted-foreground",children:U.comment})]},Q))})]})]}):null}const Sp={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function M_(){const n=ja(),[i,r]=u.useState(null),[d,m]=u.useState(""),[x,f]=u.useState("all"),[p,g]=u.useState("all"),[N,j]=u.useState(!0),[w,y]=u.useState([]),[k,_]=u.useState(!0),[L,D]=u.useState(null),[U,Q]=u.useState(null),[R,z]=u.useState(null),[I,$]=u.useState(null),[,E]=u.useState([]),[M,se]=u.useState({}),{toast:fe}=Bs(),ve=async v=>{const X=v.map(async xe=>{try{const we=await Zg(xe.id);return{id:xe.id,stats:we}}catch(we){return console.warn(`Failed to load stats for ${xe.id}:`,we),{id:xe.id,stats:null}}}),me=await Promise.all(X),ce={};me.forEach(({id:xe,stats:we})=>{we&&(ce[xe]=we)}),se(ce)};u.useEffect(()=>{let v=null,X=!1;return(async()=>{if(v=p_(ce=>{X||(z(ce),ce.stage==="success"?setTimeout(()=>{X||z(null)},2e3):ce.stage==="error"&&(_(!1),D(ce.error||"加载失败")))},ce=>{console.error("WebSocket error:",ce),X||fe({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise(ce=>{if(!v){ce();return}const xe=()=>{v&&v.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),ce()):v&&v.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),ce()):setTimeout(xe,100)};xe()}),!X){const ce=await x_();Q(ce),ce.installed||fe({title:"Git 未安装",description:ce.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!X){const ce=await h_();$(ce)}if(!X)try{_(!0),D(null);const ce=await m_();if(!X){const xe=await nr();E(xe);const we=ce.map(oe=>{const Z=Bc(oe.id,xe),te=Hc(oe.id,xe);return{...oe,installed:Z,installed_version:te}});for(const oe of xe)!we.some(te=>te.id===oe.id)&&oe.manifest&&we.push({id:oe.id,manifest:{manifest_version:oe.manifest.manifest_version||1,name:oe.manifest.name,version:oe.manifest.version,description:oe.manifest.description||"",author:oe.manifest.author,license:oe.manifest.license||"Unknown",host_application:oe.manifest.host_application,homepage_url:oe.manifest.homepage_url,repository_url:oe.manifest.repository_url,keywords:oe.manifest.keywords||[],categories:oe.manifest.categories||[],default_locale:oe.manifest.default_locale||"zh-CN",locales_path:oe.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:oe.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});y(we),ve(we)}}catch(ce){if(!X){const xe=ce instanceof Error?ce.message:"加载插件列表失败";D(xe),fe({title:"加载失败",description:xe,variant:"destructive"})}}finally{X||_(!1)}})(),()=>{X=!0,v&&v.close()}},[fe]);const Ne=v=>{if(!v.installed&&I&&!je(v))return e.jsxs(Fe,{variant:"destructive",className:"gap-1",children:[e.jsx(Mt,{className:"h-3 w-3"}),"不兼容"]});if(v.installed){const X=v.installed_version?.trim(),me=v.manifest.version?.trim();if(X!==me){const ce=X?.split(".").map(Number)||[0,0,0],xe=me?.split(".").map(Number)||[0,0,0];for(let we=0;we<3;we++){if((xe[we]||0)>(ce[we]||0))return e.jsxs(Fe,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(Mt,{className:"h-3 w-3"}),"可更新"]});if((xe[we]||0)<(ce[we]||0))break}}return e.jsxs(Fe,{variant:"default",className:"gap-1",children:[e.jsx(aa,{className:"h-3 w-3"}),"已安装"]})}return null},je=v=>!I||!v.manifest?.host_application?!0:f_(v.manifest.host_application.min_version,v.manifest.host_application.max_version,I),ye=v=>{if(!v.installed||!v.installed_version||!v.manifest?.version)return!1;const X=v.installed_version.trim(),me=v.manifest.version.trim();if(X===me)return!1;const ce=X.split(".").map(Number),xe=me.split(".").map(Number);for(let we=0;we<3;we++){if((xe[we]||0)>(ce[we]||0))return!0;if((xe[we]||0)<(ce[we]||0))return!1}return!1},Se=w.filter(v=>{if(!v.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",v.id),!1;const X=d===""||v.manifest.name?.toLowerCase().includes(d.toLowerCase())||v.manifest.description?.toLowerCase().includes(d.toLowerCase())||v.manifest.keywords&&v.manifest.keywords.some(we=>we.toLowerCase().includes(d.toLowerCase())),me=x==="all"||v.manifest.categories&&v.manifest.categories.includes(x);let ce=!0;p==="installed"?ce=v.installed===!0:p==="updates"&&(ce=v.installed===!0&&ye(v));const xe=!N||!I||je(v);return X&&me&&ce&&xe}),O=()=>{r(null)},G=async v=>{if(!U?.installed){fe({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(I&&!je(v)){fe({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}try{await g_(v.id,v.manifest.repository_url||"","main"),T_(v.id).catch(me=>{console.warn("Failed to record download:",me)}),fe({title:"安装成功",description:`${v.manifest.name} 已成功安装`});const X=await nr();E(X),y(me=>me.map(ce=>{if(ce.id===v.id){const xe=Bc(ce.id,X),we=Hc(ce.id,X);return{...ce,installed:xe,installed_version:we}}return ce}))}catch(X){fe({title:"安装失败",description:X instanceof Error?X.message:"未知错误",variant:"destructive"})}},H=async v=>{try{await j_(v.id),fe({title:"卸载成功",description:`${v.manifest.name} 已成功卸载`});const X=await nr();E(X),y(me=>me.map(ce=>{if(ce.id===v.id){const xe=Bc(ce.id,X),we=Hc(ce.id,X);return{...ce,installed:xe,installed_version:we}}return ce}))}catch(X){fe({title:"卸载失败",description:X instanceof Error?X.message:"未知错误",variant:"destructive"})}},ee=async v=>{if(!U?.installed){fe({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const X=await v_(v.id,v.manifest.repository_url||"","main");fe({title:"更新成功",description:`${v.manifest.name} 已从 ${X.old_version} 更新到 ${X.new_version}`});const me=await nr();E(me),y(ce=>ce.map(xe=>{if(xe.id===v.id){const we=Bc(xe.id,me),oe=Hc(xe.id,me);return{...xe,installed:we,installed_version:oe}}return xe}))}catch(X){fe({title:"更新失败",description:X instanceof Error?X.message:"未知错误",variant:"destructive"})}};return e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件市场"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"浏览和管理麦麦的插件"})]}),e.jsxs(S,{onClick:()=>n({to:"/plugin-mirrors"}),children:[e.jsx(vy,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]}),U&&!U.installed&&e.jsxs(Qe,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Sa,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(ts,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(st,{className:"text-orange-800 dark:text-orange-200",children:U.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(ps,{children:e.jsxs("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:["您可以从 ",e.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noopener noreferrer",className:"underline font-medium",children:"git-scm.com"})," 下载并安装 Git。 安装完成后,请重启麦麦应用。"]})})]}),e.jsx(Qe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{placeholder:"搜索插件...",value:d,onChange:v=>m(v.target.value),className:"pl-9"})]}),e.jsxs(Re,{value:x,onValueChange:f,children:[e.jsx(De,{className:"w-full sm:w-[200px]",children:e.jsx(Le,{placeholder:"选择分类"})}),e.jsxs(Oe,{children:[e.jsx(le,{value:"all",children:"全部分类"}),e.jsx(le,{value:"Group Management",children:"群组管理"}),e.jsx(le,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(le,{value:"Utility Tools",children:"实用工具"}),e.jsx(le,{value:"Content Generation",children:"内容生成"}),e.jsx(le,{value:"Multimedia",children:"多媒体"}),e.jsx(le,{value:"External Integration",children:"外部集成"}),e.jsx(le,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(le,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ft,{id:"compatible-only",checked:N,onCheckedChange:v=>j(v===!0)}),e.jsx("label",{htmlFor:"compatible-only",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:"只显示兼容当前版本的插件"})]})]})}),e.jsx(Ca,{value:p,onValueChange:g,className:"w-full",children:e.jsxs(pa,{className:"grid w-full grid-cols-3",children:[e.jsxs(es,{value:"all",children:["全部插件 (",w.filter(v=>{if(!v.manifest)return!1;const X=d===""||v.manifest.name?.toLowerCase().includes(d.toLowerCase())||v.manifest.description?.toLowerCase().includes(d.toLowerCase())||v.manifest.keywords&&v.manifest.keywords.some(xe=>xe.toLowerCase().includes(d.toLowerCase())),me=x==="all"||v.manifest.categories&&v.manifest.categories.includes(x),ce=!N||!I||je(v);return X&&me&&ce}).length,")"]}),e.jsxs(es,{value:"installed",children:["已安装 (",w.filter(v=>{if(!v.manifest)return!1;const X=d===""||v.manifest.name?.toLowerCase().includes(d.toLowerCase())||v.manifest.description?.toLowerCase().includes(d.toLowerCase())||v.manifest.keywords&&v.manifest.keywords.some(xe=>xe.toLowerCase().includes(d.toLowerCase())),me=x==="all"||v.manifest.categories&&v.manifest.categories.includes(x),ce=!N||!I||je(v);return v.installed&&X&&me&&ce}).length,")"]}),e.jsxs(es,{value:"updates",children:["可更新 (",w.filter(v=>{if(!v.manifest)return!1;const X=d===""||v.manifest.name?.toLowerCase().includes(d.toLowerCase())||v.manifest.description?.toLowerCase().includes(d.toLowerCase())||v.manifest.keywords&&v.manifest.keywords.some(xe=>xe.toLowerCase().includes(d.toLowerCase())),me=x==="all"||v.manifest.categories&&v.manifest.categories.includes(x),ce=!N||!I||je(v);return v.installed&&ye(v)&&X&&me&&ce}).length,")"]})]})}),R&&R.stage==="loading"&&e.jsx(Qe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Js,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm font-medium",children:[R.operation==="fetch"&&"加载插件列表",R.operation==="install"&&`安装插件${R.plugin_id?`: ${R.plugin_id}`:""}`,R.operation==="uninstall"&&`卸载插件${R.plugin_id?`: ${R.plugin_id}`:""}`,R.operation==="update"&&`更新插件${R.plugin_id?`: ${R.plugin_id}`:""}`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[R.progress,"%"]})]}),e.jsx(ni,{value:R.progress,className:"h-2"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:R.message}),R.operation==="fetch"&&R.total_plugins>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["已加载 ",R.loaded_plugins," / ",R.total_plugins," 个插件"]})]})}),R&&R.stage==="error"&&R.error&&e.jsx(Qe,{className:"border-destructive bg-destructive/10",children:e.jsx(ss,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Sa,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(ts,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(st,{className:"text-destructive/80",children:R.error})]})]})})}),k?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Js,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):L?e.jsx(Qe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Sa,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"加载失败"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:L}),e.jsx(S,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):Se.length===0?e.jsx(Qe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(At,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未找到插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d||x!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Se.map(v=>e.jsxs(Qe,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(ss,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(ts,{className:"text-xl",children:v.manifest?.name||v.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[v.manifest?.categories&&v.manifest.categories[0]&&e.jsx(Fe,{variant:"secondary",className:"text-xs whitespace-nowrap",children:Sp[v.manifest.categories[0]]||v.manifest.categories[0]}),Ne(v)]})]}),e.jsx(st,{className:"line-clamp-2",children:v.manifest?.description||"无描述"})]}),e.jsx(ps,{className:"flex-1",children:e.jsxs("div",{className:"space-y-3",children:[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(nl,{className:"h-4 w-4"}),e.jsx("span",{children:(M[v.id]?.downloads??v.downloads??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ll,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:(M[v.id]?.rating??v.rating??0).toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[v.manifest?.keywords&&v.manifest.keywords.slice(0,3).map(X=>e.jsx(Fe,{variant:"outline",className:"text-xs",children:X},X)),v.manifest?.keywords&&v.manifest.keywords.length>3&&e.jsxs(Fe,{variant:"outline",className:"text-xs",children:["+",v.manifest.keywords.length-3]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground pt-2 border-t space-y-1",children:[e.jsxs("div",{children:["v",v.manifest?.version||"unknown"," · ",v.manifest?.author?.name||"Unknown"]}),v.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[v.manifest.host_application.min_version,v.manifest.host_application.max_version?` - ${v.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(Tg,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[e.jsx(S,{variant:"outline",size:"sm",onClick:()=>r(v),children:"查看详情"}),v.installed?ye(v)?e.jsxs(S,{size:"sm",disabled:!U?.installed,title:U?.installed?void 0:"Git 未安装",onClick:()=>ee(v),children:[e.jsx(zt,{className:"h-4 w-4 mr-1"}),"更新"]}):e.jsxs(S,{variant:"destructive",size:"sm",disabled:!U?.installed,title:U?.installed?void 0:"Git 未安装",onClick:()=>H(v),children:[e.jsx(Ze,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(S,{size:"sm",disabled:!U?.installed||R?.operation==="install"||I!==null&&!je(v),title:U?.installed?I!==null&&!je(v)?`不兼容当前版本 (需要 ${v.manifest?.host_application?.min_version||"未知"}${v.manifest?.host_application?.max_version?` - ${v.manifest.host_application.max_version}`:"+"},当前 ${I?.version})`:void 0:"Git 未安装",onClick:()=>G(v),children:[e.jsx(nl,{className:"h-4 w-4 mr-1"}),R?.operation==="install"&&R?.plugin_id===v.id?"安装中...":"安装"]})]})})]},v.id))}),e.jsx(Gs,{open:i!==null,onOpenChange:O,children:i&&i.manifest&&e.jsx(Rs,{className:"max-w-2xl max-h-[80vh] p-0 flex flex-col",children:e.jsx(Ke,{className:"flex-1 overflow-auto",children:e.jsxs("div",{className:"p-6",children:[e.jsx(Ls,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(Us,{className:"text-2xl",children:i.manifest.name}),e.jsxs(Ps,{children:["作者: ",i.manifest.author?.name||"Unknown",i.manifest.author?.url&&e.jsx("a",{href:i.manifest.author.url,target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-primary hover:underline",children:e.jsx(qc,{className:"h-3 w-3 inline"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[i.manifest.categories&&i.manifest.categories[0]&&e.jsx(Fe,{variant:"secondary",children:Sp[i.manifest.categories[0]]||i.manifest.categories[0]}),Ne(i)]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(z_,{pluginId:i.id}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["v",i.manifest?.version||"unknown"]}),i.installed&&i.installed_version&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["已安装: v",i.installed_version]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"下载量"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(M[i.id]?.downloads??i.downloads??0).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"评分"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ll,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(M[i.id]?.rating??i.rating??0).toFixed(1)," (",M[i.id]?.rating_count??i.review_count??0,")"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"许可证"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i.manifest.license||"Unknown"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"支持版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.manifest.host_application?.min_version||"未知",i.manifest.host_application?.max_version?` - ${i.manifest.host_application.max_version}`:" - 最新版本"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"关键词"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.manifest.keywords&&i.manifest.keywords.map(v=>e.jsx(Fe,{variant:"outline",children:v},v))})]}),i.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"详细说明"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line",children:i.detailed_description})]}),!i.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"说明"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i.manifest.description||"无描述"})]}),e.jsxs("div",{className:"space-y-2",children:[i.manifest.homepage_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"主页: "}),e.jsx("a",{href:i.manifest.homepage_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:i.manifest.homepage_url})]}),i.manifest.repository_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"仓库: "}),e.jsx("a",{href:i.manifest.repository_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:i.manifest.repository_url})]})]})]}),e.jsxs(at,{children:[i.manifest.homepage_url&&e.jsxs(S,{onClick:()=>window.open(i.manifest.homepage_url,"_blank"),children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),"访问主页"]}),i.manifest.repository_url&&e.jsxs(S,{variant:"outline",onClick:()=>window.open(i.manifest.repository_url,"_blank"),children:[e.jsx(qc,{className:"h-4 w-4 mr-2"}),"查看仓库"]})]})]})})})})]})})}const Fu=hN,Vu=fN,$u=pN;function A_({field:n,value:i,onChange:r}){const[d,m]=u.useState(!1);switch(n.ui_type){case"switch":return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:n.label}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]}),e.jsx(Ve,{checked:!!i,onCheckedChange:r,disabled:n.disabled})]});case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:n.label}),e.jsx(ie,{type:"number",value:i??n.default,onChange:x=>r(parseFloat(x.target.value)||0),min:n.min,max:n.max,step:n.step??1,placeholder:n.placeholder,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"slider":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:n.label}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i??n.default})]}),e.jsx(fa,{value:[i??n.default],onValueChange:x=>r(x[0]),min:n.min??0,max:n.max??100,step:n.step??1,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:n.label}),e.jsxs(Re,{value:String(i??n.default),onValueChange:r,disabled:n.disabled,children:[e.jsx(De,{children:e.jsx(Le,{placeholder:n.placeholder??"请选择"})}),e.jsx(Oe,{children:n.choices?.map(x=>e.jsx(le,{value:String(x),children:String(x)},String(x)))})]}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:n.label}),e.jsx(Ms,{value:i??n.default,onChange:x=>r(x.target.value),placeholder:n.placeholder,rows:n.rows??3,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"password":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:n.label}),e.jsxs("div",{className:"relative",children:[e.jsx(ie,{type:d?"text":"password",value:i??"",onChange:x=>r(x.target.value),placeholder:n.placeholder,disabled:n.disabled,className:"pr-10"}),e.jsx(S,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3",onClick:()=>m(!d),children:d?e.jsx(or,{className:"h-4 w-4"}):e.jsx(Rt,{className:"h-4 w-4"})})]}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]});case"text":default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:n.label}),e.jsx(ie,{type:"text",value:i??n.default??"",onChange:x=>r(x.target.value),placeholder:n.placeholder,maxLength:n.max_length,disabled:n.disabled}),n.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.hint})]})}}function Cp({section:n,config:i,onChange:r}){const[d,m]=u.useState(!n.collapsed),x=Object.entries(n.fields).filter(([,f])=>!f.hidden).sort(([,f],[,p])=>f.order-p.order);return e.jsx(Fu,{open:d,onOpenChange:m,children:e.jsxs(Qe,{children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d?e.jsx(Ol,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ts,{className:"text-lg",children:n.title})]}),e.jsxs(Fe,{variant:"secondary",className:"text-xs",children:[x.length," 项"]})]}),n.description&&e.jsx(st,{className:"ml-6",children:n.description})]})}),e.jsx($u,{children:e.jsx(ps,{className:"space-y-4 pt-0",children:x.map(([f,p])=>e.jsx(A_,{field:p,value:i[n.name]?.[f],onChange:g=>r(n.name,f,g),sectionName:n.name},f))})})]})})}function D_({plugin:n,onBack:i}){const{toast:r}=Bs(),[d,m]=u.useState(null),[x,f]=u.useState({}),[p,g]=u.useState({}),[N,j]=u.useState(!0),[w,y]=u.useState(!1),[k,_]=u.useState(!1),[L,D]=u.useState(!1),U=u.useCallback(async()=>{j(!0);try{const[M,se]=await Promise.all([b_(n.id),N_(n.id)]);m(M),f(se),g(JSON.parse(JSON.stringify(se)))}catch(M){r({title:"加载配置失败",description:M instanceof Error?M.message:"未知错误",variant:"destructive"})}finally{j(!1)}},[n.id,r]);u.useEffect(()=>{U()},[U]),u.useEffect(()=>{_(JSON.stringify(x)!==JSON.stringify(p))},[x,p]);const Q=(M,se,fe)=>{f(ve=>({...ve,[M]:{...ve[M]||{},[se]:fe}}))},R=async()=>{y(!0);try{await y_(n.id,x),g(JSON.parse(JSON.stringify(x))),r({title:"配置已保存",description:"更改将在插件重新加载后生效"})}catch(M){r({title:"保存失败",description:M instanceof Error?M.message:"未知错误",variant:"destructive"})}finally{y(!1)}},z=async()=>{try{await w_(n.id),r({title:"配置已重置",description:"下次加载插件时将使用默认配置"}),D(!1),U()}catch(M){r({title:"重置失败",description:M instanceof Error?M.message:"未知错误",variant:"destructive"})}},I=async()=>{try{const M=await __(n.id);r({title:M.message,description:M.note}),U()}catch(M){r({title:"切换状态失败",description:M instanceof Error?M.message:"未知错误",variant:"destructive"})}};if(N)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(Js,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!d)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 space-y-4",children:[e.jsx(Mt,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"无法加载配置"}),e.jsxs(S,{onClick:i,variant:"outline",children:[e.jsx(Wn,{className:"h-4 w-4 mr-2"}),"返回"]})]});const $=Object.values(d.sections).sort((M,se)=>M.order-se.order),E=x.plugin?.enabled!==!1;return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(S,{variant:"ghost",size:"icon",onClick:i,children:e.jsx(Wn,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:d.plugin_info.name||n.manifest.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Fe,{variant:E?"default":"secondary",children:E?"已启用":"已禁用"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",d.plugin_info.version||n.manifest.version]})]})]})]}),e.jsxs("div",{className:"flex gap-2 ml-10 sm:ml-0",children:[e.jsxs(S,{variant:"outline",size:"sm",onClick:I,children:[e.jsx(pr,{className:"h-4 w-4 mr-2"}),E?"禁用":"启用"]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:()=>D(!0),children:[e.jsx(Vc,{className:"h-4 w-4 mr-2"}),"重置"]}),e.jsxs(S,{size:"sm",onClick:R,disabled:!k||w,children:[w?e.jsx(Js,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(gr,{className:"h-4 w-4 mr-2"}),"保存"]})]})]}),k&&e.jsx(Qe,{className:"border-orange-200 bg-orange-50 dark:bg-orange-950/20 dark:border-orange-900",children:e.jsx(ps,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Oa,{className:"h-4 w-4 text-orange-600"}),e.jsx("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:"有未保存的更改"})]})})}),d.layout.type==="tabs"&&d.layout.tabs.length>0?e.jsxs(Ca,{defaultValue:d.layout.tabs[0]?.id,children:[e.jsx(pa,{children:d.layout.tabs.map(M=>e.jsxs(es,{value:M.id,children:[M.title,M.badge&&e.jsx(Fe,{variant:"secondary",className:"ml-2 text-xs",children:M.badge})]},M.id))}),d.layout.tabs.map(M=>e.jsx(ws,{value:M.id,className:"space-y-4 mt-4",children:M.sections.map(se=>{const fe=d.sections[se];return fe?e.jsx(Cp,{section:fe,config:x,onChange:Q},se):null})},M.id))]}):e.jsx("div",{className:"space-y-4",children:$.map(M=>e.jsx(Cp,{section:M,config:x,onChange:Q},M.name))}),e.jsx(Gs,{open:L,onOpenChange:D,children:e.jsxs(Rs,{children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"确认重置配置"}),e.jsx(Ps,{children:"这将删除当前配置文件,下次加载插件时将使用默认配置。此操作不可撤销。"})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>D(!1),children:"取消"}),e.jsx(S,{variant:"destructive",onClick:z,children:"确认重置"})]})]})})]})}function O_(){const{toast:n}=Bs(),[i,r]=u.useState([]),[d,m]=u.useState(!0),[x,f]=u.useState(""),[p,g]=u.useState(null),N=async()=>{m(!0);try{const k=await nr();r(k)}catch(k){n({title:"加载插件列表失败",description:k instanceof Error?k.message:"未知错误",variant:"destructive"})}finally{m(!1)}};u.useEffect(()=>{N()},[]);const j=i.filter(k=>{const _=x.toLowerCase();return k.id.toLowerCase().includes(_)||k.manifest.name.toLowerCase().includes(_)||k.manifest.description?.toLowerCase().includes(_)}),w=i.length,y=0;return p?e.jsx(Ke,{className:"h-full",children:e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(D_,{plugin:p,onBack:()=>g(null)})})}):e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理和配置已安装的插件"})]}),e.jsxs(S,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(zt,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"刷新"]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ps,{children:[e.jsx("div",{className:"text-2xl font-bold",children:i.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:d?"正在加载...":"个插件"})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"已启用"}),e.jsx(aa,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(ps,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"运行中的插件"})]})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ts,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(Mt,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(ps,{children:[e.jsx("div",{className:"text-2xl font-bold",children:y}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"未激活的插件"})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{placeholder:"搜索插件...",value:x,onChange:k=>f(k.target.value),className:"pl-9"})]}),e.jsxs(Qe,{children:[e.jsxs(ss,{children:[e.jsx(ts,{children:"已安装的插件"}),e.jsx(st,{children:"点击插件查看和编辑配置"})]}),e.jsx(ps,{children:d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Js,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):j.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(tn,{className:"h-16 w-16 text-muted-foreground/50"}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-lg font-medium text-muted-foreground",children:x?"没有找到匹配的插件":"暂无已安装的插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x?"尝试其他搜索关键词":"前往插件市场安装插件"})]})]}):e.jsx("div",{className:"space-y-2",children:j.map(k=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>g(k),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(tn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-medium truncate",children:k.manifest.name}),e.jsxs(Fe,{variant:"secondary",className:"text-xs flex-shrink-0",children:["v",k.manifest.version]})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:k.manifest.description||"暂无描述"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(S,{variant:"ghost",size:"sm",children:e.jsx(ti,{className:"h-4 w-4"})}),e.jsx(Ua,{className:"h-4 w-4 text-muted-foreground"})]})]},k.id))})})]})]})})}function R_(){const n=ja(),{toast:i}=Bs(),[r,d]=u.useState([]),[m,x]=u.useState(!0),[f,p]=u.useState(null),[g,N]=u.useState(null),[j,w]=u.useState(!1),[y,k]=u.useState(!1),[_,L]=u.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),D=u.useCallback(async()=>{try{x(!0),p(null);const E=localStorage.getItem("access-token"),M=await fetch("/api/webui/plugins/mirrors",{headers:{Authorization:`Bearer ${E}`}});if(!M.ok)throw new Error("获取镜像源列表失败");const se=await M.json();d(se.mirrors||[])}catch(E){const M=E instanceof Error?E.message:"加载镜像源失败";p(M),i({title:"加载失败",description:M,variant:"destructive"})}finally{x(!1)}},[i]);u.useEffect(()=>{D()},[D]);const U=async()=>{try{const E=localStorage.getItem("access-token"),M=await fetch("/api/webui/plugins/mirrors",{method:"POST",headers:{Authorization:`Bearer ${E}`,"Content-Type":"application/json"},body:JSON.stringify(_)});if(!M.ok){const se=await M.json();throw new Error(se.detail||"添加镜像源失败")}i({title:"添加成功",description:"镜像源已添加"}),w(!1),L({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),D()}catch(E){i({title:"添加失败",description:E instanceof Error?E.message:"未知错误",variant:"destructive"})}},Q=async()=>{if(g)try{const E=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${g.id}`,{method:"PUT",headers:{Authorization:`Bearer ${E}`,"Content-Type":"application/json"},body:JSON.stringify({name:_.name,raw_prefix:_.raw_prefix,clone_prefix:_.clone_prefix,enabled:_.enabled,priority:_.priority})})).ok)throw new Error("更新镜像源失败");i({title:"更新成功",description:"镜像源已更新"}),k(!1),N(null),D()}catch(E){i({title:"更新失败",description:E instanceof Error?E.message:"未知错误",variant:"destructive"})}},R=async E=>{if(confirm("确定要删除这个镜像源吗?"))try{const M=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${M}`}})).ok)throw new Error("删除镜像源失败");i({title:"删除成功",description:"镜像源已删除"}),D()}catch(M){i({title:"删除失败",description:M instanceof Error?M.message:"未知错误",variant:"destructive"})}},z=async E=>{try{const M=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${E.id}`,{method:"PUT",headers:{Authorization:`Bearer ${M}`,"Content-Type":"application/json"},body:JSON.stringify({enabled:!E.enabled})})).ok)throw new Error("更新状态失败");D()}catch(M){i({title:"更新失败",description:M instanceof Error?M.message:"未知错误",variant:"destructive"})}},I=E=>{N(E),L({id:E.id,name:E.name,raw_prefix:E.raw_prefix,clone_prefix:E.clone_prefix,enabled:E.enabled,priority:E.priority}),k(!0)},$=async(E,M)=>{const se=M==="up"?E.priority-1:E.priority+1;if(!(se<1))try{const fe=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${E.id}`,{method:"PUT",headers:{Authorization:`Bearer ${fe}`,"Content-Type":"application/json"},body:JSON.stringify({priority:se})})).ok)throw new Error("更新优先级失败");D()}catch(fe){i({title:"更新失败",description:fe instanceof Error?fe.message:"未知错误",variant:"destructive"})}};return e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(S,{variant:"ghost",size:"icon",onClick:()=>n({to:"/plugins"}),children:e.jsx(Wn,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"镜像源配置"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"管理 Git 克隆和文件下载的镜像源"})]})]}),e.jsxs(S,{onClick:()=>w(!0),children:[e.jsx(rt,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),m?e.jsx(Qe,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Js,{className:"h-8 w-8 animate-spin text-primary"})})}):f?e.jsx(Qe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Sa,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"加载失败"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:f}),e.jsx(S,{onClick:D,children:"重新加载"})]})}):e.jsxs(Qe,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(nn,{children:[e.jsx(rn,{children:e.jsxs(ct,{children:[e.jsx(Xe,{children:"状态"}),e.jsx(Xe,{children:"名称"}),e.jsx(Xe,{children:"ID"}),e.jsx(Xe,{children:"优先级"}),e.jsx(Xe,{className:"text-right",children:"操作"})]})}),e.jsx(cn,{children:r.map(E=>e.jsxs(ct,{children:[e.jsx(Ge,{children:e.jsx(Ve,{checked:E.enabled,onCheckedChange:()=>z(E)})}),e.jsx(Ge,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:E.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",E.raw_prefix]})]})}),e.jsx(Ge,{children:e.jsx(Fe,{variant:"outline",children:E.id})}),e.jsx(Ge,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:E.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(S,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>$(E,"up"),disabled:E.priority===1,children:e.jsx(ur,{className:"h-3 w-3"})}),e.jsx(S,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>$(E,"down"),children:e.jsx(Ol,{className:"h-3 w-3"})})]})]})}),e.jsx(Ge,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(S,{variant:"ghost",size:"icon",onClick:()=>I(E),children:e.jsx(an,{className:"h-4 w-4"})}),e.jsx(S,{variant:"ghost",size:"icon",onClick:()=>R(E.id),children:e.jsx(Ze,{className:"h-4 w-4 text-destructive"})})]})})]},E.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:r.map(E=>e.jsx(Qe,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:E.name}),E.enabled&&e.jsx(Fe,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(Fe,{variant:"outline",className:"mt-1 text-xs",children:E.id})]}),e.jsx(Ve,{checked:E.enabled,onCheckedChange:()=>z(E)})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Raw: "}),e.jsx("span",{className:"break-all",children:E.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:E.priority})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t",children:[e.jsxs(S,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>I(E),children:[e.jsx(an,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>$(E,"up"),disabled:E.priority===1,children:e.jsx(ur,{className:"h-4 w-4"})}),e.jsx(S,{variant:"outline",size:"sm",onClick:()=>$(E,"down"),children:e.jsx(Ol,{className:"h-4 w-4"})}),e.jsx(S,{variant:"destructive",size:"sm",onClick:()=>R(E.id),children:e.jsx(Ze,{className:"h-4 w-4"})})]})]})},E.id))})]}),e.jsx(Gs,{open:j,onOpenChange:w,children:e.jsxs(Rs,{className:"max-w-lg",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"添加镜像源"}),e.jsx(Ps,{children:"添加新的 Git 镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"add-id",children:"镜像源 ID *"}),e.jsx(ie,{id:"add-id",placeholder:"例如: my-mirror",value:_.id,onChange:E=>L({..._,id:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"add-name",children:"名称 *"}),e.jsx(ie,{id:"add-name",placeholder:"例如: 我的镜像源",value:_.name,onChange:E=>L({..._,name:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(ie,{id:"add-raw",placeholder:"https://example.com/raw",value:_.raw_prefix,onChange:E=>L({..._,raw_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(ie,{id:"add-clone",placeholder:"https://example.com/clone",value:_.clone_prefix,onChange:E=>L({..._,clone_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"add-priority",children:"优先级"}),e.jsx(ie,{id:"add-priority",type:"number",min:"1",value:_.priority,onChange:E=>L({..._,priority:parseInt(E.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"add-enabled",checked:_.enabled,onCheckedChange:E=>L({..._,enabled:E})}),e.jsx(C,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>w(!1),children:"取消"}),e.jsx(S,{onClick:U,children:"添加"})]})]})}),e.jsx(Gs,{open:y,onOpenChange:k,children:e.jsxs(Rs,{className:"max-w-lg",children:[e.jsxs(Ls,{children:[e.jsx(Us,{children:"编辑镜像源"}),e.jsx(Ps,{children:"修改镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"镜像源 ID"}),e.jsx(ie,{value:_.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(ie,{id:"edit-name",value:_.name,onChange:E=>L({..._,name:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(ie,{id:"edit-raw",value:_.raw_prefix,onChange:E=>L({..._,raw_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(ie,{id:"edit-clone",value:_.clone_prefix,onChange:E=>L({..._,clone_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(ie,{id:"edit-priority",type:"number",min:"1",value:_.priority,onChange:E=>L({..._,priority:parseInt(E.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ve,{id:"edit-enabled",checked:_.enabled,onCheckedChange:E=>L({..._,enabled:E})}),e.jsx(C,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs(at,{children:[e.jsx(S,{variant:"outline",onClick:()=>k(!1),children:"取消"}),e.jsx(S,{onClick:Q,children:"保存"})]})]})})]})})}const ir=u.forwardRef(({className:n,...i},r)=>e.jsx(Qp,{ref:r,className:q("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",n),...i}));ir.displayName=Qp.displayName;const L_=u.forwardRef(({className:n,...i},r)=>e.jsx(Ip,{ref:r,className:q("aspect-square h-full w-full",n),...i}));L_.displayName=Ip.displayName;const rr=u.forwardRef(({className:n,...i},r)=>e.jsx(Yp,{ref:r,className:q("flex h-full w-full items-center justify-center rounded-full bg-muted",n),...i}));rr.displayName=Yp.displayName;function U_(){return"webui_"+Math.random().toString(36).substr(2,9)+"_"+Date.now().toString(36)}function B_(){const n="maibot_webui_user_id";let i=localStorage.getItem(n);return i||(i=U_(),localStorage.setItem(n,i)),i}function H_(){return localStorage.getItem("maibot_webui_user_name")||"WebUI用户"}function q_(n){localStorage.setItem("maibot_webui_user_name",n)}const Wg="maibot_webui_virtual_tabs";function G_(){try{const n=localStorage.getItem(Wg);if(n)return JSON.parse(n)}catch(n){console.error("[Chat] 加载虚拟标签页失败:",n)}return[]}function kp(n){try{localStorage.setItem(Wg,JSON.stringify(n))}catch(i){console.error("[Chat] 保存虚拟标签页失败:",i)}}function F_(){const n={id:"webui-default",type:"webui",label:"WebUI",messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}},i=()=>{const Be=G_().map(Ee=>{const Ye=Ee.virtualConfig;return!Ye.groupId&&Ye.platform&&Ye.userId&&(Ye.groupId=`webui_virtual_group_${Ye.platform}_${Ye.userId}`),{id:Ee.id,type:"virtual",label:Ee.label,virtualConfig:Ye,messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}}});return[n,...Be]},[r,d]=u.useState(i),[m,x]=u.useState("webui-default"),f=r.find(Y=>Y.id===m)||r[0],[p,g]=u.useState(""),[N,j]=u.useState(!1),[w,y]=u.useState(!0),[k,_]=u.useState(H_()),[L,D]=u.useState(!1),[U,Q]=u.useState(""),[R,z]=u.useState(!1),[I,$]=u.useState(!1),[E,M]=u.useState([]),[se,fe]=u.useState([]),[ve,Ne]=u.useState(!1),[je,ye]=u.useState(!1),[Se,O]=u.useState(""),[G,H]=u.useState({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),ee=u.useRef(B_()),v=u.useRef(new Map),X=u.useRef(null),me=u.useRef(new Map),ce=u.useRef(0),xe=u.useRef(new Map),{toast:we}=Bs(),oe=Y=>(ce.current+=1,`${Y}-${Date.now()}-${ce.current}-${Math.random().toString(36).substr(2,9)}`),Z=u.useCallback((Y,Be)=>{d(Ee=>Ee.map(Ye=>Ye.id===Y?{...Ye,...Be}:Ye))},[]),te=u.useCallback((Y,Be)=>{d(Ee=>Ee.map(Ye=>Ye.id===Y?{...Ye,messages:[...Ye.messages,Be]}:Ye))},[]),V=u.useCallback(()=>{X.current?.scrollIntoView({behavior:"smooth"})},[]);u.useEffect(()=>{V()},[f?.messages,V]);const P=u.useCallback(async()=>{Ne(!0);try{const Y=await _e("/api/chat/platforms");if(console.log("[Chat] 平台列表响应:",Y.status,Y.headers.get("content-type")),Y.ok){const Be=Y.headers.get("content-type");if(Be&&Be.includes("application/json")){const Ee=await Y.json();console.log("[Chat] 平台列表数据:",Ee),M(Ee.platforms||[])}else{const Ee=await Y.text();console.error("[Chat] 获取平台列表失败: 非 JSON 响应:",Ee.substring(0,200)),we({title:"连接失败",description:"无法连接到后端服务,请确保 MaiBot 已启动",variant:"destructive"})}}else console.error("[Chat] 获取平台列表失败: HTTP",Y.status),we({title:"获取平台失败",description:`服务器返回错误: ${Y.status}`,variant:"destructive"})}catch(Y){console.error("[Chat] 获取平台列表失败:",Y),we({title:"网络错误",description:"无法连接到后端服务",variant:"destructive"})}finally{Ne(!1)}},[we]),ke=u.useCallback(async(Y,Be)=>{ye(!0);try{const Ee=new URLSearchParams;Y&&Ee.append("platform",Y),Be&&Ee.append("search",Be),Ee.append("limit","50");const Ye=await _e(`/api/chat/persons?${Ee.toString()}`);if(Ye.ok){const Xs=Ye.headers.get("content-type");if(Xs&&Xs.includes("application/json")){const Je=await Ye.json();fe(Je.persons||[])}else console.error("[Chat] 获取用户列表失败: 后端返回非 JSON 响应")}}catch(Ee){console.error("[Chat] 获取用户列表失败:",Ee)}finally{ye(!1)}},[]);u.useEffect(()=>{G.platform&&ke(G.platform,Se)},[G.platform,Se,ke]);const He=u.useCallback(async(Y,Be)=>{y(!0);try{const Ee=new URLSearchParams;Ee.append("user_id",ee.current),Ee.append("limit","50"),Be&&Ee.append("group_id",Be);const Ye=`/api/chat/history?${Ee.toString()}`;console.log("[Chat] 正在加载历史消息:",Ye);const Xs=await _e(Ye);if(Xs.ok){const Je=await Xs.text();try{const qs=JSON.parse(Je);if(qs.messages&&qs.messages.length>0){const be=qs.messages.map(Ae=>({id:Ae.id,type:Ae.type,content:Ae.content,timestamp:Ae.timestamp,sender:{name:Ae.sender_name||(Ae.is_bot?"麦麦":"WebUI用户"),user_id:Ae.user_id,is_bot:Ae.is_bot}}));Z(Y,{messages:be});const _s=xe.current.get(Y)||new Set;be.forEach(Ae=>{if(Ae.type==="bot"){const Fs=`bot-${Ae.content}-${Math.floor(Ae.timestamp*1e3)}`;_s.add(Fs)}}),xe.current.set(Y,_s)}}catch(qs){console.error("[Chat] JSON 解析失败:",qs)}}}catch(Ee){console.error("[Chat] 加载历史消息失败:",Ee)}finally{y(!1)}},[Z]),pe=u.useCallback((Y,Be,Ee)=>{const Ye=v.current.get(Y);if(Ye?.readyState===WebSocket.OPEN||Ye?.readyState===WebSocket.CONNECTING){console.log(`[Tab ${Y}] WebSocket 已存在,跳过连接`);return}j(!0);const Xs=window.location.protocol==="https:"?"wss:":"ws:",Je=new URLSearchParams;Be==="virtual"&&Ee?(Je.append("user_id",Ee.userId),Je.append("user_name",Ee.userName),Je.append("platform",Ee.platform),Je.append("person_id",Ee.personId),Je.append("group_name",Ee.groupName||"WebUI虚拟群聊"),Ee.groupId&&Je.append("group_id",Ee.groupId)):(Je.append("user_id",ee.current),Je.append("user_name",k));const qs=`${Xs}//${window.location.host}/api/chat/ws?${Je.toString()}`;console.log(`[Tab ${Y}] 正在连接 WebSocket:`,qs);try{const be=new WebSocket(qs);v.current.set(Y,be),be.onopen=()=>{Z(Y,{isConnected:!0}),j(!1),console.log(`[Tab ${Y}] WebSocket 已连接`)},be.onmessage=_s=>{try{const Ae=JSON.parse(_s.data);switch(Ae.type){case"session_info":Z(Y,{sessionInfo:{session_id:Ae.session_id,user_id:Ae.user_id,user_name:Ae.user_name,bot_name:Ae.bot_name}});break;case"system":te(Y,{id:oe("sys"),type:"system",content:Ae.content||"",timestamp:Ae.timestamp||Date.now()/1e3});break;case"user_message":{const Fs=Ae.sender?.user_id,dt=Be==="virtual"&&Ee?Ee.userId:ee.current;if(Fs===dt)break;te(Y,{id:Ae.message_id||oe("user"),type:"user",content:Ae.content||"",timestamp:Ae.timestamp||Date.now()/1e3,sender:Ae.sender});break}case"bot_message":{Z(Y,{isTyping:!1}),z(!1);const Fs=xe.current.get(Y)||new Set,dt=`bot-${Ae.content}-${Math.floor((Ae.timestamp||0)*1e3)}`;if(Fs.has(dt))break;if(Fs.add(dt),xe.current.set(Y,Fs),Fs.size>100){const xs=Fs.values().next().value;xs&&Fs.delete(xs)}d(xs=>xs.map(gs=>{if(gs.id!==Y)return gs;const Nt=gs.messages.filter(Lt=>Lt.type!=="thinking");return{...gs,messages:[...Nt,{id:oe("bot"),type:"bot",content:Ae.content||"",timestamp:Ae.timestamp||Date.now()/1e3,sender:Ae.sender}]}}));break}case"typing":Z(Y,{isTyping:Ae.is_typing||!1});break;case"error":z(!1),d(Fs=>Fs.map(dt=>{if(dt.id!==Y)return dt;const xs=dt.messages.filter(gs=>gs.type!=="thinking");return{...dt,messages:[...xs,{id:oe("error"),type:"error",content:Ae.content||"发生错误",timestamp:Ae.timestamp||Date.now()/1e3}]}})),we({title:"错误",description:Ae.content,variant:"destructive"});break;case"pong":break;case"history":{const Fs=Ae.messages||[];if(Fs.length>0){const dt=xe.current.get(Y)||new Set,xs=Fs.map(gs=>{const Nt=gs.is_bot||!1,Lt=gs.id||oe(Nt?"bot":"user"),Dt=`${Nt?"bot":"user"}-${gs.content}-${Math.floor(gs.timestamp*1e3)}`;return dt.add(Dt),{id:Lt,type:Nt?"bot":"user",content:gs.content,timestamp:gs.timestamp,sender:{name:gs.sender_name||(Nt?"麦麦":"用户"),user_id:gs.sender_id,is_bot:Nt}}});xe.current.set(Y,dt),Z(Y,{messages:xs}),console.log(`[Tab ${Y}] 已加载 ${xs.length} 条历史消息`)}break}default:console.log("未知消息类型:",Ae.type)}}catch(Ae){console.error("解析消息失败:",Ae)}},be.onclose=()=>{Z(Y,{isConnected:!1}),j(!1),v.current.delete(Y),console.log(`[Tab ${Y}] WebSocket 已断开`);const _s=me.current.get(Y);_s&&clearTimeout(_s);const Ae=window.setTimeout(()=>{if(!Te.current){const Fs=r.find(dt=>dt.id===Y);Fs&&pe(Y,Fs.type,Fs.virtualConfig)}},5e3);me.current.set(Y,Ae)},be.onerror=_s=>{console.error(`[Tab ${Y}] WebSocket 错误:`,_s),j(!1)}}catch(be){console.error(`[Tab ${Y}] 创建 WebSocket 失败:`,be),j(!1)}},[k,Z,te,we,r]),Te=u.useRef(!1);u.useEffect(()=>{Te.current=!1;const Y=v.current,Be=me.current,Ee=xe.current;He("webui-default");const Ye=setTimeout(()=>{Te.current||(pe("webui-default","webui"),r.forEach(Je=>{Je.type==="virtual"&&Je.virtualConfig&&(Ee.set(Je.id,new Set),setTimeout(()=>{Te.current||pe(Je.id,"virtual",Je.virtualConfig)},200))}))},100),Xs=setInterval(()=>{Y.forEach(Je=>{Je.readyState===WebSocket.OPEN&&Je.send(JSON.stringify({type:"ping"}))})},3e4);return()=>{Te.current=!0,clearTimeout(Ye),clearInterval(Xs),Be.forEach(Je=>{clearTimeout(Je)}),Be.clear(),Y.forEach(Je=>{Je.close()}),Y.clear()}},[]);const Qs=u.useCallback(()=>{const Y=v.current.get(m);if(!p.trim()||!Y||Y.readyState!==WebSocket.OPEN||R)return;z(!0);const Be=f?.type==="virtual"&&f.virtualConfig?.userName||k,Ee=p.trim(),Ye=Date.now()/1e3;Y.send(JSON.stringify({type:"message",content:Ee,user_name:Be}));const Xs={id:oe("user"),type:"user",content:Ee,timestamp:Ye,sender:{name:Be,is_bot:!1}};te(m,Xs);const Je={id:oe("thinking"),type:"thinking",content:"",timestamp:Ye+.001,sender:{name:f?.sessionInfo.bot_name||"麦麦",is_bot:!0}};te(m,Je),g("")},[p,k,m,f,te,R]),vt=Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),Qs())},de=()=>{Q(k),D(!0)},qe=()=>{const Y=U.trim()||"WebUI用户";_(Y),q_(Y),D(!1);const Be=v.current.get(m);Be?.readyState===WebSocket.OPEN&&Be.send(JSON.stringify({type:"update_nickname",user_name:Y}))},Ie=()=>{Q(""),D(!1)},Ys=Y=>new Date(Y*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),Hs=()=>{const Y=v.current.get(m);Y&&(Y.close(),v.current.delete(m)),pe(m,f?.type||"webui",f?.virtualConfig)},bt=()=>{H({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),O(""),P(),$(!0)},ot=()=>{if(!G.platform||!G.personId){we({title:"配置不完整",description:"请选择平台和用户",variant:"destructive"});return}const Y=`webui_virtual_group_${G.platform}_${G.userId}`,Be=`virtual-${G.platform}-${G.userId}-${Date.now()}`,Ee=G.userName||G.userId,Ye={id:Be,type:"virtual",label:Ee,virtualConfig:{...G,groupId:Y},messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}};d(Xs=>{const Je=[...Xs,Ye],qs=Je.filter(be=>be.type==="virtual"&&be.virtualConfig).map(be=>({id:be.id,label:be.label,virtualConfig:be.virtualConfig,createdAt:Date.now()}));return kp(qs),Je}),x(Be),$(!1),xe.current.set(Be,new Set),setTimeout(()=>{pe(Be,"virtual",G)},100),we({title:"虚拟身份标签页",description:`已创建 ${Ee} 的对话`})},Ds=(Y,Be)=>{if(Be?.stopPropagation(),Y==="webui-default")return;const Ee=v.current.get(Y);Ee&&(Ee.close(),v.current.delete(Y));const Ye=me.current.get(Y);Ye&&(clearTimeout(Ye),me.current.delete(Y)),xe.current.delete(Y),d(Xs=>{const Je=Xs.filter(be=>be.id!==Y),qs=Je.filter(be=>be.type==="virtual"&&be.virtualConfig).map(be=>({id:be.id,label:be.label,virtualConfig:be.virtualConfig,createdAt:Date.now()}));return kp(qs),Je}),m===Y&&x("webui-default")},ks=Y=>{x(Y)},va=Y=>{H(Be=>({...Be,personId:Y.person_id,userId:Y.user_id,userName:Y.nickname||Y.person_name}))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Gs,{open:I,onOpenChange:$,children:e.jsxs(Rs,{className:"sm:max-w-[500px] max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ls,{children:[e.jsxs(Us,{className:"flex items-center gap-2",children:[e.jsx(wu,{className:"h-5 w-5"}),"新建虚拟身份对话"]}),e.jsx(Ps,{children:"选择一个麦麦已认识的用户,以该用户的身份与麦麦对话。麦麦将使用她对该用户的记忆和认知来回应。"})]}),e.jsxs("div",{className:"space-y-4 flex-1 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(Uu,{className:"h-4 w-4"}),"选择平台"]}),e.jsxs(Re,{value:G.platform,onValueChange:Y=>{H(Be=>({...Be,platform:Y,personId:"",userId:"",userName:""})),fe([])},children:[e.jsx(De,{disabled:ve,children:e.jsx(Le,{placeholder:ve?"加载中...":"选择平台"})}),e.jsx(Oe,{children:E.map(Y=>e.jsxs(le,{value:Y.platform,children:[Y.platform," (",Y.count," 人)"]},Y.platform))})]})]}),G.platform&&e.jsxs("div",{className:"space-y-2 flex-1 overflow-hidden flex flex-col",children:[e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(Bu,{className:"h-4 w-4"}),"选择用户"]}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ie,{placeholder:"搜索用户名...",value:Se,onChange:Y=>O(Y.target.value),className:"pl-9"})]}),e.jsx(Ke,{className:"h-[250px] border rounded-md",children:e.jsx("div",{className:"p-2",children:je?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Js,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):se.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[e.jsx(Bu,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"没有找到用户"})]}):e.jsx("div",{className:"space-y-1",children:se.map(Y=>e.jsxs("button",{onClick:()=>va(Y),className:q("w-full flex items-center gap-3 p-2 rounded-md text-left transition-colors",G.personId===Y.person_id?"bg-primary text-primary-foreground":"hover:bg-muted"),children:[e.jsx(ir,{className:"h-8 w-8 shrink-0",children:e.jsx(rr,{className:q("text-xs",G.personId===Y.person_id?"bg-primary-foreground/20":"bg-muted"),children:(Y.nickname||Y.person_name||"?").charAt(0)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium truncate",children:Y.nickname||Y.person_name}),e.jsxs("div",{className:q("text-xs truncate",G.personId===Y.person_id?"text-primary-foreground/70":"text-muted-foreground"),children:["ID: ",Y.user_id,Y.is_known&&" · 已认识"]})]})]},Y.person_id))})})})]}),G.personId&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"虚拟群名(可选)"}),e.jsx(ie,{placeholder:"WebUI虚拟群聊",value:G.groupName,onChange:Y=>H(Be=>({...Be,groupName:Y.target.value}))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦会认为这是一个名为此名称的群聊"})]})]}),e.jsxs(at,{className:"gap-2 sm:gap-0",children:[e.jsx(S,{variant:"outline",onClick:()=>$(!1),children:"取消"}),e.jsx(S,{onClick:ot,disabled:!G.platform||!G.personId,children:"创建对话"})]})]})}),e.jsx("div",{className:"shrink-0 border-b bg-muted/30",children:e.jsx("div",{className:"max-w-4xl mx-auto px-2 sm:px-4",children:e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto py-1.5 scrollbar-thin",children:[r.map(Y=>e.jsxs("button",{onClick:()=>ks(Y.id),className:q("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm whitespace-nowrap transition-colors","hover:bg-muted",m===Y.id?"bg-background shadow-sm border":"text-muted-foreground"),children:[Y.type==="webui"?e.jsx(Dl,{className:"h-3.5 w-3.5"}):e.jsx(wu,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"max-w-[100px] truncate",children:Y.label}),e.jsx("span",{className:q("w-1.5 h-1.5 rounded-full",Y.isConnected?"bg-green-500":"bg-muted-foreground/50")}),Y.id!=="webui-default"&&e.jsx("button",{onClick:Be=>Ds(Y.id,Be),className:"ml-0.5 p-0.5 rounded hover:bg-muted-foreground/20",children:e.jsx(il,{className:"h-3 w-3"})})]},Y.id)),e.jsx("button",{onClick:bt,className:"flex items-center gap-1 px-2 py-1.5 rounded-md text-sm text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",title:"新建虚拟身份对话",children:e.jsx(rt,{className:"h-3.5 w-3.5"})})]})})}),e.jsx("div",{className:"shrink-0 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsxs("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0",children:[e.jsx(ir,{className:"h-8 w-8 sm:h-10 sm:w-10 shrink-0",children:e.jsx(rr,{className:"bg-primary/10 text-primary",children:e.jsx(ar,{className:"h-4 w-4 sm:h-5 sm:w-5"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-base sm:text-lg font-semibold truncate",children:f?.sessionInfo.bot_name||"麦麦"}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:f?.isConnected?e.jsxs(e.Fragment,{children:[e.jsx(by,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"已连接"})]}):N?e.jsxs(e.Fragment,{children:[e.jsx(Js,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"连接中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ny,{className:"h-3 w-3 text-red-500"}),e.jsx("span",{className:"text-red-600 dark:text-red-400",children:"未连接"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[w&&e.jsx(Js,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx(S,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Hs,disabled:N,title:"重新连接",children:e.jsx(zt,{className:q("h-4 w-4",N&&"animate-spin")})})]})]}),e.jsx("div",{className:"hidden sm:flex items-center gap-2 mt-2 text-sm text-muted-foreground",children:f?.type==="virtual"&&f.virtualConfig?e.jsxs(e.Fragment,{children:[e.jsx(wu,{className:"h-3 w-3 text-primary"}),e.jsx("span",{children:"虚拟身份:"}),e.jsx("span",{className:"font-medium text-primary",children:f.virtualConfig.userName}),e.jsxs("span",{className:"text-xs",children:["(",f.virtualConfig.platform,")"]}),f.virtualConfig.groupName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-1",children:"·"}),e.jsxs("span",{className:"text-xs",children:["群:",f.virtualConfig.groupName]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ic,{className:"h-3 w-3"}),e.jsx("span",{children:"当前身份:"}),L?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{value:U,onChange:Y=>Q(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&qe(),Y.key==="Escape"&&Ie()},className:"h-7 w-32",placeholder:"输入昵称",autoFocus:!0}),e.jsx(S,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:qe,children:"保存"}),e.jsx(S,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:Ie,children:"取消"})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-foreground",children:k}),e.jsx(S,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:de,title:"修改昵称",children:e.jsx(yy,{className:"h-3 w-3"})})]})]})})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ke,{className:"h-full",children:e.jsxs("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto space-y-3 sm:space-y-4",children:[f?.messages.length===0&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(ar,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsxs("p",{className:"text-sm",children:["开始与 ",f?.sessionInfo.bot_name||"麦麦"," 对话吧!"]})]}),f?.messages.map(Y=>e.jsxs("div",{className:q("flex gap-2 sm:gap-3",Y.type==="user"&&"flex-row-reverse",Y.type==="system"&&"justify-center",Y.type==="error"&&"justify-center"),children:[Y.type==="system"&&e.jsx("div",{className:"text-xs text-muted-foreground bg-muted/50 px-3 py-1 rounded-full max-w-[90%]",children:Y.content}),Y.type==="error"&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400 bg-red-100 dark:bg-red-900/30 px-3 py-1 rounded-full max-w-[90%]",children:Y.content}),Y.type==="thinking"&&e.jsxs(e.Fragment,{children:[e.jsx(ir,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(rr,{className:"bg-primary/10 text-primary",children:e.jsx(ar,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsxs("div",{className:"flex flex-col gap-1 max-w-[75%] sm:max-w-[70%]",children:[e.jsx("div",{className:"flex items-center gap-2 text-[10px] sm:text-xs text-muted-foreground",children:e.jsx("span",{className:"hidden sm:inline",children:Y.sender?.name||f?.sessionInfo.bot_name})}),e.jsx("div",{className:"bg-muted rounded-2xl rounded-tl-sm px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2 h-2 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-2 h-2 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-2 h-2 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"思考中..."})]})})]})]}),(Y.type==="user"||Y.type==="bot")&&e.jsxs(e.Fragment,{children:[e.jsx(ir,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(rr,{className:q("text-xs",Y.type==="bot"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:Y.type==="bot"?e.jsx(ar,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}):e.jsx(Ic,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsxs("div",{className:q("flex flex-col gap-1 max-w-[75%] sm:max-w-[70%]",Y.type==="user"&&"items-end"),children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] sm:text-xs text-muted-foreground",children:[e.jsx("span",{className:"hidden sm:inline",children:Y.sender?.name||(Y.type==="bot"?f?.sessionInfo.bot_name:k)}),e.jsx("span",{children:Ys(Y.timestamp)})]}),e.jsx("div",{className:q("rounded-2xl px-3 py-2 text-sm whitespace-pre-wrap break-words",Y.type==="bot"?"bg-muted rounded-tl-sm":"bg-primary text-primary-foreground rounded-tr-sm"),children:Y.content})]})]})]},Y.id)),e.jsx("div",{ref:X})]})})}),e.jsx("div",{className:"shrink-0 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:e.jsx("div",{className:"p-3 sm:p-4 max-w-4xl mx-auto",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ie,{value:p,onChange:Y=>g(Y.target.value),onKeyDown:vt,placeholder:R?"等待响应中...":f?.isConnected?"输入消息...":"等待连接...",disabled:!f?.isConnected||R,className:"flex-1 h-10 sm:h-10"}),e.jsx(S,{onClick:Qs,disabled:!f?.isConnected||!p.trim()||R,size:"icon",className:"h-10 w-10 shrink-0",children:R?e.jsx(Js,{className:"h-4 w-4 animate-spin"}):e.jsx(wy,{className:"h-4 w-4"})})]})})})]})}var am="Radio",[V_,ej]=cg(am),[$_,Q_]=V_(am),sj=u.forwardRef((n,i)=>{const{__scopeRadio:r,name:d,checked:m=!1,required:x,disabled:f,value:p="on",onCheck:g,form:N,...j}=n,[w,y]=u.useState(null),k=Qu(i,D=>y(D)),_=u.useRef(!1),L=w?N||!!w.closest("form"):!0;return e.jsxs($_,{scope:r,checked:m,disabled:f,children:[e.jsx(Jc.button,{type:"button",role:"radio","aria-checked":m,"data-state":nj(m),"data-disabled":f?"":void 0,disabled:f,value:p,...j,ref:k,onClick:Ru(n.onClick,D=>{m||g?.(),L&&(_.current=D.isPropagationStopped(),_.current||D.stopPropagation())})}),L&&e.jsx(lj,{control:w,bubbles:!_.current,name:d,value:p,checked:m,required:x,disabled:f,form:N,style:{transform:"translateX(-100%)"}})]})});sj.displayName=am;var tj="RadioIndicator",aj=u.forwardRef((n,i)=>{const{__scopeRadio:r,forceMount:d,...m}=n,x=Q_(tj,r);return e.jsx(FN,{present:d||x.checked,children:e.jsx(Jc.span,{"data-state":nj(x.checked),"data-disabled":x.disabled?"":void 0,...m,ref:i})})});aj.displayName=tj;var I_="RadioBubbleInput",lj=u.forwardRef(({__scopeRadio:n,control:i,checked:r,bubbles:d=!0,...m},x)=>{const f=u.useRef(null),p=Qu(f,x),g=VN(r),N=$N(i);return u.useEffect(()=>{const j=f.current;if(!j)return;const w=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(w,"checked").set;if(g!==r&&k){const _=new Event("click",{bubbles:d});k.call(j,r),j.dispatchEvent(_)}},[g,r,d]),e.jsx(Jc.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...m,tabIndex:-1,ref:p,style:{...m.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});lj.displayName=I_;function nj(n){return n?"checked":"unchecked"}var Y_=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],no="RadioGroup",[X_]=cg(no,[Xp,ej]),ij=Xp(),rj=ej(),[K_,J_]=X_(no),cj=u.forwardRef((n,i)=>{const{__scopeRadioGroup:r,name:d,defaultValue:m,value:x,required:f=!1,disabled:p=!1,orientation:g,dir:N,loop:j=!0,onValueChange:w,...y}=n,k=ij(r),_=qN(N),[L,D]=GN({prop:x,defaultProp:m??null,onChange:w,caller:no});return e.jsx(K_,{scope:r,name:d,required:f,disabled:p,value:L,onValueChange:D,children:e.jsx(gN,{asChild:!0,...k,orientation:g,dir:_,loop:j,children:e.jsx(Jc.div,{role:"radiogroup","aria-required":f,"aria-orientation":g,"data-disabled":p?"":void 0,dir:_,...y,ref:i})})})});cj.displayName=no;var oj="RadioGroupItem",dj=u.forwardRef((n,i)=>{const{__scopeRadioGroup:r,disabled:d,...m}=n,x=J_(oj,r),f=x.disabled||d,p=ij(r),g=rj(r),N=u.useRef(null),j=Qu(i,N),w=x.value===m.value,y=u.useRef(!1);return u.useEffect(()=>{const k=L=>{Y_.includes(L.key)&&(y.current=!0)},_=()=>y.current=!1;return document.addEventListener("keydown",k),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",k),document.removeEventListener("keyup",_)}},[]),e.jsx(jN,{asChild:!0,...p,focusable:!f,active:w,children:e.jsx(sj,{disabled:f,required:x.required,checked:w,...g,...m,name:x.name,ref:j,onCheck:()=>x.onValueChange(m.value),onKeyDown:Ru(k=>{k.key==="Enter"&&k.preventDefault()}),onFocus:Ru(m.onFocus,()=>{y.current&&N.current?.click()})})})});dj.displayName=oj;var P_="RadioGroupIndicator",uj=u.forwardRef((n,i)=>{const{__scopeRadioGroup:r,...d}=n,m=rj(r);return e.jsx(aj,{...m,...d,ref:i})});uj.displayName=P_;var mj=cj,xj=dj,Z_=uj;const hj=u.forwardRef(({className:n,...i},r)=>e.jsx(mj,{className:q("grid gap-2",n),...i,ref:r}));hj.displayName=mj.displayName;const fj=u.forwardRef(({className:n,...i},r)=>e.jsx(xj,{ref:r,className:q("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n),...i,children:e.jsx(Z_,{className:"flex items-center justify-center",children:e.jsx(_y,{className:"h-2.5 w-2.5 fill-current text-current"})})}));fj.displayName=xj.displayName;function W_({question:n,value:i,onChange:r,error:d,disabled:m=!1}){const[x,f]=u.useState(null),p=m||n.readOnly,g=()=>{switch(n.type){case"single":return e.jsx(hj,{value:i||"",onValueChange:r,disabled:p,className:"space-y-2",children:n.options?.map(N=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(fj,{value:N.value,id:`${n.id}-${N.id}`}),e.jsx(C,{htmlFor:`${n.id}-${N.id}`,className:"cursor-pointer font-normal",children:N.label})]},N.id))});case"multiple":{const N=i||[];return e.jsxs("div",{className:"space-y-2",children:[n.options?.map(j=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ft,{id:`${n.id}-${j.id}`,checked:N.includes(j.value),disabled:p||n.maxSelections!==void 0&&N.length>=n.maxSelections&&!N.includes(j.value),onCheckedChange:w=>{r(w?[...N,j.value]:N.filter(y=>y!==j.value))}}),e.jsx(C,{htmlFor:`${n.id}-${j.id}`,className:"cursor-pointer font-normal",children:j.label})]},j.id)),n.maxSelections&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["最多选择 ",n.maxSelections," 项"]})]})}case"text":return e.jsx(ie,{value:i||"",onChange:N=>r(N.target.value),placeholder:n.placeholder||"请输入...",disabled:p,readOnly:n.readOnly,maxLength:n.maxLength,className:q(n.readOnly&&"bg-muted cursor-not-allowed")});case"textarea":return e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ms,{value:i||"",onChange:N=>r(N.target.value),placeholder:n.placeholder||"请输入...",disabled:p,readOnly:n.readOnly,maxLength:n.maxLength,rows:4,className:q(n.readOnly&&"bg-muted cursor-not-allowed")}),n.maxLength&&e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[(i||"").length," / ",n.maxLength]})]});case"rating":{const N=i||0,j=x!==null?x:N;return e.jsxs("div",{className:"flex items-center gap-1",children:[[1,2,3,4,5].map(w=>e.jsx("button",{type:"button",disabled:p,className:q("p-1 transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded",p&&"cursor-not-allowed opacity-50"),onMouseEnter:()=>!p&&f(w),onMouseLeave:()=>f(null),onClick:()=>!p&&r(w),children:e.jsx(ll,{className:q("h-6 w-6 transition-colors",w<=j?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},w)),N>0&&e.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[N," / 5"]})]})}case"scale":{const N=n.min??1,j=n.max??10,w=n.step??1,y=i??N;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(fa,{value:[y],onValueChange:([k])=>r(k),min:N,max:j,step:w,disabled:p}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:n.minLabel||N}),e.jsx("span",{className:"font-medium text-foreground",children:y}),e.jsx("span",{children:n.maxLabel||j})]})]})}case"dropdown":return e.jsxs(Re,{value:i||"",onValueChange:r,disabled:p,children:[e.jsx(De,{children:e.jsx(Le,{placeholder:n.placeholder||"请选择..."})}),e.jsx(Oe,{children:n.options?.map(N=>e.jsx(le,{value:N.value,children:N.label},N.id))})]});default:return e.jsx("div",{className:"text-muted-foreground",children:"不支持的问题类型"})}};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-base font-medium",children:[n.title,n.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),n.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]}),g(),d&&e.jsx("p",{className:"text-sm text-destructive",children:d})]})}const pj="https://maibot-plugin-stats.maibot-webui.workers.dev";function gj(){const n="maibot_user_id";let i=localStorage.getItem(n);if(!i){const r=Math.random().toString(36).substring(2,10),d=Date.now().toString(36),m=Math.random().toString(36).substring(2,10);i=`fp_${r}_${d}_${m}`,localStorage.setItem(n,i)}return i}async function eS(n,i,r,d){try{const m=d?.userId||gj(),x={surveyId:n,surveyVersion:i,userId:m,answers:r,submittedAt:new Date().toISOString(),allowMultiple:d?.allowMultiple,metadata:{userAgent:navigator.userAgent,language:navigator.language}},f=await fetch(`${pj}/survey/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)}),p=await f.json();return f.status===429?{success:!1,error:"提交过于频繁,请稍后再试"}:f.status===409?{success:!1,error:p.error||"你已经提交过这份问卷了"}:f.ok?{success:!0,submissionId:p.submissionId,message:p.message}:{success:!1,error:p.error||"提交失败"}}catch(m){return console.error("Error submitting survey:",m),{success:!1,error:"网络错误"}}}async function sS(n,i){try{const r=i||gj(),d=new URLSearchParams({user_id:r,survey_id:n}),m=await fetch(`${pj}/survey/check?${d}`);return m.ok?{success:!0,hasSubmitted:(await m.json()).hasSubmitted}:{success:!1,error:(await m.json()).error||"检查失败"}}catch(r){return console.error("Error checking submission:",r),{success:!1,error:"网络错误"}}}function jj({config:n,initialAnswers:i,onSubmitSuccess:r,onSubmitError:d,showProgress:m=!0,paginateQuestions:x=!1,className:f}){const p=u.useCallback(()=>!i||i.length===0?{}:i.reduce((H,ee)=>(H[ee.questionId]=ee.value,H),{}),[i]),[g,N]=u.useState(()=>p()),[j,w]=u.useState({}),[y,k]=u.useState(0),[_,L]=u.useState(!1),[D,U]=u.useState(!1),[Q,R]=u.useState(null),[z,I]=u.useState(null),[$,E]=u.useState(!1),[M,se]=u.useState(!0);u.useEffect(()=>{i&&i.length>0&&N(H=>({...H,...p()}))},[i,p]),u.useEffect(()=>{(async()=>{if(!n.settings?.allowMultiple){const ee=await sS(n.id);ee.success&&ee.hasSubmitted&&E(!0)}se(!1)})()},[n.id,n.settings?.allowMultiple]);const fe=u.useCallback(()=>{const H=new Date;return!(n.settings?.startTime&&new Date(n.settings.startTime)>H||n.settings?.endTime&&new Date(n.settings.endTime)<H)},[n.settings?.startTime,n.settings?.endTime]),ve=n.questions.filter(H=>{const ee=g[H.id];return ee==null?!1:Array.isArray(ee)?ee.length>0:typeof ee=="string"?ee.trim()!=="":!0}).length,Ne=ve/n.questions.length*100,je=u.useCallback((H,ee)=>{N(v=>({...v,[H]:ee})),w(v=>{const X={...v};return delete X[H],X})},[]),ye=u.useCallback(()=>{const H={};for(const ee of n.questions){if(ee.required){const v=g[ee.id];if(v==null){H[ee.id]="此题为必填项";continue}if(Array.isArray(v)&&v.length===0){H[ee.id]="请至少选择一项";continue}if(typeof v=="string"&&v.trim()===""){H[ee.id]="此题为必填项";continue}}ee.minLength&&typeof g[ee.id]=="string"&&g[ee.id].length<ee.minLength&&(H[ee.id]=`至少需要 ${ee.minLength} 个字符`)}return w(H),Object.keys(H).length===0},[n.questions,g]),Se=u.useCallback(async()=>{if(!ye()){if(x){const H=n.questions.findIndex(ee=>j[ee.id]);H>=0&&k(H)}return}L(!0),R(null);try{const H=n.questions.filter(v=>g[v.id]!==void 0).map(v=>({questionId:v.id,value:g[v.id]})),ee=await eS(n.id,n.version,H,{allowMultiple:n.settings?.allowMultiple});if(ee.success&&ee.submissionId)U(!0),I(ee.submissionId),r?.(ee.submissionId);else{const v=ee.error||"提交失败";R(v),d?.(v)}}catch(H){const ee=H instanceof Error?H.message:"提交失败";R(ee),d?.(ee)}finally{L(!1)}},[ye,x,n,g,j,r,d]),O=u.useCallback(H=>{H>=0&&H<n.questions.length&&k(H)},[n.questions.length]);if(M)return e.jsx(Qe,{className:q("w-full max-w-2xl mx-auto",f),children:e.jsx(ps,{className:"py-12 flex items-center justify-center",children:e.jsx(Js,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});if($&&!n.settings?.allowMultiple)return e.jsxs(Qe,{className:q("w-full max-w-2xl mx-auto",f),children:[e.jsx(ss,{children:e.jsx(ts,{children:n.title})}),e.jsx(ps,{className:"py-8",children:e.jsxs(It,{children:[e.jsx(Mt,{className:"h-4 w-4"}),e.jsx(Yt,{children:"你已经提交过这份问卷了,感谢参与!"})]})})]});if(!fe())return e.jsxs(Qe,{className:q("w-full max-w-2xl mx-auto",f),children:[e.jsx(ss,{children:e.jsx(ts,{children:n.title})}),e.jsx(ps,{className:"py-8",children:e.jsxs(It,{variant:"destructive",children:[e.jsx(Mt,{className:"h-4 w-4"}),e.jsx(Yt,{children:"问卷不在有效期内"})]})})]});if(D)return e.jsxs(Qe,{className:q("w-full max-w-2xl mx-auto",f),children:[e.jsx(ss,{children:e.jsxs(ts,{className:"flex items-center gap-2 text-green-600",children:[e.jsx(aa,{className:"h-6 w-6"}),"提交成功"]})}),e.jsxs(ps,{className:"py-8",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:n.settings?.thankYouMessage||"感谢你的参与!"}),z&&e.jsxs("p",{className:"text-center text-xs text-muted-foreground mt-4",children:["提交编号:",z]})]})]});const G=x?[n.questions[y]]:n.questions;return e.jsxs("div",{className:q("h-full flex flex-col",f),children:[e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 mb-4 shrink-0",children:[e.jsx("h2",{className:"text-xl font-semibold",children:n.title}),n.description&&e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:n.description}),m&&e.jsxs("div",{className:"space-y-1 pt-3",children:[e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"进度"}),e.jsxs("span",{children:[ve," / ",n.questions.length]})]}),e.jsx(ni,{value:Ne,className:"h-2"})]})]}),e.jsx(Ke,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[G.map((H,ee)=>e.jsxs("div",{className:q("p-4 rounded-lg border bg-card",j[H.id]?"border-destructive bg-destructive/5":"border-border"),children:[x&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:["问题 ",y+1," / ",n.questions.length]}),!x&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:[ee+1,"."]}),e.jsx(W_,{question:H,value:g[H.id],onChange:v=>je(H.id,v),error:j[H.id],disabled:_})]},H.id)),Q&&e.jsxs(It,{variant:"destructive",children:[e.jsx(Mt,{className:"h-4 w-4"}),e.jsx(Yt,{children:Q})]}),e.jsx("div",{className:"flex justify-between items-center py-4",children:x?e.jsxs(e.Fragment,{children:[e.jsxs(S,{variant:"outline",onClick:()=>O(y-1),disabled:y===0||_,children:[e.jsx(rl,{className:"h-4 w-4 mr-1"}),"上一题"]}),y===n.questions.length-1?e.jsxs(S,{onClick:Se,disabled:_,children:[_&&e.jsx(Js,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]}):e.jsxs(S,{onClick:()=>O(y+1),disabled:_,children:["下一题",e.jsx(Ua,{className:"h-4 w-4 ml-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:Object.keys(j).length>0&&e.jsxs("span",{className:"text-destructive",children:["还有 ",Object.keys(j).length," 个必填项未完成"]})}),e.jsxs(S,{onClick:Se,disabled:_,size:"lg",children:[_&&e.jsx(Js,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]})]})})]})})]})}const tS={id:"webui-feedback-v1",version:"1.0.0",title:"麦麦 WebUI 使用反馈问卷",description:"感谢您使用麦麦 WebUI您的反馈将帮助我们不断改进产品体验。",questions:[{id:"webui_version",type:"text",title:"你正在使用的 WebUI 版本",description:"此项由系统自动填写",required:!0,readOnly:!0,placeholder:"自动检测中..."},{id:"ui_design_satisfaction",type:"single",title:"你觉得当前的 WebUI 界面设计如何?",required:!0,options:[{id:"very_satisfied",label:"非常满意",value:"very_satisfied"},{id:"satisfied",label:"满意",value:"satisfied"},{id:"neutral",label:"一般",value:"neutral"},{id:"dissatisfied",label:"不满意",value:"dissatisfied"},{id:"very_dissatisfied",label:"非常不满意",value:"very_dissatisfied"}]},{id:"problems_encountered",type:"multiple",title:"你在使用 WebUI 时遇到过哪些问题?",description:"可多选",required:!0,options:[{id:"lag",label:"界面卡顿",value:"lag"},{id:"incomplete",label:"功能不完整",value:"incomplete"},{id:"complex",label:"操作复杂",value:"complex"},{id:"bugs",label:"存在 Bug",value:"bugs"},{id:"none",label:"没有遇到问题",value:"none"},{id:"other",label:"其他",value:"other"}]},{id:"problems_other",type:"text",title:'如选择"其他",请说明遇到的问题',required:!1,placeholder:"请描述你遇到的其他问题...",maxLength:500},{id:"useful_features",type:"textarea",title:"你觉得哪些功能是最有用的?",required:!0,placeholder:"请分享你认为最有价值的功能...",maxLength:1e3},{id:"feature_requests",type:"textarea",title:"你希望在未来的版本中增加哪些功能?",required:!0,placeholder:"请告诉我们你期望的新功能...",maxLength:1e3},{id:"overall_satisfaction",type:"single",title:"你对麦麦 WebUI 的整体满意度如何?",required:!0,options:[{id:"very_satisfied",label:"非常满意",value:"very_satisfied"},{id:"satisfied",label:"满意",value:"satisfied"},{id:"neutral",label:"一般",value:"neutral"},{id:"dissatisfied",label:"不满意",value:"dissatisfied"},{id:"very_dissatisfied",label:"非常不满意",value:"very_dissatisfied"}]},{id:"would_recommend",type:"single",title:"你愿意推荐麦麦 WebUI 给其他人使用吗?",required:!0,options:[{id:"yes",label:"是",value:"yes"},{id:"no",label:"否",value:"no"}]},{id:"other_suggestions",type:"textarea",title:"其他建议或意见",description:"此项为选填",required:!1,placeholder:"如果你有任何其他想法或建议,请在此分享...",maxLength:2e3}],settings:{allowMultiple:!1,thankYouMessage:"感谢你的反馈!你的意见对我们非常重要,我们会认真考虑每一条建议。"}},aS={id:"maibot-feedback-v1",version:"1.0.0",title:"麦麦使用体验反馈问卷",description:"感谢您使用麦麦!您的反馈将帮助我们打造更好的 AI 伙伴。",questions:[{id:"maibot_version",type:"text",title:"你正在使用的麦麦版本",description:"此项由系统自动填写",required:!0,readOnly:!0,placeholder:"自动检测中..."},{id:"improvement_areas",type:"textarea",title:"你认为麦麦还有哪些部分可以改进?",required:!0,placeholder:"请分享你认为可以改进的方面...",maxLength:1e3},{id:"problems_encountered",type:"multiple",title:"你在使用麦麦时遇到过哪些问题?",description:"可多选",required:!0,options:[{id:"incomplete",label:"功能不完整",value:"incomplete"},{id:"slow_response",label:"响应速度慢",value:"slow_response"},{id:"complex",label:"操作复杂",value:"complex"},{id:"unstable",label:"运行不稳定",value:"unstable"},{id:"config_difficult",label:"配置困难",value:"config_difficult"},{id:"none",label:"没有遇到问题",value:"none"},{id:"other",label:"其他",value:"other"}]},{id:"problems_other",type:"text",title:'如选择"其他",请说明遇到的问题',required:!1,placeholder:"请描述你遇到的其他问题...",maxLength:500},{id:"helpful_features",type:"textarea",title:"你觉得麦麦的哪些功能对你最有帮助?",required:!0,placeholder:"请分享对你最有帮助的功能...",maxLength:1e3},{id:"feature_requests",type:"textarea",title:"你希望在未来的版本中增加哪些功能?",required:!0,placeholder:"请告诉我们你期望的新功能...",maxLength:1e3},{id:"overall_satisfaction",type:"single",title:"你对麦麦的整体满意度如何?",required:!0,options:[{id:"very_satisfied",label:"非常满意",value:"very_satisfied"},{id:"satisfied",label:"满意",value:"satisfied"},{id:"neutral",label:"一般",value:"neutral"},{id:"dissatisfied",label:"不满意",value:"dissatisfied"},{id:"very_dissatisfied",label:"非常不满意",value:"very_dissatisfied"}]},{id:"would_recommend",type:"single",title:"你愿意推荐麦麦给其他人使用吗?",required:!0,options:[{id:"yes",label:"是",value:"yes"},{id:"no",label:"否",value:"no"}]},{id:"other_suggestions",type:"textarea",title:"其他建议或意见",description:"此项为选填",required:!1,placeholder:"如果你有任何其他想法或建议,请在此分享...",maxLength:2e3}],settings:{allowMultiple:!1,thankYouMessage:"感谢你的反馈!你的意见对麦麦的成长非常重要,我们会认真考虑每一条建议。"}};function lS(){const[n,i]=u.useState(null),[r,d]=u.useState(!0);u.useEffect(()=>{const p=JSON.parse(JSON.stringify(tS));i(p),d(!1)},[]);const m=u.useMemo(()=>[{questionId:"webui_version",value:`v${Zc}`}],[]),x=u.useCallback(p=>{console.log("WebUI Survey submitted:",p)},[]),f=u.useCallback(p=>{console.error("WebUI Survey submission error:",p)},[]);return r?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Js,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):n?e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-4 sm:mb-6 shrink-0",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(wg,{className:"h-8 w-8",strokeWidth:2}),"WebUI 使用反馈问卷"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"感谢您的反馈,帮助我们持续改进产品体验"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(jj,{config:n,initialAnswers:m,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:x,onSubmitError:f})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(It,{variant:"destructive",className:"max-w-md",children:[e.jsx(Mt,{className:"h-4 w-4"}),e.jsx(Yt,{children:"无法加载问卷配置"})]}),e.jsx(S,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}function nS(){const[n,i]=u.useState(null),[r,d]=u.useState(!0),[m,x]=u.useState("未知版本");u.useEffect(()=>{(async()=>{try{const w=await Hg();x(w.version||"未知版本")}catch(w){console.error("Failed to get MaiBot version:",w),x("获取失败")}const j=JSON.parse(JSON.stringify(aS));i(j),d(!1)})()},[]);const f=u.useMemo(()=>[{questionId:"maibot_version",value:m}],[m]),p=u.useCallback(N=>{console.log("MaiBot Survey submitted:",N)},[]),g=u.useCallback(N=>{console.error("MaiBot Survey submission error:",N)},[]);return r?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Js,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):n?e.jsxs("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:[e.jsxs("div",{className:"mb-4 sm:mb-6 shrink-0",children:[e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold flex items-center gap-2",children:[e.jsx(wg,{className:"h-8 w-8",strokeWidth:2}),"麦麦使用体验反馈问卷"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"感谢您的反馈,帮助我们打造更好的 AI 伙伴"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(jj,{config:n,initialAnswers:f,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:p,onSubmitError:g})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(It,{variant:"destructive",className:"max-w-md",children:[e.jsx(Mt,{className:"h-4 w-4"}),e.jsx(Yt,{children:"无法加载问卷配置"})]}),e.jsx(S,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}function iS(){const n=ja(),[i,r]=u.useState(!0);return u.useEffect(()=>{let d=!1;return(async()=>{try{const x=await Zu();!d&&!x&&n({to:"/auth"})}catch{d||n({to:"/auth"})}finally{d||r(!1)}})(),()=>{d=!0}},[n]),{checking:i}}async function rS(){return await Zu()}const cS=si("pointer-events-none inline-flex select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono font-medium opacity-100",{variants:{size:{sm:"h-5 text-[10px]",default:"h-6 text-xs",lg:"h-7 text-sm"}},defaultVariants:{size:"default"}}),vj=u.forwardRef(({className:n,size:i,abbrTitle:r,children:d,...m},x)=>e.jsx("kbd",{className:q(cS({size:i,className:n})),ref:x,...m,children:r?e.jsx("abbr",{title:r,children:d}):d}));vj.displayName="Kbd";const oS=[{icon:Pc,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:_a,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:_g,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:Sg,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:Iu,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:Dl,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:Cg,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:ei,title:"黑话管理",description:"管理麦麦学习到的黑话和俚语",path:"/resource/jargon",category:"资源"},{icon:Sy,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:tn,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:Yu,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:ti,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function dS({open:n,onOpenChange:i}){const[r,d]=u.useState(""),[m,x]=u.useState(0),f=ja(),p=oS.filter(j=>j.title.toLowerCase().includes(r.toLowerCase())||j.description.toLowerCase().includes(r.toLowerCase())||j.category.toLowerCase().includes(r.toLowerCase()));u.useEffect(()=>{n&&(d(""),x(0))},[n]);const g=u.useCallback(j=>{f({to:j}),i(!1)},[f,i]),N=u.useCallback(j=>{j.key==="ArrowDown"?(j.preventDefault(),x(w=>(w+1)%p.length)):j.key==="ArrowUp"?(j.preventDefault(),x(w=>(w-1+p.length)%p.length)):j.key==="Enter"&&p[m]&&(j.preventDefault(),g(p[m].path))},[p,m,g]);return e.jsx(Gs,{open:n,onOpenChange:i,children:e.jsxs(Rs,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(Ls,{className:"px-4 pt-4 pb-0",children:[e.jsx(Us,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(ie,{value:r,onChange:j=>{d(j.target.value),x(0)},onKeyDown:N,placeholder:"搜索页面...",className:"h-12 pl-11 text-base border-0 focus-visible:ring-0 shadow-none",autoFocus:!0})]})]}),e.jsx("div",{className:"border-t",children:e.jsx(Ke,{className:"h-[400px]",children:p.length>0?e.jsx("div",{className:"p-2",children:p.map((j,w)=>{const y=j.icon;return e.jsxs("button",{onClick:()=>g(j.path),onMouseEnter:()=>x(w),className:q("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",w===m?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[e.jsx(y,{className:"h-5 w-5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:j.title}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:j.description})]}),e.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:j.category})]},j.path)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(At,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r?"未找到匹配的页面":"输入关键词开始搜索"})]})})}),e.jsx("div",{className:"border-t px-4 py-3 flex items-center justify-between text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"↑"}),e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"↓"}),"导航"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"Enter"}),"选择"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded border",children:"Esc"}),"关闭"]})]})})]})})}const uS=IN,mS=YN,xS=XN,bj=u.forwardRef(({className:n,sideOffset:i=4,...r},d)=>e.jsx(QN,{children:e.jsx(og,{ref:d,sideOffset:i,className:q("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 origin-[--radix-tooltip-content-transform-origin]",n),...r})}));bj.displayName=og.displayName;function hS({children:n}){const{checking:i}=iS(),[r,d]=u.useState(!0),[m,x]=u.useState(!1),[f,p]=u.useState(!1),{theme:g,setTheme:N}=Ku(),j=Gb();if(u.useEffect(()=>{const L=D=>{(D.metaKey||D.ctrlKey)&&D.key==="k"&&(D.preventDefault(),p(!0))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]),i)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"text-muted-foreground",children:"正在验证登录状态..."})});const w=[{title:"概览",items:[{icon:Pc,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:_a,label:"麦麦主程序配置",path:"/config/bot"},{icon:_g,label:"AI模型厂商配置",path:"/config/modelProvider",tourId:"sidebar-model-provider"},{icon:Sg,label:"模型管理与分配",path:"/config/model",tourId:"sidebar-model-management"},{icon:tp,label:"麦麦适配器配置",path:"/config/adapter"}]},{title:"麦麦资源管理",items:[{icon:Iu,label:"表情包管理",path:"/resource/emoji"},{icon:Dl,label:"表达方式管理",path:"/resource/expression"},{icon:ei,label:"黑话管理",path:"/resource/jargon"},{icon:Cg,label:"人物信息管理",path:"/resource/person"},{icon:yg,label:"知识库图谱可视化",path:"/resource/knowledge-graph"}]},{title:"扩展与监控",items:[{icon:tn,label:"插件市场",path:"/plugins"},{icon:tp,label:"插件配置",path:"/plugin-config"},{icon:Yu,label:"日志查看器",path:"/logs"},{icon:Dl,label:"本地聊天室",path:"/chat"}]},{title:"系统",items:[{icon:ti,label:"系统设置",path:"/settings"}]}],k=g==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":g,_=async()=>{await X0()};return e.jsx(uS,{delayDuration:300,children:e.jsxs("div",{className:"flex h-screen overflow-hidden",children:[e.jsxs("aside",{className:q("fixed inset-y-0 left-0 z-50 flex flex-col border-r bg-card transition-all duration-300 lg:relative lg:z-0","w-64 lg:w-auto",r?"lg:w-64":"lg:w-16",m?"translate-x-0":"-translate-x-full lg:translate-x-0"),children:[e.jsx("div",{className:"flex h-16 items-center border-b px-4",children:e.jsxs("div",{className:q("relative flex items-center justify-center flex-1 transition-all overflow-hidden","lg:flex-1",!r&&"lg:flex-none lg:w-8"),children:[e.jsxs("div",{className:q("flex items-baseline gap-2",!r&&"lg:hidden"),children:[e.jsx("span",{className:"font-bold text-xl text-primary-gradient whitespace-nowrap",children:"MaiBot WebUI"}),e.jsx("span",{className:"text-xs text-primary/60 whitespace-nowrap",children:A0()})]}),!r&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx(Ke,{className:q("flex-1 overflow-x-hidden",!r&&"lg:w-16"),children:e.jsx("nav",{className:q("p-4",!r&&"lg:p-2 lg:w-16"),children:e.jsx("ul",{className:q("space-y-6",!r&&"lg:space-y-3 lg:w-full"),children:w.map((L,D)=>e.jsxs("li",{children:[e.jsx("div",{className:q("px-3 h-[1.25rem]","mb-2",!r&&"lg:mb-1 lg:invisible"),children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:L.title})}),!r&&D>0&&e.jsx("div",{className:"hidden lg:block mb-2 border-t border-border"}),e.jsx("ul",{className:"space-y-1",children:L.items.map(U=>{const Q=j({to:U.path}),R=U.icon,z=e.jsxs(e.Fragment,{children:[Q&&e.jsx("div",{className:"absolute left-0 top-1/2 h-8 w-1 -translate-y-1/2 rounded-r-full bg-primary transition-opacity duration-300"}),e.jsxs("div",{className:q("flex items-center transition-all duration-300",r?"gap-3":"gap-3 lg:gap-0"),children:[e.jsx(R,{className:q("h-5 w-5 flex-shrink-0",Q&&"text-primary"),strokeWidth:2,fill:"none"}),e.jsx("span",{className:q("text-sm font-medium whitespace-nowrap transition-all duration-300",Q&&"font-semibold",r?"opacity-100 max-w-[200px]":"opacity-100 max-w-[200px] lg:opacity-0 lg:max-w-0 lg:overflow-hidden"),children:U.label})]})]});return e.jsx("li",{className:"relative",children:e.jsxs(mS,{children:[e.jsx(xS,{asChild:!0,children:e.jsx(Yn,{to:U.path,"data-tour":U.tourId,className:q("relative flex items-center rounded-lg py-2 transition-all duration-300","hover:bg-accent hover:text-accent-foreground",Q?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground",r?"px-3":"px-3 lg:px-0 lg:justify-center lg:w-12 lg:mx-auto"),onClick:()=>x(!1),children:z})}),!r&&e.jsx(bj,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:U.label})})]})},U.path)})})]},L.title))})})})]}),m&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>x(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("header",{className:"flex h-16 items-center justify-between border-b bg-card/80 backdrop-blur-md px-4 sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(!m),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(Cy,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>d(!r),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:r?"收起侧边栏":"展开侧边栏",children:e.jsx(rl,{className:q("h-5 w-5 transition-transform",!r&&"rotate-180")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>p(!0),className:"relative hidden md:flex items-center w-64 h-9 pl-9 pr-16 bg-background/50 border rounded-md hover:bg-accent/50 transition-colors text-left",children:[e.jsx(At,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"搜索..."}),e.jsxs(vj,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(dS,{open:f,onOpenChange:p}),e.jsxs(S,{variant:"ghost",size:"sm",onClick:()=>window.open("https://docs.mai-mai.org","_blank"),className:"gap-2",title:"查看麦麦文档",children:[e.jsx(ky,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:L=>{k0(k==="dark"?"light":"dark",N,L)},className:"rounded-lg p-2 hover:bg-accent",title:k==="dark"?"切换到浅色模式":"切换到深色模式",children:k==="dark"?e.jsx(gg,{className:"h-5 w-5"}):e.jsx(jg,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(S,{variant:"ghost",size:"sm",onClick:_,className:"gap-2",title:"登出系统",children:[e.jsx(Ty,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:n})]})]})})}function fS(n){const i=n.split(`
`).slice(1),r=[];for(const d of i){const m=d.trim();if(!m.startsWith("at "))continue;const x=m.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);x?r.push({functionName:x[1]||"<anonymous>",fileName:x[2],lineNumber:x[3],columnNumber:x[4],raw:m}):r.push({functionName:"<unknown>",fileName:"",lineNumber:"",columnNumber:"",raw:m})}return r}function pS({error:n,errorInfo:i}){const[r,d]=u.useState(!0),[m,x]=u.useState(!1),[f,p]=u.useState(!1),g=n.stack?fS(n.stack):[],N=async()=>{const j=`
Error: ${n.name}
Message: ${n.message}
Stack Trace:
${n.stack||"No stack trace available"}
Component Stack:
${i?.componentStack||"No component stack available"}
URL: ${window.location.href}
User Agent: ${navigator.userAgent}
Time: ${new Date().toISOString()}
`.trim();try{await navigator.clipboard.writeText(j),p(!0),setTimeout(()=>p(!1),2e3)}catch(w){console.error("Failed to copy:",w)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(It,{variant:"destructive",className:"border-red-500/50 bg-red-500/10",children:[e.jsx(Sa,{className:"h-4 w-4"}),e.jsxs(Yt,{className:"font-mono text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[n.name,":"]})," ",n.message]})]}),g.length>0&&e.jsxs(Fu,{open:r,onOpenChange:d,children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(S,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("span",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(Ey,{className:"h-4 w-4"}),"Stack Trace (",g.length," frames)"]}),r?e.jsx(ur,{className:"h-4 w-4"}):e.jsx(Ol,{className:"h-4 w-4"})]})}),e.jsx($u,{children:e.jsx(Ke,{className:"h-[280px] rounded-md border bg-muted/30",children:e.jsx("div",{className:"p-3 space-y-1",children:g.map((j,w)=>e.jsx("div",{className:"font-mono text-xs p-2 rounded hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("span",{className:"text-muted-foreground w-6 text-right flex-shrink-0",children:[w+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-primary font-medium",children:j.functionName}),j.fileName&&e.jsxs("div",{className:"text-muted-foreground mt-0.5 break-all",children:[j.fileName,j.lineNumber&&e.jsxs("span",{className:"text-yellow-600 dark:text-yellow-400",children:[":",j.lineNumber,":",j.columnNumber]})]})]})]})},w))})})})]}),i?.componentStack&&e.jsxs(Fu,{open:m,onOpenChange:x,children:[e.jsx(Vu,{asChild:!0,children:e.jsxs(S,{variant:"ghost",className:"w-full justify-between p-3 h-auto",children:[e.jsxs("span",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(Sa,{className:"h-4 w-4"}),"Component Stack"]}),m?e.jsx(ur,{className:"h-4 w-4"}):e.jsx(Ol,{className:"h-4 w-4"})]})}),e.jsx($u,{children:e.jsx(Ke,{className:"h-[200px] rounded-md border bg-muted/30",children:e.jsx("pre",{className:"p-3 font-mono text-xs whitespace-pre-wrap text-muted-foreground",children:i.componentStack})})})]}),e.jsx(S,{variant:"outline",size:"sm",onClick:N,className:"w-full",children:f?e.jsxs(e.Fragment,{children:[e.jsx(Qt,{className:"mr-2 h-4 w-4 text-green-500"}),"已复制到剪贴板"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qc,{className:"mr-2 h-4 w-4"}),"复制错误信息"]})})]})}function Nj({error:n,errorInfo:i}){const r=()=>{window.location.href="/"},d=()=>{window.location.reload()};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Qe,{className:"w-full max-w-2xl shadow-lg",children:[e.jsxs(ss,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30 mb-4",children:e.jsx(Sa,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),e.jsx(ts,{className:"text-2xl font-bold",children:"页面出现了问题"}),e.jsx(st,{className:"text-base mt-2",children:"应用程序遇到了意外错误。您可以尝试刷新页面或返回首页。"})]}),e.jsxs(ps,{className:"space-y-4",children:[e.jsx(pS,{error:n,errorInfo:i}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2",children:[e.jsxs(S,{onClick:d,className:"flex-1",children:[e.jsx(zt,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(S,{onClick:r,variant:"outline",className:"flex-1",children:[e.jsx(Pc,{className:"mr-2 h-4 w-4"}),"返回首页"]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pt-2",children:"如果问题持续存在,请将错误信息复制并反馈给开发者"})]})]})})}class gS extends u.Component{constructor(i){super(i),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}componentDidCatch(i,r){console.error("ErrorBoundary caught an error:",i,r),this.setState({errorInfo:r})}handleReset=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback:e.jsx(Nj,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}function yj({error:n}){return e.jsx(Nj,{error:n,errorInfo:null})}const vr=Fb({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(Tp,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!rS())throw $b({to:"/auth"})}}),jS=lt({getParentRoute:()=>vr,path:"/auth",component:K0}),vS=lt({getParentRoute:()=>vr,path:"/setup",component:uw}),jt=lt({getParentRoute:()=>vr,id:"protected",component:()=>e.jsx(hS,{children:e.jsx(Tp,{})}),errorComponent:({error:n})=>e.jsx(yj,{error:n})}),bS=lt({getParentRoute:()=>jt,path:"/",component:S0}),NS=lt({getParentRoute:()=>jt,path:"/config/bot",component:Vw}),yS=lt({getParentRoute:()=>jt,path:"/config/modelProvider",component:Ww}),wS=lt({getParentRoute:()=>jt,path:"/config/model",component:h1}),_S=lt({getParentRoute:()=>jt,path:"/config/adapter",component:p1}),SS=lt({getParentRoute:()=>jt,path:"/resource/emoji",component:H1}),CS=lt({getParentRoute:()=>jt,path:"/resource/expression",component:P1}),kS=lt({getParentRoute:()=>jt,path:"/resource/person",component:N2}),TS=lt({getParentRoute:()=>jt,path:"/resource/jargon",component:u2}),ES=lt({getParentRoute:()=>jt,path:"/resource/knowledge-graph",component:z2}),zS=lt({getParentRoute:()=>jt,path:"/logs",component:r_}),MS=lt({getParentRoute:()=>jt,path:"/chat",component:F_}),AS=lt({getParentRoute:()=>jt,path:"/plugins",component:M_}),DS=lt({getParentRoute:()=>jt,path:"/plugin-config",component:O_}),OS=lt({getParentRoute:()=>jt,path:"/plugin-mirrors",component:R_}),RS=lt({getParentRoute:()=>jt,path:"/settings",component:F0}),LS=lt({getParentRoute:()=>jt,path:"/survey/webui-feedback",component:lS}),US=lt({getParentRoute:()=>jt,path:"/survey/maibot-feedback",component:nS}),BS=lt({getParentRoute:()=>vr,path:"*",component:qg}),HS=vr.addChildren([jS,vS,jt.addChildren([bS,NS,yS,wS,_S,SS,CS,TS,kS,ES,AS,DS,OS,zS,MS,RS,LS,US]),BS]),qS=Vb({routeTree:HS,defaultNotFoundComponent:qg,defaultErrorComponent:({error:n})=>e.jsx(yj,{error:n})});function GS({children:n,defaultTheme:i="system",storageKey:r="ui-theme",...d}){const[m,x]=u.useState(()=>localStorage.getItem(r)||i);u.useEffect(()=>{const p=window.document.documentElement;if(p.classList.remove("light","dark"),m==="system"){const g=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";p.classList.add(g);return}p.classList.add(m)},[m]),u.useEffect(()=>{const p=localStorage.getItem("accent-color");if(p){const g=document.documentElement,j={blue:{hsl:"221.2 83.2% 53.3%",darkHsl:"217.2 91.2% 59.8%",gradient:null},purple:{hsl:"271 91% 65%",darkHsl:"270 95% 75%",gradient:null},green:{hsl:"142 71% 45%",darkHsl:"142 76% 36%",gradient:null},orange:{hsl:"25 95% 53%",darkHsl:"20 90% 48%",gradient:null},pink:{hsl:"330 81% 60%",darkHsl:"330 85% 70%",gradient:null},red:{hsl:"0 84% 60%",darkHsl:"0 90% 70%",gradient:null},"gradient-sunset":{hsl:"15 95% 60%",darkHsl:"15 95% 65%",gradient:"linear-gradient(135deg, hsl(25 95% 53%) 0%, hsl(330 81% 60%) 100%)"},"gradient-ocean":{hsl:"200 90% 55%",darkHsl:"200 90% 60%",gradient:"linear-gradient(135deg, hsl(221.2 83.2% 53.3%) 0%, hsl(189 94% 43%) 100%)"},"gradient-forest":{hsl:"150 70% 45%",darkHsl:"150 75% 40%",gradient:"linear-gradient(135deg, hsl(142 71% 45%) 0%, hsl(158 64% 52%) 100%)"},"gradient-aurora":{hsl:"310 85% 65%",darkHsl:"310 90% 70%",gradient:"linear-gradient(135deg, hsl(271 91% 65%) 0%, hsl(330 81% 60%) 100%)"},"gradient-fire":{hsl:"15 95% 55%",darkHsl:"15 95% 60%",gradient:"linear-gradient(135deg, hsl(0 84% 60%) 0%, hsl(25 95% 53%) 100%)"},"gradient-twilight":{hsl:"250 90% 60%",darkHsl:"250 95% 65%",gradient:"linear-gradient(135deg, hsl(239 84% 67%) 0%, hsl(271 91% 65%) 100%)"}}[p];j&&(g.style.setProperty("--primary",j.hsl),j.gradient?(g.style.setProperty("--primary-gradient",j.gradient),g.classList.add("has-gradient")):(g.style.removeProperty("--primary-gradient"),g.classList.remove("has-gradient")))}},[]);const f={theme:m,setTheme:p=>{localStorage.setItem(r,p),x(p)}};return e.jsx(Dg.Provider,{...d,value:f,children:n})}function FS({children:n,defaultEnabled:i=!0,defaultWavesEnabled:r=!0,storageKey:d="enable-animations",wavesStorageKey:m="enable-waves-background"}){const[x,f]=u.useState(()=>{const j=localStorage.getItem(d);return j!==null?j==="true":i}),[p,g]=u.useState(()=>{const j=localStorage.getItem(m);return j!==null?j==="true":r});u.useEffect(()=>{const j=document.documentElement;x?j.classList.remove("no-animations"):j.classList.add("no-animations"),localStorage.setItem(d,String(x))},[x,d]),u.useEffect(()=>{localStorage.setItem(m,String(p))},[p,m]);const N={enableAnimations:x,setEnableAnimations:f,enableWavesBackground:p,setEnableWavesBackground:g};return e.jsx(Og.Provider,{value:N,children:n})}const VS=KN,wj=u.forwardRef(({className:n,...i},r)=>e.jsx(dg,{ref:r,className:q("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:max-w-[420px] gap-2",n),...i}));wj.displayName=dg.displayName;const $S=si("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-slide-in-from-right data-[state=open]:animate-fade-in data-[state=closed]:animate-slide-out-to-right data-[state=closed]:animate-fade-out data-[swipe=end]:animate-slide-out-to-right",{variants:{variant:{default:"border bg-primary/5 text-foreground backdrop-blur-sm",destructive:"destructive group border-destructive bg-destructive/10 text-destructive-foreground backdrop-blur-sm"}},defaultVariants:{variant:"default"}}),_j=u.forwardRef(({className:n,variant:i,...r},d)=>e.jsx(ug,{ref:d,className:q($S({variant:i}),n),...r}));_j.displayName=ug.displayName;const QS=u.forwardRef(({className:n,...i},r)=>e.jsx(mg,{ref:r,className:q("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",n),...i}));QS.displayName=mg.displayName;const Sj=u.forwardRef(({className:n,...i},r)=>e.jsx(xg,{ref:r,className:q("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",n),"toast-close":"",...i,children:e.jsx(il,{className:"h-4 w-4"})}));Sj.displayName=xg.displayName;const Cj=u.forwardRef(({className:n,...i},r)=>e.jsx(hg,{ref:r,className:q("text-sm font-semibold [&+div]:text-xs",n),...i}));Cj.displayName=hg.displayName;const kj=u.forwardRef(({className:n,...i},r)=>e.jsx(fg,{ref:r,className:q("text-sm opacity-90",n),...i}));kj.displayName=fg.displayName;function IS(){const{toasts:n}=Bs();return e.jsxs(VS,{children:[n.map(function({id:i,title:r,description:d,action:m,...x}){return e.jsxs(_j,{...x,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(Cj,{children:r}),d&&e.jsx(kj,{children:d})]}),m,e.jsx(Sj,{})]},i)}),e.jsx(wj,{})]})}h0.createRoot(document.getElementById("root")).render(e.jsx(u.StrictMode,{children:e.jsx(gS,{children:e.jsx(GS,{defaultTheme:"system",children:e.jsx(FS,{children:e.jsxs(Xw,{children:[e.jsx(Qb,{router:qS}),e.jsx(Pw,{}),e.jsx(IS,{})]})})})})}));