mirror of https://github.com/Mai-with-u/MaiBot.git
95 lines
1.0 MiB
95 lines
1.0 MiB
import{r as u,j as e,L as Kn,e as ha,R as Bs,b as tw,f as aw,g as lw,h as nw,k as rw,l as lt,m as iw,n as cw,O as xj,o as ow}from"./router-9vIXuQkh.js";import{a as dw,b as uw,g as mw}from"./react-vendor-BmxF9s7Q.js";import{N as xw,c as hw,O as ti,P as fw,g as Em}from"./utils-BqoaXoQ1.js";import{L as hj,T as fj,C as pj,R as pw,a as gj,V as gw,b as jw,S as jj,c as vw,d as vj,I as Nw,e as Nj,f as bw,g as bj,h as yw,i as ww,j as _w,O as yj,P as Sw,k as wj,l as _j,D as Sj,A as kj,m as Cj,n as kw,o as Cw,p as Tj,q as Tw,r as Ej,s as Ew,t as Mw,u as Mj,v as Aw,w as zw,x as Aj,y as zj,F as Rj,z as Dj,B as Rw,E as Dw,G as Oj,H as Ow,J as Lw,K as Uw,M as $w,N as Bw,Q as Iw,U as Pw,W as Fw,X as Hw,Y as qw,Z as Vw,_ as Gw,$ as Kw,a0 as Qw,a1 as Yw,a2 as Lj,a3 as Jw,a4 as Xw}from"./radix-extra-DmmnfeQE.js";import{R as Uj,T as $j,L as Zw,g as Ww,C as Ji,X as Xi,Y as Gr,h as e1,B as Bo,j as Zi,P as s1,k as t1,l as a1}from"./charts-simvewUa.js";import{S as l1,O as Bj,o as n1,C as Ij,p as r1,T as Pj,D as Fj,R as i1,q as c1,H as Hj,I as o1,J as qj,K as d1,L as Vj,M as Gj,N as u1,Q as Kj,V as m1,U as Qj,X as Yj,Y as x1,Z as h1,_ as Jj,$ as f1,a0 as p1,a1 as Xj,a2 as g1,a3 as Zj,a4 as j1,a5 as v1,a6 as N1,e as Wj,f as ad,c as ld,P as ar,d as nd,b as _n,h as b1,l as y1,m as w1,u as Ym,r as _1,a as S1,a7 as ev,a8 as sv,a9 as tv,aa as av,ab as lv,ac as nv,ad as k1}from"./radix-core-DyJi0yyw.js";import{R as dt,a as rc,C as Rt,b as st,L as Fs,X as Sa,c as Lt,d as Ba,e as Xr,f as Pa,g as ra,E as C1,h as rv,Z as sl,i as da,j as ta,S as $t,B as iv,U as Fl,k as Yn,P as pc,l as cv,F as Ua,m as T1,n as Sn,o as E1,M as Ia,A as nx,D as M1,p as Zr,T as rx,q as A1,r as ov,I as Yt,s as Ut,t as qo,u as ic,v as ua,H as z1,w as os,x as na,y as cc,z as ix,G as tc,J as Jm,K as cx,N as ox,O as R1,Q as Io,V as D1,W as rd,Y as O1,_ as L1,$ as id,a0 as $a,a1 as Xs,a2 as dx,a3 as ux,a4 as dv,a5 as gc,a6 as uv,a7 as Zn,a8 as kn,a9 as Cn,aa as mx,ab as mv,ac as xa,ad as Hl,ae as Wn,af as er,ag as cd,ah as U1,ai as $1,aj as B1,ak as I1,al as xx,am as Po,an as sr,ao as Wr,ap as Vo,aq as P1,ar as Go,as as oc,at as xv,au as F1,av as H1,aw as Ko,ax as q1,ay as hx,az as Mg,aA as V1,aB as G1,aC as hv,aD as K1,aE as vn,aF as fv,aG as Mm,aH as Ag,aI as Q1,aJ as Am,aK as Y1,aL as J1,aM as X1,aN as Z1,aO as pv,aP as W1,aQ as ei,aR as e_,aS as s_,aT as gv,aU as jv,aV as t_,aW as a_,aX as zg,aY as l_,aZ as n_,a_ as r_,a$ as i_,b0 as c_}from"./icons-8bdCaZgy.js";import{S as o_,p as d_,j as u_,a as m_,E as zm,R as x_,o as h_}from"./codemirror-TZqPU532.js";import{u as vv,a as Qo,s as Nv,K as bv,P as yv,b as wv,D as _v,c as Sv,S as kv,v as f_,d as Cv,C as Tv,h as p_}from"./dnd-BiPfFtVp.js";import{_ as ka,c as g_,g as Ev,D as j_,z as Oo}from"./misc-CJqnlRwD.js";import{D as v_,U as N_}from"./uppy-DFP_VzYR.js";import{M as b_,r as y_,a as w_,b as __}from"./markdown-CKA5gBQ9.js";import{c as S_,H as Yo,P as Jo,u as k_,d as C_,R as T_,B as E_,e as M_,C as A_,M as z_,f as R_}from"./reactflow-DtsZHOR4.js";(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))c(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const h of m.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function r(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function c(d){if(d.ep)return;d.ep=!0;const m=r(d);fetch(d.href,m)}})();var Rm={exports:{}},Ki={},Dm={exports:{}},Om={};var Rg;function D_(){return Rg||(Rg=1,(function(a){function l(D,Q){var B=D.length;D.push(Q);e:for(;0<B;){var ue=B-1>>>1,Y=D[ue];if(0<d(Y,Q))D[ue]=Q,D[B]=Y,B=ue;else break e}}function r(D){return D.length===0?null:D[0]}function c(D){if(D.length===0)return null;var Q=D[0],B=D.pop();if(B!==Q){D[0]=B;e:for(var ue=0,Y=D.length,we=Y>>>1;ue<we;){var fe=2*(ue+1)-1,Ee=D[fe],G=fe+1,$=D[G];if(0>d(Ee,B))G<Y&&0>d($,Ee)?(D[ue]=$,D[G]=B,ue=G):(D[ue]=Ee,D[fe]=B,ue=fe);else if(G<Y&&0>d($,B))D[ue]=$,D[G]=B,ue=G;else break e}}return Q}function d(D,Q){var B=D.sortIndex-Q.sortIndex;return B!==0?B:D.id-Q.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;a.unstable_now=function(){return m.now()}}else{var h=Date,f=h.now();a.unstable_now=function(){return h.now()-f}}var p=[],g=[],N=1,j=null,b=3,y=!1,w=!1,z=!1,M=!1,S=typeof setTimeout=="function"?setTimeout:null,F=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function C(D){for(var Q=r(g);Q!==null;){if(Q.callback===null)c(g);else if(Q.startTime<=D)c(g),Q.sortIndex=Q.expirationTime,l(p,Q);else break;Q=r(g)}}function R(D){if(z=!1,C(D),!w)if(r(p)!==null)w=!0,H||(H=!0,je());else{var Q=r(g);Q!==null&&pe(R,Q.startTime-D)}}var H=!1,O=-1,X=5,L=-1;function me(){return M?!0:!(a.unstable_now()-L<X)}function Ne(){if(M=!1,H){var D=a.unstable_now();L=D;var Q=!0;try{e:{w=!1,z&&(z=!1,F(O),O=-1),y=!0;var B=b;try{s:{for(C(D),j=r(p);j!==null&&!(j.expirationTime>D&&me());){var ue=j.callback;if(typeof ue=="function"){j.callback=null,b=j.priorityLevel;var Y=ue(j.expirationTime<=D);if(D=a.unstable_now(),typeof Y=="function"){j.callback=Y,C(D),Q=!0;break s}j===r(p)&&c(p),C(D)}else c(p);j=r(p)}if(j!==null)Q=!0;else{var we=r(g);we!==null&&pe(R,we.startTime-D),Q=!1}}break e}finally{j=null,b=B,y=!1}Q=void 0}}finally{Q?je():H=!1}}}var je;if(typeof E=="function")je=function(){E(Ne)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,ge=ce.port2;ce.port1.onmessage=Ne,je=function(){ge.postMessage(null)}}else je=function(){S(Ne,0)};function pe(D,Q){O=S(function(){D(a.unstable_now())},Q)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(D){D.callback=null},a.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<D?Math.floor(1e3/D):5},a.unstable_getCurrentPriorityLevel=function(){return b},a.unstable_next=function(D){switch(b){case 1:case 2:case 3:var Q=3;break;default:Q=b}var B=b;b=Q;try{return D()}finally{b=B}},a.unstable_requestPaint=function(){M=!0},a.unstable_runWithPriority=function(D,Q){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var B=b;b=D;try{return Q()}finally{b=B}},a.unstable_scheduleCallback=function(D,Q,B){var ue=a.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?ue+B:ue):B=ue,D){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=B+Y,D={id:N++,callback:Q,priorityLevel:D,startTime:B,expirationTime:Y,sortIndex:-1},B>ue?(D.sortIndex=B,l(g,D),r(p)===null&&D===r(g)&&(z?(F(O),O=-1):z=!0,pe(R,B-ue))):(D.sortIndex=Y,l(p,D),w||y||(w=!0,H||(H=!0,je()))),D},a.unstable_shouldYield=me,a.unstable_wrapCallback=function(D){var Q=b;return function(){var B=b;b=Q;try{return D.apply(this,arguments)}finally{b=B}}}})(Om)),Om}var Dg;function O_(){return Dg||(Dg=1,Dm.exports=D_()),Dm.exports}var Og;function L_(){if(Og)return Ki;Og=1;var a=O_(),l=dw(),r=uw();function c(s){var t="https://react.dev/errors/"+s;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}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 d(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function m(s){var t=s,n=s;if(s.alternate)for(;t.return;)t=t.return;else{s=t;do t=s,(t.flags&4098)!==0&&(n=t.return),s=t.return;while(s)}return t.tag===3?n:null}function h(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 f(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 p(s){if(m(s)!==s)throw Error(c(188))}function g(s){var t=s.alternate;if(!t){if(t=m(s),t===null)throw Error(c(188));return t!==s?null:s}for(var n=s,i=t;;){var o=n.return;if(o===null)break;var x=o.alternate;if(x===null){if(i=o.return,i!==null){n=i;continue}break}if(o.child===x.child){for(x=o.child;x;){if(x===n)return p(o),s;if(x===i)return p(o),t;x=x.sibling}throw Error(c(188))}if(n.return!==i.return)n=o,i=x;else{for(var v=!1,k=o.child;k;){if(k===n){v=!0,n=o,i=x;break}if(k===i){v=!0,i=o,n=x;break}k=k.sibling}if(!v){for(k=x.child;k;){if(k===n){v=!0,n=x,i=o;break}if(k===i){v=!0,i=x,n=o;break}k=k.sibling}if(!v)throw Error(c(189))}}if(n.alternate!==i)throw Error(c(190))}if(n.tag!==3)throw Error(c(188));return n.stateNode.current===n?s:t}function N(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s;for(s=s.child;s!==null;){if(t=N(s),t!==null)return t;s=s.sibling}return null}var j=Object.assign,b=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),E=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),me=Symbol.for("react.memo_cache_sentinel"),Ne=Symbol.iterator;function je(s){return s===null||typeof s!="object"?null:(s=Ne&&s[Ne]||s["@@iterator"],typeof s=="function"?s:null)}var ce=Symbol.for("react.client.reference");function ge(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===ce?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case z:return"Fragment";case S:return"Profiler";case M:return"StrictMode";case R:return"Suspense";case H:return"SuspenseList";case L:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case w:return"Portal";case E:return s.displayName||"Context";case F:return(s._context.displayName||"Context")+".Consumer";case C:var t=s.render;return s=s.displayName,s||(s=t.displayName||t.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case O:return t=s.displayName||null,t!==null?t:ge(s.type)||"Memo";case X:t=s._payload,s=s._init;try{return ge(s(t))}catch{}}return null}var pe=Array.isArray,D=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B={pending:!1,data:null,method:null,action:null},ue=[],Y=-1;function we(s){return{current:s}}function fe(s){0>Y||(s.current=ue[Y],ue[Y]=null,Y--)}function Ee(s,t){Y++,ue[Y]=s.current,s.current=t}var G=we(null),$=we(null),A=we(null),K=we(null);function Re(s,t){switch(Ee(A,t),Ee($,s),Ee(G,null),t.nodeType){case 9:case 11:s=(s=t.documentElement)&&(s=s.namespaceURI)?Wp(s):0;break;default:if(s=t.tagName,t=t.namespaceURI)t=Wp(t),s=eg(t,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}fe(G),Ee(G,s)}function se(){fe(G),fe($),fe(A)}function $e(s){s.memoizedState!==null&&Ee(K,s);var t=G.current,n=eg(t,s.type);t!==n&&(Ee($,s),Ee(G,n))}function cs(s){$.current===s&&(fe(G),fe($)),K.current===s&&(fe(K),Hi._currentValue=B)}var J,Z;function Le(s){if(J===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);J=t&&t[1]||"",Z=-1<n.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+J+s+Z}var le=!1;function De(s,t){if(!s||le)return"";le=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(t){var ye=function(){throw Error()};if(Object.defineProperty(ye.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ye,[])}catch(he){var de=he}Reflect.construct(s,[],ye)}else{try{ye.call()}catch(he){de=he}s.call(ye.prototype)}}else{try{throw Error()}catch(he){de=he}(ye=s())&&typeof ye.catch=="function"&&ye.catch(function(){})}}catch(he){if(he&&de&&typeof he.stack=="string")return[he.stack,de.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var o=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");o&&o.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=i.DetermineComponentFrameRoot(),v=x[0],k=x[1];if(v&&k){var I=v.split(`
|
||
`),ie=k.split(`
|
||
`);for(o=i=0;i<I.length&&!I[i].includes("DetermineComponentFrameRoot");)i++;for(;o<ie.length&&!ie[o].includes("DetermineComponentFrameRoot");)o++;if(i===I.length||o===ie.length)for(i=I.length-1,o=ie.length-1;1<=i&&0<=o&&I[i]!==ie[o];)o--;for(;1<=i&&0<=o;i--,o--)if(I[i]!==ie[o]){if(i!==1||o!==1)do if(i--,o--,0>o||I[i]!==ie[o]){var ve=`
|
||
`+I[i].replace(" at new "," at ");return s.displayName&&ve.includes("<anonymous>")&&(ve=ve.replace("<anonymous>",s.displayName)),ve}while(1<=i&&0<=o);break}}}finally{le=!1,Error.prepareStackTrace=n}return(n=s?s.displayName||s.name:"")?Le(n):""}function xe(s,t){switch(s.tag){case 26:case 27:case 5:return Le(s.type);case 16:return Le("Lazy");case 13:return s.child!==t&&t!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return De(s.type,!1);case 11:return De(s.type.render,!1);case 1:return De(s.type,!0);case 31:return Le("Activity");default:return""}}function Me(s){try{var t="",n=null;do t+=xe(s,n),n=s,s=s.return;while(s);return t}catch(i){return`
|
||
Error generating stack: `+i.message+`
|
||
`+i.stack}}var ds=Object.prototype.hasOwnProperty,Ts=a.unstable_scheduleCallback,kt=a.unstable_cancelCallback,ia=a.unstable_shouldYield,ut=a.unstable_requestPaint,Is=a.unstable_now,V=a.unstable_getCurrentPriorityLevel,Ke=a.unstable_ImmediatePriority,He=a.unstable_UserBlockingPriority,Je=a.unstable_NormalPriority,Es=a.unstable_LowPriority,ms=a.unstable_IdlePriority,Ms=a.log,We=a.unstable_setDisableYieldValue,Cs=null,rs=null;function is(s){if(typeof Ms=="function"&&We(s),rs&&typeof rs.setStrictMode=="function")try{rs.setStrictMode(Cs,s)}catch{}}var ys=Math.clz32?Math.clz32:Ae,rt=Math.log,jt=Math.LN2;function Ae(s){return s>>>=0,s===0?32:31-(rt(s)/jt|0)|0}var Qe=256,As=262144,mt=4194304;function Ht(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 ca(s,t,n){var i=s.pendingLanes;if(i===0)return 0;var o=0,x=s.suspendedLanes,v=s.pingedLanes;s=s.warmLanes;var k=i&134217727;return k!==0?(i=k&~x,i!==0?o=Ht(i):(v&=k,v!==0?o=Ht(v):n||(n=k&~s,n!==0&&(o=Ht(n))))):(k=i&~x,k!==0?o=Ht(k):v!==0?o=Ht(v):n||(n=i&~s,n!==0&&(o=Ht(n)))),o===0?0:t!==0&&t!==o&&(t&x)===0&&(x=o&-o,n=t&-t,x>=n||x===32&&(n&4194048)!==0)?t:o}function Fa(s,t){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&t)===0}function Xt(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 te(){var s=mt;return mt<<=1,(mt&62914560)===0&&(mt=4194304),s}function _e(s){for(var t=[],n=0;31>n;n++)t.push(s);return t}function U(s,t){s.pendingLanes|=t,t!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Se(s,t,n,i,o,x){var v=s.pendingLanes;s.pendingLanes=n,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=n,s.entangledLanes&=n,s.errorRecoveryDisabledLanes&=n,s.shellSuspendCounter=0;var k=s.entanglements,I=s.expirationTimes,ie=s.hiddenUpdates;for(n=v&~n;0<n;){var ve=31-ys(n),ye=1<<ve;k[ve]=0,I[ve]=-1;var de=ie[ve];if(de!==null)for(ie[ve]=null,ve=0;ve<de.length;ve++){var he=de[ve];he!==null&&(he.lane&=-536870913)}n&=~ye}i!==0&&as(s,i,0),x!==0&&o===0&&s.tag!==0&&(s.suspendedLanes|=x&~(v&~t))}function as(s,t,n){s.pendingLanes|=t,s.suspendedLanes&=~t;var i=31-ys(t);s.entangledLanes|=t,s.entanglements[i]=s.entanglements[i]|1073741824|n&261930}function us(s,t){var n=s.entangledLanes|=t;for(s=s.entanglements;n;){var i=31-ys(n),o=1<<i;o&t|s[i]&t&&(s[i]|=t),n&=~o}}function es(s,t){var n=t&-t;return n=(n&42)!==0?1:Ct(n),(n&(s.suspendedLanes|t))!==0?0:n}function Ct(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 $s(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function pa(){var s=Q.p;return s!==0?s:(s=window.event,s===void 0?32:wg(s.type))}function oa(s,t){var n=Q.p;try{return Q.p=s,t()}finally{Q.p=n}}var ae=Math.random().toString(36).slice(2),oe="__reactFiber$"+ae,qe="__reactProps$"+ae,Ys="__reactContainer$"+ae,Ps="__reactEvents$"+ae,vt="__reactListeners$"+ae,Ca="__reactHandles$"+ae,ll="__reactResources$"+ae,ml="__reactMarker$"+ae;function rr(s){delete s[oe],delete s[qe],delete s[Ps],delete s[vt],delete s[Ca]}function Ql(s){var t=s[oe];if(t)return t;for(var n=s.parentNode;n;){if(t=n[Ys]||n[oe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(s=ig(s);s!==null;){if(n=s[oe])return n;s=ig(s)}return t}s=n,n=s.parentNode}return null}function ir(s){if(s=s[oe]||s[Ys]){var t=s.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return s}return null}function ni(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s.stateNode;throw Error(c(33))}function cr(s){var t=s[ll];return t||(t=s[ll]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Kt(s){s[ml]=!0}var Ix=new Set,Px={};function Mn(s,t){or(s,t),or(s+"Capture",t)}function or(s,t){for(Px[s]=t,s=0;s<t.length;s++)Ix.add(t[s])}var Kb=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]*$"),Fx={},Hx={};function Qb(s){return ds.call(Hx,s)?!0:ds.call(Fx,s)?!1:Kb.test(s)?Hx[s]=!0:(Fx[s]=!0,!1)}function yc(s,t,n){if(Qb(t))if(n===null)s.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":s.removeAttribute(t);return;case"boolean":var i=t.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){s.removeAttribute(t);return}}s.setAttribute(t,""+n)}}function wc(s,t,n){if(n===null)s.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(t);return}s.setAttribute(t,""+n)}}function vl(s,t,n,i){if(i===null)s.removeAttribute(n);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(n);return}s.setAttributeNS(t,n,""+i)}}function Ha(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function qx(s){var t=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Yb(s,t,n){var i=Object.getOwnPropertyDescriptor(s.constructor.prototype,t);if(!s.hasOwnProperty(t)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var o=i.get,x=i.set;return Object.defineProperty(s,t,{configurable:!0,get:function(){return o.call(this)},set:function(v){n=""+v,x.call(this,v)}}),Object.defineProperty(s,t,{enumerable:i.enumerable}),{getValue:function(){return n},setValue:function(v){n=""+v},stopTracking:function(){s._valueTracker=null,delete s[t]}}}}function yd(s){if(!s._valueTracker){var t=qx(s)?"checked":"value";s._valueTracker=Yb(s,t,""+s[t])}}function Vx(s){if(!s)return!1;var t=s._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return s&&(i=qx(s)?s.checked?"true":"false":s.value),s=i,s!==n?(t.setValue(s),!0):!1}function _c(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 Jb=/[\n"\\]/g;function qa(s){return s.replace(Jb,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function wd(s,t,n,i,o,x,v,k){s.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?s.type=v:s.removeAttribute("type"),t!=null?v==="number"?(t===0&&s.value===""||s.value!=t)&&(s.value=""+Ha(t)):s.value!==""+Ha(t)&&(s.value=""+Ha(t)):v!=="submit"&&v!=="reset"||s.removeAttribute("value"),t!=null?_d(s,v,Ha(t)):n!=null?_d(s,v,Ha(n)):i!=null&&s.removeAttribute("value"),o==null&&x!=null&&(s.defaultChecked=!!x),o!=null&&(s.checked=o&&typeof o!="function"&&typeof o!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?s.name=""+Ha(k):s.removeAttribute("name")}function Gx(s,t,n,i,o,x,v,k){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(s.type=x),t!=null||n!=null){if(!(x!=="submit"&&x!=="reset"||t!=null)){yd(s);return}n=n!=null?""+Ha(n):"",t=t!=null?""+Ha(t):n,k||t===s.value||(s.value=t),s.defaultValue=t}i=i??o,i=typeof i!="function"&&typeof i!="symbol"&&!!i,s.checked=k?s.checked:!!i,s.defaultChecked=!!i,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(s.name=v),yd(s)}function _d(s,t,n){t==="number"&&_c(s.ownerDocument)===s||s.defaultValue===""+n||(s.defaultValue=""+n)}function dr(s,t,n,i){if(s=s.options,t){t={};for(var o=0;o<n.length;o++)t["$"+n[o]]=!0;for(n=0;n<s.length;n++)o=t.hasOwnProperty("$"+s[n].value),s[n].selected!==o&&(s[n].selected=o),o&&i&&(s[n].defaultSelected=!0)}else{for(n=""+Ha(n),t=null,o=0;o<s.length;o++){if(s[o].value===n){s[o].selected=!0,i&&(s[o].defaultSelected=!0);return}t!==null||s[o].disabled||(t=s[o])}t!==null&&(t.selected=!0)}}function Kx(s,t,n){if(t!=null&&(t=""+Ha(t),t!==s.value&&(s.value=t),n==null)){s.defaultValue!==t&&(s.defaultValue=t);return}s.defaultValue=n!=null?""+Ha(n):""}function Qx(s,t,n,i){if(t==null){if(i!=null){if(n!=null)throw Error(c(92));if(pe(i)){if(1<i.length)throw Error(c(93));i=i[0]}n=i}n==null&&(n=""),t=n}n=Ha(t),s.defaultValue=n,i=s.textContent,i===n&&i!==""&&i!==null&&(s.value=i),yd(s)}function ur(s,t){if(t){var n=s.firstChild;if(n&&n===s.lastChild&&n.nodeType===3){n.nodeValue=t;return}}s.textContent=t}var Xb=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 Yx(s,t,n){var i=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?i?s.setProperty(t,""):t==="float"?s.cssFloat="":s[t]="":i?s.setProperty(t,n):typeof n!="number"||n===0||Xb.has(t)?t==="float"?s.cssFloat=n:s[t]=(""+n).trim():s[t]=n+"px"}function Jx(s,t,n){if(t!=null&&typeof t!="object")throw Error(c(62));if(s=s.style,n!=null){for(var i in n)!n.hasOwnProperty(i)||t!=null&&t.hasOwnProperty(i)||(i.indexOf("--")===0?s.setProperty(i,""):i==="float"?s.cssFloat="":s[i]="");for(var o in t)i=t[o],t.hasOwnProperty(o)&&n[o]!==i&&Yx(s,o,i)}else for(var x in t)t.hasOwnProperty(x)&&Yx(s,x,t[x])}function Sd(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 Zb=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"]]),Wb=/^[\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 Sc(s){return Wb.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function Nl(){}var kd=null;function Cd(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var mr=null,xr=null;function Xx(s){var t=ir(s);if(t&&(s=t.stateNode)){var n=s[qe]||null;e:switch(s=t.stateNode,t.type){case"input":if(wd(s,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=s;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+qa(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var i=n[t];if(i!==s&&i.form===s.form){var o=i[qe]||null;if(!o)throw Error(c(90));wd(i,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name)}}for(t=0;t<n.length;t++)i=n[t],i.form===s.form&&Vx(i)}break e;case"textarea":Kx(s,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&dr(s,!!n.multiple,t,!1)}}}var Td=!1;function Zx(s,t,n){if(Td)return s(t,n);Td=!0;try{var i=s(t);return i}finally{if(Td=!1,(mr!==null||xr!==null)&&(xo(),mr&&(t=mr,s=xr,xr=mr=null,Xx(t),s)))for(t=0;t<s.length;t++)Xx(s[t])}}function ri(s,t){var n=s.stateNode;if(n===null)return null;var i=n[qe]||null;if(i===null)return null;n=i[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":(i=!i.disabled)||(s=s.type,i=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!i;break e;default:s=!1}if(s)return null;if(n&&typeof n!="function")throw Error(c(231,t,typeof n));return n}var bl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ed=!1;if(bl)try{var ii={};Object.defineProperty(ii,"passive",{get:function(){Ed=!0}}),window.addEventListener("test",ii,ii),window.removeEventListener("test",ii,ii)}catch{Ed=!1}var Yl=null,Md=null,kc=null;function Wx(){if(kc)return kc;var s,t=Md,n=t.length,i,o="value"in Yl?Yl.value:Yl.textContent,x=o.length;for(s=0;s<n&&t[s]===o[s];s++);var v=n-s;for(i=1;i<=v&&t[n-i]===o[x-i];i++);return kc=o.slice(s,1<i?1-i:void 0)}function Cc(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 Tc(){return!0}function eh(){return!1}function ga(s){function t(n,i,o,x,v){this._reactName=n,this._targetInst=o,this.type=i,this.nativeEvent=x,this.target=v,this.currentTarget=null;for(var k in s)s.hasOwnProperty(k)&&(n=s[k],this[k]=n?n(x):x[k]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?Tc:eh,this.isPropagationStopped=eh,this}return j(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Tc)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Tc)},persist:function(){},isPersistent:Tc}),t}var An={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ec=ga(An),ci=j({},An,{view:0,detail:0}),ey=ga(ci),Ad,zd,oi,Mc=j({},ci,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Dd,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!==oi&&(oi&&s.type==="mousemove"?(Ad=s.screenX-oi.screenX,zd=s.screenY-oi.screenY):zd=Ad=0,oi=s),Ad)},movementY:function(s){return"movementY"in s?s.movementY:zd}}),sh=ga(Mc),sy=j({},Mc,{dataTransfer:0}),ty=ga(sy),ay=j({},ci,{relatedTarget:0}),Rd=ga(ay),ly=j({},An,{animationName:0,elapsedTime:0,pseudoElement:0}),ny=ga(ly),ry=j({},An,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),iy=ga(ry),cy=j({},An,{data:0}),th=ga(cy),oy={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},dy={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"},uy={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function my(s){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(s):(s=uy[s])?!!t[s]:!1}function Dd(){return my}var xy=j({},ci,{key:function(s){if(s.key){var t=oy[s.key]||s.key;if(t!=="Unidentified")return t}return s.type==="keypress"?(s=Cc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?dy[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Dd,charCode:function(s){return s.type==="keypress"?Cc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Cc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),hy=ga(xy),fy=j({},Mc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ah=ga(fy),py=j({},ci,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Dd}),gy=ga(py),jy=j({},An,{propertyName:0,elapsedTime:0,pseudoElement:0}),vy=ga(jy),Ny=j({},Mc,{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}),by=ga(Ny),yy=j({},An,{newState:0,oldState:0}),wy=ga(yy),_y=[9,13,27,32],Od=bl&&"CompositionEvent"in window,di=null;bl&&"documentMode"in document&&(di=document.documentMode);var Sy=bl&&"TextEvent"in window&&!di,lh=bl&&(!Od||di&&8<di&&11>=di),nh=" ",rh=!1;function ih(s,t){switch(s){case"keyup":return _y.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ch(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var hr=!1;function ky(s,t){switch(s){case"compositionend":return ch(t);case"keypress":return t.which!==32?null:(rh=!0,nh);case"textInput":return s=t.data,s===nh&&rh?null:s;default:return null}}function Cy(s,t){if(hr)return s==="compositionend"||!Od&&ih(s,t)?(s=Wx(),kc=Md=Yl=null,hr=!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 lh&&t.locale!=="ko"?null:t.data;default:return null}}var Ty={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 oh(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t==="input"?!!Ty[s.type]:t==="textarea"}function dh(s,t,n,i){mr?xr?xr.push(i):xr=[i]:mr=i,t=No(t,"onChange"),0<t.length&&(n=new Ec("onChange","change",null,n,i),s.push({event:n,listeners:t}))}var ui=null,mi=null;function Ey(s){Kp(s,0)}function Ac(s){var t=ni(s);if(Vx(t))return s}function uh(s,t){if(s==="change")return t}var mh=!1;if(bl){var Ld;if(bl){var Ud="oninput"in document;if(!Ud){var xh=document.createElement("div");xh.setAttribute("oninput","return;"),Ud=typeof xh.oninput=="function"}Ld=Ud}else Ld=!1;mh=Ld&&(!document.documentMode||9<document.documentMode)}function hh(){ui&&(ui.detachEvent("onpropertychange",fh),mi=ui=null)}function fh(s){if(s.propertyName==="value"&&Ac(mi)){var t=[];dh(t,mi,s,Cd(s)),Zx(Ey,t)}}function My(s,t,n){s==="focusin"?(hh(),ui=t,mi=n,ui.attachEvent("onpropertychange",fh)):s==="focusout"&&hh()}function Ay(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return Ac(mi)}function zy(s,t){if(s==="click")return Ac(t)}function Ry(s,t){if(s==="input"||s==="change")return Ac(t)}function Dy(s,t){return s===t&&(s!==0||1/s===1/t)||s!==s&&t!==t}var Ta=typeof Object.is=="function"?Object.is:Dy;function xi(s,t){if(Ta(s,t))return!0;if(typeof s!="object"||s===null||typeof t!="object"||t===null)return!1;var n=Object.keys(s),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var o=n[i];if(!ds.call(t,o)||!Ta(s[o],t[o]))return!1}return!0}function ph(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function gh(s,t){var n=ph(s);s=0;for(var i;n;){if(n.nodeType===3){if(i=s+n.textContent.length,s<=t&&i>=t)return{node:n,offset:t-s};s=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ph(n)}}function jh(s,t){return s&&t?s===t?!0:s&&s.nodeType===3?!1:t&&t.nodeType===3?jh(s,t.parentNode):"contains"in s?s.contains(t):s.compareDocumentPosition?!!(s.compareDocumentPosition(t)&16):!1:!1}function vh(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var t=_c(s.document);t instanceof s.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)s=t.contentWindow;else break;t=_c(s.document)}return t}function $d(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 Oy=bl&&"documentMode"in document&&11>=document.documentMode,fr=null,Bd=null,hi=null,Id=!1;function Nh(s,t,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Id||fr==null||fr!==_c(i)||(i=fr,"selectionStart"in i&&$d(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),hi&&xi(hi,i)||(hi=i,i=No(Bd,"onSelect"),0<i.length&&(t=new Ec("onSelect","select",null,t,n),s.push({event:t,listeners:i}),t.target=fr)))}function zn(s,t){var n={};return n[s.toLowerCase()]=t.toLowerCase(),n["Webkit"+s]="webkit"+t,n["Moz"+s]="moz"+t,n}var pr={animationend:zn("Animation","AnimationEnd"),animationiteration:zn("Animation","AnimationIteration"),animationstart:zn("Animation","AnimationStart"),transitionrun:zn("Transition","TransitionRun"),transitionstart:zn("Transition","TransitionStart"),transitioncancel:zn("Transition","TransitionCancel"),transitionend:zn("Transition","TransitionEnd")},Pd={},bh={};bl&&(bh=document.createElement("div").style,"AnimationEvent"in window||(delete pr.animationend.animation,delete pr.animationiteration.animation,delete pr.animationstart.animation),"TransitionEvent"in window||delete pr.transitionend.transition);function Rn(s){if(Pd[s])return Pd[s];if(!pr[s])return s;var t=pr[s],n;for(n in t)if(t.hasOwnProperty(n)&&n in bh)return Pd[s]=t[n];return s}var yh=Rn("animationend"),wh=Rn("animationiteration"),_h=Rn("animationstart"),Ly=Rn("transitionrun"),Uy=Rn("transitionstart"),$y=Rn("transitioncancel"),Sh=Rn("transitionend"),kh=new Map,Fd="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(" ");Fd.push("scrollEnd");function nl(s,t){kh.set(s,t),Mn(t,[s])}var zc=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)},Va=[],gr=0,Hd=0;function Rc(){for(var s=gr,t=Hd=gr=0;t<s;){var n=Va[t];Va[t++]=null;var i=Va[t];Va[t++]=null;var o=Va[t];Va[t++]=null;var x=Va[t];if(Va[t++]=null,i!==null&&o!==null){var v=i.pending;v===null?o.next=o:(o.next=v.next,v.next=o),i.pending=o}x!==0&&Ch(n,o,x)}}function Dc(s,t,n,i){Va[gr++]=s,Va[gr++]=t,Va[gr++]=n,Va[gr++]=i,Hd|=i,s.lanes|=i,s=s.alternate,s!==null&&(s.lanes|=i)}function qd(s,t,n,i){return Dc(s,t,n,i),Oc(s)}function Dn(s,t){return Dc(s,null,null,t),Oc(s)}function Ch(s,t,n){s.lanes|=n;var i=s.alternate;i!==null&&(i.lanes|=n);for(var o=!1,x=s.return;x!==null;)x.childLanes|=n,i=x.alternate,i!==null&&(i.childLanes|=n),x.tag===22&&(s=x.stateNode,s===null||s._visibility&1||(o=!0)),s=x,x=x.return;return s.tag===3?(x=s.stateNode,o&&t!==null&&(o=31-ys(n),s=x.hiddenUpdates,i=s[o],i===null?s[o]=[t]:i.push(t),t.lane=n|536870912),x):null}function Oc(s){if(50<Li)throw Li=0,Wu=null,Error(c(185));for(var t=s.return;t!==null;)s=t,t=s.return;return s.tag===3?s.stateNode:null}var jr={};function By(s,t,n,i){this.tag=s,this.key=n,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=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ea(s,t,n,i){return new By(s,t,n,i)}function Vd(s){return s=s.prototype,!(!s||!s.isReactComponent)}function yl(s,t){var n=s.alternate;return n===null?(n=Ea(s.tag,t,s.key,s.mode),n.elementType=s.elementType,n.type=s.type,n.stateNode=s.stateNode,n.alternate=s,s.alternate=n):(n.pendingProps=t,n.type=s.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=s.flags&65011712,n.childLanes=s.childLanes,n.lanes=s.lanes,n.child=s.child,n.memoizedProps=s.memoizedProps,n.memoizedState=s.memoizedState,n.updateQueue=s.updateQueue,t=s.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=s.sibling,n.index=s.index,n.ref=s.ref,n.refCleanup=s.refCleanup,n}function Th(s,t){s.flags&=65011714;var n=s.alternate;return n===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=n.childLanes,s.lanes=n.lanes,s.child=n.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=n.memoizedProps,s.memoizedState=n.memoizedState,s.updateQueue=n.updateQueue,s.type=n.type,t=n.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),s}function Lc(s,t,n,i,o,x){var v=0;if(i=s,typeof s=="function")Vd(s)&&(v=1);else if(typeof s=="string")v=q0(s,n,G.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case L:return s=Ea(31,n,t,o),s.elementType=L,s.lanes=x,s;case z:return On(n.children,o,x,t);case M:v=8,o|=24;break;case S:return s=Ea(12,n,t,o|2),s.elementType=S,s.lanes=x,s;case R:return s=Ea(13,n,t,o),s.elementType=R,s.lanes=x,s;case H:return s=Ea(19,n,t,o),s.elementType=H,s.lanes=x,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case E:v=10;break e;case F:v=9;break e;case C:v=11;break e;case O:v=14;break e;case X:v=16,i=null;break e}v=29,n=Error(c(130,s===null?"null":typeof s,"")),i=null}return t=Ea(v,n,t,o),t.elementType=s,t.type=i,t.lanes=x,t}function On(s,t,n,i){return s=Ea(7,s,i,t),s.lanes=n,s}function Gd(s,t,n){return s=Ea(6,s,null,t),s.lanes=n,s}function Eh(s){var t=Ea(18,null,null,0);return t.stateNode=s,t}function Kd(s,t,n){return t=Ea(4,s.children!==null?s.children:[],s.key,t),t.lanes=n,t.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},t}var Mh=new WeakMap;function Ga(s,t){if(typeof s=="object"&&s!==null){var n=Mh.get(s);return n!==void 0?n:(t={value:s,source:t,stack:Me(t)},Mh.set(s,t),t)}return{value:s,source:t,stack:Me(t)}}var vr=[],Nr=0,Uc=null,fi=0,Ka=[],Qa=0,Jl=null,xl=1,hl="";function wl(s,t){vr[Nr++]=fi,vr[Nr++]=Uc,Uc=s,fi=t}function Ah(s,t,n){Ka[Qa++]=xl,Ka[Qa++]=hl,Ka[Qa++]=Jl,Jl=s;var i=xl;s=hl;var o=32-ys(i)-1;i&=~(1<<o),n+=1;var x=32-ys(t)+o;if(30<x){var v=o-o%5;x=(i&(1<<v)-1).toString(32),i>>=v,o-=v,xl=1<<32-ys(t)+o|n<<o|i,hl=x+s}else xl=1<<x|n<<o|i,hl=s}function Qd(s){s.return!==null&&(wl(s,1),Ah(s,1,0))}function Yd(s){for(;s===Uc;)Uc=vr[--Nr],vr[Nr]=null,fi=vr[--Nr],vr[Nr]=null;for(;s===Jl;)Jl=Ka[--Qa],Ka[Qa]=null,hl=Ka[--Qa],Ka[Qa]=null,xl=Ka[--Qa],Ka[Qa]=null}function zh(s,t){Ka[Qa++]=xl,Ka[Qa++]=hl,Ka[Qa++]=Jl,xl=t.id,hl=t.overflow,Jl=s}var Zt=null,bt=null,Us=!1,Xl=null,Ya=!1,Jd=Error(c(519));function Zl(s){var t=Error(c(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw pi(Ga(t,s)),Jd}function Rh(s){var t=s.stateNode,n=s.type,i=s.memoizedProps;switch(t[oe]=s,t[qe]=i,n){case"dialog":Rs("cancel",t),Rs("close",t);break;case"iframe":case"object":case"embed":Rs("load",t);break;case"video":case"audio":for(n=0;n<$i.length;n++)Rs($i[n],t);break;case"source":Rs("error",t);break;case"img":case"image":case"link":Rs("error",t),Rs("load",t);break;case"details":Rs("toggle",t);break;case"input":Rs("invalid",t),Gx(t,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":Rs("invalid",t);break;case"textarea":Rs("invalid",t),Qx(t,i.value,i.defaultValue,i.children)}n=i.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||i.suppressHydrationWarning===!0||Xp(t.textContent,n)?(i.popover!=null&&(Rs("beforetoggle",t),Rs("toggle",t)),i.onScroll!=null&&Rs("scroll",t),i.onScrollEnd!=null&&Rs("scrollend",t),i.onClick!=null&&(t.onclick=Nl),t=!0):t=!1,t||Zl(s,!0)}function Dh(s){for(Zt=s.return;Zt;)switch(Zt.tag){case 5:case 31:case 13:Ya=!1;return;case 27:case 3:Ya=!0;return;default:Zt=Zt.return}}function br(s){if(s!==Zt)return!1;if(!Us)return Dh(s),Us=!0,!1;var t=s.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=s.type,n=!(n!=="form"&&n!=="button")||hm(s.type,s.memoizedProps)),n=!n),n&&bt&&Zl(s),Dh(s),t===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));bt=rg(s)}else if(t===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));bt=rg(s)}else t===27?(t=bt,xn(s.type)?(s=vm,vm=null,bt=s):bt=t):bt=Zt?Xa(s.stateNode.nextSibling):null;return!0}function Ln(){bt=Zt=null,Us=!1}function Xd(){var s=Xl;return s!==null&&(ba===null?ba=s:ba.push.apply(ba,s),Xl=null),s}function pi(s){Xl===null?Xl=[s]:Xl.push(s)}var Zd=we(null),Un=null,_l=null;function Wl(s,t,n){Ee(Zd,t._currentValue),t._currentValue=n}function Sl(s){s._currentValue=Zd.current,fe(Zd)}function Wd(s,t,n){for(;s!==null;){var i=s.alternate;if((s.childLanes&t)!==t?(s.childLanes|=t,i!==null&&(i.childLanes|=t)):i!==null&&(i.childLanes&t)!==t&&(i.childLanes|=t),s===n)break;s=s.return}}function eu(s,t,n,i){var o=s.child;for(o!==null&&(o.return=s);o!==null;){var x=o.dependencies;if(x!==null){var v=o.child;x=x.firstContext;e:for(;x!==null;){var k=x;x=o;for(var I=0;I<t.length;I++)if(k.context===t[I]){x.lanes|=n,k=x.alternate,k!==null&&(k.lanes|=n),Wd(x.return,n,s),i||(v=null);break e}x=k.next}}else if(o.tag===18){if(v=o.return,v===null)throw Error(c(341));v.lanes|=n,x=v.alternate,x!==null&&(x.lanes|=n),Wd(v,n,s),v=null}else v=o.child;if(v!==null)v.return=o;else for(v=o;v!==null;){if(v===s){v=null;break}if(o=v.sibling,o!==null){o.return=v.return,v=o;break}v=v.return}o=v}}function yr(s,t,n,i){s=null;for(var o=t,x=!1;o!==null;){if(!x){if((o.flags&524288)!==0)x=!0;else if((o.flags&262144)!==0)break}if(o.tag===10){var v=o.alternate;if(v===null)throw Error(c(387));if(v=v.memoizedProps,v!==null){var k=o.type;Ta(o.pendingProps.value,v.value)||(s!==null?s.push(k):s=[k])}}else if(o===K.current){if(v=o.alternate,v===null)throw Error(c(387));v.memoizedState.memoizedState!==o.memoizedState.memoizedState&&(s!==null?s.push(Hi):s=[Hi])}o=o.return}s!==null&&eu(t,s,n,i),t.flags|=262144}function $c(s){for(s=s.firstContext;s!==null;){if(!Ta(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function $n(s){Un=s,_l=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Wt(s){return Oh(Un,s)}function Bc(s,t){return Un===null&&$n(s),Oh(s,t)}function Oh(s,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},_l===null){if(s===null)throw Error(c(308));_l=t,s.dependencies={lanes:0,firstContext:t},s.flags|=524288}else _l=_l.next=t;return n}var Iy=typeof AbortController<"u"?AbortController:function(){var s=[],t=this.signal={aborted:!1,addEventListener:function(n,i){s.push(i)}};this.abort=function(){t.aborted=!0,s.forEach(function(n){return n()})}},Py=a.unstable_scheduleCallback,Fy=a.unstable_NormalPriority,Bt={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function su(){return{controller:new Iy,data:new Map,refCount:0}}function gi(s){s.refCount--,s.refCount===0&&Py(Fy,function(){s.controller.abort()})}var ji=null,tu=0,wr=0,_r=null;function Hy(s,t){if(ji===null){var n=ji=[];tu=0,wr=nm(),_r={status:"pending",value:void 0,then:function(i){n.push(i)}}}return tu++,t.then(Lh,Lh),t}function Lh(){if(--tu===0&&ji!==null){_r!==null&&(_r.status="fulfilled");var s=ji;ji=null,wr=0,_r=null;for(var t=0;t<s.length;t++)(0,s[t])()}}function qy(s,t){var n=[],i={status:"pending",value:null,reason:null,then:function(o){n.push(o)}};return s.then(function(){i.status="fulfilled",i.value=t;for(var o=0;o<n.length;o++)(0,n[o])(t)},function(o){for(i.status="rejected",i.reason=o,o=0;o<n.length;o++)(0,n[o])(void 0)}),i}var Uh=D.S;D.S=function(s,t){bp=Is(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Hy(s,t),Uh!==null&&Uh(s,t)};var Bn=we(null);function au(){var s=Bn.current;return s!==null?s:xt.pooledCache}function Ic(s,t){t===null?Ee(Bn,Bn.current):Ee(Bn,t.pool)}function $h(){var s=au();return s===null?null:{parent:Bt._currentValue,pool:s}}var Sr=Error(c(460)),lu=Error(c(474)),Pc=Error(c(542)),Fc={then:function(){}};function Bh(s){return s=s.status,s==="fulfilled"||s==="rejected"}function Ih(s,t,n){switch(n=s[n],n===void 0?s.push(t):n!==t&&(t.then(Nl,Nl),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,Fh(s),s;default:if(typeof t.status=="string")t.then(Nl,Nl);else{if(s=xt,s!==null&&100<s.shellSuspendCounter)throw Error(c(482));s=t,s.status="pending",s.then(function(i){if(t.status==="pending"){var o=t;o.status="fulfilled",o.value=i}},function(i){if(t.status==="pending"){var o=t;o.status="rejected",o.reason=i}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,Fh(s),s}throw Pn=t,Sr}}function In(s){try{var t=s._init;return t(s._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Pn=n,Sr):n}}var Pn=null;function Ph(){if(Pn===null)throw Error(c(459));var s=Pn;return Pn=null,s}function Fh(s){if(s===Sr||s===Pc)throw Error(c(483))}var kr=null,vi=0;function Hc(s){var t=vi;return vi+=1,kr===null&&(kr=[]),Ih(kr,s,t)}function Ni(s,t){t=t.props.ref,s.ref=t!==void 0?t:null}function qc(s,t){throw t.$$typeof===b?Error(c(525)):(s=Object.prototype.toString.call(t),Error(c(31,s==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":s)))}function Hh(s){function t(ee,q){if(s){var re=ee.deletions;re===null?(ee.deletions=[q],ee.flags|=16):re.push(q)}}function n(ee,q){if(!s)return null;for(;q!==null;)t(ee,q),q=q.sibling;return null}function i(ee){for(var q=new Map;ee!==null;)ee.key!==null?q.set(ee.key,ee):q.set(ee.index,ee),ee=ee.sibling;return q}function o(ee,q){return ee=yl(ee,q),ee.index=0,ee.sibling=null,ee}function x(ee,q,re){return ee.index=re,s?(re=ee.alternate,re!==null?(re=re.index,re<q?(ee.flags|=67108866,q):re):(ee.flags|=67108866,q)):(ee.flags|=1048576,q)}function v(ee){return s&&ee.alternate===null&&(ee.flags|=67108866),ee}function k(ee,q,re,be){return q===null||q.tag!==6?(q=Gd(re,ee.mode,be),q.return=ee,q):(q=o(q,re),q.return=ee,q)}function I(ee,q,re,be){var ss=re.type;return ss===z?ve(ee,q,re.props.children,be,re.key):q!==null&&(q.elementType===ss||typeof ss=="object"&&ss!==null&&ss.$$typeof===X&&In(ss)===q.type)?(q=o(q,re.props),Ni(q,re),q.return=ee,q):(q=Lc(re.type,re.key,re.props,null,ee.mode,be),Ni(q,re),q.return=ee,q)}function ie(ee,q,re,be){return q===null||q.tag!==4||q.stateNode.containerInfo!==re.containerInfo||q.stateNode.implementation!==re.implementation?(q=Kd(re,ee.mode,be),q.return=ee,q):(q=o(q,re.children||[]),q.return=ee,q)}function ve(ee,q,re,be,ss){return q===null||q.tag!==7?(q=On(re,ee.mode,be,ss),q.return=ee,q):(q=o(q,re),q.return=ee,q)}function ye(ee,q,re){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=Gd(""+q,ee.mode,re),q.return=ee,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case y:return re=Lc(q.type,q.key,q.props,null,ee.mode,re),Ni(re,q),re.return=ee,re;case w:return q=Kd(q,ee.mode,re),q.return=ee,q;case X:return q=In(q),ye(ee,q,re)}if(pe(q)||je(q))return q=On(q,ee.mode,re,null),q.return=ee,q;if(typeof q.then=="function")return ye(ee,Hc(q),re);if(q.$$typeof===E)return ye(ee,Bc(ee,q),re);qc(ee,q)}return null}function de(ee,q,re,be){var ss=q!==null?q.key:null;if(typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint")return ss!==null?null:k(ee,q,""+re,be);if(typeof re=="object"&&re!==null){switch(re.$$typeof){case y:return re.key===ss?I(ee,q,re,be):null;case w:return re.key===ss?ie(ee,q,re,be):null;case X:return re=In(re),de(ee,q,re,be)}if(pe(re)||je(re))return ss!==null?null:ve(ee,q,re,be,null);if(typeof re.then=="function")return de(ee,q,Hc(re),be);if(re.$$typeof===E)return de(ee,q,Bc(ee,re),be);qc(ee,re)}return null}function he(ee,q,re,be,ss){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return ee=ee.get(re)||null,k(q,ee,""+be,ss);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case y:return ee=ee.get(be.key===null?re:be.key)||null,I(q,ee,be,ss);case w:return ee=ee.get(be.key===null?re:be.key)||null,ie(q,ee,be,ss);case X:return be=In(be),he(ee,q,re,be,ss)}if(pe(be)||je(be))return ee=ee.get(re)||null,ve(q,ee,be,ss,null);if(typeof be.then=="function")return he(ee,q,re,Hc(be),ss);if(be.$$typeof===E)return he(ee,q,re,Bc(q,be),ss);qc(q,be)}return null}function Ve(ee,q,re,be){for(var ss=null,Gs=null,Ye=q,_s=q=0,Ls=null;Ye!==null&&_s<re.length;_s++){Ye.index>_s?(Ls=Ye,Ye=null):Ls=Ye.sibling;var Ks=de(ee,Ye,re[_s],be);if(Ks===null){Ye===null&&(Ye=Ls);break}s&&Ye&&Ks.alternate===null&&t(ee,Ye),q=x(Ks,q,_s),Gs===null?ss=Ks:Gs.sibling=Ks,Gs=Ks,Ye=Ls}if(_s===re.length)return n(ee,Ye),Us&&wl(ee,_s),ss;if(Ye===null){for(;_s<re.length;_s++)Ye=ye(ee,re[_s],be),Ye!==null&&(q=x(Ye,q,_s),Gs===null?ss=Ye:Gs.sibling=Ye,Gs=Ye);return Us&&wl(ee,_s),ss}for(Ye=i(Ye);_s<re.length;_s++)Ls=he(Ye,ee,_s,re[_s],be),Ls!==null&&(s&&Ls.alternate!==null&&Ye.delete(Ls.key===null?_s:Ls.key),q=x(Ls,q,_s),Gs===null?ss=Ls:Gs.sibling=Ls,Gs=Ls);return s&&Ye.forEach(function(jn){return t(ee,jn)}),Us&&wl(ee,_s),ss}function ls(ee,q,re,be){if(re==null)throw Error(c(151));for(var ss=null,Gs=null,Ye=q,_s=q=0,Ls=null,Ks=re.next();Ye!==null&&!Ks.done;_s++,Ks=re.next()){Ye.index>_s?(Ls=Ye,Ye=null):Ls=Ye.sibling;var jn=de(ee,Ye,Ks.value,be);if(jn===null){Ye===null&&(Ye=Ls);break}s&&Ye&&jn.alternate===null&&t(ee,Ye),q=x(jn,q,_s),Gs===null?ss=jn:Gs.sibling=jn,Gs=jn,Ye=Ls}if(Ks.done)return n(ee,Ye),Us&&wl(ee,_s),ss;if(Ye===null){for(;!Ks.done;_s++,Ks=re.next())Ks=ye(ee,Ks.value,be),Ks!==null&&(q=x(Ks,q,_s),Gs===null?ss=Ks:Gs.sibling=Ks,Gs=Ks);return Us&&wl(ee,_s),ss}for(Ye=i(Ye);!Ks.done;_s++,Ks=re.next())Ks=he(Ye,ee,_s,Ks.value,be),Ks!==null&&(s&&Ks.alternate!==null&&Ye.delete(Ks.key===null?_s:Ks.key),q=x(Ks,q,_s),Gs===null?ss=Ks:Gs.sibling=Ks,Gs=Ks);return s&&Ye.forEach(function(sw){return t(ee,sw)}),Us&&wl(ee,_s),ss}function ot(ee,q,re,be){if(typeof re=="object"&&re!==null&&re.type===z&&re.key===null&&(re=re.props.children),typeof re=="object"&&re!==null){switch(re.$$typeof){case y:e:{for(var ss=re.key;q!==null;){if(q.key===ss){if(ss=re.type,ss===z){if(q.tag===7){n(ee,q.sibling),be=o(q,re.props.children),be.return=ee,ee=be;break e}}else if(q.elementType===ss||typeof ss=="object"&&ss!==null&&ss.$$typeof===X&&In(ss)===q.type){n(ee,q.sibling),be=o(q,re.props),Ni(be,re),be.return=ee,ee=be;break e}n(ee,q);break}else t(ee,q);q=q.sibling}re.type===z?(be=On(re.props.children,ee.mode,be,re.key),be.return=ee,ee=be):(be=Lc(re.type,re.key,re.props,null,ee.mode,be),Ni(be,re),be.return=ee,ee=be)}return v(ee);case w:e:{for(ss=re.key;q!==null;){if(q.key===ss)if(q.tag===4&&q.stateNode.containerInfo===re.containerInfo&&q.stateNode.implementation===re.implementation){n(ee,q.sibling),be=o(q,re.children||[]),be.return=ee,ee=be;break e}else{n(ee,q);break}else t(ee,q);q=q.sibling}be=Kd(re,ee.mode,be),be.return=ee,ee=be}return v(ee);case X:return re=In(re),ot(ee,q,re,be)}if(pe(re))return Ve(ee,q,re,be);if(je(re)){if(ss=je(re),typeof ss!="function")throw Error(c(150));return re=ss.call(re),ls(ee,q,re,be)}if(typeof re.then=="function")return ot(ee,q,Hc(re),be);if(re.$$typeof===E)return ot(ee,q,Bc(ee,re),be);qc(ee,re)}return typeof re=="string"&&re!==""||typeof re=="number"||typeof re=="bigint"?(re=""+re,q!==null&&q.tag===6?(n(ee,q.sibling),be=o(q,re),be.return=ee,ee=be):(n(ee,q),be=Gd(re,ee.mode,be),be.return=ee,ee=be),v(ee)):n(ee,q)}return function(ee,q,re,be){try{vi=0;var ss=ot(ee,q,re,be);return kr=null,ss}catch(Ye){if(Ye===Sr||Ye===Pc)throw Ye;var Gs=Ea(29,Ye,null,ee.mode);return Gs.lanes=be,Gs.return=ee,Gs}finally{}}}var Fn=Hh(!0),qh=Hh(!1),en=!1;function nu(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ru(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 sn(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function tn(s,t,n){var i=s.updateQueue;if(i===null)return null;if(i=i.shared,(Js&2)!==0){var o=i.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),i.pending=t,t=Oc(s),Ch(s,null,n),t}return Dc(s,i,t,n),Oc(s)}function bi(s,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var i=t.lanes;i&=s.pendingLanes,n|=i,t.lanes=n,us(s,n)}}function iu(s,t){var n=s.updateQueue,i=s.alternate;if(i!==null&&(i=i.updateQueue,n===i)){var o=null,x=null;if(n=n.firstBaseUpdate,n!==null){do{var v={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};x===null?o=x=v:x=x.next=v,n=n.next}while(n!==null);x===null?o=x=t:x=x.next=t}else o=x=t;n={baseState:i.baseState,firstBaseUpdate:o,lastBaseUpdate:x,shared:i.shared,callbacks:i.callbacks},s.updateQueue=n;return}s=n.lastBaseUpdate,s===null?n.firstBaseUpdate=t:s.next=t,n.lastBaseUpdate=t}var cu=!1;function yi(){if(cu){var s=_r;if(s!==null)throw s}}function wi(s,t,n,i){cu=!1;var o=s.updateQueue;en=!1;var x=o.firstBaseUpdate,v=o.lastBaseUpdate,k=o.shared.pending;if(k!==null){o.shared.pending=null;var I=k,ie=I.next;I.next=null,v===null?x=ie:v.next=ie,v=I;var ve=s.alternate;ve!==null&&(ve=ve.updateQueue,k=ve.lastBaseUpdate,k!==v&&(k===null?ve.firstBaseUpdate=ie:k.next=ie,ve.lastBaseUpdate=I))}if(x!==null){var ye=o.baseState;v=0,ve=ie=I=null,k=x;do{var de=k.lane&-536870913,he=de!==k.lane;if(he?(Os&de)===de:(i&de)===de){de!==0&&de===wr&&(cu=!0),ve!==null&&(ve=ve.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var Ve=s,ls=k;de=t;var ot=n;switch(ls.tag){case 1:if(Ve=ls.payload,typeof Ve=="function"){ye=Ve.call(ot,ye,de);break e}ye=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=ls.payload,de=typeof Ve=="function"?Ve.call(ot,ye,de):Ve,de==null)break e;ye=j({},ye,de);break e;case 2:en=!0}}de=k.callback,de!==null&&(s.flags|=64,he&&(s.flags|=8192),he=o.callbacks,he===null?o.callbacks=[de]:he.push(de))}else he={lane:de,tag:k.tag,payload:k.payload,callback:k.callback,next:null},ve===null?(ie=ve=he,I=ye):ve=ve.next=he,v|=de;if(k=k.next,k===null){if(k=o.shared.pending,k===null)break;he=k,k=he.next,he.next=null,o.lastBaseUpdate=he,o.shared.pending=null}}while(!0);ve===null&&(I=ye),o.baseState=I,o.firstBaseUpdate=ie,o.lastBaseUpdate=ve,x===null&&(o.shared.lanes=0),cn|=v,s.lanes=v,s.memoizedState=ye}}function Vh(s,t){if(typeof s!="function")throw Error(c(191,s));s.call(t)}function Gh(s,t){var n=s.callbacks;if(n!==null)for(s.callbacks=null,s=0;s<n.length;s++)Vh(n[s],t)}var Cr=we(null),Vc=we(0);function Kh(s,t){s=Dl,Ee(Vc,s),Ee(Cr,t),Dl=s|t.baseLanes}function ou(){Ee(Vc,Dl),Ee(Cr,Cr.current)}function du(){Dl=Vc.current,fe(Cr),fe(Vc)}var Ma=we(null),Ja=null;function an(s){var t=s.alternate;Ee(Dt,Dt.current&1),Ee(Ma,s),Ja===null&&(t===null||Cr.current!==null||t.memoizedState!==null)&&(Ja=s)}function uu(s){Ee(Dt,Dt.current),Ee(Ma,s),Ja===null&&(Ja=s)}function Qh(s){s.tag===22?(Ee(Dt,Dt.current),Ee(Ma,s),Ja===null&&(Ja=s)):ln()}function ln(){Ee(Dt,Dt.current),Ee(Ma,Ma.current)}function Aa(s){fe(Ma),Ja===s&&(Ja=null),fe(Dt)}var Dt=we(0);function Gc(s){for(var t=s;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||gm(n)||jm(n)))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 kl=0,ws=null,it=null,It=null,Kc=!1,Tr=!1,Hn=!1,Qc=0,_i=0,Er=null,Vy=0;function Et(){throw Error(c(321))}function mu(s,t){if(t===null)return!1;for(var n=0;n<t.length&&n<s.length;n++)if(!Ta(s[n],t[n]))return!1;return!0}function xu(s,t,n,i,o,x){return kl=x,ws=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,D.H=s===null||s.memoizedState===null?zf:Tu,Hn=!1,x=n(i,o),Hn=!1,Tr&&(x=Jh(t,n,i,o)),Yh(s),x}function Yh(s){D.H=Ci;var t=it!==null&&it.next!==null;if(kl=0,It=it=ws=null,Kc=!1,_i=0,Er=null,t)throw Error(c(300));s===null||Pt||(s=s.dependencies,s!==null&&$c(s)&&(Pt=!0))}function Jh(s,t,n,i){ws=s;var o=0;do{if(Tr&&(Er=null),_i=0,Tr=!1,25<=o)throw Error(c(301));if(o+=1,It=it=null,s.updateQueue!=null){var x=s.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}D.H=Rf,x=t(n,i)}while(Tr);return x}function Gy(){var s=D.H,t=s.useState()[0];return t=typeof t.then=="function"?Si(t):t,s=s.useState()[0],(it!==null?it.memoizedState:null)!==s&&(ws.flags|=1024),t}function hu(){var s=Qc!==0;return Qc=0,s}function fu(s,t,n){t.updateQueue=s.updateQueue,t.flags&=-2053,s.lanes&=~n}function pu(s){if(Kc){for(s=s.memoizedState;s!==null;){var t=s.queue;t!==null&&(t.pending=null),s=s.next}Kc=!1}kl=0,It=it=ws=null,Tr=!1,_i=Qc=0,Er=null}function ma(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return It===null?ws.memoizedState=It=s:It=It.next=s,It}function Ot(){if(it===null){var s=ws.alternate;s=s!==null?s.memoizedState:null}else s=it.next;var t=It===null?ws.memoizedState:It.next;if(t!==null)It=t,it=s;else{if(s===null)throw ws.alternate===null?Error(c(467)):Error(c(310));it=s,s={memoizedState:it.memoizedState,baseState:it.baseState,baseQueue:it.baseQueue,queue:it.queue,next:null},It===null?ws.memoizedState=It=s:It=It.next=s}return It}function Yc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Si(s){var t=_i;return _i+=1,Er===null&&(Er=[]),s=Ih(Er,s,t),t=ws,(It===null?t.memoizedState:It.next)===null&&(t=t.alternate,D.H=t===null||t.memoizedState===null?zf:Tu),s}function Jc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return Si(s);if(s.$$typeof===E)return Wt(s)}throw Error(c(438,String(s)))}function gu(s){var t=null,n=ws.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var i=ws.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(t={data:i.data.map(function(o){return o.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Yc(),ws.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(s),i=0;i<s;i++)n[i]=me;return t.index++,n}function Cl(s,t){return typeof t=="function"?t(s):t}function Xc(s){var t=Ot();return ju(t,it,s)}function ju(s,t,n){var i=s.queue;if(i===null)throw Error(c(311));i.lastRenderedReducer=n;var o=s.baseQueue,x=i.pending;if(x!==null){if(o!==null){var v=o.next;o.next=x.next,x.next=v}t.baseQueue=o=x,i.pending=null}if(x=s.baseState,o===null)s.memoizedState=x;else{t=o.next;var k=v=null,I=null,ie=t,ve=!1;do{var ye=ie.lane&-536870913;if(ye!==ie.lane?(Os&ye)===ye:(kl&ye)===ye){var de=ie.revertLane;if(de===0)I!==null&&(I=I.next={lane:0,revertLane:0,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),ye===wr&&(ve=!0);else if((kl&de)===de){ie=ie.next,de===wr&&(ve=!0);continue}else ye={lane:0,revertLane:ie.revertLane,gesture:null,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},I===null?(k=I=ye,v=x):I=I.next=ye,ws.lanes|=de,cn|=de;ye=ie.action,Hn&&n(x,ye),x=ie.hasEagerState?ie.eagerState:n(x,ye)}else de={lane:ye,revertLane:ie.revertLane,gesture:ie.gesture,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null},I===null?(k=I=de,v=x):I=I.next=de,ws.lanes|=ye,cn|=ye;ie=ie.next}while(ie!==null&&ie!==t);if(I===null?v=x:I.next=k,!Ta(x,s.memoizedState)&&(Pt=!0,ve&&(n=_r,n!==null)))throw n;s.memoizedState=x,s.baseState=v,s.baseQueue=I,i.lastRenderedState=x}return o===null&&(i.lanes=0),[s.memoizedState,i.dispatch]}function vu(s){var t=Ot(),n=t.queue;if(n===null)throw Error(c(311));n.lastRenderedReducer=s;var i=n.dispatch,o=n.pending,x=t.memoizedState;if(o!==null){n.pending=null;var v=o=o.next;do x=s(x,v.action),v=v.next;while(v!==o);Ta(x,t.memoizedState)||(Pt=!0),t.memoizedState=x,t.baseQueue===null&&(t.baseState=x),n.lastRenderedState=x}return[x,i]}function Xh(s,t,n){var i=ws,o=Ot(),x=Us;if(x){if(n===void 0)throw Error(c(407));n=n()}else n=t();var v=!Ta((it||o).memoizedState,n);if(v&&(o.memoizedState=n,Pt=!0),o=o.queue,yu(ef.bind(null,i,o,s),[s]),o.getSnapshot!==t||v||It!==null&&It.memoizedState.tag&1){if(i.flags|=2048,Mr(9,{destroy:void 0},Wh.bind(null,i,o,n,t),null),xt===null)throw Error(c(349));x||(kl&127)!==0||Zh(i,t,n)}return n}function Zh(s,t,n){s.flags|=16384,s={getSnapshot:t,value:n},t=ws.updateQueue,t===null?(t=Yc(),ws.updateQueue=t,t.stores=[s]):(n=t.stores,n===null?t.stores=[s]:n.push(s))}function Wh(s,t,n,i){t.value=n,t.getSnapshot=i,sf(t)&&tf(s)}function ef(s,t,n){return n(function(){sf(t)&&tf(s)})}function sf(s){var t=s.getSnapshot;s=s.value;try{var n=t();return!Ta(s,n)}catch{return!0}}function tf(s){var t=Dn(s,2);t!==null&&ya(t,s,2)}function Nu(s){var t=ma();if(typeof s=="function"){var n=s;if(s=n(),Hn){is(!0);try{n()}finally{is(!1)}}}return t.memoizedState=t.baseState=s,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cl,lastRenderedState:s},t}function af(s,t,n,i){return s.baseState=n,ju(s,it,typeof i=="function"?i:Cl)}function Ky(s,t,n,i,o){if(eo(s))throw Error(c(485));if(s=t.action,s!==null){var x={payload:o,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){x.listeners.push(v)}};D.T!==null?n(!0):x.isTransition=!1,i(x),n=t.pending,n===null?(x.next=t.pending=x,lf(t,x)):(x.next=n.next,t.pending=n.next=x)}}function lf(s,t){var n=t.action,i=t.payload,o=s.state;if(t.isTransition){var x=D.T,v={};D.T=v;try{var k=n(o,i),I=D.S;I!==null&&I(v,k),nf(s,t,k)}catch(ie){bu(s,t,ie)}finally{x!==null&&v.types!==null&&(x.types=v.types),D.T=x}}else try{x=n(o,i),nf(s,t,x)}catch(ie){bu(s,t,ie)}}function nf(s,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(i){rf(s,t,i)},function(i){return bu(s,t,i)}):rf(s,t,n)}function rf(s,t,n){t.status="fulfilled",t.value=n,cf(t),s.state=n,t=s.pending,t!==null&&(n=t.next,n===t?s.pending=null:(n=n.next,t.next=n,lf(s,n)))}function bu(s,t,n){var i=s.pending;if(s.pending=null,i!==null){i=i.next;do t.status="rejected",t.reason=n,cf(t),t=t.next;while(t!==i)}s.action=null}function cf(s){s=s.listeners;for(var t=0;t<s.length;t++)(0,s[t])()}function of(s,t){return t}function df(s,t){if(Us){var n=xt.formState;if(n!==null){e:{var i=ws;if(Us){if(bt){s:{for(var o=bt,x=Ya;o.nodeType!==8;){if(!x){o=null;break s}if(o=Xa(o.nextSibling),o===null){o=null;break s}}x=o.data,o=x==="F!"||x==="F"?o:null}if(o){bt=Xa(o.nextSibling),i=o.data==="F!";break e}}Zl(i)}i=!1}i&&(t=n[0])}}return n=ma(),n.memoizedState=n.baseState=t,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:of,lastRenderedState:t},n.queue=i,n=Ef.bind(null,ws,i),i.dispatch=n,i=Nu(!1),x=Cu.bind(null,ws,!1,i.queue),i=ma(),o={state:t,dispatch:null,action:s,pending:null},i.queue=o,n=Ky.bind(null,ws,o,x,n),o.dispatch=n,i.memoizedState=s,[t,n,!1]}function uf(s){var t=Ot();return mf(t,it,s)}function mf(s,t,n){if(t=ju(s,t,of)[0],s=Xc(Cl)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var i=Si(t)}catch(v){throw v===Sr?Pc:v}else i=t;t=Ot();var o=t.queue,x=o.dispatch;return n!==t.memoizedState&&(ws.flags|=2048,Mr(9,{destroy:void 0},Qy.bind(null,o,n),null)),[i,x,s]}function Qy(s,t){s.action=t}function xf(s){var t=Ot(),n=it;if(n!==null)return mf(t,n,s);Ot(),t=t.memoizedState,n=Ot();var i=n.queue.dispatch;return n.memoizedState=s,[t,i,!1]}function Mr(s,t,n,i){return s={tag:s,create:n,deps:i,inst:t,next:null},t=ws.updateQueue,t===null&&(t=Yc(),ws.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=s.next=s:(i=n.next,n.next=s,s.next=i,t.lastEffect=s),s}function hf(){return Ot().memoizedState}function Zc(s,t,n,i){var o=ma();ws.flags|=s,o.memoizedState=Mr(1|t,{destroy:void 0},n,i===void 0?null:i)}function Wc(s,t,n,i){var o=Ot();i=i===void 0?null:i;var x=o.memoizedState.inst;it!==null&&i!==null&&mu(i,it.memoizedState.deps)?o.memoizedState=Mr(t,x,n,i):(ws.flags|=s,o.memoizedState=Mr(1|t,x,n,i))}function ff(s,t){Zc(8390656,8,s,t)}function yu(s,t){Wc(2048,8,s,t)}function Yy(s){ws.flags|=4;var t=ws.updateQueue;if(t===null)t=Yc(),ws.updateQueue=t,t.events=[s];else{var n=t.events;n===null?t.events=[s]:n.push(s)}}function pf(s){var t=Ot().memoizedState;return Yy({ref:t,nextImpl:s}),function(){if((Js&2)!==0)throw Error(c(440));return t.impl.apply(void 0,arguments)}}function gf(s,t){return Wc(4,2,s,t)}function jf(s,t){return Wc(4,4,s,t)}function vf(s,t){if(typeof t=="function"){s=s();var n=t(s);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return s=s(),t.current=s,function(){t.current=null}}function Nf(s,t,n){n=n!=null?n.concat([s]):null,Wc(4,4,vf.bind(null,t,s),n)}function wu(){}function bf(s,t){var n=Ot();t=t===void 0?null:t;var i=n.memoizedState;return t!==null&&mu(t,i[1])?i[0]:(n.memoizedState=[s,t],s)}function yf(s,t){var n=Ot();t=t===void 0?null:t;var i=n.memoizedState;if(t!==null&&mu(t,i[1]))return i[0];if(i=s(),Hn){is(!0);try{s()}finally{is(!1)}}return n.memoizedState=[i,t],i}function _u(s,t,n){return n===void 0||(kl&1073741824)!==0&&(Os&261930)===0?s.memoizedState=t:(s.memoizedState=n,s=wp(),ws.lanes|=s,cn|=s,n)}function wf(s,t,n,i){return Ta(n,t)?n:Cr.current!==null?(s=_u(s,n,i),Ta(s,t)||(Pt=!0),s):(kl&42)===0||(kl&1073741824)!==0&&(Os&261930)===0?(Pt=!0,s.memoizedState=n):(s=wp(),ws.lanes|=s,cn|=s,t)}function _f(s,t,n,i,o){var x=Q.p;Q.p=x!==0&&8>x?x:8;var v=D.T,k={};D.T=k,Cu(s,!1,t,n);try{var I=o(),ie=D.S;if(ie!==null&&ie(k,I),I!==null&&typeof I=="object"&&typeof I.then=="function"){var ve=qy(I,i);ki(s,t,ve,Da(s))}else ki(s,t,i,Da(s))}catch(ye){ki(s,t,{then:function(){},status:"rejected",reason:ye},Da())}finally{Q.p=x,v!==null&&k.types!==null&&(v.types=k.types),D.T=v}}function Jy(){}function Su(s,t,n,i){if(s.tag!==5)throw Error(c(476));var o=Sf(s).queue;_f(s,o,t,B,n===null?Jy:function(){return kf(s),n(i)})}function Sf(s){var t=s.memoizedState;if(t!==null)return t;t={memoizedState:B,baseState:B,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cl,lastRenderedState:B},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Cl,lastRenderedState:n},next:null},s.memoizedState=t,s=s.alternate,s!==null&&(s.memoizedState=t),t}function kf(s){var t=Sf(s);t.next===null&&(t=s.alternate.memoizedState),ki(s,t.next.queue,{},Da())}function ku(){return Wt(Hi)}function Cf(){return Ot().memoizedState}function Tf(){return Ot().memoizedState}function Xy(s){for(var t=s.return;t!==null;){switch(t.tag){case 24:case 3:var n=Da();s=sn(n);var i=tn(t,s,n);i!==null&&(ya(i,t,n),bi(i,t,n)),t={cache:su()},s.payload=t;return}t=t.return}}function Zy(s,t,n){var i=Da();n={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},eo(s)?Mf(t,n):(n=qd(s,t,n,i),n!==null&&(ya(n,s,i),Af(n,t,i)))}function Ef(s,t,n){var i=Da();ki(s,t,n,i)}function ki(s,t,n,i){var o={lane:i,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(eo(s))Mf(t,o);else{var x=s.alternate;if(s.lanes===0&&(x===null||x.lanes===0)&&(x=t.lastRenderedReducer,x!==null))try{var v=t.lastRenderedState,k=x(v,n);if(o.hasEagerState=!0,o.eagerState=k,Ta(k,v))return Dc(s,t,o,0),xt===null&&Rc(),!1}catch{}finally{}if(n=qd(s,t,o,i),n!==null)return ya(n,s,i),Af(n,t,i),!0}return!1}function Cu(s,t,n,i){if(i={lane:2,revertLane:nm(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},eo(s)){if(t)throw Error(c(479))}else t=qd(s,n,i,2),t!==null&&ya(t,s,2)}function eo(s){var t=s.alternate;return s===ws||t!==null&&t===ws}function Mf(s,t){Tr=Kc=!0;var n=s.pending;n===null?t.next=t:(t.next=n.next,n.next=t),s.pending=t}function Af(s,t,n){if((n&4194048)!==0){var i=t.lanes;i&=s.pendingLanes,n|=i,t.lanes=n,us(s,n)}}var Ci={readContext:Wt,use:Jc,useCallback:Et,useContext:Et,useEffect:Et,useImperativeHandle:Et,useLayoutEffect:Et,useInsertionEffect:Et,useMemo:Et,useReducer:Et,useRef:Et,useState:Et,useDebugValue:Et,useDeferredValue:Et,useTransition:Et,useSyncExternalStore:Et,useId:Et,useHostTransitionStatus:Et,useFormState:Et,useActionState:Et,useOptimistic:Et,useMemoCache:Et,useCacheRefresh:Et};Ci.useEffectEvent=Et;var zf={readContext:Wt,use:Jc,useCallback:function(s,t){return ma().memoizedState=[s,t===void 0?null:t],s},useContext:Wt,useEffect:ff,useImperativeHandle:function(s,t,n){n=n!=null?n.concat([s]):null,Zc(4194308,4,vf.bind(null,t,s),n)},useLayoutEffect:function(s,t){return Zc(4194308,4,s,t)},useInsertionEffect:function(s,t){Zc(4,2,s,t)},useMemo:function(s,t){var n=ma();t=t===void 0?null:t;var i=s();if(Hn){is(!0);try{s()}finally{is(!1)}}return n.memoizedState=[i,t],i},useReducer:function(s,t,n){var i=ma();if(n!==void 0){var o=n(t);if(Hn){is(!0);try{n(t)}finally{is(!1)}}}else o=t;return i.memoizedState=i.baseState=o,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:o},i.queue=s,s=s.dispatch=Zy.bind(null,ws,s),[i.memoizedState,s]},useRef:function(s){var t=ma();return s={current:s},t.memoizedState=s},useState:function(s){s=Nu(s);var t=s.queue,n=Ef.bind(null,ws,t);return t.dispatch=n,[s.memoizedState,n]},useDebugValue:wu,useDeferredValue:function(s,t){var n=ma();return _u(n,s,t)},useTransition:function(){var s=Nu(!1);return s=_f.bind(null,ws,s.queue,!0,!1),ma().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,t,n){var i=ws,o=ma();if(Us){if(n===void 0)throw Error(c(407));n=n()}else{if(n=t(),xt===null)throw Error(c(349));(Os&127)!==0||Zh(i,t,n)}o.memoizedState=n;var x={value:n,getSnapshot:t};return o.queue=x,ff(ef.bind(null,i,x,s),[s]),i.flags|=2048,Mr(9,{destroy:void 0},Wh.bind(null,i,x,n,t),null),n},useId:function(){var s=ma(),t=xt.identifierPrefix;if(Us){var n=hl,i=xl;n=(i&~(1<<32-ys(i)-1)).toString(32)+n,t="_"+t+"R_"+n,n=Qc++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=Vy++,t="_"+t+"r_"+n.toString(32)+"_";return s.memoizedState=t},useHostTransitionStatus:ku,useFormState:df,useActionState:df,useOptimistic:function(s){var t=ma();t.memoizedState=t.baseState=s;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Cu.bind(null,ws,!0,n),n.dispatch=t,[s,t]},useMemoCache:gu,useCacheRefresh:function(){return ma().memoizedState=Xy.bind(null,ws)},useEffectEvent:function(s){var t=ma(),n={impl:s};return t.memoizedState=n,function(){if((Js&2)!==0)throw Error(c(440));return n.impl.apply(void 0,arguments)}}},Tu={readContext:Wt,use:Jc,useCallback:bf,useContext:Wt,useEffect:yu,useImperativeHandle:Nf,useInsertionEffect:gf,useLayoutEffect:jf,useMemo:yf,useReducer:Xc,useRef:hf,useState:function(){return Xc(Cl)},useDebugValue:wu,useDeferredValue:function(s,t){var n=Ot();return wf(n,it.memoizedState,s,t)},useTransition:function(){var s=Xc(Cl)[0],t=Ot().memoizedState;return[typeof s=="boolean"?s:Si(s),t]},useSyncExternalStore:Xh,useId:Cf,useHostTransitionStatus:ku,useFormState:uf,useActionState:uf,useOptimistic:function(s,t){var n=Ot();return af(n,it,s,t)},useMemoCache:gu,useCacheRefresh:Tf};Tu.useEffectEvent=pf;var Rf={readContext:Wt,use:Jc,useCallback:bf,useContext:Wt,useEffect:yu,useImperativeHandle:Nf,useInsertionEffect:gf,useLayoutEffect:jf,useMemo:yf,useReducer:vu,useRef:hf,useState:function(){return vu(Cl)},useDebugValue:wu,useDeferredValue:function(s,t){var n=Ot();return it===null?_u(n,s,t):wf(n,it.memoizedState,s,t)},useTransition:function(){var s=vu(Cl)[0],t=Ot().memoizedState;return[typeof s=="boolean"?s:Si(s),t]},useSyncExternalStore:Xh,useId:Cf,useHostTransitionStatus:ku,useFormState:xf,useActionState:xf,useOptimistic:function(s,t){var n=Ot();return it!==null?af(n,it,s,t):(n.baseState=s,[s,n.queue.dispatch])},useMemoCache:gu,useCacheRefresh:Tf};Rf.useEffectEvent=pf;function Eu(s,t,n,i){t=s.memoizedState,n=n(i,t),n=n==null?t:j({},t,n),s.memoizedState=n,s.lanes===0&&(s.updateQueue.baseState=n)}var Mu={enqueueSetState:function(s,t,n){s=s._reactInternals;var i=Da(),o=sn(i);o.payload=t,n!=null&&(o.callback=n),t=tn(s,o,i),t!==null&&(ya(t,s,i),bi(t,s,i))},enqueueReplaceState:function(s,t,n){s=s._reactInternals;var i=Da(),o=sn(i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=tn(s,o,i),t!==null&&(ya(t,s,i),bi(t,s,i))},enqueueForceUpdate:function(s,t){s=s._reactInternals;var n=Da(),i=sn(n);i.tag=2,t!=null&&(i.callback=t),t=tn(s,i,n),t!==null&&(ya(t,s,n),bi(t,s,n))}};function Df(s,t,n,i,o,x,v){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(i,x,v):t.prototype&&t.prototype.isPureReactComponent?!xi(n,i)||!xi(o,x):!0}function Of(s,t,n,i){s=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,i),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==s&&Mu.enqueueReplaceState(t,t.state,null)}function qn(s,t){var n=t;if("ref"in t){n={};for(var i in t)i!=="ref"&&(n[i]=t[i])}if(s=s.defaultProps){n===t&&(n=j({},n));for(var o in s)n[o]===void 0&&(n[o]=s[o])}return n}function Lf(s){zc(s)}function Uf(s){console.error(s)}function $f(s){zc(s)}function so(s,t){try{var n=s.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(i){setTimeout(function(){throw i})}}function Bf(s,t,n){try{var i=s.onCaughtError;i(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(o){setTimeout(function(){throw o})}}function Au(s,t,n){return n=sn(n),n.tag=3,n.payload={element:null},n.callback=function(){so(s,t)},n}function If(s){return s=sn(s),s.tag=3,s}function Pf(s,t,n,i){var o=n.type.getDerivedStateFromError;if(typeof o=="function"){var x=i.value;s.payload=function(){return o(x)},s.callback=function(){Bf(t,n,i)}}var v=n.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(s.callback=function(){Bf(t,n,i),typeof o!="function"&&(on===null?on=new Set([this]):on.add(this));var k=i.stack;this.componentDidCatch(i.value,{componentStack:k!==null?k:""})})}function Wy(s,t,n,i,o){if(n.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(t=n.alternate,t!==null&&yr(t,n,o,!0),n=Ma.current,n!==null){switch(n.tag){case 31:case 13:return Ja===null?ho():n.alternate===null&&Mt===0&&(Mt=3),n.flags&=-257,n.flags|=65536,n.lanes=o,i===Fc?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),tm(s,i,o)),!1;case 22:return n.flags|=65536,i===Fc?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),tm(s,i,o)),!1}throw Error(c(435,n.tag))}return tm(s,i,o),ho(),!1}if(Us)return t=Ma.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=o,i!==Jd&&(s=Error(c(422),{cause:i}),pi(Ga(s,n)))):(i!==Jd&&(t=Error(c(423),{cause:i}),pi(Ga(t,n))),s=s.current.alternate,s.flags|=65536,o&=-o,s.lanes|=o,i=Ga(i,n),o=Au(s.stateNode,i,o),iu(s,o),Mt!==4&&(Mt=2)),!1;var x=Error(c(520),{cause:i});if(x=Ga(x,n),Oi===null?Oi=[x]:Oi.push(x),Mt!==4&&(Mt=2),t===null)return!0;i=Ga(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,s=o&-o,n.lanes|=s,s=Au(n.stateNode,i,s),iu(n,s),!1;case 1:if(t=n.type,x=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(on===null||!on.has(x))))return n.flags|=65536,o&=-o,n.lanes|=o,o=If(o),Pf(o,s,n,i),iu(n,o),!1}n=n.return}while(n!==null);return!1}var zu=Error(c(461)),Pt=!1;function ea(s,t,n,i){t.child=s===null?qh(t,null,n,i):Fn(t,s.child,n,i)}function Ff(s,t,n,i,o){n=n.render;var x=t.ref;if("ref"in i){var v={};for(var k in i)k!=="ref"&&(v[k]=i[k])}else v=i;return $n(t),i=xu(s,t,n,v,x,o),k=hu(),s!==null&&!Pt?(fu(s,t,o),Tl(s,t,o)):(Us&&k&&Qd(t),t.flags|=1,ea(s,t,i,o),t.child)}function Hf(s,t,n,i,o){if(s===null){var x=n.type;return typeof x=="function"&&!Vd(x)&&x.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=x,qf(s,t,x,i,o)):(s=Lc(n.type,null,i,t,t.mode,o),s.ref=t.ref,s.return=t,t.child=s)}if(x=s.child,!Iu(s,o)){var v=x.memoizedProps;if(n=n.compare,n=n!==null?n:xi,n(v,i)&&s.ref===t.ref)return Tl(s,t,o)}return t.flags|=1,s=yl(x,i),s.ref=t.ref,s.return=t,t.child=s}function qf(s,t,n,i,o){if(s!==null){var x=s.memoizedProps;if(xi(x,i)&&s.ref===t.ref)if(Pt=!1,t.pendingProps=i=x,Iu(s,o))(s.flags&131072)!==0&&(Pt=!0);else return t.lanes=s.lanes,Tl(s,t,o)}return Ru(s,t,n,i,o)}function Vf(s,t,n,i){var o=i.children,x=s!==null?s.memoizedState:null;if(s===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((t.flags&128)!==0){if(x=x!==null?x.baseLanes|n:n,s!==null){for(i=t.child=s.child,o=0;i!==null;)o=o|i.lanes|i.childLanes,i=i.sibling;i=o&~x}else i=0,t.child=null;return Gf(s,t,x,n,i)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},s!==null&&Ic(t,x!==null?x.cachePool:null),x!==null?Kh(t,x):ou(),Qh(t);else return i=t.lanes=536870912,Gf(s,t,x!==null?x.baseLanes|n:n,n,i)}else x!==null?(Ic(t,x.cachePool),Kh(t,x),ln(),t.memoizedState=null):(s!==null&&Ic(t,null),ou(),ln());return ea(s,t,o,n),t.child}function Ti(s,t){return s!==null&&s.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Gf(s,t,n,i,o){var x=au();return x=x===null?null:{parent:Bt._currentValue,pool:x},t.memoizedState={baseLanes:n,cachePool:x},s!==null&&Ic(t,null),ou(),Qh(t),s!==null&&yr(s,t,i,!0),t.childLanes=o,null}function to(s,t){return t=lo({mode:t.mode,children:t.children},s.mode),t.ref=s.ref,s.child=t,t.return=s,t}function Kf(s,t,n){return Fn(t,s.child,null,n),s=to(t,t.pendingProps),s.flags|=2,Aa(t),t.memoizedState=null,s}function e0(s,t,n){var i=t.pendingProps,o=(t.flags&128)!==0;if(t.flags&=-129,s===null){if(Us){if(i.mode==="hidden")return s=to(t,i),t.lanes=536870912,Ti(null,s);if(uu(t),(s=bt)?(s=ng(s,Ya),s=s!==null&&s.data==="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:Jl!==null?{id:xl,overflow:hl}:null,retryLane:536870912,hydrationErrors:null},n=Eh(s),n.return=t,t.child=n,Zt=t,bt=null)):s=null,s===null)throw Zl(t);return t.lanes=536870912,null}return to(t,i)}var x=s.memoizedState;if(x!==null){var v=x.dehydrated;if(uu(t),o)if(t.flags&256)t.flags&=-257,t=Kf(s,t,n);else if(t.memoizedState!==null)t.child=s.child,t.flags|=128,t=null;else throw Error(c(558));else if(Pt||yr(s,t,n,!1),o=(n&s.childLanes)!==0,Pt||o){if(i=xt,i!==null&&(v=es(i,n),v!==0&&v!==x.retryLane))throw x.retryLane=v,Dn(s,v),ya(i,s,v),zu;ho(),t=Kf(s,t,n)}else s=x.treeContext,bt=Xa(v.nextSibling),Zt=t,Us=!0,Xl=null,Ya=!1,s!==null&&zh(t,s),t=to(t,i),t.flags|=4096;return t}return s=yl(s.child,{mode:i.mode,children:i.children}),s.ref=t.ref,t.child=s,s.return=t,s}function ao(s,t){var n=t.ref;if(n===null)s!==null&&s.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(c(284));(s===null||s.ref!==n)&&(t.flags|=4194816)}}function Ru(s,t,n,i,o){return $n(t),n=xu(s,t,n,i,void 0,o),i=hu(),s!==null&&!Pt?(fu(s,t,o),Tl(s,t,o)):(Us&&i&&Qd(t),t.flags|=1,ea(s,t,n,o),t.child)}function Qf(s,t,n,i,o,x){return $n(t),t.updateQueue=null,n=Jh(t,i,n,o),Yh(s),i=hu(),s!==null&&!Pt?(fu(s,t,x),Tl(s,t,x)):(Us&&i&&Qd(t),t.flags|=1,ea(s,t,n,x),t.child)}function Yf(s,t,n,i,o){if($n(t),t.stateNode===null){var x=jr,v=n.contextType;typeof v=="object"&&v!==null&&(x=Wt(v)),x=new n(i,x),t.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=Mu,t.stateNode=x,x._reactInternals=t,x=t.stateNode,x.props=i,x.state=t.memoizedState,x.refs={},nu(t),v=n.contextType,x.context=typeof v=="object"&&v!==null?Wt(v):jr,x.state=t.memoizedState,v=n.getDerivedStateFromProps,typeof v=="function"&&(Eu(t,n,v,i),x.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(v=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),v!==x.state&&Mu.enqueueReplaceState(x,x.state,null),wi(t,i,x,o),yi(),x.state=t.memoizedState),typeof x.componentDidMount=="function"&&(t.flags|=4194308),i=!0}else if(s===null){x=t.stateNode;var k=t.memoizedProps,I=qn(n,k);x.props=I;var ie=x.context,ve=n.contextType;v=jr,typeof ve=="object"&&ve!==null&&(v=Wt(ve));var ye=n.getDerivedStateFromProps;ve=typeof ye=="function"||typeof x.getSnapshotBeforeUpdate=="function",k=t.pendingProps!==k,ve||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(k||ie!==v)&&Of(t,x,i,v),en=!1;var de=t.memoizedState;x.state=de,wi(t,i,x,o),yi(),ie=t.memoizedState,k||de!==ie||en?(typeof ye=="function"&&(Eu(t,n,ye,i),ie=t.memoizedState),(I=en||Df(t,n,I,i,de,ie,v))?(ve||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(t.flags|=4194308)):(typeof x.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=ie),x.props=i,x.state=ie,x.context=v,i=I):(typeof x.componentDidMount=="function"&&(t.flags|=4194308),i=!1)}else{x=t.stateNode,ru(s,t),v=t.memoizedProps,ve=qn(n,v),x.props=ve,ye=t.pendingProps,de=x.context,ie=n.contextType,I=jr,typeof ie=="object"&&ie!==null&&(I=Wt(ie)),k=n.getDerivedStateFromProps,(ie=typeof k=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(v!==ye||de!==I)&&Of(t,x,i,I),en=!1,de=t.memoizedState,x.state=de,wi(t,i,x,o),yi();var he=t.memoizedState;v!==ye||de!==he||en||s!==null&&s.dependencies!==null&&$c(s.dependencies)?(typeof k=="function"&&(Eu(t,n,k,i),he=t.memoizedState),(ve=en||Df(t,n,ve,i,de,he,I)||s!==null&&s.dependencies!==null&&$c(s.dependencies))?(ie||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(i,he,I),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(i,he,I)),typeof x.componentDidUpdate=="function"&&(t.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof x.componentDidUpdate!="function"||v===s.memoizedProps&&de===s.memoizedState||(t.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||v===s.memoizedProps&&de===s.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=he),x.props=i,x.state=he,x.context=I,i=ve):(typeof x.componentDidUpdate!="function"||v===s.memoizedProps&&de===s.memoizedState||(t.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||v===s.memoizedProps&&de===s.memoizedState||(t.flags|=1024),i=!1)}return x=i,ao(s,t),i=(t.flags&128)!==0,x||i?(x=t.stateNode,n=i&&typeof n.getDerivedStateFromError!="function"?null:x.render(),t.flags|=1,s!==null&&i?(t.child=Fn(t,s.child,null,o),t.child=Fn(t,null,n,o)):ea(s,t,n,o),t.memoizedState=x.state,s=t.child):s=Tl(s,t,o),s}function Jf(s,t,n,i){return Ln(),t.flags|=256,ea(s,t,n,i),t.child}var Du={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ou(s){return{baseLanes:s,cachePool:$h()}}function Lu(s,t,n){return s=s!==null?s.childLanes&~n:0,t&&(s|=Ra),s}function Xf(s,t,n){var i=t.pendingProps,o=!1,x=(t.flags&128)!==0,v;if((v=x)||(v=s!==null&&s.memoizedState===null?!1:(Dt.current&2)!==0),v&&(o=!0,t.flags&=-129),v=(t.flags&32)!==0,t.flags&=-33,s===null){if(Us){if(o?an(t):ln(),(s=bt)?(s=ng(s,Ya),s=s!==null&&s.data!=="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:Jl!==null?{id:xl,overflow:hl}:null,retryLane:536870912,hydrationErrors:null},n=Eh(s),n.return=t,t.child=n,Zt=t,bt=null)):s=null,s===null)throw Zl(t);return jm(s)?t.lanes=32:t.lanes=536870912,null}var k=i.children;return i=i.fallback,o?(ln(),o=t.mode,k=lo({mode:"hidden",children:k},o),i=On(i,o,n,null),k.return=t,i.return=t,k.sibling=i,t.child=k,i=t.child,i.memoizedState=Ou(n),i.childLanes=Lu(s,v,n),t.memoizedState=Du,Ti(null,i)):(an(t),Uu(t,k))}var I=s.memoizedState;if(I!==null&&(k=I.dehydrated,k!==null)){if(x)t.flags&256?(an(t),t.flags&=-257,t=$u(s,t,n)):t.memoizedState!==null?(ln(),t.child=s.child,t.flags|=128,t=null):(ln(),k=i.fallback,o=t.mode,i=lo({mode:"visible",children:i.children},o),k=On(k,o,n,null),k.flags|=2,i.return=t,k.return=t,i.sibling=k,t.child=i,Fn(t,s.child,null,n),i=t.child,i.memoizedState=Ou(n),i.childLanes=Lu(s,v,n),t.memoizedState=Du,t=Ti(null,i));else if(an(t),jm(k)){if(v=k.nextSibling&&k.nextSibling.dataset,v)var ie=v.dgst;v=ie,i=Error(c(419)),i.stack="",i.digest=v,pi({value:i,source:null,stack:null}),t=$u(s,t,n)}else if(Pt||yr(s,t,n,!1),v=(n&s.childLanes)!==0,Pt||v){if(v=xt,v!==null&&(i=es(v,n),i!==0&&i!==I.retryLane))throw I.retryLane=i,Dn(s,i),ya(v,s,i),zu;gm(k)||ho(),t=$u(s,t,n)}else gm(k)?(t.flags|=192,t.child=s.child,t=null):(s=I.treeContext,bt=Xa(k.nextSibling),Zt=t,Us=!0,Xl=null,Ya=!1,s!==null&&zh(t,s),t=Uu(t,i.children),t.flags|=4096);return t}return o?(ln(),k=i.fallback,o=t.mode,I=s.child,ie=I.sibling,i=yl(I,{mode:"hidden",children:i.children}),i.subtreeFlags=I.subtreeFlags&65011712,ie!==null?k=yl(ie,k):(k=On(k,o,n,null),k.flags|=2),k.return=t,i.return=t,i.sibling=k,t.child=i,Ti(null,i),i=t.child,k=s.child.memoizedState,k===null?k=Ou(n):(o=k.cachePool,o!==null?(I=Bt._currentValue,o=o.parent!==I?{parent:I,pool:I}:o):o=$h(),k={baseLanes:k.baseLanes|n,cachePool:o}),i.memoizedState=k,i.childLanes=Lu(s,v,n),t.memoizedState=Du,Ti(s.child,i)):(an(t),n=s.child,s=n.sibling,n=yl(n,{mode:"visible",children:i.children}),n.return=t,n.sibling=null,s!==null&&(v=t.deletions,v===null?(t.deletions=[s],t.flags|=16):v.push(s)),t.child=n,t.memoizedState=null,n)}function Uu(s,t){return t=lo({mode:"visible",children:t},s.mode),t.return=s,s.child=t}function lo(s,t){return s=Ea(22,s,null,t),s.lanes=0,s}function $u(s,t,n){return Fn(t,s.child,null,n),s=Uu(t,t.pendingProps.children),s.flags|=2,t.memoizedState=null,s}function Zf(s,t,n){s.lanes|=t;var i=s.alternate;i!==null&&(i.lanes|=t),Wd(s.return,t,n)}function Bu(s,t,n,i,o,x){var v=s.memoizedState;v===null?s.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:o,treeForkCount:x}:(v.isBackwards=t,v.rendering=null,v.renderingStartTime=0,v.last=i,v.tail=n,v.tailMode=o,v.treeForkCount=x)}function Wf(s,t,n){var i=t.pendingProps,o=i.revealOrder,x=i.tail;i=i.children;var v=Dt.current,k=(v&2)!==0;if(k?(v=v&1|2,t.flags|=128):v&=1,Ee(Dt,v),ea(s,t,i,n),i=Us?fi:0,!k&&s!==null&&(s.flags&128)!==0)e:for(s=t.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&Zf(s,n,t);else if(s.tag===19)Zf(s,n,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(o){case"forwards":for(n=t.child,o=null;n!==null;)s=n.alternate,s!==null&&Gc(s)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),Bu(t,!1,o,n,x,i);break;case"backwards":case"unstable_legacy-backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(s=o.alternate,s!==null&&Gc(s)===null){t.child=o;break}s=o.sibling,o.sibling=n,n=o,o=s}Bu(t,!0,n,null,x,i);break;case"together":Bu(t,!1,null,null,void 0,i);break;default:t.memoizedState=null}return t.child}function Tl(s,t,n){if(s!==null&&(t.dependencies=s.dependencies),cn|=t.lanes,(n&t.childLanes)===0)if(s!==null){if(yr(s,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(s!==null&&t.child!==s.child)throw Error(c(153));if(t.child!==null){for(s=t.child,n=yl(s,s.pendingProps),t.child=n,n.return=t;s.sibling!==null;)s=s.sibling,n=n.sibling=yl(s,s.pendingProps),n.return=t;n.sibling=null}return t.child}function Iu(s,t){return(s.lanes&t)!==0?!0:(s=s.dependencies,!!(s!==null&&$c(s)))}function s0(s,t,n){switch(t.tag){case 3:Re(t,t.stateNode.containerInfo),Wl(t,Bt,s.memoizedState.cache),Ln();break;case 27:case 5:$e(t);break;case 4:Re(t,t.stateNode.containerInfo);break;case 10:Wl(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,uu(t),null;break;case 13:var i=t.memoizedState;if(i!==null)return i.dehydrated!==null?(an(t),t.flags|=128,null):(n&t.child.childLanes)!==0?Xf(s,t,n):(an(t),s=Tl(s,t,n),s!==null?s.sibling:null);an(t);break;case 19:var o=(s.flags&128)!==0;if(i=(n&t.childLanes)!==0,i||(yr(s,t,n,!1),i=(n&t.childLanes)!==0),o){if(i)return Wf(s,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),Ee(Dt,Dt.current),i)break;return null;case 22:return t.lanes=0,Vf(s,t,n,t.pendingProps);case 24:Wl(t,Bt,s.memoizedState.cache)}return Tl(s,t,n)}function ep(s,t,n){if(s!==null)if(s.memoizedProps!==t.pendingProps)Pt=!0;else{if(!Iu(s,n)&&(t.flags&128)===0)return Pt=!1,s0(s,t,n);Pt=(s.flags&131072)!==0}else Pt=!1,Us&&(t.flags&1048576)!==0&&Ah(t,fi,t.index);switch(t.lanes=0,t.tag){case 16:e:{var i=t.pendingProps;if(s=In(t.elementType),t.type=s,typeof s=="function")Vd(s)?(i=qn(s,i),t.tag=1,t=Yf(null,t,s,i,n)):(t.tag=0,t=Ru(null,t,s,i,n));else{if(s!=null){var o=s.$$typeof;if(o===C){t.tag=11,t=Ff(null,t,s,i,n);break e}else if(o===O){t.tag=14,t=Hf(null,t,s,i,n);break e}}throw t=ge(s)||s,Error(c(306,t,""))}}return t;case 0:return Ru(s,t,t.type,t.pendingProps,n);case 1:return i=t.type,o=qn(i,t.pendingProps),Yf(s,t,i,o,n);case 3:e:{if(Re(t,t.stateNode.containerInfo),s===null)throw Error(c(387));i=t.pendingProps;var x=t.memoizedState;o=x.element,ru(s,t),wi(t,i,null,n);var v=t.memoizedState;if(i=v.cache,Wl(t,Bt,i),i!==x.cache&&eu(t,[Bt],n,!0),yi(),i=v.element,x.isDehydrated)if(x={element:i,isDehydrated:!1,cache:v.cache},t.updateQueue.baseState=x,t.memoizedState=x,t.flags&256){t=Jf(s,t,i,n);break e}else if(i!==o){o=Ga(Error(c(424)),t),pi(o),t=Jf(s,t,i,n);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(bt=Xa(s.firstChild),Zt=t,Us=!0,Xl=null,Ya=!0,n=qh(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ln(),i===o){t=Tl(s,t,n);break e}ea(s,t,i,n)}t=t.child}return t;case 26:return ao(s,t),s===null?(n=ug(t.type,null,t.pendingProps,null))?t.memoizedState=n:Us||(n=t.type,s=t.pendingProps,i=bo(A.current).createElement(n),i[oe]=t,i[qe]=s,sa(i,n,s),Kt(i),t.stateNode=i):t.memoizedState=ug(t.type,s.memoizedProps,t.pendingProps,s.memoizedState),null;case 27:return $e(t),s===null&&Us&&(i=t.stateNode=cg(t.type,t.pendingProps,A.current),Zt=t,Ya=!0,o=bt,xn(t.type)?(vm=o,bt=Xa(i.firstChild)):bt=o),ea(s,t,t.pendingProps.children,n),ao(s,t),s===null&&(t.flags|=4194304),t.child;case 5:return s===null&&Us&&((o=i=bt)&&(i=A0(i,t.type,t.pendingProps,Ya),i!==null?(t.stateNode=i,Zt=t,bt=Xa(i.firstChild),Ya=!1,o=!0):o=!1),o||Zl(t)),$e(t),o=t.type,x=t.pendingProps,v=s!==null?s.memoizedProps:null,i=x.children,hm(o,x)?i=null:v!==null&&hm(o,v)&&(t.flags|=32),t.memoizedState!==null&&(o=xu(s,t,Gy,null,null,n),Hi._currentValue=o),ao(s,t),ea(s,t,i,n),t.child;case 6:return s===null&&Us&&((s=n=bt)&&(n=z0(n,t.pendingProps,Ya),n!==null?(t.stateNode=n,Zt=t,bt=null,s=!0):s=!1),s||Zl(t)),null;case 13:return Xf(s,t,n);case 4:return Re(t,t.stateNode.containerInfo),i=t.pendingProps,s===null?t.child=Fn(t,null,i,n):ea(s,t,i,n),t.child;case 11:return Ff(s,t,t.type,t.pendingProps,n);case 7:return ea(s,t,t.pendingProps,n),t.child;case 8:return ea(s,t,t.pendingProps.children,n),t.child;case 12:return ea(s,t,t.pendingProps.children,n),t.child;case 10:return i=t.pendingProps,Wl(t,t.type,i.value),ea(s,t,i.children,n),t.child;case 9:return o=t.type._context,i=t.pendingProps.children,$n(t),o=Wt(o),i=i(o),t.flags|=1,ea(s,t,i,n),t.child;case 14:return Hf(s,t,t.type,t.pendingProps,n);case 15:return qf(s,t,t.type,t.pendingProps,n);case 19:return Wf(s,t,n);case 31:return e0(s,t,n);case 22:return Vf(s,t,n,t.pendingProps);case 24:return $n(t),i=Wt(Bt),s===null?(o=au(),o===null&&(o=xt,x=su(),o.pooledCache=x,x.refCount++,x!==null&&(o.pooledCacheLanes|=n),o=x),t.memoizedState={parent:i,cache:o},nu(t),Wl(t,Bt,o)):((s.lanes&n)!==0&&(ru(s,t),wi(t,null,null,n),yi()),o=s.memoizedState,x=t.memoizedState,o.parent!==i?(o={parent:i,cache:i},t.memoizedState=o,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=o),Wl(t,Bt,i)):(i=x.cache,Wl(t,Bt,i),i!==o.cache&&eu(t,[Bt],n,!0))),ea(s,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(c(156,t.tag))}function El(s){s.flags|=4}function Pu(s,t,n,i,o){if((t=(s.mode&32)!==0)&&(t=!1),t){if(s.flags|=16777216,(o&335544128)===o)if(s.stateNode.complete)s.flags|=8192;else if(Cp())s.flags|=8192;else throw Pn=Fc,lu}else s.flags&=-16777217}function sp(s,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!pg(t))if(Cp())s.flags|=8192;else throw Pn=Fc,lu}function no(s,t){t!==null&&(s.flags|=4),s.flags&16384&&(t=s.tag!==22?te():536870912,s.lanes|=t,Dr|=t)}function Ei(s,t){if(!Us)switch(s.tailMode){case"hidden":t=s.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?s.tail=null:n.sibling=null;break;case"collapsed":n=s.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?t||s.tail===null?s.tail=null:s.tail.sibling=null:i.sibling=null}}function yt(s){var t=s.alternate!==null&&s.alternate.child===s.child,n=0,i=0;if(t)for(var o=s.child;o!==null;)n|=o.lanes|o.childLanes,i|=o.subtreeFlags&65011712,i|=o.flags&65011712,o.return=s,o=o.sibling;else for(o=s.child;o!==null;)n|=o.lanes|o.childLanes,i|=o.subtreeFlags,i|=o.flags,o.return=s,o=o.sibling;return s.subtreeFlags|=i,s.childLanes=n,t}function t0(s,t,n){var i=t.pendingProps;switch(Yd(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yt(t),null;case 1:return yt(t),null;case 3:return n=t.stateNode,i=null,s!==null&&(i=s.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Sl(Bt),se(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(s===null||s.child===null)&&(br(t)?El(t):s===null||s.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Xd())),yt(t),null;case 26:var o=t.type,x=t.memoizedState;return s===null?(El(t),x!==null?(yt(t),sp(t,x)):(yt(t),Pu(t,o,null,i,n))):x?x!==s.memoizedState?(El(t),yt(t),sp(t,x)):(yt(t),t.flags&=-16777217):(s=s.memoizedProps,s!==i&&El(t),yt(t),Pu(t,o,s,i,n)),null;case 27:if(cs(t),n=A.current,o=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==i&&El(t);else{if(!i){if(t.stateNode===null)throw Error(c(166));return yt(t),null}s=G.current,br(t)?Rh(t):(s=cg(o,i,n),t.stateNode=s,El(t))}return yt(t),null;case 5:if(cs(t),o=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==i&&El(t);else{if(!i){if(t.stateNode===null)throw Error(c(166));return yt(t),null}if(x=G.current,br(t))Rh(t);else{var v=bo(A.current);switch(x){case 1:x=v.createElementNS("http://www.w3.org/2000/svg",o);break;case 2:x=v.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;default:switch(o){case"svg":x=v.createElementNS("http://www.w3.org/2000/svg",o);break;case"math":x=v.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;case"script":x=v.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof i.is=="string"?v.createElement("select",{is:i.is}):v.createElement("select"),i.multiple?x.multiple=!0:i.size&&(x.size=i.size);break;default:x=typeof i.is=="string"?v.createElement(o,{is:i.is}):v.createElement(o)}}x[oe]=t,x[qe]=i;e:for(v=t.child;v!==null;){if(v.tag===5||v.tag===6)x.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===t)break e;for(;v.sibling===null;){if(v.return===null||v.return===t)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}t.stateNode=x;e:switch(sa(x,o,i),o){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&El(t)}}return yt(t),Pu(t,t.type,s===null?null:s.memoizedProps,t.pendingProps,n),null;case 6:if(s&&t.stateNode!=null)s.memoizedProps!==i&&El(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(c(166));if(s=A.current,br(t)){if(s=t.stateNode,n=t.memoizedProps,i=null,o=Zt,o!==null)switch(o.tag){case 27:case 5:i=o.memoizedProps}s[oe]=t,s=!!(s.nodeValue===n||i!==null&&i.suppressHydrationWarning===!0||Xp(s.nodeValue,n)),s||Zl(t,!0)}else s=bo(s).createTextNode(i),s[oe]=t,t.stateNode=s}return yt(t),null;case 31:if(n=t.memoizedState,s===null||s.memoizedState!==null){if(i=br(t),n!==null){if(s===null){if(!i)throw Error(c(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(557));s[oe]=t}else Ln(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;yt(t),s=!1}else n=Xd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=n),s=!0;if(!s)return t.flags&256?(Aa(t),t):(Aa(t),null);if((t.flags&128)!==0)throw Error(c(558))}return yt(t),null;case 13:if(i=t.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(o=br(t),i!==null&&i.dehydrated!==null){if(s===null){if(!o)throw Error(c(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(c(317));o[oe]=t}else Ln(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;yt(t),o=!1}else o=Xd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=o),o=!0;if(!o)return t.flags&256?(Aa(t),t):(Aa(t),null)}return Aa(t),(t.flags&128)!==0?(t.lanes=n,t):(n=i!==null,s=s!==null&&s.memoizedState!==null,n&&(i=t.child,o=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(o=i.alternate.memoizedState.cachePool.pool),x=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(x=i.memoizedState.cachePool.pool),x!==o&&(i.flags|=2048)),n!==s&&n&&(t.child.flags|=8192),no(t,t.updateQueue),yt(t),null);case 4:return se(),s===null&&om(t.stateNode.containerInfo),yt(t),null;case 10:return Sl(t.type),yt(t),null;case 19:if(fe(Dt),i=t.memoizedState,i===null)return yt(t),null;if(o=(t.flags&128)!==0,x=i.rendering,x===null)if(o)Ei(i,!1);else{if(Mt!==0||s!==null&&(s.flags&128)!==0)for(s=t.child;s!==null;){if(x=Gc(s),x!==null){for(t.flags|=128,Ei(i,!1),s=x.updateQueue,t.updateQueue=s,no(t,s),t.subtreeFlags=0,s=n,n=t.child;n!==null;)Th(n,s),n=n.sibling;return Ee(Dt,Dt.current&1|2),Us&&wl(t,i.treeForkCount),t.child}s=s.sibling}i.tail!==null&&Is()>uo&&(t.flags|=128,o=!0,Ei(i,!1),t.lanes=4194304)}else{if(!o)if(s=Gc(x),s!==null){if(t.flags|=128,o=!0,s=s.updateQueue,t.updateQueue=s,no(t,s),Ei(i,!0),i.tail===null&&i.tailMode==="hidden"&&!x.alternate&&!Us)return yt(t),null}else 2*Is()-i.renderingStartTime>uo&&n!==536870912&&(t.flags|=128,o=!0,Ei(i,!1),t.lanes=4194304);i.isBackwards?(x.sibling=t.child,t.child=x):(s=i.last,s!==null?s.sibling=x:t.child=x,i.last=x)}return i.tail!==null?(s=i.tail,i.rendering=s,i.tail=s.sibling,i.renderingStartTime=Is(),s.sibling=null,n=Dt.current,Ee(Dt,o?n&1|2:n&1),Us&&wl(t,i.treeForkCount),s):(yt(t),null);case 22:case 23:return Aa(t),du(),i=t.memoizedState!==null,s!==null?s.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(n&536870912)!==0&&(t.flags&128)===0&&(yt(t),t.subtreeFlags&6&&(t.flags|=8192)):yt(t),n=t.updateQueue,n!==null&&no(t,n.retryQueue),n=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(n=s.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),s!==null&&fe(Bn),null;case 24:return n=null,s!==null&&(n=s.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Sl(Bt),yt(t),null;case 25:return null;case 30:return null}throw Error(c(156,t.tag))}function a0(s,t){switch(Yd(t),t.tag){case 1:return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 3:return Sl(Bt),se(),s=t.flags,(s&65536)!==0&&(s&128)===0?(t.flags=s&-65537|128,t):null;case 26:case 27:case 5:return cs(t),null;case 31:if(t.memoizedState!==null){if(Aa(t),t.alternate===null)throw Error(c(340));Ln()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 13:if(Aa(t),s=t.memoizedState,s!==null&&s.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Ln()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 19:return fe(Dt),null;case 4:return se(),null;case 10:return Sl(t.type),null;case 22:case 23:return Aa(t),du(),s!==null&&fe(Bn),s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 24:return Sl(Bt),null;case 25:return null;default:return null}}function tp(s,t){switch(Yd(t),t.tag){case 3:Sl(Bt),se();break;case 26:case 27:case 5:cs(t);break;case 4:se();break;case 31:t.memoizedState!==null&&Aa(t);break;case 13:Aa(t);break;case 19:fe(Dt);break;case 10:Sl(t.type);break;case 22:case 23:Aa(t),du(),s!==null&&fe(Bn);break;case 24:Sl(Bt)}}function Mi(s,t){try{var n=t.updateQueue,i=n!==null?n.lastEffect:null;if(i!==null){var o=i.next;n=o;do{if((n.tag&s)===s){i=void 0;var x=n.create,v=n.inst;i=x(),v.destroy=i}n=n.next}while(n!==o)}}catch(k){et(t,t.return,k)}}function nn(s,t,n){try{var i=t.updateQueue,o=i!==null?i.lastEffect:null;if(o!==null){var x=o.next;i=x;do{if((i.tag&s)===s){var v=i.inst,k=v.destroy;if(k!==void 0){v.destroy=void 0,o=t;var I=n,ie=k;try{ie()}catch(ve){et(o,I,ve)}}}i=i.next}while(i!==x)}}catch(ve){et(t,t.return,ve)}}function ap(s){var t=s.updateQueue;if(t!==null){var n=s.stateNode;try{Gh(t,n)}catch(i){et(s,s.return,i)}}}function lp(s,t,n){n.props=qn(s.type,s.memoizedProps),n.state=s.memoizedState;try{n.componentWillUnmount()}catch(i){et(s,t,i)}}function Ai(s,t){try{var n=s.ref;if(n!==null){switch(s.tag){case 26:case 27:case 5:var i=s.stateNode;break;case 30:i=s.stateNode;break;default:i=s.stateNode}typeof n=="function"?s.refCleanup=n(i):n.current=i}}catch(o){et(s,t,o)}}function fl(s,t){var n=s.ref,i=s.refCleanup;if(n!==null)if(typeof i=="function")try{i()}catch(o){et(s,t,o)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(o){et(s,t,o)}else n.current=null}function np(s){var t=s.type,n=s.memoizedProps,i=s.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&i.focus();break e;case"img":n.src?i.src=n.src:n.srcSet&&(i.srcset=n.srcSet)}}catch(o){et(s,s.return,o)}}function Fu(s,t,n){try{var i=s.stateNode;S0(i,s.type,n,t),i[qe]=t}catch(o){et(s,s.return,o)}}function rp(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&xn(s.type)||s.tag===4}function Hu(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||rp(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&&xn(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 qu(s,t,n){var i=s.tag;if(i===5||i===6)s=s.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(s,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(s),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Nl));else if(i!==4&&(i===27&&xn(s.type)&&(n=s.stateNode,t=null),s=s.child,s!==null))for(qu(s,t,n),s=s.sibling;s!==null;)qu(s,t,n),s=s.sibling}function ro(s,t,n){var i=s.tag;if(i===5||i===6)s=s.stateNode,t?n.insertBefore(s,t):n.appendChild(s);else if(i!==4&&(i===27&&xn(s.type)&&(n=s.stateNode),s=s.child,s!==null))for(ro(s,t,n),s=s.sibling;s!==null;)ro(s,t,n),s=s.sibling}function ip(s){var t=s.stateNode,n=s.memoizedProps;try{for(var i=s.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);sa(t,i,n),t[oe]=s,t[qe]=n}catch(x){et(s,s.return,x)}}var Ml=!1,Ft=!1,Vu=!1,cp=typeof WeakSet=="function"?WeakSet:Set,Qt=null;function l0(s,t){if(s=s.containerInfo,mm=To,s=vh(s),$d(s)){if("selectionStart"in s)var n={start:s.selectionStart,end:s.selectionEnd};else e:{n=(n=s.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var o=i.anchorOffset,x=i.focusNode;i=i.focusOffset;try{n.nodeType,x.nodeType}catch{n=null;break e}var v=0,k=-1,I=-1,ie=0,ve=0,ye=s,de=null;s:for(;;){for(var he;ye!==n||o!==0&&ye.nodeType!==3||(k=v+o),ye!==x||i!==0&&ye.nodeType!==3||(I=v+i),ye.nodeType===3&&(v+=ye.nodeValue.length),(he=ye.firstChild)!==null;)de=ye,ye=he;for(;;){if(ye===s)break s;if(de===n&&++ie===o&&(k=v),de===x&&++ve===i&&(I=v),(he=ye.nextSibling)!==null)break;ye=de,de=ye.parentNode}ye=he}n=k===-1||I===-1?null:{start:k,end:I}}else n=null}n=n||{start:0,end:0}}else n=null;for(xm={focusedElem:s,selectionRange:n},To=!1,Qt=t;Qt!==null;)if(t=Qt,s=t.child,(t.subtreeFlags&1028)!==0&&s!==null)s.return=t,Qt=s;else for(;Qt!==null;){switch(t=Qt,x=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(n=0;n<s.length;n++)o=s[n],o.ref.impl=o.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&x!==null){s=void 0,n=t,o=x.memoizedProps,x=x.memoizedState,i=n.stateNode;try{var Ve=qn(n.type,o);s=i.getSnapshotBeforeUpdate(Ve,x),i.__reactInternalSnapshotBeforeUpdate=s}catch(ls){et(n,n.return,ls)}}break;case 3:if((s&1024)!==0){if(s=t.stateNode.containerInfo,n=s.nodeType,n===9)pm(s);else if(n===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":pm(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(c(163))}if(s=t.sibling,s!==null){s.return=t.return,Qt=s;break}Qt=t.return}}function op(s,t,n){var i=n.flags;switch(n.tag){case 0:case 11:case 15:zl(s,n),i&4&&Mi(5,n);break;case 1:if(zl(s,n),i&4)if(s=n.stateNode,t===null)try{s.componentDidMount()}catch(v){et(n,n.return,v)}else{var o=qn(n.type,t.memoizedProps);t=t.memoizedState;try{s.componentDidUpdate(o,t,s.__reactInternalSnapshotBeforeUpdate)}catch(v){et(n,n.return,v)}}i&64&&ap(n),i&512&&Ai(n,n.return);break;case 3:if(zl(s,n),i&64&&(s=n.updateQueue,s!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Gh(s,t)}catch(v){et(n,n.return,v)}}break;case 27:t===null&&i&4&&ip(n);case 26:case 5:zl(s,n),t===null&&i&4&&np(n),i&512&&Ai(n,n.return);break;case 12:zl(s,n);break;case 31:zl(s,n),i&4&&mp(s,n);break;case 13:zl(s,n),i&4&&xp(s,n),i&64&&(s=n.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(n=x0.bind(null,n),R0(s,n))));break;case 22:if(i=n.memoizedState!==null||Ml,!i){t=t!==null&&t.memoizedState!==null||Ft,o=Ml;var x=Ft;Ml=i,(Ft=t)&&!x?Rl(s,n,(n.subtreeFlags&8772)!==0):zl(s,n),Ml=o,Ft=x}break;case 30:break;default:zl(s,n)}}function dp(s){var t=s.alternate;t!==null&&(s.alternate=null,dp(t)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(t=s.stateNode,t!==null&&rr(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 St=null,ja=!1;function Al(s,t,n){for(n=n.child;n!==null;)up(s,t,n),n=n.sibling}function up(s,t,n){if(rs&&typeof rs.onCommitFiberUnmount=="function")try{rs.onCommitFiberUnmount(Cs,n)}catch{}switch(n.tag){case 26:Ft||fl(n,t),Al(s,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Ft||fl(n,t);var i=St,o=ja;xn(n.type)&&(St=n.stateNode,ja=!1),Al(s,t,n),Ii(n.stateNode),St=i,ja=o;break;case 5:Ft||fl(n,t);case 6:if(i=St,o=ja,St=null,Al(s,t,n),St=i,ja=o,St!==null)if(ja)try{(St.nodeType===9?St.body:St.nodeName==="HTML"?St.ownerDocument.body:St).removeChild(n.stateNode)}catch(x){et(n,t,x)}else try{St.removeChild(n.stateNode)}catch(x){et(n,t,x)}break;case 18:St!==null&&(ja?(s=St,ag(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,n.stateNode),Fr(s)):ag(St,n.stateNode));break;case 4:i=St,o=ja,St=n.stateNode.containerInfo,ja=!0,Al(s,t,n),St=i,ja=o;break;case 0:case 11:case 14:case 15:nn(2,n,t),Ft||nn(4,n,t),Al(s,t,n);break;case 1:Ft||(fl(n,t),i=n.stateNode,typeof i.componentWillUnmount=="function"&&lp(n,t,i)),Al(s,t,n);break;case 21:Al(s,t,n);break;case 22:Ft=(i=Ft)||n.memoizedState!==null,Al(s,t,n),Ft=i;break;default:Al(s,t,n)}}function mp(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Fr(s)}catch(n){et(t,t.return,n)}}}function xp(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Fr(s)}catch(n){et(t,t.return,n)}}function n0(s){switch(s.tag){case 31:case 13:case 19:var t=s.stateNode;return t===null&&(t=s.stateNode=new cp),t;case 22:return s=s.stateNode,t=s._retryCache,t===null&&(t=s._retryCache=new cp),t;default:throw Error(c(435,s.tag))}}function io(s,t){var n=n0(s);t.forEach(function(i){if(!n.has(i)){n.add(i);var o=h0.bind(null,s,i);i.then(o,o)}})}function va(s,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var o=n[i],x=s,v=t,k=v;e:for(;k!==null;){switch(k.tag){case 27:if(xn(k.type)){St=k.stateNode,ja=!1;break e}break;case 5:St=k.stateNode,ja=!1;break e;case 3:case 4:St=k.stateNode.containerInfo,ja=!0;break e}k=k.return}if(St===null)throw Error(c(160));up(x,v,o),St=null,ja=!1,x=o.alternate,x!==null&&(x.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)hp(t,s),t=t.sibling}var rl=null;function hp(s,t){var n=s.alternate,i=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:va(t,s),Na(s),i&4&&(nn(3,s,s.return),Mi(3,s),nn(5,s,s.return));break;case 1:va(t,s),Na(s),i&512&&(Ft||n===null||fl(n,n.return)),i&64&&Ml&&(s=s.updateQueue,s!==null&&(i=s.callbacks,i!==null&&(n=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=n===null?i:n.concat(i))));break;case 26:var o=rl;if(va(t,s),Na(s),i&512&&(Ft||n===null||fl(n,n.return)),i&4){var x=n!==null?n.memoizedState:null;if(i=s.memoizedState,n===null)if(i===null)if(s.stateNode===null){e:{i=s.type,n=s.memoizedProps,o=o.ownerDocument||o;s:switch(i){case"title":x=o.getElementsByTagName("title")[0],(!x||x[ml]||x[oe]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=o.createElement(i),o.head.insertBefore(x,o.querySelector("head > title"))),sa(x,i,n),x[oe]=s,Kt(x),i=x;break e;case"link":var v=hg("link","href",o).get(i+(n.href||""));if(v){for(var k=0;k<v.length;k++)if(x=v[k],x.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&x.getAttribute("rel")===(n.rel==null?null:n.rel)&&x.getAttribute("title")===(n.title==null?null:n.title)&&x.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){v.splice(k,1);break s}}x=o.createElement(i),sa(x,i,n),o.head.appendChild(x);break;case"meta":if(v=hg("meta","content",o).get(i+(n.content||""))){for(k=0;k<v.length;k++)if(x=v[k],x.getAttribute("content")===(n.content==null?null:""+n.content)&&x.getAttribute("name")===(n.name==null?null:n.name)&&x.getAttribute("property")===(n.property==null?null:n.property)&&x.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&x.getAttribute("charset")===(n.charSet==null?null:n.charSet)){v.splice(k,1);break s}}x=o.createElement(i),sa(x,i,n),o.head.appendChild(x);break;default:throw Error(c(468,i))}x[oe]=s,Kt(x),i=x}s.stateNode=i}else fg(o,s.type,s.stateNode);else s.stateNode=xg(o,i,s.memoizedProps);else x!==i?(x===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):x.count--,i===null?fg(o,s.type,s.stateNode):xg(o,i,s.memoizedProps)):i===null&&s.stateNode!==null&&Fu(s,s.memoizedProps,n.memoizedProps)}break;case 27:va(t,s),Na(s),i&512&&(Ft||n===null||fl(n,n.return)),n!==null&&i&4&&Fu(s,s.memoizedProps,n.memoizedProps);break;case 5:if(va(t,s),Na(s),i&512&&(Ft||n===null||fl(n,n.return)),s.flags&32){o=s.stateNode;try{ur(o,"")}catch(Ve){et(s,s.return,Ve)}}i&4&&s.stateNode!=null&&(o=s.memoizedProps,Fu(s,o,n!==null?n.memoizedProps:o)),i&1024&&(Vu=!0);break;case 6:if(va(t,s),Na(s),i&4){if(s.stateNode===null)throw Error(c(162));i=s.memoizedProps,n=s.stateNode;try{n.nodeValue=i}catch(Ve){et(s,s.return,Ve)}}break;case 3:if(_o=null,o=rl,rl=yo(t.containerInfo),va(t,s),rl=o,Na(s),i&4&&n!==null&&n.memoizedState.isDehydrated)try{Fr(t.containerInfo)}catch(Ve){et(s,s.return,Ve)}Vu&&(Vu=!1,fp(s));break;case 4:i=rl,rl=yo(s.stateNode.containerInfo),va(t,s),Na(s),rl=i;break;case 12:va(t,s),Na(s);break;case 31:va(t,s),Na(s),i&4&&(i=s.updateQueue,i!==null&&(s.updateQueue=null,io(s,i)));break;case 13:va(t,s),Na(s),s.child.flags&8192&&s.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(oo=Is()),i&4&&(i=s.updateQueue,i!==null&&(s.updateQueue=null,io(s,i)));break;case 22:o=s.memoizedState!==null;var I=n!==null&&n.memoizedState!==null,ie=Ml,ve=Ft;if(Ml=ie||o,Ft=ve||I,va(t,s),Ft=ve,Ml=ie,Na(s),i&8192)e:for(t=s.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,o&&(n===null||I||Ml||Ft||Vn(s)),n=null,t=s;;){if(t.tag===5||t.tag===26){if(n===null){I=n=t;try{if(x=I.stateNode,o)v=x.style,typeof v.setProperty=="function"?v.setProperty("display","none","important"):v.display="none";else{k=I.stateNode;var ye=I.memoizedProps.style,de=ye!=null&&ye.hasOwnProperty("display")?ye.display:null;k.style.display=de==null||typeof de=="boolean"?"":(""+de).trim()}}catch(Ve){et(I,I.return,Ve)}}}else if(t.tag===6){if(n===null){I=t;try{I.stateNode.nodeValue=o?"":I.memoizedProps}catch(Ve){et(I,I.return,Ve)}}}else if(t.tag===18){if(n===null){I=t;try{var he=I.stateNode;o?lg(he,!0):lg(I.stateNode,!1)}catch(Ve){et(I,I.return,Ve)}}}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;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}i&4&&(i=s.updateQueue,i!==null&&(n=i.retryQueue,n!==null&&(i.retryQueue=null,io(s,n))));break;case 19:va(t,s),Na(s),i&4&&(i=s.updateQueue,i!==null&&(s.updateQueue=null,io(s,i)));break;case 30:break;case 21:break;default:va(t,s),Na(s)}}function Na(s){var t=s.flags;if(t&2){try{for(var n,i=s.return;i!==null;){if(rp(i)){n=i;break}i=i.return}if(n==null)throw Error(c(160));switch(n.tag){case 27:var o=n.stateNode,x=Hu(s);ro(s,x,o);break;case 5:var v=n.stateNode;n.flags&32&&(ur(v,""),n.flags&=-33);var k=Hu(s);ro(s,k,v);break;case 3:case 4:var I=n.stateNode.containerInfo,ie=Hu(s);qu(s,ie,I);break;default:throw Error(c(161))}}catch(ve){et(s,s.return,ve)}s.flags&=-3}t&4096&&(s.flags&=-4097)}function fp(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var t=s;fp(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),s=s.sibling}}function zl(s,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)op(s,t.alternate,t),t=t.sibling}function Vn(s){for(s=s.child;s!==null;){var t=s;switch(t.tag){case 0:case 11:case 14:case 15:nn(4,t,t.return),Vn(t);break;case 1:fl(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&lp(t,t.return,n),Vn(t);break;case 27:Ii(t.stateNode);case 26:case 5:fl(t,t.return),Vn(t);break;case 22:t.memoizedState===null&&Vn(t);break;case 30:Vn(t);break;default:Vn(t)}s=s.sibling}}function Rl(s,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var i=t.alternate,o=s,x=t,v=x.flags;switch(x.tag){case 0:case 11:case 15:Rl(o,x,n),Mi(4,x);break;case 1:if(Rl(o,x,n),i=x,o=i.stateNode,typeof o.componentDidMount=="function")try{o.componentDidMount()}catch(ie){et(i,i.return,ie)}if(i=x,o=i.updateQueue,o!==null){var k=i.stateNode;try{var I=o.shared.hiddenCallbacks;if(I!==null)for(o.shared.hiddenCallbacks=null,o=0;o<I.length;o++)Vh(I[o],k)}catch(ie){et(i,i.return,ie)}}n&&v&64&&ap(x),Ai(x,x.return);break;case 27:ip(x);case 26:case 5:Rl(o,x,n),n&&i===null&&v&4&&np(x),Ai(x,x.return);break;case 12:Rl(o,x,n);break;case 31:Rl(o,x,n),n&&v&4&&mp(o,x);break;case 13:Rl(o,x,n),n&&v&4&&xp(o,x);break;case 22:x.memoizedState===null&&Rl(o,x,n),Ai(x,x.return);break;case 30:break;default:Rl(o,x,n)}t=t.sibling}}function Gu(s,t){var n=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(n=s.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==n&&(s!=null&&s.refCount++,n!=null&&gi(n))}function Ku(s,t){s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&gi(s))}function il(s,t,n,i){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)pp(s,t,n,i),t=t.sibling}function pp(s,t,n,i){var o=t.flags;switch(t.tag){case 0:case 11:case 15:il(s,t,n,i),o&2048&&Mi(9,t);break;case 1:il(s,t,n,i);break;case 3:il(s,t,n,i),o&2048&&(s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&gi(s)));break;case 12:if(o&2048){il(s,t,n,i),s=t.stateNode;try{var x=t.memoizedProps,v=x.id,k=x.onPostCommit;typeof k=="function"&&k(v,t.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch(I){et(t,t.return,I)}}else il(s,t,n,i);break;case 31:il(s,t,n,i);break;case 13:il(s,t,n,i);break;case 23:break;case 22:x=t.stateNode,v=t.alternate,t.memoizedState!==null?x._visibility&2?il(s,t,n,i):zi(s,t):x._visibility&2?il(s,t,n,i):(x._visibility|=2,Ar(s,t,n,i,(t.subtreeFlags&10256)!==0||!1)),o&2048&&Gu(v,t);break;case 24:il(s,t,n,i),o&2048&&Ku(t.alternate,t);break;default:il(s,t,n,i)}}function Ar(s,t,n,i,o){for(o=o&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var x=s,v=t,k=n,I=i,ie=v.flags;switch(v.tag){case 0:case 11:case 15:Ar(x,v,k,I,o),Mi(8,v);break;case 23:break;case 22:var ve=v.stateNode;v.memoizedState!==null?ve._visibility&2?Ar(x,v,k,I,o):zi(x,v):(ve._visibility|=2,Ar(x,v,k,I,o)),o&&ie&2048&&Gu(v.alternate,v);break;case 24:Ar(x,v,k,I,o),o&&ie&2048&&Ku(v.alternate,v);break;default:Ar(x,v,k,I,o)}t=t.sibling}}function zi(s,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=s,i=t,o=i.flags;switch(i.tag){case 22:zi(n,i),o&2048&&Gu(i.alternate,i);break;case 24:zi(n,i),o&2048&&Ku(i.alternate,i);break;default:zi(n,i)}t=t.sibling}}var Ri=8192;function zr(s,t,n){if(s.subtreeFlags&Ri)for(s=s.child;s!==null;)gp(s,t,n),s=s.sibling}function gp(s,t,n){switch(s.tag){case 26:zr(s,t,n),s.flags&Ri&&s.memoizedState!==null&&V0(n,rl,s.memoizedState,s.memoizedProps);break;case 5:zr(s,t,n);break;case 3:case 4:var i=rl;rl=yo(s.stateNode.containerInfo),zr(s,t,n),rl=i;break;case 22:s.memoizedState===null&&(i=s.alternate,i!==null&&i.memoizedState!==null?(i=Ri,Ri=16777216,zr(s,t,n),Ri=i):zr(s,t,n));break;default:zr(s,t,n)}}function jp(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 Di(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var i=t[n];Qt=i,Np(i,s)}jp(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)vp(s),s=s.sibling}function vp(s){switch(s.tag){case 0:case 11:case 15:Di(s),s.flags&2048&&nn(9,s,s.return);break;case 3:Di(s);break;case 12:Di(s);break;case 22:var t=s.stateNode;s.memoizedState!==null&&t._visibility&2&&(s.return===null||s.return.tag!==13)?(t._visibility&=-3,co(s)):Di(s);break;default:Di(s)}}function co(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var i=t[n];Qt=i,Np(i,s)}jp(s)}for(s=s.child;s!==null;){switch(t=s,t.tag){case 0:case 11:case 15:nn(8,t,t.return),co(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,co(t));break;default:co(t)}s=s.sibling}}function Np(s,t){for(;Qt!==null;){var n=Qt;switch(n.tag){case 0:case 11:case 15:nn(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var i=n.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:gi(n.memoizedState.cache)}if(i=n.child,i!==null)i.return=n,Qt=i;else e:for(n=s;Qt!==null;){i=Qt;var o=i.sibling,x=i.return;if(dp(i),i===n){Qt=null;break e}if(o!==null){o.return=x,Qt=o;break e}Qt=x}}}var r0={getCacheForType:function(s){var t=Wt(Bt),n=t.data.get(s);return n===void 0&&(n=s(),t.data.set(s,n)),n},cacheSignal:function(){return Wt(Bt).controller.signal}},i0=typeof WeakMap=="function"?WeakMap:Map,Js=0,xt=null,zs=null,Os=0,Ws=0,za=null,rn=!1,Rr=!1,Qu=!1,Dl=0,Mt=0,cn=0,Gn=0,Yu=0,Ra=0,Dr=0,Oi=null,ba=null,Ju=!1,oo=0,bp=0,uo=1/0,mo=null,on=null,qt=0,dn=null,Or=null,Ol=0,Xu=0,Zu=null,yp=null,Li=0,Wu=null;function Da(){return(Js&2)!==0&&Os!==0?Os&-Os:D.T!==null?nm():pa()}function wp(){if(Ra===0)if((Os&536870912)===0||Us){var s=As;As<<=1,(As&3932160)===0&&(As=262144),Ra=s}else Ra=536870912;return s=Ma.current,s!==null&&(s.flags|=32),Ra}function ya(s,t,n){(s===xt&&(Ws===2||Ws===9)||s.cancelPendingCommit!==null)&&(Lr(s,0),un(s,Os,Ra,!1)),U(s,n),((Js&2)===0||s!==xt)&&(s===xt&&((Js&2)===0&&(Gn|=n),Mt===4&&un(s,Os,Ra,!1)),pl(s))}function _p(s,t,n){if((Js&6)!==0)throw Error(c(327));var i=!n&&(t&127)===0&&(t&s.expiredLanes)===0||Fa(s,t),o=i?d0(s,t):sm(s,t,!0),x=i;do{if(o===0){Rr&&!i&&un(s,t,0,!1);break}else{if(n=s.current.alternate,x&&!c0(n)){o=sm(s,t,!1),x=!1;continue}if(o===2){if(x=t,s.errorRecoveryDisabledLanes&x)var v=0;else v=s.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){t=v;e:{var k=s;o=Oi;var I=k.current.memoizedState.isDehydrated;if(I&&(Lr(k,v).flags|=256),v=sm(k,v,!1),v!==2){if(Qu&&!I){k.errorRecoveryDisabledLanes|=x,Gn|=x,o=4;break e}x=ba,ba=o,x!==null&&(ba===null?ba=x:ba.push.apply(ba,x))}o=v}if(x=!1,o!==2)continue}}if(o===1){Lr(s,0),un(s,t,0,!0);break}e:{switch(i=s,x=o,x){case 0:case 1:throw Error(c(345));case 4:if((t&4194048)!==t)break;case 6:un(i,t,Ra,!rn);break e;case 2:ba=null;break;case 3:case 5:break;default:throw Error(c(329))}if((t&62914560)===t&&(o=oo+300-Is(),10<o)){if(un(i,t,Ra,!rn),ca(i,0,!0)!==0)break e;Ol=t,i.timeoutHandle=sg(Sp.bind(null,i,n,ba,mo,Ju,t,Ra,Gn,Dr,rn,x,"Throttled",-0,0),o);break e}Sp(i,n,ba,mo,Ju,t,Ra,Gn,Dr,rn,x,null,-0,0)}}break}while(!0);pl(s)}function Sp(s,t,n,i,o,x,v,k,I,ie,ve,ye,de,he){if(s.timeoutHandle=-1,ye=t.subtreeFlags,ye&8192||(ye&16785408)===16785408){ye={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Nl},gp(t,x,ye);var Ve=(x&62914560)===x?oo-Is():(x&4194048)===x?bp-Is():0;if(Ve=G0(ye,Ve),Ve!==null){Ol=x,s.cancelPendingCommit=Ve(Rp.bind(null,s,t,x,n,i,o,v,k,I,ve,ye,null,de,he)),un(s,x,v,!ie);return}}Rp(s,t,x,n,i,o,v,k,I)}function c0(s){for(var t=s;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var i=0;i<n.length;i++){var o=n[i],x=o.getSnapshot;o=o.value;try{if(!Ta(x(),o))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;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 un(s,t,n,i){t&=~Yu,t&=~Gn,s.suspendedLanes|=t,s.pingedLanes&=~t,i&&(s.warmLanes|=t),i=s.expirationTimes;for(var o=t;0<o;){var x=31-ys(o),v=1<<x;i[x]=-1,o&=~v}n!==0&&as(s,n,t)}function xo(){return(Js&6)===0?(Ui(0),!1):!0}function em(){if(zs!==null){if(Ws===0)var s=zs.return;else s=zs,_l=Un=null,pu(s),kr=null,vi=0,s=zs;for(;s!==null;)tp(s.alternate,s),s=s.return;zs=null}}function Lr(s,t){var n=s.timeoutHandle;n!==-1&&(s.timeoutHandle=-1,T0(n)),n=s.cancelPendingCommit,n!==null&&(s.cancelPendingCommit=null,n()),Ol=0,em(),xt=s,zs=n=yl(s.current,null),Os=t,Ws=0,za=null,rn=!1,Rr=Fa(s,t),Qu=!1,Dr=Ra=Yu=Gn=cn=Mt=0,ba=Oi=null,Ju=!1,(t&8)!==0&&(t|=t&32);var i=s.entangledLanes;if(i!==0)for(s=s.entanglements,i&=t;0<i;){var o=31-ys(i),x=1<<o;t|=s[o],i&=~x}return Dl=t,Rc(),n}function kp(s,t){ws=null,D.H=Ci,t===Sr||t===Pc?(t=Ph(),Ws=3):t===lu?(t=Ph(),Ws=4):Ws=t===zu?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,za=t,zs===null&&(Mt=1,so(s,Ga(t,s.current)))}function Cp(){var s=Ma.current;return s===null?!0:(Os&4194048)===Os?Ja===null:(Os&62914560)===Os||(Os&536870912)!==0?s===Ja:!1}function Tp(){var s=D.H;return D.H=Ci,s===null?Ci:s}function Ep(){var s=D.A;return D.A=r0,s}function ho(){Mt=4,rn||(Os&4194048)!==Os&&Ma.current!==null||(Rr=!0),(cn&134217727)===0&&(Gn&134217727)===0||xt===null||un(xt,Os,Ra,!1)}function sm(s,t,n){var i=Js;Js|=2;var o=Tp(),x=Ep();(xt!==s||Os!==t)&&(mo=null,Lr(s,t)),t=!1;var v=Mt;e:do try{if(Ws!==0&&zs!==null){var k=zs,I=za;switch(Ws){case 8:em(),v=6;break e;case 3:case 2:case 9:case 6:Ma.current===null&&(t=!0);var ie=Ws;if(Ws=0,za=null,Ur(s,k,I,ie),n&&Rr){v=0;break e}break;default:ie=Ws,Ws=0,za=null,Ur(s,k,I,ie)}}o0(),v=Mt;break}catch(ve){kp(s,ve)}while(!0);return t&&s.shellSuspendCounter++,_l=Un=null,Js=i,D.H=o,D.A=x,zs===null&&(xt=null,Os=0,Rc()),v}function o0(){for(;zs!==null;)Mp(zs)}function d0(s,t){var n=Js;Js|=2;var i=Tp(),o=Ep();xt!==s||Os!==t?(mo=null,uo=Is()+500,Lr(s,t)):Rr=Fa(s,t);e:do try{if(Ws!==0&&zs!==null){t=zs;var x=za;s:switch(Ws){case 1:Ws=0,za=null,Ur(s,t,x,1);break;case 2:case 9:if(Bh(x)){Ws=0,za=null,Ap(t);break}t=function(){Ws!==2&&Ws!==9||xt!==s||(Ws=7),pl(s)},x.then(t,t);break e;case 3:Ws=7;break e;case 4:Ws=5;break e;case 7:Bh(x)?(Ws=0,za=null,Ap(t)):(Ws=0,za=null,Ur(s,t,x,7));break;case 5:var v=null;switch(zs.tag){case 26:v=zs.memoizedState;case 5:case 27:var k=zs;if(v?pg(v):k.stateNode.complete){Ws=0,za=null;var I=k.sibling;if(I!==null)zs=I;else{var ie=k.return;ie!==null?(zs=ie,fo(ie)):zs=null}break s}}Ws=0,za=null,Ur(s,t,x,5);break;case 6:Ws=0,za=null,Ur(s,t,x,6);break;case 8:em(),Mt=6;break e;default:throw Error(c(462))}}u0();break}catch(ve){kp(s,ve)}while(!0);return _l=Un=null,D.H=i,D.A=o,Js=n,zs!==null?0:(xt=null,Os=0,Rc(),Mt)}function u0(){for(;zs!==null&&!ia();)Mp(zs)}function Mp(s){var t=ep(s.alternate,s,Dl);s.memoizedProps=s.pendingProps,t===null?fo(s):zs=t}function Ap(s){var t=s,n=t.alternate;switch(t.tag){case 15:case 0:t=Qf(n,t,t.pendingProps,t.type,void 0,Os);break;case 11:t=Qf(n,t,t.pendingProps,t.type.render,t.ref,Os);break;case 5:pu(t);default:tp(n,t),t=zs=Th(t,Dl),t=ep(n,t,Dl)}s.memoizedProps=s.pendingProps,t===null?fo(s):zs=t}function Ur(s,t,n,i){_l=Un=null,pu(t),kr=null,vi=0;var o=t.return;try{if(Wy(s,o,t,n,Os)){Mt=1,so(s,Ga(n,s.current)),zs=null;return}}catch(x){if(o!==null)throw zs=o,x;Mt=1,so(s,Ga(n,s.current)),zs=null;return}t.flags&32768?(Us||i===1?s=!0:Rr||(Os&536870912)!==0?s=!1:(rn=s=!0,(i===2||i===9||i===3||i===6)&&(i=Ma.current,i!==null&&i.tag===13&&(i.flags|=16384))),zp(t,s)):fo(t)}function fo(s){var t=s;do{if((t.flags&32768)!==0){zp(t,rn);return}s=t.return;var n=t0(t.alternate,t,Dl);if(n!==null){zs=n;return}if(t=t.sibling,t!==null){zs=t;return}zs=t=s}while(t!==null);Mt===0&&(Mt=5)}function zp(s,t){do{var n=a0(s.alternate,s);if(n!==null){n.flags&=32767,zs=n;return}if(n=s.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(s=s.sibling,s!==null)){zs=s;return}zs=s=n}while(s!==null);Mt=6,zs=null}function Rp(s,t,n,i,o,x,v,k,I){s.cancelPendingCommit=null;do po();while(qt!==0);if((Js&6)!==0)throw Error(c(327));if(t!==null){if(t===s.current)throw Error(c(177));if(x=t.lanes|t.childLanes,x|=Hd,Se(s,n,x,v,k,I),s===xt&&(zs=xt=null,Os=0),Or=t,dn=s,Ol=n,Xu=x,Zu=o,yp=i,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,f0(Je,function(){return $p(),null})):(s.callbackNode=null,s.callbackPriority=0),i=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||i){i=D.T,D.T=null,o=Q.p,Q.p=2,v=Js,Js|=4;try{l0(s,t,n)}finally{Js=v,Q.p=o,D.T=i}}qt=1,Dp(),Op(),Lp()}}function Dp(){if(qt===1){qt=0;var s=dn,t=Or,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=D.T,D.T=null;var i=Q.p;Q.p=2;var o=Js;Js|=4;try{hp(t,s);var x=xm,v=vh(s.containerInfo),k=x.focusedElem,I=x.selectionRange;if(v!==k&&k&&k.ownerDocument&&jh(k.ownerDocument.documentElement,k)){if(I!==null&&$d(k)){var ie=I.start,ve=I.end;if(ve===void 0&&(ve=ie),"selectionStart"in k)k.selectionStart=ie,k.selectionEnd=Math.min(ve,k.value.length);else{var ye=k.ownerDocument||document,de=ye&&ye.defaultView||window;if(de.getSelection){var he=de.getSelection(),Ve=k.textContent.length,ls=Math.min(I.start,Ve),ot=I.end===void 0?ls:Math.min(I.end,Ve);!he.extend&&ls>ot&&(v=ot,ot=ls,ls=v);var ee=gh(k,ls),q=gh(k,ot);if(ee&&q&&(he.rangeCount!==1||he.anchorNode!==ee.node||he.anchorOffset!==ee.offset||he.focusNode!==q.node||he.focusOffset!==q.offset)){var re=ye.createRange();re.setStart(ee.node,ee.offset),he.removeAllRanges(),ls>ot?(he.addRange(re),he.extend(q.node,q.offset)):(re.setEnd(q.node,q.offset),he.addRange(re))}}}}for(ye=[],he=k;he=he.parentNode;)he.nodeType===1&&ye.push({element:he,left:he.scrollLeft,top:he.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;k<ye.length;k++){var be=ye[k];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}To=!!mm,xm=mm=null}finally{Js=o,Q.p=i,D.T=n}}s.current=t,qt=2}}function Op(){if(qt===2){qt=0;var s=dn,t=Or,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=D.T,D.T=null;var i=Q.p;Q.p=2;var o=Js;Js|=4;try{op(s,t.alternate,t)}finally{Js=o,Q.p=i,D.T=n}}qt=3}}function Lp(){if(qt===4||qt===3){qt=0,ut();var s=dn,t=Or,n=Ol,i=yp;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?qt=5:(qt=0,Or=dn=null,Up(s,s.pendingLanes));var o=s.pendingLanes;if(o===0&&(on=null),$s(n),t=t.stateNode,rs&&typeof rs.onCommitFiberRoot=="function")try{rs.onCommitFiberRoot(Cs,t,void 0,(t.current.flags&128)===128)}catch{}if(i!==null){t=D.T,o=Q.p,Q.p=2,D.T=null;try{for(var x=s.onRecoverableError,v=0;v<i.length;v++){var k=i[v];x(k.value,{componentStack:k.stack})}}finally{D.T=t,Q.p=o}}(Ol&3)!==0&&po(),pl(s),o=s.pendingLanes,(n&261930)!==0&&(o&42)!==0?s===Wu?Li++:(Li=0,Wu=s):Li=0,Ui(0)}}function Up(s,t){(s.pooledCacheLanes&=t)===0&&(t=s.pooledCache,t!=null&&(s.pooledCache=null,gi(t)))}function po(){return Dp(),Op(),Lp(),$p()}function $p(){if(qt!==5)return!1;var s=dn,t=Xu;Xu=0;var n=$s(Ol),i=D.T,o=Q.p;try{Q.p=32>n?32:n,D.T=null,n=Zu,Zu=null;var x=dn,v=Ol;if(qt=0,Or=dn=null,Ol=0,(Js&6)!==0)throw Error(c(331));var k=Js;if(Js|=4,vp(x.current),pp(x,x.current,v,n),Js=k,Ui(0,!1),rs&&typeof rs.onPostCommitFiberRoot=="function")try{rs.onPostCommitFiberRoot(Cs,x)}catch{}return!0}finally{Q.p=o,D.T=i,Up(s,t)}}function Bp(s,t,n){t=Ga(n,t),t=Au(s.stateNode,t,2),s=tn(s,t,2),s!==null&&(U(s,2),pl(s))}function et(s,t,n){if(s.tag===3)Bp(s,s,n);else for(;t!==null;){if(t.tag===3){Bp(t,s,n);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(on===null||!on.has(i))){s=Ga(n,s),n=If(2),i=tn(t,n,2),i!==null&&(Pf(n,i,t,s),U(i,2),pl(i));break}}t=t.return}}function tm(s,t,n){var i=s.pingCache;if(i===null){i=s.pingCache=new i0;var o=new Set;i.set(t,o)}else o=i.get(t),o===void 0&&(o=new Set,i.set(t,o));o.has(n)||(Qu=!0,o.add(n),s=m0.bind(null,s,t,n),t.then(s,s))}function m0(s,t,n){var i=s.pingCache;i!==null&&i.delete(t),s.pingedLanes|=s.suspendedLanes&n,s.warmLanes&=~n,xt===s&&(Os&n)===n&&(Mt===4||Mt===3&&(Os&62914560)===Os&&300>Is()-oo?(Js&2)===0&&Lr(s,0):Yu|=n,Dr===Os&&(Dr=0)),pl(s)}function Ip(s,t){t===0&&(t=te()),s=Dn(s,t),s!==null&&(U(s,t),pl(s))}function x0(s){var t=s.memoizedState,n=0;t!==null&&(n=t.retryLane),Ip(s,n)}function h0(s,t){var n=0;switch(s.tag){case 31:case 13:var i=s.stateNode,o=s.memoizedState;o!==null&&(n=o.retryLane);break;case 19:i=s.stateNode;break;case 22:i=s.stateNode._retryCache;break;default:throw Error(c(314))}i!==null&&i.delete(t),Ip(s,n)}function f0(s,t){return Ts(s,t)}var go=null,$r=null,am=!1,jo=!1,lm=!1,mn=0;function pl(s){s!==$r&&s.next===null&&($r===null?go=$r=s:$r=$r.next=s),jo=!0,am||(am=!0,g0())}function Ui(s,t){if(!lm&&jo){lm=!0;do for(var n=!1,i=go;i!==null;){if(s!==0){var o=i.pendingLanes;if(o===0)var x=0;else{var v=i.suspendedLanes,k=i.pingedLanes;x=(1<<31-ys(42|s)+1)-1,x&=o&~(v&~k),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(n=!0,qp(i,x))}else x=Os,x=ca(i,i===xt?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(x&3)===0||Fa(i,x)||(n=!0,qp(i,x));i=i.next}while(n);lm=!1}}function p0(){Pp()}function Pp(){jo=am=!1;var s=0;mn!==0&&C0()&&(s=mn);for(var t=Is(),n=null,i=go;i!==null;){var o=i.next,x=Fp(i,t);x===0?(i.next=null,n===null?go=o:n.next=o,o===null&&($r=n)):(n=i,(s!==0||(x&3)!==0)&&(jo=!0)),i=o}qt!==0&&qt!==5||Ui(s),mn!==0&&(mn=0)}function Fp(s,t){for(var n=s.suspendedLanes,i=s.pingedLanes,o=s.expirationTimes,x=s.pendingLanes&-62914561;0<x;){var v=31-ys(x),k=1<<v,I=o[v];I===-1?((k&n)===0||(k&i)!==0)&&(o[v]=Xt(k,t)):I<=t&&(s.expiredLanes|=k),x&=~k}if(t=xt,n=Os,n=ca(s,s===t?n:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),i=s.callbackNode,n===0||s===t&&(Ws===2||Ws===9)||s.cancelPendingCommit!==null)return i!==null&&i!==null&&kt(i),s.callbackNode=null,s.callbackPriority=0;if((n&3)===0||Fa(s,n)){if(t=n&-n,t===s.callbackPriority)return t;switch(i!==null&&kt(i),$s(n)){case 2:case 8:n=He;break;case 32:n=Je;break;case 268435456:n=ms;break;default:n=Je}return i=Hp.bind(null,s),n=Ts(n,i),s.callbackPriority=t,s.callbackNode=n,t}return i!==null&&i!==null&&kt(i),s.callbackPriority=2,s.callbackNode=null,2}function Hp(s,t){if(qt!==0&&qt!==5)return s.callbackNode=null,s.callbackPriority=0,null;var n=s.callbackNode;if(po()&&s.callbackNode!==n)return null;var i=Os;return i=ca(s,s===xt?i:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),i===0?null:(_p(s,i,t),Fp(s,Is()),s.callbackNode!=null&&s.callbackNode===n?Hp.bind(null,s):null)}function qp(s,t){if(po())return null;_p(s,t,!0)}function g0(){E0(function(){(Js&6)!==0?Ts(Ke,p0):Pp()})}function nm(){if(mn===0){var s=wr;s===0&&(s=Qe,Qe<<=1,(Qe&261888)===0&&(Qe=256)),mn=s}return mn}function Vp(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:Sc(""+s)}function Gp(s,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,s.id&&n.setAttribute("form",s.id),t.parentNode.insertBefore(n,t),s=new FormData(s),n.parentNode.removeChild(n),s}function j0(s,t,n,i,o){if(t==="submit"&&n&&n.stateNode===o){var x=Vp((o[qe]||null).action),v=i.submitter;v&&(t=(t=v[qe]||null)?Vp(t.formAction):v.getAttribute("formAction"),t!==null&&(x=t,v=null));var k=new Ec("action","action",null,i,o);s.push({event:k,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(mn!==0){var I=v?Gp(o,v):new FormData(o);Su(n,{pending:!0,data:I,method:o.method,action:x},null,I)}}else typeof x=="function"&&(k.preventDefault(),I=v?Gp(o,v):new FormData(o),Su(n,{pending:!0,data:I,method:o.method,action:x},x,I))},currentTarget:o}]})}}for(var rm=0;rm<Fd.length;rm++){var im=Fd[rm],v0=im.toLowerCase(),N0=im[0].toUpperCase()+im.slice(1);nl(v0,"on"+N0)}nl(yh,"onAnimationEnd"),nl(wh,"onAnimationIteration"),nl(_h,"onAnimationStart"),nl("dblclick","onDoubleClick"),nl("focusin","onFocus"),nl("focusout","onBlur"),nl(Ly,"onTransitionRun"),nl(Uy,"onTransitionStart"),nl($y,"onTransitionCancel"),nl(Sh,"onTransitionEnd"),or("onMouseEnter",["mouseout","mouseover"]),or("onMouseLeave",["mouseout","mouseover"]),or("onPointerEnter",["pointerout","pointerover"]),or("onPointerLeave",["pointerout","pointerover"]),Mn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Mn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Mn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Mn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Mn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Mn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var $i="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(" "),b0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat($i));function Kp(s,t){t=(t&4)!==0;for(var n=0;n<s.length;n++){var i=s[n],o=i.event;i=i.listeners;e:{var x=void 0;if(t)for(var v=i.length-1;0<=v;v--){var k=i[v],I=k.instance,ie=k.currentTarget;if(k=k.listener,I!==x&&o.isPropagationStopped())break e;x=k,o.currentTarget=ie;try{x(o)}catch(ve){zc(ve)}o.currentTarget=null,x=I}else for(v=0;v<i.length;v++){if(k=i[v],I=k.instance,ie=k.currentTarget,k=k.listener,I!==x&&o.isPropagationStopped())break e;x=k,o.currentTarget=ie;try{x(o)}catch(ve){zc(ve)}o.currentTarget=null,x=I}}}}function Rs(s,t){var n=t[Ps];n===void 0&&(n=t[Ps]=new Set);var i=s+"__bubble";n.has(i)||(Qp(t,s,2,!1),n.add(i))}function cm(s,t,n){var i=0;t&&(i|=4),Qp(n,s,i,t)}var vo="_reactListening"+Math.random().toString(36).slice(2);function om(s){if(!s[vo]){s[vo]=!0,Ix.forEach(function(n){n!=="selectionchange"&&(b0.has(n)||cm(n,!1,s),cm(n,!0,s))});var t=s.nodeType===9?s:s.ownerDocument;t===null||t[vo]||(t[vo]=!0,cm("selectionchange",!1,t))}}function Qp(s,t,n,i){switch(wg(t)){case 2:var o=Y0;break;case 8:o=J0;break;default:o=_m}n=o.bind(null,t,n,s),o=void 0,!Ed||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),i?o!==void 0?s.addEventListener(t,n,{capture:!0,passive:o}):s.addEventListener(t,n,!0):o!==void 0?s.addEventListener(t,n,{passive:o}):s.addEventListener(t,n,!1)}function dm(s,t,n,i,o){var x=i;if((t&1)===0&&(t&2)===0&&i!==null)e:for(;;){if(i===null)return;var v=i.tag;if(v===3||v===4){var k=i.stateNode.containerInfo;if(k===o)break;if(v===4)for(v=i.return;v!==null;){var I=v.tag;if((I===3||I===4)&&v.stateNode.containerInfo===o)return;v=v.return}for(;k!==null;){if(v=Ql(k),v===null)return;if(I=v.tag,I===5||I===6||I===26||I===27){i=x=v;continue e}k=k.parentNode}}i=i.return}Zx(function(){var ie=x,ve=Cd(n),ye=[];e:{var de=kh.get(s);if(de!==void 0){var he=Ec,Ve=s;switch(s){case"keypress":if(Cc(n)===0)break e;case"keydown":case"keyup":he=hy;break;case"focusin":Ve="focus",he=Rd;break;case"focusout":Ve="blur",he=Rd;break;case"beforeblur":case"afterblur":he=Rd;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":he=sh;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":he=ty;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":he=gy;break;case yh:case wh:case _h:he=ny;break;case Sh:he=vy;break;case"scroll":case"scrollend":he=ey;break;case"wheel":he=by;break;case"copy":case"cut":case"paste":he=iy;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":he=ah;break;case"toggle":case"beforetoggle":he=wy}var ls=(t&4)!==0,ot=!ls&&(s==="scroll"||s==="scrollend"),ee=ls?de!==null?de+"Capture":null:de;ls=[];for(var q=ie,re;q!==null;){var be=q;if(re=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||re===null||ee===null||(be=ri(q,ee),be!=null&&ls.push(Bi(q,be,re))),ot)break;q=q.return}0<ls.length&&(de=new he(de,Ve,null,n,ve),ye.push({event:de,listeners:ls}))}}if((t&7)===0){e:{if(de=s==="mouseover"||s==="pointerover",he=s==="mouseout"||s==="pointerout",de&&n!==kd&&(Ve=n.relatedTarget||n.fromElement)&&(Ql(Ve)||Ve[Ys]))break e;if((he||de)&&(de=ve.window===ve?ve:(de=ve.ownerDocument)?de.defaultView||de.parentWindow:window,he?(Ve=n.relatedTarget||n.toElement,he=ie,Ve=Ve?Ql(Ve):null,Ve!==null&&(ot=m(Ve),ls=Ve.tag,Ve!==ot||ls!==5&&ls!==27&&ls!==6)&&(Ve=null)):(he=null,Ve=ie),he!==Ve)){if(ls=sh,be="onMouseLeave",ee="onMouseEnter",q="mouse",(s==="pointerout"||s==="pointerover")&&(ls=ah,be="onPointerLeave",ee="onPointerEnter",q="pointer"),ot=he==null?de:ni(he),re=Ve==null?de:ni(Ve),de=new ls(be,q+"leave",he,n,ve),de.target=ot,de.relatedTarget=re,be=null,Ql(ve)===ie&&(ls=new ls(ee,q+"enter",Ve,n,ve),ls.target=re,ls.relatedTarget=ot,be=ls),ot=be,he&&Ve)s:{for(ls=y0,ee=he,q=Ve,re=0,be=ee;be;be=ls(be))re++;be=0;for(var ss=q;ss;ss=ls(ss))be++;for(;0<re-be;)ee=ls(ee),re--;for(;0<be-re;)q=ls(q),be--;for(;re--;){if(ee===q||q!==null&&ee===q.alternate){ls=ee;break s}ee=ls(ee),q=ls(q)}ls=null}else ls=null;he!==null&&Yp(ye,de,he,ls,!1),Ve!==null&&ot!==null&&Yp(ye,ot,Ve,ls,!0)}}e:{if(de=ie?ni(ie):window,he=de.nodeName&&de.nodeName.toLowerCase(),he==="select"||he==="input"&&de.type==="file")var Gs=uh;else if(oh(de))if(mh)Gs=Ry;else{Gs=Ay;var Ye=My}else he=de.nodeName,!he||he.toLowerCase()!=="input"||de.type!=="checkbox"&&de.type!=="radio"?ie&&Sd(ie.elementType)&&(Gs=uh):Gs=zy;if(Gs&&(Gs=Gs(s,ie))){dh(ye,Gs,n,ve);break e}Ye&&Ye(s,de,ie),s==="focusout"&&ie&&de.type==="number"&&ie.memoizedProps.value!=null&&_d(de,"number",de.value)}switch(Ye=ie?ni(ie):window,s){case"focusin":(oh(Ye)||Ye.contentEditable==="true")&&(fr=Ye,Bd=ie,hi=null);break;case"focusout":hi=Bd=fr=null;break;case"mousedown":Id=!0;break;case"contextmenu":case"mouseup":case"dragend":Id=!1,Nh(ye,n,ve);break;case"selectionchange":if(Oy)break;case"keydown":case"keyup":Nh(ye,n,ve)}var _s;if(Od)e:{switch(s){case"compositionstart":var Ls="onCompositionStart";break e;case"compositionend":Ls="onCompositionEnd";break e;case"compositionupdate":Ls="onCompositionUpdate";break e}Ls=void 0}else hr?ih(s,n)&&(Ls="onCompositionEnd"):s==="keydown"&&n.keyCode===229&&(Ls="onCompositionStart");Ls&&(lh&&n.locale!=="ko"&&(hr||Ls!=="onCompositionStart"?Ls==="onCompositionEnd"&&hr&&(_s=Wx()):(Yl=ve,Md="value"in Yl?Yl.value:Yl.textContent,hr=!0)),Ye=No(ie,Ls),0<Ye.length&&(Ls=new th(Ls,s,null,n,ve),ye.push({event:Ls,listeners:Ye}),_s?Ls.data=_s:(_s=ch(n),_s!==null&&(Ls.data=_s)))),(_s=Sy?ky(s,n):Cy(s,n))&&(Ls=No(ie,"onBeforeInput"),0<Ls.length&&(Ye=new th("onBeforeInput","beforeinput",null,n,ve),ye.push({event:Ye,listeners:Ls}),Ye.data=_s)),j0(ye,s,ie,n,ve)}Kp(ye,t)})}function Bi(s,t,n){return{instance:s,listener:t,currentTarget:n}}function No(s,t){for(var n=t+"Capture",i=[];s!==null;){var o=s,x=o.stateNode;if(o=o.tag,o!==5&&o!==26&&o!==27||x===null||(o=ri(s,n),o!=null&&i.unshift(Bi(s,o,x)),o=ri(s,t),o!=null&&i.push(Bi(s,o,x))),s.tag===3)return i;s=s.return}return[]}function y0(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function Yp(s,t,n,i,o){for(var x=t._reactName,v=[];n!==null&&n!==i;){var k=n,I=k.alternate,ie=k.stateNode;if(k=k.tag,I!==null&&I===i)break;k!==5&&k!==26&&k!==27||ie===null||(I=ie,o?(ie=ri(n,x),ie!=null&&v.unshift(Bi(n,ie,I))):o||(ie=ri(n,x),ie!=null&&v.push(Bi(n,ie,I)))),n=n.return}v.length!==0&&s.push({event:t,listeners:v})}var w0=/\r\n?/g,_0=/\u0000|\uFFFD/g;function Jp(s){return(typeof s=="string"?s:""+s).replace(w0,`
|
||
`).replace(_0,"")}function Xp(s,t){return t=Jp(t),Jp(s)===t}function ct(s,t,n,i,o,x){switch(n){case"children":typeof i=="string"?t==="body"||t==="textarea"&&i===""||ur(s,i):(typeof i=="number"||typeof i=="bigint")&&t!=="body"&&ur(s,""+i);break;case"className":wc(s,"class",i);break;case"tabIndex":wc(s,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":wc(s,n,i);break;case"style":Jx(s,i,x);break;case"data":if(t!=="object"){wc(s,"data",i);break}case"src":case"href":if(i===""&&(t!=="a"||n!=="href")){s.removeAttribute(n);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){s.removeAttribute(n);break}i=Sc(""+i),s.setAttribute(n,i);break;case"action":case"formAction":if(typeof i=="function"){s.setAttribute(n,"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 x=="function"&&(n==="formAction"?(t!=="input"&&ct(s,t,"name",o.name,o,null),ct(s,t,"formEncType",o.formEncType,o,null),ct(s,t,"formMethod",o.formMethod,o,null),ct(s,t,"formTarget",o.formTarget,o,null)):(ct(s,t,"encType",o.encType,o,null),ct(s,t,"method",o.method,o,null),ct(s,t,"target",o.target,o,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){s.removeAttribute(n);break}i=Sc(""+i),s.setAttribute(n,i);break;case"onClick":i!=null&&(s.onclick=Nl);break;case"onScroll":i!=null&&Rs("scroll",s);break;case"onScrollEnd":i!=null&&Rs("scrollend",s);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(c(61));if(n=i.__html,n!=null){if(o.children!=null)throw Error(c(60));s.innerHTML=n}}break;case"multiple":s.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":s.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){s.removeAttribute("xlink:href");break}n=Sc(""+i),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?s.setAttribute(n,""+i):s.removeAttribute(n);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":i&&typeof i!="function"&&typeof i!="symbol"?s.setAttribute(n,""):s.removeAttribute(n);break;case"capture":case"download":i===!0?s.setAttribute(n,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?s.setAttribute(n,i):s.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?s.setAttribute(n,i):s.removeAttribute(n);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?s.removeAttribute(n):s.setAttribute(n,i);break;case"popover":Rs("beforetoggle",s),Rs("toggle",s),yc(s,"popover",i);break;case"xlinkActuate":vl(s,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":vl(s,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":vl(s,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":vl(s,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":vl(s,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":vl(s,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":vl(s,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":vl(s,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":vl(s,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":yc(s,"is",i);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=Zb.get(n)||n,yc(s,n,i))}}function um(s,t,n,i,o,x){switch(n){case"style":Jx(s,i,x);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(c(61));if(n=i.__html,n!=null){if(o.children!=null)throw Error(c(60));s.innerHTML=n}}break;case"children":typeof i=="string"?ur(s,i):(typeof i=="number"||typeof i=="bigint")&&ur(s,""+i);break;case"onScroll":i!=null&&Rs("scroll",s);break;case"onScrollEnd":i!=null&&Rs("scrollend",s);break;case"onClick":i!=null&&(s.onclick=Nl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Px.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(o=n.endsWith("Capture"),t=n.slice(2,o?n.length-7:void 0),x=s[qe]||null,x=x!=null?x[n]:null,typeof x=="function"&&s.removeEventListener(t,x,o),typeof i=="function")){typeof x!="function"&&x!==null&&(n in s?s[n]=null:s.hasAttribute(n)&&s.removeAttribute(n)),s.addEventListener(t,i,o);break e}n in s?s[n]=i:i===!0?s.setAttribute(n,""):yc(s,n,i)}}}function sa(s,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Rs("error",s),Rs("load",s);var i=!1,o=!1,x;for(x in n)if(n.hasOwnProperty(x)){var v=n[x];if(v!=null)switch(x){case"src":i=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:ct(s,t,x,v,n,null)}}o&&ct(s,t,"srcSet",n.srcSet,n,null),i&&ct(s,t,"src",n.src,n,null);return;case"input":Rs("invalid",s);var k=x=v=o=null,I=null,ie=null;for(i in n)if(n.hasOwnProperty(i)){var ve=n[i];if(ve!=null)switch(i){case"name":o=ve;break;case"type":v=ve;break;case"checked":I=ve;break;case"defaultChecked":ie=ve;break;case"value":x=ve;break;case"defaultValue":k=ve;break;case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(c(137,t));break;default:ct(s,t,i,ve,n,null)}}Gx(s,x,k,I,ie,v,o,!1);return;case"select":Rs("invalid",s),i=v=x=null;for(o in n)if(n.hasOwnProperty(o)&&(k=n[o],k!=null))switch(o){case"value":x=k;break;case"defaultValue":v=k;break;case"multiple":i=k;default:ct(s,t,o,k,n,null)}t=x,n=v,s.multiple=!!i,t!=null?dr(s,!!i,t,!1):n!=null&&dr(s,!!i,n,!0);return;case"textarea":Rs("invalid",s),x=o=i=null;for(v in n)if(n.hasOwnProperty(v)&&(k=n[v],k!=null))switch(v){case"value":i=k;break;case"defaultValue":o=k;break;case"children":x=k;break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(c(91));break;default:ct(s,t,v,k,n,null)}Qx(s,i,o,x);return;case"option":for(I in n)if(n.hasOwnProperty(I)&&(i=n[I],i!=null))switch(I){case"selected":s.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:ct(s,t,I,i,n,null)}return;case"dialog":Rs("beforetoggle",s),Rs("toggle",s),Rs("cancel",s),Rs("close",s);break;case"iframe":case"object":Rs("load",s);break;case"video":case"audio":for(i=0;i<$i.length;i++)Rs($i[i],s);break;case"image":Rs("error",s),Rs("load",s);break;case"details":Rs("toggle",s);break;case"embed":case"source":case"link":Rs("error",s),Rs("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(ie in n)if(n.hasOwnProperty(ie)&&(i=n[ie],i!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:ct(s,t,ie,i,n,null)}return;default:if(Sd(t)){for(ve in n)n.hasOwnProperty(ve)&&(i=n[ve],i!==void 0&&um(s,t,ve,i,n,void 0));return}}for(k in n)n.hasOwnProperty(k)&&(i=n[k],i!=null&&ct(s,t,k,i,n,null))}function S0(s,t,n,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,x=null,v=null,k=null,I=null,ie=null,ve=null;for(he in n){var ye=n[he];if(n.hasOwnProperty(he)&&ye!=null)switch(he){case"checked":break;case"value":break;case"defaultValue":I=ye;default:i.hasOwnProperty(he)||ct(s,t,he,null,i,ye)}}for(var de in i){var he=i[de];if(ye=n[de],i.hasOwnProperty(de)&&(he!=null||ye!=null))switch(de){case"type":x=he;break;case"name":o=he;break;case"checked":ie=he;break;case"defaultChecked":ve=he;break;case"value":v=he;break;case"defaultValue":k=he;break;case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(c(137,t));break;default:he!==ye&&ct(s,t,de,he,i,ye)}}wd(s,v,k,I,ie,ve,x,o);return;case"select":he=v=k=de=null;for(x in n)if(I=n[x],n.hasOwnProperty(x)&&I!=null)switch(x){case"value":break;case"multiple":he=I;default:i.hasOwnProperty(x)||ct(s,t,x,null,i,I)}for(o in i)if(x=i[o],I=n[o],i.hasOwnProperty(o)&&(x!=null||I!=null))switch(o){case"value":de=x;break;case"defaultValue":k=x;break;case"multiple":v=x;default:x!==I&&ct(s,t,o,x,i,I)}t=k,n=v,i=he,de!=null?dr(s,!!n,de,!1):!!i!=!!n&&(t!=null?dr(s,!!n,t,!0):dr(s,!!n,n?[]:"",!1));return;case"textarea":he=de=null;for(k in n)if(o=n[k],n.hasOwnProperty(k)&&o!=null&&!i.hasOwnProperty(k))switch(k){case"value":break;case"children":break;default:ct(s,t,k,null,i,o)}for(v in i)if(o=i[v],x=n[v],i.hasOwnProperty(v)&&(o!=null||x!=null))switch(v){case"value":de=o;break;case"defaultValue":he=o;break;case"children":break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(c(91));break;default:o!==x&&ct(s,t,v,o,i,x)}Kx(s,de,he);return;case"option":for(var Ve in n)if(de=n[Ve],n.hasOwnProperty(Ve)&&de!=null&&!i.hasOwnProperty(Ve))switch(Ve){case"selected":s.selected=!1;break;default:ct(s,t,Ve,null,i,de)}for(I in i)if(de=i[I],he=n[I],i.hasOwnProperty(I)&&de!==he&&(de!=null||he!=null))switch(I){case"selected":s.selected=de&&typeof de!="function"&&typeof de!="symbol";break;default:ct(s,t,I,de,i,he)}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 ls in n)de=n[ls],n.hasOwnProperty(ls)&&de!=null&&!i.hasOwnProperty(ls)&&ct(s,t,ls,null,i,de);for(ie in i)if(de=i[ie],he=n[ie],i.hasOwnProperty(ie)&&de!==he&&(de!=null||he!=null))switch(ie){case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(c(137,t));break;default:ct(s,t,ie,de,i,he)}return;default:if(Sd(t)){for(var ot in n)de=n[ot],n.hasOwnProperty(ot)&&de!==void 0&&!i.hasOwnProperty(ot)&&um(s,t,ot,void 0,i,de);for(ve in i)de=i[ve],he=n[ve],!i.hasOwnProperty(ve)||de===he||de===void 0&&he===void 0||um(s,t,ve,de,i,he);return}}for(var ee in n)de=n[ee],n.hasOwnProperty(ee)&&de!=null&&!i.hasOwnProperty(ee)&&ct(s,t,ee,null,i,de);for(ye in i)de=i[ye],he=n[ye],!i.hasOwnProperty(ye)||de===he||de==null&&he==null||ct(s,t,ye,de,i,he)}function Zp(s){switch(s){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function k0(){if(typeof performance.getEntriesByType=="function"){for(var s=0,t=0,n=performance.getEntriesByType("resource"),i=0;i<n.length;i++){var o=n[i],x=o.transferSize,v=o.initiatorType,k=o.duration;if(x&&k&&Zp(v)){for(v=0,k=o.responseEnd,i+=1;i<n.length;i++){var I=n[i],ie=I.startTime;if(ie>k)break;var ve=I.transferSize,ye=I.initiatorType;ve&&Zp(ye)&&(I=I.responseEnd,v+=ve*(I<k?1:(k-ie)/(I-ie)))}if(--i,t+=8*(x+v)/(o.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 mm=null,xm=null;function bo(s){return s.nodeType===9?s:s.ownerDocument}function Wp(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 eg(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 hm(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 fm=null;function C0(){var s=window.event;return s&&s.type==="popstate"?s===fm?!1:(fm=s,!0):(fm=null,!1)}var sg=typeof setTimeout=="function"?setTimeout:void 0,T0=typeof clearTimeout=="function"?clearTimeout:void 0,tg=typeof Promise=="function"?Promise:void 0,E0=typeof queueMicrotask=="function"?queueMicrotask:typeof tg<"u"?function(s){return tg.resolve(null).then(s).catch(M0)}:sg;function M0(s){setTimeout(function(){throw s})}function xn(s){return s==="head"}function ag(s,t){var n=t,i=0;do{var o=n.nextSibling;if(s.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"||n==="/&"){if(i===0){s.removeChild(o),Fr(t);return}i--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")i++;else if(n==="html")Ii(s.ownerDocument.documentElement);else if(n==="head"){n=s.ownerDocument.head,Ii(n);for(var x=n.firstChild;x;){var v=x.nextSibling,k=x.nodeName;x[ml]||k==="SCRIPT"||k==="STYLE"||k==="LINK"&&x.rel.toLowerCase()==="stylesheet"||n.removeChild(x),x=v}}else n==="body"&&Ii(s.ownerDocument.body);n=o}while(n);Fr(t)}function lg(s,t){var n=s;s=0;do{var i=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(s===0)break;s--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||s++;n=i}while(n)}function pm(s){var t=s.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":pm(n),rr(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}s.removeChild(n)}}function A0(s,t,n,i){for(;s.nodeType===1;){var o=n;if(s.nodeName.toLowerCase()!==t.toLowerCase()){if(!i&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(i){if(!s[ml])switch(t){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(x=s.getAttribute("rel"),x==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(x!==o.rel||s.getAttribute("href")!==(o.href==null||o.href===""?null:o.href)||s.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin)||s.getAttribute("title")!==(o.title==null?null:o.title))break;return s;case"style":if(s.hasAttribute("data-precedence"))break;return s;case"script":if(x=s.getAttribute("src"),(x!==(o.src==null?null:o.src)||s.getAttribute("type")!==(o.type==null?null:o.type)||s.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin))&&x&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(t==="input"&&s.type==="hidden"){var x=o.name==null?null:""+o.name;if(o.type==="hidden"&&s.getAttribute("name")===x)return s}else return s;if(s=Xa(s.nextSibling),s===null)break}return null}function z0(s,t,n){if(t==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!n||(s=Xa(s.nextSibling),s===null))return null;return s}function ng(s,t){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!t||(s=Xa(s.nextSibling),s===null))return null;return s}function gm(s){return s.data==="$?"||s.data==="$~"}function jm(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function R0(s,t){var n=s.ownerDocument;if(s.data==="$~")s._reactRetry=t;else if(s.data!=="$?"||n.readyState!=="loading")t();else{var i=function(){t(),n.removeEventListener("DOMContentLoaded",i)};n.addEventListener("DOMContentLoaded",i),s._reactRetry=i}}function Xa(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 vm=null;function rg(s){s=s.nextSibling;for(var t=0;s;){if(s.nodeType===8){var n=s.data;if(n==="/$"||n==="/&"){if(t===0)return Xa(s.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}s=s.nextSibling}return null}function ig(s){s=s.previousSibling;for(var t=0;s;){if(s.nodeType===8){var n=s.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return s;t--}else n!=="/$"&&n!=="/&"||t++}s=s.previousSibling}return null}function cg(s,t,n){switch(t=bo(n),s){case"html":if(s=t.documentElement,!s)throw Error(c(452));return s;case"head":if(s=t.head,!s)throw Error(c(453));return s;case"body":if(s=t.body,!s)throw Error(c(454));return s;default:throw Error(c(451))}}function Ii(s){for(var t=s.attributes;t.length;)s.removeAttributeNode(t[0]);rr(s)}var Za=new Map,og=new Set;function yo(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var Ll=Q.d;Q.d={f:D0,r:O0,D:L0,C:U0,L:$0,m:B0,X:P0,S:I0,M:F0};function D0(){var s=Ll.f(),t=xo();return s||t}function O0(s){var t=ir(s);t!==null&&t.tag===5&&t.type==="form"?kf(t):Ll.r(s)}var Br=typeof document>"u"?null:document;function dg(s,t,n){var i=Br;if(i&&typeof t=="string"&&t){var o=qa(t);o='link[rel="'+s+'"][href="'+o+'"]',typeof n=="string"&&(o+='[crossorigin="'+n+'"]'),og.has(o)||(og.add(o),s={rel:s,crossOrigin:n,href:t},i.querySelector(o)===null&&(t=i.createElement("link"),sa(t,"link",s),Kt(t),i.head.appendChild(t)))}}function L0(s){Ll.D(s),dg("dns-prefetch",s,null)}function U0(s,t){Ll.C(s,t),dg("preconnect",s,t)}function $0(s,t,n){Ll.L(s,t,n);var i=Br;if(i&&s&&t){var o='link[rel="preload"][as="'+qa(t)+'"]';t==="image"&&n&&n.imageSrcSet?(o+='[imagesrcset="'+qa(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(o+='[imagesizes="'+qa(n.imageSizes)+'"]')):o+='[href="'+qa(s)+'"]';var x=o;switch(t){case"style":x=Ir(s);break;case"script":x=Pr(s)}Za.has(x)||(s=j({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:s,as:t},n),Za.set(x,s),i.querySelector(o)!==null||t==="style"&&i.querySelector(Pi(x))||t==="script"&&i.querySelector(Fi(x))||(t=i.createElement("link"),sa(t,"link",s),Kt(t),i.head.appendChild(t)))}}function B0(s,t){Ll.m(s,t);var n=Br;if(n&&s){var i=t&&typeof t.as=="string"?t.as:"script",o='link[rel="modulepreload"][as="'+qa(i)+'"][href="'+qa(s)+'"]',x=o;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Pr(s)}if(!Za.has(x)&&(s=j({rel:"modulepreload",href:s},t),Za.set(x,s),n.querySelector(o)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(Fi(x)))return}i=n.createElement("link"),sa(i,"link",s),Kt(i),n.head.appendChild(i)}}}function I0(s,t,n){Ll.S(s,t,n);var i=Br;if(i&&s){var o=cr(i).hoistableStyles,x=Ir(s);t=t||"default";var v=o.get(x);if(!v){var k={loading:0,preload:null};if(v=i.querySelector(Pi(x)))k.loading=5;else{s=j({rel:"stylesheet",href:s,"data-precedence":t},n),(n=Za.get(x))&&Nm(s,n);var I=v=i.createElement("link");Kt(I),sa(I,"link",s),I._p=new Promise(function(ie,ve){I.onload=ie,I.onerror=ve}),I.addEventListener("load",function(){k.loading|=1}),I.addEventListener("error",function(){k.loading|=2}),k.loading|=4,wo(v,t,i)}v={type:"stylesheet",instance:v,count:1,state:k},o.set(x,v)}}}function P0(s,t){Ll.X(s,t);var n=Br;if(n&&s){var i=cr(n).hoistableScripts,o=Pr(s),x=i.get(o);x||(x=n.querySelector(Fi(o)),x||(s=j({src:s,async:!0},t),(t=Za.get(o))&&bm(s,t),x=n.createElement("script"),Kt(x),sa(x,"link",s),n.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(o,x))}}function F0(s,t){Ll.M(s,t);var n=Br;if(n&&s){var i=cr(n).hoistableScripts,o=Pr(s),x=i.get(o);x||(x=n.querySelector(Fi(o)),x||(s=j({src:s,async:!0,type:"module"},t),(t=Za.get(o))&&bm(s,t),x=n.createElement("script"),Kt(x),sa(x,"link",s),n.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(o,x))}}function ug(s,t,n,i){var o=(o=A.current)?yo(o):null;if(!o)throw Error(c(446));switch(s){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=Ir(n.href),n=cr(o).hoistableStyles,i=n.get(t),i||(i={type:"style",instance:null,count:0,state:null},n.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){s=Ir(n.href);var x=cr(o).hoistableStyles,v=x.get(s);if(v||(o=o.ownerDocument||o,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(s,v),(x=o.querySelector(Pi(s)))&&!x._p&&(v.instance=x,v.state.loading=5),Za.has(s)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Za.set(s,n),x||H0(o,s,n,v.state))),t&&i===null)throw Error(c(528,""));return v}if(t&&i!==null)throw Error(c(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Pr(n),n=cr(o).hoistableScripts,i=n.get(t),i||(i={type:"script",instance:null,count:0,state:null},n.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(c(444,s))}}function Ir(s){return'href="'+qa(s)+'"'}function Pi(s){return'link[rel="stylesheet"]['+s+"]"}function mg(s){return j({},s,{"data-precedence":s.precedence,precedence:null})}function H0(s,t,n,i){s.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=s.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),sa(t,"link",n),Kt(t),s.head.appendChild(t))}function Pr(s){return'[src="'+qa(s)+'"]'}function Fi(s){return"script[async]"+s}function xg(s,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var i=s.querySelector('style[data-href~="'+qa(n.href)+'"]');if(i)return t.instance=i,Kt(i),i;var o=j({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return i=(s.ownerDocument||s).createElement("style"),Kt(i),sa(i,"style",o),wo(i,n.precedence,s),t.instance=i;case"stylesheet":o=Ir(n.href);var x=s.querySelector(Pi(o));if(x)return t.state.loading|=4,t.instance=x,Kt(x),x;i=mg(n),(o=Za.get(o))&&Nm(i,o),x=(s.ownerDocument||s).createElement("link"),Kt(x);var v=x;return v._p=new Promise(function(k,I){v.onload=k,v.onerror=I}),sa(x,"link",i),t.state.loading|=4,wo(x,n.precedence,s),t.instance=x;case"script":return x=Pr(n.src),(o=s.querySelector(Fi(x)))?(t.instance=o,Kt(o),o):(i=n,(o=Za.get(x))&&(i=j({},n),bm(i,o)),s=s.ownerDocument||s,o=s.createElement("script"),Kt(o),sa(o,"link",i),s.head.appendChild(o),t.instance=o);case"void":return null;default:throw Error(c(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,wo(i,n.precedence,s));return t.instance}function wo(s,t,n){for(var i=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),o=i.length?i[i.length-1]:null,x=o,v=0;v<i.length;v++){var k=i[v];if(k.dataset.precedence===t)x=k;else if(x!==o)break}x?x.parentNode.insertBefore(s,x.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(s,t.firstChild))}function Nm(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.title==null&&(s.title=t.title)}function bm(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.integrity==null&&(s.integrity=t.integrity)}var _o=null;function hg(s,t,n){if(_o===null){var i=new Map,o=_o=new Map;o.set(n,i)}else o=_o,i=o.get(n),i||(i=new Map,o.set(n,i));if(i.has(s))return i;for(i.set(s,null),n=n.getElementsByTagName(s),o=0;o<n.length;o++){var x=n[o];if(!(x[ml]||x[oe]||s==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var v=x.getAttribute(t)||"";v=s+v;var k=i.get(v);k?k.push(x):i.set(v,[x])}}return i}function fg(s,t,n){s=s.ownerDocument||s,s.head.insertBefore(n,t==="title"?s.querySelector("head > title"):null)}function q0(s,t,n){if(n===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 pg(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function V0(s,t,n,i){if(n.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var o=Ir(i.href),x=t.querySelector(Pi(o));if(x){t=x._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(s.count++,s=So.bind(s),t.then(s,s)),n.state.loading|=4,n.instance=x,Kt(x);return}x=t.ownerDocument||t,i=mg(i),(o=Za.get(o))&&Nm(i,o),x=x.createElement("link"),Kt(x);var v=x;v._p=new Promise(function(k,I){v.onload=k,v.onerror=I}),sa(x,"link",i),n.instance=x}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(s.count++,n=So.bind(s),t.addEventListener("load",n),t.addEventListener("error",n))}}var ym=0;function G0(s,t){return s.stylesheets&&s.count===0&&Co(s,s.stylesheets),0<s.count||0<s.imgCount?function(n){var i=setTimeout(function(){if(s.stylesheets&&Co(s,s.stylesheets),s.unsuspend){var x=s.unsuspend;s.unsuspend=null,x()}},6e4+t);0<s.imgBytes&&ym===0&&(ym=62500*k0());var o=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&Co(s,s.stylesheets),s.unsuspend)){var x=s.unsuspend;s.unsuspend=null,x()}},(s.imgBytes>ym?50:800)+t);return s.unsuspend=n,function(){s.unsuspend=null,clearTimeout(i),clearTimeout(o)}}:null}function So(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Co(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var ko=null;function Co(s,t){s.stylesheets=null,s.unsuspend!==null&&(s.count++,ko=new Map,t.forEach(K0,s),ko=null,So.call(s))}function K0(s,t){if(!(t.state.loading&4)){var n=ko.get(s);if(n)var i=n.get(null);else{n=new Map,ko.set(s,n);for(var o=s.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<o.length;x++){var v=o[x];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(n.set(v.dataset.precedence,v),i=v)}i&&n.set(null,i)}o=t.instance,v=o.getAttribute("data-precedence"),x=n.get(v)||i,x===i&&n.set(null,o),n.set(v,o),this.count++,i=So.bind(this),o.addEventListener("load",i),o.addEventListener("error",i),x?x.parentNode.insertBefore(o,x.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(o,s.firstChild)),t.state.loading|=4}}var Hi={$$typeof:E,Provider:null,Consumer:null,_currentValue:B,_currentValue2:B,_threadCount:0};function Q0(s,t,n,i,o,x,v,k,I){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=_e(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_e(0),this.hiddenUpdates=_e(null),this.identifierPrefix=i,this.onUncaughtError=o,this.onCaughtError=x,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=I,this.incompleteTransitions=new Map}function gg(s,t,n,i,o,x,v,k,I,ie,ve,ye){return s=new Q0(s,t,n,v,I,ie,ve,ye,k),t=1,x===!0&&(t|=24),x=Ea(3,null,null,t),s.current=x,x.stateNode=s,t=su(),t.refCount++,s.pooledCache=t,t.refCount++,x.memoizedState={element:i,isDehydrated:n,cache:t},nu(x),s}function jg(s){return s?(s=jr,s):jr}function vg(s,t,n,i,o,x){o=jg(o),i.context===null?i.context=o:i.pendingContext=o,i=sn(t),i.payload={element:n},x=x===void 0?null:x,x!==null&&(i.callback=x),n=tn(s,i,t),n!==null&&(ya(n,s,t),bi(n,s,t))}function Ng(s,t){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var n=s.retryLane;s.retryLane=n!==0&&n<t?n:t}}function wm(s,t){Ng(s,t),(s=s.alternate)&&Ng(s,t)}function bg(s){if(s.tag===13||s.tag===31){var t=Dn(s,67108864);t!==null&&ya(t,s,67108864),wm(s,67108864)}}function yg(s){if(s.tag===13||s.tag===31){var t=Da();t=Ct(t);var n=Dn(s,t);n!==null&&ya(n,s,t),wm(s,t)}}var To=!0;function Y0(s,t,n,i){var o=D.T;D.T=null;var x=Q.p;try{Q.p=2,_m(s,t,n,i)}finally{Q.p=x,D.T=o}}function J0(s,t,n,i){var o=D.T;D.T=null;var x=Q.p;try{Q.p=8,_m(s,t,n,i)}finally{Q.p=x,D.T=o}}function _m(s,t,n,i){if(To){var o=Sm(i);if(o===null)dm(s,t,i,Eo,n),_g(s,i);else if(Z0(o,s,t,n,i))i.stopPropagation();else if(_g(s,i),t&4&&-1<X0.indexOf(s)){for(;o!==null;){var x=ir(o);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var v=Ht(x.pendingLanes);if(v!==0){var k=x;for(k.pendingLanes|=2,k.entangledLanes|=2;v;){var I=1<<31-ys(v);k.entanglements[1]|=I,v&=~I}pl(x),(Js&6)===0&&(uo=Is()+500,Ui(0))}}break;case 31:case 13:k=Dn(x,2),k!==null&&ya(k,x,2),xo(),wm(x,2)}if(x=Sm(i),x===null&&dm(s,t,i,Eo,n),x===o)break;o=x}o!==null&&i.stopPropagation()}else dm(s,t,i,null,n)}}function Sm(s){return s=Cd(s),km(s)}var Eo=null;function km(s){if(Eo=null,s=Ql(s),s!==null){var t=m(s);if(t===null)s=null;else{var n=t.tag;if(n===13){if(s=h(t),s!==null)return s;s=null}else if(n===31){if(s=f(t),s!==null)return s;s=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;s=null}else t!==s&&(s=null)}}return Eo=s,null}function wg(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(V()){case Ke:return 2;case He:return 8;case Je:case Es:return 32;case ms:return 268435456;default:return 32}default:return 32}}var Cm=!1,hn=null,fn=null,pn=null,qi=new Map,Vi=new Map,gn=[],X0="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 _g(s,t){switch(s){case"focusin":case"focusout":hn=null;break;case"dragenter":case"dragleave":fn=null;break;case"mouseover":case"mouseout":pn=null;break;case"pointerover":case"pointerout":qi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vi.delete(t.pointerId)}}function Gi(s,t,n,i,o,x){return s===null||s.nativeEvent!==x?(s={blockedOn:t,domEventName:n,eventSystemFlags:i,nativeEvent:x,targetContainers:[o]},t!==null&&(t=ir(t),t!==null&&bg(t)),s):(s.eventSystemFlags|=i,t=s.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),s)}function Z0(s,t,n,i,o){switch(t){case"focusin":return hn=Gi(hn,s,t,n,i,o),!0;case"dragenter":return fn=Gi(fn,s,t,n,i,o),!0;case"mouseover":return pn=Gi(pn,s,t,n,i,o),!0;case"pointerover":var x=o.pointerId;return qi.set(x,Gi(qi.get(x)||null,s,t,n,i,o)),!0;case"gotpointercapture":return x=o.pointerId,Vi.set(x,Gi(Vi.get(x)||null,s,t,n,i,o)),!0}return!1}function Sg(s){var t=Ql(s.target);if(t!==null){var n=m(t);if(n!==null){if(t=n.tag,t===13){if(t=h(n),t!==null){s.blockedOn=t,oa(s.priority,function(){yg(n)});return}}else if(t===31){if(t=f(n),t!==null){s.blockedOn=t,oa(s.priority,function(){yg(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){s.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Mo(s){if(s.blockedOn!==null)return!1;for(var t=s.targetContainers;0<t.length;){var n=Sm(s.nativeEvent);if(n===null){n=s.nativeEvent;var i=new n.constructor(n.type,n);kd=i,n.target.dispatchEvent(i),kd=null}else return t=ir(n),t!==null&&bg(t),s.blockedOn=n,!1;t.shift()}return!0}function kg(s,t,n){Mo(s)&&n.delete(t)}function W0(){Cm=!1,hn!==null&&Mo(hn)&&(hn=null),fn!==null&&Mo(fn)&&(fn=null),pn!==null&&Mo(pn)&&(pn=null),qi.forEach(kg),Vi.forEach(kg)}function Ao(s,t){s.blockedOn===t&&(s.blockedOn=null,Cm||(Cm=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,W0)))}var zo=null;function Cg(s){zo!==s&&(zo=s,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){zo===s&&(zo=null);for(var t=0;t<s.length;t+=3){var n=s[t],i=s[t+1],o=s[t+2];if(typeof i!="function"){if(km(i||n)===null)continue;break}var x=ir(n);x!==null&&(s.splice(t,3),t-=3,Su(x,{pending:!0,data:o,method:n.method,action:i},i,o))}}))}function Fr(s){function t(I){return Ao(I,s)}hn!==null&&Ao(hn,s),fn!==null&&Ao(fn,s),pn!==null&&Ao(pn,s),qi.forEach(t),Vi.forEach(t);for(var n=0;n<gn.length;n++){var i=gn[n];i.blockedOn===s&&(i.blockedOn=null)}for(;0<gn.length&&(n=gn[0],n.blockedOn===null);)Sg(n),n.blockedOn===null&&gn.shift();if(n=(s.ownerDocument||s).$$reactFormReplay,n!=null)for(i=0;i<n.length;i+=3){var o=n[i],x=n[i+1],v=o[qe]||null;if(typeof x=="function")v||Cg(n);else if(v){var k=null;if(x&&x.hasAttribute("formAction")){if(o=x,v=x[qe]||null)k=v.formAction;else if(km(o)!==null)continue}else k=v.action;typeof k=="function"?n[i+1]=k:(n.splice(i,3),i-=3),Cg(n)}}}function Tg(){function s(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(v){return o=v})},focusReset:"manual",scroll:"manual"})}function t(){o!==null&&(o(),o=null),i||setTimeout(n,20)}function n(){if(!i&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,o=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){i=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),o!==null&&(o(),o=null)}}}function Tm(s){this._internalRoot=s}Ro.prototype.render=Tm.prototype.render=function(s){var t=this._internalRoot;if(t===null)throw Error(c(409));var n=t.current,i=Da();vg(n,i,s,t,null,null)},Ro.prototype.unmount=Tm.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var t=s.containerInfo;vg(s.current,2,null,s,null,null),xo(),t[Ys]=null}};function Ro(s){this._internalRoot=s}Ro.prototype.unstable_scheduleHydration=function(s){if(s){var t=pa();s={blockedOn:null,target:s,priority:t};for(var n=0;n<gn.length&&t!==0&&t<gn[n].priority;n++);gn.splice(n,0,s),n===0&&Sg(s)}};var Eg=l.version;if(Eg!=="19.2.1")throw Error(c(527,Eg,"19.2.1"));Q.findDOMNode=function(s){var t=s._reactInternals;if(t===void 0)throw typeof s.render=="function"?Error(c(188)):(s=Object.keys(s).join(","),Error(c(268,s)));return s=g(t),s=s!==null?N(s):null,s=s===null?null:s.stateNode,s};var ew={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Do=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Do.isDisabled&&Do.supportsFiber)try{Cs=Do.inject(ew),rs=Do}catch{}}return Ki.createRoot=function(s,t){if(!d(s))throw Error(c(299));var n=!1,i="",o=Lf,x=Uf,v=$f;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(x=t.onCaughtError),t.onRecoverableError!==void 0&&(v=t.onRecoverableError)),t=gg(s,1,!1,null,null,n,i,null,o,x,v,Tg),s[Ys]=t.current,om(s),new Tm(t)},Ki.hydrateRoot=function(s,t,n){if(!d(s))throw Error(c(299));var i=!1,o="",x=Lf,v=Uf,k=$f,I=null;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(x=n.onUncaughtError),n.onCaughtError!==void 0&&(v=n.onCaughtError),n.onRecoverableError!==void 0&&(k=n.onRecoverableError),n.formState!==void 0&&(I=n.formState)),t=gg(s,1,!0,t,n??null,i,o,I,x,v,k,Tg),t.context=jg(null),n=t.current,i=Da(),i=Ct(i),o=sn(i),o.callback=null,tn(n,o,i),n=i,t.current.lanes=n,U(t,n),pl(t),s[Ys]=t.current,om(s),new Ro(t)},Ki.version="19.2.1",Ki}var Lg;function U_(){if(Lg)return Rm.exports;Lg=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(l){console.error(l)}}return a(),Rm.exports=L_(),Rm.exports}var $_=U_();function P(...a){return xw(hw(a))}const Te=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("rounded-xl border bg-card text-card-foreground shadow",a),...l}));Te.displayName="Card";const Oe=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("flex flex-col space-y-1.5 p-6",a),...l}));Oe.displayName="CardHeader";const Ue=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("font-semibold leading-none tracking-tight",a),...l}));Ue.displayName="CardTitle";const Ns=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("text-sm text-muted-foreground",a),...l}));Ns.displayName="CardDescription";const ze=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("p-6 pt-0",a),...l}));ze.displayName="CardContent";const od=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("flex items-center p-6 pt-0",a),...l}));od.displayName="CardFooter";const Jt=pw,Gt=u.forwardRef(({className:a,...l},r)=>e.jsx(hj,{ref:r,className:P("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",a),...l}));Gt.displayName=hj.displayName;const Xe=u.forwardRef(({className:a,...l},r)=>e.jsx(fj,{ref:r,className:P("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",a),...l}));Xe.displayName=fj.displayName;const Ss=u.forwardRef(({className:a,...l},r)=>e.jsx(pj,{ref:r,className:P("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",a),...l}));Ss.displayName=pj.displayName;const ts=u.forwardRef(({className:a,children:l,viewportRef:r,...c},d)=>e.jsxs(gj,{ref:d,className:P("relative overflow-hidden",a),...c,children:[e.jsx(gw,{ref:r,className:"h-full w-full rounded-[inherit]",children:l}),e.jsx(Xm,{}),e.jsx(Xm,{orientation:"horizontal"}),e.jsx(jw,{})]}));ts.displayName=gj.displayName;const Xm=u.forwardRef(({className:a,orientation:l="vertical",...r},c)=>e.jsx(jj,{ref:c,orientation:l,className:P("flex touch-none select-none transition-colors",l==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",l==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...r,children:e.jsx(vw,{className:"relative flex-1 rounded-full bg-border"})}));Xm.displayName=jj.displayName;function ks({className:a,...l}){return e.jsx("div",{className:P("animate-pulse rounded-md bg-primary/10",a),...l})}const tr=u.forwardRef(({className:a,value:l,...r},c)=>e.jsx(vj,{ref:c,className:P("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",a),...r,children:e.jsx(Nw,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(l||0)}%)`}})}));tr.displayName=vj.displayName;async function ke(a,l){const c=l?.body instanceof FormData?{...l?.headers}:{"Content-Type":"application/json",...l?.headers},d={...l,credentials:"include",headers:c},m=await fetch(a,d);if(m.status===401)throw window.location.href="/auth",new Error("认证失败,请重新登录");return m}function Zs(){return{"Content-Type":"application/json"}}async function B_(){try{await fetch("/api/webui/auth/logout",{method:"POST",credentials:"include"})}catch(a){console.error("登出请求失败:",a)}window.location.href="/auth"}async function dc(){try{return(await(await fetch("/api/webui/auth/check",{method:"GET",credentials:"include"})).json()).authenticated===!0}catch{return!1}}const I_={light:"",dark:".dark"},Mv=u.createContext(null);function Av(){const a=u.useContext(Mv);if(!a)throw new Error("useChart must be used within a <ChartContainer />");return a}const Kr=u.forwardRef(({id:a,className:l,children:r,config:c,...d},m)=>{const h=u.useId(),f=`chart-${a||h.replace(/:/g,"")}`;return e.jsx(Mv.Provider,{value:{config:c},children:e.jsxs("div",{"data-chart":f,ref:m,className:P("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",l),...d,children:[e.jsx(P_,{id:f,config:c}),e.jsx(Uj,{children:r})]})})});Kr.displayName="Chart";const P_=({id:a,config:l})=>{const r=Object.entries(l).filter(([,c])=>c.theme||c.color);return r.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(I_).map(([c,d])=>`
|
||
${d} [data-chart=${a}] {
|
||
${r.map(([m,h])=>{const f=h.theme?.[c]||h.color;return f?` --color-${m}: ${f};`:null}).join(`
|
||
`)}
|
||
}
|
||
`).join(`
|
||
`)}}):null},Qi=$j,Qr=u.forwardRef(({active:a,payload:l,className:r,indicator:c="dot",hideLabel:d=!1,hideIndicator:m=!1,label:h,labelFormatter:f,labelClassName:p,formatter:g,color:N,nameKey:j,labelKey:b},y)=>{const{config:w}=Av(),z=u.useMemo(()=>{if(d||!l?.length)return null;const[S]=l,F=`${b||S?.dataKey||S?.name||"value"}`,E=Zm(w,S,F),C=!b&&typeof h=="string"?w[h]?.label||h:E?.label;return f?e.jsx("div",{className:P("font-medium",p),children:f(C,l)}):C?e.jsx("div",{className:P("font-medium",p),children:C}):null},[h,f,l,d,p,w,b]);if(!a||!l?.length)return null;const M=l.length===1&&c!=="dot";return e.jsxs("div",{ref:y,className:P("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:[M?null:z,e.jsx("div",{className:"grid gap-1.5",children:l.filter(S=>S.type!=="none").map((S,F)=>{const E=`${j||S.name||S.dataKey||"value"}`,C=Zm(w,S,E),R=N||S.payload.fill||S.color;return e.jsx("div",{className:P("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",c==="dot"&&"items-center"),children:g&&S?.value!==void 0&&S.name?g(S.value,S.name,S,F,S.payload):e.jsxs(e.Fragment,{children:[C?.icon?e.jsx(C.icon,{}):!m&&e.jsx("div",{className:P("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":c==="dot","w-1":c==="line","w-0 border-[1.5px] border-dashed bg-transparent":c==="dashed","my-0.5":M&&c==="dashed"}),style:{"--color-bg":R,"--color-border":R}}),e.jsxs("div",{className:P("flex flex-1 justify-between leading-none",M?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[M?z:null,e.jsx("span",{className:"text-muted-foreground",children:C?.label||S.name})]}),S.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:S.value.toLocaleString()})]})]})},S.dataKey)})})]})});Qr.displayName="ChartTooltip";const F_=Zw,zv=u.forwardRef(({className:a,hideIcon:l=!1,payload:r,verticalAlign:c="bottom",nameKey:d},m)=>{const{config:h}=Av();return r?.length?e.jsx("div",{ref:m,className:P("flex items-center justify-center gap-4",c==="top"?"pb-3":"pt-3",a),children:r.filter(f=>f.type!=="none").map(f=>{const p=`${d||f.dataKey||"value"}`,g=Zm(h,f,p);return e.jsxs("div",{className:P("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[g?.icon&&!l?e.jsx(g.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:f.color}}),g?.label]},f.value)})}):null});zv.displayName="ChartLegend";function Zm(a,l,r){if(typeof l!="object"||l===null)return;const c="payload"in l&&typeof l.payload=="object"&&l.payload!==null?l.payload:void 0;let d=r;return r in l&&typeof l[r]=="string"?d=l[r]:c&&r in c&&typeof c[r]=="string"&&(d=c[r]),d in a?a[d]:a[r]}const si=ti("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"}}),_=u.forwardRef(({className:a,variant:l,size:r,asChild:c=!1,...d},m)=>{const h=c?l1:"button";return e.jsx(h,{className:P(si({variant:l,size:r,className:a})),ref:m,...d})});_.displayName="Button";const H_=ti("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 Ce({className:a,variant:l,...r}){return e.jsx("div",{className:P(H_({variant:l}),a),...r})}async function q_(){const a=await ke("/api/webui/system/restart",{method:"POST",headers:Zs()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"重启失败")}return await a.json()}async function V_(){const a=await ke("/api/webui/system/status",{method:"GET",headers:Zs()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取状态失败")}return await a.json()}const Hr={INITIAL_DELAY:3e3,CHECK_INTERVAL:2e3,CHECK_TIMEOUT:3e3,MAX_ATTEMPTS:60,PROGRESS_INTERVAL:200,SUCCESS_REDIRECT_DELAY:1500},Rv=u.createContext(null);function lr({children:a,onRestartComplete:l,onRestartFailed:r,healthCheckUrl:c="/api/webui/system/status",maxAttempts:d=Hr.MAX_ATTEMPTS}){const[m,h]=u.useState({status:"idle",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:d}),f=u.useRef({}),p=u.useCallback(()=>{const z=f.current;z.progress&&(clearInterval(z.progress),z.progress=void 0),z.elapsed&&(clearInterval(z.elapsed),z.elapsed=void 0),z.check&&(clearTimeout(z.check),z.check=void 0)},[]),g=u.useCallback(()=>{p(),h({status:"idle",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:d})},[p,d]),N=u.useCallback(async()=>{try{const z=new AbortController,M=setTimeout(()=>z.abort(),Hr.CHECK_TIMEOUT),S=await fetch(c,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include",signal:z.signal});return clearTimeout(M),S.ok}catch{return!1}},[c]),j=u.useCallback(()=>{let z=0;const M=async()=>{if(z++,h(F=>({...F,status:"checking",checkAttempts:z})),await N())p(),h(F=>({...F,status:"success",progress:100})),setTimeout(()=>{l?.(),window.location.href="/auth"},Hr.SUCCESS_REDIRECT_DELAY);else if(z>=d){p();const F=`健康检查超时 (${z}/${d})`;h(E=>({...E,status:"failed",error:F})),r?.(F)}else{const F=setTimeout(M,Hr.CHECK_INTERVAL);f.current.check=F}};M()},[N,p,d,l,r]),b=u.useCallback(()=>{h(z=>({...z,status:"checking",checkAttempts:0,error:void 0})),j()},[j]),y=u.useCallback(async z=>{const{delay:M=0,skipApiCall:S=!1}=z??{};if(m.status!=="idle"&&m.status!=="failed")return;if(p(),h({status:"requesting",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:d}),M>0&&await new Promise(C=>setTimeout(C,M)),S)h(C=>({...C,status:"restarting"}));else try{h(C=>({...C,status:"restarting"})),await Promise.race([q_(),new Promise(C=>setTimeout(C,5e3))])}catch{}const F=setInterval(()=>{h(C=>({...C,progress:C.progress>=90?C.progress:C.progress+1}))},Hr.PROGRESS_INTERVAL),E=setInterval(()=>{h(C=>({...C,elapsedTime:C.elapsedTime+1}))},1e3);f.current.progress=F,f.current.elapsed=E,setTimeout(()=>{j()},Hr.INITIAL_DELAY)},[m.status,p,d,j]),w={state:m,isRestarting:m.status!=="idle",triggerRestart:y,resetState:g,retryHealthCheck:b};return e.jsx(Rv.Provider,{value:w,children:a})}function Tn(){const a=u.useContext(Rv);if(!a)throw new Error("useRestart must be used within a RestartProvider");return a}function G_(){try{return Tn()}catch{return null}}const K_=(a,l,r,c,d)=>({idle:{icon:null,title:"",description:"",tip:""},requesting:{icon:e.jsx(Fs,{className:"h-16 w-16 text-primary animate-spin"}),title:c??"准备重启",description:d??"正在发送重启请求...",tip:"🔄 正在准备重启麦麦..."},restarting:{icon:e.jsx(Fs,{className:"h-16 w-16 text-primary animate-spin"}),title:c??"正在重启麦麦",description:d??"请稍候,麦麦正在重启中...",tip:"🔄 配置已保存,正在重启主程序..."},checking:{icon:e.jsx(Fs,{className:"h-16 w-16 text-primary animate-spin"}),title:"检查服务状态",description:`等待服务恢复... (${l}/${r})`,tip:"⏳ 正在等待服务恢复,请勿关闭页面..."},success:{icon:e.jsx(st,{className:"h-16 w-16 text-green-500"}),title:"重启成功",description:"正在跳转到登录页面...",tip:"✅ 配置已生效,服务运行正常"},failed:{icon:e.jsx(Rt,{className:"h-16 w-16 text-destructive"}),title:"重启超时",description:"服务未能在预期时间内恢复",tip:"⚠️ 如果长时间无响应,请尝试手动重启"}})[a];function nr({visible:a,onComplete:l,onFailed:r,title:c,description:d,showAnimation:m=!0,className:h}){const f=G_();return(f?f.isRestarting:a)?f?e.jsx(Dv,{state:f.state,onRetry:f.retryHealthCheck,onComplete:l,onFailed:r,title:c,description:d,showAnimation:m,className:h}):e.jsx(Q_,{onComplete:l,onFailed:r,title:c,description:d,showAnimation:m,className:h}):null}function Dv({state:a,onRetry:l,onComplete:r,onFailed:c,title:d,description:m,showAnimation:h,className:f}){const{status:p,progress:g,elapsedTime:N,checkAttempts:j,maxAttempts:b}=a;u.useEffect(()=>{p==="success"&&r?r():p==="failed"&&c&&c()},[p,r,c]);const y=K_(p,j,b,d,m),w=z=>{const M=Math.floor(z/60),S=z%60;return`${M}:${S.toString().padStart(2,"0")}`};return e.jsxs("div",{className:P("fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center",f),children:[h&&e.jsx(Y_,{}),e.jsxs("div",{className:"max-w-md w-full mx-4 space-y-8 relative z-10",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[e.jsxs("div",{className:"relative",children:[y.icon,(p==="restarting"||p==="checking")&&e.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),e.jsx("h2",{className:"text-2xl font-bold",children:y.title}),e.jsx("p",{className:"text-muted-foreground text-center",children:y.description})]}),p!=="failed"&&p!=="idle"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(tr,{value:g,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[g,"%"]}),e.jsxs("span",{children:["已用时: ",w(N)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:y.tip})}),p==="failed"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(_,{onClick:()=>window.location.reload(),variant:"default",className:"flex-1",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(_,{onClick:l,variant:"secondary",className:"flex-1",children:[e.jsx(rc,{className:"mr-2 h-4 w-4"}),"重试检测"]})]})]})]})}function Q_({onComplete:a,onFailed:l,title:r,description:c,showAnimation:d,className:m}){const[h,f]=u.useState({status:"restarting",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:60}),p=u.useCallback(()=>{let g=0;const N=60,j=async()=>{g++,f(b=>({...b,status:"checking",checkAttempts:g}));try{if((await fetch("/api/webui/system/status",{method:"GET",signal:AbortSignal.timeout(3e3)})).ok){f(y=>({...y,status:"success",progress:100})),setTimeout(()=>{a?.(),window.location.href="/auth"},1500);return}}catch{}g>=N?(f(b=>({...b,status:"failed"})),l?.()):setTimeout(j,2e3)};j()},[a,l]);return u.useEffect(()=>{const g=setInterval(()=>{f(b=>({...b,progress:b.progress>=90?b.progress:b.progress+1}))},200),N=setInterval(()=>{f(b=>({...b,elapsedTime:b.elapsedTime+1}))},1e3),j=setTimeout(()=>{p()},3e3);return()=>{clearInterval(g),clearInterval(N),clearTimeout(j)}},[p]),e.jsx(Dv,{state:h,onRetry:p,onComplete:a,onFailed:l,title:r,description:c,showAnimation:d,className:m})}function Y_(){return e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsxs("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px]",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-primary/10 animate-[ping_3s_ease-in-out_infinite]"}),e.jsx("div",{className:"absolute inset-8 rounded-full border border-primary/10 animate-[ping_3s_ease-in-out_infinite_0.5s]"}),e.jsx("div",{className:"absolute inset-16 rounded-full border border-primary/10 animate-[ping_3s_ease-in-out_infinite_1s]"})]}),e.jsx("div",{className:"absolute top-1/4 left-1/4 w-2 h-2 bg-primary/20 rounded-full animate-bounce"}),e.jsx("div",{className:"absolute top-3/4 right-1/4 w-3 h-3 bg-primary/15 rounded-full animate-bounce delay-150"}),e.jsx("div",{className:"absolute top-1/2 right-1/3 w-2 h-2 bg-primary/20 rounded-full animate-bounce delay-300"})]})}const Qs=i1,dd=c1,J_=n1,Ov=u.forwardRef(({className:a,...l},r)=>e.jsx(Bj,{ref:r,className:P("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",a),...l}));Ov.displayName=Bj.displayName;const Hs=u.forwardRef(({className:a,children:l,preventOutsideClose:r=!1,hideCloseButton:c=!1,...d},m)=>e.jsxs(J_,{children:[e.jsx(Ov,{}),e.jsxs(Ij,{ref:m,className:P("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",a),onPointerDownOutside:r?h=>h.preventDefault():void 0,onInteractOutside:r?h=>h.preventDefault():void 0,...d,children:[l,!c&&e.jsxs(r1,{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(Sa,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Hs.displayName=Ij.displayName;const qs=({className:a,...l})=>e.jsx("div",{className:P("flex flex-col space-y-1.5 text-center sm:text-left",a),...l});qs.displayName="DialogHeader";const gt=({className:a,...l})=>e.jsx("div",{className:P("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...l});gt.displayName="DialogFooter";const Vs=u.forwardRef(({className:a,...l},r)=>e.jsx(Pj,{ref:r,className:P("text-lg font-semibold leading-none tracking-tight",a),...l}));Vs.displayName=Pj.displayName;const at=u.forwardRef(({className:a,...l},r)=>e.jsx(Fj,{ref:r,className:P("text-sm text-muted-foreground",a),...l}));at.displayName=Fj.displayName;const ne=u.forwardRef(({className:a,type:l,...r},c)=>e.jsx("input",{type:l,className:P("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",a),ref:c,...r}));ne.displayName="Input";const tt=u.forwardRef(({className:a,...l},r)=>e.jsx(Hj,{ref:r,className:P("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",a),...l,children:e.jsx(o1,{className:P("grid place-content-center text-current"),children:e.jsx(Lt,{className:"h-4 w-4"})})}));tt.displayName=Hj.displayName;const Pe=f1,Fe=p1,Be=u.forwardRef(({className:a,children:l,...r},c)=>e.jsxs(qj,{ref:c,className:P("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",a),...r,children:[l,e.jsx(d1,{asChild:!0,children:e.jsx(Ba,{className:"h-4 w-4 opacity-50"})})]}));Be.displayName=qj.displayName;const Lv=u.forwardRef(({className:a,...l},r)=>e.jsx(Vj,{ref:r,className:P("flex cursor-default items-center justify-center py-1",a),...l,children:e.jsx(Xr,{className:"h-4 w-4"})}));Lv.displayName=Vj.displayName;const Uv=u.forwardRef(({className:a,...l},r)=>e.jsx(Gj,{ref:r,className:P("flex cursor-default items-center justify-center py-1",a),...l,children:e.jsx(Ba,{className:"h-4 w-4"})}));Uv.displayName=Gj.displayName;const Ie=u.forwardRef(({className:a,children:l,position:r="popper",...c},d)=>e.jsx(u1,{children:e.jsxs(Kj,{ref:d,className:P("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",a),position:r,...c,children:[e.jsx(Lv,{}),e.jsx(m1,{className:P("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:l}),e.jsx(Uv,{})]})}));Ie.displayName=Kj.displayName;const X_=u.forwardRef(({className:a,...l},r)=>e.jsx(Qj,{ref:r,className:P("px-2 py-1.5 text-sm font-semibold",a),...l}));X_.displayName=Qj.displayName;const W=u.forwardRef(({className:a,children:l,...r},c)=>e.jsxs(Yj,{ref:c,className:P("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",a),...r,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(x1,{children:e.jsx(Lt,{className:"h-4 w-4"})})}),e.jsx(h1,{children:l})]}));W.displayName=Yj.displayName;const Z_=u.forwardRef(({className:a,...l},r)=>e.jsx(Jj,{ref:r,className:P("-mx-1 my-1 h-px bg-muted",a),...l}));Z_.displayName=Jj.displayName;const fx=({className:a,...l})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:P("mx-auto flex w-full justify-center",a),...l});fx.displayName="Pagination";const px=u.forwardRef(({className:a,...l},r)=>e.jsx("ul",{ref:r,className:P("flex flex-row items-center gap-1",a),...l}));px.displayName="PaginationContent";const Xn=u.forwardRef(({className:a,...l},r)=>e.jsx("li",{ref:r,className:P("",a),...l}));Xn.displayName="PaginationItem";const jc=({className:a,isActive:l,size:r="icon",...c})=>e.jsx("a",{"aria-current":l?"page":void 0,className:P(si({variant:l?"outline":"ghost",size:r}),a),...c});jc.displayName="PaginationLink";const $v=({className:a,...l})=>e.jsxs(jc,{"aria-label":"Go to previous page",size:"default",className:P("gap-1 pl-2.5",a),...l,children:[e.jsx(Pa,{className:"h-4 w-4"}),e.jsx("span",{children:"上一页"})]});$v.displayName="PaginationPrevious";const Bv=({className:a,...l})=>e.jsxs(jc,{"aria-label":"Go to next page",size:"default",className:P("gap-1 pr-2.5",a),...l,children:[e.jsx("span",{children:"下一页"}),e.jsx(ra,{className:"h-4 w-4"})]});Bv.displayName="PaginationNext";const Iv=({className:a,...l})=>e.jsxs("span",{"aria-hidden":!0,className:P("flex h-9 w-9 items-center justify-center",a),...l,children:[e.jsx(C1,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});Iv.displayName="PaginationEllipsis";const W_=5,e2=5e3;let Lm=0;function s2(){return Lm=(Lm+1)%Number.MAX_SAFE_INTEGER,Lm.toString()}const Um=new Map,Ug=a=>{if(Um.has(a))return;const l=setTimeout(()=>{Um.delete(a),ac({type:"REMOVE_TOAST",toastId:a})},e2);Um.set(a,l)},t2=(a,l)=>{switch(l.type){case"ADD_TOAST":return{...a,toasts:[l.toast,...a.toasts].slice(0,W_)};case"UPDATE_TOAST":return{...a,toasts:a.toasts.map(r=>r.id===l.toast.id?{...r,...l.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=l;return r?Ug(r):a.toasts.forEach(c=>{Ug(c.id)}),{...a,toasts:a.toasts.map(c=>c.id===r||r===void 0?{...c,open:!1}:c)}}case"REMOVE_TOAST":return l.toastId===void 0?{...a,toasts:[]}:{...a,toasts:a.toasts.filter(r=>r.id!==l.toastId)}}},Fo=[];let Ho={toasts:[]};function ac(a){Ho=t2(Ho,a),Fo.forEach(l=>{l(Ho)})}function aa({...a}){const l=s2(),r=d=>ac({type:"UPDATE_TOAST",toast:{...d,id:l}}),c=()=>ac({type:"DISMISS_TOAST",toastId:l});return ac({type:"ADD_TOAST",toast:{...a,id:l,open:!0,onOpenChange:d=>{d||c()}}}),{id:l,dismiss:c,update:r}}function nt(){const[a,l]=u.useState(Ho);return u.useEffect(()=>(Fo.push(l),()=>{const r=Fo.indexOf(l);r>-1&&Fo.splice(r,1)}),[a]),{...a,toast:aa,dismiss:r=>ac({type:"DISMISS_TOAST",toastId:r})}}const dl="/api/webui/expression";async function gx(){const a=await ke(`${dl}/chats`,{});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取聊天列表失败")}return a.json()}async function a2(a){const l=new URLSearchParams;a.page&&l.append("page",a.page.toString()),a.page_size&&l.append("page_size",a.page_size.toString()),a.search&&l.append("search",a.search),a.chat_id&&l.append("chat_id",a.chat_id);const r=await ke(`${dl}/list?${l}`,{});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取表达方式列表失败")}return r.json()}async function l2(a){const l=await ke(`${dl}/${a}`,{});if(!l.ok){const r=await l.json();throw new Error(r.detail||"获取表达方式详情失败")}return l.json()}async function n2(a){const l=await ke(`${dl}/`,{method:"POST",body:JSON.stringify(a)});if(!l.ok){const r=await l.json();throw new Error(r.detail||"创建表达方式失败")}return l.json()}async function r2(a,l){const r=await ke(`${dl}/${a}`,{method:"PATCH",body:JSON.stringify(l)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"更新表达方式失败")}return r.json()}async function i2(a){const l=await ke(`${dl}/${a}`,{method:"DELETE"});if(!l.ok){const r=await l.json();throw new Error(r.detail||"删除表达方式失败")}return l.json()}async function c2(a){const l=await ke(`${dl}/batch/delete`,{method:"POST",body:JSON.stringify({ids:a})});if(!l.ok){const r=await l.json();throw new Error(r.detail||"批量删除表达方式失败")}return l.json()}async function o2(){const a=await ke(`${dl}/stats/summary`,{});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取统计数据失败")}return a.json()}async function jx(){const a=await ke(`${dl}/review/stats`);if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取审核统计失败")}return a.json()}async function $g(a){const l=new URLSearchParams;a.page&&l.append("page",a.page.toString()),a.page_size&&l.append("page_size",a.page_size.toString()),a.filter_type&&l.append("filter_type",a.filter_type),a.search&&l.append("search",a.search),a.chat_id&&l.append("chat_id",a.chat_id);const r=await ke(`${dl}/review/list?${l}`);if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取审核列表失败")}return r.json()}async function $m(a){const l=await ke(`${dl}/review/batch`,{method:"POST",body:JSON.stringify({items:a})});if(!l.ok){const r=await l.json();throw new Error(r.detail||"批量审核失败")}return l.json()}function Pv({open:a,onOpenChange:l}){const[r,c]=u.useState("list"),[d,m]=u.useState(null),[h,f]=u.useState([]),[p,g]=u.useState("unchecked"),[N,j]=u.useState([]),[b,y]=u.useState(0),[w,z]=u.useState(!1),[M,S]=u.useState(0),[F,E]=u.useState(1),[C,R]=u.useState(null),[H,O]=u.useState(0),[X,L]=u.useState(!1),[me,Ne]=u.useState(null),je=u.useRef(null),ce=u.useRef(null),ge=u.useRef(!1),[pe,D]=u.useState(!1),[Q,B]=u.useState(!1),[ue,Y]=u.useState(0),[we,fe]=u.useState(1),[Ee,G]=u.useState(20),[$,A]=u.useState(""),[K,Re]=u.useState("unchecked"),[se,$e]=u.useState(""),[cs,J]=u.useState(""),[Z,Le]=u.useState(new Set),[le,De]=u.useState(new Set),[xe,Me]=u.useState(new Map),{toast:ds}=nt(),Ts=u.useCallback(async()=>{try{B(!0);const U=await jx();m(U)}catch(U){console.error("加载统计失败:",U)}finally{B(!1)}},[]),kt=u.useCallback(async()=>{try{D(!0);const U=await $g({page:we,page_size:Ee,filter_type:K,search:se||void 0});f(U.data),Y(U.total)}catch(U){ds({title:"加载失败",description:U instanceof Error?U.message:"无法加载列表",variant:"destructive"})}finally{D(!1)}},[we,Ee,K,se,ds]),ia=u.useCallback(async()=>{try{const U=await gx();if(U?.data){const Se=new Map;U.data.forEach(as=>{Se.set(as.chat_id,as.chat_name)}),Me(Se)}}catch(U){console.error("加载聊天名称失败:",U)}},[]),ut=u.useCallback(async(U=!0,Se=!1)=>{try{z(!0);const as=Se?F+1:F,us=await $g({page:as,page_size:20,filter_type:p});Se?(j(es=>[...es,...us.data]),E(as)):j(us.data),S(us.total),U&&y(0)}catch(as){ds({title:"加载失败",description:as instanceof Error?as.message:"无法加载列表",variant:"destructive"})}finally{z(!1)}},[F,p,ds]);u.useEffect(()=>{r==="quick"&&(E(1),y(0))},[p,r]),u.useEffect(()=>{a&&r==="quick"&&(ut(),Ts())},[a,r,F,p,ut,Ts]);const Is=u.useCallback(U=>U?p==="unchecked"?{left:!0,right:!0}:p==="passed"?{left:!0,right:!1}:p==="rejected"?{left:!1,right:!0}:U.checked?U.rejected?{left:!1,right:!0}:{left:!0,right:!1}:{left:!0,right:!0}:{left:!1,right:!1},[p]),V=u.useCallback(async U=>{const Se=N[b];if(!Se||X)return;const as=Is(Se);if(!(U&&!as.left||!U&&!as.right)){L(!0),R(U?"left":"right"),O(U?-400:400);try{(await $m([{id:Se.id,rejected:U,require_unchecked:p==="unchecked"}])).results[0]?.success?(ds({title:U?"已拒绝":"已通过",description:`表达方式 #${Se.id} ${U?"已拒绝":"已通过"}`}),setTimeout(()=>{j(es=>es.filter((Ct,$s)=>$s!==b)),S(es=>es-1),b>=N.length-1&&y(Math.max(0,b-1)),R(null),O(0),L(!1),Ts(),N.length<=1&&M>1&&ut(!1)},300)):(Ne(Se.id),ds({title:"数据冲突",description:"该条目已被后台任务处理,正在刷新数据...",variant:"destructive"}),setTimeout(()=>{Ne(null),R(null),O(0),L(!1),ut(!1),Ts()},1500))}catch(us){ds({title:"操作失败",description:us instanceof Error?us.message:"未知错误",variant:"destructive"}),R(null),O(0),L(!1)}}},[N,b,X,Is,p,ds,Ts,M,ut]),Ke=u.useCallback((U,Se)=>{X||(ce.current={x:U,y:Se},ge.current=!1)},[X]),He=u.useCallback(U=>{X||(L(!0),O(U==="left"?-30:30),setTimeout(()=>{O(0),setTimeout(()=>L(!1),300)},150))},[X]),Je=u.useCallback(U=>{if(!ce.current||X)return;const Se=U-ce.current.x,as=N[b],us=Is(as);if(Se<0&&!us.left){O(Se*.2),R(null);return}if(Se>0&&!us.right){O(Se*.2),R(null);return}ge.current=!0,O(Se),Math.abs(Se)>50?R(Se>0?"right":"left"):R(null)},[N,b,Is,X]),Es=u.useCallback(()=>{if(!ce.current)return;Math.abs(H)>100&&C?V(C==="left"):(O(0),R(null)),ce.current=null,ge.current=!1},[H,C,V]),ms=u.useCallback(U=>{Ke(U.clientX,U.clientY)},[Ke]),Ms=u.useCallback(U=>{ce.current&&(U.preventDefault(),Je(U.clientX))},[Je]),We=u.useCallback(()=>{Es()},[Es]),Cs=u.useCallback(()=>{ce.current&&Es()},[Es]),rs=u.useCallback(U=>{const Se=U.touches[0];Ke(Se.clientX,Se.clientY)},[Ke]),is=u.useCallback(U=>{const Se=U.touches[0];Je(Se.clientX)},[Je]),ys=u.useCallback(()=>{Es()},[Es]);u.useEffect(()=>{if(!a||r!=="quick")return;const U=Se=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Se.key)||(Se.preventDefault(),Se.stopPropagation(),Se.stopImmediatePropagation(),X||w))return;const as=N[b],us=Is(as);Se.key==="ArrowLeft"?us.left?V(!0):He("left"):Se.key==="ArrowRight"?us.right?V(!1):He("right"):Se.key==="ArrowDown"?b<N.length-1&&y(es=>es+1):Se.key==="ArrowUp"&&b>0&&y(es=>es-1)};return window.addEventListener("keydown",U,!0),()=>window.removeEventListener("keydown",U,!0)},[a,r,N,b,X,w,Is,V,He]),u.useEffect(()=>{if(!a||r!=="quick"||w)return;const U=N.length-b-1,Se=N.length<M;U<=5&&Se&&ut(!1,!0)},[a,r,b,N.length,M,w,ut]),u.useEffect(()=>{a&&(Ts(),kt(),ia())},[a,Ts,kt,ia]),u.useEffect(()=>{fe(1),Le(new Set)},[K,se]),u.useEffect(()=>{Le(new Set)},[h]);const rt=()=>{$e(cs),fe(1)},jt=U=>xe.get(U)||U,Ae=async(U,Se)=>{try{De(us=>new Set(us).add(U));const as=await $m([{id:U,rejected:Se,require_unchecked:K==="unchecked"}]);as.results[0]?.success?(ds({title:Se?"已拒绝":"已通过",description:`表达方式 #${U} ${Se?"已拒绝":"已通过"}`}),kt(),Ts()):ds({title:"操作失败",description:as.results[0]?.message||"未知错误",variant:"destructive"})}catch(as){ds({title:"操作失败",description:as instanceof Error?as.message:"未知错误",variant:"destructive"})}finally{De(as=>{const us=new Set(as);return us.delete(U),us})}},Qe=async U=>{if(Z.size===0){ds({title:"请选择",description:"请先选择要审核的表达方式",variant:"destructive"});return}try{D(!0);const Se=Array.from(Z).map(us=>({id:us,rejected:U,require_unchecked:K==="unchecked"})),as=await $m(Se);ds({title:"批量审核完成",description:`成功 ${as.succeeded} 条,失败 ${as.failed} 条`,variant:as.failed>0?"destructive":"default"}),Le(new Set),kt(),Ts()}catch(Se){ds({title:"批量审核失败",description:Se instanceof Error?Se.message:"未知错误",variant:"destructive"})}finally{D(!1)}},As=()=>{Z.size===h.length?Le(new Set):Le(new Set(h.map(U=>U.id)))},mt=U=>{Le(Se=>{const as=new Set(Se);return as.has(U)?as.delete(U):as.add(U),as})},Ht=U=>U?new Date(U*1e3).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-",ca=U=>U.checked?U.rejected?e.jsxs(Ce,{variant:"destructive",className:"gap-1",children:[e.jsx(ta,{className:"h-3 w-3"}),"已拒绝"]}):e.jsxs(Ce,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(st,{className:"h-3 w-3"}),"已通过"]}):e.jsxs(Ce,{variant:"outline",className:"gap-1",children:[e.jsx(da,{className:"h-3 w-3"}),"待审核"]}),Fa=U=>U?U==="ai"?e.jsxs(Ce,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(Yn,{className:"h-3 w-3"}),"AI"]}):e.jsxs(Ce,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(Fl,{className:"h-3 w-3"}),"人工"]}):null,Xt=Math.ceil(ue/Ee),te=()=>{const U=[];if(Xt<=7)for(let Se=1;Se<=Xt;Se++)U.push(Se);else{U.push(1),we>3&&U.push("ellipsis");const Se=Math.max(2,we-1),as=Math.min(Xt-1,we+1);for(let us=Se;us<=as;us++)U.push(us);we<Xt-2&&U.push("ellipsis"),Xt>1&&U.push(Xt)}return U},_e=()=>{const U=parseInt($,10);!isNaN(U)&&U>=1&&U<=Xt&&(fe(U),A(""))};return e.jsx(Qs,{open:a,onOpenChange:l,children:e.jsxs(Hs,{className:"max-w-5xl w-[95vw] sm:w-full h-[90vh] sm:h-[85vh] flex flex-col p-0",hideCloseButton:!0,children:[e.jsxs("div",{className:"flex items-end bg-muted/30 px-2 pt-2 shrink-0",children:[e.jsxs("button",{onClick:()=>c("list"),className:P("group relative flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-t-lg transition-all","hover:bg-background/50",r==="list"?"bg-background text-foreground shadow-sm border border-b-0 border-border":"text-muted-foreground hover:text-foreground"),children:[e.jsx(rv,{className:"h-4 w-4"}),e.jsx("span",{children:"列表模式"}),r==="list"&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-[2px] bg-background"})]}),e.jsxs("button",{onClick:()=>c("quick"),className:P("group relative flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-t-lg transition-all","hover:bg-background/50",r==="quick"?"bg-background text-foreground shadow-sm border border-b-0 border-border":"text-muted-foreground hover:text-foreground"),children:[e.jsx(sl,{className:"h-4 w-4"}),e.jsx("span",{children:"快速审核"}),e.jsx(Ce,{variant:"secondary",className:"ml-1 h-5 px-1.5 text-xs",children:"新"}),r==="quick"&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-[2px] bg-background"})]}),e.jsx("div",{className:"flex-1 border-b border-border"}),e.jsx("button",{onClick:()=>l(!1),className:"mb-[1px] p-2 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:e.jsx(Sa,{className:"h-4 w-4"})})]}),r==="list"&&e.jsxs(e.Fragment,{children:[e.jsxs(qs,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-4 border-b shrink-0",children:[e.jsx(Vs,{className:"text-lg sm:text-xl",children:"表达方式审核"}),e.jsx(at,{className:"text-xs sm:text-sm",children:"审核麦麦学习到的表达方式。通过审核的项目才会被使用(可在配置中调整),被拒绝的项目永远不会被使用。"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-3 mt-4",children:[e.jsxs("div",{className:"rounded-lg border p-2 sm:p-3 text-center",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-orange-500",children:Q?"-":d?.unchecked??0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"待审核"})]}),e.jsxs("div",{className:"rounded-lg border p-2 sm:p-3 text-center",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-green-500",children:Q?"-":d?.passed??0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"已通过"})]}),e.jsxs("div",{className:"rounded-lg border p-2 sm:p-3 text-center",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-red-500",children:Q?"-":d?.rejected??0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"已拒绝"})]}),e.jsxs("div",{className:"rounded-lg border p-2 sm:p-3 text-center",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-blue-500",children:Q?"-":d?.total??0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"总计"})]})]})]}),e.jsxs("div",{className:"px-4 sm:px-6 py-3 border-b shrink-0 space-y-3",children:[e.jsx(Jt,{value:K,onValueChange:U=>Re(U),className:"w-full",children:e.jsxs(Gt,{className:"grid w-full grid-cols-4",children:[e.jsxs(Xe,{value:"unchecked",className:"gap-1 text-xs sm:text-sm px-1 sm:px-3",children:[e.jsx(da,{className:"h-3 w-3 sm:h-4 sm:w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"待审核"}),e.jsx("span",{className:"sm:hidden",children:"待审"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",d?.unchecked??0,")"]})]}),e.jsxs(Xe,{value:"passed",className:"gap-1 text-xs sm:text-sm px-1 sm:px-3",children:[e.jsx(st,{className:"h-3 w-3 sm:h-4 sm:w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"已通过"}),e.jsx("span",{className:"sm:hidden",children:"通过"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",d?.passed??0,")"]})]}),e.jsxs(Xe,{value:"rejected",className:"gap-1 text-xs sm:text-sm px-1 sm:px-3",children:[e.jsx(ta,{className:"h-3 w-3 sm:h-4 sm:w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"已拒绝"}),e.jsx("span",{className:"sm:hidden",children:"拒绝"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",d?.rejected??0,")"]})]}),e.jsxs(Xe,{value:"all",className:"gap-1 text-xs sm:text-sm px-1 sm:px-3",children:[e.jsx("span",{children:"全部"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",d?.total??0,")"]})]})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索情景或风格...",value:cs,onChange:U=>J(U.target.value),onKeyDown:U=>U.key==="Enter"&&rt(),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"icon",onClick:rt,children:e.jsx($t,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"icon",onClick:()=>{kt(),Ts()},disabled:pe,children:e.jsx(dt,{className:P("h-4 w-4",pe&&"animate-spin")})})]}),Z.size>0&&e.jsx("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:K==="unchecked"?e.jsxs(e.Fragment,{children:[e.jsxs(_,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700 flex-1 sm:flex-none",onClick:()=>Qe(!1),disabled:pe,children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量通过"}),e.jsx("span",{className:"sm:hidden",children:"通过"}),"(",Z.size,")"]}),e.jsxs(_,{variant:"destructive",size:"sm",className:"flex-1 sm:flex-none",onClick:()=>Qe(!0),disabled:pe,children:[e.jsx(ta,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量拒绝"}),e.jsx("span",{className:"sm:hidden",children:"拒绝"}),"(",Z.size,")"]})]}):K==="passed"?e.jsxs(_,{variant:"destructive",size:"sm",className:"flex-1 sm:flex-none",onClick:()=>Qe(!0),disabled:pe,children:[e.jsx(ta,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量改为拒绝"}),e.jsx("span",{className:"sm:hidden",children:"改为拒绝"}),"(",Z.size,")"]}):K==="rejected"?e.jsxs(_,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700 flex-1 sm:flex-none",onClick:()=>Qe(!1),disabled:pe,children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量改为通过"}),e.jsx("span",{className:"sm:hidden",children:"改为通过"}),"(",Z.size,")"]}):e.jsxs(e.Fragment,{children:[e.jsxs(_,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700 flex-1 sm:flex-none",onClick:()=>Qe(!1),disabled:pe,children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量通过"}),e.jsx("span",{className:"sm:hidden",children:"通过"}),"(",Z.size,")"]}),e.jsxs(_,{variant:"destructive",size:"sm",className:"flex-1 sm:flex-none",onClick:()=>Qe(!0),disabled:pe,children:[e.jsx(ta,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量拒绝"}),e.jsx("span",{className:"sm:hidden",children:"拒绝"}),"(",Z.size,")"]})]})})]})]}),e.jsx(ts,{className:"flex-1 px-4 sm:px-6",children:pe&&h.length===0?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx(dt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-muted-foreground",children:[e.jsx(Rt,{className:"h-8 w-8 mb-2"}),e.jsx("p",{children:"没有找到表达方式"})]}):e.jsxs("div",{className:"space-y-2 py-2",children:[h.length>0&&e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{checked:Z.size===h.length&&h.length>0,onCheckedChange:As}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Z.size===h.length&&h.length>0?`已全选当前页 (${h.length} 条)`:`全选当前页 (${h.length} 条)`})]}),Z.size>0&&e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>Le(new Set),className:"h-7 text-xs",children:"取消选择"})]}),h.map(U=>e.jsx("div",{className:P("rounded-lg border p-3 sm:p-4 space-y-2 sm:space-y-3 transition-colors",Z.has(U.id)&&"bg-accent border-primary",le.has(U.id)&&"opacity-50"),children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[e.jsx(tt,{checked:Z.has(U.id),onCheckedChange:()=>mt(U.id),disabled:le.has(U.id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"情景:"}),e.jsx("p",{className:"text-sm font-medium break-words",children:U.situation})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"风格:"}),e.jsx("p",{className:"text-sm text-muted-foreground break-words",children:U.style})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["#",U.id]}),e.jsx("span",{children:"·"}),e.jsx("span",{title:jt(U.chat_id),className:"truncate max-w-24 sm:max-w-32",children:jt(U.chat_id)}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Ht(U.create_date)}),e.jsxs("div",{className:"flex items-center gap-1",children:[ca(U),Fa(U.modified_by)]})]})]}),e.jsx("div",{className:"flex flex-col gap-1 sm:gap-2 shrink-0",children:K==="unchecked"?e.jsxs(e.Fragment,{children:[e.jsxs(_,{size:"sm",variant:"outline",className:"text-green-600 hover:text-green-700 hover:bg-green-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!1),disabled:le.has(U.id),children:[e.jsx(st,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"通过"})]}),e.jsxs(_,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!0),disabled:le.has(U.id),children:[e.jsx(ta,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"拒绝"})]})]}):K==="passed"?e.jsxs(_,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!0),disabled:le.has(U.id),children:[e.jsx(ta,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为拒绝"})]}):K==="rejected"?e.jsxs(_,{size:"sm",variant:"outline",className:"text-green-600 hover:text-green-700 hover:bg-green-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!1),disabled:le.has(U.id),children:[e.jsx(st,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为通过"})]}):e.jsx(e.Fragment,{children:U.rejected?e.jsxs(_,{size:"sm",variant:"outline",className:"text-green-600 hover:text-green-700 hover:bg-green-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!1),disabled:le.has(U.id),children:[e.jsx(st,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为通过"})]}):U.checked?e.jsxs(_,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!0),disabled:le.has(U.id),children:[e.jsx(ta,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为拒绝"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_,{size:"sm",variant:"outline",className:"text-green-600 hover:text-green-700 hover:bg-green-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!1),disabled:le.has(U.id),children:[e.jsx(st,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"通过"})]}),e.jsxs(_,{size:"sm",variant:"outline",className:"text-red-600 hover:text-red-700 hover:bg-red-50 h-8 sm:h-9 px-2 sm:px-3",onClick:()=>Ae(U.id,!0),disabled:le.has(U.id),children:[e.jsx(ta,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"拒绝"})]})]})})})]})},U.id))]})}),e.jsxs("div",{className:"px-4 sm:px-6 py-3 border-t shrink-0 flex flex-col sm:flex-row items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"hidden sm:inline",children:"每页"}),e.jsxs(Pe,{value:Ee.toString(),onValueChange:U=>{G(parseInt(U,10)),fe(1)},children:[e.jsx(Be,{className:"w-[70px] h-8",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10"}),e.jsx(W,{value:"20",children:"20"}),e.jsx(W,{value:"50",children:"50"}),e.jsx(W,{value:"100",children:"100"})]})]}),e.jsx("span",{className:"hidden sm:inline",children:"条"}),e.jsxs("span",{className:"text-muted-foreground",children:["共 ",ue," 条"]})]}),e.jsx(fx,{className:"mx-0 w-auto",children:e.jsxs(px,{children:[e.jsx(Xn,{children:e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>fe(U=>Math.max(1,U-1)),disabled:we<=1||pe,children:e.jsx(Pa,{className:"h-4 w-4"})})}),te().map((U,Se)=>e.jsx(Xn,{children:U==="ellipsis"?e.jsx(Iv,{}):e.jsx(jc,{href:"#",isActive:U===we,onClick:as=>{as.preventDefault(),fe(U)},className:"h-8 w-8 cursor-pointer",children:U})},Se)),e.jsx(Xn,{children:e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>fe(U=>Math.min(Xt,U+1)),disabled:we>=Xt||pe,children:e.jsx(ra,{className:"h-4 w-4"})})})]})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"跳至"}),e.jsx(ne,{type:"number",min:1,max:Xt,value:$,onChange:U=>A(U.target.value),onKeyDown:U=>U.key==="Enter"&&_e(),className:"w-16 h-8 text-center",placeholder:we.toString()}),e.jsx("span",{className:"text-muted-foreground",children:"页"}),e.jsx(_,{variant:"outline",size:"sm",className:"h-8",onClick:_e,disabled:pe,children:"跳转"})]})]})]}),r==="quick"&&e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 sm:px-6 py-3 border-b shrink-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{className:"text-muted-foreground",children:["待审核: ",e.jsx("span",{className:"font-medium text-orange-500",children:d?.unchecked??0})]}),e.jsxs("span",{className:"text-muted-foreground",children:["已通过: ",e.jsx("span",{className:"font-medium text-green-500",children:d?.passed??0})]}),e.jsxs("span",{className:"text-muted-foreground",children:["已拒绝: ",e.jsx("span",{className:"font-medium text-red-500",children:d?.rejected??0})]})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>{ut(),Ts()},disabled:w,children:[e.jsx(dt,{className:P("h-4 w-4 mr-1",w&&"animate-spin")}),"刷新"]})]}),e.jsx(Jt,{value:p,onValueChange:U=>g(U),className:"w-full",children:e.jsxs(Gt,{className:"grid w-full grid-cols-4",children:[e.jsxs(Xe,{value:"unchecked",className:"gap-1 text-xs sm:text-sm",children:[e.jsx(da,{className:"h-3 w-3 sm:h-4 sm:w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"待审核"}),e.jsx("span",{className:"sm:hidden",children:"待审"})]}),e.jsxs(Xe,{value:"passed",className:"gap-1 text-xs sm:text-sm",children:[e.jsx(st,{className:"h-3 w-3 sm:h-4 sm:w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"已通过"}),e.jsx("span",{className:"sm:hidden",children:"通过"})]}),e.jsxs(Xe,{value:"rejected",className:"gap-1 text-xs sm:text-sm",children:[e.jsx(ta,{className:"h-3 w-3 sm:h-4 sm:w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"已拒绝"}),e.jsx("span",{className:"sm:hidden",children:"拒绝"})]}),e.jsx(Xe,{value:"all",className:"gap-1 text-xs sm:text-sm",children:"全部"})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-8 relative overflow-hidden",children:w&&N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx(dt,{className:"h-8 w-8 animate-spin text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"加载中..."})]}):N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-muted/50 flex items-center justify-center mb-6",children:e.jsx(st,{className:"h-10 w-10 text-green-500"})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:"全部审核完成!"}),e.jsx("p",{className:"text-muted-foreground",children:"当前筛选条件下没有待处理的项目"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 text-sm text-muted-foreground z-50",children:[b+1," / ",N.length,M>N.length&&e.jsxs("span",{className:"ml-1",children:["(共 ",M," 条)"]})]}),e.jsx("div",{className:"absolute inset-x-4 top-1/2 -translate-y-1/2 flex justify-between pointer-events-none z-40",children:(()=>{const U=N[b],Se=Is(U);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:P("flex items-center gap-2 px-4 py-2 rounded-lg transition-all duration-300",C==="left"?"bg-red-500/20 text-red-500 scale-110":"bg-muted/50 text-muted-foreground opacity-0",!Se.left&&"invisible"),children:[e.jsx(ta,{className:"h-8 w-8"}),e.jsx("span",{className:"font-bold text-lg hidden sm:inline",children:"拒绝"})]}),e.jsxs("div",{className:P("flex items-center gap-2 px-4 py-2 rounded-lg transition-all duration-300",C==="right"?"bg-green-500/20 text-green-500 scale-110":"bg-muted/50 text-muted-foreground opacity-0",!Se.right&&"invisible"),children:[e.jsx("span",{className:"font-bold text-lg hidden sm:inline",children:"通过"}),e.jsx(st,{className:"h-8 w-8"})]})]})})()}),e.jsx("div",{className:"relative w-full max-w-md h-[400px] flex items-center justify-center",children:N.slice(b,b+5).reverse().map((U,Se,as)=>{const us=as.length-1-Se,es=us===0;let Ct={zIndex:5-us,position:"absolute",width:"100%",transition:es&&!ge.current?"all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1)":"none"};if(es)Ct={...Ct,transform:`translateX(${H}px) rotate(${H*.05}deg)`,opacity:Math.max(0,1-Math.abs(H)/500),cursor:"grab"};else{const $s=Math.min(Math.abs(H)/200,1),pa=vt=>{const Ca=vt*7%5,ll=vt*13%7;return{scale:1-vt*.05,translateY:vt*12,rotate:(vt%2===0?1:-1)*(vt*2)+Ca,translateX:(vt%2===0?-1:1)*(vt*4)+ll}},oa=pa(us),ae=pa(us-1),oe=oa.scale+(ae.scale-oa.scale)*$s,qe=oa.translateY+(ae.translateY-oa.translateY)*$s,Ys=oa.rotate+(ae.rotate-oa.rotate)*$s,Ps=oa.translateX+(ae.translateX-oa.translateX)*$s;Ct={...Ct,transform:`translate3d(${Ps}px, ${qe}px, 0) scale(${oe}) rotate(${Ys}deg)`,opacity:1-us*.15,filter:`blur(${Math.max(0,us*1-$s)}px)`,pointerEvents:"none"}}return e.jsxs("div",{ref:es?je:void 0,className:P("bg-card border rounded-xl shadow-xl p-6 select-none h-full flex flex-col",es&&"active:cursor-grabbing shadow-2xl ring-1 ring-border/50",es&&me===U.id&&"ring-4 ring-orange-500/50 bg-orange-50/10"),style:Ct,onMouseDown:es?ms:void 0,onMouseMove:es?Ms:void 0,onMouseUp:es?We:void 0,onMouseLeave:es?Cs:void 0,onTouchStart:es?rs:void 0,onTouchMove:es?is:void 0,onTouchEnd:es?ys:void 0,children:[es&&me===U.id&&e.jsxs("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center bg-background/80 backdrop-blur-sm animate-in fade-in duration-300 rounded-xl",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-orange-500/20 rounded-full animate-ping"}),e.jsx(dt,{className:"relative h-16 w-16 text-orange-500 mb-4 animate-spin duration-1000"})]}),e.jsx("h3",{className:"text-xl font-bold text-foreground animate-in slide-in-from-bottom-2 fade-in duration-500",children:"数据已更新"}),e.jsx("p",{className:"text-muted-foreground mt-2 animate-in slide-in-from-bottom-3 fade-in duration-700",children:"后台任务已处理此条目"})]}),es&&e.jsx("div",{className:P("absolute inset-0 flex items-center justify-center z-20 pointer-events-none transition-opacity duration-200",H<-10&&!Is(U).left||H>10&&!Is(U).right?"opacity-100":"opacity-0"),children:e.jsx("div",{className:"bg-background/80 backdrop-blur-sm p-4 rounded-full shadow-lg border border-border",children:e.jsx(iv,{className:"h-12 w-12 text-muted-foreground"})})}),e.jsxs("div",{className:"space-y-4 flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-muted-foreground font-mono",children:["#",U.id]}),e.jsxs("div",{className:"flex items-center gap-2",children:[ca(U),Fa(U.modified_by)]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"情景"}),e.jsx("div",{className:"p-3 bg-muted/30 rounded-lg border border-border/50",children:e.jsx("p",{className:"text-lg font-medium leading-relaxed",children:U.situation})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"风格"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:U.style.split(/[,,]/).map(($s,pa)=>e.jsx(Ce,{variant:"secondary",className:"font-normal",children:$s.trim()},pa))})]})]}),e.jsxs("div",{className:"mt-auto pt-4 border-t flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:e.jsx(Fl,{className:"h-3 w-3"})}),e.jsx("span",{title:jt(U.chat_id),className:"truncate max-w-[120px] font-medium",children:jt(U.chat_id)})]}),e.jsx("span",{className:"font-mono",children:Ht(U.create_date)})]})]},U.id)})}),e.jsx("div",{className:"flex items-center gap-8 mt-8 sm:hidden z-50",children:(()=>{const U=N[b],Se=Is(U);return e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outline",size:"lg",className:P("w-16 h-16 rounded-full border-2 shadow-lg transition-all active:scale-95",Se.left?"hover:bg-red-50 hover:text-red-600 hover:border-red-200":"opacity-30 cursor-not-allowed"),onClick:()=>Se.left&&V(!0),disabled:!Se.left||X,children:e.jsx(ta,{className:"h-8 w-8"})}),e.jsx(_,{variant:"outline",size:"lg",className:P("w-16 h-16 rounded-full border-2 shadow-lg transition-all active:scale-95",Se.right?"hover:bg-green-50 hover:text-green-600 hover:border-green-200":"opacity-30 cursor-not-allowed"),onClick:()=>Se.right&&V(!1),disabled:!Se.right||X,children:e.jsx(st,{className:"h-8 w-8"})})]})})()})]})}),e.jsxs("div",{className:"hidden sm:flex items-center justify-center gap-6 px-6 py-3 border-t text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"←"}),e.jsx("span",{children:"拒绝"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"→"}),e.jsx("span",{children:"通过"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↑"}),e.jsx("span",{children:"上一条"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↓"}),e.jsx("span",{children:"下一条"})]}),e.jsx("span",{className:"text-muted-foreground/50",children:"|"}),e.jsx("span",{children:"拖拽卡片滑动审核"})]})]})]})})}function d2(){return e.jsx(lr,{children:e.jsx(m2,{})})}const u2=a=>{const l=[];for(let r=0;r<a;r++){const c=r*137.508%360;l.push(`hsl(${c}, 70%, 55%)`)}return l};function m2(){const[a,l]=u.useState(null),[r,c]=u.useState(!0),[d,m]=u.useState(0),[h,f]=u.useState(24),[p,g]=u.useState(!0),[N,j]=u.useState(null),[b,y]=u.useState(!0),[w,z]=u.useState(null),[M,S]=u.useState(!1),[F,E]=u.useState(0),{triggerRestart:C,isRestarting:R}=Tn(),H=u.useRef(!0),O=u.useRef(null);u.useEffect(()=>(H.current=!0,()=>{H.current=!1,O.current&&(clearInterval(O.current),O.current=null)}),[]);const X=u.useCallback(async()=>{try{const A=await jx();H.current&&E(A.unchecked)}catch(A){console.error("获取审核统计失败:",A)}},[]),L=u.useCallback(async()=>{try{y(!0);const A=await fw.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");H.current&&j({hitokoto:A.data.hitokoto,from:A.data.from||A.data.from_who||"未知"})}catch(A){console.error("获取一言失败:",A),H.current&&j({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{H.current&&y(!1)}},[]),me=u.useCallback(async()=>{try{const A=await ke("/api/webui/system/status");if(!H.current)return;if(A.ok){const K=await A.json();z(K)}else z(null)}catch(A){console.error("获取机器人状态失败:",A),H.current&&z(null)}},[]),Ne=async()=>{await C()},je=u.useCallback(async()=>{try{const A=await ke(`/api/webui/statistics/dashboard?hours=${h}`);if(!H.current)return;if(A.ok){const K=await A.json();l(K)}c(!1),m(100)}catch(A){console.error("Failed to fetch dashboard data:",A),H.current&&(c(!1),m(100))}},[h]);if(u.useEffect(()=>{if(!r)return;m(0);const A=setTimeout(()=>m(15),200),K=setTimeout(()=>m(30),800),Re=setTimeout(()=>m(45),2e3),se=setTimeout(()=>m(60),4e3),$e=setTimeout(()=>m(75),6500),cs=setTimeout(()=>m(85),9e3),J=setTimeout(()=>m(92),11e3);return()=>{clearTimeout(A),clearTimeout(K),clearTimeout(Re),clearTimeout(se),clearTimeout($e),clearTimeout(cs),clearTimeout(J)}},[r]),u.useEffect(()=>{je(),L(),me(),X()},[je,L,me,X]),u.useEffect(()=>{if(O.current&&(clearInterval(O.current),O.current=null),!!p)return O.current=setInterval(()=>{H.current&&(je(),me())},3e4),()=>{O.current&&(clearInterval(O.current),O.current=null)}},[p,je,me]),r||!a)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(dt,{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(tr,{value:d,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d,"%"]})]})]})});const{summary:ce,model_stats:ge=[],hourly_data:pe=[],daily_data:D=[],recent_activity:Q=[]}=a,B=ce??{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},ue=A=>{const K=Math.floor(A/3600),Re=Math.floor(A%3600/60);return`${K}小时${Re}分钟`},Y=A=>{const K=A.toLocaleString("zh-CN");return A>=1e9?{display:`${(A/1e9).toFixed(2)}B`,exact:K,needsExact:!0}:A>=1e6?{display:`${(A/1e6).toFixed(2)}M`,exact:K,needsExact:!0}:A>=1e4?{display:`${(A/1e3).toFixed(1)}K`,exact:K,needsExact:!0}:A>=1e3?{display:`${(A/1e3).toFixed(2)}K`,exact:K,needsExact:!0}:{display:K,exact:K,needsExact:!1}},we=A=>{const K=`¥${A.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`;return A>=1e6?{display:`¥${(A/1e6).toFixed(2)}M`,exact:K,needsExact:!0}:A>=1e4?{display:`¥${(A/1e3).toFixed(1)}K`,exact:K,needsExact:!0}:A>=1e3?{display:`¥${(A/1e3).toFixed(2)}K`,exact:K,needsExact:!0}:{display:K,exact:K,needsExact:!1}},fe=A=>new Date(A).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),Ee=u2(ge.length),G=ge.map((A,K)=>({name:A.model_name,value:A.request_count,fill:Ee[K]})),$={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(ts,{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(Jt,{value:h.toString(),onValueChange:A=>f(Number(A)),children:e.jsxs(Gt,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(Xe,{value:"24",children:"24小时"}),e.jsx(Xe,{value:"168",children:"7天"}),e.jsx(Xe,{value:"720",children:"30天"})]})}),e.jsxs(_,{variant:p?"default":"outline",size:"sm",onClick:()=>g(!p),className:"gap-2",children:[e.jsx(dt,{className:`h-4 w-4 ${p?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:je,children:e.jsx(dt,{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:[b?e.jsx(ks,{className:"h-5 flex-1"}):N?e.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',N.hitokoto,'" —— ',N.from]}):null,e.jsx(_,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:L,disabled:b,children:e.jsx(dt,{className:`h-3.5 w-3.5 ${b?"animate-spin":""}`})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-3",children:[e.jsxs(Te,{className:"lg:col-span-1",children:[e.jsx(Oe,{className:"pb-3",children:e.jsxs(Ue,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(pc,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(ze,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:w?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(Ce,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(st,{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(Ce,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(Rt,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),w&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",w.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",ue(w.uptime)]})]})]})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{className:"pb-3",children:e.jsxs(Ue,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(sl,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(ze,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:Ne,disabled:R,className:"gap-2",children:[e.jsx(rc,{className:`h-4 w-4 ${R?"animate-spin":""}`}),R?"重启中...":"重启麦麦"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>S(!0),className:"gap-2",children:[e.jsx(cv,{className:"h-4 w-4"}),"表达审核",F>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs rounded-full bg-orange-500 text-white",children:F>99?"99+":F})]}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kn,{to:"/logs",children:[e.jsx(Ua,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kn,{to:"/plugins",children:[e.jsx(T1,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kn,{to:"/settings",children:[e.jsx(Sn,{className:"h-4 w-4"}),"系统设置"]})})]})})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"pb-3",children:[e.jsxs(Ue,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(E1,{className:"h-4 w-4"}),"反馈问卷"]}),e.jsx(Ns,{className:"text-xs",children:"帮助我们改进产品体验"})]}),e.jsx(ze,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kn,{to:"/survey/webui-feedback",children:[e.jsx(Ua,{className:"h-4 w-4"}),"WebUI 反馈"]})}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Kn,{to:"/survey/maibot-feedback",children:[e.jsx(Ia,{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(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(nx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[Y(B.total_requests).display,Y(B.total_requests).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",Y(B.total_requests).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",h<48?h+"小时":Math.floor(h/24)+"天"]})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"总花费"}),e.jsx(M1,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[we(B.total_cost).display,we(B.total_cost).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",we(B.total_cost).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:B.cost_per_hour>0?`¥${B.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(Zr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[Y(B.total_tokens).display,Y(B.total_tokens).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",Y(B.total_tokens).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:B.tokens_per_hour>0?`${Y(B.tokens_per_hour).display}/小时`:"暂无数据"})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(sl,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[B.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(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(da,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ze,{children:e.jsxs("div",{className:"text-xl font-bold",children:[ue(B.online_time),e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",B.online_time.toLocaleString(),"秒)"]})]})})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(Ia,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsxs("div",{className:"text-xl font-bold",children:[Y(B.total_messages).display,Y(B.total_messages).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",Y(B.total_messages).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",Y(B.total_replies).display,Y(B.total_replies).needsExact&&e.jsxs("span",{children:["(",Y(B.total_replies).exact,")"]})," 条"]})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(rx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsx("div",{className:"text-xl font-bold",children:B.total_messages>0?`¥${(B.total_cost/B.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(Jt,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(Gt,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(Xe,{value:"trends",children:"趋势"}),e.jsx(Xe,{value:"models",children:"模型"}),e.jsx(Xe,{value:"activity",children:"活动"}),e.jsx(Xe,{value:"daily",children:"日统计"})]}),e.jsxs(Ss,{value:"trends",className:"space-y-4",children:[e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"请求趋势"}),e.jsxs(Ns,{children:["最近",h,"小时的请求量变化"]})]}),e.jsx(ze,{children:e.jsx(Kr,{config:$,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(Ww,{data:pe,children:[e.jsx(Ji,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Xi,{dataKey:"timestamp",tickFormatter:A=>fe(A),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Gr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Qr,{labelFormatter:A=>fe(A)})}),e.jsx(e1,{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(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"花费趋势"}),e.jsx(Ns,{children:"API调用成本变化"})]}),e.jsx(ze,{children:e.jsx(Kr,{config:$,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Bo,{data:pe,children:[e.jsx(Ji,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Xi,{dataKey:"timestamp",tickFormatter:A=>fe(A),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Gr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Qr,{labelFormatter:A=>fe(A)})}),e.jsx(Zi,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"Token消耗"}),e.jsx(Ns,{children:"Token使用量变化"})]}),e.jsx(ze,{children:e.jsx(Kr,{config:$,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Bo,{data:pe,children:[e.jsx(Ji,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Xi,{dataKey:"timestamp",tickFormatter:A=>fe(A),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Gr,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Qr,{labelFormatter:A=>fe(A)})}),e.jsx(Zi,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(Ss,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"模型请求分布"}),e.jsxs(Ns,{children:["各模型使用占比 (共 ",ge.length," 个模型)"]})]}),e.jsx(ze,{children:e.jsx(Kr,{config:Object.fromEntries(ge.map((A,K)=>[A.model_name,{label:A.model_name,color:Ee[K]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(s1,{children:[e.jsx(Qi,{content:e.jsx(Qr,{})}),e.jsx(t1,{data:G,cx:"50%",cy:"50%",labelLine:!1,label:({name:A,percent:K})=>K&&K<.05?"":`${A} ${K?(K*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:G.map((A,K)=>e.jsx(a1,{fill:A.fill},`cell-${K}`))})]})})})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"模型详细统计"}),e.jsx(Ns,{children:"请求数、花费和性能"})]}),e.jsx(ze,{children:e.jsx(ts,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:ge.map((A,K)=>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:A.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${K%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:A.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",A.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:[(A.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:[A.avg_response_time.toFixed(2),"s"]})]})]})]},K))})})})]})]})}),e.jsx(Ss,{value:"activity",children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"最近活动"}),e.jsx(Ns,{children:"最新的API调用记录"})]}),e.jsx(ze,{children:e.jsx(ts,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:Q.map((A,K)=>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:A.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:A.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:fe(A.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:A.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",A.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[A.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${A.status==="success"?"text-green-600":"text-red-600"}`,children:A.status})]})]})]},K))})})})]})}),e.jsx(Ss,{value:"daily",children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"每日统计"}),e.jsx(Ns,{children:"最近7天的数据汇总"})]}),e.jsx(ze,{children:e.jsx(Kr,{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(Bo,{data:D,children:[e.jsx(Ji,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Xi,{dataKey:"timestamp",tickFormatter:A=>{const K=new Date(A);return`${K.getMonth()+1}/${K.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Gr,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Gr,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Qr,{labelFormatter:A=>new Date(A).toLocaleDateString("zh-CN")})}),e.jsx(F_,{content:e.jsx(zv,{})}),e.jsx(Zi,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Zi,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]}),e.jsx(nr,{}),e.jsx(Pv,{open:M,onOpenChange:A=>{S(A),A||X()}})]})})}const x2={theme:"system",setTheme:()=>null},Fv=u.createContext(x2),vx=()=>{const a=u.useContext(Fv);if(a===void 0)throw new Error("useTheme must be used within a ThemeProvider");return a},h2=(a,l,r)=>{const c=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||c){l(a);return}const d=r.clientX,m=r.clientY,h=Math.hypot(Math.max(d,innerWidth-d),Math.max(m,innerHeight-m));document.startViewTransition(()=>{l(a)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${d}px ${m}px)`,`circle(${h}px at ${d}px ${m}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},Hv=u.createContext(void 0),qv=()=>{const a=u.useContext(Hv);if(a===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return a},Ge=u.forwardRef(({className:a,...l},r)=>e.jsx(Nj,{className:P("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",a),...l,ref:r,children:e.jsx(bw,{className:P("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")})}));Ge.displayName=Nj.displayName;const f2=ti("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),T=u.forwardRef(({className:a,...l},r)=>e.jsx(Xj,{ref:r,className:P(f2(),a),...l}));T.displayName=Xj.displayName;const p2=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:a=>a.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:a=>/[A-Z]/.test(a)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:a=>/[a-z]/.test(a)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:a=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(a)}];function g2(a){const l=p2.map(c=>({id:c.id,label:c.label,description:c.description,passed:c.validate(a)}));return{isValid:l.every(c=>c.passed),rules:l}}const ud="0.12.2",Nx="MaiBot Dashboard",j2=`${Nx} v${ud}`,v2=(a="v")=>`${a}${ud}`,wa={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"},jl={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function zt(a){const l=Vv(a),r=localStorage.getItem(l);if(r===null)return jl[a];const c=jl[a];if(typeof c=="boolean")return r==="true";if(typeof c=="number"){const d=parseFloat(r);return isNaN(d)?c:d}return r}function Yr(a,l){const r=Vv(a);localStorage.setItem(r,String(l)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:a,value:l}}))}function N2(){return{theme:zt("theme"),accentColor:zt("accentColor"),enableAnimations:zt("enableAnimations"),enableWavesBackground:zt("enableWavesBackground"),logCacheSize:zt("logCacheSize"),logAutoScroll:zt("logAutoScroll"),logFontSize:zt("logFontSize"),logLineSpacing:zt("logLineSpacing"),dataSyncInterval:zt("dataSyncInterval"),wsReconnectInterval:zt("wsReconnectInterval"),wsMaxReconnectAttempts:zt("wsMaxReconnectAttempts")}}function b2(){const a=N2(),l=localStorage.getItem(wa.COMPLETED_TOURS),r=l?JSON.parse(l):[];return{...a,completedTours:r}}function y2(a){const l=[],r=[];for(const[c,d]of Object.entries(a)){if(c==="completedTours"){Array.isArray(d)?(localStorage.setItem(wa.COMPLETED_TOURS,JSON.stringify(d)),l.push("completedTours")):r.push("completedTours");continue}if(c in jl){const m=c,h=jl[m];if(typeof d==typeof h){if(m==="theme"&&!["light","dark","system"].includes(d)){r.push(c);continue}if(m==="logFontSize"&&!["xs","sm","base"].includes(d)){r.push(c);continue}Yr(m,d),l.push(c)}else r.push(c)}else r.push(c)}return{success:l.length>0,imported:l,skipped:r}}function w2(){for(const a of Object.keys(jl))Yr(a,jl[a]);localStorage.removeItem(wa.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function _2(){const a=[],l=[],r=[];for(let c=0;c<localStorage.length;c++){const d=localStorage.key(c);d&&(d.startsWith("maibot")||d.startsWith("accent-color")||d==="access-token")&&r.push(d)}for(const c of r)localStorage.removeItem(c),a.push(c);return{clearedKeys:a,preservedKeys:l}}function Bg(){let a=0;const l=[];for(let r=0;r<localStorage.length;r++){const c=localStorage.key(r);if(c){const d=localStorage.getItem(c)||"",m=(c.length+d.length)*2;a+=m,l.push({key:c,size:m})}}return l.sort((r,c)=>c.size-r.size),{used:a,items:localStorage.length,details:l}}function S2(a){if(a===0)return"0 B";const l=1024,r=["B","KB","MB"],c=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,c)).toFixed(2))+" "+r[c]}function Vv(a){return{theme:wa.THEME,accentColor:wa.ACCENT_COLOR,enableAnimations:wa.ENABLE_ANIMATIONS,enableWavesBackground:wa.ENABLE_WAVES_BACKGROUND,logCacheSize:wa.LOG_CACHE_SIZE,logAutoScroll:wa.LOG_AUTO_SCROLL,logFontSize:wa.LOG_FONT_SIZE,logLineSpacing:wa.LOG_LINE_SPACING,dataSyncInterval:wa.DATA_SYNC_INTERVAL,wsReconnectInterval:wa.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:wa.WS_MAX_RECONNECT_ATTEMPTS}[a]}const el=u.forwardRef(({className:a,...l},r)=>e.jsxs(bj,{ref:r,className:P("relative flex w-full touch-none select-none items-center",a),...l,children:[e.jsx(yw,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(ww,{className:"absolute h-full bg-primary"})}),e.jsx(_w,{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"})]}));el.displayName=bj.displayName;class k2{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return zt("logCacheSize")}getMaxReconnectAttempts(){return zt("wsMaxReconnectAttempts")}getReconnectInterval(){return zt("wsReconnectInterval")}getWebSocketUrl(l){let r;{const c=window.location.protocol==="https:"?"wss:":"ws:",d=window.location.host;r=`${c}//${d}/ws/logs`}return l?`${r}?token=${encodeURIComponent(l)}`:r}async getWsToken(){try{const l=await ke("/api/webui/ws-token",{method:"GET",credentials:"include"});if(!l.ok)return console.error("获取 WebSocket token 失败:",l.status),null;const r=await l.json();return r.success&&r.token?r.token:null}catch(l){return console.error("获取 WebSocket token 失败:",l),null}}async connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;if(window.location.pathname==="/auth"){console.log("📡 在登录页面,跳过 WebSocket 连接");return}if(!await dc()){console.log("📡 未登录,跳过 WebSocket 连接");return}const r=await this.getWsToken();if(!r){console.log("📡 无法获取 WebSocket token,跳过连接");return}const c=this.getWebSocketUrl(r);try{this.ws=new WebSocket(c),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=d=>{try{if(d.data==="pong")return;const m=JSON.parse(d.data);this.notifyLog(m)}catch(m){console.error("解析日志消息失败:",m)}},this.ws.onerror=d=>{console.error("❌ WebSocket 错误:",d),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(d){console.error("创建 WebSocket 连接失败:",d),this.attemptReconnect()}}attemptReconnect(){const l=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=l)return;this.reconnectAttempts+=1;const r=this.getReconnectInterval(),c=Math.min(r*this.reconnectAttempts,3e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},c)}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(l){return this.logCallbacks.add(l),()=>this.logCallbacks.delete(l)}onConnectionChange(l){return this.connectionCallbacks.add(l),l(this.isConnected),()=>this.connectionCallbacks.delete(l)}notifyLog(l){if(!this.logCache.some(c=>c.id===l.id)){this.logCache.push(l);const c=this.getMaxCacheSize();this.logCache.length>c&&(this.logCache=this.logCache.slice(-c)),this.logCallbacks.forEach(d=>{try{d(l)}catch(m){console.error("日志回调执行失败:",m)}})}}notifyConnection(l){this.connectionCallbacks.forEach(r=>{try{r(l)}catch(c){console.error("连接状态回调执行失败:",c)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const Qn=new k2;typeof window<"u"&&setTimeout(()=>{Qn.connect()},100);const bs=kw,wt=Cw,C2=Sw,Gv=u.forwardRef(({className:a,...l},r)=>e.jsx(yj,{className:P("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",a),...l,ref:r}));Gv.displayName=yj.displayName;const xs=u.forwardRef(({className:a,...l},r)=>e.jsxs(C2,{children:[e.jsx(Gv,{}),e.jsx(wj,{ref:r,className:P("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",a),...l})]}));xs.displayName=wj.displayName;const hs=({className:a,...l})=>e.jsx("div",{className:P("flex flex-col space-y-2 text-center sm:text-left",a),...l});hs.displayName="AlertDialogHeader";const fs=({className:a,...l})=>e.jsx("div",{className:P("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...l});fs.displayName="AlertDialogFooter";const ps=u.forwardRef(({className:a,...l},r)=>e.jsx(_j,{ref:r,className:P("text-lg font-semibold",a),...l}));ps.displayName=_j.displayName;const gs=u.forwardRef(({className:a,...l},r)=>e.jsx(Sj,{ref:r,className:P("text-sm text-muted-foreground",a),...l}));gs.displayName=Sj.displayName;const js=u.forwardRef(({className:a,variant:l,...r},c)=>e.jsx(kj,{ref:c,className:P(si({variant:l}),a),...r}));js.displayName=kj.displayName;const vs=u.forwardRef(({className:a,...l},r)=>e.jsx(Cj,{ref:r,className:P(si({variant:"outline"}),"mt-2 sm:mt-0",a),...l}));vs.displayName=Cj.displayName;function T2(){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(Jt,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(Gt,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(Xe,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(A1,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(Xe,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(ov,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(Xe,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Sn,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(Xe,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Yt,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(ts,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(Ss,{value:"appearance",className:"mt-0",children:e.jsx(E2,{})}),e.jsx(Ss,{value:"security",className:"mt-0",children:e.jsx(M2,{})}),e.jsx(Ss,{value:"other",className:"mt-0",children:e.jsx(A2,{})}),e.jsx(Ss,{value:"about",className:"mt-0",children:e.jsx(z2,{})})]})]})]})}function Ig(a){const l=document.documentElement,c={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%)"}}[a];if(c)l.style.setProperty("--primary",c.hsl),c.gradient?(l.style.setProperty("--primary-gradient",c.gradient),l.classList.add("has-gradient")):(l.style.removeProperty("--primary-gradient"),l.classList.remove("has-gradient"));else if(a.startsWith("#")){const d=m=>{m=m.replace("#","");const h=parseInt(m.substring(0,2),16)/255,f=parseInt(m.substring(2,4),16)/255,p=parseInt(m.substring(4,6),16)/255,g=Math.max(h,f,p),N=Math.min(h,f,p);let j=0,b=0;const y=(g+N)/2;if(g!==N){const w=g-N;switch(b=y>.5?w/(2-g-N):w/(g+N),g){case h:j=((f-p)/w+(f<p?6:0))/6;break;case f:j=((p-h)/w+2)/6;break;case p:j=((h-f)/w+4)/6;break}}return`${Math.round(j*360)} ${Math.round(b*100)}% ${Math.round(y*100)}%`};l.style.setProperty("--primary",d(a)),l.style.removeProperty("--primary-gradient"),l.classList.remove("has-gradient")}}function E2(){const{theme:a,setTheme:l}=vx(),{enableAnimations:r,setEnableAnimations:c,enableWavesBackground:d,setEnableWavesBackground:m}=qv(),[h,f]=u.useState(()=>localStorage.getItem("accent-color")||"blue");u.useEffect(()=>{const g=localStorage.getItem("accent-color")||"blue";Ig(g)},[]);const p=g=>{f(g),localStorage.setItem("accent-color",g),Ig(g)};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(Bm,{value:"light",current:a,onChange:l,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Bm,{value:"dark",current:a,onChange:l,label:"深色",description:"始终使用深色主题"}),e.jsx(Bm,{value:"system",current:a,onChange:l,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(Wa,{value:"blue",current:h,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(Wa,{value:"purple",current:h,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(Wa,{value:"green",current:h,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(Wa,{value:"orange",current:h,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(Wa,{value:"pink",current:h,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(Wa,{value:"red",current:h,onChange:p,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(Wa,{value:"gradient-sunset",current:h,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(Wa,{value:"gradient-ocean",current:h,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(Wa,{value:"gradient-forest",current:h,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(Wa,{value:"gradient-aurora",current:h,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(Wa,{value:"gradient-fire",current:h,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(Wa,{value:"gradient-twilight",current:h,onChange:p,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:h.startsWith("#")?h:"#3b82f6",onChange:g=>p(g.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(ne,{type:"text",value:h,onChange:g=>p(g.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(T,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Ge,{id:"animations",checked:r,onCheckedChange:c})]})}),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(T,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Ge,{id:"waves-background",checked:d,onCheckedChange:m})]})})]})]})]})}function M2(){const a=ha(),[l,r]=u.useState(""),[c,d]=u.useState(""),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[g,N]=u.useState(!1),[j,b]=u.useState(!1),[y,w]=u.useState(!1),[z,M]=u.useState(!1),[S,F]=u.useState(""),[E,C]=u.useState(!1),{toast:R}=nt(),H=u.useMemo(()=>g2(c),[c]),O=async ce=>{if(!l){R({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(ce),w(!0),R({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>w(!1),2e3)}catch{R({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},X=async()=>{if(!c.trim()){R({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!H.isValid){const ce=H.rules.filter(ge=>!ge.passed).map(ge=>ge.label).join(", ");R({title:"格式错误",description:`Token 不符合要求: ${ce}`,variant:"destructive"});return}N(!0);try{const ce=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:c.trim()})}),ge=await ce.json();ce.ok&&ge.success?(d(""),r(c.trim()),R({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{a({to:"/auth"})},1500)):R({title:"更新失败",description:ge.message||"无法更新 Token",variant:"destructive"})}catch(ce){console.error("更新 Token 错误:",ce),R({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{N(!1)}},L=async()=>{b(!0);try{const ce=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),ge=await ce.json();ce.ok&&ge.success?(r(ge.token),F(ge.token),M(!0),C(!1),R({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):R({title:"生成失败",description:ge.message||"无法生成新 Token",variant:"destructive"})}catch(ce){console.error("生成 Token 错误:",ce),R({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{b(!1)}},me=async()=>{try{await navigator.clipboard.writeText(S),C(!0),R({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{R({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},Ne=()=>{M(!1),setTimeout(()=>{F(""),C(!1)},300),setTimeout(()=>{a({to:"/auth"})},500)},je=ce=>{ce||Ne()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Qs,{open:z,onOpenChange:je,children:e.jsxs(Hs,{className:"sm:max-w-md",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(at,{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(T,{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:S})]}),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(Ut,{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(gt,{className:"gap-2 sm:gap-0",children:[e.jsx(_,{variant:"outline",onClick:me,className:"gap-2",children:E?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(qo,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(_,{onClick:Ne,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(T,{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(ne,{id:"current-token",type:m?"text":"password",value:l||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{l?h(!m):R({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:m?"隐藏":"显示",children:m?e.jsx(ic,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ua,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(_,{variant:"outline",size:"icon",onClick:()=>O(l),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!l,children:y?e.jsx(Lt,{className:"h-4 w-4 text-green-500"}):e.jsx(qo,{className:"h-4 w-4"})}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",disabled:j,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(dt,{className:P("h-4 w-4",j&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认重新生成 Token"}),e.jsx(gs,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:L,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(T,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(ne,{id:"new-token",type:f?"text":"password",value:c,onChange:ce=>d(ce.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>p(!f),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:f?"隐藏":"显示",children:f?e.jsx(ic,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ua,{className:"h-4 w-4 text-muted-foreground"})})]}),c&&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:H.rules.map(ce=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[ce.passed?e.jsx(st,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(ta,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:P(ce.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:ce.label})]},ce.id))}),H.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(Lt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(_,{onClick:X,disabled:g||!H.isValid||!c,className:"w-full sm:w-auto",children:g?"更新中...":"更新自定义 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 A2(){const a=ha(),{toast:l}=nt(),[r,c]=u.useState(!1),[d,m]=u.useState(!1),[h,f]=u.useState(()=>zt("logCacheSize")),[p,g]=u.useState(()=>zt("wsReconnectInterval")),[N,j]=u.useState(()=>zt("wsMaxReconnectAttempts")),[b,y]=u.useState(()=>zt("dataSyncInterval")),[w,z]=u.useState(()=>Bg()),[M,S]=u.useState(!1),[F,E]=u.useState(!1),C=u.useRef(null);if(d)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const R=()=>{z(Bg())},H=D=>{const Q=D[0];f(Q),Yr("logCacheSize",Q)},O=D=>{const Q=D[0];g(Q),Yr("wsReconnectInterval",Q)},X=D=>{const Q=D[0];j(Q),Yr("wsMaxReconnectAttempts",Q)},L=D=>{const Q=D[0];y(Q),Yr("dataSyncInterval",Q)},me=()=>{Qn.clearLogs(),l({title:"日志已清除",description:"日志缓存已清空"})},Ne=()=>{const D=_2();R(),l({title:"缓存已清除",description:`已清除 ${D.clearedKeys.length} 项缓存数据`})},je=()=>{S(!0);try{const D=b2(),Q=JSON.stringify(D,null,2),B=new Blob([Q],{type:"application/json"}),ue=URL.createObjectURL(B),Y=document.createElement("a");Y.href=ue,Y.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(Y),Y.click(),document.body.removeChild(Y),URL.revokeObjectURL(ue),l({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(D){console.error("导出设置失败:",D),l({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{S(!1)}},ce=D=>{const Q=D.target.files?.[0];if(!Q)return;E(!0);const B=new FileReader;B.onload=ue=>{try{const Y=ue.target?.result,we=JSON.parse(Y),fe=y2(we);fe.success?(f(zt("logCacheSize")),g(zt("wsReconnectInterval")),j(zt("wsMaxReconnectAttempts")),y(zt("dataSyncInterval")),R(),l({title:"导入成功",description:`成功导入 ${fe.imported.length} 项设置${fe.skipped.length>0?`,跳过 ${fe.skipped.length} 项`:""}`}),(fe.imported.includes("theme")||fe.imported.includes("accentColor"))&&l({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):l({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(Y){console.error("导入设置失败:",Y),l({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{E(!1),C.current&&(C.current.value="")}},B.readAsText(Q)},ge=()=>{w2(),f(jl.logCacheSize),g(jl.wsReconnectInterval),j(jl.wsMaxReconnectAttempts),y(jl.dataSyncInterval),R(),l({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},pe=async()=>{c(!0);try{const D=await ke("/api/webui/setup/reset",{method:"POST"}),Q=await D.json();D.ok&&Q.success?(l({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{a({to:"/setup"})},1e3)):l({title:"重置失败",description:Q.message||"无法重置配置状态",variant:"destructive"})}catch(D){console.error("重置配置状态错误:",D),l({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{c(!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(Zr,{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(z1,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:R,className:"h-7 px-2",children:e.jsx(dt,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"text-2xl font-bold text-primary",children:S2(w.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[w.items," 个存储项"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{className:"text-sm font-medium",children:"日志缓存大小"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h," 条"]})]}),e.jsx(el,{value:[h],onValueChange:H,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(T,{className:"text-sm font-medium",children:"首页数据刷新间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[b," 秒"]})]}),e.jsx(el,{value:[b],onValueChange:L,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(T,{className:"text-sm font-medium",children:"WebSocket 重连间隔"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[p/1e3," 秒"]})]}),e.jsx(el,{value:[p],onValueChange:O,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(T,{className:"text-sm font-medium",children:"WebSocket 最大重连次数"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[N," 次"]})]}),e.jsx(el,{value:[N],onValueChange:X,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(_,{variant:"outline",size:"sm",onClick:me,className:"gap-2",children:[e.jsx(os,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(os,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认清除本地缓存"}),e.jsx(gs,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:Ne,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(na,{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(_,{variant:"outline",onClick:je,disabled:M,className:"gap-2",children:[e.jsx(na,{className:"h-4 w-4"}),M?"导出中...":"导出设置"]}),e.jsx("input",{ref:C,type:"file",accept:".json",onChange:ce,className:"hidden"}),e.jsxs(_,{variant:"outline",onClick:()=>C.current?.click(),disabled:F,className:"gap-2",children:[e.jsx(cc,{className:"h-4 w-4"}),F?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(rc,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认重置所有设置"}),e.jsx(gs,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:ge,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(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",disabled:r,className:"gap-2",children:[e.jsx(rc,{className:P("h-4 w-4",r&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认重新配置"}),e.jsx(gs,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:pe,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(Ut,{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(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"destructive",className:"gap-2",children:[e.jsx(Ut,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认触发错误"}),e.jsx(gs,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>m(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function z2(){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:P("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:["关于 ",Nx]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",ud]}),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(ts,{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(Tt,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(Tt,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(Tt,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(Tt,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(Tt,{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(Tt,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(Tt,{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(Tt,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(Tt,{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(Tt,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(Tt,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(Tt,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(Tt,{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(Tt,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(Tt,{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(Tt,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(Tt,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(Tt,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(Tt,{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(Tt,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(Tt,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(Tt,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(Tt,{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 Tt({name:a,description:l,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:a}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:l})]}),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 Bm({value:a,current:l,onChange:r,label:c,description:d}){const m=l===a;return e.jsxs("button",{onClick:()=>r(a),className:P("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",m?"border-primary bg-accent":"border-border"),children:[m&&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:c}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:d})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[a==="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"})]}),a==="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"})]}),a==="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 Wa({value:a,current:l,onChange:r,label:c,colorClass:d}){const m=l===a;return e.jsxs("button",{onClick:()=>r(a),className:P("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",m?"border-primary bg-accent":"border-border"),children:[m&&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:P("h-8 w-8 sm:h-10 sm:w-10 rounded-full",d)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:c})]})]})}const R2=Date.now()%1e6;class D2{grad3;p;perm;constructor(l=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(l,r,c){return l[0]*r+l[1]*c}mix(l,r,c){return(1-c)*l+c*r}fade(l){return l*l*l*(l*(l*6-15)+10)}perlin2(l,r){const c=Math.floor(l)&255,d=Math.floor(r)&255;l-=Math.floor(l),r-=Math.floor(r);const m=this.fade(l),h=this.fade(r),f=this.perm[c]+d,p=this.perm[f],g=this.perm[f+1],N=this.perm[c+1]+d,j=this.perm[N],b=this.perm[N+1];return this.mix(this.mix(this.dot(this.grad3[p%12],l,r),this.dot(this.grad3[j%12],l-1,r),m),this.mix(this.dot(this.grad3[g%12],l,r-1),this.dot(this.grad3[b%12],l-1,r-1),m),h)}}function Pg(){const a=u.useRef(null),l=u.useRef(null),r=u.useRef(void 0),[c]=u.useState(()=>new D2(R2)),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:c,bounding:null});return u.useEffect(()=>{const m=l.current,h=a.current;if(!m||!h)return;const f=d.current;f.noise=c;const p=()=>{const M=m.getBoundingClientRect();f.bounding=M,h.style.width=`${M.width}px`,h.style.height=`${M.height}px`},g=()=>{if(!f.bounding)return;const{width:M,height:S}=f.bounding;f.lines=[],f.paths.forEach(me=>me.remove()),f.paths=[];const F=10,E=32,C=M+200,R=S+30,H=Math.ceil(C/F),O=Math.ceil(R/E),X=(M-F*H)/2,L=(S-E*O)/2;for(let me=0;me<=H;me++){const Ne=[];for(let ce=0;ce<=O;ce++){const ge={x:X+F*me,y:L+E*ce,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};Ne.push(ge)}const je=document.createElementNS("http://www.w3.org/2000/svg","path");h.appendChild(je),f.paths.push(je),f.lines.push(Ne)}},N=M=>{const{lines:S,mouse:F,noise:E}=f;S.forEach(C=>{C.forEach(R=>{const H=E.perlin2((R.x+M*.0125)*.002,(R.y+M*.005)*.0015)*12;R.wave.x=Math.cos(H)*32,R.wave.y=Math.sin(H)*16;const O=R.x-F.sx,X=R.y-F.sy,L=Math.hypot(O,X),me=Math.max(175,F.vs);if(L<me){const Ne=1-L/me,je=Math.cos(L*.001)*Ne;R.cursor.vx+=Math.cos(F.a)*je*me*F.vs*65e-5,R.cursor.vy+=Math.sin(F.a)*je*me*F.vs*65e-5}R.cursor.vx+=(0-R.cursor.x)*.005,R.cursor.vy+=(0-R.cursor.y)*.005,R.cursor.vx*=.925,R.cursor.vy*=.925,R.cursor.x+=R.cursor.vx*2,R.cursor.y+=R.cursor.vy*2,R.cursor.x=Math.min(100,Math.max(-100,R.cursor.x)),R.cursor.y=Math.min(100,Math.max(-100,R.cursor.y))})})},j=(M,S=!0)=>{const F={x:M.x+M.wave.x+(S?M.cursor.x:0),y:M.y+M.wave.y+(S?M.cursor.y:0)};return F.x=Math.round(F.x*10)/10,F.y=Math.round(F.y*10)/10,F},b=()=>{const{lines:M,paths:S}=f;M.forEach((F,E)=>{let C=j(F[0],!1),R=`M ${C.x} ${C.y}`;F.forEach((H,O)=>{const X=O===F.length-1;C=j(H,!X),R+=`L ${C.x} ${C.y}`}),S[E].setAttribute("d",R)})},y=M=>{const{mouse:S}=f;S.sx+=(S.x-S.sx)*.1,S.sy+=(S.y-S.sy)*.1;const F=S.x-S.lx,E=S.y-S.ly,C=Math.hypot(F,E);S.v=C,S.vs+=(C-S.vs)*.1,S.vs=Math.min(100,S.vs),S.lx=S.x,S.ly=S.y,S.a=Math.atan2(E,F),m&&(m.style.setProperty("--x",`${S.sx}px`),m.style.setProperty("--y",`${S.sy}px`)),N(M),b(),r.current=requestAnimationFrame(y)},w=M=>{if(!f.bounding)return;const{mouse:S}=f;S.x=M.pageX-f.bounding.left,S.y=M.pageY-f.bounding.top+window.scrollY,S.set||(S.sx=S.x,S.sy=S.y,S.lx=S.x,S.ly=S.y,S.set=!0)},z=()=>{p(),g()};return p(),g(),window.addEventListener("resize",z),window.addEventListener("mousemove",w),r.current=requestAnimationFrame(y),()=>{window.removeEventListener("resize",z),window.removeEventListener("mousemove",w),r.current&&cancelAnimationFrame(r.current)}},[c]),e.jsxs("div",{ref:l,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:a,style:{display:"block",width:"100%",height:"100%"},children:e.jsx("style",{children:`
|
||
path {
|
||
fill: none;
|
||
stroke: hsl(var(--primary) / 0.20);
|
||
stroke-width: 1px;
|
||
}
|
||
`})})]})}function O2(){const[a,l]=u.useState(""),[r,c]=u.useState(!1),[d,m]=u.useState(""),[h,f]=u.useState(!0),p=ha(),{enableWavesBackground:g,setEnableWavesBackground:N}=qv(),{theme:j,setTheme:b}=vx();u.useEffect(()=>{(async()=>{try{await dc()&&p({to:"/"})}catch{}finally{f(!1)}})()},[p]);const w=j==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":j,z=()=>{b(w==="dark"?"light":"dark")},M=async S=>{if(S.preventDefault(),m(""),!a.trim()){m("请输入 Access Token");return}c(!0),console.log("开始验证 token...");try{const F=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:a.trim()})});console.log("Token 验证响应状态:",F.status);const E=await F.json();if(console.log("Token 验证响应数据:",E),F.ok&&E.valid){console.log("Token 验证成功,准备跳转..."),console.log("is_first_setup:",E.is_first_setup),await new Promise(R=>setTimeout(R,100));const C=await dc();console.log("跳转前认证状态检查:",C),E.is_first_setup?(console.log("跳转到首次配置页面"),p({to:"/setup"})):(console.log("跳转到首页"),p({to:"/"}))}else console.error("Token 验证失败:",E.message),m(E.message||"Token 验证失败,请检查后重试")}catch(F){console.error("Token 验证错误:",F),m("连接服务器失败,请检查网络连接")}finally{c(!1)}};return h?e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[g&&e.jsx(Pg,{}),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:[g&&e.jsx(Pg,{}),e.jsxs(Te,{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:z,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:w==="dark"?"切换到浅色模式":"切换到深色模式",children:w==="dark"?e.jsx(ix,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(tc,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(Oe,{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(Jm,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ue,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(Ns,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(ze,{children:e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"token",className:"text-sm font-medium",children:"Access Token"}),e.jsxs("div",{className:"relative",children:[e.jsx(cx,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground",strokeWidth:2,fill:"none"}),e.jsx(ne,{id:"token",type:"password",placeholder:"请输入您的 Access Token",value:a,onChange:S=>l(S.target.value),className:P("pl-10",d&&"border-red-500 focus-visible:ring-red-500"),disabled:r,autoFocus:!0,autoComplete:"off"})]})]}),d&&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(Rt,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:d})]}),e.jsx(_,{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(Qs,{children:[e.jsx(dd,{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(ox,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token,我该去哪里获得 Token?"]})}),e.jsxs(Hs,{className:"sm:max-w-md",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(Jm,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"如何获取 Access Token"]}),e.jsx(at,{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(R1,{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(Ua,{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(Rt,{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(bs,{children:[e.jsx(wt,{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(sl,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsxs(ps,{className:"flex items-center gap-2",children:[e.jsx(sl,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(gs,{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(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>N(!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:j2})})]})}const pt=u.forwardRef(({className:a,autoResize:l=!0,minHeight:r=60,maxHeight:c,value:d,onChange:m,...h},f)=>{const p=u.useRef(null),[g,N]=u.useState(!1);u.useImperativeHandle(f,()=>p.current),u.useEffect(()=>{if(a){const y=/\b(h-\d+|h-\[[\d.]+(?:px|rem|em)\]|min-h-\[[\d.]+(?:px|rem|em)\])\b/.test(a);N(y)}},[a]);const j=u.useCallback(()=>{const y=p.current;if(!y||!l||g)return;y.style.height="auto";const w=y.scrollHeight;let z=Math.max(w,r);c&&c>0&&(z=Math.min(z,c)),y.style.height=`${z}px`,c&&c>0&&w>c?y.style.overflowY="auto":y.style.overflowY="hidden"},[l,g,r,c]);u.useEffect(()=>{j()},[d,j]),u.useEffect(()=>{j()},[j]);const b=u.useCallback(y=>{m?.(y),requestAnimationFrame(()=>{j()})},[m,j]);return e.jsx("textarea",{className:P("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","custom-scrollbar",l&&!g&&"resize-none overflow-hidden",a),ref:p,value:d,onChange:b,style:{minHeight:l&&!g?`${r}px`:void 0},...h})});pt.displayName="Textarea";const la=u.forwardRef(({className:a,orientation:l="horizontal",decorative:r=!0,...c},d)=>e.jsx(Tj,{ref:d,decorative:r,orientation:l,className:P("shrink-0 bg-border",l==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",a),...c}));la.displayName=Tj.displayName;function L2({config:a,onChange:l}){const r=d=>{d.trim()&&!a.alias_names.includes(d.trim())&&l({...a,alias_names:[...a.alias_names,d.trim()]})},c=d=>{l({...a,alias_names:a.alias_names.filter((m,h)=>h!==d)})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"qq_account",children:"QQ账号 *"}),e.jsx(ne,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:a.qq_account||"",onChange:d=>l({...a,qq_account:Number(d.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人登录使用的QQ账号"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"nickname",children:"昵称 *"}),e.jsx(ne,{id:"nickname",placeholder:"请输入机器人的昵称",value:a.nickname,onChange:d=>l({...a,nickname:d.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的主要称呼名称"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{children:"别名"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:a.alias_names.map((d,m)=>e.jsxs(Ce,{variant:"secondary",className:"gap-1",children:[d,e.jsx("button",{type:"button",onClick:()=>c(m),className:"ml-1 hover:text-destructive",children:e.jsx(Sa,{className:"h-3 w-3"})})]},m))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:d=>{d.key==="Enter"&&(r(d.target.value),d.target.value="")}}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>{const d=document.getElementById("alias_input");d&&(r(d.value),d.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function U2({config:a,onChange:l}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"personality",children:"人格特征 *"}),e.jsx(pt,{id:"personality",placeholder:"描述机器人的人格特质和身份特征(建议120字以内)",value:a.personality,onChange:r=>l({...a,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(T,{htmlFor:"reply_style",children:"表达风格 *"}),e.jsx(pt,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:a.reply_style,onChange:r=>l({...a,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(T,{htmlFor:"interest",children:"兴趣 *"}),e.jsx(pt,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:a.interest,onChange:r=>l({...a,interest:r.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(pt,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:a.plan_style,onChange:r=>l({...a,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(T,{htmlFor:"private_plan_style",children:"私聊说话规则 *"}),e.jsx(pt,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:a.private_plan_style,onChange:r=>l({...a,private_plan_style:r.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function $2({config:a,onChange:l}){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(T,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(a.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(ne,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:a.emoji_chance,onChange:r=>l({...a,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(T,{htmlFor:"max_reg_num",children:"最大表情包数量"}),e.jsx(ne,{id:"max_reg_num",type:"number",min:"1",max:"200",value:a.max_reg_num,onChange:r=>l({...a,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(T,{htmlFor:"do_replace",children:"达到最大数量时替换"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后会删除旧表情包,关闭则不再收集新表情包"})]}),e.jsx(Ge,{id:"do_replace",checked:a.do_replace,onCheckedChange:r=>l({...a,do_replace:r})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ne,{id:"check_interval",type:"number",min:"1",max:"120",value:a.check_interval,onChange:r=>l({...a,check_interval:Number(r.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(la,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{htmlFor:"steal_emoji",children:"偷取表情包"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人将一些表情包据为己有"})]}),e.jsx(Ge,{id:"steal_emoji",checked:a.steal_emoji,onCheckedChange:r=>l({...a,steal_emoji:r})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{htmlFor:"content_filtration",children:"启用表情包过滤"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只保存符合要求的表情包"})]}),e.jsx(Ge,{id:"content_filtration",checked:a.content_filtration,onCheckedChange:r=>l({...a,content_filtration:r})})]}),a.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ne,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:a.filtration_prompt,onChange:r=>l({...a,filtration_prompt:r.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function B2({config:a,onChange:l}){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(T,{htmlFor:"enable_tool",children:"启用工具系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人使用各种工具增强功能"})]}),e.jsx(Ge,{id:"enable_tool",checked:a.enable_tool,onCheckedChange:r=>l({...a,enable_tool:r})})]}),e.jsx(la,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{htmlFor:"all_global",children:"启用全局黑话模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人学习和使用群组黑话"})]}),e.jsx(Ge,{id:"all_global",checked:a.all_global,onCheckedChange:r=>l({...a,all_global:r})})]})]})}function I2({config:a,onChange:l}){const[r,c]=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(Io,{className:"h-3 w-3"})]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"siliconflow_api_key",children:"SiliconFlow API Key *"}),e.jsxs("div",{className:"relative",children:[e.jsx(ne,{id:"siliconflow_api_key",type:r?"text":"password",placeholder:"sk-...",value:a.api_key,onChange:d=>l({api_key:d.target.value}),className:"font-mono pr-10"}),e.jsx(_,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>c(!r),children:r?e.jsx(ic,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ua,{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 P2(){const a=await ke("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!a.ok)throw new Error("读取Bot配置失败");const r=(await a.json()).config.bot||{};return{qq_account:r.qq_account||0,nickname:r.nickname||"",alias_names:r.alias_names||[]}}async function F2(){const a=await ke("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!a.ok)throw new Error("读取人格配置失败");const r=(await a.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 H2(){const a=await ke("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!a.ok)throw new Error("读取表情包配置失败");const r=(await a.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 q2(){const a=await ke("/api/webui/config/bot",{method:"GET",headers:Zs()});if(!a.ok)throw new Error("读取其他配置失败");const r=(await a.json()).config,c=r.tool||{},d=r.expression||{};return{enable_tool:c.enable_tool??!0,all_global:d.all_global_jargon??!0}}async function V2(){const a=await ke("/api/webui/config/model",{method:"GET",headers:Zs()});if(!a.ok)throw new Error("读取模型配置失败");return{api_key:((await a.json()).config.api_providers||[]).find(m=>m.name==="SiliconFlow")?.api_key||""}}async function G2(a){const l=await ke("/api/webui/config/bot/section/bot",{method:"POST",headers:Zs(),body:JSON.stringify(a)});if(!l.ok){const r=await l.json();throw new Error(r.detail||"保存Bot基础配置失败")}return await l.json()}async function K2(a){const l=await ke("/api/webui/config/bot/section/personality",{method:"POST",headers:Zs(),body:JSON.stringify(a)});if(!l.ok){const r=await l.json();throw new Error(r.detail||"保存人格配置失败")}return await l.json()}async function Q2(a){const l=await ke("/api/webui/config/bot/section/emoji",{method:"POST",headers:Zs(),body:JSON.stringify(a)});if(!l.ok){const r=await l.json();throw new Error(r.detail||"保存表情包配置失败")}return await l.json()}async function Y2(a){const l=[];l.push(ke("/api/webui/config/bot/section/tool",{method:"POST",headers:Zs(),body:JSON.stringify({enable_tool:a.enable_tool})})),l.push(ke("/api/webui/config/bot/section/expression",{method:"POST",headers:Zs(),body:JSON.stringify({all_global_jargon:a.all_global})}));const r=await Promise.all(l);for(const c of r)if(!c.ok){const d=await c.json();throw new Error(d.detail||"保存其他配置失败")}return{success:!0}}async function J2(a){const l=await ke("/api/webui/config/model",{method:"GET",headers:Zs()});if(!l.ok)throw new Error("读取模型配置失败");const c=(await l.json()).config,d=c.api_providers||[],m=d.findIndex(p=>p.name==="SiliconFlow");m>=0?d[m]={...d[m],api_key:a.api_key}:d.push({name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",api_key:a.api_key,client_type:"openai",max_retry:3,timeout:120,retry_interval:5});const h={...c,api_providers:d},f=await ke("/api/webui/config/model",{method:"POST",headers:Zs(),body:JSON.stringify(h)});if(!f.ok){const p=await f.json();throw new Error(p.detail||"保存模型配置失败")}return await f.json()}async function Fg(){const a=await ke("/api/webui/setup/complete",{method:"POST"});if(!a.ok){const l=await a.json();throw new Error(l.message||"标记配置完成失败")}return await a.json()}function X2(){return e.jsx(lr,{children:e.jsx(Z2,{})})}function Z2(){const a=ha(),{toast:l}=nt(),{triggerRestart:r}=Tn(),[c,d]=u.useState(0),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[g,N]=u.useState(!0),[j,b]=u.useState({qq_account:0,nickname:"",alias_names:[]}),[y,w]=u.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
|
||
2.如果相同的内容已经被执行,请不要重复执行
|
||
3.请控制你的发言频率,不要太过频繁的发言
|
||
4.如果有人对你感到厌烦,请减少回复
|
||
5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
|
||
2.如果相同的内容已经被执行,请不要重复执行
|
||
3.某句话如果已经被回复过,不要重复回复`}),[z,M]=u.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[S,F]=u.useState({enable_tool:!0,all_global:!0}),[E,C]=u.useState({api_key:""}),R=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:Yn},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:Fl},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:rd},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:Sn},{id:"siliconflow",title:"API配置",description:"配置硅基流动API密钥",icon:cx}],H=(c+1)/R.length*100;u.useEffect(()=>{(async()=>{try{N(!0);const[ge,pe,D,Q,B]=await Promise.all([P2(),F2(),H2(),q2(),V2()]);b(ge),w(pe),M(D),F(Q),C(B)}catch(ge){l({title:"加载配置失败",description:ge instanceof Error?ge.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{N(!1)}})()},[l]);const O=async()=>{p(!0);try{switch(c){case 0:await G2(j);break;case 1:await K2(y);break;case 2:await Q2(z);break;case 3:await Y2(S);break;case 4:await J2(E);break}return l({title:"保存成功",description:`${R[c].title}配置已保存`}),!0}catch(ce){return l({title:"保存失败",description:ce instanceof Error?ce.message:"未知错误",variant:"destructive"}),!1}finally{p(!1)}},X=async()=>{await O()&&c<R.length-1&&d(c+1)},L=()=>{c>0&&d(c-1)},me=async()=>{h(!0);try{if(!await O()){h(!1);return}await Fg(),l({title:"配置完成",description:"麦麦正在重启以应用新配置..."}),await r()}catch(ce){l({title:"配置失败",description:ce instanceof Error?ce.message:"未知错误",variant:"destructive"})}finally{h(!1)}},Ne=async()=>{try{await Fg(),a({to:"/"})}catch(ce){l({title:"跳过失败",description:ce instanceof Error?ce.message:"未知错误",variant:"destructive"})}},je=()=>{switch(c){case 0:return e.jsx(L2,{config:j,onChange:b});case 1:return e.jsx(U2,{config:y,onChange:w});case 2:return e.jsx($2,{config:z,onChange:M});case 3:return e.jsx(B2,{config:S,onChange:F});case 4:return e.jsx(I2,{config:E,onChange:C});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:[e.jsx(nr,{}),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(D1,{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:["让我们一起完成 ",Nx," 的初始配置"]})]}),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:["步骤 ",c+1," / ",R.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(H),"%"]})]}),e.jsx(tr,{value:H,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:R.map((ce,ge)=>{const pe=ce.icon;return e.jsxs("div",{className:P("flex flex-1 flex-col items-center gap-1 md:gap-2",ge<R.length-1&&"relative"),children:[ge<R.length-1&&e.jsx("div",{className:P("absolute left-1/2 top-3 md:top-4 h-0.5 w-full",ge<c?"bg-primary":"bg-border")}),e.jsx("div",{className:P("relative z-10 flex h-6 w-6 md:h-8 md:w-8 items-center justify-center rounded-full border-2 transition-all",ge===c||ge<c?"border-primary bg-primary text-primary-foreground":"border-border bg-background text-muted-foreground"),children:ge<c?e.jsx(st,{className:"h-3 w-3 md:h-4 md:w-4",strokeWidth:2.5,fill:"none"}):e.jsx(pe,{className:"h-3 w-3 md:h-4 md:w-4"})}),e.jsx("span",{className:P("text-[10px] md:text-xs text-center max-w-[60px] md:max-w-none truncate md:whitespace-normal",ge===c?"font-medium text-foreground":"text-muted-foreground"),title:ce.title,children:ce.title})]},ce.id)})}),e.jsx(Te,{className:"mb-6 md:mb-8 shadow-lg",children:e.jsx(ze,{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:R[c].title}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:R[c].description})]}),e.jsx(ts,{className:"h-[400px] md:h-[500px]",children:e.jsx("div",{className:"pr-2",children:je()})})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 sm:gap-0",children:[e.jsx(_,{variant:"outline",onClick:L,disabled:c===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(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"ghost",className:"flex-1 sm:flex-none gap-2",disabled:f||m,children:[e.jsx(O1,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"跳过向导"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认跳过配置向导"}),e.jsx(gs,{children:"您可以随时在系统设置中重新进入配置向导。确定要跳过吗?"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:Ne,children:"确认跳过"})]})]})]}),c===R.length-1?e.jsx(_,{onClick:me,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(st,{className:"ml-2 h-4 w-4",strokeWidth:2,fill:"none"})]})}):e.jsx(_,{onClick:X,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(L1,{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 Kv(){const a=ha();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($t,{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(_,{size:"lg",onClick:()=>a({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(id,{className:"h-4 w-4"}),"返回首页"]}),e.jsxs(_,{size:"lg",variant:"outline",onClick:()=>window.history.back(),className:"gap-2 w-full sm:w-auto",children:[e.jsx($a,{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 W2=Bs.memo(function({config:l,onChange:r}){const c=l.platforms||[],d=l.alias_names||[],m=()=>{r({...l,platforms:[...c,""]})},h=j=>{r({...l,platforms:c.filter((b,y)=>y!==j)})},f=(j,b)=>{const y=[...c];y[j]=b,r({...l,platforms:y})},p=()=>{r({...l,alias_names:[...d,""]})},g=j=>{r({...l,alias_names:d.filter((b,y)=>y!==j)})},N=(j,b)=>{const y=[...d];y[j]=b,r({...l,alias_names:y})};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(T,{htmlFor:"platform",children:"平台"}),e.jsx(ne,{id:"platform",value:l.platform,onChange:j=>r({...l,platform:j.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(ne,{id:"qq_account",value:l.qq_account,onChange:j=>r({...l,qq_account:j.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"nickname",children:"昵称"}),e.jsx(ne,{id:"nickname",value:l.nickname,onChange:j=>r({...l,nickname:j.target.value}),placeholder:"麦麦"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:"别名"}),e.jsxs(_,{onClick:p,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[d.map((j,b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{value:j,onChange:y=>N(b,y.target.value),placeholder:"小麦"}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除别名 "',j||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>g(b),children:"删除"})]})]})]})]},b)),d.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(T,{children:"其他平台账号"}),e.jsxs(_,{onClick:m,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[c.map((j,b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{value:j,onChange:y=>f(b,y.target.value),placeholder:"wx:114514"}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除平台账号 "',j||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>h(b),children:"删除"})]})]})]})]},b)),c.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无其他平台账号"})]})]})]})]})})}),eS=Bs.memo(function({config:l,onChange:r}){const c=()=>{r({...l,states:[...l.states,""]})},d=h=>{r({...l,states:l.states.filter((f,p)=>p!==h)})},m=(h,f)=>{const p=[...l.states];p[h]=f,r({...l,states:p})};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(T,{htmlFor:"personality",children:"人格特质"}),e.jsx(pt,{id:"personality",value:l.personality,onChange:h=>r({...l,personality:h.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.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:"多重人格"}),e.jsxs(_,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加人格"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"可以定义多个不同的人格状态,麦麦会随机切换"}),e.jsx("div",{className:"space-y-2",children:l.states.map((h,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pt,{value:h,onChange:p=>m(f,p.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsx(gs,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>d(f),children:"删除"})]})]})]})]},f))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"state_probability",children:"替换为多重人格概率"}),e.jsx(ne,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:l.state_probability,onChange:h=>r({...l,state_probability:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次构建人格时,用多重人格替换主人格的概率(0.0-1.0)"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"reply_style",children:"表达风格"}),e.jsx(pt,{id:"reply_style",value:l.reply_style,onChange:h=>r({...l,reply_style:h.target.value}),placeholder:"描述说话的表达风格和习惯",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"plan_style",children:"说话规则与行为风格"}),e.jsx(pt,{id:"plan_style",value:l.plan_style,onChange:h=>r({...l,plan_style:h.target.value}),placeholder:"麦麦的说话规则和行为风格",rows:5})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"visual_style",children:"识图规则"}),e.jsx(pt,{id:"visual_style",value:l.visual_style,onChange:h=>r({...l,visual_style:h.target.value}),placeholder:"识图时的处理规则",rows:3})]})]})]})})}),cl=Ew,ol=Mw,tl=u.forwardRef(({className:a,align:l="center",sideOffset:r=4,...c},d)=>e.jsx(Tw,{children:e.jsx(Ej,{ref:d,align:l,sideOffset:r,className:P("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]",a),...c})}));tl.displayName=Ej.displayName;const sS=Bs.memo(function({value:l,onChange:r}){const c=u.useMemo(()=>{const y=l.split("-");if(y.length===2){const[w,z]=y,[M,S]=w.split(":"),[F,E]=z.split(":");return{startHour:M?M.padStart(2,"0"):"00",startMinute:S?S.padStart(2,"0"):"00",endHour:F?F.padStart(2,"0"):"23",endMinute:E?E.padStart(2,"0"):"59"}}return{startHour:"00",startMinute:"00",endHour:"23",endMinute:"59"}},[l]),[d,m]=u.useState(c.startHour),[h,f]=u.useState(c.startMinute),[p,g]=u.useState(c.endHour),[N,j]=u.useState(c.endMinute);u.useEffect(()=>{m(c.startHour),f(c.startMinute),g(c.endHour),j(c.endMinute)},[c]);const b=(y,w,z,M)=>{const S=`${y}:${w}-${z}:${M}`;r(S)};return e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(da,{className:"h-4 w-4 mr-2"}),l||"选择时间段"]})}),e.jsx(tl,{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(T,{className:"text-xs",children:"小时"}),e.jsxs(Pe,{value:d,onValueChange:y=>{m(y),b(y,h,p,N)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:Array.from({length:24},(y,w)=>w).map(y=>e.jsx(W,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs",children:"分钟"}),e.jsxs(Pe,{value:h,onValueChange:y=>{f(y),b(d,y,p,N)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:Array.from({length:60},(y,w)=>w).map(y=>e.jsx(W,{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(T,{className:"text-xs",children:"小时"}),e.jsxs(Pe,{value:p,onValueChange:y=>{g(y),b(d,h,y,N)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:Array.from({length:24},(y,w)=>w).map(y=>e.jsx(W,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs",children:"分钟"}),e.jsxs(Pe,{value:N,onValueChange:y=>{j(y),b(d,h,p,y)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:Array.from({length:60},(y,w)=>w).map(y=>e.jsx(W,{value:y.toString().padStart(2,"0"),children:y.toString().padStart(2,"0")},y))})]})]})]})]})]})})]})}),tS=Bs.memo(function({rule:l}){const r=`{ target = "${l.target}", time = "${l.time}", value = ${l.value.toFixed(1)} }`;return e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(tl,{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 文件中的格式"})]})})]})}),aS=Bs.memo(function({config:l,onChange:r}){const c=()=>{r({...l,talk_value_rules:[...l.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},d=h=>{r({...l,talk_value_rules:l.talk_value_rules.filter((f,p)=>p!==h)})},m=(h,f,p)=>{const g=[...l.talk_value_rules];g[h]={...g[h],[f]:p},r({...l,talk_value_rules:g})};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(T,{htmlFor:"talk_value",children:"聊天频率(基础值)"}),e.jsx(ne,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:l.talk_value,onChange:h=>r({...l,talk_value:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越小越沉默,范围 0-1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"think_mode",children:"思考模式"}),e.jsxs(Pe,{value:l.think_mode||"classic",onValueChange:h=>r({...l,think_mode:h}),children:[e.jsx(Be,{id:"think_mode",children:e.jsx(Fe,{placeholder:"选择思考模式"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"classic",children:"经典模式 - 浅度思考和回复"}),e.jsx(W,{value:"deep",children:"深度模式 - 进行深度思考和回复"}),e.jsx(W,{value:"dynamic",children:"动态模式 - 自动选择思考深度"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"控制麦麦的思考深度。经典模式回复快但简单;深度模式更深入但较慢;动态模式根据情况自动选择"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"mentioned_bot_reply",checked:l.mentioned_bot_reply,onCheckedChange:h=>r({...l,mentioned_bot_reply:h})}),e.jsx(T,{htmlFor:"mentioned_bot_reply",className:"cursor-pointer",children:"启用提及必回复"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"max_context_size",children:"上下文长度"}),e.jsx(ne,{id:"max_context_size",type:"number",min:"1",value:l.max_context_size,onChange:h=>r({...l,max_context_size:parseInt(h.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(ne,{id:"planner_smooth",type:"number",step:"1",min:"0",value:l.planner_smooth,onChange:h=>r({...l,planner_smooth:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"增大数值会减小 planner 负荷,推荐 1-5,0 为关闭"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"plan_reply_log_max_per_chat",children:"每个聊天流最大日志数量"}),e.jsx(ne,{id:"plan_reply_log_max_per_chat",type:"number",step:"1",min:"100",value:l.plan_reply_log_max_per_chat??1024,onChange:h=>r({...l,plan_reply_log_max_per_chat:parseInt(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每个聊天流保存的 Plan/Reply 日志最大数量,超过此数量时会自动删除最老的日志"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"llm_quote",checked:l.llm_quote??!1,onCheckedChange:h=>r({...l,llm_quote:h})}),e.jsx(T,{htmlFor:"llm_quote",className:"cursor-pointer",children:"启用 LLM 控制引用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 ml-10",children:"启用后,LLM 可以决定是否在回复时引用消息"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"enable_talk_value_rules",checked:l.enable_talk_value_rules,onCheckedChange:h=>r({...l,enable_talk_value_rules:h})}),e.jsx(T,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]})]})]}),l.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(_,{onClick:c,size:"sm",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),l.talk_value_rules&&l.talk_value_rules.length>0?e.jsx("div",{className:"space-y-4",children:l.talk_value_rules.map((h,f)=>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:["规则 #",f+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tS,{rule:h}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",children:e.jsx(os,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除规则 #",f+1," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>d(f),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(Pe,{value:h.target===""?"global":"specific",onValueChange:p=>{p==="global"?m(f,"target",""):m(f,"target","qq::group")},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"global",children:"全局配置"}),e.jsx(W,{value:"specific",children:"详细配置"})]})]})]}),h.target!==""&&(()=>{const p=h.target.split(":"),g=p[0]||"qq",N=p[1]||"",j=p[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(T,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Pe,{value:g,onValueChange:b=>{m(f,"target",`${b}:${N}:${j}`)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"qq",children:"QQ"}),e.jsx(W,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ne,{value:N,onChange:b=>{m(f,"target",`${g}:${b.target.value}:${j}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Pe,{value:j,onValueChange:b=>{m(f,"target",`${g}:${N}:${b}`)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"group",children:"群组(group)"}),e.jsx(W,{value:"private",children:"私聊(private)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID:",h.target||"(未设置)"]})]})})(),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"时间段 (Time)"}),e.jsx(sS,{value:h.time,onChange:p=>m(f,"time",p)}),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(T,{htmlFor:`rule-value-${f}`,className:"text-xs font-medium",children:"发言频率值 (Value)"}),e.jsx(ne,{id:`rule-value-${f}`,type:"number",step:"0.01",min:"0.01",max:"1",value:h.value,onChange:p=>{const g=parseFloat(p.target.value);isNaN(g)||m(f,"value",Math.max(.01,Math.min(1,g)))},className:"w-20 h-8 text-xs"})]}),e.jsx(el,{value:[h.value],onValueChange:p=>m(f,"value",p[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 (正常)"})]})]})]})]},f))}):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-1,0 表示完全沉默,1 表示正常发言"]})]})]})]})]})}),lS=Bs.memo(function({config:l,onChange:r}){const c=S=>{if(!S||!S.includes(":"))return{platform:"qq",userId:""};const[F,E]=S.split(":");return{platform:F,userId:E}},{platform:d,userId:m}=c(l.dream_send),[h,f]=u.useState(d),[p,g]=u.useState(m),N=S=>{const[F,E]=S.split("-");return{startTime:F||"09:00",endTime:E||"22:00"}},j=(S,F)=>{const E=F?`${S}:${F}`:"";r({...l,dream_send:E})},b=S=>{f(S),j(S,p)},y=S=>{g(S),j(h,S)},w=()=>{r({...l,dream_time_ranges:[...l.dream_time_ranges,"09:00-22:00"]})},z=S=>{r({...l,dream_time_ranges:l.dream_time_ranges.filter((F,E)=>E!==S)})},M=(S,F,E)=>{const C=[...l.dream_time_ranges],R=N(C[S]);F==="startTime"?R.startTime=E:R.endTime=E,C[S]=`${R.startTime}-${R.endTime}`,r({...l,dream_time_ranges:C})};return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"做梦配置"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"interval_minutes",children:"做梦时间间隔(分钟)"}),e.jsx(ne,{id:"interval_minutes",type:"number",min:"1",value:l.interval_minutes,onChange:S=>r({...l,interval_minutes:Number(S.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"默认30分钟"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"max_iterations",children:"做梦最大轮次"}),e.jsx(ne,{id:"max_iterations",type:"number",min:"1",value:l.max_iterations,onChange:S=>r({...l,max_iterations:Number(S.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"默认20轮"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"first_delay_seconds",children:"首次做梦延迟(秒)"}),e.jsx(ne,{id:"first_delay_seconds",type:"number",min:"0",value:l.first_delay_seconds,onChange:S=>r({...l,first_delay_seconds:Number(S.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"程序启动后首次做梦前的延迟时间,默认60秒"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"做梦结果推送目标"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Pe,{value:h,onValueChange:b,children:[e.jsx(Be,{className:"w-[120px]",children:e.jsx(Fe,{placeholder:"选择平台"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"qq",children:"QQ"}),e.jsx(W,{value:"wx",children:"微信"}),e.jsx(W,{value:"webui",children:"WebUI"})]})]}),e.jsx(ne,{type:"text",placeholder:"输入用户ID (例如: 123456)",value:p,onChange:S=>y(S.target.value),className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"选择平台并输入用户ID,做梦结束后将梦境发送给该用户。用户ID为空则不推送"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:"做梦时间段配置"}),e.jsx(_,{type:"button",size:"sm",onClick:w,children:"添加时间段"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置允许做梦的时间段,支持跨夜区间(如 23:00 到次日 02:00)。列表为空则全天允许做梦"}),e.jsxs("div",{className:"space-y-2",children:[l.dream_time_ranges.map((S,F)=>{const{startTime:E,endTime:C}=N(S);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{type:"time",value:E,onChange:R=>M(F,"startTime",R.target.value),className:"w-[140px]"}),e.jsx("span",{className:"text-muted-foreground",children:"至"}),e.jsx(ne,{type:"time",value:C,onChange:R=>M(F,"endTime",R.target.value),className:"w-[140px]"}),e.jsx(_,{type:"button",variant:"ghost",size:"icon",onClick:()=>z(F),children:e.jsx(Sa,{className:"h-4 w-4"})})]},F)}),l.dream_time_ranges.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 items-center space-x-2",children:[e.jsx(Ge,{id:"dream_visible",checked:l.dream_visible,onCheckedChange:S=>r({...l,dream_visible:S})}),e.jsx(T,{htmlFor:"dream_visible",className:"cursor-pointer",children:"梦境结果存储到上下文"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后,梦境发送给配置的用户后,也会存储到聊天上下文中,在后续对话中可见"})]})]})}),nS=Bs.memo(function({config:l,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(Ge,{checked:l.enable,onCheckedChange:c=>r({...l,enable:c})}),e.jsx(T,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),l.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"LPMM 模式"}),e.jsxs(Pe,{value:l.lpmm_mode,onValueChange:c=>r({...l,lpmm_mode:c}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择 LPMM 模式"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"classic",children:"经典模式"}),e.jsx(W,{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(T,{children:"同义词搜索 TopK"}),e.jsx(ne,{type:"number",min:"1",value:l.rag_synonym_search_top_k,onChange:c=>r({...l,rag_synonym_search_top_k:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"同义词阈值"}),e.jsx(ne,{type:"number",step:"0.1",min:"0",max:"1",value:l.rag_synonym_threshold,onChange:c=>r({...l,rag_synonym_threshold:parseFloat(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"实体提取线程数"}),e.jsx(ne,{type:"number",min:"1",value:l.info_extraction_workers,onChange:c=>r({...l,info_extraction_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"嵌入向量维度"}),e.jsx(ne,{type:"number",min:"1",value:l.embedding_dimension,onChange:c=>r({...l,embedding_dimension:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"嵌入并发线程数"}),e.jsx(ne,{type:"number",min:"1",value:l.max_embedding_workers,onChange:c=>r({...l,max_embedding_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"每批嵌入条数"}),e.jsx(ne,{type:"number",min:"1",value:l.embedding_chunk_size,onChange:c=>r({...l,embedding_chunk_size:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"同义实体数上限"}),e.jsx(ne,{type:"number",min:"1",value:l.max_synonym_entities,onChange:c=>r({...l,max_synonym_entities:parseInt(c.target.value)})})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:l.enable_ppr,onCheckedChange:c=>r({...l,enable_ppr:c})}),e.jsx(T,{className:"cursor-pointer",children:"启用 PPR (低配机器可关闭)"})]})]})]})]})}),rS=Bs.memo(function({config:l,onChange:r}){const[c,d]=u.useState(""),[m,h]=u.useState("WARNING"),f=()=>{c&&!l.suppress_libraries.includes(c)&&(r({...l,suppress_libraries:[...l.suppress_libraries,c]}),d(""))},p=w=>{r({...l,suppress_libraries:l.suppress_libraries.filter(z=>z!==w)})},g=()=>{c&&!l.library_log_levels[c]&&(r({...l,library_log_levels:{...l.library_log_levels,[c]:m}}),d(""),h("WARNING"))},N=w=>{const z={...l.library_log_levels};delete z[w],r({...l,library_log_levels:z})},j=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],b=["FULL","compact","lite"],y=["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(T,{children:"日期格式"}),e.jsx(ne,{value:l.date_style,onChange:w=>r({...l,date_style:w.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(T,{children:"日志级别样式"}),e.jsxs(Pe,{value:l.log_level_style,onValueChange:w=>r({...l,log_level_style:w}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:b.map(w=>e.jsx(W,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"日志文本颜色"}),e.jsxs(Pe,{value:l.color_text,onValueChange:w=>r({...l,color_text:w}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:y.map(w=>e.jsx(W,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"全局日志级别"}),e.jsxs(Pe,{value:l.log_level,onValueChange:w=>r({...l,log_level:w}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:j.map(w=>e.jsx(W,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"控制台日志级别"}),e.jsxs(Pe,{value:l.console_log_level,onValueChange:w=>r({...l,console_log_level:w}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:j.map(w=>e.jsx(W,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"文件日志级别"}),e.jsxs(Pe,{value:l.file_log_level,onValueChange:w=>r({...l,file_log_level:w}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsx(Ie,{children:j.map(w=>e.jsx(W,{value:w,children:w},w))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ne,{value:c,onChange:w=>d(w.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),f())}}),e.jsx(_,{onClick:f,size:"sm",className:"flex-shrink-0",children:e.jsx(Xs,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.suppress_libraries.map(w=>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:w}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>p(w),children:e.jsx(os,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},w))})]}),e.jsxs("div",{children:[e.jsx(T,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ne,{value:c,onChange:w=>d(w.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs(Pe,{value:m,onValueChange:h,children:[e.jsx(Be,{className:"w-32",children:e.jsx(Fe,{})}),e.jsx(Ie,{children:j.map(w=>e.jsx(W,{value:w,children:w},w))})]}),e.jsx(_,{onClick:g,size:"sm",children:e.jsx(Xs,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(l.library_log_levels).map(([w,z])=>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:w}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:z}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>N(w),children:e.jsx(os,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},w))})]})]})}),iS=Bs.memo(function({config:l,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(T,{children:"显示 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否在日志中显示提示词"})]}),e.jsx(Ge,{checked:l.show_prompt,onCheckedChange:c=>r({...l,show_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{children:"显示回复器 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的提示词"})]}),e.jsx(Ge,{checked:l.show_replyer_prompt,onCheckedChange:c=>r({...l,show_replyer_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{children:"显示回复器推理"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的推理过程"})]}),e.jsx(Ge,{checked:l.show_replyer_reasoning,onCheckedChange:c=>r({...l,show_replyer_reasoning:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{children:"显示 Jargon Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示术语相关的提示词"})]}),e.jsx(Ge,{checked:l.show_jargon_prompt,onCheckedChange:c=>r({...l,show_jargon_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{children:"显示记忆检索 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示记忆检索相关的提示词"})]}),e.jsx(Ge,{checked:l.show_memory_prompt,onCheckedChange:c=>r({...l,show_memory_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{children:"显示 Planner Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 Planner 的提示词和原始返回结果"})]}),e.jsx(Ge,{checked:l.show_planner_prompt,onCheckedChange:c=>r({...l,show_planner_prompt:c})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{children:"显示 LPMM 相关文段"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示 LPMM 知识库找到的相关文段日志"})]}),e.jsx(Ge,{checked:l.show_lpmm_paragraph,onCheckedChange:c=>r({...l,show_lpmm_paragraph:c})})]})]})]})}),cS=Bs.memo(function({config:l,onChange:r}){const c=g=>{const N=g.split(":");if(N.length>=4){const j=N[0],b=N[1],y=N[2],w=N.slice(3).join(":");return{platform:j,id:b,type:y,prompt:w}}return{platform:"qq",id:"",type:"group",prompt:""}},d=g=>`${g.platform}:${g.id}:${g.type}:${g.prompt}`,m=()=>{r({...l,chat_prompts:[...l.chat_prompts,"qq::group:"]})},h=g=>{r({...l,chat_prompts:l.chat_prompts.filter((N,j)=>j!==g)})},f=(g,N)=>{const b={...c(l.chat_prompts[g]),...N},y=[...l.chat_prompts];y[g]=d(b),r({...l,chat_prompts:y})},p=({promptStr:g})=>e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(tl,{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.jsxs("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:['"',g,'"']}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]});return e.jsxs("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsx(Ut,{className:"h-5 w-5 text-orange-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"font-medium text-orange-500",children:"实验性功能"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"此部分包含实验性功能,可能不稳定或在未来版本中发生变化。请谨慎使用,并注意不推荐在生产环境中修改私聊规则。"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"实验性设置"}),e.jsxs("div",{className:"grid gap-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"private_plan_style",children:"私聊规则(实验性)"}),e.jsx(pt,{id:"private_plan_style",value:l.private_plan_style,onChange:g=>r({...l,private_plan_style:g.target.value}),placeholder:"私聊的说话规则和行为风格(不推荐修改)",rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"⚠️ 不推荐修改此项,可能会影响私聊对话的稳定性"})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(T,{children:"特定聊天 Prompt 配置"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"为指定聊天添加额外的 prompt,用于定制特定场景的对话行为"})]}),e.jsxs(_,{onClick:m,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加配置"]})]}),e.jsxs("div",{className:"space-y-4",children:[l.chat_prompts.map((g,N)=>{const j=c(g);return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4 bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:["Prompt 配置 ",N+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{promptStr:g}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsx(gs,{children:"确定要删除这个 prompt 配置吗?此操作无法撤销。"})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>h(N),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Pe,{value:j.platform,onValueChange:b=>f(N,{platform:b}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择平台"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"qq",children:"QQ"}),e.jsx(W,{value:"wx",children:"微信"}),e.jsx(W,{value:"webui",children:"WebUI"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:j.type==="group"?"群号":"用户ID"}),e.jsx(ne,{value:j.id,onChange:b=>f(N,{id:b.target.value}),placeholder:j.type==="group"?"输入群号":"输入用户ID",className:"font-mono"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Pe,{value:j.type,onValueChange:b=>f(N,{type:b}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"group",children:"群聊 (group)"}),e.jsx(W,{value:"private",children:"私聊 (private)"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"Prompt 内容"}),e.jsx(pt,{value:j.prompt,onChange:b=>f(N,{prompt:b.target.value}),placeholder:"输入额外的 prompt 内容,例如:这是一个摄影群,你精通摄影知识",rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这段文本会作为系统提示添加到该聊天的上下文中"})]}),e.jsxs("div",{className:"rounded-md bg-muted/50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(dx,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"原始格式"})]}),e.jsx("code",{className:"text-xs font-mono text-muted-foreground break-all",children:g||"(未配置)"})]})]})]},N)}),l.chat_prompts.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{className:"text-sm",children:"暂无特定聊天 prompt 配置"}),e.jsx("p",{className:"text-xs mt-1",children:'点击上方"添加配置"按钮创建新配置'})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-2 p-4 rounded-lg bg-muted/30 border",children:[e.jsx("p",{className:"font-medium text-foreground",children:"💡 使用说明"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 pl-2",children:[e.jsx("li",{children:"为不同的聊天环境配置专属的行为提示"}),e.jsx("li",{children:"支持多个平台:QQ、微信、WebUI"}),e.jsx("li",{children:"可为群聊或私聊分别配置"}),e.jsx("li",{children:"Prompt 会自动注入到该聊天的上下文中"})]}),e.jsx("p",{className:"font-medium text-foreground mt-3",children:"📝 配置示例"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 pl-2",children:[e.jsxs("li",{children:["摄影群:",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"这是一个摄影群,你精通摄影知识"})]}),e.jsxs("li",{children:["二次元群:",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"这是一个二次元交流群"})]}),e.jsxs("li",{children:["好友私聊:",e.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:"这是你与好朋友的私聊"})]})]})]})]})]})]})]})}),oS=Bs.memo(function({config:l,onChange:r}){const[c,d]=u.useState(""),[m,h]=u.useState(""),f=()=>{c&&!l.auth_token.includes(c)&&(r({...l,auth_token:[...l.auth_token,c]}),d(""))},p=j=>{r({...l,auth_token:l.auth_token.filter((b,y)=>y!==j)})},g=()=>{m&&!l.api_server_allowed_api_keys.includes(m)&&(r({...l,api_server_allowed_api_keys:[...l.api_server_allowed_api_keys,m]}),h(""))},N=j=>{r({...l,api_server_allowed_api_keys:l.api_server_allowed_api_keys.filter((b,y)=>y!==j)})};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-2",children:"旧版 API 认证令牌"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"用于旧版 API 验证,为空则不启用验证"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ne,{value:c,onChange:j=>d(j.target.value),placeholder:"输入认证令牌",onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),f())}}),e.jsx(_,{onClick:f,size:"sm",children:e.jsx(Xs,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:l.auth_token.map((j,b)=>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:j}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>p(b),children:e.jsx(os,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},b))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"新版 API Server 配置"}),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(T,{children:"启用新版 API Server"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否启用额外的新版 API Server(额外监听端口)"})]}),e.jsx(Ge,{checked:l.enable_api_server,onCheckedChange:j=>r({...l,enable_api_server:j})})]}),l.enable_api_server&&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(T,{children:"主机地址"}),e.jsx(ne,{value:l.api_server_host,onChange:j=>r({...l,api_server_host:j.target.value}),placeholder:"0.0.0.0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"端口号"}),e.jsx(ne,{type:"number",value:l.api_server_port,onChange:j=>r({...l,api_server_port:parseInt(j.target.value)}),placeholder:"8090"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:l.api_server_use_wss,onCheckedChange:j=>r({...l,api_server_use_wss:j})}),e.jsx(T,{children:"启用 WSS 安全连接"})]}),l.api_server_use_wss&&e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"SSL 证书文件路径"}),e.jsx(ne,{value:l.api_server_cert_file,onChange:j=>r({...l,api_server_cert_file:j.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"SSL 密钥文件路径"}),e.jsx(ne,{value:l.api_server_key_file,onChange:j=>r({...l,api_server_key_file:j.target.value}),placeholder:"key.pem"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"mb-2 block",children:"允许的 API Key 列表"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"为空则允许所有连接"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ne,{value:m,onChange:j=>h(j.target.value),placeholder:"输入 API Key",onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),g())}}),e.jsx(_,{onClick:g,size:"sm",children:e.jsx(Xs,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:l.api_server_allowed_api_keys.map((j,b)=>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:j}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>N(b),children:e.jsx(os,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},b))})]})]})]})]})]})}),dS=Bs.memo(function({config:l,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(T,{children:"启用统计信息发送"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"发送匿名统计信息,帮助我们了解全球有多少只麦麦在运行"})]}),e.jsx(Ge,{checked:l.enable,onCheckedChange:c=>r({...l,enable:c})})]})]})}),uS=Bs.memo(function({emojiConfig:l,memoryConfig:r,toolConfig:c,voiceConfig:d,onEmojiChange:m,onMemoryChange:h,onToolChange:f,onVoiceChange:p}){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:"space-y-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"enable_tool",checked:c.enable_tool,onCheckedChange:g=>f({...c,enable_tool:g})}),e.jsx(T,{htmlFor:"enable_tool",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 pt-2",children:[e.jsx(Ge,{id:"enable_asr",checked:d.enable_asr,onCheckedChange:g=>p({...d,enable_asr:g})}),e.jsx(T,{htmlFor:"enable_asr",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-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"max_agent_iterations",children:"记忆思考深度"}),e.jsx(ne,{id:"max_agent_iterations",type:"number",min:"1",value:r.max_agent_iterations,onChange:g=>h({...r,max_agent_iterations:parseInt(g.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"最低为 1(不深入思考)"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"agent_timeout_seconds",children:"最长回忆时间(秒)"}),e.jsx(ne,{id:"agent_timeout_seconds",type:"number",min:"1",step:"0.1",value:r.agent_timeout_seconds??120,onChange:g=>h({...r,agent_timeout_seconds:parseFloat(g.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(Ge,{id:"enable_jargon_detection",checked:r.enable_jargon_detection??!0,onCheckedChange:g=>h({...r,enable_jargon_detection:g})}),e.jsx(T,{htmlFor:"enable_jargon_detection",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(Ge,{id:"global_memory",checked:r.global_memory??!1,onCheckedChange:g=>h({...r,global_memory:g})}),e.jsx(T,{htmlFor:"global_memory",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-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsx(ne,{id:"emoji_chance",type:"number",step:"0.1",min:"0",max:"1",value:l.emoji_chance,onChange:g=>m({...l,emoji_chance:parseFloat(g.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"范围 0-1,越大越容易发送表情包"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"max_reg_num",children:"最大注册数量"}),e.jsx(ne,{id:"max_reg_num",type:"number",min:"1",value:l.max_reg_num,onChange:g=>m({...l,max_reg_num:parseInt(g.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦最多可以注册的表情包数量"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ne,{id:"check_interval",type:"number",min:"1",value:l.check_interval,onChange:g=>m({...l,check_interval:parseInt(g.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(Ge,{id:"do_replace",checked:l.do_replace,onCheckedChange:g=>m({...l,do_replace:g})}),e.jsx(T,{htmlFor:"do_replace",className:"cursor-pointer",children:"达到最大数量时替换表情包"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"steal_emoji",checked:l.steal_emoji,onCheckedChange:g=>m({...l,steal_emoji:g})}),e.jsx(T,{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(Ge,{id:"content_filtration",checked:l.content_filtration,onCheckedChange:g=>m({...l,content_filtration:g})}),e.jsx(T,{htmlFor:"content_filtration",className:"cursor-pointer",children:"启用表情包过滤"})]}),l.content_filtration&&e.jsxs("div",{className:"grid gap-2 pl-6 border-l-2 border-primary/20",children:[e.jsx(T,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ne,{id:"filtration_prompt",value:l.filtration_prompt,onChange:g=>m({...l,filtration_prompt:g.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}),mS=Bs.memo(function({member:l,groupIndex:r,memberIndex:c,availableChatIds:d,onUpdate:m,onRemove:h}){const f=d.includes(l)||l==="*",[p,g]=u.useState(!f);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 flex gap-2",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ne,{value:l,onChange:N=>m(r,c,N.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),d.length>0&&e.jsx(_,{size:"sm",variant:"outline",onClick:()=>g(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{value:l,onValueChange:N=>m(r,c,N),children:[e.jsx(Be,{className:"flex-1",children:e.jsx(Fe,{placeholder:"选择聊天流"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"*",children:"* (全局共享)"}),d.map((N,j)=>e.jsx(W,{value:N,children:N},j))]})]}),e.jsx(_,{size:"sm",variant:"outline",onClick:()=>g(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除组成员 "',l||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>h(r,c),children:"删除"})]})]})]})]})}),xS=Bs.memo(function({config:l,onChange:r}){const c=()=>{r({...l,learning_list:[...l.learning_list,["","enable","enable","1.0"]]})},d=b=>{r({...l,learning_list:l.learning_list.filter((y,w)=>w!==b)})},m=(b,y,w)=>{const z=[...l.learning_list];z[b][y]=w,r({...l,learning_list:z})},h=({rule:b})=>{const y=`["${b[0]}", "${b[1]}", "${b[2]}", "${b[3]}"]`;return e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(tl,{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:y}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},f=()=>{r({...l,expression_groups:[...l.expression_groups,[]]})},p=b=>{r({...l,expression_groups:l.expression_groups.filter((y,w)=>w!==b)})},g=b=>{const y=[...l.expression_groups];y[b]=[...y[b],""],r({...l,expression_groups:y})},N=(b,y)=>{const w=[...l.expression_groups];w[b]=w[b].filter((z,M)=>M!==y),r({...l,expression_groups:w})},j=(b,y,w)=>{const z=[...l.expression_groups];z[b][y]=w,r({...l,expression_groups:z})};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-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"黑话设置"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"all_global_jargon",checked:l.all_global_jargon??!1,onCheckedChange:b=>r({...l,all_global_jargon:b})}),e.jsx(T,{htmlFor:"all_global_jargon",className:"cursor-pointer",children:"全局黑话模式"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"开启后,新增的黑话将默认设为全局(所有聊天流共享)。关闭后,已记录的全局黑话不会改变,需要手动删除。"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"enable_jargon_explanation",checked:l.enable_jargon_explanation??!0,onCheckedChange:b=>r({...l,enable_jargon_explanation:b})}),e.jsx(T,{htmlFor:"enable_jargon_explanation",className:"cursor-pointer",children:"启用黑话解释"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"在回复前尝试对上下文中的黑话进行解释。关闭可减少一次LLM调用,仅影响回复前的黑话匹配与解释,不影响黑话学习。"})]}),e.jsxs("div",{children:[e.jsx(T,{htmlFor:"jargon_mode",children:"黑话解释来源模式"}),e.jsxs(Pe,{value:l.jargon_mode??"context",onValueChange:b=>r({...l,jargon_mode:b}),children:[e.jsx(Be,{id:"jargon_mode",className:"mt-2",children:e.jsx(Fe,{placeholder:"选择黑话解释来源"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"context",children:"上下文模式(自动匹配黑话)"}),e.jsx(W,{value:"planner",children:"Planner模式(使用unknown_words列表)"})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["上下文模式:使用上下文自动匹配黑话并解释",e.jsx("br",{}),"Planner模式:仅使用Planner在reply动作中给出的unknown_words列表进行黑话检索"]})]})]}),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(_,{onClick:c,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[l.learning_list.map((b,y)=>{const w=l.learning_list.some((C,R)=>R!==y&&C[0]===""),z=b[0]==="",M=b[0].split(":"),S=M[0]||"qq",F=M[1]||"",E=M[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:["规则 ",y+1," ",z&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{rule:b}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除学习规则 ",y+1," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>d(y),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(Pe,{value:z?"global":"specific",onValueChange:C=>{C==="global"?m(y,0,""):m(y,0,"qq::group")},disabled:w&&!z,children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"global",children:"全局配置"}),e.jsx(W,{value:"specific",disabled:w&&!z,children:"详细配置"})]})]}),w&&!z&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!z&&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(T,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Pe,{value:S,onValueChange:C=>{m(y,0,`${C}:${F}:${E}`)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"qq",children:"QQ"}),e.jsx(W,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ne,{value:F,onChange:C=>{m(y,0,`${S}:${C.target.value}:${E}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Pe,{value:E,onValueChange:C=>{m(y,0,`${S}:${F}:${C}`)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"group",children:"群组(group)"}),e.jsx(W,{value:"private",children:"私聊(private)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前聊天流 ID:",b[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(T,{className:"text-xs font-medium",children:"使用学到的表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦使用从聊天中学到的表达方式"})]}),e.jsx(Ge,{checked:b[1]==="enable",onCheckedChange:C=>m(y,1,C?"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(T,{className:"text-xs font-medium",children:"学习表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦从聊天中学习新的表达方式"})]}),e.jsx(Ge,{checked:b[2]==="enable",onCheckedChange:C=>m(y,2,C?"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(T,{className:"text-xs font-medium",children:"启用黑话学习"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦在此聊天流中学习和记录黑话"})]}),e.jsx(Ge,{checked:b[3]==="true"||b[3]==="enable",onCheckedChange:C=>m(y,3,C?"true":"false")})]})})]})]},y)}),l.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",{className:"space-y-6",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("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{htmlFor:"expression_self_reflect",className:"cursor-pointer font-medium",children:"自动表达优化"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后,麦麦会自动检查并优化表达方式,无需管理员手动干预"})]}),e.jsx(Ge,{id:"expression_self_reflect",checked:l.expression_self_reflect??!1,onCheckedChange:b=>r({...l,expression_self_reflect:b})})]}),l.expression_self_reflect&&e.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"expression_auto_check_interval",children:"自动检查间隔(秒)"}),e.jsx(ne,{id:"expression_auto_check_interval",type:"number",min:"60",value:l.expression_auto_check_interval??3600,onChange:b=>r({...l,expression_auto_check_interval:parseInt(b.target.value)||3600})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"表达方式自动检查的间隔时间(单位:秒),默认值:3600秒(1小时)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"expression_auto_check_count",children:"每次检查数量"}),e.jsx(ne,{id:"expression_auto_check_count",type:"number",min:"1",max:"100",value:l.expression_auto_check_count??10,onChange:b=>r({...l,expression_auto_check_count:parseInt(b.target.value)||10})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次自动检查时随机选取的表达方式数量,默认值:10条"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:"自定义评估标准"}),e.jsxs(_,{onClick:()=>{r({...l,expression_auto_check_custom_criteria:[...l.expression_auto_check_custom_criteria||[],""]})},size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加标准"]})]}),e.jsxs("div",{className:"space-y-2",children:[(l.expression_auto_check_custom_criteria||[]).map((b,y)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{value:b,onChange:w=>{const z=[...l.expression_auto_check_custom_criteria||[]];z[y]=w.target.value,r({...l,expression_auto_check_custom_criteria:z})},placeholder:"输入评估标准,例如:是否符合角色人设",className:"flex-1"}),e.jsx(_,{onClick:()=>{r({...l,expression_auto_check_custom_criteria:(l.expression_auto_check_custom_criteria||[]).filter((w,z)=>z!==y)})},size:"icon",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})]},y)),(!l.expression_auto_check_custom_criteria||l.expression_auto_check_custom_criteria.length===0)&&e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:'暂无自定义标准,点击"添加标准"开始配置'})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这些标准会被添加到评估提示词中,作为额外的评估要求"})]})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{htmlFor:"expression_checked_only",className:"cursor-pointer font-medium",children:"仅使用已审核通过的表达方式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后,只有通过审核(已检查)的项目会被使用;关闭时,未审核的项目也会被使用。无论开关状态,被拒绝的项目永远不会被使用。"})]}),e.jsx(Ge,{id:"expression_checked_only",checked:l.expression_checked_only??!1,onCheckedChange:b=>r({...l,expression_checked_only:b})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{htmlFor:"expression_manual_reflect",className:"cursor-pointer font-medium",children:"手动表达优化"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后,麦麦会主动向管理员询问表达方式是否合适"})]}),e.jsx(Ge,{id:"expression_manual_reflect",checked:l.expression_manual_reflect??!1,onCheckedChange:b=>r({...l,expression_manual_reflect:b})})]}),l.expression_manual_reflect&&e.jsxs("div",{className:"space-y-4 pl-4 border-l-2 border-primary/20",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 y=(l.manual_reflect_operator_id||"").split(":"),w=y[0]||"qq",z=y[1]||"",M=y[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(T,{className:"text-xs font-medium",children:"平台"}),e.jsxs(Pe,{value:w,onValueChange:S=>{r({...l,manual_reflect_operator_id:`${S}:${z}:${M}`})},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"qq",children:"QQ"}),e.jsx(W,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"用户/群 ID"}),e.jsx(ne,{value:z,onChange:S=>{r({...l,manual_reflect_operator_id:`${w}:${S.target.value}:${M}`})},placeholder:"输入 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"类型"}),e.jsxs(Pe,{value:M,onValueChange:S=>{r({...l,manual_reflect_operator_id:`${w}:${z}:${S}`})},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"private",children:"私聊(private)"}),e.jsx(W,{value:"group",children:"群组(group)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前操作员 ID:",l.manual_reflect_operator_id||"(未设置)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'手动表达优化操作员ID,格式:platform:id:type (例如 "qq:123456:private" 或 "qq:654321:group")'})]})})()})]}),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(_,{onClick:()=>{r({...l,allow_reflect:[...l.allow_reflect||[],"qq::group"]})},size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加聊天流"]})]}),e.jsxs("div",{className:"space-y-2",children:[(l.allow_reflect||[]).map((b,y)=>{const w=b.split(":"),z=w[0]||"qq",M=w[1]||"",S=w[2]||"group";return e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50",children:[e.jsxs(Pe,{value:z,onValueChange:F=>{const E=[...l.allow_reflect];E[y]=`${F}:${M}:${S}`,r({...l,allow_reflect:E})},children:[e.jsx(Be,{className:"w-24",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"qq",children:"QQ"}),e.jsx(W,{value:"wx",children:"微信"})]})]}),e.jsx(ne,{value:M,onChange:F=>{const E=[...l.allow_reflect];E[y]=`${z}:${F.target.value}:${S}`,r({...l,allow_reflect:E})},placeholder:"ID",className:"flex-1 font-mono text-sm"}),e.jsxs(Pe,{value:S,onValueChange:F=>{const E=[...l.allow_reflect];E[y]=`${z}:${M}:${F}`,r({...l,allow_reflect:E})},children:[e.jsx(Be,{className:"w-32",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"group",children:"群组"}),e.jsx(W,{value:"private",children:"私聊"})]})]}),e.jsx(_,{onClick:()=>{r({...l,allow_reflect:l.allow_reflect.filter((F,E)=>E!==y)})},size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})]},y)}),(!l.allow_reflect||l.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(_,{onClick:f,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[l.expression_groups.map((b,y)=>{const w=l.learning_list.map(z=>z[0]).filter(z=>z!=="");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:["共享组 ",y+1,b.length===1&&b[0]==="*"&&"(全局共享)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{onClick:()=>g(y),size:"sm",variant:"outline",children:e.jsx(Xs,{className:"h-4 w-4"})}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除共享组 ",y+1," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>p(y),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:b.map((z,M)=>e.jsx(mS,{member:z,groupIndex:y,memberIndex:M,availableChatIds:w,onUpdate:j,onRemove:N},`${y}-${M}`))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},y)}),l.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})})]})});function hS({regex:a,reaction:l,onRegexChange:r,onReactionChange:c}){const[d,m]=u.useState(!1),[h,f]=u.useState(""),[p,g]=u.useState(null),[N,j]=u.useState(""),[b,y]=u.useState({}),[w,z]=u.useState(""),M=u.useRef(null),[S,F]=u.useState("build"),E=O=>O.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),C=(O,X=0)=>{const L=M.current;if(!L)return;const me=L.selectionStart||0,Ne=L.selectionEnd||0,je=a.substring(0,me)+O+a.substring(Ne);r(je),setTimeout(()=>{const ce=me+O.length+X;L.setSelectionRange(ce,ce),L.focus()},0)};u.useEffect(()=>{if(!a||!h){p!==null&&g(null),Object.keys(b).length>0&&y({}),w!==l&&z(l),N!==""&&j("");return}try{const O=E(a),X=new RegExp(O,"g"),L=h.match(X);g(L),j("");const Ne=new RegExp(O).exec(h);if(Ne&&Ne.groups){y(Ne.groups);let je=l;Object.entries(Ne.groups).forEach(([ce,ge])=>{je=je.replace(new RegExp(`\\[${ce}\\]`,"g"),ge||"")}),z(je)}else y({}),z(l)}catch(O){j(O.message),g(null),y({}),z(l)}},[a,h,l,p,b,w,N]);const R=()=>{if(!h||!p||p.length===0)return e.jsx("span",{className:"text-muted-foreground",children:h||"请输入测试文本"});try{const O=E(a),X=new RegExp(O,"g");let L=0;const me=[];let Ne;for(;(Ne=X.exec(h))!==null;)Ne.index>L&&me.push(e.jsx("span",{children:h.substring(L,Ne.index)},`text-${L}`)),me.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:Ne[0]},`match-${Ne.index}`)),L=Ne.index+Ne[0].length;return L<h.length&&me.push(e.jsx("span",{children:h.substring(L)},`text-${L}`)),e.jsx(e.Fragment,{children:me})}catch{return e.jsx("span",{children:h})}},H=[{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(Qs,{open:d,onOpenChange:m,children:[e.jsx(dd,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ux,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(Hs,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"正则表达式编辑器"}),e.jsx(at,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(ts,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(Jt,{value:S,onValueChange:O=>F(O),className:"w-full",children:[e.jsxs(Gt,{className:"grid w-full grid-cols-2",children:[e.jsx(Xe,{value:"build",children:"🔧 构建器"}),e.jsx(Xe,{value:"test",children:"🧪 测试器"})]}),e.jsxs(Ss,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(ne,{ref:M,value:a,onChange:O=>r(O.target.value),className:"font-mono text-sm",placeholder:"点击下方按钮构建正则表达式..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"Reaction 内容"}),e.jsx(pt,{value:l,onChange:O=>c(O.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[H.map(O=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:O.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:O.items.map(X=>e.jsx(_,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>C(X.pattern,X.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:X.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:X.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:X.desc})]})},X.label))})]},O.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(_,{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(_,{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(_,{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(Ss,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:a||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(pt,{id:"test-text",value:h,onChange:O=>f(O.target.value),placeholder:`在此输入要测试的文本...
|
||
例如:打游戏是这样的`,className:"min-h-[100px] text-sm"})]}),N&&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:N})]}),!N&&h&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:p&&p.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:["匹配成功 (",p.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(T,{className:"text-sm font-medium",children:"匹配高亮"}),e.jsx(ts,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:R()})})]}),Object.keys(b).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(ts,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(b).map(([O,X])=>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:["[",O,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:X})]},O))})})]}),Object.keys(b).length>0&&l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(ts,{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:w})}),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 fS=Bs.memo(function({keywordReactionConfig:l,responsePostProcessConfig:r,chineseTypoConfig:c,responseSplitterConfig:d,onKeywordReactionChange:m,onResponsePostProcessChange:h,onChineseTypoChange:f,onResponseSplitterChange:p}){const g=()=>{m({...l,regex_rules:[...l.regex_rules,{regex:[""],reaction:""}]})},N=C=>{m({...l,regex_rules:l.regex_rules.filter((R,H)=>H!==C)})},j=(C,R,H)=>{const O=[...l.regex_rules];R==="regex"&&typeof H=="string"?O[C]={...O[C],regex:[H]}:R==="reaction"&&typeof H=="string"&&(O[C]={...O[C],reaction:H}),m({...l,regex_rules:O})},b=()=>{m({...l,keyword_rules:[...l.keyword_rules,{keywords:[],reaction:""}]})},y=C=>{m({...l,keyword_rules:l.keyword_rules.filter((R,H)=>H!==C)})},w=(C,R,H)=>{const O=[...l.keyword_rules];typeof H=="string"&&(O[C]={...O[C],reaction:H}),m({...l,keyword_rules:O})},z=C=>{const R=[...l.keyword_rules];R[C]={...R[C],keywords:[...R[C].keywords||[],""]},m({...l,keyword_rules:R})},M=(C,R)=>{const H=[...l.keyword_rules];H[C]={...H[C],keywords:(H[C].keywords||[]).filter((O,X)=>X!==R)},m({...l,keyword_rules:H})},S=(C,R,H)=>{const O=[...l.keyword_rules],X=[...O[C].keywords||[]];X[R]=H,O[C]={...O[C],keywords:X},m({...l,keyword_rules:O})},F=({rule:C})=>{const R=`{ regex = [${(C.regex||[]).map(H=>`"${H}"`).join(", ")}], reaction = "${C.reaction}" }`;return e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(tl,{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(ts,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:R})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},E=({rule:C})=>{const R=`[[keyword_reaction.keyword_rules]]
|
||
keywords = [${(C.keywords||[]).map(H=>`"${H}"`).join(", ")}]
|
||
reaction = "${C.reaction}"`;return e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(tl,{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(ts,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:R})}),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(_,{onClick:g,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[l.regex_rules.map((C,R)=>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:["正则规则 ",R+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hS,{regex:C.regex&&C.regex[0]||"",reaction:C.reaction,onRegexChange:H=>j(R,"regex",H),onReactionChange:H=>j(R,"reaction",H)}),e.jsx(F,{rule:C}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除正则规则 ",R+1," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>N(R),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"正则表达式(Python 语法)"}),e.jsx(ne,{value:C.regex&&C.regex[0]||"",onChange:H=>j(R,"regex",H.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(T,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(pt,{value:C.reaction,onChange:H=>j(R,"reaction",H.target.value),placeholder:`触发后麦麦的反应...
|
||
可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},R)),l.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(_,{onClick:b,size:"sm",variant:"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[l.keyword_rules.map((C,R)=>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:["关键词规则 ",R+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{rule:C}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除关键词规则 ",R+1," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>y(R),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(T,{className:"text-xs font-medium",children:"关键词列表"}),e.jsxs(_,{onClick:()=>z(R),size:"sm",variant:"ghost",children:[e.jsx(Xs,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(C.keywords||[]).map((H,O)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{value:H,onChange:X=>S(R,O,X.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(_,{onClick:()=>M(R,O),size:"sm",variant:"ghost",children:e.jsx(os,{className:"h-4 w-4"})})]},O)),(!C.keywords||C.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(T,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(pt,{value:C.reaction,onChange:H=>w(R,"reaction",H.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},R)),l.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(Ge,{id:"enable_response_post_process",checked:r.enable_response_post_process,onCheckedChange:C=>h({...r,enable_response_post_process:C})}),e.jsx(T,{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(Ge,{id:"enable_chinese_typo",checked:c.enable,onCheckedChange:C=>f({...c,enable:C})}),e.jsx(T,{htmlFor:"enable_chinese_typo",className:"cursor-pointer font-semibold",children:"中文错别字生成器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"为回复添加随机错别字,让麦麦的回复更自然"}),c.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(T,{htmlFor:"error_rate",className:"text-xs font-medium",children:"单字替换概率"}),e.jsx(ne,{id:"error_rate",type:"number",step:"0.001",min:"0",max:"1",value:c.error_rate,onChange:C=>f({...c,error_rate:parseFloat(C.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"min_freq",className:"text-xs font-medium",children:"最小字频阈值"}),e.jsx(ne,{id:"min_freq",type:"number",min:"0",value:c.min_freq,onChange:C=>f({...c,min_freq:parseInt(C.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"tone_error_rate",className:"text-xs font-medium",children:"声调错误概率"}),e.jsx(ne,{id:"tone_error_rate",type:"number",step:"0.01",min:"0",max:"1",value:c.tone_error_rate,onChange:C=>f({...c,tone_error_rate:parseFloat(C.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"word_replace_rate",className:"text-xs font-medium",children:"整词替换概率"}),e.jsx(ne,{id:"word_replace_rate",type:"number",step:"0.001",min:"0",max:"1",value:c.word_replace_rate,onChange:C=>f({...c,word_replace_rate:parseFloat(C.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(Ge,{id:"enable_response_splitter",checked:d.enable,onCheckedChange:C=>p({...d,enable:C})}),e.jsx(T,{htmlFor:"enable_response_splitter",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(T,{htmlFor:"max_length",className:"text-xs font-medium",children:"最大长度"}),e.jsx(ne,{id:"max_length",type:"number",min:"1",value:d.max_length,onChange:C=>p({...d,max_length:parseInt(C.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大字符数"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"max_sentence_num",className:"text-xs font-medium",children:"最大句子数"}),e.jsx(ne,{id:"max_sentence_num",type:"number",min:"1",value:d.max_sentence_num,onChange:C=>p({...d,max_sentence_num:parseInt(C.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(Ge,{id:"enable_kaomoji_protection",checked:d.enable_kaomoji_protection,onCheckedChange:C=>p({...d,enable_kaomoji_protection:C})}),e.jsx(T,{htmlFor:"enable_kaomoji_protection",className:"cursor-pointer",children:"启用颜文字保护"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"enable_overflow_return_all",checked:d.enable_overflow_return_all,onCheckedChange:C=>p({...d,enable_overflow_return_all:C})}),e.jsx(T,{htmlFor:"enable_overflow_return_all",className:"cursor-pointer",children:"超出时一次性返回全部"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})});function pS({config:a,onChange:l}){const[r,c]=u.useState(""),[d,m]=u.useState(""),h=()=>{const b=r.trim();b&&!a.ban_words.includes(b)&&(l({...a,ban_words:[...a.ban_words,b]}),c(""))},f=b=>{l({...a,ban_words:a.ban_words.filter((y,w)=>w!==b)})},p=b=>{b.key==="Enter"&&(b.preventDefault(),h())},g=()=>{const b=d.trim();if(b&&!a.ban_msgs_regex.includes(b))try{new RegExp(b),l({...a,ban_msgs_regex:[...a.ban_msgs_regex,b]}),m("")}catch(y){alert(`正则表达式语法错误:${y.message}`)}},N=b=>{l({...a,ban_msgs_regex:a.ban_msgs_regex.filter((y,w)=>w!==b)})},j=b=>{b.key==="Enter"&&(b.preventDefault(),g())};return e.jsx("div",{className:"space-y-6",children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"消息过滤配置"}),e.jsx(Ns,{children:"配置消息过滤规则,过滤特定消息或在特定群组启用静默模式"})]}),e.jsx(ze,{children:e.jsxs(Jt,{defaultValue:"ban_words",className:"w-full",children:[e.jsxs(Gt,{className:"grid w-full grid-cols-2",children:[e.jsx(Xe,{value:"ban_words",children:"禁用关键词"}),e.jsx(Xe,{value:"ban_regex",children:"禁用正则"})]}),e.jsx(Ss,{value:"ban_words",className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ut,{className:"h-4 w-4 text-yellow-500 mt-1 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"包含以下关键词的消息将被过滤,Bot 不会读取这些消息"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{placeholder:"输入要禁用的关键词(按回车添加)",value:r,onChange:b=>c(b.target.value),onKeyDown:p}),e.jsx(_,{onClick:h,size:"icon",children:e.jsx(Xs,{className:"h-4 w-4"})})]}),a.ban_words.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-8 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无禁用关键词,点击上方添加"})}):e.jsx("div",{className:"space-y-2",children:a.ban_words.map((b,y)=>e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsx("code",{className:"text-sm",children:b}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"icon",children:e.jsx(os,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除关键词 ",e.jsxs("code",{children:['"',b,'"']})," 吗?"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>f(y),children:"删除"})]})]})]})]},y))})]})}),e.jsx(Ss,{value:"ban_regex",className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ut,{className:"h-4 w-4 text-yellow-500 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsx("p",{children:"匹配以下正则表达式的消息将被过滤"}),e.jsx("p",{className:"text-xs",children:"⚠️ 若不了解正则表达式,请勿随意修改"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pt,{placeholder:`输入正则表达式(按回车添加)
|
||
示例:https?://[^\\s]+ 匹配链接`,value:d,onChange:b=>m(b.target.value),onKeyDown:j,className:"min-h-[60px] font-mono text-sm"}),e.jsx(_,{onClick:g,size:"icon",children:e.jsx(Xs,{className:"h-4 w-4"})})]}),a.ban_msgs_regex.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-8 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无禁用正则表达式,点击上方添加"})}):e.jsx("div",{className:"space-y-2",children:a.ban_msgs_regex.map((b,y)=>e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsx("code",{className:"text-sm font-mono flex-1 break-all",children:b}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"icon",className:"ml-2 flex-shrink-0",children:e.jsx(os,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除正则表达式 ",e.jsxs("code",{children:['"',b,'"']})," 吗?"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>N(y),children:"删除"})]})]})]})]},y))})]})})]})})]})})}const gS=Bs.memo(function({config:l,onChange:r}){const[c,d]=u.useState(""),[m,h]=u.useState(""),[f,p]=u.useState(!1),g=l.allowed_ips?l.allowed_ips.split(",").map(S=>S.trim()).filter(S=>S):[],N=l.trusted_proxies?l.trusted_proxies.split(",").map(S=>S.trim()).filter(S=>S):[],j=()=>{if(!c.trim())return;const S=[...g,c.trim()];r({...l,allowed_ips:S.join(",")}),d("")},b=S=>{const F=g.filter((E,C)=>C!==S);r({...l,allowed_ips:F.join(",")})},y=()=>{if(!m.trim())return;const S=[...N,m.trim()];r({...l,trusted_proxies:S.join(",")}),h("")},w=S=>{const F=N.filter((E,C)=>C!==S);r({...l,trusted_proxies:F.join(",")})},z=S=>{!S&&l.enabled?p(!0):r({...l,enabled:S})},M=()=>{r({...l,enabled:!1}),p(!1)};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:"WebUI 服务配置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:l.enabled,onCheckedChange:z}),e.jsx(T,{className:"cursor-pointer",children:"启用 WebUI"})]}),l.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"运行模式"}),e.jsxs(Pe,{value:l.mode,onValueChange:S=>r({...l,mode:S}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择运行模式"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"development",children:"开发模式"}),e.jsx(W,{value:"production",children:"生产模式"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"注意: WebUI 的监听地址和端口请在 .env 文件中配置 WEBUI_HOST 和 WEBUI_PORT"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"防爬虫模式"}),e.jsxs(Pe,{value:l.anti_crawler_mode,onValueChange:S=>r({...l,anti_crawler_mode:S}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择防爬虫模式"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"false",children:"禁用"}),e.jsx(W,{value:"basic",children:"基础(只记录不阻止)"}),e.jsx(W,{value:"loose",children:"宽松"}),e.jsx(W,{value:"strict",children:"严格"})]})]})]}),e.jsxs("div",{className:"grid gap-2 sm:col-span-2",children:[e.jsx(T,{children:"IP 白名单"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{value:c,onChange:S=>d(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),j())},placeholder:"输入IP地址后按回车或点击添加"}),e.jsx(_,{type:"button",size:"sm",onClick:j,disabled:!c.trim(),children:e.jsx(Xs,{className:"h-4 w-4"})})]}),g.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:g.map((S,F)=>e.jsxs(Ce,{variant:"secondary",className:"flex items-center gap-1",children:[S,e.jsx("button",{type:"button",onClick:()=>b(F),className:"ml-1 hover:bg-destructive/20 rounded-full p-0.5",children:e.jsx(Sa,{className:"h-3 w-3"})})]},F))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持精确IP、CIDR格式和通配符(如:127.0.0.1、192.168.1.0/24)"})]}),e.jsxs("div",{className:"grid gap-2 sm:col-span-2",children:[e.jsx(T,{children:"信任的代理 IP"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{value:m,onChange:S=>h(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),y())},placeholder:"输入代理IP后按回车或点击添加"}),e.jsx(_,{type:"button",size:"sm",onClick:y,disabled:!m.trim(),children:e.jsx(Xs,{className:"h-4 w-4"})})]}),N.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:N.map((S,F)=>e.jsxs(Ce,{variant:"secondary",className:"flex items-center gap-1",children:[S,e.jsx("button",{type:"button",onClick:()=>w(F),className:"ml-1 hover:bg-destructive/20 rounded-full p-0.5",children:e.jsx(Sa,{className:"h-3 w-3"})})]},F))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有来自这些IP的X-Forwarded-For头才被信任"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:l.trust_xff,onCheckedChange:S=>r({...l,trust_xff:S})}),e.jsx(T,{className:"cursor-pointer",children:"启用 X-Forwarded-For 代理解析"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:l.secure_cookie,onCheckedChange:S=>r({...l,secure_cookie:S})}),e.jsx(T,{className:"cursor-pointer",children:"启用安全 Cookie(仅 HTTPS)"})]})]})]}),e.jsx(bs,{open:f,onOpenChange:p,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"警告:即将关闭 WebUI"}),e.jsxs(gs,{children:["关闭 WebUI 后,在您下次重启麦麦之前,WebUI 界面将无法访问。",e.jsx("br",{}),e.jsx("br",{}),"您需要通过修改配置文件或命令行重新启用 WebUI 才能再次访问此界面。",e.jsx("br",{}),e.jsx("br",{}),"确定要关闭 WebUI 吗?"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{variant:"destructive",onClick:M,children:"确认关闭"})]})]})})]})}),En="/api/webui/config";async function Hg(){const l=await(await ke(`${En}/bot`)).json();if(!l.success)throw new Error("获取配置数据失败");return l.config}async function Nn(){const l=await(await ke(`${En}/model`)).json();if(!l.success)throw new Error("获取模型配置数据失败");return l.config}async function qg(a){const r=await(await ke(`${En}/bot`,{method:"POST",body:JSON.stringify(a)})).json();if(!r.success)throw new Error(r.message||"保存配置失败")}async function jS(){const l=await(await ke(`${En}/bot/raw`)).json();if(!l.success)throw new Error("获取配置源代码失败");return l.content}async function vS(a){const r=await(await ke(`${En}/bot/raw`,{method:"POST",body:JSON.stringify({raw_content:a})})).json();if(!r.success)throw new Error(r.message||"保存配置失败")}async function lc(a){const r=await(await ke(`${En}/model`,{method:"POST",body:JSON.stringify(a)})).json();if(!r.success)throw new Error(r.message||"保存配置失败")}async function NS(a,l){const c=await(await ke(`${En}/bot/section/${a}`,{method:"POST",body:JSON.stringify(l)})).json();if(!c.success)throw new Error(c.message||`保存配置节 ${a} 失败`)}async function Wm(a,l){const c=await(await ke(`${En}/model/section/${a}`,{method:"POST",body:JSON.stringify(l)})).json();if(!c.success)throw new Error(c.message||`保存配置节 ${a} 失败`)}async function bS(a,l="openai",r="/models"){const c=new URLSearchParams({provider_name:a,parser:l,endpoint:r}),d=await ke(`/api/webui/models/list?${c}`);if(!d.ok){const h=await d.json().catch(()=>({}));throw new Error(h.detail||`获取模型列表失败 (${d.status})`)}const m=await d.json();if(!m.success)throw new Error("获取模型列表失败");return m.models}async function yS(a){const l=new URLSearchParams({provider_name:a}),r=await ke(`/api/webui/models/test-connection-by-name?${l}`,{method:"POST"});if(!r.ok){const c=await r.json().catch(()=>({}));throw new Error(c.detail||`测试连接失败 (${r.status})`)}return await r.json()}const wS=ti("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"}}),ht=u.forwardRef(({className:a,variant:l,...r},c)=>e.jsx("div",{ref:c,role:"alert",className:P(wS({variant:l}),a),...r}));ht.displayName="Alert";const Jn=u.forwardRef(({className:a,...l},r)=>e.jsx("h5",{ref:r,className:P("mb-1 font-medium leading-none tracking-tight",a),...l}));Jn.displayName="AlertTitle";const ft=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{ref:r,className:P("text-sm [&_p]:leading-relaxed",a),...l}));ft.displayName="AlertDescription";const _S={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(a,l){let r;if(!l.inString&&(r=a.match(/^('''|"""|'|")/))&&(l.stringType=r[0],l.inString=!0),a.sol()&&!l.inString&&l.inArray===0&&(l.lhs=!0),l.inString){for(;l.inString;)if(a.match(l.stringType))l.inString=!1;else if(a.peek()==="\\")a.next(),a.next();else{if(a.eol())break;a.match(/^.[^\\\"\']*/)}return l.lhs?"property":"string"}else{if(l.inArray&&a.peek()==="]")return a.next(),l.inArray--,"bracket";if(l.lhs&&a.peek()==="["&&a.skipTo("]"))return a.next(),a.peek()==="]"&&a.next(),"atom";if(a.peek()==="#")return a.skipToEnd(),"comment";if(a.eatSpace())return null;if(l.lhs&&a.eatWhile(function(c){return c!="="&&c!=" "}))return"property";if(l.lhs&&a.peek()==="=")return a.next(),l.lhs=!1,null;if(!l.lhs&&a.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!l.lhs&&(a.match("true")||a.match("false")))return"atom";if(!l.lhs&&a.peek()==="[")return l.inArray++,a.next(),"bracket";if(!l.lhs&&a.match(/^\-?\d+(?:\.\d+)?/))return"number";a.eatSpace()||a.next()}return null},languageData:{commentTokens:{line:"#"}}},SS={python:[d_()],json:[u_(),m_()],toml:[o_.define(_S)],text:[]};function Qv({value:a,onChange:l,language:r="text",readOnly:c=!1,height:d="400px",minHeight:m,maxHeight:h,placeholder:f,theme:p="dark",className:g=""}){const[N,j]=u.useState(!1);if(u.useEffect(()=>{j(!0)},[]),!N)return e.jsx("div",{className:`rounded-md border bg-muted animate-pulse ${g}`,style:{height:d,minHeight:m,maxHeight:h}});const b=[...SS[r]||[],zm.lineWrapping,zm.theme({"&":{fontFamily:'"JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace'},".cm-content":{fontFamily:'"JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace'},".cm-gutters":{fontFamily:'"JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace'},".cm-scroller":{fontFamily:'"JetBrains Mono", "Fira Code", "Consolas", "Monaco", monospace'}})];return c&&b.push(zm.editable.of(!1)),e.jsx("div",{className:`rounded-md overflow-hidden border custom-scrollbar ${g}`,children:e.jsx(x_,{value:a,height:d,minHeight:m,maxHeight:h,theme:p==="dark"?h_:void 0,extensions:b,onChange:l,placeholder:f,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 kS({id:a,index:l,itemType:r,itemFields:c,value:d,onChange:m,onRemove:h,disabled:f,canRemove:p,placeholder:g}){const{attributes:N,listeners:j,setNodeRef:b,transform:y,transition:w,isDragging:z}=Cv({id:a,disabled:f}),M={transform:Tv.Transform.toString(y),transition:w};return e.jsxs("div",{ref:b,style:M,className:P("flex items-start gap-2 group",z&&"opacity-50 z-50"),children:[e.jsx("button",{type:"button",className:P("flex-shrink-0 p-2 cursor-grab active:cursor-grabbing","text-muted-foreground hover:text-foreground transition-colors","opacity-0 group-hover:opacity-100 focus:opacity-100",f&&"cursor-not-allowed opacity-30"),...N,...j,children:e.jsx(dv,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1 min-w-0",children:r==="object"&&c?e.jsx(CS,{value:d,onChange:m,fields:c,disabled:f}):r==="number"?e.jsx(ne,{type:"number",value:d??"",onChange:S=>m(parseFloat(S.target.value)||0),placeholder:g??`第 ${l+1} 项`,disabled:f,className:"font-mono"}):e.jsx(ne,{type:"text",value:d??"",onChange:S=>m(S.target.value),placeholder:g??`第 ${l+1} 项`,disabled:f})}),e.jsx(_,{type:"button",variant:"ghost",size:"icon",onClick:h,disabled:f||!p,className:P("flex-shrink-0 text-muted-foreground hover:text-destructive","opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity"),children:e.jsx(os,{className:"h-4 w-4"})})]})}function CS({value:a,onChange:l,fields:r,disabled:c}){const d=u.useCallback((h,f)=>{l({...a,[h]:f})},[a,l]),m=(h,f)=>{const p=a?.[h];if(f.type==="boolean"||f.type==="switch")return e.jsxs("div",{className:"flex items-center justify-between py-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx(Ge,{checked:!!(p??f.default),onCheckedChange:g=>d(h,g),disabled:c})]});if(f.type==="slider"||f.type==="number"&&f.min!=null&&f.max!=null){const g=p??f.default??f.min??0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx("span",{className:"text-xs text-muted-foreground",children:g})]}),e.jsx(el,{value:[g],onValueChange:N=>d(h,N[0]),min:f.min??0,max:f.max??100,step:f.step??1,disabled:c,className:"py-1"})]})}return f.type==="select"&&f.choices?e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsxs(Pe,{value:String(p??f.default??""),onValueChange:g=>d(h,g),disabled:c,children:[e.jsx(Be,{className:"h-8 text-sm",children:e.jsx(Fe,{placeholder:f.placeholder??"请选择"})}),e.jsx(Ie,{children:f.choices.map(g=>e.jsx(W,{value:String(g),children:String(g)},String(g)))})]})]}):f.type==="number"?e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx(ne,{type:"number",value:p??f.default??"",onChange:g=>d(h,parseFloat(g.target.value)||0),placeholder:f.placeholder,disabled:c,className:"h-8 text-sm"})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:f.label??h}),e.jsx(ne,{type:"text",value:p??f.default??"",onChange:g=>d(h,g.target.value),placeholder:f.placeholder,disabled:c,className:"h-8 text-sm"})]})};return e.jsx(Te,{className:"p-3 space-y-2 bg-muted/30",children:Object.entries(r).map(([h,f])=>e.jsx("div",{children:m(h,f)},h))})}function TS({value:a,onChange:l,itemType:r="string",itemFields:c,minItems:d,maxItems:m,disabled:h,placeholder:f}){const p=u.useMemo(()=>Array.isArray(a)?a:typeof a=="string"&&a.trim()?a.split(",").map(E=>E.trim()):[],[a]),[g]=u.useState(()=>new Map),N=u.useCallback(E=>(g.has(E)||g.set(E,`item-${Date.now()}-${E}-${Math.random().toString(36).slice(2)}`),g.get(E)),[g]),j=u.useMemo(()=>{const E=[];for(let C=0;C<p.length;C++)E.push(N(C));return E},[p.length,N]),b=vv(Qo(yv,{activationConstraint:{distance:8}}),Qo(bv,{coordinateGetter:Nv})),y=u.useCallback(E=>{const{active:C,over:R}=E;if(R&&C.id!==R.id){const H=j.indexOf(C.id),O=j.indexOf(R.id),X=wv(p,H,O);l(X)}},[p,j,l]),w=u.useCallback(()=>{if(m!=null&&p.length>=m)return;let E;r==="object"&&c?E=Object.fromEntries(Object.entries(c).map(([C,R])=>[C,R.default??""])):r==="number"?E=0:E="",l([...p,E])},[p,m,r,c,l]),z=u.useCallback((E,C)=>{const R=[...p];R[E]=C,l(R)},[p,l]),M=u.useCallback(E=>{if(d!=null&&p.length<=d)return;const C=p.filter((R,H)=>H!==E);g.delete(E),l(C)},[p,d,g,l]),S=m==null||p.length<m,F=d==null||p.length>d;return e.jsxs("div",{className:"space-y-2",children:[p.length===0?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-4 justify-center border border-dashed rounded-md",children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsx("span",{children:"暂无数据,点击下方按钮添加"})]}):e.jsx(_v,{sensors:b,collisionDetection:Sv,onDragEnd:y,children:e.jsx(kv,{items:j,strategy:f_,children:e.jsx("div",{className:"space-y-2",children:p.map((E,C)=>e.jsx(kS,{id:j[C],index:C,itemType:r,itemFields:c,value:E,onChange:R=>z(C,R),onRemove:()=>M(C),disabled:h,canRemove:F,placeholder:f},j[C]))})})}),e.jsxs(_,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:h||!S,className:"w-full",children:[e.jsx(Xs,{className:"h-4 w-4 mr-1"}),"添加项目",m!==void 0&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",p.length,"/",m,")"]})]}),(d!=null||m!=null)&&(d!==null||m!==null)&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:d!=null&&m!=null?`允许 ${d} - ${m} 项`:d!=null?`至少 ${d} 项`:`最多 ${m} 项`})]})}function bx({content:a,className:l=""}){return e.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none ${l}`,children:e.jsx(b_,{remarkPlugins:[w_,__],rehypePlugins:[y_],components:{code({inline:r,className:c,children:d,...m}){return r?e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",...m,children:d}):e.jsx("code",{className:`${c} block bg-muted p-4 rounded-lg overflow-x-auto`,...m,children:d})},table({children:r,...c}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"border-collapse border border-border",...c,children:r})})},th({children:r,...c}){return e.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-semibold",...c,children:r})},td({children:r,...c}){return e.jsx("td",{className:"border border-border px-4 py-2",...c,children:r})},a({children:r,...c}){return e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...c,children:r})},blockquote({children:r,...c}){return e.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",...c,children:r})},h1({children:r,...c}){return e.jsx("h1",{className:"text-3xl font-bold mt-6 mb-4",...c,children:r})},h2({children:r,...c}){return e.jsx("h2",{className:"text-2xl font-bold mt-5 mb-3",...c,children:r})},h3({children:r,...c}){return e.jsx("h3",{className:"text-xl font-bold mt-4 mb-2",...c,children:r})},h4({children:r,...c}){return e.jsx("h4",{className:"text-lg font-semibold mt-3 mb-2",...c,children:r})},ul({children:r,...c}){return e.jsx("ul",{className:"list-disc list-inside space-y-1 my-2",...c,children:r})},ol({children:r,...c}){return e.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2",...c,children:r})},p({children:r,...c}){return e.jsx("p",{className:"my-2 leading-relaxed",...c,children:r})},hr({...r}){return e.jsx("hr",{className:"my-4 border-border",...r})}},children:a})})}function ES(a,l){let r=a.slice(0,l).split(/\r\n|\n|\r/g);return[r.length,r.pop().length+1]}function MS(a,l,r){let c=a.split(/\r\n|\n|\r/g),d="",m=(Math.log10(l+1)|0)+1;for(let h=l-1;h<=l+1;h++){let f=c[h-1];f&&(d+=h.toString().padEnd(m," "),d+=": ",d+=f,d+=`
|
||
`,h===l&&(d+=" ".repeat(m+r+2),d+=`^
|
||
`))}return d}class Ds extends Error{line;column;codeblock;constructor(l,r){const[c,d]=ES(r.toml,r.ptr),m=MS(r.toml,c,d);super(`Invalid TOML document: ${l}
|
||
|
||
${m}`,r),this.line=c,this.column=d,this.codeblock=m}}function AS(a,l){let r=0;for(;a[l-++r]==="\\";);return--r&&r%2}function Xo(a,l=0,r=a.length){let c=a.indexOf(`
|
||
`,l);return a[c-1]==="\r"&&c--,c<=r?c:-1}function yx(a,l){for(let r=l;r<a.length;r++){let c=a[r];if(c===`
|
||
`)return r;if(c==="\r"&&a[r+1]===`
|
||
`)return r+1;if(c<" "&&c!==" "||c==="")throw new Ds("control characters are not allowed in comments",{toml:a,ptr:l})}return a.length}function Pl(a,l,r,c){let d;for(;(d=a[l])===" "||d===" "||!r&&(d===`
|
||
`||d==="\r"&&a[l+1]===`
|
||
`);)l++;return c||d!=="#"?l:Pl(a,yx(a,l),r)}function Vg(a,l,r,c,d=!1){if(!c)return l=Xo(a,l),l<0?a.length:l;for(let m=l;m<a.length;m++){let h=a[m];if(h==="#")m=Xo(a,m);else{if(h===r)return m+1;if(h===c||d&&(h===`
|
||
`||h==="\r"&&a[m+1]===`
|
||
`))return m}}throw new Ds("cannot find end of structure",{toml:a,ptr:l})}function Yv(a,l){let r=a[l],c=r===a[l+1]&&a[l+1]===a[l+2]?a.slice(l,l+3):r;l+=c.length-1;do l=a.indexOf(c,++l);while(l>-1&&r!=="'"&&AS(a,l));return l>-1&&(l+=c.length,c.length>1&&(a[l]===r&&l++,a[l]===r&&l++)),l}let zS=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;class Jr extends Date{#s=!1;#t=!1;#e=null;constructor(l){let r=!0,c=!0,d="Z";if(typeof l=="string"){let m=l.match(zS);m?(m[1]||(r=!1,l=`0000-01-01T${l}`),c=!!m[2],c&&l[10]===" "&&(l=l.replace(" ","T")),m[2]&&+m[2]>23?l="":(d=m[3]||null,l=l.toUpperCase(),!d&&c&&(l+="Z"))):l=""}super(l),isNaN(this.getTime())||(this.#s=r,this.#t=c,this.#e=d)}isDateTime(){return this.#s&&this.#t}isLocal(){return!this.#s||!this.#t||!this.#e}isDate(){return this.#s&&!this.#t}isTime(){return this.#t&&!this.#s}isValid(){return this.#s||this.#t}toISOString(){let l=super.toISOString();if(this.isDate())return l.slice(0,10);if(this.isTime())return l.slice(11,23);if(this.#e===null)return l.slice(0,-1);if(this.#e==="Z")return l;let r=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return r=this.#e[0]==="-"?r:-r,new Date(this.getTime()-r*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(l,r="Z"){let c=new Jr(l);return c.#e=r,c}static wrapAsLocalDateTime(l){let r=new Jr(l);return r.#e=null,r}static wrapAsLocalDate(l){let r=new Jr(l);return r.#t=!1,r.#e=null,r}static wrapAsLocalTime(l){let r=new Jr(l);return r.#s=!1,r.#e=null,r}}let RS=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,DS=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,OS=/^[+-]?0[0-9_]/,LS=/^[0-9a-f]{4,8}$/i,Gg={b:"\b",t:" ",n:`
|
||
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};function Jv(a,l=0,r=a.length){let c=a[l]==="'",d=a[l++]===a[l]&&a[l]===a[l+1];d&&(r-=2,a[l+=2]==="\r"&&l++,a[l]===`
|
||
`&&l++);let m=0,h,f="",p=l;for(;l<r-1;){let g=a[l++];if(g===`
|
||
`||g==="\r"&&a[l]===`
|
||
`){if(!d)throw new Ds("newlines are not allowed in strings",{toml:a,ptr:l-1})}else if(g<" "&&g!==" "||g==="")throw new Ds("control characters are not allowed in strings",{toml:a,ptr:l-1});if(h){if(h=!1,g==="u"||g==="U"){let N=a.slice(l,l+=g==="u"?4:8);if(!LS.test(N))throw new Ds("invalid unicode escape",{toml:a,ptr:m});try{f+=String.fromCodePoint(parseInt(N,16))}catch{throw new Ds("invalid unicode escape",{toml:a,ptr:m})}}else if(d&&(g===`
|
||
`||g===" "||g===" "||g==="\r")){if(l=Pl(a,l-1,!0),a[l]!==`
|
||
`&&a[l]!=="\r")throw new Ds("invalid escape: only line-ending whitespace may be escaped",{toml:a,ptr:m});l=Pl(a,l)}else if(g in Gg)f+=Gg[g];else throw new Ds("unrecognized escape sequence",{toml:a,ptr:m});p=l}else!c&&g==="\\"&&(m=l-1,h=!0,f+=a.slice(p,m))}return f+a.slice(p,r-1)}function US(a,l,r,c){if(a==="true")return!0;if(a==="false")return!1;if(a==="-inf")return-1/0;if(a==="inf"||a==="+inf")return 1/0;if(a==="nan"||a==="+nan"||a==="-nan")return NaN;if(a==="-0")return c?0n:0;let d=RS.test(a);if(d||DS.test(a)){if(OS.test(a))throw new Ds("leading zeroes are not allowed",{toml:l,ptr:r});a=a.replace(/_/g,"");let h=+a;if(isNaN(h))throw new Ds("invalid number",{toml:l,ptr:r});if(d){if((d=!Number.isSafeInteger(h))&&!c)throw new Ds("integer value cannot be represented losslessly",{toml:l,ptr:r});(d||c===!0)&&(h=BigInt(a))}return h}const m=new Jr(a);if(!m.isValid())throw new Ds("invalid value",{toml:l,ptr:r});return m}function $S(a,l,r,c){let d=a.slice(l,r),m=d.indexOf("#");m>-1&&(yx(a,m),d=d.slice(0,m));let h=d.trimEnd();if(!c){let f=d.indexOf(`
|
||
`,h.length);if(f>-1)throw new Ds("newlines are not allowed in inline tables",{toml:a,ptr:l+f})}return[h,m]}function wx(a,l,r,c,d){if(c===0)throw new Ds("document contains excessively nested structures. aborting.",{toml:a,ptr:l});let m=a[l];if(m==="["||m==="{"){let[p,g]=m==="["?PS(a,l,c,d):IS(a,l,c,d),N=r?Vg(a,g,",",r):g;if(g-N&&r==="}"){let j=Xo(a,g,N);if(j>-1)throw new Ds("newlines are not allowed in inline tables",{toml:a,ptr:j})}return[p,N]}let h;if(m==='"'||m==="'"){h=Yv(a,l);let p=Jv(a,l,h);if(r){if(h=Pl(a,h,r!=="]"),a[h]&&a[h]!==","&&a[h]!==r&&a[h]!==`
|
||
`&&a[h]!=="\r")throw new Ds("unexpected character encountered",{toml:a,ptr:h});h+=+(a[h]===",")}return[p,h]}h=Vg(a,l,",",r);let f=$S(a,l,h-+(a[h-1]===","),r==="]");if(!f[0])throw new Ds("incomplete key-value declaration: no value specified",{toml:a,ptr:l});return r&&f[1]>-1&&(h=Pl(a,l+f[1]),h+=+(a[h]===",")),[US(f[0],a,l,d),h]}let BS=/^[a-zA-Z0-9-_]+[ \t]*$/;function ex(a,l,r="="){let c=l-1,d=[],m=a.indexOf(r,l);if(m<0)throw new Ds("incomplete key-value: cannot find end of key",{toml:a,ptr:l});do{let h=a[l=++c];if(h!==" "&&h!==" ")if(h==='"'||h==="'"){if(h===a[l+1]&&h===a[l+2])throw new Ds("multiline strings are not allowed in keys",{toml:a,ptr:l});let f=Yv(a,l);if(f<0)throw new Ds("unfinished string encountered",{toml:a,ptr:l});c=a.indexOf(".",f);let p=a.slice(f,c<0||c>m?m:c),g=Xo(p);if(g>-1)throw new Ds("newlines are not allowed in keys",{toml:a,ptr:l+c+g});if(p.trimStart())throw new Ds("found extra tokens after the string part",{toml:a,ptr:f});if(m<f&&(m=a.indexOf(r,f),m<0))throw new Ds("incomplete key-value: cannot find end of key",{toml:a,ptr:l});d.push(Jv(a,l,f))}else{c=a.indexOf(".",l);let f=a.slice(l,c<0||c>m?m:c);if(!BS.test(f))throw new Ds("only letter, numbers, dashes and underscores are allowed in keys",{toml:a,ptr:l});d.push(f.trimEnd())}}while(c+1&&c<m);return[d,Pl(a,m+1,!0,!0)]}function IS(a,l,r,c){let d={},m=new Set,h,f=0;for(l++;(h=a[l++])!=="}"&&h;){let p={toml:a,ptr:l-1};if(h===`
|
||
`)throw new Ds("newlines are not allowed in inline tables",p);if(h==="#")throw new Ds("inline tables cannot contain comments",p);if(h===",")throw new Ds("expected key-value, found comma",p);if(h!==" "&&h!==" "){let g,N=d,j=!1,[b,y]=ex(a,l-1);for(let M=0;M<b.length;M++){if(M&&(N=j?N[g]:N[g]={}),g=b[M],(j=Object.hasOwn(N,g))&&(typeof N[g]!="object"||m.has(N[g])))throw new Ds("trying to redefine an already defined value",{toml:a,ptr:l});!j&&g==="__proto__"&&Object.defineProperty(N,g,{enumerable:!0,configurable:!0,writable:!0})}if(j)throw new Ds("trying to redefine an already defined value",{toml:a,ptr:l});let[w,z]=wx(a,y,"}",r-1,c);m.add(w),N[g]=w,l=z,f=a[l-1]===","?l-1:0}}if(f)throw new Ds("trailing commas are not allowed in inline tables",{toml:a,ptr:f});if(!h)throw new Ds("unfinished table encountered",{toml:a,ptr:l});return[d,l]}function PS(a,l,r,c){let d=[],m;for(l++;(m=a[l++])!=="]"&&m;){if(m===",")throw new Ds("expected value, found comma",{toml:a,ptr:l-1});if(m==="#")l=yx(a,l);else if(m!==" "&&m!==" "&&m!==`
|
||
`&&m!=="\r"){let h=wx(a,l-1,"]",r-1,c);d.push(h[0]),l=h[1]}}if(!m)throw new Ds("unfinished array encountered",{toml:a,ptr:l});return[d,l]}function Kg(a,l,r,c){let d=l,m=r,h,f=!1,p;for(let g=0;g<a.length;g++){if(g){if(d=f?d[h]:d[h]={},m=(p=m[h]).c,c===0&&(p.t===1||p.t===2))return null;if(p.t===2){let N=d.length-1;d=d[N],m=m[N].c}}if(h=a[g],(f=Object.hasOwn(d,h))&&m[h]?.t===0&&m[h]?.d)return null;f||(h==="__proto__"&&(Object.defineProperty(d,h,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(m,h,{enumerable:!0,configurable:!0,writable:!0})),m[h]={t:g<a.length-1&&c===2?3:c,d:!1,i:0,c:{}})}if(p=m[h],p.t!==c&&!(c===1&&p.t===3)||(c===2&&(p.d||(p.d=!0,d[h]=[]),d[h].push(d={}),p.c[p.i++]=p={t:1,d:!1,i:0,c:{}}),p.d))return null;if(p.d=!0,c===1)d=f?d[h]:d[h]={};else if(c===0&&f)return null;return[h,d,p.c]}function _x(a,{maxDepth:l=1e3,integersAsBigInt:r}={}){let c={},d={},m=c,h=d;for(let f=Pl(a,0);f<a.length;){if(a[f]==="["){let p=a[++f]==="[",g=ex(a,f+=+p,"]");if(p){if(a[g[1]-1]!=="]")throw new Ds("expected end of table declaration",{toml:a,ptr:g[1]-1});g[1]++}let N=Kg(g[0],c,d,p?2:1);if(!N)throw new Ds("trying to redefine an already defined table or value",{toml:a,ptr:f});h=N[2],m=N[1],f=g[1]}else{let p=ex(a,f),g=Kg(p[0],m,h,0);if(!g)throw new Ds("trying to redefine an already defined table or value",{toml:a,ptr:f});let N=wx(a,p[1],void 0,l,r);g[1][g[0]]=N[0],f=N[1]}if(f=Pl(a,f,!0),a[f]&&a[f]!==`
|
||
`&&a[f]!=="\r")throw new Ds("each key-value declaration must be followed by an end-of-line",{toml:a,ptr:f});f=Pl(a,f)}return c}let Xv=/^[a-z0-9-_]+$/i;function vc(a){let l=typeof a;if(l==="object"){if(Array.isArray(a))return"array";if(a instanceof Date)return"date"}return l}function FS(a){for(let l=0;l<a.length;l++)if(vc(a[l])!=="object")return!1;return a.length!=0}function Sx(a){return JSON.stringify(a).replace(/\x7f/g,"\\u007f")}function kx(a,l,r,c){if(r===0)throw new Error("Could not stringify the object: maximum object depth exceeded");if(l==="number")return isNaN(a)?"nan":a===1/0?"inf":a===-1/0?"-inf":c&&Number.isInteger(a)?a.toFixed(1):a.toString();if(l==="bigint"||l==="boolean")return a.toString();if(l==="string")return Sx(a);if(l==="date"){if(isNaN(a.getTime()))throw new TypeError("cannot serialize invalid date");return a.toISOString()}if(l==="object")return HS(a,r,c);if(l==="array")return qS(a,r,c)}function HS(a,l,r){let c=Object.keys(a);if(c.length===0)return"{}";let d="{ ";for(let m=0;m<c.length;m++){let h=c[m];m&&(d+=", "),d+=Xv.test(h)?h:Sx(h),d+=" = ",d+=kx(a[h],vc(a[h]),l-1,r)}return d+" }"}function qS(a,l,r){if(a.length===0)return"[]";let c="[ ";for(let d=0;d<a.length;d++){if(d&&(c+=", "),a[d]===null||a[d]===void 0)throw new TypeError("arrays cannot contain null or undefined values");c+=kx(a[d],vc(a[d]),l-1,r)}return c+" ]"}function VS(a,l,r,c){if(r===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let d="";for(let m=0;m<a.length;m++)d+=`${d&&`
|
||
`}[[${l}]]
|
||
`,d+=Cx(0,a[m],l,r,c);return d}function Cx(a,l,r,c,d){if(c===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let m="",h="",f=Object.keys(l);for(let p=0;p<f.length;p++){let g=f[p];if(l[g]!==null&&l[g]!==void 0){let N=vc(l[g]);if(N==="symbol"||N==="function")throw new TypeError(`cannot serialize values of type '${N}'`);let j=Xv.test(g)?g:Sx(g);if(N==="array"&&FS(l[g]))h+=(h&&`
|
||
`)+VS(l[g],r?`${r}.${j}`:j,c-1,d);else if(N==="object"){let b=r?`${r}.${j}`:j;h+=(h&&`
|
||
`)+Cx(b,l[g],b,c-1,d)}else m+=j,m+=" = ",m+=kx(l[g],N,c,d),m+=`
|
||
`}}return a&&(m||!h)&&(m=m?`[${a}]
|
||
${m}`:`[${a}]`),m&&h?`${m}
|
||
${h}`:m||h}function GS(a,{maxDepth:l=1e3,numbersAsFloat:r=!1}={}){if(vc(a)!=="object")throw new TypeError("stringify can only be called with an object");let c=Cx(0,a,"",l,r);return c[c.length-1]!==`
|
||
`?c+`
|
||
`:c}function KS(a,l,r,c={}){const{debounceMs:d=2e3,onSaveSuccess:m,onSaveError:h}=c,f=u.useRef(null),p=u.useCallback(async(b,y)=>{try{l(!0),await NS(b,y),r(!1),m?.()}catch(w){console.error(`自动保存 ${b} 失败:`,w),r(!0),h?.(w instanceof Error?w:new Error(String(w)))}finally{l(!1)}},[l,r,m,h]),g=u.useCallback((b,y)=>{a||(r(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p(b,y)},d))},[a,r,p,d]),N=u.useCallback(async(b,y)=>{f.current&&(clearTimeout(f.current),f.current=null),await p(b,y)},[p]),j=u.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]);return u.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),{triggerAutoSave:g,saveNow:N,cancelPendingAutoSave:j}}function Vt(a,l,r,c){u.useEffect(()=>{a&&!r&&c(l,a)},[a])}const QS=500;function YS(){return e.jsx(lr,{children:e.jsx(JS,{})})}function JS(){const[a,l]=u.useState(!0),[r,c]=u.useState(!1),[d,m]=u.useState(!1),[h,f]=u.useState(!1),[p,g]=u.useState("visual"),[N,j]=u.useState(""),[b,y]=u.useState(!1),[w,z]=u.useState(""),{toast:M}=nt(),{triggerRestart:S,isRestarting:F}=Tn(),[E,C]=u.useState(null),[R,H]=u.useState(null),[O,X]=u.useState(null),[L,me]=u.useState(null),[Ne,je]=u.useState(null),[ce,ge]=u.useState(null),[pe,D]=u.useState(null),[Q,B]=u.useState(null),[ue,Y]=u.useState(null),[we,fe]=u.useState(null),[Ee,G]=u.useState(null),[$,A]=u.useState(null),[K,Re]=u.useState(null),[se,$e]=u.useState(null),[cs,J]=u.useState(null),[Z,Le]=u.useState(null),[le,De]=u.useState(null),[xe,Me]=u.useState(null),[ds,Ts]=u.useState(null),[kt,ia]=u.useState(null),[ut,Is]=u.useState(null),V=u.useRef(!0),Ke=u.useRef({}),He=Ae=>{const Qe=Ae.split(`
|
||
`);let As=Qe[0];As=As.replace(/^Error:\s*/,"");const mt=[[/Invalid TOML document: unrecognized escape sequence/,"TOML 文档错误:无法识别的转义序列(提示:在双引号字符串中使用 \\\\ 转义反斜杠,或使用单引号字符串)"],[/Invalid TOML document: only letter, numbers, dashes and underscores are allowed in keys/,"TOML 文档错误:键名只能包含字母、数字、短横线和下划线"],[/Invalid TOML document: (.+)/,"TOML 文档错误:$1"],[/Unexpected character.*at line (\d+), column (\d+)/,"第 $1 行第 $2 列:意外的字符"],[/Expected.*at line (\d+), column (\d+)/,"第 $1 行第 $2 列:缺少必要的字符"],[/Invalid.*at line (\d+), column (\d+)/,"第 $1 行第 $2 列:无效的语法"],[/Unterminated string at line (\d+)/,"第 $1 行:字符串未正常结束(缺少引号)"],[/Duplicate key.*at line (\d+)/,"第 $1 行:重复的键名"],[/Invalid escape sequence at line (\d+)/,"第 $1 行:无效的转义序列(提示:在双引号字符串中使用 \\\\ 转义反斜杠)"],[/Expected.*but got.*at line (\d+)/,"第 $1 行:类型不匹配"],[/line (\d+), column (\d+)/,"第 $1 行第 $2 列"],[/Unexpected end of input/,"意外的文件结束(可能缺少闭合符号)"],[/Unexpected token/,"意外的标记"],[/Invalid number/,"无效的数字"],[/Invalid date/,"无效的日期格式"],[/Invalid boolean/,"无效的布尔值(应为 true 或 false)"],[/Unexpected character/,"意外的字符"],[/unrecognized escape sequence/,"无法识别的转义序列"]];for(const[Ht,ca]of mt)if(Ht.test(As)){As=As.replace(Ht,ca);break}return Qe.length>1?(Qe[0]=As,Qe.join(`
|
||
`)):As},Je=u.useCallback(Ae=>{Ke.current=Ae,C(Ae.bot),H(Ae.personality);const Qe=Ae.chat;Qe.talk_value_rules||(Qe.talk_value_rules=[]),X(Qe),me(Ae.expression),je(Ae.emoji),ge(Ae.memory),D(Ae.tool),B(Ae.voice),Y(Ae.message_receive),fe(Ae.dream),G(Ae.lpmm_knowledge),A(Ae.keyword_reaction),Re(Ae.response_post_process),$e(Ae.chinese_typo),J(Ae.response_splitter),Le(Ae.log),De(Ae.debug),Me(Ae.experimental),Ts(Ae.maim_message),ia(Ae.telemetry),Is(Ae.webui)},[]),Es=u.useCallback(()=>({...Ke.current,bot:E,personality:R,chat:O,expression:L,emoji:Ne,memory:ce,tool:pe,voice:Q,message_receive:ue,dream:we,lpmm_knowledge:Ee,keyword_reaction:$,response_post_process:K,chinese_typo:se,response_splitter:cs,log:Z,debug:le,experimental:xe,maim_message:ds,telemetry:kt,webui:ut}),[E,R,O,L,Ne,ce,pe,Q,ue,we,Ee,$,K,se,cs,Z,le,xe,ds,kt,ut]),ms=u.useCallback(async()=>{try{const Qe=(await jS()).replace(/"([^"]*)"/g,(As,mt)=>`"${mt.replace(/\\n/g,`
|
||
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}"`);j(Qe),y(!1)}catch(Ae){M({variant:"destructive",title:"加载失败",description:Ae instanceof Error?Ae.message:"加载源代码失败"})}},[M]),Ms=u.useCallback(async()=>{try{l(!0);const Ae=await Hg();Je(Ae),f(!1),V.current=!1,await ms()}catch(Ae){console.error("加载配置失败:",Ae),M({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{l(!1)}},[M,ms,Je]);u.useEffect(()=>{Ms()},[Ms]);const{triggerAutoSave:We,cancelPendingAutoSave:Cs}=KS(V.current,m,f);Vt(E,"bot",V.current,We),Vt(R,"personality",V.current,We),Vt(O,"chat",V.current,We),Vt(L,"expression",V.current,We),Vt(Ne,"emoji",V.current,We),Vt(ce,"memory",V.current,We),Vt(pe,"tool",V.current,We),Vt(Q,"voice",V.current,We),Vt(we,"dream",V.current,We),Vt(Ee,"lpmm_knowledge",V.current,We),Vt($,"keyword_reaction",V.current,We),Vt(K,"response_post_process",V.current,We),Vt(se,"chinese_typo",V.current,We),Vt(cs,"response_splitter",V.current,We),Vt(Z,"log",V.current,We),Vt(le,"debug",V.current,We),Vt(ds,"maim_message",V.current,We),Vt(kt,"telemetry",V.current,We),Vt(ut,"webui",V.current,We);const rs=async()=>{try{c(!0);try{_x(N)}catch(Qe){const As=Qe instanceof Error?Qe.message:"TOML 格式错误",mt=He(As);y(!0),z(mt),M({variant:"destructive",title:"TOML 格式错误",description:mt}),c(!1);return}const Ae=N.replace(/"([^"]*)"/g,(Qe,As)=>`"${As.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")}"`);await vS(Ae),f(!1),y(!1),z(""),M({title:"保存成功",description:"配置已保存"}),await Ms()}catch(Ae){y(!0);const Qe=Ae instanceof Error?Ae.message:"保存配置失败";z(Qe),M({variant:"destructive",title:"保存失败",description:Qe})}finally{c(!1)}},is=async Ae=>{if(h){M({variant:"destructive",title:"切换失败",description:"请先保存当前更改"});return}if(g(Ae),Ae==="source")await ms();else try{const Qe=await Hg();Je(Qe),f(!1)}catch(Qe){console.error("加载配置失败:",Qe),M({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}},ys=async()=>{try{c(!0),Cs(),await qg(Es()),f(!1),M({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(Ae){console.error("保存配置失败:",Ae),M({title:"保存失败",description:Ae.message,variant:"destructive"})}finally{c(!1)}},rt=async()=>{await S()},jt=async()=>{try{c(!0),Cs(),await qg(Es()),f(!1),M({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(Ae=>setTimeout(Ae,QS)),await rt()}catch(Ae){console.error("保存失败:",Ae),M({title:"保存失败",description:Ae.message,variant:"destructive"})}finally{c(!1)}};return a?e.jsx(ts,{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(ts,{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(_,{onClick:p==="visual"?ys:rs,disabled:r||d||!h||F,size:"sm",variant:"outline",className:"w-20 sm:w-24",children:[e.jsx(gc,{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?"保存中":d?"自动":h?"保存":"已保存"})]}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{disabled:r||d||F,size:"sm",className:"w-20 sm:w-28",children:[e.jsx(pc,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"ml-1 truncate text-xs sm:text-sm",children:F?"重启中":h?"保存重启":"重启"})]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认重启麦麦?"}),e.jsx(gs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:h?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:h?jt:rt,children:h?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsx("div",{className:"flex",children:e.jsx(Jt,{value:p,onValueChange:Ae=>is(Ae),className:"w-full",children:e.jsxs(Gt,{className:"h-8 sm:h-9 w-full grid grid-cols-2",children:[e.jsxs(Xe,{value:"visual",className:"text-xs sm:text-sm",children:[e.jsx(uv,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"可视化编辑"]}),e.jsxs(Xe,{value:"source",className:"text-xs sm:text-sm",children:[e.jsx(dx,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"源代码编辑"]})]})})})]}),e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsxs(ft,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),p==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsxs(ft,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。此功能仅适用于熟悉 TOML 语法的高级用户。保存时会在前端验证格式,只有格式完全正确才能保存。",b&&w&&e.jsxs("div",{className:"text-destructive font-semibold mt-3 p-3 bg-destructive/10 rounded-md",children:[e.jsx("div",{className:"font-bold mb-2",children:"⚠️ TOML 格式错误:"}),e.jsx("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words",children:w})]})]})]}),e.jsx(Qv,{value:N,onChange:Ae=>{j(Ae),f(!0),b&&(y(!1),z(""))},language:"toml",theme:"dark",height:"calc(100vh - 280px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),p==="visual"&&e.jsx(e.Fragment,{children:e.jsxs(Jt,{defaultValue:"bot",className:"w-full",children:[e.jsxs(Gt,{className:"flex flex-wrap h-auto gap-1 p-1 sm:grid sm:grid-cols-5 lg:grid-cols-10",children:[e.jsx(Xe,{value:"bot",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"基本信息"}),e.jsx(Xe,{value:"personality",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"人格"}),e.jsx(Xe,{value:"chat",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"聊天"}),e.jsx(Xe,{value:"expression",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"表达"}),e.jsx(Xe,{value:"features",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"功能"}),e.jsx(Xe,{value:"processing",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"处理"}),e.jsx(Xe,{value:"dream",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"做梦"}),e.jsx(Xe,{value:"lpmm",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"知识库"}),e.jsx(Xe,{value:"webui",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"WebUI"}),e.jsx(Xe,{value:"other",className:"text-xs px-2 py-1.5 sm:px-3 sm:py-2 data-[state=active]:shadow-sm",children:"其他"})]}),e.jsx(Ss,{value:"bot",className:"space-y-4",children:E&&e.jsx(W2,{config:E,onChange:C})}),e.jsx(Ss,{value:"personality",className:"space-y-4",children:R&&e.jsx(eS,{config:R,onChange:H})}),e.jsx(Ss,{value:"chat",className:"space-y-4",children:O&&e.jsx(aS,{config:O,onChange:X})}),e.jsx(Ss,{value:"expression",className:"space-y-4",children:L&&e.jsx(xS,{config:L,onChange:me})}),e.jsx(Ss,{value:"features",className:"space-y-4",children:Ne&&ce&&pe&&Q&&e.jsx(uS,{emojiConfig:Ne,memoryConfig:ce,toolConfig:pe,voiceConfig:Q,onEmojiChange:je,onMemoryChange:ge,onToolChange:D,onVoiceChange:B})}),e.jsxs(Ss,{value:"processing",className:"space-y-4",children:[$&&K&&se&&cs&&e.jsx(fS,{keywordReactionConfig:$,responsePostProcessConfig:K,chineseTypoConfig:se,responseSplitterConfig:cs,onKeywordReactionChange:A,onResponsePostProcessChange:Re,onChineseTypoChange:$e,onResponseSplitterChange:J}),ue&&e.jsx(pS,{config:ue,onChange:Y})]}),e.jsx(Ss,{value:"dream",className:"space-y-4",children:we&&e.jsx(lS,{config:we,onChange:fe})}),e.jsx(Ss,{value:"lpmm",className:"space-y-4",children:Ee&&e.jsx(nS,{config:Ee,onChange:G})}),e.jsx(Ss,{value:"webui",className:"space-y-4",children:ut&&e.jsx(gS,{config:ut,onChange:Is})}),e.jsxs(Ss,{value:"other",className:"space-y-4",children:[Z&&e.jsx(rS,{config:Z,onChange:Le}),le&&e.jsx(iS,{config:le,onChange:De}),xe&&e.jsx(cS,{config:xe,onChange:Me}),ds&&e.jsx(oS,{config:ds,onChange:Ts}),kt&&e.jsx(dS,{config:kt,onChange:ia})]})]})}),e.jsx(nr,{})]})})}const ql=u.forwardRef(({className:a,...l},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:P("w-full caption-bottom text-sm",a),...l})}));ql.displayName="Table";const Vl=u.forwardRef(({className:a,...l},r)=>e.jsx("thead",{ref:r,className:P("[&_tr]:border-b",a),...l}));Vl.displayName="TableHeader";const Gl=u.forwardRef(({className:a,...l},r)=>e.jsx("tbody",{ref:r,className:P("[&_tr:last-child]:border-0",a),...l}));Gl.displayName="TableBody";const XS=u.forwardRef(({className:a,...l},r)=>e.jsx("tfoot",{ref:r,className:P("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",a),...l}));XS.displayName="TableFooter";const _t=u.forwardRef(({className:a,...l},r)=>e.jsx("tr",{ref:r,className:P("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",a),...l}));_t.displayName="TableRow";const ns=u.forwardRef(({className:a,...l},r)=>e.jsx("th",{ref:r,className:P("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",a),...l}));ns.displayName="TableHead";const Ze=u.forwardRef(({className:a,...l},r)=>e.jsx("td",{ref:r,className:P("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",a),...l}));Ze.displayName="TableCell";const ZS=u.forwardRef(({className:a,...l},r)=>e.jsx("caption",{ref:r,className:P("mt-4 text-sm text-muted-foreground",a),...l}));ZS.displayName="TableCaption";const md=u.forwardRef(({className:a,...l},r)=>e.jsx(ka,{ref:r,className:P("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...l}));md.displayName=ka.displayName;const xd=u.forwardRef(({className:a,...l},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx($t,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(ka.Input,{ref:r,className:P("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",a),...l})]}));xd.displayName=ka.Input.displayName;const hd=u.forwardRef(({className:a,...l},r)=>e.jsx(ka.List,{ref:r,className:P("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...l}));hd.displayName=ka.List.displayName;const fd=u.forwardRef((a,l)=>e.jsx(ka.Empty,{ref:l,className:"py-6 text-center text-sm",...a}));fd.displayName=ka.Empty.displayName;const uc=u.forwardRef(({className:a,...l},r)=>e.jsx(ka.Group,{ref:r,className:P("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",a),...l}));uc.displayName=ka.Group.displayName;const WS=u.forwardRef(({className:a,...l},r)=>e.jsx(ka.Separator,{ref:r,className:P("-mx-1 h-px bg-border",a),...l}));WS.displayName=ka.Separator.displayName;const mc=u.forwardRef(({className:a,...l},r)=>e.jsx(ka.Item,{ref:r,className:P("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",a),...l}));mc.displayName=ka.Item.displayName;const Zv=j1,Wv=v1,eN=N1,Tx=u.forwardRef(({className:a,sideOffset:l=4,...r},c)=>e.jsx(g1,{children:e.jsx(Zj,{ref:c,sideOffset:l,className:P("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]",a),...r})}));Tx.displayName=Zj.displayName;function Bl({content:a,className:l,iconClassName:r,side:c="top",align:d="center",maxWidth:m="300px"}){return e.jsx(Zv,{delayDuration:200,children:e.jsxs(Wv,{children:[e.jsx(eN,{asChild:!0,children:e.jsxs("button",{type:"button",className:P("inline-flex items-center justify-center rounded-full","text-muted-foreground hover:text-foreground","transition-colors cursor-help","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",l),onClick:h=>h.preventDefault(),children:[e.jsx(ox,{className:P("h-4 w-4",r)}),e.jsx("span",{className:"sr-only",children:"帮助信息"})]})}),e.jsx(Tx,{side:c,align:d,className:P("max-w-[var(--max-width)] text-sm leading-relaxed","bg-background text-foreground","border-2 border-primary shadow-lg","p-4"),style:{"--max-width":m},children:a})]})})}const sN=u.createContext(null),tN="maibot-completed-tours";function e4(){try{const a=localStorage.getItem(tN);return a?new Set(JSON.parse(a)):new Set}catch{return new Set}}function Qg(a){localStorage.setItem(tN,JSON.stringify([...a]))}function s4({children:a}){const[l,r]=u.useState({activeTourId:null,stepIndex:0,isRunning:!1}),[c]=u.useState(()=>new Map),[d,m]=u.useState(e4),[,h]=u.useState(0),f=u.useCallback((E,C)=>{c.set(E,C),h(R=>R+1)},[c]),p=u.useCallback(E=>{c.delete(E),r(C=>C.activeTourId===E?{...C,activeTourId:null,isRunning:!1,stepIndex:0}:C)},[c]),g=u.useCallback((E,C=0)=>{c.has(E)&&r({activeTourId:E,stepIndex:C,isRunning:!0})},[c]),N=u.useCallback(()=>{r(E=>({...E,isRunning:!1}))},[]),j=u.useCallback(E=>{r(C=>({...C,stepIndex:E}))},[]),b=u.useCallback(()=>{r(E=>({...E,stepIndex:E.stepIndex+1}))},[]),y=u.useCallback(()=>{r(E=>({...E,stepIndex:Math.max(0,E.stepIndex-1)}))},[]),w=u.useCallback(()=>l.activeTourId?c.get(l.activeTourId)||[]:[],[l.activeTourId,c]),z=u.useCallback(E=>{m(C=>{const R=new Set(C);return R.add(E),Qg(R),R})},[]),M=u.useCallback(E=>{const{action:C,index:R,status:H,type:O}=E,X=["finished","skipped"];if(C==="close"){r(L=>({...L,isRunning:!1,stepIndex:0}));return}X.includes(H)?r(L=>(H==="finished"&&L.activeTourId&&setTimeout(()=>z(L.activeTourId),0),{...L,isRunning:!1,stepIndex:0})):O==="step:after"&&(C==="next"?r(L=>({...L,stepIndex:R+1})):C==="prev"&&r(L=>({...L,stepIndex:R-1})))},[z]),S=u.useCallback(E=>d.has(E),[d]),F=u.useCallback(E=>{m(C=>{const R=new Set(C);return R.delete(E),Qg(R),R})},[]);return e.jsx(sN.Provider,{value:{state:l,tours:c,registerTour:f,unregisterTour:p,startTour:g,stopTour:N,goToStep:j,nextStep:b,prevStep:y,getCurrentSteps:w,handleJoyrideCallback:M,isTourCompleted:S,markTourCompleted:z,resetTourCompleted:F},children:a})}function Ex(){const a=u.useContext(sN);if(!a)throw new Error("useTour must be used within a TourProvider");return a}const t4={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)"}},a4={back:"上一步",close:"关闭",last:"完成",next:"下一步",nextLabelWithProgress:"下一步 ({step}/{steps})",open:"打开对话框",skip:"跳过"};function l4(){const{state:a,getCurrentSteps:l,handleJoyrideCallback:r}=Ex(),c=l(),[d,m]=u.useState(!1),h=u.useRef(a.stepIndex),f=u.useRef(null);u.useEffect(()=>{h.current!==a.stepIndex&&(m(!1),h.current=a.stepIndex)},[a.stepIndex]),u.useEffect(()=>{if(!a.isRunning||c.length===0){m(!1);return}const j=c[a.stepIndex];if(!j){m(!1);return}const b=j.target;if(b==="body"){m(!0);return}m(!1);const y=setTimeout(()=>{const w=()=>{const F=document.querySelector(b);if(F){const E=F.getBoundingClientRect();if(E.width>0&&E.height>0)return!0}return!1};if(w()){setTimeout(()=>m(!0),100);return}const z=setInterval(()=>{w()&&(clearInterval(z),setTimeout(()=>m(!0),100))},100),M=setTimeout(()=>{clearInterval(z),m(!0)},5e3),S=()=>{clearInterval(z),clearTimeout(M)};f.current=S},150);return()=>{clearTimeout(y),f.current&&(f.current(),f.current=null)}},[a.isRunning,a.stepIndex,c]);const[p,g]=u.useState(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(j),()=>{}},[]),!a.isRunning||c.length===0||!d)return null;const N=e.jsx(g_,{steps:c,stepIndex:a.stepIndex,run:a.isRunning,continuous:!0,showSkipButton:!0,showProgress:!0,disableOverlayClose:!0,disableScrolling:!1,disableScrollParentFix:!1,callback:r,styles:t4,locale:a4,scrollOffset:80,scrollToFirstStep:!0,floaterProps:{styles:{floater:{zIndex:99999}},disableAnimation:!0}},`tour-step-${a.stepIndex}`);return p?tw.createPortal(N,p):N}const gl="model-assignment-tour",aN=[{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}],lN={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"},Wi=[{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 Yg(a){return a?a.replace(/\/+$/,"").toLowerCase():""}function n4(a){if(!a)return null;const l=Yg(a);return Wi.find(r=>r.id!=="custom"&&Yg(r.base_url)===l)||null}const Lo=a=>({...a,max_retry:a.max_retry??2,timeout:a.timeout??30,retry_interval:a.retry_interval??10}),r4=(a,l=[],r=null)=>{const c={};return a?(a.name?.trim()?l.some((m,h)=>r!==null&&h===r?!1:m.name.trim().toLowerCase()===a.name.trim().toLowerCase())&&(c.name="提供商名称已存在,请使用其他名称"):c.name="请输入提供商名称",a.base_url?.trim()||(c.base_url="请输入基础 URL"),a.api_key?.trim()||(c.api_key="请输入 API Key"),{isValid:Object.keys(c).length===0,errors:c}):{isValid:!1,errors:{name:"提供商数据为空"}}};function i4(){return e.jsx(lr,{children:e.jsx(c4,{})})}function c4(){const[a,l]=u.useState([]),[r,c]=u.useState(!0),[d,m]=u.useState(!1),[h,f]=u.useState(!1),[p,g]=u.useState(!1),[N,j]=u.useState(!1),[b,y]=u.useState(null),[w,z]=u.useState(null),[M,S]=u.useState("custom"),[F,E]=u.useState(!1),[C,R]=u.useState(!1),[H,O]=u.useState(null),[X,L]=u.useState(!1),[me,Ne]=u.useState(""),[je,ce]=u.useState(new Set),[ge,pe]=u.useState(!1),[D,Q]=u.useState(1),[B,ue]=u.useState(20),[Y,we]=u.useState(""),[fe,Ee]=u.useState({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),[G,$]=u.useState({}),[A,K]=u.useState(new Set),[Re,se]=u.useState(new Map),{toast:$e}=nt(),cs=ha(),{state:J,goToStep:Z,registerTour:Le}=Ex(),{triggerRestart:le,isRestarting:De}=Tn(),xe=u.useRef(null),Me=u.useRef(!0);u.useEffect(()=>{Le(gl,aN)},[Le]),u.useEffect(()=>{if(J.activeTourId===gl&&J.isRunning){const te=lN[J.stepIndex];te&&!window.location.pathname.endsWith(te.replace("/config/",""))&&cs({to:te})}},[J.stepIndex,J.activeTourId,J.isRunning,cs]);const ds=u.useRef(J.stepIndex);u.useEffect(()=>{if(J.activeTourId===gl&&J.isRunning){const te=ds.current,_e=J.stepIndex;te>=3&&te<=9&&_e<3&&j(!1),te>=10&&_e>=3&&_e<=9&&($({}),S("custom"),y({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),z(null),L(!1),j(!0)),ds.current=_e}},[J.stepIndex,J.activeTourId,J.isRunning]),u.useEffect(()=>{if(J.activeTourId!==gl||!J.isRunning)return;const te=_e=>{const U=_e.target,Se=J.stepIndex;Se===2&&U.closest('[data-tour="add-provider-button"]')?setTimeout(()=>Z(3),300):Se===9&&U.closest('[data-tour="provider-cancel-button"]')&&setTimeout(()=>Z(10),300)};return document.addEventListener("click",te,!0),()=>document.removeEventListener("click",te,!0)},[J,Z]),u.useEffect(()=>{Ts()},[]);const Ts=async()=>{try{c(!0);const te=await Nn();l(te.api_providers||[]),g(!1),Me.current=!1}catch(te){console.error("加载配置失败:",te)}finally{c(!1)}},kt=async()=>{await le()},ia=async()=>{try{m(!0),xe.current&&clearTimeout(xe.current);const te=a.map(es=>({...es,max_retry:es.max_retry??2,timeout:es.timeout??30,retry_interval:es.retry_interval??10})),{shouldProceed:_e}=await ut(te,"restart");if(!_e){m(!1);return}const U=await Nn(),Se=new Set(te.map(es=>es.name)),us=(U.models||[]).filter(es=>Se.has(es.api_provider));U.api_providers=te,U.models=us,await lc(U),g(!1),$e({title:"保存成功",description:"正在重启麦麦..."}),await kt()}catch(te){console.error("保存配置失败:",te),$e({title:"保存失败",description:te.message,variant:"destructive"}),m(!1)}},ut=u.useCallback(async(te,_e="auto")=>{try{const U=await Nn(),Se=new Set(a.map($s=>$s.name)),as=new Set(te.map($s=>$s.name)),us=Array.from(Se).filter($s=>!as.has($s));if(us.length===0)return{shouldProceed:!0,providers:te};const Ct=(U.models||[]).filter($s=>us.includes($s.api_provider));return Ct.length===0?{shouldProceed:!0,providers:te}:(Ee({isOpen:!0,providersToDelete:us,affectedModels:Ct,pendingProviders:te,context:_e,oldProviders:[...a]}),{shouldProceed:!1,providers:te})}catch(U){return console.error("检查删除影响失败:",U),{shouldProceed:!0,providers:te}}},[a]),Is=async()=>{try{(fe.context==="auto"?f:m)(!0),Ee($s=>({...$s,isOpen:!1}));const _e=await Nn(),U=fe.pendingProviders.map(Lo),Se=new Set(U.map($s=>$s.name)),us=(_e.models||[]).filter($s=>Se.has($s.api_provider)),es=new Set(fe.affectedModels.map($s=>$s.name)),Ct=_e.model_task_config;Ct&&Object.keys(Ct).forEach($s=>{const pa=Ct[$s];pa&&Array.isArray(pa.model_list)&&(pa.model_list=pa.model_list.filter(oa=>!es.has(oa)))}),_e.api_providers=U,_e.models=us,_e.model_task_config=Ct,await lc(_e),l(fe.pendingProviders),g(!1),$e({title:"删除成功",description:`已删除 ${fe.providersToDelete.length} 个提供商和 ${fe.affectedModels.length} 个关联模型`}),Ee({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),ce(new Set),fe.context==="restart"&&await kt()}catch(te){console.error("删除失败:",te),$e({title:"删除失败",description:te.message,variant:"destructive"})}finally{fe.context==="auto"?f(!1):m(!1)}},V=()=>{fe.oldProviders.length>0&&l(fe.oldProviders),Ee({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),g(!1)},Ke=u.useCallback(async te=>{if(Me.current)return;const{shouldProceed:_e}=await ut(te,"auto");if(!_e){g(!0);return}try{f(!0);const U=te.map(Lo);await Wm("api_providers",U),g(!1)}catch(U){console.error("自动保存失败:",U),$e({title:"自动保存失败",description:U.message,variant:"destructive"}),g(!0)}finally{f(!1)}},[a,ut]);u.useEffect(()=>{if(!Me.current)return g(!0),xe.current&&clearTimeout(xe.current),xe.current=setTimeout(()=>{Ke(a)},2e3),()=>{xe.current&&clearTimeout(xe.current)}},[a,Ke]);const He=async()=>{try{m(!0),xe.current&&clearTimeout(xe.current);const te=a.map(Lo),{shouldProceed:_e}=await ut(te,"manual");if(!_e){m(!1);return}const U=await Nn(),Se=new Set(te.map(es=>es.name)),as=U.models||[],us=as.filter(es=>{const Ct=Se.has(es.api_provider);return Ct||console.warn(`模型 "${es.name}" 引用了已删除的提供商 "${es.api_provider}",将被移除`),Ct});if(as.length!==us.length){const es=as.length-us.length;$e({title:"注意",description:`已自动移除 ${es} 个引用已删除提供商的模型`,variant:"default"})}console.log("发送的 providers 数据:",te),U.api_providers=te,U.models=us,console.log("完整配置数据:",U),await lc(U),g(!1),$e({title:"保存成功",description:"模型提供商配置已保存"})}catch(te){console.error("保存配置失败:",te),$e({title:"保存失败",description:te.message,variant:"destructive"})}finally{m(!1)}},Je=(te,_e)=>{if($({}),te){const U=Wi.find(Se=>Se.base_url===te.base_url&&Se.client_type===te.client_type);S(U?.id||"custom"),y(te)}else S("custom"),y({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10});z(_e),L(!1),j(!0)},Es=u.useCallback(te=>{S(te),E(!1);const _e=Wi.find(U=>U.id===te);_e&&_e.id!=="custom"?y(U=>({...U,name:_e.name,base_url:_e.base_url,client_type:_e.client_type})):_e?.id==="custom"&&y(U=>({...U,name:"",base_url:"",client_type:"openai"}))},[]),ms=u.useMemo(()=>M!=="custom",[M]),Ms=u.useCallback(async()=>{if(b?.api_key)try{await navigator.clipboard.writeText(b.api_key),$e({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{$e({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},[b?.api_key,$e]),We=()=>{if(!b)return;const{isValid:te,errors:_e}=r4(b,a,w);if(!te){$(_e);return}$({});const U=Lo(b);if(w!==null){const Se=[...a];Se[w]=U,l(Se)}else l([...a,U]);j(!1),y(null),z(null)},Cs=te=>{if(!te&&b){const _e={...b,max_retry:b.max_retry??2,timeout:b.timeout??30,retry_interval:b.retry_interval??10};y(_e)}j(te)},rs=te=>{O(te),R(!0)},is=async()=>{if(H!==null){const te=a.filter((U,Se)=>Se!==H),{shouldProceed:_e}=await ut(te,"manual");_e&&(l(te),$e({title:"删除成功",description:"提供商已从列表中移除"}))}R(!1),O(null)},ys=te=>{const _e=new Set(je);_e.has(te)?_e.delete(te):_e.add(te),ce(_e)},rt=()=>{if(je.size===Qe.length)ce(new Set);else{const te=Qe.map((_e,U)=>a.findIndex(Se=>Se===Qe[U]));ce(new Set(te))}},jt=()=>{if(je.size===0){$e({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}pe(!0)},Ae=async()=>{const te=a.filter((U,Se)=>!je.has(Se)),{shouldProceed:_e}=await ut(te,"manual");_e&&(l(te),ce(new Set),$e({title:"批量删除成功",description:`已删除 ${je.size} 个提供商`})),pe(!1)},Qe=u.useMemo(()=>{if(!me)return a;const te=me.toLowerCase();return a.filter(_e=>_e.name.toLowerCase().includes(te)||_e.base_url.toLowerCase().includes(te)||_e.client_type.toLowerCase().includes(te))},[a,me]),{totalPages:As,paginatedProviders:mt}=u.useMemo(()=>{const te=Math.ceil(Qe.length/B),_e=Qe.slice((D-1)*B,D*B);return{totalPages:te,paginatedProviders:_e}},[Qe,D,B]),Ht=u.useCallback(()=>{const te=parseInt(Y);te>=1&&te<=As&&(Q(te),we(""))},[Y,As]),ca=async te=>{K(_e=>new Set(_e).add(te));try{const _e=await yS(te);se(U=>new Map(U).set(te,_e)),_e.network_ok?_e.api_key_valid===!0?$e({title:"连接正常",description:`${te} 网络连接正常,API Key 有效 (${_e.latency_ms}ms)`}):_e.api_key_valid===!1?$e({title:"连接正常但 Key 无效",description:`${te} 网络连接正常,但 API Key 无效或已过期`,variant:"destructive"}):$e({title:"网络连接正常",description:`${te} 可以访问 (${_e.latency_ms}ms)`}):$e({title:"连接失败",description:_e.error||"无法连接到提供商",variant:"destructive"})}catch(_e){$e({title:"测试失败",description:_e.message,variant:"destructive"})}finally{K(_e=>{const U=new Set(_e);return U.delete(te),U})}},Fa=async()=>{for(const te of a)await ca(te.name)},Xt=te=>{const _e=A.has(te),U=Re.get(te);return _e?e.jsxs(Ce,{variant:"secondary",className:"gap-1",children:[e.jsx(Fs,{className:"h-3 w-3 animate-spin"}),"测试中"]}):U?U.network_ok?U.api_key_valid===!0?e.jsxs(Ce,{className:"gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(st,{className:"h-3 w-3"}),"正常"]}):U.api_key_valid===!1?e.jsxs(Ce,{variant:"destructive",className:"gap-1",children:[e.jsx(Rt,{className:"h-3 w-3"}),"Key无效"]}):e.jsxs(Ce,{className:"gap-1 bg-blue-600 hover:bg-blue-700",children:[e.jsx(st,{className:"h-3 w-3"}),"可访问"]}):e.jsxs(Ce,{variant:"destructive",className:"gap-1",children:[e.jsx(ta,{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:[je.size>0&&e.jsxs(_,{onClick:jt,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(os,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",je.size,")"]}),e.jsxs(_,{onClick:Fa,size:"sm",variant:"outline",className:"w-full sm:w-auto",disabled:a.length===0||A.size>0,children:[e.jsx(sl,{className:"mr-2 h-4 w-4"}),A.size>0?`测试中 (${A.size})`:"测试全部"]}),e.jsxs(_,{onClick:()=>Je(null,null),size:"sm",className:"w-full sm:w-auto","data-tour":"add-provider-button",children:[e.jsx(Xs,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(_,{onClick:He,disabled:d||h||!p||De,size:"sm",variant:"outline",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(gc,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),d?"保存中...":h?"自动保存中...":p?"保存配置":"已保存"]}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{disabled:d||h||De,size:"sm",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(pc,{className:"mr-2 h-4 w-4"}),De?"重启中...":p?"保存并重启":"重启麦麦"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认重启麦麦?"}),e.jsx(gs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:p?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:p?ia:kt,children:p?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsxs(ft,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(ts,{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($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索提供商名称、URL 或类型...",value:me,onChange:te=>Ne(te.target.value),className:"pl-9"})]}),me&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Qe.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:Qe.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:me?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):mt.map((te,_e)=>{const U=a.findIndex(Se=>Se===te);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:te.name}),Xt(te.name)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:te.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>ca(te.name),disabled:A.has(te.name),title:"测试连接",children:A.has(te.name)?e.jsx(Fs,{className:"h-4 w-4 animate-spin"}):e.jsx(sl,{className:"h-4 w-4"})}),e.jsx(_,{variant:"default",size:"sm",onClick:()=>Je(te,U),children:e.jsx(Zn,{className:"h-4 w-4",strokeWidth:2,fill:"none"})}),e.jsx(_,{size:"sm",onClick:()=>rs(U),className:"bg-red-600 hover:bg-red-700 text-white",children:e.jsx(os,{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:te.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:te.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:te.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:te.retry_interval})]})]})]},_e)})}),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(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{className:"w-12",children:e.jsx(tt,{checked:je.size===Qe.length&&Qe.length>0,onCheckedChange:rt})}),e.jsx(ns,{children:"状态"}),e.jsx(ns,{children:"名称"}),e.jsx(ns,{children:"基础URL"}),e.jsx(ns,{children:"客户端类型"}),e.jsx(ns,{className:"text-right",children:"最大重试"}),e.jsx(ns,{className:"text-right",children:"超时(秒)"}),e.jsx(ns,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(ns,{className:"text-right",children:"操作"})]})}),e.jsx(Gl,{children:mt.length===0?e.jsx(_t,{children:e.jsx(Ze,{colSpan:9,className:"text-center text-muted-foreground py-8",children:me?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):mt.map((te,_e)=>{const U=a.findIndex(Se=>Se===te);return e.jsxs(_t,{children:[e.jsx(Ze,{children:e.jsx(tt,{checked:je.has(U),onCheckedChange:()=>ys(U)})}),e.jsx(Ze,{children:Xt(te.name)||e.jsx(Ce,{variant:"outline",className:"text-muted-foreground",children:"未测试"})}),e.jsx(Ze,{className:"font-medium",children:te.name}),e.jsx(Ze,{className:"max-w-xs truncate",title:te.base_url,children:te.base_url}),e.jsx(Ze,{children:te.client_type}),e.jsx(Ze,{className:"text-right",children:te.max_retry}),e.jsx(Ze,{className:"text-right",children:te.timeout}),e.jsx(Ze,{className:"text-right",children:te.retry_interval}),e.jsx(Ze,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>ca(te.name),disabled:A.has(te.name),title:"测试连接",children:A.has(te.name)?e.jsx(Fs,{className:"h-4 w-4 animate-spin"}):e.jsx(sl,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"default",size:"sm",onClick:()=>Je(te,U),children:[e.jsx(Zn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>rs(U),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(os,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},_e)})})]})})}),Qe.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(T,{htmlFor:"page-size-provider",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Pe,{value:B.toString(),onValueChange:te=>{ue(parseInt(te)),Q(1),ce(new Set)},children:[e.jsx(Be,{id:"page-size-provider",className:"w-20",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10"}),e.jsx(W,{value:"20",children:"20"}),e.jsx(W,{value:"50",children:"50"}),e.jsx(W,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(D-1)*B+1," 到"," ",Math.min(D*B,Qe.length)," 条,共 ",Qe.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Q(1),disabled:D===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Q(te=>Math.max(1,te-1)),disabled:D===1,children:[e.jsx(Pa,{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(ne,{type:"number",value:Y,onChange:te=>we(te.target.value),onKeyDown:te=>te.key==="Enter"&&Ht(),placeholder:D.toString(),className:"w-16 h-8 text-center",min:1,max:As}),e.jsx(_,{variant:"outline",size:"sm",onClick:Ht,disabled:!Y,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Q(te=>te+1),disabled:D>=As,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(ra,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Q(As),disabled:D>=As,className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]}),e.jsx(Qs,{open:N,onOpenChange:Cs,children:e.jsxs(Hs,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"provider-dialog",preventOutsideClose:J.isRunning,children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:w!==null?"编辑提供商":"添加提供商"}),e.jsx(at,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("form",{onSubmit:te=>{te.preventDefault(),We()},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(T,{htmlFor:"template",children:"提供商模板"}),e.jsxs(cl,{open:F,onOpenChange:E,children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":F,className:"w-full justify-between",children:[M?Wi.find(te=>te.id===M)?.display_name:"选择提供商模板...",e.jsx(mx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(tl,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(md,{children:[e.jsx(xd,{placeholder:"搜索提供商模板..."}),e.jsx(ts,{className:"h-[300px]",children:e.jsxs(hd,{className:"max-h-none overflow-visible",children:[e.jsx(fd,{children:"未找到匹配的模板"}),e.jsx(uc,{children:Wi.map(te=>e.jsxs(mc,{value:te.display_name,onSelect:()=>Es(te.id),children:[e.jsx(Lt,{className:`mr-2 h-4 w-4 ${M===te.id?"opacity-100":"opacity-0"}`}),te.display_name]},te.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.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"name",className:G.name?"text-destructive":"",children:"名称 *"}),e.jsx(Bl,{content:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"提供商名称"}),e.jsx("p",{children:"为这个 API 提供商设置一个便于识别的名称,用于在模型配置中引用。"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[e.jsx("li",{children:"推荐使用厂商官方名称,如 DeepSeek、OpenAI"}),e.jsx("li",{children:"名称需要唯一,不能与现有提供商重复"})]})]}),side:"right",maxWidth:"350px"})]}),e.jsx(ne,{id:"name",value:b?.name||"",onChange:te=>{y(_e=>_e?{..._e,name:te.target.value}:null),G.name&&$(_e=>({..._e,name:void 0}))},placeholder:"例如: DeepSeek, SiliconFlow",className:G.name?"border-destructive focus-visible:ring-destructive":""}),G.name&&e.jsx("p",{className:"text-xs text-destructive",children:G.name})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-url-input",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"base_url",className:G.base_url?"text-destructive":"",children:"基础 URL *"}),e.jsx(Bl,{content:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"API 基础地址"}),e.jsx("p",{children:"提供商的 API 端点基础 URL,通常以 /v1 结尾。"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"OpenAI 格式:"}),"https://api.openai.com/v1"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"DeepSeek:"}),"https://api.deepseek.com"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"硅基流动:"}),"https://api.siliconflow.cn/v1"]}),e.jsx("li",{children:"选择模板会自动填充正确的 URL"})]})]}),side:"right",maxWidth:"400px"})]}),e.jsx(ne,{id:"base_url",value:b?.base_url||"",onChange:te=>{y(_e=>_e?{..._e,base_url:te.target.value}:null),G.base_url&&$(_e=>({..._e,base_url:void 0}))},placeholder:"https://api.example.com/v1",disabled:ms,className:`${ms?"bg-muted cursor-not-allowed":""} ${G.base_url?"border-destructive focus-visible:ring-destructive":""}`}),G.base_url&&e.jsx("p",{className:"text-xs text-destructive",children:G.base_url}),ms&&!G.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.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"api_key",className:G.api_key?"text-destructive":"",children:"API Key *"}),e.jsx(Bl,{content:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"API 密钥"}),e.jsx("p",{children:"从提供商平台获取的身份验证密钥。"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[e.jsxs("li",{children:["通常以 ",e.jsx("code",{children:"sk-"})," 开头"]}),e.jsx("li",{children:"请妥善保管,不要泄露给他人"}),e.jsx("li",{children:"可以点击眼睛图标切换显示/隐藏"}),e.jsx("li",{children:"点击复制图标可快速复制密钥"})]})]}),side:"right",maxWidth:"350px"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{id:"api_key",type:X?"text":"password",value:b?.api_key||"",onChange:te=>{y(_e=>_e?{..._e,api_key:te.target.value}:null),G.api_key&&$(_e=>({..._e,api_key:void 0}))},placeholder:"sk-...",className:`flex-1 ${G.api_key?"border-destructive focus-visible:ring-destructive":""}`}),e.jsx(_,{type:"button",variant:"outline",size:"icon",onClick:()=>L(!X),title:X?"隐藏密钥":"显示密钥",children:X?e.jsx(ic,{className:"h-4 w-4"}):e.jsx(ua,{className:"h-4 w-4"})}),e.jsx(_,{type:"button",variant:"outline",size:"icon",onClick:Ms,title:"复制密钥",children:e.jsx(qo,{className:"h-4 w-4"})})]}),G.api_key&&e.jsx("p",{className:"text-xs text-destructive",children:G.api_key})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"client_type",children:"客户端类型"}),e.jsx(Bl,{content:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"API 客户端类型"}),e.jsx("p",{children:"指定与提供商通信时使用的 API 协议格式。"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"OpenAI:"}),"兼容 OpenAI API 格式的提供商"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Gemini:"}),"Google Gemini 专用格式"]}),e.jsx("li",{children:"大部分第三方提供商都兼容 OpenAI 格式"})]})]}),side:"right",maxWidth:"350px"})]}),e.jsxs(Pe,{value:b?.client_type||"openai",onValueChange:te=>y(_e=>_e?{..._e,client_type:te}:null),disabled:ms,children:[e.jsx(Be,{id:"client_type",className:ms?"bg-muted cursor-not-allowed":"",children:e.jsx(Fe,{placeholder:"选择客户端类型"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"openai",children:"OpenAI"}),e.jsx(W,{value:"gemini",children:"Gemini"})]})]}),ms&&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.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(Bl,{content:"API 请求失败时的最大重试次数。设置为 0 表示不重试。默认值:2",side:"top",maxWidth:"250px"})]}),e.jsx(ne,{id:"max_retry",type:"number",min:"0",value:b?.max_retry??"",onChange:te=>{const _e=te.target.value===""?null:parseInt(te.target.value);y(U=>U?{...U,max_retry:_e}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(Bl,{content:"单次 API 请求的超时时间(秒)。超时后会触发重试或报错。默认值:30 秒",side:"top",maxWidth:"250px"})]}),e.jsx(ne,{id:"timeout",type:"number",min:"1",value:b?.timeout??"",onChange:te=>{const _e=te.target.value===""?null:parseInt(te.target.value);y(U=>U?{...U,timeout:_e}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(Bl,{content:"两次重试之间的等待时间(秒)。适当的间隔可以避免触发 API 限流。默认值:10 秒",side:"top",maxWidth:"250px"})]}),e.jsx(ne,{id:"retry_interval",type:"number",min:"1",value:b?.retry_interval??"",onChange:te=>{const _e=te.target.value===""?null:parseInt(te.target.value);y(U=>U?{...U,retry_interval:_e}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs(gt,{children:[e.jsx(_,{type:"button",variant:"outline",onClick:()=>j(!1),"data-tour":"provider-cancel-button",children:"取消"}),e.jsx(_,{type:"submit","data-tour":"provider-save-button",children:"保存"})]})]})]})}),e.jsx(bs,{open:C,onOpenChange:R,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除提供商 "',H!==null?a[H]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:is,children:"删除"})]})]})}),e.jsx(bs,{open:ge,onOpenChange:pe,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认批量删除"}),e.jsxs(gs,{children:["确定要删除选中的 ",je.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:Ae,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),e.jsx(bs,{open:fe.isOpen,onOpenChange:te=>Ee(_e=>({..._e,isOpen:te})),children:e.jsxs(xs,{className:"max-w-2xl",children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除提供商"}),e.jsx(gs,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["您即将删除以下提供商:",e.jsx("strong",{className:"text-foreground ml-1",children:fe.providersToDelete.join(", ")})]}),e.jsxs("p",{className:"text-yellow-600 dark:text-yellow-500 font-medium",children:["⚠️ 此操作将同时删除 ",fe.affectedModels.length," 个关联的模型:"]}),e.jsx(ts,{className:"h-32 w-full rounded border p-3",children:e.jsx("div",{className:"space-y-1",children:fe.affectedModels.map((te,_e)=>e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-mono text-muted-foreground",children:"•"}),e.jsx("span",{className:"ml-2 font-medium",children:te.name}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",te.model_identifier,")"]})]},_e))})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"这些模型将从模型列表和所有任务分配中移除。此操作无法撤销。"})]})})]}),e.jsxs(fs,{children:[e.jsx(vs,{onClick:V,children:"取消"}),e.jsx(js,{onClick:Is,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})}),e.jsx(nr,{})]})}function nc(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,11)}`}function Im(a){return a===null?"null":Array.isArray(a)?"array":typeof a=="object"?"object":typeof a=="boolean"?"boolean":typeof a=="number"?"number":"string"}function sx(a){return Object.entries(a).map(([l,r])=>{const c=Im(r),d={id:nc(),key:l,value:r,type:c,expanded:!0};return c==="object"&&r&&typeof r=="object"?d.children=sx(r):c==="array"&&Array.isArray(r)&&(d.children=r.map((m,h)=>{const f=Im(m),p={id:nc(),key:String(h),value:m,type:f,expanded:!0};return f==="object"&&m&&typeof m=="object"?p.children=sx(m):f==="array"&&Array.isArray(m)&&(p.children=m.map((g,N)=>({id:nc(),key:String(N),value:g,type:Im(g),expanded:!0}))),p})),d})}function tx(a){const l={};for(const r of a)r.key.trim()&&(r.type==="object"&&r.children?l[r.key]=tx(r.children):r.type==="array"&&r.children?l[r.key]=r.children.map(c=>c.type==="object"&&c.children?tx(c.children):c.type==="array"&&c.children?c.children.map(d=>d.value):c.value):r.type==="null"?l[r.key]=null:l[r.key]=r.value);return l}function Jg(a,l){switch(l){case"boolean":return a==="true";case"number":{const r=parseFloat(a);return isNaN(r)?0:r}case"null":return null;default:return a}}function nN({node:a,level:l,onUpdate:r,onRemove:c,onAddChild:d,onToggleExpand:m}){const h=a.type==="object"||a.type==="array",f=a.children&&a.children.length>0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"grid gap-2 items-center",style:{gridTemplateColumns:h?"32px 1fr 90px 64px":"32px 1fr 1fr 90px 32px",paddingLeft:`${l*20}px`},children:[e.jsx(_,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(a.id),disabled:!h||!f,children:h&&f?a.expanded?e.jsx(Ba,{className:"h-4 w-4"}):e.jsx(ra,{className:"h-4 w-4"}):e.jsx("span",{className:"w-4"})}),e.jsx(ne,{value:a.key,onChange:p=>r(a.id,"key",p.target.value),placeholder:"key",className:"h-8 text-sm"}),!h&&e.jsx(e.Fragment,{children:a.type==="boolean"?e.jsxs("div",{className:"flex items-center h-8 px-3 border rounded-md bg-background",children:[e.jsx(Ge,{checked:a.value===!0,onCheckedChange:p=>r(a.id,"value",p)}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:a.value?"true":"false"})]}):a.type==="null"?e.jsx("div",{className:"flex items-center h-8 px-3 border rounded-md bg-muted text-sm text-muted-foreground",children:"null"}):e.jsx(ne,{type:a.type==="number"?"number":"text",value:a.value,onChange:p=>r(a.id,"value",p.target.value),placeholder:"value",className:"h-8 text-sm",step:a.type==="number"?"any":void 0})}),e.jsxs(Pe,{value:a.type,onValueChange:p=>r(a.id,"type",p),children:[e.jsx(Be,{className:"h-8 text-xs",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"string",children:"字符串"}),e.jsx(W,{value:"number",children:"数字"}),e.jsx(W,{value:"boolean",children:"布尔"}),e.jsx(W,{value:"null",children:"Null"}),e.jsx(W,{value:"object",children:"对象"}),e.jsx(W,{value:"array",children:"数组"})]})]}),e.jsxs("div",{className:"flex gap-1 justify-end",children:[h&&e.jsx(_,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-primary",onClick:()=>d(a.id),title:"添加子项",children:e.jsx(Xs,{className:"h-4 w-4"})}),e.jsx(_,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>c(a.id),title:"删除",children:e.jsx(os,{className:"h-4 w-4"})})]})]}),h&&a.expanded&&a.children&&a.children.length>0&&e.jsx("div",{className:"space-y-1",children:a.children.map(p=>e.jsx(nN,{node:p,level:l+1,onUpdate:r,onRemove:c,onAddChild:d,onToggleExpand:m},p.id))})]})}function o4({value:a,onChange:l,placeholder:r="添加参数..."}){const[c,d]=u.useState(()=>sx(a||{})),m=u.useCallback(j=>{d(j),l(tx(j))},[l]),h=u.useCallback(()=>{const j={id:nc(),key:"",value:"",type:"string",expanded:!1};m([...c,j])},[c,m]),f=u.useCallback((j,b,y)=>{const w=z=>z.map(M=>{if(M.id===j)if(b==="type"){const S=y;if(S==="object")return{...M,type:S,value:{},children:[]};if(S==="array")return{...M,type:S,value:[],children:[]};if(S==="null")return{...M,type:S,value:null};{const F=Jg(String(M.value),S);return{...M,type:S,value:F,children:void 0}}}else if(b==="value"){const S=Jg(String(y),M.type);return{...M,value:S}}else return{...M,[b]:String(y)};return M.children?{...M,children:w(M.children)}:M});m(w(c))},[c,m]),p=u.useCallback(j=>{const b=y=>y.filter(w=>w.id!==j).map(w=>w.children?{...w,children:b(w.children)}:w);m(b(c))},[c,m]),g=u.useCallback(j=>{const b=y=>y.map(w=>{if(w.id===j){const z={id:nc(),key:w.type==="array"?String(w.children?.length||0):"",value:"",type:"string",expanded:!0};return{...w,children:[...w.children||[],z]}}return w.children?{...w,children:b(w.children)}:w});m(b(c))},[c,m]),N=u.useCallback(j=>{const b=y=>y.map(w=>w.id===j?{...w,expanded:!w.expanded}:w.children?{...w,children:b(w.children)}:w);d(b(c))},[c]);return e.jsxs("div",{className:"h-full flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[c.length," 个参数"]}),e.jsxs(_,{type:"button",size:"sm",variant:"outline",onClick:h,className:"h-7 text-xs",children:[e.jsx(Xs,{className:"h-3 w-3 mr-1"}),"添加参数"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-1",children:c.length===0?e.jsx("div",{className:"text-sm text-muted-foreground text-center py-4 border border-dashed rounded-md",children:r}):e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"grid gap-2 text-xs text-muted-foreground px-1 sticky top-0 bg-background z-10",style:{gridTemplateColumns:"32px 1fr 1fr 90px 32px"},children:[e.jsx("span",{}),e.jsx("span",{children:"键名"}),e.jsx("span",{children:"值"}),e.jsx("span",{children:"类型"}),e.jsx("span",{})]}),c.map(j=>e.jsx(nN,{node:j,level:0,onUpdate:f,onRemove:p,onAddChild:g,onToggleExpand:N},j.id))]})})]})}function Xg(a){if(!a.trim())return{valid:!0,parsed:{}};try{const l=JSON.parse(a);return typeof l!="object"||l===null||Array.isArray(l)?{valid:!1,error:"必须是一个 JSON 对象 {}"}:{valid:!0,parsed:l}}catch{return{valid:!1,error:"JSON 格式错误"}}}function d4({value:a,onChange:l,className:r,placeholder:c="添加额外参数..."}){const[d,m]=u.useState("list"),h=u.useMemo(()=>Object.keys(a||{}).length>0?JSON.stringify(a,null,2):"",[a]),[f,p]=u.useState(h),[g,N]=u.useState(null);u.useEffect(()=>{p(h)},[h]);const j=u.useMemo(()=>{const w=Xg(f);return w.valid&&w.parsed?{success:!0,data:w.parsed}:{success:!1,data:{}}},[f]),b=u.useCallback(w=>{const z=w;z==="json"&&d==="list"&&(p(Object.keys(a).length>0?JSON.stringify(a,null,2):""),N(null)),m(z)},[d,a]),y=u.useCallback(w=>{p(w);const z=Xg(w);z.valid&&z.parsed?(N(null),l(z.parsed)):N(z.error||"JSON 格式错误")},[l]);return e.jsx("div",{className:P("h-full flex flex-col",r),children:e.jsxs(Jt,{value:d,onValueChange:b,className:"w-full flex-1 flex flex-col",children:[e.jsxs(Gt,{className:"h-8 p-0.5 bg-muted/60 w-fit",children:[e.jsx(Xe,{value:"list",className:"h-7 px-3 text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"可视化编辑"}),e.jsx(Xe,{value:"json",className:"h-7 px-3 text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"JSON 编辑"})]}),e.jsx(Ss,{value:"list",className:"mt-2 flex-1 flex flex-col overflow-hidden data-[state=inactive]:hidden data-[state=inactive]:h-0",children:e.jsx(o4,{value:a,onChange:l,placeholder:c})}),e.jsx(Ss,{value:"json",className:"mt-2 flex-1 flex flex-col overflow-hidden data-[state=inactive]:hidden data-[state=inactive]:h-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col gap-2 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"编辑"}),g?e.jsxs("div",{className:"flex items-center gap-1 text-xs text-destructive",children:[e.jsx(Rt,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[150px]",children:g})]}):f.trim()&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 dark:text-green-400",children:[e.jsx(Lt,{className:"h-3 w-3"}),e.jsx("span",{children:"有效"})]})]}),e.jsx(pt,{value:f,onChange:w=>y(w.target.value),placeholder:`{
|
||
"key": "value"
|
||
}`,className:P("font-mono text-sm flex-1 resize-none",g&&"border-destructive focus-visible:ring-destructive")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"支持任意 JSON 类型(包括嵌套对象和数组)"})]}),e.jsxs("div",{className:"flex flex-col gap-2 overflow-hidden",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"预览"}),e.jsx("div",{className:"flex-1 rounded-md border bg-muted/30 p-3 overflow-auto",children:j.success&&Object.keys(j.data).length>0?e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words",children:JSON.stringify(j.data,null,2)}):j.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 u4({open:a,onOpenChange:l,value:r,onChange:c}){const[d,m]=u.useState(r),h=g=>{g&&m(r),l(g)},f=()=>{c(d),l(!1)},p=()=>{m(r),l(!1)};return e.jsx(Qs,{open:a,onOpenChange:h,children:e.jsxs(Hs,{className:"max-w-3xl h-[70vh] flex flex-col",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"编辑额外参数"}),e.jsx(at,{children:"配置模型调用时的额外参数,支持嵌套对象和数组"})]}),e.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:e.jsx(d4,{value:d,onChange:m,placeholder:"添加额外参数(如 thinking、top_p 等)..."})}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:p,children:"取消"}),e.jsx(_,{onClick:f,children:"保存"})]})]})})}const ai="https://maibot-plugin-stats.maibot-webui.workers.dev";async function m4(a){const l=new URLSearchParams;a?.status&&l.set("status",a.status),a?.page&&l.set("page",a.page.toString()),a?.page_size&&l.set("page_size",a.page_size.toString()),a?.search&&l.set("search",a.search),a?.sort_by&&l.set("sort_by",a.sort_by),a?.sort_order&&l.set("sort_order",a.sort_order);const r=await fetch(`${ai}/pack?${l.toString()}`);if(!r.ok)throw new Error(`获取 Pack 列表失败: ${r.status}`);return r.json()}async function x4(a){const l=await fetch(`${ai}/pack/${a}`);if(!l.ok)throw new Error(`获取 Pack 失败: ${l.status}`);const r=await l.json();if(!r.success)throw new Error(r.error||"获取 Pack 失败");return r.pack}async function h4(a){const r=await(await fetch(`${ai}/pack`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).json();if(!r.success)throw new Error(r.error||"创建 Pack 失败");return r}async function f4(a,l){await fetch(`${ai}/pack/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pack_id:a,user_id:l})})}async function rN(a,l){const c=await(await fetch(`${ai}/pack/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pack_id:a,user_id:l})})).json();if(!c.success)throw new Error(c.error||"点赞失败");return{likes:c.likes,liked:c.liked}}async function iN(a,l){return(await(await fetch(`${ai}/pack/like/check?pack_id=${a}&user_id=${l}`)).json()).liked||!1}async function p4(a){const l=await ke("/api/webui/config/model");if(!l.ok)throw new Error("获取当前模型配置失败");const r=await l.json(),c=r.config||r;console.log("=== Pack Conflict Detection ==="),console.log("Pack providers:",a.providers),console.log("Local providers:",c.api_providers);const d={existing_providers:[],new_providers:[],conflicting_models:[]},m=c.api_providers||[];for(const f of a.providers){console.log(`
|
||
Checking pack provider: ${f.name}`),console.log(` Pack URL: ${f.base_url}`),console.log(` Normalized: ${Pm(f.base_url)}`);const p=m.filter(g=>{const N=Pm(g.base_url),j=Pm(f.base_url);return console.log(` Comparing with local "${g.name}": ${g.base_url}`),console.log(` Local normalized: ${N}`),console.log(` Match: ${N===j}`),N===j});p.length>0?(console.log(` ✓ Matched with ${p.length} local provider(s):`,p.map(g=>g.name).join(", ")),d.existing_providers.push({pack_provider:f,local_providers:p.map(g=>({name:g.name,base_url:g.base_url}))})):(console.log(" ✗ No match found - will need API key"),d.new_providers.push(f))}const h=c.models||[];console.log(`
|
||
=== Model Conflict Detection ===`);for(const f of a.models){const p=h.find(g=>g.name===f.name);p&&(console.log(`Model conflict: ${f.name}`),d.conflicting_models.push({pack_model:f.name,local_model:p.name}))}return console.log(`
|
||
=== Detection Summary ===`),console.log(`Existing providers: ${d.existing_providers.length}`),console.log(`New providers: ${d.new_providers.length}`),console.log(`Conflicting models: ${d.conflicting_models.length}`),console.log(`===========================
|
||
`),d}async function g4(a,l,r,c){const d=await ke("/api/webui/config/model");if(!d.ok)throw new Error("获取当前模型配置失败");const m=await d.json(),h=m.config||m;if(l.apply_providers){const p=l.selected_providers?a.providers.filter(g=>l.selected_providers.includes(g.name)):a.providers;for(const g of p){if(r[g.name])continue;const N=c[g.name];if(!N)throw new Error(`提供商 "${g.name}" 缺少 API Key`);const j={...g,api_key:N},b=h.api_providers.findIndex(y=>y.name===g.name);b>=0?h.api_providers[b]=j:h.api_providers.push(j)}}if(l.apply_models){const p=l.selected_models?a.models.filter(g=>l.selected_models.includes(g.name)):a.models;for(const g of p){const N=r[g.api_provider]||g.api_provider,j={...g,api_provider:N},b=h.models.findIndex(y=>y.name===g.name);b>=0?h.models[b]=j:h.models.push(j)}}if(l.apply_task_config){const p=l.selected_tasks||Object.keys(a.task_config);for(const g of p){const N=a.task_config[g];if(!N)continue;const j=new Set(l.selected_models||a.models.map(w=>w.name)),b=N.model_list.filter(w=>j.has(w));if(b.length===0)continue;const y={...N,model_list:b};if(l.task_mode==="replace")h.model_task_config[g]=y;else{const w=h.model_task_config[g];if(w){const z=[...new Set([...w.model_list,...b])];h.model_task_config[g]={...w,model_list:z}}else h.model_task_config[g]=y}}}if(!(await ke("/api/webui/config/model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).ok)throw new Error("保存配置失败")}async function j4(a){const l=await ke("/api/webui/config/model");if(!l.ok)throw new Error("获取当前模型配置失败");const r=await l.json();if(!r.success||!r.config)throw new Error("获取配置失败");const c=r.config;let d=(c.api_providers||[]).map(g=>({name:g.name,base_url:g.base_url,client_type:g.client_type,max_retry:g.max_retry,timeout:g.timeout,retry_interval:g.retry_interval}));a.selectedProviders&&(d=d.filter(g=>a.selectedProviders.includes(g.name)));let m=c.models||[];a.selectedModels&&(m=m.filter(g=>a.selectedModels.includes(g.name)));const h={},f=c.model_task_config||{},p=a.selectedTasks||Object.keys(f);for(const g of p)f[g]&&(h[g]=f[g]);return{providers:d,models:m,task_config:h}}function Pm(a){try{const l=new URL(a);return`${l.protocol}//${l.host}${l.pathname}`.replace(/\/$/,"").toLowerCase()}catch{return a.toLowerCase().replace(/\/$/,"")}}function cN(){const a="maibot_pack_user_id";let l=localStorage.getItem(a);return l||(l="pack_user_"+Math.random().toString(36).substring(2,15),localStorage.setItem(a,l)),l}const v4={utils:"通用工具",utils_small:"轻量工具",tool_use:"工具调用",replyer:"回复生成",planner:"规划推理",vlm:"视觉模型",voice:"语音处理",embedding:"向量嵌入",lpmm_entity_extract:"实体提取",lpmm_rdf_build:"RDF构建",lpmm_qa:"问答模型"},N4=["官方推荐","性价比","高性能","免费模型","国内可用","海外模型","OpenAI","Claude","Gemini","国产模型","多模态","轻量级"];function b4({trigger:a}){const[l,r]=u.useState(!1),[c,d]=u.useState(1),[m,h]=u.useState(!1),[f,p]=u.useState(!1),[g,N]=u.useState([]),[j,b]=u.useState([]),[y,w]=u.useState({}),[z,M]=u.useState(new Set),[S,F]=u.useState(new Set),[E,C]=u.useState(new Set),[R,H]=u.useState(""),[O,X]=u.useState(""),[L,me]=u.useState(""),[Ne,je]=u.useState([]);u.useEffect(()=>{l&&c===1&&ce()},[l,c]);const ce=async()=>{h(!0);try{const G=await j4({name:"",description:"",author:""});N(G.providers),b(G.models),w(G.task_config),M(new Set(G.providers.map($=>$.name))),F(new Set(G.models.map($=>$.name))),C(new Set(Object.keys(G.task_config)))}catch(G){console.error("加载配置失败:",G),aa({title:"加载当前配置失败",variant:"destructive"})}finally{h(!1)}},ge=G=>{const $=new Set(z),A=new Set(S),K=new Set(E);$.has(G)?($.delete(G),j.filter(se=>se.api_provider===G).forEach(se=>A.delete(se.name)),Object.entries(y).forEach(([se,$e])=>{$e.model_list&&($e.model_list.some(J=>A.has(J))||K.delete(se))})):($.add(G),j.filter(se=>se.api_provider===G).forEach(se=>A.add(se.name)),Object.entries(y).forEach(([se,$e])=>{$e.model_list&&$e.model_list.some(J=>{const Z=j.find(Le=>Le.name===J);return Z&&Z.api_provider===G})&&K.add(se)})),M($),F(A),C(K)},pe=G=>{const $=new Set(S),A=new Set(E);$.has(G)?($.delete(G),Object.entries(y).forEach(([K,Re])=>{Re.model_list&&(Re.model_list.some($e=>$.has($e))||A.delete(K))})):($.add(G),Object.entries(y).forEach(([K,Re])=>{Re.model_list&&Re.model_list.includes(G)&&A.add(K)})),F($),C(A)},D=G=>{const $=new Set(E);$.has(G)?$.delete(G):$.add(G),C($)},Q=G=>{Ne.includes(G)?je(Ne.filter($=>$!==G)):Ne.length<5?je([...Ne,G]):aa({title:"最多选择 5 个标签",variant:"destructive"})},B=()=>{z.size===g.length?M(new Set):M(new Set(g.map(G=>G.name)))},ue=()=>{S.size===j.length?F(new Set):F(new Set(j.map(G=>G.name)))},Y=()=>{const G=Object.keys(y);E.size===G.length?C(new Set):C(new Set(G))},we=async()=>{if(!R.trim()){aa({title:"请输入模板名称",variant:"destructive"});return}if(!O.trim()){aa({title:"请输入模板描述",variant:"destructive"});return}if(!L.trim()){aa({title:"请输入作者名称",variant:"destructive"});return}if(z.size===0&&S.size===0&&E.size===0){aa({title:"请至少选择一项配置",variant:"destructive"});return}p(!0);try{const G=g.filter(K=>z.has(K.name)),$=j.filter(K=>S.has(K.name)),A={};for(const[K,Re]of Object.entries(y))E.has(K)&&(A[K]=Re);await h4({name:R.trim(),description:O.trim(),author:L.trim(),tags:Ne,providers:G,models:$,task_config:A}),aa({title:"模板已提交审核,审核通过后将显示在市场中"}),r(!1),fe()}catch(G){console.error("提交失败:",G),aa({title:G instanceof Error?G.message:"提交失败",variant:"destructive"})}finally{p(!1)}},fe=()=>{d(1),H(""),X(""),me(""),je([]),M(new Set),F(new Set),C(new Set)},Ee=2;return e.jsxs(Qs,{open:l,onOpenChange:r,children:[e.jsx(dd,{asChild:!0,children:a||e.jsxs(_,{variant:"outline",children:[e.jsx(mv,{className:"w-4 h-4 mr-2"}),"分享配置"]})}),e.jsxs(Hs,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"w-5 h-5"}),"分享配置模板"]}),e.jsxs(at,{children:["步骤 ",c," / ",Ee,":",c===1&&"选择要分享的配置",c===2&&"填写模板信息"]})]}),e.jsx(ts,{className:"h-[calc(85vh-220px)] pr-4",children:m?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Fs,{className:"w-8 h-8 mx-auto animate-spin text-primary"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"正在加载当前配置..."})]}):e.jsxs(e.Fragment,{children:[c===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(Jn,{children:"安全提示"}),e.jsxs(ft,{children:["分享的配置将",e.jsx("strong",{children:"不包含"})," API Key,其他用户需要自行配置。"]})]}),e.jsxs(Jt,{defaultValue:"providers",className:"w-full",children:[e.jsxs(Gt,{className:"grid w-full grid-cols-3",children:[e.jsxs(Xe,{value:"providers",children:[e.jsx(Hl,{className:"w-4 h-4 mr-2"}),"API 提供商",e.jsxs(Ce,{variant:"secondary",className:"ml-2",children:[z.size,"/",g.length]})]}),e.jsxs(Xe,{value:"models",children:[e.jsx(Wn,{className:"w-4 h-4 mr-2"}),"模型配置",e.jsxs(Ce,{variant:"secondary",className:"ml-2",children:[S.size,"/",j.length]})]}),e.jsxs(Xe,{value:"tasks",children:[e.jsx(er,{className:"w-4 h-4 mr-2"}),"任务配置",e.jsxs(Ce,{variant:"secondary",className:"ml-2",children:[E.size,"/",Object.keys(y).length]})]})]}),e.jsx(Ss,{value:"providers",className:"space-y-2 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(_,{variant:"ghost",size:"sm",onClick:B,children:z.size===g.length?"取消全选":"全选"})}),g.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无提供商配置"}):g.map(G=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 rounded hover:bg-muted",children:[e.jsx(tt,{id:`provider-${G.name}`,checked:z.has(G.name),onCheckedChange:()=>ge(G.name)}),e.jsxs(T,{htmlFor:`provider-${G.name}`,className:"flex-1 cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:G.name}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:G.base_url})]}),e.jsx(Ce,{variant:"outline",className:"text-xs",children:G.client_type})]},G.name))]})}),e.jsx(Ss,{value:"models",className:"space-y-2 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(_,{variant:"ghost",size:"sm",onClick:ue,children:S.size===j.length?"取消全选":"全选"})}),j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无模型配置"}):j.map(G=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 rounded hover:bg-muted",children:[e.jsx(tt,{id:`model-${G.name}`,checked:S.has(G.name),onCheckedChange:()=>pe(G.name)}),e.jsxs(T,{htmlFor:`model-${G.name}`,className:"flex-1 cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:G.name}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:G.model_identifier})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:G.api_provider})]},G.name))]})}),e.jsx(Ss,{value:"tasks",className:"space-y-2 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(_,{variant:"ghost",size:"sm",onClick:Y,children:E.size===Object.keys(y).length?"取消全选":"全选"})}),Object.keys(y).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无任务配置"}):Object.entries(y).map(([G,$])=>e.jsxs("div",{className:"space-y-2 p-2 rounded hover:bg-muted",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:`task-${G}`,checked:E.has(G),onCheckedChange:()=>D(G)}),e.jsx(T,{htmlFor:`task-${G}`,className:"flex-1 cursor-pointer",children:e.jsx("span",{className:"font-medium",children:v4[G]||G})}),e.jsxs(Ce,{variant:"outline",className:"text-xs",children:[$.model_list.length," 个模型"]})]}),$.model_list&&$.model_list.length>0&&e.jsx("div",{className:"ml-6 flex flex-wrap gap-1",children:$.model_list.map(A=>{const K=j.find(se=>se.name===A),Re=S.has(A);return e.jsxs(Ce,{variant:Re?"default":"outline",className:"text-xs cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>pe(A),children:[A,K&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",K.api_provider,")"]})]},A)})})]},G))]})})]})]}),c===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 text-sm p-3 bg-muted rounded-lg",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Hl,{className:"w-4 h-4"}),z.size," 个提供商"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Wn,{className:"w-4 h-4"}),S.size," 个模型"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(er,{className:"w-4 h-4"}),E.size," 个任务"]})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"pack-name",children:"模板名称 *"}),e.jsx(ne,{id:"pack-name",placeholder:"例如:高性价比国产模型配置",value:R,onChange:G=>H(G.target.value),maxLength:50}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[R.length,"/50"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"pack-description",children:"模板描述 *"}),e.jsx(pt,{id:"pack-description",placeholder:"详细描述这个配置模板的特点、适用场景等...",value:O,onChange:G=>X(G.target.value),rows:4,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[O.length,"/500"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"pack-author",children:"作者名称 *"}),e.jsx(ne,{id:"pack-author",placeholder:"你的昵称或 ID",value:L,onChange:G=>me(G.target.value),maxLength:30})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"标签(可选,最多 5 个)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:N4.map(G=>e.jsxs(Ce,{variant:Ne.includes(G)?"default":"outline",className:"cursor-pointer transition-colors",onClick:()=>Q(G),children:[Ne.includes(G)&&e.jsx(Lt,{className:"w-3 h-3 mr-1"}),e.jsx(cd,{className:"w-3 h-3 mr-1"}),G]},G))})]})]}),e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(Jn,{children:"审核说明"}),e.jsx(ft,{children:"提交后需要经过审核才能在市场中展示。审核通常在 1-3 个工作日内完成。"})]})]})]})}),e.jsxs(gt,{className:"flex justify-between pt-4 border-t",children:[e.jsx("div",{children:c>1&&e.jsx(_,{variant:"outline",onClick:()=>d(c-1),disabled:f,children:"上一步"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{variant:"outline",onClick:()=>{r(!1),fe()},disabled:f,children:"取消"}),c<Ee?e.jsx(_,{onClick:()=>d(c+1),disabled:m||z.size===0&&S.size===0&&E.size===0,children:"下一步"}):e.jsxs(_,{onClick:we,disabled:f,children:[f&&e.jsx(Fs,{className:"w-4 h-4 mr-2 animate-spin"}),"提交审核"]})]})]})]})]})}function y4({value:a,label:l,onRemove:r}){const{attributes:c,listeners:d,setNodeRef:m,transform:h,transition:f,isDragging:p}=Cv({id:a}),g={transform:Tv.Transform.toString(h),transition:f,opacity:p?.5:1},N=b=>{b.preventDefault(),b.stopPropagation(),r(a)},j=b=>{b.stopPropagation()};return e.jsx("div",{ref:m,style:g,className:P("inline-flex items-center gap-1",p&&"shadow-lg"),children:e.jsxs(Ce,{variant:"secondary",className:"cursor-move hover:bg-secondary/80 flex items-center gap-1",children:[e.jsx("div",{...c,...d,className:"cursor-grab active:cursor-grabbing flex items-center",children:e.jsx(dv,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("span",{children:l}),e.jsx("span",{role:"button",tabIndex:0,className:"ml-1 rounded-sm hover:bg-destructive/20 focus:outline-none focus:ring-1 focus:ring-destructive cursor-pointer",onClick:N,onPointerDown:j,onMouseDown:b=>b.stopPropagation(),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),N(b))},children:e.jsx(Sa,{className:"h-3 w-3 hover:text-destructive",strokeWidth:2,fill:"none"})})]})})}function w4({options:a,selected:l,onChange:r,placeholder:c="选择选项...",emptyText:d="未找到选项",className:m}){const[h,f]=u.useState(!1),p=vv(Qo(yv,{activationConstraint:{distance:8}}),Qo(bv,{coordinateGetter:Nv})),g=b=>{l.includes(b)?r(l.filter(y=>y!==b)):r([...l,b])},N=b=>{r(l.filter(y=>y!==b))},j=b=>{const{active:y,over:w}=b;if(w&&y.id!==w.id){const z=l.indexOf(y.id),M=l.indexOf(w.id);r(wv(l,z,M))}};return e.jsxs(cl,{open:h,onOpenChange:f,children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":h,className:P("w-full justify-between min-h-10 h-auto",m),children:[e.jsx(_v,{sensors:p,collisionDetection:Sv,onDragEnd:j,children:e.jsx(kv,{items:l,strategy:p_,children:e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:l.length===0?e.jsx("span",{className:"text-muted-foreground",children:c}):l.map(b=>{const y=a.find(w=>w.value===b);return e.jsx(y4,{value:b,label:y?.label||b,onRemove:N},b)})})})}),e.jsx(mx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(tl,{className:"w-full p-0",align:"start",children:e.jsxs(md,{children:[e.jsx(xd,{placeholder:"搜索...",className:"h-9"}),e.jsxs(hd,{children:[e.jsx(fd,{children:d}),e.jsx(uc,{children:a.map(b=>{const y=l.includes(b.value);return e.jsxs(mc,{value:b.value,onSelect:()=>g(b.value),children:[e.jsx("div",{className:P("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",y?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Lt,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:b.label})]},b.value)})})]})]})})]})}const Ul=Bs.memo(function({title:l,description:r,taskConfig:c,modelNames:d,onChange:m,hideTemperature:h=!1,hideMaxTokens:f=!1,dataTour:p}){const g=N=>{m("model_list",N)};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:l}),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":p,children:[e.jsx(T,{children:"模型列表"}),e.jsx(w4,{options:d.map(N=>({label:N,value:N})),selected:c.model_list||[],onChange:g,placeholder:"选择模型...",emptyText:"暂无可用模型"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[!h&&e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:"温度"}),e.jsx(ne,{type:"number",step:"0.1",min:"0",max:"1",value:c.temperature??.3,onChange:N=>{const j=parseFloat(N.target.value);!isNaN(j)&&j>=0&&j<=1&&m("temperature",j)},className:"w-20 h-8 text-sm"})]}),e.jsx(el,{value:[c.temperature??.3],onValueChange:N=>m("temperature",N[0]),min:0,max:1,step:.1,className:"w-full"})]}),!f&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"最大 Token"}),e.jsx(ne,{type:"number",step:"1",min:"1",value:c.max_tokens??1024,onChange:N=>m("max_tokens",parseInt(N.target.value))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:"慢请求阈值 (秒)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"超时警告"})]}),e.jsx(ne,{type:"number",step:"1",min:"1",value:c.slow_threshold??15,onChange:N=>{const j=parseInt(N.target.value);!isNaN(j)&&j>=1&&m("slow_threshold",j)},placeholder:"15"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"模型响应时间超过此阈值将输出警告日志"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"模型选择策略"}),e.jsxs(Pe,{value:c.selection_strategy??"balance",onValueChange:N=>m("selection_strategy",N),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择模型选择策略"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"balance",children:"负载均衡(balance)"}),e.jsx(W,{value:"random",children:"随机选择(random)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"负载均衡:优先选择使用次数少的模型。随机选择:完全随机从模型列表中选择"})]})]})]})}),_4=Bs.memo(function({paginatedModels:l,allModels:r,onEdit:c,onDelete:d,isModelUsed:m,searchQuery:h}){return l.length===0?e.jsx("div",{className:"md:hidden text-center text-muted-foreground py-8 rounded-lg border bg-card",children:h?"未找到匹配的模型":"暂无模型配置"}):e.jsx("div",{className:"md:hidden space-y-3",children:l.map((f,p)=>{const g=r.findIndex(j=>j===f),N=m(f.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:f.name}),e.jsx(Ce,{variant:N?"default":"secondary",className:N?"bg-green-600 hover:bg-green-700":"",children:N?"已使用":"未使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",title:f.model_identifier,children:f.model_identifier})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>c(f,g),children:[e.jsx(Zn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>d(g),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(os,{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:f.api_provider})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"模型温度"}),e.jsx("p",{className:"font-medium",children:f.temperature!=null?f.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:["¥",f.price_in,"/M"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输出价格"}),e.jsxs("p",{className:"font-medium",children:["¥",f.price_out,"/M"]})]})]})]},p)})})}),S4=Bs.memo(function({paginatedModels:l,allModels:r,filteredModels:c,selectedModels:d,onEdit:m,onDelete:h,onToggleSelection:f,onToggleSelectAll:p,isModelUsed:g,searchQuery:N}){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(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{className:"w-12",children:e.jsx(tt,{checked:d.size===c.length&&c.length>0,onCheckedChange:p})}),e.jsx(ns,{className:"w-24",children:"使用状态"}),e.jsx(ns,{children:"模型名称"}),e.jsx(ns,{children:"模型标识符"}),e.jsx(ns,{children:"提供商"}),e.jsx(ns,{className:"text-center",children:"温度"}),e.jsx(ns,{className:"text-right",children:"输入价格"}),e.jsx(ns,{className:"text-right",children:"输出价格"}),e.jsx(ns,{className:"text-right",children:"操作"})]})}),e.jsx(Gl,{children:l.length===0?e.jsx(_t,{children:e.jsx(Ze,{colSpan:9,className:"text-center text-muted-foreground py-8",children:N?"未找到匹配的模型":"暂无模型配置"})}):l.map((j,b)=>{const y=r.findIndex(z=>z===j),w=g(j.name);return e.jsxs(_t,{children:[e.jsx(Ze,{children:e.jsx(tt,{checked:d.has(y),onCheckedChange:()=>f(y)})}),e.jsx(Ze,{children:e.jsx(Ce,{variant:w?"default":"secondary",className:w?"bg-green-600 hover:bg-green-700":"",children:w?"已使用":"未使用"})}),e.jsx(Ze,{className:"font-medium",children:j.name}),e.jsx(Ze,{className:"max-w-xs truncate",title:j.model_identifier,children:j.model_identifier}),e.jsx(Ze,{children:j.api_provider}),e.jsx(Ze,{className:"text-center",children:j.temperature!=null?j.temperature:e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsxs(Ze,{className:"text-right",children:["¥",j.price_in,"/M"]}),e.jsxs(Ze,{className:"text-right",children:["¥",j.price_out,"/M"]}),e.jsx(Ze,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>m(j,y),children:[e.jsx(Zn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>h(y),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(os,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},b)})})]})})})}),k4=300*1e3,Zg=new Map,C4=[10,20,50,100],T4=Bs.memo(function({page:l,pageSize:r,totalItems:c,jumpToPage:d,onPageChange:m,onPageSizeChange:h,onJumpToPageChange:f,onJumpToPage:p,onSelectionClear:g}){const N=Math.ceil(c/r),j=y=>{h(parseInt(y)),m(1),g?.()},b=y=>{y.key==="Enter"&&p()};return c===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(T,{htmlFor:"page-size-model",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Pe,{value:r.toString(),onValueChange:j,children:[e.jsx(Be,{id:"page-size-model",className:"w-20",children:e.jsx(Fe,{})}),e.jsx(Ie,{children:C4.map(y=>e.jsx(W,{value:y.toString(),children:y},y))})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(l-1)*r+1," 到"," ",Math.min(l*r,c)," 条,共 ",c," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>m(1),disabled:l===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>m(Math.max(1,l-1)),disabled:l===1,children:[e.jsx(Pa,{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(ne,{type:"number",value:d,onChange:y=>f(y.target.value),onKeyDown:b,placeholder:l.toString(),className:"w-16 h-8 text-center",min:1,max:N}),e.jsx(_,{variant:"outline",size:"sm",onClick:p,disabled:!d,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>m(l+1),disabled:l>=N,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(ra,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>m(N),disabled:l>=N,className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})});function E4(a){const{models:l,taskConfig:r,debounceMs:c=2e3,onSavingChange:d,onUnsavedChange:m}=a,h=u.useRef(null),f=u.useRef(null),p=u.useRef(!0),g=u.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null),f.current&&(clearTimeout(f.current),f.current=null)},[]),N=u.useCallback(y=>{const w={model_identifier:y.model_identifier,name:y.name,api_provider:y.api_provider,price_in:y.price_in??0,price_out:y.price_out??0,force_stream_mode:y.force_stream_mode??!1,extra_params:y.extra_params??{}};return y.temperature!=null&&(w.temperature=y.temperature),y.max_tokens!=null&&(w.max_tokens=y.max_tokens),w},[]),j=u.useCallback(async y=>{try{d?.(!0);const w=y.map(N);await Wm("models",w),m?.(!1)}catch(w){console.error("自动保存模型列表失败:",w),m?.(!0)}finally{d?.(!1)}},[d,m,N]),b=u.useCallback(async y=>{try{d?.(!0),await Wm("model_task_config",y),m?.(!1)}catch(w){console.error("自动保存任务配置失败:",w),m?.(!0)}finally{d?.(!1)}},[d,m]);return u.useEffect(()=>{if(!p.current)return m?.(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{j(l)},c),()=>{h.current&&clearTimeout(h.current)}},[l,j,c,m]),u.useEffect(()=>{if(!(p.current||!r))return m?.(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{b(r)},c),()=>{f.current&&clearTimeout(f.current)}},[r,b,c,m]),u.useEffect(()=>()=>{g()},[g]),{clearTimers:g,initialLoadRef:p}}function M4(a={}){const{onCloseEditDialog:l}=a,r=ha(),{registerTour:c,startTour:d,state:m,goToStep:h}=Ex(),f=u.useRef(m.stepIndex);return u.useEffect(()=>{c(gl,aN)},[c]),u.useEffect(()=>{if(m.activeTourId===gl&&m.isRunning){const g=lN[m.stepIndex];g&&!window.location.pathname.endsWith(g.replace("/config/",""))&&r({to:g})}},[m.stepIndex,m.activeTourId,m.isRunning,r]),u.useEffect(()=>{if(m.activeTourId===gl&&m.isRunning){const g=f.current,N=m.stepIndex;g>=12&&g<=17&&N<12&&l?.(),f.current=N}},[m.stepIndex,m.activeTourId,m.isRunning,l]),u.useEffect(()=>{if(m.activeTourId!==gl||!m.isRunning)return;const g=N=>{const j=N.target,b=m.stepIndex;b===2&&j.closest('[data-tour="add-provider-button"]')?setTimeout(()=>h(3),300):b===9&&j.closest('[data-tour="provider-cancel-button"]')?setTimeout(()=>h(10),300):b===11&&j.closest('[data-tour="add-model-button"]')?setTimeout(()=>h(12),300):b===17&&j.closest('[data-tour="model-cancel-button"]')?setTimeout(()=>h(18),300):b===18&&j.closest('[data-tour="tasks-tab-trigger"]')&&setTimeout(()=>h(19),300)};return document.addEventListener("click",g,!0),()=>document.removeEventListener("click",g,!0)},[m,h]),{startTour:u.useCallback(()=>{d(gl)},[d]),isRunning:m.isRunning&&m.activeTourId===gl,stepIndex:m.stepIndex}}function A4(a){const{getProviderConfig:l}=a,[r,c]=u.useState([]),[d,m]=u.useState(!1),[h,f]=u.useState(null),[p,g]=u.useState(null),N=u.useCallback(()=>{c([]),f(null),g(null)},[]),j=u.useCallback(async(b,y=!1)=>{const w=l(b);if(!w?.base_url){c([]),g(null),f('提供商配置不完整,请先在"模型提供商配置"中配置');return}if(!w.api_key){c([]),g(null),f('该提供商未配置 API Key,请先在"模型提供商配置"中填写');return}const z=n4(w.base_url);if(g(z),!z?.modelFetcher){c([]),f(null);return}const M=`${b}:${w.base_url}`,S=Zg.get(M);if(!y&&S&&Date.now()-S.timestamp<k4){c(S.models),f(null);return}m(!0),f(null);try{const F=await bS(b,z.modelFetcher.parser,z.modelFetcher.endpoint);c(F),Zg.set(M,{models:F,timestamp:Date.now()})}catch(F){console.error("获取模型列表失败:",F);const E=F.message||"获取模型列表失败";E.includes("无效")||E.includes("过期")||E.includes("API Key")?f('API Key 无效或已过期,请检查"模型提供商配置"中的密钥'):E.includes("权限")?f("没有权限获取模型列表,请检查 API Key 权限"):E.includes("timeout")||E.includes("超时")?f("请求超时,请检查网络连接后重试"):E.includes("不支持")?f("该提供商不支持自动获取模型列表,请手动输入"):f(E),c([])}finally{m(!1)}},[l]);return{availableModels:r,fetchingModels:d,modelFetchError:h,matchedTemplate:p,fetchModelsForProvider:j,clearModels:N}}function z4(){return e.jsx(lr,{children:e.jsx(R4,{})})}function R4(){const[a,l]=u.useState([]),[r,c]=u.useState([]),[d,m]=u.useState([]),[h,f]=u.useState([]),[p,g]=u.useState(null),[N,j]=u.useState(!0),[b,y]=u.useState(!1),[w,z]=u.useState(!1),[M,S]=u.useState(!1),[F,E]=u.useState(!1),[C,R]=u.useState(null),[H,O]=u.useState(null),[X,L]=u.useState(!1),[me,Ne]=u.useState(!1),[je,ce]=u.useState(null),[ge,pe]=u.useState(""),[D,Q]=u.useState(new Set),[B,ue]=u.useState(!1),[Y,we]=u.useState(1),[fe,Ee]=u.useState(20),[G,$]=u.useState(""),[A,K]=u.useState(!1),[Re,se]=u.useState(!1),[$e,cs]=u.useState(!1),J=u.useRef([]),Z=u.useRef(null),[Le,le]=u.useState([]),[De,xe]=u.useState([]),[Me,ds]=u.useState({}),{toast:Ts}=nt(),{triggerRestart:kt,isRestarting:ia}=Tn(),{startTour:ut,isRunning:Is}=M4({onCloseEditDialog:()=>E(!1)}),{clearTimers:V,initialLoadRef:Ke}=E4({models:a,taskConfig:p,onSavingChange:z,onUnsavedChange:S}),He=u.useCallback((ae,oe)=>{if(!ae)return;const qe=new Set(oe.map(Ca=>Ca.name)),Ys=[],Ps=[],vt=[{key:"utils",label:"工具模型"},{key:"tool_use",label:"工具调用模型"},{key:"replyer",label:"回复模型"},{key:"planner",label:"规划器模型"},{key:"vlm",label:"视觉模型"},{key:"voice",label:"语音模型"},{key:"embedding",label:"嵌入模型"},{key:"lpmm_entity_extract",label:"LPMM实体抽取"},{key:"lpmm_rdf_build",label:"LPMM关系构建"}];for(const{key:Ca,label:ll}of vt){const ml=ae[Ca];if(!ml)continue;if(!ml.model_list||ml.model_list.length===0){Ps.push(ll);continue}const rr=ml.model_list.filter(Ql=>!qe.has(Ql));rr.length>0&&Ys.push({taskName:ll,invalidModels:rr})}le(Ys),xe(Ps)},[]),Je=u.useCallback(async()=>{try{j(!0);const ae=await Nn(),oe=ae.models||[];l(oe),f(oe.map(vt=>vt.name));const qe=ae.api_providers||[];c(qe.map(vt=>vt.name)),m(qe);const Ys=ae.model_task_config||null;g(Ys),He(Ys,oe);const Ps=Ys?.embedding?.model_list||[];J.current=[...Ps],S(!1),Ke.current=!1}catch(ae){console.error("加载配置失败:",ae)}finally{j(!1)}},[Ke,He]);u.useEffect(()=>{Je()},[Je]);const Es=u.useCallback(ae=>d.find(oe=>oe.name===ae),[d]),{availableModels:ms,fetchingModels:Ms,modelFetchError:We,matchedTemplate:Cs,fetchModelsForProvider:rs,clearModels:is}=A4({getProviderConfig:Es});u.useEffect(()=>{F&&C?.api_provider&&rs(C.api_provider)},[F,C?.api_provider,rs]);const ys=async()=>{await kt()},rt=u.useCallback(()=>{if(!p)return;const ae=new Set(a.map(Ys=>Ys.name)),oe={...p},qe=Object.keys(oe);for(const Ys of qe){const Ps=oe[Ys];Ps&&Ps.model_list&&(Ps.model_list=Ps.model_list.filter(vt=>ae.has(vt)))}g(oe),le([]),Ts({title:"清理完成",description:"已删除所有无效的模型引用"})},[p,a,Ts]),jt=ae=>{const oe={model_identifier:ae.model_identifier,name:ae.name,api_provider:ae.api_provider,price_in:ae.price_in??0,price_out:ae.price_out??0,force_stream_mode:ae.force_stream_mode??!1,extra_params:ae.extra_params??{}};return ae.temperature!=null&&(oe.temperature=ae.temperature),ae.max_tokens!=null&&(oe.max_tokens=ae.max_tokens),oe},Ae=async()=>{try{y(!0),V();const ae=await Nn();ae.models=a.map(jt),ae.model_task_config=p,await lc(ae),S(!1),Ts({title:"保存成功",description:"正在重启麦麦..."}),await ys()}catch(ae){console.error("保存配置失败:",ae),Ts({title:"保存失败",description:ae.message,variant:"destructive"}),y(!1)}},Qe=async()=>{try{y(!0),V();const ae=await Nn();ae.models=a.map(jt),ae.model_task_config=p,await lc(ae),S(!1),Ts({title:"保存成功",description:"模型配置已保存"}),await Je()}catch(ae){console.error("保存配置失败:",ae),Ts({title:"保存失败",description:ae.message,variant:"destructive"})}finally{y(!1)}},As=(ae,oe)=>{ds({}),R(ae||{model_identifier:"",name:"",api_provider:r[0]||"",price_in:0,price_out:0,temperature:null,max_tokens:null,force_stream_mode:!1,extra_params:{}}),O(oe),E(!0)},mt=()=>{if(!C)return;const ae={};if(C.name?.trim()?a.some((vt,Ca)=>H!==null&&Ca===H?!1:vt.name.trim().toLowerCase()===C.name.trim().toLowerCase())&&(ae.name="模型名称已存在,请使用其他名称"):ae.name="请输入模型名称",C.api_provider?.trim()||(ae.api_provider="请选择 API 提供商"),C.model_identifier?.trim()||(ae.model_identifier="请输入模型标识符"),Object.keys(ae).length>0){ds(ae);return}ds({});const oe={model_identifier:C.model_identifier,name:C.name,api_provider:C.api_provider,price_in:C.price_in??0,price_out:C.price_out??0,force_stream_mode:C.force_stream_mode??!1,extra_params:C.extra_params??{}};C.temperature!=null&&(oe.temperature=C.temperature),C.max_tokens!=null&&(oe.max_tokens=C.max_tokens);let qe,Ys=null;if(H!==null?(Ys=a[H].name,qe=[...a],qe[H]=oe):qe=[...a,oe],l(qe),f(qe.map(Ps=>Ps.name)),Ys&&Ys!==oe.name&&p){const Ps=vt=>vt.map(Ca=>Ca===Ys?oe.name:Ca);g({...p,utils:{...p.utils,model_list:Ps(p.utils?.model_list||[])},tool_use:{...p.tool_use,model_list:Ps(p.tool_use?.model_list||[])},replyer:{...p.replyer,model_list:Ps(p.replyer?.model_list||[])},planner:{...p.planner,model_list:Ps(p.planner?.model_list||[])},vlm:{...p.vlm,model_list:Ps(p.vlm?.model_list||[])},voice:{...p.voice,model_list:Ps(p.voice?.model_list||[])},embedding:{...p.embedding,model_list:Ps(p.embedding?.model_list||[])},lpmm_entity_extract:{...p.lpmm_entity_extract,model_list:Ps(p.lpmm_entity_extract?.model_list||[])},lpmm_rdf_build:{...p.lpmm_rdf_build,model_list:Ps(p.lpmm_rdf_build?.model_list||[])}})}E(!1),R(null),O(null),Ts({title:H!==null?"模型已更新":"模型已添加",description:'配置将在 2 秒后自动保存,或点击右上角"保存配置"按钮立即保存'})},Ht=ae=>{if(!ae&&C){const oe={...C,price_in:C.price_in??0,price_out:C.price_out??0};R(oe)}E(ae)},ca=ae=>{ce(ae),Ne(!0)},Fa=()=>{if(je!==null){const ae=a.filter((oe,qe)=>qe!==je);l(ae),f(ae.map(oe=>oe.name)),He(p,ae),Ts({title:"删除成功",description:'配置将在 2 秒后自动保存,或点击右上角"保存配置"按钮立即保存'})}Ne(!1),ce(null)},Xt=ae=>{const oe=new Set(D);oe.has(ae)?oe.delete(ae):oe.add(ae),Q(oe)},te=()=>{if(D.size===es.length)Q(new Set);else{const ae=es.map((oe,qe)=>a.findIndex(Ys=>Ys===es[qe]));Q(new Set(ae))}},_e=()=>{if(D.size===0){Ts({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}ue(!0)},U=()=>{const ae=D.size,oe=a.filter((qe,Ys)=>!D.has(Ys));l(oe),f(oe.map(qe=>qe.name)),He(p,oe),Q(new Set),ue(!1),Ts({title:"批量删除成功",description:`已删除 ${ae} 个模型,配置将在 2 秒后自动保存`})},Se=(ae,oe,qe)=>{if(!p)return;if(ae==="embedding"&&oe==="model_list"&&Array.isArray(qe)){const Ps=J.current,vt=qe;if((Ps.length!==vt.length||Ps.some(ll=>!vt.includes(ll))||vt.some(ll=>!Ps.includes(ll)))&&Ps.length>0){Z.current={field:oe,value:qe},cs(!0);return}}const Ys={...p,[ae]:{...p[ae],[oe]:qe}};g(Ys),He(Ys,a),ae==="embedding"&&oe==="model_list"&&Array.isArray(qe)&&(J.current=[...qe])},as=()=>{if(!p||!Z.current)return;const{field:ae,value:oe}=Z.current,qe={...p,embedding:{...p.embedding,[ae]:oe}};g(qe),He(qe,a),ae==="model_list"&&Array.isArray(oe)&&(J.current=[...oe]),Z.current=null,cs(!1),Ts({title:"嵌入模型已更新",description:"建议重新生成知识库向量以确保最佳匹配精度"})},us=()=>{Z.current=null,cs(!1)},es=a.filter(ae=>{if(!ge)return!0;const oe=ge.toLowerCase();return ae.name.toLowerCase().includes(oe)||ae.model_identifier.toLowerCase().includes(oe)||ae.api_provider.toLowerCase().includes(oe)}),Ct=Math.ceil(es.length/fe),$s=es.slice((Y-1)*fe,Y*fe),pa=()=>{const ae=parseInt(G);ae>=1&&ae<=Ct&&(we(ae),$(""))},oa=ae=>p?[p.utils?.model_list||[],p.tool_use?.model_list||[],p.replyer?.model_list||[],p.planner?.model_list||[],p.vlm?.model_list||[],p.voice?.model_list||[],p.embedding?.model_list||[],p.lpmm_entity_extract?.model_list||[],p.lpmm_rdf_build?.model_list||[]].some(qe=>qe.includes(ae)):!1;return N?e.jsx(ts,{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(ts,{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.jsx(b4,{trigger:e.jsxs(_,{variant:"outline",size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(mv,{className:"mr-2 h-4 w-4"}),"分享配置"]})}),e.jsxs(_,{onClick:Qe,disabled:b||w||!M||ia,size:"sm",variant:"outline",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(gc,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),b?"保存中...":w?"自动保存中...":M?"保存配置":"已保存"]}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{disabled:b||w||ia,size:"sm",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(pc,{className:"mr-2 h-4 w-4"}),ia?"重启中...":M?"保存并重启":"重启麦麦"]})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认重启麦麦?"}),e.jsx(gs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:M?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:M?Ae:ys,children:M?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsxs(ft,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),Le.length>0&&e.jsxs(ht,{variant:"destructive",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsxs(ft,{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("strong",{children:"检测到无效的模型引用"}),e.jsx("div",{className:"mt-2 space-y-1",children:Le.map(({taskName:ae,invalidModels:oe})=>e.jsxs("div",{className:"text-sm",children:[e.jsx("strong",{children:ae})," 引用了不存在的模型: ",oe.join(", ")]},ae))})]}),e.jsx(_,{variant:"outline",size:"sm",className:"shrink-0 bg-background hover:bg-accent",onClick:rt,children:"一键清理"})]})]}),De.length>0&&e.jsxs(ht,{variant:"default",className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Ut,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(ft,{children:[e.jsx("strong",{className:"text-yellow-600",children:"以下任务未配置模型"}),e.jsxs("div",{className:"mt-2 text-sm",children:[De.join("、")," 还未分配模型,这些功能将无法正常工作。"]})]})]}),e.jsxs(ht,{className:"hidden lg:flex border-primary/30 bg-primary/5 cursor-pointer hover:bg-primary/10 transition-colors",onClick:ut,children:[e.jsx(U1,{className:"h-4 w-4 text-primary"}),e.jsxs(ft,{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:"新手引导:"}),"不知道如何配置模型?点击这里开始学习如何为麦麦的组件分配模型。"]}),e.jsx(_,{variant:"outline",size:"sm",className:"ml-4 shrink-0",children:"开始引导"})]})]}),e.jsxs(Jt,{defaultValue:"models",className:"w-full",children:[e.jsxs(Gt,{className:"grid w-full max-w-full sm:max-w-md grid-cols-2",children:[e.jsx(Xe,{value:"models",children:"添加模型"}),e.jsx(Xe,{value:"tasks","data-tour":"tasks-tab-trigger",children:"为模型分配功能"})]}),e.jsxs(Ss,{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:[D.size>0&&e.jsxs(_,{onClick:_e,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(os,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",D.size,")"]}),e.jsxs(_,{onClick:()=>As(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto","data-tour":"add-model-button",children:[e.jsx(Xs,{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($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索模型名称、标识符或提供商...",value:ge,onChange:ae=>pe(ae.target.value),className:"pl-9"})]}),ge&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",es.length," 个结果"]})]}),e.jsx(_4,{paginatedModels:$s,allModels:a,onEdit:As,onDelete:ca,isModelUsed:oa,searchQuery:ge}),e.jsx(S4,{paginatedModels:$s,allModels:a,filteredModels:es,selectedModels:D,onEdit:As,onDelete:ca,onToggleSelection:Xt,onToggleSelectAll:te,isModelUsed:oa,searchQuery:ge}),e.jsx(T4,{page:Y,pageSize:fe,totalItems:es.length,jumpToPage:G,onPageChange:we,onPageSizeChange:Ee,onJumpToPageChange:$,onJumpToPage:pa,onSelectionClear:()=>Q(new Set)})]}),e.jsxs(Ss,{value:"tasks",className:"space-y-6 mt-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"为不同的任务配置使用的模型和参数"}),p&&e.jsxs("div",{className:"grid gap-4 sm:gap-6",children:[e.jsx(Ul,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:p.utils,modelNames:h,onChange:(ae,oe)=>Se("utils",ae,oe),dataTour:"task-model-select"}),e.jsx(Ul,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:p.tool_use,modelNames:h,onChange:(ae,oe)=>Se("tool_use",ae,oe)}),e.jsx(Ul,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:p.replyer,modelNames:h,onChange:(ae,oe)=>Se("replyer",ae,oe)}),e.jsx(Ul,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:p.planner,modelNames:h,onChange:(ae,oe)=>Se("planner",ae,oe)}),e.jsx(Ul,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:p.vlm,modelNames:h,onChange:(ae,oe)=>Se("vlm",ae,oe),hideTemperature:!0}),e.jsx(Ul,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:p.voice,modelNames:h,onChange:(ae,oe)=>Se("voice",ae,oe),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(Ul,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:p.embedding,modelNames:h,onChange:(ae,oe)=>Se("embedding",ae,oe),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(Ul,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:p.lpmm_entity_extract,modelNames:h,onChange:(ae,oe)=>Se("lpmm_entity_extract",ae,oe)}),e.jsx(Ul,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:p.lpmm_rdf_build,modelNames:h,onChange:(ae,oe)=>Se("lpmm_rdf_build",ae,oe)})]})]})]})]}),e.jsx(Qs,{open:F,onOpenChange:Ht,children:e.jsxs(Hs,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"model-dialog",preventOutsideClose:Is,children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:H!==null?"编辑模型":"添加模型"}),e.jsx(at,{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(T,{htmlFor:"model_name",className:Me.name?"text-destructive":"",children:"模型名称 *"}),e.jsx(ne,{id:"model_name",value:C?.name||"",onChange:ae=>{R(oe=>oe?{...oe,name:ae.target.value}:null),Me.name&&ds(oe=>({...oe,name:void 0}))},placeholder:"例如: qwen3-30b",className:Me.name?"border-destructive focus-visible:ring-destructive":""}),Me.name?e.jsx("p",{className:"text-xs text-destructive",children:Me.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(T,{htmlFor:"api_provider",className:Me.api_provider?"text-destructive":"",children:"API 提供商 *"}),e.jsxs(Pe,{value:C?.api_provider||"",onValueChange:ae=>{R(oe=>oe?{...oe,api_provider:ae}:null),is(),Me.api_provider&&ds(oe=>({...oe,api_provider:void 0}))},children:[e.jsx(Be,{id:"api_provider",className:Me.api_provider?"border-destructive focus-visible:ring-destructive":"",children:e.jsx(Fe,{placeholder:"选择提供商"})}),e.jsx(Ie,{children:r.map(ae=>e.jsx(W,{value:ae,children:ae},ae))})]}),Me.api_provider&&e.jsx("p",{className:"text-xs text-destructive",children:Me.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(T,{htmlFor:"model_identifier",className:Me.model_identifier?"text-destructive":"",children:"模型标识符 *"}),Cs?.modelFetcher&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{variant:"secondary",className:"text-xs",children:Cs.display_name}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>C?.api_provider&&rs(C.api_provider,!0),disabled:Ms,children:Ms?e.jsx(Fs,{className:"h-3 w-3 animate-spin"}):e.jsx(dt,{className:"h-3 w-3"})})]})]}),Cs?.modelFetcher?e.jsxs(cl,{open:Re,onOpenChange:se,children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":Re,className:"w-full justify-between font-normal",disabled:Ms||!!We,children:[Ms?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Fs,{className:"h-4 w-4 animate-spin"}),"正在获取模型列表..."]}):We?e.jsx("span",{className:"text-muted-foreground text-sm",children:"点击下方输入框手动填写"}):C?.model_identifier?e.jsx("span",{className:"truncate",children:C.model_identifier}):e.jsx("span",{className:"text-muted-foreground",children:"搜索或选择模型..."}),e.jsx(mx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(tl,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(md,{children:[e.jsx(xd,{placeholder:"搜索模型..."}),e.jsx(ts,{className:"h-[300px]",children:e.jsxs(hd,{className:"max-h-none overflow-visible",children:[e.jsx(fd,{children:We?e.jsxs("div",{className:"py-4 px-2 text-center space-y-2",children:[e.jsx("p",{className:"text-sm text-destructive",children:We}),!We.includes("API Key")&&e.jsx(_,{variant:"link",size:"sm",onClick:()=>C?.api_provider&&rs(C.api_provider,!0),children:"重试"})]}):"未找到匹配的模型"}),e.jsx(uc,{heading:"可用模型",children:ms.map(ae=>e.jsxs(mc,{value:ae.id,onSelect:()=>{R(oe=>oe?{...oe,model_identifier:ae.id}:null),se(!1)},children:[e.jsx(Lt,{className:`mr-2 h-4 w-4 ${C?.model_identifier===ae.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:ae.id}),ae.name!==ae.id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ae.name})]})]},ae.id))}),e.jsx(uc,{heading:"手动输入",children:e.jsxs(mc,{value:"__manual_input__",onSelect:()=>{se(!1)},children:[e.jsx(Zn,{className:"mr-2 h-4 w-4"}),"手动输入模型标识符..."]})})]})})]})})]}):e.jsx(ne,{id:"model_identifier",value:C?.model_identifier||"",onChange:ae=>{R(oe=>oe?{...oe,model_identifier:ae.target.value}:null),Me.model_identifier&&ds(oe=>({...oe,model_identifier:void 0}))},placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507",className:Me.model_identifier?"border-destructive focus-visible:ring-destructive":""}),Me.model_identifier&&e.jsx("p",{className:"text-xs text-destructive",children:Me.model_identifier}),We&&Cs?.modelFetcher&&!Me.model_identifier&&e.jsxs(ht,{variant:"destructive",className:"mt-2 py-2",children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(ft,{className:"text-xs",children:We})]}),Cs?.modelFetcher&&e.jsx(ne,{value:C?.model_identifier||"",onChange:ae=>{R(oe=>oe?{...oe,model_identifier:ae.target.value}:null),Me.model_identifier&&ds(oe=>({...oe,model_identifier:void 0}))},placeholder:"或手动输入模型标识符",className:`mt-2 ${Me.model_identifier?"border-destructive focus-visible:ring-destructive":""}`}),!Me.model_identifier&&e.jsx("p",{className:"text-xs text-muted-foreground",children:We?'请手动输入模型标识符,或前往"模型提供商配置"检查 API Key':Cs?.modelFetcher?`已识别为 ${Cs.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(T,{htmlFor:"price_in",children:"输入价格 (¥/M token)"}),e.jsx(ne,{id:"price_in",type:"number",step:"0.1",min:"0",value:C?.price_in??"",onChange:ae=>{const oe=ae.target.value===""?null:parseFloat(ae.target.value);R(qe=>qe?{...qe,price_in:oe}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(ne,{id:"price_out",type:"number",step:"0.1",min:"0",value:C?.price_out??"",onChange:ae=>{const oe=ae.target.value===""?null:parseFloat(ae.target.value);R(qe=>qe?{...qe,price_out:oe}: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.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"enable_model_temperature",className:"cursor-pointer",children:"自定义模型温度"}),e.jsx(Bl,{content:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"什么是温度(Temperature)?"}),e.jsx("p",{children:"温度控制模型输出的随机性和创造性:"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"低温度(0.1-0.3)"}),":更确定、更保守的输出,适合事实性任务"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"中温度(0.5-0.7)"}),":平衡创造性与可控性"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"高温度(0.8-1.0)"}),":更有创意、更多样化的输出"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"极高温度(1.0-2.0)"}),":极度随机,可能产生不可预测的结果"]})]})]}),side:"right",maxWidth:"400px"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务温度配置"})]}),e.jsx(Ge,{id:"enable_model_temperature",checked:C?.temperature!=null,onCheckedChange:ae=>{R(ae?oe=>oe?{...oe,temperature:.5}:null:oe=>oe?{...oe,temperature:null}:null)}})]}),C?.temperature!=null&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(T,{className:"text-sm",children:"温度值"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{type:"number",value:C.temperature,onChange:ae=>{const oe=parseFloat(ae.target.value);!isNaN(oe)&&oe>=0&&oe<=2&&R(qe=>qe?{...qe,temperature:oe}:null)},onBlur:ae=>{const oe=parseFloat(ae.target.value);isNaN(oe)||oe<0?R(qe=>qe?{...qe,temperature:0}:null):oe>2&&R(qe=>qe?{...qe,temperature:2}:null)},step:.01,min:0,max:2,className:"w-20 h-8 text-sm text-right tabular-nums"}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>K(!A),className:"h-8 px-2",title:A?"切换到基础模式 (0-1)":"解锁高级范围 (0-2)",children:A?e.jsx($1,{className:"h-4 w-4"}):e.jsx(Jm,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:"0"}),e.jsx(el,{value:[C.temperature],onValueChange:ae=>R(oe=>oe?{...oe,temperature:ae[0]}:null),min:0,max:A?2:1,step:A?.05:.1,className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:A?"2":"1"})]}),A&&e.jsxs(ht,{className:"bg-amber-500/10 border-amber-500/20 [&>svg+div]:translate-y-0",children:[e.jsx(Ut,{className:"h-4 w-4 text-amber-500"}),e.jsx(ft,{className:"text-xs text-amber-600 dark:text-amber-400",children:"高级模式:温度 > 1 会产生更随机、更不可预测的输出,请谨慎使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:A?"较低(0.1-0.5)产生确定输出,中等(0.5-1.0)平衡创造性,较高(1.0-2.0)产生极度随机输出":"较低的温度(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.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(T,{htmlFor:"enable_model_max_tokens",className:"cursor-pointer",children:"自定义最大 Token"}),e.jsx(Bl,{content:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"什么是最大 Token?"}),e.jsx("p",{children:"控制模型单次回复的最大长度。1 token ≈ 0.75 个英文单词或 0.5 个中文字符。"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"较小值(512-1024)"}),":简短回复,节省成本"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"中等值(2048-4096)"}),":正常对话长度"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"较大值(8192+)"}),":长文本生成,成本较高"]})]})]}),side:"right",maxWidth:"400px"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务最大 Token 配置"})]}),e.jsx(Ge,{id:"enable_model_max_tokens",checked:C?.max_tokens!=null,onCheckedChange:ae=>{R(ae?oe=>oe?{...oe,max_tokens:2048}:null:oe=>oe?{...oe,max_tokens:null}:null)}})]}),C?.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(T,{className:"text-sm",children:"最大 Token 数"}),e.jsx(ne,{type:"number",min:"1",max:"128000",value:C.max_tokens,onChange:ae=>{const oe=parseInt(ae.target.value);!isNaN(oe)&&oe>=1&&R(qe=>qe?{...qe,max_tokens:oe}: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(Ge,{id:"force_stream_mode",checked:C?.force_stream_mode||!1,onCheckedChange:ae=>R(oe=>oe?{...oe,force_stream_mode:ae}:null)}),e.jsx(T,{htmlFor:"force_stream_mode",className:"cursor-pointer",children:"强制流式输出模式"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"额外参数"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(_,{type:"button",variant:"outline",size:"sm",className:"flex-1 justify-start h-9",onClick:()=>L(!0),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),Object.keys(C?.extra_params||{}).length>0?e.jsxs("span",{children:["已配置 ",Object.keys(C?.extra_params||{}).length," 个参数"]}):e.jsx("span",{className:"text-muted-foreground",children:"未配置额外参数"})]})}),Object.keys(C?.extra_params||{}).length>0&&e.jsxs("div",{className:"text-xs text-muted-foreground px-1",children:[Object.keys(C?.extra_params||{}).slice(0,3).map(ae=>e.jsx("span",{className:"inline-block mr-2",children:e.jsx("code",{className:"px-1.5 py-0.5 bg-muted rounded",children:ae})},ae)),Object.keys(C?.extra_params||{}).length>3&&e.jsx("span",{children:"..."})]})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>E(!1),"data-tour":"model-cancel-button",children:"取消"}),e.jsx(_,{onClick:mt,"data-tour":"model-save-button",children:"保存"})]})]})}),e.jsx(bs,{open:me,onOpenChange:Ne,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除模型 "',je!==null?a[je]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:Fa,children:"删除"})]})]})}),e.jsx(bs,{open:B,onOpenChange:ue,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认批量删除"}),e.jsxs(gs,{children:["确定要删除选中的 ",D.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),e.jsx(bs,{open:$e,onOpenChange:cs,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsxs(ps,{className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"h-5 w-5 text-amber-500"}),"更换嵌入模型警告"]}),e.jsx(gs,{asChild:!0,children:e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-foreground",children:"注意:"}),"更换嵌入模型可能会影响知识库的匹配精度!"]}),e.jsxs("ul",{className:"space-y-2 ml-4 list-disc text-muted-foreground",children:[e.jsx("li",{children:"不同的嵌入模型会产生不同的向量表示"}),e.jsx("li",{children:"这可能导致现有知识库的检索结果不准确"}),e.jsx("li",{children:"建议更换嵌入模型后重新生成所有知识库的向量"})]}),e.jsx("p",{className:"text-foreground font-medium",children:"确定要更换嵌入模型吗?"})]})})]}),e.jsxs(fs,{children:[e.jsx(vs,{onClick:us,children:"取消"}),e.jsx(js,{onClick:as,className:"bg-amber-600 hover:bg-amber-700",children:"确认更换"})]})]})}),e.jsx(u4,{open:X,onOpenChange:L,value:C?.extra_params||{},onChange:ae=>R(oe=>oe?{...oe,extra_params:ae}:null)}),e.jsx(nr,{})]})})}const xc=Mj,hc=Aw,fc=zw,pd="/api/webui/config";async function D4(){const l=await(await ke(`${pd}/adapter-config/path`)).json();return!l.success||!l.path?null:{path:l.path,lastModified:l.lastModified}}async function Wg(a){const r=await(await ke(`${pd}/adapter-config/path`,{method:"POST",headers:Zs(),body:JSON.stringify({path:a})})).json();if(!r.success)throw new Error(r.message||"保存路径失败")}async function ej(a){const r=await(await ke(`${pd}/adapter-config?path=${encodeURIComponent(a)}`)).json();if(!r.success)throw new Error("读取配置文件失败");return r.content}async function sj(a,l){const c=await(await ke(`${pd}/adapter-config`,{method:"POST",headers:Zs(),body:JSON.stringify({path:a,content:l})})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}const At={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"}},Fm={oneclick:{name:"一键包",description:"使用一键包部署的适配器配置",path:"../MaiBot-Napcat-Adapter/config.toml",icon:xa},docker:{name:"Docker",description:"Docker Compose 部署的适配器配置",path:"/MaiMBot/adapters-config/config.toml",icon:B1}};function Hm(a){try{const l=_x(a);return{inner:{...At.inner,...l.inner},nickname:{...At.nickname,...l.nickname},napcat_server:{...At.napcat_server,...l.napcat_server},maibot_server:{...At.maibot_server,...l.maibot_server},chat:{...At.chat,...l.chat},voice:{...At.voice,...l.voice},debug:{...At.debug,...l.debug}}}catch(l){throw console.error("TOML 解析失败:",l),new Error(`无法解析 TOML 文件: ${l instanceof Error?l.message:"未知错误"}`)}}function qm(a){try{const l=(d,m)=>d===""||d===null||d===void 0?m:d,r={inner:{version:l(a.inner.version,At.inner.version)},nickname:{nickname:l(a.nickname.nickname,At.nickname.nickname)},napcat_server:{host:l(a.napcat_server.host,At.napcat_server.host),port:l(a.napcat_server.port||0,At.napcat_server.port),token:l(a.napcat_server.token,At.napcat_server.token),heartbeat_interval:l(a.napcat_server.heartbeat_interval||0,At.napcat_server.heartbeat_interval)},maibot_server:{host:l(a.maibot_server.host,At.maibot_server.host),port:l(a.maibot_server.port||0,At.maibot_server.port)},chat:{group_list_type:l(a.chat.group_list_type,At.chat.group_list_type),group_list:a.chat.group_list||[],private_list_type:l(a.chat.private_list_type,At.chat.private_list_type),private_list:a.chat.private_list||[],ban_user_id:a.chat.ban_user_id||[],ban_qq_bot:a.chat.ban_qq_bot??At.chat.ban_qq_bot,enable_poke:a.chat.enable_poke??At.chat.enable_poke},voice:{use_tts:a.voice.use_tts??At.voice.use_tts},debug:{level:l(a.debug.level,At.debug.level)}};let c=GS(r);return c=O4(c),c}catch(l){throw console.error("TOML 生成失败:",l),new Error(`无法生成 TOML 文件: ${l instanceof Error?l.message:"未知错误"}`)}}function O4(a){const l=a.split(`
|
||
`),r=[];for(let c=0;c<l.length;c++){const d=l[c];if(d==="[inner]"){r.push(d);continue}if(d.startsWith("version = ")){r.push(`${d} # 版本号`),r.push("# 请勿修改版本号,除非你知道自己在做什么");continue}if(d==="[nickname]"){r.push("[nickname] # 现在没用");continue}if(d==="[napcat_server]"){r.push("[napcat_server] # Napcat连接的ws服务设置");continue}if(d.startsWith("host = ")&&r[r.length-1]?.includes("[napcat_server]")){r.push(`${d} # Napcat设定的主机地址`);continue}if(d.startsWith("port = ")&&l[c-1]?.includes("host")){r.push(`${d} # Napcat设定的端口`);continue}if(d.startsWith("token = ")){r.push(`${d} # Napcat设定的访问令牌,若无则留空`);continue}if(d.startsWith("heartbeat_interval = ")){r.push(`${d} # 与Napcat设置的心跳相同(按秒计)`);continue}if(d==="[maibot_server]"){r.push("[maibot_server] # 连接麦麦的ws服务设置");continue}if(d.startsWith("host = ")&&r[r.length-1]?.includes("[maibot_server]")){r.push(`${d} # 麦麦在.env文件中设置的主机地址,即HOST字段`);continue}if(d.startsWith("port = ")&&r[r.length-1]?.includes("麦麦在.env")){r.push(`${d} # 麦麦在.env文件中设置的端口,即PORT字段`);continue}if(d==="[chat]"){r.push("[chat] # 黑白名单功能");continue}if(d.startsWith("group_list_type = ")){r.push(`${d} # 群组名单类型,可选为:whitelist, blacklist`);continue}if(d.startsWith("group_list = ")){r.push(`${d} # 群组名单`),r.push("# 当group_list_type为whitelist时,只有群组名单中的群组可以聊天"),r.push("# 当group_list_type为blacklist时,群组名单中的任何群组无法聊天");continue}if(d.startsWith("private_list_type = ")){r.push(`${d} # 私聊名单类型,可选为:whitelist, blacklist`);continue}if(d.startsWith("private_list = ")){r.push(`${d} # 私聊名单`),r.push("# 当private_list_type为whitelist时,只有私聊名单中的用户可以聊天"),r.push("# 当private_list_type为blacklist时,私聊名单中的任何用户无法聊天");continue}if(d.startsWith("ban_user_id = ")){r.push(`${d} # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)`);continue}if(d.startsWith("ban_qq_bot = ")){r.push(`${d} # 是否屏蔽QQ官方机器人`);continue}if(d.startsWith("enable_poke = ")){r.push(`${d} # 是否启用戳一戳功能`);continue}if(d==="[voice]"){r.push("[voice] # 发送语音设置");continue}if(d.startsWith("use_tts = ")){r.push(`${d} # 是否使用tts语音(请确保你配置了tts并有对应的adapter)`);continue}if(d.startsWith("level = ")&&r[r.length-1]==="[debug]"){r.push(`${d} # 日志等级(DEBUG, INFO, WARNING, ERROR, CRITICAL)`);continue}r.push(d)}return r.join(`
|
||
`)}function Vm(a){if(!a.trim())return{valid:!1,error:"路径不能为空"};if(!a.toLowerCase().endsWith(".toml"))return{valid:!1,error:"文件必须是 .toml 格式"};const l=/^([a-zA-Z]:\\|\\\\[^\\]+\\[^\\]+\\).+\.toml$/i,r=/^(\/|~\/).+\.toml$/i,c=/^(\.{1,2}[\\/]|[^:\\/]).+\.toml$/i,d=l.test(a),m=r.test(a),h=c.test(a);return!d&&!m&&!h?{valid:!1,error:"路径格式错误"}:/[<>"|?*\x00-\x1F]/.test(a)?{valid:!1,error:"路径包含非法字符"}:{valid:!0,error:""}}function L4(){const[a,l]=u.useState("upload"),[r,c]=u.useState(null),[d,m]=u.useState(""),[h,f]=u.useState(""),[p,g]=u.useState("oneclick"),[N,j]=u.useState(""),[b,y]=u.useState(!1),[w,z]=u.useState(!1),[M,S]=u.useState(!1),[F,E]=u.useState(!1),[C,R]=u.useState(null),[H,O]=u.useState(!1),X=u.useRef(null),{toast:L}=nt(),me=u.useRef(null),Ne=A=>{if(f(A),A.trim()){const K=Vm(A);j(K.error)}else j("")},je=u.useCallback(async A=>{const K=Fm[A];z(!0);try{const Re=await ej(K.path),se=Hm(Re);c(se),g(A),f(K.path),await Wg(K.path),L({title:"加载成功",description:`已从${K.name}预设加载配置`})}catch(Re){console.error("加载预设配置失败:",Re),L({title:"加载失败",description:Re instanceof Error?Re.message:"无法读取预设配置文件",variant:"destructive"})}finally{z(!1)}},[L]),ce=u.useCallback(async A=>{const K=Vm(A);if(!K.valid){j(K.error),L({title:"路径无效",description:K.error,variant:"destructive"});return}j(""),z(!0);try{const Re=await ej(A),se=Hm(Re);c(se),f(A),await Wg(A),L({title:"加载成功",description:"已从配置文件加载"})}catch(Re){console.error("加载配置失败:",Re),L({title:"加载失败",description:Re instanceof Error?Re.message:"无法读取配置文件",variant:"destructive"})}finally{z(!1)}},[L]);u.useEffect(()=>{(async()=>{try{const K=await D4();if(K&&K.path){f(K.path);const Re=Object.entries(Fm).find(([,se])=>se.path===K.path);Re?(l("preset"),g(Re[0]),await je(Re[0])):(l("path"),await ce(K.path))}}catch(K){console.error("加载保存的路径失败:",K)}})()},[ce,je]);const ge=u.useCallback(A=>{a!=="path"&&a!=="preset"||!h||(me.current&&clearTimeout(me.current),me.current=setTimeout(async()=>{y(!0);try{const K=qm(A);await sj(h,K),L({title:"自动保存成功",description:"配置已保存到文件"})}catch(K){console.error("自动保存失败:",K),L({title:"自动保存失败",description:K instanceof Error?K.message:"保存配置失败",variant:"destructive"})}finally{y(!1)}},1e3))},[a,h,L]),pe=async()=>{if(!r||!h)return;const A=Vm(h);if(!A.valid){L({title:"保存失败",description:A.error,variant:"destructive"});return}y(!0);try{const K=qm(r);await sj(h,K),L({title:"保存成功",description:"配置已保存到文件"})}catch(K){console.error("保存失败:",K),L({title:"保存失败",description:K instanceof Error?K.message:"保存配置失败",variant:"destructive"})}finally{y(!1)}},D=async()=>{h&&await ce(h)},Q=A=>{if(A!==a){if(r){R(A),S(!0);return}B(A)}},B=A=>{c(null),m(""),j(""),l(A),A==="preset"&&je("oneclick"),L({title:"已切换模式",description:{upload:"现在可以上传配置文件",path:"现在可以指定配置文件路径",preset:"现在可以使用预设配置"}[A]})},ue=()=>{C&&(B(C),R(null)),S(!1)},Y=()=>{if(r){E(!0);return}we()},we=()=>{f(""),c(null),j(""),L({title:"已清空",description:"路径和配置已清空"})},fe=()=>{we(),E(!1)},Ee=A=>{const K=A.target.files?.[0];if(!K)return;const Re=new FileReader;Re.onload=se=>{try{const $e=se.target?.result,cs=Hm($e);c(cs),m(K.name),L({title:"上传成功",description:`已加载配置文件:${K.name}`})}catch($e){console.error("解析配置文件失败:",$e),L({title:"解析失败",description:"配置文件格式错误,请检查文件内容",variant:"destructive"})}},Re.readAsText(K)},G=()=>{if(!r)return;const A=qm(r),K=new Blob([A],{type:"text/plain;charset=utf-8"}),Re=URL.createObjectURL(K),se=document.createElement("a");se.href=Re,se.download=d||"config.toml",document.body.appendChild(se),se.click(),document.body.removeChild(se),URL.revokeObjectURL(Re),L({title:"下载成功",description:"配置文件已下载,请手动覆盖并重启适配器"})},$=()=>{c(JSON.parse(JSON.stringify(At))),m("config.toml"),L({title:"已加载默认配置",description:"可以开始编辑配置"})};return e.jsx(ts,{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(Rt,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:"适配器配置保存之后使用 WebUI 的重启功能适配器并不会重启,需要手动重启适配器。"})]}),e.jsx(xc,{open:H,onOpenChange:O,children:e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ue,{children:"工作模式"}),e.jsx(Ns,{children:"选择配置文件的管理方式"})]}),e.jsx(hc,{asChild:!0,children:e.jsxs(_,{variant:"ghost",size:"sm",className:"w-9 p-0",children:[e.jsx(Ba,{className:`h-4 w-4 transition-transform duration-200 ${H?"transform rotate-180":""}`}),e.jsx("span",{className:"sr-only",children:"切换"})]})})]})}),e.jsx(fc,{children:e.jsxs(ze,{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 ${a==="preset"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>Q("preset"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(xa,{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 ${a==="upload"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>Q("upload"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(cc,{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 ${a==="path"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>Q("path"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(I1,{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:"指定配置文件路径,自动加载和保存"})]})]})})]}),a==="preset"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsx(T,{className:"text-sm md:text-base",children:"选择部署方式"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(Fm).map(([A,K])=>{const Re=K.icon,se=p===A;return e.jsx("div",{className:`border-2 rounded-lg p-3 cursor-pointer transition-all ${se?"border-primary bg-primary/5":"border-muted hover:border-primary/50"}`,onClick:()=>{g(A),je(A)},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Re,{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:K.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:K.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:K.path})]})]})},A)})})]}),a==="path"&&e.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{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(ne,{id:"config-path",value:h,onChange:A=>Ne(A.target.value),placeholder:"例: C:\\Adapter\\config.toml",className:`text-sm ${N?"border-destructive":""}`}),N&&e.jsx("p",{className:"text-xs text-destructive",children:N})]}),e.jsx(_,{onClick:()=>ce(h),disabled:w||!h||!!N,className:"w-full sm:w-auto",children:w?e.jsxs(e.Fragment,{children:[e.jsx(dt,{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(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(ft,{children:a==="preset"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"预设模式:"}),"选择预设的部署方式,配置会自动加载,修改后 1 秒自动保存",b&&" (正在保存...)"]}):a==="upload"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"上传文件模式:"}),"上传配置文件 → 在线编辑 → 下载文件 → 手动覆盖并重启适配器"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"指定路径模式:"}),"指定配置文件路径后,配置会自动加载,修改后 1 秒自动保存",b&&" (正在保存...)"]})})]}),a==="upload"&&!r&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsx("input",{ref:X,type:"file",accept:".toml",className:"hidden",onChange:Ee}),e.jsxs(_,{onClick:()=>X.current?.click(),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(cc,{className:"mr-2 h-4 w-4"}),"上传配置"]}),e.jsxs(_,{onClick:$,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(Ua,{className:"mr-2 h-4 w-4"}),"使用默认配置"]})]}),a==="upload"&&r&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(_,{onClick:G,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(na,{className:"mr-2 h-4 w-4"}),"下载配置"]})}),(a==="preset"||a==="path")&&r&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(_,{onClick:pe,size:"sm",disabled:b||!!N,className:"w-full sm:w-auto",children:[e.jsx(gc,{className:"mr-2 h-4 w-4"}),b?"保存中...":"立即保存"]}),e.jsxs(_,{onClick:D,size:"sm",variant:"outline",disabled:w,className:"w-full sm:w-auto",children:[e.jsx(dt,{className:`mr-2 h-4 w-4 ${w?"animate-spin":""}`}),"刷新"]}),a==="path"&&e.jsxs(_,{onClick:Y,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"清空路径"]})]}),r?e.jsxs(Jt,{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(Gt,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5",children:[e.jsxs(Xe,{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(Xe,{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(Xe,{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(Xe,{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(Xe,{value:"debug",className:"flex-shrink-0 text-xs sm:text-sm whitespace-nowrap",children:"调试"})]})}),e.jsx(Ss,{value:"napcat",className:"space-y-4",children:e.jsx(U4,{config:r,onChange:A=>{c(A),ge(A)}})}),e.jsx(Ss,{value:"maibot",className:"space-y-4",children:e.jsx($4,{config:r,onChange:A=>{c(A),ge(A)}})}),e.jsx(Ss,{value:"chat",className:"space-y-4",children:e.jsx(B4,{config:r,onChange:A=>{c(A),ge(A)}})}),e.jsx(Ss,{value:"voice",className:"space-y-4",children:e.jsx(I4,{config:r,onChange:A=>{c(A),ge(A)}})}),e.jsx(Ss,{value:"debug",className:"space-y-4",children:e.jsx(P4,{config:r,onChange:A=>{c(A),ge(A)}})})]}):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(Ua,{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:a==="preset"?"请选择预设的部署方式":a==="upload"?"请上传现有配置文件,或使用默认配置开始编辑":"请指定配置文件路径并点击加载按钮"})]})]})}),e.jsx(bs,{open:M,onOpenChange:S,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认切换模式"}),e.jsxs(gs,{children:["切换模式将清空当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-destructive font-medium",children:"请确保已保存重要配置"})]})]}),e.jsxs(fs,{children:[e.jsx(vs,{onClick:()=>{S(!1),R(null)},children:"取消"}),e.jsx(js,{onClick:ue,children:"确认切换"})]})]})}),e.jsx(bs,{open:F,onOpenChange:E,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认清空路径"}),e.jsxs(gs,{children:["清空路径将清除当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"此操作不会删除配置文件,只是清除界面中的配置"})]})]}),e.jsxs(fs,{children:[e.jsx(vs,{onClick:()=>E(!1),children:"取消"}),e.jsx(js,{onClick:fe,className:"bg-destructive hover:bg-destructive/90",children:"确认清空"})]})]})})]})})}function U4({config:a,onChange:l}){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(T,{htmlFor:"napcat-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ne,{id:"napcat-host",value:a.napcat_server.host,onChange:r=>l({...a,napcat_server:{...a.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(T,{htmlFor:"napcat-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ne,{id:"napcat-port",type:"number",value:a.napcat_server.port||"",onChange:r=>l({...a,napcat_server:{...a.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(T,{htmlFor:"napcat-token",className:"text-sm md:text-base",children:"访问令牌(Token)"}),e.jsx(ne,{id:"napcat-token",type:"password",value:a.napcat_server.token,onChange:r=>l({...a,napcat_server:{...a.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(T,{htmlFor:"napcat-heartbeat",className:"text-sm md:text-base",children:"心跳间隔(秒)"}),e.jsx(ne,{id:"napcat-heartbeat",type:"number",value:a.napcat_server.heartbeat_interval||"",onChange:r=>l({...a,napcat_server:{...a.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 $4({config:a,onChange:l}){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(T,{htmlFor:"maibot-host",className:"text-sm md:text-base",children:"主机地址"}),e.jsx(ne,{id:"maibot-host",value:a.maibot_server.host,onChange:r=>l({...a,maibot_server:{...a.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(T,{htmlFor:"maibot-port",className:"text-sm md:text-base",children:"端口"}),e.jsx(ne,{id:"maibot-port",type:"number",value:a.maibot_server.port||"",onChange:r=>l({...a,maibot_server:{...a.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 B4({config:a,onChange:l}){const r=m=>{const h={...a};m==="group"?h.chat.group_list=[...h.chat.group_list,0]:m==="private"?h.chat.private_list=[...h.chat.private_list,0]:h.chat.ban_user_id=[...h.chat.ban_user_id,0],l(h)},c=(m,h)=>{const f={...a};m==="group"?f.chat.group_list=f.chat.group_list.filter((p,g)=>g!==h):m==="private"?f.chat.private_list=f.chat.private_list.filter((p,g)=>g!==h):f.chat.ban_user_id=f.chat.ban_user_id.filter((p,g)=>g!==h),l(f)},d=(m,h,f)=>{const p={...a};m==="group"?p.chat.group_list[h]=f:m==="private"?p.chat.private_list[h]=f:p.chat.ban_user_id[h]=f,l(p)};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(T,{className:"text-sm md:text-base",children:"群组名单类型"}),e.jsxs(Pe,{value:a.chat.group_list_type,onValueChange:m=>l({...a,chat:{...a.chat,group_list_type:m}}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(W,{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(T,{className:"text-sm md:text-base",children:"群组列表"}),e.jsxs(_,{onClick:()=>r("group"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ua,{className:"mr-1 h-4 w-4"}),"添加群号"]})]}),a.chat.group_list.map((m,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{type:"number",value:m,onChange:f=>d("group",h,parseInt(f.target.value)||0),placeholder:"输入群号",className:"text-sm md:text-base"}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除群号 ",m," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>c("group",h),children:"删除"})]})]})]})]},h)),a.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(T,{className:"text-sm md:text-base",children:"私聊名单类型"}),e.jsxs(Pe,{value:a.chat.private_list_type,onValueChange:m=>l({...a,chat:{...a.chat,private_list_type:m}}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(W,{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(T,{className:"text-sm md:text-base",children:"私聊列表"}),e.jsxs(_,{onClick:()=>r("private"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ua,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),a.chat.private_list.map((m,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{type:"number",value:m,onChange:f=>d("private",h,parseInt(f.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要删除用户 ",m," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>c("private",h),children:"删除"})]})]})]})]},h)),a.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(T,{className:"text-sm md:text-base",children:"全局禁止名单"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"名单中的用户无法进行任何聊天"})]}),e.jsxs(_,{onClick:()=>r("ban"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ua,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),a.chat.ban_user_id.map((m,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ne,{type:"number",value:m,onChange:f=>d("ban",h,parseInt(f.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(bs,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(os,{className:"h-4 w-4"})})}),e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:["确定要从全局禁止名单中删除用户 ",m," 吗?此操作无法撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>c("ban",h),children:"删除"})]})]})]})]},h)),a.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(T,{className:"text-sm md:text-base",children:"屏蔽QQ官方机器人"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否屏蔽来自QQ官方机器人的消息"})]}),e.jsx(Ge,{checked:a.chat.ban_qq_bot,onCheckedChange:m=>l({...a,chat:{...a.chat,ban_qq_bot:m}})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(T,{className:"text-sm md:text-base",children:"启用戳一戳功能"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"是否响应戳一戳消息"})]}),e.jsx(Ge,{checked:a.chat.enable_poke,onCheckedChange:m=>l({...a,chat:{...a.chat,enable_poke:m}})})]})]})]})})}function I4({config:a,onChange:l}){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(T,{className:"text-sm md:text-base",children:"使用 TTS 语音"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"请确保已配置 TTS 并有对应的适配器"})]}),e.jsx(Ge,{checked:a.voice.use_tts,onCheckedChange:r=>l({...a,voice:{use_tts:r}})})]})]})})}function P4({config:a,onChange:l}){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(T,{className:"text-sm md:text-base",children:"日志等级"}),e.jsxs(Pe,{value:a.debug.level,onValueChange:r=>l({...a,debug:{level:r}}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"DEBUG",children:"DEBUG(调试)"}),e.jsx(W,{value:"INFO",children:"INFO(信息)"}),e.jsx(W,{value:"WARNING",children:"WARNING(警告)"}),e.jsx(W,{value:"ERROR",children:"ERROR(错误)"}),e.jsx(W,{value:"CRITICAL",children:"CRITICAL(严重)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置适配器的日志输出等级"})]})})]})})}const F4=["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"],H4=/^(aria-|data-)/,oN=a=>Object.fromEntries(Object.entries(a).filter(([l])=>H4.test(l)||F4.includes(l)));function q4(a,l){const r=oN(a);return Object.keys(a).some(c=>!Object.hasOwn(r,c)&&a[c]!==l[c])}class V4 extends u.Component{container;plugin;componentDidMount(){this.installPlugin()}componentDidUpdate(l){if(l.uppy!==this.props.uppy)this.uninstallPlugin(l),this.installPlugin();else if(q4(this.props,l)){const{uppy:r,...c}={...this.props,target:this.container};this.plugin.setOptions(c)}}componentWillUnmount(){this.uninstallPlugin()}installPlugin(){const{uppy:l,...r}={id:"Dashboard",...this.props,inline:!0,target:this.container};l.use(v_,r),this.plugin=l.getPlugin(r.id)}uninstallPlugin(l=this.props){const{uppy:r}=l;r.removePlugin(this.plugin)}render(){return u.createElement("div",{className:"uppy-Container",ref:l=>{this.container=l},...oN(this.props)})}}function G4({src:a,alt:l="表情包",className:r,maxRetries:c=5,retryInterval:d=1500}){const[m,h]=u.useState("loading"),[f,p]=u.useState(0),[g,N]=u.useState(null),[j,b]=u.useState(a);a!==j&&(h("loading"),p(0),N(null),b(a));const y=u.useCallback(async()=>{try{const w=await fetch(a,{credentials:"include"});if(w.status===202){h("generating"),f<c?setTimeout(()=>{p(S=>S+1)},d):h("error");return}if(!w.ok){h("error");return}const z=await w.blob(),M=URL.createObjectURL(z);N(M),h("loaded")}catch(w){console.error("加载缩略图失败:",w),h("error")}},[a,f,c,d]);return u.useEffect(()=>{y()},[y]),u.useEffect(()=>()=>{g&&URL.revokeObjectURL(g)},[g]),m==="loading"||m==="generating"?e.jsx(ks,{className:P("w-full h-full",r)}):m==="error"||!g?e.jsx("div",{className:P("w-full h-full flex items-center justify-center bg-muted",r),children:e.jsx(xx,{className:"h-8 w-8 text-muted-foreground"})}):e.jsx("img",{src:g,alt:l,className:P("w-full h-full object-contain",r)})}function K4({children:a,className:l}){return e.jsx(bx,{content:a,className:l})}const al="/api/webui/emoji";async function Q4(a){const l=new URLSearchParams;a.page&&l.append("page",a.page.toString()),a.page_size&&l.append("page_size",a.page_size.toString()),a.search&&l.append("search",a.search),a.is_registered!==void 0&&l.append("is_registered",a.is_registered.toString()),a.is_banned!==void 0&&l.append("is_banned",a.is_banned.toString()),a.format&&l.append("format",a.format),a.sort_by&&l.append("sort_by",a.sort_by),a.sort_order&&l.append("sort_order",a.sort_order);const r=await ke(`${al}/list?${l}`,{});if(!r.ok)throw new Error(`获取表情包列表失败: ${r.statusText}`);return r.json()}async function Y4(a){const l=await ke(`${al}/${a}`,{});if(!l.ok)throw new Error(`获取表情包详情失败: ${l.statusText}`);return l.json()}async function J4(a,l){const r=await ke(`${al}/${a}`,{method:"PATCH",body:JSON.stringify(l)});if(!r.ok)throw new Error(`更新表情包失败: ${r.statusText}`);return r.json()}async function X4(a){const l=await ke(`${al}/${a}`,{method:"DELETE"});if(!l.ok)throw new Error(`删除表情包失败: ${l.statusText}`);return l.json()}async function Z4(){const a=await ke(`${al}/stats/summary`,{});if(!a.ok)throw new Error(`获取统计数据失败: ${a.statusText}`);return a.json()}async function W4(a){const l=await ke(`${al}/${a}/register`,{method:"POST"});if(!l.ok)throw new Error(`注册表情包失败: ${l.statusText}`);return l.json()}async function ek(a){const l=await ke(`${al}/${a}/ban`,{method:"POST"});if(!l.ok)throw new Error(`封禁表情包失败: ${l.statusText}`);return l.json()}function sk(a,l=!1){return l?`${al}/${a}/thumbnail?original=true`:`${al}/${a}/thumbnail`}function tk(a){return`${al}/${a}/thumbnail?original=true`}async function ak(a){const l=await ke(`${al}/batch/delete`,{method:"POST",body:JSON.stringify({emoji_ids:a})});if(!l.ok){const r=await l.json();throw new Error(r.detail||"批量删除失败")}return l.json()}function lk(){return`${al}/upload`}function nk(){const[a,l]=u.useState([]),[r,c]=u.useState(null),[d,m]=u.useState(!1),[h,f]=u.useState(1),[p,g]=u.useState(0),[N,j]=u.useState(20),[b,y]=u.useState("all"),[w,z]=u.useState("all"),[M,S]=u.useState("all"),[F,E]=u.useState("usage_count"),[C,R]=u.useState("desc"),[H,O]=u.useState(null),[X,L]=u.useState(!1),[me,Ne]=u.useState(!1),[je,ce]=u.useState(!1),[ge,pe]=u.useState(new Set),[D,Q]=u.useState(!1),[B,ue]=u.useState(""),[Y,we]=u.useState("medium"),[fe,Ee]=u.useState(!1),{toast:G}=nt(),$=u.useCallback(async()=>{try{m(!0);const xe=await Q4({page:h,page_size:N,is_registered:b==="all"?void 0:b==="registered",is_banned:w==="all"?void 0:w==="banned",format:M==="all"?void 0:M,sort_by:F,sort_order:C});l(xe.data),g(xe.total)}catch(xe){const Me=xe instanceof Error?xe.message:"加载表情包列表失败";G({title:"错误",description:Me,variant:"destructive"})}finally{m(!1)}},[h,N,b,w,M,F,C,G]),A=async()=>{try{const xe=await Z4();c(xe.data)}catch(xe){console.error("加载统计数据失败:",xe)}};u.useEffect(()=>{$()},[$]),u.useEffect(()=>{A()},[]);const K=async xe=>{try{const Me=await Y4(xe.id);O(Me.data),L(!0)}catch(Me){const ds=Me instanceof Error?Me.message:"加载详情失败";G({title:"错误",description:ds,variant:"destructive"})}},Re=xe=>{O(xe),Ne(!0)},se=xe=>{O(xe),ce(!0)},$e=async()=>{if(H)try{await X4(H.id),G({title:"成功",description:"表情包已删除"}),ce(!1),O(null),$(),A()}catch(xe){const Me=xe instanceof Error?xe.message:"删除失败";G({title:"错误",description:Me,variant:"destructive"})}},cs=async xe=>{try{await W4(xe.id),G({title:"成功",description:"表情包已注册"}),$(),A()}catch(Me){const ds=Me instanceof Error?Me.message:"注册失败";G({title:"错误",description:ds,variant:"destructive"})}},J=async xe=>{try{await ek(xe.id),G({title:"成功",description:"表情包已封禁"}),$(),A()}catch(Me){const ds=Me instanceof Error?Me.message:"封禁失败";G({title:"错误",description:ds,variant:"destructive"})}},Z=xe=>{const Me=new Set(ge);Me.has(xe)?Me.delete(xe):Me.add(xe),pe(Me)},Le=async()=>{try{const xe=await ak(Array.from(ge));G({title:"批量删除完成",description:xe.message}),pe(new Set),Q(!1),$(),A()}catch(xe){G({title:"批量删除失败",description:xe instanceof Error?xe.message:"批量删除失败",variant:"destructive"})}},le=()=>{const xe=parseInt(B),Me=Math.ceil(p/N);xe>=1&&xe<=Me?(f(xe),ue("")):G({title:"无效的页码",description:`请输入1-${Me}之间的页码`,variant:"destructive"})},De=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(_,{onClick:()=>Ee(!0),className:"gap-2",children:[e.jsx(cc,{className:"h-4 w-4"}),"上传表情包"]})]}),e.jsx(ts,{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(Te,{children:e.jsxs(Oe,{className:"pb-2",children:[e.jsx(Ns,{children:"总数"}),e.jsx(Ue,{className:"text-2xl",children:r.total})]})}),e.jsx(Te,{children:e.jsxs(Oe,{className:"pb-2",children:[e.jsx(Ns,{children:"已注册"}),e.jsx(Ue,{className:"text-2xl text-green-600",children:r.registered})]})}),e.jsx(Te,{children:e.jsxs(Oe,{className:"pb-2",children:[e.jsx(Ns,{children:"已封禁"}),e.jsx(Ue,{className:"text-2xl text-red-600",children:r.banned})]})}),e.jsx(Te,{children:e.jsxs(Oe,{className:"pb-2",children:[e.jsx(Ns,{children:"未注册"}),e.jsx(Ue,{className:"text-2xl text-gray-600",children:r.unregistered})]})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx(Po,{className:"h-5 w-5"}),"筛选和排序"]})}),e.jsxs(ze,{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(T,{children:"排序方式"}),e.jsxs(Pe,{value:`${F}-${C}`,onValueChange:xe=>{const[Me,ds]=xe.split("-");E(Me),R(ds),f(1)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"usage_count-desc",children:"使用次数 (多→少)"}),e.jsx(W,{value:"usage_count-asc",children:"使用次数 (少→多)"}),e.jsx(W,{value:"register_time-desc",children:"注册时间 (新→旧)"}),e.jsx(W,{value:"register_time-asc",children:"注册时间 (旧→新)"}),e.jsx(W,{value:"record_time-desc",children:"记录时间 (新→旧)"}),e.jsx(W,{value:"record_time-asc",children:"记录时间 (旧→新)"}),e.jsx(W,{value:"last_used_time-desc",children:"最后使用 (新→旧)"}),e.jsx(W,{value:"last_used_time-asc",children:"最后使用 (旧→新)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"注册状态"}),e.jsxs(Pe,{value:b,onValueChange:xe=>{y(xe),f(1)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部"}),e.jsx(W,{value:"registered",children:"已注册"}),e.jsx(W,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"封禁状态"}),e.jsxs(Pe,{value:w,onValueChange:xe=>{z(xe),f(1)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部"}),e.jsx(W,{value:"banned",children:"已封禁"}),e.jsx(W,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"格式"}),e.jsxs(Pe,{value:M,onValueChange:xe=>{S(xe),f(1)},children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部"}),De.map(xe=>e.jsxs(W,{value:xe,children:[xe.toUpperCase()," (",r?.formats[xe],")"]},xe))]})]})]})]}),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:[ge.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",ge.size," 个表情包"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"text-sm whitespace-nowrap",children:"卡片大小"}),e.jsxs(Pe,{value:Y,onValueChange:xe=>we(xe),children:[e.jsx(Be,{className:"w-24",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"small",children:"小"}),e.jsx(W,{value:"medium",children:"中"}),e.jsx(W,{value:"large",children:"大"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{htmlFor:"emoji-page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Pe,{value:N.toString(),onValueChange:xe=>{j(parseInt(xe)),f(1),pe(new Set)},children:[e.jsx(Be,{id:"emoji-page-size",className:"w-20",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"20",children:"20"}),e.jsx(W,{value:"40",children:"40"}),e.jsx(W,{value:"60",children:"60"}),e.jsx(W,{value:"100",children:"100"})]})]}),ge.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>pe(new Set),children:"取消选择"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:()=>Q(!0),children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(_,{variant:"outline",size:"sm",onClick:$,disabled:d,children:[e.jsx(dt,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"表情包列表"}),e.jsxs(Ns,{children:["共 ",p," 个表情包,当前第 ",h," 页"]})]}),e.jsxs(ze,{children:[a.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"暂无数据"}):e.jsx("div",{className:`grid gap-3 ${Y==="small"?"grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10":Y==="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:a.map(xe=>e.jsxs("div",{className:`group relative rounded-lg border bg-card overflow-hidden hover:ring-2 hover:ring-primary transition-all cursor-pointer ${ge.has(xe.id)?"ring-2 ring-primary bg-primary/5":""}`,onClick:()=>Z(xe.id),children:[e.jsx("div",{className:`absolute top-1 left-1 z-10 transition-opacity ${ge.has(xe.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 ${ge.has(xe.id)?"bg-primary border-primary text-primary-foreground":"bg-background/80 border-muted-foreground/50"}`,children:ge.has(xe.id)&&e.jsx(st,{className:"h-3 w-3"})})}),e.jsxs("div",{className:"absolute top-1 right-1 z-10 flex flex-col gap-0.5",children:[xe.is_registered&&e.jsx(Ce,{variant:"default",className:"bg-green-600 text-[10px] px-1 py-0",children:"已注册"}),xe.is_banned&&e.jsx(Ce,{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 ${Y==="small"?"p-1":Y==="medium"?"p-2":"p-3"}`,children:e.jsx(G4,{src:sk(xe.id),alt:"表情包"})}),e.jsxs("div",{className:`border-t bg-card ${Y==="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(Ce,{variant:"outline",className:"text-[10px] px-1 py-0",children:xe.format.toUpperCase()}),e.jsxs("span",{className:"font-mono",children:[xe.usage_count,"次"]})]}),e.jsxs("div",{className:`flex gap-1 justify-center opacity-0 group-hover:opacity-100 transition-opacity ${Y==="small"?"flex-wrap":""}`,children:[e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Me=>{Me.stopPropagation(),Re(xe)},title:"编辑",children:e.jsx(sr,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:Me=>{Me.stopPropagation(),K(xe)},title:"详情",children:e.jsx(Yt,{className:"h-3 w-3"})}),!xe.is_registered&&e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6 text-green-600 hover:text-green-700",onClick:Me=>{Me.stopPropagation(),cs(xe)},title:"注册",children:e.jsx(st,{className:"h-3 w-3"})}),!xe.is_banned&&e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6 text-orange-600 hover:text-orange-700",onClick:Me=>{Me.stopPropagation(),J(xe)},title:"封禁",children:e.jsx(iv,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6 text-red-600 hover:text-red-700",onClick:Me=>{Me.stopPropagation(),se(xe)},title:"删除",children:e.jsx(os,{className:"h-3 w-3"})})]})]})]},xe.id))}),p>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:["显示 ",(h-1)*N+1," 到"," ",Math.min(h*N,p)," 条,共 ",p," 条"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(xe=>Math.max(1,xe-1)),disabled:h===1,children:[e.jsx(Pa,{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(ne,{type:"number",value:B,onChange:xe=>ue(xe.target.value),onKeyDown:xe=>xe.key==="Enter"&&le(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(p/N)}),e.jsx(_,{variant:"outline",size:"sm",onClick:le,disabled:!B,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(xe=>xe+1),disabled:h>=Math.ceil(p/N),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(ra,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(p/N)),disabled:h>=Math.ceil(p/N),className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(rk,{emoji:H,open:X,onOpenChange:L}),e.jsx(ik,{emoji:H,open:me,onOpenChange:Ne,onSuccess:()=>{$(),A()}}),e.jsx(ck,{open:fe,onOpenChange:Ee,onSuccess:()=>{$(),A()}})]})}),e.jsx(bs,{open:D,onOpenChange:Q,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认批量删除"}),e.jsxs(gs,{children:["你确定要删除选中的 ",ge.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:Le,children:"确认删除"})]})]})}),e.jsx(Qs,{open:je,onOpenChange:ce,children:e.jsxs(Hs,{children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"确认删除"}),e.jsx(at,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>ce(!1),children:"取消"}),e.jsx(_,{variant:"destructive",onClick:$e,children:"删除"})]})]})})]})}function rk({emoji:a,open:l,onOpenChange:r}){if(!a)return null;const c=d=>d?new Date(d*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(qs,{children:e.jsx(Vs,{children:"表情包详情"})}),e.jsx(ts,{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:tk(a.id),alt:a.description||"表情包",className:"w-full h-full object-cover",onError:d=>{const m=d.target;m.style.display="none";const h=m.parentElement;h&&(h.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(T,{className:"text-muted-foreground",children:"ID"}),e.jsx("div",{className:"mt-1 font-mono",children:a.id})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(Ce,{variant:"outline",children:a.format.toUpperCase()})})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"文件路径"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:a.full_path})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"哈希值"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:a.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"描述"}),a.description?e.jsx("div",{className:"mt-1 rounded-lg border bg-muted/50 p-3",children:e.jsx(K4,{className:"prose-sm",children:a.description})}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"-"})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"情绪"}),e.jsx("div",{className:"mt-1",children:a.emotion?e.jsx("span",{className:"text-sm",children:a.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(T,{className:"text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[a.is_registered&&e.jsx(Ce,{variant:"default",className:"bg-green-600",children:"已注册"}),a.is_banned&&e.jsx(Ce,{variant:"destructive",children:"已封禁"}),!a.is_registered&&!a.is_banned&&e.jsx(Ce,{variant:"outline",children:"未注册"})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"使用次数"}),e.jsx("div",{className:"mt-1 font-mono text-lg",children:a.usage_count})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"记录时间"}),e.jsx("div",{className:"mt-1 text-sm",children:c(a.record_time)})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:c(a.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:c(a.last_used_time)})]})]})})]})})}function ik({emoji:a,open:l,onOpenChange:r,onSuccess:c}){const[d,m]=u.useState(""),[h,f]=u.useState(!1),[p,g]=u.useState(!1),[N,j]=u.useState(!1),{toast:b}=nt();u.useEffect(()=>{a&&(m(a.emotion||""),f(a.is_registered),g(a.is_banned))},[a]);const y=async()=>{if(a)try{j(!0);const w=d.split(/[,,]/).map(z=>z.trim()).filter(Boolean).join(",");await J4(a.id,{emotion:w||void 0,is_registered:h,is_banned:p}),b({title:"成功",description:"表情包信息已更新"}),r(!1),c()}catch(w){const z=w instanceof Error?w.message:"保存失败";b({title:"错误",description:z,variant:"destructive"})}finally{j(!1)}};return a?e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"编辑表情包"}),e.jsx(at,{children:"修改表情包的情绪和状态信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"情绪"}),e.jsx(pt,{value:d,onChange:w=>m(w.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(tt,{id:"is_registered",checked:h,onCheckedChange:w=>{w===!0?(f(!0),g(!1)):f(!1)}}),e.jsx(T,{htmlFor:"is_registered",className:"cursor-pointer",children:"已注册"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"is_banned",checked:p,onCheckedChange:w=>{w===!0?(g(!0),f(!1)):g(!1)}}),e.jsx(T,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(_,{onClick:y,disabled:N,children:N?"保存中...":"保存"})]})]})}):null}function ck({open:a,onOpenChange:l,onSuccess:r}){const[c,d]=u.useState("select"),[m,h]=u.useState([]),[f,p]=u.useState(null),[g,N]=u.useState(!1),{toast:j}=nt(),b=u.useMemo(()=>new N_({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 H=()=>{const O=b.getFiles();if(O.length===0)return;const X=O.map(L=>({id:L.id,name:L.name,previewUrl:L.preview||URL.createObjectURL(L.data),emotion:"",description:"",isRegistered:!0,file:L.data}));h(X),O.length===1?(p(X[0].id),d("edit-single")):d("edit-multiple")};return b.on("upload",H),()=>{b.off("upload",H)}},[b]),u.useEffect(()=>{a||(b.cancelAll(),d("select"),h([]),p(null),N(!1))},[a,b]);const y=u.useCallback((H,O)=>{h(X=>X.map(L=>L.id===H?{...L,...O}:L))},[]),w=u.useCallback(H=>H.emotion.trim().length>0,[]),z=u.useMemo(()=>m.length>0&&m.every(w),[m,w]),M=u.useMemo(()=>m.find(H=>H.id===f)||null,[m,f]),S=u.useCallback(()=>{(c==="edit-single"||c==="edit-multiple")&&(d("select"),h([]),p(null))},[c]),F=u.useCallback(async()=>{if(!z){j({title:"请填写必填项",description:"每个表情包的情感标签都是必填的",variant:"destructive"});return}N(!0);let H=0,O=0;try{for(const X of m){const L=new FormData;L.append("file",X.file),L.append("emotion",X.emotion),L.append("description",X.description),L.append("is_registered",X.isRegistered.toString());try{(await ke(lk(),{method:"POST",body:L})).ok?H++:O++}catch{O++}}O===0?(j({title:"上传成功",description:`成功上传 ${H} 个表情包`}),l(!1),r()):(j({title:"部分上传失败",description:`成功 ${H} 个,失败 ${O} 个`,variant:"destructive"}),r())}finally{N(!1)}},[z,m,j,l,r]),E=()=>e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"border rounded-lg overflow-hidden w-full",children:e.jsx(V4,{uppy:b,proudlyDisplayPoweredByUppy:!1,hideProgressDetails:!0,height:350,width:"100%",theme:"auto",note:"支持 JPG、PNG、GIF、WebP 格式,最多 20 个文件"})})}),C=()=>{const H=m[0];return H?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(_,{variant:"ghost",size:"sm",onClick:S,children:[e.jsx($a,{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:H.previewUrl,alt:H.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:H.name})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"single-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ne,{id:"single-emotion",value:H.emotion,onChange:O=>y(H.id,{emotion:O.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:H.emotion.trim()?"":"border-destructive"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于情感匹配,多个标签用逗号分隔"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"single-description",children:"描述"}),e.jsx(ne,{id:"single-description",value:H.description,onChange:O=>y(H.id,{description:O.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"single-is-registered",checked:H.isRegistered,onCheckedChange:O=>y(H.id,{isRegistered:O===!0})}),e.jsx(T,{htmlFor:"single-is-registered",className:"cursor-pointer",children:"上传后立即注册(可被麦麦使用)"})]})]})]}),e.jsx(gt,{children:e.jsx(_,{onClick:F,disabled:!z||g,children:g?"上传中...":"上传"})})]}):null},R=()=>{const H=m.filter(w).length,O=m.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(_,{variant:"ghost",size:"sm",onClick:S,children:[e.jsx($a,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["编辑表情包信息(",H,"/",O," 已完成)"]})]}),e.jsx(Ce,{variant:z?"default":"secondary",children:z?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"h-3 w-3 mr-1"}),"全部完成"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sa,{className:"h-3 w-3 mr-1"}),"未完成"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ts,{className:"h-[350px] pr-2",children:e.jsx("div",{className:"space-y-2",children:m.map(X=>{const L=w(X),me=f===X.id;return e.jsxs("div",{onClick:()=>p(X.id),className:`
|
||
flex items-center gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all
|
||
${me?"ring-2 ring-primary":""}
|
||
${L?"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:X.previewUrl,alt:X.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:X.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:X.emotion||"未填写情感标签"})]}),L?e.jsx(st,{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"})]},X.id)})})}),e.jsx("div",{className:"border rounded-lg p-4",children:M?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: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:"font-medium truncate",children:M.name}),w(M)&&e.jsxs(Ce,{variant:"outline",className:"text-green-600 border-green-600",children:[e.jsx(Lt,{className:"h-3 w-3 mr-1"}),"已完成"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"multi-emotion",children:["情感标签 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ne,{id:"multi-emotion",value:M.emotion,onChange:X=>y(M.id,{emotion:X.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:M.emotion.trim()?"":"border-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"multi-description",children:"描述"}),e.jsx(ne,{id:"multi-description",value:M.description,onChange:X=>y(M.id,{description:X.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"multi-is-registered",checked:M.isRegistered,onCheckedChange:X=>y(M.id,{isRegistered:X===!0})}),e.jsx(T,{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(xx,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"点击左侧卡片编辑"})]})})})]}),e.jsx(gt,{children:e.jsx(_,{onClick:F,disabled:!z||g,children:g?"上传中...":`上传全部 (${O})`})})]})};return e.jsx(Qs,{open:a,onOpenChange:l,children:e.jsxs(Hs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(cc,{className:"h-5 w-5"}),c==="select"&&"上传表情包 - 选择文件",c==="edit-single"&&"上传表情包 - 填写信息",c==="edit-multiple"&&"上传表情包 - 批量编辑"]}),e.jsxs(at,{children:[c==="select"&&"支持 JPG、PNG、GIF、WebP 格式,单个文件最大 10MB,可同时上传多个文件",c==="edit-single"&&"请填写表情包的情感标签(必填)和描述",c==="edit-multiple"&&"点击左侧卡片编辑每个表情包的信息,情感标签为必填项"]})]}),e.jsxs("div",{className:"overflow-y-auto pr-1",children:[c==="select"&&E(),c==="edit-single"&&C(),c==="edit-multiple"&&R()]})]})})}function ok(){const[a,l]=u.useState([]),[r,c]=u.useState(!0),[d,m]=u.useState(0),[h,f]=u.useState(1),[p,g]=u.useState(20),[N,j]=u.useState(""),[b,y]=u.useState(null),[w,z]=u.useState(!1),[M,S]=u.useState(!1),[F,E]=u.useState(!1),[C,R]=u.useState(null),[H,O]=u.useState(new Set),[X,L]=u.useState(!1),[me,Ne]=u.useState(""),[je,ce]=u.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),[ge,pe]=u.useState([]),[D,Q]=u.useState(new Map),[B,ue]=u.useState(!1),[Y,we]=u.useState(0),{toast:fe}=nt(),Ee=async()=>{try{c(!0);const le=await a2({page:h,page_size:p,search:N||void 0});l(le.data),m(le.total)}catch(le){fe({title:"加载失败",description:le instanceof Error?le.message:"无法加载表达方式",variant:"destructive"})}finally{c(!1)}},G=async()=>{try{const le=await o2();le?.data&&ce(le.data)}catch(le){console.error("加载统计数据失败:",le)}},$=async()=>{try{const le=await jx();we(le.unchecked)}catch(le){console.error("加载审核统计失败:",le)}},A=async()=>{try{const le=await gx();if(le?.data){pe(le.data);const De=new Map;le.data.forEach(xe=>{De.set(xe.chat_id,xe.chat_name)}),Q(De)}}catch(le){console.error("加载聊天列表失败:",le)}},K=le=>D.get(le)||le;u.useEffect(()=>{Ee(),$(),G(),A()},[h,p,N]);const Re=async le=>{try{const De=await l2(le.id);y(De.data),z(!0)}catch(De){fe({title:"加载详情失败",description:De instanceof Error?De.message:"无法加载表达方式详情",variant:"destructive"})}},se=le=>{y(le),S(!0)},$e=async le=>{try{await i2(le.id),fe({title:"删除成功",description:`已删除表达方式: ${le.situation}`}),R(null),Ee(),G()}catch(De){fe({title:"删除失败",description:De instanceof Error?De.message:"无法删除表达方式",variant:"destructive"})}},cs=le=>{const De=new Set(H);De.has(le)?De.delete(le):De.add(le),O(De)},J=()=>{H.size===a.length&&a.length>0?O(new Set):O(new Set(a.map(le=>le.id)))},Z=async()=>{try{await c2(Array.from(H)),fe({title:"批量删除成功",description:`已删除 ${H.size} 个表达方式`}),O(new Set),L(!1),Ee(),G()}catch(le){fe({title:"批量删除失败",description:le instanceof Error?le.message:"无法批量删除表达方式",variant:"destructive"})}},Le=()=>{const le=parseInt(me),De=Math.ceil(d/p);le>=1&&le<=De?(f(le),Ne("")):fe({title:"无效的页码",description:`请输入1-${De}之间的页码`,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(Ia,{className:"h-8 w-8",strokeWidth:2}),"表达方式管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦的表达方式和话术模板"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_,{variant:"outline",onClick:()=>ue(!0),className:"gap-2",children:[e.jsx(cv,{className:"h-4 w-4"}),"人工审核",Y>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs rounded-full bg-orange-500 text-white",children:Y>99?"99+":Y})]}),e.jsxs(_,{onClick:()=>E(!0),className:"gap-2",children:[e.jsx(Xs,{className:"h-4 w-4"}),"新增表达方式"]})]})]})}),e.jsx(ts,{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:je.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:je.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:je.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx(T,{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($t,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{id:"search",placeholder:"搜索情境、风格或上下文...",value:N,onChange:le=>j(le.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:H.size>0&&e.jsxs("span",{children:["已选择 ",H.size," 个表达方式"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Pe,{value:p.toString(),onValueChange:le=>{g(parseInt(le)),f(1),O(new Set)},children:[e.jsx(Be,{id:"page-size",className:"w-20",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10"}),e.jsx(W,{value:"20",children:"20"}),e.jsx(W,{value:"50",children:"50"}),e.jsx(W,{value:"100",children:"100"})]})]}),H.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(new Set),children:"取消选择"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:()=>L(!0),children:[e.jsx(os,{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(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{className:"w-12",children:e.jsx(tt,{checked:H.size===a.length&&a.length>0,onCheckedChange:J})}),e.jsx(ns,{children:"情境"}),e.jsx(ns,{children:"风格"}),e.jsx(ns,{children:"聊天"}),e.jsx(ns,{className:"text-right",children:"操作"})]})}),e.jsx(Gl,{children:r?e.jsx(_t,{children:e.jsx(Ze,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):a.length===0?e.jsx(_t,{children:e.jsx(Ze,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):a.map(le=>e.jsxs(_t,{children:[e.jsx(Ze,{children:e.jsx(tt,{checked:H.has(le.id),onCheckedChange:()=>cs(le.id)})}),e.jsx(Ze,{className:"font-medium max-w-xs truncate",children:le.situation}),e.jsx(Ze,{className:"max-w-xs truncate",children:le.style}),e.jsx(Ze,{className:"max-w-[200px] truncate",title:K(le.chat_id),style:{wordBreak:"keep-all"},children:e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis block",children:K(le.chat_id)})}),e.jsx(Ze,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>se(le),children:[e.jsx(sr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Re(le),title:"查看详情",children:e.jsx(ua,{className:"h-4 w-4"})}),e.jsxs(_,{size:"sm",onClick:()=>R(le),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},le.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:"加载中..."}):a.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):a.map(le=>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(tt,{checked:H.has(le.id),onCheckedChange:()=>cs(le.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:le.situation,children:le.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:le.style,children:le.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:K(le.chat_id),style:{wordBreak:"keep-all"},children:K(le.chat_id)})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>se(le),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(sr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Re(le),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:e.jsx(ua,{className:"h-3 w-3"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>R(le),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(os,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},le.id))}),d>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:["共 ",d," 条记录,第 ",h," / ",Math.ceil(d/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(Pa,{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(ne,{type:"number",value:me,onChange:le=>Ne(le.target.value),onKeyDown:le=>le.key==="Enter"&&Le(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(d/p)}),e.jsx(_,{variant:"outline",size:"sm",onClick:Le,disabled:!me,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(d/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(ra,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(d/p)),disabled:h>=Math.ceil(d/p),className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(dk,{expression:b,open:w,onOpenChange:z,chatNameMap:D}),e.jsx(uk,{open:F,onOpenChange:E,chatList:ge,onSuccess:()=>{Ee(),G(),E(!1)}}),e.jsx(mk,{expression:b,open:M,onOpenChange:S,chatList:ge,onSuccess:()=>{Ee(),G(),S(!1)}}),e.jsx(bs,{open:!!C,onOpenChange:()=>R(null),children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除表达方式 "',C?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>C&&$e(C),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(xk,{open:X,onOpenChange:L,onConfirm:Z,count:H.size}),e.jsx(Pv,{open:B,onOpenChange:le=>{ue(le),le||(Ee(),G(),$())}})]})}function dk({expression:a,open:l,onOpenChange:r,chatNameMap:c}){if(!a)return null;const d=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-",m=h=>c.get(h)||h;return e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"表达方式详情"}),e.jsx(at,{children:"查看表达方式的完整信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Yi,{label:"情境",value:a.situation}),e.jsx(Yi,{label:"风格",value:a.style}),e.jsx(Yi,{label:"聊天",value:m(a.chat_id)}),e.jsx(Yi,{icon:Wr,label:"记录ID",value:a.id.toString(),mono:!0})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsx(Yi,{icon:da,label:"创建时间",value:d(a.create_date)})}),e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-4",children:[e.jsx(T,{className:"text-xs text-muted-foreground mb-3 block",children:"状态标记"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:P("flex h-8 w-8 items-center justify-center rounded-full",a.checked?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400":"bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-600"),children:a.checked?e.jsx(st,{className:"h-5 w-5"}):e.jsx(Vo,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"已检查"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.checked?"已通过审核":"未审核"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:P("flex h-8 w-8 items-center justify-center rounded-full",a.rejected?"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400":"bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-600"),children:a.rejected?e.jsx(ta,{className:"h-5 w-5"}):e.jsx(Vo,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"已拒绝"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.rejected?"不会被使用":"正常"})]})]})]})]})]}),e.jsx(gt,{children:e.jsx(_,{onClick:()=>r(!1),children:"关闭"})})]})})}function Yi({icon:a,label:l,value:r,mono:c=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(T,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[a&&e.jsx(a,{className:"h-3 w-3"}),l]}),e.jsx("div",{className:P("text-sm",c&&"font-mono",!r&&"text-muted-foreground"),children:r||"-"})]})}function uk({open:a,onOpenChange:l,chatList:r,onSuccess:c}){const[d,m]=u.useState({situation:"",style:"",chat_id:""}),[h,f]=u.useState(!1),{toast:p}=nt(),g=async()=>{if(!d.situation||!d.style||!d.chat_id){p({title:"验证失败",description:"请填写必填字段:情境、风格和聊天",variant:"destructive"});return}try{f(!0),await n2(d),p({title:"创建成功",description:"表达方式已创建"}),m({situation:"",style:"",chat_id:""}),c()}catch(N){p({title:"创建失败",description:N instanceof Error?N.message:"无法创建表达方式",variant:"destructive"})}finally{f(!1)}};return e.jsx(Qs,{open:a,onOpenChange:l,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"新增表达方式"}),e.jsx(at,{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(T,{htmlFor:"situation",children:["情境 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ne,{id:"situation",value:d.situation,onChange:N=>m({...d,situation:N.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"style",children:["风格 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ne,{id:"style",value:d.style,onChange:N=>m({...d,style:N.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Pe,{value:d.chat_id,onValueChange:N=>m({...d,chat_id:N}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择关联的聊天"})}),e.jsx(Ie,{children:r.map(N=>e.jsx(W,{value:N.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[N.chat_name,N.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},N.chat_id))})]})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>l(!1),children:"取消"}),e.jsx(_,{onClick:g,disabled:h,children:h?"创建中...":"创建"})]})]})})}function mk({expression:a,open:l,onOpenChange:r,chatList:c,onSuccess:d}){const[m,h]=u.useState({}),[f,p]=u.useState(!1),{toast:g}=nt();u.useEffect(()=>{a&&h({situation:a.situation,style:a.style,chat_id:a.chat_id,checked:a.checked,rejected:a.rejected})},[a]);const N=async()=>{if(a)try{p(!0),await r2(a.id,m),g({title:"保存成功",description:"表达方式已更新"}),d()}catch(j){g({title:"保存失败",description:j instanceof Error?j.message:"无法更新表达方式",variant:"destructive"})}finally{p(!1)}};return a?e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"编辑表达方式"}),e.jsx(at,{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(T,{htmlFor:"edit_situation",children:"情境"}),e.jsx(ne,{id:"edit_situation",value:m.situation||"",onChange:j=>h({...m,situation:j.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_style",children:"风格"}),e.jsx(ne,{id:"edit_style",value:m.style||"",onChange:j=>h({...m,style:j.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Pe,{value:m.chat_id||"",onValueChange:j=>h({...m,chat_id:j}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择关联的聊天"})}),e.jsx(Ie,{children:c.map(j=>e.jsx(W,{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(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(ft,{className:"text-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:e.jsx("strong",{children:"状态标记说明:"})}),e.jsx("p",{children:"• 已检查:表示该表达方式已通过审核(可由AI自动检查或人工审核)"}),e.jsx("p",{children:"• 已拒绝:表示该表达方式被标记为不合适,将永远不会被使用"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['根据配置中"仅使用已审核通过的表达方式"设置:',e.jsx("br",{}),"• 开启时:只有通过审核(已检查)的项目会被使用",e.jsx("br",{}),"• 关闭时:未审核的项目也会被使用"]})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between space-x-2 rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"edit_checked",className:"text-sm font-medium",children:"已检查"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"已通过审核"})]}),e.jsx(Ge,{id:"edit_checked",checked:m.checked??!1,onCheckedChange:j=>h({...m,checked:j})})]}),e.jsxs("div",{className:"flex items-center justify-between space-x-2 rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"edit_rejected",className:"text-sm font-medium",children:"已拒绝"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"不会被使用"})]}),e.jsx(Ge,{id:"edit_rejected",checked:m.rejected??!1,onCheckedChange:j=>h({...m,rejected:j})})]})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(_,{onClick:N,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}function xk({open:a,onOpenChange:l,onConfirm:r,count:c}){return e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认批量删除"}),e.jsxs(gs,{children:["您即将删除 ",c," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:r,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const Kl="/api/webui/jargon";async function hk(){const a=await ke(`${Kl}/chats`,{});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取聊天列表失败")}return a.json()}async function fk(a){const l=new URLSearchParams;a.page&&l.append("page",a.page.toString()),a.page_size&&l.append("page_size",a.page_size.toString()),a.search&&l.append("search",a.search),a.chat_id&&l.append("chat_id",a.chat_id),a.is_jargon!==void 0&&a.is_jargon!==null&&l.append("is_jargon",a.is_jargon.toString()),a.is_global!==void 0&&l.append("is_global",a.is_global.toString());const r=await ke(`${Kl}/list?${l}`,{});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取黑话列表失败")}return r.json()}async function pk(a){const l=await ke(`${Kl}/${a}`,{});if(!l.ok){const r=await l.json();throw new Error(r.detail||"获取黑话详情失败")}return l.json()}async function gk(a){const l=await ke(`${Kl}/`,{method:"POST",body:JSON.stringify(a)});if(!l.ok){const r=await l.json();throw new Error(r.detail||"创建黑话失败")}return l.json()}async function jk(a,l){const r=await ke(`${Kl}/${a}`,{method:"PATCH",body:JSON.stringify(l)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"更新黑话失败")}return r.json()}async function vk(a){const l=await ke(`${Kl}/${a}`,{method:"DELETE"});if(!l.ok){const r=await l.json();throw new Error(r.detail||"删除黑话失败")}return l.json()}async function Nk(a){const l=await ke(`${Kl}/batch/delete`,{method:"POST",body:JSON.stringify({ids:a})});if(!l.ok){const r=await l.json();throw new Error(r.detail||"批量删除黑话失败")}return l.json()}async function bk(){const a=await ke(`${Kl}/stats/summary`,{});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取黑话统计失败")}return a.json()}async function yk(a,l){const r=new URLSearchParams;a.forEach(d=>r.append("ids",d.toString())),r.append("is_jargon",l.toString());const c=await ke(`${Kl}/batch/set-jargon?${r}`,{method:"POST"});if(!c.ok){const d=await c.json();throw new Error(d.detail||"批量设置黑话状态失败")}return c.json()}function wk(){const[a,l]=u.useState([]),[r,c]=u.useState(!0),[d,m]=u.useState(0),[h,f]=u.useState(1),[p,g]=u.useState(20),[N,j]=u.useState(""),[b,y]=u.useState("all"),[w,z]=u.useState("all"),[M,S]=u.useState(null),[F,E]=u.useState(!1),[C,R]=u.useState(!1),[H,O]=u.useState(!1),[X,L]=u.useState(null),[me,Ne]=u.useState(new Set),[je,ce]=u.useState(!1),[ge,pe]=u.useState(""),[D,Q]=u.useState({total:0,confirmed_jargon:0,confirmed_not_jargon:0,pending:0,global_count:0,complete_count:0,chat_count:0,top_chats:{}}),[B,ue]=u.useState([]),{toast:Y}=nt(),we=async()=>{try{c(!0);const Z=await fk({page:h,page_size:p,search:N||void 0,chat_id:b==="all"?void 0:b,is_jargon:w==="all"?void 0:w==="true"?!0:w==="false"?!1:void 0});l(Z.data),m(Z.total)}catch(Z){Y({title:"加载失败",description:Z instanceof Error?Z.message:"无法加载黑话列表",variant:"destructive"})}finally{c(!1)}},fe=async()=>{try{const Z=await bk();Z?.data&&Q(Z.data)}catch(Z){console.error("加载统计数据失败:",Z)}},Ee=async()=>{try{const Z=await hk();Z?.data&&ue(Z.data)}catch(Z){console.error("加载聊天列表失败:",Z)}};u.useEffect(()=>{we(),fe(),Ee()},[h,p,N,b,w]);const G=async Z=>{try{const Le=await pk(Z.id);S(Le.data),E(!0)}catch(Le){Y({title:"加载详情失败",description:Le instanceof Error?Le.message:"无法加载黑话详情",variant:"destructive"})}},$=Z=>{S(Z),R(!0)},A=async Z=>{try{await vk(Z.id),Y({title:"删除成功",description:`已删除黑话: ${Z.content}`}),L(null),we(),fe()}catch(Le){Y({title:"删除失败",description:Le instanceof Error?Le.message:"无法删除黑话",variant:"destructive"})}},K=Z=>{const Le=new Set(me);Le.has(Z)?Le.delete(Z):Le.add(Z),Ne(Le)},Re=()=>{me.size===a.length&&a.length>0?Ne(new Set):Ne(new Set(a.map(Z=>Z.id)))},se=async()=>{try{await Nk(Array.from(me)),Y({title:"批量删除成功",description:`已删除 ${me.size} 个黑话`}),Ne(new Set),ce(!1),we(),fe()}catch(Z){Y({title:"批量删除失败",description:Z instanceof Error?Z.message:"无法批量删除黑话",variant:"destructive"})}},$e=async Z=>{try{await yk(Array.from(me),Z),Y({title:"操作成功",description:`已将 ${me.size} 个词条设为${Z?"黑话":"非黑话"}`}),Ne(new Set),we(),fe()}catch(Le){Y({title:"操作失败",description:Le instanceof Error?Le.message:"批量设置失败",variant:"destructive"})}},cs=()=>{const Z=parseInt(ge),Le=Math.ceil(d/p);Z>=1&&Z<=Le?(f(Z),pe("")):Y({title:"无效的页码",description:`请输入1-${Le}之间的页码`,variant:"destructive"})},J=Z=>Z===!0?e.jsxs(Ce,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Lt,{className:"h-3 w-3 mr-1"}),"是黑话"]}):Z===!1?e.jsxs(Ce,{variant:"secondary",children:[e.jsx(Sa,{className:"h-3 w-3 mr-1"}),"非黑话"]}):e.jsxs(Ce,{variant:"outline",children:[e.jsx(ox,{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(P1,{className:"h-8 w-8",strokeWidth:2}),"黑话管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦学习到的黑话和俚语"})]}),e.jsxs(_,{onClick:()=>O(!0),className:"gap-2",children:[e.jsx(Xs,{className:"h-4 w-4"}),"新增黑话"]})]})}),e.jsx(ts,{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:D.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:D.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:D.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:D.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:D.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:D.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:D.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(T,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx($t,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{id:"search",placeholder:"搜索内容、含义...",value:N,onChange:Z=>j(Z.target.value),className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(T,{children:"聊天筛选"}),e.jsxs(Pe,{value:b,onValueChange:y,children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"全部聊天"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部聊天"}),B.map(Z=>e.jsx(W,{value:Z.chat_id,children:Z.chat_name},Z.chat_id))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(T,{children:"状态筛选"}),e.jsxs(Pe,{value:w,onValueChange:z,children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"全部状态"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部状态"}),e.jsx(W,{value:"true",children:"是黑话"}),e.jsx(W,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(T,{htmlFor:"page-size",children:"每页显示"}),e.jsxs(Pe,{value:p.toString(),onValueChange:Z=>{g(parseInt(Z)),f(1),Ne(new Set)},children:[e.jsx(Be,{id:"page-size",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10"}),e.jsx(W,{value:"20",children:"20"}),e.jsx(W,{value:"50",children:"50"}),e.jsx(W,{value:"100",children:"100"})]})]})]})]}),me.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:["已选择 ",me.size," 个"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>$e(!0),children:[e.jsx(Lt,{className:"h-4 w-4 mr-1"}),"标记为黑话"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>$e(!1),children:[e.jsx(Sa,{className:"h-4 w-4 mr-1"}),"标记为非黑话"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Ne(new Set),children:"取消选择"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:()=>ce(!0),children:[e.jsx(os,{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(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{className:"w-12",children:e.jsx(tt,{checked:me.size===a.length&&a.length>0,onCheckedChange:Re})}),e.jsx(ns,{children:"内容"}),e.jsx(ns,{children:"含义"}),e.jsx(ns,{children:"聊天"}),e.jsx(ns,{children:"状态"}),e.jsx(ns,{className:"text-center",children:"次数"}),e.jsx(ns,{className:"text-right",children:"操作"})]})}),e.jsx(Gl,{children:r?e.jsx(_t,{children:e.jsx(Ze,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):a.length===0?e.jsx(_t,{children:e.jsx(Ze,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):a.map(Z=>e.jsxs(_t,{children:[e.jsx(Ze,{children:e.jsx(tt,{checked:me.has(Z.id),onCheckedChange:()=>K(Z.id)})}),e.jsx(Ze,{className:"font-medium max-w-[200px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Z.is_global&&e.jsx("span",{title:"全局黑话",children:e.jsx(Go,{className:"h-4 w-4 text-blue-500 flex-shrink-0"})}),e.jsx("span",{className:"truncate",title:Z.content,children:Z.content})]})}),e.jsx(Ze,{className:"max-w-[200px] truncate",title:Z.meaning||"",children:Z.meaning||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ze,{className:"max-w-[150px] truncate",title:Z.chat_name||Z.chat_id,children:Z.chat_name||Z.chat_id}),e.jsx(Ze,{children:J(Z.is_jargon)}),e.jsx(Ze,{className:"text-center",children:Z.count}),e.jsx(Ze,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>$(Z),children:[e.jsx(sr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>G(Z),title:"查看详情",children:e.jsx(ua,{className:"h-4 w-4"})}),e.jsxs(_,{size:"sm",onClick:()=>L(Z),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},Z.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:"加载中..."}):a.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):a.map(Z=>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(tt,{checked:me.has(Z.id),onCheckedChange:()=>K(Z.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:[Z.is_global&&e.jsx(Go,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-sm break-all",children:Z.content})]}),Z.meaning&&e.jsx("p",{className:"text-sm text-muted-foreground break-all",children:Z.meaning}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[J(Z.is_jargon),e.jsxs("span",{className:"text-muted-foreground",children:["次数: ",Z.count]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["聊天: ",Z.chat_name||Z.chat_id]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>$(Z),className:"text-xs px-2 py-1 h-auto",children:[e.jsx(sr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>G(Z),className:"text-xs px-2 py-1 h-auto",children:e.jsx(ua,{className:"h-3 w-3"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>L(Z),className:"text-xs px-2 py-1 h-auto text-destructive hover:text-destructive",children:[e.jsx(os,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},Z.id))}),d>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:["共 ",d," 条记录,第 ",h," / ",Math.ceil(d/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(Pa,{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(ne,{type:"number",value:ge,onChange:Z=>pe(Z.target.value),onKeyDown:Z=>Z.key==="Enter"&&cs(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(d/p)}),e.jsx(_,{variant:"outline",size:"sm",onClick:cs,disabled:!ge,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(d/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(ra,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(d/p)),disabled:h>=Math.ceil(d/p),className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(_k,{jargon:M,open:F,onOpenChange:E}),e.jsx(Sk,{open:H,onOpenChange:O,chatList:B,onSuccess:()=>{we(),fe(),O(!1)}}),e.jsx(kk,{jargon:M,open:C,onOpenChange:R,chatList:B,onSuccess:()=>{we(),fe(),R(!1)}}),e.jsx(bs,{open:!!X,onOpenChange:()=>L(null),children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除黑话 "',X?.content,'" 吗?此操作不可撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>X&&A(X),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(bs,{open:je,onOpenChange:ce,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认批量删除"}),e.jsxs(gs,{children:["您即将删除 ",me.size," 个黑话,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:se,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})]})}function _k({jargon:a,open:l,onOpenChange:r}){return a?e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"黑话详情"}),e.jsx(at,{children:"查看黑话的完整信息"})]}),e.jsx(ts,{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(Gm,{icon:Wr,label:"记录ID",value:a.id.toString(),mono:!0}),e.jsx(Gm,{label:"使用次数",value:a.count.toString()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all whitespace-pre-wrap",children:a.content})]}),a.raw_content&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"原始内容"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:(()=>{try{const c=JSON.parse(a.raw_content);return Array.isArray(c)?c.map((d,m)=>e.jsxs("div",{children:[m>0&&e.jsx("hr",{className:"my-3 border-border"}),e.jsx("div",{className:"whitespace-pre-wrap",children:d})]},m)):e.jsx("div",{className:"whitespace-pre-wrap",children:a.raw_content})}catch{return e.jsx("div",{className:"whitespace-pre-wrap",children:a.raw_content})}})()})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"含义"}),e.jsx("div",{className:"text-sm p-2 bg-muted rounded break-all",children:a.meaning?e.jsx(bx,{content:a.meaning}):"-"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Gm,{label:"聊天",value:a.chat_name||a.chat_id}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"flex items-center gap-2",children:[a.is_jargon===!0&&e.jsx(Ce,{variant:"default",className:"bg-green-600",children:"是黑话"}),a.is_jargon===!1&&e.jsx(Ce,{variant:"secondary",children:"非黑话"}),a.is_jargon===null&&e.jsx(Ce,{variant:"outline",children:"未判定"}),a.is_global&&e.jsx(Ce,{variant:"outline",className:"border-blue-500 text-blue-500",children:"全局"}),a.is_complete&&e.jsx(Ce,{variant:"outline",className:"border-purple-500 text-purple-500",children:"推断完成"})]})]})]}),a.inference_with_context&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{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:a.inference_with_context})]}),a.inference_content_only&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(T,{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:a.inference_content_only})]})]})}),e.jsx(gt,{className:"flex-shrink-0",children:e.jsx(_,{onClick:()=>r(!1),children:"关闭"})})]})}):null}function Gm({icon:a,label:l,value:r,mono:c=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(T,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[a&&e.jsx(a,{className:"h-3 w-3"}),l]}),e.jsx("div",{className:P("text-sm",c&&"font-mono",!r&&"text-muted-foreground"),children:r||"-"})]})}function Sk({open:a,onOpenChange:l,chatList:r,onSuccess:c}){const[d,m]=u.useState({content:"",meaning:"",chat_id:"",is_global:!1}),[h,f]=u.useState(!1),{toast:p}=nt(),g=async()=>{if(!d.content||!d.chat_id){p({title:"验证失败",description:"请填写必填字段:内容和聊天",variant:"destructive"});return}try{f(!0),await gk(d),p({title:"创建成功",description:"黑话已创建"}),m({content:"",meaning:"",chat_id:"",is_global:!1}),c()}catch(N){p({title:"创建失败",description:N instanceof Error?N.message:"无法创建黑话",variant:"destructive"})}finally{f(!1)}};return e.jsx(Qs,{open:a,onOpenChange:l,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"新增黑话"}),e.jsx(at,{children:"创建新的黑话记录"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"content",children:["内容 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ne,{id:"content",value:d.content,onChange:N=>m({...d,content:N.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"meaning",children:"含义"}),e.jsx(pt,{id:"meaning",value:d.meaning||"",onChange:N=>m({...d,meaning:N.target.value}),placeholder:"输入黑话含义(可选)",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"chat_id",children:["聊天 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(Pe,{value:d.chat_id,onValueChange:N=>m({...d,chat_id:N}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择关联的聊天"})}),e.jsx(Ie,{children:r.map(N=>e.jsx(W,{value:N.chat_id,children:N.chat_name},N.chat_id))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"is_global",checked:d.is_global,onCheckedChange:N=>m({...d,is_global:N})}),e.jsx(T,{htmlFor:"is_global",children:"设为全局黑话"})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>l(!1),children:"取消"}),e.jsx(_,{onClick:g,disabled:h,children:h?"创建中...":"创建"})]})]})})}function kk({jargon:a,open:l,onOpenChange:r,chatList:c,onSuccess:d}){const[m,h]=u.useState({}),[f,p]=u.useState(!1),{toast:g}=nt();u.useEffect(()=>{a&&h({content:a.content,meaning:a.meaning||"",chat_id:a.stream_id||a.chat_id,is_global:a.is_global,is_jargon:a.is_jargon})},[a]);const N=async()=>{if(a)try{p(!0),await jk(a.id,m),g({title:"保存成功",description:"黑话已更新"}),d()}catch(j){g({title:"保存失败",description:j instanceof Error?j.message:"无法更新黑话",variant:"destructive"})}finally{p(!1)}};return a?e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"编辑黑话"}),e.jsx(at,{children:"修改黑话的信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_content",children:"内容"}),e.jsx(ne,{id:"edit_content",value:m.content||"",onChange:j=>h({...m,content:j.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_meaning",children:"含义"}),e.jsx(pt,{id:"edit_meaning",value:m.meaning||"",onChange:j=>h({...m,meaning:j.target.value}),placeholder:"输入黑话含义",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Pe,{value:m.chat_id||"",onValueChange:j=>h({...m,chat_id:j}),children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择关联的聊天"})}),e.jsx(Ie,{children:c.map(j=>e.jsx(W,{value:j.chat_id,children:j.chat_name},j.chat_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"黑话状态"}),e.jsxs(Pe,{value:m.is_jargon===null?"null":m.is_jargon?.toString()||"null",onValueChange:j=>h({...m,is_jargon:j==="null"?null:j==="true"}),children:[e.jsx(Be,{children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"null",children:"未判定"}),e.jsx(W,{value:"true",children:"是黑话"}),e.jsx(W,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"edit_is_global",checked:m.is_global,onCheckedChange:j=>h({...m,is_global:j})}),e.jsx(T,{htmlFor:"edit_is_global",children:"全局黑话"})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(_,{onClick:N,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}const li="/api/webui/person";async function Ck(a){const l=new URLSearchParams;a.page&&l.append("page",a.page.toString()),a.page_size&&l.append("page_size",a.page_size.toString()),a.search&&l.append("search",a.search),a.is_known!==void 0&&l.append("is_known",a.is_known.toString()),a.platform&&l.append("platform",a.platform);const r=await ke(`${li}/list?${l}`,{headers:Zs()});if(!r.ok){const c=await r.json();throw new Error(c.detail||"获取人物列表失败")}return r.json()}async function Tk(a){const l=await ke(`${li}/${a}`,{headers:Zs()});if(!l.ok){const r=await l.json();throw new Error(r.detail||"获取人物详情失败")}return l.json()}async function Ek(a,l){const r=await ke(`${li}/${a}`,{method:"PATCH",headers:Zs(),body:JSON.stringify(l)});if(!r.ok){const c=await r.json();throw new Error(c.detail||"更新人物信息失败")}return r.json()}async function Mk(a){const l=await ke(`${li}/${a}`,{method:"DELETE",headers:Zs()});if(!l.ok){const r=await l.json();throw new Error(r.detail||"删除人物信息失败")}return l.json()}async function Ak(){const a=await ke(`${li}/stats/summary`,{headers:Zs()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取统计数据失败")}return a.json()}async function zk(a){const l=await ke(`${li}/batch/delete`,{method:"POST",headers:Zs(),body:JSON.stringify({person_ids:a})});if(!l.ok){const r=await l.json();throw new Error(r.detail||"批量删除失败")}return l.json()}function Rk(){const[a,l]=u.useState([]),[r,c]=u.useState(!0),[d,m]=u.useState(0),[h,f]=u.useState(1),[p,g]=u.useState(20),[N,j]=u.useState(""),[b,y]=u.useState(void 0),[w,z]=u.useState(void 0),[M,S]=u.useState(null),[F,E]=u.useState(!1),[C,R]=u.useState(!1),[H,O]=u.useState(null),[X,L]=u.useState({total:0,known:0,unknown:0,platforms:{}}),[me,Ne]=u.useState(new Set),[je,ce]=u.useState(!1),[ge,pe]=u.useState(""),{toast:D}=nt(),Q=async()=>{try{c(!0);const se=await Ck({page:h,page_size:p,search:N||void 0,is_known:b,platform:w});l(se.data),m(se.total)}catch(se){D({title:"加载失败",description:se instanceof Error?se.message:"无法加载人物信息",variant:"destructive"})}finally{c(!1)}},B=async()=>{try{const se=await Ak();se?.data&&L(se.data)}catch(se){console.error("加载统计数据失败:",se)}};u.useEffect(()=>{Q(),B()},[h,p,N,b,w]);const ue=async se=>{try{const $e=await Tk(se.person_id);S($e.data),E(!0)}catch($e){D({title:"加载详情失败",description:$e instanceof Error?$e.message:"无法加载人物详情",variant:"destructive"})}},Y=se=>{S(se),R(!0)},we=async se=>{try{await Mk(se.person_id),D({title:"删除成功",description:`已删除人物信息: ${se.person_name||se.nickname||se.user_id}`}),O(null),Q(),B()}catch($e){D({title:"删除失败",description:$e instanceof Error?$e.message:"无法删除人物信息",variant:"destructive"})}},fe=u.useMemo(()=>Object.keys(X.platforms),[X.platforms]),Ee=se=>{const $e=new Set(me);$e.has(se)?$e.delete(se):$e.add(se),Ne($e)},G=()=>{me.size===a.length&&a.length>0?Ne(new Set):Ne(new Set(a.map(se=>se.person_id)))},$=()=>{if(me.size===0){D({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}ce(!0)},A=async()=>{try{const se=await zk(Array.from(me));D({title:"批量删除完成",description:se.message}),Ne(new Set),ce(!1),Q(),B()}catch(se){D({title:"批量删除失败",description:se instanceof Error?se.message:"批量删除失败",variant:"destructive"})}},K=()=>{const se=parseInt(ge),$e=Math.ceil(d/p);se>=1&&se<=$e?(f(se),pe("")):D({title:"无效的页码",description:`请输入1-${$e}之间的页码`,variant:"destructive"})},Re=se=>se?new Date(se*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(oc,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(ts,{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:X.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:X.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:X.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(T,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx($t,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{id:"search",placeholder:"搜索名称、昵称或用户ID...",value:N,onChange:se=>j(se.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(T,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs(Pe,{value:b===void 0?"all":b.toString(),onValueChange:se=>{y(se==="all"?void 0:se==="true"),f(1)},children:[e.jsx(Be,{id:"filter-known",className:"mt-1.5",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部"}),e.jsx(W,{value:"true",children:"已认识"}),e.jsx(W,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(T,{htmlFor:"filter-platform",children:"平台"}),e.jsxs(Pe,{value:w||"all",onValueChange:se=>{z(se==="all"?void 0:se),f(1)},children:[e.jsx(Be,{id:"filter-platform",className:"mt-1.5",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部平台"}),fe.map(se=>e.jsxs(W,{value:se,children:[se," (",X.platforms[se],")"]},se))]})]})]})]}),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:me.size>0&&e.jsxs("span",{children:["已选择 ",me.size," 个人物"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(Pe,{value:p.toString(),onValueChange:se=>{g(parseInt(se)),f(1),Ne(new Set)},children:[e.jsx(Be,{id:"page-size",className:"w-20",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10"}),e.jsx(W,{value:"20",children:"20"}),e.jsx(W,{value:"50",children:"50"}),e.jsx(W,{value:"100",children:"100"})]})]}),me.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Ne(new Set),children:"取消选择"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:$,children:[e.jsx(os,{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(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{className:"w-12",children:e.jsx(tt,{checked:a.length>0&&me.size===a.length,onCheckedChange:G,"aria-label":"全选"})}),e.jsx(ns,{children:"状态"}),e.jsx(ns,{children:"名称"}),e.jsx(ns,{children:"昵称"}),e.jsx(ns,{children:"平台"}),e.jsx(ns,{children:"用户ID"}),e.jsx(ns,{children:"最后更新"}),e.jsx(ns,{className:"text-right",children:"操作"})]})}),e.jsx(Gl,{children:r?e.jsx(_t,{children:e.jsx(Ze,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):a.length===0?e.jsx(_t,{children:e.jsx(Ze,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):a.map(se=>e.jsxs(_t,{children:[e.jsx(Ze,{children:e.jsx(tt,{checked:me.has(se.person_id),onCheckedChange:()=>Ee(se.person_id),"aria-label":`选择 ${se.person_name||se.nickname||se.user_id}`})}),e.jsx(Ze,{children:e.jsx("div",{className:P("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",se.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:se.is_known?"已认识":"未认识"})}),e.jsx(Ze,{className:"font-medium",children:se.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ze,{children:se.nickname||"-"}),e.jsx(Ze,{children:se.platform}),e.jsx(Ze,{className:"font-mono text-sm",children:se.user_id}),e.jsx(Ze,{className:"text-sm text-muted-foreground",children:Re(se.last_know)}),e.jsx(Ze,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>ue(se),children:[e.jsx(ua,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(_,{variant:"default",size:"sm",onClick:()=>Y(se),children:[e.jsx(sr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>O(se),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},se.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:"加载中..."}):a.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):a.map(se=>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(tt,{checked:me.has(se.person_id),onCheckedChange:()=>Ee(se.person_id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:P("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium mb-2",se.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:se.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:se.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),se.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",se.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:se.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:se.user_id,children:se.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:Re(se.last_know)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>ue(se),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(ua,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Y(se),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(sr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>O(se),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(os,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},se.id))}),d>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:["共 ",d," 条记录,第 ",h," / ",Math.ceil(d/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(1),disabled:h===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(Pa,{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(ne,{type:"number",value:ge,onChange:se=>pe(se.target.value),onKeyDown:se=>se.key==="Enter"&&K(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(d/p)}),e.jsx(_,{variant:"outline",size:"sm",onClick:K,disabled:!ge,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(d/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(ra,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(d/p)),disabled:h>=Math.ceil(d/p),className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(Dk,{person:M,open:F,onOpenChange:E}),e.jsx(Ok,{person:M,open:C,onOpenChange:R,onSuccess:()=>{Q(),B(),R(!1)}}),e.jsx(bs,{open:!!H,onOpenChange:()=>O(null),children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认删除"}),e.jsxs(gs,{children:['确定要删除人物信息 "',H?.person_name||H?.nickname||H?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:()=>H&&we(H),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(bs,{open:je,onOpenChange:ce,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"确认批量删除"}),e.jsxs(gs,{children:["确定要删除选中的 ",me.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{children:"取消"}),e.jsx(js,{onClick:A,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function Dk({person:a,open:l,onOpenChange:r}){if(!a)return null;const c=d=>d?new Date(d*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"人物详情"}),e.jsxs(at,{children:["查看 ",a.person_name||a.nickname||a.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx($l,{icon:Fl,label:"人物名称",value:a.person_name}),e.jsx($l,{icon:Ia,label:"昵称",value:a.nickname}),e.jsx($l,{icon:Wr,label:"用户ID",value:a.user_id,mono:!0}),e.jsx($l,{icon:Wr,label:"人物ID",value:a.person_id,mono:!0}),e.jsx($l,{label:"平台",value:a.platform}),e.jsx($l,{label:"状态",value:a.is_known?"已认识":"未认识"})]}),a.name_reason&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"名称设定原因"}),e.jsx("p",{className:"mt-1 text-sm",children:a.name_reason})]}),a.memory_points&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"个人印象"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:a.memory_points})]}),a.group_nick_name&&a.group_nick_name.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(T,{className:"text-xs text-muted-foreground",children:"群昵称"}),e.jsx("div",{className:"mt-2 space-y-1",children:a.group_nick_name.map((d,m)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:d.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:d.group_nick_name})]},m))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx($l,{icon:da,label:"认识时间",value:c(a.know_times)}),e.jsx($l,{icon:da,label:"首次记录",value:c(a.know_since)}),e.jsx($l,{icon:da,label:"最后更新",value:c(a.last_know)})]})]}),e.jsx(gt,{children:e.jsx(_,{onClick:()=>r(!1),children:"关闭"})})]})})}function $l({icon:a,label:l,value:r,mono:c=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(T,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[a&&e.jsx(a,{className:"h-3 w-3"}),l]}),e.jsx("div",{className:P("text-sm",c&&"font-mono",!r&&"text-muted-foreground"),children:r||"-"})]})}function Ok({person:a,open:l,onOpenChange:r,onSuccess:c}){const[d,m]=u.useState({}),[h,f]=u.useState(!1),{toast:p}=nt();u.useEffect(()=>{a&&m({person_name:a.person_name||"",name_reason:a.name_reason||"",nickname:a.nickname||"",is_known:a.is_known})},[a]);const g=async()=>{if(a)try{f(!0),await Ek(a.person_id,d),p({title:"保存成功",description:"人物信息已更新"}),c()}catch(N){p({title:"保存失败",description:N instanceof Error?N.message:"无法更新人物信息",variant:"destructive"})}finally{f(!1)}};return a?e.jsx(Qs,{open:l,onOpenChange:r,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"编辑人物信息"}),e.jsxs(at,{children:["修改 ",a.person_name||a.nickname||a.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(T,{htmlFor:"person_name",children:"人物名称"}),e.jsx(ne,{id:"person_name",value:d.person_name||"",onChange:N=>m({...d,person_name:N.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"nickname",children:"昵称"}),e.jsx(ne,{id:"nickname",value:d.nickname||"",onChange:N=>m({...d,nickname:N.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(pt,{id:"name_reason",value:d.name_reason||"",onChange:N=>m({...d,name_reason:N.target.value}),placeholder:"为什么这样称呼这个人?",rows:2})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx(T,{htmlFor:"is_known",className:"text-base font-medium",children:"已认识"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"标记是否已经认识这个人"})]}),e.jsx(Ge,{id:"is_known",checked:d.is_known,onCheckedChange:N=>m({...d,is_known:N})})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>r(!1),children:"取消"}),e.jsx(_,{onClick:g,disabled:h,children:h?"保存中...":"保存"})]})]})}):null}var Lk=S_();const tj=mw(Lk),Mx="/api/webui";async function Uk(a=100,l="all"){const r=`${Mx}/knowledge/graph?limit=${a}&node_type=${l}`,c=await fetch(r);if(!c.ok)throw new Error(`获取知识图谱失败: ${c.status}`);return c.json()}async function $k(){const a=await fetch(`${Mx}/knowledge/stats`);if(!a.ok)throw new Error("获取知识图谱统计信息失败");return a.json()}async function Bk(a){const l=await fetch(`${Mx}/knowledge/search?query=${encodeURIComponent(a)}`);if(!l.ok)throw new Error("搜索知识节点失败");return l.json()}const dN=u.memo(({data:a})=>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(Yo,{type:"target",position:Jo.Top}),e.jsx("div",{className:"font-semibold text-white text-sm truncate max-w-[200px]",title:a.content,children:a.label}),e.jsx(Yo,{type:"source",position:Jo.Bottom})]}));dN.displayName="EntityNode";const uN=u.memo(({data:a})=>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(Yo,{type:"target",position:Jo.Top}),e.jsx("div",{className:"font-medium text-white text-xs truncate max-w-[150px]",title:a.content,children:a.label}),e.jsx(Yo,{type:"source",position:Jo.Bottom})]}));uN.displayName="ParagraphNode";const Ik={entity:dN,paragraph:uN};function Pk(a,l){const r=new tj.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:"TB",ranksep:100,nodesep:80});const c=[],d=[];return a.forEach(m=>{r.setNode(m.id,{width:150,height:50})}),l.forEach(m=>{r.setEdge(m.source,m.target)}),tj.layout(r),a.forEach(m=>{const h=r.node(m.id);c.push({id:m.id,type:m.type,position:{x:h.x-75,y:h.y-25},data:{label:m.content.slice(0,20)+(m.content.length>20?"...":""),content:m.content}})}),l.forEach((m,h)=>{const f={id:`edge-${h}`,source:m.source,target:m.target,animated:a.length<=200&&m.weight>5,style:{strokeWidth:Math.min(m.weight/2,5),opacity:.6}};m.weight>10&&a.length<100&&(f.label=`${m.weight.toFixed(0)}`),d.push(f)}),{nodes:c,edges:d}}function Fk(){const a=ha(),[l,r]=u.useState(!1),[c,d]=u.useState(null),[m,h]=u.useState(""),[f,p]=u.useState("all"),[g,N]=u.useState(50),[j,b]=u.useState("50"),[y,w]=u.useState(!1),[z,M]=u.useState(!0),[S,F]=u.useState(!1),[E,C]=u.useState(!1),[R,H,O]=k_([]),[X,L,me]=C_([]),[Ne,je]=u.useState(0),[ce,ge]=u.useState(null),[pe,D]=u.useState(null),{toast:Q}=nt(),B=u.useCallback(A=>A.type==="entity"?"#6366f1":A.type==="paragraph"?"#10b981":"#6b7280",[]),ue=u.useCallback(async(A=!1)=>{try{if(!A&&g>200){C(!0);return}r(!0);const[K,Re]=await Promise.all([Uk(g,f),$k()]);if(d(Re),K.nodes.length===0){Q({title:"提示",description:"知识库为空,请先导入知识数据"}),H([]),L([]);return}const{nodes:se,edges:$e}=Pk(K.nodes,K.edges);H(se),L($e),je(se.length),Re&&Re.total_nodes>g&&Q({title:"提示",description:`知识图谱包含 ${Re.total_nodes} 个节点,当前显示 ${se.length} 个`}),Q({title:"加载成功",description:`已加载 ${se.length} 个节点,${$e.length} 条边`})}catch(K){console.error("加载知识图谱失败:",K),Q({title:"加载失败",description:K instanceof Error?K.message:"未知错误",variant:"destructive"})}finally{r(!1)}},[g,f,Q]),Y=u.useCallback(async()=>{if(!m.trim()){Q({title:"提示",description:"请输入搜索关键词"});return}try{const A=await Bk(m);if(A.length===0){Q({title:"未找到",description:"没有找到匹配的节点"});return}const K=new Set(A.map(Re=>Re.id));H(Re=>Re.map(se=>({...se,style:{...se.style,opacity:K.has(se.id)?1:.3,filter:K.has(se.id)?"brightness(1.2)":"brightness(0.8)"}}))),Q({title:"搜索完成",description:`找到 ${A.length} 个匹配节点`})}catch(A){console.error("搜索失败:",A),Q({title:"搜索失败",description:A instanceof Error?A.message:"未知错误",variant:"destructive"})}},[m,Q]),we=u.useCallback(()=>{H(A=>A.map(K=>({...K,style:{...K.style,opacity:1,filter:"brightness(1)"}})))},[]),fe=u.useCallback(()=>{M(!1),F(!0),ue()},[ue]),Ee=u.useCallback(()=>{C(!1),setTimeout(()=>{ue(!0)},0)},[ue]),G=u.useCallback((A,K)=>{R.find(se=>se.id===K.id)&&ge({id:K.id,type:K.type,content:K.data.content})},[R]);u.useEffect(()=>{z||S&&ue()},[g,f,z,S]);const $=u.useCallback((A,K)=>{const Re=R.find(cs=>cs.id===K.source),se=R.find(cs=>cs.id===K.target),$e=X.find(cs=>cs.id===K.id);Re&&se&&$e&&D({source:{id:Re.id,type:Re.type,content:Re.data.content},target:{id:se.id,type:se.type,content:se.data.content},edge:{source:K.source,target:K.target,weight:parseFloat(K.label||"0")}})},[R,X]);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:"可视化知识实体与关系网络"})]}),c&&e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(Ce,{variant:"outline",className:"gap-1",children:[e.jsx(Zr,{className:"h-3 w-3"}),"节点: ",c.total_nodes]}),e.jsxs(Ce,{variant:"outline",className:"gap-1",children:[e.jsx(xv,{className:"h-3 w-3"}),"边: ",c.total_edges]}),e.jsxs(Ce,{variant:"outline",className:"gap-1",children:[e.jsx(Yt,{className:"h-3 w-3"}),"实体: ",c.entity_nodes]}),e.jsxs(Ce,{variant:"outline",className:"gap-1",children:[e.jsx(Ua,{className:"h-3 w-3"}),"段落: ",c.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(ne,{placeholder:"搜索节点内容...",value:m,onChange:A=>h(A.target.value),onKeyDown:A=>A.key==="Enter"&&Y(),className:"flex-1"}),e.jsx(_,{onClick:Y,size:"sm",children:e.jsx($t,{className:"h-4 w-4"})}),e.jsx(_,{onClick:we,variant:"outline",size:"sm",children:"重置"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Pe,{value:f,onValueChange:A=>p(A),children:[e.jsx(Be,{className:"w-[120px]",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部节点"}),e.jsx(W,{value:"entity",children:"仅实体"}),e.jsx(W,{value:"paragraph",children:"仅段落"})]})]}),e.jsxs(Pe,{value:g===1e4?"all":y?"custom":g.toString(),onValueChange:A=>{A==="custom"?(w(!0),b(g.toString())):A==="all"?(w(!1),N(1e4)):(w(!1),N(Number(A)))},children:[e.jsx(Be,{className:"w-[120px]",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"50",children:"50 节点"}),e.jsx(W,{value:"100",children:"100 节点"}),e.jsx(W,{value:"200",children:"200 节点"}),e.jsx(W,{value:"500",children:"500 节点"}),e.jsx(W,{value:"1000",children:"1000 节点"}),e.jsx(W,{value:"all",children:"全部 (最多10000)"}),e.jsx(W,{value:"custom",children:"自定义..."})]})]}),y&&e.jsx(ne,{type:"number",min:"50",value:j,onChange:A=>b(A.target.value),onBlur:()=>{const A=parseInt(j);!isNaN(A)&&A>=50?N(A):(b("50"),N(50))},onKeyDown:A=>{if(A.key==="Enter"){const K=parseInt(j);!isNaN(K)&&K>=50?N(K):(b("50"),N(50))}},placeholder:"最少50个",className:"w-[120px]"}),e.jsx(_,{onClick:()=>ue(),variant:"outline",size:"sm",disabled:l,children:e.jsx(dt,{className:P("h-4 w-4",l&&"animate-spin")})})]})]})]}),e.jsx("div",{className:"flex-1 relative",children:l?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(dt,{className:"h-8 w-8 animate-spin mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"加载知识图谱中..."})]})}):R.length===0?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Zr,{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(T_,{nodes:R,edges:X,onNodesChange:O,onEdgesChange:me,onNodeClick:G,onEdgeClick:$,nodeTypes:Ik,fitView:!0,minZoom:.05,maxZoom:1.5,defaultViewport:{x:0,y:0,zoom:.5},elevateNodesOnSelect:Ne<=500,nodesDraggable:Ne<=1e3,attributionPosition:"bottom-left",children:[e.jsx(E_,{variant:M_.Dots,gap:12,size:1}),e.jsx(A_,{}),Ne<=500&&e.jsx(z_,{nodeColor:B,nodeBorderRadius:8,pannable:!0,zoomable:!0}),e.jsxs(R_,{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:"段落节点"})]}),Ne>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:"已禁用动画"}),Ne>500&&e.jsx("div",{children:"已禁用缩略图"})]})]})]})]})}),e.jsx(Qs,{open:!!ce,onOpenChange:A=>!A&&ge(null),children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(qs,{children:e.jsx(Vs,{children:"节点详情"})}),ce&&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(Ce,{variant:ce.type==="entity"?"default":"secondary",children:ce.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:ce.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"内容"}),e.jsx(ts,{className:"mt-1 h-40 p-3 bg-muted rounded",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:ce.content})})]})]})]})}),e.jsx(Qs,{open:!!pe,onOpenChange:A=>!A&&D(null),children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(qs,{children:e.jsx(Vs,{children:"边详情"})}),pe&&e.jsx(ts,{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:pe.source.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[pe.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:pe.target.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[pe.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(Ce,{variant:"outline",className:"text-base font-mono",children:pe.edge.weight.toFixed(4)})})]})]})})]})}),e.jsx(bs,{open:z,onOpenChange:M,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"加载知识图谱"}),e.jsxs(gs,{children:["知识图谱的动态展示会消耗较多系统资源。",e.jsx("br",{}),"确定要加载知识图谱吗?"]})]}),e.jsxs(fs,{children:[e.jsx(vs,{onClick:()=>a({to:"/"}),children:"取消 (返回首页)"}),e.jsx(js,{onClick:fe,children:"确认加载"})]})]})}),e.jsx(bs,{open:E,onOpenChange:C,children:e.jsxs(xs,{children:[e.jsxs(hs,{children:[e.jsx(ps,{children:"⚠️ 节点数量较多"}),e.jsx(gs,{asChild:!0,children:e.jsxs("div",{children:[e.jsxs("p",{children:["您正在尝试加载 ",e.jsx("strong",{className:"text-orange-600",children:g>=1e4?"全部 (最多10000个)":g})," 个节点。"]}),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(fs,{children:[e.jsx(vs,{onClick:()=>{C(!1),g>200&&(N(50),w(!1))},children:"取消"}),e.jsx(js,{onClick:Ee,className:"bg-orange-600 hover:bg-orange-700",children:"我了解风险,继续加载"})]})]})})]})}function Hk(){return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsx("div",{className:"flex-none border-b bg-card/50 px-6 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"麦麦知识库管理"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"管理和组织麦麦的知识库内容"})]})})}),e.jsx("div",{className:"flex-1 overflow-auto p-6",children:e.jsx("div",{className:"mx-auto max-w-4xl",children:e.jsxs(Te,{children:[e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Zr,{className:"h-10 w-10 text-primary"})}),e.jsx(Ue,{className:"text-2xl",children:"麦麦知识库管理"}),e.jsx(Ns,{className:"text-base",children:"功能开发中,敬请期待"})]}),e.jsx(ze,{className:"text-center text-sm text-muted-foreground",children:e.jsx("p",{children:"此功能将提供知识库的创建、编辑、导入和管理能力"})})]})})})]})}function aj({className:a,classNames:l,showOutsideDays:r=!0,captionLayout:c="label",buttonVariant:d="ghost",formatters:m,components:h,...f}){const p=Ev();return e.jsx(j_,{showOutsideDays:r,className:P("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`,a),captionLayout:c,formatters:{formatMonthDropdown:g=>g.toLocaleString("default",{month:"short"}),...m},classNames:{root:P("w-fit",p.root),months:P("relative flex flex-col gap-4 md:flex-row",p.months),month:P("flex w-full flex-col gap-4",p.month),nav:P("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",p.nav),button_previous:P(si({variant:d}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_previous),button_next:P(si({variant:d}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_next),month_caption:P("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",p.month_caption),dropdowns:P("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",p.dropdowns),dropdown_root:P("has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",p.dropdown_root),dropdown:P("bg-popover absolute inset-0 opacity-0",p.dropdown),caption_label:P("select-none font-medium",c==="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",p.caption_label),table:"w-full border-collapse",weekdays:P("flex",p.weekdays),weekday:P("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",p.weekday),week:P("mt-2 flex w-full",p.week),week_number_header:P("w-[--cell-size] select-none",p.week_number_header),week_number:P("text-muted-foreground select-none text-[0.8rem]",p.week_number),day:P("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",p.day),range_start:P("bg-accent rounded-l-md",p.range_start),range_middle:P("rounded-none",p.range_middle),range_end:P("bg-accent rounded-r-md",p.range_end),today:P("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",p.today),outside:P("text-muted-foreground aria-selected:text-muted-foreground",p.outside),disabled:P("text-muted-foreground opacity-50",p.disabled),hidden:P("invisible",p.hidden),...l},components:{Root:({className:g,rootRef:N,...j})=>e.jsx("div",{"data-slot":"calendar",ref:N,className:P(g),...j}),Chevron:({className:g,orientation:N,...j})=>N==="left"?e.jsx(Pa,{className:P("size-4",g),...j}):N==="right"?e.jsx(ra,{className:P("size-4",g),...j}):e.jsx(Ba,{className:P("size-4",g),...j}),DayButton:qk,WeekNumber:({children:g,...N})=>e.jsx("td",{...N,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:g})}),...h},...f})}function qk({className:a,day:l,modifiers:r,...c}){const d=Ev(),m=u.useRef(null);return u.useEffect(()=>{r.focused&&m.current?.focus()},[r.focused]),e.jsx(_,{ref:m,variant:"ghost",size:"icon","data-day":l.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:P("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",d.day,a),...c})}const Uo={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 Vk(){const[a,l]=u.useState([]),[r,c]=u.useState(""),[d,m]=u.useState("all"),[h,f]=u.useState("all"),[p,g]=u.useState(void 0),[N,j]=u.useState(void 0),[b,y]=u.useState(!0),[w,z]=u.useState(!1),[M,S]=u.useState("xs"),[F,E]=u.useState(4),[C,R]=u.useState(!1),H=u.useRef(null);u.useEffect(()=>{const Y=Qn.getAllLogs();l(Y);const we=Qn.onLog(()=>{l(Qn.getAllLogs())}),fe=Qn.onConnectionChange(Ee=>{z(Ee)});return()=>{we(),fe()}},[]);const O=u.useMemo(()=>{const Y=new Set(a.map(we=>we.module).filter(we=>we&&we.trim()!==""));return Array.from(Y).sort()},[a]),X=Y=>{switch(Y){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"}},L=Y=>{switch(Y){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"}},me=()=>{window.location.reload()},Ne=()=>{Qn.clearLogs(),l([])},je=()=>{const Y=pe.map(G=>`${G.timestamp} [${G.level.padEnd(8)}] [${G.module}] ${G.message}`).join(`
|
||
`),we=new Blob([Y],{type:"text/plain;charset=utf-8"}),fe=URL.createObjectURL(we),Ee=document.createElement("a");Ee.href=fe,Ee.download=`logs-${Em(new Date,"yyyy-MM-dd-HHmmss")}.txt`,Ee.click(),URL.revokeObjectURL(fe)},ce=()=>{y(!b)},ge=()=>{g(void 0),j(void 0)},pe=u.useMemo(()=>a.filter(Y=>{const we=r===""||Y.message.toLowerCase().includes(r.toLowerCase())||Y.module.toLowerCase().includes(r.toLowerCase()),fe=d==="all"||Y.level===d,Ee=h==="all"||Y.module===h;let G=!0;if(p||N){const $=new Date(Y.timestamp);if(p){const A=new Date(p);A.setHours(0,0,0,0),G=G&&$>=A}if(N){const A=new Date(N);A.setHours(23,59,59,999),G=G&&$<=A}}return we&&fe&&Ee&&G}),[a,r,d,h,p,N]),D=Uo[M].rowHeight+F,Q=aw({count:pe.length,getScrollElement:()=>H.current,estimateSize:()=>D,overscan:50}),B=u.useRef(!1),ue=u.useRef(pe.length);return u.useEffect(()=>{const Y=H.current;if(!Y)return;const we=()=>{if(B.current)return;const{scrollTop:fe,scrollHeight:Ee,clientHeight:G}=Y,$=Ee-fe-G;$>100&&b?y(!1):$<50&&!b&&y(!0)};return Y.addEventListener("scroll",we,{passive:!0}),()=>Y.removeEventListener("scroll",we)},[b]),u.useEffect(()=>{const Y=pe.length>ue.current;ue.current=pe.length,b&&pe.length>0&&Y&&(B.current=!0,Q.scrollToIndex(pe.length-1,{align:"end",behavior:"auto"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{B.current=!1})}))},[pe.length,b,Q]),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-shrink-0 space-y-2 sm:space-y-3 p-2 sm:p-3 lg:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg sm:text-xl lg:text-2xl font-bold",children:"日志查看器"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 hidden sm:block",children:"实时查看和分析麦麦运行日志"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:P("h-2 w-2 sm:h-2.5 sm:w-2.5 rounded-full",w?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w?"已连接":"未连接"})]})]}),e.jsx(Te,{className:"p-2 sm:p-3",children:e.jsx(xc,{open:C,onOpenChange:R,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative min-w-0",children:[e.jsx($t,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索日志...",value:r,onChange:Y=>c(Y.target.value),className:"pl-8 h-8 text-xs sm:text-sm"})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(_,{variant:b?"default":"outline",size:"sm",onClick:ce,className:"h-8 px-2",title:b?"自动滚动":"已暂停",children:[b?e.jsx(F1,{className:"h-3.5 w-3.5"}):e.jsx(H1,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden sm:inline",children:b?"滚动":"暂停"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:Ne,className:"h-8 px-2",title:"清空日志",children:[e.jsx(os,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden md:inline",children:"清空"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:je,className:"h-8 px-2 hidden sm:flex",title:"导出日志",children:[e.jsx(na,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden lg:inline",children:"导出"})]}),e.jsx(hc,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"h-8 px-2",title:C?"收起筛选":"展开筛选",children:[e.jsx(Po,{className:"h-3.5 w-3.5"}),C?e.jsx(Xr,{className:"h-3.5 w-3.5 ml-1"}):e.jsx(Ba,{className:"h-3.5 w-3.5 ml-1"})]})})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center sm:text-right -mt-1",children:[e.jsxs("span",{className:"font-mono",children:[pe.length," / ",a.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]}),e.jsxs(fc,{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsxs(Pe,{value:d,onValueChange:m,children:[e.jsxs(Be,{className:"w-full sm:flex-1 h-8 text-xs",children:[e.jsx(Po,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Fe,{placeholder:"级别"})]}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部级别"}),e.jsx(W,{value:"DEBUG",children:"DEBUG"}),e.jsx(W,{value:"INFO",children:"INFO"}),e.jsx(W,{value:"WARNING",children:"WARNING"}),e.jsx(W,{value:"ERROR",children:"ERROR"}),e.jsx(W,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs(Pe,{value:h,onValueChange:f,children:[e.jsxs(Be,{className:"w-full sm:flex-1 h-8 text-xs",children:[e.jsx(Po,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Fe,{placeholder:"模块"})]}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部模块"}),O.map(Y=>e.jsx(W,{value:Y,children:Y},Y))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:P("w-full sm:flex-1 justify-start text-left font-normal h-8",!p&&"text-muted-foreground"),children:[e.jsx(Ko,{className:"mr-1.5 h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:p?Em(p,"PP",{locale:Oo}):"开始日期"})]})}),e.jsx(tl,{className:"w-auto p-0",align:"start",children:e.jsx(aj,{mode:"single",selected:p,onSelect:g,initialFocus:!0,locale:Oo})})]}),e.jsxs(cl,{children:[e.jsx(ol,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:P("w-full sm:flex-1 justify-start text-left font-normal h-8",!N&&"text-muted-foreground"),children:[e.jsx(Ko,{className:"mr-1.5 h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:N?Em(N,"PP",{locale:Oo}):"结束日期"})]})}),e.jsx(tl,{className:"w-auto p-0",align:"start",children:e.jsx(aj,{mode:"single",selected:N,onSelect:j,initialFocus:!0,locale:Oo})})]}),(p||N)&&e.jsxs(_,{variant:"outline",size:"sm",onClick:ge,className:"w-full sm:w-auto h-8",children:[e.jsx(Sa,{className:"h-3.5 w-3.5 sm:mr-1"}),e.jsx("span",{className:"text-xs",children:"清除"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3 pt-2 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(q1,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"字号"})]}),e.jsx("div",{className:"flex gap-1",children:Object.keys(Uo).map(Y=>e.jsx(_,{variant:M===Y?"default":"outline",size:"sm",onClick:()=>S(Y),className:"h-6 px-2 text-xs",children:Uo[Y].label},Y))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-[200px]",children:[e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"行距"}),e.jsx(el,{value:[F],onValueChange:([Y])=>E(Y),min:0,max:12,step:2,className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground w-7",children:[F,"px"]})]}),e.jsxs("div",{className:"flex gap-2 sm:hidden",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:me,className:"flex-1 h-8",children:[e.jsx(dt,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:"刷新"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:je,className:"flex-1 h-8",children:[e.jsx(na,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:"导出"})]})]})]})]})]})})})]}),e.jsx("div",{className:"flex-1 min-h-0 px-2 sm:px-3 lg:px-4 pb-2 sm:pb-3 lg:pb-4",children:e.jsx(Te,{className:"bg-black dark:bg-gray-950 border-gray-800 dark:border-gray-900 h-full overflow-hidden",children:e.jsx("div",{ref:H,className:P("h-full overflow-auto","[&::-webkit-scrollbar]:w-2.5","[&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:bg-border [&::-webkit-scrollbar-thumb]:rounded-full","[&::-webkit-scrollbar-thumb:hover]:bg-border/80"),children:e.jsx("div",{className:P("p-2 sm:p-3 font-mono relative",Uo[M].class),style:{height:`${Q.getTotalSize()}px`},children:pe.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-xs sm:text-sm",children:"暂无日志数据"}):Q.getVirtualItems().map(Y=>{const we=pe[Y.index];return e.jsxs("div",{"data-index":Y.index,ref:Q.measureElement,className:P("absolute top-0 left-0 w-full px-2 sm:px-3 rounded hover:bg-white/5 transition-colors",L(we.level)),style:{transform:`translateY(${Y.start}px)`,paddingTop:`${F/2}px`,paddingBottom:`${F/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 text-[10px]",children:we.timestamp}),e.jsxs("span",{className:P("font-semibold text-[10px]",X(we.level)),children:["[",we.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 truncate text-[10px]",children:we.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 whitespace-pre-wrap break-words text-[10px]",children:we.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:we.timestamp}),e.jsxs("span",{className:P("flex-shrink-0 w-[65px] lg:w-[75px] font-semibold",X(we.level)),children:["[",we.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[100px] lg:w-[130px] truncate",children:we.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 whitespace-pre-wrap break-words",children:we.message})]})]},Y.key)})})})})})]})}async function Gk(){return(await ke("/api/planner/overview")).json()}async function Kk(a,l=1,r=20,c){const d=new URLSearchParams({page:l.toString(),page_size:r.toString()});return c&&d.append("search",c),(await ke(`/api/planner/chat/${a}/logs?${d}`)).json()}async function Qk(a,l){return(await ke(`/api/planner/log/${a}/${l}`)).json()}async function Yk(){return(await ke("/api/replier/overview")).json()}async function Jk(a,l=1,r=20,c){const d=new URLSearchParams({page:l.toString(),page_size:r.toString()});return c&&d.append("search",c),(await ke(`/api/replier/chat/${a}/logs?${d}`)).json()}async function Xk(a,l){return(await ke(`/api/replier/log/${a}/${l}`)).json()}function mN(){const[a,l]=u.useState(new Map),[r,c]=u.useState(!0),d=u.useCallback(async()=>{try{c(!0);const h=await gx();if(h?.data){const f=new Map;h.data.forEach(p=>{f.set(p.chat_id,p.chat_name)}),l(f)}}catch(h){console.error("加载聊天列表失败:",h)}finally{c(!1)}},[]);u.useEffect(()=>{d()},[d]);const m=u.useCallback(h=>a.get(h)||h,[a]);return{chatNameMap:a,getChatName:m,loading:r,reload:d}}function Zo(a){return new Date(a*1e3).toLocaleString("zh-CN")}function xN(a){const r=Date.now()/1e3-a;return r<60?"刚刚":r<3600?`${Math.floor(r/60)} 分钟前`:r<86400?`${Math.floor(r/3600)} 小时前`:`${Math.floor(r/86400)} 天前`}function hN(a,l,r=1e4){u.useEffect(()=>{if(!a)return;const c=setInterval(l,r);return()=>clearInterval(c)},[a,l,r])}function Zk({autoRefresh:a,refreshKey:l}){const[r,c]=u.useState("overview"),[d,m]=u.useState(null),{getChatName:h}=mN(),[f,p]=u.useState(null),[g,N]=u.useState(!0),[j,b]=u.useState(null),[y,w]=u.useState(!1),[z,M]=u.useState(1),[S,F]=u.useState(20),[E,C]=u.useState(""),[R,H]=u.useState(""),[O,X]=u.useState(""),[L,me]=u.useState(null),[Ne,je]=u.useState(!1),[ce,ge]=u.useState(!1),pe=u.useCallback(async()=>{try{N(!0);const $=await Gk();p($)}catch($){console.error("加载规划器总览失败:",$)}finally{N(!1)}},[]),D=u.useCallback(async()=>{if(d)try{w(!0);const $=await Kk(d.chat_id,z,S,R||void 0);b($)}catch($){console.error("加载聊天日志失败:",$)}finally{w(!1)}},[d,z,S,R]);u.useEffect(()=>{pe()},[pe]),u.useEffect(()=>{l>0&&(r==="overview"?pe():D())},[l,r,pe,D]),u.useEffect(()=>{r==="chat-logs"&&d&&D()},[r,d,D]),hN(a,u.useCallback(()=>{r==="overview"?pe():D()},[r,pe,D]));const Q=$=>{m($),M(1),H(""),X(""),c("chat-logs")},B=()=>{c("overview"),m(null),b(null),H(""),X("")},ue=()=>{H(O),M(1)},Y=()=>{X(""),H(""),M(1)},we=async($,A)=>{try{ge(!0),je(!0);const K=await Qk($,A);me(K)}catch(K){console.error("加载计划详情失败:",K)}finally{ge(!1)}},fe=$=>{F(Number($)),M(1)},Ee=()=>{const $=parseInt(E),A=j?Math.ceil(j.total/j.page_size):0;!isNaN($)&&$>=1&&$<=A&&(M($),C(""))},G=j?Math.ceil(j.total/j.page_size):0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-4",children:r==="overview"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"聊天数量"}),e.jsx(Ia,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ze,{children:g?e.jsx(ks,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_chats||0})})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"计划总数"}),e.jsx(rx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ze,{children:g?e.jsx(ks,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_plans||0})})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"聊天列表"}),e.jsx(Ns,{children:"点击查看该聊天的所有计划记录"})]}),e.jsx(ze,{children:g?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map(($,A)=>e.jsx(ks,{className:"h-24 w-full"},A))}):f?.chats&&f.chats.length>0?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:f.chats.map($=>e.jsxs("div",{className:"border rounded-lg p-4 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>Q($),children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ia,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm truncate max-w-[180px]",title:h($.chat_id),children:h($.chat_id)})]}),e.jsx(Ce,{variant:"secondary",children:$.plan_count})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["最后活动: ",xN($.latest_timestamp)]})]},$.chat_id))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无聊天记录"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mb-4",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:B,children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"返回聊天列表"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["当前聊天: ",e.jsx("span",{className:"font-medium",children:d?h(d.chat_id):""}),e.jsx("span",{className:"mx-2",children:"•"}),"共 ",j?.total||0," 条计划记录"]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(Ue,{children:"计划执行记录"}),e.jsx(Ns,{children:d?h(d.chat_id):""})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ne,{placeholder:"搜索提示词内容...",value:O,onChange:$=>X($.target.value),onKeyDown:$=>$.key==="Enter"&&ue(),className:"w-full sm:w-48"}),e.jsx(_,{variant:"outline",size:"icon",onClick:ue,children:e.jsx($t,{className:"h-4 w-4"})}),R&&e.jsx(_,{variant:"ghost",size:"sm",onClick:Y,children:"清除"})]}),e.jsxs(Pe,{value:S.toString(),onValueChange:fe,children:[e.jsx(Be,{className:"w-full sm:w-32",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10条/页"}),e.jsx(W,{value:"20",children:"20条/页"}),e.jsx(W,{value:"50",children:"50条/页"}),e.jsx(W,{value:"100",children:"100条/页"})]})]})]})]}),R&&e.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:["搜索关键词: ",e.jsxs("span",{className:"font-medium",children:['"',R,'"']})]})]}),e.jsx(ze,{children:y?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map(($,A)=>e.jsx(ks,{className:"h-20 w-full"},A))}):j?.data&&j.data.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:j.data.map($=>e.jsxs("div",{className:"border rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>we($.chat_id,$.filename),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:Zo($.timestamp)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:[$.action_count," 个动作"]}),e.jsxs(Ce,{variant:"outline",className:"text-xs",children:[$.total_plan_ms.toFixed(0),"ms"]})]})]}),$.action_types&&$.action_types.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.action_types.map((A,K)=>e.jsx(Ce,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-950 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800",children:A},K))}),e.jsx("p",{className:"text-sm line-clamp-2",children:$.reasoning_preview||"无推理内容"})]},$.filename))}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",j.total," 条记录,第 ",z," / ",G," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M(1),disabled:z===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M($=>Math.max(1,$-1)),disabled:z===1,children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[e.jsx(ne,{type:"number",min:1,max:G,value:E,onChange:$=>C($.target.value),onKeyDown:$=>$.key==="Enter"&&Ee(),placeholder:"跳转",className:"w-20 h-8"}),e.jsx(_,{size:"sm",variant:"outline",onClick:Ee,children:"跳转"})]}),e.jsxs("span",{className:"sm:hidden text-sm text-muted-foreground",children:[z,"/",G]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M($=>Math.min(G,$+1)),disabled:z===G,children:e.jsx(ra,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M(G),disabled:z===G,className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无计划记录"})})]})]})}),e.jsx(Qs,{open:Ne,onOpenChange:je,children:e.jsxs(Hs,{className:"max-w-4xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(Ua,{className:"h-5 w-5"}),"计划执行详情"]}),e.jsx(at,{children:"查看麦麦的详细计划推理过程和执行动作"})]}),e.jsx(ts,{className:"h-full pr-4",children:e.jsx("div",{className:"space-y-6 pb-4",children:ce?e.jsx("div",{className:"space-y-4",children:[...Array(5)].map(($,A)=>e.jsx(ks,{className:"h-24 w-full"},A))}):L?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(da,{className:"h-4 w-4"}),"基本信息"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"聊天"}),e.jsx("div",{className:"text-sm",title:L.chat_id,children:h(L.chat_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"时间戳"}),e.jsx("div",{className:"text-sm",children:Zo(L.timestamp)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"类型"}),e.jsx(Ce,{variant:"outline",children:L.type})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"动作数量"}),e.jsxs(Ce,{children:[L.actions.length," 个动作"]})]})]})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(sl,{className:"h-4 w-4"}),"性能统计"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-2",children:e.jsx(Ue,{className:"text-xs text-muted-foreground",children:"提示词构建"})}),e.jsx(ze,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[L.timing.prompt_build_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-2",children:e.jsx(Ue,{className:"text-xs text-muted-foreground",children:"LLM 推理"})}),e.jsx(ze,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[L.timing.llm_duration_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-2",children:e.jsx(Ue,{className:"text-xs text-muted-foreground",children:"总计划时间"})}),e.jsx(ze,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[L.timing.total_plan_ms?.toFixed(2)||0,"ms"]})})]})]})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(hx,{className:"h-4 w-4"}),"推理过程"]}),e.jsx("div",{className:"p-4 bg-muted/50 rounded-lg",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:L.reasoning||"无推理内容"})})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(rv,{className:"h-4 w-4"}),"执行动作 (",L.actions.length,")"]}),e.jsx("div",{className:"space-y-3",children:L.actions.map(($,A)=>e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-3",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ce,{variant:"default",children:["动作 ",A+1]}),e.jsx(Ce,{variant:"outline",children:$.action_type})]})})}),e.jsxs(ze,{className:"p-4 pt-0 space-y-3",children:[$.reasoning&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"推理依据"}),e.jsx("p",{className:"text-sm bg-muted/30 p-2 rounded",children:typeof $.reasoning=="string"?$.reasoning:JSON.stringify($.reasoning)})]}),$.action_message&&e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"动作消息"}),typeof $.action_message=="string"?e.jsx("p",{className:"text-sm bg-muted/30 p-2 rounded break-all whitespace-pre-wrap",children:$.action_message}):e.jsx("pre",{className:"text-xs bg-muted/30 p-2 rounded overflow-x-auto whitespace-pre-wrap break-all",children:JSON.stringify($.action_message,null,2)})]}),$.action_data&&Object.keys($.action_data).length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"动作数据"}),e.jsx("pre",{className:"text-xs bg-muted/30 p-2 rounded overflow-x-auto",children:JSON.stringify($.action_data,null,2)})]}),$.action_reasoning&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"动作推理"}),e.jsx("p",{className:"text-sm bg-muted/30 p-2 rounded",children:typeof $.action_reasoning=="string"?$.action_reasoning:JSON.stringify($.action_reasoning)})]})]})]},A))})]}),e.jsx(la,{}),L.raw_output&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"原始输出"}),e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground hover:text-foreground",children:"点击展开查看完整原始输出"}),e.jsx("div",{className:"mt-2 p-4 bg-muted/50 rounded-lg",children:e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words",children:L.raw_output})})]})]}),L.prompt&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"完整提示词"}),e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground hover:text-foreground",children:"点击展开查看完整提示词"}),e.jsx("div",{className:"mt-2 p-4 bg-muted/50 rounded-lg",children:e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words",children:L.prompt})})]})]})]}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"无数据"})})})}),e.jsx(gt,{className:"flex-shrink-0",children:e.jsx(_,{onClick:()=>je(!1),children:"关闭"})})]})})]})}function Wk({autoRefresh:a,refreshKey:l}){const[r,c]=u.useState("overview"),[d,m]=u.useState(null),{getChatName:h}=mN(),[f,p]=u.useState(null),[g,N]=u.useState(!0),[j,b]=u.useState(null),[y,w]=u.useState(!1),[z,M]=u.useState(1),[S,F]=u.useState(20),[E,C]=u.useState(""),[R,H]=u.useState(""),[O,X]=u.useState(""),[L,me]=u.useState(null),[Ne,je]=u.useState(!1),[ce,ge]=u.useState(!1),pe=u.useCallback(async()=>{try{N(!0);const $=await Yk();p($)}catch($){console.error("加载回复器总览失败:",$)}finally{N(!1)}},[]),D=u.useCallback(async()=>{if(d)try{w(!0);const $=await Jk(d.chat_id,z,S,R||void 0);b($)}catch($){console.error("加载聊天日志失败:",$)}finally{w(!1)}},[d,z,S,R]);u.useEffect(()=>{pe()},[pe]),u.useEffect(()=>{l>0&&(r==="overview"?pe():D())},[l,r,pe,D]),u.useEffect(()=>{r==="chat-logs"&&d&&D()},[r,d,D]),hN(a,u.useCallback(()=>{r==="overview"?pe():D()},[r,pe,D]));const Q=$=>{m($),M(1),H(""),X(""),c("chat-logs")},B=()=>{c("overview"),m(null),b(null),H(""),X("")},ue=()=>{H(O),M(1)},Y=()=>{X(""),H(""),M(1)},we=async($,A)=>{try{ge(!0),je(!0);const K=await Xk($,A);me(K)}catch(K){console.error("加载回复详情失败:",K)}finally{ge(!1)}},fe=$=>{F(Number($)),M(1)},Ee=()=>{const $=parseInt(E),A=j?Math.ceil(j.total/j.page_size):0;!isNaN($)&&$>=1&&$<=A&&(M($),C(""))},G=j?Math.ceil(j.total/j.page_size):0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-4",children:r==="overview"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"聊天数量"}),e.jsx(Ia,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ze,{children:g?e.jsx(ks,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_chats||0})})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"回复总数"}),e.jsx(rx,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(ze,{children:g?e.jsx(ks,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_replies||0})})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"聊天列表"}),e.jsx(Ns,{children:"点击查看该聊天的所有回复记录"})]}),e.jsx(ze,{children:g?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map(($,A)=>e.jsx(ks,{className:"h-24 w-full"},A))}):f?.chats&&f.chats.length>0?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:f.chats.map($=>e.jsxs("div",{className:"border rounded-lg p-4 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>Q($),children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ia,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm truncate max-w-[180px]",title:h($.chat_id),children:h($.chat_id)})]}),e.jsx(Ce,{variant:"secondary",children:$.reply_count})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["最后活动: ",xN($.latest_timestamp)]})]},$.chat_id))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无聊天记录"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mb-4",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:B,children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"返回聊天列表"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["当前聊天: ",e.jsx("span",{className:"font-medium",children:d?h(d.chat_id):""}),e.jsx("span",{className:"mx-2",children:"•"}),"共 ",j?.total||0," 条回复记录"]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(Ue,{children:"回复生成记录"}),e.jsx(Ns,{children:d?h(d.chat_id):""})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ne,{placeholder:"搜索提示词内容...",value:O,onChange:$=>X($.target.value),onKeyDown:$=>$.key==="Enter"&&ue(),className:"w-full sm:w-48"}),e.jsx(_,{variant:"outline",size:"icon",onClick:ue,children:e.jsx($t,{className:"h-4 w-4"})}),R&&e.jsx(_,{variant:"ghost",size:"sm",onClick:Y,children:"清除"})]}),e.jsxs(Pe,{value:S.toString(),onValueChange:fe,children:[e.jsx(Be,{className:"w-full sm:w-32",children:e.jsx(Fe,{})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"10",children:"10条/页"}),e.jsx(W,{value:"20",children:"20条/页"}),e.jsx(W,{value:"50",children:"50条/页"}),e.jsx(W,{value:"100",children:"100条/页"})]})]})]})]}),R&&e.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:["搜索关键词: ",e.jsxs("span",{className:"font-medium",children:['"',R,'"']})]})]}),e.jsx(ze,{children:y?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map(($,A)=>e.jsx(ks,{className:"h-20 w-full"},A))}):j?.data&&j.data.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:j.data.map($=>e.jsxs("div",{className:"border rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>we($.chat_id,$.filename),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:Zo($.timestamp)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[$.success?e.jsxs(Ce,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(Mg,{className:"h-3 w-3 mr-1"}),"成功"]}):e.jsxs(Ce,{variant:"destructive",className:"text-xs",children:[e.jsx(ta,{className:"h-3 w-3 mr-1"}),"失败"]}),e.jsx(Ce,{variant:"outline",className:"text-xs",children:$.model}),e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:[$.overall_ms.toFixed(0),"ms"]})]})]}),e.jsx("p",{className:"text-sm line-clamp-2",children:$.output_preview||"无输出内容"})]},$.filename))}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 mt-4 pt-4 border-t",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共 ",j.total," 条记录,第 ",z," / ",G," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M(1),disabled:z===1,className:"hidden sm:flex",children:e.jsx(kn,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M($=>Math.max(1,$-1)),disabled:z===1,children:e.jsx(Pa,{className:"h-4 w-4"})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[e.jsx(ne,{type:"number",min:1,max:G,value:E,onChange:$=>C($.target.value),onKeyDown:$=>$.key==="Enter"&&Ee(),placeholder:"跳转",className:"w-20 h-8"}),e.jsx(_,{size:"sm",variant:"outline",onClick:Ee,children:"跳转"})]}),e.jsxs("span",{className:"sm:hidden text-sm text-muted-foreground",children:[z,"/",G]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M($=>Math.min(G,$+1)),disabled:z===G,children:e.jsx(ra,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>M(G),disabled:z===G,className:"hidden sm:flex",children:e.jsx(Cn,{className:"h-4 w-4"})})]})]})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无回复记录"})})]})]})}),e.jsx(Qs,{open:Ne,onOpenChange:je,children:e.jsxs(Hs,{className:"max-w-4xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(Ua,{className:"h-5 w-5"}),"回复生成详情"]}),e.jsx(at,{children:"查看麦麦的详细回复生成过程"})]}),e.jsx(ts,{className:"h-full pr-4",children:e.jsx("div",{className:"space-y-6 pb-4",children:ce?e.jsx("div",{className:"space-y-4",children:[...Array(5)].map(($,A)=>e.jsx(ks,{className:"h-24 w-full"},A))}):L?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(da,{className:"h-4 w-4"}),"基本信息"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"聊天"}),e.jsx("div",{className:"text-sm",title:L.chat_id,children:h(L.chat_id)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"时间戳"}),e.jsx("div",{className:"text-sm",children:Zo(L.timestamp)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"状态"}),L.success?e.jsxs(Ce,{variant:"default",className:"bg-green-600",children:[e.jsx(Mg,{className:"h-3 w-3 mr-1"}),"成功"]}):e.jsxs(Ce,{variant:"destructive",children:[e.jsx(ta,{className:"h-3 w-3 mr-1"}),"失败"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"思考深度"}),e.jsxs(Ce,{variant:"outline",children:["Level ",L.think_level]})]})]})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(V1,{className:"h-4 w-4"}),"模型信息"]}),e.jsx("div",{className:"p-4 bg-muted/50 rounded-lg",children:e.jsx(Ce,{variant:"secondary",className:"text-sm",children:L.model})})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(sl,{className:"h-4 w-4"}),"性能统计"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-2",children:e.jsx(Ue,{className:"text-xs text-muted-foreground",children:"提示词构建"})}),e.jsx(ze,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[L.timing.prompt_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-2",children:e.jsx(Ue,{className:"text-xs text-muted-foreground",children:"LLM 推理"})}),e.jsx(ze,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[L.timing.llm_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{className:"p-4 pb-2",children:e.jsx(Ue,{className:"text-xs text-muted-foreground",children:"总耗时"})}),e.jsx(ze,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[L.timing.overall_ms?.toFixed(2)||0,"ms"]})})]})]}),L.timing.timing_logs&&L.timing.timing_logs.length>0&&e.jsxs("div",{className:"mt-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:"耗时详情"}),e.jsx("div",{className:"space-y-1",children:L.timing.timing_logs.map(($,A)=>e.jsx("div",{className:"text-xs text-muted-foreground",children:$},A))})]}),L.timing.almost_zero&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"近乎零耗时: "}),L.timing.almost_zero]})]}),e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(hx,{className:"h-4 w-4"}),"回复输出"]}),e.jsx("div",{className:"p-4 bg-muted/50 rounded-lg",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:L.output||"无输出内容"})})]}),L.processed_output&&L.processed_output.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"处理后的输出"}),e.jsx("div",{className:"space-y-2",children:L.processed_output.map(($,A)=>e.jsx("div",{className:"p-3 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:$})},A))})]})]}),L.reasoning&&e.jsxs(e.Fragment,{children:[e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"推理过程"}),e.jsx("div",{className:"p-4 bg-muted/50 rounded-lg",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed",children:L.reasoning})})]})]}),L.error&&e.jsxs(e.Fragment,{children:[e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-destructive",children:"错误信息"}),e.jsx("div",{className:"p-4 bg-destructive/10 rounded-lg border border-destructive/20",children:e.jsx("p",{className:"text-sm text-destructive whitespace-pre-wrap",children:L.error})})]})]}),L.prompt&&e.jsxs(e.Fragment,{children:[e.jsx(la,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"完整提示词"}),e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground hover:text-foreground",children:"点击展开查看完整提示词"}),e.jsx("div",{className:"mt-2 p-4 bg-muted/50 rounded-lg",children:e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-words",children:L.prompt})})]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"无数据"})})})}),e.jsx(gt,{className:"flex-shrink-0",children:e.jsx(_,{onClick:()=>je(!1),children:"关闭"})})]})})]})}function eC(){const[a,l]=u.useState("planner"),[r,c]=u.useState(!1),[d,m]=u.useState(0),h=u.useCallback(()=>{m(f=>f+1)},[]);return 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 items-center gap-2",children:[e.jsxs(_,{variant:r?"default":"outline",size:"sm",onClick:()=>c(!r),children:[e.jsx(dt,{className:`h-4 w-4 mr-2 ${r?"animate-spin":""}`}),r?"自动刷新中":"自动刷新"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:h,children:e.jsx(dt,{className:"h-4 w-4"})})]})]}),e.jsxs(Jt,{value:a,onValueChange:f=>l(f),className:"w-full",children:[e.jsxs(Gt,{className:"grid w-full grid-cols-2 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(Xe,{value:"planner",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(nx,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"计划器监控"})]}),e.jsxs(Xe,{value:"replier",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(G1,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"回复器监控"})]})]}),e.jsxs(ts,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(Ss,{value:"planner",className:"mt-0",children:e.jsx(Zk,{autoRefresh:r,refreshKey:d})}),e.jsx(Ss,{value:"replier",className:"mt-0",children:e.jsx(Wk,{autoRefresh:r,refreshKey:d})})]})]})]})}const sC="Mai-with-u",tC="plugin-repo",aC="main",lC="plugin_details.json";async function nC(){try{const a=await ke("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:sC,repo:tC,branch:aC,file_path:lC})});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const l=await a.json();if(!l.success||!l.data)throw new Error(l.error||"获取插件列表失败");return JSON.parse(l.data).filter(d=>!d?.id||!d?.manifest?(console.warn("跳过无效插件数据:",d),!1):!d.manifest.name||!d.manifest.version?(console.warn("跳过缺少必需字段的插件:",d.id),!1):!0).map(d=>({id:d.id,manifest:{manifest_version:d.manifest.manifest_version||1,name:d.manifest.name,version:d.manifest.version,description:d.manifest.description||"",author:d.manifest.author||{name:"Unknown"},license:d.manifest.license||"Unknown",host_application:d.manifest.host_application||{min_version:"0.0.0"},homepage_url:d.manifest.homepage_url,repository_url:d.manifest.repository_url,keywords:d.manifest.keywords||[],categories:d.manifest.categories||[],default_locale:d.manifest.default_locale||"zh-CN",locales_path:d.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(a){throw console.error("Failed to fetch plugin list:",a),a}}async function fN(){try{const a=await ke("/api/webui/plugins/git-status");if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return await a.json()}catch(a){return console.error("Failed to check Git status:",a),{installed:!1,error:"无法检测 Git 安装状态"}}}async function pN(){try{const a=await ke("/api/webui/plugins/version");if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return await a.json()}catch(a){return console.error("Failed to get Maimai version:",a),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function gN(a,l,r){const c=a.split(".").map(f=>parseInt(f)||0),d=c[0]||0,m=c[1]||0,h=c[2]||0;if(r.version_major<d||r.version_major===d&&r.version_minor<m||r.version_major===d&&r.version_minor===m&&r.version_patch<h)return!1;if(l){const f=l.split(".").map(j=>parseInt(j)||0),p=f[0]||0,g=f[1]||0,N=f[2]||0;if(r.version_major>p||r.version_major===p&&r.version_minor>g||r.version_major===p&&r.version_minor===g&&r.version_patch>N)return!1}return!0}async function rC(){try{const a=await ke("/api/webui/ws-token");if(!a.ok)return console.error("获取 WebSocket token 失败:",a.status),null;const l=await a.json();return l.success&&l.token?l.token:null}catch(a){return console.error("获取 WebSocket token 失败:",a),null}}async function iC(a,l){const r=await rC();if(!r)return console.warn("无法获取 WebSocket token,可能未登录"),null;const c=window.location.protocol==="https:"?"wss:":"ws:",d=window.location.host,m=`${c}//${d}/api/webui/ws/plugin-progress?token=${encodeURIComponent(r)}`;try{const h=new WebSocket(m);return h.onopen=()=>{console.log("Plugin progress WebSocket connected");const f=setInterval(()=>{h.readyState===WebSocket.OPEN?h.send("ping"):clearInterval(f)},3e4)},h.onmessage=f=>{try{if(f.data==="pong")return;const p=JSON.parse(f.data);a(p)}catch(p){console.error("Failed to parse progress data:",p)}},h.onerror=f=>{console.error("Plugin progress WebSocket error:",f),l?.(f)},h.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},h}catch(h){return console.error("创建 WebSocket 连接失败:",h),null}}async function Il(){try{const a=await ke("/api/webui/plugins/installed",{headers:Zs()});if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const l=await a.json();if(!l.success)throw new Error(l.message||"获取已安装插件列表失败");return l.plugins||[]}catch(a){return console.error("Failed to get installed plugins:",a),[]}}function bn(a,l){return l.some(r=>r.id===a)}function yn(a,l){const r=l.find(c=>c.id===a);if(r)return r.manifest?.version||r.version}async function jN(a,l,r="main"){const c=await ke("/api/webui/plugins/install",{method:"POST",body:JSON.stringify({plugin_id:a,repository_url:l,branch:r})});if(!c.ok){const d=await c.json();throw new Error(d.detail||"安装失败")}return await c.json()}async function vN(a){const l=await ke("/api/webui/plugins/uninstall",{method:"POST",body:JSON.stringify({plugin_id:a})});if(!l.ok){const r=await l.json();throw new Error(r.detail||"卸载失败")}return await l.json()}async function NN(a,l,r="main"){const c=await ke("/api/webui/plugins/update",{method:"POST",body:JSON.stringify({plugin_id:a,repository_url:l,branch:r})});if(!c.ok){const d=await c.json();throw new Error(d.detail||"更新失败")}return await c.json()}async function cC(a){const l=await ke(`/api/webui/plugins/config/${a}/schema`,{headers:Zs()});if(!l.ok){const c=await l.text();try{const d=JSON.parse(c);throw new Error(d.detail||"获取配置 Schema 失败")}catch{throw new Error(`获取配置 Schema 失败 (${l.status})`)}}const r=await l.json();if(!r.success)throw new Error(r.message||"获取配置 Schema 失败");return r.schema}async function oC(a){const l=await ke(`/api/webui/plugins/config/${a}`,{headers:Zs()});if(!l.ok){const c=await l.text();try{const d=JSON.parse(c);throw new Error(d.detail||"获取配置失败")}catch{throw new Error(`获取配置失败 (${l.status})`)}}const r=await l.json();if(!r.success)throw new Error(r.message||"获取配置失败");return r.config}async function dC(a){const l=await ke(`/api/webui/plugins/config/${a}/raw`,{headers:Zs()});if(!l.ok){const c=await l.text();try{const d=JSON.parse(c);throw new Error(d.detail||"获取配置失败")}catch{throw new Error(`获取配置失败 (${l.status})`)}}const r=await l.json();if(!r.success)throw new Error(r.message||"获取配置失败");return r.config}async function uC(a,l){const r=await ke(`/api/webui/plugins/config/${a}`,{method:"PUT",headers:Zs(),body:JSON.stringify({config:l})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存配置失败")}return await r.json()}async function mC(a,l){const r=await ke(`/api/webui/plugins/config/${a}/raw`,{method:"PUT",headers:Zs(),body:JSON.stringify({config:l})});if(!r.ok){const c=await r.json();throw new Error(c.detail||"保存配置失败")}return await r.json()}async function xC(a){const l=await ke(`/api/webui/plugins/config/${a}/reset`,{method:"POST",headers:Zs()});if(!l.ok){const r=await l.json();throw new Error(r.detail||"重置配置失败")}return await l.json()}async function hC(a){const l=await ke(`/api/webui/plugins/config/${a}/toggle`,{method:"POST",headers:Zs()});if(!l.ok){const r=await l.json();throw new Error(r.detail||"切换状态失败")}return await l.json()}const Nc="https://maibot-plugin-stats.maibot-webui.workers.dev";async function bN(a){try{const l=await fetch(`${Nc}/stats/${a}`);return l.ok?await l.json():(console.error("Failed to fetch plugin stats:",l.statusText),null)}catch(l){return console.error("Error fetching plugin stats:",l),null}}async function fC(a,l){try{const r=l||Ax(),c=await fetch(`${Nc}/stats/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:a,user_id:r})}),d=await c.json();return c.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:c.ok?{success:!0,...d}:{success:!1,error:d.error||"点赞失败"}}catch(r){return console.error("Error liking plugin:",r),{success:!1,error:"网络错误"}}}async function pC(a,l){try{const r=l||Ax(),c=await fetch(`${Nc}/stats/dislike`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:a,user_id:r})}),d=await c.json();return c.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:c.ok?{success:!0,...d}:{success:!1,error:d.error||"点踩失败"}}catch(r){return console.error("Error disliking plugin:",r),{success:!1,error:"网络错误"}}}async function gC(a,l,r,c){if(l<1||l>5)return{success:!1,error:"评分必须在 1-5 之间"};try{const d=c||Ax(),m=await fetch(`${Nc}/stats/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:a,rating:l,comment:r,user_id:d})}),h=await m.json();return m.status===429?{success:!1,error:"每天最多评分 3 次"}:m.ok?{success:!0,...h}:{success:!1,error:h.error||"评分失败"}}catch(d){return console.error("Error rating plugin:",d),{success:!1,error:"网络错误"}}}async function yN(a){try{const l=await fetch(`${Nc}/stats/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:a})}),r=await l.json();return l.status===429?(console.warn("Download recording rate limited"),{success:!0}):l.ok?{success:!0,...r}:(console.error("Failed to record download:",r.error),{success:!1,error:r.error})}catch(l){return console.error("Error recording download:",l),{success:!1,error:"网络错误"}}}function jC(){const a=navigator,l=[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,a.deviceMemory||0].join("|");let r=0;for(let c=0;c<l.length;c++){const d=l.charCodeAt(c);r=(r<<5)-r+d,r=r&r}return`fp_${Math.abs(r).toString(36)}`}function Ax(){const a="maibot_user_id";let l=localStorage.getItem(a);if(!l){const r=jC(),c=Date.now().toString(36),d=Math.random().toString(36).substring(2,15);l=`${r}_${c}_${d}`,localStorage.setItem(a,l)}return l}const vC={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function NC(){return e.jsx(lr,{children:e.jsx(bC,{})})}function bC(){const a=ha(),{triggerRestart:l,isRestarting:r}=Tn(),[c,d]=u.useState(""),[m,h]=u.useState("all"),[f,p]=u.useState("all"),[g,N]=u.useState(!0),[j,b]=u.useState([]),[y,w]=u.useState(!0),[z,M]=u.useState(null),[S,F]=u.useState(null),[E,C]=u.useState(null),[R,H]=u.useState(null),[,O]=u.useState([]),[X,L]=u.useState({}),[me,Ne]=u.useState(!1),[je,ce]=u.useState(null),[ge,pe]=u.useState("main"),[D,Q]=u.useState(""),[B,ue]=u.useState("preset"),[Y,we]=u.useState(!1),{toast:fe}=nt(),Ee=async J=>{const Z=J.map(async De=>{try{const xe=await bN(De.id);return{id:De.id,stats:xe}}catch(xe){return console.warn(`Failed to load stats for ${De.id}:`,xe),{id:De.id,stats:null}}}),Le=await Promise.all(Z),le={};Le.forEach(({id:De,stats:xe})=>{xe&&(le[De]=xe)}),L(le)};u.useEffect(()=>{let J=null,Z=!1;return(async()=>{if(J=await iC(le=>{Z||(C(le),le.stage==="success"?setTimeout(()=>{Z||C(null)},2e3):le.stage==="error"&&(w(!1),M(le.error||"加载失败")))},le=>{console.error("WebSocket error:",le),Z||fe({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise(le=>{if(!J){le();return}const De=()=>{J&&J.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),le()):J&&J.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),le()):setTimeout(De,100)};De()}),!Z){const le=await fN();F(le),le.installed||fe({title:"Git 未安装",description:le.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!Z){const le=await pN();H(le)}if(!Z)try{w(!0),M(null);const le=await nC();if(!Z){const De=await Il();O(De);const xe=le.map(Me=>{const ds=bn(Me.id,De),Ts=yn(Me.id,De);return{...Me,installed:ds,installed_version:Ts}});for(const Me of De)!xe.some(Ts=>Ts.id===Me.id)&&Me.manifest&&xe.push({id:Me.id,manifest:{manifest_version:Me.manifest.manifest_version||1,name:Me.manifest.name,version:Me.manifest.version,description:Me.manifest.description||"",author:Me.manifest.author,license:Me.manifest.license||"Unknown",host_application:Me.manifest.host_application,homepage_url:Me.manifest.homepage_url,repository_url:Me.manifest.repository_url,keywords:Me.manifest.keywords||[],categories:Me.manifest.categories||[],default_locale:Me.manifest.default_locale||"zh-CN",locales_path:Me.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:Me.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});b(xe),Ee(xe)}}catch(le){if(!Z){const De=le instanceof Error?le.message:"加载插件列表失败";M(De),fe({title:"加载失败",description:De,variant:"destructive"})}}finally{Z||w(!1)}})(),()=>{Z=!0,J&&J.close()}},[fe]);const G=J=>{if(!J.installed&&R&&!$(J))return e.jsxs(Ce,{variant:"destructive",className:"gap-1",children:[e.jsx(Rt,{className:"h-3 w-3"}),"不兼容"]});if(J.installed){const Z=J.installed_version?.trim(),Le=J.manifest.version?.trim();if(Z!==Le){const le=Z?.split(".").map(Number)||[0,0,0],De=Le?.split(".").map(Number)||[0,0,0];for(let xe=0;xe<3;xe++){if((De[xe]||0)>(le[xe]||0))return e.jsxs(Ce,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(Rt,{className:"h-3 w-3"}),"可更新"]});if((De[xe]||0)<(le[xe]||0))break}}return e.jsxs(Ce,{variant:"default",className:"gap-1",children:[e.jsx(st,{className:"h-3 w-3"}),"已安装"]})}return null},$=J=>!R||!J.manifest?.host_application?!0:gN(J.manifest.host_application.min_version,J.manifest.host_application.max_version,R),A=J=>{if(!J.installed||!J.installed_version||!J.manifest?.version)return!1;const Z=J.installed_version.trim(),Le=J.manifest.version.trim();if(Z===Le)return!1;const le=Z.split(".").map(Number),De=Le.split(".").map(Number);for(let xe=0;xe<3;xe++){if((De[xe]||0)>(le[xe]||0))return!0;if((De[xe]||0)<(le[xe]||0))return!1}return!1},K=j.filter(J=>{if(!J.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",J.id),!1;const Z=c===""||J.manifest.name?.toLowerCase().includes(c.toLowerCase())||J.manifest.description?.toLowerCase().includes(c.toLowerCase())||J.manifest.keywords&&J.manifest.keywords.some(xe=>xe.toLowerCase().includes(c.toLowerCase())),Le=m==="all"||J.manifest.categories&&J.manifest.categories.includes(m);let le=!0;f==="installed"?le=J.installed===!0:f==="updates"&&(le=J.installed===!0&&A(J));const De=!g||!R||$(J);return Z&&Le&&le&&De}),Re=J=>{if(!S?.installed){fe({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(R&&!$(J)){fe({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}ce(J),pe("main"),Q(""),ue("preset"),we(!1),Ne(!0)},se=async()=>{if(!je)return;const J=B==="custom"?D:ge;if(!J||J.trim()===""){fe({title:"分支名称不能为空",variant:"destructive"});return}try{Ne(!1),await jN(je.id,je.manifest.repository_url||"",J),yN(je.id).catch(Le=>{console.warn("Failed to record download:",Le)}),fe({title:"安装成功",description:`${je.manifest.name} 已成功安装`});const Z=await Il();O(Z),b(Le=>Le.map(le=>{if(le.id===je.id){const De=bn(le.id,Z),xe=yn(le.id,Z);return{...le,installed:De,installed_version:xe}}return le}))}catch(Z){fe({title:"安装失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}finally{ce(null)}},$e=async J=>{try{await vN(J.id),fe({title:"卸载成功",description:`${J.manifest.name} 已成功卸载`});const Z=await Il();O(Z),b(Le=>Le.map(le=>{if(le.id===J.id){const De=bn(le.id,Z),xe=yn(le.id,Z);return{...le,installed:De,installed_version:xe}}return le}))}catch(Z){fe({title:"卸载失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}},cs=async J=>{if(!S?.installed){fe({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const Z=await NN(J.id,J.manifest.repository_url||"","main");fe({title:"更新成功",description:`${J.manifest.name} 已从 ${Z.old_version} 更新到 ${Z.new_version}`});const Le=await Il();O(Le),b(le=>le.map(De=>{if(De.id===J.id){const xe=bn(De.id,Le),Me=yn(De.id,Le);return{...De,installed:xe,installed_version:Me}}return De}))}catch(Z){fe({title:"更新失败",description:Z instanceof Error?Z.message:"未知错误",variant:"destructive"})}};return e.jsx(ts,{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("div",{className:"flex gap-2",children:[e.jsxs(_,{variant:"outline",onClick:()=>l(),disabled:r,children:[e.jsx(hv,{className:`h-4 w-4 mr-2 ${r?"animate-spin":""}`}),"重启麦麦"]}),e.jsxs(_,{onClick:()=>a({to:"/plugin-mirrors"}),children:[e.jsx(K1,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]})]}),e.jsx(Te,{className:"border-blue-200 bg-blue-50 dark:bg-blue-950/20 dark:border-blue-900",children:e.jsx(ze,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-blue-600 flex-shrink-0"}),e.jsxs("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:["安装、卸载或更新插件后,需要",e.jsx("span",{className:"font-semibold",children:"重启麦麦"}),"才能使更改生效"]})]})})}),S&&!S.installed&&e.jsxs(Te,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ut,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(Ue,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(Ns,{className:"text-orange-800 dark:text-orange-200",children:S.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(ze,{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(Te,{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($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索插件...",value:c,onChange:J=>d(J.target.value),className:"pl-9"})]}),e.jsxs(Pe,{value:m,onValueChange:h,children:[e.jsx(Be,{className:"w-full sm:w-[200px]",children:e.jsx(Fe,{placeholder:"选择分类"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"all",children:"全部分类"}),e.jsx(W,{value:"Group Management",children:"群组管理"}),e.jsx(W,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(W,{value:"Utility Tools",children:"实用工具"}),e.jsx(W,{value:"Content Generation",children:"内容生成"}),e.jsx(W,{value:"Multimedia",children:"多媒体"}),e.jsx(W,{value:"External Integration",children:"外部集成"}),e.jsx(W,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(W,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"compatible-only",checked:g,onCheckedChange:J=>N(J===!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(Jt,{value:f,onValueChange:p,className:"w-full",children:e.jsxs(Gt,{className:"grid w-full grid-cols-3",children:[e.jsxs(Xe,{value:"all",children:["全部插件 (",j.filter(J=>{if(!J.manifest)return!1;const Z=c===""||J.manifest.name?.toLowerCase().includes(c.toLowerCase())||J.manifest.description?.toLowerCase().includes(c.toLowerCase())||J.manifest.keywords&&J.manifest.keywords.some(De=>De.toLowerCase().includes(c.toLowerCase())),Le=m==="all"||J.manifest.categories&&J.manifest.categories.includes(m),le=!g||!R||$(J);return Z&&Le&&le}).length,")"]}),e.jsxs(Xe,{value:"installed",children:["已安装 (",j.filter(J=>{if(!J.manifest)return!1;const Z=c===""||J.manifest.name?.toLowerCase().includes(c.toLowerCase())||J.manifest.description?.toLowerCase().includes(c.toLowerCase())||J.manifest.keywords&&J.manifest.keywords.some(De=>De.toLowerCase().includes(c.toLowerCase())),Le=m==="all"||J.manifest.categories&&J.manifest.categories.includes(m),le=!g||!R||$(J);return J.installed&&Z&&Le&&le}).length,")"]}),e.jsxs(Xe,{value:"updates",children:["可更新 (",j.filter(J=>{if(!J.manifest)return!1;const Z=c===""||J.manifest.name?.toLowerCase().includes(c.toLowerCase())||J.manifest.description?.toLowerCase().includes(c.toLowerCase())||J.manifest.keywords&&J.manifest.keywords.some(De=>De.toLowerCase().includes(c.toLowerCase())),Le=m==="all"||J.manifest.categories&&J.manifest.categories.includes(m),le=!g||!R||$(J);return J.installed&&A(J)&&Z&&Le&&le}).length,")"]})]})}),E&&E.stage==="loading"&&E.operation==="fetch"&&e.jsx(Te,{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(Fs,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm font-medium",children:"加载插件列表"})]}),e.jsxs("span",{className:"text-sm font-medium",children:[E.progress,"%"]})]}),e.jsx(tr,{value:E.progress,className:"h-2"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:E.message}),E.total_plugins>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["已加载 ",E.loaded_plugins," / ",E.total_plugins," 个插件"]})]})}),E&&E.stage==="error"&&E.error&&e.jsx(Te,{className:"border-destructive bg-destructive/10",children:e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ut,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(Ue,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(Ns,{className:"text-destructive/80",children:E.error})]})]})})}),y?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Fs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):z?e.jsx(Te,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Ut,{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:z}),e.jsx(_,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):K.length===0?e.jsx(Te,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx($t,{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:c||m!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:K.map(J=>e.jsxs(Te,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Ue,{className:"text-xl",children:J.manifest?.name||J.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[J.manifest?.categories&&J.manifest.categories[0]&&e.jsx(Ce,{variant:"secondary",className:"text-xs whitespace-nowrap",children:vC[J.manifest.categories[0]]||J.manifest.categories[0]}),G(J)]})]}),e.jsx(Ns,{className:"line-clamp-2",children:J.manifest?.description||"无描述"})]}),e.jsx(ze,{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(na,{className:"h-4 w-4"}),e.jsx("span",{children:(X[J.id]?.downloads??J.downloads??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(vn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:(X[J.id]?.rating??J.rating??0).toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[J.manifest?.keywords&&J.manifest.keywords.slice(0,3).map(Z=>e.jsx(Ce,{variant:"outline",className:"text-xs",children:Z},Z)),J.manifest?.keywords&&J.manifest.keywords.length>3&&e.jsxs(Ce,{variant:"outline",className:"text-xs",children:["+",J.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",J.manifest?.version||"unknown"," · ",J.manifest?.author?.name||"Unknown"]}),J.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[J.manifest.host_application.min_version,J.manifest.host_application.max_version?` - ${J.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(od,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>a({to:"/plugin-detail",search:{pluginId:J.id}}),children:"查看详情"}),J.installed?A(J)?e.jsxs(_,{size:"sm",disabled:!S?.installed,title:S?.installed?void 0:"Git 未安装",onClick:()=>cs(J),children:[e.jsx(dt,{className:"h-4 w-4 mr-1"}),"更新"]}):e.jsxs(_,{variant:"destructive",size:"sm",disabled:!S?.installed,title:S?.installed?void 0:"Git 未安装",onClick:()=>$e(J),children:[e.jsx(os,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(_,{size:"sm",disabled:!S?.installed||E?.operation==="install"||R!==null&&!$(J),title:S?.installed?R!==null&&!$(J)?`不兼容当前版本 (需要 ${J.manifest?.host_application?.min_version||"未知"}${J.manifest?.host_application?.max_version?` - ${J.manifest.host_application.max_version}`:"+"},当前 ${R?.version})`:void 0:"Git 未安装",onClick:()=>Re(J),children:[e.jsx(na,{className:"h-4 w-4 mr-1"}),E?.operation==="install"&&E?.plugin_id===J.id?"安装中...":"安装"]})]})}),E&&(E.stage==="loading"||E.stage==="success"||E.stage==="error")&&E.operation!=="fetch"&&E.plugin_id===J.id&&e.jsx("div",{className:"px-6 pb-4 -mt-2",children:e.jsxs("div",{className:`space-y-2 p-3 rounded-lg border ${E.stage==="success"?"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-900":E.stage==="error"?"bg-red-50 dark:bg-red-950/20 border-red-200 dark:border-red-900":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[E.stage==="loading"?e.jsx(Fs,{className:"h-3 w-3 animate-spin"}):E.stage==="success"?e.jsx(st,{className:"h-3 w-3 text-green-600"}):e.jsx(Rt,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:`text-xs font-medium ${E.stage==="success"?"text-green-700 dark:text-green-300":E.stage==="error"?"text-red-700 dark:text-red-300":""}`,children:E.stage==="loading"?e.jsxs(e.Fragment,{children:[E.operation==="install"&&"正在安装",E.operation==="uninstall"&&"正在卸载",E.operation==="update"&&"正在更新"]}):E.stage==="success"?e.jsxs(e.Fragment,{children:[E.operation==="install"&&"安装完成",E.operation==="uninstall"&&"卸载完成",E.operation==="update"&&"更新完成"]}):e.jsxs(e.Fragment,{children:[E.operation==="install"&&"安装失败",E.operation==="uninstall"&&"卸载失败",E.operation==="update"&&"更新失败"]})})]}),E.stage!=="error"&&e.jsxs("span",{className:`text-xs font-medium ${E.stage==="success"?"text-green-700 dark:text-green-300":""}`,children:[E.progress,"%"]})]}),E.stage!=="error"&&e.jsx(tr,{value:E.progress,className:`h-1.5 ${E.stage==="success"?"[&>div]:bg-green-500":""}`}),e.jsx("div",{className:`text-xs ${E.stage==="success"?"text-green-600 dark:text-green-400 truncate":E.stage==="error"?"text-red-600 dark:text-red-400":"text-muted-foreground truncate"}`,children:E.stage==="error"?E.error||E.message||"操作失败":E.message})]})})]},J.id))}),e.jsx(Qs,{open:me,onOpenChange:Ne,children:e.jsxs(Hs,{children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"安装插件"}),e.jsxs(at,{children:["安装 ",je?.manifest.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["版本: ",je?.manifest.version]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["作者: ",typeof je?.manifest.author=="string"?je.manifest.author:je?.manifest.author?.name]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"advanced-options",checked:Y,onCheckedChange:J=>we(J)}),e.jsx("label",{htmlFor:"advanced-options",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"高级选项"})]}),Y&&e.jsx("div",{className:"space-y-4 p-4 border rounded-lg",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"分支选择"}),e.jsxs(Jt,{value:B,onValueChange:J=>ue(J),children:[e.jsxs(Gt,{className:"grid w-full grid-cols-2",children:[e.jsx(Xe,{value:"preset",className:"text-xs",children:"预设分支"}),e.jsx(Xe,{value:"custom",className:"text-xs",children:"自定义分支"})]}),B==="preset"&&e.jsx("div",{className:"mt-3",children:e.jsxs(Pe,{value:ge,onValueChange:pe,children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:"选择分支"})}),e.jsxs(Ie,{children:[e.jsx(W,{value:"main",children:"main (默认)"}),e.jsx(W,{value:"master",children:"master"}),e.jsx(W,{value:"dev",children:"dev (开发版)"}),e.jsx(W,{value:"develop",children:"develop"}),e.jsx(W,{value:"beta",children:"beta (测试版)"}),e.jsx(W,{value:"stable",children:"stable (稳定版)"})]})]})}),B==="custom"&&e.jsxs("div",{className:"space-y-2 mt-3",children:[e.jsx("input",{type:"text",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",placeholder:"输入分支名称,例如: feature/new-feature",value:D,onChange:J=>Q(J.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"输入 Git 分支名称、标签或提交哈希"})]})]})]})}),!Y&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"将从默认分支 (main) 安装插件"})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>Ne(!1),children:"取消"}),e.jsxs(_,{onClick:se,children:[e.jsx(na,{className:"h-4 w-4 mr-2"}),"安装"]})]})]})}),e.jsx(nr,{})]})})}function yC(){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(fv,{className:"h-8 w-8",strokeWidth:2}),"模型分配预设市场"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"浏览和下载社区共享的模型分配预设配置"})]})})}),e.jsx(ts,{className:"flex-1",children:e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-12rem)]",children:e.jsxs(Te,{className:"max-w-2xl w-full border-dashed",children:[e.jsxs(Oe,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(xa,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Ue,{className:"text-2xl",children:"功能开发中"}),e.jsx(Ns,{className:"text-base",children:"模型分配预设市场功能正在开发中,敬请期待!"})]}),e.jsx(ze,{children:e.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsx("p",{className:"font-medium text-foreground",children:"📦 即将推出的功能:"}),e.jsxs("ul",{className:"space-y-2 ml-6",children:[e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"浏览社区共享的模型分配预设配置"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"一键下载和应用预设配置"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"分享自己的模型分配方案"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"预设配置评分和评论系统"})]}),e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"mr-2",children:"•"}),e.jsx("span",{children:"根据使用场景智能推荐配置"})]})]})]})})]})})})]})}function wC({field:a,value:l,onChange:r}){const[c,d]=u.useState(!1);switch(a.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(T,{children:a.label}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]}),e.jsx(Ge,{checked:!!l,onCheckedChange:r,disabled:a.disabled})]});case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:a.label}),e.jsx(ne,{type:"number",value:l??a.default,onChange:m=>r(parseFloat(m.target.value)||0),min:a.min,max:a.max,step:a.step??1,placeholder:a.placeholder,disabled:a.disabled}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]});case"slider":return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{children:a.label}),e.jsx("span",{className:"text-sm text-muted-foreground",children:l??a.default})]}),e.jsx(el,{value:[l??a.default],onValueChange:m=>r(m[0]),min:a.min??0,max:a.max??100,step:a.step??1,disabled:a.disabled}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]});case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:a.label}),e.jsxs(Pe,{value:String(l??a.default),onValueChange:r,disabled:a.disabled,children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:a.placeholder??"请选择"})}),e.jsx(Ie,{children:a.choices?.map(m=>e.jsx(W,{value:String(m),children:String(m)},String(m)))})]}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]});case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:a.label}),e.jsx(pt,{value:l??a.default,onChange:m=>r(m.target.value),placeholder:a.placeholder,rows:a.rows??3,disabled:a.disabled}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]});case"password":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:a.label}),e.jsxs("div",{className:"relative",children:[e.jsx(ne,{type:c?"text":"password",value:l??"",onChange:m=>r(m.target.value),placeholder:a.placeholder,disabled:a.disabled,className:"pr-10"}),e.jsx(_,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3",onClick:()=>d(!c),children:c?e.jsx(ic,{className:"h-4 w-4"}):e.jsx(ua,{className:"h-4 w-4"})})]}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]});case"list":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:a.label}),e.jsx(TS,{value:Array.isArray(l)?l:[],onChange:m=>r(m),itemType:a.item_type??"string",itemFields:a.item_fields,minItems:a.min_items,maxItems:a.max_items,disabled:a.disabled,placeholder:a.placeholder}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]});case"text":default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:a.label}),e.jsx(ne,{type:"text",value:l??a.default??"",onChange:m=>r(m.target.value),placeholder:a.placeholder,maxLength:a.max_length,disabled:a.disabled}),a.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a.hint})]})}}function lj({section:a,config:l,onChange:r}){const[c,d]=u.useState(!a.collapsed),m=Object.entries(a.fields).filter(([,h])=>!h.hidden).sort(([,h],[,f])=>h.order-f.order);return e.jsx(xc,{open:c,onOpenChange:d,children:e.jsxs(Te,{children:[e.jsx(hc,{asChild:!0,children:e.jsxs(Oe,{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:[c?e.jsx(Ba,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ra,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Ue,{className:"text-lg",children:a.title})]}),e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:[m.length," 项"]})]}),a.description&&e.jsx(Ns,{className:"ml-6",children:a.description})]})}),e.jsx(fc,{children:e.jsx(ze,{className:"space-y-4 pt-0",children:m.map(([h,f])=>e.jsx(wC,{field:f,value:l[a.name]?.[h],onChange:p=>r(a.name,h,p),sectionName:a.name},h))})})]})})}function _C({plugin:a,onBack:l}){const{toast:r}=nt(),{triggerRestart:c,isRestarting:d}=Tn(),[m,h]=u.useState("visual"),[f,p]=u.useState(null),[g,N]=u.useState({}),[j,b]=u.useState({}),[y,w]=u.useState(""),[z,M]=u.useState(""),[S,F]=u.useState(!0),[E,C]=u.useState(!1),[R,H]=u.useState(!1),[O,X]=u.useState(!1),[L,me]=u.useState(!1),Ne=u.useCallback(async()=>{F(!0);try{const[B,ue,Y]=await Promise.all([cC(a.id),oC(a.id),dC(a.id)]);p(B),N(ue),b(JSON.parse(JSON.stringify(ue))),w(Y),M(Y)}catch(B){r({title:"加载配置失败",description:B instanceof Error?B.message:"未知错误",variant:"destructive"})}finally{F(!1)}},[a.id,r]);u.useEffect(()=>{Ne()},[Ne]),u.useEffect(()=>{H(m==="visual"?JSON.stringify(g)!==JSON.stringify(j):y!==z)},[g,j,y,z,m]);const je=(B,ue,Y)=>{N(we=>({...we,[B]:{...we[B]||{},[ue]:Y}}))},ce=async()=>{C(!0);try{if(m==="source"){try{_x(y)}catch(B){X(!0),r({title:"TOML 格式错误",description:B instanceof Error?B.message:"无法解析 TOML 配置,请检查语法",variant:"destructive"}),C(!1);return}await mC(a.id,y),M(y),X(!1)}else await uC(a.id,g),b(JSON.parse(JSON.stringify(g)));r({title:"配置已保存",description:"更改将在插件重新加载后生效"})}catch(B){r({title:"保存失败",description:B instanceof Error?B.message:"未知错误",variant:"destructive"})}finally{C(!1)}},ge=async()=>{try{await xC(a.id),r({title:"配置已重置",description:"下次加载插件时将使用默认配置"}),me(!1),Ne()}catch(B){r({title:"重置失败",description:B instanceof Error?B.message:"未知错误",variant:"destructive"})}},pe=async()=>{try{const B=await hC(a.id);r({title:B.message,description:B.note}),Ne()}catch(B){r({title:"切换状态失败",description:B instanceof Error?B.message:"未知错误",variant:"destructive"})}};if(S)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(Fs,{className:"h-8 w-8 animate-spin text-muted-foreground"})});if(!f)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-64 space-y-4",children:[e.jsx(Rt,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"无法加载配置"}),e.jsxs(_,{onClick:l,variant:"outline",children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"返回"]})]});const D=Object.values(f.sections).sort((B,ue)=>B.order-ue.order),Q=g.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(_,{variant:"ghost",size:"icon",onClick:l,children:e.jsx($a,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:f.plugin_info.name||a.manifest.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Ce,{variant:Q?"default":"secondary",children:Q?"已启用":"已禁用"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",f.plugin_info.version||a.manifest.version]})]})]})]}),e.jsxs("div",{className:"flex gap-2 ml-10 sm:ml-0",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>h(m==="visual"?"source":"visual"),children:m==="visual"?e.jsxs(e.Fragment,{children:[e.jsx(dx,{className:"h-4 w-4 mr-2"}),"源代码"]}):e.jsxs(e.Fragment,{children:[e.jsx(uv,{className:"h-4 w-4 mr-2"}),"可视化"]})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>c(),disabled:d,children:[e.jsx(hv,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"重启麦麦"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:pe,children:[e.jsx(pc,{className:"h-4 w-4 mr-2"}),Q?"禁用":"启用"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>me(!0),children:[e.jsx(rc,{className:"h-4 w-4 mr-2"}),"重置"]}),e.jsxs(_,{size:"sm",onClick:ce,disabled:!R||E,children:[E?e.jsx(Fs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(gc,{className:"h-4 w-4 mr-2"}),"保存"]})]})]}),R&&e.jsx(Te,{className:"border-orange-200 bg-orange-50 dark:bg-orange-950/20 dark:border-orange-900",children:e.jsx(ze,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-orange-600"}),e.jsx("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:"有未保存的更改"})]})})}),m==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ht,{children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsxs(ft,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。保存时会验证格式,只有格式正确才能保存。",O&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(Qv,{value:y,onChange:B=>{w(B),O&&X(!1)},language:"toml",theme:"dark",height:"calc(100vh - 350px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),m==="visual"&&e.jsxs(e.Fragment,{children:[e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsxs(ft,{children:[e.jsx("strong",{children:"提示:"}),"如果插件当前未加载或未启用,WebUI 适配器的高级插件可视化编辑功能可能会不可用。 请确保插件已启用并成功加载后,再进行配置编辑。"]})]}),f.layout.type==="tabs"&&f.layout.tabs.length>0?e.jsxs(Jt,{defaultValue:f.layout.tabs[0]?.id,children:[e.jsx(Gt,{children:f.layout.tabs.map(B=>e.jsxs(Xe,{value:B.id,children:[B.title,B.badge&&e.jsx(Ce,{variant:"secondary",className:"ml-2 text-xs",children:B.badge})]},B.id))}),f.layout.tabs.map(B=>e.jsx(Ss,{value:B.id,className:"space-y-4 mt-4",children:B.sections.map(ue=>{const Y=f.sections[ue];return Y?e.jsx(lj,{section:Y,config:g,onChange:je},ue):null})},B.id))]}):e.jsx("div",{className:"space-y-4",children:D.map(B=>e.jsx(lj,{section:B,config:g,onChange:je},B.name))})]}),e.jsx(Qs,{open:L,onOpenChange:me,children:e.jsxs(Hs,{children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"确认重置配置"}),e.jsx(at,{children:"这将删除当前配置文件,下次加载插件时将使用默认配置。此操作不可撤销。"})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>me(!1),children:"取消"}),e.jsx(_,{variant:"destructive",onClick:ge,children:"确认重置"})]})]})})]})}function SC(){return e.jsx(lr,{children:e.jsx(kC,{})})}function kC(){const{toast:a}=nt(),[l,r]=u.useState([]),[c,d]=u.useState(!0),[m,h]=u.useState(""),[f,p]=u.useState(null),g=async()=>{d(!0);try{const w=await Il();r(w)}catch(w){a({title:"加载插件列表失败",description:w instanceof Error?w.message:"未知错误",variant:"destructive"})}finally{d(!1)}};u.useEffect(()=>{g()},[]);const j=l.filter(w=>{const z=m.toLowerCase();return w.id.toLowerCase().includes(z)||w.manifest.name.toLowerCase().includes(z)||w.manifest.description?.toLowerCase().includes(z)}).filter((w,z,M)=>z===M.findIndex(S=>S.id===w.id)),b=l.length,y=0;return f?e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"h-full",children:e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(_C,{plugin:f,onBack:()=>p(null)})})}),e.jsx(nr,{})]}):e.jsx(ts,{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(_,{variant:"outline",size:"sm",onClick:g,children:[e.jsx(dt,{className:`h-4 w-4 mr-2 ${c?"animate-spin":""}`}),"刷新"]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(ze,{children:[e.jsx("div",{className:"text-2xl font-bold",children:l.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:c?"正在加载...":"个插件"})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"已启用"}),e.jsx(st,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(ze,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"运行中的插件"})]})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(Rt,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(ze,{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($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索插件...",value:m,onChange:w=>h(w.target.value),className:"pl-9"})]}),e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"已安装的插件"}),e.jsx(Ns,{children:"点击插件查看和编辑配置"})]}),e.jsx(ze,{children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Fs,{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(xa,{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:m?"没有找到匹配的插件":"暂无已安装的插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m?"尝试其他搜索关键词":"前往插件市场安装插件"})]})]}):e.jsx("div",{className:"space-y-2",children:j.map(w=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>p(w),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(xa,{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:w.manifest.name}),e.jsxs(Ce,{variant:"secondary",className:"text-xs flex-shrink-0",children:["v",w.manifest.version]})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:w.manifest.description||"暂无描述"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(_,{variant:"ghost",size:"sm",children:e.jsx(Sn,{className:"h-4 w-4"})}),e.jsx(ra,{className:"h-4 w-4 text-muted-foreground"})]})]},w.id))})})]})]})})}function CC(){const a=ha(),{toast:l}=nt(),[r,c]=u.useState([]),[d,m]=u.useState(!0),[h,f]=u.useState(null),[p,g]=u.useState(null),[N,j]=u.useState(!1),[b,y]=u.useState(!1),[w,z]=u.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),M=u.useCallback(async()=>{try{m(!0),f(null);const O=await ke("/api/webui/plugins/mirrors");if(!O.ok)throw new Error("获取镜像源列表失败");const X=await O.json();c(X.mirrors||[])}catch(O){const X=O instanceof Error?O.message:"加载镜像源失败";f(X),l({title:"加载失败",description:X,variant:"destructive"})}finally{m(!1)}},[l]);u.useEffect(()=>{M()},[M]);const S=async()=>{try{const O=await ke("/api/webui/plugins/mirrors",{method:"POST",body:JSON.stringify(w)});if(!O.ok){const X=await O.json();throw new Error(X.detail||"添加镜像源失败")}l({title:"添加成功",description:"镜像源已添加"}),j(!1),z({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),M()}catch(O){l({title:"添加失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}},F=async()=>{if(p)try{if(!(await ke(`/api/webui/plugins/mirrors/${p.id}`,{method:"PUT",body:JSON.stringify({name:w.name,raw_prefix:w.raw_prefix,clone_prefix:w.clone_prefix,enabled:w.enabled,priority:w.priority})})).ok)throw new Error("更新镜像源失败");l({title:"更新成功",description:"镜像源已更新"}),y(!1),g(null),M()}catch(O){l({title:"更新失败",description:O instanceof Error?O.message:"未知错误",variant:"destructive"})}},E=async O=>{if(confirm("确定要删除这个镜像源吗?"))try{if(!(await ke(`/api/webui/plugins/mirrors/${O}`,{method:"DELETE"})).ok)throw new Error("删除镜像源失败");l({title:"删除成功",description:"镜像源已删除"}),M()}catch(X){l({title:"删除失败",description:X instanceof Error?X.message:"未知错误",variant:"destructive"})}},C=async O=>{try{if(!(await ke(`/api/webui/plugins/mirrors/${O.id}`,{method:"PUT",body:JSON.stringify({enabled:!O.enabled})})).ok)throw new Error("更新状态失败");M()}catch(X){l({title:"更新失败",description:X instanceof Error?X.message:"未知错误",variant:"destructive"})}},R=O=>{g(O),z({id:O.id,name:O.name,raw_prefix:O.raw_prefix,clone_prefix:O.clone_prefix,enabled:O.enabled,priority:O.priority}),y(!0)},H=async(O,X)=>{const L=X==="up"?O.priority-1:O.priority+1;if(!(L<1))try{if(!(await ke(`/api/webui/plugins/mirrors/${O.id}`,{method:"PUT",body:JSON.stringify({priority:L})})).ok)throw new Error("更新优先级失败");M()}catch(me){l({title:"更新失败",description:me instanceof Error?me.message:"未知错误",variant:"destructive"})}};return e.jsx(ts,{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(_,{variant:"ghost",size:"icon",onClick:()=>a({to:"/plugins"}),children:e.jsx($a,{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(_,{onClick:()=>j(!0),children:[e.jsx(Xs,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),d?e.jsx(Te,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Fs,{className:"h-8 w-8 animate-spin text-primary"})})}):h?e.jsx(Te,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Ut,{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:h}),e.jsx(_,{onClick:M,children:"重新加载"})]})}):e.jsxs(Te,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{children:"状态"}),e.jsx(ns,{children:"名称"}),e.jsx(ns,{children:"ID"}),e.jsx(ns,{children:"优先级"}),e.jsx(ns,{className:"text-right",children:"操作"})]})}),e.jsx(Gl,{children:r.map(O=>e.jsxs(_t,{children:[e.jsx(Ze,{children:e.jsx(Ge,{checked:O.enabled,onCheckedChange:()=>C(O)})}),e.jsx(Ze,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:O.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",O.raw_prefix]})]})}),e.jsx(Ze,{children:e.jsx(Ce,{variant:"outline",children:O.id})}),e.jsx(Ze,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:O.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(_,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>H(O,"up"),disabled:O.priority===1,children:e.jsx(Xr,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>H(O,"down"),children:e.jsx(Ba,{className:"h-3 w-3"})})]})]})}),e.jsx(Ze,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>R(O),children:e.jsx(Zn,{className:"h-4 w-4"})}),e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>E(O.id),children:e.jsx(os,{className:"h-4 w-4 text-destructive"})})]})})]},O.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:r.map(O=>e.jsx(Te,{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:O.name}),O.enabled&&e.jsx(Ce,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(Ce,{variant:"outline",className:"mt-1 text-xs",children:O.id})]}),e.jsx(Ge,{checked:O.enabled,onCheckedChange:()=>C(O)})]}),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:O.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:O.priority})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t",children:[e.jsxs(_,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>R(O),children:[e.jsx(Zn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>H(O,"up"),disabled:O.priority===1,children:e.jsx(Xr,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>H(O,"down"),children:e.jsx(Ba,{className:"h-4 w-4"})}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>E(O.id),children:e.jsx(os,{className:"h-4 w-4"})})]})]})},O.id))})]}),e.jsx(Qs,{open:N,onOpenChange:j,children:e.jsxs(Hs,{className:"max-w-lg",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"添加镜像源"}),e.jsx(at,{children:"添加新的 Git 镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-id",children:"镜像源 ID *"}),e.jsx(ne,{id:"add-id",placeholder:"例如: my-mirror",value:w.id,onChange:O=>z({...w,id:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-name",children:"名称 *"}),e.jsx(ne,{id:"add-name",placeholder:"例如: 我的镜像源",value:w.name,onChange:O=>z({...w,name:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(ne,{id:"add-raw",placeholder:"https://example.com/raw",value:w.raw_prefix,onChange:O=>z({...w,raw_prefix:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(ne,{id:"add-clone",placeholder:"https://example.com/clone",value:w.clone_prefix,onChange:O=>z({...w,clone_prefix:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-priority",children:"优先级"}),e.jsx(ne,{id:"add-priority",type:"number",min:"1",value:w.priority,onChange:O=>z({...w,priority:parseInt(O.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(Ge,{id:"add-enabled",checked:w.enabled,onCheckedChange:O=>z({...w,enabled:O})}),e.jsx(T,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>j(!1),children:"取消"}),e.jsx(_,{onClick:S,children:"添加"})]})]})}),e.jsx(Qs,{open:b,onOpenChange:y,children:e.jsxs(Hs,{className:"max-w-lg",children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"编辑镜像源"}),e.jsx(at,{children:"修改镜像源配置"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"镜像源 ID"}),e.jsx(ne,{value:w.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(ne,{id:"edit-name",value:w.name,onChange:O=>z({...w,name:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(ne,{id:"edit-raw",value:w.raw_prefix,onChange:O=>z({...w,raw_prefix:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(ne,{id:"edit-clone",value:w.clone_prefix,onChange:O=>z({...w,clone_prefix:O.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(ne,{id:"edit-priority",type:"number",min:"1",value:w.priority,onChange:O=>z({...w,priority:parseInt(O.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(Ge,{id:"edit-enabled",checked:w.enabled,onCheckedChange:O=>z({...w,enabled:O})}),e.jsx(T,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>y(!1),children:"取消"}),e.jsx(_,{onClick:F,children:"保存"})]})]})})]})})}function TC({pluginId:a,compact:l=!1}){const[r,c]=u.useState(null),[d,m]=u.useState(!0),[h,f]=u.useState(0),[p,g]=u.useState(""),[N,j]=u.useState(!1),{toast:b}=nt(),y=async()=>{m(!0);const S=await bN(a);S&&c(S),m(!1)};u.useEffect(()=>{y()},[a]);const w=async()=>{const S=await fC(a);S.success?(b({title:"已点赞",description:"感谢你的支持!"}),y()):b({title:"点赞失败",description:S.error||"未知错误",variant:"destructive"})},z=async()=>{const S=await pC(a);S.success?(b({title:"已反馈",description:"感谢你的反馈!"}),y()):b({title:"操作失败",description:S.error||"未知错误",variant:"destructive"})},M=async()=>{if(h===0){b({title:"请选择评分",description:"至少选择 1 颗星",variant:"destructive"});return}const S=await gC(a,h,p||void 0);S.success?(b({title:"评分成功",description:"感谢你的评价!"}),j(!1),f(0),g(""),y()):b({title:"评分失败",description:S.error||"未知错误",variant:"destructive"})};return d?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(na,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(vn,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]})]}):r?l?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(na,{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(vn,{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(Mm,{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(na,{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(vn,{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(Mm,{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(Ag,{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(_,{variant:"outline",size:"sm",onClick:w,children:[e.jsx(Mm,{className:"h-4 w-4 mr-1"}),"点赞"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:z,children:[e.jsx(Ag,{className:"h-4 w-4 mr-1"}),"点踩"]}),e.jsxs(Qs,{open:N,onOpenChange:j,children:[e.jsx(dd,{asChild:!0,children:e.jsxs(_,{variant:"default",size:"sm",children:[e.jsx(vn,{className:"h-4 w-4 mr-1"}),"评分"]})}),e.jsxs(Hs,{children:[e.jsxs(qs,{children:[e.jsx(Vs,{children:"为插件评分"}),e.jsx(at,{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(S=>e.jsx("button",{onClick:()=>f(S),className:"focus:outline-none",children:e.jsx(vn,{className:`h-8 w-8 transition-colors ${S<=h?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-300"}`})},S))}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h===0&&"点击星星进行评分",h===1&&"很差",h===2&&"一般",h===3&&"还行",h===4&&"不错",h===5&&"非常好"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"评论(可选)"}),e.jsx(pt,{value:p,onChange:S=>g(S.target.value),placeholder:"分享你的使用体验...",rows:4,maxLength:500}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 text-right",children:[p.length," / 500"]})]})]}),e.jsxs(gt,{children:[e.jsx(_,{variant:"outline",onClick:()=>j(!1),children:"取消"}),e.jsx(_,{onClick:M,disabled:h===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((S,F)=>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(E=>e.jsx(vn,{className:`h-3 w-3 ${E<=S.rating?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},E))}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(S.created_at).toLocaleDateString()})]}),S.comment&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.comment})]},F))})]})]}):null}const EC={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function MC(){const a=ha(),l=lw({strict:!1}),{toast:r}=nt(),[c,d]=u.useState(null),[m,h]=u.useState(""),[f,p]=u.useState(!0),[g,N]=u.useState(!0),[j,b]=u.useState(null),[y,w]=u.useState(null),[z,M]=u.useState(null),[S,F]=u.useState(!1),[E,C]=u.useState(),[R,H]=u.useState(!1);u.useEffect(()=>{(async()=>{if(!l.pluginId){b("缺少插件 ID"),p(!1);return}try{p(!0),b(null);const ge=await ke("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:"Mai-with-u",repo:"plugin-repo",branch:"main",file_path:"plugin_details.json"})});if(!ge.ok)throw new Error("获取插件列表失败");const pe=await ge.json();if(!pe.success||!pe.data)throw new Error(pe.error||"获取插件列表失败");const Q=JSON.parse(pe.data).find(fe=>fe.id===l.pluginId);if(!Q)throw new Error("未找到该插件");const B={id:Q.id,manifest:Q.manifest,downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()};d(B);const[ue,Y,we]=await Promise.all([fN(),pN(),Il()]);w(ue),M(Y),F(bn(l.pluginId,we)),C(yn(l.pluginId,we))}catch(ge){b(ge instanceof Error?ge.message:"加载失败")}finally{p(!1)}})()},[l.pluginId]),u.useEffect(()=>{(async()=>{if(!c?.manifest?.repository_url){N(!1);return}try{if(N(!0),S&&l.pluginId)try{const Y=await ke(`/api/webui/plugins/local-readme/${l.pluginId}`);if(Y.ok){const we=await Y.json();if(we.success&&we.data){h(we.data),N(!1);return}}}catch(Y){console.log("本地 README 获取失败,尝试远程获取:",Y)}const ge=c.manifest.repository_url.match(/github\.com\/([^/]+)\/([^/\s]+)/);if(!ge){h("无法解析仓库地址");return}const[,pe,D]=ge,Q=D.replace(/\.git$/,""),B=await ke("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:pe,repo:Q,branch:"main",file_path:"README.md"})});if(!B.ok)throw new Error("获取 README 失败");const ue=await B.json();ue.success&&ue.data?h(ue.data):h("该插件暂无 README 文档")}catch(ge){console.error("加载 README 失败:",ge),h("加载 README 失败")}finally{N(!1)}})()},[c,S,l.pluginId]);const O=()=>!c||!S||!E?!1:E!==c.manifest.version,X=()=>!c||!z?!0:gN(c.manifest.host_application.min_version,c.manifest.host_application.max_version,z),L=async()=>{if(!(!c||!y?.installed))try{H(!0),await jN(c.id,c.manifest.repository_url||"","main"),yN(c.id).catch(ge=>{console.warn("Failed to record download:",ge)}),r({title:"安装成功",description:`${c.manifest.name} 已成功安装`});const ce=await Il();F(bn(c.id,ce)),C(yn(c.id,ce))}catch(ce){r({title:"安装失败",description:ce instanceof Error?ce.message:"未知错误",variant:"destructive"})}finally{H(!1)}},me=async()=>{if(c)try{H(!0),await vN(c.id),r({title:"卸载成功",description:`${c.manifest.name} 已成功卸载`});const ce=await Il();F(bn(c.id,ce)),C(yn(c.id,ce))}catch(ce){r({title:"卸载失败",description:ce instanceof Error?ce.message:"未知错误",variant:"destructive"})}finally{H(!1)}},Ne=async()=>{if(!(!c||!y?.installed))try{H(!0);const ce=await NN(c.id,c.manifest.repository_url||"","main");r({title:"更新成功",description:`${c.manifest.name} 已从 ${ce.old_version} 更新到 ${ce.new_version}`});const ge=await Il();F(bn(c.id,ge)),C(yn(c.id,ge))}catch(ce){r({title:"更新失败",description:ce instanceof Error?ce.message:"未知错误",variant:"destructive"})}finally{H(!1)}};if(f)return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>a({to:"/plugins"}),children:e.jsx($a,{className:"h-5 w-5"})}),e.jsx("div",{children:e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件详情"})})]}),e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Fs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件信息中..."})]})]});if(j||!c)return e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>a({to:"/plugins"}),children:e.jsx($a,{className:"h-5 w-5"})}),e.jsx("div",{children:e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件详情"})})]}),e.jsx(Te,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Rt,{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:j}),e.jsx(_,{onClick:()=>a({to:"/plugins"}),children:"返回插件列表"})]})})]});const je=X();return 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",{className:"flex items-center gap-3",children:[e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>a({to:"/plugins"}),className:"shrink-0",children:e.jsx($a,{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-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:c.manifest.name})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:S?e.jsxs(e.Fragment,{children:[O()?e.jsx(_,{disabled:!y?.installed||R,onClick:Ne,title:y?.installed?void 0:"Git 未安装",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-4 w-4 mr-2 animate-spin"}),"更新中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{className:"h-4 w-4 mr-2"}),"更新"]})}):null,e.jsx(_,{variant:"destructive",disabled:!y?.installed||R,onClick:me,title:y?.installed?void 0:"Git 未安装",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-4 w-4 mr-2 animate-spin"}),"卸载中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(os,{className:"h-4 w-4 mr-2"}),"卸载"]})})]}):e.jsx(_,{disabled:!y?.installed||!je||R,onClick:L,title:y?.installed?je?void 0:`不兼容当前版本 (需要 ${c.manifest.host_application.min_version}${c.manifest.host_application.max_version?` - ${c.manifest.host_application.max_version}`:"+"},当前 ${z?.version})`:"Git 未安装",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-4 w-4 mr-2 animate-spin"}),"安装中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(na,{className:"h-4 w-4 mr-2"}),"安装"]})})})]}),e.jsx(ts,{className:"h-[calc(100vh-200px)] sm:h-[calc(100vh-220px)]",children:e.jsxs("div",{className:"space-y-6 pr-4",children:[e.jsx(Te,{children:e.jsx(Oe,{children:e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(Ue,{className:"text-2xl",children:c.manifest.name}),e.jsxs(Ce,{variant:"secondary",className:"text-sm",children:["v",c.manifest.version]}),S&&e.jsxs(Ce,{variant:"default",className:"text-sm",children:[e.jsx(st,{className:"h-3 w-3 mr-1"}),"已安装 ",E&&`(v${E})`]}),O()&&e.jsxs(Ce,{variant:"outline",className:"text-sm border-orange-500 text-orange-500",children:[e.jsx(dt,{className:"h-3 w-3 mr-1"}),"可更新"]}),!je&&e.jsxs(Ce,{variant:"destructive",className:"text-sm",children:[e.jsx(Rt,{className:"h-3 w-3 mr-1"}),"不兼容"]})]}),e.jsx(Ns,{className:"text-base",children:c.manifest.description})]})})})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 space-y-6",children:[e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsx(Ue,{className:"text-lg",children:"统计信息"})}),e.jsx(ze,{children:e.jsx(TC,{pluginId:c.id})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsx(Ue,{className:"text-lg",children:"基本信息"})}),e.jsx(ze,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"作者:"}),e.jsx("span",{className:"font-medium",children:c.manifest.author?.name||"Unknown"}),c.manifest.author?.url&&e.jsx("a",{href:c.manifest.author.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:e.jsx(Io,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"版本:"}),e.jsxs("span",{className:"font-medium",children:["v",c.manifest.version]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ov,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"许可证:"}),e.jsx("span",{className:"font-medium",children:c.manifest.license})]}),c.manifest.homepage_url&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Go,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"主页:"}),e.jsxs("a",{href:c.manifest.homepage_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:["访问",e.jsx(Io,{className:"h-3 w-3"})]})]}),c.manifest.repository_url&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Q1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"仓库:"}),e.jsxs("a",{href:c.manifest.repository_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:["GitHub",e.jsx(Io,{className:"h-3 w-3"})]})]}),e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm mb-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"支持版本:"})]}),e.jsxs("div",{className:"text-sm pl-6 font-medium",children:[c.manifest.host_application.min_version,c.manifest.host_application.max_version?` - ${c.manifest.host_application.max_version}`:" - 最新版本"]})]})]})})]}),(c.manifest.categories||c.manifest.keywords)&&e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsx(Ue,{className:"text-lg",children:"分类与标签"})}),e.jsxs(ze,{className:"space-y-4",children:[c.manifest.categories&&c.manifest.categories.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"分类"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:c.manifest.categories.map(ce=>e.jsx(Ce,{variant:"secondary",children:EC[ce]||ce},ce))})]}),c.manifest.keywords&&c.manifest.keywords.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"标签"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:c.manifest.keywords.map(ce=>e.jsxs(Ce,{variant:"outline",className:"text-xs",children:[e.jsx(cd,{className:"h-3 w-3 mr-1"}),ce]},ce))})]})]})]})]}),e.jsxs(Te,{className:"lg:col-span-2",children:[e.jsx(Oe,{children:e.jsx(Ue,{className:"text-lg",children:"插件说明"})}),e.jsx(ze,{children:e.jsx(ts,{className:"h-[600px] pr-4",children:g?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Fs,{className:"h-6 w-6 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-sm text-muted-foreground",children:"加载说明文档中..."})]}):m?e.jsx(bx,{content:m}):e.jsx("div",{className:"text-center text-muted-foreground py-12",children:"暂无说明文档"})})})]})]})]})})]})}const ec=u.forwardRef(({className:a,...l},r)=>e.jsx(Aj,{ref:r,className:P("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",a),...l}));ec.displayName=Aj.displayName;const AC=u.forwardRef(({className:a,...l},r)=>e.jsx(zj,{ref:r,className:P("aspect-square h-full w-full",a),...l}));AC.displayName=zj.displayName;const sc=u.forwardRef(({className:a,...l},r)=>e.jsx(Rj,{ref:r,className:P("flex h-full w-full items-center justify-center rounded-full bg-muted",a),...l}));sc.displayName=Rj.displayName;function zC(){return"webui_"+Math.random().toString(36).substr(2,9)+"_"+Date.now().toString(36)}function RC(){const a="maibot_webui_user_id";let l=localStorage.getItem(a);return l||(l=zC(),localStorage.setItem(a,l)),l}function DC(){return localStorage.getItem("maibot_webui_user_name")||"WebUI用户"}function OC(a){localStorage.setItem("maibot_webui_user_name",a)}const wN="maibot_webui_virtual_tabs";function LC(){try{const a=localStorage.getItem(wN);if(a)return JSON.parse(a)}catch(a){console.error("[Chat] 加载虚拟标签页失败:",a)}return[]}function nj(a){try{localStorage.setItem(wN,JSON.stringify(a))}catch(l){console.error("[Chat] 保存虚拟标签页失败:",l)}}function UC({segment:a}){switch(a.type){case"text":return e.jsx("span",{className:"whitespace-pre-wrap",children:String(a.data)});case"image":case"emoji":return e.jsx("img",{src:String(a.data),alt:a.type==="emoji"?"表情包":"图片",className:P("rounded-lg max-w-full",a.type==="emoji"?"max-h-32":"max-h-64"),loading:"lazy",onError:l=>{const r=l.target;r.style.display="none",r.parentElement?.insertAdjacentHTML("beforeend",`<span class="text-muted-foreground text-xs">[${a.type==="emoji"?"表情包":"图片"}加载失败]</span>`)}});case"voice":return e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("audio",{controls:!0,src:String(a.data),className:"max-w-[200px] h-8",children:"您的浏览器不支持音频播放"})});case"video":return e.jsx("video",{controls:!0,src:String(a.data),className:"rounded-lg max-w-full max-h-64",children:"您的浏览器不支持视频播放"});case"face":return e.jsxs("span",{className:"text-muted-foreground",children:["[表情:",String(a.data),"]"]});case"music":return e.jsx("span",{className:"text-muted-foreground",children:"[音乐分享]"});case"file":return e.jsxs("span",{className:"text-muted-foreground",children:["[文件: ",String(a.data),"]"]});case"reply":return e.jsx("span",{className:"text-muted-foreground text-xs",children:"[回复消息]"});case"forward":return e.jsx("span",{className:"text-muted-foreground",children:"[转发消息]"});case"unknown":default:return e.jsxs("span",{className:"text-muted-foreground",children:["[",a.original_type||"未知消息","]"]})}}function $C({message:a,isBot:l}){return a.message_type==="rich"&&a.segments&&a.segments.length>0?e.jsx("div",{className:"flex flex-col gap-2",children:a.segments.map((r,c)=>e.jsx(UC,{segment:r},c))}):e.jsx("span",{className:"whitespace-pre-wrap",children:a.content})}function BC(){const a={id:"webui-default",type:"webui",label:"WebUI",messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}},l=()=>{const Ke=LC().map(He=>{const Je=He.virtualConfig;return!Je.groupId&&Je.platform&&Je.userId&&(Je.groupId=`webui_virtual_group_${Je.platform}_${Je.userId}`),{id:He.id,type:"virtual",label:He.label,virtualConfig:Je,messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}}});return[a,...Ke]},[r,c]=u.useState(l),[d,m]=u.useState("webui-default"),h=r.find(V=>V.id===d)||r[0],[f,p]=u.useState(""),[g,N]=u.useState(!1),[j,b]=u.useState(!0),[y,w]=u.useState(DC()),[z,M]=u.useState(!1),[S,F]=u.useState(""),[E,C]=u.useState(!1),[R,H]=u.useState([]),[O,X]=u.useState([]),[L,me]=u.useState(!1),[Ne,je]=u.useState(!1),[ce,ge]=u.useState(""),[pe,D]=u.useState({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),Q=u.useRef(RC()),B=u.useRef(new Map),ue=u.useRef(null),Y=u.useRef(new Map),we=u.useRef(0),fe=u.useRef(new Map),{toast:Ee}=nt(),G=V=>(we.current+=1,`${V}-${Date.now()}-${we.current}-${Math.random().toString(36).substr(2,9)}`),$=u.useCallback((V,Ke)=>{c(He=>He.map(Je=>Je.id===V?{...Je,...Ke}:Je))},[]),A=u.useCallback((V,Ke)=>{c(He=>He.map(Je=>Je.id===V?{...Je,messages:[...Je.messages,Ke]}:Je))},[]),K=u.useCallback(()=>{ue.current?.scrollIntoView({behavior:"smooth"})},[]);u.useEffect(()=>{K()},[h?.messages,K]);const Re=u.useCallback(async()=>{me(!0);try{const V=await ke("/api/chat/platforms");if(console.log("[Chat] 平台列表响应:",V.status,V.headers.get("content-type")),V.ok){const Ke=V.headers.get("content-type");if(Ke&&Ke.includes("application/json")){const He=await V.json();console.log("[Chat] 平台列表数据:",He),H(He.platforms||[])}else{const He=await V.text();console.error("[Chat] 获取平台列表失败: 非 JSON 响应:",He.substring(0,200)),Ee({title:"连接失败",description:"无法连接到后端服务,请确保 MaiBot 已启动",variant:"destructive"})}}else console.error("[Chat] 获取平台列表失败: HTTP",V.status),Ee({title:"获取平台失败",description:`服务器返回错误: ${V.status}`,variant:"destructive"})}catch(V){console.error("[Chat] 获取平台列表失败:",V),Ee({title:"网络错误",description:"无法连接到后端服务",variant:"destructive"})}finally{me(!1)}},[Ee]),se=u.useCallback(async(V,Ke)=>{je(!0);try{const He=new URLSearchParams;V&&He.append("platform",V),Ke&&He.append("search",Ke),He.append("limit","50");const Je=await ke(`/api/chat/persons?${He.toString()}`);if(Je.ok){const Es=Je.headers.get("content-type");if(Es&&Es.includes("application/json")){const ms=await Je.json();X(ms.persons||[])}else console.error("[Chat] 获取用户列表失败: 后端返回非 JSON 响应")}}catch(He){console.error("[Chat] 获取用户列表失败:",He)}finally{je(!1)}},[]);u.useEffect(()=>{pe.platform&&se(pe.platform,ce)},[pe.platform,ce,se]);const $e=u.useCallback(async(V,Ke)=>{b(!0);try{const He=new URLSearchParams;He.append("user_id",Q.current),He.append("limit","50"),Ke&&He.append("group_id",Ke);const Je=`/api/chat/history?${He.toString()}`;console.log("[Chat] 正在加载历史消息:",Je);const Es=await ke(Je);if(Es.ok){const ms=await Es.text();try{const Ms=JSON.parse(ms);if(Ms.messages&&Ms.messages.length>0){const We=Ms.messages.map(rs=>({id:rs.id,type:rs.type,content:rs.content,timestamp:rs.timestamp,sender:{name:rs.sender_name||(rs.is_bot?"麦麦":"WebUI用户"),user_id:rs.user_id,is_bot:rs.is_bot}}));$(V,{messages:We});const Cs=fe.current.get(V)||new Set;We.forEach(rs=>{if(rs.type==="bot"){const is=`bot-${rs.content}-${Math.floor(rs.timestamp*1e3)}`;Cs.add(is)}}),fe.current.set(V,Cs)}}catch(Ms){console.error("[Chat] JSON 解析失败:",Ms)}}}catch(He){console.error("[Chat] 加载历史消息失败:",He)}finally{b(!1)}},[$]),cs=u.useCallback(async(V,Ke,He)=>{const Je=B.current.get(V);if(Je?.readyState===WebSocket.OPEN||Je?.readyState===WebSocket.CONNECTING){console.log(`[Tab ${V}] WebSocket 已存在,跳过连接`);return}N(!0);let Es=null;try{const Cs=await ke("/api/webui/ws-token");if(Cs.ok){const rs=await Cs.json();if(rs.success&&rs.token)Es=rs.token;else{console.warn(`[Tab ${V}] 获取 WebSocket token 失败: ${rs.message||"未登录"}`),N(!1);return}}}catch(Cs){console.error(`[Tab ${V}] 获取 WebSocket token 失败:`,Cs),N(!1);return}if(!Es){N(!1);return}const ms=window.location.protocol==="https:"?"wss:":"ws:",Ms=new URLSearchParams;Ms.append("token",Es),Ke==="virtual"&&He?(Ms.append("user_id",He.userId),Ms.append("user_name",He.userName),Ms.append("platform",He.platform),Ms.append("person_id",He.personId),Ms.append("group_name",He.groupName||"WebUI虚拟群聊"),He.groupId&&Ms.append("group_id",He.groupId)):(Ms.append("user_id",Q.current),Ms.append("user_name",y));const We=`${ms}//${window.location.host}/api/chat/ws?${Ms.toString()}`;console.log(`[Tab ${V}] 正在连接 WebSocket:`,We);try{const Cs=new WebSocket(We);B.current.set(V,Cs),Cs.onopen=()=>{$(V,{isConnected:!0}),N(!1),console.log(`[Tab ${V}] WebSocket 已连接`)},Cs.onmessage=rs=>{try{const is=JSON.parse(rs.data);switch(is.type){case"session_info":$(V,{sessionInfo:{session_id:is.session_id,user_id:is.user_id,user_name:is.user_name,bot_name:is.bot_name}});break;case"system":A(V,{id:G("sys"),type:"system",content:is.content||"",timestamp:is.timestamp||Date.now()/1e3});break;case"user_message":{const ys=is.sender?.user_id,rt=Ke==="virtual"&&He?He.userId:Q.current;console.log(`[Tab ${V}] 收到 user_message, sender: ${ys}, current: ${rt}`);const jt=ys?ys.replace(/^webui_user_/,""):"",Ae=rt?rt.replace(/^webui_user_/,""):"";if(jt&&Ae&&jt===Ae){console.log(`[Tab ${V}] 跳过自己的消息(user_id 匹配)`);break}const Qe=fe.current.get(V)||new Set,As=`user-${is.content}-${Math.floor((is.timestamp||0)*1e3)}`;if(Qe.has(As)){console.log(`[Tab ${V}] 跳过自己的消息(内容去重)`);break}if(Qe.add(As),fe.current.set(V,Qe),Qe.size>100){const mt=Qe.values().next().value;mt&&Qe.delete(mt)}A(V,{id:is.message_id||G("user"),type:"user",content:is.content||"",timestamp:is.timestamp||Date.now()/1e3,sender:is.sender});break}case"bot_message":{$(V,{isTyping:!1});const ys=fe.current.get(V)||new Set,rt=`bot-${is.content}-${Math.floor((is.timestamp||0)*1e3)}`;if(ys.has(rt))break;if(ys.add(rt),fe.current.set(V,ys),ys.size>100){const jt=ys.values().next().value;jt&&ys.delete(jt)}c(jt=>jt.map(Ae=>{if(Ae.id!==V)return Ae;const Qe=Ae.messages.filter(mt=>mt.type!=="thinking"),As={id:G("bot"),type:"bot",content:is.content||"",message_type:is.message_type==="rich"?"rich":"text",segments:is.segments,timestamp:is.timestamp||Date.now()/1e3,sender:is.sender};return{...Ae,messages:[...Qe,As]}}));break}case"typing":$(V,{isTyping:is.is_typing||!1});break;case"error":c(ys=>ys.map(rt=>{if(rt.id!==V)return rt;const jt=rt.messages.filter(Ae=>Ae.type!=="thinking");return{...rt,messages:[...jt,{id:G("error"),type:"error",content:is.content||"发生错误",timestamp:is.timestamp||Date.now()/1e3}]}})),Ee({title:"错误",description:is.content,variant:"destructive"});break;case"pong":break;case"history":{const ys=is.messages||[];if(ys.length>0){const rt=fe.current.get(V)||new Set,jt=ys.map(Ae=>{const Qe=Ae.is_bot||!1,As=Ae.id||G(Qe?"bot":"user"),mt=`${Qe?"bot":"user"}-${Ae.content}-${Math.floor(Ae.timestamp*1e3)}`;return rt.add(mt),{id:As,type:Qe?"bot":"user",content:Ae.content,timestamp:Ae.timestamp,sender:{name:Ae.sender_name||(Qe?"麦麦":"用户"),user_id:Ae.sender_id,is_bot:Qe}}});fe.current.set(V,rt),$(V,{messages:jt}),console.log(`[Tab ${V}] 已加载 ${jt.length} 条历史消息`)}break}default:console.log("未知消息类型:",is.type)}}catch(is){console.error("解析消息失败:",is)}},Cs.onclose=()=>{$(V,{isConnected:!1}),N(!1),B.current.delete(V),console.log(`[Tab ${V}] WebSocket 已断开`);const rs=Y.current.get(V);rs&&clearTimeout(rs);const is=window.setTimeout(()=>{if(!J.current){const ys=r.find(rt=>rt.id===V);ys&&cs(V,ys.type,ys.virtualConfig)}},5e3);Y.current.set(V,is)},Cs.onerror=rs=>{console.error(`[Tab ${V}] WebSocket 错误:`,rs),N(!1)}}catch(Cs){console.error(`[Tab ${V}] 创建 WebSocket 失败:`,Cs),N(!1)}},[y,$,A,Ee,r]),J=u.useRef(!1);u.useEffect(()=>{J.current=!1;const V=B.current,Ke=Y.current,He=fe.current;$e("webui-default");const Je=setTimeout(()=>{J.current||(cs("webui-default","webui"),r.forEach(ms=>{ms.type==="virtual"&&ms.virtualConfig&&(He.set(ms.id,new Set),setTimeout(()=>{J.current||cs(ms.id,"virtual",ms.virtualConfig)},200))}))},100),Es=setInterval(()=>{V.forEach(ms=>{ms.readyState===WebSocket.OPEN&&ms.send(JSON.stringify({type:"ping"}))})},3e4);return()=>{J.current=!0,clearTimeout(Je),clearInterval(Es),Ke.forEach(ms=>{clearTimeout(ms)}),Ke.clear(),V.forEach(ms=>{ms.close()}),V.clear()}},[]);const Z=u.useCallback(()=>{const V=B.current.get(d);if(!f.trim()||!V||V.readyState!==WebSocket.OPEN)return;const Ke=h?.type==="virtual"&&h.virtualConfig?.userName||y,He=f.trim(),Je=Date.now()/1e3;V.send(JSON.stringify({type:"message",content:He,user_name:Ke}));const Es=fe.current.get(d)||new Set,ms=`user-${He}-${Math.floor(Je*1e3)}`;if(Es.add(ms),fe.current.set(d,Es),Es.size>100){const Cs=Es.values().next().value;Cs&&Es.delete(Cs)}const Ms={id:G("user"),type:"user",content:He,timestamp:Je,sender:{name:Ke,is_bot:!1}};A(d,Ms);const We={id:G("thinking"),type:"thinking",content:"",timestamp:Je+.001,sender:{name:h?.sessionInfo.bot_name||"麦麦",is_bot:!0}};A(d,We),p("")},[f,y,d,h,A]),Le=V=>{V.key==="Enter"&&!V.shiftKey&&(V.preventDefault(),Z())},le=()=>{F(y),M(!0)},De=()=>{const V=S.trim()||"WebUI用户";w(V),OC(V),M(!1);const Ke=B.current.get(d);Ke?.readyState===WebSocket.OPEN&&Ke.send(JSON.stringify({type:"update_nickname",user_name:V}))},xe=()=>{F(""),M(!1)},Me=V=>new Date(V*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),ds=()=>{const V=B.current.get(d);V&&(V.close(),B.current.delete(d)),cs(d,h?.type||"webui",h?.virtualConfig)},Ts=()=>{D({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),ge(""),Re(),C(!0)},kt=()=>{if(!pe.platform||!pe.personId){Ee({title:"配置不完整",description:"请选择平台和用户",variant:"destructive"});return}const V=`webui_virtual_group_${pe.platform}_${pe.userId}`,Ke=`virtual-${pe.platform}-${pe.userId}-${Date.now()}`,He=pe.userName||pe.userId,Je={id:Ke,type:"virtual",label:He,virtualConfig:{...pe,groupId:V},messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}};c(Es=>{const ms=[...Es,Je],Ms=ms.filter(We=>We.type==="virtual"&&We.virtualConfig).map(We=>({id:We.id,label:We.label,virtualConfig:We.virtualConfig,createdAt:Date.now()}));return nj(Ms),ms}),m(Ke),C(!1),fe.current.set(Ke,new Set),setTimeout(()=>{cs(Ke,"virtual",pe)},100),Ee({title:"虚拟身份标签页",description:`已创建 ${He} 的对话`})},ia=(V,Ke)=>{if(Ke?.stopPropagation(),V==="webui-default")return;const He=B.current.get(V);He&&(He.close(),B.current.delete(V));const Je=Y.current.get(V);Je&&(clearTimeout(Je),Y.current.delete(V)),fe.current.delete(V),c(Es=>{const ms=Es.filter(We=>We.id!==V),Ms=ms.filter(We=>We.type==="virtual"&&We.virtualConfig).map(We=>({id:We.id,label:We.label,virtualConfig:We.virtualConfig,createdAt:Date.now()}));return nj(Ms),ms}),d===V&&m("webui-default")},ut=V=>{m(V)},Is=V=>{D(Ke=>({...Ke,personId:V.person_id,userId:V.user_id,userName:V.nickname||V.person_name}))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Qs,{open:E,onOpenChange:C,children:e.jsxs(Hs,{className:"sm:max-w-[500px] max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(Am,{className:"h-5 w-5"}),"新建虚拟身份对话"]}),e.jsx(at,{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(T,{className:"flex items-center gap-2",children:[e.jsx(Go,{className:"h-4 w-4"}),"选择平台"]}),e.jsxs(Pe,{value:pe.platform,onValueChange:V=>{D(Ke=>({...Ke,platform:V,personId:"",userId:"",userName:""})),X([])},children:[e.jsx(Be,{disabled:L,children:e.jsx(Fe,{placeholder:L?"加载中...":"选择平台"})}),e.jsx(Ie,{children:R.map(V=>e.jsxs(W,{value:V.platform,children:[V.platform," (",V.count," 人)"]},V.platform))})]})]}),pe.platform&&e.jsxs("div",{className:"space-y-2 flex-1 overflow-hidden flex flex-col",children:[e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(oc,{className:"h-4 w-4"}),"选择用户"]}),e.jsxs("div",{className:"relative",children:[e.jsx($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索用户名...",value:ce,onChange:V=>ge(V.target.value),className:"pl-9"})]}),e.jsx(ts,{className:"h-[250px] border rounded-md",children:e.jsx("div",{className:"p-2",children:Ne?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Fs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):O.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[e.jsx(oc,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"没有找到用户"})]}):e.jsx("div",{className:"space-y-1",children:O.map(V=>e.jsxs("button",{onClick:()=>Is(V),className:P("w-full flex items-center gap-3 p-2 rounded-md text-left transition-colors",pe.personId===V.person_id?"bg-primary text-primary-foreground":"hover:bg-muted"),children:[e.jsx(ec,{className:"h-8 w-8 shrink-0",children:e.jsx(sc,{className:P("text-xs",pe.personId===V.person_id?"bg-primary-foreground/20":"bg-muted"),children:(V.nickname||V.person_name||"?").charAt(0)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium truncate",children:V.nickname||V.person_name}),e.jsxs("div",{className:P("text-xs truncate",pe.personId===V.person_id?"text-primary-foreground/70":"text-muted-foreground"),children:["ID: ",V.user_id,V.is_known&&" · 已认识"]})]})]},V.person_id))})})})]}),pe.personId&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"虚拟群名(可选)"}),e.jsx(ne,{placeholder:"WebUI虚拟群聊",value:pe.groupName,onChange:V=>D(Ke=>({...Ke,groupName:V.target.value}))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦会认为这是一个名为此名称的群聊"})]})]}),e.jsxs(gt,{className:"gap-2 sm:gap-0",children:[e.jsx(_,{variant:"outline",onClick:()=>C(!1),children:"取消"}),e.jsx(_,{onClick:kt,disabled:!pe.platform||!pe.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(V=>e.jsxs("div",{className:P("flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm whitespace-nowrap transition-colors cursor-pointer","hover:bg-muted",d===V.id?"bg-background shadow-sm border":"text-muted-foreground"),onClick:()=>ut(V.id),children:[V.type==="webui"?e.jsx(Ia,{className:"h-3.5 w-3.5"}):e.jsx(Am,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"max-w-[100px] truncate",children:V.label}),e.jsx("span",{className:P("w-1.5 h-1.5 rounded-full",V.isConnected?"bg-green-500":"bg-muted-foreground/50")}),V.id!=="webui-default"&&e.jsx("span",{onClick:Ke=>ia(V.id,Ke),className:"ml-0.5 p-0.5 rounded hover:bg-muted-foreground/20 cursor-pointer",role:"button",tabIndex:0,onKeyDown:Ke=>{(Ke.key==="Enter"||Ke.key===" ")&&(Ke.preventDefault(),ia(V.id,Ke))},children:e.jsx(Sa,{className:"h-3 w-3"})})]},V.id)),e.jsx("button",{onClick:Ts,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(Xs,{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(ec,{className:"h-8 w-8 sm:h-10 sm:w-10 shrink-0",children:e.jsx(sc,{className:"bg-primary/10 text-primary",children:e.jsx(Yn,{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:h?.sessionInfo.bot_name||"麦麦"}),e.jsx("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:h?.isConnected?e.jsxs(e.Fragment,{children:[e.jsx(Y1,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"已连接"})]}):g?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"连接中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(J1,{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:[j&&e.jsx(Fs,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:ds,disabled:g,title:"重新连接",children:e.jsx(dt,{className:P("h-4 w-4",g&&"animate-spin")})})]})]}),e.jsx("div",{className:"hidden sm:flex items-center gap-2 mt-2 text-sm text-muted-foreground",children:h?.type==="virtual"&&h.virtualConfig?e.jsxs(e.Fragment,{children:[e.jsx(Am,{className:"h-3 w-3 text-primary"}),e.jsx("span",{children:"虚拟身份:"}),e.jsx("span",{className:"font-medium text-primary",children:h.virtualConfig.userName}),e.jsxs("span",{className:"text-xs",children:["(",h.virtualConfig.platform,")"]}),h.virtualConfig.groupName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-1",children:"·"}),e.jsxs("span",{className:"text-xs",children:["群:",h.virtualConfig.groupName]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fl,{className:"h-3 w-3"}),e.jsx("span",{children:"当前身份:"}),z?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{value:S,onChange:V=>F(V.target.value),onKeyDown:V=>{V.key==="Enter"&&De(),V.key==="Escape"&&xe()},className:"h-7 w-32",placeholder:"输入昵称",autoFocus:!0}),e.jsx(_,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:De,children:"保存"}),e.jsx(_,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:xe,children:"取消"})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-foreground",children:y}),e.jsx(_,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:le,title:"修改昵称",children:e.jsx(X1,{className:"h-3 w-3"})})]})]})})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(ts,{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:[h?.messages.length===0&&!j&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(Yn,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsxs("p",{className:"text-sm",children:["开始与 ",h?.sessionInfo.bot_name||"麦麦"," 对话吧!"]})]}),h?.messages.map(V=>e.jsxs("div",{className:P("flex gap-2 sm:gap-3",V.type==="user"&&"flex-row-reverse",V.type==="system"&&"justify-center",V.type==="error"&&"justify-center"),children:[V.type==="system"&&e.jsx("div",{className:"text-xs text-muted-foreground bg-muted/50 px-3 py-1 rounded-full max-w-[90%]",children:V.content}),V.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:V.content}),V.type==="thinking"&&e.jsxs(e.Fragment,{children:[e.jsx(ec,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(sc,{className:"bg-primary/10 text-primary",children:e.jsx(Yn,{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:V.sender?.name||h?.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:"思考中..."})]})})]})]}),(V.type==="user"||V.type==="bot")&&e.jsxs(e.Fragment,{children:[e.jsx(ec,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(sc,{className:P("text-xs",V.type==="bot"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:V.type==="bot"?e.jsx(Yn,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}):e.jsx(Fl,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})}),e.jsxs("div",{className:P("flex flex-col gap-1 max-w-[75%] sm:max-w-[70%]",V.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:V.sender?.name||(V.type==="bot"?h?.sessionInfo.bot_name:y)}),e.jsx("span",{children:Me(V.timestamp)})]}),e.jsx("div",{className:P("rounded-2xl px-3 py-2 text-sm break-words",V.type==="bot"?"bg-muted rounded-tl-sm":"bg-primary text-primary-foreground rounded-tr-sm"),children:e.jsx($C,{message:V,isBot:V.type==="bot"})})]})]})]},V.id)),e.jsx("div",{ref:ue})]})})}),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(ne,{value:f,onChange:V=>p(V.target.value),onKeyDown:Le,placeholder:h?.isConnected?"输入消息...":"等待连接...",disabled:!h?.isConnected,className:"flex-1 h-10 sm:h-10"}),e.jsx(_,{onClick:Z,disabled:!h?.isConnected||!f.trim(),size:"icon",className:"h-10 w-10 shrink-0",children:e.jsx(Z1,{className:"h-4 w-4"})})]})})})]})}var zx="Radio",[IC,_N]=ld(zx),[PC,FC]=IC(zx),SN=u.forwardRef((a,l)=>{const{__scopeRadio:r,name:c,checked:d=!1,required:m,disabled:h,value:f="on",onCheck:p,form:g,...N}=a,[j,b]=u.useState(null),y=nd(l,M=>b(M)),w=u.useRef(!1),z=j?g||!!j.closest("form"):!0;return e.jsxs(PC,{scope:r,checked:d,disabled:h,children:[e.jsx(ar.button,{type:"button",role:"radio","aria-checked":d,"data-state":EN(d),"data-disabled":h?"":void 0,disabled:h,value:f,...N,ref:y,onClick:_n(a.onClick,M=>{d||p?.(),z&&(w.current=M.isPropagationStopped(),w.current||M.stopPropagation())})}),z&&e.jsx(TN,{control:j,bubbles:!w.current,name:c,value:f,checked:d,required:m,disabled:h,form:g,style:{transform:"translateX(-100%)"}})]})});SN.displayName=zx;var kN="RadioIndicator",CN=u.forwardRef((a,l)=>{const{__scopeRadio:r,forceMount:c,...d}=a,m=FC(kN,r);return e.jsx(b1,{present:c||m.checked,children:e.jsx(ar.span,{"data-state":EN(m.checked),"data-disabled":m.disabled?"":void 0,...d,ref:l})})});CN.displayName=kN;var HC="RadioBubbleInput",TN=u.forwardRef(({__scopeRadio:a,control:l,checked:r,bubbles:c=!0,...d},m)=>{const h=u.useRef(null),f=nd(h,m),p=y1(r),g=w1(l);return u.useEffect(()=>{const N=h.current;if(!N)return;const j=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(j,"checked").set;if(p!==r&&y){const w=new Event("click",{bubbles:c});y.call(N,r),N.dispatchEvent(w)}},[p,r,c]),e.jsx(ar.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...d,tabIndex:-1,ref:f,style:{...d.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});TN.displayName=HC;function EN(a){return a?"checked":"unchecked"}var qC=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],gd="RadioGroup",[VC]=ld(gd,[Dj,_N]),MN=Dj(),AN=_N(),[GC,KC]=VC(gd),zN=u.forwardRef((a,l)=>{const{__scopeRadioGroup:r,name:c,defaultValue:d,value:m,required:h=!1,disabled:f=!1,orientation:p,dir:g,loop:N=!0,onValueChange:j,...b}=a,y=MN(r),w=Wj(g),[z,M]=ad({prop:m,defaultProp:d??null,onChange:j,caller:gd});return e.jsx(GC,{scope:r,name:c,required:h,disabled:f,value:z,onValueChange:M,children:e.jsx(Rw,{asChild:!0,...y,orientation:p,dir:w,loop:N,children:e.jsx(ar.div,{role:"radiogroup","aria-required":h,"aria-orientation":p,"data-disabled":f?"":void 0,dir:w,...b,ref:l})})})});zN.displayName=gd;var RN="RadioGroupItem",DN=u.forwardRef((a,l)=>{const{__scopeRadioGroup:r,disabled:c,...d}=a,m=KC(RN,r),h=m.disabled||c,f=MN(r),p=AN(r),g=u.useRef(null),N=nd(l,g),j=m.value===d.value,b=u.useRef(!1);return u.useEffect(()=>{const y=z=>{qC.includes(z.key)&&(b.current=!0)},w=()=>b.current=!1;return document.addEventListener("keydown",y),document.addEventListener("keyup",w),()=>{document.removeEventListener("keydown",y),document.removeEventListener("keyup",w)}},[]),e.jsx(Dw,{asChild:!0,...f,focusable:!h,active:j,children:e.jsx(SN,{disabled:h,required:m.required,checked:j,...p,...d,name:m.name,ref:N,onCheck:()=>m.onValueChange(d.value),onKeyDown:_n(y=>{y.key==="Enter"&&y.preventDefault()}),onFocus:_n(d.onFocus,()=>{b.current&&g.current?.click()})})})});DN.displayName=RN;var QC="RadioGroupIndicator",ON=u.forwardRef((a,l)=>{const{__scopeRadioGroup:r,...c}=a,d=AN(r);return e.jsx(CN,{...d,...c,ref:l})});ON.displayName=QC;var LN=zN,UN=DN,YC=ON;const Rx=u.forwardRef(({className:a,...l},r)=>e.jsx(LN,{className:P("grid gap-2",a),...l,ref:r}));Rx.displayName=LN.displayName;const Wo=u.forwardRef(({className:a,...l},r)=>e.jsx(UN,{ref:r,className:P("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",a),...l,children:e.jsx(YC,{className:"flex items-center justify-center",children:e.jsx(Vo,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Wo.displayName=UN.displayName;function JC({question:a,value:l,onChange:r,error:c,disabled:d=!1}){const[m,h]=u.useState(null),f=d||a.readOnly,p=()=>{switch(a.type){case"single":return e.jsx(Rx,{value:l||"",onValueChange:r,disabled:f,className:"space-y-2",children:a.options?.map(g=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wo,{value:g.value,id:`${a.id}-${g.id}`}),e.jsx(T,{htmlFor:`${a.id}-${g.id}`,className:"cursor-pointer font-normal",children:g.label})]},g.id))});case"multiple":{const g=l||[];return e.jsxs("div",{className:"space-y-2",children:[a.options?.map(N=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:`${a.id}-${N.id}`,checked:g.includes(N.value),disabled:f||a.maxSelections!==void 0&&g.length>=a.maxSelections&&!g.includes(N.value),onCheckedChange:j=>{r(j?[...g,N.value]:g.filter(b=>b!==N.value))}}),e.jsx(T,{htmlFor:`${a.id}-${N.id}`,className:"cursor-pointer font-normal",children:N.label})]},N.id)),a.maxSelections&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["最多选择 ",a.maxSelections," 项"]})]})}case"text":return e.jsx(ne,{value:l||"",onChange:g=>r(g.target.value),placeholder:a.placeholder||"请输入...",disabled:f,readOnly:a.readOnly,maxLength:a.maxLength,className:P(a.readOnly&&"bg-muted cursor-not-allowed")});case"textarea":return e.jsxs("div",{className:"space-y-1",children:[e.jsx(pt,{value:l||"",onChange:g=>r(g.target.value),placeholder:a.placeholder||"请输入...",disabled:f,readOnly:a.readOnly,maxLength:a.maxLength,rows:4,className:P(a.readOnly&&"bg-muted cursor-not-allowed")}),a.maxLength&&e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[(l||"").length," / ",a.maxLength]})]});case"rating":{const g=l||0,N=m!==null?m:g;return e.jsxs("div",{className:"flex items-center gap-1",children:[[1,2,3,4,5].map(j=>e.jsx("button",{type:"button",disabled:f,className:P("p-1 transition-colors focus:outline-none focus:ring-2 focus:ring-ring rounded",f&&"cursor-not-allowed opacity-50"),onMouseEnter:()=>!f&&h(j),onMouseLeave:()=>h(null),onClick:()=>!f&&r(j),children:e.jsx(vn,{className:P("h-6 w-6 transition-colors",j<=N?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},j)),g>0&&e.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[g," / 5"]})]})}case"scale":{const g=a.min??1,N=a.max??10,j=a.step??1,b=l??g;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(el,{value:[b],onValueChange:([y])=>r(y),min:g,max:N,step:j,disabled:f}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:a.minLabel||g}),e.jsx("span",{className:"font-medium text-foreground",children:b}),e.jsx("span",{children:a.maxLabel||N})]})]})}case"dropdown":return e.jsxs(Pe,{value:l||"",onValueChange:r,disabled:f,children:[e.jsx(Be,{children:e.jsx(Fe,{placeholder:a.placeholder||"请选择..."})}),e.jsx(Ie,{children:a.options?.map(g=>e.jsx(W,{value:g.value,children:g.label},g.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(T,{className:"text-base font-medium",children:[a.title,a.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description})]}),p(),c&&e.jsx("p",{className:"text-sm text-destructive",children:c})]})}const $N="https://maibot-plugin-stats.maibot-webui.workers.dev";function BN(){const a="maibot_user_id";let l=localStorage.getItem(a);if(!l){const r=Math.random().toString(36).substring(2,10),c=Date.now().toString(36),d=Math.random().toString(36).substring(2,10);l=`fp_${r}_${c}_${d}`,localStorage.setItem(a,l)}return l}async function XC(a,l,r,c){try{const d=c?.userId||BN(),m={surveyId:a,surveyVersion:l,userId:d,answers:r,submittedAt:new Date().toISOString(),allowMultiple:c?.allowMultiple,metadata:{userAgent:navigator.userAgent,language:navigator.language}},h=await fetch(`${$N}/survey/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)}),f=await h.json();return h.status===429?{success:!1,error:"提交过于频繁,请稍后再试"}:h.status===409?{success:!1,error:f.error||"你已经提交过这份问卷了"}:h.ok?{success:!0,submissionId:f.submissionId,message:f.message}:{success:!1,error:f.error||"提交失败"}}catch(d){return console.error("Error submitting survey:",d),{success:!1,error:"网络错误"}}}async function ZC(a,l){try{const r=l||BN(),c=new URLSearchParams({user_id:r,survey_id:a}),d=await fetch(`${$N}/survey/check?${c}`);return d.ok?{success:!0,hasSubmitted:(await d.json()).hasSubmitted}:{success:!1,error:(await d.json()).error||"检查失败"}}catch(r){return console.error("Error checking submission:",r),{success:!1,error:"网络错误"}}}function IN({config:a,initialAnswers:l,onSubmitSuccess:r,onSubmitError:c,showProgress:d=!0,paginateQuestions:m=!1,className:h}){const f=u.useCallback(()=>!l||l.length===0?{}:l.reduce((B,ue)=>(B[ue.questionId]=ue.value,B),{}),[l]),[p,g]=u.useState(()=>f()),[N,j]=u.useState({}),[b,y]=u.useState(0),[w,z]=u.useState(!1),[M,S]=u.useState(!1),[F,E]=u.useState(null),[C,R]=u.useState(null),[H,O]=u.useState(!1),[X,L]=u.useState(!0);u.useEffect(()=>{l&&l.length>0&&g(B=>({...B,...f()}))},[l,f]),u.useEffect(()=>{(async()=>{if(!a.settings?.allowMultiple){const ue=await ZC(a.id);ue.success&&ue.hasSubmitted&&O(!0)}L(!1)})()},[a.id,a.settings?.allowMultiple]);const me=u.useCallback(()=>{const B=new Date;return!(a.settings?.startTime&&new Date(a.settings.startTime)>B||a.settings?.endTime&&new Date(a.settings.endTime)<B)},[a.settings?.startTime,a.settings?.endTime]),Ne=a.questions.filter(B=>{const ue=p[B.id];return ue==null?!1:Array.isArray(ue)?ue.length>0:typeof ue=="string"?ue.trim()!=="":!0}).length,je=Ne/a.questions.length*100,ce=u.useCallback((B,ue)=>{g(Y=>({...Y,[B]:ue})),j(Y=>{const we={...Y};return delete we[B],we})},[]),ge=u.useCallback(()=>{const B={};for(const ue of a.questions){if(ue.required){const Y=p[ue.id];if(Y==null){B[ue.id]="此题为必填项";continue}if(Array.isArray(Y)&&Y.length===0){B[ue.id]="请至少选择一项";continue}if(typeof Y=="string"&&Y.trim()===""){B[ue.id]="此题为必填项";continue}}ue.minLength&&typeof p[ue.id]=="string"&&p[ue.id].length<ue.minLength&&(B[ue.id]=`至少需要 ${ue.minLength} 个字符`)}return j(B),Object.keys(B).length===0},[a.questions,p]),pe=u.useCallback(async()=>{if(!ge()){if(m){const B=a.questions.findIndex(ue=>N[ue.id]);B>=0&&y(B)}return}z(!0),E(null);try{const B=a.questions.filter(Y=>p[Y.id]!==void 0).map(Y=>({questionId:Y.id,value:p[Y.id]})),ue=await XC(a.id,a.version,B,{allowMultiple:a.settings?.allowMultiple});if(ue.success&&ue.submissionId)S(!0),R(ue.submissionId),r?.(ue.submissionId);else{const Y=ue.error||"提交失败";E(Y),c?.(Y)}}catch(B){const ue=B instanceof Error?B.message:"提交失败";E(ue),c?.(ue)}finally{z(!1)}},[ge,m,a,p,N,r,c]),D=u.useCallback(B=>{B>=0&&B<a.questions.length&&y(B)},[a.questions.length]);if(X)return e.jsx(Te,{className:P("w-full max-w-2xl mx-auto",h),children:e.jsx(ze,{className:"py-12 flex items-center justify-center",children:e.jsx(Fs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});if(H&&!a.settings?.allowMultiple)return e.jsxs(Te,{className:P("w-full max-w-2xl mx-auto",h),children:[e.jsx(Oe,{children:e.jsx(Ue,{children:a.title})}),e.jsx(ze,{className:"py-8",children:e.jsxs(ht,{children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsx(ft,{children:"你已经提交过这份问卷了,感谢参与!"})]})})]});if(!me())return e.jsxs(Te,{className:P("w-full max-w-2xl mx-auto",h),children:[e.jsx(Oe,{children:e.jsx(Ue,{children:a.title})}),e.jsx(ze,{className:"py-8",children:e.jsxs(ht,{variant:"destructive",children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsx(ft,{children:"问卷不在有效期内"})]})})]});if(M)return e.jsxs(Te,{className:P("w-full max-w-2xl mx-auto",h),children:[e.jsx(Oe,{children:e.jsxs(Ue,{className:"flex items-center gap-2 text-green-600",children:[e.jsx(st,{className:"h-6 w-6"}),"提交成功"]})}),e.jsxs(ze,{className:"py-8",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:a.settings?.thankYouMessage||"感谢你的参与!"}),C&&e.jsxs("p",{className:"text-center text-xs text-muted-foreground mt-4",children:["提交编号:",C]})]})]});const Q=m?[a.questions[b]]:a.questions;return e.jsxs("div",{className:P("h-full flex flex-col",h),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:a.title}),a.description&&e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:a.description}),d&&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:[Ne," / ",a.questions.length]})]}),e.jsx(tr,{value:je,className:"h-2"})]})]}),e.jsx(ts,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[Q.map((B,ue)=>e.jsxs("div",{className:P("p-4 rounded-lg border bg-card",N[B.id]?"border-destructive bg-destructive/5":"border-border"),children:[m&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:["问题 ",b+1," / ",a.questions.length]}),!m&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:[ue+1,"."]}),e.jsx(JC,{question:B,value:p[B.id],onChange:Y=>ce(B.id,Y),error:N[B.id],disabled:w})]},B.id)),F&&e.jsxs(ht,{variant:"destructive",children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsx(ft,{children:F})]}),e.jsx("div",{className:"flex justify-between items-center py-4",children:m?e.jsxs(e.Fragment,{children:[e.jsxs(_,{variant:"outline",onClick:()=>D(b-1),disabled:b===0||w,children:[e.jsx(Pa,{className:"h-4 w-4 mr-1"}),"上一题"]}),b===a.questions.length-1?e.jsxs(_,{onClick:pe,disabled:w,children:[w&&e.jsx(Fs,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]}):e.jsxs(_,{onClick:()=>D(b+1),disabled:w,children:["下一题",e.jsx(ra,{className:"h-4 w-4 ml-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:Object.keys(N).length>0&&e.jsxs("span",{className:"text-destructive",children:["还有 ",Object.keys(N).length," 个必填项未完成"]})}),e.jsxs(_,{onClick:pe,disabled:w,size:"lg",children:[w&&e.jsx(Fs,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]})]})})]})})]})}const WC={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:"感谢你的反馈!你的意见对我们非常重要,我们会认真考虑每一条建议。"}},e3={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 s3(){const[a,l]=u.useState(!0),r=u.useMemo(()=>JSON.parse(JSON.stringify(WC)),[]);u.useEffect(()=>{l(!1)},[]);const c=u.useMemo(()=>[{questionId:"webui_version",value:`v${ud}`}],[]),d=u.useCallback(h=>{console.log("WebUI Survey submitted:",h)},[]),m=u.useCallback(h=>{console.error("WebUI Survey submission error:",h)},[]);return a?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Fs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r?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(pv,{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(IN,{config:r,initialAnswers:c,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:d,onSubmitError:m})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(ht,{variant:"destructive",className:"max-w-md",children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsx(ft,{children:"无法加载问卷配置"})]}),e.jsx(_,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}function t3(){const[a,l]=u.useState(null),[r,c]=u.useState(!0),[d,m]=u.useState("未知版本");u.useEffect(()=>{(async()=>{try{const j=await V_();m(j.version||"未知版本")}catch(j){console.error("Failed to get MaiBot version:",j),m("获取失败")}const N=JSON.parse(JSON.stringify(e3));l(N),c(!1)})()},[]);const h=u.useMemo(()=>[{questionId:"maibot_version",value:d}],[d]),f=u.useCallback(g=>{console.log("MaiBot Survey submitted:",g)},[]),p=u.useCallback(g=>{console.error("MaiBot Survey submission error:",g)},[]);return r?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Fs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):a?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(pv,{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(IN,{config:a,initialAnswers:h,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:f,onSubmitError:p})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(ht,{variant:"destructive",className:"max-w-md",children:[e.jsx(Rt,{className:"h-4 w-4"}),e.jsx(ft,{children:"无法加载问卷配置"})]}),e.jsx(_,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}async function a3(a=2025){const l=await ke(`/api/webui/annual-report/full?year=${a}`);if(!l.ok){const r=await l.json();throw new Error(r.detail||"获取年度报告失败")}return l.json()}function l3(a,l){if(a.match(/^[a-z]+:\/\//i))return a;if(a.match(/^\/\//))return window.location.protocol+a;if(a.match(/^[a-z]+:/i))return a;const r=document.implementation.createHTMLDocument(),c=r.createElement("base"),d=r.createElement("a");return r.head.appendChild(c),r.body.appendChild(d),l&&(c.href=l),d.href=a,d.href}const n3=(()=>{let a=0;const l=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(a+=1,`u${l()}${a}`)})();function wn(a){const l=[];for(let r=0,c=a.length;r<c;r++)l.push(a[r]);return l}let qr=null;function PN(a={}){return qr||(a.includeStyleProperties?(qr=a.includeStyleProperties,qr):(qr=wn(window.getComputedStyle(document.documentElement)),qr))}function ed(a,l){const c=(a.ownerDocument.defaultView||window).getComputedStyle(a).getPropertyValue(l);return c?parseFloat(c.replace("px","")):0}function r3(a){const l=ed(a,"border-left-width"),r=ed(a,"border-right-width");return a.clientWidth+l+r}function i3(a){const l=ed(a,"border-top-width"),r=ed(a,"border-bottom-width");return a.clientHeight+l+r}function FN(a,l={}){const r=l.width||r3(a),c=l.height||i3(a);return{width:r,height:c}}function c3(){let a,l;try{l=process}catch{}const r=l&&l.env?l.env.devicePixelRatio:null;return r&&(a=parseInt(r,10),Number.isNaN(a)&&(a=1)),a||window.devicePixelRatio||1}const Oa=16384;function o3(a){(a.width>Oa||a.height>Oa)&&(a.width>Oa&&a.height>Oa?a.width>a.height?(a.height*=Oa/a.width,a.width=Oa):(a.width*=Oa/a.height,a.height=Oa):a.width>Oa?(a.height*=Oa/a.width,a.width=Oa):(a.width*=Oa/a.height,a.height=Oa))}function sd(a){return new Promise((l,r)=>{const c=new Image;c.onload=()=>{c.decode().then(()=>{requestAnimationFrame(()=>l(c))})},c.onerror=r,c.crossOrigin="anonymous",c.decoding="async",c.src=a})}async function d3(a){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(a)).then(encodeURIComponent).then(l=>`data:image/svg+xml;charset=utf-8,${l}`)}async function u3(a,l,r){const c="http://www.w3.org/2000/svg",d=document.createElementNS(c,"svg"),m=document.createElementNS(c,"foreignObject");return d.setAttribute("width",`${l}`),d.setAttribute("height",`${r}`),d.setAttribute("viewBox",`0 0 ${l} ${r}`),m.setAttribute("width","100%"),m.setAttribute("height","100%"),m.setAttribute("x","0"),m.setAttribute("y","0"),m.setAttribute("externalResourcesRequired","true"),d.appendChild(m),m.appendChild(a),d3(d)}const _a=(a,l)=>{if(a instanceof l)return!0;const r=Object.getPrototypeOf(a);return r===null?!1:r.constructor.name===l.name||_a(r,l)};function m3(a){const l=a.getPropertyValue("content");return`${a.cssText} content: '${l.replace(/'|"/g,"")}';`}function x3(a,l){return PN(l).map(r=>{const c=a.getPropertyValue(r),d=a.getPropertyPriority(r);return`${r}: ${c}${d?" !important":""};`}).join(" ")}function h3(a,l,r,c){const d=`.${a}:${l}`,m=r.cssText?m3(r):x3(r,c);return document.createTextNode(`${d}{${m}}`)}function rj(a,l,r,c){const d=window.getComputedStyle(a,r),m=d.getPropertyValue("content");if(m===""||m==="none")return;const h=n3();try{l.className=`${l.className} ${h}`}catch{return}const f=document.createElement("style");f.appendChild(h3(h,r,d,c)),l.appendChild(f)}function f3(a,l,r){rj(a,l,":before",r),rj(a,l,":after",r)}const ij="application/font-woff",cj="image/jpeg",p3={woff:ij,woff2:ij,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:cj,jpeg:cj,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function g3(a){const l=/\.([^./]*?)$/g.exec(a);return l?l[1]:""}function Dx(a){const l=g3(a).toLowerCase();return p3[l]||""}function j3(a){return a.split(/,/)[1]}function ax(a){return a.search(/^(data:)/)!==-1}function v3(a,l){return`data:${l};base64,${a}`}async function HN(a,l,r){const c=await fetch(a,l);if(c.status===404)throw new Error(`Resource "${c.url}" not found`);const d=await c.blob();return new Promise((m,h)=>{const f=new FileReader;f.onerror=h,f.onloadend=()=>{try{m(r({res:c,result:f.result}))}catch(p){h(p)}},f.readAsDataURL(d)})}const Km={};function N3(a,l,r){let c=a.replace(/\?.*/,"");return r&&(c=a),/ttf|otf|eot|woff2?/i.test(c)&&(c=c.replace(/.*\//,"")),l?`[${l}]${c}`:c}async function Ox(a,l,r){const c=N3(a,l,r.includeQueryParams);if(Km[c]!=null)return Km[c];r.cacheBust&&(a+=(/\?/.test(a)?"&":"?")+new Date().getTime());let d;try{const m=await HN(a,r.fetchRequestInit,({res:h,result:f})=>(l||(l=h.headers.get("Content-Type")||""),j3(f)));d=v3(m,l)}catch(m){d=r.imagePlaceholder||"";let h=`Failed to fetch resource: ${a}`;m&&(h=typeof m=="string"?m:m.message),h&&console.warn(h)}return Km[c]=d,d}async function b3(a){const l=a.toDataURL();return l==="data:,"?a.cloneNode(!1):sd(l)}async function y3(a,l){if(a.currentSrc){const m=document.createElement("canvas"),h=m.getContext("2d");m.width=a.clientWidth,m.height=a.clientHeight,h?.drawImage(a,0,0,m.width,m.height);const f=m.toDataURL();return sd(f)}const r=a.poster,c=Dx(r),d=await Ox(r,c,l);return sd(d)}async function w3(a,l){var r;try{if(!((r=a?.contentDocument)===null||r===void 0)&&r.body)return await jd(a.contentDocument.body,l,!0)}catch{}return a.cloneNode(!1)}async function _3(a,l){return _a(a,HTMLCanvasElement)?b3(a):_a(a,HTMLVideoElement)?y3(a,l):_a(a,HTMLIFrameElement)?w3(a,l):a.cloneNode(qN(a))}const S3=a=>a.tagName!=null&&a.tagName.toUpperCase()==="SLOT",qN=a=>a.tagName!=null&&a.tagName.toUpperCase()==="SVG";async function k3(a,l,r){var c,d;if(qN(l))return l;let m=[];return S3(a)&&a.assignedNodes?m=wn(a.assignedNodes()):_a(a,HTMLIFrameElement)&&(!((c=a.contentDocument)===null||c===void 0)&&c.body)?m=wn(a.contentDocument.body.childNodes):m=wn(((d=a.shadowRoot)!==null&&d!==void 0?d:a).childNodes),m.length===0||_a(a,HTMLVideoElement)||await m.reduce((h,f)=>h.then(()=>jd(f,r)).then(p=>{p&&l.appendChild(p)}),Promise.resolve()),l}function C3(a,l,r){const c=l.style;if(!c)return;const d=window.getComputedStyle(a);d.cssText?(c.cssText=d.cssText,c.transformOrigin=d.transformOrigin):PN(r).forEach(m=>{let h=d.getPropertyValue(m);m==="font-size"&&h.endsWith("px")&&(h=`${Math.floor(parseFloat(h.substring(0,h.length-2)))-.1}px`),_a(a,HTMLIFrameElement)&&m==="display"&&h==="inline"&&(h="block"),m==="d"&&l.getAttribute("d")&&(h=`path(${l.getAttribute("d")})`),c.setProperty(m,h,d.getPropertyPriority(m))})}function T3(a,l){_a(a,HTMLTextAreaElement)&&(l.innerHTML=a.value),_a(a,HTMLInputElement)&&l.setAttribute("value",a.value)}function E3(a,l){if(_a(a,HTMLSelectElement)){const c=Array.from(l.children).find(d=>a.value===d.getAttribute("value"));c&&c.setAttribute("selected","")}}function M3(a,l,r){return _a(l,Element)&&(C3(a,l,r),f3(a,l,r),T3(a,l),E3(a,l)),l}async function A3(a,l){const r=a.querySelectorAll?a.querySelectorAll("use"):[];if(r.length===0)return a;const c={};for(let m=0;m<r.length;m++){const f=r[m].getAttribute("xlink:href");if(f){const p=a.querySelector(f),g=document.querySelector(f);!p&&g&&!c[f]&&(c[f]=await jd(g,l,!0))}}const d=Object.values(c);if(d.length){const m="http://www.w3.org/1999/xhtml",h=document.createElementNS(m,"svg");h.setAttribute("xmlns",m),h.style.position="absolute",h.style.width="0",h.style.height="0",h.style.overflow="hidden",h.style.display="none";const f=document.createElementNS(m,"defs");h.appendChild(f);for(let p=0;p<d.length;p++)f.appendChild(d[p]);a.appendChild(h)}return a}async function jd(a,l,r){return!r&&l.filter&&!l.filter(a)?null:Promise.resolve(a).then(c=>_3(c,l)).then(c=>k3(a,c,l)).then(c=>M3(a,c,l)).then(c=>A3(c,l))}const VN=/url\((['"]?)([^'"]+?)\1\)/g,z3=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,R3=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function D3(a){const l=a.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${l})(['"]?\\))`,"g")}function O3(a){const l=[];return a.replace(VN,(r,c,d)=>(l.push(d),r)),l.filter(r=>!ax(r))}async function L3(a,l,r,c,d){try{const m=r?l3(l,r):l,h=Dx(l);let f;return d||(f=await Ox(m,h,c)),a.replace(D3(l),`$1${f}$3`)}catch{}return a}function U3(a,{preferredFontFormat:l}){return l?a.replace(R3,r=>{for(;;){const[c,,d]=z3.exec(r)||[];if(!d)return"";if(d===l)return`src: ${c};`}}):a}function GN(a){return a.search(VN)!==-1}async function KN(a,l,r){if(!GN(a))return a;const c=U3(a,r);return O3(c).reduce((m,h)=>m.then(f=>L3(f,h,l,r)),Promise.resolve(c))}async function Vr(a,l,r){var c;const d=(c=l.style)===null||c===void 0?void 0:c.getPropertyValue(a);if(d){const m=await KN(d,null,r);return l.style.setProperty(a,m,l.style.getPropertyPriority(a)),!0}return!1}async function $3(a,l){await Vr("background",a,l)||await Vr("background-image",a,l),await Vr("mask",a,l)||await Vr("-webkit-mask",a,l)||await Vr("mask-image",a,l)||await Vr("-webkit-mask-image",a,l)}async function B3(a,l){const r=_a(a,HTMLImageElement);if(!(r&&!ax(a.src))&&!(_a(a,SVGImageElement)&&!ax(a.href.baseVal)))return;const c=r?a.src:a.href.baseVal,d=await Ox(c,Dx(c),l);await new Promise((m,h)=>{a.onload=m,a.onerror=l.onImageErrorHandler?(...p)=>{try{m(l.onImageErrorHandler(...p))}catch(g){h(g)}}:h;const f=a;f.decode&&(f.decode=m),f.loading==="lazy"&&(f.loading="eager"),r?(a.srcset="",a.src=d):a.href.baseVal=d})}async function I3(a,l){const c=wn(a.childNodes).map(d=>QN(d,l));await Promise.all(c).then(()=>a)}async function QN(a,l){_a(a,Element)&&(await $3(a,l),await B3(a,l),await I3(a,l))}function P3(a,l){const{style:r}=a;l.backgroundColor&&(r.backgroundColor=l.backgroundColor),l.width&&(r.width=`${l.width}px`),l.height&&(r.height=`${l.height}px`);const c=l.style;return c!=null&&Object.keys(c).forEach(d=>{r[d]=c[d]}),a}const oj={};async function dj(a){let l=oj[a];if(l!=null)return l;const c=await(await fetch(a)).text();return l={url:a,cssText:c},oj[a]=l,l}async function uj(a,l){let r=a.cssText;const c=/url\(["']?([^"')]+)["']?\)/g,m=(r.match(/url\([^)]+\)/g)||[]).map(async h=>{let f=h.replace(c,"$1");return f.startsWith("https://")||(f=new URL(f,a.url).href),HN(f,l.fetchRequestInit,({result:p})=>(r=r.replace(h,`url(${p})`),[h,p]))});return Promise.all(m).then(()=>r)}function mj(a){if(a==null)return[];const l=[],r=/(\/\*[\s\S]*?\*\/)/gi;let c=a.replace(r,"");const d=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const p=d.exec(c);if(p===null)break;l.push(p[0])}c=c.replace(d,"");const m=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,h="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",f=new RegExp(h,"gi");for(;;){let p=m.exec(c);if(p===null){if(p=f.exec(c),p===null)break;m.lastIndex=f.lastIndex}else f.lastIndex=m.lastIndex;l.push(p[0])}return l}async function F3(a,l){const r=[],c=[];return a.forEach(d=>{if("cssRules"in d)try{wn(d.cssRules||[]).forEach((m,h)=>{if(m.type===CSSRule.IMPORT_RULE){let f=h+1;const p=m.href,g=dj(p).then(N=>uj(N,l)).then(N=>mj(N).forEach(j=>{try{d.insertRule(j,j.startsWith("@import")?f+=1:d.cssRules.length)}catch(b){console.error("Error inserting rule from remote css",{rule:j,error:b})}})).catch(N=>{console.error("Error loading remote css",N.toString())});c.push(g)}})}catch(m){const h=a.find(f=>f.href==null)||document.styleSheets[0];d.href!=null&&c.push(dj(d.href).then(f=>uj(f,l)).then(f=>mj(f).forEach(p=>{h.insertRule(p,h.cssRules.length)})).catch(f=>{console.error("Error loading remote stylesheet",f)})),console.error("Error inlining remote css file",m)}}),Promise.all(c).then(()=>(a.forEach(d=>{if("cssRules"in d)try{wn(d.cssRules||[]).forEach(m=>{r.push(m)})}catch(m){console.error(`Error while reading CSS rules from ${d.href}`,m)}}),r))}function H3(a){return a.filter(l=>l.type===CSSRule.FONT_FACE_RULE).filter(l=>GN(l.style.getPropertyValue("src")))}async function q3(a,l){if(a.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=wn(a.ownerDocument.styleSheets),c=await F3(r,l);return H3(c)}function YN(a){return a.trim().replace(/["']/g,"")}function V3(a){const l=new Set;function r(c){(c.style.fontFamily||getComputedStyle(c).fontFamily).split(",").forEach(m=>{l.add(YN(m))}),Array.from(c.children).forEach(m=>{m instanceof HTMLElement&&r(m)})}return r(a),l}async function G3(a,l){const r=await q3(a,l),c=V3(a);return(await Promise.all(r.filter(m=>c.has(YN(m.style.fontFamily))).map(m=>{const h=m.parentStyleSheet?m.parentStyleSheet.href:null;return KN(m.cssText,h,l)}))).join(`
|
||
`)}async function K3(a,l){const r=l.fontEmbedCSS!=null?l.fontEmbedCSS:l.skipFonts?null:await G3(a,l);if(r){const c=document.createElement("style"),d=document.createTextNode(r);c.appendChild(d),a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c)}}async function Q3(a,l={}){const{width:r,height:c}=FN(a,l),d=await jd(a,l,!0);return await K3(d,l),await QN(d,l),P3(d,l),await u3(d,r,c)}async function Y3(a,l={}){const{width:r,height:c}=FN(a,l),d=await Q3(a,l),m=await sd(d),h=document.createElement("canvas"),f=h.getContext("2d"),p=l.pixelRatio||c3(),g=l.canvasWidth||r,N=l.canvasHeight||c;return h.width=g*p,h.height=N*p,l.skipAutoScale||o3(h),h.style.width=`${g}`,h.style.height=`${N}`,l.backgroundColor&&(f.fillStyle=l.backgroundColor,f.fillRect(0,0,h.width,h.height)),f.drawImage(m,0,0,h.width,h.height),h}async function J3(a,l={}){return(await Y3(a,l)).toDataURL()}const $o=["#0088FE","#00C49F","#FFBB28","#FF8042","#8884d8","#82ca9d"];function X3(a){return a>=8760?"相当于全年无休,7x24小时在线!":a>=5e3?"相当于一位全职员工的年工作时长":a>=2e3?"相当于看完了 1000 部电影":a>=1e3?"相当于环球飞行 80 次":a>=500?"相当于读完了 100 本书":a>=100?"相当于马拉松跑了 25 次":"虽然不多,但每一刻都很珍贵"}function Z3(a){return a>=1e3?"夜深人静时的知心好友":a>=500?"午夜场的常客":a>=100?"偶尔熬夜的小伙伴":a>=50?"深夜有时也会陪你聊聊":"早睡早起,健康作息"}function W3(a){const l=a/1e6;return l>=100?"思考量堪比一座图书馆":l>=50?"相当于写了一部百科全书":l>=10?"脑细胞估计消耗了不少":l>=1?"也算是费了一番脑筋":"轻轻松松,游刃有余"}function e5(a){return a>=1e3?"这钱够吃一年的泡面了":a>=500?"相当于买了一台游戏机":a>=100?"够请大家喝几杯奶茶":a>=50?"一顿火锅的钱":a>=10?"几杯咖啡的价格":"省钱小能手"}function s5(a){return a>=80?"沉默是金,惜字如金":a>=60?"话不多但句句到位":a>=40?"该说的时候才开口":a>=20?"能聊的都聊了":"话痨本痨,有问必答"}function t5(a){return a>=1e4?"眼睛都快看花了":a>=5e3?"堪比专业摄影师的阅片量":a>=1e3?"看图小达人":a>=500?"图片鉴赏家":a>=100?"偶尔欣赏一下美图":"图片?有空再看"}function a5(a){return a>=500?"在不断的纠正中成长":a>=200?"学习永无止境":a>=100?"虚心接受,积极改正":a>=50?"偶尔也会犯错":a>=10?"表现还算不错":"完美表达,无需纠正"}function l5(a){return a>=1?"这次思考的价值堪比一顿大餐!":a>=.5?"为了这个问题,我可是认真思考了!":a>=.1?"下了点功夫,值得的!":a>=.01?"花了点小钱,但很值得":"小小思考,不足挂齿"}function n5(a,l){return a>=100?"这句话简直是万能钥匙!":a>=50?"百试不爽的经典回复":a>=20?`${l}的口头禅`:a>=10?"常用语录之一":"偶尔用用的小确幸"}function r5(a,l){return a?l>=1e3?"深夜的守护者,黑暗中的光芒":l>=500?"月亮是我的好朋友":l>=100?"越夜越精神,夜晚才是主场":"偶尔熬夜,享受宁静时光":l<=10?"作息规律,健康生活的典范":l<=50?"早睡早起,偶尔也会熬个夜":"虽然是早起鸟,但也会守候深夜"}function i5(a){return a>=1e3?"忙到飞起,键盘都要冒烟了":a>=500?"这天简直是话痨附体":a>=200?"社交达人上线":a>=100?"比平时活跃不少":a>=50?"小忙一下":"还算轻松的一天"}function c5(){const[a]=u.useState(2025),[l,r]=u.useState(null),[c,d]=u.useState(!0),[m,h]=u.useState(!1),[f,p]=u.useState(null),g=u.useRef(null),{toast:N}=nt(),j=u.useCallback(async()=>{try{d(!0),p(null);const y=await a3(a);r(y)}catch(y){p(y instanceof Error?y:new Error("获取年度报告失败"))}finally{d(!1)}},[a]),b=u.useCallback(async()=>{if(!(!g.current||!l)){h(!0),N({title:"正在生成图片",description:"请稍候..."});try{const y=g.current,w=getComputedStyle(document.documentElement),z=w.getPropertyValue("--background").trim()?`hsl(${w.getPropertyValue("--background").trim()})`:document.documentElement.classList.contains("dark")?"#0a0a0a":"#ffffff",M=y.style.width,S=y.style.maxWidth;y.style.width="1024px",y.style.maxWidth="1024px";const F=await J3(y,{quality:1,pixelRatio:2,backgroundColor:z,cacheBust:!0,filter:C=>!(C instanceof HTMLElement&&C.hasAttribute("data-export-btn"))});y.style.width=M,y.style.maxWidth=S;const E=document.createElement("a");E.download=`${l.bot_name}_${l.year}_年度总结.png`,E.href=F,E.click(),N({title:"导出成功",description:"年度报告已保存为图片"})}catch(y){console.error("导出图片失败:",y),N({title:"导出失败",description:"请重试",variant:"destructive"})}finally{h(!1)}}},[l,N]);return u.useEffect(()=>{j()},[j]),c?e.jsx(o5,{}):f?e.jsxs("div",{className:"flex h-screen items-center justify-center text-red-500",children:["获取年度报告失败: ",f.message]}):l?e.jsx(ts,{className:"h-[calc(100vh-4rem)]",children:e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-background to-muted/50 p-4 md:p-8 print:p-0",ref:g,children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 print:space-y-4",children:[e.jsxs("header",{className:"relative overflow-hidden rounded-3xl bg-primary p-8 text-primary-foreground shadow-2xl print:rounded-none print:shadow-none",children:[e.jsx("div",{className:"absolute right-4 top-4 z-20 print:hidden","data-export-btn":!0,children:e.jsx(_,{variant:"secondary",size:"sm",onClick:b,disabled:m,className:"gap-2 bg-white/20 hover:bg-white/30 text-white border-white/30",children:m?e.jsxs(e.Fragment,{children:[e.jsx(Fs,{className:"h-4 w-4 animate-spin"}),"导出中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(na,{className:"h-4 w-4"}),"保存图片"]})})}),e.jsxs("div",{className:"relative z-10 flex flex-col items-center text-center",children:[e.jsx(Yn,{className:"mb-4 h-16 w-16 animate-bounce"}),e.jsxs("h1",{className:"text-4xl font-bold tracking-tighter sm:text-6xl",children:[l.bot_name," ",l.year," 年度总结"]}),e.jsx("p",{className:"mt-4 max-w-2xl text-lg opacity-90",children:"连接与成长 · Connection & Growth"}),e.jsxs("div",{className:"mt-6 flex items-center gap-2 text-sm opacity-75",children:[e.jsx(Ko,{className:"h-4 w-4"}),e.jsxs("span",{children:["生成时间: ",l.generated_at]})]})]}),e.jsx("div",{className:"absolute -right-20 -top-20 h-64 w-64 rounded-full bg-white/10 blur-3xl"}),e.jsx("div",{className:"absolute -bottom-20 -left-20 h-64 w-64 rounded-full bg-white/10 blur-3xl"})]}),e.jsxs("section",{className:"space-y-4 break-inside-avoid",children:[e.jsxs("div",{className:"flex items-center gap-2 text-2xl font-bold text-primary",children:[e.jsx(da,{className:"h-8 w-8"}),e.jsx("h2",{children:"时光足迹"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsx(La,{title:"年度在线时长",value:`${l.time_footprint.total_online_hours} 小时`,description:X3(l.time_footprint.total_online_hours),icon:e.jsx(da,{className:"h-4 w-4"})}),e.jsx(La,{title:"最忙碌的一天",value:l.time_footprint.busiest_day||"N/A",description:i5(l.time_footprint.busiest_day_count),icon:e.jsx(Ko,{className:"h-4 w-4"})}),e.jsx(La,{title:"深夜互动 (0-4点)",value:`${l.time_footprint.midnight_chat_count} 次`,description:Z3(l.time_footprint.midnight_chat_count),icon:e.jsx(tc,{className:"h-4 w-4"})}),e.jsx(La,{title:"作息属性",value:l.time_footprint.is_night_owl?"夜猫子":"早起鸟",description:r5(l.time_footprint.is_night_owl,l.time_footprint.midnight_chat_count),icon:l.time_footprint.is_night_owl?e.jsx(tc,{className:"h-4 w-4"}):e.jsx(ix,{className:"h-4 w-4"})})]}),e.jsxs(Te,{className:"overflow-hidden",children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"24小时活跃时钟"}),e.jsxs(Ns,{children:[l.bot_name,"在一天中各个时段的活跃程度"]})]}),e.jsx(ze,{className:"h-[300px]",children:e.jsx(Uj,{width:"100%",height:"100%",children:e.jsxs(Bo,{data:l.time_footprint.hourly_distribution.map((y,w)=>({hour:`${w}点`,count:y})),children:[e.jsx(Ji,{strokeDasharray:"3 3",vertical:!1}),e.jsx(Xi,{dataKey:"hour"}),e.jsx(Gr,{}),e.jsx($j,{contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},cursor:{fill:"transparent"}}),e.jsx(Zi,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})})]}),l.time_footprint.first_message_time&&e.jsx(Te,{className:"bg-muted/30 border-dashed",children:e.jsxs(ze,{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-2",children:"2025年的故事开始于"}),e.jsx("div",{className:"text-xl font-bold text-primary mb-1",children:l.time_footprint.first_message_time}),e.jsxs("p",{className:"text-lg",children:[e.jsx("span",{className:"font-semibold text-foreground",children:l.time_footprint.first_message_user})," 说:",e.jsxs("span",{className:"italic text-muted-foreground",children:['"',l.time_footprint.first_message_content,'"']})]})]})})]}),e.jsxs("section",{className:"space-y-4 break-inside-avoid",children:[e.jsxs("div",{className:"flex items-center gap-2 text-2xl font-bold text-primary",children:[e.jsx(oc,{className:"h-8 w-8"}),e.jsx("h2",{children:"社交网络"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(La,{title:"社交圈子",value:`${l.social_network.total_groups} 个群组`,description:`${l.bot_name}加入的群组总数`,icon:e.jsx(oc,{className:"h-4 w-4"})}),e.jsx(La,{title:"被呼叫次数",value:`${l.social_network.at_count+l.social_network.mentioned_count} 次`,description:"我的名字被大家频繁提起",icon:e.jsx(W1,{className:"h-4 w-4"})}),e.jsx(La,{title:"最长情陪伴",value:l.social_network.longest_companion_user||"N/A",description:`始终都在,已陪伴 ${l.social_network.longest_companion_days} 天`,icon:e.jsx(ei,{className:"h-4 w-4 text-red-500"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsx(Ue,{children:"话痨群组 TOP5"})}),e.jsx(ze,{children:e.jsx("div",{className:"space-y-3",children:l.social_network.top_groups.length>0?l.social_network.top_groups.map((y,w)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ce,{variant:w===0?"default":"secondary",className:"h-6 w-6 rounded-full p-0 flex items-center justify-center shrink-0",children:w+1}),e.jsx("span",{className:"font-medium truncate max-w-[120px]",children:y.group_name}),y.is_webui&&e.jsx(Ce,{variant:"outline",className:"text-xs px-1.5 py-0 h-5 bg-blue-50 text-blue-600 border-blue-200",children:"WebUI"})]}),e.jsxs("span",{className:"text-muted-foreground text-sm shrink-0",children:[y.message_count," 条消息"]})]},y.group_id)):e.jsx("div",{className:"text-center text-muted-foreground py-4",children:"暂无数据"})})})]}),e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsx(Ue,{children:"年度最佳损友 TOP5"})}),e.jsx(ze,{children:e.jsx("div",{className:"space-y-3",children:l.social_network.top_users.length>0?l.social_network.top_users.map((y,w)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ce,{variant:w===0?"default":"secondary",className:"h-6 w-6 rounded-full p-0 flex items-center justify-center shrink-0",children:w+1}),e.jsx("span",{className:"font-medium truncate max-w-[120px]",children:y.user_nickname}),y.is_webui&&e.jsx(Ce,{variant:"outline",className:"text-xs px-1.5 py-0 h-5 bg-blue-50 text-blue-600 border-blue-200",children:"WebUI"})]}),e.jsxs("span",{className:"text-muted-foreground text-sm shrink-0",children:[y.message_count," 次互动"]})]},y.user_id)):e.jsx("div",{className:"text-center text-muted-foreground py-4",children:"暂无数据"})})})]})]})]}),e.jsxs("section",{className:"space-y-4 break-inside-avoid",children:[e.jsxs("div",{className:"flex items-center gap-2 text-2xl font-bold text-primary",children:[e.jsx(hx,{className:"h-8 w-8"}),e.jsx("h2",{children:"最强大脑"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsx(La,{title:"年度 Token 消耗",value:(l.brain_power.total_tokens/1e6).toFixed(2)+" M",description:W3(l.brain_power.total_tokens),icon:e.jsx(sl,{className:"h-4 w-4"})}),e.jsx(La,{title:"年度总花费",value:`$${l.brain_power.total_cost.toFixed(2)}`,description:e5(l.brain_power.total_cost),icon:e.jsx("span",{className:"font-bold",children:"$"})}),e.jsx(La,{title:"高冷指数",value:`${l.brain_power.silence_rate}%`,description:s5(l.brain_power.silence_rate),icon:e.jsx(tc,{className:"h-4 w-4"})}),e.jsx(La,{title:"最高兴趣值",value:l.brain_power.max_interest_value??"N/A",description:l.brain_power.max_interest_time?`出现在 ${l.brain_power.max_interest_time}`:"暂无数据",icon:e.jsx(ei,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Te,{children:[e.jsx(Oe,{children:e.jsx(Ue,{children:"模型偏好分布"})}),e.jsx(ze,{children:e.jsx("div",{className:"space-y-3",children:l.brain_power.model_distribution.slice(0,5).map((y,w)=>{const z=l.brain_power.model_distribution[0]?.count||1,M=Math.round(y.count/z*100);return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"font-medium truncate max-w-[200px]",children:y.model}),e.jsxs("span",{className:"text-muted-foreground",children:[y.count.toLocaleString()," 次"]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:e.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${M}%`,backgroundColor:$o[w%$o.length]}})})]},y.model)})})})]}),l.brain_power.top_reply_models&&l.brain_power.top_reply_models.length>0&&e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"最喜欢的回复模型 TOP5"}),e.jsxs(Ns,{children:[l.bot_name,"用来回复消息的模型偏好"]})]}),e.jsx(ze,{children:e.jsx("div",{className:"space-y-3",children:l.brain_power.top_reply_models.map((y,w)=>{const z=l.brain_power.top_reply_models[0]?.count||1,M=Math.round(y.count/z*100);return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"font-medium truncate max-w-[200px]",children:y.model}),e.jsxs("span",{className:"text-muted-foreground",children:[y.count.toLocaleString()," 次"]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:e.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${M}%`,backgroundColor:$o[w%$o.length]}})})]},y.model)})})})]}),l.brain_power.top_token_consumers&&l.brain_power.top_token_consumers.length>0&&e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"烧钱大户 TOP3"}),e.jsx(Ns,{children:"谁消耗了最多的 API 额度"})]}),e.jsx(ze,{children:e.jsx("div",{className:"space-y-6",children:l.brain_power.top_token_consumers.map(y=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm font-medium",children:[e.jsxs("span",{children:["用户 ",y.user_id]}),e.jsxs("span",{children:["$",y.cost.toFixed(2)]})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-500",style:{width:`${y.cost/(l.brain_power.top_token_consumers[0]?.cost||1)*100}%`}})})]},y.user_id))})})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Te,{className:"bg-gradient-to-br from-amber-50 to-orange-50 dark:from-amber-950/20 dark:to-orange-950/20",children:[e.jsx(Oe,{children:e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"💰"}),"最昂贵的一次思考"]})}),e.jsxs(ze,{className:"text-center",children:[e.jsxs("div",{className:"text-4xl font-bold text-amber-600 dark:text-amber-400",children:["$",l.brain_power.most_expensive_cost.toFixed(4)]}),l.brain_power.most_expensive_time&&e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["发生在 ",l.brain_power.most_expensive_time]}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:l5(l.brain_power.most_expensive_cost)})]})]}),e.jsxs(Te,{className:"bg-gradient-to-br from-indigo-50 to-blue-50 dark:from-indigo-950/20 dark:to-blue-950/20",children:[e.jsx(Oe,{children:e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"🧠"}),"思考深度"]})}),e.jsxs(ze,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-indigo-600 dark:text-indigo-400",children:l.brain_power.avg_reasoning_length?.toFixed(0)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"平均思考字数"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600 dark:text-blue-400",children:l.brain_power.max_reasoning_length?.toLocaleString()||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"最长思考字数"})]})]}),l.brain_power.max_reasoning_time&&e.jsxs("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:["最深沉的思考发生在 ",l.brain_power.max_reasoning_time]})]})]})]})]}),e.jsxs("section",{className:"space-y-4 break-inside-avoid",children:[e.jsxs("div",{className:"flex items-center gap-2 text-2xl font-bold text-primary",children:[e.jsx(rd,{className:"h-8 w-8"}),e.jsx("h2",{children:"个性与表达"})]}),(l.expression_vibe.late_night_reply||l.expression_vibe.favorite_reply)&&e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[l.expression_vibe.late_night_reply&&e.jsxs(Te,{className:"bg-gradient-to-br from-indigo-50 to-violet-50 dark:from-indigo-950/20 dark:to-violet-950/20",children:[e.jsxs(Oe,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"🌙"}),"深夜还在回复"]}),e.jsxs(Ns,{children:["凌晨 ",l.expression_vibe.late_night_reply.time,",",l.bot_name,"还在回复..."]})]}),e.jsxs(ze,{className:"text-center",children:[e.jsxs("p",{className:"text-lg italic text-muted-foreground",children:['"',l.expression_vibe.late_night_reply.content,'"']}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"是有什么心事吗?"})]})]}),l.expression_vibe.favorite_reply&&e.jsxs(Te,{className:"bg-gradient-to-br from-rose-50 to-pink-50 dark:from-rose-950/20 dark:to-pink-950/20",children:[e.jsxs(Oe,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"💬"}),"最喜欢的回复"]}),e.jsxs(Ns,{children:["使用了 ",l.expression_vibe.favorite_reply.count," 次"]})]}),e.jsxs(ze,{className:"text-center",children:[e.jsxs("p",{className:"text-lg font-medium text-primary",children:['"',l.expression_vibe.favorite_reply.content,'"']}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:n5(l.expression_vibe.favorite_reply.count,l.bot_name)})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Te,{className:"bg-gradient-to-br from-pink-50 to-purple-50 dark:from-pink-950/20 dark:to-purple-950/20",children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"使用最多的表情包 TOP3"}),e.jsx(Ns,{children:"年度最爱的表情包们"})]}),e.jsx(ze,{children:l.expression_vibe.top_emojis&&l.expression_vibe.top_emojis.length>0?e.jsx("div",{className:"flex justify-center gap-4",children:l.expression_vibe.top_emojis.slice(0,3).map((y,w)=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:`/api/webui/emoji/${y.id}/thumbnail?original=true`,alt:`TOP ${w+1}`,className:"h-24 w-24 rounded-lg object-cover shadow-md transition-transform hover:scale-105"}),e.jsx(Ce,{className:P("absolute -top-2 -right-2",w===0?"bg-yellow-500":w===1?"bg-gray-400":"bg-amber-700"),children:w+1})]}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[y.usage_count," 次"]})]},y.id))}):e.jsx("div",{className:"flex h-32 items-center justify-center text-muted-foreground",children:"暂无数据"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"印象最深刻的表达风格"}),e.jsxs(Ns,{children:[l.bot_name,"最常使用的表达方式"]})]}),e.jsx(ze,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:l.expression_vibe.top_expressions.map((y,w)=>e.jsxs(Ce,{variant:"outline",className:P("px-3 py-1 text-sm",w===0&&"border-primary bg-primary/10 text-primary text-base px-4 py-2"),children:[y.style," (",y.count,")"]},y.style))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(La,{title:"图片鉴赏",value:`${l.expression_vibe.image_processed_count} 张`,description:t5(l.expression_vibe.image_processed_count),icon:e.jsx(xx,{className:"h-4 w-4"})}),e.jsx(La,{title:"成长的足迹",value:`${l.expression_vibe.rejected_expression_count} 次`,description:a5(l.expression_vibe.rejected_expression_count),icon:e.jsx(sl,{className:"h-4 w-4"})})]})]})]}),l.expression_vibe.action_types.length>0&&e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsxs(Ue,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"⚡"}),"行动派"]}),e.jsx(Ns,{children:"除了聊天,我还帮大家做了这些事"})]}),e.jsx(ze,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:l.expression_vibe.action_types.map(y=>e.jsxs("div",{className:"flex items-center gap-2 rounded-full bg-primary/10 px-4 py-2",children:[e.jsx("span",{className:"font-medium text-primary",children:y.action}),e.jsxs(Ce,{variant:"secondary",children:[y.count," 次"]})]},y.action))})})]})]}),e.jsxs("section",{className:"space-y-4 break-inside-avoid",children:[e.jsxs("div",{className:"flex items-center gap-2 text-2xl font-bold text-primary",children:[e.jsx(e_,{className:"h-8 w-8"}),e.jsx("h2",{children:"趣味成就"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(Te,{className:"col-span-1 md:col-span-2",children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:'新学到的"黑话"'}),e.jsxs(Ns,{children:["今年我学会了 ",l.achievements.new_jargon_count," 个新词"]})]}),e.jsx(ze,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:l.achievements.sample_jargons.map(y=>e.jsxs("div",{className:"group relative rounded-lg border bg-card p-3 shadow-sm transition-all hover:shadow-md",children:[e.jsx("div",{className:"font-bold text-primary",children:y.content}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2 max-w-[200px]",children:y.meaning||"暂无解释"})]},y.content))})})]}),e.jsx(Te,{className:"flex flex-col justify-center items-center bg-primary text-primary-foreground",children:e.jsxs(ze,{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(Ia,{className:"h-12 w-12 mb-4 opacity-80"}),e.jsx("div",{className:"text-4xl font-bold mb-2",children:l.achievements.total_messages.toLocaleString()}),e.jsx("div",{className:"text-sm opacity-80",children:"年度总消息数"}),e.jsxs("div",{className:"mt-4 text-xs opacity-60",children:["其中回复了 ",l.achievements.total_replies.toLocaleString()," 次"]})]})})]})]}),e.jsxs("footer",{className:"mt-12 text-center text-muted-foreground",children:[e.jsx("p",{children:"MaiBot 2025 Annual Report"}),e.jsx("p",{className:"text-sm",children:"Generated with ❤️ by MaiBot Team"})]})]})})}):null}function La({title:a,value:l,description:r,icon:c}){return e.jsxs(Te,{children:[e.jsxs(Oe,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ue,{className:"text-sm font-medium",children:a}),e.jsx("div",{className:"text-muted-foreground",children:c})]}),e.jsxs(ze,{children:[e.jsx("div",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]})}function o5(){return e.jsxs("div",{className:"container mx-auto space-y-8 p-8",children:[e.jsx(ks,{className:"h-64 w-full rounded-3xl"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((a,l)=>e.jsx(ks,{className:"h-32 w-full"},l))}),e.jsx(ks,{className:"h-96 w-full"})]})}var vd="DropdownMenu",[d5]=ld(vd,[Oj]),fa=Oj(),[u5,JN]=d5(vd),XN=a=>{const{__scopeDropdownMenu:l,children:r,dir:c,open:d,defaultOpen:m,onOpenChange:h,modal:f=!0}=a,p=fa(l),g=u.useRef(null),[N,j]=ad({prop:d,defaultProp:m??!1,onChange:h,caller:vd});return e.jsx(u5,{scope:l,triggerId:Ym(),triggerRef:g,contentId:Ym(),open:N,onOpenChange:j,onOpenToggle:u.useCallback(()=>j(b=>!b),[j]),modal:f,children:e.jsx(Vw,{...p,open:N,onOpenChange:j,dir:c,modal:f,children:r})})};XN.displayName=vd;var ZN="DropdownMenuTrigger",WN=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,disabled:c=!1,...d}=a,m=JN(ZN,r),h=fa(r);return e.jsx(Gw,{asChild:!0,...h,children:e.jsx(ar.button,{type:"button",id:m.triggerId,"aria-haspopup":"menu","aria-expanded":m.open,"aria-controls":m.open?m.contentId:void 0,"data-state":m.open?"open":"closed","data-disabled":c?"":void 0,disabled:c,...d,ref:_1(l,m.triggerRef),onPointerDown:_n(a.onPointerDown,f=>{!c&&f.button===0&&f.ctrlKey===!1&&(m.onOpenToggle(),m.open||f.preventDefault())}),onKeyDown:_n(a.onKeyDown,f=>{c||(["Enter"," "].includes(f.key)&&m.onOpenToggle(),f.key==="ArrowDown"&&m.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(f.key)&&f.preventDefault())})})})});WN.displayName=ZN;var m5="DropdownMenuPortal",eb=a=>{const{__scopeDropdownMenu:l,...r}=a,c=fa(l);return e.jsx(Uw,{...c,...r})};eb.displayName=m5;var sb="DropdownMenuContent",tb=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=JN(sb,r),m=fa(r),h=u.useRef(!1);return e.jsx($w,{id:d.contentId,"aria-labelledby":d.triggerId,...m,...c,ref:l,onCloseAutoFocus:_n(a.onCloseAutoFocus,f=>{h.current||d.triggerRef.current?.focus(),h.current=!1,f.preventDefault()}),onInteractOutside:_n(a.onInteractOutside,f=>{const p=f.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0,N=p.button===2||g;(!d.modal||N)&&(h.current=!0)}),style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});tb.displayName=sb;var x5="DropdownMenuGroup",h5=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Kw,{...d,...c,ref:l})});h5.displayName=x5;var f5="DropdownMenuLabel",ab=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Hw,{...d,...c,ref:l})});ab.displayName=f5;var p5="DropdownMenuItem",lb=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Bw,{...d,...c,ref:l})});lb.displayName=p5;var g5="DropdownMenuCheckboxItem",nb=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Iw,{...d,...c,ref:l})});nb.displayName=g5;var j5="DropdownMenuRadioGroup",v5=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Qw,{...d,...c,ref:l})});v5.displayName=j5;var N5="DropdownMenuRadioItem",rb=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Fw,{...d,...c,ref:l})});rb.displayName=N5;var b5="DropdownMenuItemIndicator",ib=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Pw,{...d,...c,ref:l})});ib.displayName=b5;var y5="DropdownMenuSeparator",cb=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(qw,{...d,...c,ref:l})});cb.displayName=y5;var w5="DropdownMenuArrow",_5=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Yw,{...d,...c,ref:l})});_5.displayName=w5;var S5="DropdownMenuSubTrigger",ob=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Ow,{...d,...c,ref:l})});ob.displayName=S5;var k5="DropdownMenuSubContent",db=u.forwardRef((a,l)=>{const{__scopeDropdownMenu:r,...c}=a,d=fa(r);return e.jsx(Lw,{...d,...c,ref:l,style:{...a.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});db.displayName=k5;var C5=XN,T5=WN,E5=eb,ub=tb,mb=ab,xb=lb,hb=nb,fb=rb,pb=ib,gb=cb,jb=ob,vb=db;const M5=C5,A5=T5,z5=u.forwardRef(({className:a,inset:l,children:r,...c},d)=>e.jsxs(jb,{ref:d,className:P("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",l&&"pl-8",a),...c,children:[r,e.jsx(ra,{className:"ml-auto h-4 w-4"})]}));z5.displayName=jb.displayName;const R5=u.forwardRef(({className:a,...l},r)=>e.jsx(vb,{ref:r,className:P("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...l}));R5.displayName=vb.displayName;const Nb=u.forwardRef(({className:a,sideOffset:l=4,...r},c)=>e.jsx(E5,{children:e.jsx(ub,{ref:c,sideOffset:l,className:P("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...r})}));Nb.displayName=ub.displayName;const bb=u.forwardRef(({className:a,inset:l,...r},c)=>e.jsx(xb,{ref:c,className:P("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",l&&"pl-8",a),...r}));bb.displayName=xb.displayName;const D5=u.forwardRef(({className:a,children:l,checked:r,...c},d)=>e.jsxs(hb,{ref:d,className:P("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:r,...c,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(pb,{children:e.jsx(Lt,{className:"h-4 w-4"})})}),l]}));D5.displayName=hb.displayName;const O5=u.forwardRef(({className:a,children:l,...r},c)=>e.jsxs(fb,{ref:c,className:P("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(pb,{children:e.jsx(Vo,{className:"h-2 w-2 fill-current"})})}),l]}));O5.displayName=fb.displayName;const L5=u.forwardRef(({className:a,inset:l,...r},c)=>e.jsx(mb,{ref:c,className:P("px-2 py-1.5 text-sm font-semibold",l&&"pl-8",a),...r}));L5.displayName=mb.displayName;const U5=u.forwardRef(({className:a,...l},r)=>e.jsx(gb,{ref:r,className:P("-mx-1 my-1 h-px bg-muted",a),...l}));U5.displayName=gb.displayName;const Qm=[{value:"created_at",label:"最新发布",icon:da},{value:"downloads",label:"下载最多",icon:na},{value:"likes",label:"最受欢迎",icon:ei}];function $5(){const a=ha(),[l,r]=u.useState([]),[c,d]=u.useState(!0),[m,h]=u.useState(""),[f,p]=u.useState("downloads"),[g,N]=u.useState(1),[j,b]=u.useState(1),[y,w]=u.useState(0),[z,M]=u.useState(new Set),[S,F]=u.useState(new Set),E=cN(),C=u.useCallback(async()=>{d(!0);try{const L=await m4({status:"approved",page:g,page_size:12,search:m||void 0,sort_by:f,sort_order:"desc"});r(L.packs),b(L.total_pages),w(L.total);const me=new Set;for(const Ne of L.packs)await iN(Ne.id,E)&&me.add(Ne.id);M(me)}catch(L){console.error("加载 Pack 列表失败:",L),aa({title:"加载 Pack 列表失败",variant:"destructive"})}finally{d(!1)}},[g,m,f,E]);u.useEffect(()=>{C()},[C]);const R=L=>{L.preventDefault(),N(1),C()},H=async L=>{if(!S.has(L)){F(me=>new Set(me).add(L));try{const me=await rN(L,E);M(Ne=>{const je=new Set(Ne);return me.liked?je.add(L):je.delete(L),je}),r(Ne=>Ne.map(je=>je.id===L?{...je,likes:me.likes}:je))}catch(me){console.error("点赞失败:",me),aa({title:"点赞失败",variant:"destructive"})}finally{F(me=>{const Ne=new Set(me);return Ne.delete(L),Ne})}}},O=L=>{a({to:"/config/pack-market/$packId",params:{packId:L}})},X=Qm.find(L=>L.value===f)||Qm[0];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(xa,{className:"h-8 w-8",strokeWidth:2}),"配置模板市场"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"浏览和应用社区分享的模型配置模板,快速配置你的 MaiBot"})]}),e.jsxs(_,{variant:"outline",onClick:C,disabled:c,className:"gap-2",children:[e.jsx(dt,{className:`h-4 w-4 ${c?"animate-spin":""}`}),"刷新"]})]})}),e.jsx(ts,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 flex-wrap",children:[e.jsx("form",{onSubmit:R,className:"flex-1 min-w-[200px] max-w-md",children:e.jsxs("div",{className:"relative",children:[e.jsx($t,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ne,{placeholder:"搜索模板名称、描述...",value:m,onChange:L=>h(L.target.value),className:"pl-10"})]})}),e.jsxs(M5,{children:[e.jsx(A5,{asChild:!0,children:e.jsxs(_,{variant:"outline",className:"min-w-[140px] gap-2",children:[e.jsx(s_,{className:"w-4 h-4"}),X.label,e.jsx(Ba,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(Nb,{align:"end",children:Qm.map(L=>e.jsxs(bb,{onClick:()=>{p(L.value),N(1)},children:[e.jsx(L.icon,{className:"w-4 h-4 mr-2"}),L.label]},L.value))})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共找到 ",e.jsx("span",{className:"font-medium text-foreground",children:y})," 个模板"]}),c?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((L,me)=>e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(ks,{className:"h-6 w-3/4"}),e.jsx(ks,{className:"h-4 w-full mt-2"})]}),e.jsx(ze,{children:e.jsx(ks,{className:"h-20 w-full"})}),e.jsx(od,{children:e.jsx(ks,{className:"h-9 w-full"})})]},me))}):l.length===0?e.jsx(Te,{className:"py-12",children:e.jsxs(ze,{className:"text-center text-muted-foreground",children:[e.jsx(xa,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"text-lg font-medium",children:"暂无模板"}),e.jsx("p",{className:"mt-1",children:"还没有人分享配置模板,快来分享第一个吧!"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map(L=>e.jsx(B5,{pack:L,liked:z.has(L.id),liking:S.has(L.id),onLike:()=>H(L.id),onView:()=>O(L.id)},L.id))}),j>1&&e.jsx(fx,{children:e.jsxs(px,{children:[e.jsx(Xn,{children:e.jsx($v,{onClick:()=>N(L=>Math.max(1,L-1)),className:g===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:j},(L,me)=>me+1).filter(L=>L===1||L===j||Math.abs(L-g)<=1).map((L,me,Ne)=>{const je=me>0&&L-Ne[me-1]>1;return e.jsxs(Xn,{children:[je&&e.jsx("span",{className:"px-2",children:"..."}),e.jsx(jc,{onClick:()=>N(L),isActive:L===g,className:"cursor-pointer",children:L})]},L)}),e.jsx(Xn,{children:e.jsx(Bv,{onClick:()=>N(L=>Math.min(j,L+1)),className:g===j?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})})]})}function B5({pack:a,liked:l,liking:r,onLike:c,onView:d}){const m=h=>new Date(h).toLocaleDateString("zh-CN",{year:"numeric",month:"short",day:"numeric"});return e.jsxs(Te,{className:"flex flex-col hover:shadow-md transition-shadow",children:[e.jsxs(Oe,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Ue,{className:"text-lg line-clamp-1",children:a.name}),e.jsxs(Ce,{variant:"secondary",className:"text-xs",children:["v",a.version]})]}),e.jsx(Ns,{className:"line-clamp-2 min-h-[40px]",children:a.description})]}),e.jsxs(ze,{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"w-3.5 h-3.5"}),a.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(da,{className:"w-3.5 h-3.5"}),m(a.created_at)]})]}),e.jsxs("div",{className:"flex gap-4 text-sm",children:[e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"提供商数量",children:[e.jsx(Hl,{className:"w-3.5 h-3.5"}),a.provider_count]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"模型数量",children:[e.jsx(Wn,{className:"w-3.5 h-3.5"}),a.model_count]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"任务配置数",children:[e.jsx(er,{className:"w-3.5 h-3.5"}),a.task_count]})]}),a.tags&&a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(h=>e.jsxs(Ce,{variant:"outline",className:"text-xs",children:[e.jsx(cd,{className:"w-2.5 h-2.5 mr-1"}),h]},h)),a.tags.length>3&&e.jsxs(Ce,{variant:"outline",className:"text-xs",children:["+",a.tags.length-3]})]})]}),e.jsx(od,{className:"pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(na,{className:"w-4 h-4"}),a.downloads]}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),c()},disabled:r,className:`flex items-center gap-1 transition-colors ${l?"text-red-500":"hover:text-red-500"} ${r?"opacity-50":""}`,children:[e.jsx(ei,{className:`w-4 h-4 ${l?"fill-current":""}`}),a.likes]})]}),e.jsx(_,{size:"sm",onClick:d,children:"查看详情"})]})})]})}var ul="Accordion",I5=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Lx,P5,F5]=S1(ul),[Nd]=ld(ul,[F5,Lj]),Ux=Lj(),yb=Bs.forwardRef((a,l)=>{const{type:r,...c}=a,d=c,m=c;return e.jsx(Lx.Provider,{scope:a.__scopeAccordion,children:r==="multiple"?e.jsx(G5,{...m,ref:l}):e.jsx(V5,{...d,ref:l})})});yb.displayName=ul;var[wb,H5]=Nd(ul),[_b,q5]=Nd(ul,{collapsible:!1}),V5=Bs.forwardRef((a,l)=>{const{value:r,defaultValue:c,onValueChange:d=()=>{},collapsible:m=!1,...h}=a,[f,p]=ad({prop:r,defaultProp:c??"",onChange:d,caller:ul});return e.jsx(wb,{scope:a.__scopeAccordion,value:Bs.useMemo(()=>f?[f]:[],[f]),onItemOpen:p,onItemClose:Bs.useCallback(()=>m&&p(""),[m,p]),children:e.jsx(_b,{scope:a.__scopeAccordion,collapsible:m,children:e.jsx(Sb,{...h,ref:l})})})}),G5=Bs.forwardRef((a,l)=>{const{value:r,defaultValue:c,onValueChange:d=()=>{},...m}=a,[h,f]=ad({prop:r,defaultProp:c??[],onChange:d,caller:ul}),p=Bs.useCallback(N=>f((j=[])=>[...j,N]),[f]),g=Bs.useCallback(N=>f((j=[])=>j.filter(b=>b!==N)),[f]);return e.jsx(wb,{scope:a.__scopeAccordion,value:h,onItemOpen:p,onItemClose:g,children:e.jsx(_b,{scope:a.__scopeAccordion,collapsible:!0,children:e.jsx(Sb,{...m,ref:l})})})}),[K5,bd]=Nd(ul),Sb=Bs.forwardRef((a,l)=>{const{__scopeAccordion:r,disabled:c,dir:d,orientation:m="vertical",...h}=a,f=Bs.useRef(null),p=nd(f,l),g=P5(r),j=Wj(d)==="ltr",b=_n(a.onKeyDown,y=>{if(!I5.includes(y.key))return;const w=y.target,z=g().filter(X=>!X.ref.current?.disabled),M=z.findIndex(X=>X.ref.current===w),S=z.length;if(M===-1)return;y.preventDefault();let F=M;const E=0,C=S-1,R=()=>{F=M+1,F>C&&(F=E)},H=()=>{F=M-1,F<E&&(F=C)};switch(y.key){case"Home":F=E;break;case"End":F=C;break;case"ArrowRight":m==="horizontal"&&(j?R():H());break;case"ArrowDown":m==="vertical"&&R();break;case"ArrowLeft":m==="horizontal"&&(j?H():R());break;case"ArrowUp":m==="vertical"&&H();break}const O=F%S;z[O].ref.current?.focus()});return e.jsx(K5,{scope:r,disabled:c,direction:d,orientation:m,children:e.jsx(Lx.Slot,{scope:r,children:e.jsx(ar.div,{...h,"data-orientation":m,ref:p,onKeyDown:c?void 0:b})})})}),td="AccordionItem",[Q5,$x]=Nd(td),kb=Bs.forwardRef((a,l)=>{const{__scopeAccordion:r,value:c,...d}=a,m=bd(td,r),h=H5(td,r),f=Ux(r),p=Ym(),g=c&&h.value.includes(c)||!1,N=m.disabled||a.disabled;return e.jsx(Q5,{scope:r,open:g,disabled:N,triggerId:p,children:e.jsx(Mj,{"data-orientation":m.orientation,"data-state":zb(g),...f,...d,ref:l,disabled:N,open:g,onOpenChange:j=>{j?h.onItemOpen(c):h.onItemClose(c)}})})});kb.displayName=td;var Cb="AccordionHeader",Tb=Bs.forwardRef((a,l)=>{const{__scopeAccordion:r,...c}=a,d=bd(ul,r),m=$x(Cb,r);return e.jsx(ar.h3,{"data-orientation":d.orientation,"data-state":zb(m.open),"data-disabled":m.disabled?"":void 0,...c,ref:l})});Tb.displayName=Cb;var lx="AccordionTrigger",Eb=Bs.forwardRef((a,l)=>{const{__scopeAccordion:r,...c}=a,d=bd(ul,r),m=$x(lx,r),h=q5(lx,r),f=Ux(r);return e.jsx(Lx.ItemSlot,{scope:r,children:e.jsx(Jw,{"aria-disabled":m.open&&!h.collapsible||void 0,"data-orientation":d.orientation,id:m.triggerId,...f,...c,ref:l})})});Eb.displayName=lx;var Mb="AccordionContent",Ab=Bs.forwardRef((a,l)=>{const{__scopeAccordion:r,...c}=a,d=bd(ul,r),m=$x(Mb,r),h=Ux(r);return e.jsx(Xw,{role:"region","aria-labelledby":m.triggerId,"data-orientation":d.orientation,...h,...c,ref:l,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...a.style}})});Ab.displayName=Mb;function zb(a){return a?"open":"closed"}var Y5=yb,J5=kb,X5=Tb,Rb=Eb,Db=Ab;const Z5=Y5,Ob=u.forwardRef(({className:a,...l},r)=>e.jsx(J5,{ref:r,className:P("border-b",a),...l}));Ob.displayName="AccordionItem";const Lb=u.forwardRef(({className:a,children:l,...r},c)=>e.jsx(X5,{className:"flex",children:e.jsxs(Rb,{ref:c,className:P("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...r,children:[l,e.jsx(Ba,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Lb.displayName=Rb.displayName;const Ub=u.forwardRef(({className:a,children:l,...r},c)=>e.jsx(Db,{ref:c,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:e.jsx("div",{className:P("pb-4 pt-0",a),children:l})}));Ub.displayName=Db.displayName;const W5={utils:"通用工具",utils_small:"轻量工具",tool_use:"工具调用",replyer:"回复生成",planner:"规划推理",vlm:"视觉模型",voice:"语音处理",embedding:"向量嵌入",lpmm_entity_extract:"实体提取",lpmm_rdf_build:"RDF构建",lpmm_qa:"问答模型"};function eT(){const{packId:a}=Pb.useParams(),l=ha(),[r,c]=u.useState(null),[d,m]=u.useState(!0),[h,f]=u.useState(!1),[p,g]=u.useState(!1),[N,j]=u.useState(!1),[b,y]=u.useState(1),[w,z]=u.useState(null),[M,S]=u.useState(!1),[F,E]=u.useState(!1),[C,R]=u.useState({apply_providers:!0,apply_models:!0,apply_task_config:!0,task_mode:"append",selected_providers:void 0,selected_models:void 0,selected_tasks:void 0}),[H,O]=u.useState({}),[X,L]=u.useState({}),me=cN(),Ne=u.useCallback(async()=>{if(a){m(!0);try{const D=await x4(a);c(D);const Q=await iN(a,me);f(Q)}catch(D){console.error("加载 Pack 失败:",D),aa({title:"加载模板失败",variant:"destructive"})}finally{m(!1)}}},[a,me]);u.useEffect(()=>{Ne()},[Ne]);const je=async()=>{if(!(!a||p)){g(!0);try{const D=await rN(a,me);f(D.liked),r&&c({...r,likes:D.likes})}catch(D){console.error("点赞失败:",D),aa({title:"点赞失败",variant:"destructive"})}finally{g(!1)}}},ce=async()=>{if(r){j(!0),y(1),S(!0);try{const D=await p4(r);z(D);const Q={};for(const ue of D.existing_providers)Q[ue.pack_provider.name]=ue.local_providers[0].name;O(Q);const B={};for(const ue of D.new_providers)B[ue.name]="";L(B)}catch(D){console.error("检测冲突失败:",D),aa({title:"检测配置冲突失败",variant:"destructive"}),j(!1)}finally{S(!1)}}},ge=async()=>{if(r){if(C.apply_providers&&w){for(const D of w.new_providers)if(!X[D.name]){aa({title:`请填写提供商 "${D.name}" 的 API Key`,variant:"destructive"});return}}E(!0);try{await g4(r,C,H,X),await f4(r.id,me),c({...r,downloads:r.downloads+1}),aa({title:"配置模板应用成功!"}),j(!1)}catch(D){console.error("应用 Pack 失败:",D),aa({title:D instanceof Error?D.message:"应用配置失败",variant:"destructive"})}finally{E(!1)}}},pe=D=>new Date(D).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"});return d?e.jsx(tT,{}):r?e.jsx("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:e.jsx(ts,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs(_,{variant:"ghost",size:"sm",onClick:()=>l({to:"/config/pack-market"}),className:"gap-2",children:[e.jsx($a,{className:"w-4 h-4"}),"返回市场"]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xa,{className:"w-10 h-10 text-primary mt-1"}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[r.name,e.jsxs(Ce,{variant:"secondary",children:["v",r.version]})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:r.description})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fl,{className:"w-4 h-4"}),r.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(da,{className:"w-4 h-4"}),pe(r.created_at)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(na,{className:"w-4 h-4"}),r.downloads," 次下载"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ei,{className:`w-4 h-4 ${h?"fill-red-500 text-red-500":""}`}),r.likes," 赞"]})]}),r.tags&&r.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:r.tags.map(D=>e.jsxs(Ce,{variant:"outline",children:[e.jsx(cd,{className:"w-3 h-3 mr-1"}),D]},D))})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-[160px]",children:[e.jsxs(_,{size:"lg",onClick:ce,children:[e.jsx(na,{className:"w-4 h-4 mr-2"}),"应用模板"]}),e.jsxs(_,{variant:"outline",onClick:je,disabled:p,className:h?"text-red-500 border-red-200":"",children:[e.jsx(ei,{className:`w-4 h-4 mr-2 ${h?"fill-current":""}`}),h?"已点赞":"点赞"]})]})]}),e.jsx(la,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(Te,{children:e.jsxs(ze,{className:"flex items-center gap-3 py-4",children:[e.jsx(Hl,{className:"w-8 h-8 text-blue-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:r.providers.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"API 提供商"})]})]})}),e.jsx(Te,{children:e.jsxs(ze,{className:"flex items-center gap-3 py-4",children:[e.jsx(Wn,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:r.models.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"模型配置"})]})]})}),e.jsx(Te,{children:e.jsxs(ze,{className:"flex items-center gap-3 py-4",children:[e.jsx(er,{className:"w-8 h-8 text-purple-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:Object.keys(r.task_config).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"任务配置"})]})]})})]}),e.jsxs(Jt,{defaultValue:"providers",className:"space-y-4",children:[e.jsxs(Gt,{className:"w-full sm:w-auto grid grid-cols-3 sm:flex",children:[e.jsxs(Xe,{value:"providers",className:"gap-1 sm:gap-2",children:[e.jsx(Hl,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"提供商"}),e.jsx("span",{className:"sm:hidden",children:"提供商"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",r.providers.length,")"]})]}),e.jsxs(Xe,{value:"models",className:"gap-1 sm:gap-2",children:[e.jsx(Wn,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"模型"}),e.jsx("span",{className:"sm:hidden",children:"模型"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",r.models.length,")"]})]}),e.jsxs(Xe,{value:"tasks",className:"gap-1 sm:gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"任务配置"}),e.jsx("span",{className:"sm:hidden",children:"任务"}),e.jsxs("span",{className:"hidden sm:inline",children:["(",Object.keys(r.task_config).length,")"]})]})]}),e.jsx(Ss,{value:"providers",children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"API 提供商"}),e.jsx(Ns,{children:"模板中包含的 API 提供商配置(不含 API Key)"})]}),e.jsx(ze,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{children:"名称"}),e.jsx(ns,{children:"Base URL"}),e.jsx(ns,{children:"类型"})]})}),e.jsx(Gl,{children:r.providers.map(D=>e.jsxs(_t,{children:[e.jsx(Ze,{className:"font-medium whitespace-nowrap",children:D.name}),e.jsx(Ze,{className:"text-muted-foreground font-mono text-sm max-w-[200px] truncate",children:D.base_url}),e.jsx(Ze,{children:e.jsx(Ce,{variant:"outline",children:D.client_type})})]},D.name))})]})})})]})}),e.jsx(Ss,{value:"models",children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"模型配置"}),e.jsx(Ns,{children:"模板中包含的模型配置"})]}),e.jsx(ze,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ql,{children:[e.jsx(Vl,{children:e.jsxs(_t,{children:[e.jsx(ns,{children:"模型名称"}),e.jsx(ns,{children:"标识符"}),e.jsx(ns,{children:"提供商"}),e.jsx(ns,{className:"text-right",children:"价格 (入/出)"})]})}),e.jsx(Gl,{children:r.models.map(D=>e.jsxs(_t,{children:[e.jsx(Ze,{className:"font-medium whitespace-nowrap",children:D.name}),e.jsx(Ze,{className:"text-muted-foreground font-mono text-sm max-w-[150px] truncate",children:D.model_identifier}),e.jsx(Ze,{className:"whitespace-nowrap",children:D.api_provider}),e.jsxs(Ze,{className:"text-right text-muted-foreground whitespace-nowrap",children:["¥",D.price_in," / ¥",D.price_out]})]},D.name))})]})})})]})}),e.jsx(Ss,{value:"tasks",children:e.jsxs(Te,{children:[e.jsxs(Oe,{children:[e.jsx(Ue,{children:"任务配置"}),e.jsx(Ns,{children:"模板中各任务类型的模型分配"})]}),e.jsx(ze,{children:e.jsx(Z5,{type:"multiple",className:"w-full",children:Object.entries(r.task_config).map(([D,Q])=>e.jsxs(Ob,{value:D,children:[e.jsx(Lb,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"w-4 h-4"}),W5[D]||D,e.jsxs(Ce,{variant:"secondary",className:"ml-2",children:[Q.model_list.length," 个模型"]})]})}),e.jsx(Ub,{children:e.jsxs("div",{className:"space-y-2 pl-6",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"分配的模型:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Q.model_list.map(B=>e.jsx(Ce,{variant:"outline",children:B},B))}),Q.temperature!==void 0&&e.jsxs("div",{className:"text-sm",children:["Temperature: ",e.jsx("span",{className:"font-mono",children:Q.temperature})]}),Q.max_tokens!==void 0&&e.jsxs("div",{className:"text-sm",children:["Max Tokens: ",e.jsx("span",{className:"font-mono",children:Q.max_tokens})]})]})})]},D))})})]})})]}),e.jsx(sT,{open:N,onOpenChange:j,pack:r,step:b,setStep:y,conflicts:w,detectingConflicts:M,applying:F,options:C,setOptions:R,_providerMapping:H,_setProviderMapping:O,newProviderApiKeys:X,setNewProviderApiKeys:L,onApply:ge})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(xa,{className:"w-16 h-16 mx-auto mb-4 opacity-50"}),e.jsx("h2",{className:"text-xl font-semibold",children:"模板不存在"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"该配置模板可能已被删除或尚未通过审核"}),e.jsxs(_,{className:"mt-4",onClick:()=>l({to:"/config/pack-market"}),children:[e.jsx($a,{className:"w-4 h-4 mr-2"}),"返回市场"]})]})}function sT({open:a,onOpenChange:l,pack:r,step:c,setStep:d,conflicts:m,detectingConflicts:h,applying:f,options:p,setOptions:g,_providerMapping:N,_setProviderMapping:j,newProviderApiKeys:b,setNewProviderApiKeys:y,onApply:w}){return e.jsx(Qs,{open:a,onOpenChange:l,children:e.jsxs(Hs,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(qs,{children:[e.jsxs(Vs,{className:"flex items-center gap-2",children:[e.jsx(xa,{className:"w-5 h-5"}),"应用配置模板"]}),e.jsxs(at,{children:["步骤 ",c," / ",3,":",c===1&&"选择要应用的内容",c===2&&"配置提供商映射",c===3&&"确认并应用"]})]}),h?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Fs,{className:"w-8 h-8 mx-auto animate-spin text-primary"}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"正在检测配置冲突..."})]}):e.jsxs(e.Fragment,{children:[c===1&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"apply_providers",checked:p.apply_providers,onCheckedChange:M=>g({...p,apply_providers:M})}),e.jsxs(T,{htmlFor:"apply_providers",className:"flex items-center gap-2",children:[e.jsx(Hl,{className:"w-4 h-4"}),"应用提供商配置 (",r.providers.length," 个)"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"apply_models",checked:p.apply_models,onCheckedChange:M=>g({...p,apply_models:M})}),e.jsxs(T,{htmlFor:"apply_models",className:"flex items-center gap-2",children:[e.jsx(Wn,{className:"w-4 h-4"}),"应用模型配置 (",r.models.length," 个)"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(tt,{id:"apply_task_config",checked:p.apply_task_config,onCheckedChange:M=>g({...p,apply_task_config:M})}),e.jsxs(T,{htmlFor:"apply_task_config",className:"flex items-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),"应用任务配置 (",Object.keys(r.task_config).length," 个)"]})]})]}),p.apply_task_config&&e.jsxs("div",{className:"pl-6 space-y-2 border-l-2 border-muted",children:[e.jsx(T,{className:"text-sm font-medium",children:"任务配置应用模式"}),e.jsxs(Rx,{value:p.task_mode,onValueChange:M=>g({...p,task_mode:M}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wo,{value:"append",id:"mode_append"}),e.jsx(T,{htmlFor:"mode_append",className:"font-normal",children:"追加模式 - 将模板中的模型添加到现有配置"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wo,{value:"replace",id:"mode_replace"}),e.jsx(T,{htmlFor:"mode_replace",className:"font-normal",children:"替换模式 - 用模板配置完全替换现有配置"})]})]})]})]}),c===2&&m&&e.jsxs("div",{className:"space-y-4",children:[p.apply_providers&&m.existing_providers.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(Jn,{children:"发现已有的提供商"}),e.jsx(ft,{children:"以下提供商的 URL 与您本地配置中的提供商匹配,将自动使用本地提供商:"})]}),e.jsx("div",{className:"space-y-2",children:m.existing_providers.map(({pack_provider:M,local_providers:S})=>e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx(Lt,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"font-medium flex-shrink-0",children:M.name}),e.jsx(ra,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),S.length===1?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:S[0].name}),e.jsx(Ce,{variant:"outline",className:"ml-auto",children:"URL 匹配"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{value:N[M.name]||S[0].name,onValueChange:F=>j({...N,[M.name]:F}),children:[e.jsx(Be,{className:"w-[200px]",children:e.jsx(Fe,{})}),e.jsx(Ie,{children:S.map(F=>e.jsx(W,{value:F.name,children:F.name},F.name))})]}),e.jsxs(Ce,{variant:"outline",className:"ml-auto",children:[S.length," 个匹配"]})]})]},M.name))})]}),p.apply_providers&&m.new_providers.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ht,{variant:"destructive",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsx(Jn,{children:"需要配置 API Key"}),e.jsx(ft,{children:"以下提供商在您的本地配置中不存在,需要填写 API Key:"})]}),e.jsx("div",{className:"space-y-4",children:m.new_providers.map(M=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(cx,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"font-medium",children:M.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",M.base_url,")"]})]}),e.jsx(ne,{type:"password",placeholder:`输入 ${M.name} 的 API Key`,value:b[M.name]||"",onChange:S=>y({...b,[M.name]:S.target.value})})]},M.name))})]}),(!p.apply_providers||m.existing_providers.length===0&&m.new_providers.length===0)&&e.jsxs(ht,{children:[e.jsx(Lt,{className:"h-4 w-4"}),e.jsx(Jn,{children:"无需配置"}),e.jsx(ft,{children:"模板中没有提供商配置,或您选择不应用提供商。"})]})]}),c===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ht,{children:[e.jsx(Yt,{className:"h-4 w-4"}),e.jsx(Jn,{children:"确认应用"}),e.jsx(ft,{children:"请确认以下将要应用的内容:"})]}),e.jsxs("div",{className:"space-y-2",children:[p.apply_providers&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Lt,{className:"w-4 h-4 text-green-500"}),e.jsx(Hl,{className:"w-4 h-4"}),e.jsxs("span",{children:["应用 ",r.providers.length," 个提供商配置"]})]}),p.apply_models&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Lt,{className:"w-4 h-4 text-green-500"}),e.jsx(Wn,{className:"w-4 h-4"}),e.jsxs("span",{children:["应用 ",r.models.length," 个模型配置"]})]}),p.apply_task_config&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Lt,{className:"w-4 h-4 text-green-500"}),e.jsx(er,{className:"w-4 h-4"}),e.jsxs("span",{children:[p.task_mode==="append"?"追加":"替换"," ",Object.keys(r.task_config).length," 个任务配置"]})]})]}),m&&m.new_providers.length>0&&e.jsxs(ht,{variant:"destructive",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsxs(ft,{children:["将添加 ",m.new_providers.length," 个新提供商,请确保已填写正确的 API Key。"]})]})]})]}),e.jsxs(gt,{className:"flex justify-between",children:[e.jsx("div",{children:c>1&&!h&&e.jsx(_,{variant:"outline",onClick:()=>d(c-1),disabled:f,children:"上一步"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{variant:"outline",onClick:()=>l(!1),disabled:f,children:"取消"}),c<3?e.jsx(_,{onClick:()=>d(c+1),disabled:h,children:"下一步"}):e.jsxs(_,{onClick:w,disabled:f,children:[f&&e.jsx(Fs,{className:"w-4 h-4 mr-2 animate-spin"}),"应用模板"]})]})]})]})})}function tT(){return e.jsx("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:e.jsx(ts,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(ks,{className:"h-9 w-24"}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ks,{className:"w-10 h-10"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ks,{className:"h-8 w-2/3"}),e.jsx(ks,{className:"h-4 w-full"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(ks,{className:"h-4 w-24"}),e.jsx(ks,{className:"h-4 w-32"}),e.jsx(ks,{className:"h-4 w-28"}),e.jsx(ks,{className:"h-4 w-20"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ks,{className:"h-6 w-20"}),e.jsx(ks,{className:"h-6 w-24"}),e.jsx(ks,{className:"h-6 w-16"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-[160px]",children:[e.jsx(ks,{className:"h-10 w-full"}),e.jsx(ks,{className:"h-10 w-full"})]})]}),e.jsx(ks,{className:"h-px w-full"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(ks,{className:"h-24"}),e.jsx(ks,{className:"h-24"}),e.jsx(ks,{className:"h-24"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ks,{className:"h-10 w-32"}),e.jsx(ks,{className:"h-10 w-32"}),e.jsx(ks,{className:"h-10 w-32"})]}),e.jsx(ks,{className:"h-96 w-full"})]})]})})})}function aT(){const a=ha(),[l,r]=u.useState(!0);return u.useEffect(()=>{let c=!1;return(async()=>{try{const m=await dc();!c&&!m&&a({to:"/auth"})}catch{c||a({to:"/auth"})}finally{c||r(!1)}})(),()=>{c=!0}},[a]),{checking:l}}async function lT(){return await dc()}const nT=ti("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"}}),$b=u.forwardRef(({className:a,size:l,abbrTitle:r,children:c,...d},m)=>e.jsx("kbd",{className:P(nT({size:l,className:a})),ref:m,...d,children:r?e.jsx("abbr",{title:r,children:c}):c}));$b.displayName="Kbd";const rT=[{icon:id,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:Ua,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:Hl,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:gv,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:rd,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:Ia,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:jv,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:Wr,title:"黑话管理",description:"管理麦麦学习到的黑话和俚语",path:"/resource/jargon",category:"资源"},{icon:t_,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:xa,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:ux,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:Sn,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function iT({open:a,onOpenChange:l}){const[r,c]=u.useState(""),[d,m]=u.useState(0),h=ha(),f=rT.filter(N=>N.title.toLowerCase().includes(r.toLowerCase())||N.description.toLowerCase().includes(r.toLowerCase())||N.category.toLowerCase().includes(r.toLowerCase())),p=u.useCallback(N=>{h({to:N}),l(!1),c(""),m(0)},[h,l]),g=u.useCallback(N=>{N.key==="ArrowDown"?(N.preventDefault(),m(j=>(j+1)%f.length)):N.key==="ArrowUp"?(N.preventDefault(),m(j=>(j-1+f.length)%f.length)):N.key==="Enter"&&f[d]&&(N.preventDefault(),p(f[d].path))},[f,d,p]);return e.jsx(Qs,{open:a,onOpenChange:l,children:e.jsxs(Hs,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(qs,{className:"px-4 pt-4 pb-0",children:[e.jsx(Vs,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx($t,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(ne,{value:r,onChange:N=>{c(N.target.value),m(0)},onKeyDown:g,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(ts,{className:"h-[400px]",children:f.length>0?e.jsx("div",{className:"p-2",children:f.map((N,j)=>{const b=N.icon;return e.jsxs("button",{onClick:()=>p(N.path),onMouseEnter:()=>m(j),className:P("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",j===d?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:[e.jsx(b,{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:N.title}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:N.description})]}),e.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:N.category})]},N.path)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx($t,{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"}),"关闭"]})]})})]})})}function cT(){const a=window.location.protocol==="http:",l=window.location.hostname.toLowerCase(),r=l==="localhost"||l==="127.0.0.1"||l==="::1",c=sessionStorage.getItem("http-warning-dismissed")==="true",[d,m]=u.useState(a&&!r&&!c),[h,f]=u.useState(!1),p=()=>{f(!0),m(!1),sessionStorage.setItem("http-warning-dismissed","true")};return!d||h?null:e.jsx("div",{className:"relative bg-amber-500/10 border-b border-amber-500/20 backdrop-blur-sm",children:e.jsx("div",{className:"container mx-auto px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(Ut,{className:"h-5 w-5 text-amber-600 dark:text-amber-500 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-sm font-medium text-amber-900 dark:text-amber-100",children:[e.jsx("span",{className:"font-semibold",children:"安全警告:"}),"您正在使用 ",e.jsx("strong",{children:"HTTP"})," 访问 MaiBot WebUI"]}),e.jsx("p",{className:"text-xs text-amber-800 dark:text-amber-200 mt-1",children:"如果这是公网服务器,您的数据(包括 Token、聊天记录等)可能在传输过程中被窃取。强烈建议使用 HTTPS 访问或仅在本地网络使用。"})]})]}),e.jsx(_,{variant:"ghost",size:"icon",onClick:p,className:"h-8 w-8 text-amber-700 hover:text-amber-900 dark:text-amber-400 dark:hover:text-amber-200 flex-shrink-0","aria-label":"关闭警告",children:e.jsx(Sa,{className:"h-4 w-4"})})]})})})}function oT(){const[a,l]=u.useState(0),[r,c]=u.useState(!1),d=u.useRef(null);u.useEffect(()=>{const g=N=>{const j=N.target;if(j.scrollHeight>j.clientHeight+100){d.current=j;const b=j.scrollTop,y=j.scrollHeight-j.clientHeight,w=y>0?b/y*100:0;l(w),c(b>300)}};return window.addEventListener("scroll",g,{capture:!0,passive:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})},[]);const m=()=>{d.current?.scrollTo({top:0,behavior:"smooth"})},h=18,f=2*Math.PI*h,p=f-a/100*f;return e.jsx("div",{className:P("fixed bottom-24 right-8 z-50 transition-all duration-500 ease-in-out transform",r?"translate-x-0 opacity-100":"translate-x-32 opacity-0 pointer-events-none"),children:e.jsxs(_,{variant:"outline",size:"icon",className:P("relative h-12 w-12 rounded-full shadow-xl","bg-background/80 backdrop-blur-md border-border/50","hover:bg-accent hover:scale-110 hover:shadow-2xl hover:border-primary/50","transition-all duration-300","group"),onClick:m,"aria-label":"回到顶部",children:[e.jsxs("svg",{className:"absolute inset-0 h-full w-full -rotate-90 transform p-1",viewBox:"0 0 44 44",children:[e.jsx("circle",{className:"text-muted-foreground/10",strokeWidth:"3",stroke:"currentColor",fill:"transparent",r:h,cx:"22",cy:"22"}),e.jsx("circle",{className:"text-primary transition-all duration-100 ease-out",strokeWidth:"3",strokeDasharray:f,strokeDashoffset:p,strokeLinecap:"round",stroke:"currentColor",fill:"transparent",r:h,cx:"22",cy:"22"})]}),e.jsx(a_,{className:"h-5 w-5 text-primary transition-transform duration-300 group-hover:-translate-y-1 group-hover:scale-110",strokeWidth:2.5}),e.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/5 opacity-0 group-hover:opacity-100 transition-opacity duration-300"})]})})}function dT({children:a}){const{checking:l}=aT(),[r,c]=u.useState(!0),[d,m]=u.useState(!1),[h,f]=u.useState(!1),[p,g]=u.useState(!1),{theme:N,setTheme:j}=vx(),b=nw();if(u.useEffect(()=>{if(r)g(!1);else{const S=setTimeout(()=>{g(!0)},350);return()=>clearTimeout(S)}},[r]),u.useEffect(()=>{const S=F=>{(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),f(!0))};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[]),l)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"text-muted-foreground",children:"正在验证登录状态..."})});const y=[{title:"概览",items:[{icon:id,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:Ua,label:"麦麦主程序配置",path:"/config/bot"},{icon:Hl,label:"AI模型厂商配置",path:"/config/modelProvider",tourId:"sidebar-model-provider"},{icon:gv,label:"模型管理与分配",path:"/config/model",tourId:"sidebar-model-management"},{icon:zg,label:"麦麦适配器配置",path:"/config/adapter"}]},{title:"麦麦资源管理",items:[{icon:rd,label:"表情包管理",path:"/resource/emoji"},{icon:Ia,label:"表达方式管理",path:"/resource/expression"},{icon:Wr,label:"黑话管理",path:"/resource/jargon"},{icon:jv,label:"人物信息管理",path:"/resource/person"},{icon:xv,label:"知识库图谱可视化",path:"/resource/knowledge-graph"},{icon:Zr,label:"麦麦知识库管理",path:"/resource/knowledge-base"}]},{title:"扩展与监控",items:[{icon:xa,label:"插件市场",path:"/plugins"},{icon:fv,label:"配置模板市场",path:"/config/pack-market"},{icon:zg,label:"插件配置",path:"/plugin-config"},{icon:ux,label:"日志查看器",path:"/logs"},{icon:nx,label:"计划器&回复器监控",path:"/planner-monitor"},{icon:Ia,label:"本地聊天室",path:"/chat"}]},{title:"系统",items:[{icon:Sn,label:"系统设置",path:"/settings"}]}],z=N==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":N,M=async()=>{await B_()};return e.jsx(Zv,{delayDuration:300,children:e.jsxs("div",{className:"flex h-screen overflow-hidden",children:[e.jsxs("aside",{className:P("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",d?"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:P("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:P("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:v2()})]}),!r&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx(ts,{className:P("flex-1 overflow-x-hidden",!r&&"lg:w-16"),children:e.jsx("nav",{className:P("p-4",!r&&"lg:p-2 lg:w-16"),children:e.jsx("ul",{className:P("space-y-6",!r&&"lg:space-y-3 lg:w-full"),children:y.map((S,F)=>e.jsxs("li",{children:[e.jsx("div",{className:P("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:S.title})}),!r&&F>0&&e.jsx("div",{className:"hidden lg:block mb-2 border-t border-border"}),e.jsx("ul",{className:"space-y-1",children:S.items.map(E=>{const C=b({to:E.path}),R=E.icon,H=e.jsxs(e.Fragment,{children:[C&&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:P("flex items-center transition-all duration-300",r?"gap-3":"gap-3 lg:gap-0"),children:[e.jsx(R,{className:P("h-5 w-5 flex-shrink-0",C&&"text-primary"),strokeWidth:2,fill:"none"}),e.jsx("span",{className:P("text-sm font-medium whitespace-nowrap transition-all duration-300",C&&"font-semibold",r?"opacity-100 max-w-[200px]":"opacity-100 max-w-[200px] lg:opacity-0 lg:max-w-0 lg:overflow-hidden"),children:E.label})]})]});return e.jsx("li",{className:"relative",children:e.jsxs(Wv,{children:[e.jsx(eN,{asChild:!0,children:e.jsx(Kn,{to:E.path,"data-tour":E.tourId,className:P("relative flex items-center rounded-lg py-2 transition-all duration-300","hover:bg-accent hover:text-accent-foreground",C?"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:()=>m(!1),children:H})}),p&&e.jsx(Tx,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:E.label})})]})},E.path)})})]},S.title))})})})]}),d&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>m(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(cT,{}),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:()=>m(!d),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(l_,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>c(!r),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:r?"收起侧边栏":"展开侧边栏",children:e.jsx(Pa,{className:P("h-5 w-5 transition-transform",!r&&"rotate-180")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kn,{to:"/annual-report",children:e.jsxs(_,{variant:"ghost",size:"sm",className:"gap-2 bg-gradient-to-r from-pink-500/10 to-purple-500/10 hover:from-pink-500/20 hover:to-purple-500/20 border border-pink-500/20",title:"查看年度总结",children:[e.jsx(n_,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"hidden sm:inline bg-gradient-to-r from-pink-500 to-purple-500 bg-clip-text text-transparent font-medium",children:"2025 年度总结"})]})}),e.jsxs("button",{onClick:()=>f(!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($t,{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($b,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(iT,{open:h,onOpenChange:f}),e.jsxs(_,{variant:"ghost",size:"sm",onClick:()=>window.open("https://docs.mai-mai.org","_blank"),className:"gap-2",title:"查看麦麦文档",children:[e.jsx(r_,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:S=>{h2(z==="dark"?"light":"dark",j,S)},className:"rounded-lg p-2 hover:bg-accent",title:z==="dark"?"切换到浅色模式":"切换到深色模式",children:z==="dark"?e.jsx(ix,{className:"h-5 w-5"}):e.jsx(tc,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(_,{variant:"ghost",size:"sm",onClick:M,className:"gap-2",title:"登出系统",children:[e.jsx(i_,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:a}),e.jsx(oT,{})]})]})})}function uT(a){const l=a.split(`
|
||
`).slice(1),r=[];for(const c of l){const d=c.trim();if(!d.startsWith("at "))continue;const m=d.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);m?r.push({functionName:m[1]||"<anonymous>",fileName:m[2],lineNumber:m[3],columnNumber:m[4],raw:d}):r.push({functionName:"<unknown>",fileName:"",lineNumber:"",columnNumber:"",raw:d})}return r}function mT({error:a,errorInfo:l}){const[r,c]=u.useState(!0),[d,m]=u.useState(!1),[h,f]=u.useState(!1),p=a.stack?uT(a.stack):[],g=async()=>{const N=`
|
||
Error: ${a.name}
|
||
Message: ${a.message}
|
||
|
||
Stack Trace:
|
||
${a.stack||"No stack trace available"}
|
||
|
||
Component Stack:
|
||
${l?.componentStack||"No component stack available"}
|
||
|
||
URL: ${window.location.href}
|
||
User Agent: ${navigator.userAgent}
|
||
Time: ${new Date().toISOString()}
|
||
`.trim();try{await navigator.clipboard.writeText(N),f(!0),setTimeout(()=>f(!1),2e3)}catch(j){console.error("Failed to copy:",j)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ht,{variant:"destructive",className:"border-red-500/50 bg-red-500/10",children:[e.jsx(Ut,{className:"h-4 w-4"}),e.jsxs(ft,{className:"font-mono text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[a.name,":"]})," ",a.message]})]}),p.length>0&&e.jsxs(xc,{open:r,onOpenChange:c,children:[e.jsx(hc,{asChild:!0,children:e.jsxs(_,{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(c_,{className:"h-4 w-4"}),"Stack Trace (",p.length," frames)"]}),r?e.jsx(Xr,{className:"h-4 w-4"}):e.jsx(Ba,{className:"h-4 w-4"})]})}),e.jsx(fc,{children:e.jsx(ts,{className:"h-[280px] rounded-md border bg-muted/30",children:e.jsx("div",{className:"p-3 space-y-1",children:p.map((N,j)=>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:[j+1,"."]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-primary font-medium",children:N.functionName}),N.fileName&&e.jsxs("div",{className:"text-muted-foreground mt-0.5 break-all",children:[N.fileName,N.lineNumber&&e.jsxs("span",{className:"text-yellow-600 dark:text-yellow-400",children:[":",N.lineNumber,":",N.columnNumber]})]})]})]})},j))})})})]}),l?.componentStack&&e.jsxs(xc,{open:d,onOpenChange:m,children:[e.jsx(hc,{asChild:!0,children:e.jsxs(_,{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(Ut,{className:"h-4 w-4"}),"Component Stack"]}),d?e.jsx(Xr,{className:"h-4 w-4"}):e.jsx(Ba,{className:"h-4 w-4"})]})}),e.jsx(fc,{children:e.jsx(ts,{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:l.componentStack})})})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:g,className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{className:"mr-2 h-4 w-4 text-green-500"}),"已复制到剪贴板"]}):e.jsxs(e.Fragment,{children:[e.jsx(qo,{className:"mr-2 h-4 w-4"}),"复制错误信息"]})})]})}function Bb({error:a,errorInfo:l}){const r=()=>{window.location.href="/"},c=()=>{window.location.reload()};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Te,{className:"w-full max-w-2xl shadow-lg",children:[e.jsxs(Oe,{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(Ut,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),e.jsx(Ue,{className:"text-2xl font-bold",children:"页面出现了问题"}),e.jsx(Ns,{className:"text-base mt-2",children:"应用程序遇到了意外错误。您可以尝试刷新页面或返回首页。"})]}),e.jsxs(ze,{className:"space-y-4",children:[e.jsx(mT,{error:a,errorInfo:l}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-2",children:[e.jsxs(_,{onClick:c,className:"flex-1",children:[e.jsx(dt,{className:"mr-2 h-4 w-4"}),"刷新页面"]}),e.jsxs(_,{onClick:r,variant:"outline",className:"flex-1",children:[e.jsx(id,{className:"mr-2 h-4 w-4"}),"返回首页"]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pt-2",children:"如果问题持续存在,请将错误信息复制并反馈给开发者"})]})]})})}class xT extends u.Component{constructor(l){super(l),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(l){return{hasError:!0,error:l}}componentDidCatch(l,r){console.error("ErrorBoundary caught an error:",l,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(Bb,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}function Ib({error:a}){return e.jsx(Bb,{error:a,errorInfo:null})}const bc=rw({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(xj,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!lT())throw cw({to:"/auth"})}}),hT=lt({getParentRoute:()=>bc,path:"/auth",component:O2}),fT=lt({getParentRoute:()=>bc,path:"/setup",component:X2}),Nt=lt({getParentRoute:()=>bc,id:"protected",component:()=>e.jsx(dT,{children:e.jsx(xj,{})}),errorComponent:({error:a})=>e.jsx(Ib,{error:a})}),pT=lt({getParentRoute:()=>Nt,path:"/",component:d2}),gT=lt({getParentRoute:()=>Nt,path:"/config/bot",component:YS}),jT=lt({getParentRoute:()=>Nt,path:"/config/modelProvider",component:i4}),vT=lt({getParentRoute:()=>Nt,path:"/config/model",component:z4}),NT=lt({getParentRoute:()=>Nt,path:"/config/adapter",component:L4}),bT=lt({getParentRoute:()=>Nt,path:"/resource/emoji",component:nk}),yT=lt({getParentRoute:()=>Nt,path:"/resource/expression",component:ok}),wT=lt({getParentRoute:()=>Nt,path:"/resource/person",component:Rk}),_T=lt({getParentRoute:()=>Nt,path:"/resource/jargon",component:wk}),ST=lt({getParentRoute:()=>Nt,path:"/resource/knowledge-graph",component:Fk}),kT=lt({getParentRoute:()=>Nt,path:"/resource/knowledge-base",component:Hk}),CT=lt({getParentRoute:()=>Nt,path:"/logs",component:Vk}),TT=lt({getParentRoute:()=>Nt,path:"/planner-monitor",component:eC}),ET=lt({getParentRoute:()=>Nt,path:"/chat",component:BC}),MT=lt({getParentRoute:()=>Nt,path:"/plugins",component:NC}),AT=lt({getParentRoute:()=>Nt,path:"/plugin-detail",component:MC}),zT=lt({getParentRoute:()=>Nt,path:"/model-presets",component:yC}),RT=lt({getParentRoute:()=>Nt,path:"/plugin-config",component:SC}),DT=lt({getParentRoute:()=>Nt,path:"/plugin-mirrors",component:CC}),OT=lt({getParentRoute:()=>Nt,path:"/settings",component:T2}),LT=lt({getParentRoute:()=>Nt,path:"/config/pack-market",component:$5}),Pb=lt({getParentRoute:()=>Nt,path:"/config/pack-market/$packId",component:eT}),UT=lt({getParentRoute:()=>Nt,path:"/survey/webui-feedback",component:s3}),$T=lt({getParentRoute:()=>Nt,path:"/survey/maibot-feedback",component:t3}),BT=lt({getParentRoute:()=>Nt,path:"/annual-report",component:c5}),IT=lt({getParentRoute:()=>bc,path:"*",component:Kv}),PT=bc.addChildren([hT,fT,Nt.addChildren([pT,gT,jT,vT,NT,bT,yT,_T,wT,ST,kT,MT,AT,zT,RT,DT,CT,TT,ET,OT,LT,Pb,UT,$T,BT]),IT]),FT=iw({routeTree:PT,defaultNotFoundComponent:Kv,defaultErrorComponent:({error:a})=>e.jsx(Ib,{error:a})});function HT({children:a,defaultTheme:l="system",storageKey:r="ui-theme",...c}){const[d,m]=u.useState(()=>localStorage.getItem(r)||l);u.useEffect(()=>{const f=window.document.documentElement;if(f.classList.remove("light","dark"),d==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(p);return}f.classList.add(d)},[d]),u.useEffect(()=>{const f=localStorage.getItem("accent-color");if(f){const p=document.documentElement,N={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%)"}}[f];N&&(p.style.setProperty("--primary",N.hsl),N.gradient?(p.style.setProperty("--primary-gradient",N.gradient),p.classList.add("has-gradient")):(p.style.removeProperty("--primary-gradient"),p.classList.remove("has-gradient")))}},[]);const h={theme:d,setTheme:f=>{localStorage.setItem(r,f),m(f)}};return e.jsx(Fv.Provider,{...c,value:h,children:a})}function qT({children:a,defaultEnabled:l=!0,defaultWavesEnabled:r=!0,storageKey:c="enable-animations",wavesStorageKey:d="enable-waves-background"}){const[m,h]=u.useState(()=>{const N=localStorage.getItem(c);return N!==null?N==="true":l}),[f,p]=u.useState(()=>{const N=localStorage.getItem(d);return N!==null?N==="true":r});u.useEffect(()=>{const N=document.documentElement;m?N.classList.remove("no-animations"):N.classList.add("no-animations"),localStorage.setItem(c,String(m))},[m,c]),u.useEffect(()=>{localStorage.setItem(d,String(f))},[f,d]);const g={enableAnimations:m,setEnableAnimations:h,enableWavesBackground:f,setEnableWavesBackground:p};return e.jsx(Hv.Provider,{value:g,children:a})}function VT(a){const[l,r]=u.useState(()=>typeof window<"u"?window.matchMedia(a).matches:!1);return u.useEffect(()=>{if(typeof window>"u")return;const c=window.matchMedia(a),d=m=>{r(m.matches)};return r(c.matches),c.addEventListener("change",d),()=>{c.removeEventListener("change",d)}},[a]),l}function Bx(){return VT("(max-width: 768px)")}const GT=k1,Fb=u.forwardRef(({className:a,...l},r)=>{const c=Bx();return e.jsx(ev,{ref:r,className:P("fixed z-[100] flex max-h-screen w-full gap-2 p-4",c?"top-0 left-0 right-0 flex-col items-center":"bottom-0 right-0 flex-col-reverse sm:max-w-[420px]",a),...l})});Fb.displayName=ev.displayName;const KT=ti("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",{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"},position:{desktop:"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",mobile:"data-[swipe=cancel]:translate-y-0 data-[swipe=end]:translate-y-[var(--radix-toast-swipe-end-y)] data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=move]:transition-none data-[state=open]:animate-slide-in-from-top data-[state=open]:animate-fade-in data-[state=closed]:animate-slide-out-to-top data-[state=closed]:animate-fade-out data-[swipe=end]:animate-slide-out-to-top"}},defaultVariants:{variant:"default",position:"desktop"}}),Hb=u.forwardRef(({className:a,variant:l,...r},c)=>{const m=Bx()?"mobile":"desktop";return e.jsx(sv,{ref:c,className:P(KT({variant:l,position:m}),a),...r})});Hb.displayName=sv.displayName;const QT=u.forwardRef(({className:a,...l},r)=>e.jsx(tv,{ref:r,className:P("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",a),...l}));QT.displayName=tv.displayName;const qb=u.forwardRef(({className:a,...l},r)=>e.jsx(av,{ref:r,className:P("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",a),"toast-close":"",...l,children:e.jsx(Sa,{className:"h-4 w-4"})}));qb.displayName=av.displayName;const Vb=u.forwardRef(({className:a,...l},r)=>e.jsx(lv,{ref:r,className:P("text-sm font-semibold [&+div]:text-xs",a),...l}));Vb.displayName=lv.displayName;const Gb=u.forwardRef(({className:a,...l},r)=>e.jsx(nv,{ref:r,className:P("text-sm opacity-90",a),...l}));Gb.displayName=nv.displayName;function YT(){const{toasts:a}=nt(),l=Bx();return e.jsxs(GT,{swipeDirection:l?"up":"right",children:[a.map(function({id:r,title:c,description:d,action:m,...h}){return e.jsxs(Hb,{...h,children:[e.jsxs("div",{className:"grid gap-1",children:[c&&e.jsx(Vb,{children:c}),d&&e.jsx(Gb,{children:d})]}),m,e.jsx(qb,{})]},r)}),e.jsx(Fb,{})]})}$_.createRoot(document.getElementById("root")).render(e.jsx(u.StrictMode,{children:e.jsx(xT,{children:e.jsx(HT,{defaultTheme:"system",children:e.jsx(qT,{children:e.jsxs(s4,{children:[e.jsx(ow,{router:FT}),e.jsx(l4,{}),e.jsx(YT,{})]})})})})}));
|