mirror of https://github.com/Mai-with-u/MaiBot.git
91 lines
972 KiB
JavaScript
91 lines
972 KiB
JavaScript
import{r as d,j as e,L as Bn,e as ca,R as As,b as N0,f as b0,g as y0,h as w0,k as _0,l as Qs,m as S0,n as k0,O as Pg,o as C0}from"./router-9vIXuQkh.js";import{a as T0,b as E0,g as M0}from"./react-vendor-BmxF9s7Q.js";import{N as z0,c as A0,O as Qr,P as O0,g as Nm}from"./utils-BqoaXoQ1.js";import{L as Hg,T as Fg,C as Gg,R as D0,a as Vg,V as R0,b as L0,S as qg,c as U0,d as Kg,I as $0,e as Qg,f as B0,g as Yg,h as I0,i as P0,j as H0,O as Jg,P as F0,k as Xg,l as Zg,D as Wg,A as ej,m as sj,n as G0,o as V0,p as tj,q as q0,r as aj,s as K0,t as Q0,u as lj,v as Y0,w as J0,x as nj,y as rj,F as ij,z as cj,B as X0,E as Z0,G as oj,H as W0,J as ew,K as sw,M as tw,N as aw,Q as lw,U as nw,W as rw,X as iw,Y as cw,Z as ow,_ as dw,$ as uw,a0 as mw,a1 as xw,a2 as dj,a3 as hw,a4 as fw}from"./radix-extra-DmmnfeQE.js";import{R as uj,T as mj,L as pw,g as gw,C as Fi,X as Gi,Y as $r,h as jw,B as Ao,j as Vi,P as vw,k as Nw,l as bw}from"./charts-simvewUa.js";import{S as yw,O as xj,o as ww,C as hj,p as _w,T as fj,D as pj,R as Sw,q as kw,H as gj,I as Cw,J as jj,K as Tw,L as vj,M as Nj,N as Ew,Q as bj,V as Mw,U as yj,X as wj,Y as zw,Z as Aw,_ as _j,$ as Ow,a0 as Dw,a1 as Sj,e as kj,f as Qo,c as Yo,P as Yn,d as Jo,b as hn,h as Rw,l as Lw,m as Uw,u as Um,r as $w,a as Bw,a2 as Iw,a3 as Cj,a4 as Pw,a5 as Hw,a6 as Fw,a7 as Tj,a8 as Ej,a9 as Mj,aa as zj,ab as Aj,ac as Oj,ad as Gw}from"./radix-core-DyJi0yyw.js";import{R as dt,a as Wi,C as _t,b as pt,L as Bs,X as Ea,c as Ct,d as Ma,e as Fr,f as Aa,g as Zt,E as Vw,h as na,i as Va,S as Tt,B as Pn,U as fn,P as oc,Z as Za,j as Dj,F as Ca,k as qw,l as pn,m as Kw,M as za,A as Vm,D as Qw,n as Gr,T as qm,o as Yw,p as Rj,I as Ht,q as Jt,r as Uo,s as ec,t as ia,H as Jw,u as ns,v as sa,w as sc,x as Km,y as Yi,z as og,K as Qm,G as Lj,J as Xw,N as Oo,O as Zw,Q as Xo,V as Ww,W as e_,Y as Zo,_ as Ta,$ as et,a0 as Ym,a1 as Uj,a2 as dc,a3 as $j,a4 as Bj,a5 as Gn,a6 as gn,a7 as jn,a8 as Jm,a9 as Ij,aa as ra,ab as Dl,ac as Vn,ad as qn,ae as Wo,af as s_,ag as t_,ah as a_,ai as Xm,aj as Do,ak as Kn,al as l_,am as Vr,an as $o,ao as n_,ap as Bo,aq as tc,ar as Pj,as as r_,at as i_,au as Io,av as c_,aw as Zm,ax as o_,ay as dg,az as d_,aA as u_,aB as Hj,aC as m_,aD as dn,aE as Fj,aF as bm,aG as ug,aH as x_,aI as ym,aJ as h_,aK as f_,aL as p_,aM as g_,aN as Gj,aO as j_,aP as qr,aQ as v_,aR as N_,aS as Vj,aT as qj,aU as b_,aV as y_,aW as mg,aX as w_,aY as __,aZ as S_,a_ as k_,a$ as C_}from"./icons-9Z4kBNLK.js";import{S as T_,p as E_,j as M_,a as z_,E as xg,R as A_,o as O_}from"./codemirror-TZqPU532.js";import{u as Kj,a as Po,s as Qj,K as Yj,P as Jj,b as Xj,D as Zj,c as Wj,S as ev,v as D_,d as sv,C as tv,h as R_}from"./dnd-BiPfFtVp.js";import{_ as ga,c as L_,g as av,D as U_,z as To}from"./misc-CJqnlRwD.js";import{D as $_,U as B_}from"./uppy-DFP_VzYR.js";import{M as I_,r as P_,a as H_,b as F_}from"./markdown-CKA5gBQ9.js";import{c as G_,H as Ho,P as Fo,u as V_,d as q_,R as K_,B as Q_,e as Y_,C as J_,M as X_,f as Z_}from"./reactflow-DtsZHOR4.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))c(u);new MutationObserver(u=>{for(const x of u)if(x.type==="childList")for(const h of x.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function i(u){const x={};return u.integrity&&(x.integrity=u.integrity),u.referrerPolicy&&(x.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?x.credentials="include":u.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function c(u){if(u.ep)return;u.ep=!0;const x=i(u);fetch(u.href,x)}})();var wm={exports:{}},Ii={},_m={exports:{}},Sm={};var hg;function W_(){return hg||(hg=1,(function(l){function n(M,K){var I=M.length;M.push(K);e:for(;0<I;){var ue=I-1>>>1,Q=M[ue];if(0<u(Q,K))M[ue]=K,M[I]=Q,I=ue;else break e}}function i(M){return M.length===0?null:M[0]}function c(M){if(M.length===0)return null;var K=M[0],I=M.pop();if(I!==K){M[0]=I;e:for(var ue=0,Q=M.length,Se=Q>>>1;ue<Se;){var pe=2*(ue+1)-1,Te=M[pe],A=pe+1,D=M[A];if(0>u(Te,I))A<Q&&0>u(D,Te)?(M[ue]=D,M[A]=I,ue=A):(M[ue]=Te,M[pe]=I,ue=pe);else if(A<Q&&0>u(D,I))M[ue]=D,M[A]=I,ue=A;else break e}}return K}function u(M,K){var I=M.sortIndex-K.sortIndex;return I!==0?I:M.id-K.id}if(l.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var x=performance;l.unstable_now=function(){return x.now()}}else{var h=Date,f=h.now();l.unstable_now=function(){return h.now()-f}}var p=[],g=[],N=1,v=null,b=3,w=!1,y=!1,R=!1,O=!1,S=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function C(M){for(var K=i(g);K!==null;){if(K.callback===null)c(g);else if(K.startTime<=M)c(g),K.sortIndex=K.expirationTime,n(p,K);else break;K=i(g)}}function z(M){if(R=!1,C(M),!y)if(i(p)!==null)y=!0,H||(H=!0,je());else{var K=i(g);K!==null&&ge(z,K.startTime-M)}}var H=!1,L=-1,J=5,U=-1;function oe(){return O?!0:!(l.unstable_now()-U<J)}function Ne(){if(O=!1,H){var M=l.unstable_now();U=M;var K=!0;try{e:{y=!1,R&&(R=!1,B(L),L=-1),w=!0;var I=b;try{s:{for(C(M),v=i(p);v!==null&&!(v.expirationTime>M&&oe());){var ue=v.callback;if(typeof ue=="function"){v.callback=null,b=v.priorityLevel;var Q=ue(v.expirationTime<=M);if(M=l.unstable_now(),typeof Q=="function"){v.callback=Q,C(M),K=!0;break s}v===i(p)&&c(p),C(M)}else c(p);v=i(p)}if(v!==null)K=!0;else{var Se=i(g);Se!==null&&ge(z,Se.startTime-M),K=!1}}break e}finally{v=null,b=I,w=!1}K=void 0}}finally{K?je():H=!1}}}var je;if(typeof E=="function")je=function(){E(Ne)};else if(typeof MessageChannel<"u"){var re=new MessageChannel,fe=re.port2;re.port1.onmessage=Ne,je=function(){fe.postMessage(null)}}else je=function(){S(Ne,0)};function ge(M,K){L=S(function(){M(l.unstable_now())},K)}l.unstable_IdlePriority=5,l.unstable_ImmediatePriority=1,l.unstable_LowPriority=4,l.unstable_NormalPriority=3,l.unstable_Profiling=null,l.unstable_UserBlockingPriority=2,l.unstable_cancelCallback=function(M){M.callback=null},l.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):J=0<M?Math.floor(1e3/M):5},l.unstable_getCurrentPriorityLevel=function(){return b},l.unstable_next=function(M){switch(b){case 1:case 2:case 3:var K=3;break;default:K=b}var I=b;b=K;try{return M()}finally{b=I}},l.unstable_requestPaint=function(){O=!0},l.unstable_runWithPriority=function(M,K){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var I=b;b=M;try{return K()}finally{b=I}},l.unstable_scheduleCallback=function(M,K,I){var ue=l.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?ue+I:ue):I=ue,M){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=I+Q,M={id:N++,callback:K,priorityLevel:M,startTime:I,expirationTime:Q,sortIndex:-1},I>ue?(M.sortIndex=I,n(g,M),i(p)===null&&M===i(g)&&(R?(B(L),L=-1):R=!0,ge(z,I-ue))):(M.sortIndex=Q,n(p,M),y||w||(y=!0,H||(H=!0,je()))),M},l.unstable_shouldYield=oe,l.unstable_wrapCallback=function(M){var K=b;return function(){var I=b;b=K;try{return M.apply(this,arguments)}finally{b=I}}}})(Sm)),Sm}var fg;function e1(){return fg||(fg=1,_m.exports=W_()),_m.exports}var pg;function s1(){if(pg)return Ii;pg=1;var l=e1(),n=T0(),i=E0();function c(s){var t="https://react.dev/errors/"+s;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+s+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function u(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function x(s){var t=s,a=s;if(s.alternate)for(;t.return;)t=t.return;else{s=t;do t=s,(t.flags&4098)!==0&&(a=t.return),s=t.return;while(s)}return t.tag===3?a:null}function 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(x(s)!==s)throw Error(c(188))}function g(s){var t=s.alternate;if(!t){if(t=x(s),t===null)throw Error(c(188));return t!==s?null:s}for(var a=s,r=t;;){var o=a.return;if(o===null)break;var m=o.alternate;if(m===null){if(r=o.return,r!==null){a=r;continue}break}if(o.child===m.child){for(m=o.child;m;){if(m===a)return p(o),s;if(m===r)return p(o),t;m=m.sibling}throw Error(c(188))}if(a.return!==r.return)a=o,r=m;else{for(var j=!1,k=o.child;k;){if(k===a){j=!0,a=o,r=m;break}if(k===r){j=!0,r=o,a=m;break}k=k.sibling}if(!j){for(k=m.child;k;){if(k===a){j=!0,a=m,r=o;break}if(k===r){j=!0,r=m,a=o;break}k=k.sibling}if(!j)throw Error(c(189))}}if(a.alternate!==r)throw Error(c(190))}if(a.tag!==3)throw Error(c(188));return a.stateNode.current===a?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 v=Object.assign,b=Symbol.for("react.element"),w=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),B=Symbol.for("react.consumer"),E=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),oe=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 re=Symbol.for("react.client.reference");function fe(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===re?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case R:return"Fragment";case S:return"Profiler";case O:return"StrictMode";case z:return"Suspense";case H:return"SuspenseList";case U:return"Activity"}if(typeof s=="object")switch(s.$$typeof){case y:return"Portal";case E:return s.displayName||"Context";case B: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 L:return t=s.displayName||null,t!==null?t:fe(s.type)||"Memo";case J:t=s._payload,s=s._init;try{return fe(s(t))}catch{}}return null}var ge=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},ue=[],Q=-1;function Se(s){return{current:s}}function pe(s){0>Q||(s.current=ue[Q],ue[Q]=null,Q--)}function Te(s,t){Q++,ue[Q]=s.current,s.current=t}var A=Se(null),D=Se(null),V=Se(null),de=Se(null);function Oe(s,t){switch(Te(V,t),Te(D,s),Te(A,null),t.nodeType){case 9:case 11:s=(s=t.documentElement)&&(s=s.namespaceURI)?Ap(s):0;break;default:if(s=t.tagName,t=t.namespaceURI)t=Ap(t),s=Op(t,s);else switch(s){case"svg":s=1;break;case"math":s=2;break;default:s=0}}pe(A),Te(A,s)}function W(){pe(A),pe(D),pe(V)}function Y(s){s.memoizedState!==null&&Te(de,s);var t=A.current,a=Op(t,s.type);t!==a&&(Te(D,s),Te(A,a))}function He(s){D.current===s&&(pe(A),pe(D)),de.current===s&&(pe(de),Li._currentValue=I)}var F,ee;function Ue(s){if(F===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);F=t&&t[1]||"",ee=-1<a.stack.indexOf(`
|
||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||
`+F+s+ee}var ie=!1;function Ee(s,t){if(!s||ie)return"";ie=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={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(xe){var ce=xe}Reflect.construct(s,[],ye)}else{try{ye.call()}catch(xe){ce=xe}s.call(ye.prototype)}}else{try{throw Error()}catch(xe){ce=xe}(ye=s())&&typeof ye.catch=="function"&&ye.catch(function(){})}}catch(xe){if(xe&&ce&&typeof xe.stack=="string")return[xe.stack,ce.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var o=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");o&&o.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=r.DetermineComponentFrameRoot(),j=m[0],k=m[1];if(j&&k){var $=j.split(`
|
||
`),le=k.split(`
|
||
`);for(o=r=0;r<$.length&&!$[r].includes("DetermineComponentFrameRoot");)r++;for(;o<le.length&&!le[o].includes("DetermineComponentFrameRoot");)o++;if(r===$.length||o===le.length)for(r=$.length-1,o=le.length-1;1<=r&&0<=o&&$[r]!==le[o];)o--;for(;1<=r&&0<=o;r--,o--)if($[r]!==le[o]){if(r!==1||o!==1)do if(r--,o--,0>o||$[r]!==le[o]){var ve=`
|
||
`+$[r].replace(" at new "," at ");return s.displayName&&ve.includes("<anonymous>")&&(ve=ve.replace("<anonymous>",s.displayName)),ve}while(1<=r&&0<=o);break}}}finally{ie=!1,Error.prepareStackTrace=a}return(a=s?s.displayName||s.name:"")?Ue(a):""}function me(s,t){switch(s.tag){case 26:case 27:case 5:return Ue(s.type);case 16:return Ue("Lazy");case 13:return s.child!==t&&t!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return Ee(s.type,!1);case 11:return Ee(s.type.render,!1);case 1:return Ee(s.type,!0);case 31:return Ue("Activity");default:return""}}function ze(s){try{var t="",a=null;do t+=me(s,a),a=s,s=s.return;while(s);return t}catch(r){return`
|
||
Error generating stack: `+r.message+`
|
||
`+r.stack}}var rs=Object.prototype.hasOwnProperty,Ut=l.unstable_scheduleCallback,aa=l.unstable_cancelCallback,Qa=l.unstable_shouldYield,Ft=l.unstable_requestPaint,mt=l.unstable_now,q=l.unstable_getCurrentPriorityLevel,qe=l.unstable_ImmediatePriority,Qe=l.unstable_UserBlockingPriority,es=l.unstable_NormalPriority,Ls=l.unstable_LowPriority,as=l.unstable_IdlePriority,Cs=l.log,Ae=l.unstable_setDisableYieldValue,bs=null,ls=null;function ss(s){if(typeof Cs=="function"&&Ae(s),ls&&typeof ls.setStrictMode=="function")try{ls.setStrictMode(bs,s)}catch{}}var ys=Math.clz32?Math.clz32:tt,gt=Math.log,$t=Math.LN2;function tt(s){return s>>>=0,s===0?32:31-(gt(s)/$t|0)|0}var Ms=256,Et=262144,Bt=4194304;function Oa(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 tl(s,t,a){var r=s.pendingLanes;if(r===0)return 0;var o=0,m=s.suspendedLanes,j=s.pingedLanes;s=s.warmLanes;var k=r&134217727;return k!==0?(r=k&~m,r!==0?o=Oa(r):(j&=k,j!==0?o=Oa(j):a||(a=k&~s,a!==0&&(o=Oa(a))))):(k=r&~m,k!==0?o=Oa(k):j!==0?o=Oa(j):a||(a=r&~s,a!==0&&(o=Oa(a)))),o===0?0:t!==0&&t!==o&&(t&m)===0&&(m=o&-o,a=t&-t,m>=a||m===32&&(a&4194048)!==0)?t:o}function ul(s,t){return(s.pendingLanes&~(s.suspendedLanes&~s.pingedLanes)&t)===0}function Zn(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 se(){var s=Bt;return Bt<<=1,(Bt&62914560)===0&&(Bt=4194304),s}function we(s){for(var t=[],a=0;31>a;a++)t.push(s);return t}function Le(s,t){s.pendingLanes|=t,t!==268435456&&(s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0)}function Hs(s,t,a,r,o,m){var j=s.pendingLanes;s.pendingLanes=a,s.suspendedLanes=0,s.pingedLanes=0,s.warmLanes=0,s.expiredLanes&=a,s.entangledLanes&=a,s.errorRecoveryDisabledLanes&=a,s.shellSuspendCounter=0;var k=s.entanglements,$=s.expirationTimes,le=s.hiddenUpdates;for(a=j&~a;0<a;){var ve=31-ys(a),ye=1<<ve;k[ve]=0,$[ve]=-1;var ce=le[ve];if(ce!==null)for(le[ve]=null,ve=0;ve<ce.length;ve++){var xe=ce[ve];xe!==null&&(xe.lane&=-536870913)}a&=~ye}r!==0&&Dt(s,r,0),m!==0&&o===0&&s.tag!==0&&(s.suspendedLanes|=m&~(j&~t))}function Dt(s,t,a){s.pendingLanes|=t,s.suspendedLanes&=~t;var r=31-ys(t);s.entangledLanes|=t,s.entanglements[r]=s.entanglements[r]|1073741824|a&261930}function Wt(s,t){var a=s.entangledLanes|=t;for(s=s.entanglements;a;){var r=31-ys(a),o=1<<r;o&t|s[r]&t&&(s[r]|=t),a&=~o}}function rt(s,t){var a=t&-t;return a=(a&42)!==0?1:ea(a),(a&(s.suspendedLanes|t))!==0?0:a}function ea(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 xt(s){return s&=-s,2<s?8<s?(s&134217727)!==0?32:268435456:8:2}function ne(){var s=K.p;return s!==0?s:(s=window.event,s===void 0?32:tg(s.type))}function he(s,t){var a=K.p;try{return K.p=s,t()}finally{K.p=a}}var ts=Math.random().toString(36).slice(2),js="__reactFiber$"+ts,is="__reactProps$"+ts,jt="__reactContainer$"+ts,ja="__reactEvents$"+ts,Bl="__reactListeners$"+ts,Wn="__reactHandles$"+ts,Xr="__reactResources$"+ts,bn="__reactMarker$"+ts;function md(s){delete s[js],delete s[is],delete s[ja],delete s[Bl],delete s[Wn]}function er(s){var t=s[js];if(t)return t;for(var a=s.parentNode;a;){if(t=a[jt]||a[js]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(s=Ip(s);s!==null;){if(a=s[js])return a;s=Ip(s)}return t}s=a,a=s.parentNode}return null}function sr(s){if(s=s[js]||s[jt]){var t=s.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return s}return null}function Zr(s){var t=s.tag;if(t===5||t===26||t===27||t===6)return s.stateNode;throw Error(c(33))}function tr(s){var t=s[Xr];return t||(t=s[Xr]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function It(s){s[bn]=!0}var vx=new Set,Nx={};function yn(s,t){ar(s,t),ar(s+"Capture",t)}function ar(s,t){for(Nx[s]=t,s=0;s<t.length;s++)vx.add(t[s])}var ub=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]*$"),bx={},yx={};function mb(s){return rs.call(yx,s)?!0:rs.call(bx,s)?!1:ub.test(s)?yx[s]=!0:(bx[s]=!0,!1)}function fc(s,t,a){if(mb(t))if(a===null)s.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":s.removeAttribute(t);return;case"boolean":var r=t.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){s.removeAttribute(t);return}}s.setAttribute(t,""+a)}}function pc(s,t,a){if(a===null)s.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(t);return}s.setAttribute(t,""+a)}}function ml(s,t,a,r){if(r===null)s.removeAttribute(a);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":s.removeAttribute(a);return}s.setAttributeNS(t,a,""+r)}}function Da(s){switch(typeof s){case"bigint":case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function wx(s){var t=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function xb(s,t,a){var r=Object.getOwnPropertyDescriptor(s.constructor.prototype,t);if(!s.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var o=r.get,m=r.set;return Object.defineProperty(s,t,{configurable:!0,get:function(){return o.call(this)},set:function(j){a=""+j,m.call(this,j)}}),Object.defineProperty(s,t,{enumerable:r.enumerable}),{getValue:function(){return a},setValue:function(j){a=""+j},stopTracking:function(){s._valueTracker=null,delete s[t]}}}}function xd(s){if(!s._valueTracker){var t=wx(s)?"checked":"value";s._valueTracker=xb(s,t,""+s[t])}}function _x(s){if(!s)return!1;var t=s._valueTracker;if(!t)return!0;var a=t.getValue(),r="";return s&&(r=wx(s)?s.checked?"true":"false":s.value),s=r,s!==a?(t.setValue(s),!0):!1}function gc(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 hb=/[\n"\\]/g;function Ra(s){return s.replace(hb,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function hd(s,t,a,r,o,m,j,k){s.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?s.type=j:s.removeAttribute("type"),t!=null?j==="number"?(t===0&&s.value===""||s.value!=t)&&(s.value=""+Da(t)):s.value!==""+Da(t)&&(s.value=""+Da(t)):j!=="submit"&&j!=="reset"||s.removeAttribute("value"),t!=null?fd(s,j,Da(t)):a!=null?fd(s,j,Da(a)):r!=null&&s.removeAttribute("value"),o==null&&m!=null&&(s.defaultChecked=!!m),o!=null&&(s.checked=o&&typeof o!="function"&&typeof o!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?s.name=""+Da(k):s.removeAttribute("name")}function Sx(s,t,a,r,o,m,j,k){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(s.type=m),t!=null||a!=null){if(!(m!=="submit"&&m!=="reset"||t!=null)){xd(s);return}a=a!=null?""+Da(a):"",t=t!=null?""+Da(t):a,k||t===s.value||(s.value=t),s.defaultValue=t}r=r??o,r=typeof r!="function"&&typeof r!="symbol"&&!!r,s.checked=k?s.checked:!!r,s.defaultChecked=!!r,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(s.name=j),xd(s)}function fd(s,t,a){t==="number"&&gc(s.ownerDocument)===s||s.defaultValue===""+a||(s.defaultValue=""+a)}function lr(s,t,a,r){if(s=s.options,t){t={};for(var o=0;o<a.length;o++)t["$"+a[o]]=!0;for(a=0;a<s.length;a++)o=t.hasOwnProperty("$"+s[a].value),s[a].selected!==o&&(s[a].selected=o),o&&r&&(s[a].defaultSelected=!0)}else{for(a=""+Da(a),t=null,o=0;o<s.length;o++){if(s[o].value===a){s[o].selected=!0,r&&(s[o].defaultSelected=!0);return}t!==null||s[o].disabled||(t=s[o])}t!==null&&(t.selected=!0)}}function kx(s,t,a){if(t!=null&&(t=""+Da(t),t!==s.value&&(s.value=t),a==null)){s.defaultValue!==t&&(s.defaultValue=t);return}s.defaultValue=a!=null?""+Da(a):""}function Cx(s,t,a,r){if(t==null){if(r!=null){if(a!=null)throw Error(c(92));if(ge(r)){if(1<r.length)throw Error(c(93));r=r[0]}a=r}a==null&&(a=""),t=a}a=Da(t),s.defaultValue=a,r=s.textContent,r===a&&r!==""&&r!==null&&(s.value=r),xd(s)}function nr(s,t){if(t){var a=s.firstChild;if(a&&a===s.lastChild&&a.nodeType===3){a.nodeValue=t;return}}s.textContent=t}var fb=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 Tx(s,t,a){var r=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?r?s.setProperty(t,""):t==="float"?s.cssFloat="":s[t]="":r?s.setProperty(t,a):typeof a!="number"||a===0||fb.has(t)?t==="float"?s.cssFloat=a:s[t]=(""+a).trim():s[t]=a+"px"}function Ex(s,t,a){if(t!=null&&typeof t!="object")throw Error(c(62));if(s=s.style,a!=null){for(var r in a)!a.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf("--")===0?s.setProperty(r,""):r==="float"?s.cssFloat="":s[r]="");for(var o in t)r=t[o],t.hasOwnProperty(o)&&a[o]!==r&&Tx(s,o,r)}else for(var m in t)t.hasOwnProperty(m)&&Tx(s,m,t[m])}function pd(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 pb=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"]]),gb=/^[\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 jc(s){return gb.test(""+s)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":s}function xl(){}var gd=null;function jd(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var rr=null,ir=null;function Mx(s){var t=sr(s);if(t&&(s=t.stateNode)){var a=s[is]||null;e:switch(s=t.stateNode,t.type){case"input":if(hd(s,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=s;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+Ra(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var r=a[t];if(r!==s&&r.form===s.form){var o=r[is]||null;if(!o)throw Error(c(90));hd(r,o.value,o.defaultValue,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name)}}for(t=0;t<a.length;t++)r=a[t],r.form===s.form&&_x(r)}break e;case"textarea":kx(s,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&lr(s,!!a.multiple,t,!1)}}}var vd=!1;function zx(s,t,a){if(vd)return s(t,a);vd=!0;try{var r=s(t);return r}finally{if(vd=!1,(rr!==null||ir!==null)&&(no(),rr&&(t=rr,s=ir,ir=rr=null,Mx(t),s)))for(t=0;t<s.length;t++)Mx(s[t])}}function Wr(s,t){var a=s.stateNode;if(a===null)return null;var r=a[is]||null;if(r===null)return null;a=r[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":(r=!r.disabled)||(s=s.type,r=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!r;break e;default:s=!1}if(s)return null;if(a&&typeof a!="function")throw Error(c(231,t,typeof a));return a}var hl=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nd=!1;if(hl)try{var ei={};Object.defineProperty(ei,"passive",{get:function(){Nd=!0}}),window.addEventListener("test",ei,ei),window.removeEventListener("test",ei,ei)}catch{Nd=!1}var Il=null,bd=null,vc=null;function Ax(){if(vc)return vc;var s,t=bd,a=t.length,r,o="value"in Il?Il.value:Il.textContent,m=o.length;for(s=0;s<a&&t[s]===o[s];s++);var j=a-s;for(r=1;r<=j&&t[a-r]===o[m-r];r++);return vc=o.slice(s,1<r?1-r:void 0)}function Nc(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 bc(){return!0}function Ox(){return!1}function da(s){function t(a,r,o,m,j){this._reactName=a,this._targetInst=o,this.type=r,this.nativeEvent=m,this.target=j,this.currentTarget=null;for(var k in s)s.hasOwnProperty(k)&&(a=s[k],this[k]=a?a(m):m[k]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?bc:Ox,this.isPropagationStopped=Ox,this}return v(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=bc)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=bc)},persist:function(){},isPersistent:bc}),t}var wn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yc=da(wn),si=v({},wn,{view:0,detail:0}),jb=da(si),yd,wd,ti,wc=v({},si,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sd,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!==ti&&(ti&&s.type==="mousemove"?(yd=s.screenX-ti.screenX,wd=s.screenY-ti.screenY):wd=yd=0,ti=s),yd)},movementY:function(s){return"movementY"in s?s.movementY:wd}}),Dx=da(wc),vb=v({},wc,{dataTransfer:0}),Nb=da(vb),bb=v({},si,{relatedTarget:0}),_d=da(bb),yb=v({},wn,{animationName:0,elapsedTime:0,pseudoElement:0}),wb=da(yb),_b=v({},wn,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),Sb=da(_b),kb=v({},wn,{data:0}),Rx=da(kb),Cb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Tb={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"},Eb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Mb(s){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(s):(s=Eb[s])?!!t[s]:!1}function Sd(){return Mb}var zb=v({},si,{key:function(s){if(s.key){var t=Cb[s.key]||s.key;if(t!=="Unidentified")return t}return s.type==="keypress"?(s=Nc(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?Tb[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sd,charCode:function(s){return s.type==="keypress"?Nc(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Nc(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),Ab=da(zb),Ob=v({},wc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Lx=da(Ob),Db=v({},si,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sd}),Rb=da(Db),Lb=v({},wn,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ub=da(Lb),$b=v({},wc,{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}),Bb=da($b),Ib=v({},wn,{newState:0,oldState:0}),Pb=da(Ib),Hb=[9,13,27,32],kd=hl&&"CompositionEvent"in window,ai=null;hl&&"documentMode"in document&&(ai=document.documentMode);var Fb=hl&&"TextEvent"in window&&!ai,Ux=hl&&(!kd||ai&&8<ai&&11>=ai),$x=" ",Bx=!1;function Ix(s,t){switch(s){case"keyup":return Hb.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Px(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var cr=!1;function Gb(s,t){switch(s){case"compositionend":return Px(t);case"keypress":return t.which!==32?null:(Bx=!0,$x);case"textInput":return s=t.data,s===$x&&Bx?null:s;default:return null}}function Vb(s,t){if(cr)return s==="compositionend"||!kd&&Ix(s,t)?(s=Ax(),vc=bd=Il=null,cr=!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 Ux&&t.locale!=="ko"?null:t.data;default:return null}}var qb={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 Hx(s){var t=s&&s.nodeName&&s.nodeName.toLowerCase();return t==="input"?!!qb[s.type]:t==="textarea"}function Fx(s,t,a,r){rr?ir?ir.push(r):ir=[r]:rr=r,t=xo(t,"onChange"),0<t.length&&(a=new yc("onChange","change",null,a,r),s.push({event:a,listeners:t}))}var li=null,ni=null;function Kb(s){kp(s,0)}function _c(s){var t=Zr(s);if(_x(t))return s}function Gx(s,t){if(s==="change")return t}var Vx=!1;if(hl){var Cd;if(hl){var Td="oninput"in document;if(!Td){var qx=document.createElement("div");qx.setAttribute("oninput","return;"),Td=typeof qx.oninput=="function"}Cd=Td}else Cd=!1;Vx=Cd&&(!document.documentMode||9<document.documentMode)}function Kx(){li&&(li.detachEvent("onpropertychange",Qx),ni=li=null)}function Qx(s){if(s.propertyName==="value"&&_c(ni)){var t=[];Fx(t,ni,s,jd(s)),zx(Kb,t)}}function Qb(s,t,a){s==="focusin"?(Kx(),li=t,ni=a,li.attachEvent("onpropertychange",Qx)):s==="focusout"&&Kx()}function Yb(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return _c(ni)}function Jb(s,t){if(s==="click")return _c(t)}function Xb(s,t){if(s==="input"||s==="change")return _c(t)}function Zb(s,t){return s===t&&(s!==0||1/s===1/t)||s!==s&&t!==t}var va=typeof Object.is=="function"?Object.is:Zb;function ri(s,t){if(va(s,t))return!0;if(typeof s!="object"||s===null||typeof t!="object"||t===null)return!1;var a=Object.keys(s),r=Object.keys(t);if(a.length!==r.length)return!1;for(r=0;r<a.length;r++){var o=a[r];if(!rs.call(t,o)||!va(s[o],t[o]))return!1}return!0}function Yx(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function Jx(s,t){var a=Yx(s);s=0;for(var r;a;){if(a.nodeType===3){if(r=s+a.textContent.length,s<=t&&r>=t)return{node:a,offset:t-s};s=r}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Yx(a)}}function Xx(s,t){return s&&t?s===t?!0:s&&s.nodeType===3?!1:t&&t.nodeType===3?Xx(s,t.parentNode):"contains"in s?s.contains(t):s.compareDocumentPosition?!!(s.compareDocumentPosition(t)&16):!1:!1}function Zx(s){s=s!=null&&s.ownerDocument!=null&&s.ownerDocument.defaultView!=null?s.ownerDocument.defaultView:window;for(var t=gc(s.document);t instanceof s.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)s=t.contentWindow;else break;t=gc(s.document)}return t}function Ed(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 Wb=hl&&"documentMode"in document&&11>=document.documentMode,or=null,Md=null,ii=null,zd=!1;function Wx(s,t,a){var r=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;zd||or==null||or!==gc(r)||(r=or,"selectionStart"in r&&Ed(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ii&&ri(ii,r)||(ii=r,r=xo(Md,"onSelect"),0<r.length&&(t=new yc("onSelect","select",null,t,a),s.push({event:t,listeners:r}),t.target=or)))}function _n(s,t){var a={};return a[s.toLowerCase()]=t.toLowerCase(),a["Webkit"+s]="webkit"+t,a["Moz"+s]="moz"+t,a}var dr={animationend:_n("Animation","AnimationEnd"),animationiteration:_n("Animation","AnimationIteration"),animationstart:_n("Animation","AnimationStart"),transitionrun:_n("Transition","TransitionRun"),transitionstart:_n("Transition","TransitionStart"),transitioncancel:_n("Transition","TransitionCancel"),transitionend:_n("Transition","TransitionEnd")},Ad={},eh={};hl&&(eh=document.createElement("div").style,"AnimationEvent"in window||(delete dr.animationend.animation,delete dr.animationiteration.animation,delete dr.animationstart.animation),"TransitionEvent"in window||delete dr.transitionend.transition);function Sn(s){if(Ad[s])return Ad[s];if(!dr[s])return s;var t=dr[s],a;for(a in t)if(t.hasOwnProperty(a)&&a in eh)return Ad[s]=t[a];return s}var sh=Sn("animationend"),th=Sn("animationiteration"),ah=Sn("animationstart"),ey=Sn("transitionrun"),sy=Sn("transitionstart"),ty=Sn("transitioncancel"),lh=Sn("transitionend"),nh=new Map,Od="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(" ");Od.push("scrollEnd");function Ya(s,t){nh.set(s,t),yn(t,[s])}var Sc=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)},La=[],ur=0,Dd=0;function kc(){for(var s=ur,t=Dd=ur=0;t<s;){var a=La[t];La[t++]=null;var r=La[t];La[t++]=null;var o=La[t];La[t++]=null;var m=La[t];if(La[t++]=null,r!==null&&o!==null){var j=r.pending;j===null?o.next=o:(o.next=j.next,j.next=o),r.pending=o}m!==0&&rh(a,o,m)}}function Cc(s,t,a,r){La[ur++]=s,La[ur++]=t,La[ur++]=a,La[ur++]=r,Dd|=r,s.lanes|=r,s=s.alternate,s!==null&&(s.lanes|=r)}function Rd(s,t,a,r){return Cc(s,t,a,r),Tc(s)}function kn(s,t){return Cc(s,null,null,t),Tc(s)}function rh(s,t,a){s.lanes|=a;var r=s.alternate;r!==null&&(r.lanes|=a);for(var o=!1,m=s.return;m!==null;)m.childLanes|=a,r=m.alternate,r!==null&&(r.childLanes|=a),m.tag===22&&(s=m.stateNode,s===null||s._visibility&1||(o=!0)),s=m,m=m.return;return s.tag===3?(m=s.stateNode,o&&t!==null&&(o=31-ys(a),s=m.hiddenUpdates,r=s[o],r===null?s[o]=[t]:r.push(t),t.lane=a|536870912),m):null}function Tc(s){if(50<Ei)throw Ei=0,Gu=null,Error(c(185));for(var t=s.return;t!==null;)s=t,t=s.return;return s.tag===3?s.stateNode:null}var mr={};function ay(s,t,a,r){this.tag=s,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Na(s,t,a,r){return new ay(s,t,a,r)}function Ld(s){return s=s.prototype,!(!s||!s.isReactComponent)}function fl(s,t){var a=s.alternate;return a===null?(a=Na(s.tag,t,s.key,s.mode),a.elementType=s.elementType,a.type=s.type,a.stateNode=s.stateNode,a.alternate=s,s.alternate=a):(a.pendingProps=t,a.type=s.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=s.flags&65011712,a.childLanes=s.childLanes,a.lanes=s.lanes,a.child=s.child,a.memoizedProps=s.memoizedProps,a.memoizedState=s.memoizedState,a.updateQueue=s.updateQueue,t=s.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=s.sibling,a.index=s.index,a.ref=s.ref,a.refCleanup=s.refCleanup,a}function ih(s,t){s.flags&=65011714;var a=s.alternate;return a===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=a.childLanes,s.lanes=a.lanes,s.child=a.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=a.memoizedProps,s.memoizedState=a.memoizedState,s.updateQueue=a.updateQueue,s.type=a.type,t=a.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),s}function Ec(s,t,a,r,o,m){var j=0;if(r=s,typeof s=="function")Ld(s)&&(j=1);else if(typeof s=="string")j=c0(s,a,A.current)?26:s==="html"||s==="head"||s==="body"?27:5;else e:switch(s){case U:return s=Na(31,a,t,o),s.elementType=U,s.lanes=m,s;case R:return Cn(a.children,o,m,t);case O:j=8,o|=24;break;case S:return s=Na(12,a,t,o|2),s.elementType=S,s.lanes=m,s;case z:return s=Na(13,a,t,o),s.elementType=z,s.lanes=m,s;case H:return s=Na(19,a,t,o),s.elementType=H,s.lanes=m,s;default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case E:j=10;break e;case B:j=9;break e;case C:j=11;break e;case L:j=14;break e;case J:j=16,r=null;break e}j=29,a=Error(c(130,s===null?"null":typeof s,"")),r=null}return t=Na(j,a,t,o),t.elementType=s,t.type=r,t.lanes=m,t}function Cn(s,t,a,r){return s=Na(7,s,r,t),s.lanes=a,s}function Ud(s,t,a){return s=Na(6,s,null,t),s.lanes=a,s}function ch(s){var t=Na(18,null,null,0);return t.stateNode=s,t}function $d(s,t,a){return t=Na(4,s.children!==null?s.children:[],s.key,t),t.lanes=a,t.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},t}var oh=new WeakMap;function Ua(s,t){if(typeof s=="object"&&s!==null){var a=oh.get(s);return a!==void 0?a:(t={value:s,source:t,stack:ze(t)},oh.set(s,t),t)}return{value:s,source:t,stack:ze(t)}}var xr=[],hr=0,Mc=null,ci=0,$a=[],Ba=0,Pl=null,al=1,ll="";function pl(s,t){xr[hr++]=ci,xr[hr++]=Mc,Mc=s,ci=t}function dh(s,t,a){$a[Ba++]=al,$a[Ba++]=ll,$a[Ba++]=Pl,Pl=s;var r=al;s=ll;var o=32-ys(r)-1;r&=~(1<<o),a+=1;var m=32-ys(t)+o;if(30<m){var j=o-o%5;m=(r&(1<<j)-1).toString(32),r>>=j,o-=j,al=1<<32-ys(t)+o|a<<o|r,ll=m+s}else al=1<<m|a<<o|r,ll=s}function Bd(s){s.return!==null&&(pl(s,1),dh(s,1,0))}function Id(s){for(;s===Mc;)Mc=xr[--hr],xr[hr]=null,ci=xr[--hr],xr[hr]=null;for(;s===Pl;)Pl=$a[--Ba],$a[Ba]=null,ll=$a[--Ba],$a[Ba]=null,al=$a[--Ba],$a[Ba]=null}function uh(s,t){$a[Ba++]=al,$a[Ba++]=ll,$a[Ba++]=Pl,al=t.id,ll=t.overflow,Pl=s}var Gt=null,it=null,zs=!1,Hl=null,Ia=!1,Pd=Error(c(519));function Fl(s){var t=Error(c(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw oi(Ua(t,s)),Pd}function mh(s){var t=s.stateNode,a=s.type,r=s.memoizedProps;switch(t[js]=s,t[is]=r,a){case"dialog":Ss("cancel",t),Ss("close",t);break;case"iframe":case"object":case"embed":Ss("load",t);break;case"video":case"audio":for(a=0;a<zi.length;a++)Ss(zi[a],t);break;case"source":Ss("error",t);break;case"img":case"image":case"link":Ss("error",t),Ss("load",t);break;case"details":Ss("toggle",t);break;case"input":Ss("invalid",t),Sx(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case"select":Ss("invalid",t);break;case"textarea":Ss("invalid",t),Cx(t,r.value,r.defaultValue,r.children)}a=r.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||r.suppressHydrationWarning===!0||Mp(t.textContent,a)?(r.popover!=null&&(Ss("beforetoggle",t),Ss("toggle",t)),r.onScroll!=null&&Ss("scroll",t),r.onScrollEnd!=null&&Ss("scrollend",t),r.onClick!=null&&(t.onclick=xl),t=!0):t=!1,t||Fl(s,!0)}function xh(s){for(Gt=s.return;Gt;)switch(Gt.tag){case 5:case 31:case 13:Ia=!1;return;case 27:case 3:Ia=!0;return;default:Gt=Gt.return}}function fr(s){if(s!==Gt)return!1;if(!zs)return xh(s),zs=!0,!1;var t=s.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=s.type,a=!(a!=="form"&&a!=="button")||nm(s.type,s.memoizedProps)),a=!a),a&&it&&Fl(s),xh(s),t===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));it=Bp(s)}else if(t===31){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));it=Bp(s)}else t===27?(t=it,an(s.type)?(s=dm,dm=null,it=s):it=t):it=Gt?Ha(s.stateNode.nextSibling):null;return!0}function Tn(){it=Gt=null,zs=!1}function Hd(){var s=Hl;return s!==null&&(ha===null?ha=s:ha.push.apply(ha,s),Hl=null),s}function oi(s){Hl===null?Hl=[s]:Hl.push(s)}var Fd=Se(null),En=null,gl=null;function Gl(s,t,a){Te(Fd,t._currentValue),t._currentValue=a}function jl(s){s._currentValue=Fd.current,pe(Fd)}function Gd(s,t,a){for(;s!==null;){var r=s.alternate;if((s.childLanes&t)!==t?(s.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),s===a)break;s=s.return}}function Vd(s,t,a,r){var o=s.child;for(o!==null&&(o.return=s);o!==null;){var m=o.dependencies;if(m!==null){var j=o.child;m=m.firstContext;e:for(;m!==null;){var k=m;m=o;for(var $=0;$<t.length;$++)if(k.context===t[$]){m.lanes|=a,k=m.alternate,k!==null&&(k.lanes|=a),Gd(m.return,a,s),r||(j=null);break e}m=k.next}}else if(o.tag===18){if(j=o.return,j===null)throw Error(c(341));j.lanes|=a,m=j.alternate,m!==null&&(m.lanes|=a),Gd(j,a,s),j=null}else j=o.child;if(j!==null)j.return=o;else for(j=o;j!==null;){if(j===s){j=null;break}if(o=j.sibling,o!==null){o.return=j.return,j=o;break}j=j.return}o=j}}function pr(s,t,a,r){s=null;for(var o=t,m=!1;o!==null;){if(!m){if((o.flags&524288)!==0)m=!0;else if((o.flags&262144)!==0)break}if(o.tag===10){var j=o.alternate;if(j===null)throw Error(c(387));if(j=j.memoizedProps,j!==null){var k=o.type;va(o.pendingProps.value,j.value)||(s!==null?s.push(k):s=[k])}}else if(o===de.current){if(j=o.alternate,j===null)throw Error(c(387));j.memoizedState.memoizedState!==o.memoizedState.memoizedState&&(s!==null?s.push(Li):s=[Li])}o=o.return}s!==null&&Vd(t,s,a,r),t.flags|=262144}function zc(s){for(s=s.firstContext;s!==null;){if(!va(s.context._currentValue,s.memoizedValue))return!0;s=s.next}return!1}function Mn(s){En=s,gl=null,s=s.dependencies,s!==null&&(s.firstContext=null)}function Vt(s){return hh(En,s)}function Ac(s,t){return En===null&&Mn(s),hh(s,t)}function hh(s,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},gl===null){if(s===null)throw Error(c(308));gl=t,s.dependencies={lanes:0,firstContext:t},s.flags|=524288}else gl=gl.next=t;return a}var ly=typeof AbortController<"u"?AbortController:function(){var s=[],t=this.signal={aborted:!1,addEventListener:function(a,r){s.push(r)}};this.abort=function(){t.aborted=!0,s.forEach(function(a){return a()})}},ny=l.unstable_scheduleCallback,ry=l.unstable_NormalPriority,Mt={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function qd(){return{controller:new ly,data:new Map,refCount:0}}function di(s){s.refCount--,s.refCount===0&&ny(ry,function(){s.controller.abort()})}var ui=null,Kd=0,gr=0,jr=null;function iy(s,t){if(ui===null){var a=ui=[];Kd=0,gr=Ju(),jr={status:"pending",value:void 0,then:function(r){a.push(r)}}}return Kd++,t.then(fh,fh),t}function fh(){if(--Kd===0&&ui!==null){jr!==null&&(jr.status="fulfilled");var s=ui;ui=null,gr=0,jr=null;for(var t=0;t<s.length;t++)(0,s[t])()}}function cy(s,t){var a=[],r={status:"pending",value:null,reason:null,then:function(o){a.push(o)}};return s.then(function(){r.status="fulfilled",r.value=t;for(var o=0;o<a.length;o++)(0,a[o])(t)},function(o){for(r.status="rejected",r.reason=o,o=0;o<a.length;o++)(0,a[o])(void 0)}),r}var ph=M.S;M.S=function(s,t){ep=mt(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&iy(s,t),ph!==null&&ph(s,t)};var zn=Se(null);function Qd(){var s=zn.current;return s!==null?s:Ws.pooledCache}function Oc(s,t){t===null?Te(zn,zn.current):Te(zn,t.pool)}function gh(){var s=Qd();return s===null?null:{parent:Mt._currentValue,pool:s}}var vr=Error(c(460)),Yd=Error(c(474)),Dc=Error(c(542)),Rc={then:function(){}};function jh(s){return s=s.status,s==="fulfilled"||s==="rejected"}function vh(s,t,a){switch(a=s[a],a===void 0?s.push(t):a!==t&&(t.then(xl,xl),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,bh(s),s;default:if(typeof t.status=="string")t.then(xl,xl);else{if(s=Ws,s!==null&&100<s.shellSuspendCounter)throw Error(c(482));s=t,s.status="pending",s.then(function(r){if(t.status==="pending"){var o=t;o.status="fulfilled",o.value=r}},function(r){if(t.status==="pending"){var o=t;o.status="rejected",o.reason=r}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw s=t.reason,bh(s),s}throw On=t,vr}}function An(s){try{var t=s._init;return t(s._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(On=a,vr):a}}var On=null;function Nh(){if(On===null)throw Error(c(459));var s=On;return On=null,s}function bh(s){if(s===vr||s===Dc)throw Error(c(483))}var Nr=null,mi=0;function Lc(s){var t=mi;return mi+=1,Nr===null&&(Nr=[]),vh(Nr,s,t)}function xi(s,t){t=t.props.ref,s.ref=t!==void 0?t:null}function Uc(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 yh(s){function t(X,G){if(s){var te=X.deletions;te===null?(X.deletions=[G],X.flags|=16):te.push(G)}}function a(X,G){if(!s)return null;for(;G!==null;)t(X,G),G=G.sibling;return null}function r(X){for(var G=new Map;X!==null;)X.key!==null?G.set(X.key,X):G.set(X.index,X),X=X.sibling;return G}function o(X,G){return X=fl(X,G),X.index=0,X.sibling=null,X}function m(X,G,te){return X.index=te,s?(te=X.alternate,te!==null?(te=te.index,te<G?(X.flags|=67108866,G):te):(X.flags|=67108866,G)):(X.flags|=1048576,G)}function j(X){return s&&X.alternate===null&&(X.flags|=67108866),X}function k(X,G,te,be){return G===null||G.tag!==6?(G=Ud(te,X.mode,be),G.return=X,G):(G=o(G,te),G.return=X,G)}function $(X,G,te,be){var Ye=te.type;return Ye===R?ve(X,G,te.props.children,be,te.key):G!==null&&(G.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===J&&An(Ye)===G.type)?(G=o(G,te.props),xi(G,te),G.return=X,G):(G=Ec(te.type,te.key,te.props,null,X.mode,be),xi(G,te),G.return=X,G)}function le(X,G,te,be){return G===null||G.tag!==4||G.stateNode.containerInfo!==te.containerInfo||G.stateNode.implementation!==te.implementation?(G=$d(te,X.mode,be),G.return=X,G):(G=o(G,te.children||[]),G.return=X,G)}function ve(X,G,te,be,Ye){return G===null||G.tag!==7?(G=Cn(te,X.mode,be,Ye),G.return=X,G):(G=o(G,te),G.return=X,G)}function ye(X,G,te){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Ud(""+G,X.mode,te),G.return=X,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case w:return te=Ec(G.type,G.key,G.props,null,X.mode,te),xi(te,G),te.return=X,te;case y:return G=$d(G,X.mode,te),G.return=X,G;case J:return G=An(G),ye(X,G,te)}if(ge(G)||je(G))return G=Cn(G,X.mode,te,null),G.return=X,G;if(typeof G.then=="function")return ye(X,Lc(G),te);if(G.$$typeof===E)return ye(X,Ac(X,G),te);Uc(X,G)}return null}function ce(X,G,te,be){var Ye=G!==null?G.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return Ye!==null?null:k(X,G,""+te,be);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case w:return te.key===Ye?$(X,G,te,be):null;case y:return te.key===Ye?le(X,G,te,be):null;case J:return te=An(te),ce(X,G,te,be)}if(ge(te)||je(te))return Ye!==null?null:ve(X,G,te,be,null);if(typeof te.then=="function")return ce(X,G,Lc(te),be);if(te.$$typeof===E)return ce(X,G,Ac(X,te),be);Uc(X,te)}return null}function xe(X,G,te,be,Ye){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return X=X.get(te)||null,k(G,X,""+be,Ye);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case w:return X=X.get(be.key===null?te:be.key)||null,$(G,X,be,Ye);case y:return X=X.get(be.key===null?te:be.key)||null,le(G,X,be,Ye);case J:return be=An(be),xe(X,G,te,be,Ye)}if(ge(be)||je(be))return X=X.get(te)||null,ve(G,X,be,Ye,null);if(typeof be.then=="function")return xe(X,G,te,Lc(be),Ye);if(be.$$typeof===E)return xe(X,G,te,Ac(G,be),Ye);Uc(G,be)}return null}function Fe(X,G,te,be){for(var Ye=null,Us=null,Ve=G,ds=G=0,Es=null;Ve!==null&&ds<te.length;ds++){Ve.index>ds?(Es=Ve,Ve=null):Es=Ve.sibling;var $s=ce(X,Ve,te[ds],be);if($s===null){Ve===null&&(Ve=Es);break}s&&Ve&&$s.alternate===null&&t(X,Ve),G=m($s,G,ds),Us===null?Ye=$s:Us.sibling=$s,Us=$s,Ve=Es}if(ds===te.length)return a(X,Ve),zs&&pl(X,ds),Ye;if(Ve===null){for(;ds<te.length;ds++)Ve=ye(X,te[ds],be),Ve!==null&&(G=m(Ve,G,ds),Us===null?Ye=Ve:Us.sibling=Ve,Us=Ve);return zs&&pl(X,ds),Ye}for(Ve=r(Ve);ds<te.length;ds++)Es=xe(Ve,X,ds,te[ds],be),Es!==null&&(s&&Es.alternate!==null&&Ve.delete(Es.key===null?ds:Es.key),G=m(Es,G,ds),Us===null?Ye=Es:Us.sibling=Es,Us=Es);return s&&Ve.forEach(function(on){return t(X,on)}),zs&&pl(X,ds),Ye}function Ze(X,G,te,be){if(te==null)throw Error(c(151));for(var Ye=null,Us=null,Ve=G,ds=G=0,Es=null,$s=te.next();Ve!==null&&!$s.done;ds++,$s=te.next()){Ve.index>ds?(Es=Ve,Ve=null):Es=Ve.sibling;var on=ce(X,Ve,$s.value,be);if(on===null){Ve===null&&(Ve=Es);break}s&&Ve&&on.alternate===null&&t(X,Ve),G=m(on,G,ds),Us===null?Ye=on:Us.sibling=on,Us=on,Ve=Es}if($s.done)return a(X,Ve),zs&&pl(X,ds),Ye;if(Ve===null){for(;!$s.done;ds++,$s=te.next())$s=ye(X,$s.value,be),$s!==null&&(G=m($s,G,ds),Us===null?Ye=$s:Us.sibling=$s,Us=$s);return zs&&pl(X,ds),Ye}for(Ve=r(Ve);!$s.done;ds++,$s=te.next())$s=xe(Ve,X,ds,$s.value,be),$s!==null&&(s&&$s.alternate!==null&&Ve.delete($s.key===null?ds:$s.key),G=m($s,G,ds),Us===null?Ye=$s:Us.sibling=$s,Us=$s);return s&&Ve.forEach(function(v0){return t(X,v0)}),zs&&pl(X,ds),Ye}function Xs(X,G,te,be){if(typeof te=="object"&&te!==null&&te.type===R&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case w:e:{for(var Ye=te.key;G!==null;){if(G.key===Ye){if(Ye=te.type,Ye===R){if(G.tag===7){a(X,G.sibling),be=o(G,te.props.children),be.return=X,X=be;break e}}else if(G.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===J&&An(Ye)===G.type){a(X,G.sibling),be=o(G,te.props),xi(be,te),be.return=X,X=be;break e}a(X,G);break}else t(X,G);G=G.sibling}te.type===R?(be=Cn(te.props.children,X.mode,be,te.key),be.return=X,X=be):(be=Ec(te.type,te.key,te.props,null,X.mode,be),xi(be,te),be.return=X,X=be)}return j(X);case y:e:{for(Ye=te.key;G!==null;){if(G.key===Ye)if(G.tag===4&&G.stateNode.containerInfo===te.containerInfo&&G.stateNode.implementation===te.implementation){a(X,G.sibling),be=o(G,te.children||[]),be.return=X,X=be;break e}else{a(X,G);break}else t(X,G);G=G.sibling}be=$d(te,X.mode,be),be.return=X,X=be}return j(X);case J:return te=An(te),Xs(X,G,te,be)}if(ge(te))return Fe(X,G,te,be);if(je(te)){if(Ye=je(te),typeof Ye!="function")throw Error(c(150));return te=Ye.call(te),Ze(X,G,te,be)}if(typeof te.then=="function")return Xs(X,G,Lc(te),be);if(te.$$typeof===E)return Xs(X,G,Ac(X,te),be);Uc(X,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,G!==null&&G.tag===6?(a(X,G.sibling),be=o(G,te),be.return=X,X=be):(a(X,G),be=Ud(te,X.mode,be),be.return=X,X=be),j(X)):a(X,G)}return function(X,G,te,be){try{mi=0;var Ye=Xs(X,G,te,be);return Nr=null,Ye}catch(Ve){if(Ve===vr||Ve===Dc)throw Ve;var Us=Na(29,Ve,null,X.mode);return Us.lanes=be,Us.return=X,Us}finally{}}}var Dn=yh(!0),wh=yh(!1),Vl=!1;function Jd(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Xd(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 ql(s){return{lane:s,tag:0,payload:null,callback:null,next:null}}function Kl(s,t,a){var r=s.updateQueue;if(r===null)return null;if(r=r.shared,(Ps&2)!==0){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,t=Tc(s),rh(s,null,a),t}return Cc(s,r,t,a),Tc(s)}function hi(s,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var r=t.lanes;r&=s.pendingLanes,a|=r,t.lanes=a,Wt(s,a)}}function Zd(s,t){var a=s.updateQueue,r=s.alternate;if(r!==null&&(r=r.updateQueue,a===r)){var o=null,m=null;if(a=a.firstBaseUpdate,a!==null){do{var j={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};m===null?o=m=j:m=m.next=j,a=a.next}while(a!==null);m===null?o=m=t:m=m.next=t}else o=m=t;a={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:m,shared:r.shared,callbacks:r.callbacks},s.updateQueue=a;return}s=a.lastBaseUpdate,s===null?a.firstBaseUpdate=t:s.next=t,a.lastBaseUpdate=t}var Wd=!1;function fi(){if(Wd){var s=jr;if(s!==null)throw s}}function pi(s,t,a,r){Wd=!1;var o=s.updateQueue;Vl=!1;var m=o.firstBaseUpdate,j=o.lastBaseUpdate,k=o.shared.pending;if(k!==null){o.shared.pending=null;var $=k,le=$.next;$.next=null,j===null?m=le:j.next=le,j=$;var ve=s.alternate;ve!==null&&(ve=ve.updateQueue,k=ve.lastBaseUpdate,k!==j&&(k===null?ve.firstBaseUpdate=le:k.next=le,ve.lastBaseUpdate=$))}if(m!==null){var ye=o.baseState;j=0,ve=le=$=null,k=m;do{var ce=k.lane&-536870913,xe=ce!==k.lane;if(xe?(Ts&ce)===ce:(r&ce)===ce){ce!==0&&ce===gr&&(Wd=!0),ve!==null&&(ve=ve.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var Fe=s,Ze=k;ce=t;var Xs=a;switch(Ze.tag){case 1:if(Fe=Ze.payload,typeof Fe=="function"){ye=Fe.call(Xs,ye,ce);break e}ye=Fe;break e;case 3:Fe.flags=Fe.flags&-65537|128;case 0:if(Fe=Ze.payload,ce=typeof Fe=="function"?Fe.call(Xs,ye,ce):Fe,ce==null)break e;ye=v({},ye,ce);break e;case 2:Vl=!0}}ce=k.callback,ce!==null&&(s.flags|=64,xe&&(s.flags|=8192),xe=o.callbacks,xe===null?o.callbacks=[ce]:xe.push(ce))}else xe={lane:ce,tag:k.tag,payload:k.payload,callback:k.callback,next:null},ve===null?(le=ve=xe,$=ye):ve=ve.next=xe,j|=ce;if(k=k.next,k===null){if(k=o.shared.pending,k===null)break;xe=k,k=xe.next,xe.next=null,o.lastBaseUpdate=xe,o.shared.pending=null}}while(!0);ve===null&&($=ye),o.baseState=$,o.firstBaseUpdate=le,o.lastBaseUpdate=ve,m===null&&(o.shared.lanes=0),Zl|=j,s.lanes=j,s.memoizedState=ye}}function _h(s,t){if(typeof s!="function")throw Error(c(191,s));s.call(t)}function Sh(s,t){var a=s.callbacks;if(a!==null)for(s.callbacks=null,s=0;s<a.length;s++)_h(a[s],t)}var br=Se(null),$c=Se(0);function kh(s,t){s=Cl,Te($c,s),Te(br,t),Cl=s|t.baseLanes}function eu(){Te($c,Cl),Te(br,br.current)}function su(){Cl=$c.current,pe(br),pe($c)}var ba=Se(null),Pa=null;function Ql(s){var t=s.alternate;Te(St,St.current&1),Te(ba,s),Pa===null&&(t===null||br.current!==null||t.memoizedState!==null)&&(Pa=s)}function tu(s){Te(St,St.current),Te(ba,s),Pa===null&&(Pa=s)}function Ch(s){s.tag===22?(Te(St,St.current),Te(ba,s),Pa===null&&(Pa=s)):Yl()}function Yl(){Te(St,St.current),Te(ba,ba.current)}function ya(s){pe(ba),Pa===s&&(Pa=null),pe(St)}var St=Se(0);function Bc(s){for(var t=s;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||cm(a)||om(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break;for(;t.sibling===null;){if(t.return===null||t.return===s)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var vl=0,cs=null,Ys=null,zt=null,Ic=!1,yr=!1,Rn=!1,Pc=0,gi=0,wr=null,oy=0;function vt(){throw Error(c(321))}function au(s,t){if(t===null)return!1;for(var a=0;a<t.length&&a<s.length;a++)if(!va(s[a],t[a]))return!1;return!0}function lu(s,t,a,r,o,m){return vl=m,cs=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,M.H=s===null||s.memoizedState===null?uf:vu,Rn=!1,m=a(r,o),Rn=!1,yr&&(m=Eh(t,a,r,o)),Th(s),m}function Th(s){M.H=Ni;var t=Ys!==null&&Ys.next!==null;if(vl=0,zt=Ys=cs=null,Ic=!1,gi=0,wr=null,t)throw Error(c(300));s===null||At||(s=s.dependencies,s!==null&&zc(s)&&(At=!0))}function Eh(s,t,a,r){cs=s;var o=0;do{if(yr&&(wr=null),gi=0,yr=!1,25<=o)throw Error(c(301));if(o+=1,zt=Ys=null,s.updateQueue!=null){var m=s.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}M.H=mf,m=t(a,r)}while(yr);return m}function dy(){var s=M.H,t=s.useState()[0];return t=typeof t.then=="function"?ji(t):t,s=s.useState()[0],(Ys!==null?Ys.memoizedState:null)!==s&&(cs.flags|=1024),t}function nu(){var s=Pc!==0;return Pc=0,s}function ru(s,t,a){t.updateQueue=s.updateQueue,t.flags&=-2053,s.lanes&=~a}function iu(s){if(Ic){for(s=s.memoizedState;s!==null;){var t=s.queue;t!==null&&(t.pending=null),s=s.next}Ic=!1}vl=0,zt=Ys=cs=null,yr=!1,gi=Pc=0,wr=null}function la(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zt===null?cs.memoizedState=zt=s:zt=zt.next=s,zt}function kt(){if(Ys===null){var s=cs.alternate;s=s!==null?s.memoizedState:null}else s=Ys.next;var t=zt===null?cs.memoizedState:zt.next;if(t!==null)zt=t,Ys=s;else{if(s===null)throw cs.alternate===null?Error(c(467)):Error(c(310));Ys=s,s={memoizedState:Ys.memoizedState,baseState:Ys.baseState,baseQueue:Ys.baseQueue,queue:Ys.queue,next:null},zt===null?cs.memoizedState=zt=s:zt=zt.next=s}return zt}function Hc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ji(s){var t=gi;return gi+=1,wr===null&&(wr=[]),s=vh(wr,s,t),t=cs,(zt===null?t.memoizedState:zt.next)===null&&(t=t.alternate,M.H=t===null||t.memoizedState===null?uf:vu),s}function Fc(s){if(s!==null&&typeof s=="object"){if(typeof s.then=="function")return ji(s);if(s.$$typeof===E)return Vt(s)}throw Error(c(438,String(s)))}function cu(s){var t=null,a=cs.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var r=cs.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(o){return o.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=Hc(),cs.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(s),r=0;r<s;r++)a[r]=oe;return t.index++,a}function Nl(s,t){return typeof t=="function"?t(s):t}function Gc(s){var t=kt();return ou(t,Ys,s)}function ou(s,t,a){var r=s.queue;if(r===null)throw Error(c(311));r.lastRenderedReducer=a;var o=s.baseQueue,m=r.pending;if(m!==null){if(o!==null){var j=o.next;o.next=m.next,m.next=j}t.baseQueue=o=m,r.pending=null}if(m=s.baseState,o===null)s.memoizedState=m;else{t=o.next;var k=j=null,$=null,le=t,ve=!1;do{var ye=le.lane&-536870913;if(ye!==le.lane?(Ts&ye)===ye:(vl&ye)===ye){var ce=le.revertLane;if(ce===0)$!==null&&($=$.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),ye===gr&&(ve=!0);else if((vl&ce)===ce){le=le.next,ce===gr&&(ve=!0);continue}else ye={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},$===null?(k=$=ye,j=m):$=$.next=ye,cs.lanes|=ce,Zl|=ce;ye=le.action,Rn&&a(m,ye),m=le.hasEagerState?le.eagerState:a(m,ye)}else ce={lane:ye,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},$===null?(k=$=ce,j=m):$=$.next=ce,cs.lanes|=ye,Zl|=ye;le=le.next}while(le!==null&&le!==t);if($===null?j=m:$.next=k,!va(m,s.memoizedState)&&(At=!0,ve&&(a=jr,a!==null)))throw a;s.memoizedState=m,s.baseState=j,s.baseQueue=$,r.lastRenderedState=m}return o===null&&(r.lanes=0),[s.memoizedState,r.dispatch]}function du(s){var t=kt(),a=t.queue;if(a===null)throw Error(c(311));a.lastRenderedReducer=s;var r=a.dispatch,o=a.pending,m=t.memoizedState;if(o!==null){a.pending=null;var j=o=o.next;do m=s(m,j.action),j=j.next;while(j!==o);va(m,t.memoizedState)||(At=!0),t.memoizedState=m,t.baseQueue===null&&(t.baseState=m),a.lastRenderedState=m}return[m,r]}function Mh(s,t,a){var r=cs,o=kt(),m=zs;if(m){if(a===void 0)throw Error(c(407));a=a()}else a=t();var j=!va((Ys||o).memoizedState,a);if(j&&(o.memoizedState=a,At=!0),o=o.queue,xu(Oh.bind(null,r,o,s),[s]),o.getSnapshot!==t||j||zt!==null&&zt.memoizedState.tag&1){if(r.flags|=2048,_r(9,{destroy:void 0},Ah.bind(null,r,o,a,t),null),Ws===null)throw Error(c(349));m||(vl&127)!==0||zh(r,t,a)}return a}function zh(s,t,a){s.flags|=16384,s={getSnapshot:t,value:a},t=cs.updateQueue,t===null?(t=Hc(),cs.updateQueue=t,t.stores=[s]):(a=t.stores,a===null?t.stores=[s]:a.push(s))}function Ah(s,t,a,r){t.value=a,t.getSnapshot=r,Dh(t)&&Rh(s)}function Oh(s,t,a){return a(function(){Dh(t)&&Rh(s)})}function Dh(s){var t=s.getSnapshot;s=s.value;try{var a=t();return!va(s,a)}catch{return!0}}function Rh(s){var t=kn(s,2);t!==null&&fa(t,s,2)}function uu(s){var t=la();if(typeof s=="function"){var a=s;if(s=a(),Rn){ss(!0);try{a()}finally{ss(!1)}}}return t.memoizedState=t.baseState=s,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Nl,lastRenderedState:s},t}function Lh(s,t,a,r){return s.baseState=a,ou(s,Ys,typeof r=="function"?r:Nl)}function uy(s,t,a,r,o){if(Kc(s))throw Error(c(485));if(s=t.action,s!==null){var m={payload:o,action:s,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){m.listeners.push(j)}};M.T!==null?a(!0):m.isTransition=!1,r(m),a=t.pending,a===null?(m.next=t.pending=m,Uh(t,m)):(m.next=a.next,t.pending=a.next=m)}}function Uh(s,t){var a=t.action,r=t.payload,o=s.state;if(t.isTransition){var m=M.T,j={};M.T=j;try{var k=a(o,r),$=M.S;$!==null&&$(j,k),$h(s,t,k)}catch(le){mu(s,t,le)}finally{m!==null&&j.types!==null&&(m.types=j.types),M.T=m}}else try{m=a(o,r),$h(s,t,m)}catch(le){mu(s,t,le)}}function $h(s,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(r){Bh(s,t,r)},function(r){return mu(s,t,r)}):Bh(s,t,a)}function Bh(s,t,a){t.status="fulfilled",t.value=a,Ih(t),s.state=a,t=s.pending,t!==null&&(a=t.next,a===t?s.pending=null:(a=a.next,t.next=a,Uh(s,a)))}function mu(s,t,a){var r=s.pending;if(s.pending=null,r!==null){r=r.next;do t.status="rejected",t.reason=a,Ih(t),t=t.next;while(t!==r)}s.action=null}function Ih(s){s=s.listeners;for(var t=0;t<s.length;t++)(0,s[t])()}function Ph(s,t){return t}function Hh(s,t){if(zs){var a=Ws.formState;if(a!==null){e:{var r=cs;if(zs){if(it){s:{for(var o=it,m=Ia;o.nodeType!==8;){if(!m){o=null;break s}if(o=Ha(o.nextSibling),o===null){o=null;break s}}m=o.data,o=m==="F!"||m==="F"?o:null}if(o){it=Ha(o.nextSibling),r=o.data==="F!";break e}}Fl(r)}r=!1}r&&(t=a[0])}}return a=la(),a.memoizedState=a.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ph,lastRenderedState:t},a.queue=r,a=cf.bind(null,cs,r),r.dispatch=a,r=uu(!1),m=ju.bind(null,cs,!1,r.queue),r=la(),o={state:t,dispatch:null,action:s,pending:null},r.queue=o,a=uy.bind(null,cs,o,m,a),o.dispatch=a,r.memoizedState=s,[t,a,!1]}function Fh(s){var t=kt();return Gh(t,Ys,s)}function Gh(s,t,a){if(t=ou(s,t,Ph)[0],s=Gc(Nl)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var r=ji(t)}catch(j){throw j===vr?Dc:j}else r=t;t=kt();var o=t.queue,m=o.dispatch;return a!==t.memoizedState&&(cs.flags|=2048,_r(9,{destroy:void 0},my.bind(null,o,a),null)),[r,m,s]}function my(s,t){s.action=t}function Vh(s){var t=kt(),a=Ys;if(a!==null)return Gh(t,a,s);kt(),t=t.memoizedState,a=kt();var r=a.queue.dispatch;return a.memoizedState=s,[t,r,!1]}function _r(s,t,a,r){return s={tag:s,create:a,deps:r,inst:t,next:null},t=cs.updateQueue,t===null&&(t=Hc(),cs.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=s.next=s:(r=a.next,a.next=s,s.next=r,t.lastEffect=s),s}function qh(){return kt().memoizedState}function Vc(s,t,a,r){var o=la();cs.flags|=s,o.memoizedState=_r(1|t,{destroy:void 0},a,r===void 0?null:r)}function qc(s,t,a,r){var o=kt();r=r===void 0?null:r;var m=o.memoizedState.inst;Ys!==null&&r!==null&&au(r,Ys.memoizedState.deps)?o.memoizedState=_r(t,m,a,r):(cs.flags|=s,o.memoizedState=_r(1|t,m,a,r))}function Kh(s,t){Vc(8390656,8,s,t)}function xu(s,t){qc(2048,8,s,t)}function xy(s){cs.flags|=4;var t=cs.updateQueue;if(t===null)t=Hc(),cs.updateQueue=t,t.events=[s];else{var a=t.events;a===null?t.events=[s]:a.push(s)}}function Qh(s){var t=kt().memoizedState;return xy({ref:t,nextImpl:s}),function(){if((Ps&2)!==0)throw Error(c(440));return t.impl.apply(void 0,arguments)}}function Yh(s,t){return qc(4,2,s,t)}function Jh(s,t){return qc(4,4,s,t)}function Xh(s,t){if(typeof t=="function"){s=s();var a=t(s);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return s=s(),t.current=s,function(){t.current=null}}function Zh(s,t,a){a=a!=null?a.concat([s]):null,qc(4,4,Xh.bind(null,t,s),a)}function hu(){}function Wh(s,t){var a=kt();t=t===void 0?null:t;var r=a.memoizedState;return t!==null&&au(t,r[1])?r[0]:(a.memoizedState=[s,t],s)}function ef(s,t){var a=kt();t=t===void 0?null:t;var r=a.memoizedState;if(t!==null&&au(t,r[1]))return r[0];if(r=s(),Rn){ss(!0);try{s()}finally{ss(!1)}}return a.memoizedState=[r,t],r}function fu(s,t,a){return a===void 0||(vl&1073741824)!==0&&(Ts&261930)===0?s.memoizedState=t:(s.memoizedState=a,s=tp(),cs.lanes|=s,Zl|=s,a)}function sf(s,t,a,r){return va(a,t)?a:br.current!==null?(s=fu(s,a,r),va(s,t)||(At=!0),s):(vl&42)===0||(vl&1073741824)!==0&&(Ts&261930)===0?(At=!0,s.memoizedState=a):(s=tp(),cs.lanes|=s,Zl|=s,t)}function tf(s,t,a,r,o){var m=K.p;K.p=m!==0&&8>m?m:8;var j=M.T,k={};M.T=k,ju(s,!1,t,a);try{var $=o(),le=M.S;if(le!==null&&le(k,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var ve=cy($,r);vi(s,t,ve,Sa(s))}else vi(s,t,r,Sa(s))}catch(ye){vi(s,t,{then:function(){},status:"rejected",reason:ye},Sa())}finally{K.p=m,j!==null&&k.types!==null&&(j.types=k.types),M.T=j}}function hy(){}function pu(s,t,a,r){if(s.tag!==5)throw Error(c(476));var o=af(s).queue;tf(s,o,t,I,a===null?hy:function(){return lf(s),a(r)})}function af(s){var t=s.memoizedState;if(t!==null)return t;t={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Nl,lastRenderedState:I},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Nl,lastRenderedState:a},next:null},s.memoizedState=t,s=s.alternate,s!==null&&(s.memoizedState=t),t}function lf(s){var t=af(s);t.next===null&&(t=s.alternate.memoizedState),vi(s,t.next.queue,{},Sa())}function gu(){return Vt(Li)}function nf(){return kt().memoizedState}function rf(){return kt().memoizedState}function fy(s){for(var t=s.return;t!==null;){switch(t.tag){case 24:case 3:var a=Sa();s=ql(a);var r=Kl(t,s,a);r!==null&&(fa(r,t,a),hi(r,t,a)),t={cache:qd()},s.payload=t;return}t=t.return}}function py(s,t,a){var r=Sa();a={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Kc(s)?of(t,a):(a=Rd(s,t,a,r),a!==null&&(fa(a,s,r),df(a,t,r)))}function cf(s,t,a){var r=Sa();vi(s,t,a,r)}function vi(s,t,a,r){var o={lane:r,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Kc(s))of(t,o);else{var m=s.alternate;if(s.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var j=t.lastRenderedState,k=m(j,a);if(o.hasEagerState=!0,o.eagerState=k,va(k,j))return Cc(s,t,o,0),Ws===null&&kc(),!1}catch{}finally{}if(a=Rd(s,t,o,r),a!==null)return fa(a,s,r),df(a,t,r),!0}return!1}function ju(s,t,a,r){if(r={lane:2,revertLane:Ju(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Kc(s)){if(t)throw Error(c(479))}else t=Rd(s,a,r,2),t!==null&&fa(t,s,2)}function Kc(s){var t=s.alternate;return s===cs||t!==null&&t===cs}function of(s,t){yr=Ic=!0;var a=s.pending;a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t}function df(s,t,a){if((a&4194048)!==0){var r=t.lanes;r&=s.pendingLanes,a|=r,t.lanes=a,Wt(s,a)}}var Ni={readContext:Vt,use:Fc,useCallback:vt,useContext:vt,useEffect:vt,useImperativeHandle:vt,useLayoutEffect:vt,useInsertionEffect:vt,useMemo:vt,useReducer:vt,useRef:vt,useState:vt,useDebugValue:vt,useDeferredValue:vt,useTransition:vt,useSyncExternalStore:vt,useId:vt,useHostTransitionStatus:vt,useFormState:vt,useActionState:vt,useOptimistic:vt,useMemoCache:vt,useCacheRefresh:vt};Ni.useEffectEvent=vt;var uf={readContext:Vt,use:Fc,useCallback:function(s,t){return la().memoizedState=[s,t===void 0?null:t],s},useContext:Vt,useEffect:Kh,useImperativeHandle:function(s,t,a){a=a!=null?a.concat([s]):null,Vc(4194308,4,Xh.bind(null,t,s),a)},useLayoutEffect:function(s,t){return Vc(4194308,4,s,t)},useInsertionEffect:function(s,t){Vc(4,2,s,t)},useMemo:function(s,t){var a=la();t=t===void 0?null:t;var r=s();if(Rn){ss(!0);try{s()}finally{ss(!1)}}return a.memoizedState=[r,t],r},useReducer:function(s,t,a){var r=la();if(a!==void 0){var o=a(t);if(Rn){ss(!0);try{a(t)}finally{ss(!1)}}}else o=t;return r.memoizedState=r.baseState=o,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:o},r.queue=s,s=s.dispatch=py.bind(null,cs,s),[r.memoizedState,s]},useRef:function(s){var t=la();return s={current:s},t.memoizedState=s},useState:function(s){s=uu(s);var t=s.queue,a=cf.bind(null,cs,t);return t.dispatch=a,[s.memoizedState,a]},useDebugValue:hu,useDeferredValue:function(s,t){var a=la();return fu(a,s,t)},useTransition:function(){var s=uu(!1);return s=tf.bind(null,cs,s.queue,!0,!1),la().memoizedState=s,[!1,s]},useSyncExternalStore:function(s,t,a){var r=cs,o=la();if(zs){if(a===void 0)throw Error(c(407));a=a()}else{if(a=t(),Ws===null)throw Error(c(349));(Ts&127)!==0||zh(r,t,a)}o.memoizedState=a;var m={value:a,getSnapshot:t};return o.queue=m,Kh(Oh.bind(null,r,m,s),[s]),r.flags|=2048,_r(9,{destroy:void 0},Ah.bind(null,r,m,a,t),null),a},useId:function(){var s=la(),t=Ws.identifierPrefix;if(zs){var a=ll,r=al;a=(r&~(1<<32-ys(r)-1)).toString(32)+a,t="_"+t+"R_"+a,a=Pc++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=oy++,t="_"+t+"r_"+a.toString(32)+"_";return s.memoizedState=t},useHostTransitionStatus:gu,useFormState:Hh,useActionState:Hh,useOptimistic:function(s){var t=la();t.memoizedState=t.baseState=s;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=ju.bind(null,cs,!0,a),a.dispatch=t,[s,t]},useMemoCache:cu,useCacheRefresh:function(){return la().memoizedState=fy.bind(null,cs)},useEffectEvent:function(s){var t=la(),a={impl:s};return t.memoizedState=a,function(){if((Ps&2)!==0)throw Error(c(440));return a.impl.apply(void 0,arguments)}}},vu={readContext:Vt,use:Fc,useCallback:Wh,useContext:Vt,useEffect:xu,useImperativeHandle:Zh,useInsertionEffect:Yh,useLayoutEffect:Jh,useMemo:ef,useReducer:Gc,useRef:qh,useState:function(){return Gc(Nl)},useDebugValue:hu,useDeferredValue:function(s,t){var a=kt();return sf(a,Ys.memoizedState,s,t)},useTransition:function(){var s=Gc(Nl)[0],t=kt().memoizedState;return[typeof s=="boolean"?s:ji(s),t]},useSyncExternalStore:Mh,useId:nf,useHostTransitionStatus:gu,useFormState:Fh,useActionState:Fh,useOptimistic:function(s,t){var a=kt();return Lh(a,Ys,s,t)},useMemoCache:cu,useCacheRefresh:rf};vu.useEffectEvent=Qh;var mf={readContext:Vt,use:Fc,useCallback:Wh,useContext:Vt,useEffect:xu,useImperativeHandle:Zh,useInsertionEffect:Yh,useLayoutEffect:Jh,useMemo:ef,useReducer:du,useRef:qh,useState:function(){return du(Nl)},useDebugValue:hu,useDeferredValue:function(s,t){var a=kt();return Ys===null?fu(a,s,t):sf(a,Ys.memoizedState,s,t)},useTransition:function(){var s=du(Nl)[0],t=kt().memoizedState;return[typeof s=="boolean"?s:ji(s),t]},useSyncExternalStore:Mh,useId:nf,useHostTransitionStatus:gu,useFormState:Vh,useActionState:Vh,useOptimistic:function(s,t){var a=kt();return Ys!==null?Lh(a,Ys,s,t):(a.baseState=s,[s,a.queue.dispatch])},useMemoCache:cu,useCacheRefresh:rf};mf.useEffectEvent=Qh;function Nu(s,t,a,r){t=s.memoizedState,a=a(r,t),a=a==null?t:v({},t,a),s.memoizedState=a,s.lanes===0&&(s.updateQueue.baseState=a)}var bu={enqueueSetState:function(s,t,a){s=s._reactInternals;var r=Sa(),o=ql(r);o.payload=t,a!=null&&(o.callback=a),t=Kl(s,o,r),t!==null&&(fa(t,s,r),hi(t,s,r))},enqueueReplaceState:function(s,t,a){s=s._reactInternals;var r=Sa(),o=ql(r);o.tag=1,o.payload=t,a!=null&&(o.callback=a),t=Kl(s,o,r),t!==null&&(fa(t,s,r),hi(t,s,r))},enqueueForceUpdate:function(s,t){s=s._reactInternals;var a=Sa(),r=ql(a);r.tag=2,t!=null&&(r.callback=t),t=Kl(s,r,a),t!==null&&(fa(t,s,a),hi(t,s,a))}};function xf(s,t,a,r,o,m,j){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(r,m,j):t.prototype&&t.prototype.isPureReactComponent?!ri(a,r)||!ri(o,m):!0}function hf(s,t,a,r){s=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,r),t.state!==s&&bu.enqueueReplaceState(t,t.state,null)}function Ln(s,t){var a=t;if("ref"in t){a={};for(var r in t)r!=="ref"&&(a[r]=t[r])}if(s=s.defaultProps){a===t&&(a=v({},a));for(var o in s)a[o]===void 0&&(a[o]=s[o])}return a}function ff(s){Sc(s)}function pf(s){console.error(s)}function gf(s){Sc(s)}function Qc(s,t){try{var a=s.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(r){setTimeout(function(){throw r})}}function jf(s,t,a){try{var r=s.onCaughtError;r(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(o){setTimeout(function(){throw o})}}function yu(s,t,a){return a=ql(a),a.tag=3,a.payload={element:null},a.callback=function(){Qc(s,t)},a}function vf(s){return s=ql(s),s.tag=3,s}function Nf(s,t,a,r){var o=a.type.getDerivedStateFromError;if(typeof o=="function"){var m=r.value;s.payload=function(){return o(m)},s.callback=function(){jf(t,a,r)}}var j=a.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(s.callback=function(){jf(t,a,r),typeof o!="function"&&(Wl===null?Wl=new Set([this]):Wl.add(this));var k=r.stack;this.componentDidCatch(r.value,{componentStack:k!==null?k:""})})}function gy(s,t,a,r,o){if(a.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(t=a.alternate,t!==null&&pr(t,a,o,!0),a=ba.current,a!==null){switch(a.tag){case 31:case 13:return Pa===null?ro():a.alternate===null&&Nt===0&&(Nt=3),a.flags&=-257,a.flags|=65536,a.lanes=o,r===Rc?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([r]):t.add(r),Ku(s,r,o)),!1;case 22:return a.flags|=65536,r===Rc?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([r]):a.add(r)),Ku(s,r,o)),!1}throw Error(c(435,a.tag))}return Ku(s,r,o),ro(),!1}if(zs)return t=ba.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=o,r!==Pd&&(s=Error(c(422),{cause:r}),oi(Ua(s,a)))):(r!==Pd&&(t=Error(c(423),{cause:r}),oi(Ua(t,a))),s=s.current.alternate,s.flags|=65536,o&=-o,s.lanes|=o,r=Ua(r,a),o=yu(s.stateNode,r,o),Zd(s,o),Nt!==4&&(Nt=2)),!1;var m=Error(c(520),{cause:r});if(m=Ua(m,a),Ti===null?Ti=[m]:Ti.push(m),Nt!==4&&(Nt=2),t===null)return!0;r=Ua(r,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,s=o&-o,a.lanes|=s,s=yu(a.stateNode,r,s),Zd(a,s),!1;case 1:if(t=a.type,m=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Wl===null||!Wl.has(m))))return a.flags|=65536,o&=-o,a.lanes|=o,o=vf(o),Nf(o,s,a,r),Zd(a,o),!1}a=a.return}while(a!==null);return!1}var wu=Error(c(461)),At=!1;function qt(s,t,a,r){t.child=s===null?wh(t,null,a,r):Dn(t,s.child,a,r)}function bf(s,t,a,r,o){a=a.render;var m=t.ref;if("ref"in r){var j={};for(var k in r)k!=="ref"&&(j[k]=r[k])}else j=r;return Mn(t),r=lu(s,t,a,j,m,o),k=nu(),s!==null&&!At?(ru(s,t,o),bl(s,t,o)):(zs&&k&&Bd(t),t.flags|=1,qt(s,t,r,o),t.child)}function yf(s,t,a,r,o){if(s===null){var m=a.type;return typeof m=="function"&&!Ld(m)&&m.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=m,wf(s,t,m,r,o)):(s=Ec(a.type,null,r,t,t.mode,o),s.ref=t.ref,s.return=t,t.child=s)}if(m=s.child,!zu(s,o)){var j=m.memoizedProps;if(a=a.compare,a=a!==null?a:ri,a(j,r)&&s.ref===t.ref)return bl(s,t,o)}return t.flags|=1,s=fl(m,r),s.ref=t.ref,s.return=t,t.child=s}function wf(s,t,a,r,o){if(s!==null){var m=s.memoizedProps;if(ri(m,r)&&s.ref===t.ref)if(At=!1,t.pendingProps=r=m,zu(s,o))(s.flags&131072)!==0&&(At=!0);else return t.lanes=s.lanes,bl(s,t,o)}return _u(s,t,a,r,o)}function _f(s,t,a,r){var o=r.children,m=s!==null?s.memoizedState:null;if(s===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode==="hidden"){if((t.flags&128)!==0){if(m=m!==null?m.baseLanes|a:a,s!==null){for(r=t.child=s.child,o=0;r!==null;)o=o|r.lanes|r.childLanes,r=r.sibling;r=o&~m}else r=0,t.child=null;return Sf(s,t,m,a,r)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},s!==null&&Oc(t,m!==null?m.cachePool:null),m!==null?kh(t,m):eu(),Ch(t);else return r=t.lanes=536870912,Sf(s,t,m!==null?m.baseLanes|a:a,a,r)}else m!==null?(Oc(t,m.cachePool),kh(t,m),Yl(),t.memoizedState=null):(s!==null&&Oc(t,null),eu(),Yl());return qt(s,t,o,a),t.child}function bi(s,t){return s!==null&&s.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Sf(s,t,a,r,o){var m=Qd();return m=m===null?null:{parent:Mt._currentValue,pool:m},t.memoizedState={baseLanes:a,cachePool:m},s!==null&&Oc(t,null),eu(),Ch(t),s!==null&&pr(s,t,r,!0),t.childLanes=o,null}function Yc(s,t){return t=Xc({mode:t.mode,children:t.children},s.mode),t.ref=s.ref,s.child=t,t.return=s,t}function kf(s,t,a){return Dn(t,s.child,null,a),s=Yc(t,t.pendingProps),s.flags|=2,ya(t),t.memoizedState=null,s}function jy(s,t,a){var r=t.pendingProps,o=(t.flags&128)!==0;if(t.flags&=-129,s===null){if(zs){if(r.mode==="hidden")return s=Yc(t,r),t.lanes=536870912,bi(null,s);if(tu(t),(s=it)?(s=$p(s,Ia),s=s!==null&&s.data==="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:Pl!==null?{id:al,overflow:ll}:null,retryLane:536870912,hydrationErrors:null},a=ch(s),a.return=t,t.child=a,Gt=t,it=null)):s=null,s===null)throw Fl(t);return t.lanes=536870912,null}return Yc(t,r)}var m=s.memoizedState;if(m!==null){var j=m.dehydrated;if(tu(t),o)if(t.flags&256)t.flags&=-257,t=kf(s,t,a);else if(t.memoizedState!==null)t.child=s.child,t.flags|=128,t=null;else throw Error(c(558));else if(At||pr(s,t,a,!1),o=(a&s.childLanes)!==0,At||o){if(r=Ws,r!==null&&(j=rt(r,a),j!==0&&j!==m.retryLane))throw m.retryLane=j,kn(s,j),fa(r,s,j),wu;ro(),t=kf(s,t,a)}else s=m.treeContext,it=Ha(j.nextSibling),Gt=t,zs=!0,Hl=null,Ia=!1,s!==null&&uh(t,s),t=Yc(t,r),t.flags|=4096;return t}return s=fl(s.child,{mode:r.mode,children:r.children}),s.ref=t.ref,t.child=s,s.return=t,s}function Jc(s,t){var a=t.ref;if(a===null)s!==null&&s.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(c(284));(s===null||s.ref!==a)&&(t.flags|=4194816)}}function _u(s,t,a,r,o){return Mn(t),a=lu(s,t,a,r,void 0,o),r=nu(),s!==null&&!At?(ru(s,t,o),bl(s,t,o)):(zs&&r&&Bd(t),t.flags|=1,qt(s,t,a,o),t.child)}function Cf(s,t,a,r,o,m){return Mn(t),t.updateQueue=null,a=Eh(t,r,a,o),Th(s),r=nu(),s!==null&&!At?(ru(s,t,m),bl(s,t,m)):(zs&&r&&Bd(t),t.flags|=1,qt(s,t,a,m),t.child)}function Tf(s,t,a,r,o){if(Mn(t),t.stateNode===null){var m=mr,j=a.contextType;typeof j=="object"&&j!==null&&(m=Vt(j)),m=new a(r,m),t.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=bu,t.stateNode=m,m._reactInternals=t,m=t.stateNode,m.props=r,m.state=t.memoizedState,m.refs={},Jd(t),j=a.contextType,m.context=typeof j=="object"&&j!==null?Vt(j):mr,m.state=t.memoizedState,j=a.getDerivedStateFromProps,typeof j=="function"&&(Nu(t,a,j,r),m.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(j=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),j!==m.state&&bu.enqueueReplaceState(m,m.state,null),pi(t,r,m,o),fi(),m.state=t.memoizedState),typeof m.componentDidMount=="function"&&(t.flags|=4194308),r=!0}else if(s===null){m=t.stateNode;var k=t.memoizedProps,$=Ln(a,k);m.props=$;var le=m.context,ve=a.contextType;j=mr,typeof ve=="object"&&ve!==null&&(j=Vt(ve));var ye=a.getDerivedStateFromProps;ve=typeof ye=="function"||typeof m.getSnapshotBeforeUpdate=="function",k=t.pendingProps!==k,ve||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(k||le!==j)&&hf(t,m,r,j),Vl=!1;var ce=t.memoizedState;m.state=ce,pi(t,r,m,o),fi(),le=t.memoizedState,k||ce!==le||Vl?(typeof ye=="function"&&(Nu(t,a,ye,r),le=t.memoizedState),($=Vl||xf(t,a,$,r,ce,le,j))?(ve||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(t.flags|=4194308)):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=le),m.props=r,m.state=le,m.context=j,r=$):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{m=t.stateNode,Xd(s,t),j=t.memoizedProps,ve=Ln(a,j),m.props=ve,ye=t.pendingProps,ce=m.context,le=a.contextType,$=mr,typeof le=="object"&&le!==null&&($=Vt(le)),k=a.getDerivedStateFromProps,(le=typeof k=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(j!==ye||ce!==$)&&hf(t,m,r,$),Vl=!1,ce=t.memoizedState,m.state=ce,pi(t,r,m,o),fi();var xe=t.memoizedState;j!==ye||ce!==xe||Vl||s!==null&&s.dependencies!==null&&zc(s.dependencies)?(typeof k=="function"&&(Nu(t,a,k,r),xe=t.memoizedState),(ve=Vl||xf(t,a,ve,r,ce,xe,$)||s!==null&&s.dependencies!==null&&zc(s.dependencies))?(le||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(r,xe,$),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(r,xe,$)),typeof m.componentDidUpdate=="function"&&(t.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof m.componentDidUpdate!="function"||j===s.memoizedProps&&ce===s.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||j===s.memoizedProps&&ce===s.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=xe),m.props=r,m.state=xe,m.context=$,r=ve):(typeof m.componentDidUpdate!="function"||j===s.memoizedProps&&ce===s.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||j===s.memoizedProps&&ce===s.memoizedState||(t.flags|=1024),r=!1)}return m=r,Jc(s,t),r=(t.flags&128)!==0,m||r?(m=t.stateNode,a=r&&typeof a.getDerivedStateFromError!="function"?null:m.render(),t.flags|=1,s!==null&&r?(t.child=Dn(t,s.child,null,o),t.child=Dn(t,null,a,o)):qt(s,t,a,o),t.memoizedState=m.state,s=t.child):s=bl(s,t,o),s}function Ef(s,t,a,r){return Tn(),t.flags|=256,qt(s,t,a,r),t.child}var Su={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function ku(s){return{baseLanes:s,cachePool:gh()}}function Cu(s,t,a){return s=s!==null?s.childLanes&~a:0,t&&(s|=_a),s}function Mf(s,t,a){var r=t.pendingProps,o=!1,m=(t.flags&128)!==0,j;if((j=m)||(j=s!==null&&s.memoizedState===null?!1:(St.current&2)!==0),j&&(o=!0,t.flags&=-129),j=(t.flags&32)!==0,t.flags&=-33,s===null){if(zs){if(o?Ql(t):Yl(),(s=it)?(s=$p(s,Ia),s=s!==null&&s.data!=="&"?s:null,s!==null&&(t.memoizedState={dehydrated:s,treeContext:Pl!==null?{id:al,overflow:ll}:null,retryLane:536870912,hydrationErrors:null},a=ch(s),a.return=t,t.child=a,Gt=t,it=null)):s=null,s===null)throw Fl(t);return om(s)?t.lanes=32:t.lanes=536870912,null}var k=r.children;return r=r.fallback,o?(Yl(),o=t.mode,k=Xc({mode:"hidden",children:k},o),r=Cn(r,o,a,null),k.return=t,r.return=t,k.sibling=r,t.child=k,r=t.child,r.memoizedState=ku(a),r.childLanes=Cu(s,j,a),t.memoizedState=Su,bi(null,r)):(Ql(t),Tu(t,k))}var $=s.memoizedState;if($!==null&&(k=$.dehydrated,k!==null)){if(m)t.flags&256?(Ql(t),t.flags&=-257,t=Eu(s,t,a)):t.memoizedState!==null?(Yl(),t.child=s.child,t.flags|=128,t=null):(Yl(),k=r.fallback,o=t.mode,r=Xc({mode:"visible",children:r.children},o),k=Cn(k,o,a,null),k.flags|=2,r.return=t,k.return=t,r.sibling=k,t.child=r,Dn(t,s.child,null,a),r=t.child,r.memoizedState=ku(a),r.childLanes=Cu(s,j,a),t.memoizedState=Su,t=bi(null,r));else if(Ql(t),om(k)){if(j=k.nextSibling&&k.nextSibling.dataset,j)var le=j.dgst;j=le,r=Error(c(419)),r.stack="",r.digest=j,oi({value:r,source:null,stack:null}),t=Eu(s,t,a)}else if(At||pr(s,t,a,!1),j=(a&s.childLanes)!==0,At||j){if(j=Ws,j!==null&&(r=rt(j,a),r!==0&&r!==$.retryLane))throw $.retryLane=r,kn(s,r),fa(j,s,r),wu;cm(k)||ro(),t=Eu(s,t,a)}else cm(k)?(t.flags|=192,t.child=s.child,t=null):(s=$.treeContext,it=Ha(k.nextSibling),Gt=t,zs=!0,Hl=null,Ia=!1,s!==null&&uh(t,s),t=Tu(t,r.children),t.flags|=4096);return t}return o?(Yl(),k=r.fallback,o=t.mode,$=s.child,le=$.sibling,r=fl($,{mode:"hidden",children:r.children}),r.subtreeFlags=$.subtreeFlags&65011712,le!==null?k=fl(le,k):(k=Cn(k,o,a,null),k.flags|=2),k.return=t,r.return=t,r.sibling=k,t.child=r,bi(null,r),r=t.child,k=s.child.memoizedState,k===null?k=ku(a):(o=k.cachePool,o!==null?($=Mt._currentValue,o=o.parent!==$?{parent:$,pool:$}:o):o=gh(),k={baseLanes:k.baseLanes|a,cachePool:o}),r.memoizedState=k,r.childLanes=Cu(s,j,a),t.memoizedState=Su,bi(s.child,r)):(Ql(t),a=s.child,s=a.sibling,a=fl(a,{mode:"visible",children:r.children}),a.return=t,a.sibling=null,s!==null&&(j=t.deletions,j===null?(t.deletions=[s],t.flags|=16):j.push(s)),t.child=a,t.memoizedState=null,a)}function Tu(s,t){return t=Xc({mode:"visible",children:t},s.mode),t.return=s,s.child=t}function Xc(s,t){return s=Na(22,s,null,t),s.lanes=0,s}function Eu(s,t,a){return Dn(t,s.child,null,a),s=Tu(t,t.pendingProps.children),s.flags|=2,t.memoizedState=null,s}function zf(s,t,a){s.lanes|=t;var r=s.alternate;r!==null&&(r.lanes|=t),Gd(s.return,t,a)}function Mu(s,t,a,r,o,m){var j=s.memoizedState;j===null?s.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:a,tailMode:o,treeForkCount:m}:(j.isBackwards=t,j.rendering=null,j.renderingStartTime=0,j.last=r,j.tail=a,j.tailMode=o,j.treeForkCount=m)}function Af(s,t,a){var r=t.pendingProps,o=r.revealOrder,m=r.tail;r=r.children;var j=St.current,k=(j&2)!==0;if(k?(j=j&1|2,t.flags|=128):j&=1,Te(St,j),qt(s,t,r,a),r=zs?ci:0,!k&&s!==null&&(s.flags&128)!==0)e:for(s=t.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&zf(s,a,t);else if(s.tag===19)zf(s,a,t);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}switch(o){case"forwards":for(a=t.child,o=null;a!==null;)s=a.alternate,s!==null&&Bc(s)===null&&(o=a),a=a.sibling;a=o,a===null?(o=t.child,t.child=null):(o=a.sibling,a.sibling=null),Mu(t,!1,o,a,m,r);break;case"backwards":case"unstable_legacy-backwards":for(a=null,o=t.child,t.child=null;o!==null;){if(s=o.alternate,s!==null&&Bc(s)===null){t.child=o;break}s=o.sibling,o.sibling=a,a=o,o=s}Mu(t,!0,a,null,m,r);break;case"together":Mu(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function bl(s,t,a){if(s!==null&&(t.dependencies=s.dependencies),Zl|=t.lanes,(a&t.childLanes)===0)if(s!==null){if(pr(s,t,a,!1),(a&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,a=fl(s,s.pendingProps),t.child=a,a.return=t;s.sibling!==null;)s=s.sibling,a=a.sibling=fl(s,s.pendingProps),a.return=t;a.sibling=null}return t.child}function zu(s,t){return(s.lanes&t)!==0?!0:(s=s.dependencies,!!(s!==null&&zc(s)))}function vy(s,t,a){switch(t.tag){case 3:Oe(t,t.stateNode.containerInfo),Gl(t,Mt,s.memoizedState.cache),Tn();break;case 27:case 5:Y(t);break;case 4:Oe(t,t.stateNode.containerInfo);break;case 10:Gl(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,tu(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated!==null?(Ql(t),t.flags|=128,null):(a&t.child.childLanes)!==0?Mf(s,t,a):(Ql(t),s=bl(s,t,a),s!==null?s.sibling:null);Ql(t);break;case 19:var o=(s.flags&128)!==0;if(r=(a&t.childLanes)!==0,r||(pr(s,t,a,!1),r=(a&t.childLanes)!==0),o){if(r)return Af(s,t,a);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),Te(St,St.current),r)break;return null;case 22:return t.lanes=0,_f(s,t,a,t.pendingProps);case 24:Gl(t,Mt,s.memoizedState.cache)}return bl(s,t,a)}function Of(s,t,a){if(s!==null)if(s.memoizedProps!==t.pendingProps)At=!0;else{if(!zu(s,a)&&(t.flags&128)===0)return At=!1,vy(s,t,a);At=(s.flags&131072)!==0}else At=!1,zs&&(t.flags&1048576)!==0&&dh(t,ci,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(s=An(t.elementType),t.type=s,typeof s=="function")Ld(s)?(r=Ln(s,r),t.tag=1,t=Tf(null,t,s,r,a)):(t.tag=0,t=_u(null,t,s,r,a));else{if(s!=null){var o=s.$$typeof;if(o===C){t.tag=11,t=bf(null,t,s,r,a);break e}else if(o===L){t.tag=14,t=yf(null,t,s,r,a);break e}}throw t=fe(s)||s,Error(c(306,t,""))}}return t;case 0:return _u(s,t,t.type,t.pendingProps,a);case 1:return r=t.type,o=Ln(r,t.pendingProps),Tf(s,t,r,o,a);case 3:e:{if(Oe(t,t.stateNode.containerInfo),s===null)throw Error(c(387));r=t.pendingProps;var m=t.memoizedState;o=m.element,Xd(s,t),pi(t,r,null,a);var j=t.memoizedState;if(r=j.cache,Gl(t,Mt,r),r!==m.cache&&Vd(t,[Mt],a,!0),fi(),r=j.element,m.isDehydrated)if(m={element:r,isDehydrated:!1,cache:j.cache},t.updateQueue.baseState=m,t.memoizedState=m,t.flags&256){t=Ef(s,t,r,a);break e}else if(r!==o){o=Ua(Error(c(424)),t),oi(o),t=Ef(s,t,r,a);break e}else{switch(s=t.stateNode.containerInfo,s.nodeType){case 9:s=s.body;break;default:s=s.nodeName==="HTML"?s.ownerDocument.body:s}for(it=Ha(s.firstChild),Gt=t,zs=!0,Hl=null,Ia=!0,a=wh(t,null,r,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Tn(),r===o){t=bl(s,t,a);break e}qt(s,t,r,a)}t=t.child}return t;case 26:return Jc(s,t),s===null?(a=Gp(t.type,null,t.pendingProps,null))?t.memoizedState=a:zs||(a=t.type,s=t.pendingProps,r=ho(V.current).createElement(a),r[js]=t,r[is]=s,Kt(r,a,s),It(r),t.stateNode=r):t.memoizedState=Gp(t.type,s.memoizedProps,t.pendingProps,s.memoizedState),null;case 27:return Y(t),s===null&&zs&&(r=t.stateNode=Pp(t.type,t.pendingProps,V.current),Gt=t,Ia=!0,o=it,an(t.type)?(dm=o,it=Ha(r.firstChild)):it=o),qt(s,t,t.pendingProps.children,a),Jc(s,t),s===null&&(t.flags|=4194304),t.child;case 5:return s===null&&zs&&((o=r=it)&&(r=Yy(r,t.type,t.pendingProps,Ia),r!==null?(t.stateNode=r,Gt=t,it=Ha(r.firstChild),Ia=!1,o=!0):o=!1),o||Fl(t)),Y(t),o=t.type,m=t.pendingProps,j=s!==null?s.memoizedProps:null,r=m.children,nm(o,m)?r=null:j!==null&&nm(o,j)&&(t.flags|=32),t.memoizedState!==null&&(o=lu(s,t,dy,null,null,a),Li._currentValue=o),Jc(s,t),qt(s,t,r,a),t.child;case 6:return s===null&&zs&&((s=a=it)&&(a=Jy(a,t.pendingProps,Ia),a!==null?(t.stateNode=a,Gt=t,it=null,s=!0):s=!1),s||Fl(t)),null;case 13:return Mf(s,t,a);case 4:return Oe(t,t.stateNode.containerInfo),r=t.pendingProps,s===null?t.child=Dn(t,null,r,a):qt(s,t,r,a),t.child;case 11:return bf(s,t,t.type,t.pendingProps,a);case 7:return qt(s,t,t.pendingProps,a),t.child;case 8:return qt(s,t,t.pendingProps.children,a),t.child;case 12:return qt(s,t,t.pendingProps.children,a),t.child;case 10:return r=t.pendingProps,Gl(t,t.type,r.value),qt(s,t,r.children,a),t.child;case 9:return o=t.type._context,r=t.pendingProps.children,Mn(t),o=Vt(o),r=r(o),t.flags|=1,qt(s,t,r,a),t.child;case 14:return yf(s,t,t.type,t.pendingProps,a);case 15:return wf(s,t,t.type,t.pendingProps,a);case 19:return Af(s,t,a);case 31:return jy(s,t,a);case 22:return _f(s,t,a,t.pendingProps);case 24:return Mn(t),r=Vt(Mt),s===null?(o=Qd(),o===null&&(o=Ws,m=qd(),o.pooledCache=m,m.refCount++,m!==null&&(o.pooledCacheLanes|=a),o=m),t.memoizedState={parent:r,cache:o},Jd(t),Gl(t,Mt,o)):((s.lanes&a)!==0&&(Xd(s,t),pi(t,null,null,a),fi()),o=s.memoizedState,m=t.memoizedState,o.parent!==r?(o={parent:r,cache:r},t.memoizedState=o,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=o),Gl(t,Mt,r)):(r=m.cache,Gl(t,Mt,r),r!==o.cache&&Vd(t,[Mt],a,!0))),qt(s,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(c(156,t.tag))}function yl(s){s.flags|=4}function Au(s,t,a,r,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(rp())s.flags|=8192;else throw On=Rc,Yd}else s.flags&=-16777217}function Df(s,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)s.flags&=-16777217;else if(s.flags|=16777216,!Yp(t))if(rp())s.flags|=8192;else throw On=Rc,Yd}function Zc(s,t){t!==null&&(s.flags|=4),s.flags&16384&&(t=s.tag!==22?se():536870912,s.lanes|=t,Tr|=t)}function yi(s,t){if(!zs)switch(s.tailMode){case"hidden":t=s.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?s.tail=null:a.sibling=null;break;case"collapsed":a=s.tail;for(var r=null;a!==null;)a.alternate!==null&&(r=a),a=a.sibling;r===null?t||s.tail===null?s.tail=null:s.tail.sibling=null:r.sibling=null}}function ct(s){var t=s.alternate!==null&&s.alternate.child===s.child,a=0,r=0;if(t)for(var o=s.child;o!==null;)a|=o.lanes|o.childLanes,r|=o.subtreeFlags&65011712,r|=o.flags&65011712,o.return=s,o=o.sibling;else for(o=s.child;o!==null;)a|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=s,o=o.sibling;return s.subtreeFlags|=r,s.childLanes=a,t}function Ny(s,t,a){var r=t.pendingProps;switch(Id(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ct(t),null;case 1:return ct(t),null;case 3:return a=t.stateNode,r=null,s!==null&&(r=s.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),jl(Mt),W(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(s===null||s.child===null)&&(fr(t)?yl(t):s===null||s.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Hd())),ct(t),null;case 26:var o=t.type,m=t.memoizedState;return s===null?(yl(t),m!==null?(ct(t),Df(t,m)):(ct(t),Au(t,o,null,r,a))):m?m!==s.memoizedState?(yl(t),ct(t),Df(t,m)):(ct(t),t.flags&=-16777217):(s=s.memoizedProps,s!==r&&yl(t),ct(t),Au(t,o,s,r,a)),null;case 27:if(He(t),a=V.current,o=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==r&&yl(t);else{if(!r){if(t.stateNode===null)throw Error(c(166));return ct(t),null}s=A.current,fr(t)?mh(t):(s=Pp(o,r,a),t.stateNode=s,yl(t))}return ct(t),null;case 5:if(He(t),o=t.type,s!==null&&t.stateNode!=null)s.memoizedProps!==r&&yl(t);else{if(!r){if(t.stateNode===null)throw Error(c(166));return ct(t),null}if(m=A.current,fr(t))mh(t);else{var j=ho(V.current);switch(m){case 1:m=j.createElementNS("http://www.w3.org/2000/svg",o);break;case 2:m=j.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;default:switch(o){case"svg":m=j.createElementNS("http://www.w3.org/2000/svg",o);break;case"math":m=j.createElementNS("http://www.w3.org/1998/Math/MathML",o);break;case"script":m=j.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof r.is=="string"?j.createElement("select",{is:r.is}):j.createElement("select"),r.multiple?m.multiple=!0:r.size&&(m.size=r.size);break;default:m=typeof r.is=="string"?j.createElement(o,{is:r.is}):j.createElement(o)}}m[js]=t,m[is]=r;e:for(j=t.child;j!==null;){if(j.tag===5||j.tag===6)m.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===t)break e;for(;j.sibling===null;){if(j.return===null||j.return===t)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}t.stateNode=m;e:switch(Kt(m,o,r),o){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&yl(t)}}return ct(t),Au(t,t.type,s===null?null:s.memoizedProps,t.pendingProps,a),null;case 6:if(s&&t.stateNode!=null)s.memoizedProps!==r&&yl(t);else{if(typeof r!="string"&&t.stateNode===null)throw Error(c(166));if(s=V.current,fr(t)){if(s=t.stateNode,a=t.memoizedProps,r=null,o=Gt,o!==null)switch(o.tag){case 27:case 5:r=o.memoizedProps}s[js]=t,s=!!(s.nodeValue===a||r!==null&&r.suppressHydrationWarning===!0||Mp(s.nodeValue,a)),s||Fl(t,!0)}else s=ho(s).createTextNode(r),s[js]=t,t.stateNode=s}return ct(t),null;case 31:if(a=t.memoizedState,s===null||s.memoizedState!==null){if(r=fr(t),a!==null){if(s===null){if(!r)throw Error(c(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(557));s[js]=t}else Tn(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;ct(t),s=!1}else a=Hd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=a),s=!0;if(!s)return t.flags&256?(ya(t),t):(ya(t),null);if((t.flags&128)!==0)throw Error(c(558))}return ct(t),null;case 13:if(r=t.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(o=fr(t),r!==null&&r.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[js]=t}else Tn(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;ct(t),o=!1}else o=Hd(),s!==null&&s.memoizedState!==null&&(s.memoizedState.hydrationErrors=o),o=!0;if(!o)return t.flags&256?(ya(t),t):(ya(t),null)}return ya(t),(t.flags&128)!==0?(t.lanes=a,t):(a=r!==null,s=s!==null&&s.memoizedState!==null,a&&(r=t.child,o=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(o=r.alternate.memoizedState.cachePool.pool),m=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(m=r.memoizedState.cachePool.pool),m!==o&&(r.flags|=2048)),a!==s&&a&&(t.child.flags|=8192),Zc(t,t.updateQueue),ct(t),null);case 4:return W(),s===null&&em(t.stateNode.containerInfo),ct(t),null;case 10:return jl(t.type),ct(t),null;case 19:if(pe(St),r=t.memoizedState,r===null)return ct(t),null;if(o=(t.flags&128)!==0,m=r.rendering,m===null)if(o)yi(r,!1);else{if(Nt!==0||s!==null&&(s.flags&128)!==0)for(s=t.child;s!==null;){if(m=Bc(s),m!==null){for(t.flags|=128,yi(r,!1),s=m.updateQueue,t.updateQueue=s,Zc(t,s),t.subtreeFlags=0,s=a,a=t.child;a!==null;)ih(a,s),a=a.sibling;return Te(St,St.current&1|2),zs&&pl(t,r.treeForkCount),t.child}s=s.sibling}r.tail!==null&&mt()>ao&&(t.flags|=128,o=!0,yi(r,!1),t.lanes=4194304)}else{if(!o)if(s=Bc(m),s!==null){if(t.flags|=128,o=!0,s=s.updateQueue,t.updateQueue=s,Zc(t,s),yi(r,!0),r.tail===null&&r.tailMode==="hidden"&&!m.alternate&&!zs)return ct(t),null}else 2*mt()-r.renderingStartTime>ao&&a!==536870912&&(t.flags|=128,o=!0,yi(r,!1),t.lanes=4194304);r.isBackwards?(m.sibling=t.child,t.child=m):(s=r.last,s!==null?s.sibling=m:t.child=m,r.last=m)}return r.tail!==null?(s=r.tail,r.rendering=s,r.tail=s.sibling,r.renderingStartTime=mt(),s.sibling=null,a=St.current,Te(St,o?a&1|2:a&1),zs&&pl(t,r.treeForkCount),s):(ct(t),null);case 22:case 23:return ya(t),su(),r=t.memoizedState!==null,s!==null?s.memoizedState!==null!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?(a&536870912)!==0&&(t.flags&128)===0&&(ct(t),t.subtreeFlags&6&&(t.flags|=8192)):ct(t),a=t.updateQueue,a!==null&&Zc(t,a.retryQueue),a=null,s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==a&&(t.flags|=2048),s!==null&&pe(zn),null;case 24:return a=null,s!==null&&(a=s.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),jl(Mt),ct(t),null;case 25:return null;case 30:return null}throw Error(c(156,t.tag))}function by(s,t){switch(Id(t),t.tag){case 1:return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 3:return jl(Mt),W(),s=t.flags,(s&65536)!==0&&(s&128)===0?(t.flags=s&-65537|128,t):null;case 26:case 27:case 5:return He(t),null;case 31:if(t.memoizedState!==null){if(ya(t),t.alternate===null)throw Error(c(340));Tn()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 13:if(ya(t),s=t.memoizedState,s!==null&&s.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Tn()}return s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 19:return pe(St),null;case 4:return W(),null;case 10:return jl(t.type),null;case 22:case 23:return ya(t),su(),s!==null&&pe(zn),s=t.flags,s&65536?(t.flags=s&-65537|128,t):null;case 24:return jl(Mt),null;case 25:return null;default:return null}}function Rf(s,t){switch(Id(t),t.tag){case 3:jl(Mt),W();break;case 26:case 27:case 5:He(t);break;case 4:W();break;case 31:t.memoizedState!==null&&ya(t);break;case 13:ya(t);break;case 19:pe(St);break;case 10:jl(t.type);break;case 22:case 23:ya(t),su(),s!==null&&pe(zn);break;case 24:jl(Mt)}}function wi(s,t){try{var a=t.updateQueue,r=a!==null?a.lastEffect:null;if(r!==null){var o=r.next;a=o;do{if((a.tag&s)===s){r=void 0;var m=a.create,j=a.inst;r=m(),j.destroy=r}a=a.next}while(a!==o)}}catch(k){Vs(t,t.return,k)}}function Jl(s,t,a){try{var r=t.updateQueue,o=r!==null?r.lastEffect:null;if(o!==null){var m=o.next;r=m;do{if((r.tag&s)===s){var j=r.inst,k=j.destroy;if(k!==void 0){j.destroy=void 0,o=t;var $=a,le=k;try{le()}catch(ve){Vs(o,$,ve)}}}r=r.next}while(r!==m)}}catch(ve){Vs(t,t.return,ve)}}function Lf(s){var t=s.updateQueue;if(t!==null){var a=s.stateNode;try{Sh(t,a)}catch(r){Vs(s,s.return,r)}}}function Uf(s,t,a){a.props=Ln(s.type,s.memoizedProps),a.state=s.memoizedState;try{a.componentWillUnmount()}catch(r){Vs(s,t,r)}}function _i(s,t){try{var a=s.ref;if(a!==null){switch(s.tag){case 26:case 27:case 5:var r=s.stateNode;break;case 30:r=s.stateNode;break;default:r=s.stateNode}typeof a=="function"?s.refCleanup=a(r):a.current=r}}catch(o){Vs(s,t,o)}}function nl(s,t){var a=s.ref,r=s.refCleanup;if(a!==null)if(typeof r=="function")try{r()}catch(o){Vs(s,t,o)}finally{s.refCleanup=null,s=s.alternate,s!=null&&(s.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(o){Vs(s,t,o)}else a.current=null}function $f(s){var t=s.type,a=s.memoizedProps,r=s.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&r.focus();break e;case"img":a.src?r.src=a.src:a.srcSet&&(r.srcset=a.srcSet)}}catch(o){Vs(s,s.return,o)}}function Ou(s,t,a){try{var r=s.stateNode;Fy(r,s.type,a,t),r[is]=t}catch(o){Vs(s,s.return,o)}}function Bf(s){return s.tag===5||s.tag===3||s.tag===26||s.tag===27&&an(s.type)||s.tag===4}function Du(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||Bf(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&&an(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 Ru(s,t,a){var r=s.tag;if(r===5||r===6)s=s.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(s,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(s),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=xl));else if(r!==4&&(r===27&&an(s.type)&&(a=s.stateNode,t=null),s=s.child,s!==null))for(Ru(s,t,a),s=s.sibling;s!==null;)Ru(s,t,a),s=s.sibling}function Wc(s,t,a){var r=s.tag;if(r===5||r===6)s=s.stateNode,t?a.insertBefore(s,t):a.appendChild(s);else if(r!==4&&(r===27&&an(s.type)&&(a=s.stateNode),s=s.child,s!==null))for(Wc(s,t,a),s=s.sibling;s!==null;)Wc(s,t,a),s=s.sibling}function If(s){var t=s.stateNode,a=s.memoizedProps;try{for(var r=s.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);Kt(t,r,a),t[js]=s,t[is]=a}catch(m){Vs(s,s.return,m)}}var wl=!1,Ot=!1,Lu=!1,Pf=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function yy(s,t){if(s=s.containerInfo,am=bo,s=Zx(s),Ed(s)){if("selectionStart"in s)var a={start:s.selectionStart,end:s.selectionEnd};else e:{a=(a=s.ownerDocument)&&a.defaultView||window;var r=a.getSelection&&a.getSelection();if(r&&r.rangeCount!==0){a=r.anchorNode;var o=r.anchorOffset,m=r.focusNode;r=r.focusOffset;try{a.nodeType,m.nodeType}catch{a=null;break e}var j=0,k=-1,$=-1,le=0,ve=0,ye=s,ce=null;s:for(;;){for(var xe;ye!==a||o!==0&&ye.nodeType!==3||(k=j+o),ye!==m||r!==0&&ye.nodeType!==3||($=j+r),ye.nodeType===3&&(j+=ye.nodeValue.length),(xe=ye.firstChild)!==null;)ce=ye,ye=xe;for(;;){if(ye===s)break s;if(ce===a&&++le===o&&(k=j),ce===m&&++ve===r&&($=j),(xe=ye.nextSibling)!==null)break;ye=ce,ce=ye.parentNode}ye=xe}a=k===-1||$===-1?null:{start:k,end:$}}else a=null}a=a||{start:0,end:0}}else a=null;for(lm={focusedElem:s,selectionRange:a},bo=!1,Pt=t;Pt!==null;)if(t=Pt,s=t.child,(t.subtreeFlags&1028)!==0&&s!==null)s.return=t,Pt=s;else for(;Pt!==null;){switch(t=Pt,m=t.alternate,s=t.flags,t.tag){case 0:if((s&4)!==0&&(s=t.updateQueue,s=s!==null?s.events:null,s!==null))for(a=0;a<s.length;a++)o=s[a],o.ref.impl=o.nextImpl;break;case 11:case 15:break;case 1:if((s&1024)!==0&&m!==null){s=void 0,a=t,o=m.memoizedProps,m=m.memoizedState,r=a.stateNode;try{var Fe=Ln(a.type,o);s=r.getSnapshotBeforeUpdate(Fe,m),r.__reactInternalSnapshotBeforeUpdate=s}catch(Ze){Vs(a,a.return,Ze)}}break;case 3:if((s&1024)!==0){if(s=t.stateNode.containerInfo,a=s.nodeType,a===9)im(s);else if(a===1)switch(s.nodeName){case"HEAD":case"HTML":case"BODY":im(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,Pt=s;break}Pt=t.return}}function Hf(s,t,a){var r=a.flags;switch(a.tag){case 0:case 11:case 15:Sl(s,a),r&4&&wi(5,a);break;case 1:if(Sl(s,a),r&4)if(s=a.stateNode,t===null)try{s.componentDidMount()}catch(j){Vs(a,a.return,j)}else{var o=Ln(a.type,t.memoizedProps);t=t.memoizedState;try{s.componentDidUpdate(o,t,s.__reactInternalSnapshotBeforeUpdate)}catch(j){Vs(a,a.return,j)}}r&64&&Lf(a),r&512&&_i(a,a.return);break;case 3:if(Sl(s,a),r&64&&(s=a.updateQueue,s!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{Sh(s,t)}catch(j){Vs(a,a.return,j)}}break;case 27:t===null&&r&4&&If(a);case 26:case 5:Sl(s,a),t===null&&r&4&&$f(a),r&512&&_i(a,a.return);break;case 12:Sl(s,a);break;case 31:Sl(s,a),r&4&&Vf(s,a);break;case 13:Sl(s,a),r&4&&qf(s,a),r&64&&(s=a.memoizedState,s!==null&&(s=s.dehydrated,s!==null&&(a=zy.bind(null,a),Xy(s,a))));break;case 22:if(r=a.memoizedState!==null||wl,!r){t=t!==null&&t.memoizedState!==null||Ot,o=wl;var m=Ot;wl=r,(Ot=t)&&!m?kl(s,a,(a.subtreeFlags&8772)!==0):Sl(s,a),wl=o,Ot=m}break;case 30:break;default:Sl(s,a)}}function Ff(s){var t=s.alternate;t!==null&&(s.alternate=null,Ff(t)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(t=s.stateNode,t!==null&&md(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 ht=null,ua=!1;function _l(s,t,a){for(a=a.child;a!==null;)Gf(s,t,a),a=a.sibling}function Gf(s,t,a){if(ls&&typeof ls.onCommitFiberUnmount=="function")try{ls.onCommitFiberUnmount(bs,a)}catch{}switch(a.tag){case 26:Ot||nl(a,t),_l(s,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ot||nl(a,t);var r=ht,o=ua;an(a.type)&&(ht=a.stateNode,ua=!1),_l(s,t,a),Oi(a.stateNode),ht=r,ua=o;break;case 5:Ot||nl(a,t);case 6:if(r=ht,o=ua,ht=null,_l(s,t,a),ht=r,ua=o,ht!==null)if(ua)try{(ht.nodeType===9?ht.body:ht.nodeName==="HTML"?ht.ownerDocument.body:ht).removeChild(a.stateNode)}catch(m){Vs(a,t,m)}else try{ht.removeChild(a.stateNode)}catch(m){Vs(a,t,m)}break;case 18:ht!==null&&(ua?(s=ht,Lp(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,a.stateNode),Lr(s)):Lp(ht,a.stateNode));break;case 4:r=ht,o=ua,ht=a.stateNode.containerInfo,ua=!0,_l(s,t,a),ht=r,ua=o;break;case 0:case 11:case 14:case 15:Jl(2,a,t),Ot||Jl(4,a,t),_l(s,t,a);break;case 1:Ot||(nl(a,t),r=a.stateNode,typeof r.componentWillUnmount=="function"&&Uf(a,t,r)),_l(s,t,a);break;case 21:_l(s,t,a);break;case 22:Ot=(r=Ot)||a.memoizedState!==null,_l(s,t,a),Ot=r;break;default:_l(s,t,a)}}function Vf(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null))){s=s.dehydrated;try{Lr(s)}catch(a){Vs(t,t.return,a)}}}function qf(s,t){if(t.memoizedState===null&&(s=t.alternate,s!==null&&(s=s.memoizedState,s!==null&&(s=s.dehydrated,s!==null))))try{Lr(s)}catch(a){Vs(t,t.return,a)}}function wy(s){switch(s.tag){case 31:case 13:case 19:var t=s.stateNode;return t===null&&(t=s.stateNode=new Pf),t;case 22:return s=s.stateNode,t=s._retryCache,t===null&&(t=s._retryCache=new Pf),t;default:throw Error(c(435,s.tag))}}function eo(s,t){var a=wy(s);t.forEach(function(r){if(!a.has(r)){a.add(r);var o=Ay.bind(null,s,r);r.then(o,o)}})}function ma(s,t){var a=t.deletions;if(a!==null)for(var r=0;r<a.length;r++){var o=a[r],m=s,j=t,k=j;e:for(;k!==null;){switch(k.tag){case 27:if(an(k.type)){ht=k.stateNode,ua=!1;break e}break;case 5:ht=k.stateNode,ua=!1;break e;case 3:case 4:ht=k.stateNode.containerInfo,ua=!0;break e}k=k.return}if(ht===null)throw Error(c(160));Gf(m,j,o),ht=null,ua=!1,m=o.alternate,m!==null&&(m.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Kf(t,s),t=t.sibling}var Ja=null;function Kf(s,t){var a=s.alternate,r=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:ma(t,s),xa(s),r&4&&(Jl(3,s,s.return),wi(3,s),Jl(5,s,s.return));break;case 1:ma(t,s),xa(s),r&512&&(Ot||a===null||nl(a,a.return)),r&64&&wl&&(s=s.updateQueue,s!==null&&(r=s.callbacks,r!==null&&(a=s.shared.hiddenCallbacks,s.shared.hiddenCallbacks=a===null?r:a.concat(r))));break;case 26:var o=Ja;if(ma(t,s),xa(s),r&512&&(Ot||a===null||nl(a,a.return)),r&4){var m=a!==null?a.memoizedState:null;if(r=s.memoizedState,a===null)if(r===null)if(s.stateNode===null){e:{r=s.type,a=s.memoizedProps,o=o.ownerDocument||o;s:switch(r){case"title":m=o.getElementsByTagName("title")[0],(!m||m[bn]||m[js]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=o.createElement(r),o.head.insertBefore(m,o.querySelector("head > title"))),Kt(m,r,a),m[js]=s,It(m),r=m;break e;case"link":var j=Kp("link","href",o).get(r+(a.href||""));if(j){for(var k=0;k<j.length;k++)if(m=j[k],m.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&m.getAttribute("rel")===(a.rel==null?null:a.rel)&&m.getAttribute("title")===(a.title==null?null:a.title)&&m.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){j.splice(k,1);break s}}m=o.createElement(r),Kt(m,r,a),o.head.appendChild(m);break;case"meta":if(j=Kp("meta","content",o).get(r+(a.content||""))){for(k=0;k<j.length;k++)if(m=j[k],m.getAttribute("content")===(a.content==null?null:""+a.content)&&m.getAttribute("name")===(a.name==null?null:a.name)&&m.getAttribute("property")===(a.property==null?null:a.property)&&m.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&m.getAttribute("charset")===(a.charSet==null?null:a.charSet)){j.splice(k,1);break s}}m=o.createElement(r),Kt(m,r,a),o.head.appendChild(m);break;default:throw Error(c(468,r))}m[js]=s,It(m),r=m}s.stateNode=r}else Qp(o,s.type,s.stateNode);else s.stateNode=qp(o,r,s.memoizedProps);else m!==r?(m===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):m.count--,r===null?Qp(o,s.type,s.stateNode):qp(o,r,s.memoizedProps)):r===null&&s.stateNode!==null&&Ou(s,s.memoizedProps,a.memoizedProps)}break;case 27:ma(t,s),xa(s),r&512&&(Ot||a===null||nl(a,a.return)),a!==null&&r&4&&Ou(s,s.memoizedProps,a.memoizedProps);break;case 5:if(ma(t,s),xa(s),r&512&&(Ot||a===null||nl(a,a.return)),s.flags&32){o=s.stateNode;try{nr(o,"")}catch(Fe){Vs(s,s.return,Fe)}}r&4&&s.stateNode!=null&&(o=s.memoizedProps,Ou(s,o,a!==null?a.memoizedProps:o)),r&1024&&(Lu=!0);break;case 6:if(ma(t,s),xa(s),r&4){if(s.stateNode===null)throw Error(c(162));r=s.memoizedProps,a=s.stateNode;try{a.nodeValue=r}catch(Fe){Vs(s,s.return,Fe)}}break;case 3:if(go=null,o=Ja,Ja=fo(t.containerInfo),ma(t,s),Ja=o,xa(s),r&4&&a!==null&&a.memoizedState.isDehydrated)try{Lr(t.containerInfo)}catch(Fe){Vs(s,s.return,Fe)}Lu&&(Lu=!1,Qf(s));break;case 4:r=Ja,Ja=fo(s.stateNode.containerInfo),ma(t,s),xa(s),Ja=r;break;case 12:ma(t,s),xa(s);break;case 31:ma(t,s),xa(s),r&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,eo(s,r)));break;case 13:ma(t,s),xa(s),s.child.flags&8192&&s.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(to=mt()),r&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,eo(s,r)));break;case 22:o=s.memoizedState!==null;var $=a!==null&&a.memoizedState!==null,le=wl,ve=Ot;if(wl=le||o,Ot=ve||$,ma(t,s),Ot=ve,wl=le,xa(s),r&8192)e:for(t=s.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,o&&(a===null||$||wl||Ot||Un(s)),a=null,t=s;;){if(t.tag===5||t.tag===26){if(a===null){$=a=t;try{if(m=$.stateNode,o)j=m.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{k=$.stateNode;var ye=$.memoizedProps.style,ce=ye!=null&&ye.hasOwnProperty("display")?ye.display:null;k.style.display=ce==null||typeof ce=="boolean"?"":(""+ce).trim()}}catch(Fe){Vs($,$.return,Fe)}}}else if(t.tag===6){if(a===null){$=t;try{$.stateNode.nodeValue=o?"":$.memoizedProps}catch(Fe){Vs($,$.return,Fe)}}}else if(t.tag===18){if(a===null){$=t;try{var xe=$.stateNode;o?Up(xe,!0):Up($.stateNode,!1)}catch(Fe){Vs($,$.return,Fe)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===s)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=s.updateQueue,r!==null&&(a=r.retryQueue,a!==null&&(r.retryQueue=null,eo(s,a))));break;case 19:ma(t,s),xa(s),r&4&&(r=s.updateQueue,r!==null&&(s.updateQueue=null,eo(s,r)));break;case 30:break;case 21:break;default:ma(t,s),xa(s)}}function xa(s){var t=s.flags;if(t&2){try{for(var a,r=s.return;r!==null;){if(Bf(r)){a=r;break}r=r.return}if(a==null)throw Error(c(160));switch(a.tag){case 27:var o=a.stateNode,m=Du(s);Wc(s,m,o);break;case 5:var j=a.stateNode;a.flags&32&&(nr(j,""),a.flags&=-33);var k=Du(s);Wc(s,k,j);break;case 3:case 4:var $=a.stateNode.containerInfo,le=Du(s);Ru(s,le,$);break;default:throw Error(c(161))}}catch(ve){Vs(s,s.return,ve)}s.flags&=-3}t&4096&&(s.flags&=-4097)}function Qf(s){if(s.subtreeFlags&1024)for(s=s.child;s!==null;){var t=s;Qf(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),s=s.sibling}}function Sl(s,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Hf(s,t.alternate,t),t=t.sibling}function Un(s){for(s=s.child;s!==null;){var t=s;switch(t.tag){case 0:case 11:case 14:case 15:Jl(4,t,t.return),Un(t);break;case 1:nl(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Uf(t,t.return,a),Un(t);break;case 27:Oi(t.stateNode);case 26:case 5:nl(t,t.return),Un(t);break;case 22:t.memoizedState===null&&Un(t);break;case 30:Un(t);break;default:Un(t)}s=s.sibling}}function kl(s,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var r=t.alternate,o=s,m=t,j=m.flags;switch(m.tag){case 0:case 11:case 15:kl(o,m,a),wi(4,m);break;case 1:if(kl(o,m,a),r=m,o=r.stateNode,typeof o.componentDidMount=="function")try{o.componentDidMount()}catch(le){Vs(r,r.return,le)}if(r=m,o=r.updateQueue,o!==null){var k=r.stateNode;try{var $=o.shared.hiddenCallbacks;if($!==null)for(o.shared.hiddenCallbacks=null,o=0;o<$.length;o++)_h($[o],k)}catch(le){Vs(r,r.return,le)}}a&&j&64&&Lf(m),_i(m,m.return);break;case 27:If(m);case 26:case 5:kl(o,m,a),a&&r===null&&j&4&&$f(m),_i(m,m.return);break;case 12:kl(o,m,a);break;case 31:kl(o,m,a),a&&j&4&&Vf(o,m);break;case 13:kl(o,m,a),a&&j&4&&qf(o,m);break;case 22:m.memoizedState===null&&kl(o,m,a),_i(m,m.return);break;case 30:break;default:kl(o,m,a)}t=t.sibling}}function Uu(s,t){var a=null;s!==null&&s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(a=s.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==a&&(s!=null&&s.refCount++,a!=null&&di(a))}function $u(s,t){s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&di(s))}function Xa(s,t,a,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Yf(s,t,a,r),t=t.sibling}function Yf(s,t,a,r){var o=t.flags;switch(t.tag){case 0:case 11:case 15:Xa(s,t,a,r),o&2048&&wi(9,t);break;case 1:Xa(s,t,a,r);break;case 3:Xa(s,t,a,r),o&2048&&(s=null,t.alternate!==null&&(s=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==s&&(t.refCount++,s!=null&&di(s)));break;case 12:if(o&2048){Xa(s,t,a,r),s=t.stateNode;try{var m=t.memoizedProps,j=m.id,k=m.onPostCommit;typeof k=="function"&&k(j,t.alternate===null?"mount":"update",s.passiveEffectDuration,-0)}catch($){Vs(t,t.return,$)}}else Xa(s,t,a,r);break;case 31:Xa(s,t,a,r);break;case 13:Xa(s,t,a,r);break;case 23:break;case 22:m=t.stateNode,j=t.alternate,t.memoizedState!==null?m._visibility&2?Xa(s,t,a,r):Si(s,t):m._visibility&2?Xa(s,t,a,r):(m._visibility|=2,Sr(s,t,a,r,(t.subtreeFlags&10256)!==0||!1)),o&2048&&Uu(j,t);break;case 24:Xa(s,t,a,r),o&2048&&$u(t.alternate,t);break;default:Xa(s,t,a,r)}}function Sr(s,t,a,r,o){for(o=o&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var m=s,j=t,k=a,$=r,le=j.flags;switch(j.tag){case 0:case 11:case 15:Sr(m,j,k,$,o),wi(8,j);break;case 23:break;case 22:var ve=j.stateNode;j.memoizedState!==null?ve._visibility&2?Sr(m,j,k,$,o):Si(m,j):(ve._visibility|=2,Sr(m,j,k,$,o)),o&&le&2048&&Uu(j.alternate,j);break;case 24:Sr(m,j,k,$,o),o&&le&2048&&$u(j.alternate,j);break;default:Sr(m,j,k,$,o)}t=t.sibling}}function Si(s,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=s,r=t,o=r.flags;switch(r.tag){case 22:Si(a,r),o&2048&&Uu(r.alternate,r);break;case 24:Si(a,r),o&2048&&$u(r.alternate,r);break;default:Si(a,r)}t=t.sibling}}var ki=8192;function kr(s,t,a){if(s.subtreeFlags&ki)for(s=s.child;s!==null;)Jf(s,t,a),s=s.sibling}function Jf(s,t,a){switch(s.tag){case 26:kr(s,t,a),s.flags&ki&&s.memoizedState!==null&&o0(a,Ja,s.memoizedState,s.memoizedProps);break;case 5:kr(s,t,a);break;case 3:case 4:var r=Ja;Ja=fo(s.stateNode.containerInfo),kr(s,t,a),Ja=r;break;case 22:s.memoizedState===null&&(r=s.alternate,r!==null&&r.memoizedState!==null?(r=ki,ki=16777216,kr(s,t,a),ki=r):kr(s,t,a));break;default:kr(s,t,a)}}function Xf(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 Ci(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var r=t[a];Pt=r,Wf(r,s)}Xf(s)}if(s.subtreeFlags&10256)for(s=s.child;s!==null;)Zf(s),s=s.sibling}function Zf(s){switch(s.tag){case 0:case 11:case 15:Ci(s),s.flags&2048&&Jl(9,s,s.return);break;case 3:Ci(s);break;case 12:Ci(s);break;case 22:var t=s.stateNode;s.memoizedState!==null&&t._visibility&2&&(s.return===null||s.return.tag!==13)?(t._visibility&=-3,so(s)):Ci(s);break;default:Ci(s)}}function so(s){var t=s.deletions;if((s.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var r=t[a];Pt=r,Wf(r,s)}Xf(s)}for(s=s.child;s!==null;){switch(t=s,t.tag){case 0:case 11:case 15:Jl(8,t,t.return),so(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,so(t));break;default:so(t)}s=s.sibling}}function Wf(s,t){for(;Pt!==null;){var a=Pt;switch(a.tag){case 0:case 11:case 15:Jl(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var r=a.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:di(a.memoizedState.cache)}if(r=a.child,r!==null)r.return=a,Pt=r;else e:for(a=s;Pt!==null;){r=Pt;var o=r.sibling,m=r.return;if(Ff(r),r===a){Pt=null;break e}if(o!==null){o.return=m,Pt=o;break e}Pt=m}}}var _y={getCacheForType:function(s){var t=Vt(Mt),a=t.data.get(s);return a===void 0&&(a=s(),t.data.set(s,a)),a},cacheSignal:function(){return Vt(Mt).controller.signal}},Sy=typeof WeakMap=="function"?WeakMap:Map,Ps=0,Ws=null,_s=null,Ts=0,Gs=0,wa=null,Xl=!1,Cr=!1,Bu=!1,Cl=0,Nt=0,Zl=0,$n=0,Iu=0,_a=0,Tr=0,Ti=null,ha=null,Pu=!1,to=0,ep=0,ao=1/0,lo=null,Wl=null,Rt=0,en=null,Er=null,Tl=0,Hu=0,Fu=null,sp=null,Ei=0,Gu=null;function Sa(){return(Ps&2)!==0&&Ts!==0?Ts&-Ts:M.T!==null?Ju():ne()}function tp(){if(_a===0)if((Ts&536870912)===0||zs){var s=Et;Et<<=1,(Et&3932160)===0&&(Et=262144),_a=s}else _a=536870912;return s=ba.current,s!==null&&(s.flags|=32),_a}function fa(s,t,a){(s===Ws&&(Gs===2||Gs===9)||s.cancelPendingCommit!==null)&&(Mr(s,0),sn(s,Ts,_a,!1)),Le(s,a),((Ps&2)===0||s!==Ws)&&(s===Ws&&((Ps&2)===0&&($n|=a),Nt===4&&sn(s,Ts,_a,!1)),rl(s))}function ap(s,t,a){if((Ps&6)!==0)throw Error(c(327));var r=!a&&(t&127)===0&&(t&s.expiredLanes)===0||ul(s,t),o=r?Ty(s,t):qu(s,t,!0),m=r;do{if(o===0){Cr&&!r&&sn(s,t,0,!1);break}else{if(a=s.current.alternate,m&&!ky(a)){o=qu(s,t,!1),m=!1;continue}if(o===2){if(m=t,s.errorRecoveryDisabledLanes&m)var j=0;else j=s.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){t=j;e:{var k=s;o=Ti;var $=k.current.memoizedState.isDehydrated;if($&&(Mr(k,j).flags|=256),j=qu(k,j,!1),j!==2){if(Bu&&!$){k.errorRecoveryDisabledLanes|=m,$n|=m,o=4;break e}m=ha,ha=o,m!==null&&(ha===null?ha=m:ha.push.apply(ha,m))}o=j}if(m=!1,o!==2)continue}}if(o===1){Mr(s,0),sn(s,t,0,!0);break}e:{switch(r=s,m=o,m){case 0:case 1:throw Error(c(345));case 4:if((t&4194048)!==t)break;case 6:sn(r,t,_a,!Xl);break e;case 2:ha=null;break;case 3:case 5:break;default:throw Error(c(329))}if((t&62914560)===t&&(o=to+300-mt(),10<o)){if(sn(r,t,_a,!Xl),tl(r,0,!0)!==0)break e;Tl=t,r.timeoutHandle=Dp(lp.bind(null,r,a,ha,lo,Pu,t,_a,$n,Tr,Xl,m,"Throttled",-0,0),o);break e}lp(r,a,ha,lo,Pu,t,_a,$n,Tr,Xl,m,null,-0,0)}}break}while(!0);rl(s)}function lp(s,t,a,r,o,m,j,k,$,le,ve,ye,ce,xe){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:xl},Jf(t,m,ye);var Fe=(m&62914560)===m?to-mt():(m&4194048)===m?ep-mt():0;if(Fe=d0(ye,Fe),Fe!==null){Tl=m,s.cancelPendingCommit=Fe(mp.bind(null,s,t,m,a,r,o,j,k,$,ve,ye,null,ce,xe)),sn(s,m,j,!le);return}}mp(s,t,m,a,r,o,j,k,$)}function ky(s){for(var t=s;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var r=0;r<a.length;r++){var o=a[r],m=o.getSnapshot;o=o.value;try{if(!va(m(),o))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===s)break;for(;t.sibling===null;){if(t.return===null||t.return===s)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function sn(s,t,a,r){t&=~Iu,t&=~$n,s.suspendedLanes|=t,s.pingedLanes&=~t,r&&(s.warmLanes|=t),r=s.expirationTimes;for(var o=t;0<o;){var m=31-ys(o),j=1<<m;r[m]=-1,o&=~j}a!==0&&Dt(s,a,t)}function no(){return(Ps&6)===0?(Mi(0),!1):!0}function Vu(){if(_s!==null){if(Gs===0)var s=_s.return;else s=_s,gl=En=null,iu(s),Nr=null,mi=0,s=_s;for(;s!==null;)Rf(s.alternate,s),s=s.return;_s=null}}function Mr(s,t){var a=s.timeoutHandle;a!==-1&&(s.timeoutHandle=-1,qy(a)),a=s.cancelPendingCommit,a!==null&&(s.cancelPendingCommit=null,a()),Tl=0,Vu(),Ws=s,_s=a=fl(s.current,null),Ts=t,Gs=0,wa=null,Xl=!1,Cr=ul(s,t),Bu=!1,Tr=_a=Iu=$n=Zl=Nt=0,ha=Ti=null,Pu=!1,(t&8)!==0&&(t|=t&32);var r=s.entangledLanes;if(r!==0)for(s=s.entanglements,r&=t;0<r;){var o=31-ys(r),m=1<<o;t|=s[o],r&=~m}return Cl=t,kc(),a}function np(s,t){cs=null,M.H=Ni,t===vr||t===Dc?(t=Nh(),Gs=3):t===Yd?(t=Nh(),Gs=4):Gs=t===wu?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,wa=t,_s===null&&(Nt=1,Qc(s,Ua(t,s.current)))}function rp(){var s=ba.current;return s===null?!0:(Ts&4194048)===Ts?Pa===null:(Ts&62914560)===Ts||(Ts&536870912)!==0?s===Pa:!1}function ip(){var s=M.H;return M.H=Ni,s===null?Ni:s}function cp(){var s=M.A;return M.A=_y,s}function ro(){Nt=4,Xl||(Ts&4194048)!==Ts&&ba.current!==null||(Cr=!0),(Zl&134217727)===0&&($n&134217727)===0||Ws===null||sn(Ws,Ts,_a,!1)}function qu(s,t,a){var r=Ps;Ps|=2;var o=ip(),m=cp();(Ws!==s||Ts!==t)&&(lo=null,Mr(s,t)),t=!1;var j=Nt;e:do try{if(Gs!==0&&_s!==null){var k=_s,$=wa;switch(Gs){case 8:Vu(),j=6;break e;case 3:case 2:case 9:case 6:ba.current===null&&(t=!0);var le=Gs;if(Gs=0,wa=null,zr(s,k,$,le),a&&Cr){j=0;break e}break;default:le=Gs,Gs=0,wa=null,zr(s,k,$,le)}}Cy(),j=Nt;break}catch(ve){np(s,ve)}while(!0);return t&&s.shellSuspendCounter++,gl=En=null,Ps=r,M.H=o,M.A=m,_s===null&&(Ws=null,Ts=0,kc()),j}function Cy(){for(;_s!==null;)op(_s)}function Ty(s,t){var a=Ps;Ps|=2;var r=ip(),o=cp();Ws!==s||Ts!==t?(lo=null,ao=mt()+500,Mr(s,t)):Cr=ul(s,t);e:do try{if(Gs!==0&&_s!==null){t=_s;var m=wa;s:switch(Gs){case 1:Gs=0,wa=null,zr(s,t,m,1);break;case 2:case 9:if(jh(m)){Gs=0,wa=null,dp(t);break}t=function(){Gs!==2&&Gs!==9||Ws!==s||(Gs=7),rl(s)},m.then(t,t);break e;case 3:Gs=7;break e;case 4:Gs=5;break e;case 7:jh(m)?(Gs=0,wa=null,dp(t)):(Gs=0,wa=null,zr(s,t,m,7));break;case 5:var j=null;switch(_s.tag){case 26:j=_s.memoizedState;case 5:case 27:var k=_s;if(j?Yp(j):k.stateNode.complete){Gs=0,wa=null;var $=k.sibling;if($!==null)_s=$;else{var le=k.return;le!==null?(_s=le,io(le)):_s=null}break s}}Gs=0,wa=null,zr(s,t,m,5);break;case 6:Gs=0,wa=null,zr(s,t,m,6);break;case 8:Vu(),Nt=6;break e;default:throw Error(c(462))}}Ey();break}catch(ve){np(s,ve)}while(!0);return gl=En=null,M.H=r,M.A=o,Ps=a,_s!==null?0:(Ws=null,Ts=0,kc(),Nt)}function Ey(){for(;_s!==null&&!Qa();)op(_s)}function op(s){var t=Of(s.alternate,s,Cl);s.memoizedProps=s.pendingProps,t===null?io(s):_s=t}function dp(s){var t=s,a=t.alternate;switch(t.tag){case 15:case 0:t=Cf(a,t,t.pendingProps,t.type,void 0,Ts);break;case 11:t=Cf(a,t,t.pendingProps,t.type.render,t.ref,Ts);break;case 5:iu(t);default:Rf(a,t),t=_s=ih(t,Cl),t=Of(a,t,Cl)}s.memoizedProps=s.pendingProps,t===null?io(s):_s=t}function zr(s,t,a,r){gl=En=null,iu(t),Nr=null,mi=0;var o=t.return;try{if(gy(s,o,t,a,Ts)){Nt=1,Qc(s,Ua(a,s.current)),_s=null;return}}catch(m){if(o!==null)throw _s=o,m;Nt=1,Qc(s,Ua(a,s.current)),_s=null;return}t.flags&32768?(zs||r===1?s=!0:Cr||(Ts&536870912)!==0?s=!1:(Xl=s=!0,(r===2||r===9||r===3||r===6)&&(r=ba.current,r!==null&&r.tag===13&&(r.flags|=16384))),up(t,s)):io(t)}function io(s){var t=s;do{if((t.flags&32768)!==0){up(t,Xl);return}s=t.return;var a=Ny(t.alternate,t,Cl);if(a!==null){_s=a;return}if(t=t.sibling,t!==null){_s=t;return}_s=t=s}while(t!==null);Nt===0&&(Nt=5)}function up(s,t){do{var a=by(s.alternate,s);if(a!==null){a.flags&=32767,_s=a;return}if(a=s.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(s=s.sibling,s!==null)){_s=s;return}_s=s=a}while(s!==null);Nt=6,_s=null}function mp(s,t,a,r,o,m,j,k,$){s.cancelPendingCommit=null;do co();while(Rt!==0);if((Ps&6)!==0)throw Error(c(327));if(t!==null){if(t===s.current)throw Error(c(177));if(m=t.lanes|t.childLanes,m|=Dd,Hs(s,a,m,j,k,$),s===Ws&&(_s=Ws=null,Ts=0),Er=t,en=s,Tl=a,Hu=m,Fu=o,sp=r,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(s.callbackNode=null,s.callbackPriority=0,Oy(es,function(){return gp(),null})):(s.callbackNode=null,s.callbackPriority=0),r=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||r){r=M.T,M.T=null,o=K.p,K.p=2,j=Ps,Ps|=4;try{yy(s,t,a)}finally{Ps=j,K.p=o,M.T=r}}Rt=1,xp(),hp(),fp()}}function xp(){if(Rt===1){Rt=0;var s=en,t=Er,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=M.T,M.T=null;var r=K.p;K.p=2;var o=Ps;Ps|=4;try{Kf(t,s);var m=lm,j=Zx(s.containerInfo),k=m.focusedElem,$=m.selectionRange;if(j!==k&&k&&k.ownerDocument&&Xx(k.ownerDocument.documentElement,k)){if($!==null&&Ed(k)){var le=$.start,ve=$.end;if(ve===void 0&&(ve=le),"selectionStart"in k)k.selectionStart=le,k.selectionEnd=Math.min(ve,k.value.length);else{var ye=k.ownerDocument||document,ce=ye&&ye.defaultView||window;if(ce.getSelection){var xe=ce.getSelection(),Fe=k.textContent.length,Ze=Math.min($.start,Fe),Xs=$.end===void 0?Ze:Math.min($.end,Fe);!xe.extend&&Ze>Xs&&(j=Xs,Xs=Ze,Ze=j);var X=Jx(k,Ze),G=Jx(k,Xs);if(X&&G&&(xe.rangeCount!==1||xe.anchorNode!==X.node||xe.anchorOffset!==X.offset||xe.focusNode!==G.node||xe.focusOffset!==G.offset)){var te=ye.createRange();te.setStart(X.node,X.offset),xe.removeAllRanges(),Ze>Xs?(xe.addRange(te),xe.extend(G.node,G.offset)):(te.setEnd(G.node,G.offset),xe.addRange(te))}}}}for(ye=[],xe=k;xe=xe.parentNode;)xe.nodeType===1&&ye.push({element:xe,left:xe.scrollLeft,top:xe.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}}bo=!!am,lm=am=null}finally{Ps=o,K.p=r,M.T=a}}s.current=t,Rt=2}}function hp(){if(Rt===2){Rt=0;var s=en,t=Er,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=M.T,M.T=null;var r=K.p;K.p=2;var o=Ps;Ps|=4;try{Hf(s,t.alternate,t)}finally{Ps=o,K.p=r,M.T=a}}Rt=3}}function fp(){if(Rt===4||Rt===3){Rt=0,Ft();var s=en,t=Er,a=Tl,r=sp;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Rt=5:(Rt=0,Er=en=null,pp(s,s.pendingLanes));var o=s.pendingLanes;if(o===0&&(Wl=null),xt(a),t=t.stateNode,ls&&typeof ls.onCommitFiberRoot=="function")try{ls.onCommitFiberRoot(bs,t,void 0,(t.current.flags&128)===128)}catch{}if(r!==null){t=M.T,o=K.p,K.p=2,M.T=null;try{for(var m=s.onRecoverableError,j=0;j<r.length;j++){var k=r[j];m(k.value,{componentStack:k.stack})}}finally{M.T=t,K.p=o}}(Tl&3)!==0&&co(),rl(s),o=s.pendingLanes,(a&261930)!==0&&(o&42)!==0?s===Gu?Ei++:(Ei=0,Gu=s):Ei=0,Mi(0)}}function pp(s,t){(s.pooledCacheLanes&=t)===0&&(t=s.pooledCache,t!=null&&(s.pooledCache=null,di(t)))}function co(){return xp(),hp(),fp(),gp()}function gp(){if(Rt!==5)return!1;var s=en,t=Hu;Hu=0;var a=xt(Tl),r=M.T,o=K.p;try{K.p=32>a?32:a,M.T=null,a=Fu,Fu=null;var m=en,j=Tl;if(Rt=0,Er=en=null,Tl=0,(Ps&6)!==0)throw Error(c(331));var k=Ps;if(Ps|=4,Zf(m.current),Yf(m,m.current,j,a),Ps=k,Mi(0,!1),ls&&typeof ls.onPostCommitFiberRoot=="function")try{ls.onPostCommitFiberRoot(bs,m)}catch{}return!0}finally{K.p=o,M.T=r,pp(s,t)}}function jp(s,t,a){t=Ua(a,t),t=yu(s.stateNode,t,2),s=Kl(s,t,2),s!==null&&(Le(s,2),rl(s))}function Vs(s,t,a){if(s.tag===3)jp(s,s,a);else for(;t!==null;){if(t.tag===3){jp(t,s,a);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Wl===null||!Wl.has(r))){s=Ua(a,s),a=vf(2),r=Kl(t,a,2),r!==null&&(Nf(a,r,t,s),Le(r,2),rl(r));break}}t=t.return}}function Ku(s,t,a){var r=s.pingCache;if(r===null){r=s.pingCache=new Sy;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(a)||(Bu=!0,o.add(a),s=My.bind(null,s,t,a),t.then(s,s))}function My(s,t,a){var r=s.pingCache;r!==null&&r.delete(t),s.pingedLanes|=s.suspendedLanes&a,s.warmLanes&=~a,Ws===s&&(Ts&a)===a&&(Nt===4||Nt===3&&(Ts&62914560)===Ts&&300>mt()-to?(Ps&2)===0&&Mr(s,0):Iu|=a,Tr===Ts&&(Tr=0)),rl(s)}function vp(s,t){t===0&&(t=se()),s=kn(s,t),s!==null&&(Le(s,t),rl(s))}function zy(s){var t=s.memoizedState,a=0;t!==null&&(a=t.retryLane),vp(s,a)}function Ay(s,t){var a=0;switch(s.tag){case 31:case 13:var r=s.stateNode,o=s.memoizedState;o!==null&&(a=o.retryLane);break;case 19:r=s.stateNode;break;case 22:r=s.stateNode._retryCache;break;default:throw Error(c(314))}r!==null&&r.delete(t),vp(s,a)}function Oy(s,t){return Ut(s,t)}var oo=null,Ar=null,Qu=!1,uo=!1,Yu=!1,tn=0;function rl(s){s!==Ar&&s.next===null&&(Ar===null?oo=Ar=s:Ar=Ar.next=s),uo=!0,Qu||(Qu=!0,Ry())}function Mi(s,t){if(!Yu&&uo){Yu=!0;do for(var a=!1,r=oo;r!==null;){if(s!==0){var o=r.pendingLanes;if(o===0)var m=0;else{var j=r.suspendedLanes,k=r.pingedLanes;m=(1<<31-ys(42|s)+1)-1,m&=o&~(j&~k),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(a=!0,wp(r,m))}else m=Ts,m=tl(r,r===Ws?m:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),(m&3)===0||ul(r,m)||(a=!0,wp(r,m));r=r.next}while(a);Yu=!1}}function Dy(){Np()}function Np(){uo=Qu=!1;var s=0;tn!==0&&Vy()&&(s=tn);for(var t=mt(),a=null,r=oo;r!==null;){var o=r.next,m=bp(r,t);m===0?(r.next=null,a===null?oo=o:a.next=o,o===null&&(Ar=a)):(a=r,(s!==0||(m&3)!==0)&&(uo=!0)),r=o}Rt!==0&&Rt!==5||Mi(s),tn!==0&&(tn=0)}function bp(s,t){for(var a=s.suspendedLanes,r=s.pingedLanes,o=s.expirationTimes,m=s.pendingLanes&-62914561;0<m;){var j=31-ys(m),k=1<<j,$=o[j];$===-1?((k&a)===0||(k&r)!==0)&&(o[j]=Zn(k,t)):$<=t&&(s.expiredLanes|=k),m&=~k}if(t=Ws,a=Ts,a=tl(s,s===t?a:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),r=s.callbackNode,a===0||s===t&&(Gs===2||Gs===9)||s.cancelPendingCommit!==null)return r!==null&&r!==null&&aa(r),s.callbackNode=null,s.callbackPriority=0;if((a&3)===0||ul(s,a)){if(t=a&-a,t===s.callbackPriority)return t;switch(r!==null&&aa(r),xt(a)){case 2:case 8:a=Qe;break;case 32:a=es;break;case 268435456:a=as;break;default:a=es}return r=yp.bind(null,s),a=Ut(a,r),s.callbackPriority=t,s.callbackNode=a,t}return r!==null&&r!==null&&aa(r),s.callbackPriority=2,s.callbackNode=null,2}function yp(s,t){if(Rt!==0&&Rt!==5)return s.callbackNode=null,s.callbackPriority=0,null;var a=s.callbackNode;if(co()&&s.callbackNode!==a)return null;var r=Ts;return r=tl(s,s===Ws?r:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),r===0?null:(ap(s,r,t),bp(s,mt()),s.callbackNode!=null&&s.callbackNode===a?yp.bind(null,s):null)}function wp(s,t){if(co())return null;ap(s,t,!0)}function Ry(){Ky(function(){(Ps&6)!==0?Ut(qe,Dy):Np()})}function Ju(){if(tn===0){var s=gr;s===0&&(s=Ms,Ms<<=1,(Ms&261888)===0&&(Ms=256)),tn=s}return tn}function _p(s){return s==null||typeof s=="symbol"||typeof s=="boolean"?null:typeof s=="function"?s:jc(""+s)}function Sp(s,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,s.id&&a.setAttribute("form",s.id),t.parentNode.insertBefore(a,t),s=new FormData(s),a.parentNode.removeChild(a),s}function Ly(s,t,a,r,o){if(t==="submit"&&a&&a.stateNode===o){var m=_p((o[is]||null).action),j=r.submitter;j&&(t=(t=j[is]||null)?_p(t.formAction):j.getAttribute("formAction"),t!==null&&(m=t,j=null));var k=new yc("action","action",null,r,o);s.push({event:k,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(tn!==0){var $=j?Sp(o,j):new FormData(o);pu(a,{pending:!0,data:$,method:o.method,action:m},null,$)}}else typeof m=="function"&&(k.preventDefault(),$=j?Sp(o,j):new FormData(o),pu(a,{pending:!0,data:$,method:o.method,action:m},m,$))},currentTarget:o}]})}}for(var Xu=0;Xu<Od.length;Xu++){var Zu=Od[Xu],Uy=Zu.toLowerCase(),$y=Zu[0].toUpperCase()+Zu.slice(1);Ya(Uy,"on"+$y)}Ya(sh,"onAnimationEnd"),Ya(th,"onAnimationIteration"),Ya(ah,"onAnimationStart"),Ya("dblclick","onDoubleClick"),Ya("focusin","onFocus"),Ya("focusout","onBlur"),Ya(ey,"onTransitionRun"),Ya(sy,"onTransitionStart"),Ya(ty,"onTransitionCancel"),Ya(lh,"onTransitionEnd"),ar("onMouseEnter",["mouseout","mouseover"]),ar("onMouseLeave",["mouseout","mouseover"]),ar("onPointerEnter",["pointerout","pointerover"]),ar("onPointerLeave",["pointerout","pointerover"]),yn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),yn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),yn("onBeforeInput",["compositionend","keypress","textInput","paste"]),yn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),yn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),yn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zi="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(" "),By=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(zi));function kp(s,t){t=(t&4)!==0;for(var a=0;a<s.length;a++){var r=s[a],o=r.event;r=r.listeners;e:{var m=void 0;if(t)for(var j=r.length-1;0<=j;j--){var k=r[j],$=k.instance,le=k.currentTarget;if(k=k.listener,$!==m&&o.isPropagationStopped())break e;m=k,o.currentTarget=le;try{m(o)}catch(ve){Sc(ve)}o.currentTarget=null,m=$}else for(j=0;j<r.length;j++){if(k=r[j],$=k.instance,le=k.currentTarget,k=k.listener,$!==m&&o.isPropagationStopped())break e;m=k,o.currentTarget=le;try{m(o)}catch(ve){Sc(ve)}o.currentTarget=null,m=$}}}}function Ss(s,t){var a=t[ja];a===void 0&&(a=t[ja]=new Set);var r=s+"__bubble";a.has(r)||(Cp(t,s,2,!1),a.add(r))}function Wu(s,t,a){var r=0;t&&(r|=4),Cp(a,s,r,t)}var mo="_reactListening"+Math.random().toString(36).slice(2);function em(s){if(!s[mo]){s[mo]=!0,vx.forEach(function(a){a!=="selectionchange"&&(By.has(a)||Wu(a,!1,s),Wu(a,!0,s))});var t=s.nodeType===9?s:s.ownerDocument;t===null||t[mo]||(t[mo]=!0,Wu("selectionchange",!1,t))}}function Cp(s,t,a,r){switch(tg(t)){case 2:var o=x0;break;case 8:o=h0;break;default:o=fm}a=o.bind(null,t,a,s),o=void 0,!Nd||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),r?o!==void 0?s.addEventListener(t,a,{capture:!0,passive:o}):s.addEventListener(t,a,!0):o!==void 0?s.addEventListener(t,a,{passive:o}):s.addEventListener(t,a,!1)}function sm(s,t,a,r,o){var m=r;if((t&1)===0&&(t&2)===0&&r!==null)e:for(;;){if(r===null)return;var j=r.tag;if(j===3||j===4){var k=r.stateNode.containerInfo;if(k===o)break;if(j===4)for(j=r.return;j!==null;){var $=j.tag;if(($===3||$===4)&&j.stateNode.containerInfo===o)return;j=j.return}for(;k!==null;){if(j=er(k),j===null)return;if($=j.tag,$===5||$===6||$===26||$===27){r=m=j;continue e}k=k.parentNode}}r=r.return}zx(function(){var le=m,ve=jd(a),ye=[];e:{var ce=nh.get(s);if(ce!==void 0){var xe=yc,Fe=s;switch(s){case"keypress":if(Nc(a)===0)break e;case"keydown":case"keyup":xe=Ab;break;case"focusin":Fe="focus",xe=_d;break;case"focusout":Fe="blur",xe=_d;break;case"beforeblur":case"afterblur":xe=_d;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xe=Dx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xe=Nb;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xe=Rb;break;case sh:case th:case ah:xe=wb;break;case lh:xe=Ub;break;case"scroll":case"scrollend":xe=jb;break;case"wheel":xe=Bb;break;case"copy":case"cut":case"paste":xe=Sb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xe=Lx;break;case"toggle":case"beforetoggle":xe=Pb}var Ze=(t&4)!==0,Xs=!Ze&&(s==="scroll"||s==="scrollend"),X=Ze?ce!==null?ce+"Capture":null:ce;Ze=[];for(var G=le,te;G!==null;){var be=G;if(te=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||te===null||X===null||(be=Wr(G,X),be!=null&&Ze.push(Ai(G,be,te))),Xs)break;G=G.return}0<Ze.length&&(ce=new xe(ce,Fe,null,a,ve),ye.push({event:ce,listeners:Ze}))}}if((t&7)===0){e:{if(ce=s==="mouseover"||s==="pointerover",xe=s==="mouseout"||s==="pointerout",ce&&a!==gd&&(Fe=a.relatedTarget||a.fromElement)&&(er(Fe)||Fe[jt]))break e;if((xe||ce)&&(ce=ve.window===ve?ve:(ce=ve.ownerDocument)?ce.defaultView||ce.parentWindow:window,xe?(Fe=a.relatedTarget||a.toElement,xe=le,Fe=Fe?er(Fe):null,Fe!==null&&(Xs=x(Fe),Ze=Fe.tag,Fe!==Xs||Ze!==5&&Ze!==27&&Ze!==6)&&(Fe=null)):(xe=null,Fe=le),xe!==Fe)){if(Ze=Dx,be="onMouseLeave",X="onMouseEnter",G="mouse",(s==="pointerout"||s==="pointerover")&&(Ze=Lx,be="onPointerLeave",X="onPointerEnter",G="pointer"),Xs=xe==null?ce:Zr(xe),te=Fe==null?ce:Zr(Fe),ce=new Ze(be,G+"leave",xe,a,ve),ce.target=Xs,ce.relatedTarget=te,be=null,er(ve)===le&&(Ze=new Ze(X,G+"enter",Fe,a,ve),Ze.target=te,Ze.relatedTarget=Xs,be=Ze),Xs=be,xe&&Fe)s:{for(Ze=Iy,X=xe,G=Fe,te=0,be=X;be;be=Ze(be))te++;be=0;for(var Ye=G;Ye;Ye=Ze(Ye))be++;for(;0<te-be;)X=Ze(X),te--;for(;0<be-te;)G=Ze(G),be--;for(;te--;){if(X===G||G!==null&&X===G.alternate){Ze=X;break s}X=Ze(X),G=Ze(G)}Ze=null}else Ze=null;xe!==null&&Tp(ye,ce,xe,Ze,!1),Fe!==null&&Xs!==null&&Tp(ye,Xs,Fe,Ze,!0)}}e:{if(ce=le?Zr(le):window,xe=ce.nodeName&&ce.nodeName.toLowerCase(),xe==="select"||xe==="input"&&ce.type==="file")var Us=Gx;else if(Hx(ce))if(Vx)Us=Xb;else{Us=Yb;var Ve=Qb}else xe=ce.nodeName,!xe||xe.toLowerCase()!=="input"||ce.type!=="checkbox"&&ce.type!=="radio"?le&&pd(le.elementType)&&(Us=Gx):Us=Jb;if(Us&&(Us=Us(s,le))){Fx(ye,Us,a,ve);break e}Ve&&Ve(s,ce,le),s==="focusout"&&le&&ce.type==="number"&&le.memoizedProps.value!=null&&fd(ce,"number",ce.value)}switch(Ve=le?Zr(le):window,s){case"focusin":(Hx(Ve)||Ve.contentEditable==="true")&&(or=Ve,Md=le,ii=null);break;case"focusout":ii=Md=or=null;break;case"mousedown":zd=!0;break;case"contextmenu":case"mouseup":case"dragend":zd=!1,Wx(ye,a,ve);break;case"selectionchange":if(Wb)break;case"keydown":case"keyup":Wx(ye,a,ve)}var ds;if(kd)e:{switch(s){case"compositionstart":var Es="onCompositionStart";break e;case"compositionend":Es="onCompositionEnd";break e;case"compositionupdate":Es="onCompositionUpdate";break e}Es=void 0}else cr?Ix(s,a)&&(Es="onCompositionEnd"):s==="keydown"&&a.keyCode===229&&(Es="onCompositionStart");Es&&(Ux&&a.locale!=="ko"&&(cr||Es!=="onCompositionStart"?Es==="onCompositionEnd"&&cr&&(ds=Ax()):(Il=ve,bd="value"in Il?Il.value:Il.textContent,cr=!0)),Ve=xo(le,Es),0<Ve.length&&(Es=new Rx(Es,s,null,a,ve),ye.push({event:Es,listeners:Ve}),ds?Es.data=ds:(ds=Px(a),ds!==null&&(Es.data=ds)))),(ds=Fb?Gb(s,a):Vb(s,a))&&(Es=xo(le,"onBeforeInput"),0<Es.length&&(Ve=new Rx("onBeforeInput","beforeinput",null,a,ve),ye.push({event:Ve,listeners:Es}),Ve.data=ds)),Ly(ye,s,le,a,ve)}kp(ye,t)})}function Ai(s,t,a){return{instance:s,listener:t,currentTarget:a}}function xo(s,t){for(var a=t+"Capture",r=[];s!==null;){var o=s,m=o.stateNode;if(o=o.tag,o!==5&&o!==26&&o!==27||m===null||(o=Wr(s,a),o!=null&&r.unshift(Ai(s,o,m)),o=Wr(s,t),o!=null&&r.push(Ai(s,o,m))),s.tag===3)return r;s=s.return}return[]}function Iy(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5&&s.tag!==27);return s||null}function Tp(s,t,a,r,o){for(var m=t._reactName,j=[];a!==null&&a!==r;){var k=a,$=k.alternate,le=k.stateNode;if(k=k.tag,$!==null&&$===r)break;k!==5&&k!==26&&k!==27||le===null||($=le,o?(le=Wr(a,m),le!=null&&j.unshift(Ai(a,le,$))):o||(le=Wr(a,m),le!=null&&j.push(Ai(a,le,$)))),a=a.return}j.length!==0&&s.push({event:t,listeners:j})}var Py=/\r\n?/g,Hy=/\u0000|\uFFFD/g;function Ep(s){return(typeof s=="string"?s:""+s).replace(Py,`
|
||
`).replace(Hy,"")}function Mp(s,t){return t=Ep(t),Ep(s)===t}function Js(s,t,a,r,o,m){switch(a){case"children":typeof r=="string"?t==="body"||t==="textarea"&&r===""||nr(s,r):(typeof r=="number"||typeof r=="bigint")&&t!=="body"&&nr(s,""+r);break;case"className":pc(s,"class",r);break;case"tabIndex":pc(s,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":pc(s,a,r);break;case"style":Ex(s,r,m);break;case"data":if(t!=="object"){pc(s,"data",r);break}case"src":case"href":if(r===""&&(t!=="a"||a!=="href")){s.removeAttribute(a);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){s.removeAttribute(a);break}r=jc(""+r),s.setAttribute(a,r);break;case"action":case"formAction":if(typeof r=="function"){s.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof m=="function"&&(a==="formAction"?(t!=="input"&&Js(s,t,"name",o.name,o,null),Js(s,t,"formEncType",o.formEncType,o,null),Js(s,t,"formMethod",o.formMethod,o,null),Js(s,t,"formTarget",o.formTarget,o,null)):(Js(s,t,"encType",o.encType,o,null),Js(s,t,"method",o.method,o,null),Js(s,t,"target",o.target,o,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){s.removeAttribute(a);break}r=jc(""+r),s.setAttribute(a,r);break;case"onClick":r!=null&&(s.onclick=xl);break;case"onScroll":r!=null&&Ss("scroll",s);break;case"onScrollEnd":r!=null&&Ss("scrollend",s);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(c(61));if(a=r.__html,a!=null){if(o.children!=null)throw Error(c(60));s.innerHTML=a}}break;case"multiple":s.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":s.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){s.removeAttribute("xlink:href");break}a=jc(""+r),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?s.setAttribute(a,""+r):s.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?s.setAttribute(a,""):s.removeAttribute(a);break;case"capture":case"download":r===!0?s.setAttribute(a,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?s.setAttribute(a,r):s.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?s.setAttribute(a,r):s.removeAttribute(a);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?s.removeAttribute(a):s.setAttribute(a,r);break;case"popover":Ss("beforetoggle",s),Ss("toggle",s),fc(s,"popover",r);break;case"xlinkActuate":ml(s,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":ml(s,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":ml(s,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":ml(s,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":ml(s,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":ml(s,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":ml(s,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":ml(s,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":ml(s,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":fc(s,"is",r);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=pb.get(a)||a,fc(s,a,r))}}function tm(s,t,a,r,o,m){switch(a){case"style":Ex(s,r,m);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(c(61));if(a=r.__html,a!=null){if(o.children!=null)throw Error(c(60));s.innerHTML=a}}break;case"children":typeof r=="string"?nr(s,r):(typeof r=="number"||typeof r=="bigint")&&nr(s,""+r);break;case"onScroll":r!=null&&Ss("scroll",s);break;case"onScrollEnd":r!=null&&Ss("scrollend",s);break;case"onClick":r!=null&&(s.onclick=xl);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Nx.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(o=a.endsWith("Capture"),t=a.slice(2,o?a.length-7:void 0),m=s[is]||null,m=m!=null?m[a]:null,typeof m=="function"&&s.removeEventListener(t,m,o),typeof r=="function")){typeof m!="function"&&m!==null&&(a in s?s[a]=null:s.hasAttribute(a)&&s.removeAttribute(a)),s.addEventListener(t,r,o);break e}a in s?s[a]=r:r===!0?s.setAttribute(a,""):fc(s,a,r)}}}function Kt(s,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ss("error",s),Ss("load",s);var r=!1,o=!1,m;for(m in a)if(a.hasOwnProperty(m)){var j=a[m];if(j!=null)switch(m){case"src":r=!0;break;case"srcSet":o=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:Js(s,t,m,j,a,null)}}o&&Js(s,t,"srcSet",a.srcSet,a,null),r&&Js(s,t,"src",a.src,a,null);return;case"input":Ss("invalid",s);var k=m=j=o=null,$=null,le=null;for(r in a)if(a.hasOwnProperty(r)){var ve=a[r];if(ve!=null)switch(r){case"name":o=ve;break;case"type":j=ve;break;case"checked":$=ve;break;case"defaultChecked":le=ve;break;case"value":m=ve;break;case"defaultValue":k=ve;break;case"children":case"dangerouslySetInnerHTML":if(ve!=null)throw Error(c(137,t));break;default:Js(s,t,r,ve,a,null)}}Sx(s,m,k,$,le,j,o,!1);return;case"select":Ss("invalid",s),r=j=m=null;for(o in a)if(a.hasOwnProperty(o)&&(k=a[o],k!=null))switch(o){case"value":m=k;break;case"defaultValue":j=k;break;case"multiple":r=k;default:Js(s,t,o,k,a,null)}t=m,a=j,s.multiple=!!r,t!=null?lr(s,!!r,t,!1):a!=null&&lr(s,!!r,a,!0);return;case"textarea":Ss("invalid",s),m=o=r=null;for(j in a)if(a.hasOwnProperty(j)&&(k=a[j],k!=null))switch(j){case"value":r=k;break;case"defaultValue":o=k;break;case"children":m=k;break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(c(91));break;default:Js(s,t,j,k,a,null)}Cx(s,r,o,m);return;case"option":for($ in a)if(a.hasOwnProperty($)&&(r=a[$],r!=null))switch($){case"selected":s.selected=r&&typeof r!="function"&&typeof r!="symbol";break;default:Js(s,t,$,r,a,null)}return;case"dialog":Ss("beforetoggle",s),Ss("toggle",s),Ss("cancel",s),Ss("close",s);break;case"iframe":case"object":Ss("load",s);break;case"video":case"audio":for(r=0;r<zi.length;r++)Ss(zi[r],s);break;case"image":Ss("error",s),Ss("load",s);break;case"details":Ss("toggle",s);break;case"embed":case"source":case"link":Ss("error",s),Ss("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(le in a)if(a.hasOwnProperty(le)&&(r=a[le],r!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:Js(s,t,le,r,a,null)}return;default:if(pd(t)){for(ve in a)a.hasOwnProperty(ve)&&(r=a[ve],r!==void 0&&tm(s,t,ve,r,a,void 0));return}}for(k in a)a.hasOwnProperty(k)&&(r=a[k],r!=null&&Js(s,t,k,r,a,null))}function Fy(s,t,a,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,m=null,j=null,k=null,$=null,le=null,ve=null;for(xe in a){var ye=a[xe];if(a.hasOwnProperty(xe)&&ye!=null)switch(xe){case"checked":break;case"value":break;case"defaultValue":$=ye;default:r.hasOwnProperty(xe)||Js(s,t,xe,null,r,ye)}}for(var ce in r){var xe=r[ce];if(ye=a[ce],r.hasOwnProperty(ce)&&(xe!=null||ye!=null))switch(ce){case"type":m=xe;break;case"name":o=xe;break;case"checked":le=xe;break;case"defaultChecked":ve=xe;break;case"value":j=xe;break;case"defaultValue":k=xe;break;case"children":case"dangerouslySetInnerHTML":if(xe!=null)throw Error(c(137,t));break;default:xe!==ye&&Js(s,t,ce,xe,r,ye)}}hd(s,j,k,$,le,ve,m,o);return;case"select":xe=j=k=ce=null;for(m in a)if($=a[m],a.hasOwnProperty(m)&&$!=null)switch(m){case"value":break;case"multiple":xe=$;default:r.hasOwnProperty(m)||Js(s,t,m,null,r,$)}for(o in r)if(m=r[o],$=a[o],r.hasOwnProperty(o)&&(m!=null||$!=null))switch(o){case"value":ce=m;break;case"defaultValue":k=m;break;case"multiple":j=m;default:m!==$&&Js(s,t,o,m,r,$)}t=k,a=j,r=xe,ce!=null?lr(s,!!a,ce,!1):!!r!=!!a&&(t!=null?lr(s,!!a,t,!0):lr(s,!!a,a?[]:"",!1));return;case"textarea":xe=ce=null;for(k in a)if(o=a[k],a.hasOwnProperty(k)&&o!=null&&!r.hasOwnProperty(k))switch(k){case"value":break;case"children":break;default:Js(s,t,k,null,r,o)}for(j in r)if(o=r[j],m=a[j],r.hasOwnProperty(j)&&(o!=null||m!=null))switch(j){case"value":ce=o;break;case"defaultValue":xe=o;break;case"children":break;case"dangerouslySetInnerHTML":if(o!=null)throw Error(c(91));break;default:o!==m&&Js(s,t,j,o,r,m)}kx(s,ce,xe);return;case"option":for(var Fe in a)if(ce=a[Fe],a.hasOwnProperty(Fe)&&ce!=null&&!r.hasOwnProperty(Fe))switch(Fe){case"selected":s.selected=!1;break;default:Js(s,t,Fe,null,r,ce)}for($ in r)if(ce=r[$],xe=a[$],r.hasOwnProperty($)&&ce!==xe&&(ce!=null||xe!=null))switch($){case"selected":s.selected=ce&&typeof ce!="function"&&typeof ce!="symbol";break;default:Js(s,t,$,ce,r,xe)}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 Ze in a)ce=a[Ze],a.hasOwnProperty(Ze)&&ce!=null&&!r.hasOwnProperty(Ze)&&Js(s,t,Ze,null,r,ce);for(le in r)if(ce=r[le],xe=a[le],r.hasOwnProperty(le)&&ce!==xe&&(ce!=null||xe!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(c(137,t));break;default:Js(s,t,le,ce,r,xe)}return;default:if(pd(t)){for(var Xs in a)ce=a[Xs],a.hasOwnProperty(Xs)&&ce!==void 0&&!r.hasOwnProperty(Xs)&&tm(s,t,Xs,void 0,r,ce);for(ve in r)ce=r[ve],xe=a[ve],!r.hasOwnProperty(ve)||ce===xe||ce===void 0&&xe===void 0||tm(s,t,ve,ce,r,xe);return}}for(var X in a)ce=a[X],a.hasOwnProperty(X)&&ce!=null&&!r.hasOwnProperty(X)&&Js(s,t,X,null,r,ce);for(ye in r)ce=r[ye],xe=a[ye],!r.hasOwnProperty(ye)||ce===xe||ce==null&&xe==null||Js(s,t,ye,ce,r,xe)}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 Gy(){if(typeof performance.getEntriesByType=="function"){for(var s=0,t=0,a=performance.getEntriesByType("resource"),r=0;r<a.length;r++){var o=a[r],m=o.transferSize,j=o.initiatorType,k=o.duration;if(m&&k&&zp(j)){for(j=0,k=o.responseEnd,r+=1;r<a.length;r++){var $=a[r],le=$.startTime;if(le>k)break;var ve=$.transferSize,ye=$.initiatorType;ve&&zp(ye)&&($=$.responseEnd,j+=ve*($<k?1:(k-le)/($-le)))}if(--r,t+=8*(m+j)/(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 am=null,lm=null;function ho(s){return s.nodeType===9?s:s.ownerDocument}function Ap(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 Op(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 nm(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 rm=null;function Vy(){var s=window.event;return s&&s.type==="popstate"?s===rm?!1:(rm=s,!0):(rm=null,!1)}var Dp=typeof setTimeout=="function"?setTimeout:void 0,qy=typeof clearTimeout=="function"?clearTimeout:void 0,Rp=typeof Promise=="function"?Promise:void 0,Ky=typeof queueMicrotask=="function"?queueMicrotask:typeof Rp<"u"?function(s){return Rp.resolve(null).then(s).catch(Qy)}:Dp;function Qy(s){setTimeout(function(){throw s})}function an(s){return s==="head"}function Lp(s,t){var a=t,r=0;do{var o=a.nextSibling;if(s.removeChild(a),o&&o.nodeType===8)if(a=o.data,a==="/$"||a==="/&"){if(r===0){s.removeChild(o),Lr(t);return}r--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")r++;else if(a==="html")Oi(s.ownerDocument.documentElement);else if(a==="head"){a=s.ownerDocument.head,Oi(a);for(var m=a.firstChild;m;){var j=m.nextSibling,k=m.nodeName;m[bn]||k==="SCRIPT"||k==="STYLE"||k==="LINK"&&m.rel.toLowerCase()==="stylesheet"||a.removeChild(m),m=j}}else a==="body"&&Oi(s.ownerDocument.body);a=o}while(a);Lr(t)}function Up(s,t){var a=s;s=0;do{var r=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),r&&r.nodeType===8)if(a=r.data,a==="/$"){if(s===0)break;s--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||s++;a=r}while(a)}function im(s){var t=s.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":im(a),md(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}s.removeChild(a)}}function Yy(s,t,a,r){for(;s.nodeType===1;){var o=a;if(s.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(s.nodeName!=="INPUT"||s.type!=="hidden"))break}else if(r){if(!s[bn])switch(t){case"meta":if(!s.hasAttribute("itemprop"))break;return s;case"link":if(m=s.getAttribute("rel"),m==="stylesheet"&&s.hasAttribute("data-precedence"))break;if(m!==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(m=s.getAttribute("src"),(m!==(o.src==null?null:o.src)||s.getAttribute("type")!==(o.type==null?null:o.type)||s.getAttribute("crossorigin")!==(o.crossOrigin==null?null:o.crossOrigin))&&m&&s.hasAttribute("async")&&!s.hasAttribute("itemprop"))break;return s;default:return s}}else if(t==="input"&&s.type==="hidden"){var m=o.name==null?null:""+o.name;if(o.type==="hidden"&&s.getAttribute("name")===m)return s}else return s;if(s=Ha(s.nextSibling),s===null)break}return null}function Jy(s,t,a){if(t==="")return null;for(;s.nodeType!==3;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!a||(s=Ha(s.nextSibling),s===null))return null;return s}function $p(s,t){for(;s.nodeType!==8;)if((s.nodeType!==1||s.nodeName!=="INPUT"||s.type!=="hidden")&&!t||(s=Ha(s.nextSibling),s===null))return null;return s}function cm(s){return s.data==="$?"||s.data==="$~"}function om(s){return s.data==="$!"||s.data==="$?"&&s.ownerDocument.readyState!=="loading"}function Xy(s,t){var a=s.ownerDocument;if(s.data==="$~")s._reactRetry=t;else if(s.data!=="$?"||a.readyState!=="loading")t();else{var r=function(){t(),a.removeEventListener("DOMContentLoaded",r)};a.addEventListener("DOMContentLoaded",r),s._reactRetry=r}}function Ha(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 dm=null;function Bp(s){s=s.nextSibling;for(var t=0;s;){if(s.nodeType===8){var a=s.data;if(a==="/$"||a==="/&"){if(t===0)return Ha(s.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}s=s.nextSibling}return null}function Ip(s){s=s.previousSibling;for(var t=0;s;){if(s.nodeType===8){var a=s.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return s;t--}else a!=="/$"&&a!=="/&"||t++}s=s.previousSibling}return null}function Pp(s,t,a){switch(t=ho(a),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 Oi(s){for(var t=s.attributes;t.length;)s.removeAttributeNode(t[0]);md(s)}var Fa=new Map,Hp=new Set;function fo(s){return typeof s.getRootNode=="function"?s.getRootNode():s.nodeType===9?s:s.ownerDocument}var El=K.d;K.d={f:Zy,r:Wy,D:e0,C:s0,L:t0,m:a0,X:n0,S:l0,M:r0};function Zy(){var s=El.f(),t=no();return s||t}function Wy(s){var t=sr(s);t!==null&&t.tag===5&&t.type==="form"?lf(t):El.r(s)}var Or=typeof document>"u"?null:document;function Fp(s,t,a){var r=Or;if(r&&typeof t=="string"&&t){var o=Ra(t);o='link[rel="'+s+'"][href="'+o+'"]',typeof a=="string"&&(o+='[crossorigin="'+a+'"]'),Hp.has(o)||(Hp.add(o),s={rel:s,crossOrigin:a,href:t},r.querySelector(o)===null&&(t=r.createElement("link"),Kt(t,"link",s),It(t),r.head.appendChild(t)))}}function e0(s){El.D(s),Fp("dns-prefetch",s,null)}function s0(s,t){El.C(s,t),Fp("preconnect",s,t)}function t0(s,t,a){El.L(s,t,a);var r=Or;if(r&&s&&t){var o='link[rel="preload"][as="'+Ra(t)+'"]';t==="image"&&a&&a.imageSrcSet?(o+='[imagesrcset="'+Ra(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(o+='[imagesizes="'+Ra(a.imageSizes)+'"]')):o+='[href="'+Ra(s)+'"]';var m=o;switch(t){case"style":m=Dr(s);break;case"script":m=Rr(s)}Fa.has(m)||(s=v({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:s,as:t},a),Fa.set(m,s),r.querySelector(o)!==null||t==="style"&&r.querySelector(Di(m))||t==="script"&&r.querySelector(Ri(m))||(t=r.createElement("link"),Kt(t,"link",s),It(t),r.head.appendChild(t)))}}function a0(s,t){El.m(s,t);var a=Or;if(a&&s){var r=t&&typeof t.as=="string"?t.as:"script",o='link[rel="modulepreload"][as="'+Ra(r)+'"][href="'+Ra(s)+'"]',m=o;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Rr(s)}if(!Fa.has(m)&&(s=v({rel:"modulepreload",href:s},t),Fa.set(m,s),a.querySelector(o)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Ri(m)))return}r=a.createElement("link"),Kt(r,"link",s),It(r),a.head.appendChild(r)}}}function l0(s,t,a){El.S(s,t,a);var r=Or;if(r&&s){var o=tr(r).hoistableStyles,m=Dr(s);t=t||"default";var j=o.get(m);if(!j){var k={loading:0,preload:null};if(j=r.querySelector(Di(m)))k.loading=5;else{s=v({rel:"stylesheet",href:s,"data-precedence":t},a),(a=Fa.get(m))&&um(s,a);var $=j=r.createElement("link");It($),Kt($,"link",s),$._p=new Promise(function(le,ve){$.onload=le,$.onerror=ve}),$.addEventListener("load",function(){k.loading|=1}),$.addEventListener("error",function(){k.loading|=2}),k.loading|=4,po(j,t,r)}j={type:"stylesheet",instance:j,count:1,state:k},o.set(m,j)}}}function n0(s,t){El.X(s,t);var a=Or;if(a&&s){var r=tr(a).hoistableScripts,o=Rr(s),m=r.get(o);m||(m=a.querySelector(Ri(o)),m||(s=v({src:s,async:!0},t),(t=Fa.get(o))&&mm(s,t),m=a.createElement("script"),It(m),Kt(m,"link",s),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},r.set(o,m))}}function r0(s,t){El.M(s,t);var a=Or;if(a&&s){var r=tr(a).hoistableScripts,o=Rr(s),m=r.get(o);m||(m=a.querySelector(Ri(o)),m||(s=v({src:s,async:!0,type:"module"},t),(t=Fa.get(o))&&mm(s,t),m=a.createElement("script"),It(m),Kt(m,"link",s),a.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},r.set(o,m))}}function Gp(s,t,a,r){var o=(o=V.current)?fo(o):null;if(!o)throw Error(c(446));switch(s){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=Dr(a.href),a=tr(o).hoistableStyles,r=a.get(t),r||(r={type:"style",instance:null,count:0,state:null},a.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){s=Dr(a.href);var m=tr(o).hoistableStyles,j=m.get(s);if(j||(o=o.ownerDocument||o,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(s,j),(m=o.querySelector(Di(s)))&&!m._p&&(j.instance=m,j.state.loading=5),Fa.has(s)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Fa.set(s,a),m||i0(o,s,a,j.state))),t&&r===null)throw Error(c(528,""));return j}if(t&&r!==null)throw Error(c(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Rr(a),a=tr(o).hoistableScripts,r=a.get(t),r||(r={type:"script",instance:null,count:0,state:null},a.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(c(444,s))}}function Dr(s){return'href="'+Ra(s)+'"'}function Di(s){return'link[rel="stylesheet"]['+s+"]"}function Vp(s){return v({},s,{"data-precedence":s.precedence,precedence:null})}function i0(s,t,a,r){s.querySelector('link[rel="preload"][as="style"]['+t+"]")?r.loading=1:(t=s.createElement("link"),r.preload=t,t.addEventListener("load",function(){return r.loading|=1}),t.addEventListener("error",function(){return r.loading|=2}),Kt(t,"link",a),It(t),s.head.appendChild(t))}function Rr(s){return'[src="'+Ra(s)+'"]'}function Ri(s){return"script[async]"+s}function qp(s,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var r=s.querySelector('style[data-href~="'+Ra(a.href)+'"]');if(r)return t.instance=r,It(r),r;var o=v({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return r=(s.ownerDocument||s).createElement("style"),It(r),Kt(r,"style",o),po(r,a.precedence,s),t.instance=r;case"stylesheet":o=Dr(a.href);var m=s.querySelector(Di(o));if(m)return t.state.loading|=4,t.instance=m,It(m),m;r=Vp(a),(o=Fa.get(o))&&um(r,o),m=(s.ownerDocument||s).createElement("link"),It(m);var j=m;return j._p=new Promise(function(k,$){j.onload=k,j.onerror=$}),Kt(m,"link",r),t.state.loading|=4,po(m,a.precedence,s),t.instance=m;case"script":return m=Rr(a.src),(o=s.querySelector(Ri(m)))?(t.instance=o,It(o),o):(r=a,(o=Fa.get(m))&&(r=v({},a),mm(r,o)),s=s.ownerDocument||s,o=s.createElement("script"),It(o),Kt(o,"link",r),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&&(r=t.instance,t.state.loading|=4,po(r,a.precedence,s));return t.instance}function po(s,t,a){for(var r=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),o=r.length?r[r.length-1]:null,m=o,j=0;j<r.length;j++){var k=r[j];if(k.dataset.precedence===t)m=k;else if(m!==o)break}m?m.parentNode.insertBefore(s,m.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(s,t.firstChild))}function um(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.title==null&&(s.title=t.title)}function mm(s,t){s.crossOrigin==null&&(s.crossOrigin=t.crossOrigin),s.referrerPolicy==null&&(s.referrerPolicy=t.referrerPolicy),s.integrity==null&&(s.integrity=t.integrity)}var go=null;function Kp(s,t,a){if(go===null){var r=new Map,o=go=new Map;o.set(a,r)}else o=go,r=o.get(a),r||(r=new Map,o.set(a,r));if(r.has(s))return r;for(r.set(s,null),a=a.getElementsByTagName(s),o=0;o<a.length;o++){var m=a[o];if(!(m[bn]||m[js]||s==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var j=m.getAttribute(t)||"";j=s+j;var k=r.get(j);k?k.push(m):r.set(j,[m])}}return r}function Qp(s,t,a){s=s.ownerDocument||s,s.head.insertBefore(a,t==="title"?s.querySelector("head > title"):null)}function c0(s,t,a){if(a===1||t.itemProp!=null)return!1;switch(s){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return s=t.disabled,typeof t.precedence=="string"&&s==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Yp(s){return!(s.type==="stylesheet"&&(s.state.loading&3)===0)}function o0(s,t,a,r){if(a.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var o=Dr(r.href),m=t.querySelector(Di(o));if(m){t=m._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(s.count++,s=jo.bind(s),t.then(s,s)),a.state.loading|=4,a.instance=m,It(m);return}m=t.ownerDocument||t,r=Vp(r),(o=Fa.get(o))&&um(r,o),m=m.createElement("link"),It(m);var j=m;j._p=new Promise(function(k,$){j.onload=k,j.onerror=$}),Kt(m,"link",r),a.instance=m}s.stylesheets===null&&(s.stylesheets=new Map),s.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(s.count++,a=jo.bind(s),t.addEventListener("load",a),t.addEventListener("error",a))}}var xm=0;function d0(s,t){return s.stylesheets&&s.count===0&&No(s,s.stylesheets),0<s.count||0<s.imgCount?function(a){var r=setTimeout(function(){if(s.stylesheets&&No(s,s.stylesheets),s.unsuspend){var m=s.unsuspend;s.unsuspend=null,m()}},6e4+t);0<s.imgBytes&&xm===0&&(xm=62500*Gy());var o=setTimeout(function(){if(s.waitingForImages=!1,s.count===0&&(s.stylesheets&&No(s,s.stylesheets),s.unsuspend)){var m=s.unsuspend;s.unsuspend=null,m()}},(s.imgBytes>xm?50:800)+t);return s.unsuspend=a,function(){s.unsuspend=null,clearTimeout(r),clearTimeout(o)}}:null}function jo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)No(this,this.stylesheets);else if(this.unsuspend){var s=this.unsuspend;this.unsuspend=null,s()}}}var vo=null;function No(s,t){s.stylesheets=null,s.unsuspend!==null&&(s.count++,vo=new Map,t.forEach(u0,s),vo=null,jo.call(s))}function u0(s,t){if(!(t.state.loading&4)){var a=vo.get(s);if(a)var r=a.get(null);else{a=new Map,vo.set(s,a);for(var o=s.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<o.length;m++){var j=o[m];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(a.set(j.dataset.precedence,j),r=j)}r&&a.set(null,r)}o=t.instance,j=o.getAttribute("data-precedence"),m=a.get(j)||r,m===r&&a.set(null,o),a.set(j,o),this.count++,r=jo.bind(this),o.addEventListener("load",r),o.addEventListener("error",r),m?m.parentNode.insertBefore(o,m.nextSibling):(s=s.nodeType===9?s.head:s,s.insertBefore(o,s.firstChild)),t.state.loading|=4}}var Li={$$typeof:E,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function m0(s,t,a,r,o,m,j,k,$){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=we(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=we(0),this.hiddenUpdates=we(null),this.identifierPrefix=r,this.onUncaughtError=o,this.onCaughtError=m,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function Jp(s,t,a,r,o,m,j,k,$,le,ve,ye){return s=new m0(s,t,a,j,$,le,ve,ye,k),t=1,m===!0&&(t|=24),m=Na(3,null,null,t),s.current=m,m.stateNode=s,t=qd(),t.refCount++,s.pooledCache=t,t.refCount++,m.memoizedState={element:r,isDehydrated:a,cache:t},Jd(m),s}function Xp(s){return s?(s=mr,s):mr}function Zp(s,t,a,r,o,m){o=Xp(o),r.context===null?r.context=o:r.pendingContext=o,r=ql(t),r.payload={element:a},m=m===void 0?null:m,m!==null&&(r.callback=m),a=Kl(s,r,t),a!==null&&(fa(a,s,t),hi(a,s,t))}function Wp(s,t){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var a=s.retryLane;s.retryLane=a!==0&&a<t?a:t}}function hm(s,t){Wp(s,t),(s=s.alternate)&&Wp(s,t)}function eg(s){if(s.tag===13||s.tag===31){var t=kn(s,67108864);t!==null&&fa(t,s,67108864),hm(s,67108864)}}function sg(s){if(s.tag===13||s.tag===31){var t=Sa();t=ea(t);var a=kn(s,t);a!==null&&fa(a,s,t),hm(s,t)}}var bo=!0;function x0(s,t,a,r){var o=M.T;M.T=null;var m=K.p;try{K.p=2,fm(s,t,a,r)}finally{K.p=m,M.T=o}}function h0(s,t,a,r){var o=M.T;M.T=null;var m=K.p;try{K.p=8,fm(s,t,a,r)}finally{K.p=m,M.T=o}}function fm(s,t,a,r){if(bo){var o=pm(r);if(o===null)sm(s,t,r,yo,a),ag(s,r);else if(p0(o,s,t,a,r))r.stopPropagation();else if(ag(s,r),t&4&&-1<f0.indexOf(s)){for(;o!==null;){var m=sr(o);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var j=Oa(m.pendingLanes);if(j!==0){var k=m;for(k.pendingLanes|=2,k.entangledLanes|=2;j;){var $=1<<31-ys(j);k.entanglements[1]|=$,j&=~$}rl(m),(Ps&6)===0&&(ao=mt()+500,Mi(0))}}break;case 31:case 13:k=kn(m,2),k!==null&&fa(k,m,2),no(),hm(m,2)}if(m=pm(r),m===null&&sm(s,t,r,yo,a),m===o)break;o=m}o!==null&&r.stopPropagation()}else sm(s,t,r,null,a)}}function pm(s){return s=jd(s),gm(s)}var yo=null;function gm(s){if(yo=null,s=er(s),s!==null){var t=x(s);if(t===null)s=null;else{var a=t.tag;if(a===13){if(s=h(t),s!==null)return s;s=null}else if(a===31){if(s=f(t),s!==null)return s;s=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;s=null}else t!==s&&(s=null)}}return yo=s,null}function tg(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(q()){case qe:return 2;case Qe:return 8;case es:case Ls:return 32;case as:return 268435456;default:return 32}default:return 32}}var jm=!1,ln=null,nn=null,rn=null,Ui=new Map,$i=new Map,cn=[],f0="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 ag(s,t){switch(s){case"focusin":case"focusout":ln=null;break;case"dragenter":case"dragleave":nn=null;break;case"mouseover":case"mouseout":rn=null;break;case"pointerover":case"pointerout":Ui.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":$i.delete(t.pointerId)}}function Bi(s,t,a,r,o,m){return s===null||s.nativeEvent!==m?(s={blockedOn:t,domEventName:a,eventSystemFlags:r,nativeEvent:m,targetContainers:[o]},t!==null&&(t=sr(t),t!==null&&eg(t)),s):(s.eventSystemFlags|=r,t=s.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),s)}function p0(s,t,a,r,o){switch(t){case"focusin":return ln=Bi(ln,s,t,a,r,o),!0;case"dragenter":return nn=Bi(nn,s,t,a,r,o),!0;case"mouseover":return rn=Bi(rn,s,t,a,r,o),!0;case"pointerover":var m=o.pointerId;return Ui.set(m,Bi(Ui.get(m)||null,s,t,a,r,o)),!0;case"gotpointercapture":return m=o.pointerId,$i.set(m,Bi($i.get(m)||null,s,t,a,r,o)),!0}return!1}function lg(s){var t=er(s.target);if(t!==null){var a=x(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){s.blockedOn=t,he(s.priority,function(){sg(a)});return}}else if(t===31){if(t=f(a),t!==null){s.blockedOn=t,he(s.priority,function(){sg(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){s.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}s.blockedOn=null}function wo(s){if(s.blockedOn!==null)return!1;for(var t=s.targetContainers;0<t.length;){var a=pm(s.nativeEvent);if(a===null){a=s.nativeEvent;var r=new a.constructor(a.type,a);gd=r,a.target.dispatchEvent(r),gd=null}else return t=sr(a),t!==null&&eg(t),s.blockedOn=a,!1;t.shift()}return!0}function ng(s,t,a){wo(s)&&a.delete(t)}function g0(){jm=!1,ln!==null&&wo(ln)&&(ln=null),nn!==null&&wo(nn)&&(nn=null),rn!==null&&wo(rn)&&(rn=null),Ui.forEach(ng),$i.forEach(ng)}function _o(s,t){s.blockedOn===t&&(s.blockedOn=null,jm||(jm=!0,l.unstable_scheduleCallback(l.unstable_NormalPriority,g0)))}var So=null;function rg(s){So!==s&&(So=s,l.unstable_scheduleCallback(l.unstable_NormalPriority,function(){So===s&&(So=null);for(var t=0;t<s.length;t+=3){var a=s[t],r=s[t+1],o=s[t+2];if(typeof r!="function"){if(gm(r||a)===null)continue;break}var m=sr(a);m!==null&&(s.splice(t,3),t-=3,pu(m,{pending:!0,data:o,method:a.method,action:r},r,o))}}))}function Lr(s){function t($){return _o($,s)}ln!==null&&_o(ln,s),nn!==null&&_o(nn,s),rn!==null&&_o(rn,s),Ui.forEach(t),$i.forEach(t);for(var a=0;a<cn.length;a++){var r=cn[a];r.blockedOn===s&&(r.blockedOn=null)}for(;0<cn.length&&(a=cn[0],a.blockedOn===null);)lg(a),a.blockedOn===null&&cn.shift();if(a=(s.ownerDocument||s).$$reactFormReplay,a!=null)for(r=0;r<a.length;r+=3){var o=a[r],m=a[r+1],j=o[is]||null;if(typeof m=="function")j||rg(a);else if(j){var k=null;if(m&&m.hasAttribute("formAction")){if(o=m,j=m[is]||null)k=j.formAction;else if(gm(o)!==null)continue}else k=j.action;typeof k=="function"?a[r+1]=k:(a.splice(r,3),r-=3),rg(a)}}}function ig(){function s(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(j){return o=j})},focusReset:"manual",scroll:"manual"})}function t(){o!==null&&(o(),o=null),r||setTimeout(a,20)}function a(){if(!r&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var r=!1,o=null;return navigation.addEventListener("navigate",s),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){r=!0,navigation.removeEventListener("navigate",s),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),o!==null&&(o(),o=null)}}}function vm(s){this._internalRoot=s}ko.prototype.render=vm.prototype.render=function(s){var t=this._internalRoot;if(t===null)throw Error(c(409));var a=t.current,r=Sa();Zp(a,r,s,t,null,null)},ko.prototype.unmount=vm.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var t=s.containerInfo;Zp(s.current,2,null,s,null,null),no(),t[jt]=null}};function ko(s){this._internalRoot=s}ko.prototype.unstable_scheduleHydration=function(s){if(s){var t=ne();s={blockedOn:null,target:s,priority:t};for(var a=0;a<cn.length&&t!==0&&t<cn[a].priority;a++);cn.splice(a,0,s),a===0&&lg(s)}};var cg=n.version;if(cg!=="19.2.1")throw Error(c(527,cg,"19.2.1"));K.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 j0={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Co=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Co.isDisabled&&Co.supportsFiber)try{bs=Co.inject(j0),ls=Co}catch{}}return Ii.createRoot=function(s,t){if(!u(s))throw Error(c(299));var a=!1,r="",o=ff,m=pf,j=gf;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(m=t.onCaughtError),t.onRecoverableError!==void 0&&(j=t.onRecoverableError)),t=Jp(s,1,!1,null,null,a,r,null,o,m,j,ig),s[jt]=t.current,em(s),new vm(t)},Ii.hydrateRoot=function(s,t,a){if(!u(s))throw Error(c(299));var r=!1,o="",m=ff,j=pf,k=gf,$=null;return a!=null&&(a.unstable_strictMode===!0&&(r=!0),a.identifierPrefix!==void 0&&(o=a.identifierPrefix),a.onUncaughtError!==void 0&&(m=a.onUncaughtError),a.onCaughtError!==void 0&&(j=a.onCaughtError),a.onRecoverableError!==void 0&&(k=a.onRecoverableError),a.formState!==void 0&&($=a.formState)),t=Jp(s,1,!0,t,a??null,r,o,$,m,j,k,ig),t.context=Xp(null),a=t.current,r=Sa(),r=ea(r),o=ql(r),o.callback=null,Kl(a,o,r),a=r,t.current.lanes=a,Le(t,a),rl(t),s[jt]=t.current,em(s),new ko(t)},Ii.version="19.2.1",Ii}var gg;function t1(){if(gg)return wm.exports;gg=1;function l(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(l)}catch(n){console.error(n)}}return l(),wm.exports=s1(),wm.exports}var a1=t1();function P(...l){return z0(A0(l))}const Ce=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("rounded-xl border bg-card text-card-foreground shadow",l),...n}));Ce.displayName="Card";const De=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("flex flex-col space-y-1.5 p-6",l),...n}));De.displayName="CardHeader";const Re=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("font-semibold leading-none tracking-tight",l),...n}));Re.displayName="CardTitle";const os=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("text-sm text-muted-foreground",l),...n}));os.displayName="CardDescription";const Me=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("p-6 pt-0",l),...n}));Me.displayName="CardContent";const ed=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("flex items-center p-6 pt-0",l),...n}));ed.displayName="CardFooter";const ta=D0,Xt=d.forwardRef(({className:l,...n},i)=>e.jsx(Hg,{ref:i,className:P("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",l),...n}));Xt.displayName=Hg.displayName;const Xe=d.forwardRef(({className:l,...n},i)=>e.jsx(Fg,{ref:i,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",l),...n}));Xe.displayName=Fg.displayName;const ws=d.forwardRef(({className:l,...n},i)=>e.jsx(Gg,{ref:i,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",l),...n}));ws.displayName=Gg.displayName;const Je=d.forwardRef(({className:l,children:n,viewportRef:i,...c},u)=>e.jsxs(Vg,{ref:u,className:P("relative overflow-hidden",l),...c,children:[e.jsx(R0,{ref:i,className:"h-full w-full rounded-[inherit]",children:n}),e.jsx($m,{}),e.jsx($m,{orientation:"horizontal"}),e.jsx(L0,{})]}));Je.displayName=Vg.displayName;const $m=d.forwardRef(({className:l,orientation:n="vertical",...i},c)=>e.jsx(qg,{ref:c,orientation:n,className:P("flex touch-none select-none transition-colors",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",l),...i,children:e.jsx(U0,{className:"relative flex-1 rounded-full bg-border"})}));$m.displayName=qg.displayName;function vs({className:l,...n}){return e.jsx("div",{className:P("animate-pulse rounded-md bg-primary/10",l),...n})}const Qn=d.forwardRef(({className:l,value:n,...i},c)=>e.jsx(Kg,{ref:c,className:P("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",l),...i,children:e.jsx($0,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(n||0)}%)`}})}));Qn.displayName=Kg.displayName;async function _e(l,n){const c=n?.body instanceof FormData?{...n?.headers}:{"Content-Type":"application/json",...n?.headers},u={...n,credentials:"include",headers:c},x=await fetch(l,u);if(x.status===401)throw window.location.href="/auth",new Error("认证失败,请重新登录");return x}function Fs(){return{"Content-Type":"application/json"}}async function l1(){try{await fetch("/api/webui/auth/logout",{method:"POST",credentials:"include"})}catch(l){console.error("登出请求失败:",l)}window.location.href="/auth"}async function ac(){try{return(await(await fetch("/api/webui/auth/check",{method:"GET",credentials:"include"})).json()).authenticated===!0}catch{return!1}}const n1={light:"",dark:".dark"},lv=d.createContext(null);function nv(){const l=d.useContext(lv);if(!l)throw new Error("useChart must be used within a <ChartContainer />");return l}const Br=d.forwardRef(({id:l,className:n,children:i,config:c,...u},x)=>{const h=d.useId(),f=`chart-${l||h.replace(/:/g,"")}`;return e.jsx(lv.Provider,{value:{config:c},children:e.jsxs("div",{"data-chart":f,ref:x,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",n),...u,children:[e.jsx(r1,{id:f,config:c}),e.jsx(uj,{children:i})]})})});Br.displayName="Chart";const r1=({id:l,config:n})=>{const i=Object.entries(n).filter(([,c])=>c.theme||c.color);return i.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(n1).map(([c,u])=>`
|
||
${u} [data-chart=${l}] {
|
||
${i.map(([x,h])=>{const f=h.theme?.[c]||h.color;return f?` --color-${x}: ${f};`:null}).join(`
|
||
`)}
|
||
}
|
||
`).join(`
|
||
`)}}):null},Pi=mj,Ir=d.forwardRef(({active:l,payload:n,className:i,indicator:c="dot",hideLabel:u=!1,hideIndicator:x=!1,label:h,labelFormatter:f,labelClassName:p,formatter:g,color:N,nameKey:v,labelKey:b},w)=>{const{config:y}=nv(),R=d.useMemo(()=>{if(u||!n?.length)return null;const[S]=n,B=`${b||S?.dataKey||S?.name||"value"}`,E=Bm(y,S,B),C=!b&&typeof h=="string"?y[h]?.label||h:E?.label;return f?e.jsx("div",{className:P("font-medium",p),children:f(C,n)}):C?e.jsx("div",{className:P("font-medium",p),children:C}):null},[h,f,n,u,p,y,b]);if(!l||!n?.length)return null;const O=n.length===1&&c!=="dot";return e.jsxs("div",{ref:w,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",i),children:[O?null:R,e.jsx("div",{className:"grid gap-1.5",children:n.filter(S=>S.type!=="none").map((S,B)=>{const E=`${v||S.name||S.dataKey||"value"}`,C=Bm(y,S,E),z=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,B,S.payload):e.jsxs(e.Fragment,{children:[C?.icon?e.jsx(C.icon,{}):!x&&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":O&&c==="dashed"}),style:{"--color-bg":z,"--color-border":z}}),e.jsxs("div",{className:P("flex flex-1 justify-between leading-none",O?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[O?R: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)})})]})});Ir.displayName="ChartTooltip";const i1=pw,rv=d.forwardRef(({className:l,hideIcon:n=!1,payload:i,verticalAlign:c="bottom",nameKey:u},x)=>{const{config:h}=nv();return i?.length?e.jsx("div",{ref:x,className:P("flex items-center justify-center gap-4",c==="top"?"pb-3":"pt-3",l),children:i.filter(f=>f.type!=="none").map(f=>{const p=`${u||f.dataKey||"value"}`,g=Bm(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&&!n?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});rv.displayName="ChartLegend";function Bm(l,n,i){if(typeof n!="object"||n===null)return;const c="payload"in n&&typeof n.payload=="object"&&n.payload!==null?n.payload:void 0;let u=i;return i in n&&typeof n[i]=="string"?u=n[i]:c&&i in c&&typeof c[i]=="string"&&(u=c[i]),u in l?l[u]:l[i]}const Kr=Qr("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"}}),_=d.forwardRef(({className:l,variant:n,size:i,asChild:c=!1,...u},x)=>{const h=c?yw:"button";return e.jsx(h,{className:P(Kr({variant:n,size:i,className:l})),ref:x,...u})});_.displayName="Button";const c1=Qr("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 ke({className:l,variant:n,...i}){return e.jsx("div",{className:P(c1({variant:n}),l),...i})}async function o1(){const l=await _e("/api/webui/system/restart",{method:"POST",headers:Fs()});if(!l.ok){const n=await l.json();throw new Error(n.detail||"重启失败")}return await l.json()}async function d1(){const l=await _e("/api/webui/system/status",{method:"GET",headers:Fs()});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取状态失败")}return await l.json()}const Ur={INITIAL_DELAY:3e3,CHECK_INTERVAL:2e3,CHECK_TIMEOUT:3e3,MAX_ATTEMPTS:60,PROGRESS_INTERVAL:200,SUCCESS_REDIRECT_DELAY:1500},iv=d.createContext(null);function Jn({children:l,onRestartComplete:n,onRestartFailed:i,healthCheckUrl:c="/api/webui/system/status",maxAttempts:u=Ur.MAX_ATTEMPTS}){const[x,h]=d.useState({status:"idle",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:u}),[f,p]=d.useState({}),g=d.useCallback(()=>{f.progress&&clearInterval(f.progress),f.elapsed&&clearInterval(f.elapsed),f.check&&clearTimeout(f.check),p({})},[f]),N=d.useCallback(()=>{g(),h({status:"idle",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:u})},[g,u]),v=d.useCallback(async()=>{try{const O=new AbortController,S=setTimeout(()=>O.abort(),Ur.CHECK_TIMEOUT),B=await fetch(c,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include",signal:O.signal});return clearTimeout(S),B.ok}catch{return!1}},[c]),b=d.useCallback(()=>{let O=0;const S=async()=>{if(O++,h(E=>({...E,status:"checking",checkAttempts:O})),await v())g(),h(E=>({...E,status:"success",progress:100})),setTimeout(()=>{n?.(),window.location.href="/auth"},Ur.SUCCESS_REDIRECT_DELAY);else if(O>=u){g();const E=`健康检查超时 (${O}/${u})`;h(C=>({...C,status:"failed",error:E})),i?.(E)}else{const E=setTimeout(S,Ur.CHECK_INTERVAL);p(C=>({...C,check:E}))}};S()},[v,g,u,n,i]),w=d.useCallback(()=>{h(O=>({...O,status:"checking",checkAttempts:0,error:void 0})),b()},[b]),y=d.useCallback(async O=>{const{delay:S=0,skipApiCall:B=!1}=O??{};if(x.status!=="idle"&&x.status!=="failed")return;if(g(),h({status:"requesting",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:u}),S>0&&await new Promise(z=>setTimeout(z,S)),B)h(z=>({...z,status:"restarting"}));else try{h(z=>({...z,status:"restarting"})),await Promise.race([o1(),new Promise(z=>setTimeout(z,5e3))])}catch{}const E=setInterval(()=>{h(z=>({...z,progress:z.progress>=90?z.progress:z.progress+1}))},Ur.PROGRESS_INTERVAL),C=setInterval(()=>{h(z=>({...z,elapsedTime:z.elapsedTime+1}))},1e3);p({progress:E,elapsed:C}),setTimeout(()=>{b()},Ur.INITIAL_DELAY)},[x.status,g,u,b]),R={state:x,isRestarting:x.status!=="idle",triggerRestart:y,resetState:N,retryHealthCheck:w};return e.jsx(iv.Provider,{value:R,children:l})}function vn(){const l=d.useContext(iv);if(!l)throw new Error("useRestart must be used within a RestartProvider");return l}function u1(){try{return vn()}catch{return null}}const m1=(l,n,i,c,u)=>({idle:{icon:null,title:"",description:"",tip:""},requesting:{icon:e.jsx(Bs,{className:"h-16 w-16 text-primary animate-spin"}),title:c??"准备重启",description:u??"正在发送重启请求...",tip:"🔄 正在准备重启麦麦..."},restarting:{icon:e.jsx(Bs,{className:"h-16 w-16 text-primary animate-spin"}),title:c??"正在重启麦麦",description:u??"请稍候,麦麦正在重启中...",tip:"🔄 配置已保存,正在重启主程序..."},checking:{icon:e.jsx(Bs,{className:"h-16 w-16 text-primary animate-spin"}),title:"检查服务状态",description:`等待服务恢复... (${n}/${i})`,tip:"⏳ 正在等待服务恢复,请勿关闭页面..."},success:{icon:e.jsx(pt,{className:"h-16 w-16 text-green-500"}),title:"重启成功",description:"正在跳转到登录页面...",tip:"✅ 配置已生效,服务运行正常"},failed:{icon:e.jsx(_t,{className:"h-16 w-16 text-destructive"}),title:"重启超时",description:"服务未能在预期时间内恢复",tip:"⚠️ 如果长时间无响应,请尝试手动重启"}})[l];function Xn({visible:l,onComplete:n,onFailed:i,title:c,description:u,showAnimation:x=!0,className:h}){const f=u1();return(f?f.isRestarting:l)?f?e.jsx(cv,{state:f.state,onRetry:f.retryHealthCheck,onComplete:n,onFailed:i,title:c,description:u,showAnimation:x,className:h}):e.jsx(x1,{onComplete:n,onFailed:i,title:c,description:u,showAnimation:x,className:h}):null}function cv({state:l,onRetry:n,onComplete:i,onFailed:c,title:u,description:x,showAnimation:h,className:f}){const{status:p,progress:g,elapsedTime:N,checkAttempts:v,maxAttempts:b}=l;d.useEffect(()=>{p==="success"&&i?i():p==="failed"&&c&&c()},[p,i,c]);const w=m1(p,v,b,u,x),y=R=>{const O=Math.floor(R/60),S=R%60;return`${O}:${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(h1,{}),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:[w.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:w.title}),e.jsx("p",{className:"text-muted-foreground text-center",children:w.description})]}),p!=="failed"&&p!=="idle"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Qn,{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:["已用时: ",y(N)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:w.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:n,variant:"secondary",className:"flex-1",children:[e.jsx(Wi,{className:"mr-2 h-4 w-4"}),"重试检测"]})]})]})]})}function x1({onComplete:l,onFailed:n,title:i,description:c,showAnimation:u,className:x}){const[h,f]=d.useState({status:"restarting",progress:0,elapsedTime:0,checkAttempts:0,maxAttempts:60}),p=d.useCallback(()=>{let g=0;const N=60,v=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(w=>({...w,status:"success",progress:100})),setTimeout(()=>{l?.(),window.location.href="/auth"},1500);return}}catch{}g>=N?(f(b=>({...b,status:"failed"})),n?.()):setTimeout(v,2e3)};v()},[l,n]);return d.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),v=setTimeout(()=>{p()},3e3);return()=>{clearInterval(g),clearInterval(N),clearTimeout(v)}},[p]),e.jsx(cv,{state:h,onRetry:p,onComplete:l,onFailed:n,title:i,description:c,showAnimation:u,className:x})}function h1(){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 Is=Sw,sd=kw,f1=ww,ov=d.forwardRef(({className:l,...n},i)=>e.jsx(xj,{ref:i,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",l),...n}));ov.displayName=xj.displayName;const Os=d.forwardRef(({className:l,children:n,preventOutsideClose:i=!1,...c},u)=>e.jsxs(f1,{children:[e.jsx(ov,{}),e.jsxs(hj,{ref:u,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",l),onPointerDownOutside:i?x=>x.preventDefault():void 0,onInteractOutside:i?x=>x.preventDefault():void 0,...c,children:[n,e.jsxs(_w,{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(Ea,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Os.displayName=hj.displayName;const Ds=({className:l,...n})=>e.jsx("div",{className:P("flex flex-col space-y-1.5 text-center sm:text-left",l),...n});Ds.displayName="DialogHeader";const st=({className:l,...n})=>e.jsx("div",{className:P("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",l),...n});st.displayName="DialogFooter";const Rs=d.forwardRef(({className:l,...n},i)=>e.jsx(fj,{ref:i,className:P("text-lg font-semibold leading-none tracking-tight",l),...n}));Rs.displayName=fj.displayName;const Ks=d.forwardRef(({className:l,...n},i)=>e.jsx(pj,{ref:i,className:P("text-sm text-muted-foreground",l),...n}));Ks.displayName=pj.displayName;const ae=d.forwardRef(({className:l,type:n,...i},c)=>e.jsx("input",{type:n,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",l),ref:c,...i}));ae.displayName="Input";const qs=d.forwardRef(({className:l,...n},i)=>e.jsx(gj,{ref:i,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",l),...n,children:e.jsx(Cw,{className:P("grid place-content-center text-current"),children:e.jsx(Ct,{className:"h-4 w-4"})})}));qs.displayName=gj.displayName;const Ie=Ow,Pe=Dw,$e=d.forwardRef(({className:l,children:n,...i},c)=>e.jsxs(jj,{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",l),...i,children:[n,e.jsx(Tw,{asChild:!0,children:e.jsx(Ma,{className:"h-4 w-4 opacity-50"})})]}));$e.displayName=jj.displayName;const dv=d.forwardRef(({className:l,...n},i)=>e.jsx(vj,{ref:i,className:P("flex cursor-default items-center justify-center py-1",l),...n,children:e.jsx(Fr,{className:"h-4 w-4"})}));dv.displayName=vj.displayName;const uv=d.forwardRef(({className:l,...n},i)=>e.jsx(Nj,{ref:i,className:P("flex cursor-default items-center justify-center py-1",l),...n,children:e.jsx(Ma,{className:"h-4 w-4"})}));uv.displayName=Nj.displayName;const Be=d.forwardRef(({className:l,children:n,position:i="popper",...c},u)=>e.jsx(Ew,{children:e.jsxs(bj,{ref:u,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]",i==="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",l),position:i,...c,children:[e.jsx(dv,{}),e.jsx(Mw,{className:P("p-1",i==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),e.jsx(uv,{})]})}));Be.displayName=bj.displayName;const p1=d.forwardRef(({className:l,...n},i)=>e.jsx(yj,{ref:i,className:P("px-2 py-1.5 text-sm font-semibold",l),...n}));p1.displayName=yj.displayName;const Z=d.forwardRef(({className:l,children:n,...i},c)=>e.jsxs(wj,{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",l),...i,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(zw,{children:e.jsx(Ct,{className:"h-4 w-4"})})}),e.jsx(Aw,{children:n})]}));Z.displayName=wj.displayName;const g1=d.forwardRef(({className:l,...n},i)=>e.jsx(_j,{ref:i,className:P("-mx-1 my-1 h-px bg-muted",l),...n}));g1.displayName=_j.displayName;const Wm=({className:l,...n})=>e.jsx("nav",{role:"navigation","aria-label":"pagination",className:P("mx-auto flex w-full justify-center",l),...n});Wm.displayName="Pagination";const ex=d.forwardRef(({className:l,...n},i)=>e.jsx("ul",{ref:i,className:P("flex flex-row items-center gap-1",l),...n}));ex.displayName="PaginationContent";const Fn=d.forwardRef(({className:l,...n},i)=>e.jsx("li",{ref:i,className:P("",l),...n}));Fn.displayName="PaginationItem";const uc=({className:l,isActive:n,size:i="icon",...c})=>e.jsx("a",{"aria-current":n?"page":void 0,className:P(Kr({variant:n?"outline":"ghost",size:i}),l),...c});uc.displayName="PaginationLink";const mv=({className:l,...n})=>e.jsxs(uc,{"aria-label":"Go to previous page",size:"default",className:P("gap-1 pl-2.5",l),...n,children:[e.jsx(Aa,{className:"h-4 w-4"}),e.jsx("span",{children:"上一页"})]});mv.displayName="PaginationPrevious";const xv=({className:l,...n})=>e.jsxs(uc,{"aria-label":"Go to next page",size:"default",className:P("gap-1 pr-2.5",l),...n,children:[e.jsx("span",{children:"下一页"}),e.jsx(Zt,{className:"h-4 w-4"})]});xv.displayName="PaginationNext";const hv=({className:l,...n})=>e.jsxs("span",{"aria-hidden":!0,className:P("flex h-9 w-9 items-center justify-center",l),...n,children:[e.jsx(Vw,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More pages"})]});hv.displayName="PaginationEllipsis";const j1=5,v1=5e3;let km=0;function N1(){return km=(km+1)%Number.MAX_SAFE_INTEGER,km.toString()}const Cm=new Map,jg=l=>{if(Cm.has(l))return;const n=setTimeout(()=>{Cm.delete(l),Ji({type:"REMOVE_TOAST",toastId:l})},v1);Cm.set(l,n)},b1=(l,n)=>{switch(n.type){case"ADD_TOAST":return{...l,toasts:[n.toast,...l.toasts].slice(0,j1)};case"UPDATE_TOAST":return{...l,toasts:l.toasts.map(i=>i.id===n.toast.id?{...i,...n.toast}:i)};case"DISMISS_TOAST":{const{toastId:i}=n;return i?jg(i):l.toasts.forEach(c=>{jg(c.id)}),{...l,toasts:l.toasts.map(c=>c.id===i||i===void 0?{...c,open:!1}:c)}}case"REMOVE_TOAST":return n.toastId===void 0?{...l,toasts:[]}:{...l,toasts:l.toasts.filter(i=>i.id!==n.toastId)}}},Ro=[];let Lo={toasts:[]};function Ji(l){Lo=b1(Lo,l),Ro.forEach(n=>{n(Lo)})}function Qt({...l}){const n=N1(),i=u=>Ji({type:"UPDATE_TOAST",toast:{...u,id:n}}),c=()=>Ji({type:"DISMISS_TOAST",toastId:n});return Ji({type:"ADD_TOAST",toast:{...l,id:n,open:!0,onOpenChange:u=>{u||c()}}}),{id:n,dismiss:c,update:i}}function Zs(){const[l,n]=d.useState(Lo);return d.useEffect(()=>(Ro.push(n),()=>{const i=Ro.indexOf(n);i>-1&&Ro.splice(i,1)}),[l]),{...l,toast:Qt,dismiss:i=>Ji({type:"DISMISS_TOAST",toastId:i})}}const el="/api/webui/expression";async function sx(){const l=await _e(`${el}/chats`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取聊天列表失败")}return l.json()}async function y1(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.chat_id&&n.append("chat_id",l.chat_id);const i=await _e(`${el}/list?${n}`,{});if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取表达方式列表失败")}return i.json()}async function w1(l){const n=await _e(`${el}/${l}`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取表达方式详情失败")}return n.json()}async function _1(l){const n=await _e(`${el}/`,{method:"POST",body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"创建表达方式失败")}return n.json()}async function S1(l,n){const i=await _e(`${el}/${l}`,{method:"PATCH",body:JSON.stringify(n)});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新表达方式失败")}return i.json()}async function k1(l){const n=await _e(`${el}/${l}`,{method:"DELETE"});if(!n.ok){const i=await n.json();throw new Error(i.detail||"删除表达方式失败")}return n.json()}async function C1(l){const n=await _e(`${el}/batch/delete`,{method:"POST",body:JSON.stringify({ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除表达方式失败")}return n.json()}async function T1(){const l=await _e(`${el}/stats/summary`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取统计数据失败")}return l.json()}async function tx(){const l=await _e(`${el}/review/stats`);if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取审核统计失败")}return l.json()}async function E1(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.filter_type&&n.append("filter_type",l.filter_type),l.search&&n.append("search",l.search),l.chat_id&&n.append("chat_id",l.chat_id);const i=await _e(`${el}/review/list?${n}`);if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取审核列表失败")}return i.json()}async function vg(l){const n=await _e(`${el}/review/batch`,{method:"POST",body:JSON.stringify({items:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量审核失败")}return n.json()}function fv({open:l,onOpenChange:n}){const[i,c]=d.useState(null),[u,x]=d.useState([]),[h,f]=d.useState(!1),[p,g]=d.useState(!1),[N,v]=d.useState(0),[b,w]=d.useState(1),[y,R]=d.useState(20),[O,S]=d.useState(""),[B,E]=d.useState("unchecked"),[C,z]=d.useState(""),[H,L]=d.useState(""),[J,U]=d.useState(new Set),[oe,Ne]=d.useState(new Set),[je,re]=d.useState(new Map),{toast:fe}=Zs(),ge=d.useCallback(async()=>{try{g(!0);const Y=await tx();c(Y)}catch(Y){console.error("加载统计失败:",Y)}finally{g(!1)}},[]),M=d.useCallback(async()=>{try{f(!0);const Y=await E1({page:b,page_size:y,filter_type:B,search:C||void 0});x(Y.data),v(Y.total)}catch(Y){fe({title:"加载失败",description:Y instanceof Error?Y.message:"无法加载列表",variant:"destructive"})}finally{f(!1)}},[b,y,B,C,fe]),K=d.useCallback(async()=>{try{const Y=await sx();if(Y?.data){const He=new Map;Y.data.forEach(F=>{He.set(F.chat_id,F.chat_name)}),re(He)}}catch(Y){console.error("加载聊天名称失败:",Y)}},[]);d.useEffect(()=>{l&&(ge(),M(),K())},[l,ge,M,K]),d.useEffect(()=>{w(1),U(new Set)},[B,C]);const I=()=>{z(H),w(1)},ue=Y=>je.get(Y)||Y,Q=async(Y,He)=>{try{Ne(ee=>new Set(ee).add(Y));const F=await vg([{id:Y,rejected:He,require_unchecked:B==="unchecked"}]);F.results[0]?.success?(fe({title:He?"已拒绝":"已通过",description:`表达方式 #${Y} ${He?"已拒绝":"已通过"}`}),M(),ge()):fe({title:"操作失败",description:F.results[0]?.message||"未知错误",variant:"destructive"})}catch(F){fe({title:"操作失败",description:F instanceof Error?F.message:"未知错误",variant:"destructive"})}finally{Ne(F=>{const ee=new Set(F);return ee.delete(Y),ee})}},Se=async Y=>{if(J.size===0){fe({title:"请选择",description:"请先选择要审核的表达方式",variant:"destructive"});return}try{f(!0);const He=Array.from(J).map(ee=>({id:ee,rejected:Y,require_unchecked:B==="unchecked"})),F=await vg(He);fe({title:"批量审核完成",description:`成功 ${F.succeeded} 条,失败 ${F.failed} 条`,variant:F.failed>0?"destructive":"default"}),U(new Set),M(),ge()}catch(He){fe({title:"批量审核失败",description:He instanceof Error?He.message:"未知错误",variant:"destructive"})}finally{f(!1)}},pe=()=>{J.size===u.length?U(new Set):U(new Set(u.map(Y=>Y.id)))},Te=Y=>{U(He=>{const F=new Set(He);return F.has(Y)?F.delete(Y):F.add(Y),F})},A=Y=>Y?new Date(Y*1e3).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-",D=Y=>Y.checked?Y.rejected?e.jsxs(ke,{variant:"destructive",className:"gap-1",children:[e.jsx(Va,{className:"h-3 w-3"}),"已拒绝"]}):e.jsxs(ke,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(pt,{className:"h-3 w-3"}),"已通过"]}):e.jsxs(ke,{variant:"outline",className:"gap-1",children:[e.jsx(na,{className:"h-3 w-3"}),"待审核"]}),V=Y=>Y?Y==="ai"?e.jsxs(ke,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(Pn,{className:"h-3 w-3"}),"AI"]}):e.jsxs(ke,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(fn,{className:"h-3 w-3"}),"人工"]}):null,de=Math.ceil(N/y),Oe=()=>{const Y=[];if(de<=7)for(let He=1;He<=de;He++)Y.push(He);else{Y.push(1),b>3&&Y.push("ellipsis");const He=Math.max(2,b-1),F=Math.min(de-1,b+1);for(let ee=He;ee<=F;ee++)Y.push(ee);b<de-2&&Y.push("ellipsis"),de>1&&Y.push(de)}return Y},W=()=>{const Y=parseInt(O,10);!isNaN(Y)&&Y>=1&&Y<=de&&(w(Y),S(""))};return e.jsx(Is,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-5xl w-[95vw] sm:w-full h-[90vh] sm:h-[85vh] flex flex-col p-0",children:[e.jsxs(Ds,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-4 border-b shrink-0",children:[e.jsx(Rs,{className:"text-lg sm:text-xl",children:"表达方式审核"}),e.jsx(Ks,{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:p?"-":i?.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:p?"-":i?.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:p?"-":i?.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:p?"-":i?.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(ta,{value:B,onValueChange:Y=>E(Y),className:"w-full",children:e.jsxs(Xt,{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(na,{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:["(",i?.unchecked??0,")"]})]}),e.jsxs(Xe,{value:"passed",className:"gap-1 text-xs sm:text-sm px-1 sm:px-3",children:[e.jsx(pt,{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:["(",i?.passed??0,")"]})]}),e.jsxs(Xe,{value:"rejected",className:"gap-1 text-xs sm:text-sm px-1 sm:px-3",children:[e.jsx(Va,{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:["(",i?.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:["(",i?.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(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索情景或风格...",value:H,onChange:Y=>L(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&I(),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"icon",onClick:I,children:e.jsx(Tt,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"icon",onClick:()=>{M(),ge()},disabled:h,children:e.jsx(dt,{className:P("h-4 w-4",h&&"animate-spin")})})]}),B==="unchecked"&&J.size>0&&e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[e.jsxs(_,{variant:"default",size:"sm",className:"bg-green-600 hover:bg-green-700 flex-1 sm:flex-none",onClick:()=>Se(!1),disabled:h,children:[e.jsx(pt,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量通过"}),e.jsx("span",{className:"sm:hidden",children:"通过"}),"(",J.size,")"]}),e.jsxs(_,{variant:"destructive",size:"sm",className:"flex-1 sm:flex-none",onClick:()=>Se(!0),disabled:h,children:[e.jsx(Va,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"批量拒绝"}),e.jsx("span",{className:"sm:hidden",children:"拒绝"}),"(",J.size,")"]})]})]})]}),e.jsx(Je,{className:"flex-1 px-4 sm:px-6",children:h&&u.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"})}):u.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-muted-foreground",children:[e.jsx(_t,{className:"h-8 w-8 mb-2"}),e.jsx("p",{children:"没有找到表达方式"})]}):e.jsxs("div",{className:"space-y-2 py-2",children:[B==="unchecked"&&u.length>0&&e.jsxs("div",{className:"flex items-center gap-2 py-2 px-3 rounded-lg bg-muted/50",children:[e.jsx(qs,{checked:J.size===u.length&&u.length>0,onCheckedChange:pe}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["全选当前页 (",u.length," 条)"]})]}),u.map(Y=>e.jsx("div",{className:P("rounded-lg border p-3 sm:p-4 space-y-2 sm:space-y-3 transition-colors",J.has(Y.id)&&"bg-accent border-primary",oe.has(Y.id)&&"opacity-50"),children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[B==="unchecked"&&e.jsx(qs,{checked:J.has(Y.id),onCheckedChange:()=>Te(Y.id),disabled:oe.has(Y.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:Y.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:Y.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:["#",Y.id]}),e.jsx("span",{children:"·"}),e.jsx("span",{title:ue(Y.chat_id),className:"truncate max-w-24 sm:max-w-32",children:ue(Y.chat_id)}),e.jsx("span",{children:"·"}),e.jsx("span",{children:A(Y.create_date)}),e.jsxs("div",{className:"flex items-center gap-1",children:[D(Y),V(Y.modified_by)]})]})]}),e.jsx("div",{className:"flex flex-col gap-1 sm:gap-2 shrink-0",children:B==="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:()=>Q(Y.id,!1),disabled:oe.has(Y.id),children:[e.jsx(pt,{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:()=>Q(Y.id,!0),disabled:oe.has(Y.id),children:[e.jsx(Va,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"拒绝"})]})]}):B==="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:()=>Q(Y.id,!0),disabled:oe.has(Y.id),children:[e.jsx(Va,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为拒绝"})]}):B==="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:()=>Q(Y.id,!1),disabled:oe.has(Y.id),children:[e.jsx(pt,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为通过"})]}):e.jsx(e.Fragment,{children:Y.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:()=>Q(Y.id,!1),disabled:oe.has(Y.id),children:[e.jsx(pt,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"改为通过"})]}):Y.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:()=>Q(Y.id,!0),disabled:oe.has(Y.id),children:[e.jsx(Va,{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:()=>Q(Y.id,!1),disabled:oe.has(Y.id),children:[e.jsx(pt,{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:()=>Q(Y.id,!0),disabled:oe.has(Y.id),children:[e.jsx(Va,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"拒绝"})]})]})})})]})},Y.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(Ie,{value:y.toString(),onValueChange:Y=>{R(parseInt(Y,10)),w(1)},children:[e.jsx($e,{className:"w-[70px] h-8",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10"}),e.jsx(Z,{value:"20",children:"20"}),e.jsx(Z,{value:"50",children:"50"}),e.jsx(Z,{value:"100",children:"100"})]})]}),e.jsx("span",{className:"hidden sm:inline",children:"条"}),e.jsxs("span",{className:"text-muted-foreground",children:["共 ",N," 条"]})]}),e.jsx(Wm,{className:"mx-0 w-auto",children:e.jsxs(ex,{children:[e.jsx(Fn,{children:e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(Y=>Math.max(1,Y-1)),disabled:b<=1||h,children:e.jsx(Aa,{className:"h-4 w-4"})})}),Oe().map((Y,He)=>e.jsx(Fn,{children:Y==="ellipsis"?e.jsx(hv,{}):e.jsx(uc,{href:"#",isActive:Y===b,onClick:F=>{F.preventDefault(),w(Y)},className:"h-8 w-8 cursor-pointer",children:Y})},He)),e.jsx(Fn,{children:e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(Y=>Math.min(de,Y+1)),disabled:b>=de||h,children:e.jsx(Zt,{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(ae,{type:"number",min:1,max:de,value:O,onChange:Y=>S(Y.target.value),onKeyDown:Y=>Y.key==="Enter"&&W(),className:"w-16 h-8 text-center",placeholder:b.toString()}),e.jsx("span",{className:"text-muted-foreground",children:"页"}),e.jsx(_,{variant:"outline",size:"sm",className:"h-8",onClick:W,disabled:h,children:"跳转"})]})]})]})})}function M1(){return e.jsx(Jn,{children:e.jsx(A1,{})})}const z1=l=>{const n=[];for(let i=0;i<l;i++){const c=i*137.508%360;n.push(`hsl(${c}, 70%, 55%)`)}return n};function A1(){const[l,n]=d.useState(null),[i,c]=d.useState(!0),[u,x]=d.useState(0),[h,f]=d.useState(24),[p,g]=d.useState(!0),[N,v]=d.useState(null),[b,w]=d.useState(!0),[y,R]=d.useState(null),[O,S]=d.useState(!1),[B,E]=d.useState(0),{triggerRestart:C,isRestarting:z}=vn(),H=d.useCallback(async()=>{try{const A=await tx();E(A.unchecked)}catch(A){console.error("获取审核统计失败:",A)}},[]),L=d.useCallback(async()=>{try{w(!0);const A=await O0.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");v({hitokoto:A.data.hitokoto,from:A.data.from||A.data.from_who||"未知"})}catch(A){console.error("获取一言失败:",A),v({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{w(!1)}},[]),J=d.useCallback(async()=>{try{const A=await _e("/api/webui/system/status");if(A.ok){const D=await A.json();R(D)}else R(null)}catch(A){console.error("获取机器人状态失败:",A),R(null)}},[]),U=async()=>{await C()},oe=d.useCallback(async()=>{try{const A=await _e(`/api/webui/statistics/dashboard?hours=${h}`);if(A.ok){const D=await A.json();n(D)}c(!1),x(100)}catch(A){console.error("Failed to fetch dashboard data:",A),c(!1),x(100)}},[h]);if(d.useEffect(()=>{if(!i)return;x(0);const A=setTimeout(()=>x(15),200),D=setTimeout(()=>x(30),800),V=setTimeout(()=>x(45),2e3),de=setTimeout(()=>x(60),4e3),Oe=setTimeout(()=>x(75),6500),W=setTimeout(()=>x(85),9e3),Y=setTimeout(()=>x(92),11e3);return()=>{clearTimeout(A),clearTimeout(D),clearTimeout(V),clearTimeout(de),clearTimeout(Oe),clearTimeout(W),clearTimeout(Y)}},[i]),d.useEffect(()=>{oe(),L(),J(),H()},[oe,L,J,H]),d.useEffect(()=>{if(!p)return;const A=setInterval(()=>{oe(),J()},3e4);return()=>clearInterval(A)},[p,oe,J]),i||!l)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(Qn,{value:u,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u,"%"]})]})]})});const{summary:Ne,model_stats:je=[],hourly_data:re=[],daily_data:fe=[],recent_activity:ge=[]}=l,M=Ne??{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},K=A=>{const D=Math.floor(A/3600),V=Math.floor(A%3600/60);return`${D}小时${V}分钟`},I=A=>{const D=A.toLocaleString("zh-CN");return A>=1e9?{display:`${(A/1e9).toFixed(2)}B`,exact:D,needsExact:!0}:A>=1e6?{display:`${(A/1e6).toFixed(2)}M`,exact:D,needsExact:!0}:A>=1e4?{display:`${(A/1e3).toFixed(1)}K`,exact:D,needsExact:!0}:A>=1e3?{display:`${(A/1e3).toFixed(2)}K`,exact:D,needsExact:!0}:{display:D,exact:D,needsExact:!1}},ue=A=>{const D=`¥${A.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`;return A>=1e6?{display:`¥${(A/1e6).toFixed(2)}M`,exact:D,needsExact:!0}:A>=1e4?{display:`¥${(A/1e3).toFixed(1)}K`,exact:D,needsExact:!0}:A>=1e3?{display:`¥${(A/1e3).toFixed(2)}K`,exact:D,needsExact:!0}:{display:D,exact:D,needsExact:!1}},Q=A=>new Date(A).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),Se=z1(je.length),pe=je.map((A,D)=>({name:A.model_name,value:A.request_count,fill:Se[D]})),Te={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(Je,{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(ta,{value:h.toString(),onValueChange:A=>f(Number(A)),children:e.jsxs(Xt,{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:oe,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(vs,{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(Ce,{className:"lg:col-span-1",children:[e.jsx(De,{className:"pb-3",children:e.jsxs(Re,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(oc,{className:"h-4 w-4"}),"麦麦状态"]})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:y?.running?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),e.jsxs(ke,{variant:"outline",className:"text-green-600 border-green-300 bg-green-50",children:[e.jsx(pt,{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(ke,{variant:"outline",className:"text-red-600 border-red-300 bg-red-50",children:[e.jsx(_t,{className:"h-3 w-3 mr-1"}),"已停止"]})]})}),y&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("span",{children:["v",y.version]}),e.jsx("span",{className:"mx-2",children:"|"}),e.jsxs("span",{children:["运行 ",K(y.uptime)]})]})]})})]}),e.jsxs(Ce,{children:[e.jsx(De,{className:"pb-3",children:e.jsxs(Re,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Za,{className:"h-4 w-4"}),"快速操作"]})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:U,disabled:z,className:"gap-2",children:[e.jsx(Wi,{className:`h-4 w-4 ${z?"animate-spin":""}`}),z?"重启中...":"重启麦麦"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>S(!0),className:"gap-2",children:[e.jsx(Dj,{className:"h-4 w-4"}),"表达审核",B>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs rounded-full bg-orange-500 text-white",children:B>99?"99+":B})]}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Bn,{to:"/logs",children:[e.jsx(Ca,{className:"h-4 w-4"}),"查看日志"]})}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Bn,{to:"/plugins",children:[e.jsx(qw,{className:"h-4 w-4"}),"插件管理"]})}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Bn,{to:"/settings",children:[e.jsx(pn,{className:"h-4 w-4"}),"系统设置"]})})]})})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"pb-3",children:[e.jsxs(Re,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Kw,{className:"h-4 w-4"}),"反馈问卷"]}),e.jsx(os,{className:"text-xs",children:"帮助我们改进产品体验"})]}),e.jsx(Me,{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(Bn,{to:"/survey/webui-feedback",children:[e.jsx(Ca,{className:"h-4 w-4"}),"WebUI 反馈"]})}),e.jsx(_,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsxs(Bn,{to:"/survey/maibot-feedback",children:[e.jsx(za,{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(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(Vm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[I(M.total_requests).display,I(M.total_requests).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",I(M.total_requests).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",h<48?h+"小时":Math.floor(h/24)+"天"]})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"总花费"}),e.jsx(Qw,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[ue(M.total_cost).display,ue(M.total_cost).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",ue(M.total_cost).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:M.cost_per_hour>0?`¥${M.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(Gr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[I(M.total_tokens).display,I(M.total_tokens).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",I(M.total_tokens).exact,")"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:M.tokens_per_hour>0?`${I(M.tokens_per_hour).display}/小时`:"暂无数据"})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(Za,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[M.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(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(na,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Me,{children:e.jsxs("div",{className:"text-xl font-bold",children:[K(M.online_time),e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",M.online_time.toLocaleString(),"秒)"]})]})})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(za,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsxs("div",{className:"text-xl font-bold",children:[I(M.total_messages).display,I(M.total_messages).needsExact&&e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",I(M.total_messages).exact,")"]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",I(M.total_replies).display,I(M.total_replies).needsExact&&e.jsxs("span",{children:["(",I(M.total_replies).exact,")"]})," 条"]})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(qm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsx("div",{className:"text-xl font-bold",children:M.total_messages>0?`¥${(M.total_cost/M.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(ta,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs(Xt,{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(ws,{value:"trends",className:"space-y-4",children:[e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"请求趋势"}),e.jsxs(os,{children:["最近",h,"小时的请求量变化"]})]}),e.jsx(Me,{children:e.jsx(Br,{config:Te,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(gw,{data:re,children:[e.jsx(Fi,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Gi,{dataKey:"timestamp",tickFormatter:A=>Q(A),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx($r,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Pi,{content:e.jsx(Ir,{labelFormatter:A=>Q(A)})}),e.jsx(jw,{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(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"花费趋势"}),e.jsx(os,{children:"API调用成本变化"})]}),e.jsx(Me,{children:e.jsx(Br,{config:Te,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Ao,{data:re,children:[e.jsx(Fi,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Gi,{dataKey:"timestamp",tickFormatter:A=>Q(A),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx($r,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Pi,{content:e.jsx(Ir,{labelFormatter:A=>Q(A)})}),e.jsx(Vi,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"Token消耗"}),e.jsx(os,{children:"Token使用量变化"})]}),e.jsx(Me,{children:e.jsx(Br,{config:Te,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(Ao,{data:re,children:[e.jsx(Fi,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Gi,{dataKey:"timestamp",tickFormatter:A=>Q(A),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx($r,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Pi,{content:e.jsx(Ir,{labelFormatter:A=>Q(A)})}),e.jsx(Vi,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(ws,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"模型请求分布"}),e.jsxs(os,{children:["各模型使用占比 (共 ",je.length," 个模型)"]})]}),e.jsx(Me,{children:e.jsx(Br,{config:Object.fromEntries(je.map((A,D)=>[A.model_name,{label:A.model_name,color:Se[D]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(vw,{children:[e.jsx(Pi,{content:e.jsx(Ir,{})}),e.jsx(Nw,{data:pe,cx:"50%",cy:"50%",labelLine:!1,label:({name:A,percent:D})=>D&&D<.05?"":`${A} ${D?(D*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:pe.map((A,D)=>e.jsx(bw,{fill:A.fill},`cell-${D}`))})]})})})]}),e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"模型详细统计"}),e.jsx(os,{children:"请求数、花费和性能"})]}),e.jsx(Me,{children:e.jsx(Je,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:je.map((A,D)=>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-${D%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"]})]})]})]},D))})})})]})]})}),e.jsx(ws,{value:"activity",children:e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"最近活动"}),e.jsx(os,{children:"最新的API调用记录"})]}),e.jsx(Me,{children:e.jsx(Je,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:ge.map((A,D)=>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:Q(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})]})]})]},D))})})})]})}),e.jsx(ws,{value:"daily",children:e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"每日统计"}),e.jsx(os,{children:"最近7天的数据汇总"})]}),e.jsx(Me,{children:e.jsx(Br,{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(Ao,{data:fe,children:[e.jsx(Fi,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Gi,{dataKey:"timestamp",tickFormatter:A=>{const D=new Date(A);return`${D.getMonth()+1}/${D.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx($r,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx($r,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Pi,{content:e.jsx(Ir,{labelFormatter:A=>new Date(A).toLocaleDateString("zh-CN")})}),e.jsx(i1,{content:e.jsx(rv,{})}),e.jsx(Vi,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Vi,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]}),e.jsx(Xn,{}),e.jsx(fv,{open:O,onOpenChange:A=>{S(A),A||H()}})]})})}const O1={theme:"system",setTheme:()=>null},pv=d.createContext(O1),ax=()=>{const l=d.useContext(pv);if(l===void 0)throw new Error("useTheme must be used within a ThemeProvider");return l},D1=(l,n,i)=>{const c=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||c){n(l);return}const u=i.clientX,x=i.clientY,h=Math.hypot(Math.max(u,innerWidth-u),Math.max(x,innerHeight-x));document.startViewTransition(()=>{n(l)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${u}px ${x}px)`,`circle(${h}px at ${u}px ${x}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},gv=d.createContext(void 0),jv=()=>{const l=d.useContext(gv);if(l===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return l},Ge=d.forwardRef(({className:l,...n},i)=>e.jsx(Qg,{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",l),...n,ref:i,children:e.jsx(B0,{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=Qg.displayName;const R1=Qr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),T=d.forwardRef(({className:l,...n},i)=>e.jsx(Sj,{ref:i,className:P(R1(),l),...n}));T.displayName=Sj.displayName;const L1=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:l=>l.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:l=>/[A-Z]/.test(l)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:l=>/[a-z]/.test(l)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:l=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(l)}];function U1(l){const n=L1.map(c=>({id:c.id,label:c.label,description:c.description,passed:c.validate(l)}));return{isValid:n.every(c=>c.passed),rules:n}}const td="0.12.1",lx="MaiBot Dashboard",$1=`${lx} v${td}`,B1=(l="v")=>`${l}${td}`,pa={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"},cl={theme:"system",accentColor:"blue",enableAnimations:!0,enableWavesBackground:!0,logCacheSize:1e3,logAutoScroll:!0,logFontSize:"xs",logLineSpacing:4,dataSyncInterval:30,wsReconnectInterval:3e3,wsMaxReconnectAttempts:10};function yt(l){const n=vv(l),i=localStorage.getItem(n);if(i===null)return cl[l];const c=cl[l];if(typeof c=="boolean")return i==="true";if(typeof c=="number"){const u=parseFloat(i);return isNaN(u)?c:u}return i}function Pr(l,n){const i=vv(l);localStorage.setItem(i,String(n)),window.dispatchEvent(new CustomEvent("maibot-settings-change",{detail:{key:l,value:n}}))}function I1(){return{theme:yt("theme"),accentColor:yt("accentColor"),enableAnimations:yt("enableAnimations"),enableWavesBackground:yt("enableWavesBackground"),logCacheSize:yt("logCacheSize"),logAutoScroll:yt("logAutoScroll"),logFontSize:yt("logFontSize"),logLineSpacing:yt("logLineSpacing"),dataSyncInterval:yt("dataSyncInterval"),wsReconnectInterval:yt("wsReconnectInterval"),wsMaxReconnectAttempts:yt("wsMaxReconnectAttempts")}}function P1(){const l=I1(),n=localStorage.getItem(pa.COMPLETED_TOURS),i=n?JSON.parse(n):[];return{...l,completedTours:i}}function H1(l){const n=[],i=[];for(const[c,u]of Object.entries(l)){if(c==="completedTours"){Array.isArray(u)?(localStorage.setItem(pa.COMPLETED_TOURS,JSON.stringify(u)),n.push("completedTours")):i.push("completedTours");continue}if(c in cl){const x=c,h=cl[x];if(typeof u==typeof h){if(x==="theme"&&!["light","dark","system"].includes(u)){i.push(c);continue}if(x==="logFontSize"&&!["xs","sm","base"].includes(u)){i.push(c);continue}Pr(x,u),n.push(c)}else i.push(c)}else i.push(c)}return{success:n.length>0,imported:n,skipped:i}}function F1(){for(const l of Object.keys(cl))Pr(l,cl[l]);localStorage.removeItem(pa.COMPLETED_TOURS),window.dispatchEvent(new CustomEvent("maibot-settings-reset"))}function G1(){const l=[],n=[],i=[];for(let c=0;c<localStorage.length;c++){const u=localStorage.key(c);u&&(u.startsWith("maibot")||u.startsWith("accent-color")||u==="access-token")&&i.push(u)}for(const c of i)localStorage.removeItem(c),l.push(c);return{clearedKeys:l,preservedKeys:n}}function Ng(){let l=0;const n=[];for(let i=0;i<localStorage.length;i++){const c=localStorage.key(i);if(c){const u=localStorage.getItem(c)||"",x=(c.length+u.length)*2;l+=x,n.push({key:c,size:x})}}return n.sort((i,c)=>c.size-i.size),{used:l,items:localStorage.length,details:n}}function V1(l){if(l===0)return"0 B";const n=1024,i=["B","KB","MB"],c=Math.floor(Math.log(l)/Math.log(n));return parseFloat((l/Math.pow(n,c)).toFixed(2))+" "+i[c]}function vv(l){return{theme:pa.THEME,accentColor:pa.ACCENT_COLOR,enableAnimations:pa.ENABLE_ANIMATIONS,enableWavesBackground:pa.ENABLE_WAVES_BACKGROUND,logCacheSize:pa.LOG_CACHE_SIZE,logAutoScroll:pa.LOG_AUTO_SCROLL,logFontSize:pa.LOG_FONT_SIZE,logLineSpacing:pa.LOG_LINE_SPACING,dataSyncInterval:pa.DATA_SYNC_INTERVAL,wsReconnectInterval:pa.WS_RECONNECT_INTERVAL,wsMaxReconnectAttempts:pa.WS_MAX_RECONNECT_ATTEMPTS}[l]}const qa=d.forwardRef(({className:l,...n},i)=>e.jsxs(Yg,{ref:i,className:P("relative flex w-full touch-none select-none items-center",l),...n,children:[e.jsx(I0,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(P0,{className:"absolute h-full bg-primary"})}),e.jsx(H0,{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"})]}));qa.displayName=Yg.displayName;class q1{ws=null;reconnectTimeout=null;reconnectAttempts=0;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];getMaxCacheSize(){return yt("logCacheSize")}getMaxReconnectAttempts(){return yt("wsMaxReconnectAttempts")}getReconnectInterval(){return yt("wsReconnectInterval")}getWebSocketUrl(n){let i;{const c=window.location.protocol==="https:"?"wss:":"ws:",u=window.location.host;i=`${c}//${u}/ws/logs`}return n?`${i}?token=${encodeURIComponent(n)}`:i}async getWsToken(){try{const n=await _e("/api/webui/ws-token",{method:"GET",credentials:"include"});if(!n.ok)return console.error("获取 WebSocket token 失败:",n.status),null;const i=await n.json();return i.success&&i.token?i.token:null}catch(n){return console.error("获取 WebSocket token 失败:",n),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 ac()){console.log("📡 未登录,跳过 WebSocket 连接");return}const i=await this.getWsToken();if(!i){console.log("📡 无法获取 WebSocket token,跳过连接");return}const c=this.getWebSocketUrl(i);try{this.ws=new WebSocket(c),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=u=>{try{if(u.data==="pong")return;const x=JSON.parse(u.data);this.notifyLog(x)}catch(x){console.error("解析日志消息失败:",x)}},this.ws.onerror=u=>{console.error("❌ WebSocket 错误:",u),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(u){console.error("创建 WebSocket 连接失败:",u),this.attemptReconnect()}}attemptReconnect(){const n=this.getMaxReconnectAttempts();if(this.reconnectAttempts>=n)return;this.reconnectAttempts+=1;const i=this.getReconnectInterval(),c=Math.min(i*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(n){return this.logCallbacks.add(n),()=>this.logCallbacks.delete(n)}onConnectionChange(n){return this.connectionCallbacks.add(n),n(this.isConnected),()=>this.connectionCallbacks.delete(n)}notifyLog(n){if(!this.logCache.some(c=>c.id===n.id)){this.logCache.push(n);const c=this.getMaxCacheSize();this.logCache.length>c&&(this.logCache=this.logCache.slice(-c)),this.logCallbacks.forEach(u=>{try{u(n)}catch(x){console.error("日志回调执行失败:",x)}})}}notifyConnection(n){this.connectionCallbacks.forEach(i=>{try{i(n)}catch(c){console.error("连接状态回调执行失败:",c)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const In=new q1;typeof window<"u"&&setTimeout(()=>{In.connect()},100);const Ns=G0,wt=V0,K1=F0,Nv=d.forwardRef(({className:l,...n},i)=>e.jsx(Jg,{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",l),...n,ref:i}));Nv.displayName=Jg.displayName;const us=d.forwardRef(({className:l,...n},i)=>e.jsxs(K1,{children:[e.jsx(Nv,{}),e.jsx(Xg,{ref:i,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",l),...n})]}));us.displayName=Xg.displayName;const ms=({className:l,...n})=>e.jsx("div",{className:P("flex flex-col space-y-2 text-center sm:text-left",l),...n});ms.displayName="AlertDialogHeader";const xs=({className:l,...n})=>e.jsx("div",{className:P("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",l),...n});xs.displayName="AlertDialogFooter";const hs=d.forwardRef(({className:l,...n},i)=>e.jsx(Zg,{ref:i,className:P("text-lg font-semibold",l),...n}));hs.displayName=Zg.displayName;const fs=d.forwardRef(({className:l,...n},i)=>e.jsx(Wg,{ref:i,className:P("text-sm text-muted-foreground",l),...n}));fs.displayName=Wg.displayName;const ps=d.forwardRef(({className:l,variant:n,...i},c)=>e.jsx(ej,{ref:c,className:P(Kr({variant:n}),l),...i}));ps.displayName=ej.displayName;const gs=d.forwardRef(({className:l,...n},i)=>e.jsx(sj,{ref:i,className:P(Kr({variant:"outline"}),"mt-2 sm:mt-0",l),...n}));gs.displayName=sj.displayName;function Q1(){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(ta,{defaultValue:"appearance",className:"w-full",children:[e.jsxs(Xt,{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(Yw,{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(Rj,{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(pn,{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(Ht,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(Je,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(ws,{value:"appearance",className:"mt-0",children:e.jsx(Y1,{})}),e.jsx(ws,{value:"security",className:"mt-0",children:e.jsx(J1,{})}),e.jsx(ws,{value:"other",className:"mt-0",children:e.jsx(X1,{})}),e.jsx(ws,{value:"about",className:"mt-0",children:e.jsx(Z1,{})})]})]})]})}function bg(l){const n=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%)"}}[l];if(c)n.style.setProperty("--primary",c.hsl),c.gradient?(n.style.setProperty("--primary-gradient",c.gradient),n.classList.add("has-gradient")):(n.style.removeProperty("--primary-gradient"),n.classList.remove("has-gradient"));else if(l.startsWith("#")){const u=x=>{x=x.replace("#","");const h=parseInt(x.substring(0,2),16)/255,f=parseInt(x.substring(2,4),16)/255,p=parseInt(x.substring(4,6),16)/255,g=Math.max(h,f,p),N=Math.min(h,f,p);let v=0,b=0;const w=(g+N)/2;if(g!==N){const y=g-N;switch(b=w>.5?y/(2-g-N):y/(g+N),g){case h:v=((f-p)/y+(f<p?6:0))/6;break;case f:v=((p-h)/y+2)/6;break;case p:v=((h-f)/y+4)/6;break}}return`${Math.round(v*360)} ${Math.round(b*100)}% ${Math.round(w*100)}%`};n.style.setProperty("--primary",u(l)),n.style.removeProperty("--primary-gradient"),n.classList.remove("has-gradient")}}function Y1(){const{theme:l,setTheme:n}=ax(),{enableAnimations:i,setEnableAnimations:c,enableWavesBackground:u,setEnableWavesBackground:x}=jv(),[h,f]=d.useState(()=>localStorage.getItem("accent-color")||"blue");d.useEffect(()=>{const g=localStorage.getItem("accent-color")||"blue";bg(g)},[]);const p=g=>{f(g),localStorage.setItem("accent-color",g),bg(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(Tm,{value:"light",current:l,onChange:n,label:"浅色",description:"始终使用浅色主题"}),e.jsx(Tm,{value:"dark",current:l,onChange:n,label:"深色",description:"始终使用深色主题"}),e.jsx(Tm,{value:"system",current:l,onChange:n,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(Ga,{value:"blue",current:h,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(Ga,{value:"purple",current:h,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(Ga,{value:"green",current:h,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(Ga,{value:"orange",current:h,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(Ga,{value:"pink",current:h,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(Ga,{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(Ga,{value:"gradient-sunset",current:h,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(Ga,{value:"gradient-ocean",current:h,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(Ga,{value:"gradient-forest",current:h,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(Ga,{value:"gradient-aurora",current:h,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(Ga,{value:"gradient-fire",current:h,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(Ga,{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(ae,{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:i,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:u,onCheckedChange:x})]})})]})]})]})}function J1(){const l=ca(),[n,i]=d.useState(""),[c,u]=d.useState(""),[x,h]=d.useState(!1),[f,p]=d.useState(!1),[g,N]=d.useState(!1),[v,b]=d.useState(!1),[w,y]=d.useState(!1),[R,O]=d.useState(!1),[S,B]=d.useState(""),[E,C]=d.useState(!1),{toast:z}=Zs(),H=d.useMemo(()=>U1(c),[c]),L=async re=>{if(!n){z({title:"无法复制",description:"Token 存储在安全 Cookie 中,请重新生成以获取新 Token",variant:"destructive"});return}try{await navigator.clipboard.writeText(re),y(!0),z({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>y(!1),2e3)}catch{z({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},J=async()=>{if(!c.trim()){z({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!H.isValid){const re=H.rules.filter(fe=>!fe.passed).map(fe=>fe.label).join(", ");z({title:"格式错误",description:`Token 不符合要求: ${re}`,variant:"destructive"});return}N(!0);try{const re=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({new_token:c.trim()})}),fe=await re.json();re.ok&&fe.success?(u(""),i(c.trim()),z({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{l({to:"/auth"})},1500)):z({title:"更新失败",description:fe.message||"无法更新 Token",variant:"destructive"})}catch(re){console.error("更新 Token 错误:",re),z({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{N(!1)}},U=async()=>{b(!0);try{const re=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),fe=await re.json();re.ok&&fe.success?(i(fe.token),B(fe.token),O(!0),C(!1),z({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):z({title:"生成失败",description:fe.message||"无法生成新 Token",variant:"destructive"})}catch(re){console.error("生成 Token 错误:",re),z({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{b(!1)}},oe=async()=>{try{await navigator.clipboard.writeText(S),C(!0),z({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{z({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},Ne=()=>{O(!1),setTimeout(()=>{B(""),C(!1)},300),setTimeout(()=>{l({to:"/auth"})},500)},je=re=>{re||Ne()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(Is,{open:R,onOpenChange:je,children:e.jsxs(Os,{className:"sm:max-w-md",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-5 w-5 text-yellow-500"}),"新的 Access Token"]}),e.jsx(Ks,{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(Jt,{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(st,{className:"gap-2 sm:gap-0",children:[e.jsx(_,{variant:"outline",onClick:oe,className:"gap-2",children:E?e.jsxs(e.Fragment,{children:[e.jsx(Ct,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(Uo,{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(ae,{id:"current-token",type:x?"text":"password",value:n||"••••••••••••••••••••••••••••••••",readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"Token 存储在安全 Cookie 中"}),e.jsx("button",{onClick:()=>{n?h(!x):z({title:"无法查看",description:'Token 存储在安全 Cookie 中,如需新 Token 请点击"重新生成"'})},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:x?"隐藏":"显示",children:x?e.jsx(ec,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ia,{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:()=>L(n),title:"复制到剪贴板",className:"flex-shrink-0",disabled:!n,children:w?e.jsx(Ct,{className:"h-4 w-4 text-green-500"}):e.jsx(Uo,{className:"h-4 w-4"})}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",disabled:v,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(dt,{className:P("h-4 w-4",v&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认重新生成 Token"}),e.jsx(fs,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:U,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(ae,{id:"new-token",type:f?"text":"password",value:c,onChange:re=>u(re.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(ec,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ia,{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(re=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[re.passed?e.jsx(pt,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(Va,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:P(re.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:re.label})]},re.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(Ct,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(_,{onClick:J,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 X1(){const l=ca(),{toast:n}=Zs(),[i,c]=d.useState(!1),[u,x]=d.useState(!1),[h,f]=d.useState(()=>yt("logCacheSize")),[p,g]=d.useState(()=>yt("wsReconnectInterval")),[N,v]=d.useState(()=>yt("wsMaxReconnectAttempts")),[b,w]=d.useState(()=>yt("dataSyncInterval")),[y,R]=d.useState(()=>Ng()),[O,S]=d.useState(!1),[B,E]=d.useState(!1),C=d.useRef(null);if(u)throw new Error("这是一个手动触发的测试错误,用于验证错误边界组件是否正常工作。");const z=()=>{R(Ng())},H=M=>{const K=M[0];f(K),Pr("logCacheSize",K)},L=M=>{const K=M[0];g(K),Pr("wsReconnectInterval",K)},J=M=>{const K=M[0];v(K),Pr("wsMaxReconnectAttempts",K)},U=M=>{const K=M[0];w(K),Pr("dataSyncInterval",K)},oe=()=>{In.clearLogs(),n({title:"日志已清除",description:"日志缓存已清空"})},Ne=()=>{const M=G1();z(),n({title:"缓存已清除",description:`已清除 ${M.clearedKeys.length} 项缓存数据`})},je=()=>{S(!0);try{const M=P1(),K=JSON.stringify(M,null,2),I=new Blob([K],{type:"application/json"}),ue=URL.createObjectURL(I),Q=document.createElement("a");Q.href=ue,Q.download=`maibot-webui-settings-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(ue),n({title:"导出成功",description:"设置已导出为 JSON 文件"})}catch(M){console.error("导出设置失败:",M),n({title:"导出失败",description:"无法导出设置",variant:"destructive"})}finally{S(!1)}},re=M=>{const K=M.target.files?.[0];if(!K)return;E(!0);const I=new FileReader;I.onload=ue=>{try{const Q=ue.target?.result,Se=JSON.parse(Q),pe=H1(Se);pe.success?(f(yt("logCacheSize")),g(yt("wsReconnectInterval")),v(yt("wsMaxReconnectAttempts")),w(yt("dataSyncInterval")),z(),n({title:"导入成功",description:`成功导入 ${pe.imported.length} 项设置${pe.skipped.length>0?`,跳过 ${pe.skipped.length} 项`:""}`}),(pe.imported.includes("theme")||pe.imported.includes("accentColor"))&&n({title:"提示",description:"部分设置需要刷新页面才能完全生效"})):n({title:"导入失败",description:"没有有效的设置项可导入",variant:"destructive"})}catch(Q){console.error("导入设置失败:",Q),n({title:"导入失败",description:"文件格式无效",variant:"destructive"})}finally{E(!1),C.current&&(C.current.value="")}},I.readAsText(K)},fe=()=>{F1(),f(cl.logCacheSize),g(cl.wsReconnectInterval),v(cl.wsMaxReconnectAttempts),w(cl.dataSyncInterval),z(),n({title:"已重置",description:"所有设置已恢复为默认值,刷新页面以应用更改"})},ge=async()=>{c(!0);try{const M=await _e("/api/webui/setup/reset",{method:"POST"}),K=await M.json();M.ok&&K.success?(n({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{l({to:"/setup"})},1e3)):n({title:"重置失败",description:K.message||"无法重置配置状态",variant:"destructive"})}catch(M){console.error("重置配置状态错误:",M),n({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(Gr,{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(Jw,{className:"h-4 w-4"}),"本地存储使用"]}),e.jsx(_,{variant:"ghost",size:"sm",onClick:z,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:V1(y.used)}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[y.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(qa,{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(qa,{value:[b],onValueChange:U,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(qa,{value:[p],onValueChange:L,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(qa,{value:[N],onValueChange:J,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:oe,className:"gap-2",children:[e.jsx(ns,{className:"h-4 w-4"}),"清除日志缓存"]}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(ns,{className:"h-4 w-4"}),"清除本地缓存"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认清除本地缓存"}),e.jsx(fs,{children:"这将清除所有本地缓存的设置和数据(不包括登录凭证)。 您可能需要重新配置部分偏好设置。确定要继续吗?"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{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(sa,{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:O,className:"gap-2",children:[e.jsx(sa,{className:"h-4 w-4"}),O?"导出中...":"导出设置"]}),e.jsx("input",{ref:C,type:"file",accept:".json",onChange:re,className:"hidden"}),e.jsxs(_,{variant:"outline",onClick:()=>C.current?.click(),disabled:B,className:"gap-2",children:[e.jsx(sc,{className:"h-4 w-4"}),B?"导入中...":"导入设置"]})]}),e.jsx("div",{className:"pt-2 border-t",children:e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"gap-2 text-destructive hover:text-destructive",children:[e.jsx(Wi,{className:"h-4 w-4"}),"重置所有设置为默认值"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认重置所有设置"}),e.jsx(fs,{children:"这将把所有界面设置恢复为默认值,包括主题、颜色、动画等偏好设置。 此操作不会影响您的登录状态。确定要继续吗?"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:fe,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(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"outline",disabled:i,className:"gap-2",children:[e.jsx(Wi,{className:P("h-4 w-4",i&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认重新配置"}),e.jsx(fs,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:ge,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(Jt,{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(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"destructive",className:"gap-2",children:[e.jsx(Jt,{className:"h-4 w-4"}),"触发测试错误"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认触发错误"}),e.jsx(fs,{children:"这将手动触发一个 React 错误,用于测试错误边界组件的显示效果。 页面将显示错误界面,您可以通过刷新页面或点击返回首页来恢复。"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>x(!0),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认触发"})]})]})]})]})]})]})}function Z1(){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:["关于 ",lx]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",td]}),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(Je,{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(ft,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(ft,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(ft,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(ft,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(ft,{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(ft,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(ft,{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(ft,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(ft,{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(ft,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(ft,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(ft,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(ft,{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(ft,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(ft,{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(ft,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(ft,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(ft,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(ft,{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(ft,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(ft,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(ft,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(ft,{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 ft({name:l,description:n,license:i}){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:l}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:n})]}),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:i})]})}function Tm({value:l,current:n,onChange:i,label:c,description:u}){const x=n===l;return e.jsxs("button",{onClick:()=>i(l),className:P("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-2 right-2 sm:top-3 sm:right-3 h-2 w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm sm:text-base font-medium",children:c}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:u})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[l==="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"})]}),l==="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"})]}),l==="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 Ga({value:l,current:n,onChange:i,label:c,colorClass:u}){const x=n===l;return e.jsxs("button",{onClick:()=>i(l),className:P("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",x?"border-primary bg-accent":"border-border"),children:[x&&e.jsx("div",{className:"absolute top-1.5 right-1.5 sm:top-2 sm:right-2 h-1.5 w-1.5 sm:h-2 sm:w-2 rounded-full bg-primary"}),e.jsxs("div",{className:"flex flex-col items-center gap-1.5 sm:gap-2",children:[e.jsx("div",{className:P("h-8 w-8 sm:h-10 sm:w-10 rounded-full",u)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:c})]})]})}const W1=Date.now()%1e6;class e2{grad3;p;perm;constructor(n=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 i=0;i<256;i++)this.p[i]=Math.floor(Math.random()*256);this.perm=[];for(let i=0;i<512;i++)this.perm[i]=this.p[i&255]}dot(n,i,c){return n[0]*i+n[1]*c}mix(n,i,c){return(1-c)*n+c*i}fade(n){return n*n*n*(n*(n*6-15)+10)}perlin2(n,i){const c=Math.floor(n)&255,u=Math.floor(i)&255;n-=Math.floor(n),i-=Math.floor(i);const x=this.fade(n),h=this.fade(i),f=this.perm[c]+u,p=this.perm[f],g=this.perm[f+1],N=this.perm[c+1]+u,v=this.perm[N],b=this.perm[N+1];return this.mix(this.mix(this.dot(this.grad3[p%12],n,i),this.dot(this.grad3[v%12],n-1,i),x),this.mix(this.dot(this.grad3[g%12],n,i-1),this.dot(this.grad3[b%12],n-1,i-1),x),h)}}function yg(){const l=d.useRef(null),n=d.useRef(null),i=d.useRef(void 0),[c]=d.useState(()=>new e2(W1)),u=d.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 d.useEffect(()=>{const x=n.current,h=l.current;if(!x||!h)return;const f=u.current;f.noise=c;const p=()=>{const O=x.getBoundingClientRect();f.bounding=O,h.style.width=`${O.width}px`,h.style.height=`${O.height}px`},g=()=>{if(!f.bounding)return;const{width:O,height:S}=f.bounding;f.lines=[],f.paths.forEach(oe=>oe.remove()),f.paths=[];const B=10,E=32,C=O+200,z=S+30,H=Math.ceil(C/B),L=Math.ceil(z/E),J=(O-B*H)/2,U=(S-E*L)/2;for(let oe=0;oe<=H;oe++){const Ne=[];for(let re=0;re<=L;re++){const fe={x:J+B*oe,y:U+E*re,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};Ne.push(fe)}const je=document.createElementNS("http://www.w3.org/2000/svg","path");h.appendChild(je),f.paths.push(je),f.lines.push(Ne)}},N=O=>{const{lines:S,mouse:B,noise:E}=f;S.forEach(C=>{C.forEach(z=>{const H=E.perlin2((z.x+O*.0125)*.002,(z.y+O*.005)*.0015)*12;z.wave.x=Math.cos(H)*32,z.wave.y=Math.sin(H)*16;const L=z.x-B.sx,J=z.y-B.sy,U=Math.hypot(L,J),oe=Math.max(175,B.vs);if(U<oe){const Ne=1-U/oe,je=Math.cos(U*.001)*Ne;z.cursor.vx+=Math.cos(B.a)*je*oe*B.vs*65e-5,z.cursor.vy+=Math.sin(B.a)*je*oe*B.vs*65e-5}z.cursor.vx+=(0-z.cursor.x)*.005,z.cursor.vy+=(0-z.cursor.y)*.005,z.cursor.vx*=.925,z.cursor.vy*=.925,z.cursor.x+=z.cursor.vx*2,z.cursor.y+=z.cursor.vy*2,z.cursor.x=Math.min(100,Math.max(-100,z.cursor.x)),z.cursor.y=Math.min(100,Math.max(-100,z.cursor.y))})})},v=(O,S=!0)=>{const B={x:O.x+O.wave.x+(S?O.cursor.x:0),y:O.y+O.wave.y+(S?O.cursor.y:0)};return B.x=Math.round(B.x*10)/10,B.y=Math.round(B.y*10)/10,B},b=()=>{const{lines:O,paths:S}=f;O.forEach((B,E)=>{let C=v(B[0],!1),z=`M ${C.x} ${C.y}`;B.forEach((H,L)=>{const J=L===B.length-1;C=v(H,!J),z+=`L ${C.x} ${C.y}`}),S[E].setAttribute("d",z)})},w=O=>{const{mouse:S}=f;S.sx+=(S.x-S.sx)*.1,S.sy+=(S.y-S.sy)*.1;const B=S.x-S.lx,E=S.y-S.ly,C=Math.hypot(B,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,B),x&&(x.style.setProperty("--x",`${S.sx}px`),x.style.setProperty("--y",`${S.sy}px`)),N(O),b(),i.current=requestAnimationFrame(w)},y=O=>{if(!f.bounding)return;const{mouse:S}=f;S.x=O.pageX-f.bounding.left,S.y=O.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)},R=()=>{p(),g()};return p(),g(),window.addEventListener("resize",R),window.addEventListener("mousemove",y),i.current=requestAnimationFrame(w),()=>{window.removeEventListener("resize",R),window.removeEventListener("mousemove",y),i.current&&cancelAnimationFrame(i.current)}},[c]),e.jsxs("div",{ref:n,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:l,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 s2(){const[l,n]=d.useState(""),[i,c]=d.useState(!1),[u,x]=d.useState(""),[h,f]=d.useState(!0),p=ca(),{enableWavesBackground:g,setEnableWavesBackground:N}=jv(),{theme:v,setTheme:b}=ax();d.useEffect(()=>{(async()=>{try{await ac()&&p({to:"/"})}catch{}finally{f(!1)}})()},[p]);const y=v==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":v,R=()=>{b(y==="dark"?"light":"dark")},O=async S=>{if(S.preventDefault(),x(""),!l.trim()){x("请输入 Access Token");return}c(!0),console.log("开始验证 token...");try{const B=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({token:l.trim()})});console.log("Token 验证响应状态:",B.status);const E=await B.json();if(console.log("Token 验证响应数据:",E),B.ok&&E.valid){console.log("Token 验证成功,准备跳转..."),console.log("is_first_setup:",E.is_first_setup),await new Promise(z=>setTimeout(z,100));const C=await ac();console.log("跳转前认证状态检查:",C),E.is_first_setup?(console.log("跳转到首次配置页面"),p({to:"/setup"})):(console.log("跳转到首页"),p({to:"/"}))}else console.error("Token 验证失败:",E.message),x(E.message||"Token 验证失败,请检查后重试")}catch(B){console.error("Token 验证错误:",B),x("连接服务器失败,请检查网络连接")}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(yg,{}),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(yg,{}),e.jsxs(Ce,{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:R,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:y==="dark"?"切换到浅色模式":"切换到深色模式",children:y==="dark"?e.jsx(Km,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(Yi,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(De,{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(og,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(os,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(Me,{children:e.jsxs("form",{onSubmit:O,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(Qm,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground",strokeWidth:2,fill:"none"}),e.jsx(ae,{id:"token",type:"password",placeholder:"请输入您的 Access Token",value:l,onChange:S=>n(S.target.value),className:P("pl-10",u&&"border-red-500 focus-visible:ring-red-500"),disabled:i,autoFocus:!0,autoComplete:"off"})]})]}),u&&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(_t,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:u})]}),e.jsx(_,{type:"submit",className:"w-full",disabled:i,children:i?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(Is,{children:[e.jsx(sd,{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(Lj,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token,我该去哪里获得 Token?"]})}),e.jsxs(Os,{className:"sm:max-w-md",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(og,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"如何获取 Access Token"]}),e.jsx(Ks,{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(Xw,{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(Ca,{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(_t,{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(Ns,{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(Za,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsxs(hs,{className:"flex items-center gap-2",children:[e.jsx(Za,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(fs,{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(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{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:$1})})]})}const ot=d.forwardRef(({className:l,...n},i)=>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),ref:i,...n}));ot.displayName="Textarea";const Yt=d.forwardRef(({className:l,orientation:n="horizontal",decorative:i=!0,...c},u)=>e.jsx(tj,{ref:u,decorative:i,orientation:n,className:P("shrink-0 bg-border",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",l),...c}));Yt.displayName=tj.displayName;function t2({config:l,onChange:n}){const i=u=>{u.trim()&&!l.alias_names.includes(u.trim())&&n({...l,alias_names:[...l.alias_names,u.trim()]})},c=u=>{n({...l,alias_names:l.alias_names.filter((x,h)=>h!==u)})};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(ae,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:l.qq_account||"",onChange:u=>n({...l,qq_account:Number(u.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(ae,{id:"nickname",placeholder:"请输入机器人的昵称",value:l.nickname,onChange:u=>n({...l,nickname:u.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:l.alias_names.map((u,x)=>e.jsxs(ke,{variant:"secondary",className:"gap-1",children:[u,e.jsx("button",{type:"button",onClick:()=>c(x),className:"ml-1 hover:text-destructive",children:e.jsx(Ea,{className:"h-3 w-3"})})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:u=>{u.key==="Enter"&&(i(u.target.value),u.target.value="")}}),e.jsx(_,{type:"button",variant:"outline",onClick:()=>{const u=document.getElementById("alias_input");u&&(i(u.value),u.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function a2({config:l,onChange:n}){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(ot,{id:"personality",placeholder:"描述机器人的人格特质和身份特征(建议120字以内)",value:l.personality,onChange:i=>n({...l,personality:i.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(ot,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:l.reply_style,onChange:i=>n({...l,reply_style:i.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(ot,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:l.interest,onChange:i=>n({...l,interest:i.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(ot,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:l.plan_style,onChange:i=>n({...l,plan_style:i.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(ot,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:l.private_plan_style,onChange:i=>n({...l,private_plan_style:i.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function l2({config:l,onChange:n}){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:[(l.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(ae,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:l.emoji_chance,onChange:i=>n({...l,emoji_chance:Number(i.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(ae,{id:"max_reg_num",type:"number",min:"1",max:"200",value:l.max_reg_num,onChange:i=>n({...l,max_reg_num:Number(i.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:l.do_replace,onCheckedChange:i=>n({...l,do_replace:i})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(ae,{id:"check_interval",type:"number",min:"1",max:"120",value:l.check_interval,onChange:i=>n({...l,check_interval:Number(i.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(Yt,{}),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:l.steal_emoji,onCheckedChange:i=>n({...l,steal_emoji:i})})]}),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:l.content_filtration,onCheckedChange:i=>n({...l,content_filtration:i})})]}),l.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(T,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(ae,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:l.filtration_prompt,onChange:i=>n({...l,filtration_prompt:i.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function n2({config:l,onChange:n}){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:l.enable_tool,onCheckedChange:i=>n({...l,enable_tool:i})})]}),e.jsx(Yt,{}),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:l.all_global,onCheckedChange:i=>n({...l,all_global:i})})]})]})}function r2({config:l,onChange:n}){const[i,c]=d.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(Oo,{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(ae,{id:"siliconflow_api_key",type:i?"text":"password",placeholder:"sk-...",value:l.api_key,onChange:u=>n({api_key:u.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(!i),children:i?e.jsx(ec,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ia,{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 i2(){const l=await _e("/api/webui/config/bot",{method:"GET",headers:Fs()});if(!l.ok)throw new Error("读取Bot配置失败");const i=(await l.json()).config.bot||{};return{qq_account:i.qq_account||0,nickname:i.nickname||"",alias_names:i.alias_names||[]}}async function c2(){const l=await _e("/api/webui/config/bot",{method:"GET",headers:Fs()});if(!l.ok)throw new Error("读取人格配置失败");const i=(await l.json()).config.personality||{};return{personality:i.personality||"",reply_style:i.reply_style||"",interest:i.interest||"",plan_style:i.plan_style||"",private_plan_style:i.private_plan_style||""}}async function o2(){const l=await _e("/api/webui/config/bot",{method:"GET",headers:Fs()});if(!l.ok)throw new Error("读取表情包配置失败");const i=(await l.json()).config.emoji||{};return{emoji_chance:i.emoji_chance??.4,max_reg_num:i.max_reg_num??40,do_replace:i.do_replace??!0,check_interval:i.check_interval??10,steal_emoji:i.steal_emoji??!0,content_filtration:i.content_filtration??!1,filtration_prompt:i.filtration_prompt||""}}async function d2(){const l=await _e("/api/webui/config/bot",{method:"GET",headers:Fs()});if(!l.ok)throw new Error("读取其他配置失败");const i=(await l.json()).config,c=i.tool||{},u=i.expression||{};return{enable_tool:c.enable_tool??!0,all_global:u.all_global_jargon??!0}}async function u2(){const l=await _e("/api/webui/config/model",{method:"GET",headers:Fs()});if(!l.ok)throw new Error("读取模型配置失败");return{api_key:((await l.json()).config.api_providers||[]).find(x=>x.name==="SiliconFlow")?.api_key||""}}async function m2(l){const n=await _e("/api/webui/config/bot/section/bot",{method:"POST",headers:Fs(),body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"保存Bot基础配置失败")}return await n.json()}async function x2(l){const n=await _e("/api/webui/config/bot/section/personality",{method:"POST",headers:Fs(),body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"保存人格配置失败")}return await n.json()}async function h2(l){const n=await _e("/api/webui/config/bot/section/emoji",{method:"POST",headers:Fs(),body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"保存表情包配置失败")}return await n.json()}async function f2(l){const n=[];n.push(_e("/api/webui/config/bot/section/tool",{method:"POST",headers:Fs(),body:JSON.stringify({enable_tool:l.enable_tool})})),n.push(_e("/api/webui/config/bot/section/expression",{method:"POST",headers:Fs(),body:JSON.stringify({all_global_jargon:l.all_global})}));const i=await Promise.all(n);for(const c of i)if(!c.ok){const u=await c.json();throw new Error(u.detail||"保存其他配置失败")}return{success:!0}}async function p2(l){const n=await _e("/api/webui/config/model",{method:"GET",headers:Fs()});if(!n.ok)throw new Error("读取模型配置失败");const c=(await n.json()).config,u=c.api_providers||[],x=u.findIndex(p=>p.name==="SiliconFlow");x>=0?u[x]={...u[x],api_key:l.api_key}:u.push({name:"SiliconFlow",base_url:"https://api.siliconflow.cn/v1",api_key:l.api_key,client_type:"openai",max_retry:3,timeout:120,retry_interval:5});const h={...c,api_providers:u},f=await _e("/api/webui/config/model",{method:"POST",headers:Fs(),body:JSON.stringify(h)});if(!f.ok){const p=await f.json();throw new Error(p.detail||"保存模型配置失败")}return await f.json()}async function wg(){const l=await _e("/api/webui/setup/complete",{method:"POST"});if(!l.ok){const n=await l.json();throw new Error(n.message||"标记配置完成失败")}return await l.json()}function g2(){return e.jsx(Jn,{children:e.jsx(j2,{})})}function j2(){const l=ca(),{toast:n}=Zs(),{triggerRestart:i}=vn(),[c,u]=d.useState(0),[x,h]=d.useState(!1),[f,p]=d.useState(!1),[g,N]=d.useState(!0),[v,b]=d.useState({qq_account:0,nickname:"",alias_names:[]}),[w,y]=d.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
|
||
2.如果相同的内容已经被执行,请不要重复执行
|
||
3.请控制你的发言频率,不要太过频繁的发言
|
||
4.如果有人对你感到厌烦,请减少回复
|
||
5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
|
||
2.如果相同的内容已经被执行,请不要重复执行
|
||
3.某句话如果已经被回复过,不要重复回复`}),[R,O]=d.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[S,B]=d.useState({enable_tool:!0,all_global:!0}),[E,C]=d.useState({api_key:""}),z=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:Pn},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:fn},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:Xo},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:pn},{id:"siliconflow",title:"API配置",description:"配置硅基流动API密钥",icon:Qm}],H=(c+1)/z.length*100;d.useEffect(()=>{(async()=>{try{N(!0);const[fe,ge,M,K,I]=await Promise.all([i2(),c2(),o2(),d2(),u2()]);b(fe),y(ge),O(M),B(K),C(I)}catch(fe){n({title:"加载配置失败",description:fe instanceof Error?fe.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{N(!1)}})()},[n]);const L=async()=>{p(!0);try{switch(c){case 0:await m2(v);break;case 1:await x2(w);break;case 2:await h2(R);break;case 3:await f2(S);break;case 4:await p2(E);break}return n({title:"保存成功",description:`${z[c].title}配置已保存`}),!0}catch(re){return n({title:"保存失败",description:re instanceof Error?re.message:"未知错误",variant:"destructive"}),!1}finally{p(!1)}},J=async()=>{await L()&&c<z.length-1&&u(c+1)},U=()=>{c>0&&u(c-1)},oe=async()=>{h(!0);try{if(!await L()){h(!1);return}await wg(),n({title:"配置完成",description:"麦麦正在重启以应用新配置..."}),await i()}catch(re){n({title:"配置失败",description:re instanceof Error?re.message:"未知错误",variant:"destructive"})}finally{h(!1)}},Ne=async()=>{try{await wg(),l({to:"/"})}catch(re){n({title:"跳过失败",description:re instanceof Error?re.message:"未知错误",variant:"destructive"})}},je=()=>{switch(c){case 0:return e.jsx(t2,{config:v,onChange:b});case 1:return e.jsx(a2,{config:w,onChange:y});case 2:return e.jsx(l2,{config:R,onChange:O});case 3:return e.jsx(n2,{config:S,onChange:B});case 4:return e.jsx(r2,{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(Xn,{}),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(Zw,{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:["让我们一起完成 ",lx," 的初始配置"]})]}),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," / ",z.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(H),"%"]})]}),e.jsx(Qn,{value:H,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:z.map((re,fe)=>{const ge=re.icon;return e.jsxs("div",{className:P("flex flex-1 flex-col items-center gap-1 md:gap-2",fe<z.length-1&&"relative"),children:[fe<z.length-1&&e.jsx("div",{className:P("absolute left-1/2 top-3 md:top-4 h-0.5 w-full",fe<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",fe===c||fe<c?"border-primary bg-primary text-primary-foreground":"border-border bg-background text-muted-foreground"),children:fe<c?e.jsx(pt,{className:"h-3 w-3 md:h-4 md:w-4",strokeWidth:2.5,fill:"none"}):e.jsx(ge,{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",fe===c?"font-medium text-foreground":"text-muted-foreground"),title:re.title,children:re.title})]},re.id)})}),e.jsx(Ce,{className:"mb-6 md:mb-8 shadow-lg",children:e.jsx(Me,{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:z[c].title}),e.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:z[c].description})]}),e.jsx(Je,{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:U,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(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{variant:"ghost",className:"flex-1 sm:flex-none gap-2",disabled:f||x,children:[e.jsx(Ww,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"跳过向导"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认跳过配置向导"}),e.jsx(fs,{children:"您可以随时在系统设置中重新进入配置向导。确定要跳过吗?"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:Ne,children:"确认跳过"})]})]})]}),c===z.length-1?e.jsx(_,{onClick:oe,disabled:x||f,className:"flex-1 sm:flex-none",children:x||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(pt,{className:"ml-2 h-4 w-4",strokeWidth:2,fill:"none"})]})}):e.jsx(_,{onClick:J,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(e_,{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 bv(){const l=ca();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(Tt,{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:()=>l({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(Zo,{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(Ta,{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 v2=As.memo(function({config:n,onChange:i}){const c=n.platforms||[],u=n.alias_names||[],x=()=>{i({...n,platforms:[...c,""]})},h=v=>{i({...n,platforms:c.filter((b,w)=>w!==v)})},f=(v,b)=>{const w=[...c];w[v]=b,i({...n,platforms:w})},p=()=>{i({...n,alias_names:[...u,""]})},g=v=>{i({...n,alias_names:u.filter((b,w)=>w!==v)})},N=(v,b)=>{const w=[...u];w[v]=b,i({...n,alias_names:w})};return e.jsx("div",{className:"rounded-lg border bg-card p-4 sm:p-6 space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"基本信息"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"platform",children:"平台"}),e.jsx(ae,{id:"platform",value:n.platform,onChange:v=>i({...n,platform:v.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(ae,{id:"qq_account",value:n.qq_account,onChange:v=>i({...n,qq_account:v.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"nickname",children:"昵称"}),e.jsx(ae,{id:"nickname",value:n.nickname,onChange:v=>i({...n,nickname:v.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(et,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[u.map((v,b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{value:v,onChange:w=>N(b,w.target.value),placeholder:"小麦"}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除别名 "',v||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>g(b),children:"删除"})]})]})]})]},b)),u.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:x,size:"sm",variant:"outline",children:[e.jsx(et,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[c.map((v,b)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{value:v,onChange:w=>f(b,w.target.value),placeholder:"wx:114514"}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除平台账号 "',v||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>h(b),children:"删除"})]})]})]})]},b)),c.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无其他平台账号"})]})]})]})]})})}),N2=As.memo(function({config:n,onChange:i}){const c=()=>{i({...n,states:[...n.states,""]})},u=h=>{i({...n,states:n.states.filter((f,p)=>p!==h)})},x=(h,f)=>{const p=[...n.states];p[h]=f,i({...n,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(ot,{id:"personality",value:n.personality,onChange:h=>i({...n,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(et,{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:n.states.map((h,f)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ot,{value:h,onChange:p=>x(f,p.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsx(fs,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>u(f),children:"删除"})]})]})]})]},f))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"state_probability",children:"替换为多重人格概率"}),e.jsx(ae,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:n.state_probability,onChange:h=>i({...n,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(ot,{id:"reply_style",value:n.reply_style,onChange:h=>i({...n,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(ot,{id:"plan_style",value:n.plan_style,onChange:h=>i({...n,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(ot,{id:"visual_style",value:n.visual_style,onChange:h=>i({...n,visual_style:h.target.value}),placeholder:"识图时的处理规则",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"private_plan_style",children:"私聊规则"}),e.jsx(ot,{id:"private_plan_style",value:n.private_plan_style,onChange:h=>i({...n,private_plan_style:h.target.value}),placeholder:"私聊的说话规则和行为风格",rows:4})]})]})]})})}),ol=K0,dl=Q0,Wa=d.forwardRef(({className:l,align:n="center",sideOffset:i=4,...c},u)=>e.jsx(q0,{children:e.jsx(aj,{ref:u,align:n,sideOffset:i,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]",l),...c})}));Wa.displayName=aj.displayName;const b2=As.memo(function({value:n,onChange:i}){const c=d.useMemo(()=>{const w=n.split("-");if(w.length===2){const[y,R]=w,[O,S]=y.split(":"),[B,E]=R.split(":");return{startHour:O?O.padStart(2,"0"):"00",startMinute:S?S.padStart(2,"0"):"00",endHour:B?B.padStart(2,"0"):"23",endMinute:E?E.padStart(2,"0"):"59"}}return{startHour:"00",startMinute:"00",endHour:"23",endMinute:"59"}},[n]),[u,x]=d.useState(c.startHour),[h,f]=d.useState(c.startMinute),[p,g]=d.useState(c.endHour),[N,v]=d.useState(c.endMinute);d.useEffect(()=>{x(c.startHour),f(c.startMinute),g(c.endHour),v(c.endMinute)},[c]);const b=(w,y,R,O)=>{const S=`${w}:${y}-${R}:${O}`;i(S)};return e.jsxs(ol,{children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(na,{className:"h-4 w-4 mr-2"}),n||"选择时间段"]})}),e.jsx(Wa,{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(Ie,{value:u,onValueChange:w=>{x(w),b(w,h,p,N)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:Array.from({length:24},(w,y)=>y).map(w=>e.jsx(Z,{value:w.toString().padStart(2,"0"),children:w.toString().padStart(2,"0")},w))})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs",children:"分钟"}),e.jsxs(Ie,{value:h,onValueChange:w=>{f(w),b(u,w,p,N)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:Array.from({length:60},(w,y)=>y).map(w=>e.jsx(Z,{value:w.toString().padStart(2,"0"),children:w.toString().padStart(2,"0")},w))})]})]})]})]}),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(Ie,{value:p,onValueChange:w=>{g(w),b(u,h,w,N)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:Array.from({length:24},(w,y)=>y).map(w=>e.jsx(Z,{value:w.toString().padStart(2,"0"),children:w.toString().padStart(2,"0")},w))})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-xs",children:"分钟"}),e.jsxs(Ie,{value:N,onValueChange:w=>{v(w),b(u,h,p,w)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:Array.from({length:60},(w,y)=>y).map(w=>e.jsx(Z,{value:w.toString().padStart(2,"0"),children:w.toString().padStart(2,"0")},w))})]})]})]})]})]})})]})}),y2=As.memo(function({rule:n}){const i=`{ target = "${n.target}", time = "${n.time}", value = ${n.value.toFixed(1)} }`;return e.jsxs(ol,{children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Wa,{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:i}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})}),w2=As.memo(function({config:n,onChange:i}){const c=()=>{i({...n,talk_value_rules:[...n.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},u=h=>{i({...n,talk_value_rules:n.talk_value_rules.filter((f,p)=>p!==h)})},x=(h,f,p)=>{const g=[...n.talk_value_rules];g[h]={...g[h],[f]:p},i({...n,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(ae,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:n.talk_value,onChange:h=>i({...n,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(Ie,{value:n.think_mode||"classic",onValueChange:h=>i({...n,think_mode:h}),children:[e.jsx($e,{id:"think_mode",children:e.jsx(Pe,{placeholder:"选择思考模式"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"classic",children:"经典模式 - 浅度思考和回复"}),e.jsx(Z,{value:"deep",children:"深度模式 - 进行深度思考和回复"}),e.jsx(Z,{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:n.mentioned_bot_reply,onCheckedChange:h=>i({...n,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(ae,{id:"max_context_size",type:"number",min:"1",value:n.max_context_size,onChange:h=>i({...n,max_context_size:parseInt(h.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(ae,{id:"planner_smooth",type:"number",step:"1",min:"0",value:n.planner_smooth,onChange:h=>i({...n,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(ae,{id:"plan_reply_log_max_per_chat",type:"number",step:"1",min:"100",value:n.plan_reply_log_max_per_chat??1024,onChange:h=>i({...n,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:n.llm_quote??!1,onCheckedChange:h=>i({...n,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:n.enable_talk_value_rules,onCheckedChange:h=>i({...n,enable_talk_value_rules:h})}),e.jsx(T,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]})]})]}),n.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(et,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),n.talk_value_rules&&n.talk_value_rules.length>0?e.jsx("div",{className:"space-y-4",children:n.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(y2,{rule:h}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{variant:"ghost",size:"sm",children:e.jsx(ns,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除规则 #",f+1," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>u(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(Ie,{value:h.target===""?"global":"specific",onValueChange:p=>{p==="global"?x(f,"target",""):x(f,"target","qq::group")},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"global",children:"全局配置"}),e.jsx(Z,{value:"specific",children:"详细配置"})]})]})]}),h.target!==""&&(()=>{const p=h.target.split(":"),g=p[0]||"qq",N=p[1]||"",v=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(Ie,{value:g,onValueChange:b=>{x(f,"target",`${b}:${N}:${v}`)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"qq",children:"QQ"}),e.jsx(Z,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ae,{value:N,onChange:b=>{x(f,"target",`${g}:${b.target.value}:${v}`)},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(Ie,{value:v,onValueChange:b=>{x(f,"target",`${g}:${N}:${b}`)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"group",children:"群组(group)"}),e.jsx(Z,{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(b2,{value:h.time,onChange:p=>x(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(ae,{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)||x(f,"value",Math.max(.01,Math.min(1,g)))},className:"w-20 h-8 text-xs"})]}),e.jsx(qa,{value:[h.value],onValueChange:p=>x(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 表示正常发言"]})]})]})]})]})}),_2=As.memo(function({config:n,onChange:i}){const c=S=>{if(!S||!S.includes(":"))return{platform:"qq",userId:""};const[B,E]=S.split(":");return{platform:B,userId:E}},{platform:u,userId:x}=c(n.dream_send),[h,f]=d.useState(u),[p,g]=d.useState(x),N=S=>{const[B,E]=S.split("-");return{startTime:B||"09:00",endTime:E||"22:00"}},v=(S,B)=>{const E=B?`${S}:${B}`:"";i({...n,dream_send:E})},b=S=>{f(S),v(S,p)},w=S=>{g(S),v(h,S)},y=()=>{i({...n,dream_time_ranges:[...n.dream_time_ranges,"09:00-22:00"]})},R=S=>{i({...n,dream_time_ranges:n.dream_time_ranges.filter((B,E)=>E!==S)})},O=(S,B,E)=>{const C=[...n.dream_time_ranges],z=N(C[S]);B==="startTime"?z.startTime=E:z.endTime=E,C[S]=`${z.startTime}-${z.endTime}`,i({...n,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(ae,{id:"interval_minutes",type:"number",min:"1",value:n.interval_minutes,onChange:S=>i({...n,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(ae,{id:"max_iterations",type:"number",min:"1",value:n.max_iterations,onChange:S=>i({...n,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(ae,{id:"first_delay_seconds",type:"number",min:"0",value:n.first_delay_seconds,onChange:S=>i({...n,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(Ie,{value:h,onValueChange:b,children:[e.jsx($e,{className:"w-[120px]",children:e.jsx(Pe,{placeholder:"选择平台"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"qq",children:"QQ"}),e.jsx(Z,{value:"wx",children:"微信"}),e.jsx(Z,{value:"webui",children:"WebUI"})]})]}),e.jsx(ae,{type:"text",placeholder:"输入用户ID (例如: 123456)",value:p,onChange:S=>w(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:y,children:"添加时间段"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置允许做梦的时间段,支持跨夜区间(如 23:00 到次日 02:00)。列表为空则全天允许做梦"}),e.jsxs("div",{className:"space-y-2",children:[n.dream_time_ranges.map((S,B)=>{const{startTime:E,endTime:C}=N(S);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{type:"time",value:E,onChange:z=>O(B,"startTime",z.target.value),className:"w-[140px]"}),e.jsx("span",{className:"text-muted-foreground",children:"至"}),e.jsx(ae,{type:"time",value:C,onChange:z=>O(B,"endTime",z.target.value),className:"w-[140px]"}),e.jsx(_,{type:"button",variant:"ghost",size:"icon",onClick:()=>R(B),children:e.jsx(Ea,{className:"h-4 w-4"})})]},B)}),n.dream_time_ranges.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"当前配置为全天允许做梦"})]})]})]})}),S2=As.memo(function({config:n,onChange:i}){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:n.enable,onCheckedChange:c=>i({...n,enable:c})}),e.jsx(T,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),n.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"LPMM 模式"}),e.jsxs(Ie,{value:n.lpmm_mode,onValueChange:c=>i({...n,lpmm_mode:c}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择 LPMM 模式"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"classic",children:"经典模式"}),e.jsx(Z,{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(ae,{type:"number",min:"1",value:n.rag_synonym_search_top_k,onChange:c=>i({...n,rag_synonym_search_top_k:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"同义词阈值"}),e.jsx(ae,{type:"number",step:"0.1",min:"0",max:"1",value:n.rag_synonym_threshold,onChange:c=>i({...n,rag_synonym_threshold:parseFloat(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"实体提取线程数"}),e.jsx(ae,{type:"number",min:"1",value:n.info_extraction_workers,onChange:c=>i({...n,info_extraction_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"嵌入向量维度"}),e.jsx(ae,{type:"number",min:"1",value:n.embedding_dimension,onChange:c=>i({...n,embedding_dimension:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"嵌入并发线程数"}),e.jsx(ae,{type:"number",min:"1",value:n.max_embedding_workers,onChange:c=>i({...n,max_embedding_workers:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"每批嵌入条数"}),e.jsx(ae,{type:"number",min:"1",value:n.embedding_chunk_size,onChange:c=>i({...n,embedding_chunk_size:parseInt(c.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"同义实体数上限"}),e.jsx(ae,{type:"number",min:"1",value:n.max_synonym_entities,onChange:c=>i({...n,max_synonym_entities:parseInt(c.target.value)})})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:n.enable_ppr,onCheckedChange:c=>i({...n,enable_ppr:c})}),e.jsx(T,{className:"cursor-pointer",children:"启用 PPR (低配机器可关闭)"})]})]})]})]})}),k2=As.memo(function({config:n,onChange:i}){const[c,u]=d.useState(""),[x,h]=d.useState("WARNING"),f=()=>{c&&!n.suppress_libraries.includes(c)&&(i({...n,suppress_libraries:[...n.suppress_libraries,c]}),u(""))},p=y=>{i({...n,suppress_libraries:n.suppress_libraries.filter(R=>R!==y)})},g=()=>{c&&!n.library_log_levels[c]&&(i({...n,library_log_levels:{...n.library_log_levels,[c]:x}}),u(""),h("WARNING"))},N=y=>{const R={...n.library_log_levels};delete R[y],i({...n,library_log_levels:R})},v=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],b=["FULL","compact","lite"],w=["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(ae,{value:n.date_style,onChange:y=>i({...n,date_style:y.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(Ie,{value:n.log_level_style,onValueChange:y=>i({...n,log_level_style:y}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:b.map(y=>e.jsx(Z,{value:y,children:y},y))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"日志文本颜色"}),e.jsxs(Ie,{value:n.color_text,onValueChange:y=>i({...n,color_text:y}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:w.map(y=>e.jsx(Z,{value:y,children:y},y))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"全局日志级别"}),e.jsxs(Ie,{value:n.log_level,onValueChange:y=>i({...n,log_level:y}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:v.map(y=>e.jsx(Z,{value:y,children:y},y))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"控制台日志级别"}),e.jsxs(Ie,{value:n.console_log_level,onValueChange:y=>i({...n,console_log_level:y}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:v.map(y=>e.jsx(Z,{value:y,children:y},y))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"文件日志级别"}),e.jsxs(Ie,{value:n.file_log_level,onValueChange:y=>i({...n,file_log_level:y}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsx(Be,{children:v.map(y=>e.jsx(Z,{value:y,children:y},y))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ae,{value:c,onChange:y=>u(y.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),f())}}),e.jsx(_,{onClick:f,size:"sm",className:"flex-shrink-0",children:e.jsx(et,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.suppress_libraries.map(y=>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:y}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>p(y),children:e.jsx(ns,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},y))})]}),e.jsxs("div",{children:[e.jsx(T,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(ae,{value:c,onChange:y=>u(y.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs(Ie,{value:x,onValueChange:h,children:[e.jsx($e,{className:"w-32",children:e.jsx(Pe,{})}),e.jsx(Be,{children:v.map(y=>e.jsx(Z,{value:y,children:y},y))})]}),e.jsx(_,{onClick:g,size:"sm",children:e.jsx(et,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.library_log_levels).map(([y,R])=>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:y}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:R}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>N(y),children:e.jsx(ns,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},y))})]})]})}),C2=As.memo(function({config:n,onChange:i}){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:n.show_prompt,onCheckedChange:c=>i({...n,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:n.show_replyer_prompt,onCheckedChange:c=>i({...n,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:n.show_replyer_reasoning,onCheckedChange:c=>i({...n,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:n.show_jargon_prompt,onCheckedChange:c=>i({...n,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:n.show_memory_prompt,onCheckedChange:c=>i({...n,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:n.show_planner_prompt,onCheckedChange:c=>i({...n,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:n.show_lpmm_paragraph,onCheckedChange:c=>i({...n,show_lpmm_paragraph:c})})]})]})]})}),T2=As.memo(function({config:n,onChange:i}){const[c,u]=d.useState(""),[x,h]=d.useState(""),f=()=>{c&&!n.auth_token.includes(c)&&(i({...n,auth_token:[...n.auth_token,c]}),u(""))},p=v=>{i({...n,auth_token:n.auth_token.filter((b,w)=>w!==v)})},g=()=>{x&&!n.api_server_allowed_api_keys.includes(x)&&(i({...n,api_server_allowed_api_keys:[...n.api_server_allowed_api_keys,x]}),h(""))},N=v=>{i({...n,api_server_allowed_api_keys:n.api_server_allowed_api_keys.filter((b,w)=>w!==v)})};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(ae,{value:c,onChange:v=>u(v.target.value),placeholder:"输入认证令牌",onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),f())}}),e.jsx(_,{onClick:f,size:"sm",children:e.jsx(et,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:n.auth_token.map((v,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:v}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>p(b),children:e.jsx(ns,{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:n.enable_api_server,onCheckedChange:v=>i({...n,enable_api_server:v})})]}),n.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(ae,{value:n.api_server_host,onChange:v=>i({...n,api_server_host:v.target.value}),placeholder:"0.0.0.0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"端口号"}),e.jsx(ae,{type:"number",value:n.api_server_port,onChange:v=>i({...n,api_server_port:parseInt(v.target.value)}),placeholder:"8090"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{checked:n.api_server_use_wss,onCheckedChange:v=>i({...n,api_server_use_wss:v})}),e.jsx(T,{children:"启用 WSS 安全连接"})]}),n.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(ae,{value:n.api_server_cert_file,onChange:v=>i({...n,api_server_cert_file:v.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"SSL 密钥文件路径"}),e.jsx(ae,{value:n.api_server_key_file,onChange:v=>i({...n,api_server_key_file:v.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(ae,{value:x,onChange:v=>h(v.target.value),placeholder:"输入 API Key",onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),g())}}),e.jsx(_,{onClick:g,size:"sm",children:e.jsx(et,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:n.api_server_allowed_api_keys.map((v,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:v}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>N(b),children:e.jsx(ns,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},b))})]})]})]})]})]})}),E2=As.memo(function({config:n,onChange:i}){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:n.enable,onCheckedChange:c=>i({...n,enable:c})})]})]})}),M2=As.memo(function({emojiConfig:n,memoryConfig:i,toolConfig:c,voiceConfig:u,onEmojiChange:x,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:u.enable_asr,onCheckedChange:g=>p({...u,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(ae,{id:"max_agent_iterations",type:"number",min:"1",value:i.max_agent_iterations,onChange:g=>h({...i,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(ae,{id:"agent_timeout_seconds",type:"number",min:"1",step:"0.1",value:i.agent_timeout_seconds??120,onChange:g=>h({...i,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:i.enable_jargon_detection??!0,onCheckedChange:g=>h({...i,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:i.global_memory??!1,onCheckedChange:g=>h({...i,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(ae,{id:"emoji_chance",type:"number",step:"0.1",min:"0",max:"1",value:n.emoji_chance,onChange:g=>x({...n,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(ae,{id:"max_reg_num",type:"number",min:"1",value:n.max_reg_num,onChange:g=>x({...n,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(ae,{id:"check_interval",type:"number",min:"1",value:n.check_interval,onChange:g=>x({...n,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:n.do_replace,onCheckedChange:g=>x({...n,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:n.steal_emoji,onCheckedChange:g=>x({...n,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:n.content_filtration,onCheckedChange:g=>x({...n,content_filtration:g})}),e.jsx(T,{htmlFor:"content_filtration",className:"cursor-pointer",children:"启用表情包过滤"})]}),n.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(ae,{id:"filtration_prompt",value:n.filtration_prompt,onChange:g=>x({...n,filtration_prompt:g.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}),z2=As.memo(function({member:n,groupIndex:i,memberIndex:c,availableChatIds:u,onUpdate:x,onRemove:h}){const f=u.includes(n)||n==="*",[p,g]=d.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(ae,{value:n,onChange:N=>x(i,c,N.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),u.length>0&&e.jsx(_,{size:"sm",variant:"outline",onClick:()=>g(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{value:n,onValueChange:N=>x(i,c,N),children:[e.jsx($e,{className:"flex-1",children:e.jsx(Pe,{placeholder:"选择聊天流"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"*",children:"* (全局共享)"}),u.map((N,v)=>e.jsx(Z,{value:N,children:N},v))]})]}),e.jsx(_,{size:"sm",variant:"outline",onClick:()=>g(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除组成员 "',n||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>h(i,c),children:"删除"})]})]})]})]})}),A2=As.memo(function({config:n,onChange:i}){const c=()=>{i({...n,learning_list:[...n.learning_list,["","enable","enable","1.0"]]})},u=b=>{i({...n,learning_list:n.learning_list.filter((w,y)=>y!==b)})},x=(b,w,y)=>{const R=[...n.learning_list];R[b][w]=y,i({...n,learning_list:R})},h=({rule:b})=>{const w=`["${b[0]}", "${b[1]}", "${b[2]}", "${b[3]}"]`;return e.jsxs(ol,{children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Wa,{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:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},f=()=>{i({...n,expression_groups:[...n.expression_groups,[]]})},p=b=>{i({...n,expression_groups:n.expression_groups.filter((w,y)=>y!==b)})},g=b=>{const w=[...n.expression_groups];w[b]=[...w[b],""],i({...n,expression_groups:w})},N=(b,w)=>{const y=[...n.expression_groups];y[b]=y[b].filter((R,O)=>O!==w),i({...n,expression_groups:y})},v=(b,w,y)=>{const R=[...n.expression_groups];R[b][w]=y,i({...n,expression_groups:R})};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:n.all_global_jargon??!1,onCheckedChange:b=>i({...n,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:n.enable_jargon_explanation??!0,onCheckedChange:b=>i({...n,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(Ie,{value:n.jargon_mode??"context",onValueChange:b=>i({...n,jargon_mode:b}),children:[e.jsx($e,{id:"jargon_mode",className:"mt-2",children:e.jsx(Pe,{placeholder:"选择黑话解释来源"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"context",children:"上下文模式(自动匹配黑话)"}),e.jsx(Z,{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(et,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.learning_list.map((b,w)=>{const y=n.learning_list.some((C,z)=>z!==w&&C[0]===""),R=b[0]==="",O=b[0].split(":"),S=O[0]||"qq",B=O[1]||"",E=O[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:["规则 ",w+1," ",R&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{rule:b}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除学习规则 ",w+1," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>u(w),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(Ie,{value:R?"global":"specific",onValueChange:C=>{C==="global"?x(w,0,""):x(w,0,"qq::group")},disabled:y&&!R,children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"global",children:"全局配置"}),e.jsx(Z,{value:"specific",disabled:y&&!R,children:"详细配置"})]})]}),y&&!R&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!R&&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(Ie,{value:S,onValueChange:C=>{x(w,0,`${C}:${B}:${E}`)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"qq",children:"QQ"}),e.jsx(Z,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(ae,{value:B,onChange:C=>{x(w,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(Ie,{value:E,onValueChange:C=>{x(w,0,`${S}:${B}:${C}`)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"group",children:"群组(group)"}),e.jsx(Z,{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=>x(w,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=>x(w,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=>x(w,3,C?"true":"false")})]})})]})]},w)}),n.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:n.expression_self_reflect??!1,onCheckedChange:b=>i({...n,expression_self_reflect:b})})]}),n.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(ae,{id:"expression_auto_check_interval",type:"number",min:"60",value:n.expression_auto_check_interval??3600,onChange:b=>i({...n,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(ae,{id:"expression_auto_check_count",type:"number",min:"1",max:"100",value:n.expression_auto_check_count??10,onChange:b=>i({...n,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:()=>{i({...n,expression_auto_check_custom_criteria:[...n.expression_auto_check_custom_criteria||[],""]})},size:"sm",variant:"outline",children:[e.jsx(et,{className:"h-4 w-4 mr-1"}),"添加标准"]})]}),e.jsxs("div",{className:"space-y-2",children:[(n.expression_auto_check_custom_criteria||[]).map((b,w)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{value:b,onChange:y=>{const R=[...n.expression_auto_check_custom_criteria||[]];R[w]=y.target.value,i({...n,expression_auto_check_custom_criteria:R})},placeholder:"输入评估标准,例如:是否符合角色人设",className:"flex-1"}),e.jsx(_,{onClick:()=>{i({...n,expression_auto_check_custom_criteria:(n.expression_auto_check_custom_criteria||[]).filter((y,R)=>R!==w)})},size:"icon",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})]},w)),(!n.expression_auto_check_custom_criteria||n.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:n.expression_checked_only??!1,onCheckedChange:b=>i({...n,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:n.expression_manual_reflect??!1,onCheckedChange:b=>i({...n,expression_manual_reflect:b})})]}),n.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 w=(n.manual_reflect_operator_id||"").split(":"),y=w[0]||"qq",R=w[1]||"",O=w[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(Ie,{value:y,onValueChange:S=>{i({...n,manual_reflect_operator_id:`${S}:${R}:${O}`})},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"qq",children:"QQ"}),e.jsx(Z,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{className:"text-xs font-medium",children:"用户/群 ID"}),e.jsx(ae,{value:R,onChange:S=>{i({...n,manual_reflect_operator_id:`${y}:${S.target.value}:${O}`})},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(Ie,{value:O,onValueChange:S=>{i({...n,manual_reflect_operator_id:`${y}:${R}:${S}`})},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"private",children:"私聊(private)"}),e.jsx(Z,{value:"group",children:"群组(group)"})]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["当前操作员 ID:",n.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:()=>{i({...n,allow_reflect:[...n.allow_reflect||[],"qq::group"]})},size:"sm",variant:"outline",children:[e.jsx(et,{className:"h-4 w-4 mr-1"}),"添加聊天流"]})]}),e.jsxs("div",{className:"space-y-2",children:[(n.allow_reflect||[]).map((b,w)=>{const y=b.split(":"),R=y[0]||"qq",O=y[1]||"",S=y[2]||"group";return e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/50",children:[e.jsxs(Ie,{value:R,onValueChange:B=>{const E=[...n.allow_reflect];E[w]=`${B}:${O}:${S}`,i({...n,allow_reflect:E})},children:[e.jsx($e,{className:"w-24",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"qq",children:"QQ"}),e.jsx(Z,{value:"wx",children:"微信"})]})]}),e.jsx(ae,{value:O,onChange:B=>{const E=[...n.allow_reflect];E[w]=`${R}:${B.target.value}:${S}`,i({...n,allow_reflect:E})},placeholder:"ID",className:"flex-1 font-mono text-sm"}),e.jsxs(Ie,{value:S,onValueChange:B=>{const E=[...n.allow_reflect];E[w]=`${R}:${O}:${B}`,i({...n,allow_reflect:E})},children:[e.jsx($e,{className:"w-32",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"group",children:"群组"}),e.jsx(Z,{value:"private",children:"私聊"})]})]}),e.jsx(_,{onClick:()=>{i({...n,allow_reflect:n.allow_reflect.filter((B,E)=>E!==w)})},size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})]},w)}),(!n.allow_reflect||n.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(et,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[n.expression_groups.map((b,w)=>{const y=n.learning_list.map(R=>R[0]).filter(R=>R!=="");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:["共享组 ",w+1,b.length===1&&b[0]==="*"&&"(全局共享)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{onClick:()=>g(w),size:"sm",variant:"outline",children:e.jsx(et,{className:"h-4 w-4"})}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除共享组 ",w+1," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>p(w),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:b.map((R,O)=>e.jsx(z2,{member:R,groupIndex:w,memberIndex:O,availableChatIds:y,onUpdate:v,onRemove:N},`${w}-${O}`))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},w)}),n.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})})]})});function O2({regex:l,reaction:n,onRegexChange:i,onReactionChange:c}){const[u,x]=d.useState(!1),[h,f]=d.useState(""),[p,g]=d.useState(null),[N,v]=d.useState(""),[b,w]=d.useState({}),[y,R]=d.useState(""),O=d.useRef(null),[S,B]=d.useState("build"),E=L=>L.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),C=(L,J=0)=>{const U=O.current;if(!U)return;const oe=U.selectionStart||0,Ne=U.selectionEnd||0,je=l.substring(0,oe)+L+l.substring(Ne);i(je),setTimeout(()=>{const re=oe+L.length+J;U.setSelectionRange(re,re),U.focus()},0)};d.useEffect(()=>{if(!l||!h){p!==null&&g(null),Object.keys(b).length>0&&w({}),y!==n&&R(n),N!==""&&v("");return}try{const L=E(l),J=new RegExp(L,"g"),U=h.match(J);g(U),v("");const Ne=new RegExp(L).exec(h);if(Ne&&Ne.groups){w(Ne.groups);let je=n;Object.entries(Ne.groups).forEach(([re,fe])=>{je=je.replace(new RegExp(`\\[${re}\\]`,"g"),fe||"")}),R(je)}else w({}),R(n)}catch(L){v(L.message),g(null),w({}),R(n)}},[l,h,n,p,b,y,N]);const z=()=>{if(!h||!p||p.length===0)return e.jsx("span",{className:"text-muted-foreground",children:h||"请输入测试文本"});try{const L=E(l),J=new RegExp(L,"g");let U=0;const oe=[];let Ne;for(;(Ne=J.exec(h))!==null;)Ne.index>U&&oe.push(e.jsx("span",{children:h.substring(U,Ne.index)},`text-${U}`)),oe.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:Ne[0]},`match-${Ne.index}`)),U=Ne.index+Ne[0].length;return U<h.length&&oe.push(e.jsx("span",{children:h.substring(U)},`text-${U}`)),e.jsx(e.Fragment,{children:oe})}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(Is,{open:u,onOpenChange:x,children:[e.jsx(sd,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(Ym,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(Os,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"正则表达式编辑器"}),e.jsx(Ks,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(Je,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(ta,{value:S,onValueChange:L=>B(L),className:"w-full",children:[e.jsxs(Xt,{className:"grid w-full grid-cols-2",children:[e.jsx(Xe,{value:"build",children:"🔧 构建器"}),e.jsx(Xe,{value:"test",children:"🧪 测试器"})]}),e.jsxs(ws,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(ae,{ref:O,value:l,onChange:L=>i(L.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(ot,{value:n,onChange:L=>c(L.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[H.map(L=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:L.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:L.items.map(J=>e.jsx(_,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>C(J.pattern,J.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:J.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:J.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:J.desc})]})},J.label))})]},L.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:()=>i("^(?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:()=>i("(?:[^,。.\\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:()=>i("(?P<subject>.+?)(?:是|为什么|怎么)"),children:e.jsxs("div",{className:"flex flex-col items-start w-full",children:[e.jsx("code",{className:"text-xs font-mono bg-muted px-2 py-1 rounded w-full overflow-x-auto",children:"(?P<subject>.+?)(?:是|为什么|怎么)"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"捕获问题主题词"})]})})]})]})]}),e.jsxs("div",{className:"rounded-md bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 p-3 space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-blue-900 dark:text-blue-100",children:"💡 使用提示"}),e.jsxs("ul",{className:"text-xs text-blue-700 dark:text-blue-300 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"点击输入框设置光标位置,然后点击按钮插入模式"}),e.jsxs("li",{children:["命名捕获组格式:",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"(?P<名称>模式)"})]}),e.jsxs("li",{children:["在 reaction 中使用 ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded",children:"[名称]"})," 引用捕获的内容"]}),e.jsx("li",{children:"切换到测试器标签页验证正则表达式效果"})]})]})]}),e.jsxs(ws,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:l||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(ot,{id:"test-text",value:h,onChange:L=>f(L.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(Je,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:z()})})]}),Object.keys(b).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(Je,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(b).map(([L,J])=>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:["[",L,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:J})]},L))})})]}),Object.keys(b).length>0&&n&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(Je,{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:y})}),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 D2=As.memo(function({keywordReactionConfig:n,responsePostProcessConfig:i,chineseTypoConfig:c,responseSplitterConfig:u,onKeywordReactionChange:x,onResponsePostProcessChange:h,onChineseTypoChange:f,onResponseSplitterChange:p}){const g=()=>{x({...n,regex_rules:[...n.regex_rules,{regex:[""],reaction:""}]})},N=C=>{x({...n,regex_rules:n.regex_rules.filter((z,H)=>H!==C)})},v=(C,z,H)=>{const L=[...n.regex_rules];z==="regex"&&typeof H=="string"?L[C]={...L[C],regex:[H]}:z==="reaction"&&typeof H=="string"&&(L[C]={...L[C],reaction:H}),x({...n,regex_rules:L})},b=()=>{x({...n,keyword_rules:[...n.keyword_rules,{keywords:[],reaction:""}]})},w=C=>{x({...n,keyword_rules:n.keyword_rules.filter((z,H)=>H!==C)})},y=(C,z,H)=>{const L=[...n.keyword_rules];typeof H=="string"&&(L[C]={...L[C],reaction:H}),x({...n,keyword_rules:L})},R=C=>{const z=[...n.keyword_rules];z[C]={...z[C],keywords:[...z[C].keywords||[],""]},x({...n,keyword_rules:z})},O=(C,z)=>{const H=[...n.keyword_rules];H[C]={...H[C],keywords:(H[C].keywords||[]).filter((L,J)=>J!==z)},x({...n,keyword_rules:H})},S=(C,z,H)=>{const L=[...n.keyword_rules],J=[...L[C].keywords||[]];J[z]=H,L[C]={...L[C],keywords:J},x({...n,keyword_rules:L})},B=({rule:C})=>{const z=`{ regex = [${(C.regex||[]).map(H=>`"${H}"`).join(", ")}], reaction = "${C.reaction}" }`;return e.jsxs(ol,{children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Wa,{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(Je,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:z})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},E=({rule:C})=>{const z=`[[keyword_reaction.keyword_rules]]
|
||
keywords = [${(C.keywords||[]).map(H=>`"${H}"`).join(", ")}]
|
||
reaction = "${C.reaction}"`;return e.jsxs(ol,{children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(Wa,{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(Je,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:z})}),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(et,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.regex_rules.map((C,z)=>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:["正则规则 ",z+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O2,{regex:C.regex&&C.regex[0]||"",reaction:C.reaction,onRegexChange:H=>v(z,"regex",H),onReactionChange:H=>v(z,"reaction",H)}),e.jsx(B,{rule:C}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除正则规则 ",z+1," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>N(z),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(ae,{value:C.regex&&C.regex[0]||"",onChange:H=>v(z,"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(ot,{value:C.reaction,onChange:H=>v(z,"reaction",H.target.value),placeholder:`触发后麦麦的反应...
|
||
可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},z)),n.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(et,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[n.keyword_rules.map((C,z)=>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:["关键词规则 ",z+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{rule:C}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除关键词规则 ",z+1," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>w(z),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:()=>R(z),size:"sm",variant:"ghost",children:[e.jsx(et,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(C.keywords||[]).map((H,L)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{value:H,onChange:J=>S(z,L,J.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(_,{onClick:()=>O(z,L),size:"sm",variant:"ghost",children:e.jsx(ns,{className:"h-4 w-4"})})]},L)),(!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(ot,{value:C.reaction,onChange:H=>y(z,"reaction",H.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},z)),n.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:i.enable_response_post_process,onCheckedChange:C=>h({...i,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:"包括错别字生成器和回复分割器"})]}),i.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(ae,{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(ae,{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(ae,{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(ae,{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:u.enable,onCheckedChange:C=>p({...u,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:"控制回复的长度和句子数量"}),u.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(ae,{id:"max_length",type:"number",min:"1",value:u.max_length,onChange:C=>p({...u,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(ae,{id:"max_sentence_num",type:"number",min:"1",value:u.max_sentence_num,onChange:C=>p({...u,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:u.enable_kaomoji_protection,onCheckedChange:C=>p({...u,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:u.enable_overflow_return_all,onCheckedChange:C=>p({...u,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:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})}),R2=As.memo(function({config:n,onChange:i}){const[c,u]=d.useState(""),[x,h]=d.useState(""),[f,p]=d.useState(!1),g=n.allowed_ips?n.allowed_ips.split(",").map(S=>S.trim()).filter(S=>S):[],N=n.trusted_proxies?n.trusted_proxies.split(",").map(S=>S.trim()).filter(S=>S):[],v=()=>{if(!c.trim())return;const S=[...g,c.trim()];i({...n,allowed_ips:S.join(",")}),u("")},b=S=>{const B=g.filter((E,C)=>C!==S);i({...n,allowed_ips:B.join(",")})},w=()=>{if(!x.trim())return;const S=[...N,x.trim()];i({...n,trusted_proxies:S.join(",")}),h("")},y=S=>{const B=N.filter((E,C)=>C!==S);i({...n,trusted_proxies:B.join(",")})},R=S=>{!S&&n.enabled?p(!0):i({...n,enabled:S})},O=()=>{i({...n,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:n.enabled,onCheckedChange:R}),e.jsx(T,{className:"cursor-pointer",children:"启用 WebUI"})]}),n.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{children:"运行模式"}),e.jsxs(Ie,{value:n.mode,onValueChange:S=>i({...n,mode:S}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择运行模式"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"development",children:"开发模式"}),e.jsx(Z,{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(Ie,{value:n.anti_crawler_mode,onValueChange:S=>i({...n,anti_crawler_mode:S}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择防爬虫模式"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"false",children:"禁用"}),e.jsx(Z,{value:"basic",children:"基础(只记录不阻止)"}),e.jsx(Z,{value:"loose",children:"宽松"}),e.jsx(Z,{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(ae,{value:c,onChange:S=>u(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),v())},placeholder:"输入IP地址后按回车或点击添加"}),e.jsx(_,{type:"button",size:"sm",onClick:v,disabled:!c.trim(),children:e.jsx(et,{className:"h-4 w-4"})})]}),g.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:g.map((S,B)=>e.jsxs(ke,{variant:"secondary",className:"flex items-center gap-1",children:[S,e.jsx("button",{type:"button",onClick:()=>b(B),className:"ml-1 hover:bg-destructive/20 rounded-full p-0.5",children:e.jsx(Ea,{className:"h-3 w-3"})})]},B))}),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(ae,{value:x,onChange:S=>h(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),w())},placeholder:"输入代理IP后按回车或点击添加"}),e.jsx(_,{type:"button",size:"sm",onClick:w,disabled:!x.trim(),children:e.jsx(et,{className:"h-4 w-4"})})]}),N.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:N.map((S,B)=>e.jsxs(ke,{variant:"secondary",className:"flex items-center gap-1",children:[S,e.jsx("button",{type:"button",onClick:()=>y(B),className:"ml-1 hover:bg-destructive/20 rounded-full p-0.5",children:e.jsx(Ea,{className:"h-3 w-3"})})]},B))}),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:n.trust_xff,onCheckedChange:S=>i({...n,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:n.secure_cookie,onCheckedChange:S=>i({...n,secure_cookie:S})}),e.jsx(T,{className:"cursor-pointer",children:"启用安全 Cookie(仅 HTTPS)"})]})]})]}),e.jsx(Ns,{open:f,onOpenChange:p,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"警告:即将关闭 WebUI"}),e.jsxs(fs,{children:["关闭 WebUI 后,在您下次重启麦麦之前,WebUI 界面将无法访问。",e.jsx("br",{}),e.jsx("br",{}),"您需要通过修改配置文件或命令行重新启用 WebUI 才能再次访问此界面。",e.jsx("br",{}),e.jsx("br",{}),"确定要关闭 WebUI 吗?"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{variant:"destructive",onClick:O,children:"确认关闭"})]})]})})]})}),Nn="/api/webui/config";async function _g(){const n=await(await _e(`${Nn}/bot`)).json();if(!n.success)throw new Error("获取配置数据失败");return n.config}async function un(){const n=await(await _e(`${Nn}/model`)).json();if(!n.success)throw new Error("获取模型配置数据失败");return n.config}async function Sg(l){const i=await(await _e(`${Nn}/bot`,{method:"POST",body:JSON.stringify(l)})).json();if(!i.success)throw new Error(i.message||"保存配置失败")}async function L2(){const n=await(await _e(`${Nn}/bot/raw`)).json();if(!n.success)throw new Error("获取配置源代码失败");return n.content}async function U2(l){const i=await(await _e(`${Nn}/bot/raw`,{method:"POST",body:JSON.stringify({raw_content:l})})).json();if(!i.success)throw new Error(i.message||"保存配置失败")}async function Xi(l){const i=await(await _e(`${Nn}/model`,{method:"POST",body:JSON.stringify(l)})).json();if(!i.success)throw new Error(i.message||"保存配置失败")}async function $2(l,n){const c=await(await _e(`${Nn}/bot/section/${l}`,{method:"POST",body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||`保存配置节 ${l} 失败`)}async function Im(l,n){const c=await(await _e(`${Nn}/model/section/${l}`,{method:"POST",body:JSON.stringify(n)})).json();if(!c.success)throw new Error(c.message||`保存配置节 ${l} 失败`)}async function B2(l,n="openai",i="/models"){const c=new URLSearchParams({provider_name:l,parser:n,endpoint:i}),u=await _e(`/api/webui/models/list?${c}`);if(!u.ok){const h=await u.json().catch(()=>({}));throw new Error(h.detail||`获取模型列表失败 (${u.status})`)}const x=await u.json();if(!x.success)throw new Error("获取模型列表失败");return x.models}async function I2(l){const n=new URLSearchParams({provider_name:l}),i=await _e(`/api/webui/models/test-connection-by-name?${n}`,{method:"POST"});if(!i.ok){const c=await i.json().catch(()=>({}));throw new Error(c.detail||`测试连接失败 (${i.status})`)}return await i.json()}const P2=Qr("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"}}),at=d.forwardRef(({className:l,variant:n,...i},c)=>e.jsx("div",{ref:c,role:"alert",className:P(P2({variant:n}),l),...i}));at.displayName="Alert";const Hn=d.forwardRef(({className:l,...n},i)=>e.jsx("h5",{ref:i,className:P("mb-1 font-medium leading-none tracking-tight",l),...n}));Hn.displayName="AlertTitle";const lt=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{ref:i,className:P("text-sm [&_p]:leading-relaxed",l),...n}));lt.displayName="AlertDescription";const H2={name:"toml",startState:function(){return{inString:!1,stringType:"",lhs:!0,inArray:0}},token:function(l,n){let i;if(!n.inString&&(i=l.match(/^('''|"""|'|")/))&&(n.stringType=i[0],n.inString=!0),l.sol()&&!n.inString&&n.inArray===0&&(n.lhs=!0),n.inString){for(;n.inString;)if(l.match(n.stringType))n.inString=!1;else if(l.peek()==="\\")l.next(),l.next();else{if(l.eol())break;l.match(/^.[^\\\"\']*/)}return n.lhs?"property":"string"}else{if(n.inArray&&l.peek()==="]")return l.next(),n.inArray--,"bracket";if(n.lhs&&l.peek()==="["&&l.skipTo("]"))return l.next(),l.peek()==="]"&&l.next(),"atom";if(l.peek()==="#")return l.skipToEnd(),"comment";if(l.eatSpace())return null;if(n.lhs&&l.eatWhile(function(c){return c!="="&&c!=" "}))return"property";if(n.lhs&&l.peek()==="=")return l.next(),n.lhs=!1,null;if(!n.lhs&&l.match(/^\d\d\d\d[\d\-\:\.T]*Z/))return"atom";if(!n.lhs&&(l.match("true")||l.match("false")))return"atom";if(!n.lhs&&l.peek()==="[")return n.inArray++,l.next(),"bracket";if(!n.lhs&&l.match(/^\-?\d+(?:\.\d+)?/))return"number";l.eatSpace()||l.next()}return null},languageData:{commentTokens:{line:"#"}}},F2={python:[E_()],json:[M_(),z_()],toml:[T_.define(H2)],text:[]};function yv({value:l,onChange:n,language:i="text",readOnly:c=!1,height:u="400px",minHeight:x,maxHeight:h,placeholder:f,theme:p="dark",className:g=""}){const[N,v]=d.useState(!1);if(d.useEffect(()=>{v(!0)},[]),!N)return e.jsx("div",{className:`rounded-md border bg-muted animate-pulse ${g}`,style:{height:u,minHeight:x,maxHeight:h}});const b=[...F2[i]||[],xg.lineWrapping];return c&&b.push(xg.editable.of(!1)),e.jsx("div",{className:`rounded-md overflow-hidden border ${g}`,children:e.jsx(A_,{value:l,height:u,minHeight:x,maxHeight:h,theme:p==="dark"?O_:void 0,extensions:b,onChange:n,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 G2({id:l,index:n,itemType:i,itemFields:c,value:u,onChange:x,onRemove:h,disabled:f,canRemove:p,placeholder:g}){const{attributes:N,listeners:v,setNodeRef:b,transform:w,transition:y,isDragging:R}=sv({id:l,disabled:f}),O={transform:tv.Transform.toString(w),transition:y};return e.jsxs("div",{ref:b,style:O,className:P("flex items-start gap-2 group",R&&"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,...v,children:e.jsx(Uj,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1 min-w-0",children:i==="object"&&c?e.jsx(V2,{value:u,onChange:x,fields:c,disabled:f}):i==="number"?e.jsx(ae,{type:"number",value:u??"",onChange:S=>x(parseFloat(S.target.value)||0),placeholder:g??`第 ${n+1} 项`,disabled:f,className:"font-mono"}):e.jsx(ae,{type:"text",value:u??"",onChange:S=>x(S.target.value),placeholder:g??`第 ${n+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(ns,{className:"h-4 w-4"})})]})}function V2({value:l,onChange:n,fields:i,disabled:c}){const u=d.useCallback((h,f)=>{n({...l,[h]:f})},[l,n]),x=(h,f)=>{const p=l?.[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=>u(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(qa,{value:[g],onValueChange:N=>u(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(Ie,{value:String(p??f.default??""),onValueChange:g=>u(h,g),disabled:c,children:[e.jsx($e,{className:"h-8 text-sm",children:e.jsx(Pe,{placeholder:f.placeholder??"请选择"})}),e.jsx(Be,{children:f.choices.map(g=>e.jsx(Z,{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(ae,{type:"number",value:p??f.default??"",onChange:g=>u(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(ae,{type:"text",value:p??f.default??"",onChange:g=>u(h,g.target.value),placeholder:f.placeholder,disabled:c,className:"h-8 text-sm"})]})};return e.jsx(Ce,{className:"p-3 space-y-2 bg-muted/30",children:Object.entries(i).map(([h,f])=>e.jsx("div",{children:x(h,f)},h))})}function q2({value:l,onChange:n,itemType:i="string",itemFields:c,minItems:u,maxItems:x,disabled:h,placeholder:f}){const p=d.useMemo(()=>Array.isArray(l)?l:typeof l=="string"&&l.trim()?l.split(",").map(E=>E.trim()):[],[l]),[g]=d.useState(()=>new Map),N=d.useCallback(E=>(g.has(E)||g.set(E,`item-${Date.now()}-${E}-${Math.random().toString(36).slice(2)}`),g.get(E)),[g]),v=d.useMemo(()=>{const E=[];for(let C=0;C<p.length;C++)E.push(N(C));return E},[p.length,N]),b=Kj(Po(Jj,{activationConstraint:{distance:8}}),Po(Yj,{coordinateGetter:Qj})),w=d.useCallback(E=>{const{active:C,over:z}=E;if(z&&C.id!==z.id){const H=v.indexOf(C.id),L=v.indexOf(z.id),J=Xj(p,H,L);n(J)}},[p,v,n]),y=d.useCallback(()=>{if(x!=null&&p.length>=x)return;let E;i==="object"&&c?E=Object.fromEntries(Object.entries(c).map(([C,z])=>[C,z.default??""])):i==="number"?E=0:E="",n([...p,E])},[p,x,i,c,n]),R=d.useCallback((E,C)=>{const z=[...p];z[E]=C,n(z)},[p,n]),O=d.useCallback(E=>{if(u!=null&&p.length<=u)return;const C=p.filter((z,H)=>H!==E);g.delete(E),n(C)},[p,u,g,n]),S=x==null||p.length<x,B=u==null||p.length>u;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(_t,{className:"h-4 w-4"}),e.jsx("span",{children:"暂无数据,点击下方按钮添加"})]}):e.jsx(Zj,{sensors:b,collisionDetection:Wj,onDragEnd:w,children:e.jsx(ev,{items:v,strategy:D_,children:e.jsx("div",{className:"space-y-2",children:p.map((E,C)=>e.jsx(G2,{id:v[C],index:C,itemType:i,itemFields:c,value:E,onChange:z=>R(C,z),onRemove:()=>O(C),disabled:h,canRemove:B,placeholder:f},v[C]))})})}),e.jsxs(_,{type:"button",variant:"outline",size:"sm",onClick:y,disabled:h||!S,className:"w-full",children:[e.jsx(et,{className:"h-4 w-4 mr-1"}),"添加项目",x!==void 0&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",p.length,"/",x,")"]})]}),(u!=null||x!=null)&&(u!==null||x!==null)&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:u!=null&&x!=null?`允许 ${u} - ${x} 项`:u!=null?`至少 ${u} 项`:`最多 ${x} 项`})]})}function nx({content:l,className:n=""}){return e.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none ${n}`,children:e.jsx(I_,{remarkPlugins:[H_,F_],rehypePlugins:[P_],components:{code({inline:i,className:c,children:u,...x}){return i?e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-sm font-mono",...x,children:u}):e.jsx("code",{className:`${c} block bg-muted p-4 rounded-lg overflow-x-auto`,...x,children:u})},table({children:i,...c}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"border-collapse border border-border",...c,children:i})})},th({children:i,...c}){return e.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-semibold",...c,children:i})},td({children:i,...c}){return e.jsx("td",{className:"border border-border px-4 py-2",...c,children:i})},a({children:i,...c}){return e.jsx("a",{className:"text-primary hover:underline",target:"_blank",rel:"noopener noreferrer",...c,children:i})},blockquote({children:i,...c}){return e.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",...c,children:i})},h1({children:i,...c}){return e.jsx("h1",{className:"text-3xl font-bold mt-6 mb-4",...c,children:i})},h2({children:i,...c}){return e.jsx("h2",{className:"text-2xl font-bold mt-5 mb-3",...c,children:i})},h3({children:i,...c}){return e.jsx("h3",{className:"text-xl font-bold mt-4 mb-2",...c,children:i})},h4({children:i,...c}){return e.jsx("h4",{className:"text-lg font-semibold mt-3 mb-2",...c,children:i})},ul({children:i,...c}){return e.jsx("ul",{className:"list-disc list-inside space-y-1 my-2",...c,children:i})},ol({children:i,...c}){return e.jsx("ol",{className:"list-decimal list-inside space-y-1 my-2",...c,children:i})},p({children:i,...c}){return e.jsx("p",{className:"my-2 leading-relaxed",...c,children:i})},hr({...i}){return e.jsx("hr",{className:"my-4 border-border",...i})}},children:l})})}function K2(l,n,i,c={}){const{debounceMs:u=2e3,onSaveSuccess:x,onSaveError:h}=c,f=d.useRef(null),p=d.useCallback(async(b,w)=>{try{n(!0),await $2(b,w),i(!1),x?.()}catch(y){console.error(`自动保存 ${b} 失败:`,y),i(!0),h?.(y instanceof Error?y:new Error(String(y)))}finally{n(!1)}},[n,i,x,h]),g=d.useCallback((b,w)=>{l||(i(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{p(b,w)},u))},[l,i,p,u]),N=d.useCallback(async(b,w)=>{f.current&&(clearTimeout(f.current),f.current=null),await p(b,w)},[p]),v=d.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]);return d.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]),{triggerAutoSave:g,saveNow:N,cancelPendingAutoSave:v}}function Lt(l,n,i,c){d.useEffect(()=>{l&&!i&&c(n,l)},[l])}const Q2=500;function Y2(){return e.jsx(Jn,{children:e.jsx(J2,{})})}function J2(){const[l,n]=d.useState(!0),[i,c]=d.useState(!1),[u,x]=d.useState(!1),[h,f]=d.useState(!1),[p,g]=d.useState("visual"),[N,v]=d.useState(""),[b,w]=d.useState(!1),{toast:y}=Zs(),{triggerRestart:R,isRestarting:O}=vn(),[S,B]=d.useState(null),[E,C]=d.useState(null),[z,H]=d.useState(null),[L,J]=d.useState(null),[U,oe]=d.useState(null),[Ne,je]=d.useState(null),[re,fe]=d.useState(null),[ge,M]=d.useState(null),[K,I]=d.useState(null),[ue,Q]=d.useState(null),[Se,pe]=d.useState(null),[Te,A]=d.useState(null),[D,V]=d.useState(null),[de,Oe]=d.useState(null),[W,Y]=d.useState(null),[He,F]=d.useState(null),[ee,Ue]=d.useState(null),[ie,Ee]=d.useState(null),[me,ze]=d.useState(null),rs=d.useRef(!0),Ut=d.useRef({}),aa=d.useCallback(Ae=>{Ut.current=Ae,B(Ae.bot),C(Ae.personality);const bs=Ae.chat;bs.talk_value_rules||(bs.talk_value_rules=[]),H(bs),J(Ae.expression),oe(Ae.emoji),je(Ae.memory),fe(Ae.tool),M(Ae.voice),I(Ae.dream),Q(Ae.lpmm_knowledge),pe(Ae.keyword_reaction),A(Ae.response_post_process),V(Ae.chinese_typo),Oe(Ae.response_splitter),Y(Ae.log),F(Ae.debug),Ue(Ae.maim_message),Ee(Ae.telemetry),ze(Ae.webui)},[]),Qa=d.useCallback(()=>({...Ut.current,bot:S,personality:E,chat:z,expression:L,emoji:U,memory:Ne,tool:re,voice:ge,dream:K,lpmm_knowledge:ue,keyword_reaction:Se,response_post_process:Te,chinese_typo:D,response_splitter:de,log:W,debug:He,maim_message:ee,telemetry:ie,webui:me}),[S,E,z,L,U,Ne,re,ge,K,ue,Se,Te,D,de,W,He,ee,ie,me]),Ft=d.useCallback(async()=>{try{const bs=(await L2()).replace(/"([^"]*)"/g,(ls,ss)=>`"${ss.replace(/\\n/g,`
|
||
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}"`);v(bs),w(!1)}catch(Ae){y({variant:"destructive",title:"加载失败",description:Ae instanceof Error?Ae.message:"加载源代码失败"})}},[y]),mt=d.useCallback(async()=>{try{n(!0);const Ae=await _g();aa(Ae),f(!1),rs.current=!1,await Ft()}catch(Ae){console.error("加载配置失败:",Ae),y({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{n(!1)}},[y,Ft,aa]);d.useEffect(()=>{mt()},[mt]);const{triggerAutoSave:q,cancelPendingAutoSave:qe}=K2(rs.current,x,f);Lt(S,"bot",rs.current,q),Lt(E,"personality",rs.current,q),Lt(z,"chat",rs.current,q),Lt(L,"expression",rs.current,q),Lt(U,"emoji",rs.current,q),Lt(Ne,"memory",rs.current,q),Lt(re,"tool",rs.current,q),Lt(ge,"voice",rs.current,q),Lt(K,"dream",rs.current,q),Lt(ue,"lpmm_knowledge",rs.current,q),Lt(Se,"keyword_reaction",rs.current,q),Lt(Te,"response_post_process",rs.current,q),Lt(D,"chinese_typo",rs.current,q),Lt(de,"response_splitter",rs.current,q),Lt(W,"log",rs.current,q),Lt(He,"debug",rs.current,q),Lt(ee,"maim_message",rs.current,q),Lt(ie,"telemetry",rs.current,q),Lt(me,"webui",rs.current,q);const Qe=async()=>{try{c(!0);const Ae=N.replace(/"([^"]*)"/g,(bs,ls)=>`"${ls.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")}"`);await U2(Ae),f(!1),w(!1),y({title:"保存成功",description:"配置已保存"}),await mt()}catch(Ae){w(!0),y({variant:"destructive",title:"保存失败",description:Ae instanceof Error?Ae.message:"保存配置失败"})}finally{c(!1)}},es=async Ae=>{if(h){y({variant:"destructive",title:"切换失败",description:"请先保存当前更改"});return}if(g(Ae),Ae==="source")await Ft();else try{const bs=await _g();aa(bs),f(!1)}catch(bs){console.error("加载配置失败:",bs),y({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}},Ls=async()=>{try{c(!0),qe(),await Sg(Qa()),f(!1),y({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(Ae){console.error("保存配置失败:",Ae),y({title:"保存失败",description:Ae.message,variant:"destructive"})}finally{c(!1)}},as=async()=>{await R()},Cs=async()=>{try{c(!0),qe(),await Sg(Qa()),f(!1),y({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(Ae=>setTimeout(Ae,Q2)),await as()}catch(Ae){console.error("保存失败:",Ae),y({title:"保存失败",description:Ae.message,variant:"destructive"})}finally{c(!1)}};return l?e.jsx(Je,{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(Je,{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"?Ls:Qe,disabled:i||u||!h||O,size:"sm",variant:"outline",className:"w-20 sm:w-24",children:[e.jsx(dc,{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:i?"保存中":u?"自动":h?"保存":"已保存"})]}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{disabled:i||u||O,size:"sm",className:"w-20 sm:w-28",children:[e.jsx(oc,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"ml-1 truncate text-xs sm:text-sm",children:O?"重启中":h?"保存重启":"重启"})]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认重启麦麦?"}),e.jsx(fs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:h?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:h?Cs:as,children:h?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsx("div",{className:"flex",children:e.jsx(ta,{value:p,onValueChange:Ae=>es(Ae),className:"w-full",children:e.jsxs(Xt,{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($j,{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(Bj,{className:"h-3 w-3 sm:h-4 sm:w-4 mr-1"}),"源代码编辑"]})]})})})]}),e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsxs(lt,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),p==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsxs(lt,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。此功能仅适用于熟悉 TOML 语法的高级用户。保存时会在后端验证格式,只有格式完全正确才能保存。",b&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(yv,{value:N,onChange:Ae=>{v(Ae),f(!0),b&&w(!1)},language:"toml",theme:"dark",height:"calc(100vh - 280px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),p==="visual"&&e.jsx(e.Fragment,{children:e.jsxs(ta,{defaultValue:"bot",className:"w-full",children:[e.jsxs(Xt,{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(ws,{value:"bot",className:"space-y-4",children:S&&e.jsx(v2,{config:S,onChange:B})}),e.jsx(ws,{value:"personality",className:"space-y-4",children:E&&e.jsx(N2,{config:E,onChange:C})}),e.jsx(ws,{value:"chat",className:"space-y-4",children:z&&e.jsx(w2,{config:z,onChange:H})}),e.jsx(ws,{value:"expression",className:"space-y-4",children:L&&e.jsx(A2,{config:L,onChange:J})}),e.jsx(ws,{value:"features",className:"space-y-4",children:U&&Ne&&re&&ge&&e.jsx(M2,{emojiConfig:U,memoryConfig:Ne,toolConfig:re,voiceConfig:ge,onEmojiChange:oe,onMemoryChange:je,onToolChange:fe,onVoiceChange:M})}),e.jsx(ws,{value:"processing",className:"space-y-4",children:Se&&Te&&D&&de&&e.jsx(D2,{keywordReactionConfig:Se,responsePostProcessConfig:Te,chineseTypoConfig:D,responseSplitterConfig:de,onKeywordReactionChange:pe,onResponsePostProcessChange:A,onChineseTypoChange:V,onResponseSplitterChange:Oe})}),e.jsx(ws,{value:"dream",className:"space-y-4",children:K&&e.jsx(_2,{config:K,onChange:I})}),e.jsx(ws,{value:"lpmm",className:"space-y-4",children:ue&&e.jsx(S2,{config:ue,onChange:Q})}),e.jsx(ws,{value:"webui",className:"space-y-4",children:me&&e.jsx(R2,{config:me,onChange:ze})}),e.jsxs(ws,{value:"other",className:"space-y-4",children:[W&&e.jsx(k2,{config:W,onChange:Y}),He&&e.jsx(C2,{config:He,onChange:F}),ee&&e.jsx(T2,{config:ee,onChange:Ue}),ie&&e.jsx(E2,{config:ie,onChange:Ee})]})]})}),e.jsx(Xn,{})]})})}const Rl=d.forwardRef(({className:l,...n},i)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:i,className:P("w-full caption-bottom text-sm",l),...n})}));Rl.displayName="Table";const Ll=d.forwardRef(({className:l,...n},i)=>e.jsx("thead",{ref:i,className:P("[&_tr]:border-b",l),...n}));Ll.displayName="TableHeader";const Ul=d.forwardRef(({className:l,...n},i)=>e.jsx("tbody",{ref:i,className:P("[&_tr:last-child]:border-0",l),...n}));Ul.displayName="TableBody";const X2=d.forwardRef(({className:l,...n},i)=>e.jsx("tfoot",{ref:i,className:P("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",l),...n}));X2.displayName="TableFooter";const ut=d.forwardRef(({className:l,...n},i)=>e.jsx("tr",{ref:i,className:P("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",l),...n}));ut.displayName="TableRow";const We=d.forwardRef(({className:l,...n},i)=>e.jsx("th",{ref:i,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]",l),...n}));We.displayName="TableHead";const Ke=d.forwardRef(({className:l,...n},i)=>e.jsx("td",{ref:i,className:P("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",l),...n}));Ke.displayName="TableCell";const Z2=d.forwardRef(({className:l,...n},i)=>e.jsx("caption",{ref:i,className:P("mt-4 text-sm text-muted-foreground",l),...n}));Z2.displayName="TableCaption";const ad=d.forwardRef(({className:l,...n},i)=>e.jsx(ga,{ref:i,className:P("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",l),...n}));ad.displayName=ga.displayName;const ld=d.forwardRef(({className:l,...n},i)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Tt,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(ga.Input,{ref:i,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",l),...n})]}));ld.displayName=ga.Input.displayName;const nd=d.forwardRef(({className:l,...n},i)=>e.jsx(ga.List,{ref:i,className:P("max-h-[300px] overflow-y-auto overflow-x-hidden",l),...n}));nd.displayName=ga.List.displayName;const rd=d.forwardRef((l,n)=>e.jsx(ga.Empty,{ref:n,className:"py-6 text-center text-sm",...l}));rd.displayName=ga.Empty.displayName;const lc=d.forwardRef(({className:l,...n},i)=>e.jsx(ga.Group,{ref:i,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",l),...n}));lc.displayName=ga.Group.displayName;const W2=d.forwardRef(({className:l,...n},i)=>e.jsx(ga.Separator,{ref:i,className:P("-mx-1 h-px bg-border",l),...n}));W2.displayName=ga.Separator.displayName;const nc=d.forwardRef(({className:l,...n},i)=>e.jsx(ga.Item,{ref:i,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",l),...n}));nc.displayName=ga.Item.displayName;const wv=d.createContext(null),_v="maibot-completed-tours";function eS(){try{const l=localStorage.getItem(_v);return l?new Set(JSON.parse(l)):new Set}catch{return new Set}}function kg(l){localStorage.setItem(_v,JSON.stringify([...l]))}function sS({children:l}){const[n,i]=d.useState({activeTourId:null,stepIndex:0,isRunning:!1}),[c]=d.useState(()=>new Map),[u,x]=d.useState(eS),[,h]=d.useState(0),f=d.useCallback((E,C)=>{c.set(E,C),h(z=>z+1)},[c]),p=d.useCallback(E=>{c.delete(E),i(C=>C.activeTourId===E?{...C,activeTourId:null,isRunning:!1,stepIndex:0}:C)},[c]),g=d.useCallback((E,C=0)=>{c.has(E)&&i({activeTourId:E,stepIndex:C,isRunning:!0})},[c]),N=d.useCallback(()=>{i(E=>({...E,isRunning:!1}))},[]),v=d.useCallback(E=>{i(C=>({...C,stepIndex:E}))},[]),b=d.useCallback(()=>{i(E=>({...E,stepIndex:E.stepIndex+1}))},[]),w=d.useCallback(()=>{i(E=>({...E,stepIndex:Math.max(0,E.stepIndex-1)}))},[]),y=d.useCallback(()=>n.activeTourId?c.get(n.activeTourId)||[]:[],[n.activeTourId,c]),R=d.useCallback(E=>{x(C=>{const z=new Set(C);return z.add(E),kg(z),z})},[]),O=d.useCallback(E=>{const{action:C,index:z,status:H,type:L}=E,J=["finished","skipped"];if(C==="close"){i(U=>({...U,isRunning:!1,stepIndex:0}));return}J.includes(H)?i(U=>(H==="finished"&&U.activeTourId&&setTimeout(()=>R(U.activeTourId),0),{...U,isRunning:!1,stepIndex:0})):L==="step:after"&&(C==="next"?i(U=>({...U,stepIndex:z+1})):C==="prev"&&i(U=>({...U,stepIndex:z-1})))},[R]),S=d.useCallback(E=>u.has(E),[u]),B=d.useCallback(E=>{x(C=>{const z=new Set(C);return z.delete(E),kg(z),z})},[]);return e.jsx(wv.Provider,{value:{state:n,tours:c,registerTour:f,unregisterTour:p,startTour:g,stopTour:N,goToStep:v,nextStep:b,prevStep:w,getCurrentSteps:y,handleJoyrideCallback:O,isTourCompleted:S,markTourCompleted:R,resetTourCompleted:B},children:l})}function rx(){const l=d.useContext(wv);if(!l)throw new Error("useTour must be used within a TourProvider");return l}const tS={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)"}},aS={back:"上一步",close:"关闭",last:"完成",next:"下一步",nextLabelWithProgress:"下一步 ({step}/{steps})",open:"打开对话框",skip:"跳过"};function lS(){const{state:l,getCurrentSteps:n,handleJoyrideCallback:i}=rx(),c=n(),[u,x]=d.useState(!1),h=d.useRef(l.stepIndex),f=d.useRef(null);d.useEffect(()=>{h.current!==l.stepIndex&&(x(!1),h.current=l.stepIndex)},[l.stepIndex]),d.useEffect(()=>{if(!l.isRunning||c.length===0){x(!1);return}const v=c[l.stepIndex];if(!v){x(!1);return}const b=v.target;if(b==="body"){x(!0);return}x(!1);const w=setTimeout(()=>{const y=()=>{const B=document.querySelector(b);if(B){const E=B.getBoundingClientRect();if(E.width>0&&E.height>0)return!0}return!1};if(y()){setTimeout(()=>x(!0),100);return}const R=setInterval(()=>{y()&&(clearInterval(R),setTimeout(()=>x(!0),100))},100),O=setTimeout(()=>{clearInterval(R),x(!0)},5e3),S=()=>{clearInterval(R),clearTimeout(O)};f.current=S},150);return()=>{clearTimeout(w),f.current&&(f.current(),f.current=null)}},[l.isRunning,l.stepIndex,c]);const[p,g]=d.useState(null);if(d.useEffect(()=>{let v=document.getElementById("tour-portal-container");return v||(v=document.createElement("div"),v.id="tour-portal-container",v.style.cssText="position: fixed; top: 0; left: 0; z-index: 99999; pointer-events: none;",document.body.appendChild(v)),g(v),()=>{}},[]),!l.isRunning||c.length===0||!u)return null;const N=e.jsx(L_,{steps:c,stepIndex:l.stepIndex,run:l.isRunning,continuous:!0,showSkipButton:!0,showProgress:!0,disableOverlayClose:!0,disableScrolling:!1,disableScrollParentFix:!1,callback:i,styles:tS,locale:aS,scrollOffset:80,scrollToFirstStep:!0,floaterProps:{styles:{floater:{zIndex:99999}},disableAnimation:!0}},`tour-step-${l.stepIndex}`);return p?N0.createPortal(N,p):N}const il="model-assignment-tour",Sv=[{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}],kv={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"},qi=[{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 Cg(l){return l?l.replace(/\/+$/,"").toLowerCase():""}function nS(l){if(!l)return null;const n=Cg(l);return qi.find(i=>i.id!=="custom"&&Cg(i.base_url)===n)||null}const Eo=l=>({...l,max_retry:l.max_retry??2,timeout:l.timeout??30,retry_interval:l.retry_interval??10}),rS=(l,n=[],i=null)=>{const c={};return l?(l.name?.trim()?n.some((x,h)=>i!==null&&h===i?!1:x.name.trim().toLowerCase()===l.name.trim().toLowerCase())&&(c.name="提供商名称已存在,请使用其他名称"):c.name="请输入提供商名称",l.base_url?.trim()||(c.base_url="请输入基础 URL"),l.api_key?.trim()||(c.api_key="请输入 API Key"),{isValid:Object.keys(c).length===0,errors:c}):{isValid:!1,errors:{name:"提供商数据为空"}}};function iS(){return e.jsx(Jn,{children:e.jsx(cS,{})})}function cS(){const[l,n]=d.useState([]),[i,c]=d.useState(!0),[u,x]=d.useState(!1),[h,f]=d.useState(!1),[p,g]=d.useState(!1),[N,v]=d.useState(!1),[b,w]=d.useState(null),[y,R]=d.useState(null),[O,S]=d.useState("custom"),[B,E]=d.useState(!1),[C,z]=d.useState(!1),[H,L]=d.useState(null),[J,U]=d.useState(!1),[oe,Ne]=d.useState(""),[je,re]=d.useState(new Set),[fe,ge]=d.useState(!1),[M,K]=d.useState(1),[I,ue]=d.useState(20),[Q,Se]=d.useState(""),[pe,Te]=d.useState({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),[A,D]=d.useState({}),[V,de]=d.useState(new Set),[Oe,W]=d.useState(new Map),{toast:Y}=Zs(),He=ca(),{state:F,goToStep:ee,registerTour:Ue}=rx(),{triggerRestart:ie,isRestarting:Ee}=vn(),me=d.useRef(null),ze=d.useRef(!0);d.useEffect(()=>{Ue(il,Sv)},[Ue]),d.useEffect(()=>{if(F.activeTourId===il&&F.isRunning){const se=kv[F.stepIndex];se&&!window.location.pathname.endsWith(se.replace("/config/",""))&&He({to:se})}},[F.stepIndex,F.activeTourId,F.isRunning,He]);const rs=d.useRef(F.stepIndex);d.useEffect(()=>{if(F.activeTourId===il&&F.isRunning){const se=rs.current,we=F.stepIndex;se>=3&&se<=9&&we<3&&v(!1),se>=10&&we>=3&&we<=9&&(D({}),S("custom"),w({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),R(null),U(!1),v(!0)),rs.current=we}},[F.stepIndex,F.activeTourId,F.isRunning]),d.useEffect(()=>{if(F.activeTourId!==il||!F.isRunning)return;const se=we=>{const Le=we.target,Hs=F.stepIndex;Hs===2&&Le.closest('[data-tour="add-provider-button"]')?setTimeout(()=>ee(3),300):Hs===9&&Le.closest('[data-tour="provider-cancel-button"]')&&setTimeout(()=>ee(10),300)};return document.addEventListener("click",se,!0),()=>document.removeEventListener("click",se,!0)},[F,ee]),d.useEffect(()=>{Ut()},[]);const Ut=async()=>{try{c(!0);const se=await un();n(se.api_providers||[]),g(!1),ze.current=!1}catch(se){console.error("加载配置失败:",se)}finally{c(!1)}},aa=async()=>{await ie()},Qa=async()=>{try{x(!0),me.current&&clearTimeout(me.current);const se=l.map(rt=>({...rt,max_retry:rt.max_retry??2,timeout:rt.timeout??30,retry_interval:rt.retry_interval??10})),{shouldProceed:we}=await Ft(se,"restart");if(!we){x(!1);return}const Le=await un(),Hs=new Set(se.map(rt=>rt.name)),Wt=(Le.models||[]).filter(rt=>Hs.has(rt.api_provider));Le.api_providers=se,Le.models=Wt,await Xi(Le),g(!1),Y({title:"保存成功",description:"正在重启麦麦..."}),await aa()}catch(se){console.error("保存配置失败:",se),Y({title:"保存失败",description:se.message,variant:"destructive"}),x(!1)}},Ft=d.useCallback(async(se,we="auto")=>{try{const Le=await un(),Hs=new Set(l.map(xt=>xt.name)),Dt=new Set(se.map(xt=>xt.name)),Wt=Array.from(Hs).filter(xt=>!Dt.has(xt));if(Wt.length===0)return{shouldProceed:!0,providers:se};const ea=(Le.models||[]).filter(xt=>Wt.includes(xt.api_provider));return ea.length===0?{shouldProceed:!0,providers:se}:(Te({isOpen:!0,providersToDelete:Wt,affectedModels:ea,pendingProviders:se,context:we,oldProviders:[...l]}),{shouldProceed:!1,providers:se})}catch(Le){return console.error("检查删除影响失败:",Le),{shouldProceed:!0,providers:se}}},[l]),mt=async()=>{try{(pe.context==="auto"?f:x)(!0),Te(xt=>({...xt,isOpen:!1}));const we=await un(),Le=pe.pendingProviders.map(Eo),Hs=new Set(Le.map(xt=>xt.name)),Wt=(we.models||[]).filter(xt=>Hs.has(xt.api_provider)),rt=new Set(pe.affectedModels.map(xt=>xt.name)),ea=we.model_task_config;ea&&Object.keys(ea).forEach(xt=>{const ne=ea[xt];ne&&Array.isArray(ne.model_list)&&(ne.model_list=ne.model_list.filter(he=>!rt.has(he)))}),we.api_providers=Le,we.models=Wt,we.model_task_config=ea,await Xi(we),n(pe.pendingProviders),g(!1),Y({title:"删除成功",description:`已删除 ${pe.providersToDelete.length} 个提供商和 ${pe.affectedModels.length} 个关联模型`}),Te({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),re(new Set),pe.context==="restart"&&await aa()}catch(se){console.error("删除失败:",se),Y({title:"删除失败",description:se.message,variant:"destructive"})}finally{pe.context==="auto"?f(!1):x(!1)}},q=()=>{pe.oldProviders.length>0&&n(pe.oldProviders),Te({isOpen:!1,providersToDelete:[],affectedModels:[],pendingProviders:[],context:"auto",oldProviders:[]}),g(!1)},qe=d.useCallback(async se=>{if(ze.current)return;const{shouldProceed:we}=await Ft(se,"auto");if(!we){g(!0);return}try{f(!0);const Le=se.map(Eo);await Im("api_providers",Le),g(!1)}catch(Le){console.error("自动保存失败:",Le),Y({title:"自动保存失败",description:Le.message,variant:"destructive"}),g(!0)}finally{f(!1)}},[l,Ft]);d.useEffect(()=>{if(!ze.current)return g(!0),me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{qe(l)},2e3),()=>{me.current&&clearTimeout(me.current)}},[l,qe]);const Qe=async()=>{try{x(!0),me.current&&clearTimeout(me.current);const se=l.map(Eo),{shouldProceed:we}=await Ft(se,"manual");if(!we){x(!1);return}const Le=await un(),Hs=new Set(se.map(rt=>rt.name)),Dt=Le.models||[],Wt=Dt.filter(rt=>{const ea=Hs.has(rt.api_provider);return ea||console.warn(`模型 "${rt.name}" 引用了已删除的提供商 "${rt.api_provider}",将被移除`),ea});if(Dt.length!==Wt.length){const rt=Dt.length-Wt.length;Y({title:"注意",description:`已自动移除 ${rt} 个引用已删除提供商的模型`,variant:"default"})}console.log("发送的 providers 数据:",se),Le.api_providers=se,Le.models=Wt,console.log("完整配置数据:",Le),await Xi(Le),g(!1),Y({title:"保存成功",description:"模型提供商配置已保存"})}catch(se){console.error("保存配置失败:",se),Y({title:"保存失败",description:se.message,variant:"destructive"})}finally{x(!1)}},es=(se,we)=>{if(D({}),se){const Le=qi.find(Hs=>Hs.base_url===se.base_url&&Hs.client_type===se.client_type);S(Le?.id||"custom"),w(se)}else S("custom"),w({name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10});R(we),U(!1),v(!0)},Ls=d.useCallback(se=>{S(se),E(!1);const we=qi.find(Le=>Le.id===se);we&&we.id!=="custom"?w(Le=>({...Le,name:we.name,base_url:we.base_url,client_type:we.client_type})):we?.id==="custom"&&w(Le=>({...Le,name:"",base_url:"",client_type:"openai"}))},[]),as=d.useMemo(()=>O!=="custom",[O]),Cs=d.useCallback(async()=>{if(b?.api_key)try{await navigator.clipboard.writeText(b.api_key),Y({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{Y({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},[b?.api_key,Y]),Ae=()=>{if(!b)return;const{isValid:se,errors:we}=rS(b,l,y);if(!se){D(we);return}D({});const Le=Eo(b);if(y!==null){const Hs=[...l];Hs[y]=Le,n(Hs)}else n([...l,Le]);v(!1),w(null),R(null)},bs=se=>{if(!se&&b){const we={...b,max_retry:b.max_retry??2,timeout:b.timeout??30,retry_interval:b.retry_interval??10};w(we)}v(se)},ls=se=>{L(se),z(!0)},ss=async()=>{if(H!==null){const se=l.filter((Le,Hs)=>Hs!==H),{shouldProceed:we}=await Ft(se,"manual");we&&(n(se),Y({title:"删除成功",description:"提供商已从列表中移除"}))}z(!1),L(null)},ys=se=>{const we=new Set(je);we.has(se)?we.delete(se):we.add(se),re(we)},gt=()=>{if(je.size===Ms.length)re(new Set);else{const se=Ms.map((we,Le)=>l.findIndex(Hs=>Hs===Ms[Le]));re(new Set(se))}},$t=()=>{if(je.size===0){Y({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}ge(!0)},tt=async()=>{const se=l.filter((Le,Hs)=>!je.has(Hs)),{shouldProceed:we}=await Ft(se,"manual");we&&(n(se),re(new Set),Y({title:"批量删除成功",description:`已删除 ${je.size} 个提供商`})),ge(!1)},Ms=d.useMemo(()=>{if(!oe)return l;const se=oe.toLowerCase();return l.filter(we=>we.name.toLowerCase().includes(se)||we.base_url.toLowerCase().includes(se)||we.client_type.toLowerCase().includes(se))},[l,oe]),{totalPages:Et,paginatedProviders:Bt}=d.useMemo(()=>{const se=Math.ceil(Ms.length/I),we=Ms.slice((M-1)*I,M*I);return{totalPages:se,paginatedProviders:we}},[Ms,M,I]),Oa=d.useCallback(()=>{const se=parseInt(Q);se>=1&&se<=Et&&(K(se),Se(""))},[Q,Et]),tl=async se=>{de(we=>new Set(we).add(se));try{const we=await I2(se);W(Le=>new Map(Le).set(se,we)),we.network_ok?we.api_key_valid===!0?Y({title:"连接正常",description:`${se} 网络连接正常,API Key 有效 (${we.latency_ms}ms)`}):we.api_key_valid===!1?Y({title:"连接正常但 Key 无效",description:`${se} 网络连接正常,但 API Key 无效或已过期`,variant:"destructive"}):Y({title:"网络连接正常",description:`${se} 可以访问 (${we.latency_ms}ms)`}):Y({title:"连接失败",description:we.error||"无法连接到提供商",variant:"destructive"})}catch(we){Y({title:"测试失败",description:we.message,variant:"destructive"})}finally{de(we=>{const Le=new Set(we);return Le.delete(se),Le})}},ul=async()=>{for(const se of l)await tl(se.name)},Zn=se=>{const we=V.has(se),Le=Oe.get(se);return we?e.jsxs(ke,{variant:"secondary",className:"gap-1",children:[e.jsx(Bs,{className:"h-3 w-3 animate-spin"}),"测试中"]}):Le?Le.network_ok?Le.api_key_valid===!0?e.jsxs(ke,{className:"gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(pt,{className:"h-3 w-3"}),"正常"]}):Le.api_key_valid===!1?e.jsxs(ke,{variant:"destructive",className:"gap-1",children:[e.jsx(_t,{className:"h-3 w-3"}),"Key无效"]}):e.jsxs(ke,{className:"gap-1 bg-blue-600 hover:bg-blue-700",children:[e.jsx(pt,{className:"h-3 w-3"}),"可访问"]}):e.jsxs(ke,{variant:"destructive",className:"gap-1",children:[e.jsx(Va,{className:"h-3 w-3"}),"离线"]}):null};return i?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:$t,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ns,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",je.size,")"]}),e.jsxs(_,{onClick:ul,size:"sm",variant:"outline",className:"w-full sm:w-auto",disabled:l.length===0||V.size>0,children:[e.jsx(Za,{className:"mr-2 h-4 w-4"}),V.size>0?`测试中 (${V.size})`:"测试全部"]}),e.jsxs(_,{onClick:()=>es(null,null),size:"sm",className:"w-full sm:w-auto","data-tour":"add-provider-button",children:[e.jsx(et,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(_,{onClick:Qe,disabled:u||h||!p||Ee,size:"sm",variant:"outline",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(dc,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),u?"保存中...":h?"自动保存中...":p?"保存配置":"已保存"]}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{disabled:u||h||Ee,size:"sm",className:"w-full sm:w-auto sm:min-w-[120px]",children:[e.jsx(oc,{className:"mr-2 h-4 w-4"}),Ee?"重启中...":p?"保存并重启":"重启麦麦"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认重启麦麦?"}),e.jsx(fs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:p?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:p?Qa:aa,children:p?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsxs(lt,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Je,{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(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索提供商名称、URL 或类型...",value:oe,onChange:se=>Ne(se.target.value),className:"pl-9"})]}),oe&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Ms.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:Ms.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:oe?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):Bt.map((se,we)=>{const Le=l.findIndex(Hs=>Hs===se);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:se.name}),Zn(se.name)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:se.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>tl(se.name),disabled:V.has(se.name),title:"测试连接",children:V.has(se.name)?e.jsx(Bs,{className:"h-4 w-4 animate-spin"}):e.jsx(Za,{className:"h-4 w-4"})}),e.jsx(_,{variant:"default",size:"sm",onClick:()=>es(se,Le),children:e.jsx(Gn,{className:"h-4 w-4",strokeWidth:2,fill:"none"})}),e.jsx(_,{size:"sm",onClick:()=>ls(Le),className:"bg-red-600 hover:bg-red-700 text-white",children:e.jsx(ns,{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:se.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:se.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:se.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:se.retry_interval})]})]})]},we)})}),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(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{className:"w-12",children:e.jsx(qs,{checked:je.size===Ms.length&&Ms.length>0,onCheckedChange:gt})}),e.jsx(We,{children:"状态"}),e.jsx(We,{children:"名称"}),e.jsx(We,{children:"基础URL"}),e.jsx(We,{children:"客户端类型"}),e.jsx(We,{className:"text-right",children:"最大重试"}),e.jsx(We,{className:"text-right",children:"超时(秒)"}),e.jsx(We,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(We,{className:"text-right",children:"操作"})]})}),e.jsx(Ul,{children:Bt.length===0?e.jsx(ut,{children:e.jsx(Ke,{colSpan:9,className:"text-center text-muted-foreground py-8",children:oe?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):Bt.map((se,we)=>{const Le=l.findIndex(Hs=>Hs===se);return e.jsxs(ut,{children:[e.jsx(Ke,{children:e.jsx(qs,{checked:je.has(Le),onCheckedChange:()=>ys(Le)})}),e.jsx(Ke,{children:Zn(se.name)||e.jsx(ke,{variant:"outline",className:"text-muted-foreground",children:"未测试"})}),e.jsx(Ke,{className:"font-medium",children:se.name}),e.jsx(Ke,{className:"max-w-xs truncate",title:se.base_url,children:se.base_url}),e.jsx(Ke,{children:se.client_type}),e.jsx(Ke,{className:"text-right",children:se.max_retry}),e.jsx(Ke,{className:"text-right",children:se.timeout}),e.jsx(Ke,{className:"text-right",children:se.retry_interval}),e.jsx(Ke,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>tl(se.name),disabled:V.has(se.name),title:"测试连接",children:V.has(se.name)?e.jsx(Bs,{className:"h-4 w-4 animate-spin"}):e.jsx(Za,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"default",size:"sm",onClick:()=>es(se,Le),children:[e.jsx(Gn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>ls(Le),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},we)})})]})})}),Ms.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(Ie,{value:I.toString(),onValueChange:se=>{ue(parseInt(se)),K(1),re(new Set)},children:[e.jsx($e,{id:"page-size-provider",className:"w-20",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10"}),e.jsx(Z,{value:"20",children:"20"}),e.jsx(Z,{value:"50",children:"50"}),e.jsx(Z,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(M-1)*I+1," 到"," ",Math.min(M*I,Ms.length)," 条,共 ",Ms.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>K(1),disabled:M===1,className:"hidden sm:flex",children:e.jsx(gn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>K(se=>Math.max(1,se-1)),disabled:M===1,children:[e.jsx(Aa,{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(ae,{type:"number",value:Q,onChange:se=>Se(se.target.value),onKeyDown:se=>se.key==="Enter"&&Oa(),placeholder:M.toString(),className:"w-16 h-8 text-center",min:1,max:Et}),e.jsx(_,{variant:"outline",size:"sm",onClick:Oa,disabled:!Q,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>K(se=>se+1),disabled:M>=Et,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Zt,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>K(Et),disabled:M>=Et,className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})]}),e.jsx(Is,{open:N,onOpenChange:bs,children:e.jsxs(Os,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"provider-dialog",preventOutsideClose:F.isRunning,children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:y!==null?"编辑提供商":"添加提供商"}),e.jsx(Ks,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("form",{onSubmit:se=>{se.preventDefault(),Ae()},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(ol,{open:B,onOpenChange:E,children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":B,className:"w-full justify-between",children:[O?qi.find(se=>se.id===O)?.display_name:"选择提供商模板...",e.jsx(Jm,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Wa,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(ad,{children:[e.jsx(ld,{placeholder:"搜索提供商模板..."}),e.jsx(Je,{className:"h-[300px]",children:e.jsxs(nd,{className:"max-h-none overflow-visible",children:[e.jsx(rd,{children:"未找到匹配的模板"}),e.jsx(lc,{children:qi.map(se=>e.jsxs(nc,{value:se.display_name,onSelect:()=>Ls(se.id),children:[e.jsx(Ct,{className:`mr-2 h-4 w-4 ${O===se.id?"opacity-100":"opacity-0"}`}),se.display_name]},se.id))})]})})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"选择预设模板可自动填充 URL 和客户端类型,支持搜索"})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-name-input",children:[e.jsx(T,{htmlFor:"name",className:A.name?"text-destructive":"",children:"名称 *"}),e.jsx(ae,{id:"name",value:b?.name||"",onChange:se=>{w(we=>we?{...we,name:se.target.value}:null),A.name&&D(we=>({...we,name:void 0}))},placeholder:"例如: DeepSeek, SiliconFlow",className:A.name?"border-destructive focus-visible:ring-destructive":""}),A.name&&e.jsx("p",{className:"text-xs text-destructive",children:A.name})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-url-input",children:[e.jsx(T,{htmlFor:"base_url",className:A.base_url?"text-destructive":"",children:"基础 URL *"}),e.jsx(ae,{id:"base_url",value:b?.base_url||"",onChange:se=>{w(we=>we?{...we,base_url:se.target.value}:null),A.base_url&&D(we=>({...we,base_url:void 0}))},placeholder:"https://api.example.com/v1",disabled:as,className:`${as?"bg-muted cursor-not-allowed":""} ${A.base_url?"border-destructive focus-visible:ring-destructive":""}`}),A.base_url&&e.jsx("p",{className:"text-xs text-destructive",children:A.base_url}),as&&!A.base_url&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时 URL 不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid gap-2","data-tour":"provider-apikey-input",children:[e.jsx(T,{htmlFor:"api_key",className:A.api_key?"text-destructive":"",children:"API Key *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{id:"api_key",type:J?"text":"password",value:b?.api_key||"",onChange:se=>{w(we=>we?{...we,api_key:se.target.value}:null),A.api_key&&D(we=>({...we,api_key:void 0}))},placeholder:"sk-...",className:`flex-1 ${A.api_key?"border-destructive focus-visible:ring-destructive":""}`}),e.jsx(_,{type:"button",variant:"outline",size:"icon",onClick:()=>U(!J),title:J?"隐藏密钥":"显示密钥",children:J?e.jsx(ec,{className:"h-4 w-4"}):e.jsx(ia,{className:"h-4 w-4"})}),e.jsx(_,{type:"button",variant:"outline",size:"icon",onClick:Cs,title:"复制密钥",children:e.jsx(Uo,{className:"h-4 w-4"})})]}),A.api_key&&e.jsx("p",{className:"text-xs text-destructive",children:A.api_key})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"client_type",children:"客户端类型"}),e.jsxs(Ie,{value:b?.client_type||"openai",onValueChange:se=>w(we=>we?{...we,client_type:se}:null),disabled:as,children:[e.jsx($e,{id:"client_type",className:as?"bg-muted cursor-not-allowed":"",children:e.jsx(Pe,{placeholder:"选择客户端类型"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"openai",children:"OpenAI"}),e.jsx(Z,{value:"gemini",children:"Gemini"})]})]}),as&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'使用模板时客户端类型不可编辑,切换到"自定义"以手动配置'})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(ae,{id:"max_retry",type:"number",min:"0",value:b?.max_retry??"",onChange:se=>{const we=se.target.value===""?null:parseInt(se.target.value);w(Le=>Le?{...Le,max_retry:we}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(ae,{id:"timeout",type:"number",min:"1",value:b?.timeout??"",onChange:se=>{const we=se.target.value===""?null:parseInt(se.target.value);w(Le=>Le?{...Le,timeout:we}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(ae,{id:"retry_interval",type:"number",min:"1",value:b?.retry_interval??"",onChange:se=>{const we=se.target.value===""?null:parseInt(se.target.value);w(Le=>Le?{...Le,retry_interval:we}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs(st,{children:[e.jsx(_,{type:"button",variant:"outline",onClick:()=>v(!1),"data-tour":"provider-cancel-button",children:"取消"}),e.jsx(_,{type:"submit","data-tour":"provider-save-button",children:"保存"})]})]})]})}),e.jsx(Ns,{open:C,onOpenChange:z,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除提供商 "',H!==null?l[H]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:ss,children:"删除"})]})]})}),e.jsx(Ns,{open:fe,onOpenChange:ge,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认批量删除"}),e.jsxs(fs,{children:["确定要删除选中的 ",je.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:tt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),e.jsx(Ns,{open:pe.isOpen,onOpenChange:se=>Te(we=>({...we,isOpen:se})),children:e.jsxs(us,{className:"max-w-2xl",children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除提供商"}),e.jsx(fs,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["您即将删除以下提供商:",e.jsx("strong",{className:"text-foreground ml-1",children:pe.providersToDelete.join(", ")})]}),e.jsxs("p",{className:"text-yellow-600 dark:text-yellow-500 font-medium",children:["⚠️ 此操作将同时删除 ",pe.affectedModels.length," 个关联的模型:"]}),e.jsx(Je,{className:"h-32 w-full rounded border p-3",children:e.jsx("div",{className:"space-y-1",children:pe.affectedModels.map((se,we)=>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:se.name}),e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",se.model_identifier,")"]})]},we))})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"这些模型将从模型列表和所有任务分配中移除。此操作无法撤销。"})]})})]}),e.jsxs(xs,{children:[e.jsx(gs,{onClick:q,children:"取消"}),e.jsx(ps,{onClick:mt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})}),e.jsx(Xn,{})]})}function Zi(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,11)}`}function Em(l){return l===null?"null":Array.isArray(l)?"array":typeof l=="object"?"object":typeof l=="boolean"?"boolean":typeof l=="number"?"number":"string"}function Pm(l){return Object.entries(l).map(([n,i])=>{const c=Em(i),u={id:Zi(),key:n,value:i,type:c,expanded:!0};return c==="object"&&i&&typeof i=="object"?u.children=Pm(i):c==="array"&&Array.isArray(i)&&(u.children=i.map((x,h)=>{const f=Em(x),p={id:Zi(),key:String(h),value:x,type:f,expanded:!0};return f==="object"&&x&&typeof x=="object"?p.children=Pm(x):f==="array"&&Array.isArray(x)&&(p.children=x.map((g,N)=>({id:Zi(),key:String(N),value:g,type:Em(g),expanded:!0}))),p})),u})}function Hm(l){const n={};for(const i of l)i.key.trim()&&(i.type==="object"&&i.children?n[i.key]=Hm(i.children):i.type==="array"&&i.children?n[i.key]=i.children.map(c=>c.type==="object"&&c.children?Hm(c.children):c.type==="array"&&c.children?c.children.map(u=>u.value):c.value):i.type==="null"?n[i.key]=null:n[i.key]=i.value);return n}function Tg(l,n){switch(n){case"boolean":return l==="true";case"number":{const i=parseFloat(l);return isNaN(i)?0:i}case"null":return null;default:return l}}function Cv({node:l,level:n,onUpdate:i,onRemove:c,onAddChild:u,onToggleExpand:x}){const h=l.type==="object"||l.type==="array",f=l.children&&l.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:`${n*20}px`},children:[e.jsx(_,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>x(l.id),disabled:!h||!f,children:h&&f?l.expanded?e.jsx(Ma,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"}):e.jsx("span",{className:"w-4"})}),e.jsx(ae,{value:l.key,onChange:p=>i(l.id,"key",p.target.value),placeholder:"key",className:"h-8 text-sm"}),!h&&e.jsx(e.Fragment,{children:l.type==="boolean"?e.jsxs("div",{className:"flex items-center h-8 px-3 border rounded-md bg-background",children:[e.jsx(Ge,{checked:l.value===!0,onCheckedChange:p=>i(l.id,"value",p)}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:l.value?"true":"false"})]}):l.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(ae,{type:l.type==="number"?"number":"text",value:l.value,onChange:p=>i(l.id,"value",p.target.value),placeholder:"value",className:"h-8 text-sm",step:l.type==="number"?"any":void 0})}),e.jsxs(Ie,{value:l.type,onValueChange:p=>i(l.id,"type",p),children:[e.jsx($e,{className:"h-8 text-xs",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"string",children:"字符串"}),e.jsx(Z,{value:"number",children:"数字"}),e.jsx(Z,{value:"boolean",children:"布尔"}),e.jsx(Z,{value:"null",children:"Null"}),e.jsx(Z,{value:"object",children:"对象"}),e.jsx(Z,{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:()=>u(l.id),title:"添加子项",children:e.jsx(et,{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(l.id),title:"删除",children:e.jsx(ns,{className:"h-4 w-4"})})]})]}),h&&l.expanded&&l.children&&l.children.length>0&&e.jsx("div",{className:"space-y-1",children:l.children.map(p=>e.jsx(Cv,{node:p,level:n+1,onUpdate:i,onRemove:c,onAddChild:u,onToggleExpand:x},p.id))})]})}function oS({value:l,onChange:n,placeholder:i="添加参数..."}){const[c,u]=d.useState(()=>Pm(l||{})),x=d.useCallback(v=>{u(v),n(Hm(v))},[n]),h=d.useCallback(()=>{const v={id:Zi(),key:"",value:"",type:"string",expanded:!1};x([...c,v])},[c,x]),f=d.useCallback((v,b,w)=>{const y=R=>R.map(O=>{if(O.id===v)if(b==="type"){const S=w;if(S==="object")return{...O,type:S,value:{},children:[]};if(S==="array")return{...O,type:S,value:[],children:[]};if(S==="null")return{...O,type:S,value:null};{const B=Tg(String(O.value),S);return{...O,type:S,value:B,children:void 0}}}else if(b==="value"){const S=Tg(String(w),O.type);return{...O,value:S}}else return{...O,[b]:String(w)};return O.children?{...O,children:y(O.children)}:O});x(y(c))},[c,x]),p=d.useCallback(v=>{const b=w=>w.filter(y=>y.id!==v).map(y=>y.children?{...y,children:b(y.children)}:y);x(b(c))},[c,x]),g=d.useCallback(v=>{const b=w=>w.map(y=>{if(y.id===v){const R={id:Zi(),key:y.type==="array"?String(y.children?.length||0):"",value:"",type:"string",expanded:!0};return{...y,children:[...y.children||[],R]}}return y.children?{...y,children:b(y.children)}:y});x(b(c))},[c,x]),N=d.useCallback(v=>{const b=w=>w.map(y=>y.id===v?{...y,expanded:!y.expanded}:y.children?{...y,children:b(y.children)}:y);u(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(et,{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:i}):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(v=>e.jsx(Cv,{node:v,level:0,onUpdate:f,onRemove:p,onAddChild:g,onToggleExpand:N},v.id))]})})]})}function Eg(l){if(!l.trim())return{valid:!0,parsed:{}};try{const n=JSON.parse(l);return typeof n!="object"||n===null||Array.isArray(n)?{valid:!1,error:"必须是一个 JSON 对象 {}"}:{valid:!0,parsed:n}}catch{return{valid:!1,error:"JSON 格式错误"}}}function dS({value:l,onChange:n,className:i,placeholder:c="添加额外参数..."}){const[u,x]=d.useState("list"),h=d.useMemo(()=>Object.keys(l||{}).length>0?JSON.stringify(l,null,2):"",[l]),[f,p]=d.useState(h),[g,N]=d.useState(null);d.useEffect(()=>{p(h)},[h]);const v=d.useMemo(()=>{const y=Eg(f);return y.valid&&y.parsed?{success:!0,data:y.parsed}:{success:!1,data:{}}},[f]),b=d.useCallback(y=>{const R=y;R==="json"&&u==="list"&&(p(Object.keys(l).length>0?JSON.stringify(l,null,2):""),N(null)),x(R)},[u,l]),w=d.useCallback(y=>{p(y);const R=Eg(y);R.valid&&R.parsed?(N(null),n(R.parsed)):N(R.error||"JSON 格式错误")},[n]);return e.jsx("div",{className:P("h-full flex flex-col",i),children:e.jsxs(ta,{value:u,onValueChange:b,className:"w-full flex-1 flex flex-col",children:[e.jsxs(Xt,{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(ws,{value:"list",className:"mt-2 flex-1 flex flex-col overflow-hidden data-[state=inactive]:hidden data-[state=inactive]:h-0",children:e.jsx(oS,{value:l,onChange:n,placeholder:c})}),e.jsx(ws,{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(_t,{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(Ct,{className:"h-3 w-3"}),e.jsx("span",{children:"有效"})]})]}),e.jsx(ot,{value:f,onChange:y=>w(y.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:v.success&&Object.keys(v.data).length>0?e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words",children:JSON.stringify(v.data,null,2)}):v.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 uS({open:l,onOpenChange:n,value:i,onChange:c}){const[u,x]=d.useState(i),h=g=>{g&&x(i),n(g)},f=()=>{c(u),n(!1)},p=()=>{x(i),n(!1)};return e.jsx(Is,{open:l,onOpenChange:h,children:e.jsxs(Os,{className:"max-w-3xl h-[70vh] flex flex-col",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"编辑额外参数"}),e.jsx(Ks,{children:"配置模型调用时的额外参数,支持嵌套对象和数组"})]}),e.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:e.jsx(dS,{value:u,onChange:x,placeholder:"添加额外参数(如 thinking、top_p 等)..."})}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:p,children:"取消"}),e.jsx(_,{onClick:f,children:"保存"})]})]})})}const Yr="https://maibot-plugin-stats.maibot-webui.workers.dev";async function mS(l){const n=new URLSearchParams;l?.status&&n.set("status",l.status),l?.page&&n.set("page",l.page.toString()),l?.page_size&&n.set("page_size",l.page_size.toString()),l?.search&&n.set("search",l.search),l?.sort_by&&n.set("sort_by",l.sort_by),l?.sort_order&&n.set("sort_order",l.sort_order);const i=await fetch(`${Yr}/pack?${n.toString()}`);if(!i.ok)throw new Error(`获取 Pack 列表失败: ${i.status}`);return i.json()}async function xS(l){const n=await fetch(`${Yr}/pack/${l}`);if(!n.ok)throw new Error(`获取 Pack 失败: ${n.status}`);const i=await n.json();if(!i.success)throw new Error(i.error||"获取 Pack 失败");return i.pack}async function hS(l){const i=await(await fetch(`${Yr}/pack`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).json();if(!i.success)throw new Error(i.error||"创建 Pack 失败");return i}async function fS(l,n){await fetch(`${Yr}/pack/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pack_id:l,user_id:n})})}async function Tv(l,n){const c=await(await fetch(`${Yr}/pack/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pack_id:l,user_id:n})})).json();if(!c.success)throw new Error(c.error||"点赞失败");return{likes:c.likes,liked:c.liked}}async function Ev(l,n){return(await(await fetch(`${Yr}/pack/like/check?pack_id=${l}&user_id=${n}`)).json()).liked||!1}async function pS(l){const n=await _e("/api/webui/config/model");if(!n.ok)throw new Error("获取当前模型配置失败");const i=await n.json(),c=i.config||i;console.log("=== Pack Conflict Detection ==="),console.log("Pack providers:",l.providers),console.log("Local providers:",c.api_providers);const u={existing_providers:[],new_providers:[],conflicting_models:[]},x=c.api_providers||[];for(const f of l.providers){console.log(`
|
||
Checking pack provider: ${f.name}`),console.log(` Pack URL: ${f.base_url}`),console.log(` Normalized: ${Mm(f.base_url)}`);const p=x.filter(g=>{const N=Mm(g.base_url),v=Mm(f.base_url);return console.log(` Comparing with local "${g.name}": ${g.base_url}`),console.log(` Local normalized: ${N}`),console.log(` Match: ${N===v}`),N===v});p.length>0?(console.log(` ✓ Matched with ${p.length} local provider(s):`,p.map(g=>g.name).join(", ")),u.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"),u.new_providers.push(f))}const h=c.models||[];console.log(`
|
||
=== Model Conflict Detection ===`);for(const f of l.models){const p=h.find(g=>g.name===f.name);p&&(console.log(`Model conflict: ${f.name}`),u.conflicting_models.push({pack_model:f.name,local_model:p.name}))}return console.log(`
|
||
=== Detection Summary ===`),console.log(`Existing providers: ${u.existing_providers.length}`),console.log(`New providers: ${u.new_providers.length}`),console.log(`Conflicting models: ${u.conflicting_models.length}`),console.log(`===========================
|
||
`),u}async function gS(l,n,i,c){const u=await _e("/api/webui/config/model");if(!u.ok)throw new Error("获取当前模型配置失败");const x=await u.json(),h=x.config||x;if(n.apply_providers){const p=n.selected_providers?l.providers.filter(g=>n.selected_providers.includes(g.name)):l.providers;for(const g of p){if(i[g.name])continue;const N=c[g.name];if(!N)throw new Error(`提供商 "${g.name}" 缺少 API Key`);const v={...g,api_key:N},b=h.api_providers.findIndex(w=>w.name===g.name);b>=0?h.api_providers[b]=v:h.api_providers.push(v)}}if(n.apply_models){const p=n.selected_models?l.models.filter(g=>n.selected_models.includes(g.name)):l.models;for(const g of p){const N=i[g.api_provider]||g.api_provider,v={...g,api_provider:N},b=h.models.findIndex(w=>w.name===g.name);b>=0?h.models[b]=v:h.models.push(v)}}if(n.apply_task_config){const p=n.selected_tasks||Object.keys(l.task_config);for(const g of p){const N=l.task_config[g];if(!N)continue;const v=new Set(n.selected_models||l.models.map(y=>y.name)),b=N.model_list.filter(y=>v.has(y));if(b.length===0)continue;const w={...N,model_list:b};if(n.task_mode==="replace")h.model_task_config[g]=w;else{const y=h.model_task_config[g];if(y){const R=[...new Set([...y.model_list,...b])];h.model_task_config[g]={...y,model_list:R}}else h.model_task_config[g]=w}}}if(!(await _e("/api/webui/config/model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)})).ok)throw new Error("保存配置失败")}async function jS(l){const n=await _e("/api/webui/config/model");if(!n.ok)throw new Error("获取当前模型配置失败");const i=await n.json();if(!i.success||!i.config)throw new Error("获取配置失败");const c=i.config;let u=(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}));l.selectedProviders&&(u=u.filter(g=>l.selectedProviders.includes(g.name)));let x=c.models||[];l.selectedModels&&(x=x.filter(g=>l.selectedModels.includes(g.name)));const h={},f=c.model_task_config||{},p=l.selectedTasks||Object.keys(f);for(const g of p)f[g]&&(h[g]=f[g]);return{providers:u,models:x,task_config:h}}function Mm(l){try{const n=new URL(l);return`${n.protocol}//${n.host}${n.pathname}`.replace(/\/$/,"").toLowerCase()}catch{return l.toLowerCase().replace(/\/$/,"")}}function Mv(){const l="maibot_pack_user_id";let n=localStorage.getItem(l);return n||(n="pack_user_"+Math.random().toString(36).substring(2,15),localStorage.setItem(l,n)),n}const vS={utils:"通用工具",utils_small:"轻量工具",tool_use:"工具调用",replyer:"回复生成",planner:"规划推理",vlm:"视觉模型",voice:"语音处理",embedding:"向量嵌入",lpmm_entity_extract:"实体提取",lpmm_rdf_build:"RDF构建",lpmm_qa:"问答模型"},NS=["官方推荐","性价比","高性能","免费模型","国内可用","海外模型","OpenAI","Claude","Gemini","国产模型","多模态","轻量级"];function bS({trigger:l}){const[n,i]=d.useState(!1),[c,u]=d.useState(1),[x,h]=d.useState(!1),[f,p]=d.useState(!1),[g,N]=d.useState([]),[v,b]=d.useState([]),[w,y]=d.useState({}),[R,O]=d.useState(new Set),[S,B]=d.useState(new Set),[E,C]=d.useState(new Set),[z,H]=d.useState(""),[L,J]=d.useState(""),[U,oe]=d.useState(""),[Ne,je]=d.useState([]);d.useEffect(()=>{n&&c===1&&re()},[n,c]);const re=async()=>{h(!0);try{const A=await jS({name:"",description:"",author:""});N(A.providers),b(A.models),y(A.task_config),O(new Set(A.providers.map(D=>D.name))),B(new Set(A.models.map(D=>D.name))),C(new Set(Object.keys(A.task_config)))}catch(A){console.error("加载配置失败:",A),Qt({title:"加载当前配置失败",variant:"destructive"})}finally{h(!1)}},fe=A=>{const D=new Set(R),V=new Set(S),de=new Set(E);D.has(A)?(D.delete(A),v.filter(W=>W.api_provider===A).forEach(W=>V.delete(W.name)),Object.entries(w).forEach(([W,Y])=>{Y.model_list&&(Y.model_list.some(F=>V.has(F))||de.delete(W))})):(D.add(A),v.filter(W=>W.api_provider===A).forEach(W=>V.add(W.name)),Object.entries(w).forEach(([W,Y])=>{Y.model_list&&Y.model_list.some(F=>{const ee=v.find(Ue=>Ue.name===F);return ee&&ee.api_provider===A})&&de.add(W)})),O(D),B(V),C(de)},ge=A=>{const D=new Set(S),V=new Set(E);D.has(A)?(D.delete(A),Object.entries(w).forEach(([de,Oe])=>{Oe.model_list&&(Oe.model_list.some(Y=>D.has(Y))||V.delete(de))})):(D.add(A),Object.entries(w).forEach(([de,Oe])=>{Oe.model_list&&Oe.model_list.includes(A)&&V.add(de)})),B(D),C(V)},M=A=>{const D=new Set(E);D.has(A)?D.delete(A):D.add(A),C(D)},K=A=>{Ne.includes(A)?je(Ne.filter(D=>D!==A)):Ne.length<5?je([...Ne,A]):Qt({title:"最多选择 5 个标签",variant:"destructive"})},I=()=>{R.size===g.length?O(new Set):O(new Set(g.map(A=>A.name)))},ue=()=>{S.size===v.length?B(new Set):B(new Set(v.map(A=>A.name)))},Q=()=>{const A=Object.keys(w);E.size===A.length?C(new Set):C(new Set(A))},Se=async()=>{if(!z.trim()){Qt({title:"请输入模板名称",variant:"destructive"});return}if(!L.trim()){Qt({title:"请输入模板描述",variant:"destructive"});return}if(!U.trim()){Qt({title:"请输入作者名称",variant:"destructive"});return}if(R.size===0&&S.size===0&&E.size===0){Qt({title:"请至少选择一项配置",variant:"destructive"});return}p(!0);try{const A=g.filter(de=>R.has(de.name)),D=v.filter(de=>S.has(de.name)),V={};for(const[de,Oe]of Object.entries(w))E.has(de)&&(V[de]=Oe);await hS({name:z.trim(),description:L.trim(),author:U.trim(),tags:Ne,providers:A,models:D,task_config:V}),Qt({title:"模板已提交审核,审核通过后将显示在市场中"}),i(!1),pe()}catch(A){console.error("提交失败:",A),Qt({title:A instanceof Error?A.message:"提交失败",variant:"destructive"})}finally{p(!1)}},pe=()=>{u(1),H(""),J(""),oe(""),je([]),O(new Set),B(new Set),C(new Set)},Te=2;return e.jsxs(Is,{open:n,onOpenChange:i,children:[e.jsx(sd,{asChild:!0,children:l||e.jsxs(_,{variant:"outline",children:[e.jsx(Ij,{className:"w-4 h-4 mr-2"}),"分享配置"]})}),e.jsxs(Os,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"w-5 h-5"}),"分享配置模板"]}),e.jsxs(Ks,{children:["步骤 ",c," / ",Te,":",c===1&&"选择要分享的配置",c===2&&"填写模板信息"]})]}),e.jsx(Je,{className:"h-[calc(85vh-220px)] pr-4",children:x?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Bs,{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(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(Hn,{children:"安全提示"}),e.jsxs(lt,{children:["分享的配置将",e.jsx("strong",{children:"不包含"})," API Key,其他用户需要自行配置。"]})]}),e.jsxs(ta,{defaultValue:"providers",className:"w-full",children:[e.jsxs(Xt,{className:"grid w-full grid-cols-3",children:[e.jsxs(Xe,{value:"providers",children:[e.jsx(Dl,{className:"w-4 h-4 mr-2"}),"API 提供商",e.jsxs(ke,{variant:"secondary",className:"ml-2",children:[R.size,"/",g.length]})]}),e.jsxs(Xe,{value:"models",children:[e.jsx(Vn,{className:"w-4 h-4 mr-2"}),"模型配置",e.jsxs(ke,{variant:"secondary",className:"ml-2",children:[S.size,"/",v.length]})]}),e.jsxs(Xe,{value:"tasks",children:[e.jsx(qn,{className:"w-4 h-4 mr-2"}),"任务配置",e.jsxs(ke,{variant:"secondary",className:"ml-2",children:[E.size,"/",Object.keys(w).length]})]})]}),e.jsx(ws,{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:I,children:R.size===g.length?"取消全选":"全选"})}),g.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无提供商配置"}):g.map(A=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 rounded hover:bg-muted",children:[e.jsx(qs,{id:`provider-${A.name}`,checked:R.has(A.name),onCheckedChange:()=>fe(A.name)}),e.jsxs(T,{htmlFor:`provider-${A.name}`,className:"flex-1 cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:A.name}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:A.base_url})]}),e.jsx(ke,{variant:"outline",className:"text-xs",children:A.client_type})]},A.name))]})}),e.jsx(ws,{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===v.length?"取消全选":"全选"})}),v.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无模型配置"}):v.map(A=>e.jsxs("div",{className:"flex items-center space-x-2 p-2 rounded hover:bg-muted",children:[e.jsx(qs,{id:`model-${A.name}`,checked:S.has(A.name),onCheckedChange:()=>ge(A.name)}),e.jsxs(T,{htmlFor:`model-${A.name}`,className:"flex-1 cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:A.name}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:A.model_identifier})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:A.api_provider})]},A.name))]})}),e.jsx(ws,{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:Q,children:E.size===Object.keys(w).length?"取消全选":"全选"})}),Object.keys(w).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"暂无任务配置"}):Object.entries(w).map(([A,D])=>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(qs,{id:`task-${A}`,checked:E.has(A),onCheckedChange:()=>M(A)}),e.jsx(T,{htmlFor:`task-${A}`,className:"flex-1 cursor-pointer",children:e.jsx("span",{className:"font-medium",children:vS[A]||A})}),e.jsxs(ke,{variant:"outline",className:"text-xs",children:[D.model_list.length," 个模型"]})]}),D.model_list&&D.model_list.length>0&&e.jsx("div",{className:"ml-6 flex flex-wrap gap-1",children:D.model_list.map(V=>{const de=v.find(W=>W.name===V),Oe=S.has(V);return e.jsxs(ke,{variant:Oe?"default":"outline",className:"text-xs cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ge(V),children:[V,de&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",de.api_provider,")"]})]},V)})})]},A))]})})]})]}),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(Dl,{className:"w-4 h-4"}),R.size," 个提供商"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vn,{className:"w-4 h-4"}),S.size," 个模型"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qn,{className:"w-4 h-4"}),E.size," 个任务"]})]}),e.jsx(Yt,{}),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(ae,{id:"pack-name",placeholder:"例如:高性价比国产模型配置",value:z,onChange:A=>H(A.target.value),maxLength:50}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[z.length,"/50"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"pack-description",children:"模板描述 *"}),e.jsx(ot,{id:"pack-description",placeholder:"详细描述这个配置模板的特点、适用场景等...",value:L,onChange:A=>J(A.target.value),rows:4,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[L.length,"/500"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"pack-author",children:"作者名称 *"}),e.jsx(ae,{id:"pack-author",placeholder:"你的昵称或 ID",value:U,onChange:A=>oe(A.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:NS.map(A=>e.jsxs(ke,{variant:Ne.includes(A)?"default":"outline",className:"cursor-pointer transition-colors",onClick:()=>K(A),children:[Ne.includes(A)&&e.jsx(Ct,{className:"w-3 h-3 mr-1"}),e.jsx(Wo,{className:"w-3 h-3 mr-1"}),A]},A))})]})]}),e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(Hn,{children:"审核说明"}),e.jsx(lt,{children:"提交后需要经过审核才能在市场中展示。审核通常在 1-3 个工作日内完成。"})]})]})]})}),e.jsxs(st,{className:"flex justify-between pt-4 border-t",children:[e.jsx("div",{children:c>1&&e.jsx(_,{variant:"outline",onClick:()=>u(c-1),disabled:f,children:"上一步"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{variant:"outline",onClick:()=>{i(!1),pe()},disabled:f,children:"取消"}),c<Te?e.jsx(_,{onClick:()=>u(c+1),disabled:x||R.size===0&&S.size===0&&E.size===0,children:"下一步"}):e.jsxs(_,{onClick:Se,disabled:f,children:[f&&e.jsx(Bs,{className:"w-4 h-4 mr-2 animate-spin"}),"提交审核"]})]})]})]})]})}function yS({value:l,label:n,onRemove:i}){const{attributes:c,listeners:u,setNodeRef:x,transform:h,transition:f,isDragging:p}=sv({id:l}),g={transform:tv.Transform.toString(h),transition:f,opacity:p?.5:1},N=b=>{b.preventDefault(),b.stopPropagation(),i(l)},v=b=>{b.stopPropagation()};return e.jsx("div",{ref:x,style:g,className:P("inline-flex items-center gap-1",p&&"shadow-lg"),children:e.jsxs(ke,{variant:"secondary",className:"cursor-move hover:bg-secondary/80 flex items-center gap-1",children:[e.jsx("div",{...c,...u,className:"cursor-grab active:cursor-grabbing flex items-center",children:e.jsx(Uj,{className:"h-3 w-3 text-muted-foreground"})}),e.jsx("span",{children:n}),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:v,onMouseDown:b=>b.stopPropagation(),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),N(b))},children:e.jsx(Ea,{className:"h-3 w-3 hover:text-destructive",strokeWidth:2,fill:"none"})})]})})}function wS({options:l,selected:n,onChange:i,placeholder:c="选择选项...",emptyText:u="未找到选项",className:x}){const[h,f]=d.useState(!1),p=Kj(Po(Jj,{activationConstraint:{distance:8}}),Po(Yj,{coordinateGetter:Qj})),g=b=>{n.includes(b)?i(n.filter(w=>w!==b)):i([...n,b])},N=b=>{i(n.filter(w=>w!==b))},v=b=>{const{active:w,over:y}=b;if(y&&w.id!==y.id){const R=n.indexOf(w.id),O=n.indexOf(y.id);i(Xj(n,R,O))}};return e.jsxs(ol,{open:h,onOpenChange:f,children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":h,className:P("w-full justify-between min-h-10 h-auto",x),children:[e.jsx(Zj,{sensors:p,collisionDetection:Wj,onDragEnd:v,children:e.jsx(ev,{items:n,strategy:R_,children:e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:n.length===0?e.jsx("span",{className:"text-muted-foreground",children:c}):n.map(b=>{const w=l.find(y=>y.value===b);return e.jsx(yS,{value:b,label:w?.label||b,onRemove:N},b)})})})}),e.jsx(Jm,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(Wa,{className:"w-full p-0",align:"start",children:e.jsxs(ad,{children:[e.jsx(ld,{placeholder:"搜索...",className:"h-9"}),e.jsxs(nd,{children:[e.jsx(rd,{children:u}),e.jsx(lc,{children:l.map(b=>{const w=n.includes(b.value);return e.jsxs(nc,{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",w?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Ct,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:b.label})]},b.value)})})]})]})})]})}const Ml=As.memo(function({title:n,description:i,taskConfig:c,modelNames:u,onChange:x,hideTemperature:h=!1,hideMaxTokens:f=!1,dataTour:p}){const g=N=>{x("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:n}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:i})]}),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(wS,{options:u.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(ae,{type:"number",step:"0.1",min:"0",max:"1",value:c.temperature??.3,onChange:N=>{const v=parseFloat(N.target.value);!isNaN(v)&&v>=0&&v<=1&&x("temperature",v)},className:"w-20 h-8 text-sm"})]}),e.jsx(qa,{value:[c.temperature??.3],onValueChange:N=>x("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(ae,{type:"number",step:"1",min:"1",value:c.max_tokens??1024,onChange:N=>x("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(ae,{type:"number",step:"1",min:"1",value:c.slow_threshold??15,onChange:N=>{const v=parseInt(N.target.value);!isNaN(v)&&v>=1&&x("slow_threshold",v)},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(Ie,{value:c.selection_strategy??"balance",onValueChange:N=>x("selection_strategy",N),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择模型选择策略"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"balance",children:"负载均衡(balance)"}),e.jsx(Z,{value:"random",children:"随机选择(random)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"负载均衡:优先选择使用次数少的模型。随机选择:完全随机从模型列表中选择"})]})]})]})}),_S=As.memo(function({paginatedModels:n,allModels:i,onEdit:c,onDelete:u,isModelUsed:x,searchQuery:h}){return n.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:n.map((f,p)=>{const g=i.findIndex(v=>v===f),N=x(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(ke,{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(Gn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>u(g),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{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)})})}),SS=As.memo(function({paginatedModels:n,allModels:i,filteredModels:c,selectedModels:u,onEdit:x,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(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{className:"w-12",children:e.jsx(qs,{checked:u.size===c.length&&c.length>0,onCheckedChange:p})}),e.jsx(We,{className:"w-24",children:"使用状态"}),e.jsx(We,{children:"模型名称"}),e.jsx(We,{children:"模型标识符"}),e.jsx(We,{children:"提供商"}),e.jsx(We,{className:"text-center",children:"温度"}),e.jsx(We,{className:"text-right",children:"输入价格"}),e.jsx(We,{className:"text-right",children:"输出价格"}),e.jsx(We,{className:"text-right",children:"操作"})]})}),e.jsx(Ul,{children:n.length===0?e.jsx(ut,{children:e.jsx(Ke,{colSpan:9,className:"text-center text-muted-foreground py-8",children:N?"未找到匹配的模型":"暂无模型配置"})}):n.map((v,b)=>{const w=i.findIndex(R=>R===v),y=g(v.name);return e.jsxs(ut,{children:[e.jsx(Ke,{children:e.jsx(qs,{checked:u.has(w),onCheckedChange:()=>f(w)})}),e.jsx(Ke,{children:e.jsx(ke,{variant:y?"default":"secondary",className:y?"bg-green-600 hover:bg-green-700":"",children:y?"已使用":"未使用"})}),e.jsx(Ke,{className:"font-medium",children:v.name}),e.jsx(Ke,{className:"max-w-xs truncate",title:v.model_identifier,children:v.model_identifier}),e.jsx(Ke,{children:v.api_provider}),e.jsx(Ke,{className:"text-center",children:v.temperature!=null?v.temperature:e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsxs(Ke,{className:"text-right",children:["¥",v.price_in,"/M"]}),e.jsxs(Ke,{className:"text-right",children:["¥",v.price_out,"/M"]}),e.jsx(Ke,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>x(v,w),children:[e.jsx(Gn,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>h(w),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},b)})})]})})})}),kS=300*1e3,Mg=new Map,CS=[10,20,50,100],TS=As.memo(function({page:n,pageSize:i,totalItems:c,jumpToPage:u,onPageChange:x,onPageSizeChange:h,onJumpToPageChange:f,onJumpToPage:p,onSelectionClear:g}){const N=Math.ceil(c/i),v=w=>{h(parseInt(w)),x(1),g?.()},b=w=>{w.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(Ie,{value:i.toString(),onValueChange:v,children:[e.jsx($e,{id:"page-size-model",className:"w-20",children:e.jsx(Pe,{})}),e.jsx(Be,{children:CS.map(w=>e.jsx(Z,{value:w.toString(),children:w},w))})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(n-1)*i+1," 到"," ",Math.min(n*i,c)," 条,共 ",c," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>x(1),disabled:n===1,className:"hidden sm:flex",children:e.jsx(gn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>x(Math.max(1,n-1)),disabled:n===1,children:[e.jsx(Aa,{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(ae,{type:"number",value:u,onChange:w=>f(w.target.value),onKeyDown:b,placeholder:n.toString(),className:"w-16 h-8 text-center",min:1,max:N}),e.jsx(_,{variant:"outline",size:"sm",onClick:p,disabled:!u,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>x(n+1),disabled:n>=N,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Zt,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>x(N),disabled:n>=N,className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})});function ES(l){const{models:n,taskConfig:i,debounceMs:c=2e3,onSavingChange:u,onUnsavedChange:x}=l,h=d.useRef(null),f=d.useRef(null),p=d.useRef(!0),g=d.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null),f.current&&(clearTimeout(f.current),f.current=null)},[]),N=d.useCallback(w=>{const y={model_identifier:w.model_identifier,name:w.name,api_provider:w.api_provider,price_in:w.price_in??0,price_out:w.price_out??0,force_stream_mode:w.force_stream_mode??!1,extra_params:w.extra_params??{}};return w.temperature!=null&&(y.temperature=w.temperature),w.max_tokens!=null&&(y.max_tokens=w.max_tokens),y},[]),v=d.useCallback(async w=>{try{u?.(!0);const y=w.map(N);await Im("models",y),x?.(!1)}catch(y){console.error("自动保存模型列表失败:",y),x?.(!0)}finally{u?.(!1)}},[u,x,N]),b=d.useCallback(async w=>{try{u?.(!0),await Im("model_task_config",w),x?.(!1)}catch(y){console.error("自动保存任务配置失败:",y),x?.(!0)}finally{u?.(!1)}},[u,x]);return d.useEffect(()=>{if(!p.current)return x?.(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{v(n)},c),()=>{h.current&&clearTimeout(h.current)}},[n,v,c,x]),d.useEffect(()=>{if(!(p.current||!i))return x?.(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{b(i)},c),()=>{f.current&&clearTimeout(f.current)}},[i,b,c,x]),d.useEffect(()=>()=>{g()},[g]),{clearTimers:g,initialLoadRef:p}}function MS(l={}){const{onCloseEditDialog:n}=l,i=ca(),{registerTour:c,startTour:u,state:x,goToStep:h}=rx(),f=d.useRef(x.stepIndex);return d.useEffect(()=>{c(il,Sv)},[c]),d.useEffect(()=>{if(x.activeTourId===il&&x.isRunning){const g=kv[x.stepIndex];g&&!window.location.pathname.endsWith(g.replace("/config/",""))&&i({to:g})}},[x.stepIndex,x.activeTourId,x.isRunning,i]),d.useEffect(()=>{if(x.activeTourId===il&&x.isRunning){const g=f.current,N=x.stepIndex;g>=12&&g<=17&&N<12&&n?.(),f.current=N}},[x.stepIndex,x.activeTourId,x.isRunning,n]),d.useEffect(()=>{if(x.activeTourId!==il||!x.isRunning)return;const g=N=>{const v=N.target,b=x.stepIndex;b===2&&v.closest('[data-tour="add-provider-button"]')?setTimeout(()=>h(3),300):b===9&&v.closest('[data-tour="provider-cancel-button"]')?setTimeout(()=>h(10),300):b===11&&v.closest('[data-tour="add-model-button"]')?setTimeout(()=>h(12),300):b===17&&v.closest('[data-tour="model-cancel-button"]')?setTimeout(()=>h(18),300):b===18&&v.closest('[data-tour="tasks-tab-trigger"]')&&setTimeout(()=>h(19),300)};return document.addEventListener("click",g,!0),()=>document.removeEventListener("click",g,!0)},[x,h]),{startTour:d.useCallback(()=>{u(il)},[u]),isRunning:x.isRunning&&x.activeTourId===il,stepIndex:x.stepIndex}}function zS(l){const{getProviderConfig:n}=l,[i,c]=d.useState([]),[u,x]=d.useState(!1),[h,f]=d.useState(null),[p,g]=d.useState(null),N=d.useCallback(()=>{c([]),f(null),g(null)},[]),v=d.useCallback(async(b,w=!1)=>{const y=n(b);if(!y?.base_url){c([]),g(null),f('提供商配置不完整,请先在"模型提供商配置"中配置');return}if(!y.api_key){c([]),g(null),f('该提供商未配置 API Key,请先在"模型提供商配置"中填写');return}const R=nS(y.base_url);if(g(R),!R?.modelFetcher){c([]),f(null);return}const O=`${b}:${y.base_url}`,S=Mg.get(O);if(!w&&S&&Date.now()-S.timestamp<kS){c(S.models),f(null);return}x(!0),f(null);try{const B=await B2(b,R.modelFetcher.parser,R.modelFetcher.endpoint);c(B),Mg.set(O,{models:B,timestamp:Date.now()})}catch(B){console.error("获取模型列表失败:",B);const E=B.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{x(!1)}},[n]);return{availableModels:i,fetchingModels:u,modelFetchError:h,matchedTemplate:p,fetchModelsForProvider:v,clearModels:N}}function AS(){return e.jsx(Jn,{children:e.jsx(OS,{})})}function OS(){const[l,n]=d.useState([]),[i,c]=d.useState([]),[u,x]=d.useState([]),[h,f]=d.useState([]),[p,g]=d.useState(null),[N,v]=d.useState(!0),[b,w]=d.useState(!1),[y,R]=d.useState(!1),[O,S]=d.useState(!1),[B,E]=d.useState(!1),[C,z]=d.useState(null),[H,L]=d.useState(null),[J,U]=d.useState(!1),[oe,Ne]=d.useState(!1),[je,re]=d.useState(null),[fe,ge]=d.useState(""),[M,K]=d.useState(new Set),[I,ue]=d.useState(!1),[Q,Se]=d.useState(1),[pe,Te]=d.useState(20),[A,D]=d.useState(""),[V,de]=d.useState(!1),[Oe,W]=d.useState(!1),Y=d.useRef([]),He=d.useRef(null),[F,ee]=d.useState([]),[Ue,ie]=d.useState([]),[Ee,me]=d.useState({}),{toast:ze}=Zs(),{triggerRestart:rs,isRestarting:Ut}=vn(),{startTour:aa,isRunning:Qa}=MS({onCloseEditDialog:()=>E(!1)}),{clearTimers:Ft,initialLoadRef:mt}=ES({models:l,taskConfig:p,onSavingChange:R,onUnsavedChange:S}),q=d.useCallback((ne,he)=>{if(!ne)return;const ts=new Set(he.map(ja=>ja.name)),js=[],is=[],jt=[{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:ja,label:Bl}of jt){const Wn=ne[ja];if(!Wn)continue;if(!Wn.model_list||Wn.model_list.length===0){is.push(Bl);continue}const Xr=Wn.model_list.filter(bn=>!ts.has(bn));Xr.length>0&&js.push({taskName:Bl,invalidModels:Xr})}ee(js),ie(is)},[]),qe=d.useCallback(async()=>{try{v(!0);const ne=await un(),he=ne.models||[];n(he),f(he.map(jt=>jt.name));const ts=ne.api_providers||[];c(ts.map(jt=>jt.name)),x(ts);const js=ne.model_task_config||null;g(js),q(js,he);const is=js?.embedding?.model_list||[];Y.current=[...is],S(!1),mt.current=!1}catch(ne){console.error("加载配置失败:",ne)}finally{v(!1)}},[mt,q]);d.useEffect(()=>{qe()},[qe]);const Qe=d.useCallback(ne=>u.find(he=>he.name===ne),[u]),{availableModels:es,fetchingModels:Ls,modelFetchError:as,matchedTemplate:Cs,fetchModelsForProvider:Ae,clearModels:bs}=zS({getProviderConfig:Qe});d.useEffect(()=>{B&&C?.api_provider&&Ae(C.api_provider)},[B,C?.api_provider,Ae]);const ls=async()=>{await rs()},ss=d.useCallback(()=>{if(!p)return;const ne=new Set(l.map(js=>js.name)),he={...p},ts=Object.keys(he);for(const js of ts){const is=he[js];is&&is.model_list&&(is.model_list=is.model_list.filter(jt=>ne.has(jt)))}g(he),ee([]),ze({title:"清理完成",description:"已删除所有无效的模型引用"})},[p,l,ze]),ys=ne=>{const he={model_identifier:ne.model_identifier,name:ne.name,api_provider:ne.api_provider,price_in:ne.price_in??0,price_out:ne.price_out??0,force_stream_mode:ne.force_stream_mode??!1,extra_params:ne.extra_params??{}};return ne.temperature!=null&&(he.temperature=ne.temperature),ne.max_tokens!=null&&(he.max_tokens=ne.max_tokens),he},gt=async()=>{try{w(!0),Ft();const ne=await un();ne.models=l.map(ys),ne.model_task_config=p,await Xi(ne),S(!1),ze({title:"保存成功",description:"正在重启麦麦..."}),await ls()}catch(ne){console.error("保存配置失败:",ne),ze({title:"保存失败",description:ne.message,variant:"destructive"}),w(!1)}},$t=async()=>{try{w(!0),Ft();const ne=await un();ne.models=l.map(ys),ne.model_task_config=p,await Xi(ne),S(!1),ze({title:"保存成功",description:"模型配置已保存"}),await qe()}catch(ne){console.error("保存配置失败:",ne),ze({title:"保存失败",description:ne.message,variant:"destructive"})}finally{w(!1)}},tt=(ne,he)=>{me({}),z(ne||{model_identifier:"",name:"",api_provider:i[0]||"",price_in:0,price_out:0,temperature:null,max_tokens:null,force_stream_mode:!1,extra_params:{}}),L(he),E(!0)},Ms=()=>{if(!C)return;const ne={};if(C.name?.trim()?l.some((jt,ja)=>H!==null&&ja===H?!1:jt.name.trim().toLowerCase()===C.name.trim().toLowerCase())&&(ne.name="模型名称已存在,请使用其他名称"):ne.name="请输入模型名称",C.api_provider?.trim()||(ne.api_provider="请选择 API 提供商"),C.model_identifier?.trim()||(ne.model_identifier="请输入模型标识符"),Object.keys(ne).length>0){me(ne);return}me({});const he={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&&(he.temperature=C.temperature),C.max_tokens!=null&&(he.max_tokens=C.max_tokens);let ts,js=null;if(H!==null?(js=l[H].name,ts=[...l],ts[H]=he):ts=[...l,he],n(ts),f(ts.map(is=>is.name)),js&&js!==he.name&&p){const is=jt=>jt.map(ja=>ja===js?he.name:ja);g({...p,utils:{...p.utils,model_list:is(p.utils?.model_list||[])},tool_use:{...p.tool_use,model_list:is(p.tool_use?.model_list||[])},replyer:{...p.replyer,model_list:is(p.replyer?.model_list||[])},planner:{...p.planner,model_list:is(p.planner?.model_list||[])},vlm:{...p.vlm,model_list:is(p.vlm?.model_list||[])},voice:{...p.voice,model_list:is(p.voice?.model_list||[])},embedding:{...p.embedding,model_list:is(p.embedding?.model_list||[])},lpmm_entity_extract:{...p.lpmm_entity_extract,model_list:is(p.lpmm_entity_extract?.model_list||[])},lpmm_rdf_build:{...p.lpmm_rdf_build,model_list:is(p.lpmm_rdf_build?.model_list||[])}})}E(!1),z(null),L(null),ze({title:H!==null?"模型已更新":"模型已添加",description:'配置将在 2 秒后自动保存,或点击右上角"保存配置"按钮立即保存'})},Et=ne=>{if(!ne&&C){const he={...C,price_in:C.price_in??0,price_out:C.price_out??0};z(he)}E(ne)},Bt=ne=>{re(ne),Ne(!0)},Oa=()=>{if(je!==null){const ne=l.filter((he,ts)=>ts!==je);n(ne),f(ne.map(he=>he.name)),q(p,ne),ze({title:"删除成功",description:'配置将在 2 秒后自动保存,或点击右上角"保存配置"按钮立即保存'})}Ne(!1),re(null)},tl=ne=>{const he=new Set(M);he.has(ne)?he.delete(ne):he.add(ne),K(he)},ul=()=>{if(M.size===Dt.length)K(new Set);else{const ne=Dt.map((he,ts)=>l.findIndex(js=>js===Dt[ts]));K(new Set(ne))}},Zn=()=>{if(M.size===0){ze({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}ue(!0)},se=()=>{const ne=M.size,he=l.filter((ts,js)=>!M.has(js));n(he),f(he.map(ts=>ts.name)),q(p,he),K(new Set),ue(!1),ze({title:"批量删除成功",description:`已删除 ${ne} 个模型,配置将在 2 秒后自动保存`})},we=(ne,he,ts)=>{if(!p)return;if(ne==="embedding"&&he==="model_list"&&Array.isArray(ts)){const is=Y.current,jt=ts;if((is.length!==jt.length||is.some(Bl=>!jt.includes(Bl))||jt.some(Bl=>!is.includes(Bl)))&&is.length>0){He.current={field:he,value:ts},W(!0);return}}const js={...p,[ne]:{...p[ne],[he]:ts}};g(js),q(js,l),ne==="embedding"&&he==="model_list"&&Array.isArray(ts)&&(Y.current=[...ts])},Le=()=>{if(!p||!He.current)return;const{field:ne,value:he}=He.current,ts={...p,embedding:{...p.embedding,[ne]:he}};g(ts),q(ts,l),ne==="model_list"&&Array.isArray(he)&&(Y.current=[...he]),He.current=null,W(!1),ze({title:"嵌入模型已更新",description:"建议重新生成知识库向量以确保最佳匹配精度"})},Hs=()=>{He.current=null,W(!1)},Dt=l.filter(ne=>{if(!fe)return!0;const he=fe.toLowerCase();return ne.name.toLowerCase().includes(he)||ne.model_identifier.toLowerCase().includes(he)||ne.api_provider.toLowerCase().includes(he)}),Wt=Math.ceil(Dt.length/pe),rt=Dt.slice((Q-1)*pe,Q*pe),ea=()=>{const ne=parseInt(A);ne>=1&&ne<=Wt&&(Se(ne),D(""))},xt=ne=>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(ts=>ts.includes(ne)):!1;return N?e.jsx(Je,{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(Je,{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(bS,{trigger:e.jsxs(_,{variant:"outline",size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(Ij,{className:"mr-2 h-4 w-4"}),"分享配置"]})}),e.jsxs(_,{onClick:$t,disabled:b||y||!O||Ut,size:"sm",variant:"outline",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(dc,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),b?"保存中...":y?"自动保存中...":O?"保存配置":"已保存"]}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsxs(_,{disabled:b||y||Ut,size:"sm",className:"flex-1 sm:flex-none sm:min-w-[120px]",children:[e.jsx(oc,{className:"mr-2 h-4 w-4"}),Ut?"重启中...":O?"保存并重启":"重启麦麦"]})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认重启麦麦?"}),e.jsx(fs,{asChild:!0,children:e.jsx("div",{children:e.jsx("p",{children:O?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})})})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:O?gt:ls,children:O?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsxs(lt,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),F.length>0&&e.jsxs(at,{variant:"destructive",children:[e.jsx(Jt,{className:"h-4 w-4"}),e.jsxs(lt,{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:F.map(({taskName:ne,invalidModels:he})=>e.jsxs("div",{className:"text-sm",children:[e.jsx("strong",{children:ne})," 引用了不存在的模型: ",he.join(", ")]},ne))})]}),e.jsx(_,{variant:"outline",size:"sm",className:"shrink-0 bg-background hover:bg-accent",onClick:ss,children:"一键清理"})]})]}),Ue.length>0&&e.jsxs(at,{variant:"default",className:"border-yellow-500/50 bg-yellow-500/10",children:[e.jsx(Jt,{className:"h-4 w-4 text-yellow-600"}),e.jsxs(lt,{children:[e.jsx("strong",{className:"text-yellow-600",children:"以下任务未配置模型"}),e.jsxs("div",{className:"mt-2 text-sm",children:[Ue.join("、")," 还未分配模型,这些功能将无法正常工作。"]})]})]}),e.jsxs(at,{className:"hidden lg:flex border-primary/30 bg-primary/5 cursor-pointer hover:bg-primary/10 transition-colors",onClick:aa,children:[e.jsx(s_,{className:"h-4 w-4 text-primary"}),e.jsxs(lt,{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(ta,{defaultValue:"models",className:"w-full",children:[e.jsxs(Xt,{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(ws,{value:"models",className:"space-y-4 mt-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"配置可用的模型列表"}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[M.size>0&&e.jsxs(_,{onClick:Zn,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ns,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",M.size,")"]}),e.jsxs(_,{onClick:()=>tt(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto","data-tour":"add-model-button",children:[e.jsx(et,{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(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索模型名称、标识符或提供商...",value:fe,onChange:ne=>ge(ne.target.value),className:"pl-9"})]}),fe&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Dt.length," 个结果"]})]}),e.jsx(_S,{paginatedModels:rt,allModels:l,onEdit:tt,onDelete:Bt,isModelUsed:xt,searchQuery:fe}),e.jsx(SS,{paginatedModels:rt,allModels:l,filteredModels:Dt,selectedModels:M,onEdit:tt,onDelete:Bt,onToggleSelection:tl,onToggleSelectAll:ul,isModelUsed:xt,searchQuery:fe}),e.jsx(TS,{page:Q,pageSize:pe,totalItems:Dt.length,jumpToPage:A,onPageChange:Se,onPageSizeChange:Te,onJumpToPageChange:D,onJumpToPage:ea,onSelectionClear:()=>K(new Set)})]}),e.jsxs(ws,{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(Ml,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:p.utils,modelNames:h,onChange:(ne,he)=>we("utils",ne,he),dataTour:"task-model-select"}),e.jsx(Ml,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:p.tool_use,modelNames:h,onChange:(ne,he)=>we("tool_use",ne,he)}),e.jsx(Ml,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:p.replyer,modelNames:h,onChange:(ne,he)=>we("replyer",ne,he)}),e.jsx(Ml,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:p.planner,modelNames:h,onChange:(ne,he)=>we("planner",ne,he)}),e.jsx(Ml,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:p.vlm,modelNames:h,onChange:(ne,he)=>we("vlm",ne,he),hideTemperature:!0}),e.jsx(Ml,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:p.voice,modelNames:h,onChange:(ne,he)=>we("voice",ne,he),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(Ml,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:p.embedding,modelNames:h,onChange:(ne,he)=>we("embedding",ne,he),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(Ml,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:p.lpmm_entity_extract,modelNames:h,onChange:(ne,he)=>we("lpmm_entity_extract",ne,he)}),e.jsx(Ml,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:p.lpmm_rdf_build,modelNames:h,onChange:(ne,he)=>we("lpmm_rdf_build",ne,he)})]})]})]})]}),e.jsx(Is,{open:B,onOpenChange:Et,children:e.jsxs(Os,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto","data-tour":"model-dialog",preventOutsideClose:Qa,children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:H!==null?"编辑模型":"添加模型"}),e.jsx(Ks,{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:Ee.name?"text-destructive":"",children:"模型名称 *"}),e.jsx(ae,{id:"model_name",value:C?.name||"",onChange:ne=>{z(he=>he?{...he,name:ne.target.value}:null),Ee.name&&me(he=>({...he,name:void 0}))},placeholder:"例如: qwen3-30b",className:Ee.name?"border-destructive focus-visible:ring-destructive":""}),Ee.name?e.jsx("p",{className:"text-xs text-destructive",children:Ee.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:Ee.api_provider?"text-destructive":"",children:"API 提供商 *"}),e.jsxs(Ie,{value:C?.api_provider||"",onValueChange:ne=>{z(he=>he?{...he,api_provider:ne}:null),bs(),Ee.api_provider&&me(he=>({...he,api_provider:void 0}))},children:[e.jsx($e,{id:"api_provider",className:Ee.api_provider?"border-destructive focus-visible:ring-destructive":"",children:e.jsx(Pe,{placeholder:"选择提供商"})}),e.jsx(Be,{children:i.map(ne=>e.jsx(Z,{value:ne,children:ne},ne))})]}),Ee.api_provider&&e.jsx("p",{className:"text-xs text-destructive",children:Ee.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:Ee.model_identifier?"text-destructive":"",children:"模型标识符 *"}),Cs?.modelFetcher&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{variant:"secondary",className:"text-xs",children:Cs.display_name}),e.jsx(_,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:()=>C?.api_provider&&Ae(C.api_provider,!0),disabled:Ls,children:Ls?e.jsx(Bs,{className:"h-3 w-3 animate-spin"}):e.jsx(dt,{className:"h-3 w-3"})})]})]}),Cs?.modelFetcher?e.jsxs(ol,{open:V,onOpenChange:de,children:[e.jsx(dl,{asChild:!0,children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":V,className:"w-full justify-between font-normal",disabled:Ls||!!as,children:[Ls?e.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Bs,{className:"h-4 w-4 animate-spin"}),"正在获取模型列表..."]}):as?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(Jm,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Wa,{className:"p-0",align:"start",style:{width:"var(--radix-popover-trigger-width)"},children:e.jsxs(ad,{children:[e.jsx(ld,{placeholder:"搜索模型..."}),e.jsx(Je,{className:"h-[300px]",children:e.jsxs(nd,{className:"max-h-none overflow-visible",children:[e.jsx(rd,{children:as?e.jsxs("div",{className:"py-4 px-2 text-center space-y-2",children:[e.jsx("p",{className:"text-sm text-destructive",children:as}),!as.includes("API Key")&&e.jsx(_,{variant:"link",size:"sm",onClick:()=>C?.api_provider&&Ae(C.api_provider,!0),children:"重试"})]}):"未找到匹配的模型"}),e.jsx(lc,{heading:"可用模型",children:es.map(ne=>e.jsxs(nc,{value:ne.id,onSelect:()=>{z(he=>he?{...he,model_identifier:ne.id}:null),de(!1)},children:[e.jsx(Ct,{className:`mr-2 h-4 w-4 ${C?.model_identifier===ne.id?"opacity-100":"opacity-0"}`}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:ne.id}),ne.name!==ne.id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ne.name})]})]},ne.id))}),e.jsx(lc,{heading:"手动输入",children:e.jsxs(nc,{value:"__manual_input__",onSelect:()=>{de(!1)},children:[e.jsx(Gn,{className:"mr-2 h-4 w-4"}),"手动输入模型标识符..."]})})]})})]})})]}):e.jsx(ae,{id:"model_identifier",value:C?.model_identifier||"",onChange:ne=>{z(he=>he?{...he,model_identifier:ne.target.value}:null),Ee.model_identifier&&me(he=>({...he,model_identifier:void 0}))},placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507",className:Ee.model_identifier?"border-destructive focus-visible:ring-destructive":""}),Ee.model_identifier&&e.jsx("p",{className:"text-xs text-destructive",children:Ee.model_identifier}),as&&Cs?.modelFetcher&&!Ee.model_identifier&&e.jsxs(at,{variant:"destructive",className:"mt-2 py-2",children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(lt,{className:"text-xs",children:as})]}),Cs?.modelFetcher&&e.jsx(ae,{value:C?.model_identifier||"",onChange:ne=>{z(he=>he?{...he,model_identifier:ne.target.value}:null),Ee.model_identifier&&me(he=>({...he,model_identifier:void 0}))},placeholder:"或手动输入模型标识符",className:`mt-2 ${Ee.model_identifier?"border-destructive focus-visible:ring-destructive":""}`}),!Ee.model_identifier&&e.jsx("p",{className:"text-xs text-muted-foreground",children:as?'请手动输入模型标识符,或前往"模型提供商配置"检查 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(ae,{id:"price_in",type:"number",step:"0.1",min:"0",value:C?.price_in??"",onChange:ne=>{const he=ne.target.value===""?null:parseFloat(ne.target.value);z(ts=>ts?{...ts,price_in:he}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(T,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(ae,{id:"price_out",type:"number",step:"0.1",min:"0",value:C?.price_out??"",onChange:ne=>{const he=ne.target.value===""?null:parseFloat(ne.target.value);z(ts=>ts?{...ts,price_out:he}:null)},placeholder:"默认: 0"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enable_model_temperature",className:"cursor-pointer",children:"自定义模型温度"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后将覆盖「为模型分配功能」中的任务温度配置"})]}),e.jsx(Ge,{id:"enable_model_temperature",checked:C?.temperature!=null,onCheckedChange:ne=>{z(ne?he=>he?{...he,temperature:.5}:null:he=>he?{...he,temperature:null}:null)}})]}),C?.temperature!=null&&e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(T,{className:"text-sm",children:"温度值"}),e.jsx("span",{className:"text-sm font-medium tabular-nums",children:C.temperature.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"0"}),e.jsx(qa,{value:[C.temperature],onValueChange:ne=>z(he=>he?{...he,temperature:ne[0]}:null),min:0,max:1,step:.1,className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"较低的温度(0.1-0.3)产生更确定的输出,较高的温度(0.7-1.0)产生更多样化的输出"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(T,{htmlFor:"enable_model_max_tokens",className:"cursor-pointer",children:"自定义最大 Token"}),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:ne=>{z(ne?he=>he?{...he,max_tokens:2048}:null:he=>he?{...he,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(ae,{type:"number",min:"1",max:"128000",value:C.max_tokens,onChange:ne=>{const he=parseInt(ne.target.value);!isNaN(he)&&he>=1&&z(ts=>ts?{...ts,max_tokens:he}: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:ne=>z(he=>he?{...he,force_stream_mode:ne}: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:()=>U(!0),children:[e.jsx(pn,{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(ne=>e.jsx("span",{className:"inline-block mr-2",children:e.jsx("code",{className:"px-1.5 py-0.5 bg-muted rounded",children:ne})},ne)),Object.keys(C?.extra_params||{}).length>3&&e.jsx("span",{children:"..."})]})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>E(!1),"data-tour":"model-cancel-button",children:"取消"}),e.jsx(_,{onClick:Ms,"data-tour":"model-save-button",children:"保存"})]})]})}),e.jsx(Ns,{open:oe,onOpenChange:Ne,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除模型 "',je!==null?l[je]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:Oa,children:"删除"})]})]})}),e.jsx(Ns,{open:I,onOpenChange:ue,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认批量删除"}),e.jsxs(fs,{children:["确定要删除选中的 ",M.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:se,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),e.jsx(Ns,{open:Oe,onOpenChange:W,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsxs(hs,{className:"flex items-center gap-2",children:[e.jsx(Jt,{className:"h-5 w-5 text-amber-500"}),"更换嵌入模型警告"]}),e.jsx(fs,{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(xs,{children:[e.jsx(gs,{onClick:Hs,children:"取消"}),e.jsx(ps,{onClick:Le,className:"bg-amber-600 hover:bg-amber-700",children:"确认更换"})]})]})}),e.jsx(uS,{open:J,onOpenChange:U,value:C?.extra_params||{},onChange:ne=>z(he=>he?{...he,extra_params:ne}:null)}),e.jsx(Xn,{})]})})}const rc=lj,ic=Y0,cc=J0,id="/api/webui/config";async function DS(){const n=await(await _e(`${id}/adapter-config/path`)).json();return!n.success||!n.path?null:{path:n.path,lastModified:n.lastModified}}async function zg(l){const i=await(await _e(`${id}/adapter-config/path`,{method:"POST",headers:Fs(),body:JSON.stringify({path:l})})).json();if(!i.success)throw new Error(i.message||"保存路径失败")}async function Ag(l){const i=await(await _e(`${id}/adapter-config?path=${encodeURIComponent(l)}`)).json();if(!i.success)throw new Error("读取配置文件失败");return i.content}async function Og(l,n){const c=await(await _e(`${id}/adapter-config`,{method:"POST",headers:Fs(),body:JSON.stringify({path:l,content:n})})).json();if(!c.success)throw new Error(c.message||"保存配置失败")}const bt={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"}},zm={oneclick:{name:"一键包",description:"使用一键包部署的适配器配置",path:"../MaiBot-Napcat-Adapter/config.toml",icon:ra},docker:{name:"Docker",description:"Docker Compose 部署的适配器配置",path:"/MaiMBot/adapters-config/config.toml",icon:t_}};function RS(l,n){let i=l.slice(0,n).split(/\r\n|\n|\r/g);return[i.length,i.pop().length+1]}function LS(l,n,i){let c=l.split(/\r\n|\n|\r/g),u="",x=(Math.log10(n+1)|0)+1;for(let h=n-1;h<=n+1;h++){let f=c[h-1];f&&(u+=h.toString().padEnd(x," "),u+=": ",u+=f,u+=`
|
||
`,h===n&&(u+=" ".repeat(x+i+2),u+=`^
|
||
`))}return u}class ks extends Error{line;column;codeblock;constructor(n,i){const[c,u]=RS(i.toml,i.ptr),x=LS(i.toml,c,u);super(`Invalid TOML document: ${n}
|
||
|
||
${x}`,i),this.line=c,this.column=u,this.codeblock=x}}function US(l,n){let i=0;for(;l[n-++i]==="\\";);return--i&&i%2}function Go(l,n=0,i=l.length){let c=l.indexOf(`
|
||
`,n);return l[c-1]==="\r"&&c--,c<=i?c:-1}function ix(l,n){for(let i=n;i<l.length;i++){let c=l[i];if(c===`
|
||
`)return i;if(c==="\r"&&l[i+1]===`
|
||
`)return i+1;if(c<" "&&c!==" "||c==="")throw new ks("control characters are not allowed in comments",{toml:l,ptr:n})}return l.length}function Ol(l,n,i,c){let u;for(;(u=l[n])===" "||u===" "||!i&&(u===`
|
||
`||u==="\r"&&l[n+1]===`
|
||
`);)n++;return c||u!=="#"?n:Ol(l,ix(l,n),i)}function Dg(l,n,i,c,u=!1){if(!c)return n=Go(l,n),n<0?l.length:n;for(let x=n;x<l.length;x++){let h=l[x];if(h==="#")x=Go(l,x);else{if(h===i)return x+1;if(h===c||u&&(h===`
|
||
`||h==="\r"&&l[x+1]===`
|
||
`))return x}}throw new ks("cannot find end of structure",{toml:l,ptr:n})}function zv(l,n){let i=l[n],c=i===l[n+1]&&l[n+1]===l[n+2]?l.slice(n,n+3):i;n+=c.length-1;do n=l.indexOf(c,++n);while(n>-1&&i!=="'"&&US(l,n));return n>-1&&(n+=c.length,c.length>1&&(l[n]===i&&n++,l[n]===i&&n++)),n}let $S=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;class Hr extends Date{#s=!1;#t=!1;#e=null;constructor(n){let i=!0,c=!0,u="Z";if(typeof n=="string"){let x=n.match($S);x?(x[1]||(i=!1,n=`0000-01-01T${n}`),c=!!x[2],c&&n[10]===" "&&(n=n.replace(" ","T")),x[2]&&+x[2]>23?n="":(u=x[3]||null,n=n.toUpperCase(),!u&&c&&(n+="Z"))):n=""}super(n),isNaN(this.getTime())||(this.#s=i,this.#t=c,this.#e=u)}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 n=super.toISOString();if(this.isDate())return n.slice(0,10);if(this.isTime())return n.slice(11,23);if(this.#e===null)return n.slice(0,-1);if(this.#e==="Z")return n;let i=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return i=this.#e[0]==="-"?i:-i,new Date(this.getTime()-i*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(n,i="Z"){let c=new Hr(n);return c.#e=i,c}static wrapAsLocalDateTime(n){let i=new Hr(n);return i.#e=null,i}static wrapAsLocalDate(n){let i=new Hr(n);return i.#t=!1,i.#e=null,i}static wrapAsLocalTime(n){let i=new Hr(n);return i.#s=!1,i.#e=null,i}}let BS=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,IS=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,PS=/^[+-]?0[0-9_]/,HS=/^[0-9a-f]{4,8}$/i,Rg={b:"\b",t:" ",n:`
|
||
`,f:"\f",r:"\r",'"':'"',"\\":"\\"};function Av(l,n=0,i=l.length){let c=l[n]==="'",u=l[n++]===l[n]&&l[n]===l[n+1];u&&(i-=2,l[n+=2]==="\r"&&n++,l[n]===`
|
||
`&&n++);let x=0,h,f="",p=n;for(;n<i-1;){let g=l[n++];if(g===`
|
||
`||g==="\r"&&l[n]===`
|
||
`){if(!u)throw new ks("newlines are not allowed in strings",{toml:l,ptr:n-1})}else if(g<" "&&g!==" "||g==="")throw new ks("control characters are not allowed in strings",{toml:l,ptr:n-1});if(h){if(h=!1,g==="u"||g==="U"){let N=l.slice(n,n+=g==="u"?4:8);if(!HS.test(N))throw new ks("invalid unicode escape",{toml:l,ptr:x});try{f+=String.fromCodePoint(parseInt(N,16))}catch{throw new ks("invalid unicode escape",{toml:l,ptr:x})}}else if(u&&(g===`
|
||
`||g===" "||g===" "||g==="\r")){if(n=Ol(l,n-1,!0),l[n]!==`
|
||
`&&l[n]!=="\r")throw new ks("invalid escape: only line-ending whitespace may be escaped",{toml:l,ptr:x});n=Ol(l,n)}else if(g in Rg)f+=Rg[g];else throw new ks("unrecognized escape sequence",{toml:l,ptr:x});p=n}else!c&&g==="\\"&&(x=n-1,h=!0,f+=l.slice(p,x))}return f+l.slice(p,i-1)}function FS(l,n,i,c){if(l==="true")return!0;if(l==="false")return!1;if(l==="-inf")return-1/0;if(l==="inf"||l==="+inf")return 1/0;if(l==="nan"||l==="+nan"||l==="-nan")return NaN;if(l==="-0")return c?0n:0;let u=BS.test(l);if(u||IS.test(l)){if(PS.test(l))throw new ks("leading zeroes are not allowed",{toml:n,ptr:i});l=l.replace(/_/g,"");let h=+l;if(isNaN(h))throw new ks("invalid number",{toml:n,ptr:i});if(u){if((u=!Number.isSafeInteger(h))&&!c)throw new ks("integer value cannot be represented losslessly",{toml:n,ptr:i});(u||c===!0)&&(h=BigInt(l))}return h}const x=new Hr(l);if(!x.isValid())throw new ks("invalid value",{toml:n,ptr:i});return x}function GS(l,n,i,c){let u=l.slice(n,i),x=u.indexOf("#");x>-1&&(ix(l,x),u=u.slice(0,x));let h=u.trimEnd();if(!c){let f=u.indexOf(`
|
||
`,h.length);if(f>-1)throw new ks("newlines are not allowed in inline tables",{toml:l,ptr:n+f})}return[h,x]}function cx(l,n,i,c,u){if(c===0)throw new ks("document contains excessively nested structures. aborting.",{toml:l,ptr:n});let x=l[n];if(x==="["||x==="{"){let[p,g]=x==="["?KS(l,n,c,u):qS(l,n,c,u),N=i?Dg(l,g,",",i):g;if(g-N&&i==="}"){let v=Go(l,g,N);if(v>-1)throw new ks("newlines are not allowed in inline tables",{toml:l,ptr:v})}return[p,N]}let h;if(x==='"'||x==="'"){h=zv(l,n);let p=Av(l,n,h);if(i){if(h=Ol(l,h,i!=="]"),l[h]&&l[h]!==","&&l[h]!==i&&l[h]!==`
|
||
`&&l[h]!=="\r")throw new ks("unexpected character encountered",{toml:l,ptr:h});h+=+(l[h]===",")}return[p,h]}h=Dg(l,n,",",i);let f=GS(l,n,h-+(l[h-1]===","),i==="]");if(!f[0])throw new ks("incomplete key-value declaration: no value specified",{toml:l,ptr:n});return i&&f[1]>-1&&(h=Ol(l,n+f[1]),h+=+(l[h]===",")),[FS(f[0],l,n,u),h]}let VS=/^[a-zA-Z0-9-_]+[ \t]*$/;function Fm(l,n,i="="){let c=n-1,u=[],x=l.indexOf(i,n);if(x<0)throw new ks("incomplete key-value: cannot find end of key",{toml:l,ptr:n});do{let h=l[n=++c];if(h!==" "&&h!==" ")if(h==='"'||h==="'"){if(h===l[n+1]&&h===l[n+2])throw new ks("multiline strings are not allowed in keys",{toml:l,ptr:n});let f=zv(l,n);if(f<0)throw new ks("unfinished string encountered",{toml:l,ptr:n});c=l.indexOf(".",f);let p=l.slice(f,c<0||c>x?x:c),g=Go(p);if(g>-1)throw new ks("newlines are not allowed in keys",{toml:l,ptr:n+c+g});if(p.trimStart())throw new ks("found extra tokens after the string part",{toml:l,ptr:f});if(x<f&&(x=l.indexOf(i,f),x<0))throw new ks("incomplete key-value: cannot find end of key",{toml:l,ptr:n});u.push(Av(l,n,f))}else{c=l.indexOf(".",n);let f=l.slice(n,c<0||c>x?x:c);if(!VS.test(f))throw new ks("only letter, numbers, dashes and underscores are allowed in keys",{toml:l,ptr:n});u.push(f.trimEnd())}}while(c+1&&c<x);return[u,Ol(l,x+1,!0,!0)]}function qS(l,n,i,c){let u={},x=new Set,h,f=0;for(n++;(h=l[n++])!=="}"&&h;){let p={toml:l,ptr:n-1};if(h===`
|
||
`)throw new ks("newlines are not allowed in inline tables",p);if(h==="#")throw new ks("inline tables cannot contain comments",p);if(h===",")throw new ks("expected key-value, found comma",p);if(h!==" "&&h!==" "){let g,N=u,v=!1,[b,w]=Fm(l,n-1);for(let O=0;O<b.length;O++){if(O&&(N=v?N[g]:N[g]={}),g=b[O],(v=Object.hasOwn(N,g))&&(typeof N[g]!="object"||x.has(N[g])))throw new ks("trying to redefine an already defined value",{toml:l,ptr:n});!v&&g==="__proto__"&&Object.defineProperty(N,g,{enumerable:!0,configurable:!0,writable:!0})}if(v)throw new ks("trying to redefine an already defined value",{toml:l,ptr:n});let[y,R]=cx(l,w,"}",i-1,c);x.add(y),N[g]=y,n=R,f=l[n-1]===","?n-1:0}}if(f)throw new ks("trailing commas are not allowed in inline tables",{toml:l,ptr:f});if(!h)throw new ks("unfinished table encountered",{toml:l,ptr:n});return[u,n]}function KS(l,n,i,c){let u=[],x;for(n++;(x=l[n++])!=="]"&&x;){if(x===",")throw new ks("expected value, found comma",{toml:l,ptr:n-1});if(x==="#")n=ix(l,n);else if(x!==" "&&x!==" "&&x!==`
|
||
`&&x!=="\r"){let h=cx(l,n-1,"]",i-1,c);u.push(h[0]),n=h[1]}}if(!x)throw new ks("unfinished array encountered",{toml:l,ptr:n});return[u,n]}function Lg(l,n,i,c){let u=n,x=i,h,f=!1,p;for(let g=0;g<l.length;g++){if(g){if(u=f?u[h]:u[h]={},x=(p=x[h]).c,c===0&&(p.t===1||p.t===2))return null;if(p.t===2){let N=u.length-1;u=u[N],x=x[N].c}}if(h=l[g],(f=Object.hasOwn(u,h))&&x[h]?.t===0&&x[h]?.d)return null;f||(h==="__proto__"&&(Object.defineProperty(u,h,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(x,h,{enumerable:!0,configurable:!0,writable:!0})),x[h]={t:g<l.length-1&&c===2?3:c,d:!1,i:0,c:{}})}if(p=x[h],p.t!==c&&!(c===1&&p.t===3)||(c===2&&(p.d||(p.d=!0,u[h]=[]),u[h].push(u={}),p.c[p.i++]=p={t:1,d:!1,i:0,c:{}}),p.d))return null;if(p.d=!0,c===1)u=f?u[h]:u[h]={};else if(c===0&&f)return null;return[h,u,p.c]}function Ov(l,{maxDepth:n=1e3,integersAsBigInt:i}={}){let c={},u={},x=c,h=u;for(let f=Ol(l,0);f<l.length;){if(l[f]==="["){let p=l[++f]==="[",g=Fm(l,f+=+p,"]");if(p){if(l[g[1]-1]!=="]")throw new ks("expected end of table declaration",{toml:l,ptr:g[1]-1});g[1]++}let N=Lg(g[0],c,u,p?2:1);if(!N)throw new ks("trying to redefine an already defined table or value",{toml:l,ptr:f});h=N[2],x=N[1],f=g[1]}else{let p=Fm(l,f),g=Lg(p[0],x,h,0);if(!g)throw new ks("trying to redefine an already defined table or value",{toml:l,ptr:f});let N=cx(l,p[1],void 0,n,i);g[1][g[0]]=N[0],f=N[1]}if(f=Ol(l,f,!0),l[f]&&l[f]!==`
|
||
`&&l[f]!=="\r")throw new ks("each key-value declaration must be followed by an end-of-line",{toml:l,ptr:f});f=Ol(l,f)}return c}let Dv=/^[a-z0-9-_]+$/i;function mc(l){let n=typeof l;if(n==="object"){if(Array.isArray(l))return"array";if(l instanceof Date)return"date"}return n}function QS(l){for(let n=0;n<l.length;n++)if(mc(l[n])!=="object")return!1;return l.length!=0}function ox(l){return JSON.stringify(l).replace(/\x7f/g,"\\u007f")}function dx(l,n,i,c){if(i===0)throw new Error("Could not stringify the object: maximum object depth exceeded");if(n==="number")return isNaN(l)?"nan":l===1/0?"inf":l===-1/0?"-inf":c&&Number.isInteger(l)?l.toFixed(1):l.toString();if(n==="bigint"||n==="boolean")return l.toString();if(n==="string")return ox(l);if(n==="date"){if(isNaN(l.getTime()))throw new TypeError("cannot serialize invalid date");return l.toISOString()}if(n==="object")return YS(l,i,c);if(n==="array")return JS(l,i,c)}function YS(l,n,i){let c=Object.keys(l);if(c.length===0)return"{}";let u="{ ";for(let x=0;x<c.length;x++){let h=c[x];x&&(u+=", "),u+=Dv.test(h)?h:ox(h),u+=" = ",u+=dx(l[h],mc(l[h]),n-1,i)}return u+" }"}function JS(l,n,i){if(l.length===0)return"[]";let c="[ ";for(let u=0;u<l.length;u++){if(u&&(c+=", "),l[u]===null||l[u]===void 0)throw new TypeError("arrays cannot contain null or undefined values");c+=dx(l[u],mc(l[u]),n-1,i)}return c+" ]"}function XS(l,n,i,c){if(i===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let u="";for(let x=0;x<l.length;x++)u+=`${u&&`
|
||
`}[[${n}]]
|
||
`,u+=ux(0,l[x],n,i,c);return u}function ux(l,n,i,c,u){if(c===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let x="",h="",f=Object.keys(n);for(let p=0;p<f.length;p++){let g=f[p];if(n[g]!==null&&n[g]!==void 0){let N=mc(n[g]);if(N==="symbol"||N==="function")throw new TypeError(`cannot serialize values of type '${N}'`);let v=Dv.test(g)?g:ox(g);if(N==="array"&&QS(n[g]))h+=(h&&`
|
||
`)+XS(n[g],i?`${i}.${v}`:v,c-1,u);else if(N==="object"){let b=i?`${i}.${v}`:v;h+=(h&&`
|
||
`)+ux(b,n[g],b,c-1,u)}else x+=v,x+=" = ",x+=dx(n[g],N,c,u),x+=`
|
||
`}}return l&&(x||!h)&&(x=x?`[${l}]
|
||
${x}`:`[${l}]`),x&&h?`${x}
|
||
${h}`:x||h}function ZS(l,{maxDepth:n=1e3,numbersAsFloat:i=!1}={}){if(mc(l)!=="object")throw new TypeError("stringify can only be called with an object");let c=ux(0,l,"",n,i);return c[c.length-1]!==`
|
||
`?c+`
|
||
`:c}function Am(l){try{const n=Ov(l);return{inner:{...bt.inner,...n.inner},nickname:{...bt.nickname,...n.nickname},napcat_server:{...bt.napcat_server,...n.napcat_server},maibot_server:{...bt.maibot_server,...n.maibot_server},chat:{...bt.chat,...n.chat},voice:{...bt.voice,...n.voice},debug:{...bt.debug,...n.debug}}}catch(n){throw console.error("TOML 解析失败:",n),new Error(`无法解析 TOML 文件: ${n instanceof Error?n.message:"未知错误"}`)}}function Om(l){try{const n=(u,x)=>u===""||u===null||u===void 0?x:u,i={inner:{version:n(l.inner.version,bt.inner.version)},nickname:{nickname:n(l.nickname.nickname,bt.nickname.nickname)},napcat_server:{host:n(l.napcat_server.host,bt.napcat_server.host),port:n(l.napcat_server.port||0,bt.napcat_server.port),token:n(l.napcat_server.token,bt.napcat_server.token),heartbeat_interval:n(l.napcat_server.heartbeat_interval||0,bt.napcat_server.heartbeat_interval)},maibot_server:{host:n(l.maibot_server.host,bt.maibot_server.host),port:n(l.maibot_server.port||0,bt.maibot_server.port)},chat:{group_list_type:n(l.chat.group_list_type,bt.chat.group_list_type),group_list:l.chat.group_list||[],private_list_type:n(l.chat.private_list_type,bt.chat.private_list_type),private_list:l.chat.private_list||[],ban_user_id:l.chat.ban_user_id||[],ban_qq_bot:l.chat.ban_qq_bot??bt.chat.ban_qq_bot,enable_poke:l.chat.enable_poke??bt.chat.enable_poke},voice:{use_tts:l.voice.use_tts??bt.voice.use_tts},debug:{level:n(l.debug.level,bt.debug.level)}};let c=ZS(i);return c=WS(c),c}catch(n){throw console.error("TOML 生成失败:",n),new Error(`无法生成 TOML 文件: ${n instanceof Error?n.message:"未知错误"}`)}}function WS(l){const n=l.split(`
|
||
`),i=[];for(let c=0;c<n.length;c++){const u=n[c];if(u==="[inner]"){i.push(u);continue}if(u.startsWith("version = ")){i.push(`${u} # 版本号`),i.push("# 请勿修改版本号,除非你知道自己在做什么");continue}if(u==="[nickname]"){i.push("[nickname] # 现在没用");continue}if(u==="[napcat_server]"){i.push("[napcat_server] # Napcat连接的ws服务设置");continue}if(u.startsWith("host = ")&&i[i.length-1]?.includes("[napcat_server]")){i.push(`${u} # Napcat设定的主机地址`);continue}if(u.startsWith("port = ")&&n[c-1]?.includes("host")){i.push(`${u} # Napcat设定的端口`);continue}if(u.startsWith("token = ")){i.push(`${u} # Napcat设定的访问令牌,若无则留空`);continue}if(u.startsWith("heartbeat_interval = ")){i.push(`${u} # 与Napcat设置的心跳相同(按秒计)`);continue}if(u==="[maibot_server]"){i.push("[maibot_server] # 连接麦麦的ws服务设置");continue}if(u.startsWith("host = ")&&i[i.length-1]?.includes("[maibot_server]")){i.push(`${u} # 麦麦在.env文件中设置的主机地址,即HOST字段`);continue}if(u.startsWith("port = ")&&i[i.length-1]?.includes("麦麦在.env")){i.push(`${u} # 麦麦在.env文件中设置的端口,即PORT字段`);continue}if(u==="[chat]"){i.push("[chat] # 黑白名单功能");continue}if(u.startsWith("group_list_type = ")){i.push(`${u} # 群组名单类型,可选为:whitelist, blacklist`);continue}if(u.startsWith("group_list = ")){i.push(`${u} # 群组名单`),i.push("# 当group_list_type为whitelist时,只有群组名单中的群组可以聊天"),i.push("# 当group_list_type为blacklist时,群组名单中的任何群组无法聊天");continue}if(u.startsWith("private_list_type = ")){i.push(`${u} # 私聊名单类型,可选为:whitelist, blacklist`);continue}if(u.startsWith("private_list = ")){i.push(`${u} # 私聊名单`),i.push("# 当private_list_type为whitelist时,只有私聊名单中的用户可以聊天"),i.push("# 当private_list_type为blacklist时,私聊名单中的任何用户无法聊天");continue}if(u.startsWith("ban_user_id = ")){i.push(`${u} # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)`);continue}if(u.startsWith("ban_qq_bot = ")){i.push(`${u} # 是否屏蔽QQ官方机器人`);continue}if(u.startsWith("enable_poke = ")){i.push(`${u} # 是否启用戳一戳功能`);continue}if(u==="[voice]"){i.push("[voice] # 发送语音设置");continue}if(u.startsWith("use_tts = ")){i.push(`${u} # 是否使用tts语音(请确保你配置了tts并有对应的adapter)`);continue}if(u.startsWith("level = ")&&i[i.length-1]==="[debug]"){i.push(`${u} # 日志等级(DEBUG, INFO, WARNING, ERROR, CRITICAL)`);continue}i.push(u)}return i.join(`
|
||
`)}function Dm(l){if(!l.trim())return{valid:!1,error:"路径不能为空"};if(!l.toLowerCase().endsWith(".toml"))return{valid:!1,error:"文件必须是 .toml 格式"};const n=/^([a-zA-Z]:\\|\\\\[^\\]+\\[^\\]+\\).+\.toml$/i,i=/^(\/|~\/).+\.toml$/i,c=/^(\.{1,2}[\\/]|[^:\\/]).+\.toml$/i,u=n.test(l),x=i.test(l),h=c.test(l);return!u&&!x&&!h?{valid:!1,error:"路径格式错误"}:/[<>"|?*\x00-\x1F]/.test(l)?{valid:!1,error:"路径包含非法字符"}:{valid:!0,error:""}}function e4(){const[l,n]=d.useState("upload"),[i,c]=d.useState(null),[u,x]=d.useState(""),[h,f]=d.useState(""),[p,g]=d.useState("oneclick"),[N,v]=d.useState(""),[b,w]=d.useState(!1),[y,R]=d.useState(!1),[O,S]=d.useState(!1),[B,E]=d.useState(!1),[C,z]=d.useState(null),[H,L]=d.useState(!1),J=d.useRef(null),{toast:U}=Zs(),oe=d.useRef(null),Ne=V=>{if(f(V),V.trim()){const de=Dm(V);v(de.error)}else v("")},je=d.useCallback(async V=>{const de=zm[V];R(!0);try{const Oe=await Ag(de.path),W=Am(Oe);c(W),g(V),f(de.path),await zg(de.path),U({title:"加载成功",description:`已从${de.name}预设加载配置`})}catch(Oe){console.error("加载预设配置失败:",Oe),U({title:"加载失败",description:Oe instanceof Error?Oe.message:"无法读取预设配置文件",variant:"destructive"})}finally{R(!1)}},[U]),re=d.useCallback(async V=>{const de=Dm(V);if(!de.valid){v(de.error),U({title:"路径无效",description:de.error,variant:"destructive"});return}v(""),R(!0);try{const Oe=await Ag(V),W=Am(Oe);c(W),f(V),await zg(V),U({title:"加载成功",description:"已从配置文件加载"})}catch(Oe){console.error("加载配置失败:",Oe),U({title:"加载失败",description:Oe instanceof Error?Oe.message:"无法读取配置文件",variant:"destructive"})}finally{R(!1)}},[U]);d.useEffect(()=>{(async()=>{try{const de=await DS();if(de&&de.path){f(de.path);const Oe=Object.entries(zm).find(([,W])=>W.path===de.path);Oe?(n("preset"),g(Oe[0]),await je(Oe[0])):(n("path"),await re(de.path))}}catch(de){console.error("加载保存的路径失败:",de)}})()},[re,je]);const fe=d.useCallback(V=>{l!=="path"&&l!=="preset"||!h||(oe.current&&clearTimeout(oe.current),oe.current=setTimeout(async()=>{w(!0);try{const de=Om(V);await Og(h,de),U({title:"自动保存成功",description:"配置已保存到文件"})}catch(de){console.error("自动保存失败:",de),U({title:"自动保存失败",description:de instanceof Error?de.message:"保存配置失败",variant:"destructive"})}finally{w(!1)}},1e3))},[l,h,U]),ge=async()=>{if(!i||!h)return;const V=Dm(h);if(!V.valid){U({title:"保存失败",description:V.error,variant:"destructive"});return}w(!0);try{const de=Om(i);await Og(h,de),U({title:"保存成功",description:"配置已保存到文件"})}catch(de){console.error("保存失败:",de),U({title:"保存失败",description:de instanceof Error?de.message:"保存配置失败",variant:"destructive"})}finally{w(!1)}},M=async()=>{h&&await re(h)},K=V=>{if(V!==l){if(i){z(V),S(!0);return}I(V)}},I=V=>{c(null),x(""),v(""),n(V),V==="preset"&&je("oneclick"),U({title:"已切换模式",description:{upload:"现在可以上传配置文件",path:"现在可以指定配置文件路径",preset:"现在可以使用预设配置"}[V]})},ue=()=>{C&&(I(C),z(null)),S(!1)},Q=()=>{if(i){E(!0);return}Se()},Se=()=>{f(""),c(null),v(""),U({title:"已清空",description:"路径和配置已清空"})},pe=()=>{Se(),E(!1)},Te=V=>{const de=V.target.files?.[0];if(!de)return;const Oe=new FileReader;Oe.onload=W=>{try{const Y=W.target?.result,He=Am(Y);c(He),x(de.name),U({title:"上传成功",description:`已加载配置文件:${de.name}`})}catch(Y){console.error("解析配置文件失败:",Y),U({title:"解析失败",description:"配置文件格式错误,请检查文件内容",variant:"destructive"})}},Oe.readAsText(de)},A=()=>{if(!i)return;const V=Om(i),de=new Blob([V],{type:"text/plain;charset=utf-8"}),Oe=URL.createObjectURL(de),W=document.createElement("a");W.href=Oe,W.download=u||"config.toml",document.body.appendChild(W),W.click(),document.body.removeChild(W),URL.revokeObjectURL(Oe),U({title:"下载成功",description:"配置文件已下载,请手动覆盖并重启适配器"})},D=()=>{c(JSON.parse(JSON.stringify(bt))),x("config.toml"),U({title:"已加载默认配置",description:"可以开始编辑配置"})};return e.jsx(Je,{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(_t,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-sm",children:"适配器配置保存之后使用 WebUI 的重启功能适配器并不会重启,需要手动重启适配器。"})]}),e.jsx(rc,{open:H,onOpenChange:L,children:e.jsxs(Ce,{children:[e.jsx(De,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Re,{children:"工作模式"}),e.jsx(os,{children:"选择配置文件的管理方式"})]}),e.jsx(ic,{asChild:!0,children:e.jsxs(_,{variant:"ghost",size:"sm",className:"w-9 p-0",children:[e.jsx(Ma,{className:`h-4 w-4 transition-transform duration-200 ${H?"transform rotate-180":""}`}),e.jsx("span",{className:"sr-only",children:"切换"})]})})]})}),e.jsx(cc,{children:e.jsxs(Me,{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 ${l==="preset"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>K("preset"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(ra,{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 ${l==="upload"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>K("upload"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(sc,{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 ${l==="path"?"border-primary bg-primary/5":"border-muted hover:border-primary/50 active:border-primary/70"}`,onClick:()=>K("path"),children:e.jsxs("div",{className:"flex items-start gap-2 md:gap-3",children:[e.jsx(a_,{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:"指定配置文件路径,自动加载和保存"})]})]})})]}),l==="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(zm).map(([V,de])=>{const Oe=de.icon,W=p===V;return e.jsx("div",{className:`border-2 rounded-lg p-3 cursor-pointer transition-all ${W?"border-primary bg-primary/5":"border-muted hover:border-primary/50"}`,onClick:()=>{g(V),je(V)},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Oe,{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:de.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:de.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:de.path})]})]})},V)})})]}),l==="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(ae,{id:"config-path",value:h,onChange:V=>Ne(V.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:()=>re(h),disabled:y||!h||!!N,className:"w-full sm:w-auto",children:y?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(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(lt,{children:l==="preset"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"预设模式:"}),"选择预设的部署方式,配置会自动加载,修改后 1 秒自动保存",b&&" (正在保存...)"]}):l==="upload"?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"上传文件模式:"}),"上传配置文件 → 在线编辑 → 下载文件 → 手动覆盖并重启适配器"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"指定路径模式:"}),"指定配置文件路径后,配置会自动加载,修改后 1 秒自动保存",b&&" (正在保存...)"]})})]}),l==="upload"&&!i&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full",children:[e.jsx("input",{ref:J,type:"file",accept:".toml",className:"hidden",onChange:Te}),e.jsxs(_,{onClick:()=>J.current?.click(),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(sc,{className:"mr-2 h-4 w-4"}),"上传配置"]}),e.jsxs(_,{onClick:D,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(Ca,{className:"mr-2 h-4 w-4"}),"使用默认配置"]})]}),l==="upload"&&i&&e.jsx("div",{className:"flex gap-2",children:e.jsxs(_,{onClick:A,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(sa,{className:"mr-2 h-4 w-4"}),"下载配置"]})}),(l==="preset"||l==="path")&&i&&e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(_,{onClick:ge,size:"sm",disabled:b||!!N,className:"w-full sm:w-auto",children:[e.jsx(dc,{className:"mr-2 h-4 w-4"}),b?"保存中...":"立即保存"]}),e.jsxs(_,{onClick:M,size:"sm",variant:"outline",disabled:y,className:"w-full sm:w-auto",children:[e.jsx(dt,{className:`mr-2 h-4 w-4 ${y?"animate-spin":""}`}),"刷新"]}),l==="path"&&e.jsxs(_,{onClick:Q,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ns,{className:"mr-2 h-4 w-4"}),"清空路径"]})]}),i?e.jsxs(ta,{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(Xt,{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(ws,{value:"napcat",className:"space-y-4",children:e.jsx(s4,{config:i,onChange:V=>{c(V),fe(V)}})}),e.jsx(ws,{value:"maibot",className:"space-y-4",children:e.jsx(t4,{config:i,onChange:V=>{c(V),fe(V)}})}),e.jsx(ws,{value:"chat",className:"space-y-4",children:e.jsx(a4,{config:i,onChange:V=>{c(V),fe(V)}})}),e.jsx(ws,{value:"voice",className:"space-y-4",children:e.jsx(l4,{config:i,onChange:V=>{c(V),fe(V)}})}),e.jsx(ws,{value:"debug",className:"space-y-4",children:e.jsx(n4,{config:i,onChange:V=>{c(V),fe(V)}})})]}):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(Ca,{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:l==="preset"?"请选择预设的部署方式":l==="upload"?"请上传现有配置文件,或使用默认配置开始编辑":"请指定配置文件路径并点击加载按钮"})]})]})}),e.jsx(Ns,{open:O,onOpenChange:S,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认切换模式"}),e.jsxs(fs,{children:["切换模式将清空当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-destructive font-medium",children:"请确保已保存重要配置"})]})]}),e.jsxs(xs,{children:[e.jsx(gs,{onClick:()=>{S(!1),z(null)},children:"取消"}),e.jsx(ps,{onClick:ue,children:"确认切换"})]})]})}),e.jsx(Ns,{open:B,onOpenChange:E,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认清空路径"}),e.jsxs(fs,{children:["清空路径将清除当前配置,确定要继续吗?",e.jsx("br",{}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"此操作不会删除配置文件,只是清除界面中的配置"})]})]}),e.jsxs(xs,{children:[e.jsx(gs,{onClick:()=>E(!1),children:"取消"}),e.jsx(ps,{onClick:pe,className:"bg-destructive hover:bg-destructive/90",children:"确认清空"})]})]})})]})})}function s4({config:l,onChange:n}){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(ae,{id:"napcat-host",value:l.napcat_server.host,onChange:i=>n({...l,napcat_server:{...l.napcat_server,host:i.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(ae,{id:"napcat-port",type:"number",value:l.napcat_server.port||"",onChange:i=>n({...l,napcat_server:{...l.napcat_server,port:i.target.value?parseInt(i.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(ae,{id:"napcat-token",type:"password",value:l.napcat_server.token,onChange:i=>n({...l,napcat_server:{...l.napcat_server,token:i.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(ae,{id:"napcat-heartbeat",type:"number",value:l.napcat_server.heartbeat_interval||"",onChange:i=>n({...l,napcat_server:{...l.napcat_server,heartbeat_interval:i.target.value?parseInt(i.target.value):0}}),placeholder:"30",className:"text-sm md:text-base"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"与 Napcat 设置的心跳间隔保持一致(留空使用默认值 30)"})]})]})]})})}function t4({config:l,onChange:n}){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(ae,{id:"maibot-host",value:l.maibot_server.host,onChange:i=>n({...l,maibot_server:{...l.maibot_server,host:i.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(ae,{id:"maibot-port",type:"number",value:l.maibot_server.port||"",onChange:i=>n({...l,maibot_server:{...l.maibot_server,port:i.target.value?parseInt(i.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 a4({config:l,onChange:n}){const i=x=>{const h={...l};x==="group"?h.chat.group_list=[...h.chat.group_list,0]:x==="private"?h.chat.private_list=[...h.chat.private_list,0]:h.chat.ban_user_id=[...h.chat.ban_user_id,0],n(h)},c=(x,h)=>{const f={...l};x==="group"?f.chat.group_list=f.chat.group_list.filter((p,g)=>g!==h):x==="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),n(f)},u=(x,h,f)=>{const p={...l};x==="group"?p.chat.group_list[h]=f:x==="private"?p.chat.private_list[h]=f:p.chat.ban_user_id[h]=f,n(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(Ie,{value:l.chat.group_list_type,onValueChange:x=>n({...l,chat:{...l.chat,group_list_type:x}}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(Z,{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:()=>i("group"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ca,{className:"mr-1 h-4 w-4"}),"添加群号"]})]}),l.chat.group_list.map((x,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{type:"number",value:x,onChange:f=>u("group",h,parseInt(f.target.value)||0),placeholder:"输入群号",className:"text-sm md:text-base"}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除群号 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>c("group",h),children:"删除"})]})]})]})]},h)),l.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(Ie,{value:l.chat.private_list_type,onValueChange:x=>n({...l,chat:{...l.chat,private_list_type:x}}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"whitelist",children:"白名单(仅名单内可聊天)"}),e.jsx(Z,{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:()=>i("private"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ca,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),l.chat.private_list.map((x,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{type:"number",value:x,onChange:f=>u("private",h,parseInt(f.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>c("private",h),children:"删除"})]})]})]})]},h)),l.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:()=>i("ban"),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(Ca,{className:"mr-1 h-4 w-4"}),"添加用户"]})]}),l.chat.ban_user_id.map((x,h)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ae,{type:"number",value:x,onChange:f=>u("ban",h,parseInt(f.target.value)||0),placeholder:"输入QQ号",className:"text-sm md:text-base"}),e.jsxs(Ns,{children:[e.jsx(wt,{asChild:!0,children:e.jsx(_,{size:"icon",variant:"outline",children:e.jsx(ns,{className:"h-4 w-4"})})}),e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:["确定要从全局禁止名单中删除用户 ",x," 吗?此操作无法撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>c("ban",h),children:"删除"})]})]})]})]},h)),l.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:l.chat.ban_qq_bot,onCheckedChange:x=>n({...l,chat:{...l.chat,ban_qq_bot:x}})})]}),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:l.chat.enable_poke,onCheckedChange:x=>n({...l,chat:{...l.chat,enable_poke:x}})})]})]})]})})}function l4({config:l,onChange:n}){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:l.voice.use_tts,onCheckedChange:i=>n({...l,voice:{use_tts:i}})})]})]})})}function n4({config:l,onChange:n}){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(Ie,{value:l.debug.level,onValueChange:i=>n({...l,debug:{level:i}}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"DEBUG",children:"DEBUG(调试)"}),e.jsx(Z,{value:"INFO",children:"INFO(信息)"}),e.jsx(Z,{value:"WARNING",children:"WARNING(警告)"}),e.jsx(Z,{value:"ERROR",children:"ERROR(错误)"}),e.jsx(Z,{value:"CRITICAL",children:"CRITICAL(严重)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"设置适配器的日志输出等级"})]})})]})})}const r4=["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"],i4=/^(aria-|data-)/,Rv=l=>Object.fromEntries(Object.entries(l).filter(([n])=>i4.test(n)||r4.includes(n)));function c4(l,n){const i=Rv(l);return Object.keys(l).some(c=>!Object.hasOwn(i,c)&&l[c]!==n[c])}class o4 extends d.Component{container;plugin;componentDidMount(){this.installPlugin()}componentDidUpdate(n){if(n.uppy!==this.props.uppy)this.uninstallPlugin(n),this.installPlugin();else if(c4(this.props,n)){const{uppy:i,...c}={...this.props,target:this.container};this.plugin.setOptions(c)}}componentWillUnmount(){this.uninstallPlugin()}installPlugin(){const{uppy:n,...i}={id:"Dashboard",...this.props,inline:!0,target:this.container};n.use($_,i),this.plugin=n.getPlugin(i.id)}uninstallPlugin(n=this.props){const{uppy:i}=n;i.removePlugin(this.plugin)}render(){return d.createElement("div",{className:"uppy-Container",ref:n=>{this.container=n},...Rv(this.props)})}}function d4({src:l,alt:n="表情包",className:i,maxRetries:c=5,retryInterval:u=1500}){const[x,h]=d.useState("loading"),[f,p]=d.useState(0),[g,N]=d.useState(null),[v,b]=d.useState(l);l!==v&&(h("loading"),p(0),N(null),b(l));const w=d.useCallback(async()=>{try{const y=await fetch(l,{credentials:"include"});if(y.status===202){h("generating"),f<c?setTimeout(()=>{p(S=>S+1)},u):h("error");return}if(!y.ok){h("error");return}const R=await y.blob(),O=URL.createObjectURL(R);N(O),h("loaded")}catch(y){console.error("加载缩略图失败:",y),h("error")}},[l,f,c,u]);return d.useEffect(()=>{w()},[w]),d.useEffect(()=>()=>{g&&URL.revokeObjectURL(g)},[g]),x==="loading"||x==="generating"?e.jsx(vs,{className:P("w-full h-full",i)}):x==="error"||!g?e.jsx("div",{className:P("w-full h-full flex items-center justify-center bg-muted",i),children:e.jsx(Xm,{className:"h-8 w-8 text-muted-foreground"})}):e.jsx("img",{src:g,alt:n,className:P("w-full h-full object-contain",i)})}function u4({children:l,className:n}){return e.jsx(nx,{content:l,className:n})}const Ka="/api/webui/emoji";async function m4(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.is_registered!==void 0&&n.append("is_registered",l.is_registered.toString()),l.is_banned!==void 0&&n.append("is_banned",l.is_banned.toString()),l.format&&n.append("format",l.format),l.sort_by&&n.append("sort_by",l.sort_by),l.sort_order&&n.append("sort_order",l.sort_order);const i=await _e(`${Ka}/list?${n}`,{});if(!i.ok)throw new Error(`获取表情包列表失败: ${i.statusText}`);return i.json()}async function x4(l){const n=await _e(`${Ka}/${l}`,{});if(!n.ok)throw new Error(`获取表情包详情失败: ${n.statusText}`);return n.json()}async function h4(l,n){const i=await _e(`${Ka}/${l}`,{method:"PATCH",body:JSON.stringify(n)});if(!i.ok)throw new Error(`更新表情包失败: ${i.statusText}`);return i.json()}async function f4(l){const n=await _e(`${Ka}/${l}`,{method:"DELETE"});if(!n.ok)throw new Error(`删除表情包失败: ${n.statusText}`);return n.json()}async function p4(){const l=await _e(`${Ka}/stats/summary`,{});if(!l.ok)throw new Error(`获取统计数据失败: ${l.statusText}`);return l.json()}async function g4(l){const n=await _e(`${Ka}/${l}/register`,{method:"POST"});if(!n.ok)throw new Error(`注册表情包失败: ${n.statusText}`);return n.json()}async function j4(l){const n=await _e(`${Ka}/${l}/ban`,{method:"POST"});if(!n.ok)throw new Error(`封禁表情包失败: ${n.statusText}`);return n.json()}function v4(l,n=!1){return n?`${Ka}/${l}/thumbnail?original=true`:`${Ka}/${l}/thumbnail`}function N4(l){return`${Ka}/${l}/thumbnail?original=true`}async function b4(l){const n=await _e(`${Ka}/batch/delete`,{method:"POST",body:JSON.stringify({emoji_ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除失败")}return n.json()}function y4(){return`${Ka}/upload`}function w4(){const[l,n]=d.useState([]),[i,c]=d.useState(null),[u,x]=d.useState(!1),[h,f]=d.useState(1),[p,g]=d.useState(0),[N,v]=d.useState(20),[b,w]=d.useState("all"),[y,R]=d.useState("all"),[O,S]=d.useState("all"),[B,E]=d.useState("usage_count"),[C,z]=d.useState("desc"),[H,L]=d.useState(null),[J,U]=d.useState(!1),[oe,Ne]=d.useState(!1),[je,re]=d.useState(!1),[fe,ge]=d.useState(new Set),[M,K]=d.useState(!1),[I,ue]=d.useState(""),[Q,Se]=d.useState("medium"),[pe,Te]=d.useState(!1),{toast:A}=Zs(),D=d.useCallback(async()=>{try{x(!0);const me=await m4({page:h,page_size:N,is_registered:b==="all"?void 0:b==="registered",is_banned:y==="all"?void 0:y==="banned",format:O==="all"?void 0:O,sort_by:B,sort_order:C});n(me.data),g(me.total)}catch(me){const ze=me instanceof Error?me.message:"加载表情包列表失败";A({title:"错误",description:ze,variant:"destructive"})}finally{x(!1)}},[h,N,b,y,O,B,C,A]),V=async()=>{try{const me=await p4();c(me.data)}catch(me){console.error("加载统计数据失败:",me)}};d.useEffect(()=>{D()},[D]),d.useEffect(()=>{V()},[]);const de=async me=>{try{const ze=await x4(me.id);L(ze.data),U(!0)}catch(ze){const rs=ze instanceof Error?ze.message:"加载详情失败";A({title:"错误",description:rs,variant:"destructive"})}},Oe=me=>{L(me),Ne(!0)},W=me=>{L(me),re(!0)},Y=async()=>{if(H)try{await f4(H.id),A({title:"成功",description:"表情包已删除"}),re(!1),L(null),D(),V()}catch(me){const ze=me instanceof Error?me.message:"删除失败";A({title:"错误",description:ze,variant:"destructive"})}},He=async me=>{try{await g4(me.id),A({title:"成功",description:"表情包已注册"}),D(),V()}catch(ze){const rs=ze instanceof Error?ze.message:"注册失败";A({title:"错误",description:rs,variant:"destructive"})}},F=async me=>{try{await j4(me.id),A({title:"成功",description:"表情包已封禁"}),D(),V()}catch(ze){const rs=ze instanceof Error?ze.message:"封禁失败";A({title:"错误",description:rs,variant:"destructive"})}},ee=me=>{const ze=new Set(fe);ze.has(me)?ze.delete(me):ze.add(me),ge(ze)},Ue=async()=>{try{const me=await b4(Array.from(fe));A({title:"批量删除完成",description:me.message}),ge(new Set),K(!1),D(),V()}catch(me){A({title:"批量删除失败",description:me instanceof Error?me.message:"批量删除失败",variant:"destructive"})}},ie=()=>{const me=parseInt(I),ze=Math.ceil(p/N);me>=1&&me<=ze?(f(me),ue("")):A({title:"无效的页码",description:`请输入1-${ze}之间的页码`,variant:"destructive"})},Ee=i?.formats?Object.keys(i.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:()=>Te(!0),className:"gap-2",children:[e.jsx(sc,{className:"h-4 w-4"}),"上传表情包"]})]}),e.jsx(Je,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[i&&e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(Ce,{children:e.jsxs(De,{className:"pb-2",children:[e.jsx(os,{children:"总数"}),e.jsx(Re,{className:"text-2xl",children:i.total})]})}),e.jsx(Ce,{children:e.jsxs(De,{className:"pb-2",children:[e.jsx(os,{children:"已注册"}),e.jsx(Re,{className:"text-2xl text-green-600",children:i.registered})]})}),e.jsx(Ce,{children:e.jsxs(De,{className:"pb-2",children:[e.jsx(os,{children:"已封禁"}),e.jsx(Re,{className:"text-2xl text-red-600",children:i.banned})]})}),e.jsx(Ce,{children:e.jsxs(De,{className:"pb-2",children:[e.jsx(os,{children:"未注册"}),e.jsx(Re,{className:"text-2xl text-gray-600",children:i.unregistered})]})})]}),e.jsxs(Ce,{children:[e.jsx(De,{children:e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx(Do,{className:"h-5 w-5"}),"筛选和排序"]})}),e.jsxs(Me,{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(Ie,{value:`${B}-${C}`,onValueChange:me=>{const[ze,rs]=me.split("-");E(ze),z(rs),f(1)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"usage_count-desc",children:"使用次数 (多→少)"}),e.jsx(Z,{value:"usage_count-asc",children:"使用次数 (少→多)"}),e.jsx(Z,{value:"register_time-desc",children:"注册时间 (新→旧)"}),e.jsx(Z,{value:"register_time-asc",children:"注册时间 (旧→新)"}),e.jsx(Z,{value:"record_time-desc",children:"记录时间 (新→旧)"}),e.jsx(Z,{value:"record_time-asc",children:"记录时间 (旧→新)"}),e.jsx(Z,{value:"last_used_time-desc",children:"最后使用 (新→旧)"}),e.jsx(Z,{value:"last_used_time-asc",children:"最后使用 (旧→新)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"注册状态"}),e.jsxs(Ie,{value:b,onValueChange:me=>{w(me),f(1)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部"}),e.jsx(Z,{value:"registered",children:"已注册"}),e.jsx(Z,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"封禁状态"}),e.jsxs(Ie,{value:y,onValueChange:me=>{R(me),f(1)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部"}),e.jsx(Z,{value:"banned",children:"已封禁"}),e.jsx(Z,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"格式"}),e.jsxs(Ie,{value:O,onValueChange:me=>{S(me),f(1)},children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部"}),Ee.map(me=>e.jsxs(Z,{value:me,children:[me.toUpperCase()," (",i?.formats[me],")"]},me))]})]})]})]}),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:[fe.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["已选择 ",fe.size," 个表情包"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"text-sm whitespace-nowrap",children:"卡片大小"}),e.jsxs(Ie,{value:Q,onValueChange:me=>Se(me),children:[e.jsx($e,{className:"w-24",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"small",children:"小"}),e.jsx(Z,{value:"medium",children:"中"}),e.jsx(Z,{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(Ie,{value:N.toString(),onValueChange:me=>{v(parseInt(me)),f(1),ge(new Set)},children:[e.jsx($e,{id:"emoji-page-size",className:"w-20",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"20",children:"20"}),e.jsx(Z,{value:"40",children:"40"}),e.jsx(Z,{value:"60",children:"60"}),e.jsx(Z,{value:"100",children:"100"})]})]}),fe.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>ge(new Set),children:"取消选择"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:()=>K(!0),children:[e.jsx(ns,{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:D,disabled:u,children:[e.jsx(dt,{className:`h-4 w-4 mr-2 ${u?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"表情包列表"}),e.jsxs(os,{children:["共 ",p," 个表情包,当前第 ",h," 页"]})]}),e.jsxs(Me,{children:[l.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"暂无数据"}):e.jsx("div",{className:`grid gap-3 ${Q==="small"?"grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 xl:grid-cols-10":Q==="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:l.map(me=>e.jsxs("div",{className:`group relative rounded-lg border bg-card overflow-hidden hover:ring-2 hover:ring-primary transition-all cursor-pointer ${fe.has(me.id)?"ring-2 ring-primary bg-primary/5":""}`,onClick:()=>ee(me.id),children:[e.jsx("div",{className:`absolute top-1 left-1 z-10 transition-opacity ${fe.has(me.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 ${fe.has(me.id)?"bg-primary border-primary text-primary-foreground":"bg-background/80 border-muted-foreground/50"}`,children:fe.has(me.id)&&e.jsx(pt,{className:"h-3 w-3"})})}),e.jsxs("div",{className:"absolute top-1 right-1 z-10 flex flex-col gap-0.5",children:[me.is_registered&&e.jsx(ke,{variant:"default",className:"bg-green-600 text-[10px] px-1 py-0",children:"已注册"}),me.is_banned&&e.jsx(ke,{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 ${Q==="small"?"p-1":Q==="medium"?"p-2":"p-3"}`,children:e.jsx(d4,{src:v4(me.id),alt:"表情包"})}),e.jsxs("div",{className:`border-t bg-card ${Q==="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(ke,{variant:"outline",className:"text-[10px] px-1 py-0",children:me.format.toUpperCase()}),e.jsxs("span",{className:"font-mono",children:[me.usage_count,"次"]})]}),e.jsxs("div",{className:`flex gap-1 justify-center opacity-0 group-hover:opacity-100 transition-opacity ${Q==="small"?"flex-wrap":""}`,children:[e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ze=>{ze.stopPropagation(),Oe(me)},title:"编辑",children:e.jsx(Kn,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:ze=>{ze.stopPropagation(),de(me)},title:"详情",children:e.jsx(Ht,{className:"h-3 w-3"})}),!me.is_registered&&e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6 text-green-600 hover:text-green-700",onClick:ze=>{ze.stopPropagation(),He(me)},title:"注册",children:e.jsx(pt,{className:"h-3 w-3"})}),!me.is_banned&&e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6 text-orange-600 hover:text-orange-700",onClick:ze=>{ze.stopPropagation(),F(me)},title:"封禁",children:e.jsx(l_,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-6 w-6 text-red-600 hover:text-red-700",onClick:ze=>{ze.stopPropagation(),W(me)},title:"删除",children:e.jsx(ns,{className:"h-3 w-3"})})]})]})]},me.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(gn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(me=>Math.max(1,me-1)),disabled:h===1,children:[e.jsx(Aa,{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(ae,{type:"number",value:I,onChange:me=>ue(me.target.value),onKeyDown:me=>me.key==="Enter"&&ie(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(p/N)}),e.jsx(_,{variant:"outline",size:"sm",onClick:ie,disabled:!I,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(me=>me+1),disabled:h>=Math.ceil(p/N),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Zt,{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(jn,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(_4,{emoji:H,open:J,onOpenChange:U}),e.jsx(S4,{emoji:H,open:oe,onOpenChange:Ne,onSuccess:()=>{D(),V()}}),e.jsx(k4,{open:pe,onOpenChange:Te,onSuccess:()=>{D(),V()}})]})}),e.jsx(Ns,{open:M,onOpenChange:K,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认批量删除"}),e.jsxs(fs,{children:["你确定要删除选中的 ",fe.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:Ue,children:"确认删除"})]})]})}),e.jsx(Is,{open:je,onOpenChange:re,children:e.jsxs(Os,{children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"确认删除"}),e.jsx(Ks,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>re(!1),children:"取消"}),e.jsx(_,{variant:"destructive",onClick:Y,children:"删除"})]})]})})]})}function _4({emoji:l,open:n,onOpenChange:i}){if(!l)return null;const c=u=>u?new Date(u*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(Ds,{children:e.jsx(Rs,{children:"表情包详情"})}),e.jsx(Je,{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:N4(l.id),alt:l.description||"表情包",className:"w-full h-full object-cover",onError:u=>{const x=u.target;x.style.display="none";const h=x.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:l.id})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(ke,{variant:"outline",children:l.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:l.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:l.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"描述"}),l.description?e.jsx("div",{className:"mt-1 rounded-lg border bg-muted/50 p-3",children:e.jsx(u4,{className:"prose-sm",children:l.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:l.emotion?e.jsx("span",{className:"text-sm",children:l.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:[l.is_registered&&e.jsx(ke,{variant:"default",className:"bg-green-600",children:"已注册"}),l.is_banned&&e.jsx(ke,{variant:"destructive",children:"已封禁"}),!l.is_registered&&!l.is_banned&&e.jsx(ke,{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:l.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(l.record_time)})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:c(l.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(T,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:c(l.last_used_time)})]})]})})]})})}function S4({emoji:l,open:n,onOpenChange:i,onSuccess:c}){const[u,x]=d.useState(""),[h,f]=d.useState(!1),[p,g]=d.useState(!1),[N,v]=d.useState(!1),{toast:b}=Zs();d.useEffect(()=>{l&&(x(l.emotion||""),f(l.is_registered),g(l.is_banned))},[l]);const w=async()=>{if(l)try{v(!0);const y=u.split(/[,,]/).map(R=>R.trim()).filter(Boolean).join(",");await h4(l.id,{emotion:y||void 0,is_registered:h,is_banned:p}),b({title:"成功",description:"表情包信息已更新"}),i(!1),c()}catch(y){const R=y instanceof Error?y.message:"保存失败";b({title:"错误",description:R,variant:"destructive"})}finally{v(!1)}};return l?e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"编辑表情包"}),e.jsx(Ks,{children:"修改表情包的情绪和状态信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(T,{children:"情绪"}),e.jsx(ot,{value:u,onChange:y=>x(y.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(qs,{id:"is_registered",checked:h,onCheckedChange:y=>{y===!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(qs,{id:"is_banned",checked:p,onCheckedChange:y=>{y===!0?(g(!0),f(!1)):g(!1)}}),e.jsx(T,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(_,{onClick:w,disabled:N,children:N?"保存中...":"保存"})]})]})}):null}function k4({open:l,onOpenChange:n,onSuccess:i}){const[c,u]=d.useState("select"),[x,h]=d.useState([]),[f,p]=d.useState(null),[g,N]=d.useState(!1),{toast:v}=Zs(),b=d.useMemo(()=>new B_({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}"}}}),[]);d.useEffect(()=>{const H=()=>{const L=b.getFiles();if(L.length===0)return;const J=L.map(U=>({id:U.id,name:U.name,previewUrl:U.preview||URL.createObjectURL(U.data),emotion:"",description:"",isRegistered:!0,file:U.data}));h(J),L.length===1?(p(J[0].id),u("edit-single")):u("edit-multiple")};return b.on("upload",H),()=>{b.off("upload",H)}},[b]),d.useEffect(()=>{l||(b.cancelAll(),u("select"),h([]),p(null),N(!1))},[l,b]);const w=d.useCallback((H,L)=>{h(J=>J.map(U=>U.id===H?{...U,...L}:U))},[]),y=d.useCallback(H=>H.emotion.trim().length>0,[]),R=d.useMemo(()=>x.length>0&&x.every(y),[x,y]),O=d.useMemo(()=>x.find(H=>H.id===f)||null,[x,f]),S=d.useCallback(()=>{(c==="edit-single"||c==="edit-multiple")&&(u("select"),h([]),p(null))},[c]),B=d.useCallback(async()=>{if(!R){v({title:"请填写必填项",description:"每个表情包的情感标签都是必填的",variant:"destructive"});return}N(!0);let H=0,L=0;try{for(const J of x){const U=new FormData;U.append("file",J.file),U.append("emotion",J.emotion),U.append("description",J.description),U.append("is_registered",J.isRegistered.toString());try{(await _e(y4(),{method:"POST",body:U})).ok?H++:L++}catch{L++}}L===0?(v({title:"上传成功",description:`成功上传 ${H} 个表情包`}),n(!1),i()):(v({title:"部分上传失败",description:`成功 ${H} 个,失败 ${L} 个`,variant:"destructive"}),i())}finally{N(!1)}},[R,x,v,n,i]),E=()=>e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"border rounded-lg overflow-hidden w-full",children:e.jsx(o4,{uppy:b,proudlyDisplayPoweredByUppy:!1,hideProgressDetails:!0,height:350,width:"100%",theme:"auto",note:"支持 JPG、PNG、GIF、WebP 格式,最多 20 个文件"})})}),C=()=>{const H=x[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(Ta,{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(ae,{id:"single-emotion",value:H.emotion,onChange:L=>w(H.id,{emotion:L.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(ae,{id:"single-description",value:H.description,onChange:L=>w(H.id,{description:L.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qs,{id:"single-is-registered",checked:H.isRegistered,onCheckedChange:L=>w(H.id,{isRegistered:L===!0})}),e.jsx(T,{htmlFor:"single-is-registered",className:"cursor-pointer",children:"上传后立即注册(可被麦麦使用)"})]})]})]}),e.jsx(st,{children:e.jsx(_,{onClick:B,disabled:!R||g,children:g?"上传中...":"上传"})})]}):null},z=()=>{const H=x.filter(y).length,L=x.length;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(_,{variant:"ghost",size:"sm",onClick:S,children:[e.jsx(Ta,{className:"h-4 w-4 mr-1"}),"返回"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["编辑表情包信息(",H,"/",L," 已完成)"]})]}),e.jsx(ke,{variant:R?"default":"secondary",children:R?e.jsxs(e.Fragment,{children:[e.jsx(Ct,{className:"h-3 w-3 mr-1"}),"全部完成"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ea,{className:"h-3 w-3 mr-1"}),"未完成"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Je,{className:"h-[350px] pr-2",children:e.jsx("div",{className:"space-y-2",children:x.map(J=>{const U=y(J),oe=f===J.id;return e.jsxs("div",{onClick:()=>p(J.id),className:`
|
||
flex items-center gap-3 p-3 rounded-lg border-2 cursor-pointer transition-all
|
||
${oe?"ring-2 ring-primary":""}
|
||
${U?"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:J.previewUrl,alt:J.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:J.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:J.emotion||"未填写情感标签"})]}),U?e.jsx(pt,{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"})]},J.id)})})}),e.jsx("div",{className:"border rounded-lg p-4",children:O?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:O.previewUrl,alt:O.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:O.name}),y(O)&&e.jsxs(ke,{variant:"outline",className:"text-green-600 border-green-600",children:[e.jsx(Ct,{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(ae,{id:"multi-emotion",value:O.emotion,onChange:J=>w(O.id,{emotion:J.target.value}),placeholder:"多个标签用逗号分隔,如:开心,高兴",className:O.emotion.trim()?"":"border-destructive"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"multi-description",children:"描述"}),e.jsx(ae,{id:"multi-description",value:O.description,onChange:J=>w(O.id,{description:J.target.value}),placeholder:"输入表情包描述..."})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qs,{id:"multi-is-registered",checked:O.isRegistered,onCheckedChange:J=>w(O.id,{isRegistered:J===!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(Xm,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"点击左侧卡片编辑"})]})})})]}),e.jsx(st,{children:e.jsx(_,{onClick:B,disabled:!R||g,children:g?"上传中...":`上传全部 (${L})`})})]})};return e.jsx(Is,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(sc,{className:"h-5 w-5"}),c==="select"&&"上传表情包 - 选择文件",c==="edit-single"&&"上传表情包 - 填写信息",c==="edit-multiple"&&"上传表情包 - 批量编辑"]}),e.jsxs(Ks,{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"&&z()]})]})})}function C4(){const[l,n]=d.useState([]),[i,c]=d.useState(!0),[u,x]=d.useState(0),[h,f]=d.useState(1),[p,g]=d.useState(20),[N,v]=d.useState(""),[b,w]=d.useState(null),[y,R]=d.useState(!1),[O,S]=d.useState(!1),[B,E]=d.useState(!1),[C,z]=d.useState(null),[H,L]=d.useState(new Set),[J,U]=d.useState(!1),[oe,Ne]=d.useState(""),[je,re]=d.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),[fe,ge]=d.useState([]),[M,K]=d.useState(new Map),[I,ue]=d.useState(!1),[Q,Se]=d.useState(0),{toast:pe}=Zs(),Te=async()=>{try{c(!0);const ie=await y1({page:h,page_size:p,search:N||void 0});n(ie.data),x(ie.total)}catch(ie){pe({title:"加载失败",description:ie instanceof Error?ie.message:"无法加载表达方式",variant:"destructive"})}finally{c(!1)}},A=async()=>{try{const ie=await T1();ie?.data&&re(ie.data)}catch(ie){console.error("加载统计数据失败:",ie)}},D=async()=>{try{const ie=await tx();Se(ie.unchecked)}catch(ie){console.error("加载审核统计失败:",ie)}},V=async()=>{try{const ie=await sx();if(ie?.data){ge(ie.data);const Ee=new Map;ie.data.forEach(me=>{Ee.set(me.chat_id,me.chat_name)}),K(Ee)}}catch(ie){console.error("加载聊天列表失败:",ie)}},de=ie=>M.get(ie)||ie;d.useEffect(()=>{Te(),D(),A(),V()},[h,p,N]);const Oe=async ie=>{try{const Ee=await w1(ie.id);w(Ee.data),R(!0)}catch(Ee){pe({title:"加载详情失败",description:Ee instanceof Error?Ee.message:"无法加载表达方式详情",variant:"destructive"})}},W=ie=>{w(ie),S(!0)},Y=async ie=>{try{await k1(ie.id),pe({title:"删除成功",description:`已删除表达方式: ${ie.situation}`}),z(null),Te(),A()}catch(Ee){pe({title:"删除失败",description:Ee instanceof Error?Ee.message:"无法删除表达方式",variant:"destructive"})}},He=ie=>{const Ee=new Set(H);Ee.has(ie)?Ee.delete(ie):Ee.add(ie),L(Ee)},F=()=>{H.size===l.length&&l.length>0?L(new Set):L(new Set(l.map(ie=>ie.id)))},ee=async()=>{try{await C1(Array.from(H)),pe({title:"批量删除成功",description:`已删除 ${H.size} 个表达方式`}),L(new Set),U(!1),Te(),A()}catch(ie){pe({title:"批量删除失败",description:ie instanceof Error?ie.message:"无法批量删除表达方式",variant:"destructive"})}},Ue=()=>{const ie=parseInt(oe),Ee=Math.ceil(u/p);ie>=1&&ie<=Ee?(f(ie),Ne("")):pe({title:"无效的页码",description:`请输入1-${Ee}之间的页码`,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(za,{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(Dj,{className:"h-4 w-4"}),"人工审核",Q>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs rounded-full bg-orange-500 text-white",children:Q>99?"99+":Q})]}),e.jsxs(_,{onClick:()=>E(!0),className:"gap-2",children:[e.jsx(et,{className:"h-4 w-4"}),"新增表达方式"]})]})]})}),e.jsx(Je,{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(Tt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{id:"search",placeholder:"搜索情境、风格或上下文...",value:N,onChange:ie=>v(ie.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(Ie,{value:p.toString(),onValueChange:ie=>{g(parseInt(ie)),f(1),L(new Set)},children:[e.jsx($e,{id:"page-size",className:"w-20",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10"}),e.jsx(Z,{value:"20",children:"20"}),e.jsx(Z,{value:"50",children:"50"}),e.jsx(Z,{value:"100",children:"100"})]})]}),H.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>L(new Set),children:"取消选择"}),e.jsxs(_,{variant:"destructive",size:"sm",onClick:()=>U(!0),children:[e.jsx(ns,{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(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{className:"w-12",children:e.jsx(qs,{checked:H.size===l.length&&l.length>0,onCheckedChange:F})}),e.jsx(We,{children:"情境"}),e.jsx(We,{children:"风格"}),e.jsx(We,{children:"聊天"}),e.jsx(We,{className:"text-right",children:"操作"})]})}),e.jsx(Ul,{children:i?e.jsx(ut,{children:e.jsx(Ke,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):l.length===0?e.jsx(ut,{children:e.jsx(Ke,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):l.map(ie=>e.jsxs(ut,{children:[e.jsx(Ke,{children:e.jsx(qs,{checked:H.has(ie.id),onCheckedChange:()=>He(ie.id)})}),e.jsx(Ke,{className:"font-medium max-w-xs truncate",children:ie.situation}),e.jsx(Ke,{className:"max-w-xs truncate",children:ie.style}),e.jsx(Ke,{className:"max-w-[200px] truncate",title:de(ie.chat_id),style:{wordBreak:"keep-all"},children:e.jsx("span",{className:"whitespace-nowrap overflow-hidden text-ellipsis block",children:de(ie.chat_id)})}),e.jsx(Ke,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>W(ie),children:[e.jsx(Kn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Oe(ie),title:"查看详情",children:e.jsx(ia,{className:"h-4 w-4"})}),e.jsxs(_,{size:"sm",onClick:()=>z(ie),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},ie.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:i?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):l.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):l.map(ie=>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(qs,{checked:H.has(ie.id),onCheckedChange:()=>He(ie.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:ie.situation,children:ie.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:ie.style,children:ie.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:de(ie.chat_id),style:{wordBreak:"keep-all"},children:de(ie.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:()=>W(ie),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>Oe(ie),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:e.jsx(ia,{className:"h-3 w-3"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>z(ie),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(ns,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},ie.id))}),u>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:["共 ",u," 条记录,第 ",h," / ",Math.ceil(u/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(gn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(Aa,{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(ae,{type:"number",value:oe,onChange:ie=>Ne(ie.target.value),onKeyDown:ie=>ie.key==="Enter"&&Ue(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(u/p)}),e.jsx(_,{variant:"outline",size:"sm",onClick:Ue,disabled:!oe,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(u/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Zt,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(u/p)),disabled:h>=Math.ceil(u/p),className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(T4,{expression:b,open:y,onOpenChange:R,chatNameMap:M}),e.jsx(E4,{open:B,onOpenChange:E,chatList:fe,onSuccess:()=>{Te(),A(),E(!1)}}),e.jsx(M4,{expression:b,open:O,onOpenChange:S,chatList:fe,onSuccess:()=>{Te(),A(),S(!1)}}),e.jsx(Ns,{open:!!C,onOpenChange:()=>z(null),children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除表达方式 "',C?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>C&&Y(C),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(z4,{open:J,onOpenChange:U,onConfirm:ee,count:H.size}),e.jsx(fv,{open:I,onOpenChange:ie=>{ue(ie),ie||(Te(),A(),D())}})]})}function T4({expression:l,open:n,onOpenChange:i,chatNameMap:c}){if(!l)return null;const u=h=>h?new Date(h*1e3).toLocaleString("zh-CN"):"-",x=h=>c.get(h)||h;return e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"表达方式详情"}),e.jsx(Ks,{children:"查看表达方式的完整信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Hi,{label:"情境",value:l.situation}),e.jsx(Hi,{label:"风格",value:l.style}),e.jsx(Hi,{label:"聊天",value:x(l.chat_id)}),e.jsx(Hi,{icon:Vr,label:"记录ID",value:l.id.toString(),mono:!0})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsx(Hi,{icon:na,label:"创建时间",value:u(l.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",l.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:l.checked?e.jsx(pt,{className:"h-5 w-5"}):e.jsx($o,{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:l.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",l.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:l.rejected?e.jsx(Va,{className:"h-5 w-5"}):e.jsx($o,{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:l.rejected?"不会被使用":"正常"})]})]})]})]})]}),e.jsx(st,{children:e.jsx(_,{onClick:()=>i(!1),children:"关闭"})})]})})}function Hi({icon:l,label:n,value:i,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:[l&&e.jsx(l,{className:"h-3 w-3"}),n]}),e.jsx("div",{className:P("text-sm",c&&"font-mono",!i&&"text-muted-foreground"),children:i||"-"})]})}function E4({open:l,onOpenChange:n,chatList:i,onSuccess:c}){const[u,x]=d.useState({situation:"",style:"",chat_id:""}),[h,f]=d.useState(!1),{toast:p}=Zs(),g=async()=>{if(!u.situation||!u.style||!u.chat_id){p({title:"验证失败",description:"请填写必填字段:情境、风格和聊天",variant:"destructive"});return}try{f(!0),await _1(u),p({title:"创建成功",description:"表达方式已创建"}),x({situation:"",style:"",chat_id:""}),c()}catch(N){p({title:"创建失败",description:N instanceof Error?N.message:"无法创建表达方式",variant:"destructive"})}finally{f(!1)}};return e.jsx(Is,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"新增表达方式"}),e.jsx(Ks,{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(ae,{id:"situation",value:u.situation,onChange:N=>x({...u,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(ae,{id:"style",value:u.style,onChange:N=>x({...u,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(Ie,{value:u.chat_id,onValueChange:N=>x({...u,chat_id:N}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择关联的聊天"})}),e.jsx(Be,{children:i.map(N=>e.jsx(Z,{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(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsx(_,{onClick:g,disabled:h,children:h?"创建中...":"创建"})]})]})})}function M4({expression:l,open:n,onOpenChange:i,chatList:c,onSuccess:u}){const[x,h]=d.useState({}),[f,p]=d.useState(!1),{toast:g}=Zs();d.useEffect(()=>{l&&h({situation:l.situation,style:l.style,chat_id:l.chat_id,checked:l.checked,rejected:l.rejected})},[l]);const N=async()=>{if(l)try{p(!0),await S1(l.id,x),g({title:"保存成功",description:"表达方式已更新"}),u()}catch(v){g({title:"保存失败",description:v instanceof Error?v.message:"无法更新表达方式",variant:"destructive"})}finally{p(!1)}};return l?e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"编辑表达方式"}),e.jsx(Ks,{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(ae,{id:"edit_situation",value:x.situation||"",onChange:v=>h({...x,situation:v.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_style",children:"风格"}),e.jsx(ae,{id:"edit_style",value:x.style||"",onChange:v=>h({...x,style:v.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Ie,{value:x.chat_id||"",onValueChange:v=>h({...x,chat_id:v}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择关联的聊天"})}),e.jsx(Be,{children:c.map(v=>e.jsx(Z,{value:v.chat_id,children:e.jsxs("span",{className:"truncate",style:{wordBreak:"keep-all"},children:[v.chat_name,v.is_group&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(群聊)"})]})},v.chat_id))})]})]}),e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(lt,{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:x.checked??!1,onCheckedChange:v=>h({...x,checked:v})})]}),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:x.rejected??!1,onCheckedChange:v=>h({...x,rejected:v})})]})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(_,{onClick:N,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}function z4({open:l,onOpenChange:n,onConfirm:i,count:c}){return e.jsx(Ns,{open:l,onOpenChange:n,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认批量删除"}),e.jsxs(fs,{children:["您即将删除 ",c," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:i,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const $l="/api/webui/jargon";async function A4(){const l=await _e(`${$l}/chats`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取聊天列表失败")}return l.json()}async function O4(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.chat_id&&n.append("chat_id",l.chat_id),l.is_jargon!==void 0&&l.is_jargon!==null&&n.append("is_jargon",l.is_jargon.toString()),l.is_global!==void 0&&n.append("is_global",l.is_global.toString());const i=await _e(`${$l}/list?${n}`,{});if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取黑话列表失败")}return i.json()}async function D4(l){const n=await _e(`${$l}/${l}`,{});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取黑话详情失败")}return n.json()}async function R4(l){const n=await _e(`${$l}/`,{method:"POST",body:JSON.stringify(l)});if(!n.ok){const i=await n.json();throw new Error(i.detail||"创建黑话失败")}return n.json()}async function L4(l,n){const i=await _e(`${$l}/${l}`,{method:"PATCH",body:JSON.stringify(n)});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新黑话失败")}return i.json()}async function U4(l){const n=await _e(`${$l}/${l}`,{method:"DELETE"});if(!n.ok){const i=await n.json();throw new Error(i.detail||"删除黑话失败")}return n.json()}async function $4(l){const n=await _e(`${$l}/batch/delete`,{method:"POST",body:JSON.stringify({ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除黑话失败")}return n.json()}async function B4(){const l=await _e(`${$l}/stats/summary`,{});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取黑话统计失败")}return l.json()}async function I4(l,n){const i=new URLSearchParams;l.forEach(u=>i.append("ids",u.toString())),i.append("is_jargon",n.toString());const c=await _e(`${$l}/batch/set-jargon?${i}`,{method:"POST"});if(!c.ok){const u=await c.json();throw new Error(u.detail||"批量设置黑话状态失败")}return c.json()}function P4(){const[l,n]=d.useState([]),[i,c]=d.useState(!0),[u,x]=d.useState(0),[h,f]=d.useState(1),[p,g]=d.useState(20),[N,v]=d.useState(""),[b,w]=d.useState("all"),[y,R]=d.useState("all"),[O,S]=d.useState(null),[B,E]=d.useState(!1),[C,z]=d.useState(!1),[H,L]=d.useState(!1),[J,U]=d.useState(null),[oe,Ne]=d.useState(new Set),[je,re]=d.useState(!1),[fe,ge]=d.useState(""),[M,K]=d.useState({total:0,confirmed_jargon:0,confirmed_not_jargon:0,pending:0,global_count:0,complete_count:0,chat_count:0,top_chats:{}}),[I,ue]=d.useState([]),{toast:Q}=Zs(),Se=async()=>{try{c(!0);const ee=await O4({page:h,page_size:p,search:N||void 0,chat_id:b==="all"?void 0:b,is_jargon:y==="all"?void 0:y==="true"?!0:y==="false"?!1:void 0});n(ee.data),x(ee.total)}catch(ee){Q({title:"加载失败",description:ee instanceof Error?ee.message:"无法加载黑话列表",variant:"destructive"})}finally{c(!1)}},pe=async()=>{try{const ee=await B4();ee?.data&&K(ee.data)}catch(ee){console.error("加载统计数据失败:",ee)}},Te=async()=>{try{const ee=await A4();ee?.data&&ue(ee.data)}catch(ee){console.error("加载聊天列表失败:",ee)}};d.useEffect(()=>{Se(),pe(),Te()},[h,p,N,b,y]);const A=async ee=>{try{const Ue=await D4(ee.id);S(Ue.data),E(!0)}catch(Ue){Q({title:"加载详情失败",description:Ue instanceof Error?Ue.message:"无法加载黑话详情",variant:"destructive"})}},D=ee=>{S(ee),z(!0)},V=async ee=>{try{await U4(ee.id),Q({title:"删除成功",description:`已删除黑话: ${ee.content}`}),U(null),Se(),pe()}catch(Ue){Q({title:"删除失败",description:Ue instanceof Error?Ue.message:"无法删除黑话",variant:"destructive"})}},de=ee=>{const Ue=new Set(oe);Ue.has(ee)?Ue.delete(ee):Ue.add(ee),Ne(Ue)},Oe=()=>{oe.size===l.length&&l.length>0?Ne(new Set):Ne(new Set(l.map(ee=>ee.id)))},W=async()=>{try{await $4(Array.from(oe)),Q({title:"批量删除成功",description:`已删除 ${oe.size} 个黑话`}),Ne(new Set),re(!1),Se(),pe()}catch(ee){Q({title:"批量删除失败",description:ee instanceof Error?ee.message:"无法批量删除黑话",variant:"destructive"})}},Y=async ee=>{try{await I4(Array.from(oe),ee),Q({title:"操作成功",description:`已将 ${oe.size} 个词条设为${ee?"黑话":"非黑话"}`}),Ne(new Set),Se(),pe()}catch(Ue){Q({title:"操作失败",description:Ue instanceof Error?Ue.message:"批量设置失败",variant:"destructive"})}},He=()=>{const ee=parseInt(fe),Ue=Math.ceil(u/p);ee>=1&&ee<=Ue?(f(ee),ge("")):Q({title:"无效的页码",description:`请输入1-${Ue}之间的页码`,variant:"destructive"})},F=ee=>ee===!0?e.jsxs(ke,{variant:"default",className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Ct,{className:"h-3 w-3 mr-1"}),"是黑话"]}):ee===!1?e.jsxs(ke,{variant:"secondary",children:[e.jsx(Ea,{className:"h-3 w-3 mr-1"}),"非黑话"]}):e.jsxs(ke,{variant:"outline",children:[e.jsx(Lj,{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(n_,{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:()=>L(!0),className:"gap-2",children:[e.jsx(et,{className:"h-4 w-4"}),"新增黑话"]})]})}),e.jsx(Je,{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:M.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:M.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:M.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:M.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:M.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:M.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:M.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(Tt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{id:"search",placeholder:"搜索内容、含义...",value:N,onChange:ee=>v(ee.target.value),className:"pl-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(T,{children:"聊天筛选"}),e.jsxs(Ie,{value:b,onValueChange:w,children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"全部聊天"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部聊天"}),I.map(ee=>e.jsx(Z,{value:ee.chat_id,children:ee.chat_name},ee.chat_id))]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(T,{children:"状态筛选"}),e.jsxs(Ie,{value:y,onValueChange:R,children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"全部状态"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部状态"}),e.jsx(Z,{value:"true",children:"是黑话"}),e.jsx(Z,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(T,{htmlFor:"page-size",children:"每页显示"}),e.jsxs(Ie,{value:p.toString(),onValueChange:ee=>{g(parseInt(ee)),f(1),Ne(new Set)},children:[e.jsx($e,{id:"page-size",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10"}),e.jsx(Z,{value:"20",children:"20"}),e.jsx(Z,{value:"50",children:"50"}),e.jsx(Z,{value:"100",children:"100"})]})]})]})]}),oe.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:["已选择 ",oe.size," 个"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Y(!0),children:[e.jsx(Ct,{className:"h-4 w-4 mr-1"}),"标记为黑话"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Y(!1),children:[e.jsx(Ea,{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:()=>re(!0),children:[e.jsx(ns,{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(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{className:"w-12",children:e.jsx(qs,{checked:oe.size===l.length&&l.length>0,onCheckedChange:Oe})}),e.jsx(We,{children:"内容"}),e.jsx(We,{children:"含义"}),e.jsx(We,{children:"聊天"}),e.jsx(We,{children:"状态"}),e.jsx(We,{className:"text-center",children:"次数"}),e.jsx(We,{className:"text-right",children:"操作"})]})}),e.jsx(Ul,{children:i?e.jsx(ut,{children:e.jsx(Ke,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):l.length===0?e.jsx(ut,{children:e.jsx(Ke,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):l.map(ee=>e.jsxs(ut,{children:[e.jsx(Ke,{children:e.jsx(qs,{checked:oe.has(ee.id),onCheckedChange:()=>de(ee.id)})}),e.jsx(Ke,{className:"font-medium max-w-[200px]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee.is_global&&e.jsx("span",{title:"全局黑话",children:e.jsx(Bo,{className:"h-4 w-4 text-blue-500 flex-shrink-0"})}),e.jsx("span",{className:"truncate",title:ee.content,children:ee.content})]})}),e.jsx(Ke,{className:"max-w-[200px] truncate",title:ee.meaning||"",children:ee.meaning||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ke,{className:"max-w-[150px] truncate",title:ee.chat_name||ee.chat_id,children:ee.chat_name||ee.chat_id}),e.jsx(Ke,{children:F(ee.is_jargon)}),e.jsx(Ke,{className:"text-center",children:ee.count}),e.jsx(Ke,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>D(ee),children:[e.jsx(Kn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>A(ee),title:"查看详情",children:e.jsx(ia,{className:"h-4 w-4"})}),e.jsxs(_,{size:"sm",onClick:()=>U(ee),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},ee.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:i?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):l.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):l.map(ee=>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(qs,{checked:oe.has(ee.id),onCheckedChange:()=>de(ee.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:[ee.is_global&&e.jsx(Bo,{className:"h-4 w-4 text-blue-500 flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-sm break-all",children:ee.content})]}),ee.meaning&&e.jsx("p",{className:"text-sm text-muted-foreground break-all",children:ee.meaning}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[F(ee.is_jargon),e.jsxs("span",{className:"text-muted-foreground",children:["次数: ",ee.count]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:["聊天: ",ee.chat_name||ee.chat_id]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>D(ee),className:"text-xs px-2 py-1 h-auto",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>A(ee),className:"text-xs px-2 py-1 h-auto",children:e.jsx(ia,{className:"h-3 w-3"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>U(ee),className:"text-xs px-2 py-1 h-auto text-destructive hover:text-destructive",children:[e.jsx(ns,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},ee.id))}),u>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:["共 ",u," 条记录,第 ",h," / ",Math.ceil(u/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(gn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(Aa,{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(ae,{type:"number",value:fe,onChange:ee=>ge(ee.target.value),onKeyDown:ee=>ee.key==="Enter"&&He(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(u/p)}),e.jsx(_,{variant:"outline",size:"sm",onClick:He,disabled:!fe,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(u/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Zt,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(u/p)),disabled:h>=Math.ceil(u/p),className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(H4,{jargon:O,open:B,onOpenChange:E}),e.jsx(F4,{open:H,onOpenChange:L,chatList:I,onSuccess:()=>{Se(),pe(),L(!1)}}),e.jsx(G4,{jargon:O,open:C,onOpenChange:z,chatList:I,onSuccess:()=>{Se(),pe(),z(!1)}}),e.jsx(Ns,{open:!!J,onOpenChange:()=>U(null),children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除黑话 "',J?.content,'" 吗?此操作不可撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>J&&V(J),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(Ns,{open:je,onOpenChange:re,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认批量删除"}),e.jsxs(fs,{children:["您即将删除 ",oe.size," 个黑话,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:W,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})]})}function H4({jargon:l,open:n,onOpenChange:i}){return l?e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"黑话详情"}),e.jsx(Ks,{children:"查看黑话的完整信息"})]}),e.jsx(Je,{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(Rm,{icon:Vr,label:"记录ID",value:l.id.toString(),mono:!0}),e.jsx(Rm,{label:"使用次数",value:l.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:l.content})]}),l.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(l.raw_content);return Array.isArray(c)?c.map((u,x)=>e.jsxs("div",{children:[x>0&&e.jsx("hr",{className:"my-3 border-border"}),e.jsx("div",{className:"whitespace-pre-wrap",children:u})]},x)):e.jsx("div",{className:"whitespace-pre-wrap",children:l.raw_content})}catch{return e.jsx("div",{className:"whitespace-pre-wrap",children:l.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:l.meaning?e.jsx(nx,{content:l.meaning}):"-"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Rm,{label:"聊天",value:l.chat_name||l.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:[l.is_jargon===!0&&e.jsx(ke,{variant:"default",className:"bg-green-600",children:"是黑话"}),l.is_jargon===!1&&e.jsx(ke,{variant:"secondary",children:"非黑话"}),l.is_jargon===null&&e.jsx(ke,{variant:"outline",children:"未判定"}),l.is_global&&e.jsx(ke,{variant:"outline",className:"border-blue-500 text-blue-500",children:"全局"}),l.is_complete&&e.jsx(ke,{variant:"outline",className:"border-purple-500 text-purple-500",children:"推断完成"})]})]})]}),l.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:l.inference_with_context})]}),l.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:l.inference_content_only})]})]})}),e.jsx(st,{className:"flex-shrink-0",children:e.jsx(_,{onClick:()=>i(!1),children:"关闭"})})]})}):null}function Rm({icon:l,label:n,value:i,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:[l&&e.jsx(l,{className:"h-3 w-3"}),n]}),e.jsx("div",{className:P("text-sm",c&&"font-mono",!i&&"text-muted-foreground"),children:i||"-"})]})}function F4({open:l,onOpenChange:n,chatList:i,onSuccess:c}){const[u,x]=d.useState({content:"",meaning:"",chat_id:"",is_global:!1}),[h,f]=d.useState(!1),{toast:p}=Zs(),g=async()=>{if(!u.content||!u.chat_id){p({title:"验证失败",description:"请填写必填字段:内容和聊天",variant:"destructive"});return}try{f(!0),await R4(u),p({title:"创建成功",description:"黑话已创建"}),x({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(Is,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"新增黑话"}),e.jsx(Ks,{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(ae,{id:"content",value:u.content,onChange:N=>x({...u,content:N.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"meaning",children:"含义"}),e.jsx(ot,{id:"meaning",value:u.meaning||"",onChange:N=>x({...u,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(Ie,{value:u.chat_id,onValueChange:N=>x({...u,chat_id:N}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择关联的聊天"})}),e.jsx(Be,{children:i.map(N=>e.jsx(Z,{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:u.is_global,onCheckedChange:N=>x({...u,is_global:N})}),e.jsx(T,{htmlFor:"is_global",children:"设为全局黑话"})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>n(!1),children:"取消"}),e.jsx(_,{onClick:g,disabled:h,children:h?"创建中...":"创建"})]})]})})}function G4({jargon:l,open:n,onOpenChange:i,chatList:c,onSuccess:u}){const[x,h]=d.useState({}),[f,p]=d.useState(!1),{toast:g}=Zs();d.useEffect(()=>{l&&h({content:l.content,meaning:l.meaning||"",chat_id:l.stream_id||l.chat_id,is_global:l.is_global,is_jargon:l.is_jargon})},[l]);const N=async()=>{if(l)try{p(!0),await L4(l.id,x),g({title:"保存成功",description:"黑话已更新"}),u()}catch(v){g({title:"保存失败",description:v instanceof Error?v.message:"无法更新黑话",variant:"destructive"})}finally{p(!1)}};return l?e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"编辑黑话"}),e.jsx(Ks,{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(ae,{id:"edit_content",value:x.content||"",onChange:v=>h({...x,content:v.target.value}),placeholder:"输入黑话内容"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_meaning",children:"含义"}),e.jsx(ot,{id:"edit_meaning",value:x.meaning||"",onChange:v=>h({...x,meaning:v.target.value}),placeholder:"输入黑话含义",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit_chat_id",children:"聊天"}),e.jsxs(Ie,{value:x.chat_id||"",onValueChange:v=>h({...x,chat_id:v}),children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择关联的聊天"})}),e.jsx(Be,{children:c.map(v=>e.jsx(Z,{value:v.chat_id,children:v.chat_name},v.chat_id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"黑话状态"}),e.jsxs(Ie,{value:x.is_jargon===null?"null":x.is_jargon?.toString()||"null",onValueChange:v=>h({...x,is_jargon:v==="null"?null:v==="true"}),children:[e.jsx($e,{children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"null",children:"未判定"}),e.jsx(Z,{value:"true",children:"是黑话"}),e.jsx(Z,{value:"false",children:"非黑话"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ge,{id:"edit_is_global",checked:x.is_global,onCheckedChange:v=>h({...x,is_global:v})}),e.jsx(T,{htmlFor:"edit_is_global",children:"全局黑话"})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(_,{onClick:N,disabled:f,children:f?"保存中...":"保存"})]})]})}):null}const Jr="/api/webui/person";async function V4(l){const n=new URLSearchParams;l.page&&n.append("page",l.page.toString()),l.page_size&&n.append("page_size",l.page_size.toString()),l.search&&n.append("search",l.search),l.is_known!==void 0&&n.append("is_known",l.is_known.toString()),l.platform&&n.append("platform",l.platform);const i=await _e(`${Jr}/list?${n}`,{headers:Fs()});if(!i.ok){const c=await i.json();throw new Error(c.detail||"获取人物列表失败")}return i.json()}async function q4(l){const n=await _e(`${Jr}/${l}`,{headers:Fs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取人物详情失败")}return n.json()}async function K4(l,n){const i=await _e(`${Jr}/${l}`,{method:"PATCH",headers:Fs(),body:JSON.stringify(n)});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新人物信息失败")}return i.json()}async function Q4(l){const n=await _e(`${Jr}/${l}`,{method:"DELETE",headers:Fs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"删除人物信息失败")}return n.json()}async function Y4(){const l=await _e(`${Jr}/stats/summary`,{headers:Fs()});if(!l.ok){const n=await l.json();throw new Error(n.detail||"获取统计数据失败")}return l.json()}async function J4(l){const n=await _e(`${Jr}/batch/delete`,{method:"POST",headers:Fs(),body:JSON.stringify({person_ids:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"批量删除失败")}return n.json()}function X4(){const[l,n]=d.useState([]),[i,c]=d.useState(!0),[u,x]=d.useState(0),[h,f]=d.useState(1),[p,g]=d.useState(20),[N,v]=d.useState(""),[b,w]=d.useState(void 0),[y,R]=d.useState(void 0),[O,S]=d.useState(null),[B,E]=d.useState(!1),[C,z]=d.useState(!1),[H,L]=d.useState(null),[J,U]=d.useState({total:0,known:0,unknown:0,platforms:{}}),[oe,Ne]=d.useState(new Set),[je,re]=d.useState(!1),[fe,ge]=d.useState(""),{toast:M}=Zs(),K=async()=>{try{c(!0);const W=await V4({page:h,page_size:p,search:N||void 0,is_known:b,platform:y});n(W.data),x(W.total)}catch(W){M({title:"加载失败",description:W instanceof Error?W.message:"无法加载人物信息",variant:"destructive"})}finally{c(!1)}},I=async()=>{try{const W=await Y4();W?.data&&U(W.data)}catch(W){console.error("加载统计数据失败:",W)}};d.useEffect(()=>{K(),I()},[h,p,N,b,y]);const ue=async W=>{try{const Y=await q4(W.person_id);S(Y.data),E(!0)}catch(Y){M({title:"加载详情失败",description:Y instanceof Error?Y.message:"无法加载人物详情",variant:"destructive"})}},Q=W=>{S(W),z(!0)},Se=async W=>{try{await Q4(W.person_id),M({title:"删除成功",description:`已删除人物信息: ${W.person_name||W.nickname||W.user_id}`}),L(null),K(),I()}catch(Y){M({title:"删除失败",description:Y instanceof Error?Y.message:"无法删除人物信息",variant:"destructive"})}},pe=d.useMemo(()=>Object.keys(J.platforms),[J.platforms]),Te=W=>{const Y=new Set(oe);Y.has(W)?Y.delete(W):Y.add(W),Ne(Y)},A=()=>{oe.size===l.length&&l.length>0?Ne(new Set):Ne(new Set(l.map(W=>W.person_id)))},D=()=>{if(oe.size===0){M({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}re(!0)},V=async()=>{try{const W=await J4(Array.from(oe));M({title:"批量删除完成",description:W.message}),Ne(new Set),re(!1),K(),I()}catch(W){M({title:"批量删除失败",description:W instanceof Error?W.message:"批量删除失败",variant:"destructive"})}},de=()=>{const W=parseInt(fe),Y=Math.ceil(u/p);W>=1&&W<=Y?(f(W),ge("")):M({title:"无效的页码",description:`请输入1-${Y}之间的页码`,variant:"destructive"})},Oe=W=>W?new Date(W*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(tc,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(Je,{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:J.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:J.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:J.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(Tt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{id:"search",placeholder:"搜索名称、昵称或用户ID...",value:N,onChange:W=>v(W.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(T,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs(Ie,{value:b===void 0?"all":b.toString(),onValueChange:W=>{w(W==="all"?void 0:W==="true"),f(1)},children:[e.jsx($e,{id:"filter-known",className:"mt-1.5",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部"}),e.jsx(Z,{value:"true",children:"已认识"}),e.jsx(Z,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(T,{htmlFor:"filter-platform",children:"平台"}),e.jsxs(Ie,{value:y||"all",onValueChange:W=>{R(W==="all"?void 0:W),f(1)},children:[e.jsx($e,{id:"filter-platform",className:"mt-1.5",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部平台"}),pe.map(W=>e.jsxs(Z,{value:W,children:[W," (",J.platforms[W],")"]},W))]})]})]})]}),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:oe.size>0&&e.jsxs("span",{children:["已选择 ",oe.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(Ie,{value:p.toString(),onValueChange:W=>{g(parseInt(W)),f(1),Ne(new Set)},children:[e.jsx($e,{id:"page-size",className:"w-20",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10"}),e.jsx(Z,{value:"20",children:"20"}),e.jsx(Z,{value:"50",children:"50"}),e.jsx(Z,{value:"100",children:"100"})]})]}),oe.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:D,children:[e.jsx(ns,{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(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{className:"w-12",children:e.jsx(qs,{checked:l.length>0&&oe.size===l.length,onCheckedChange:A,"aria-label":"全选"})}),e.jsx(We,{children:"状态"}),e.jsx(We,{children:"名称"}),e.jsx(We,{children:"昵称"}),e.jsx(We,{children:"平台"}),e.jsx(We,{children:"用户ID"}),e.jsx(We,{children:"最后更新"}),e.jsx(We,{className:"text-right",children:"操作"})]})}),e.jsx(Ul,{children:i?e.jsx(ut,{children:e.jsx(Ke,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):l.length===0?e.jsx(ut,{children:e.jsx(Ke,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):l.map(W=>e.jsxs(ut,{children:[e.jsx(Ke,{children:e.jsx(qs,{checked:oe.has(W.person_id),onCheckedChange:()=>Te(W.person_id),"aria-label":`选择 ${W.person_name||W.nickname||W.user_id}`})}),e.jsx(Ke,{children:e.jsx("div",{className:P("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",W.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:W.is_known?"已认识":"未认识"})}),e.jsx(Ke,{className:"font-medium",children:W.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ke,{children:W.nickname||"-"}),e.jsx(Ke,{children:W.platform}),e.jsx(Ke,{className:"font-mono text-sm",children:W.user_id}),e.jsx(Ke,{className:"text-sm text-muted-foreground",children:Oe(W.last_know)}),e.jsx(Ke,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(_,{variant:"default",size:"sm",onClick:()=>ue(W),children:[e.jsx(ia,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(_,{variant:"default",size:"sm",onClick:()=>Q(W),children:[e.jsx(Kn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(_,{size:"sm",onClick:()=>L(W),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},W.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:i?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):l.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):l.map(W=>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(qs,{checked:oe.has(W.person_id),onCheckedChange:()=>Te(W.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",W.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:W.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:W.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),W.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",W.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:W.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:W.user_id,children:W.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:Oe(W.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(W),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(ia,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Q(W),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>L(W),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(ns,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},W.id))}),u>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:["共 ",u," 条记录,第 ",h," / ",Math.ceil(u/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(gn,{className:"h-4 w-4"})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h-1),disabled:h===1,children:[e.jsx(Aa,{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(ae,{type:"number",value:fe,onChange:W=>ge(W.target.value),onKeyDown:W=>W.key==="Enter"&&de(),placeholder:h.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(u/p)}),e.jsx(_,{variant:"outline",size:"sm",onClick:de,disabled:!fe,className:"h-8",children:"跳转"})]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>f(h+1),disabled:h>=Math.ceil(u/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Zt,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>f(Math.ceil(u/p)),disabled:h>=Math.ceil(u/p),className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(Z4,{person:O,open:B,onOpenChange:E}),e.jsx(W4,{person:O,open:C,onOpenChange:z,onSuccess:()=>{K(),I(),z(!1)}}),e.jsx(Ns,{open:!!H,onOpenChange:()=>L(null),children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认删除"}),e.jsxs(fs,{children:['确定要删除人物信息 "',H?.person_name||H?.nickname||H?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:()=>H&&Se(H),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(Ns,{open:je,onOpenChange:re,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"确认批量删除"}),e.jsxs(fs,{children:["确定要删除选中的 ",oe.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{children:"取消"}),e.jsx(ps,{onClick:V,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function Z4({person:l,open:n,onOpenChange:i}){if(!l)return null;const c=u=>u?new Date(u*1e3).toLocaleString("zh-CN"):"-";return e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"人物详情"}),e.jsxs(Ks,{children:["查看 ",l.person_name||l.nickname||l.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(zl,{icon:fn,label:"人物名称",value:l.person_name}),e.jsx(zl,{icon:za,label:"昵称",value:l.nickname}),e.jsx(zl,{icon:Vr,label:"用户ID",value:l.user_id,mono:!0}),e.jsx(zl,{icon:Vr,label:"人物ID",value:l.person_id,mono:!0}),e.jsx(zl,{label:"平台",value:l.platform}),e.jsx(zl,{label:"状态",value:l.is_known?"已认识":"未认识"})]}),l.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:l.name_reason})]}),l.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:l.memory_points})]}),l.group_nick_name&&l.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:l.group_nick_name.map((u,x)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:u.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:u.group_nick_name})]},x))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(zl,{icon:na,label:"认识时间",value:c(l.know_times)}),e.jsx(zl,{icon:na,label:"首次记录",value:c(l.know_since)}),e.jsx(zl,{icon:na,label:"最后更新",value:c(l.last_know)})]})]}),e.jsx(st,{children:e.jsx(_,{onClick:()=>i(!1),children:"关闭"})})]})})}function zl({icon:l,label:n,value:i,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:[l&&e.jsx(l,{className:"h-3 w-3"}),n]}),e.jsx("div",{className:P("text-sm",c&&"font-mono",!i&&"text-muted-foreground"),children:i||"-"})]})}function W4({person:l,open:n,onOpenChange:i,onSuccess:c}){const[u,x]=d.useState({}),[h,f]=d.useState(!1),{toast:p}=Zs();d.useEffect(()=>{l&&x({person_name:l.person_name||"",name_reason:l.name_reason||"",nickname:l.nickname||"",is_known:l.is_known})},[l]);const g=async()=>{if(l)try{f(!0),await K4(l.person_id,u),p({title:"保存成功",description:"人物信息已更新"}),c()}catch(N){p({title:"保存失败",description:N instanceof Error?N.message:"无法更新人物信息",variant:"destructive"})}finally{f(!1)}};return l?e.jsx(Is,{open:n,onOpenChange:i,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"编辑人物信息"}),e.jsxs(Ks,{children:["修改 ",l.person_name||l.nickname||l.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(ae,{id:"person_name",value:u.person_name||"",onChange:N=>x({...u,person_name:N.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"nickname",children:"昵称"}),e.jsx(ae,{id:"nickname",value:u.nickname||"",onChange:N=>x({...u,nickname:N.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(ot,{id:"name_reason",value:u.name_reason||"",onChange:N=>x({...u,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:u.is_known,onCheckedChange:N=>x({...u,is_known:N})})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsx(_,{onClick:g,disabled:h,children:h?"保存中...":"保存"})]})]})}):null}var ek=G_();const Ug=M0(ek),mx="/api/webui";async function sk(l=100,n="all"){const i=`${mx}/knowledge/graph?limit=${l}&node_type=${n}`,c=await fetch(i);if(!c.ok)throw new Error(`获取知识图谱失败: ${c.status}`);return c.json()}async function tk(){const l=await fetch(`${mx}/knowledge/stats`);if(!l.ok)throw new Error("获取知识图谱统计信息失败");return l.json()}async function ak(l){const n=await fetch(`${mx}/knowledge/search?query=${encodeURIComponent(l)}`);if(!n.ok)throw new Error("搜索知识节点失败");return n.json()}const Lv=d.memo(({data:l})=>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(Ho,{type:"target",position:Fo.Top}),e.jsx("div",{className:"font-semibold text-white text-sm truncate max-w-[200px]",title:l.content,children:l.label}),e.jsx(Ho,{type:"source",position:Fo.Bottom})]}));Lv.displayName="EntityNode";const Uv=d.memo(({data:l})=>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(Ho,{type:"target",position:Fo.Top}),e.jsx("div",{className:"font-medium text-white text-xs truncate max-w-[150px]",title:l.content,children:l.label}),e.jsx(Ho,{type:"source",position:Fo.Bottom})]}));Uv.displayName="ParagraphNode";const lk={entity:Lv,paragraph:Uv};function nk(l,n){const i=new Ug.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:"TB",ranksep:100,nodesep:80});const c=[],u=[];return l.forEach(x=>{i.setNode(x.id,{width:150,height:50})}),n.forEach(x=>{i.setEdge(x.source,x.target)}),Ug.layout(i),l.forEach(x=>{const h=i.node(x.id);c.push({id:x.id,type:x.type,position:{x:h.x-75,y:h.y-25},data:{label:x.content.slice(0,20)+(x.content.length>20?"...":""),content:x.content}})}),n.forEach((x,h)=>{const f={id:`edge-${h}`,source:x.source,target:x.target,animated:l.length<=200&&x.weight>5,style:{strokeWidth:Math.min(x.weight/2,5),opacity:.6}};x.weight>10&&l.length<100&&(f.label=`${x.weight.toFixed(0)}`),u.push(f)}),{nodes:c,edges:u}}function rk(){const l=ca(),[n,i]=d.useState(!1),[c,u]=d.useState(null),[x,h]=d.useState(""),[f,p]=d.useState("all"),[g,N]=d.useState(50),[v,b]=d.useState("50"),[w,y]=d.useState(!1),[R,O]=d.useState(!0),[S,B]=d.useState(!1),[E,C]=d.useState(!1),[z,H,L]=V_([]),[J,U,oe]=q_([]),[Ne,je]=d.useState(0),[re,fe]=d.useState(null),[ge,M]=d.useState(null),{toast:K}=Zs(),I=d.useCallback(V=>V.type==="entity"?"#6366f1":V.type==="paragraph"?"#10b981":"#6b7280",[]),ue=d.useCallback(async(V=!1)=>{try{if(!V&&g>200){C(!0);return}i(!0);const[de,Oe]=await Promise.all([sk(g,f),tk()]);if(u(Oe),de.nodes.length===0){K({title:"提示",description:"知识库为空,请先导入知识数据"}),H([]),U([]);return}const{nodes:W,edges:Y}=nk(de.nodes,de.edges);H(W),U(Y),je(W.length),Oe&&Oe.total_nodes>g&&K({title:"提示",description:`知识图谱包含 ${Oe.total_nodes} 个节点,当前显示 ${W.length} 个`}),K({title:"加载成功",description:`已加载 ${W.length} 个节点,${Y.length} 条边`})}catch(de){console.error("加载知识图谱失败:",de),K({title:"加载失败",description:de instanceof Error?de.message:"未知错误",variant:"destructive"})}finally{i(!1)}},[g,f,K]),Q=d.useCallback(async()=>{if(!x.trim()){K({title:"提示",description:"请输入搜索关键词"});return}try{const V=await ak(x);if(V.length===0){K({title:"未找到",description:"没有找到匹配的节点"});return}const de=new Set(V.map(Oe=>Oe.id));H(Oe=>Oe.map(W=>({...W,style:{...W.style,opacity:de.has(W.id)?1:.3,filter:de.has(W.id)?"brightness(1.2)":"brightness(0.8)"}}))),K({title:"搜索完成",description:`找到 ${V.length} 个匹配节点`})}catch(V){console.error("搜索失败:",V),K({title:"搜索失败",description:V instanceof Error?V.message:"未知错误",variant:"destructive"})}},[x,K]),Se=d.useCallback(()=>{H(V=>V.map(de=>({...de,style:{...de.style,opacity:1,filter:"brightness(1)"}})))},[]),pe=d.useCallback(()=>{O(!1),B(!0),ue()},[ue]),Te=d.useCallback(()=>{C(!1),setTimeout(()=>{ue(!0)},0)},[ue]),A=d.useCallback((V,de)=>{z.find(W=>W.id===de.id)&&fe({id:de.id,type:de.type,content:de.data.content})},[z]);d.useEffect(()=>{R||S&&ue()},[g,f,R,S]);const D=d.useCallback((V,de)=>{const Oe=z.find(He=>He.id===de.source),W=z.find(He=>He.id===de.target),Y=J.find(He=>He.id===de.id);Oe&&W&&Y&&M({source:{id:Oe.id,type:Oe.type,content:Oe.data.content},target:{id:W.id,type:W.type,content:W.data.content},edge:{source:de.source,target:de.target,weight:parseFloat(de.label||"0")}})},[z,J]);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(ke,{variant:"outline",className:"gap-1",children:[e.jsx(Gr,{className:"h-3 w-3"}),"节点: ",c.total_nodes]}),e.jsxs(ke,{variant:"outline",className:"gap-1",children:[e.jsx(Pj,{className:"h-3 w-3"}),"边: ",c.total_edges]}),e.jsxs(ke,{variant:"outline",className:"gap-1",children:[e.jsx(Ht,{className:"h-3 w-3"}),"实体: ",c.entity_nodes]}),e.jsxs(ke,{variant:"outline",className:"gap-1",children:[e.jsx(Ca,{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(ae,{placeholder:"搜索节点内容...",value:x,onChange:V=>h(V.target.value),onKeyDown:V=>V.key==="Enter"&&Q(),className:"flex-1"}),e.jsx(_,{onClick:Q,size:"sm",children:e.jsx(Tt,{className:"h-4 w-4"})}),e.jsx(_,{onClick:Se,variant:"outline",size:"sm",children:"重置"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ie,{value:f,onValueChange:V=>p(V),children:[e.jsx($e,{className:"w-[120px]",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部节点"}),e.jsx(Z,{value:"entity",children:"仅实体"}),e.jsx(Z,{value:"paragraph",children:"仅段落"})]})]}),e.jsxs(Ie,{value:g===1e4?"all":w?"custom":g.toString(),onValueChange:V=>{V==="custom"?(y(!0),b(g.toString())):V==="all"?(y(!1),N(1e4)):(y(!1),N(Number(V)))},children:[e.jsx($e,{className:"w-[120px]",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"50",children:"50 节点"}),e.jsx(Z,{value:"100",children:"100 节点"}),e.jsx(Z,{value:"200",children:"200 节点"}),e.jsx(Z,{value:"500",children:"500 节点"}),e.jsx(Z,{value:"1000",children:"1000 节点"}),e.jsx(Z,{value:"all",children:"全部 (最多10000)"}),e.jsx(Z,{value:"custom",children:"自定义..."})]})]}),w&&e.jsx(ae,{type:"number",min:"50",value:v,onChange:V=>b(V.target.value),onBlur:()=>{const V=parseInt(v);!isNaN(V)&&V>=50?N(V):(b("50"),N(50))},onKeyDown:V=>{if(V.key==="Enter"){const de=parseInt(v);!isNaN(de)&&de>=50?N(de):(b("50"),N(50))}},placeholder:"最少50个",className:"w-[120px]"}),e.jsx(_,{onClick:()=>ue(),variant:"outline",size:"sm",disabled:n,children:e.jsx(dt,{className:P("h-4 w-4",n&&"animate-spin")})})]})]})]}),e.jsx("div",{className:"flex-1 relative",children:n?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:"加载知识图谱中..."})]})}):z.length===0?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Gr,{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(K_,{nodes:z,edges:J,onNodesChange:L,onEdgesChange:oe,onNodeClick:A,onEdgeClick:D,nodeTypes:lk,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(Q_,{variant:Y_.Dots,gap:12,size:1}),e.jsx(J_,{}),Ne<=500&&e.jsx(X_,{nodeColor:I,nodeBorderRadius:8,pannable:!0,zoomable:!0}),e.jsxs(Z_,{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(Is,{open:!!re,onOpenChange:V=>!V&&fe(null),children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(Ds,{children:e.jsx(Rs,{children:"节点详情"})}),re&&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(ke,{variant:re.type==="entity"?"default":"secondary",children:re.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:re.id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:"内容"}),e.jsx(Je,{className:"mt-1 h-40 p-3 bg-muted rounded",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:re.content})})]})]})]})}),e.jsx(Is,{open:!!ge,onOpenChange:V=>!V&&M(null),children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Ds,{children:e.jsx(Rs,{children:"边详情"})}),ge&&e.jsx(Je,{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:ge.source.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[ge.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:ge.target.content}),e.jsxs("code",{className:"text-xs text-muted-foreground truncate block",children:[ge.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(ke,{variant:"outline",className:"text-base font-mono",children:ge.edge.weight.toFixed(4)})})]})]})})]})}),e.jsx(Ns,{open:R,onOpenChange:O,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"加载知识图谱"}),e.jsxs(fs,{children:["知识图谱的动态展示会消耗较多系统资源。",e.jsx("br",{}),"确定要加载知识图谱吗?"]})]}),e.jsxs(xs,{children:[e.jsx(gs,{onClick:()=>l({to:"/"}),children:"取消 (返回首页)"}),e.jsx(ps,{onClick:pe,children:"确认加载"})]})]})}),e.jsx(Ns,{open:E,onOpenChange:C,children:e.jsxs(us,{children:[e.jsxs(ms,{children:[e.jsx(hs,{children:"⚠️ 节点数量较多"}),e.jsx(fs,{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(xs,{children:[e.jsx(gs,{onClick:()=>{C(!1),g>200&&(N(50),y(!1))},children:"取消"}),e.jsx(ps,{onClick:Te,className:"bg-orange-600 hover:bg-orange-700",children:"我了解风险,继续加载"})]})]})})]})}function ik(){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(Ce,{children:[e.jsxs(De,{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(Gr,{className:"h-10 w-10 text-primary"})}),e.jsx(Re,{className:"text-2xl",children:"麦麦知识库管理"}),e.jsx(os,{className:"text-base",children:"功能开发中,敬请期待"})]}),e.jsx(Me,{className:"text-center text-sm text-muted-foreground",children:e.jsx("p",{children:"此功能将提供知识库的创建、编辑、导入和管理能力"})})]})})})]})}function $g({className:l,classNames:n,showOutsideDays:i=!0,captionLayout:c="label",buttonVariant:u="ghost",formatters:x,components:h,...f}){const p=av();return e.jsx(U_,{showOutsideDays:i,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`,l),captionLayout:c,formatters:{formatMonthDropdown:g=>g.toLocaleString("default",{month:"short"}),...x},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(Kr({variant:u}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_previous),button_next:P(Kr({variant:u}),"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),...n},components:{Root:({className:g,rootRef:N,...v})=>e.jsx("div",{"data-slot":"calendar",ref:N,className:P(g),...v}),Chevron:({className:g,orientation:N,...v})=>N==="left"?e.jsx(Aa,{className:P("size-4",g),...v}):N==="right"?e.jsx(Zt,{className:P("size-4",g),...v}):e.jsx(Ma,{className:P("size-4",g),...v}),DayButton:ck,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 ck({className:l,day:n,modifiers:i,...c}){const u=av(),x=d.useRef(null);return d.useEffect(()=>{i.focused&&x.current?.focus()},[i.focused]),e.jsx(_,{ref:x,variant:"ghost",size:"icon","data-day":n.date.toLocaleDateString(),"data-selected-single":i.selected&&!i.range_start&&!i.range_end&&!i.range_middle,"data-range-start":i.range_start,"data-range-end":i.range_end,"data-range-middle":i.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",u.day,l),...c})}const Mo={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 ok(){const[l,n]=d.useState([]),[i,c]=d.useState(""),[u,x]=d.useState("all"),[h,f]=d.useState("all"),[p,g]=d.useState(void 0),[N,v]=d.useState(void 0),[b,w]=d.useState(!0),[y,R]=d.useState(!1),[O,S]=d.useState("xs"),[B,E]=d.useState(4),[C,z]=d.useState(!1),H=d.useRef(null);d.useEffect(()=>{const Q=In.getAllLogs();n(Q);const Se=In.onLog(()=>{n(In.getAllLogs())}),pe=In.onConnectionChange(Te=>{R(Te)});return()=>{Se(),pe()}},[]);const L=d.useMemo(()=>{const Q=new Set(l.map(Se=>Se.module).filter(Se=>Se&&Se.trim()!==""));return Array.from(Q).sort()},[l]),J=Q=>{switch(Q){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"}},U=Q=>{switch(Q){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"}},oe=()=>{window.location.reload()},Ne=()=>{In.clearLogs(),n([])},je=()=>{const Q=ge.map(A=>`${A.timestamp} [${A.level.padEnd(8)}] [${A.module}] ${A.message}`).join(`
|
||
`),Se=new Blob([Q],{type:"text/plain;charset=utf-8"}),pe=URL.createObjectURL(Se),Te=document.createElement("a");Te.href=pe,Te.download=`logs-${Nm(new Date,"yyyy-MM-dd-HHmmss")}.txt`,Te.click(),URL.revokeObjectURL(pe)},re=()=>{w(!b)},fe=()=>{g(void 0),v(void 0)},ge=d.useMemo(()=>l.filter(Q=>{const Se=i===""||Q.message.toLowerCase().includes(i.toLowerCase())||Q.module.toLowerCase().includes(i.toLowerCase()),pe=u==="all"||Q.level===u,Te=h==="all"||Q.module===h;let A=!0;if(p||N){const D=new Date(Q.timestamp);if(p){const V=new Date(p);V.setHours(0,0,0,0),A=A&&D>=V}if(N){const V=new Date(N);V.setHours(23,59,59,999),A=A&&D<=V}}return Se&&pe&&Te&&A}),[l,i,u,h,p,N]),M=Mo[O].rowHeight+B,K=b0({count:ge.length,getScrollElement:()=>H.current,estimateSize:()=>M,overscan:50}),I=d.useRef(!1),ue=d.useRef(ge.length);return d.useEffect(()=>{const Q=H.current;if(!Q)return;const Se=()=>{if(I.current)return;const{scrollTop:pe,scrollHeight:Te,clientHeight:A}=Q,D=Te-pe-A;D>100&&b?w(!1):D<50&&!b&&w(!0)};return Q.addEventListener("scroll",Se,{passive:!0}),()=>Q.removeEventListener("scroll",Se)},[b]),d.useEffect(()=>{const Q=ge.length>ue.current;ue.current=ge.length,b&&ge.length>0&&Q&&(I.current=!0,K.scrollToIndex(ge.length-1,{align:"end",behavior:"auto"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{I.current=!1})}))},[ge.length,b,K]),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",y?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:y?"已连接":"未连接"})]})]}),e.jsx(Ce,{className:"p-2 sm:p-3",children:e.jsx(rc,{open:C,onOpenChange:z,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(Tt,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索日志...",value:i,onChange:Q=>c(Q.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:re,className:"h-8 px-2",title:b?"自动滚动":"已暂停",children:[b?e.jsx(r_,{className:"h-3.5 w-3.5"}):e.jsx(i_,{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(ns,{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(sa,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"ml-1 text-xs hidden lg:inline",children:"导出"})]}),e.jsx(ic,{asChild:!0,children:e.jsxs(_,{variant:"outline",size:"sm",className:"h-8 px-2",title:C?"收起筛选":"展开筛选",children:[e.jsx(Do,{className:"h-3.5 w-3.5"}),C?e.jsx(Fr,{className:"h-3.5 w-3.5 ml-1"}):e.jsx(Ma,{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:[ge.length," / ",l.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]}),e.jsxs(cc,{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsxs(Ie,{value:u,onValueChange:x,children:[e.jsxs($e,{className:"w-full sm:flex-1 h-8 text-xs",children:[e.jsx(Do,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Pe,{placeholder:"级别"})]}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部级别"}),e.jsx(Z,{value:"DEBUG",children:"DEBUG"}),e.jsx(Z,{value:"INFO",children:"INFO"}),e.jsx(Z,{value:"WARNING",children:"WARNING"}),e.jsx(Z,{value:"ERROR",children:"ERROR"}),e.jsx(Z,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs(Ie,{value:h,onValueChange:f,children:[e.jsxs($e,{className:"w-full sm:flex-1 h-8 text-xs",children:[e.jsx(Do,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Pe,{placeholder:"模块"})]}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部模块"}),L.map(Q=>e.jsx(Z,{value:Q,children:Q},Q))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsxs(ol,{children:[e.jsx(dl,{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(Io,{className:"mr-1.5 h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:p?Nm(p,"PP",{locale:To}):"开始日期"})]})}),e.jsx(Wa,{className:"w-auto p-0",align:"start",children:e.jsx($g,{mode:"single",selected:p,onSelect:g,initialFocus:!0,locale:To})})]}),e.jsxs(ol,{children:[e.jsx(dl,{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(Io,{className:"mr-1.5 h-3.5 w-3.5"}),e.jsx("span",{className:"text-xs",children:N?Nm(N,"PP",{locale:To}):"结束日期"})]})}),e.jsx(Wa,{className:"w-auto p-0",align:"start",children:e.jsx($g,{mode:"single",selected:N,onSelect:v,initialFocus:!0,locale:To})})]}),(p||N)&&e.jsxs(_,{variant:"outline",size:"sm",onClick:fe,className:"w-full sm:w-auto h-8",children:[e.jsx(Ea,{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(c_,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"字号"})]}),e.jsx("div",{className:"flex gap-1",children:Object.keys(Mo).map(Q=>e.jsx(_,{variant:O===Q?"default":"outline",size:"sm",onClick:()=>S(Q),className:"h-6 px-2 text-xs",children:Mo[Q].label},Q))})]}),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(qa,{value:[B],onValueChange:([Q])=>E(Q),min:0,max:12,step:2,className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground w-7",children:[B,"px"]})]}),e.jsxs("div",{className:"flex gap-2 sm:hidden",children:[e.jsxs(_,{variant:"outline",size:"sm",onClick:oe,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(sa,{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(Ce,{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",Mo[O].class),style:{height:`${K.getTotalSize()}px`},children:ge.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-xs sm:text-sm",children:"暂无日志数据"}):K.getVirtualItems().map(Q=>{const Se=ge[Q.index];return e.jsxs("div",{"data-index":Q.index,ref:K.measureElement,className:P("absolute top-0 left-0 w-full px-2 sm:px-3 rounded hover:bg-white/5 transition-colors",U(Se.level)),style:{transform:`translateY(${Q.start}px)`,paddingTop:`${B/2}px`,paddingBottom:`${B/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:Se.timestamp}),e.jsxs("span",{className:P("font-semibold text-[10px]",J(Se.level)),children:["[",Se.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 truncate text-[10px]",children:Se.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 whitespace-pre-wrap break-words text-[10px]",children:Se.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:Se.timestamp}),e.jsxs("span",{className:P("flex-shrink-0 w-[65px] lg:w-[75px] font-semibold",J(Se.level)),children:["[",Se.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[100px] lg:w-[130px] truncate",children:Se.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 whitespace-pre-wrap break-words",children:Se.message})]})]},Q.key)})})})})})]})}async function dk(){return(await _e("/api/planner/overview")).json()}async function uk(l,n=1,i=20,c){const u=new URLSearchParams({page:n.toString(),page_size:i.toString()});return c&&u.append("search",c),(await _e(`/api/planner/chat/${l}/logs?${u}`)).json()}async function mk(l,n){return(await _e(`/api/planner/log/${l}/${n}`)).json()}async function xk(){return(await _e("/api/replier/overview")).json()}async function hk(l,n=1,i=20,c){const u=new URLSearchParams({page:n.toString(),page_size:i.toString()});return c&&u.append("search",c),(await _e(`/api/replier/chat/${l}/logs?${u}`)).json()}async function fk(l,n){return(await _e(`/api/replier/log/${l}/${n}`)).json()}function $v(){const[l,n]=d.useState(new Map),[i,c]=d.useState(!0),u=d.useCallback(async()=>{try{c(!0);const h=await sx();if(h?.data){const f=new Map;h.data.forEach(p=>{f.set(p.chat_id,p.chat_name)}),n(f)}}catch(h){console.error("加载聊天列表失败:",h)}finally{c(!1)}},[]);d.useEffect(()=>{u()},[u]);const x=d.useCallback(h=>l.get(h)||h,[l]);return{chatNameMap:l,getChatName:x,loading:i,reload:u}}function Vo(l){return new Date(l*1e3).toLocaleString("zh-CN")}function Bv(l){const i=Date.now()/1e3-l;return i<60?"刚刚":i<3600?`${Math.floor(i/60)} 分钟前`:i<86400?`${Math.floor(i/3600)} 小时前`:`${Math.floor(i/86400)} 天前`}function Iv(l,n,i=1e4){d.useEffect(()=>{if(!l)return;const c=setInterval(n,i);return()=>clearInterval(c)},[l,n,i])}function pk({autoRefresh:l,refreshKey:n}){const[i,c]=d.useState("overview"),[u,x]=d.useState(null),{getChatName:h}=$v(),[f,p]=d.useState(null),[g,N]=d.useState(!0),[v,b]=d.useState(null),[w,y]=d.useState(!1),[R,O]=d.useState(1),[S,B]=d.useState(20),[E,C]=d.useState(""),[z,H]=d.useState(""),[L,J]=d.useState(""),[U,oe]=d.useState(null),[Ne,je]=d.useState(!1),[re,fe]=d.useState(!1),ge=d.useCallback(async()=>{try{N(!0);const D=await dk();p(D)}catch(D){console.error("加载规划器总览失败:",D)}finally{N(!1)}},[]),M=d.useCallback(async()=>{if(u)try{y(!0);const D=await uk(u.chat_id,R,S,z||void 0);b(D)}catch(D){console.error("加载聊天日志失败:",D)}finally{y(!1)}},[u,R,S,z]);d.useEffect(()=>{ge()},[ge]),d.useEffect(()=>{n>0&&(i==="overview"?ge():M())},[n,i,ge,M]),d.useEffect(()=>{i==="chat-logs"&&u&&M()},[i,u,M]),Iv(l,d.useCallback(()=>{i==="overview"?ge():M()},[i,ge,M]));const K=D=>{x(D),O(1),H(""),J(""),c("chat-logs")},I=()=>{c("overview"),x(null),b(null),H(""),J("")},ue=()=>{H(L),O(1)},Q=()=>{J(""),H(""),O(1)},Se=async(D,V)=>{try{fe(!0),je(!0);const de=await mk(D,V);oe(de)}catch(de){console.error("加载计划详情失败:",de)}finally{fe(!1)}},pe=D=>{B(Number(D)),O(1)},Te=()=>{const D=parseInt(E),V=v?Math.ceil(v.total/v.page_size):0;!isNaN(D)&&D>=1&&D<=V&&(O(D),C(""))},A=v?Math.ceil(v.total/v.page_size):0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-4",children:i==="overview"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"聊天数量"}),e.jsx(za,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Me,{children:g?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_chats||0})})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"计划总数"}),e.jsx(qm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Me,{children:g?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_plans||0})})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"聊天列表"}),e.jsx(os,{children:"点击查看该聊天的所有计划记录"})]}),e.jsx(Me,{children:g?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((D,V)=>e.jsx(vs,{className:"h-24 w-full"},V))}):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(D=>e.jsxs("div",{className:"border rounded-lg p-4 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>K(D),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(za,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm truncate max-w-[180px]",title:h(D.chat_id),children:h(D.chat_id)})]}),e.jsx(ke,{variant:"secondary",children:D.plan_count})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["最后活动: ",Bv(D.latest_timestamp)]})]},D.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:I,children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"返回聊天列表"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["当前聊天: ",e.jsx("span",{className:"font-medium",children:u?h(u.chat_id):""}),e.jsx("span",{className:"mx-2",children:"•"}),"共 ",v?.total||0," 条计划记录"]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{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(Re,{children:"计划执行记录"}),e.jsx(os,{children:u?h(u.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(ae,{placeholder:"搜索提示词内容...",value:L,onChange:D=>J(D.target.value),onKeyDown:D=>D.key==="Enter"&&ue(),className:"w-full sm:w-48"}),e.jsx(_,{variant:"outline",size:"icon",onClick:ue,children:e.jsx(Tt,{className:"h-4 w-4"})}),z&&e.jsx(_,{variant:"ghost",size:"sm",onClick:Q,children:"清除"})]}),e.jsxs(Ie,{value:S.toString(),onValueChange:pe,children:[e.jsx($e,{className:"w-full sm:w-32",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10条/页"}),e.jsx(Z,{value:"20",children:"20条/页"}),e.jsx(Z,{value:"50",children:"50条/页"}),e.jsx(Z,{value:"100",children:"100条/页"})]})]})]})]}),z&&e.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:["搜索关键词: ",e.jsxs("span",{className:"font-medium",children:['"',z,'"']})]})]}),e.jsx(Me,{children:w?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((D,V)=>e.jsx(vs,{className:"h-20 w-full"},V))}):v?.data&&v.data.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:v.data.map(D=>e.jsxs("div",{className:"border rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>Se(D.chat_id,D.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:Vo(D.timestamp)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs(ke,{variant:"secondary",className:"text-xs",children:[D.action_count," 个动作"]}),e.jsxs(ke,{variant:"outline",className:"text-xs",children:[D.total_plan_ms.toFixed(0),"ms"]})]})]}),D.action_types&&D.action_types.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:D.action_types.map((V,de)=>e.jsx(ke,{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:V},de))}),e.jsx("p",{className:"text-sm line-clamp-2",children:D.reasoning_preview||"无推理内容"})]},D.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:["共 ",v.total," 条记录,第 ",R," / ",A," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(1),disabled:R===1,className:"hidden sm:flex",children:e.jsx(gn,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(D=>Math.max(1,D-1)),disabled:R===1,children:e.jsx(Aa,{className:"h-4 w-4"})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[e.jsx(ae,{type:"number",min:1,max:A,value:E,onChange:D=>C(D.target.value),onKeyDown:D=>D.key==="Enter"&&Te(),placeholder:"跳转",className:"w-20 h-8"}),e.jsx(_,{size:"sm",variant:"outline",onClick:Te,children:"跳转"})]}),e.jsxs("span",{className:"sm:hidden text-sm text-muted-foreground",children:[R,"/",A]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(D=>Math.min(A,D+1)),disabled:R===A,children:e.jsx(Zt,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(A),disabled:R===A,className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无计划记录"})})]})]})}),e.jsx(Is,{open:Ne,onOpenChange:je,children:e.jsxs(Os,{className:"max-w-4xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-5 w-5"}),"计划执行详情"]}),e.jsx(Ks,{children:"查看麦麦的详细计划推理过程和执行动作"})]}),e.jsx(Je,{className:"h-full pr-4",children:e.jsx("div",{className:"space-y-6 pb-4",children:re?e.jsx("div",{className:"space-y-4",children:[...Array(5)].map((D,V)=>e.jsx(vs,{className:"h-24 w-full"},V))}):U?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(na,{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:U.chat_id,children:h(U.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:Vo(U.timestamp)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"类型"}),e.jsx(ke,{variant:"outline",children:U.type})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"动作数量"}),e.jsxs(ke,{children:[U.actions.length," 个动作"]})]})]})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Za,{className:"h-4 w-4"}),"性能统计"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs(Ce,{children:[e.jsx(De,{className:"p-4 pb-2",children:e.jsx(Re,{className:"text-xs text-muted-foreground",children:"提示词构建"})}),e.jsx(Me,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[U.timing.prompt_build_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Ce,{children:[e.jsx(De,{className:"p-4 pb-2",children:e.jsx(Re,{className:"text-xs text-muted-foreground",children:"LLM 推理"})}),e.jsx(Me,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[U.timing.llm_duration_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Ce,{children:[e.jsx(De,{className:"p-4 pb-2",children:e.jsx(Re,{className:"text-xs text-muted-foreground",children:"总计划时间"})}),e.jsx(Me,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[U.timing.total_plan_ms?.toFixed(2)||0,"ms"]})})]})]})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Zm,{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:U.reasoning||"无推理内容"})})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(o_,{className:"h-4 w-4"}),"执行动作 (",U.actions.length,")"]}),e.jsx("div",{className:"space-y-3",children:U.actions.map((D,V)=>e.jsxs(Ce,{children:[e.jsx(De,{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(ke,{variant:"default",children:["动作 ",V+1]}),e.jsx(ke,{variant:"outline",children:D.action_type})]})})}),e.jsxs(Me,{className:"p-4 pt-0 space-y-3",children:[D.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 D.reasoning=="string"?D.reasoning:JSON.stringify(D.reasoning)})]}),D.action_message&&e.jsxs("div",{className:"overflow-hidden",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"动作消息"}),typeof D.action_message=="string"?e.jsx("p",{className:"text-sm bg-muted/30 p-2 rounded break-all whitespace-pre-wrap",children:D.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(D.action_message,null,2)})]}),D.action_data&&Object.keys(D.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(D.action_data,null,2)})]}),D.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 D.action_reasoning=="string"?D.action_reasoning:JSON.stringify(D.action_reasoning)})]})]})]},V))})]}),e.jsx(Yt,{}),U.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:U.raw_output})})]})]}),U.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:U.prompt})})]})]})]}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"无数据"})})})}),e.jsx(st,{className:"flex-shrink-0",children:e.jsx(_,{onClick:()=>je(!1),children:"关闭"})})]})})]})}function gk({autoRefresh:l,refreshKey:n}){const[i,c]=d.useState("overview"),[u,x]=d.useState(null),{getChatName:h}=$v(),[f,p]=d.useState(null),[g,N]=d.useState(!0),[v,b]=d.useState(null),[w,y]=d.useState(!1),[R,O]=d.useState(1),[S,B]=d.useState(20),[E,C]=d.useState(""),[z,H]=d.useState(""),[L,J]=d.useState(""),[U,oe]=d.useState(null),[Ne,je]=d.useState(!1),[re,fe]=d.useState(!1),ge=d.useCallback(async()=>{try{N(!0);const D=await xk();p(D)}catch(D){console.error("加载回复器总览失败:",D)}finally{N(!1)}},[]),M=d.useCallback(async()=>{if(u)try{y(!0);const D=await hk(u.chat_id,R,S,z||void 0);b(D)}catch(D){console.error("加载聊天日志失败:",D)}finally{y(!1)}},[u,R,S,z]);d.useEffect(()=>{ge()},[ge]),d.useEffect(()=>{n>0&&(i==="overview"?ge():M())},[n,i,ge,M]),d.useEffect(()=>{i==="chat-logs"&&u&&M()},[i,u,M]),Iv(l,d.useCallback(()=>{i==="overview"?ge():M()},[i,ge,M]));const K=D=>{x(D),O(1),H(""),J(""),c("chat-logs")},I=()=>{c("overview"),x(null),b(null),H(""),J("")},ue=()=>{H(L),O(1)},Q=()=>{J(""),H(""),O(1)},Se=async(D,V)=>{try{fe(!0),je(!0);const de=await fk(D,V);oe(de)}catch(de){console.error("加载回复详情失败:",de)}finally{fe(!1)}},pe=D=>{B(Number(D)),O(1)},Te=()=>{const D=parseInt(E),V=v?Math.ceil(v.total/v.page_size):0;!isNaN(D)&&D>=1&&D<=V&&(O(D),C(""))},A=v?Math.ceil(v.total/v.page_size):0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-4",children:i==="overview"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"聊天数量"}),e.jsx(za,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Me,{children:g?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_chats||0})})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"回复总数"}),e.jsx(qm,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Me,{children:g?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:f?.total_replies||0})})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"聊天列表"}),e.jsx(os,{children:"点击查看该聊天的所有回复记录"})]}),e.jsx(Me,{children:g?e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((D,V)=>e.jsx(vs,{className:"h-24 w-full"},V))}):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(D=>e.jsxs("div",{className:"border rounded-lg p-4 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>K(D),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(za,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm truncate max-w-[180px]",title:h(D.chat_id),children:h(D.chat_id)})]}),e.jsx(ke,{variant:"secondary",children:D.reply_count})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["最后活动: ",Bv(D.latest_timestamp)]})]},D.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:I,children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"返回聊天列表"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["当前聊天: ",e.jsx("span",{className:"font-medium",children:u?h(u.chat_id):""}),e.jsx("span",{className:"mx-2",children:"•"}),"共 ",v?.total||0," 条回复记录"]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{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(Re,{children:"回复生成记录"}),e.jsx(os,{children:u?h(u.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(ae,{placeholder:"搜索提示词内容...",value:L,onChange:D=>J(D.target.value),onKeyDown:D=>D.key==="Enter"&&ue(),className:"w-full sm:w-48"}),e.jsx(_,{variant:"outline",size:"icon",onClick:ue,children:e.jsx(Tt,{className:"h-4 w-4"})}),z&&e.jsx(_,{variant:"ghost",size:"sm",onClick:Q,children:"清除"})]}),e.jsxs(Ie,{value:S.toString(),onValueChange:pe,children:[e.jsx($e,{className:"w-full sm:w-32",children:e.jsx(Pe,{})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"10",children:"10条/页"}),e.jsx(Z,{value:"20",children:"20条/页"}),e.jsx(Z,{value:"50",children:"50条/页"}),e.jsx(Z,{value:"100",children:"100条/页"})]})]})]})]}),z&&e.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:["搜索关键词: ",e.jsxs("span",{className:"font-medium",children:['"',z,'"']})]})]}),e.jsx(Me,{children:w?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((D,V)=>e.jsx(vs,{className:"h-20 w-full"},V))}):v?.data&&v.data.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:v.data.map(D=>e.jsxs("div",{className:"border rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>Se(D.chat_id,D.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:Vo(D.timestamp)}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[D.success?e.jsxs(ke,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(dg,{className:"h-3 w-3 mr-1"}),"成功"]}):e.jsxs(ke,{variant:"destructive",className:"text-xs",children:[e.jsx(Va,{className:"h-3 w-3 mr-1"}),"失败"]}),e.jsx(ke,{variant:"outline",className:"text-xs",children:D.model}),e.jsxs(ke,{variant:"secondary",className:"text-xs",children:[D.overall_ms.toFixed(0),"ms"]})]})]}),e.jsx("p",{className:"text-sm line-clamp-2",children:D.output_preview||"无输出内容"})]},D.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:["共 ",v.total," 条记录,第 ",R," / ",A," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(1),disabled:R===1,className:"hidden sm:flex",children:e.jsx(gn,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(D=>Math.max(1,D-1)),disabled:R===1,children:e.jsx(Aa,{className:"h-4 w-4"})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[e.jsx(ae,{type:"number",min:1,max:A,value:E,onChange:D=>C(D.target.value),onKeyDown:D=>D.key==="Enter"&&Te(),placeholder:"跳转",className:"w-20 h-8"}),e.jsx(_,{size:"sm",variant:"outline",onClick:Te,children:"跳转"})]}),e.jsxs("span",{className:"sm:hidden text-sm text-muted-foreground",children:[R,"/",A]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(D=>Math.min(A,D+1)),disabled:R===A,children:e.jsx(Zt,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>O(A),disabled:R===A,className:"hidden sm:flex",children:e.jsx(jn,{className:"h-4 w-4"})})]})]})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无回复记录"})})]})]})}),e.jsx(Is,{open:Ne,onOpenChange:je,children:e.jsxs(Os,{className:"max-w-4xl max-h-[80vh] grid grid-rows-[auto_1fr_auto] overflow-hidden",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(Ca,{className:"h-5 w-5"}),"回复生成详情"]}),e.jsx(Ks,{children:"查看麦麦的详细回复生成过程"})]}),e.jsx(Je,{className:"h-full pr-4",children:e.jsx("div",{className:"space-y-6 pb-4",children:re?e.jsx("div",{className:"space-y-4",children:[...Array(5)].map((D,V)=>e.jsx(vs,{className:"h-24 w-full"},V))}):U?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(na,{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:U.chat_id,children:h(U.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:Vo(U.timestamp)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"状态"}),U.success?e.jsxs(ke,{variant:"default",className:"bg-green-600",children:[e.jsx(dg,{className:"h-3 w-3 mr-1"}),"成功"]}):e.jsxs(ke,{variant:"destructive",children:[e.jsx(Va,{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(ke,{variant:"outline",children:["Level ",U.think_level]})]})]})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(d_,{className:"h-4 w-4"}),"模型信息"]}),e.jsx("div",{className:"p-4 bg-muted/50 rounded-lg",children:e.jsx(ke,{variant:"secondary",className:"text-sm",children:U.model})})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Za,{className:"h-4 w-4"}),"性能统计"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs(Ce,{children:[e.jsx(De,{className:"p-4 pb-2",children:e.jsx(Re,{className:"text-xs text-muted-foreground",children:"提示词构建"})}),e.jsx(Me,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[U.timing.prompt_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Ce,{children:[e.jsx(De,{className:"p-4 pb-2",children:e.jsx(Re,{className:"text-xs text-muted-foreground",children:"LLM 推理"})}),e.jsx(Me,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[U.timing.llm_ms?.toFixed(2)||0,"ms"]})})]}),e.jsxs(Ce,{children:[e.jsx(De,{className:"p-4 pb-2",children:e.jsx(Re,{className:"text-xs text-muted-foreground",children:"总耗时"})}),e.jsx(Me,{className:"p-4 pt-0",children:e.jsxs("div",{className:"text-xl font-bold",children:[U.timing.overall_ms?.toFixed(2)||0,"ms"]})})]})]}),U.timing.timing_logs&&U.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:U.timing.timing_logs.map((D,V)=>e.jsx("div",{className:"text-xs text-muted-foreground",children:D},V))})]}),U.timing.almost_zero&&e.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"近乎零耗时: "}),U.timing.almost_zero]})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Zm,{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:U.output||"无输出内容"})})]}),U.processed_output&&U.processed_output.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Yt,{}),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:U.processed_output.map((D,V)=>e.jsx("div",{className:"p-3 bg-muted/30 rounded-lg",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:D})},V))})]})]}),U.reasoning&&e.jsxs(e.Fragment,{children:[e.jsx(Yt,{}),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:U.reasoning})})]})]}),U.error&&e.jsxs(e.Fragment,{children:[e.jsx(Yt,{}),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:U.error})})]})]}),U.prompt&&e.jsxs(e.Fragment,{children:[e.jsx(Yt,{}),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:U.prompt})})]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"无数据"})})})}),e.jsx(st,{className:"flex-shrink-0",children:e.jsx(_,{onClick:()=>je(!1),children:"关闭"})})]})})]})}function jk(){const[l,n]=d.useState("planner"),[i,c]=d.useState(!1),[u,x]=d.useState(0),h=d.useCallback(()=>{x(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:i?"default":"outline",size:"sm",onClick:()=>c(!i),children:[e.jsx(dt,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),i?"自动刷新中":"自动刷新"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:h,children:e.jsx(dt,{className:"h-4 w-4"})})]})]}),e.jsxs(ta,{value:l,onValueChange:f=>n(f),className:"w-full",children:[e.jsxs(Xt,{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(Vm,{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(u_,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"回复器监控"})]})]}),e.jsxs(Je,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(ws,{value:"planner",className:"mt-0",children:e.jsx(pk,{autoRefresh:i,refreshKey:u})}),e.jsx(ws,{value:"replier",className:"mt-0",children:e.jsx(gk,{autoRefresh:i,refreshKey:u})})]})]})]})}const vk="Mai-with-u",Nk="plugin-repo",bk="main",yk="plugin_details.json";async function wk(){try{const l=await _e("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:vk,repo:Nk,branch:bk,file_path:yk})});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const n=await l.json();if(!n.success||!n.data)throw new Error(n.error||"获取插件列表失败");return JSON.parse(n.data).filter(u=>!u?.id||!u?.manifest?(console.warn("跳过无效插件数据:",u),!1):!u.manifest.name||!u.manifest.version?(console.warn("跳过缺少必需字段的插件:",u.id),!1):!0).map(u=>({id:u.id,manifest:{manifest_version:u.manifest.manifest_version||1,name:u.manifest.name,version:u.manifest.version,description:u.manifest.description||"",author:u.manifest.author||{name:"Unknown"},license:u.manifest.license||"Unknown",host_application:u.manifest.host_application||{min_version:"0.0.0"},homepage_url:u.manifest.homepage_url,repository_url:u.manifest.repository_url,keywords:u.manifest.keywords||[],categories:u.manifest.categories||[],default_locale:u.manifest.default_locale||"zh-CN",locales_path:u.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(l){throw console.error("Failed to fetch plugin list:",l),l}}async function Pv(){try{const l=await _e("/api/webui/plugins/git-status");if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return await l.json()}catch(l){return console.error("Failed to check Git status:",l),{installed:!1,error:"无法检测 Git 安装状态"}}}async function Hv(){try{const l=await _e("/api/webui/plugins/version");if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return await l.json()}catch(l){return console.error("Failed to get Maimai version:",l),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function Fv(l,n,i){const c=l.split(".").map(f=>parseInt(f)||0),u=c[0]||0,x=c[1]||0,h=c[2]||0;if(i.version_major<u||i.version_major===u&&i.version_minor<x||i.version_major===u&&i.version_minor===x&&i.version_patch<h)return!1;if(n){const f=n.split(".").map(v=>parseInt(v)||0),p=f[0]||0,g=f[1]||0,N=f[2]||0;if(i.version_major>p||i.version_major===p&&i.version_minor>g||i.version_major===p&&i.version_minor===g&&i.version_patch>N)return!1}return!0}async function _k(){try{const l=await _e("/api/webui/ws-token");if(!l.ok)return console.error("获取 WebSocket token 失败:",l.status),null;const n=await l.json();return n.success&&n.token?n.token:null}catch(l){return console.error("获取 WebSocket token 失败:",l),null}}async function Sk(l,n){const i=await _k();if(!i)return console.warn("无法获取 WebSocket token,可能未登录"),null;const c=window.location.protocol==="https:"?"wss:":"ws:",u=window.location.host,x=`${c}//${u}/api/webui/ws/plugin-progress?token=${encodeURIComponent(i)}`;try{const h=new WebSocket(x);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);l(p)}catch(p){console.error("Failed to parse progress data:",p)}},h.onerror=f=>{console.error("Plugin progress WebSocket error:",f),n?.(f)},h.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},h}catch(h){return console.error("创建 WebSocket 连接失败:",h),null}}async function Al(){try{const l=await _e("/api/webui/plugins/installed",{headers:Fs()});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const n=await l.json();if(!n.success)throw new Error(n.message||"获取已安装插件列表失败");return n.plugins||[]}catch(l){return console.error("Failed to get installed plugins:",l),[]}}function mn(l,n){return n.some(i=>i.id===l)}function xn(l,n){const i=n.find(c=>c.id===l);if(i)return i.manifest?.version||i.version}async function Gv(l,n,i="main"){const c=await _e("/api/webui/plugins/install",{method:"POST",body:JSON.stringify({plugin_id:l,repository_url:n,branch:i})});if(!c.ok){const u=await c.json();throw new Error(u.detail||"安装失败")}return await c.json()}async function Vv(l){const n=await _e("/api/webui/plugins/uninstall",{method:"POST",body:JSON.stringify({plugin_id:l})});if(!n.ok){const i=await n.json();throw new Error(i.detail||"卸载失败")}return await n.json()}async function qv(l,n,i="main"){const c=await _e("/api/webui/plugins/update",{method:"POST",body:JSON.stringify({plugin_id:l,repository_url:n,branch:i})});if(!c.ok){const u=await c.json();throw new Error(u.detail||"更新失败")}return await c.json()}async function kk(l){const n=await _e(`/api/webui/plugins/config/${l}/schema`,{headers:Fs()});if(!n.ok){const c=await n.text();try{const u=JSON.parse(c);throw new Error(u.detail||"获取配置 Schema 失败")}catch{throw new Error(`获取配置 Schema 失败 (${n.status})`)}}const i=await n.json();if(!i.success)throw new Error(i.message||"获取配置 Schema 失败");return i.schema}async function Ck(l){const n=await _e(`/api/webui/plugins/config/${l}`,{headers:Fs()});if(!n.ok){const c=await n.text();try{const u=JSON.parse(c);throw new Error(u.detail||"获取配置失败")}catch{throw new Error(`获取配置失败 (${n.status})`)}}const i=await n.json();if(!i.success)throw new Error(i.message||"获取配置失败");return i.config}async function Tk(l){const n=await _e(`/api/webui/plugins/config/${l}/raw`,{headers:Fs()});if(!n.ok){const c=await n.text();try{const u=JSON.parse(c);throw new Error(u.detail||"获取配置失败")}catch{throw new Error(`获取配置失败 (${n.status})`)}}const i=await n.json();if(!i.success)throw new Error(i.message||"获取配置失败");return i.config}async function Ek(l,n){const i=await _e(`/api/webui/plugins/config/${l}`,{method:"PUT",headers:Fs(),body:JSON.stringify({config:n})});if(!i.ok){const c=await i.json();throw new Error(c.detail||"保存配置失败")}return await i.json()}async function Mk(l,n){const i=await _e(`/api/webui/plugins/config/${l}/raw`,{method:"PUT",headers:Fs(),body:JSON.stringify({config:n})});if(!i.ok){const c=await i.json();throw new Error(c.detail||"保存配置失败")}return await i.json()}async function zk(l){const n=await _e(`/api/webui/plugins/config/${l}/reset`,{method:"POST",headers:Fs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"重置配置失败")}return await n.json()}async function Ak(l){const n=await _e(`/api/webui/plugins/config/${l}/toggle`,{method:"POST",headers:Fs()});if(!n.ok){const i=await n.json();throw new Error(i.detail||"切换状态失败")}return await n.json()}const xc="https://maibot-plugin-stats.maibot-webui.workers.dev";async function Kv(l){try{const n=await fetch(`${xc}/stats/${l}`);return n.ok?await n.json():(console.error("Failed to fetch plugin stats:",n.statusText),null)}catch(n){return console.error("Error fetching plugin stats:",n),null}}async function Ok(l,n){try{const i=n||xx(),c=await fetch(`${xc}/stats/like`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l,user_id:i})}),u=await c.json();return c.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:c.ok?{success:!0,...u}:{success:!1,error:u.error||"点赞失败"}}catch(i){return console.error("Error liking plugin:",i),{success:!1,error:"网络错误"}}}async function Dk(l,n){try{const i=n||xx(),c=await fetch(`${xc}/stats/dislike`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l,user_id:i})}),u=await c.json();return c.status===429?{success:!1,error:"操作过于频繁,请稍后再试"}:c.ok?{success:!0,...u}:{success:!1,error:u.error||"点踩失败"}}catch(i){return console.error("Error disliking plugin:",i),{success:!1,error:"网络错误"}}}async function Rk(l,n,i,c){if(n<1||n>5)return{success:!1,error:"评分必须在 1-5 之间"};try{const u=c||xx(),x=await fetch(`${xc}/stats/rate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l,rating:n,comment:i,user_id:u})}),h=await x.json();return x.status===429?{success:!1,error:"每天最多评分 3 次"}:x.ok?{success:!0,...h}:{success:!1,error:h.error||"评分失败"}}catch(u){return console.error("Error rating plugin:",u),{success:!1,error:"网络错误"}}}async function Qv(l){try{const n=await fetch(`${xc}/stats/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plugin_id:l})}),i=await n.json();return n.status===429?(console.warn("Download recording rate limited"),{success:!0}):n.ok?{success:!0,...i}:(console.error("Failed to record download:",i.error),{success:!1,error:i.error})}catch(n){return console.error("Error recording download:",n),{success:!1,error:"网络错误"}}}function Lk(){const l=navigator,n=[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,l.deviceMemory||0].join("|");let i=0;for(let c=0;c<n.length;c++){const u=n.charCodeAt(c);i=(i<<5)-i+u,i=i&i}return`fp_${Math.abs(i).toString(36)}`}function xx(){const l="maibot_user_id";let n=localStorage.getItem(l);if(!n){const i=Lk(),c=Date.now().toString(36),u=Math.random().toString(36).substring(2,15);n=`${i}_${c}_${u}`,localStorage.setItem(l,n)}return n}const Uk={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function $k(){return e.jsx(Jn,{children:e.jsx(Bk,{})})}function Bk(){const l=ca(),{triggerRestart:n,isRestarting:i}=vn(),[c,u]=d.useState(""),[x,h]=d.useState("all"),[f,p]=d.useState("all"),[g,N]=d.useState(!0),[v,b]=d.useState([]),[w,y]=d.useState(!0),[R,O]=d.useState(null),[S,B]=d.useState(null),[E,C]=d.useState(null),[z,H]=d.useState(null),[,L]=d.useState([]),[J,U]=d.useState({}),[oe,Ne]=d.useState(!1),[je,re]=d.useState(null),[fe,ge]=d.useState("main"),[M,K]=d.useState(""),[I,ue]=d.useState("preset"),[Q,Se]=d.useState(!1),{toast:pe}=Zs(),Te=async F=>{const ee=F.map(async Ee=>{try{const me=await Kv(Ee.id);return{id:Ee.id,stats:me}}catch(me){return console.warn(`Failed to load stats for ${Ee.id}:`,me),{id:Ee.id,stats:null}}}),Ue=await Promise.all(ee),ie={};Ue.forEach(({id:Ee,stats:me})=>{me&&(ie[Ee]=me)}),U(ie)};d.useEffect(()=>{let F=null,ee=!1;return(async()=>{if(F=await Sk(ie=>{ee||(C(ie),ie.stage==="success"?setTimeout(()=>{ee||C(null)},2e3):ie.stage==="error"&&(y(!1),O(ie.error||"加载失败")))},ie=>{console.error("WebSocket error:",ie),ee||pe({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise(ie=>{if(!F){ie();return}const Ee=()=>{F&&F.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),ie()):F&&F.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),ie()):setTimeout(Ee,100)};Ee()}),!ee){const ie=await Pv();B(ie),ie.installed||pe({title:"Git 未安装",description:ie.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!ee){const ie=await Hv();H(ie)}if(!ee)try{y(!0),O(null);const ie=await wk();if(!ee){const Ee=await Al();L(Ee);const me=ie.map(ze=>{const rs=mn(ze.id,Ee),Ut=xn(ze.id,Ee);return{...ze,installed:rs,installed_version:Ut}});for(const ze of Ee)!me.some(Ut=>Ut.id===ze.id)&&ze.manifest&&me.push({id:ze.id,manifest:{manifest_version:ze.manifest.manifest_version||1,name:ze.manifest.name,version:ze.manifest.version,description:ze.manifest.description||"",author:ze.manifest.author,license:ze.manifest.license||"Unknown",host_application:ze.manifest.host_application,homepage_url:ze.manifest.homepage_url,repository_url:ze.manifest.repository_url,keywords:ze.manifest.keywords||[],categories:ze.manifest.categories||[],default_locale:ze.manifest.default_locale||"zh-CN",locales_path:ze.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:ze.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});b(me),Te(me)}}catch(ie){if(!ee){const Ee=ie instanceof Error?ie.message:"加载插件列表失败";O(Ee),pe({title:"加载失败",description:Ee,variant:"destructive"})}}finally{ee||y(!1)}})(),()=>{ee=!0,F&&F.close()}},[pe]);const A=F=>{if(!F.installed&&z&&!D(F))return e.jsxs(ke,{variant:"destructive",className:"gap-1",children:[e.jsx(_t,{className:"h-3 w-3"}),"不兼容"]});if(F.installed){const ee=F.installed_version?.trim(),Ue=F.manifest.version?.trim();if(ee!==Ue){const ie=ee?.split(".").map(Number)||[0,0,0],Ee=Ue?.split(".").map(Number)||[0,0,0];for(let me=0;me<3;me++){if((Ee[me]||0)>(ie[me]||0))return e.jsxs(ke,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(_t,{className:"h-3 w-3"}),"可更新"]});if((Ee[me]||0)<(ie[me]||0))break}}return e.jsxs(ke,{variant:"default",className:"gap-1",children:[e.jsx(pt,{className:"h-3 w-3"}),"已安装"]})}return null},D=F=>!z||!F.manifest?.host_application?!0:Fv(F.manifest.host_application.min_version,F.manifest.host_application.max_version,z),V=F=>{if(!F.installed||!F.installed_version||!F.manifest?.version)return!1;const ee=F.installed_version.trim(),Ue=F.manifest.version.trim();if(ee===Ue)return!1;const ie=ee.split(".").map(Number),Ee=Ue.split(".").map(Number);for(let me=0;me<3;me++){if((Ee[me]||0)>(ie[me]||0))return!0;if((Ee[me]||0)<(ie[me]||0))return!1}return!1},de=v.filter(F=>{if(!F.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",F.id),!1;const ee=c===""||F.manifest.name?.toLowerCase().includes(c.toLowerCase())||F.manifest.description?.toLowerCase().includes(c.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(me=>me.toLowerCase().includes(c.toLowerCase())),Ue=x==="all"||F.manifest.categories&&F.manifest.categories.includes(x);let ie=!0;f==="installed"?ie=F.installed===!0:f==="updates"&&(ie=F.installed===!0&&V(F));const Ee=!g||!z||D(F);return ee&&Ue&&ie&&Ee}),Oe=F=>{if(!S?.installed){pe({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(z&&!D(F)){pe({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}re(F),ge("main"),K(""),ue("preset"),Se(!1),Ne(!0)},W=async()=>{if(!je)return;const F=I==="custom"?M:fe;if(!F||F.trim()===""){pe({title:"分支名称不能为空",variant:"destructive"});return}try{Ne(!1),await Gv(je.id,je.manifest.repository_url||"",F),Qv(je.id).catch(Ue=>{console.warn("Failed to record download:",Ue)}),pe({title:"安装成功",description:`${je.manifest.name} 已成功安装`});const ee=await Al();L(ee),b(Ue=>Ue.map(ie=>{if(ie.id===je.id){const Ee=mn(ie.id,ee),me=xn(ie.id,ee);return{...ie,installed:Ee,installed_version:me}}return ie}))}catch(ee){pe({title:"安装失败",description:ee instanceof Error?ee.message:"未知错误",variant:"destructive"})}finally{re(null)}},Y=async F=>{try{await Vv(F.id),pe({title:"卸载成功",description:`${F.manifest.name} 已成功卸载`});const ee=await Al();L(ee),b(Ue=>Ue.map(ie=>{if(ie.id===F.id){const Ee=mn(ie.id,ee),me=xn(ie.id,ee);return{...ie,installed:Ee,installed_version:me}}return ie}))}catch(ee){pe({title:"卸载失败",description:ee instanceof Error?ee.message:"未知错误",variant:"destructive"})}},He=async F=>{if(!S?.installed){pe({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const ee=await qv(F.id,F.manifest.repository_url||"","main");pe({title:"更新成功",description:`${F.manifest.name} 已从 ${ee.old_version} 更新到 ${ee.new_version}`});const Ue=await Al();L(Ue),b(ie=>ie.map(Ee=>{if(Ee.id===F.id){const me=mn(Ee.id,Ue),ze=xn(Ee.id,Ue);return{...Ee,installed:me,installed_version:ze}}return Ee}))}catch(ee){pe({title:"更新失败",description:ee instanceof Error?ee.message:"未知错误",variant:"destructive"})}};return e.jsx(Je,{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:()=>n(),disabled:i,children:[e.jsx(Hj,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),"重启麦麦"]}),e.jsxs(_,{onClick:()=>l({to:"/plugin-mirrors"}),children:[e.jsx(m_,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]})]}),e.jsx(Ce,{className:"border-blue-200 bg-blue-50 dark:bg-blue-950/20 dark:border-blue-900",children:e.jsx(Me,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ht,{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(Ce,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(De,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Jt,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(Re,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(os,{className:"text-orange-800 dark:text-orange-200",children:S.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(Me,{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(Ce,{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(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索插件...",value:c,onChange:F=>u(F.target.value),className:"pl-9"})]}),e.jsxs(Ie,{value:x,onValueChange:h,children:[e.jsx($e,{className:"w-full sm:w-[200px]",children:e.jsx(Pe,{placeholder:"选择分类"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"all",children:"全部分类"}),e.jsx(Z,{value:"Group Management",children:"群组管理"}),e.jsx(Z,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(Z,{value:"Utility Tools",children:"实用工具"}),e.jsx(Z,{value:"Content Generation",children:"内容生成"}),e.jsx(Z,{value:"Multimedia",children:"多媒体"}),e.jsx(Z,{value:"External Integration",children:"外部集成"}),e.jsx(Z,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(Z,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qs,{id:"compatible-only",checked:g,onCheckedChange:F=>N(F===!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(ta,{value:f,onValueChange:p,className:"w-full",children:e.jsxs(Xt,{className:"grid w-full grid-cols-3",children:[e.jsxs(Xe,{value:"all",children:["全部插件 (",v.filter(F=>{if(!F.manifest)return!1;const ee=c===""||F.manifest.name?.toLowerCase().includes(c.toLowerCase())||F.manifest.description?.toLowerCase().includes(c.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Ee=>Ee.toLowerCase().includes(c.toLowerCase())),Ue=x==="all"||F.manifest.categories&&F.manifest.categories.includes(x),ie=!g||!z||D(F);return ee&&Ue&&ie}).length,")"]}),e.jsxs(Xe,{value:"installed",children:["已安装 (",v.filter(F=>{if(!F.manifest)return!1;const ee=c===""||F.manifest.name?.toLowerCase().includes(c.toLowerCase())||F.manifest.description?.toLowerCase().includes(c.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Ee=>Ee.toLowerCase().includes(c.toLowerCase())),Ue=x==="all"||F.manifest.categories&&F.manifest.categories.includes(x),ie=!g||!z||D(F);return F.installed&&ee&&Ue&&ie}).length,")"]}),e.jsxs(Xe,{value:"updates",children:["可更新 (",v.filter(F=>{if(!F.manifest)return!1;const ee=c===""||F.manifest.name?.toLowerCase().includes(c.toLowerCase())||F.manifest.description?.toLowerCase().includes(c.toLowerCase())||F.manifest.keywords&&F.manifest.keywords.some(Ee=>Ee.toLowerCase().includes(c.toLowerCase())),Ue=x==="all"||F.manifest.categories&&F.manifest.categories.includes(x),ie=!g||!z||D(F);return F.installed&&V(F)&&ee&&Ue&&ie}).length,")"]})]})}),E&&E.stage==="loading"&&E.operation==="fetch"&&e.jsx(Ce,{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(Bs,{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(Qn,{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(Ce,{className:"border-destructive bg-destructive/10",children:e.jsx(De,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Jt,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(Re,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(os,{className:"text-destructive/80",children:E.error})]})]})})}),w?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Bs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):R?e.jsx(Ce,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Jt,{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:R}),e.jsx(_,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):de.length===0?e.jsx(Ce,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Tt,{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||x!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:de.map(F=>e.jsxs(Ce,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(De,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Re,{className:"text-xl",children:F.manifest?.name||F.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[F.manifest?.categories&&F.manifest.categories[0]&&e.jsx(ke,{variant:"secondary",className:"text-xs whitespace-nowrap",children:Uk[F.manifest.categories[0]]||F.manifest.categories[0]}),A(F)]})]}),e.jsx(os,{className:"line-clamp-2",children:F.manifest?.description||"无描述"})]}),e.jsx(Me,{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(sa,{className:"h-4 w-4"}),e.jsx("span",{children:(J[F.id]?.downloads??F.downloads??0).toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:(J[F.id]?.rating??F.rating??0).toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[F.manifest?.keywords&&F.manifest.keywords.slice(0,3).map(ee=>e.jsx(ke,{variant:"outline",className:"text-xs",children:ee},ee)),F.manifest?.keywords&&F.manifest.keywords.length>3&&e.jsxs(ke,{variant:"outline",className:"text-xs",children:["+",F.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",F.manifest?.version||"unknown"," · ",F.manifest?.author?.name||"Unknown"]}),F.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[F.manifest.host_application.min_version,F.manifest.host_application.max_version?` - ${F.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(ed,{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:()=>l({to:"/plugin-detail",search:{pluginId:F.id}}),children:"查看详情"}),F.installed?V(F)?e.jsxs(_,{size:"sm",disabled:!S?.installed,title:S?.installed?void 0:"Git 未安装",onClick:()=>He(F),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:()=>Y(F),children:[e.jsx(ns,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(_,{size:"sm",disabled:!S?.installed||E?.operation==="install"||z!==null&&!D(F),title:S?.installed?z!==null&&!D(F)?`不兼容当前版本 (需要 ${F.manifest?.host_application?.min_version||"未知"}${F.manifest?.host_application?.max_version?` - ${F.manifest.host_application.max_version}`:"+"},当前 ${z?.version})`:void 0:"Git 未安装",onClick:()=>Oe(F),children:[e.jsx(sa,{className:"h-4 w-4 mr-1"}),E?.operation==="install"&&E?.plugin_id===F.id?"安装中...":"安装"]})]})}),E&&(E.stage==="loading"||E.stage==="success"||E.stage==="error")&&E.operation!=="fetch"&&E.plugin_id===F.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(Bs,{className:"h-3 w-3 animate-spin"}):E.stage==="success"?e.jsx(pt,{className:"h-3 w-3 text-green-600"}):e.jsx(_t,{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(Qn,{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})]})})]},F.id))}),e.jsx(Is,{open:oe,onOpenChange:Ne,children:e.jsxs(Os,{children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"安装插件"}),e.jsxs(Ks,{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(qs,{id:"advanced-options",checked:Q,onCheckedChange:F=>Se(F)}),e.jsx("label",{htmlFor:"advanced-options",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"高级选项"})]}),Q&&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(ta,{value:I,onValueChange:F=>ue(F),children:[e.jsxs(Xt,{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:"自定义分支"})]}),I==="preset"&&e.jsx("div",{className:"mt-3",children:e.jsxs(Ie,{value:fe,onValueChange:ge,children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:"选择分支"})}),e.jsxs(Be,{children:[e.jsx(Z,{value:"main",children:"main (默认)"}),e.jsx(Z,{value:"master",children:"master"}),e.jsx(Z,{value:"dev",children:"dev (开发版)"}),e.jsx(Z,{value:"develop",children:"develop"}),e.jsx(Z,{value:"beta",children:"beta (测试版)"}),e.jsx(Z,{value:"stable",children:"stable (稳定版)"})]})]})}),I==="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:M,onChange:F=>K(F.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"输入 Git 分支名称、标签或提交哈希"})]})]})]})}),!Q&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"将从默认分支 (main) 安装插件"})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>Ne(!1),children:"取消"}),e.jsxs(_,{onClick:W,children:[e.jsx(sa,{className:"h-4 w-4 mr-2"}),"安装"]})]})]})}),e.jsx(Xn,{})]})})}function Ik(){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(Fj,{className:"h-8 w-8",strokeWidth:2}),"模型分配预设市场"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"浏览和下载社区共享的模型分配预设配置"})]})})}),e.jsx(Je,{className:"flex-1",children:e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-12rem)]",children:e.jsxs(Ce,{className:"max-w-2xl w-full border-dashed",children:[e.jsxs(De,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ra,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Re,{className:"text-2xl",children:"功能开发中"}),e.jsx(os,{className:"text-base",children:"模型分配预设市场功能正在开发中,敬请期待!"})]}),e.jsx(Me,{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 Pk({field:l,value:n,onChange:i}){const[c,u]=d.useState(!1);switch(l.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:l.label}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]}),e.jsx(Ge,{checked:!!n,onCheckedChange:i,disabled:l.disabled})]});case"number":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:l.label}),e.jsx(ae,{type:"number",value:n??l.default,onChange:x=>i(parseFloat(x.target.value)||0),min:l.min,max:l.max,step:l.step??1,placeholder:l.placeholder,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.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:l.label}),e.jsx("span",{className:"text-sm text-muted-foreground",children:n??l.default})]}),e.jsx(qa,{value:[n??l.default],onValueChange:x=>i(x[0]),min:l.min??0,max:l.max??100,step:l.step??1,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"select":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:l.label}),e.jsxs(Ie,{value:String(n??l.default),onValueChange:i,disabled:l.disabled,children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:l.placeholder??"请选择"})}),e.jsx(Be,{children:l.choices?.map(x=>e.jsx(Z,{value:String(x),children:String(x)},String(x)))})]}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"textarea":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:l.label}),e.jsx(ot,{value:n??l.default,onChange:x=>i(x.target.value),placeholder:l.placeholder,rows:l.rows??3,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"password":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:l.label}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{type:c?"text":"password",value:n??"",onChange:x=>i(x.target.value),placeholder:l.placeholder,disabled:l.disabled,className:"pr-10"}),e.jsx(_,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3",onClick:()=>u(!c),children:c?e.jsx(ec,{className:"h-4 w-4"}):e.jsx(ia,{className:"h-4 w-4"})})]}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"list":return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:l.label}),e.jsx(q2,{value:Array.isArray(n)?n:[],onChange:x=>i(x),itemType:l.item_type??"string",itemFields:l.item_fields,minItems:l.min_items,maxItems:l.max_items,disabled:l.disabled,placeholder:l.placeholder}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]});case"text":default:return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:l.label}),e.jsx(ae,{type:"text",value:n??l.default??"",onChange:x=>i(x.target.value),placeholder:l.placeholder,maxLength:l.max_length,disabled:l.disabled}),l.hint&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l.hint})]})}}function Bg({section:l,config:n,onChange:i}){const[c,u]=d.useState(!l.collapsed),x=Object.entries(l.fields).filter(([,h])=>!h.hidden).sort(([,h],[,f])=>h.order-f.order);return e.jsx(rc,{open:c,onOpenChange:u,children:e.jsxs(Ce,{children:[e.jsx(ic,{asChild:!0,children:e.jsxs(De,{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(Ma,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Re,{className:"text-lg",children:l.title})]}),e.jsxs(ke,{variant:"secondary",className:"text-xs",children:[x.length," 项"]})]}),l.description&&e.jsx(os,{className:"ml-6",children:l.description})]})}),e.jsx(cc,{children:e.jsx(Me,{className:"space-y-4 pt-0",children:x.map(([h,f])=>e.jsx(Pk,{field:f,value:n[l.name]?.[h],onChange:p=>i(l.name,h,p),sectionName:l.name},h))})})]})})}function Hk({plugin:l,onBack:n}){const{toast:i}=Zs(),{triggerRestart:c,isRestarting:u}=vn(),[x,h]=d.useState("visual"),[f,p]=d.useState(null),[g,N]=d.useState({}),[v,b]=d.useState({}),[w,y]=d.useState(""),[R,O]=d.useState(""),[S,B]=d.useState(!0),[E,C]=d.useState(!1),[z,H]=d.useState(!1),[L,J]=d.useState(!1),[U,oe]=d.useState(!1),Ne=d.useCallback(async()=>{B(!0);try{const[I,ue,Q]=await Promise.all([kk(l.id),Ck(l.id),Tk(l.id)]);p(I),N(ue),b(JSON.parse(JSON.stringify(ue))),y(Q),O(Q)}catch(I){i({title:"加载配置失败",description:I instanceof Error?I.message:"未知错误",variant:"destructive"})}finally{B(!1)}},[l.id,i]);d.useEffect(()=>{Ne()},[Ne]),d.useEffect(()=>{H(x==="visual"?JSON.stringify(g)!==JSON.stringify(v):w!==R)},[g,v,w,R,x]);const je=(I,ue,Q)=>{N(Se=>({...Se,[I]:{...Se[I]||{},[ue]:Q}}))},re=async()=>{C(!0);try{if(x==="source"){try{Ov(w)}catch(I){J(!0),i({title:"TOML 格式错误",description:I instanceof Error?I.message:"无法解析 TOML 配置,请检查语法",variant:"destructive"}),C(!1);return}await Mk(l.id,w),O(w),J(!1)}else await Ek(l.id,g),b(JSON.parse(JSON.stringify(g)));i({title:"配置已保存",description:"更改将在插件重新加载后生效"})}catch(I){i({title:"保存失败",description:I instanceof Error?I.message:"未知错误",variant:"destructive"})}finally{C(!1)}},fe=async()=>{try{await zk(l.id),i({title:"配置已重置",description:"下次加载插件时将使用默认配置"}),oe(!1),Ne()}catch(I){i({title:"重置失败",description:I instanceof Error?I.message:"未知错误",variant:"destructive"})}},ge=async()=>{try{const I=await Ak(l.id);i({title:I.message,description:I.note}),Ne()}catch(I){i({title:"切换状态失败",description:I instanceof Error?I.message:"未知错误",variant:"destructive"})}};if(S)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(Bs,{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(_t,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:"无法加载配置"}),e.jsxs(_,{onClick:n,variant:"outline",children:[e.jsx(Ta,{className:"h-4 w-4 mr-2"}),"返回"]})]});const M=Object.values(f.sections).sort((I,ue)=>I.order-ue.order),K=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:n,children:e.jsx(Ta,{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||l.manifest.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ke,{variant:K?"default":"secondary",children:K?"已启用":"已禁用"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["v",f.plugin_info.version||l.manifest.version]})]})]})]}),e.jsxs("div",{className:"flex gap-2 ml-10 sm:ml-0",children:[e.jsx(_,{variant:"outline",size:"sm",onClick:()=>h(x==="visual"?"source":"visual"),children:x==="visual"?e.jsxs(e.Fragment,{children:[e.jsx(Bj,{className:"h-4 w-4 mr-2"}),"源代码"]}):e.jsxs(e.Fragment,{children:[e.jsx($j,{className:"h-4 w-4 mr-2"}),"可视化"]})}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>c(),disabled:u,children:[e.jsx(Hj,{className:`h-4 w-4 mr-2 ${u?"animate-spin":""}`}),"重启麦麦"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:ge,children:[e.jsx(oc,{className:"h-4 w-4 mr-2"}),K?"禁用":"启用"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:()=>oe(!0),children:[e.jsx(Wi,{className:"h-4 w-4 mr-2"}),"重置"]}),e.jsxs(_,{size:"sm",onClick:re,disabled:!z||E,children:[E?e.jsx(Bs,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(dc,{className:"h-4 w-4 mr-2"}),"保存"]})]})]}),z&&e.jsx(Ce,{className:"border-orange-200 bg-orange-50 dark:bg-orange-950/20 dark:border-orange-900",children:e.jsx(Me,{className:"py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ht,{className:"h-4 w-4 text-orange-600"}),e.jsx("p",{className:"text-sm text-orange-800 dark:text-orange-200",children:"有未保存的更改"})]})})}),x==="source"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(at,{children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsxs(lt,{children:[e.jsx("strong",{children:"源代码模式(高级功能):"}),"直接编辑 TOML 配置文件。保存时会验证格式,只有格式正确才能保存。",L&&e.jsx("span",{className:"text-destructive font-semibold ml-2",children:"⚠️ 上次保存失败,请检查 TOML 格式"})]})]}),e.jsx(yv,{value:w,onChange:I=>{y(I),L&&J(!1)},language:"toml",theme:"dark",height:"calc(100vh - 350px)",minHeight:"500px",placeholder:"TOML 配置内容"})]}),x==="visual"&&e.jsxs(e.Fragment,{children:[e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsxs(lt,{children:[e.jsx("strong",{children:"提示:"}),"如果插件当前未加载或未启用,WebUI 适配器的高级插件可视化编辑功能可能会不可用。 请确保插件已启用并成功加载后,再进行配置编辑。"]})]}),f.layout.type==="tabs"&&f.layout.tabs.length>0?e.jsxs(ta,{defaultValue:f.layout.tabs[0]?.id,children:[e.jsx(Xt,{children:f.layout.tabs.map(I=>e.jsxs(Xe,{value:I.id,children:[I.title,I.badge&&e.jsx(ke,{variant:"secondary",className:"ml-2 text-xs",children:I.badge})]},I.id))}),f.layout.tabs.map(I=>e.jsx(ws,{value:I.id,className:"space-y-4 mt-4",children:I.sections.map(ue=>{const Q=f.sections[ue];return Q?e.jsx(Bg,{section:Q,config:g,onChange:je},ue):null})},I.id))]}):e.jsx("div",{className:"space-y-4",children:M.map(I=>e.jsx(Bg,{section:I,config:g,onChange:je},I.name))})]}),e.jsx(Is,{open:U,onOpenChange:oe,children:e.jsxs(Os,{children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"确认重置配置"}),e.jsx(Ks,{children:"这将删除当前配置文件,下次加载插件时将使用默认配置。此操作不可撤销。"})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>oe(!1),children:"取消"}),e.jsx(_,{variant:"destructive",onClick:fe,children:"确认重置"})]})]})})]})}function Fk(){return e.jsx(Jn,{children:e.jsx(Gk,{})})}function Gk(){const{toast:l}=Zs(),[n,i]=d.useState([]),[c,u]=d.useState(!0),[x,h]=d.useState(""),[f,p]=d.useState(null),g=async()=>{u(!0);try{const y=await Al();i(y)}catch(y){l({title:"加载插件列表失败",description:y instanceof Error?y.message:"未知错误",variant:"destructive"})}finally{u(!1)}};d.useEffect(()=>{g()},[]);const v=n.filter(y=>{const R=x.toLowerCase();return y.id.toLowerCase().includes(R)||y.manifest.name.toLowerCase().includes(R)||y.manifest.description?.toLowerCase().includes(R)}).filter((y,R,O)=>R===O.findIndex(S=>S.id===y.id)),b=n.length,w=0;return f?e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"h-full",children:e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(Hk,{plugin:f,onBack:()=>p(null)})})}),e.jsx(Xn,{})]}):e.jsx(Je,{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(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(ra,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Me,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n.length}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:c?"正在加载...":"个插件"})]})]}),e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"已启用"}),e.jsx(pt,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(Me,{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(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(_t,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(Me,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"未激活的插件"})]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索插件...",value:x,onChange:y=>h(y.target.value),className:"pl-9"})]}),e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"已安装的插件"}),e.jsx(os,{children:"点击插件查看和编辑配置"})]}),e.jsx(Me,{children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):v.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(ra,{className:"h-16 w-16 text-muted-foreground/50"}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-lg font-medium text-muted-foreground",children:x?"没有找到匹配的插件":"暂无已安装的插件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x?"尝试其他搜索关键词":"前往插件市场安装插件"})]})]}):e.jsx("div",{className:"space-y-2",children:v.map(y=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>p(y),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(ra,{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:y.manifest.name}),e.jsxs(ke,{variant:"secondary",className:"text-xs flex-shrink-0",children:["v",y.manifest.version]})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:y.manifest.description||"暂无描述"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(_,{variant:"ghost",size:"sm",children:e.jsx(pn,{className:"h-4 w-4"})}),e.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})]})]},y.id))})})]})]})})}function Vk(){const l=ca(),{toast:n}=Zs(),[i,c]=d.useState([]),[u,x]=d.useState(!0),[h,f]=d.useState(null),[p,g]=d.useState(null),[N,v]=d.useState(!1),[b,w]=d.useState(!1),[y,R]=d.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),O=d.useCallback(async()=>{try{x(!0),f(null);const L=await _e("/api/webui/plugins/mirrors");if(!L.ok)throw new Error("获取镜像源列表失败");const J=await L.json();c(J.mirrors||[])}catch(L){const J=L instanceof Error?L.message:"加载镜像源失败";f(J),n({title:"加载失败",description:J,variant:"destructive"})}finally{x(!1)}},[n]);d.useEffect(()=>{O()},[O]);const S=async()=>{try{const L=await _e("/api/webui/plugins/mirrors",{method:"POST",body:JSON.stringify(y)});if(!L.ok){const J=await L.json();throw new Error(J.detail||"添加镜像源失败")}n({title:"添加成功",description:"镜像源已添加"}),v(!1),R({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),O()}catch(L){n({title:"添加失败",description:L instanceof Error?L.message:"未知错误",variant:"destructive"})}},B=async()=>{if(p)try{if(!(await _e(`/api/webui/plugins/mirrors/${p.id}`,{method:"PUT",body:JSON.stringify({name:y.name,raw_prefix:y.raw_prefix,clone_prefix:y.clone_prefix,enabled:y.enabled,priority:y.priority})})).ok)throw new Error("更新镜像源失败");n({title:"更新成功",description:"镜像源已更新"}),w(!1),g(null),O()}catch(L){n({title:"更新失败",description:L instanceof Error?L.message:"未知错误",variant:"destructive"})}},E=async L=>{if(confirm("确定要删除这个镜像源吗?"))try{if(!(await _e(`/api/webui/plugins/mirrors/${L}`,{method:"DELETE"})).ok)throw new Error("删除镜像源失败");n({title:"删除成功",description:"镜像源已删除"}),O()}catch(J){n({title:"删除失败",description:J instanceof Error?J.message:"未知错误",variant:"destructive"})}},C=async L=>{try{if(!(await _e(`/api/webui/plugins/mirrors/${L.id}`,{method:"PUT",body:JSON.stringify({enabled:!L.enabled})})).ok)throw new Error("更新状态失败");O()}catch(J){n({title:"更新失败",description:J instanceof Error?J.message:"未知错误",variant:"destructive"})}},z=L=>{g(L),R({id:L.id,name:L.name,raw_prefix:L.raw_prefix,clone_prefix:L.clone_prefix,enabled:L.enabled,priority:L.priority}),w(!0)},H=async(L,J)=>{const U=J==="up"?L.priority-1:L.priority+1;if(!(U<1))try{if(!(await _e(`/api/webui/plugins/mirrors/${L.id}`,{method:"PUT",body:JSON.stringify({priority:U})})).ok)throw new Error("更新优先级失败");O()}catch(oe){n({title:"更新失败",description:oe instanceof Error?oe.message:"未知错误",variant:"destructive"})}};return e.jsx(Je,{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:()=>l({to:"/plugins"}),children:e.jsx(Ta,{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:()=>v(!0),children:[e.jsx(et,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),u?e.jsx(Ce,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Bs,{className:"h-8 w-8 animate-spin text-primary"})})}):h?e.jsx(Ce,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Jt,{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:O,children:"重新加载"})]})}):e.jsxs(Ce,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{children:"状态"}),e.jsx(We,{children:"名称"}),e.jsx(We,{children:"ID"}),e.jsx(We,{children:"优先级"}),e.jsx(We,{className:"text-right",children:"操作"})]})}),e.jsx(Ul,{children:i.map(L=>e.jsxs(ut,{children:[e.jsx(Ke,{children:e.jsx(Ge,{checked:L.enabled,onCheckedChange:()=>C(L)})}),e.jsx(Ke,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:L.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",L.raw_prefix]})]})}),e.jsx(Ke,{children:e.jsx(ke,{variant:"outline",children:L.id})}),e.jsx(Ke,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:L.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(_,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>H(L,"up"),disabled:L.priority===1,children:e.jsx(Fr,{className:"h-3 w-3"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>H(L,"down"),children:e.jsx(Ma,{className:"h-3 w-3"})})]})]})}),e.jsx(Ke,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>z(L),children:e.jsx(Gn,{className:"h-4 w-4"})}),e.jsx(_,{variant:"ghost",size:"icon",onClick:()=>E(L.id),children:e.jsx(ns,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:i.map(L=>e.jsx(Ce,{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:L.name}),L.enabled&&e.jsx(ke,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(ke,{variant:"outline",className:"mt-1 text-xs",children:L.id})]}),e.jsx(Ge,{checked:L.enabled,onCheckedChange:()=>C(L)})]}),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:L.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:L.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:()=>z(L),children:[e.jsx(Gn,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>H(L,"up"),disabled:L.priority===1,children:e.jsx(Fr,{className:"h-4 w-4"})}),e.jsx(_,{variant:"outline",size:"sm",onClick:()=>H(L,"down"),children:e.jsx(Ma,{className:"h-4 w-4"})}),e.jsx(_,{variant:"destructive",size:"sm",onClick:()=>E(L.id),children:e.jsx(ns,{className:"h-4 w-4"})})]})]})},L.id))})]}),e.jsx(Is,{open:N,onOpenChange:v,children:e.jsxs(Os,{className:"max-w-lg",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"添加镜像源"}),e.jsx(Ks,{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(ae,{id:"add-id",placeholder:"例如: my-mirror",value:y.id,onChange:L=>R({...y,id:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-name",children:"名称 *"}),e.jsx(ae,{id:"add-name",placeholder:"例如: 我的镜像源",value:y.name,onChange:L=>R({...y,name:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(ae,{id:"add-raw",placeholder:"https://example.com/raw",value:y.raw_prefix,onChange:L=>R({...y,raw_prefix:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(ae,{id:"add-clone",placeholder:"https://example.com/clone",value:y.clone_prefix,onChange:L=>R({...y,clone_prefix:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"add-priority",children:"优先级"}),e.jsx(ae,{id:"add-priority",type:"number",min:"1",value:y.priority,onChange:L=>R({...y,priority:parseInt(L.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:y.enabled,onCheckedChange:L=>R({...y,enabled:L})}),e.jsx(T,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>v(!1),children:"取消"}),e.jsx(_,{onClick:S,children:"添加"})]})]})}),e.jsx(Is,{open:b,onOpenChange:w,children:e.jsxs(Os,{className:"max-w-lg",children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"编辑镜像源"}),e.jsx(Ks,{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(ae,{value:y.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(ae,{id:"edit-name",value:y.name,onChange:L=>R({...y,name:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(ae,{id:"edit-raw",value:y.raw_prefix,onChange:L=>R({...y,raw_prefix:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(ae,{id:"edit-clone",value:y.clone_prefix,onChange:L=>R({...y,clone_prefix:L.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(ae,{id:"edit-priority",type:"number",min:"1",value:y.priority,onChange:L=>R({...y,priority:parseInt(L.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:y.enabled,onCheckedChange:L=>R({...y,enabled:L})}),e.jsx(T,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>w(!1),children:"取消"}),e.jsx(_,{onClick:B,children:"保存"})]})]})})]})})}function qk({pluginId:l,compact:n=!1}){const[i,c]=d.useState(null),[u,x]=d.useState(!0),[h,f]=d.useState(0),[p,g]=d.useState(""),[N,v]=d.useState(!1),{toast:b}=Zs(),w=async()=>{x(!0);const S=await Kv(l);S&&c(S),x(!1)};d.useEffect(()=>{w()},[l]);const y=async()=>{const S=await Ok(l);S.success?(b({title:"已点赞",description:"感谢你的支持!"}),w()):b({title:"点赞失败",description:S.error||"未知错误",variant:"destructive"})},R=async()=>{const S=await Dk(l);S.success?(b({title:"已反馈",description:"感谢你的反馈!"}),w()):b({title:"操作失败",description:S.error||"未知错误",variant:"destructive"})},O=async()=>{if(h===0){b({title:"请选择评分",description:"至少选择 1 颗星",variant:"destructive"});return}const S=await Rk(l,h,p||void 0);S.success?(b({title:"评分成功",description:"感谢你的评价!"}),v(!1),f(0),g(""),w()):b({title:"评分失败",description:S.error||"未知错误",variant:"destructive"})};return u?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(sa,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(dn,{className:"h-4 w-4"}),e.jsx("span",{children:"-"})]})]}):i?n?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:`下载量: ${i.downloads.toLocaleString()}`,children:[e.jsx(sa,{className:"h-4 w-4"}),e.jsx("span",{children:i.downloads.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`评分: ${i.rating.toFixed(1)} (${i.rating_count} 条评价)`,children:[e.jsx(dn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:i.rating.toFixed(1)})]}),e.jsxs("div",{className:"flex items-center gap-1",title:`点赞数: ${i.likes}`,children:[e.jsx(bm,{className:"h-4 w-4"}),e.jsx("span",{children:i.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(sa,{className:"h-5 w-5 text-muted-foreground mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:i.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(dn,{className:"h-5 w-5 text-yellow-400 mb-1 fill-yellow-400"}),e.jsx("span",{className:"text-2xl font-bold",children:i.rating.toFixed(1)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[i.rating_count," 条评价"]})]}),e.jsxs("div",{className:"flex flex-col items-center p-3 rounded-lg border bg-card",children:[e.jsx(bm,{className:"h-5 w-5 text-green-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:i.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(ug,{className:"h-5 w-5 text-red-500 mb-1"}),e.jsx("span",{className:"text-2xl font-bold",children:i.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:y,children:[e.jsx(bm,{className:"h-4 w-4 mr-1"}),"点赞"]}),e.jsxs(_,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ug,{className:"h-4 w-4 mr-1"}),"点踩"]}),e.jsxs(Is,{open:N,onOpenChange:v,children:[e.jsx(sd,{asChild:!0,children:e.jsxs(_,{variant:"default",size:"sm",children:[e.jsx(dn,{className:"h-4 w-4 mr-1"}),"评分"]})}),e.jsxs(Os,{children:[e.jsxs(Ds,{children:[e.jsx(Rs,{children:"为插件评分"}),e.jsx(Ks,{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(dn,{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(ot,{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(st,{children:[e.jsx(_,{variant:"outline",onClick:()=>v(!1),children:"取消"}),e.jsx(_,{onClick:O,disabled:h===0,children:"提交评分"})]})]})]})]}),i.recent_ratings&&i.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:i.recent_ratings.map((S,B)=>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(dn,{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})]},B))})]})]}):null}const Kk={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function Qk(){const l=ca(),n=y0({strict:!1}),{toast:i}=Zs(),[c,u]=d.useState(null),[x,h]=d.useState(""),[f,p]=d.useState(!0),[g,N]=d.useState(!0),[v,b]=d.useState(null),[w,y]=d.useState(null),[R,O]=d.useState(null),[S,B]=d.useState(!1),[E,C]=d.useState(),[z,H]=d.useState(!1);d.useEffect(()=>{(async()=>{if(!n.pluginId){b("缺少插件 ID"),p(!1);return}try{p(!0),b(null);const fe=await _e("/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(!fe.ok)throw new Error("获取插件列表失败");const ge=await fe.json();if(!ge.success||!ge.data)throw new Error(ge.error||"获取插件列表失败");const K=JSON.parse(ge.data).find(pe=>pe.id===n.pluginId);if(!K)throw new Error("未找到该插件");const I={id:K.id,manifest:K.manifest,downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()};u(I);const[ue,Q,Se]=await Promise.all([Pv(),Hv(),Al()]);y(ue),O(Q),B(mn(n.pluginId,Se)),C(xn(n.pluginId,Se))}catch(fe){b(fe instanceof Error?fe.message:"加载失败")}finally{p(!1)}})()},[n.pluginId]),d.useEffect(()=>{(async()=>{if(!c?.manifest?.repository_url){N(!1);return}try{if(N(!0),S&&n.pluginId)try{const Q=await _e(`/api/webui/plugins/local-readme/${n.pluginId}`);if(Q.ok){const Se=await Q.json();if(Se.success&&Se.data){h(Se.data),N(!1);return}}}catch(Q){console.log("本地 README 获取失败,尝试远程获取:",Q)}const fe=c.manifest.repository_url.match(/github\.com\/([^/]+)\/([^/\s]+)/);if(!fe){h("无法解析仓库地址");return}const[,ge,M]=fe,K=M.replace(/\.git$/,""),I=await _e("/api/webui/plugins/fetch-raw",{method:"POST",body:JSON.stringify({owner:ge,repo:K,branch:"main",file_path:"README.md"})});if(!I.ok)throw new Error("获取 README 失败");const ue=await I.json();ue.success&&ue.data?h(ue.data):h("该插件暂无 README 文档")}catch(fe){console.error("加载 README 失败:",fe),h("加载 README 失败")}finally{N(!1)}})()},[c,S,n.pluginId]);const L=()=>!c||!S||!E?!1:E!==c.manifest.version,J=()=>!c||!R?!0:Fv(c.manifest.host_application.min_version,c.manifest.host_application.max_version,R),U=async()=>{if(!(!c||!w?.installed))try{H(!0),await Gv(c.id,c.manifest.repository_url||"","main"),Qv(c.id).catch(fe=>{console.warn("Failed to record download:",fe)}),i({title:"安装成功",description:`${c.manifest.name} 已成功安装`});const re=await Al();B(mn(c.id,re)),C(xn(c.id,re))}catch(re){i({title:"安装失败",description:re instanceof Error?re.message:"未知错误",variant:"destructive"})}finally{H(!1)}},oe=async()=>{if(c)try{H(!0),await Vv(c.id),i({title:"卸载成功",description:`${c.manifest.name} 已成功卸载`});const re=await Al();B(mn(c.id,re)),C(xn(c.id,re))}catch(re){i({title:"卸载失败",description:re instanceof Error?re.message:"未知错误",variant:"destructive"})}finally{H(!1)}},Ne=async()=>{if(!(!c||!w?.installed))try{H(!0);const re=await qv(c.id,c.manifest.repository_url||"","main");i({title:"更新成功",description:`${c.manifest.name} 已从 ${re.old_version} 更新到 ${re.new_version}`});const fe=await Al();B(mn(c.id,fe)),C(xn(c.id,fe))}catch(re){i({title:"更新失败",description:re instanceof Error?re.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:()=>l({to:"/plugins"}),children:e.jsx(Ta,{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(Bs,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件信息中..."})]})]});if(v||!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:()=>l({to:"/plugins"}),children:e.jsx(Ta,{className:"h-5 w-5"})}),e.jsx("div",{children:e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"插件详情"})})]}),e.jsx(Ce,{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-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:v}),e.jsx(_,{onClick:()=>l({to:"/plugins"}),children:"返回插件列表"})]})})]});const je=J();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:()=>l({to:"/plugins"}),className:"shrink-0",children:e.jsx(Ta,{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:[L()?e.jsx(_,{disabled:!w?.installed||z,onClick:Ne,title:w?.installed?void 0:"Git 未安装",children:z?e.jsxs(e.Fragment,{children:[e.jsx(Bs,{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:!w?.installed||z,onClick:oe,title:w?.installed?void 0:"Git 未安装",children:z?e.jsxs(e.Fragment,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2 animate-spin"}),"卸载中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ns,{className:"h-4 w-4 mr-2"}),"卸载"]})})]}):e.jsx(_,{disabled:!w?.installed||!je||z,onClick:U,title:w?.installed?je?void 0:`不兼容当前版本 (需要 ${c.manifest.host_application.min_version}${c.manifest.host_application.max_version?` - ${c.manifest.host_application.max_version}`:"+"},当前 ${R?.version})`:"Git 未安装",children:z?e.jsxs(e.Fragment,{children:[e.jsx(Bs,{className:"h-4 w-4 mr-2 animate-spin"}),"安装中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(sa,{className:"h-4 w-4 mr-2"}),"安装"]})})})]}),e.jsx(Je,{className:"h-[calc(100vh-200px)] sm:h-[calc(100vh-220px)]",children:e.jsxs("div",{className:"space-y-6 pr-4",children:[e.jsx(Ce,{children:e.jsx(De,{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(Re,{className:"text-2xl",children:c.manifest.name}),e.jsxs(ke,{variant:"secondary",className:"text-sm",children:["v",c.manifest.version]}),S&&e.jsxs(ke,{variant:"default",className:"text-sm",children:[e.jsx(pt,{className:"h-3 w-3 mr-1"}),"已安装 ",E&&`(v${E})`]}),L()&&e.jsxs(ke,{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(ke,{variant:"destructive",className:"text-sm",children:[e.jsx(_t,{className:"h-3 w-3 mr-1"}),"不兼容"]})]}),e.jsx(os,{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(Ce,{children:[e.jsx(De,{children:e.jsx(Re,{className:"text-lg",children:"统计信息"})}),e.jsx(Me,{children:e.jsx(qk,{pluginId:c.id})})]}),e.jsxs(Ce,{children:[e.jsx(De,{children:e.jsx(Re,{className:"text-lg",children:"基本信息"})}),e.jsx(Me,{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(fn,{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(Oo,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(ra,{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(Rj,{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(Bo,{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(Oo,{className:"h-3 w-3"})]})]}),c.manifest.repository_url&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(x_,{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(Oo,{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(Ht,{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(Ce,{children:[e.jsx(De,{children:e.jsx(Re,{className:"text-lg",children:"分类与标签"})}),e.jsxs(Me,{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(re=>e.jsx(ke,{variant:"secondary",children:Kk[re]||re},re))})]}),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(re=>e.jsxs(ke,{variant:"outline",className:"text-xs",children:[e.jsx(Wo,{className:"h-3 w-3 mr-1"}),re]},re))})]})]})]})]}),e.jsxs(Ce,{className:"lg:col-span-2",children:[e.jsx(De,{children:e.jsx(Re,{className:"text-lg",children:"插件说明"})}),e.jsx(Me,{children:e.jsx(Je,{className:"h-[600px] pr-4",children:g?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(Bs,{className:"h-6 w-6 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-sm text-muted-foreground",children:"加载说明文档中..."})]}):x?e.jsx(nx,{content:x}):e.jsx("div",{className:"text-center text-muted-foreground py-12",children:"暂无说明文档"})})})]})]})]})})]})}const Ki=d.forwardRef(({className:l,...n},i)=>e.jsx(nj,{ref:i,className:P("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",l),...n}));Ki.displayName=nj.displayName;const Yk=d.forwardRef(({className:l,...n},i)=>e.jsx(rj,{ref:i,className:P("aspect-square h-full w-full",l),...n}));Yk.displayName=rj.displayName;const Qi=d.forwardRef(({className:l,...n},i)=>e.jsx(ij,{ref:i,className:P("flex h-full w-full items-center justify-center rounded-full bg-muted",l),...n}));Qi.displayName=ij.displayName;function Jk(){return"webui_"+Math.random().toString(36).substr(2,9)+"_"+Date.now().toString(36)}function Xk(){const l="maibot_webui_user_id";let n=localStorage.getItem(l);return n||(n=Jk(),localStorage.setItem(l,n)),n}function Zk(){return localStorage.getItem("maibot_webui_user_name")||"WebUI用户"}function Wk(l){localStorage.setItem("maibot_webui_user_name",l)}const Yv="maibot_webui_virtual_tabs";function eC(){try{const l=localStorage.getItem(Yv);if(l)return JSON.parse(l)}catch(l){console.error("[Chat] 加载虚拟标签页失败:",l)}return[]}function Ig(l){try{localStorage.setItem(Yv,JSON.stringify(l))}catch(n){console.error("[Chat] 保存虚拟标签页失败:",n)}}function sC({segment:l}){switch(l.type){case"text":return e.jsx("span",{className:"whitespace-pre-wrap",children:String(l.data)});case"image":case"emoji":return e.jsx("img",{src:String(l.data),alt:l.type==="emoji"?"表情包":"图片",className:P("rounded-lg max-w-full",l.type==="emoji"?"max-h-32":"max-h-64"),loading:"lazy",onError:n=>{const i=n.target;i.style.display="none",i.parentElement?.insertAdjacentHTML("beforeend",`<span class="text-muted-foreground text-xs">[${l.type==="emoji"?"表情包":"图片"}加载失败]</span>`)}});case"voice":return e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("audio",{controls:!0,src:String(l.data),className:"max-w-[200px] h-8",children:"您的浏览器不支持音频播放"})});case"video":return e.jsx("video",{controls:!0,src:String(l.data),className:"rounded-lg max-w-full max-h-64",children:"您的浏览器不支持视频播放"});case"face":return e.jsxs("span",{className:"text-muted-foreground",children:["[表情:",String(l.data),"]"]});case"music":return e.jsx("span",{className:"text-muted-foreground",children:"[音乐分享]"});case"file":return e.jsxs("span",{className:"text-muted-foreground",children:["[文件: ",String(l.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:["[",l.original_type||"未知消息","]"]})}}function tC({message:l,isBot:n}){return l.message_type==="rich"&&l.segments&&l.segments.length>0?e.jsx("div",{className:"flex flex-col gap-2",children:l.segments.map((i,c)=>e.jsx(sC,{segment:i},c))}):e.jsx("span",{className:"whitespace-pre-wrap",children:l.content})}function aC(){const l={id:"webui-default",type:"webui",label:"WebUI",messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}},n=()=>{const qe=eC().map(Qe=>{const es=Qe.virtualConfig;return!es.groupId&&es.platform&&es.userId&&(es.groupId=`webui_virtual_group_${es.platform}_${es.userId}`),{id:Qe.id,type:"virtual",label:Qe.label,virtualConfig:es,messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}}});return[l,...qe]},[i,c]=d.useState(n),[u,x]=d.useState("webui-default"),h=i.find(q=>q.id===u)||i[0],[f,p]=d.useState(""),[g,N]=d.useState(!1),[v,b]=d.useState(!0),[w,y]=d.useState(Zk()),[R,O]=d.useState(!1),[S,B]=d.useState(""),[E,C]=d.useState(!1),[z,H]=d.useState([]),[L,J]=d.useState([]),[U,oe]=d.useState(!1),[Ne,je]=d.useState(!1),[re,fe]=d.useState(""),[ge,M]=d.useState({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),K=d.useRef(Xk()),I=d.useRef(new Map),ue=d.useRef(null),Q=d.useRef(new Map),Se=d.useRef(0),pe=d.useRef(new Map),{toast:Te}=Zs(),A=q=>(Se.current+=1,`${q}-${Date.now()}-${Se.current}-${Math.random().toString(36).substr(2,9)}`),D=d.useCallback((q,qe)=>{c(Qe=>Qe.map(es=>es.id===q?{...es,...qe}:es))},[]),V=d.useCallback((q,qe)=>{c(Qe=>Qe.map(es=>es.id===q?{...es,messages:[...es.messages,qe]}:es))},[]),de=d.useCallback(()=>{ue.current?.scrollIntoView({behavior:"smooth"})},[]);d.useEffect(()=>{de()},[h?.messages,de]);const Oe=d.useCallback(async()=>{oe(!0);try{const q=await _e("/api/chat/platforms");if(console.log("[Chat] 平台列表响应:",q.status,q.headers.get("content-type")),q.ok){const qe=q.headers.get("content-type");if(qe&&qe.includes("application/json")){const Qe=await q.json();console.log("[Chat] 平台列表数据:",Qe),H(Qe.platforms||[])}else{const Qe=await q.text();console.error("[Chat] 获取平台列表失败: 非 JSON 响应:",Qe.substring(0,200)),Te({title:"连接失败",description:"无法连接到后端服务,请确保 MaiBot 已启动",variant:"destructive"})}}else console.error("[Chat] 获取平台列表失败: HTTP",q.status),Te({title:"获取平台失败",description:`服务器返回错误: ${q.status}`,variant:"destructive"})}catch(q){console.error("[Chat] 获取平台列表失败:",q),Te({title:"网络错误",description:"无法连接到后端服务",variant:"destructive"})}finally{oe(!1)}},[Te]),W=d.useCallback(async(q,qe)=>{je(!0);try{const Qe=new URLSearchParams;q&&Qe.append("platform",q),qe&&Qe.append("search",qe),Qe.append("limit","50");const es=await _e(`/api/chat/persons?${Qe.toString()}`);if(es.ok){const Ls=es.headers.get("content-type");if(Ls&&Ls.includes("application/json")){const as=await es.json();J(as.persons||[])}else console.error("[Chat] 获取用户列表失败: 后端返回非 JSON 响应")}}catch(Qe){console.error("[Chat] 获取用户列表失败:",Qe)}finally{je(!1)}},[]);d.useEffect(()=>{ge.platform&&W(ge.platform,re)},[ge.platform,re,W]);const Y=d.useCallback(async(q,qe)=>{b(!0);try{const Qe=new URLSearchParams;Qe.append("user_id",K.current),Qe.append("limit","50"),qe&&Qe.append("group_id",qe);const es=`/api/chat/history?${Qe.toString()}`;console.log("[Chat] 正在加载历史消息:",es);const Ls=await _e(es);if(Ls.ok){const as=await Ls.text();try{const Cs=JSON.parse(as);if(Cs.messages&&Cs.messages.length>0){const Ae=Cs.messages.map(ls=>({id:ls.id,type:ls.type,content:ls.content,timestamp:ls.timestamp,sender:{name:ls.sender_name||(ls.is_bot?"麦麦":"WebUI用户"),user_id:ls.user_id,is_bot:ls.is_bot}}));D(q,{messages:Ae});const bs=pe.current.get(q)||new Set;Ae.forEach(ls=>{if(ls.type==="bot"){const ss=`bot-${ls.content}-${Math.floor(ls.timestamp*1e3)}`;bs.add(ss)}}),pe.current.set(q,bs)}}catch(Cs){console.error("[Chat] JSON 解析失败:",Cs)}}}catch(Qe){console.error("[Chat] 加载历史消息失败:",Qe)}finally{b(!1)}},[D]),He=d.useCallback(async(q,qe,Qe)=>{const es=I.current.get(q);if(es?.readyState===WebSocket.OPEN||es?.readyState===WebSocket.CONNECTING){console.log(`[Tab ${q}] WebSocket 已存在,跳过连接`);return}N(!0);let Ls=null;try{const bs=await _e("/api/webui/ws-token");if(bs.ok){const ls=await bs.json();if(ls.success&&ls.token)Ls=ls.token;else{console.warn(`[Tab ${q}] 获取 WebSocket token 失败: ${ls.message||"未登录"}`),N(!1);return}}}catch(bs){console.error(`[Tab ${q}] 获取 WebSocket token 失败:`,bs),N(!1);return}if(!Ls){N(!1);return}const as=window.location.protocol==="https:"?"wss:":"ws:",Cs=new URLSearchParams;Cs.append("token",Ls),qe==="virtual"&&Qe?(Cs.append("user_id",Qe.userId),Cs.append("user_name",Qe.userName),Cs.append("platform",Qe.platform),Cs.append("person_id",Qe.personId),Cs.append("group_name",Qe.groupName||"WebUI虚拟群聊"),Qe.groupId&&Cs.append("group_id",Qe.groupId)):(Cs.append("user_id",K.current),Cs.append("user_name",w));const Ae=`${as}//${window.location.host}/api/chat/ws?${Cs.toString()}`;console.log(`[Tab ${q}] 正在连接 WebSocket:`,Ae);try{const bs=new WebSocket(Ae);I.current.set(q,bs),bs.onopen=()=>{D(q,{isConnected:!0}),N(!1),console.log(`[Tab ${q}] WebSocket 已连接`)},bs.onmessage=ls=>{try{const ss=JSON.parse(ls.data);switch(ss.type){case"session_info":D(q,{sessionInfo:{session_id:ss.session_id,user_id:ss.user_id,user_name:ss.user_name,bot_name:ss.bot_name}});break;case"system":V(q,{id:A("sys"),type:"system",content:ss.content||"",timestamp:ss.timestamp||Date.now()/1e3});break;case"user_message":{const ys=ss.sender?.user_id,gt=qe==="virtual"&&Qe?Qe.userId:K.current;console.log(`[Tab ${q}] 收到 user_message, sender: ${ys}, current: ${gt}`);const $t=ys?ys.replace(/^webui_user_/,""):"",tt=gt?gt.replace(/^webui_user_/,""):"";if($t&&tt&&$t===tt){console.log(`[Tab ${q}] 跳过自己的消息(user_id 匹配)`);break}const Ms=pe.current.get(q)||new Set,Et=`user-${ss.content}-${Math.floor((ss.timestamp||0)*1e3)}`;if(Ms.has(Et)){console.log(`[Tab ${q}] 跳过自己的消息(内容去重)`);break}if(Ms.add(Et),pe.current.set(q,Ms),Ms.size>100){const Bt=Ms.values().next().value;Bt&&Ms.delete(Bt)}V(q,{id:ss.message_id||A("user"),type:"user",content:ss.content||"",timestamp:ss.timestamp||Date.now()/1e3,sender:ss.sender});break}case"bot_message":{D(q,{isTyping:!1});const ys=pe.current.get(q)||new Set,gt=`bot-${ss.content}-${Math.floor((ss.timestamp||0)*1e3)}`;if(ys.has(gt))break;if(ys.add(gt),pe.current.set(q,ys),ys.size>100){const $t=ys.values().next().value;$t&&ys.delete($t)}c($t=>$t.map(tt=>{if(tt.id!==q)return tt;const Ms=tt.messages.filter(Bt=>Bt.type!=="thinking"),Et={id:A("bot"),type:"bot",content:ss.content||"",message_type:ss.message_type==="rich"?"rich":"text",segments:ss.segments,timestamp:ss.timestamp||Date.now()/1e3,sender:ss.sender};return{...tt,messages:[...Ms,Et]}}));break}case"typing":D(q,{isTyping:ss.is_typing||!1});break;case"error":c(ys=>ys.map(gt=>{if(gt.id!==q)return gt;const $t=gt.messages.filter(tt=>tt.type!=="thinking");return{...gt,messages:[...$t,{id:A("error"),type:"error",content:ss.content||"发生错误",timestamp:ss.timestamp||Date.now()/1e3}]}})),Te({title:"错误",description:ss.content,variant:"destructive"});break;case"pong":break;case"history":{const ys=ss.messages||[];if(ys.length>0){const gt=pe.current.get(q)||new Set,$t=ys.map(tt=>{const Ms=tt.is_bot||!1,Et=tt.id||A(Ms?"bot":"user"),Bt=`${Ms?"bot":"user"}-${tt.content}-${Math.floor(tt.timestamp*1e3)}`;return gt.add(Bt),{id:Et,type:Ms?"bot":"user",content:tt.content,timestamp:tt.timestamp,sender:{name:tt.sender_name||(Ms?"麦麦":"用户"),user_id:tt.sender_id,is_bot:Ms}}});pe.current.set(q,gt),D(q,{messages:$t}),console.log(`[Tab ${q}] 已加载 ${$t.length} 条历史消息`)}break}default:console.log("未知消息类型:",ss.type)}}catch(ss){console.error("解析消息失败:",ss)}},bs.onclose=()=>{D(q,{isConnected:!1}),N(!1),I.current.delete(q),console.log(`[Tab ${q}] WebSocket 已断开`);const ls=Q.current.get(q);ls&&clearTimeout(ls);const ss=window.setTimeout(()=>{if(!F.current){const ys=i.find(gt=>gt.id===q);ys&&He(q,ys.type,ys.virtualConfig)}},5e3);Q.current.set(q,ss)},bs.onerror=ls=>{console.error(`[Tab ${q}] WebSocket 错误:`,ls),N(!1)}}catch(bs){console.error(`[Tab ${q}] 创建 WebSocket 失败:`,bs),N(!1)}},[w,D,V,Te,i]),F=d.useRef(!1);d.useEffect(()=>{F.current=!1;const q=I.current,qe=Q.current,Qe=pe.current;Y("webui-default");const es=setTimeout(()=>{F.current||(He("webui-default","webui"),i.forEach(as=>{as.type==="virtual"&&as.virtualConfig&&(Qe.set(as.id,new Set),setTimeout(()=>{F.current||He(as.id,"virtual",as.virtualConfig)},200))}))},100),Ls=setInterval(()=>{q.forEach(as=>{as.readyState===WebSocket.OPEN&&as.send(JSON.stringify({type:"ping"}))})},3e4);return()=>{F.current=!0,clearTimeout(es),clearInterval(Ls),qe.forEach(as=>{clearTimeout(as)}),qe.clear(),q.forEach(as=>{as.close()}),q.clear()}},[]);const ee=d.useCallback(()=>{const q=I.current.get(u);if(!f.trim()||!q||q.readyState!==WebSocket.OPEN)return;const qe=h?.type==="virtual"&&h.virtualConfig?.userName||w,Qe=f.trim(),es=Date.now()/1e3;q.send(JSON.stringify({type:"message",content:Qe,user_name:qe}));const Ls=pe.current.get(u)||new Set,as=`user-${Qe}-${Math.floor(es*1e3)}`;if(Ls.add(as),pe.current.set(u,Ls),Ls.size>100){const bs=Ls.values().next().value;bs&&Ls.delete(bs)}const Cs={id:A("user"),type:"user",content:Qe,timestamp:es,sender:{name:qe,is_bot:!1}};V(u,Cs);const Ae={id:A("thinking"),type:"thinking",content:"",timestamp:es+.001,sender:{name:h?.sessionInfo.bot_name||"麦麦",is_bot:!0}};V(u,Ae),p("")},[f,w,u,h,V]),Ue=q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),ee())},ie=()=>{B(w),O(!0)},Ee=()=>{const q=S.trim()||"WebUI用户";y(q),Wk(q),O(!1);const qe=I.current.get(u);qe?.readyState===WebSocket.OPEN&&qe.send(JSON.stringify({type:"update_nickname",user_name:q}))},me=()=>{B(""),O(!1)},ze=q=>new Date(q*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}),rs=()=>{const q=I.current.get(u);q&&(q.close(),I.current.delete(u)),He(u,h?.type||"webui",h?.virtualConfig)},Ut=()=>{M({platform:"",personId:"",userId:"",userName:"",groupName:"",groupId:""}),fe(""),Oe(),C(!0)},aa=()=>{if(!ge.platform||!ge.personId){Te({title:"配置不完整",description:"请选择平台和用户",variant:"destructive"});return}const q=`webui_virtual_group_${ge.platform}_${ge.userId}`,qe=`virtual-${ge.platform}-${ge.userId}-${Date.now()}`,Qe=ge.userName||ge.userId,es={id:qe,type:"virtual",label:Qe,virtualConfig:{...ge,groupId:q},messages:[],isConnected:!1,isTyping:!1,sessionInfo:{}};c(Ls=>{const as=[...Ls,es],Cs=as.filter(Ae=>Ae.type==="virtual"&&Ae.virtualConfig).map(Ae=>({id:Ae.id,label:Ae.label,virtualConfig:Ae.virtualConfig,createdAt:Date.now()}));return Ig(Cs),as}),x(qe),C(!1),pe.current.set(qe,new Set),setTimeout(()=>{He(qe,"virtual",ge)},100),Te({title:"虚拟身份标签页",description:`已创建 ${Qe} 的对话`})},Qa=(q,qe)=>{if(qe?.stopPropagation(),q==="webui-default")return;const Qe=I.current.get(q);Qe&&(Qe.close(),I.current.delete(q));const es=Q.current.get(q);es&&(clearTimeout(es),Q.current.delete(q)),pe.current.delete(q),c(Ls=>{const as=Ls.filter(Ae=>Ae.id!==q),Cs=as.filter(Ae=>Ae.type==="virtual"&&Ae.virtualConfig).map(Ae=>({id:Ae.id,label:Ae.label,virtualConfig:Ae.virtualConfig,createdAt:Date.now()}));return Ig(Cs),as}),u===q&&x("webui-default")},Ft=q=>{x(q)},mt=q=>{M(qe=>({...qe,personId:q.person_id,userId:q.user_id,userName:q.nickname||q.person_name}))};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Is,{open:E,onOpenChange:C,children:e.jsxs(Os,{className:"sm:max-w-[500px] max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(ym,{className:"h-5 w-5"}),"新建虚拟身份对话"]}),e.jsx(Ks,{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(Bo,{className:"h-4 w-4"}),"选择平台"]}),e.jsxs(Ie,{value:ge.platform,onValueChange:q=>{M(qe=>({...qe,platform:q,personId:"",userId:"",userName:""})),J([])},children:[e.jsx($e,{disabled:U,children:e.jsx(Pe,{placeholder:U?"加载中...":"选择平台"})}),e.jsx(Be,{children:z.map(q=>e.jsxs(Z,{value:q.platform,children:[q.platform," (",q.count," 人)"]},q.platform))})]})]}),ge.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(tc,{className:"h-4 w-4"}),"选择用户"]}),e.jsxs("div",{className:"relative",children:[e.jsx(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索用户名...",value:re,onChange:q=>fe(q.target.value),className:"pl-9"})]}),e.jsx(Je,{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(Bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):L.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-muted-foreground",children:[e.jsx(tc,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"没有找到用户"})]}):e.jsx("div",{className:"space-y-1",children:L.map(q=>e.jsxs("button",{onClick:()=>mt(q),className:P("w-full flex items-center gap-3 p-2 rounded-md text-left transition-colors",ge.personId===q.person_id?"bg-primary text-primary-foreground":"hover:bg-muted"),children:[e.jsx(Ki,{className:"h-8 w-8 shrink-0",children:e.jsx(Qi,{className:P("text-xs",ge.personId===q.person_id?"bg-primary-foreground/20":"bg-muted"),children:(q.nickname||q.person_name||"?").charAt(0)})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium truncate",children:q.nickname||q.person_name}),e.jsxs("div",{className:P("text-xs truncate",ge.personId===q.person_id?"text-primary-foreground/70":"text-muted-foreground"),children:["ID: ",q.user_id,q.is_known&&" · 已认识"]})]})]},q.person_id))})})})]}),ge.personId&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"虚拟群名(可选)"}),e.jsx(ae,{placeholder:"WebUI虚拟群聊",value:ge.groupName,onChange:q=>M(qe=>({...qe,groupName:q.target.value}))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦会认为这是一个名为此名称的群聊"})]})]}),e.jsxs(st,{className:"gap-2 sm:gap-0",children:[e.jsx(_,{variant:"outline",onClick:()=>C(!1),children:"取消"}),e.jsx(_,{onClick:aa,disabled:!ge.platform||!ge.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:[i.map(q=>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",u===q.id?"bg-background shadow-sm border":"text-muted-foreground"),onClick:()=>Ft(q.id),children:[q.type==="webui"?e.jsx(za,{className:"h-3.5 w-3.5"}):e.jsx(ym,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"max-w-[100px] truncate",children:q.label}),e.jsx("span",{className:P("w-1.5 h-1.5 rounded-full",q.isConnected?"bg-green-500":"bg-muted-foreground/50")}),q.id!=="webui-default"&&e.jsx("span",{onClick:qe=>Qa(q.id,qe),className:"ml-0.5 p-0.5 rounded hover:bg-muted-foreground/20 cursor-pointer",role:"button",tabIndex:0,onKeyDown:qe=>{(qe.key==="Enter"||qe.key===" ")&&(qe.preventDefault(),Qa(q.id,qe))},children:e.jsx(Ea,{className:"h-3 w-3"})})]},q.id)),e.jsx("button",{onClick:Ut,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(et,{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(Ki,{className:"h-8 w-8 sm:h-10 sm:w-10 shrink-0",children:e.jsx(Qi,{className:"bg-primary/10 text-primary",children:e.jsx(Pn,{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(h_,{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(Bs,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"连接中..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(f_,{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:[v&&e.jsx(Bs,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:rs,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(ym,{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(fn,{className:"h-3 w-3"}),e.jsx("span",{children:"当前身份:"}),R?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{value:S,onChange:q=>B(q.target.value),onKeyDown:q=>{q.key==="Enter"&&Ee(),q.key==="Escape"&&me()},className:"h-7 w-32",placeholder:"输入昵称",autoFocus:!0}),e.jsx(_,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:Ee,children:"保存"}),e.jsx(_,{size:"sm",variant:"ghost",className:"h-7 px-2",onClick:me,children:"取消"})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium text-foreground",children:w}),e.jsx(_,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:ie,title:"修改昵称",children:e.jsx(p_,{className:"h-3 w-3"})})]})]})})]})}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Je,{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&&!v&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(Pn,{className:"h-12 w-12 mb-4 opacity-50"}),e.jsxs("p",{className:"text-sm",children:["开始与 ",h?.sessionInfo.bot_name||"麦麦"," 对话吧!"]})]}),h?.messages.map(q=>e.jsxs("div",{className:P("flex gap-2 sm:gap-3",q.type==="user"&&"flex-row-reverse",q.type==="system"&&"justify-center",q.type==="error"&&"justify-center"),children:[q.type==="system"&&e.jsx("div",{className:"text-xs text-muted-foreground bg-muted/50 px-3 py-1 rounded-full max-w-[90%]",children:q.content}),q.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:q.content}),q.type==="thinking"&&e.jsxs(e.Fragment,{children:[e.jsx(Ki,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Qi,{className:"bg-primary/10 text-primary",children:e.jsx(Pn,{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:q.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:"思考中..."})]})})]})]}),(q.type==="user"||q.type==="bot")&&e.jsxs(e.Fragment,{children:[e.jsx(Ki,{className:"h-7 w-7 sm:h-8 sm:w-8 shrink-0",children:e.jsx(Qi,{className:P("text-xs",q.type==="bot"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:q.type==="bot"?e.jsx(Pn,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}):e.jsx(fn,{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%]",q.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:q.sender?.name||(q.type==="bot"?h?.sessionInfo.bot_name:w)}),e.jsx("span",{children:ze(q.timestamp)})]}),e.jsx("div",{className:P("rounded-2xl px-3 py-2 text-sm break-words",q.type==="bot"?"bg-muted rounded-tl-sm":"bg-primary text-primary-foreground rounded-tr-sm"),children:e.jsx(tC,{message:q,isBot:q.type==="bot"})})]})]})]},q.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(ae,{value:f,onChange:q=>p(q.target.value),onKeyDown:Ue,placeholder:h?.isConnected?"输入消息...":"等待连接...",disabled:!h?.isConnected,className:"flex-1 h-10 sm:h-10"}),e.jsx(_,{onClick:ee,disabled:!h?.isConnected||!f.trim(),size:"icon",className:"h-10 w-10 shrink-0",children:e.jsx(g_,{className:"h-4 w-4"})})]})})})]})}var hx="Radio",[lC,Jv]=Yo(hx),[nC,rC]=lC(hx),Xv=d.forwardRef((l,n)=>{const{__scopeRadio:i,name:c,checked:u=!1,required:x,disabled:h,value:f="on",onCheck:p,form:g,...N}=l,[v,b]=d.useState(null),w=Jo(n,O=>b(O)),y=d.useRef(!1),R=v?g||!!v.closest("form"):!0;return e.jsxs(nC,{scope:i,checked:u,disabled:h,children:[e.jsx(Yn.button,{type:"button",role:"radio","aria-checked":u,"data-state":sN(u),"data-disabled":h?"":void 0,disabled:h,value:f,...N,ref:w,onClick:hn(l.onClick,O=>{u||p?.(),R&&(y.current=O.isPropagationStopped(),y.current||O.stopPropagation())})}),R&&e.jsx(eN,{control:v,bubbles:!y.current,name:c,value:f,checked:u,required:x,disabled:h,form:g,style:{transform:"translateX(-100%)"}})]})});Xv.displayName=hx;var Zv="RadioIndicator",Wv=d.forwardRef((l,n)=>{const{__scopeRadio:i,forceMount:c,...u}=l,x=rC(Zv,i);return e.jsx(Rw,{present:c||x.checked,children:e.jsx(Yn.span,{"data-state":sN(x.checked),"data-disabled":x.disabled?"":void 0,...u,ref:n})})});Wv.displayName=Zv;var iC="RadioBubbleInput",eN=d.forwardRef(({__scopeRadio:l,control:n,checked:i,bubbles:c=!0,...u},x)=>{const h=d.useRef(null),f=Jo(h,x),p=Lw(i),g=Uw(n);return d.useEffect(()=>{const N=h.current;if(!N)return;const v=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(v,"checked").set;if(p!==i&&w){const y=new Event("click",{bubbles:c});w.call(N,i),N.dispatchEvent(y)}},[p,i,c]),e.jsx(Yn.input,{type:"radio","aria-hidden":!0,defaultChecked:i,...u,tabIndex:-1,ref:f,style:{...u.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});eN.displayName=iC;function sN(l){return l?"checked":"unchecked"}var cC=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],cd="RadioGroup",[oC]=Yo(cd,[cj,Jv]),tN=cj(),aN=Jv(),[dC,uC]=oC(cd),lN=d.forwardRef((l,n)=>{const{__scopeRadioGroup:i,name:c,defaultValue:u,value:x,required:h=!1,disabled:f=!1,orientation:p,dir:g,loop:N=!0,onValueChange:v,...b}=l,w=tN(i),y=kj(g),[R,O]=Qo({prop:x,defaultProp:u??null,onChange:v,caller:cd});return e.jsx(dC,{scope:i,name:c,required:h,disabled:f,value:R,onValueChange:O,children:e.jsx(X0,{asChild:!0,...w,orientation:p,dir:y,loop:N,children:e.jsx(Yn.div,{role:"radiogroup","aria-required":h,"aria-orientation":p,"data-disabled":f?"":void 0,dir:y,...b,ref:n})})})});lN.displayName=cd;var nN="RadioGroupItem",rN=d.forwardRef((l,n)=>{const{__scopeRadioGroup:i,disabled:c,...u}=l,x=uC(nN,i),h=x.disabled||c,f=tN(i),p=aN(i),g=d.useRef(null),N=Jo(n,g),v=x.value===u.value,b=d.useRef(!1);return d.useEffect(()=>{const w=R=>{cC.includes(R.key)&&(b.current=!0)},y=()=>b.current=!1;return document.addEventListener("keydown",w),document.addEventListener("keyup",y),()=>{document.removeEventListener("keydown",w),document.removeEventListener("keyup",y)}},[]),e.jsx(Z0,{asChild:!0,...f,focusable:!h,active:v,children:e.jsx(Xv,{disabled:h,required:x.required,checked:v,...p,...u,name:x.name,ref:N,onCheck:()=>x.onValueChange(u.value),onKeyDown:hn(w=>{w.key==="Enter"&&w.preventDefault()}),onFocus:hn(u.onFocus,()=>{b.current&&g.current?.click()})})})});rN.displayName=nN;var mC="RadioGroupIndicator",iN=d.forwardRef((l,n)=>{const{__scopeRadioGroup:i,...c}=l,u=aN(i);return e.jsx(Wv,{...u,...c,ref:n})});iN.displayName=mC;var cN=lN,oN=rN,xC=iN;const fx=d.forwardRef(({className:l,...n},i)=>e.jsx(cN,{className:P("grid gap-2",l),...n,ref:i}));fx.displayName=cN.displayName;const qo=d.forwardRef(({className:l,...n},i)=>e.jsx(oN,{ref:i,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",l),...n,children:e.jsx(xC,{className:"flex items-center justify-center",children:e.jsx($o,{className:"h-2.5 w-2.5 fill-current text-current"})})}));qo.displayName=oN.displayName;function hC({question:l,value:n,onChange:i,error:c,disabled:u=!1}){const[x,h]=d.useState(null),f=u||l.readOnly,p=()=>{switch(l.type){case"single":return e.jsx(fx,{value:n||"",onValueChange:i,disabled:f,className:"space-y-2",children:l.options?.map(g=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qo,{value:g.value,id:`${l.id}-${g.id}`}),e.jsx(T,{htmlFor:`${l.id}-${g.id}`,className:"cursor-pointer font-normal",children:g.label})]},g.id))});case"multiple":{const g=n||[];return e.jsxs("div",{className:"space-y-2",children:[l.options?.map(N=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qs,{id:`${l.id}-${N.id}`,checked:g.includes(N.value),disabled:f||l.maxSelections!==void 0&&g.length>=l.maxSelections&&!g.includes(N.value),onCheckedChange:v=>{i(v?[...g,N.value]:g.filter(b=>b!==N.value))}}),e.jsx(T,{htmlFor:`${l.id}-${N.id}`,className:"cursor-pointer font-normal",children:N.label})]},N.id)),l.maxSelections&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["最多选择 ",l.maxSelections," 项"]})]})}case"text":return e.jsx(ae,{value:n||"",onChange:g=>i(g.target.value),placeholder:l.placeholder||"请输入...",disabled:f,readOnly:l.readOnly,maxLength:l.maxLength,className:P(l.readOnly&&"bg-muted cursor-not-allowed")});case"textarea":return e.jsxs("div",{className:"space-y-1",children:[e.jsx(ot,{value:n||"",onChange:g=>i(g.target.value),placeholder:l.placeholder||"请输入...",disabled:f,readOnly:l.readOnly,maxLength:l.maxLength,rows:4,className:P(l.readOnly&&"bg-muted cursor-not-allowed")}),l.maxLength&&e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[(n||"").length," / ",l.maxLength]})]});case"rating":{const g=n||0,N=x!==null?x:g;return e.jsxs("div",{className:"flex items-center gap-1",children:[[1,2,3,4,5].map(v=>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(v),onMouseLeave:()=>h(null),onClick:()=>!f&&i(v),children:e.jsx(dn,{className:P("h-6 w-6 transition-colors",v<=N?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},v)),g>0&&e.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:[g," / 5"]})]})}case"scale":{const g=l.min??1,N=l.max??10,v=l.step??1,b=n??g;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(qa,{value:[b],onValueChange:([w])=>i(w),min:g,max:N,step:v,disabled:f}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:l.minLabel||g}),e.jsx("span",{className:"font-medium text-foreground",children:b}),e.jsx("span",{children:l.maxLabel||N})]})]})}case"dropdown":return e.jsxs(Ie,{value:n||"",onValueChange:i,disabled:f,children:[e.jsx($e,{children:e.jsx(Pe,{placeholder:l.placeholder||"请选择..."})}),e.jsx(Be,{children:l.options?.map(g=>e.jsx(Z,{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:[l.title,l.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),l.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),p(),c&&e.jsx("p",{className:"text-sm text-destructive",children:c})]})}const dN="https://maibot-plugin-stats.maibot-webui.workers.dev";function uN(){const l="maibot_user_id";let n=localStorage.getItem(l);if(!n){const i=Math.random().toString(36).substring(2,10),c=Date.now().toString(36),u=Math.random().toString(36).substring(2,10);n=`fp_${i}_${c}_${u}`,localStorage.setItem(l,n)}return n}async function fC(l,n,i,c){try{const u=c?.userId||uN(),x={surveyId:l,surveyVersion:n,userId:u,answers:i,submittedAt:new Date().toISOString(),allowMultiple:c?.allowMultiple,metadata:{userAgent:navigator.userAgent,language:navigator.language}},h=await fetch(`${dN}/survey/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)}),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(u){return console.error("Error submitting survey:",u),{success:!1,error:"网络错误"}}}async function pC(l,n){try{const i=n||uN(),c=new URLSearchParams({user_id:i,survey_id:l}),u=await fetch(`${dN}/survey/check?${c}`);return u.ok?{success:!0,hasSubmitted:(await u.json()).hasSubmitted}:{success:!1,error:(await u.json()).error||"检查失败"}}catch(i){return console.error("Error checking submission:",i),{success:!1,error:"网络错误"}}}function mN({config:l,initialAnswers:n,onSubmitSuccess:i,onSubmitError:c,showProgress:u=!0,paginateQuestions:x=!1,className:h}){const f=d.useCallback(()=>!n||n.length===0?{}:n.reduce((I,ue)=>(I[ue.questionId]=ue.value,I),{}),[n]),[p,g]=d.useState(()=>f()),[N,v]=d.useState({}),[b,w]=d.useState(0),[y,R]=d.useState(!1),[O,S]=d.useState(!1),[B,E]=d.useState(null),[C,z]=d.useState(null),[H,L]=d.useState(!1),[J,U]=d.useState(!0);d.useEffect(()=>{n&&n.length>0&&g(I=>({...I,...f()}))},[n,f]),d.useEffect(()=>{(async()=>{if(!l.settings?.allowMultiple){const ue=await pC(l.id);ue.success&&ue.hasSubmitted&&L(!0)}U(!1)})()},[l.id,l.settings?.allowMultiple]);const oe=d.useCallback(()=>{const I=new Date;return!(l.settings?.startTime&&new Date(l.settings.startTime)>I||l.settings?.endTime&&new Date(l.settings.endTime)<I)},[l.settings?.startTime,l.settings?.endTime]),Ne=l.questions.filter(I=>{const ue=p[I.id];return ue==null?!1:Array.isArray(ue)?ue.length>0:typeof ue=="string"?ue.trim()!=="":!0}).length,je=Ne/l.questions.length*100,re=d.useCallback((I,ue)=>{g(Q=>({...Q,[I]:ue})),v(Q=>{const Se={...Q};return delete Se[I],Se})},[]),fe=d.useCallback(()=>{const I={};for(const ue of l.questions){if(ue.required){const Q=p[ue.id];if(Q==null){I[ue.id]="此题为必填项";continue}if(Array.isArray(Q)&&Q.length===0){I[ue.id]="请至少选择一项";continue}if(typeof Q=="string"&&Q.trim()===""){I[ue.id]="此题为必填项";continue}}ue.minLength&&typeof p[ue.id]=="string"&&p[ue.id].length<ue.minLength&&(I[ue.id]=`至少需要 ${ue.minLength} 个字符`)}return v(I),Object.keys(I).length===0},[l.questions,p]),ge=d.useCallback(async()=>{if(!fe()){if(x){const I=l.questions.findIndex(ue=>N[ue.id]);I>=0&&w(I)}return}R(!0),E(null);try{const I=l.questions.filter(Q=>p[Q.id]!==void 0).map(Q=>({questionId:Q.id,value:p[Q.id]})),ue=await fC(l.id,l.version,I,{allowMultiple:l.settings?.allowMultiple});if(ue.success&&ue.submissionId)S(!0),z(ue.submissionId),i?.(ue.submissionId);else{const Q=ue.error||"提交失败";E(Q),c?.(Q)}}catch(I){const ue=I instanceof Error?I.message:"提交失败";E(ue),c?.(ue)}finally{R(!1)}},[fe,x,l,p,N,i,c]),M=d.useCallback(I=>{I>=0&&I<l.questions.length&&w(I)},[l.questions.length]);if(J)return e.jsx(Ce,{className:P("w-full max-w-2xl mx-auto",h),children:e.jsx(Me,{className:"py-12 flex items-center justify-center",children:e.jsx(Bs,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});if(H&&!l.settings?.allowMultiple)return e.jsxs(Ce,{className:P("w-full max-w-2xl mx-auto",h),children:[e.jsx(De,{children:e.jsx(Re,{children:l.title})}),e.jsx(Me,{className:"py-8",children:e.jsxs(at,{children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx(lt,{children:"你已经提交过这份问卷了,感谢参与!"})]})})]});if(!oe())return e.jsxs(Ce,{className:P("w-full max-w-2xl mx-auto",h),children:[e.jsx(De,{children:e.jsx(Re,{children:l.title})}),e.jsx(Me,{className:"py-8",children:e.jsxs(at,{variant:"destructive",children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx(lt,{children:"问卷不在有效期内"})]})})]});if(O)return e.jsxs(Ce,{className:P("w-full max-w-2xl mx-auto",h),children:[e.jsx(De,{children:e.jsxs(Re,{className:"flex items-center gap-2 text-green-600",children:[e.jsx(pt,{className:"h-6 w-6"}),"提交成功"]})}),e.jsxs(Me,{className:"py-8",children:[e.jsx("p",{className:"text-center text-muted-foreground",children:l.settings?.thankYouMessage||"感谢你的参与!"}),C&&e.jsxs("p",{className:"text-center text-xs text-muted-foreground mt-4",children:["提交编号:",C]})]})]});const K=x?[l.questions[b]]:l.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:l.title}),l.description&&e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:l.description}),u&&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," / ",l.questions.length]})]}),e.jsx(Qn,{value:je,className:"h-2"})]})]}),e.jsx(Je,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"space-y-4 pr-4",children:[K.map((I,ue)=>e.jsxs("div",{className:P("p-4 rounded-lg border bg-card",N[I.id]?"border-destructive bg-destructive/5":"border-border"),children:[x&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:["问题 ",b+1," / ",l.questions.length]}),!x&&e.jsxs("div",{className:"text-xs text-muted-foreground mb-2",children:[ue+1,"."]}),e.jsx(hC,{question:I,value:p[I.id],onChange:Q=>re(I.id,Q),error:N[I.id],disabled:y})]},I.id)),B&&e.jsxs(at,{variant:"destructive",children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx(lt,{children:B})]}),e.jsx("div",{className:"flex justify-between items-center py-4",children:x?e.jsxs(e.Fragment,{children:[e.jsxs(_,{variant:"outline",onClick:()=>M(b-1),disabled:b===0||y,children:[e.jsx(Aa,{className:"h-4 w-4 mr-1"}),"上一题"]}),b===l.questions.length-1?e.jsxs(_,{onClick:ge,disabled:y,children:[y&&e.jsx(Bs,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]}):e.jsxs(_,{onClick:()=>M(b+1),disabled:y,children:["下一题",e.jsx(Zt,{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:ge,disabled:y,size:"lg",children:[y&&e.jsx(Bs,{className:"h-4 w-4 mr-2 animate-spin"}),"提交问卷"]})]})})]})})]})}const gC={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:"感谢你的反馈!你的意见对我们非常重要,我们会认真考虑每一条建议。"}},jC={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 vC(){const[l,n]=d.useState(!0),i=d.useMemo(()=>JSON.parse(JSON.stringify(gC)),[]);d.useEffect(()=>{n(!1)},[]);const c=d.useMemo(()=>[{questionId:"webui_version",value:`v${td}`}],[]),u=d.useCallback(h=>{console.log("WebUI Survey submitted:",h)},[]),x=d.useCallback(h=>{console.error("WebUI Survey submission error:",h)},[]);return l?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i?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(Gj,{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(mN,{config:i,initialAnswers:c,showProgress:!0,paginateQuestions:!1,onSubmitSuccess:u,onSubmitError:x})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[400px] gap-4",children:[e.jsxs(at,{variant:"destructive",className:"max-w-md",children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx(lt,{children:"无法加载问卷配置"})]}),e.jsx(_,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}function NC(){const[l,n]=d.useState(null),[i,c]=d.useState(!0),[u,x]=d.useState("未知版本");d.useEffect(()=>{(async()=>{try{const v=await d1();x(v.version||"未知版本")}catch(v){console.error("Failed to get MaiBot version:",v),x("获取失败")}const N=JSON.parse(JSON.stringify(jC));n(N),c(!1)})()},[]);const h=d.useMemo(()=>[{questionId:"maibot_version",value:u}],[u]),f=d.useCallback(g=>{console.log("MaiBot Survey submitted:",g)},[]),p=d.useCallback(g=>{console.error("MaiBot Survey submission error:",g)},[]);return i?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx(Bs,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l?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(Gj,{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(mN,{config:l,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(at,{variant:"destructive",className:"max-w-md",children:[e.jsx(_t,{className:"h-4 w-4"}),e.jsx(lt,{children:"无法加载问卷配置"})]}),e.jsx(_,{variant:"outline",onClick:()=>window.location.reload(),children:"重试"})]})}async function bC(l=2025){const n=await _e(`/api/webui/annual-report/full?year=${l}`);if(!n.ok){const i=await n.json();throw new Error(i.detail||"获取年度报告失败")}return n.json()}const zo=["#0088FE","#00C49F","#FFBB28","#FF8042","#8884d8","#82ca9d"];function yC(l){return l>=8760?"相当于全年无休,7x24小时在线!":l>=5e3?"相当于一位全职员工的年工作时长":l>=2e3?"相当于看完了 1000 部电影":l>=1e3?"相当于环球飞行 80 次":l>=500?"相当于读完了 100 本书":l>=100?"相当于马拉松跑了 25 次":"虽然不多,但每一刻都很珍贵"}function wC(l){return l>=1e3?"夜深人静时的知心好友":l>=500?"午夜场的常客":l>=100?"偶尔熬夜的小伙伴":l>=50?"深夜有时也会陪你聊聊":"早睡早起,健康作息"}function _C(l){const n=l/1e6;return n>=100?"思考量堪比一座图书馆":n>=50?"相当于写了一部百科全书":n>=10?"脑细胞估计消耗了不少":n>=1?"也算是费了一番脑筋":"轻轻松松,游刃有余"}function SC(l){return l>=1e3?"这钱够吃一年的泡面了":l>=500?"相当于买了一台游戏机":l>=100?"够请大家喝几杯奶茶":l>=50?"一顿火锅的钱":l>=10?"几杯咖啡的价格":"省钱小能手"}function kC(l){return l>=80?"沉默是金,惜字如金":l>=60?"话不多但句句到位":l>=40?"该说的时候才开口":l>=20?"能聊的都聊了":"话痨本痨,有问必答"}function CC(l){return l>=1e4?"眼睛都快看花了":l>=5e3?"堪比专业摄影师的阅片量":l>=1e3?"看图小达人":l>=500?"图片鉴赏家":l>=100?"偶尔欣赏一下美图":"图片?有空再看"}function TC(l){return l>=500?"在不断的纠正中成长":l>=200?"学习永无止境":l>=100?"虚心接受,积极改正":l>=50?"偶尔也会犯错":l>=10?"表现还算不错":"完美表达,无需纠正"}function EC(l){return l>=1?"这次思考的价值堪比一顿大餐!":l>=.5?"为了这个问题,我可是认真思考了!":l>=.1?"下了点功夫,值得的!":l>=.01?"花了点小钱,但很值得":"小小思考,不足挂齿"}function MC(l,n){return l>=100?"这句话简直是万能钥匙!":l>=50?"百试不爽的经典回复":l>=20?`${n}的口头禅`:l>=10?"常用语录之一":"偶尔用用的小确幸"}function zC(l,n){return l?n>=1e3?"深夜的守护者,黑暗中的光芒":n>=500?"月亮是我的好朋友":n>=100?"越夜越精神,夜晚才是主场":"偶尔熬夜,享受宁静时光":n<=10?"作息规律,健康生活的典范":n<=50?"早睡早起,偶尔也会熬个夜":"虽然是早起鸟,但也会守候深夜"}function AC(l){return l>=1e3?"忙到飞起,键盘都要冒烟了":l>=500?"这天简直是话痨附体":l>=200?"社交达人上线":l>=100?"比平时活跃不少":l>=50?"小忙一下":"还算轻松的一天"}function OC(){const[l]=d.useState(2025),[n,i]=d.useState(null),[c,u]=d.useState(!0),[x,h]=d.useState(null),f=d.useRef(null),p=d.useCallback(async()=>{try{u(!0),h(null);const g=await bC(l);i(g)}catch(g){h(g instanceof Error?g:new Error("获取年度报告失败"))}finally{u(!1)}},[l]);return d.useEffect(()=>{p()},[p]),c?e.jsx(DC,{}):x?e.jsxs("div",{className:"flex h-screen items-center justify-center text-red-500",children:["获取年度报告失败: ",x.message]}):n?e.jsx(Je,{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",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-8 print:space-y-4",ref:f,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.jsxs("div",{className:"relative z-10 flex flex-col items-center text-center",children:[e.jsx(Pn,{className:"mb-4 h-16 w-16 animate-bounce"}),e.jsxs("h1",{className:"text-4xl font-bold tracking-tighter sm:text-6xl",children:[n.bot_name," ",n.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(Io,{className:"h-4 w-4"}),e.jsxs("span",{children:["生成时间: ",n.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(na,{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(ka,{title:"年度在线时长",value:`${n.time_footprint.total_online_hours} 小时`,description:yC(n.time_footprint.total_online_hours),icon:e.jsx(na,{className:"h-4 w-4"})}),e.jsx(ka,{title:"最忙碌的一天",value:n.time_footprint.busiest_day||"N/A",description:AC(n.time_footprint.busiest_day_count),icon:e.jsx(Io,{className:"h-4 w-4"})}),e.jsx(ka,{title:"深夜互动 (0-4点)",value:`${n.time_footprint.midnight_chat_count} 次`,description:wC(n.time_footprint.midnight_chat_count),icon:e.jsx(Yi,{className:"h-4 w-4"})}),e.jsx(ka,{title:"作息属性",value:n.time_footprint.is_night_owl?"夜猫子":"早起鸟",description:zC(n.time_footprint.is_night_owl,n.time_footprint.midnight_chat_count),icon:n.time_footprint.is_night_owl?e.jsx(Yi,{className:"h-4 w-4"}):e.jsx(Km,{className:"h-4 w-4"})})]}),e.jsxs(Ce,{className:"overflow-hidden",children:[e.jsxs(De,{children:[e.jsx(Re,{children:"24小时活跃时钟"}),e.jsxs(os,{children:[n.bot_name,"在一天中各个时段的活跃程度"]})]}),e.jsx(Me,{className:"h-[300px]",children:e.jsx(uj,{width:"100%",height:"100%",children:e.jsxs(Ao,{data:n.time_footprint.hourly_distribution.map((g,N)=>({hour:`${N}点`,count:g})),children:[e.jsx(Fi,{strokeDasharray:"3 3",vertical:!1}),e.jsx(Gi,{dataKey:"hour"}),e.jsx($r,{}),e.jsx(mj,{contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 12px rgba(0,0,0,0.1)"},cursor:{fill:"transparent"}}),e.jsx(Vi,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})})]}),n.time_footprint.first_message_time&&e.jsx(Ce,{className:"bg-muted/30 border-dashed",children:e.jsxs(Me,{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:n.time_footprint.first_message_time}),e.jsxs("p",{className:"text-lg",children:[e.jsx("span",{className:"font-semibold text-foreground",children:n.time_footprint.first_message_user})," 说:",e.jsxs("span",{className:"italic text-muted-foreground",children:['"',n.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(tc,{className:"h-8 w-8"}),e.jsx("h2",{children:"社交网络"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(ka,{title:"社交圈子",value:`${n.social_network.total_groups} 个群组`,description:`${n.bot_name}加入的群组总数`,icon:e.jsx(tc,{className:"h-4 w-4"})}),e.jsx(ka,{title:"被呼叫次数",value:`${n.social_network.at_count+n.social_network.mentioned_count} 次`,description:"我的名字被大家频繁提起",icon:e.jsx(j_,{className:"h-4 w-4"})}),e.jsx(ka,{title:"最长情陪伴",value:n.social_network.longest_companion_user||"N/A",description:`始终都在,已陪伴 ${n.social_network.longest_companion_days} 天`,icon:e.jsx(qr,{className:"h-4 w-4 text-red-500"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ce,{children:[e.jsx(De,{children:e.jsx(Re,{children:"话痨群组 TOP5"})}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-3",children:n.social_network.top_groups.length>0?n.social_network.top_groups.map((g,N)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ke,{variant:N===0?"default":"secondary",className:"h-6 w-6 rounded-full p-0 flex items-center justify-center shrink-0",children:N+1}),e.jsx("span",{className:"font-medium truncate max-w-[120px]",children:g.group_name}),g.is_webui&&e.jsx(ke,{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:[g.message_count," 条消息"]})]},g.group_id)):e.jsx("div",{className:"text-center text-muted-foreground py-4",children:"暂无数据"})})})]}),e.jsxs(Ce,{children:[e.jsx(De,{children:e.jsx(Re,{children:"年度最佳损友 TOP5"})}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-3",children:n.social_network.top_users.length>0?n.social_network.top_users.map((g,N)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ke,{variant:N===0?"default":"secondary",className:"h-6 w-6 rounded-full p-0 flex items-center justify-center shrink-0",children:N+1}),e.jsx("span",{className:"font-medium truncate max-w-[120px]",children:g.user_nickname}),g.is_webui&&e.jsx(ke,{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:[g.message_count," 次互动"]})]},g.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(Zm,{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(ka,{title:"年度 Token 消耗",value:(n.brain_power.total_tokens/1e6).toFixed(2)+" M",description:_C(n.brain_power.total_tokens),icon:e.jsx(Za,{className:"h-4 w-4"})}),e.jsx(ka,{title:"年度总花费",value:`$${n.brain_power.total_cost.toFixed(2)}`,description:SC(n.brain_power.total_cost),icon:e.jsx("span",{className:"font-bold",children:"$"})}),e.jsx(ka,{title:"高冷指数",value:`${n.brain_power.silence_rate}%`,description:kC(n.brain_power.silence_rate),icon:e.jsx(Yi,{className:"h-4 w-4"})}),e.jsx(ka,{title:"最高兴趣值",value:n.brain_power.max_interest_value??"N/A",description:n.brain_power.max_interest_time?`出现在 ${n.brain_power.max_interest_time}`:"暂无数据",icon:e.jsx(qr,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ce,{children:[e.jsx(De,{children:e.jsx(Re,{children:"模型偏好分布"})}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-3",children:n.brain_power.model_distribution.slice(0,5).map((g,N)=>{const v=n.brain_power.model_distribution[0]?.count||1,b=Math.round(g.count/v*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:g.model}),e.jsxs("span",{className:"text-muted-foreground",children:[g.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:`${b}%`,backgroundColor:zo[N%zo.length]}})})]},g.model)})})})]}),n.brain_power.top_reply_models&&n.brain_power.top_reply_models.length>0&&e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"最喜欢的回复模型 TOP5"}),e.jsxs(os,{children:[n.bot_name,"用来回复消息的模型偏好"]})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-3",children:n.brain_power.top_reply_models.map((g,N)=>{const v=n.brain_power.top_reply_models[0]?.count||1,b=Math.round(g.count/v*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:g.model}),e.jsxs("span",{className:"text-muted-foreground",children:[g.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:`${b}%`,backgroundColor:zo[N%zo.length]}})})]},g.model)})})})]}),n.brain_power.top_token_consumers&&n.brain_power.top_token_consumers.length>0&&e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"烧钱大户 TOP3"}),e.jsx(os,{children:"谁消耗了最多的 API 额度"})]}),e.jsx(Me,{children:e.jsx("div",{className:"space-y-6",children:n.brain_power.top_token_consumers.map(g=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm font-medium",children:[e.jsxs("span",{children:["用户 ",g.user_id]}),e.jsxs("span",{children:["$",g.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:`${g.cost/(n.brain_power.top_token_consumers[0]?.cost||1)*100}%`}})})]},g.user_id))})})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ce,{className:"bg-gradient-to-br from-amber-50 to-orange-50 dark:from-amber-950/20 dark:to-orange-950/20",children:[e.jsx(De,{children:e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"💰"}),"最昂贵的一次思考"]})}),e.jsxs(Me,{className:"text-center",children:[e.jsxs("div",{className:"text-4xl font-bold text-amber-600 dark:text-amber-400",children:["$",n.brain_power.most_expensive_cost.toFixed(4)]}),n.brain_power.most_expensive_time&&e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["发生在 ",n.brain_power.most_expensive_time]}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:EC(n.brain_power.most_expensive_cost)})]})]}),e.jsxs(Ce,{className:"bg-gradient-to-br from-indigo-50 to-blue-50 dark:from-indigo-950/20 dark:to-blue-950/20",children:[e.jsx(De,{children:e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"🧠"}),"思考深度"]})}),e.jsxs(Me,{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:n.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:n.brain_power.max_reasoning_length?.toLocaleString()||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"最长思考字数"})]})]}),n.brain_power.max_reasoning_time&&e.jsxs("p",{className:"mt-4 text-center text-xs text-muted-foreground",children:["最深沉的思考发生在 ",n.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(Xo,{className:"h-8 w-8"}),e.jsx("h2",{children:"个性与表达"})]}),(n.expression_vibe.late_night_reply||n.expression_vibe.favorite_reply)&&e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.expression_vibe.late_night_reply&&e.jsxs(Ce,{className:"bg-gradient-to-br from-indigo-50 to-violet-50 dark:from-indigo-950/20 dark:to-violet-950/20",children:[e.jsxs(De,{children:[e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"🌙"}),"深夜还在回复"]}),e.jsxs(os,{children:["凌晨 ",n.expression_vibe.late_night_reply.time,",",n.bot_name,"还在回复..."]})]}),e.jsxs(Me,{className:"text-center",children:[e.jsxs("p",{className:"text-lg italic text-muted-foreground",children:['"',n.expression_vibe.late_night_reply.content,'"']}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"是有什么心事吗?"})]})]}),n.expression_vibe.favorite_reply&&e.jsxs(Ce,{className:"bg-gradient-to-br from-rose-50 to-pink-50 dark:from-rose-950/20 dark:to-pink-950/20",children:[e.jsxs(De,{children:[e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"💬"}),"最喜欢的回复"]}),e.jsxs(os,{children:["使用了 ",n.expression_vibe.favorite_reply.count," 次"]})]}),e.jsxs(Me,{className:"text-center",children:[e.jsxs("p",{className:"text-lg font-medium text-primary",children:['"',n.expression_vibe.favorite_reply.content,'"']}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:MC(n.expression_vibe.favorite_reply.count,n.bot_name)})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ce,{className:"bg-gradient-to-br from-pink-50 to-purple-50 dark:from-pink-950/20 dark:to-purple-950/20",children:[e.jsxs(De,{children:[e.jsx(Re,{children:"使用最多的表情包 TOP3"}),e.jsx(os,{children:"年度最爱的表情包们"})]}),e.jsx(Me,{children:n.expression_vibe.top_emojis&&n.expression_vibe.top_emojis.length>0?e.jsx("div",{className:"flex justify-center gap-4",children:n.expression_vibe.top_emojis.slice(0,3).map((g,N)=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:`/api/webui/emoji/${g.id}/thumbnail?original=true`,alt:`TOP ${N+1}`,className:"h-24 w-24 rounded-lg object-cover shadow-md transition-transform hover:scale-105"}),e.jsx(ke,{className:P("absolute -top-2 -right-2",N===0?"bg-yellow-500":N===1?"bg-gray-400":"bg-amber-700"),children:N+1})]}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:[g.usage_count," 次"]})]},g.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(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"印象最深刻的表达风格"}),e.jsxs(os,{children:[n.bot_name,"最常使用的表达方式"]})]}),e.jsx(Me,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:n.expression_vibe.top_expressions.map((g,N)=>e.jsxs(ke,{variant:"outline",className:P("px-3 py-1 text-sm",N===0&&"border-primary bg-primary/10 text-primary text-base px-4 py-2"),children:[g.style," (",g.count,")"]},g.style))})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ka,{title:"图片鉴赏",value:`${n.expression_vibe.image_processed_count} 张`,description:CC(n.expression_vibe.image_processed_count),icon:e.jsx(Xm,{className:"h-4 w-4"})}),e.jsx(ka,{title:"成长的足迹",value:`${n.expression_vibe.rejected_expression_count} 次`,description:TC(n.expression_vibe.rejected_expression_count),icon:e.jsx(Za,{className:"h-4 w-4"})})]})]})]}),n.expression_vibe.action_types.length>0&&e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:"⚡"}),"行动派"]}),e.jsx(os,{children:"除了聊天,我还帮大家做了这些事"})]}),e.jsx(Me,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:n.expression_vibe.action_types.map(g=>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:g.action}),e.jsxs(ke,{variant:"secondary",children:[g.count," 次"]})]},g.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(v_,{className:"h-8 w-8"}),e.jsx("h2",{children:"趣味成就"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(Ce,{className:"col-span-1 md:col-span-2",children:[e.jsxs(De,{children:[e.jsx(Re,{children:'新学到的"黑话"'}),e.jsxs(os,{children:["今年我学会了 ",n.achievements.new_jargon_count," 个新词"]})]}),e.jsx(Me,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:n.achievements.sample_jargons.map(g=>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:g.content}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2 max-w-[200px]",children:g.meaning||"暂无解释"})]},g.content))})})]}),e.jsx(Ce,{className:"flex flex-col justify-center items-center bg-primary text-primary-foreground",children:e.jsxs(Me,{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(za,{className:"h-12 w-12 mb-4 opacity-80"}),e.jsx("div",{className:"text-4xl font-bold mb-2",children:n.achievements.total_messages.toLocaleString()}),e.jsx("div",{className:"text-sm opacity-80",children:"年度总消息数"}),e.jsxs("div",{className:"mt-4 text-xs opacity-60",children:["其中回复了 ",n.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 ka({title:l,value:n,description:i,icon:c}){return e.jsxs(Ce,{children:[e.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Re,{className:"text-sm font-medium",children:l}),e.jsx("div",{className:"text-muted-foreground",children:c})]}),e.jsxs(Me,{children:[e.jsx("div",{className:"text-2xl font-bold",children:n}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i})]})]})}function DC(){return e.jsxs("div",{className:"container mx-auto space-y-8 p-8",children:[e.jsx(vs,{className:"h-64 w-full rounded-3xl"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((l,n)=>e.jsx(vs,{className:"h-32 w-full"},n))}),e.jsx(vs,{className:"h-96 w-full"})]})}var od="DropdownMenu",[RC]=Yo(od,[oj]),oa=oj(),[LC,xN]=RC(od),hN=l=>{const{__scopeDropdownMenu:n,children:i,dir:c,open:u,defaultOpen:x,onOpenChange:h,modal:f=!0}=l,p=oa(n),g=d.useRef(null),[N,v]=Qo({prop:u,defaultProp:x??!1,onChange:h,caller:od});return e.jsx(LC,{scope:n,triggerId:Um(),triggerRef:g,contentId:Um(),open:N,onOpenChange:v,onOpenToggle:d.useCallback(()=>v(b=>!b),[v]),modal:f,children:e.jsx(ow,{...p,open:N,onOpenChange:v,dir:c,modal:f,children:i})})};hN.displayName=od;var fN="DropdownMenuTrigger",pN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,disabled:c=!1,...u}=l,x=xN(fN,i),h=oa(i);return e.jsx(dw,{asChild:!0,...h,children:e.jsx(Yn.button,{type:"button",id:x.triggerId,"aria-haspopup":"menu","aria-expanded":x.open,"aria-controls":x.open?x.contentId:void 0,"data-state":x.open?"open":"closed","data-disabled":c?"":void 0,disabled:c,...u,ref:$w(n,x.triggerRef),onPointerDown:hn(l.onPointerDown,f=>{!c&&f.button===0&&f.ctrlKey===!1&&(x.onOpenToggle(),x.open||f.preventDefault())}),onKeyDown:hn(l.onKeyDown,f=>{c||(["Enter"," "].includes(f.key)&&x.onOpenToggle(),f.key==="ArrowDown"&&x.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(f.key)&&f.preventDefault())})})})});pN.displayName=fN;var UC="DropdownMenuPortal",gN=l=>{const{__scopeDropdownMenu:n,...i}=l,c=oa(n);return e.jsx(sw,{...c,...i})};gN.displayName=UC;var jN="DropdownMenuContent",vN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=xN(jN,i),x=oa(i),h=d.useRef(!1);return e.jsx(tw,{id:u.contentId,"aria-labelledby":u.triggerId,...x,...c,ref:n,onCloseAutoFocus:hn(l.onCloseAutoFocus,f=>{h.current||u.triggerRef.current?.focus(),h.current=!1,f.preventDefault()}),onInteractOutside:hn(l.onInteractOutside,f=>{const p=f.detail.originalEvent,g=p.button===0&&p.ctrlKey===!0,N=p.button===2||g;(!u.modal||N)&&(h.current=!0)}),style:{...l.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)"}})});vN.displayName=jN;var $C="DropdownMenuGroup",BC=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(uw,{...u,...c,ref:n})});BC.displayName=$C;var IC="DropdownMenuLabel",NN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(iw,{...u,...c,ref:n})});NN.displayName=IC;var PC="DropdownMenuItem",bN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(aw,{...u,...c,ref:n})});bN.displayName=PC;var HC="DropdownMenuCheckboxItem",yN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(lw,{...u,...c,ref:n})});yN.displayName=HC;var FC="DropdownMenuRadioGroup",GC=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(mw,{...u,...c,ref:n})});GC.displayName=FC;var VC="DropdownMenuRadioItem",wN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(rw,{...u,...c,ref:n})});wN.displayName=VC;var qC="DropdownMenuItemIndicator",_N=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(nw,{...u,...c,ref:n})});_N.displayName=qC;var KC="DropdownMenuSeparator",SN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(cw,{...u,...c,ref:n})});SN.displayName=KC;var QC="DropdownMenuArrow",YC=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(xw,{...u,...c,ref:n})});YC.displayName=QC;var JC="DropdownMenuSubTrigger",kN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(W0,{...u,...c,ref:n})});kN.displayName=JC;var XC="DropdownMenuSubContent",CN=d.forwardRef((l,n)=>{const{__scopeDropdownMenu:i,...c}=l,u=oa(i);return e.jsx(ew,{...u,...c,ref:n,style:{...l.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)"}})});CN.displayName=XC;var ZC=hN,WC=pN,e3=gN,TN=vN,EN=NN,MN=bN,zN=yN,AN=wN,ON=_N,DN=SN,RN=kN,LN=CN;const s3=ZC,t3=WC,a3=d.forwardRef(({className:l,inset:n,children:i,...c},u)=>e.jsxs(RN,{ref:u,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",n&&"pl-8",l),...c,children:[i,e.jsx(Zt,{className:"ml-auto h-4 w-4"})]}));a3.displayName=RN.displayName;const l3=d.forwardRef(({className:l,...n},i)=>e.jsx(LN,{ref:i,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",l),...n}));l3.displayName=LN.displayName;const UN=d.forwardRef(({className:l,sideOffset:n=4,...i},c)=>e.jsx(e3,{children:e.jsx(TN,{ref:c,sideOffset:n,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",l),...i})}));UN.displayName=TN.displayName;const $N=d.forwardRef(({className:l,inset:n,...i},c)=>e.jsx(MN,{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",n&&"pl-8",l),...i}));$N.displayName=MN.displayName;const n3=d.forwardRef(({className:l,children:n,checked:i,...c},u)=>e.jsxs(zN,{ref:u,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",l),checked:i,...c,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ON,{children:e.jsx(Ct,{className:"h-4 w-4"})})}),n]}));n3.displayName=zN.displayName;const r3=d.forwardRef(({className:l,children:n,...i},c)=>e.jsxs(AN,{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",l),...i,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(ON,{children:e.jsx($o,{className:"h-2 w-2 fill-current"})})}),n]}));r3.displayName=AN.displayName;const i3=d.forwardRef(({className:l,inset:n,...i},c)=>e.jsx(EN,{ref:c,className:P("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",l),...i}));i3.displayName=EN.displayName;const c3=d.forwardRef(({className:l,...n},i)=>e.jsx(DN,{ref:i,className:P("-mx-1 my-1 h-px bg-muted",l),...n}));c3.displayName=DN.displayName;const Lm=[{value:"created_at",label:"最新发布",icon:na},{value:"downloads",label:"下载最多",icon:sa},{value:"likes",label:"最受欢迎",icon:qr}];function o3(){const l=ca(),[n,i]=d.useState([]),[c,u]=d.useState(!0),[x,h]=d.useState(""),[f,p]=d.useState("downloads"),[g,N]=d.useState(1),[v,b]=d.useState(1),[w,y]=d.useState(0),[R,O]=d.useState(new Set),[S,B]=d.useState(new Set),E=Mv(),C=d.useCallback(async()=>{u(!0);try{const U=await mS({status:"approved",page:g,page_size:12,search:x||void 0,sort_by:f,sort_order:"desc"});i(U.packs),b(U.total_pages),y(U.total);const oe=new Set;for(const Ne of U.packs)await Ev(Ne.id,E)&&oe.add(Ne.id);O(oe)}catch(U){console.error("加载 Pack 列表失败:",U),Qt({title:"加载 Pack 列表失败",variant:"destructive"})}finally{u(!1)}},[g,x,f,E]);d.useEffect(()=>{C()},[C]);const z=U=>{U.preventDefault(),N(1),C()},H=async U=>{if(!S.has(U)){B(oe=>new Set(oe).add(U));try{const oe=await Tv(U,E);O(Ne=>{const je=new Set(Ne);return oe.liked?je.add(U):je.delete(U),je}),i(Ne=>Ne.map(je=>je.id===U?{...je,likes:oe.likes}:je))}catch(oe){console.error("点赞失败:",oe),Qt({title:"点赞失败",variant:"destructive"})}finally{B(oe=>{const Ne=new Set(oe);return Ne.delete(U),Ne})}}},L=U=>{l({to:"/config/pack-market/$packId",params:{packId:U}})},J=Lm.find(U=>U.value===f)||Lm[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(ra,{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(Je,{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:z,className:"flex-1 min-w-[200px] max-w-md",children:e.jsxs("div",{className:"relative",children:[e.jsx(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ae,{placeholder:"搜索模板名称、描述...",value:x,onChange:U=>h(U.target.value),className:"pl-10"})]})}),e.jsxs(s3,{children:[e.jsx(t3,{asChild:!0,children:e.jsxs(_,{variant:"outline",className:"min-w-[140px] gap-2",children:[e.jsx(N_,{className:"w-4 h-4"}),J.label,e.jsx(Ma,{className:"w-4 h-4 ml-auto"})]})}),e.jsx(UN,{align:"end",children:Lm.map(U=>e.jsxs($N,{onClick:()=>{p(U.value),N(1)},children:[e.jsx(U.icon,{className:"w-4 h-4 mr-2"}),U.label]},U.value))})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["共找到 ",e.jsx("span",{className:"font-medium text-foreground",children:w})," 个模板"]}),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((U,oe)=>e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(vs,{className:"h-6 w-3/4"}),e.jsx(vs,{className:"h-4 w-full mt-2"})]}),e.jsx(Me,{children:e.jsx(vs,{className:"h-20 w-full"})}),e.jsx(ed,{children:e.jsx(vs,{className:"h-9 w-full"})})]},oe))}):n.length===0?e.jsx(Ce,{className:"py-12",children:e.jsxs(Me,{className:"text-center text-muted-foreground",children:[e.jsx(ra,{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:n.map(U=>e.jsx(d3,{pack:U,liked:R.has(U.id),liking:S.has(U.id),onLike:()=>H(U.id),onView:()=>L(U.id)},U.id))}),v>1&&e.jsx(Wm,{children:e.jsxs(ex,{children:[e.jsx(Fn,{children:e.jsx(mv,{onClick:()=>N(U=>Math.max(1,U-1)),className:g===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:v},(U,oe)=>oe+1).filter(U=>U===1||U===v||Math.abs(U-g)<=1).map((U,oe,Ne)=>{const je=oe>0&&U-Ne[oe-1]>1;return e.jsxs(Fn,{children:[je&&e.jsx("span",{className:"px-2",children:"..."}),e.jsx(uc,{onClick:()=>N(U),isActive:U===g,className:"cursor-pointer",children:U})]},U)}),e.jsx(Fn,{children:e.jsx(xv,{onClick:()=>N(U=>Math.min(v,U+1)),className:g===v?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})})]})}function d3({pack:l,liked:n,liking:i,onLike:c,onView:u}){const x=h=>new Date(h).toLocaleDateString("zh-CN",{year:"numeric",month:"short",day:"numeric"});return e.jsxs(Ce,{className:"flex flex-col hover:shadow-md transition-shadow",children:[e.jsxs(De,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Re,{className:"text-lg line-clamp-1",children:l.name}),e.jsxs(ke,{variant:"secondary",className:"text-xs",children:["v",l.version]})]}),e.jsx(os,{className:"line-clamp-2 min-h-[40px]",children:l.description})]}),e.jsxs(Me,{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(fn,{className:"w-3.5 h-3.5"}),l.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(na,{className:"w-3.5 h-3.5"}),x(l.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(Dl,{className:"w-3.5 h-3.5"}),l.provider_count]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"模型数量",children:[e.jsx(Vn,{className:"w-3.5 h-3.5"}),l.model_count]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",title:"任务配置数",children:[e.jsx(qn,{className:"w-3.5 h-3.5"}),l.task_count]})]}),l.tags&&l.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[l.tags.slice(0,3).map(h=>e.jsxs(ke,{variant:"outline",className:"text-xs",children:[e.jsx(Wo,{className:"w-2.5 h-2.5 mr-1"}),h]},h)),l.tags.length>3&&e.jsxs(ke,{variant:"outline",className:"text-xs",children:["+",l.tags.length-3]})]})]}),e.jsx(ed,{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(sa,{className:"w-4 h-4"}),l.downloads]}),e.jsxs("button",{onClick:h=>{h.stopPropagation(),c()},disabled:i,className:`flex items-center gap-1 transition-colors ${n?"text-red-500":"hover:text-red-500"} ${i?"opacity-50":""}`,children:[e.jsx(qr,{className:`w-4 h-4 ${n?"fill-current":""}`}),l.likes]})]}),e.jsx(_,{size:"sm",onClick:u,children:"查看详情"})]})})]})}var sl="Accordion",u3=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[px,m3,x3]=Bw(sl),[dd]=Yo(sl,[x3,dj]),gx=dj(),BN=As.forwardRef((l,n)=>{const{type:i,...c}=l,u=c,x=c;return e.jsx(px.Provider,{scope:l.__scopeAccordion,children:i==="multiple"?e.jsx(g3,{...x,ref:n}):e.jsx(p3,{...u,ref:n})})});BN.displayName=sl;var[IN,h3]=dd(sl),[PN,f3]=dd(sl,{collapsible:!1}),p3=As.forwardRef((l,n)=>{const{value:i,defaultValue:c,onValueChange:u=()=>{},collapsible:x=!1,...h}=l,[f,p]=Qo({prop:i,defaultProp:c??"",onChange:u,caller:sl});return e.jsx(IN,{scope:l.__scopeAccordion,value:As.useMemo(()=>f?[f]:[],[f]),onItemOpen:p,onItemClose:As.useCallback(()=>x&&p(""),[x,p]),children:e.jsx(PN,{scope:l.__scopeAccordion,collapsible:x,children:e.jsx(HN,{...h,ref:n})})})}),g3=As.forwardRef((l,n)=>{const{value:i,defaultValue:c,onValueChange:u=()=>{},...x}=l,[h,f]=Qo({prop:i,defaultProp:c??[],onChange:u,caller:sl}),p=As.useCallback(N=>f((v=[])=>[...v,N]),[f]),g=As.useCallback(N=>f((v=[])=>v.filter(b=>b!==N)),[f]);return e.jsx(IN,{scope:l.__scopeAccordion,value:h,onItemOpen:p,onItemClose:g,children:e.jsx(PN,{scope:l.__scopeAccordion,collapsible:!0,children:e.jsx(HN,{...x,ref:n})})})}),[j3,ud]=dd(sl),HN=As.forwardRef((l,n)=>{const{__scopeAccordion:i,disabled:c,dir:u,orientation:x="vertical",...h}=l,f=As.useRef(null),p=Jo(f,n),g=m3(i),v=kj(u)==="ltr",b=hn(l.onKeyDown,w=>{if(!u3.includes(w.key))return;const y=w.target,R=g().filter(J=>!J.ref.current?.disabled),O=R.findIndex(J=>J.ref.current===y),S=R.length;if(O===-1)return;w.preventDefault();let B=O;const E=0,C=S-1,z=()=>{B=O+1,B>C&&(B=E)},H=()=>{B=O-1,B<E&&(B=C)};switch(w.key){case"Home":B=E;break;case"End":B=C;break;case"ArrowRight":x==="horizontal"&&(v?z():H());break;case"ArrowDown":x==="vertical"&&z();break;case"ArrowLeft":x==="horizontal"&&(v?H():z());break;case"ArrowUp":x==="vertical"&&H();break}const L=B%S;R[L].ref.current?.focus()});return e.jsx(j3,{scope:i,disabled:c,direction:u,orientation:x,children:e.jsx(px.Slot,{scope:i,children:e.jsx(Yn.div,{...h,"data-orientation":x,ref:p,onKeyDown:c?void 0:b})})})}),Ko="AccordionItem",[v3,jx]=dd(Ko),FN=As.forwardRef((l,n)=>{const{__scopeAccordion:i,value:c,...u}=l,x=ud(Ko,i),h=h3(Ko,i),f=gx(i),p=Um(),g=c&&h.value.includes(c)||!1,N=x.disabled||l.disabled;return e.jsx(v3,{scope:i,open:g,disabled:N,triggerId:p,children:e.jsx(lj,{"data-orientation":x.orientation,"data-state":YN(g),...f,...u,ref:n,disabled:N,open:g,onOpenChange:v=>{v?h.onItemOpen(c):h.onItemClose(c)}})})});FN.displayName=Ko;var GN="AccordionHeader",VN=As.forwardRef((l,n)=>{const{__scopeAccordion:i,...c}=l,u=ud(sl,i),x=jx(GN,i);return e.jsx(Yn.h3,{"data-orientation":u.orientation,"data-state":YN(x.open),"data-disabled":x.disabled?"":void 0,...c,ref:n})});VN.displayName=GN;var Gm="AccordionTrigger",qN=As.forwardRef((l,n)=>{const{__scopeAccordion:i,...c}=l,u=ud(sl,i),x=jx(Gm,i),h=f3(Gm,i),f=gx(i);return e.jsx(px.ItemSlot,{scope:i,children:e.jsx(hw,{"aria-disabled":x.open&&!h.collapsible||void 0,"data-orientation":u.orientation,id:x.triggerId,...f,...c,ref:n})})});qN.displayName=Gm;var KN="AccordionContent",QN=As.forwardRef((l,n)=>{const{__scopeAccordion:i,...c}=l,u=ud(sl,i),x=jx(KN,i),h=gx(i);return e.jsx(fw,{role:"region","aria-labelledby":x.triggerId,"data-orientation":u.orientation,...h,...c,ref:n,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...l.style}})});QN.displayName=KN;function YN(l){return l?"open":"closed"}var N3=BN,b3=FN,y3=VN,JN=qN,XN=QN;const w3=N3,ZN=d.forwardRef(({className:l,...n},i)=>e.jsx(b3,{ref:i,className:P("border-b",l),...n}));ZN.displayName="AccordionItem";const WN=d.forwardRef(({className:l,children:n,...i},c)=>e.jsx(y3,{className:"flex",children:e.jsxs(JN,{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",l),...i,children:[n,e.jsx(Ma,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));WN.displayName=JN.displayName;const eb=d.forwardRef(({className:l,children:n,...i},c)=>e.jsx(XN,{ref:c,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...i,children:e.jsx("div",{className:P("pb-4 pt-0",l),children:n})}));eb.displayName=XN.displayName;const _3={utils:"通用工具",utils_small:"轻量工具",tool_use:"工具调用",replyer:"回复生成",planner:"规划推理",vlm:"视觉模型",voice:"语音处理",embedding:"向量嵌入",lpmm_entity_extract:"实体提取",lpmm_rdf_build:"RDF构建",lpmm_qa:"问答模型"};function S3(){const{packId:l}=nb.useParams(),n=ca(),[i,c]=d.useState(null),[u,x]=d.useState(!0),[h,f]=d.useState(!1),[p,g]=d.useState(!1),[N,v]=d.useState(!1),[b,w]=d.useState(1),[y,R]=d.useState(null),[O,S]=d.useState(!1),[B,E]=d.useState(!1),[C,z]=d.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,L]=d.useState({}),[J,U]=d.useState({}),oe=Mv(),Ne=d.useCallback(async()=>{if(l){x(!0);try{const M=await xS(l);c(M);const K=await Ev(l,oe);f(K)}catch(M){console.error("加载 Pack 失败:",M),Qt({title:"加载模板失败",variant:"destructive"})}finally{x(!1)}}},[l,oe]);d.useEffect(()=>{Ne()},[Ne]);const je=async()=>{if(!(!l||p)){g(!0);try{const M=await Tv(l,oe);f(M.liked),i&&c({...i,likes:M.likes})}catch(M){console.error("点赞失败:",M),Qt({title:"点赞失败",variant:"destructive"})}finally{g(!1)}}},re=async()=>{if(i){v(!0),w(1),S(!0);try{const M=await pS(i);R(M);const K={};for(const ue of M.existing_providers)K[ue.pack_provider.name]=ue.local_providers[0].name;L(K);const I={};for(const ue of M.new_providers)I[ue.name]="";U(I)}catch(M){console.error("检测冲突失败:",M),Qt({title:"检测配置冲突失败",variant:"destructive"}),v(!1)}finally{S(!1)}}},fe=async()=>{if(i){if(C.apply_providers&&y){for(const M of y.new_providers)if(!J[M.name]){Qt({title:`请填写提供商 "${M.name}" 的 API Key`,variant:"destructive"});return}}E(!0);try{await gS(i,C,H,J),await fS(i.id,oe),c({...i,downloads:i.downloads+1}),Qt({title:"配置模板应用成功!"}),v(!1)}catch(M){console.error("应用 Pack 失败:",M),Qt({title:M instanceof Error?M.message:"应用配置失败",variant:"destructive"})}finally{E(!1)}}},ge=M=>new Date(M).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"});return u?e.jsx(C3,{}):i?e.jsx("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:e.jsx(Je,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsxs(_,{variant:"ghost",size:"sm",onClick:()=>n({to:"/config/pack-market"}),className:"gap-2",children:[e.jsx(Ta,{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(ra,{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:[i.name,e.jsxs(ke,{variant:"secondary",children:["v",i.version]})]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:i.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(fn,{className:"w-4 h-4"}),i.author]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(na,{className:"w-4 h-4"}),ge(i.created_at)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(sa,{className:"w-4 h-4"}),i.downloads," 次下载"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qr,{className:`w-4 h-4 ${h?"fill-red-500 text-red-500":""}`}),i.likes," 赞"]})]}),i.tags&&i.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:i.tags.map(M=>e.jsxs(ke,{variant:"outline",children:[e.jsx(Wo,{className:"w-3 h-3 mr-1"}),M]},M))})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-[160px]",children:[e.jsxs(_,{size:"lg",onClick:re,children:[e.jsx(sa,{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(qr,{className:`w-4 h-4 mr-2 ${h?"fill-current":""}`}),h?"已点赞":"点赞"]})]})]}),e.jsx(Yt,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(Ce,{children:e.jsxs(Me,{className:"flex items-center gap-3 py-4",children:[e.jsx(Dl,{className:"w-8 h-8 text-blue-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.providers.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"API 提供商"})]})]})}),e.jsx(Ce,{children:e.jsxs(Me,{className:"flex items-center gap-3 py-4",children:[e.jsx(Vn,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.models.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"模型配置"})]})]})}),e.jsx(Ce,{children:e.jsxs(Me,{className:"flex items-center gap-3 py-4",children:[e.jsx(qn,{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(i.task_config).length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"任务配置"})]})]})})]}),e.jsxs(ta,{defaultValue:"providers",className:"space-y-4",children:[e.jsxs(Xt,{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(Dl,{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:["(",i.providers.length,")"]})]}),e.jsxs(Xe,{value:"models",className:"gap-1 sm:gap-2",children:[e.jsx(Vn,{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:["(",i.models.length,")"]})]}),e.jsxs(Xe,{value:"tasks",className:"gap-1 sm:gap-2",children:[e.jsx(qn,{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(i.task_config).length,")"]})]})]}),e.jsx(ws,{value:"providers",children:e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"API 提供商"}),e.jsx(os,{children:"模板中包含的 API 提供商配置(不含 API Key)"})]}),e.jsx(Me,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{children:"名称"}),e.jsx(We,{children:"Base URL"}),e.jsx(We,{children:"类型"})]})}),e.jsx(Ul,{children:i.providers.map(M=>e.jsxs(ut,{children:[e.jsx(Ke,{className:"font-medium whitespace-nowrap",children:M.name}),e.jsx(Ke,{className:"text-muted-foreground font-mono text-sm max-w-[200px] truncate",children:M.base_url}),e.jsx(Ke,{children:e.jsx(ke,{variant:"outline",children:M.client_type})})]},M.name))})]})})})]})}),e.jsx(ws,{value:"models",children:e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"模型配置"}),e.jsx(os,{children:"模板中包含的模型配置"})]}),e.jsx(Me,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Rl,{children:[e.jsx(Ll,{children:e.jsxs(ut,{children:[e.jsx(We,{children:"模型名称"}),e.jsx(We,{children:"标识符"}),e.jsx(We,{children:"提供商"}),e.jsx(We,{className:"text-right",children:"价格 (入/出)"})]})}),e.jsx(Ul,{children:i.models.map(M=>e.jsxs(ut,{children:[e.jsx(Ke,{className:"font-medium whitespace-nowrap",children:M.name}),e.jsx(Ke,{className:"text-muted-foreground font-mono text-sm max-w-[150px] truncate",children:M.model_identifier}),e.jsx(Ke,{className:"whitespace-nowrap",children:M.api_provider}),e.jsxs(Ke,{className:"text-right text-muted-foreground whitespace-nowrap",children:["¥",M.price_in," / ¥",M.price_out]})]},M.name))})]})})})]})}),e.jsx(ws,{value:"tasks",children:e.jsxs(Ce,{children:[e.jsxs(De,{children:[e.jsx(Re,{children:"任务配置"}),e.jsx(os,{children:"模板中各任务类型的模型分配"})]}),e.jsx(Me,{children:e.jsx(w3,{type:"multiple",className:"w-full",children:Object.entries(i.task_config).map(([M,K])=>e.jsxs(ZN,{value:M,children:[e.jsx(WN,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pn,{className:"w-4 h-4"}),_3[M]||M,e.jsxs(ke,{variant:"secondary",className:"ml-2",children:[K.model_list.length," 个模型"]})]})}),e.jsx(eb,{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:K.model_list.map(I=>e.jsx(ke,{variant:"outline",children:I},I))}),K.temperature!==void 0&&e.jsxs("div",{className:"text-sm",children:["Temperature: ",e.jsx("span",{className:"font-mono",children:K.temperature})]}),K.max_tokens!==void 0&&e.jsxs("div",{className:"text-sm",children:["Max Tokens: ",e.jsx("span",{className:"font-mono",children:K.max_tokens})]})]})})]},M))})})]})})]}),e.jsx(k3,{open:N,onOpenChange:v,pack:i,step:b,setStep:w,conflicts:y,detectingConflicts:O,applying:B,options:C,setOptions:z,_providerMapping:H,_setProviderMapping:L,newProviderApiKeys:J,setNewProviderApiKeys:U,onApply:fe})]})})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ra,{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:()=>n({to:"/config/pack-market"}),children:[e.jsx(Ta,{className:"w-4 h-4 mr-2"}),"返回市场"]})]})}function k3({open:l,onOpenChange:n,pack:i,step:c,setStep:u,conflicts:x,detectingConflicts:h,applying:f,options:p,setOptions:g,_providerMapping:N,_setProviderMapping:v,newProviderApiKeys:b,setNewProviderApiKeys:w,onApply:y}){return e.jsx(Is,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Ds,{children:[e.jsxs(Rs,{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"w-5 h-5"}),"应用配置模板"]}),e.jsxs(Ks,{children:["步骤 ",c," / ",3,":",c===1&&"选择要应用的内容",c===2&&"配置提供商映射",c===3&&"确认并应用"]})]}),h?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(Bs,{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(qs,{id:"apply_providers",checked:p.apply_providers,onCheckedChange:O=>g({...p,apply_providers:O})}),e.jsxs(T,{htmlFor:"apply_providers",className:"flex items-center gap-2",children:[e.jsx(Dl,{className:"w-4 h-4"}),"应用提供商配置 (",i.providers.length," 个)"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qs,{id:"apply_models",checked:p.apply_models,onCheckedChange:O=>g({...p,apply_models:O})}),e.jsxs(T,{htmlFor:"apply_models",className:"flex items-center gap-2",children:[e.jsx(Vn,{className:"w-4 h-4"}),"应用模型配置 (",i.models.length," 个)"]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qs,{id:"apply_task_config",checked:p.apply_task_config,onCheckedChange:O=>g({...p,apply_task_config:O})}),e.jsxs(T,{htmlFor:"apply_task_config",className:"flex items-center gap-2",children:[e.jsx(qn,{className:"w-4 h-4"}),"应用任务配置 (",Object.keys(i.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(fx,{value:p.task_mode,onValueChange:O=>g({...p,task_mode:O}),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(qo,{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(qo,{value:"replace",id:"mode_replace"}),e.jsx(T,{htmlFor:"mode_replace",className:"font-normal",children:"替换模式 - 用模板配置完全替换现有配置"})]})]})]})]}),c===2&&x&&e.jsxs("div",{className:"space-y-4",children:[p.apply_providers&&x.existing_providers.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(Hn,{children:"发现已有的提供商"}),e.jsx(lt,{children:"以下提供商的 URL 与您本地配置中的提供商匹配,将自动使用本地提供商:"})]}),e.jsx("div",{className:"space-y-2",children:x.existing_providers.map(({pack_provider:O,local_providers:S})=>e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[e.jsx(Ct,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"font-medium flex-shrink-0",children:O.name}),e.jsx(Zt,{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(ke,{variant:"outline",className:"ml-auto",children:"URL 匹配"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{value:N[O.name]||S[0].name,onValueChange:B=>v({...N,[O.name]:B}),children:[e.jsx($e,{className:"w-[200px]",children:e.jsx(Pe,{})}),e.jsx(Be,{children:S.map(B=>e.jsx(Z,{value:B.name,children:B.name},B.name))})]}),e.jsxs(ke,{variant:"outline",className:"ml-auto",children:[S.length," 个匹配"]})]})]},O.name))})]}),p.apply_providers&&x.new_providers.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(at,{variant:"destructive",children:[e.jsx(Jt,{className:"h-4 w-4"}),e.jsx(Hn,{children:"需要配置 API Key"}),e.jsx(lt,{children:"以下提供商在您的本地配置中不存在,需要填写 API Key:"})]}),e.jsx("div",{className:"space-y-4",children:x.new_providers.map(O=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qm,{className:"w-4 h-4 text-amber-500"}),e.jsx("span",{className:"font-medium",children:O.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",O.base_url,")"]})]}),e.jsx(ae,{type:"password",placeholder:`输入 ${O.name} 的 API Key`,value:b[O.name]||"",onChange:S=>w({...b,[O.name]:S.target.value})})]},O.name))})]}),(!p.apply_providers||x.existing_providers.length===0&&x.new_providers.length===0)&&e.jsxs(at,{children:[e.jsx(Ct,{className:"h-4 w-4"}),e.jsx(Hn,{children:"无需配置"}),e.jsx(lt,{children:"模板中没有提供商配置,或您选择不应用提供商。"})]})]}),c===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(at,{children:[e.jsx(Ht,{className:"h-4 w-4"}),e.jsx(Hn,{children:"确认应用"}),e.jsx(lt,{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(Ct,{className:"w-4 h-4 text-green-500"}),e.jsx(Dl,{className:"w-4 h-4"}),e.jsxs("span",{children:["应用 ",i.providers.length," 个提供商配置"]})]}),p.apply_models&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ct,{className:"w-4 h-4 text-green-500"}),e.jsx(Vn,{className:"w-4 h-4"}),e.jsxs("span",{children:["应用 ",i.models.length," 个模型配置"]})]}),p.apply_task_config&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ct,{className:"w-4 h-4 text-green-500"}),e.jsx(qn,{className:"w-4 h-4"}),e.jsxs("span",{children:[p.task_mode==="append"?"追加":"替换"," ",Object.keys(i.task_config).length," 个任务配置"]})]})]}),x&&x.new_providers.length>0&&e.jsxs(at,{variant:"destructive",children:[e.jsx(Jt,{className:"h-4 w-4"}),e.jsxs(lt,{children:["将添加 ",x.new_providers.length," 个新提供商,请确保已填写正确的 API Key。"]})]})]})]}),e.jsxs(st,{className:"flex justify-between",children:[e.jsx("div",{children:c>1&&!h&&e.jsx(_,{variant:"outline",onClick:()=>u(c-1),disabled:f,children:"上一步"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{variant:"outline",onClick:()=>n(!1),disabled:f,children:"取消"}),c<3?e.jsx(_,{onClick:()=>u(c+1),disabled:h,children:"下一步"}):e.jsxs(_,{onClick:y,disabled:f,children:[f&&e.jsx(Bs,{className:"w-4 h-4 mr-2 animate-spin"}),"应用模板"]})]})]})]})})}function C3(){return e.jsx("div",{className:"h-[calc(100vh-4rem)] flex flex-col p-4 sm:p-6",children:e.jsx(Je,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(vs,{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(vs,{className:"w-10 h-10"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(vs,{className:"h-8 w-2/3"}),e.jsx(vs,{className:"h-4 w-full"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(vs,{className:"h-4 w-24"}),e.jsx(vs,{className:"h-4 w-32"}),e.jsx(vs,{className:"h-4 w-28"}),e.jsx(vs,{className:"h-4 w-20"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(vs,{className:"h-6 w-20"}),e.jsx(vs,{className:"h-6 w-24"}),e.jsx(vs,{className:"h-6 w-16"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-[160px]",children:[e.jsx(vs,{className:"h-10 w-full"}),e.jsx(vs,{className:"h-10 w-full"})]})]}),e.jsx(vs,{className:"h-px w-full"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(vs,{className:"h-24"}),e.jsx(vs,{className:"h-24"}),e.jsx(vs,{className:"h-24"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(vs,{className:"h-10 w-32"}),e.jsx(vs,{className:"h-10 w-32"}),e.jsx(vs,{className:"h-10 w-32"})]}),e.jsx(vs,{className:"h-96 w-full"})]})]})})})}function T3(){const l=ca(),[n,i]=d.useState(!0);return d.useEffect(()=>{let c=!1;return(async()=>{try{const x=await ac();!c&&!x&&l({to:"/auth"})}catch{c||l({to:"/auth"})}finally{c||i(!1)}})(),()=>{c=!0}},[l]),{checking:n}}async function E3(){return await ac()}const M3=Qr("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"}}),sb=d.forwardRef(({className:l,size:n,abbrTitle:i,children:c,...u},x)=>e.jsx("kbd",{className:P(M3({size:n,className:l})),ref:x,...u,children:i?e.jsx("abbr",{title:i,children:c}):c}));sb.displayName="Kbd";const z3=[{icon:Zo,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:Ca,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:Dl,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:Vj,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:Xo,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:za,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:qj,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:Vr,title:"黑话管理",description:"管理麦麦学习到的黑话和俚语",path:"/resource/jargon",category:"资源"},{icon:b_,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:ra,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:Ym,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:pn,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function A3({open:l,onOpenChange:n}){const[i,c]=d.useState(""),[u,x]=d.useState(0),h=ca(),f=z3.filter(N=>N.title.toLowerCase().includes(i.toLowerCase())||N.description.toLowerCase().includes(i.toLowerCase())||N.category.toLowerCase().includes(i.toLowerCase())),p=d.useCallback(N=>{h({to:N}),n(!1),c(""),x(0)},[h,n]),g=d.useCallback(N=>{N.key==="ArrowDown"?(N.preventDefault(),x(v=>(v+1)%f.length)):N.key==="ArrowUp"?(N.preventDefault(),x(v=>(v-1+f.length)%f.length)):N.key==="Enter"&&f[u]&&(N.preventDefault(),p(f[u].path))},[f,u,p]);return e.jsx(Is,{open:l,onOpenChange:n,children:e.jsxs(Os,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(Ds,{className:"px-4 pt-4 pb-0",children:[e.jsx(Rs,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(Tt,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(ae,{value:i,onChange:N=>{c(N.target.value),x(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(Je,{className:"h-[400px]",children:f.length>0?e.jsx("div",{className:"p-2",children:f.map((N,v)=>{const b=N.icon;return e.jsxs("button",{onClick:()=>p(N.path),onMouseEnter:()=>x(v),className:P("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",v===u?"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(Tt,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"未找到匹配的页面":"输入关键词开始搜索"})]})})}),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 O3(){const l=window.location.protocol==="http:",n=window.location.hostname.toLowerCase(),i=n==="localhost"||n==="127.0.0.1"||n==="::1",c=sessionStorage.getItem("http-warning-dismissed")==="true",[u,x]=d.useState(l&&!i&&!c),[h,f]=d.useState(!1),p=()=>{f(!0),x(!1),sessionStorage.setItem("http-warning-dismissed","true")};return!u||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(Jt,{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(Ea,{className:"h-4 w-4"})})]})})})}function D3(){const[l,n]=d.useState(0),[i,c]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{const g=N=>{const v=N.target;if(v.scrollHeight>v.clientHeight+100){u.current=v;const b=v.scrollTop,w=v.scrollHeight-v.clientHeight,y=w>0?b/w*100:0;n(y),c(b>300)}};return window.addEventListener("scroll",g,{capture:!0,passive:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})},[]);const x=()=>{u.current?.scrollTo({top:0,behavior:"smooth"})},h=18,f=2*Math.PI*h,p=f-l/100*f;return e.jsx("div",{className:P("fixed bottom-24 right-8 z-50 transition-all duration-500 ease-in-out transform",i?"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:x,"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(y_,{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"})]})})}const R3=Pw,L3=Hw,U3=Fw,tb=d.forwardRef(({className:l,sideOffset:n=4,...i},c)=>e.jsx(Iw,{children:e.jsx(Cj,{ref:c,sideOffset:n,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]",l),...i})}));tb.displayName=Cj.displayName;function $3({children:l}){const{checking:n}=T3(),[i,c]=d.useState(!0),[u,x]=d.useState(!1),[h,f]=d.useState(!1),[p,g]=d.useState(!1),{theme:N,setTheme:v}=ax(),b=w0();if(d.useEffect(()=>{if(i)g(!1);else{const S=setTimeout(()=>{g(!0)},350);return()=>clearTimeout(S)}},[i]),d.useEffect(()=>{const S=B=>{(B.metaKey||B.ctrlKey)&&B.key==="k"&&(B.preventDefault(),f(!0))};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[]),n)return e.jsx("div",{className:"flex h-screen items-center justify-center bg-background",children:e.jsx("div",{className:"text-muted-foreground",children:"正在验证登录状态..."})});const w=[{title:"概览",items:[{icon:Zo,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:Ca,label:"麦麦主程序配置",path:"/config/bot"},{icon:Dl,label:"AI模型厂商配置",path:"/config/modelProvider",tourId:"sidebar-model-provider"},{icon:Vj,label:"模型管理与分配",path:"/config/model",tourId:"sidebar-model-management"},{icon:mg,label:"麦麦适配器配置",path:"/config/adapter"}]},{title:"麦麦资源管理",items:[{icon:Xo,label:"表情包管理",path:"/resource/emoji"},{icon:za,label:"表达方式管理",path:"/resource/expression"},{icon:Vr,label:"黑话管理",path:"/resource/jargon"},{icon:qj,label:"人物信息管理",path:"/resource/person"},{icon:Pj,label:"知识库图谱可视化",path:"/resource/knowledge-graph"},{icon:Gr,label:"麦麦知识库管理",path:"/resource/knowledge-base"}]},{title:"扩展与监控",items:[{icon:ra,label:"插件市场",path:"/plugins"},{icon:Fj,label:"配置模板市场",path:"/config/pack-market"},{icon:mg,label:"插件配置",path:"/plugin-config"},{icon:Ym,label:"日志查看器",path:"/logs"},{icon:Vm,label:"计划器&回复器监控",path:"/planner-monitor"},{icon:za,label:"本地聊天室",path:"/chat"}]},{title:"系统",items:[{icon:pn,label:"系统设置",path:"/settings"}]}],R=N==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":N,O=async()=>{await l1()};return e.jsx(R3,{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",i?"lg:w-64":"lg:w-16",u?"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",!i&&"lg:flex-none lg:w-8"),children:[e.jsxs("div",{className:P("flex items-baseline gap-2",!i&&"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:B1()})]}),!i&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx(Je,{className:P("flex-1 overflow-x-hidden",!i&&"lg:w-16"),children:e.jsx("nav",{className:P("p-4",!i&&"lg:p-2 lg:w-16"),children:e.jsx("ul",{className:P("space-y-6",!i&&"lg:space-y-3 lg:w-full"),children:w.map((S,B)=>e.jsxs("li",{children:[e.jsx("div",{className:P("px-3 h-[1.25rem]","mb-2",!i&&"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})}),!i&&B>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}),z=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",i?"gap-3":"gap-3 lg:gap-0"),children:[e.jsx(z,{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",i?"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(L3,{children:[e.jsx(U3,{asChild:!0,children:e.jsx(Bn,{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",i?"px-3":"px-3 lg:px-0 lg:justify-center lg:w-12 lg:mx-auto"),onClick:()=>x(!1),children:H})}),p&&e.jsx(tb,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:E.label})})]})},E.path)})})]},S.title))})})})]}),u&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>x(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(O3,{}),e.jsxs("header",{className:"flex h-16 items-center justify-between border-b bg-card/80 backdrop-blur-md px-4 sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>x(!u),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(w_,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>c(!i),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:i?"收起侧边栏":"展开侧边栏",children:e.jsx(Aa,{className:P("h-5 w-5 transition-transform",!i&&"rotate-180")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bn,{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(__,{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(Tt,{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(sb,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(A3,{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(S_,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:S=>{D1(R==="dark"?"light":"dark",v,S)},className:"rounded-lg p-2 hover:bg-accent",title:R==="dark"?"切换到浅色模式":"切换到深色模式",children:R==="dark"?e.jsx(Km,{className:"h-5 w-5"}):e.jsx(Yi,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(_,{variant:"ghost",size:"sm",onClick:O,className:"gap-2",title:"登出系统",children:[e.jsx(k_,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:l}),e.jsx(D3,{})]})]})})}function B3(l){const n=l.split(`
|
||
`).slice(1),i=[];for(const c of n){const u=c.trim();if(!u.startsWith("at "))continue;const x=u.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);x?i.push({functionName:x[1]||"<anonymous>",fileName:x[2],lineNumber:x[3],columnNumber:x[4],raw:u}):i.push({functionName:"<unknown>",fileName:"",lineNumber:"",columnNumber:"",raw:u})}return i}function I3({error:l,errorInfo:n}){const[i,c]=d.useState(!0),[u,x]=d.useState(!1),[h,f]=d.useState(!1),p=l.stack?B3(l.stack):[],g=async()=>{const N=`
|
||
Error: ${l.name}
|
||
Message: ${l.message}
|
||
|
||
Stack Trace:
|
||
${l.stack||"No stack trace available"}
|
||
|
||
Component Stack:
|
||
${n?.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(v){console.error("Failed to copy:",v)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(at,{variant:"destructive",className:"border-red-500/50 bg-red-500/10",children:[e.jsx(Jt,{className:"h-4 w-4"}),e.jsxs(lt,{className:"font-mono text-sm",children:[e.jsxs("span",{className:"font-semibold",children:[l.name,":"]})," ",l.message]})]}),p.length>0&&e.jsxs(rc,{open:i,onOpenChange:c,children:[e.jsx(ic,{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)"]}),i?e.jsx(Fr,{className:"h-4 w-4"}):e.jsx(Ma,{className:"h-4 w-4"})]})}),e.jsx(cc,{children:e.jsx(Je,{className:"h-[280px] rounded-md border bg-muted/30",children:e.jsx("div",{className:"p-3 space-y-1",children:p.map((N,v)=>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:[v+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]})]})]})]})},v))})})})]}),n?.componentStack&&e.jsxs(rc,{open:u,onOpenChange:x,children:[e.jsx(ic,{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(Jt,{className:"h-4 w-4"}),"Component Stack"]}),u?e.jsx(Fr,{className:"h-4 w-4"}):e.jsx(Ma,{className:"h-4 w-4"})]})}),e.jsx(cc,{children:e.jsx(Je,{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:n.componentStack})})})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:g,className:"w-full",children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ct,{className:"mr-2 h-4 w-4 text-green-500"}),"已复制到剪贴板"]}):e.jsxs(e.Fragment,{children:[e.jsx(Uo,{className:"mr-2 h-4 w-4"}),"复制错误信息"]})})]})}function ab({error:l,errorInfo:n}){const i=()=>{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(Ce,{className:"w-full max-w-2xl shadow-lg",children:[e.jsxs(De,{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(Jt,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),e.jsx(Re,{className:"text-2xl font-bold",children:"页面出现了问题"}),e.jsx(os,{className:"text-base mt-2",children:"应用程序遇到了意外错误。您可以尝试刷新页面或返回首页。"})]}),e.jsxs(Me,{className:"space-y-4",children:[e.jsx(I3,{error:l,errorInfo:n}),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:i,variant:"outline",className:"flex-1",children:[e.jsx(Zo,{className:"mr-2 h-4 w-4"}),"返回首页"]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground pt-2",children:"如果问题持续存在,请将错误信息复制并反馈给开发者"})]})]})})}class P3 extends d.Component{constructor(n){super(n),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){console.error("ErrorBoundary caught an error:",n,i),this.setState({errorInfo:i})}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(ab,{error:this.state.error,errorInfo:this.state.errorInfo}):this.props.children}}function lb({error:l}){return e.jsx(ab,{error:l,errorInfo:null})}const hc=_0({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(Pg,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!E3())throw k0({to:"/auth"})}}),H3=Qs({getParentRoute:()=>hc,path:"/auth",component:s2}),F3=Qs({getParentRoute:()=>hc,path:"/setup",component:g2}),nt=Qs({getParentRoute:()=>hc,id:"protected",component:()=>e.jsx($3,{children:e.jsx(Pg,{})}),errorComponent:({error:l})=>e.jsx(lb,{error:l})}),G3=Qs({getParentRoute:()=>nt,path:"/",component:M1}),V3=Qs({getParentRoute:()=>nt,path:"/config/bot",component:Y2}),q3=Qs({getParentRoute:()=>nt,path:"/config/modelProvider",component:iS}),K3=Qs({getParentRoute:()=>nt,path:"/config/model",component:AS}),Q3=Qs({getParentRoute:()=>nt,path:"/config/adapter",component:e4}),Y3=Qs({getParentRoute:()=>nt,path:"/resource/emoji",component:w4}),J3=Qs({getParentRoute:()=>nt,path:"/resource/expression",component:C4}),X3=Qs({getParentRoute:()=>nt,path:"/resource/person",component:X4}),Z3=Qs({getParentRoute:()=>nt,path:"/resource/jargon",component:P4}),W3=Qs({getParentRoute:()=>nt,path:"/resource/knowledge-graph",component:rk}),e5=Qs({getParentRoute:()=>nt,path:"/resource/knowledge-base",component:ik}),s5=Qs({getParentRoute:()=>nt,path:"/logs",component:ok}),t5=Qs({getParentRoute:()=>nt,path:"/planner-monitor",component:jk}),a5=Qs({getParentRoute:()=>nt,path:"/chat",component:aC}),l5=Qs({getParentRoute:()=>nt,path:"/plugins",component:$k}),n5=Qs({getParentRoute:()=>nt,path:"/plugin-detail",component:Qk}),r5=Qs({getParentRoute:()=>nt,path:"/model-presets",component:Ik}),i5=Qs({getParentRoute:()=>nt,path:"/plugin-config",component:Fk}),c5=Qs({getParentRoute:()=>nt,path:"/plugin-mirrors",component:Vk}),o5=Qs({getParentRoute:()=>nt,path:"/settings",component:Q1}),d5=Qs({getParentRoute:()=>nt,path:"/config/pack-market",component:o3}),nb=Qs({getParentRoute:()=>nt,path:"/config/pack-market/$packId",component:S3}),u5=Qs({getParentRoute:()=>nt,path:"/survey/webui-feedback",component:vC}),m5=Qs({getParentRoute:()=>nt,path:"/survey/maibot-feedback",component:NC}),x5=Qs({getParentRoute:()=>nt,path:"/annual-report",component:OC}),h5=Qs({getParentRoute:()=>hc,path:"*",component:bv}),f5=hc.addChildren([H3,F3,nt.addChildren([G3,V3,q3,K3,Q3,Y3,J3,Z3,X3,W3,e5,l5,n5,r5,i5,c5,s5,t5,a5,o5,d5,nb,u5,m5,x5]),h5]),p5=S0({routeTree:f5,defaultNotFoundComponent:bv,defaultErrorComponent:({error:l})=>e.jsx(lb,{error:l})});function g5({children:l,defaultTheme:n="system",storageKey:i="ui-theme",...c}){const[u,x]=d.useState(()=>localStorage.getItem(i)||n);d.useEffect(()=>{const f=window.document.documentElement;if(f.classList.remove("light","dark"),u==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(p);return}f.classList.add(u)},[u]),d.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:u,setTheme:f=>{localStorage.setItem(i,f),x(f)}};return e.jsx(pv.Provider,{...c,value:h,children:l})}function j5({children:l,defaultEnabled:n=!0,defaultWavesEnabled:i=!0,storageKey:c="enable-animations",wavesStorageKey:u="enable-waves-background"}){const[x,h]=d.useState(()=>{const N=localStorage.getItem(c);return N!==null?N==="true":n}),[f,p]=d.useState(()=>{const N=localStorage.getItem(u);return N!==null?N==="true":i});d.useEffect(()=>{const N=document.documentElement;x?N.classList.remove("no-animations"):N.classList.add("no-animations"),localStorage.setItem(c,String(x))},[x,c]),d.useEffect(()=>{localStorage.setItem(u,String(f))},[f,u]);const g={enableAnimations:x,setEnableAnimations:h,enableWavesBackground:f,setEnableWavesBackground:p};return e.jsx(gv.Provider,{value:g,children:l})}const v5=Gw,rb=d.forwardRef(({className:l,...n},i)=>e.jsx(Tj,{ref:i,className:P("fixed bottom-0 right-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:max-w-[420px] gap-2",l),...n}));rb.displayName=Tj.displayName;const N5=Qr("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-slide-in-from-right data-[state=open]:animate-fade-in data-[state=closed]:animate-slide-out-to-right data-[state=closed]:animate-fade-out data-[swipe=end]:animate-slide-out-to-right",{variants:{variant:{default:"border bg-primary/5 text-foreground backdrop-blur-sm",destructive:"destructive group border-destructive bg-destructive/10 text-destructive-foreground backdrop-blur-sm"}},defaultVariants:{variant:"default"}}),ib=d.forwardRef(({className:l,variant:n,...i},c)=>e.jsx(Ej,{ref:c,className:P(N5({variant:n}),l),...i}));ib.displayName=Ej.displayName;const b5=d.forwardRef(({className:l,...n},i)=>e.jsx(Mj,{ref:i,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",l),...n}));b5.displayName=Mj.displayName;const cb=d.forwardRef(({className:l,...n},i)=>e.jsx(zj,{ref:i,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",l),"toast-close":"",...n,children:e.jsx(Ea,{className:"h-4 w-4"})}));cb.displayName=zj.displayName;const ob=d.forwardRef(({className:l,...n},i)=>e.jsx(Aj,{ref:i,className:P("text-sm font-semibold [&+div]:text-xs",l),...n}));ob.displayName=Aj.displayName;const db=d.forwardRef(({className:l,...n},i)=>e.jsx(Oj,{ref:i,className:P("text-sm opacity-90",l),...n}));db.displayName=Oj.displayName;function y5(){const{toasts:l}=Zs();return e.jsxs(v5,{children:[l.map(function({id:n,title:i,description:c,action:u,...x}){return e.jsxs(ib,{...x,children:[e.jsxs("div",{className:"grid gap-1",children:[i&&e.jsx(ob,{children:i}),c&&e.jsx(db,{children:c})]}),u,e.jsx(cb,{})]},n)}),e.jsx(rb,{})]})}a1.createRoot(document.getElementById("root")).render(e.jsx(d.StrictMode,{children:e.jsx(P3,{children:e.jsx(g5,{defaultTheme:"system",children:e.jsx(j5,{children:e.jsxs(sS,{children:[e.jsx(C0,{router:p5}),e.jsx(lS,{}),e.jsx(y5,{})]})})})})}));
|