import{r as x,j as e,u as qn,R as Ne,d as K_,L as Q_,e as Z_,f as Ts,g as J_,h as e2,O as ry,b as t2,k as s2}from"./router-BWgTyY51.js";import{a as n2,b as a2}from"./react-vendor-Dtc2IqVY.js";import{c as iy,R as l2,T as r2,L as i2,a as o2,C as Xc,X as Kc,Y as Ii,b as c2,B as uf,d as Qc,P as d2,e as u2,f as m2}from"./charts-DU5SeejN.js";import{c as Dn,a as _d,u as jn,P as dt,b as be,d as Tt,e as xo,f as Qa,g as ws,h as Is,i as oy,j as rh,k as ih,S as f2,l as cy,m as dy,R as uy,O as Cd,n as oh,C as kd,o as ch,T as dh,D as uh,p as mh,q as my,r as fy,W as h2,s as hy,I as x2,t as xy,v as py,w as p2,x as gy,V as g2,L as vy,y as jy,z as v2,A as j2,B as yy,E as y2,F as b2,G as Ga,H as Td,J as Wr,K as by,M as Ny,N as wy,Q as Sy,U as fh,X as hh,Y as Ed,Z as Md,_ as xh,$ as _y,a0 as N2,a1 as Cy,a2 as w2,a3 as S2,a4 as ky,a5 as _2}from"./ui-vendor-nTGLnMlb.js";import{R as xa,A as C2,D as k2,a as T2,Z as ao,C as _l,M as po,T as E2,X as go,P as Ty,S as M2,b as Tn,I as Fr,c as Lr,d as Cl,e as Df,E as Of,f as Mn,g as Ys,h as Af,i as D2,j as Rf,k as zf,L as Zv,K as O2,l as Tl,m as A2,n as R2,F as ph,o as z2,B as P2,U as Ey,p as gh,q as L2,r as B2,s as Gs,H as fd,t as My,u as lo,v as Pf,w as ro,x as vh,y as jh,z as ys,G as ft,J as hd,N as Yr,O as vo,Q as Ol,V as Al,W as jo,Y as U2,_ as Lf,$ as qr,a0 as Jv,a1 as xd,a2 as H2,a3 as ej,a4 as F2,a5 as Y2,a6 as Bf,a7 as q2,a8 as tj,a9 as so,aa as pd,ab as Dy,ac as Oy,ad as Ay,ae as V2,af as G2,ag as $2,ah as I2,ai as W2,aj as sj,ak as X2}from"./icons-DnP4c9nr.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function l(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function i(c){if(c.ep)return;c.ep=!0;const d=l(c);fetch(c.href,d)}})();var mf={exports:{}},Wi={},ff={exports:{}},hf={};var nj;function K2(){return nj||(nj=1,(function(s){function a(R,O){var L=R.length;R.push(O);e:for(;0>>1,le=R[ee];if(0>>1;eec(W,L))fec(I,W)?(R[ee]=I,R[fe]=L,ee=fe):(R[ee]=W,R[F]=L,ee=F);else if(fec(I,L))R[ee]=I,R[fe]=L,ee=fe;else break e}}return O}function c(R,O){var L=R.sortIndex-O.sortIndex;return L!==0?L:R.id-O.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;s.unstable_now=function(){return d.now()}}else{var m=Date,h=m.now();s.unstable_now=function(){return m.now()-h}}var p=[],v=[],g=1,j=null,b=3,w=!1,S=!1,C=!1,N=!1,T=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function k(R){for(var O=l(v);O!==null;){if(O.callback===null)i(v);else if(O.startTime<=R)i(v),O.sortIndex=O.expirationTime,a(p,O);else break;O=l(v)}}function D(R){if(C=!1,k(R),!S)if(l(p)!==null)S=!0,A||(A=!0,oe());else{var O=l(v);O!==null&&me(D,O.startTime-R)}}var A=!1,E=-1,B=5,Y=-1;function G(){return N?!0:!(s.unstable_now()-YR&&G());){var ee=j.callback;if(typeof ee=="function"){j.callback=null,b=j.priorityLevel;var le=ee(j.expirationTime<=R);if(R=s.unstable_now(),typeof le=="function"){j.callback=le,k(R),O=!0;break t}j===l(p)&&i(p),k(R)}else i(p);j=l(p)}if(j!==null)O=!0;else{var xe=l(v);xe!==null&&me(D,xe.startTime-R),O=!1}}break e}finally{j=null,b=L,w=!1}O=void 0}}finally{O?oe():A=!1}}}var oe;if(typeof M=="function")oe=function(){M($)};else if(typeof MessageChannel<"u"){var je=new MessageChannel,ae=je.port2;je.port1.onmessage=$,oe=function(){ae.postMessage(null)}}else oe=function(){T($,0)};function me(R,O){E=T(function(){R(s.unstable_now())},O)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(R){R.callback=null},s.unstable_forceFrameRate=function(R){0>R||125ee?(R.sortIndex=L,a(v,R),l(p)===null&&R===l(v)&&(C?(P(E),E=-1):C=!0,me(D,L-ee))):(R.sortIndex=le,a(p,R),S||w||(S=!0,A||(A=!0,oe()))),R},s.unstable_shouldYield=G,s.unstable_wrapCallback=function(R){var O=b;return function(){var L=b;b=O;try{return R.apply(this,arguments)}finally{b=L}}}})(hf)),hf}var aj;function Q2(){return aj||(aj=1,ff.exports=K2()),ff.exports}var lj;function Z2(){if(lj)return Wi;lj=1;var s=Q2(),a=n2(),l=a2();function i(t){var n="https://react.dev/errors/"+t;if(1le||(t.current=ee[le],ee[le]=null,le--)}function W(t,n){le++,ee[le]=t.current,t.current=n}var fe=xe(null),I=xe(null),ve=xe(null),de=xe(null);function Ce(t,n){switch(W(ve,n),W(I,t),W(fe,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?bv(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=bv(n),t=Nv(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}F(fe),W(fe,t)}function Q(){F(fe),F(I),F(ve)}function Oe(t){t.memoizedState!==null&&W(de,t);var n=fe.current,r=Nv(n,t.type);n!==r&&(W(I,t),W(fe,r))}function $e(t){I.current===t&&(F(fe),F(I)),de.current===t&&(F(de),qi._currentValue=L)}var re,Pe;function ze(t){if(re===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);re=n&&n[1]||"",Pe=-1)":-1u||z[o]!==K[u]){var ie=` `+z[o].replace(" at new "," at ");return t.displayName&&ie.includes("")&&(ie=ie.replace("",t.displayName)),ie}while(1<=o&&0<=u);break}}}finally{Zt=!1,Error.prepareStackTrace=r}return(r=t?t.displayName||t.name:"")?ze(r):""}function An(t,n){switch(t.tag){case 26:case 27:case 5:return ze(t.type);case 16:return ze("Lazy");case 13:return t.child!==n&&n!==null?ze("Suspense Fallback"):ze("Suspense");case 19:return ze("SuspenseList");case 0:case 15:return Rs(t.type,!1);case 11:return Rs(t.type.render,!1);case 1:return Rs(t.type,!0);case 31:return ze("Activity");default:return""}}function Le(t){try{var n="",r=null;do n+=An(t,r),r=t,t=t.return;while(t);return n}catch(o){return` Error generating stack: `+o.message+` `+o.stack}}var Nn=Object.prototype.hasOwnProperty,ln=s.unstable_scheduleCallback,rn=s.unstable_cancelCallback,Xt=s.unstable_shouldYield,Ds=s.unstable_requestPaint,ke=s.unstable_now,is=s.unstable_getCurrentPriorityLevel,he=s.unstable_ImmediatePriority,Ee=s.unstable_UserBlockingPriority,Ve=s.unstable_NormalPriority,Os=s.unstable_LowPriority,$n=s.unstable_IdlePriority,Hl=s.log,Fl=s.unstable_setDisableYieldValue,se=null,ge=null;function Qe(t){if(typeof Hl=="function"&&Fl(t),ge&&typeof ge.setStrictMode=="function")try{ge.setStrictMode(se,t)}catch{}}var pt=Math.clz32?Math.clz32:Mt,tl=Math.log,We=Math.LN2;function Mt(t){return t>>>=0,t===0?32:31-(tl(t)/We|0)|0}var Be=256,ht=262144,os=4194304;function Xe(t){var n=t&42;if(n!==0)return n;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Yl(t,n,r){var o=t.pendingLanes;if(o===0)return 0;var u=0,f=t.suspendedLanes,y=t.pingedLanes;t=t.warmLanes;var _=o&134217727;return _!==0?(o=_&~f,o!==0?u=Xe(o):(y&=_,y!==0?u=Xe(y):r||(r=_&~t,r!==0&&(u=Xe(r))))):(_=o&~f,_!==0?u=Xe(_):y!==0?u=Xe(y):r||(r=o&~t,r!==0&&(u=Xe(r)))),u===0?0:n!==0&&n!==u&&(n&f)===0&&(f=u&-u,r=n&-n,f>=r||f===32&&(r&4194048)!==0)?n:u}function sl(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function Zd(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 ql(){var t=os;return os<<=1,(os&62914560)===0&&(os=4194304),t}function nl(t){for(var n=[],r=0;31>r;r++)n.push(t);return n}function ni(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function B1(t,n,r,o,u,f){var y=t.pendingLanes;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=r,t.entangledLanes&=r,t.errorRecoveryDisabledLanes&=r,t.shellSuspendCounter=0;var _=t.entanglements,z=t.expirationTimes,K=t.hiddenUpdates;for(r=y&~r;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var V1=/[\n"\\]/g;function cn(t){return t.replace(V1,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function au(t,n,r,o,u,f,y,_){t.name="",y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?t.type=y:t.removeAttribute("type"),n!=null?y==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+on(n)):t.value!==""+on(n)&&(t.value=""+on(n)):y!=="submit"&&y!=="reset"||t.removeAttribute("value"),n!=null?lu(t,y,on(n)):r!=null?lu(t,y,on(r)):o!=null&&t.removeAttribute("value"),u==null&&f!=null&&(t.defaultChecked=!!f),u!=null&&(t.checked=u&&typeof u!="function"&&typeof u!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?t.name=""+on(_):t.removeAttribute("name")}function xx(t,n,r,o,u,f,y,_){if(f!=null&&typeof f!="function"&&typeof f!="symbol"&&typeof f!="boolean"&&(t.type=f),n!=null||r!=null){if(!(f!=="submit"&&f!=="reset"||n!=null)){nu(t);return}r=r!=null?""+on(r):"",n=n!=null?""+on(n):r,_||n===t.value||(t.value=n),t.defaultValue=n}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,t.checked=_?t.checked:!!o,t.defaultChecked=!!o,y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.name=y),nu(t)}function lu(t,n,r){n==="number"&&Uo(t.ownerDocument)===t||t.defaultValue===""+r||(t.defaultValue=""+r)}function Xl(t,n,r,o){if(t=t.options,n){n={};for(var u=0;u"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),du=!1;if(Xn)try{var ii={};Object.defineProperty(ii,"passive",{get:function(){du=!0}}),window.addEventListener("test",ii,ii),window.removeEventListener("test",ii,ii)}catch{du=!1}var ya=null,uu=null,Fo=null;function Nx(){if(Fo)return Fo;var t,n=uu,r=n.length,o,u="value"in ya?ya.value:ya.textContent,f=u.length;for(t=0;t=di),Tx=" ",Ex=!1;function Mx(t,n){switch(t){case"keyup":return vS.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dx(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Jl=!1;function yS(t,n){switch(t){case"compositionend":return Dx(n);case"keypress":return n.which!==32?null:(Ex=!0,Tx);case"textInput":return t=n.data,t===Tx&&Ex?null:t;default:return null}}function bS(t,n){if(Jl)return t==="compositionend"||!pu&&Mx(t,n)?(t=Nx(),Fo=uu=ya=null,Jl=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:r,offset:n-t};t=o}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Ux(r)}}function Fx(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Fx(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Yx(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=Uo(t.document);n instanceof t.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)t=n.contentWindow;else break;n=Uo(t.document)}return n}function ju(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var ES=Xn&&"documentMode"in document&&11>=document.documentMode,er=null,yu=null,hi=null,bu=!1;function qx(t,n,r){var o=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;bu||er==null||er!==Uo(o)||(o=er,"selectionStart"in o&&ju(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),hi&&fi(hi,o)||(hi=o,o=Rc(yu,"onSelect"),0>=y,u-=y,Rn=1<<32-pt(n)+u|r<Ge?(st=Te,Te=null):st=Te.sibling;var mt=J(V,Te,X[Ge],ce);if(mt===null){Te===null&&(Te=st);break}t&&Te&&mt.alternate===null&&n(V,Te),H=f(mt,H,Ge),ut===null?De=mt:ut.sibling=mt,ut=mt,Te=st}if(Ge===X.length)return r(V,Te),nt&&Qn(V,Ge),De;if(Te===null){for(;GeGe?(st=Te,Te=null):st=Te.sibling;var Ya=J(V,Te,mt.value,ce);if(Ya===null){Te===null&&(Te=st);break}t&&Te&&Ya.alternate===null&&n(V,Te),H=f(Ya,H,Ge),ut===null?De=Ya:ut.sibling=Ya,ut=Ya,Te=st}if(mt.done)return r(V,Te),nt&&Qn(V,Ge),De;if(Te===null){for(;!mt.done;Ge++,mt=X.next())mt=ue(V,mt.value,ce),mt!==null&&(H=f(mt,H,Ge),ut===null?De=mt:ut.sibling=mt,ut=mt);return nt&&Qn(V,Ge),De}for(Te=o(Te);!mt.done;Ge++,mt=X.next())mt=ne(Te,V,Ge,mt.value,ce),mt!==null&&(t&&mt.alternate!==null&&Te.delete(mt.key===null?Ge:mt.key),H=f(mt,H,Ge),ut===null?De=mt:ut.sibling=mt,ut=mt);return t&&Te.forEach(function(X_){return n(V,X_)}),nt&&Qn(V,Ge),De}function St(V,H,X,ce){if(typeof X=="object"&&X!==null&&X.type===C&&X.key===null&&(X=X.props.children),typeof X=="object"&&X!==null){switch(X.$$typeof){case w:e:{for(var De=X.key;H!==null;){if(H.key===De){if(De=X.type,De===C){if(H.tag===7){r(V,H.sibling),ce=u(H,X.props.children),ce.return=V,V=ce;break e}}else if(H.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===B&&hl(De)===H.type){r(V,H.sibling),ce=u(H,X.props),yi(ce,X),ce.return=V,V=ce;break e}r(V,H);break}else n(V,H);H=H.sibling}X.type===C?(ce=cl(X.props.children,V.mode,ce,X.key),ce.return=V,V=ce):(ce=Qo(X.type,X.key,X.props,null,V.mode,ce),yi(ce,X),ce.return=V,V=ce)}return y(V);case S:e:{for(De=X.key;H!==null;){if(H.key===De)if(H.tag===4&&H.stateNode.containerInfo===X.containerInfo&&H.stateNode.implementation===X.implementation){r(V,H.sibling),ce=u(H,X.children||[]),ce.return=V,V=ce;break e}else{r(V,H);break}else n(V,H);H=H.sibling}ce=Tu(X,V.mode,ce),ce.return=V,V=ce}return y(V);case B:return X=hl(X),St(V,H,X,ce)}if(me(X))return we(V,H,X,ce);if(oe(X)){if(De=oe(X),typeof De!="function")throw Error(i(150));return X=De.call(X),Re(V,H,X,ce)}if(typeof X.then=="function")return St(V,H,ac(X),ce);if(X.$$typeof===M)return St(V,H,ec(V,X),ce);lc(V,X)}return typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint"?(X=""+X,H!==null&&H.tag===6?(r(V,H.sibling),ce=u(H,X),ce.return=V,V=ce):(r(V,H),ce=ku(X,V.mode,ce),ce.return=V,V=ce),y(V)):r(V,H)}return function(V,H,X,ce){try{ji=0;var De=St(V,H,X,ce);return ur=null,De}catch(Te){if(Te===dr||Te===sc)throw Te;var ut=Ks(29,Te,null,V.mode);return ut.lanes=ce,ut.return=V,ut}finally{}}}var pl=mp(!0),fp=mp(!1),_a=!1;function Hu(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Fu(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Ca(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function ka(t,n,r){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(xt&2)!==0){var u=o.pending;return u===null?n.next=n:(n.next=u.next,u.next=n),o.pending=n,n=Ko(t),Kx(t,null,r),n}return Xo(t,o,n,r),Ko(t)}function bi(t,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var o=n.lanes;o&=t.pendingLanes,r|=o,n.lanes=r,ax(t,r)}}function Yu(t,n){var r=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,r===o)){var u=null,f=null;if(r=r.firstBaseUpdate,r!==null){do{var y={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};f===null?u=f=y:f=f.next=y,r=r.next}while(r!==null);f===null?u=f=n:f=f.next=n}else u=f=n;r={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:f,shared:o.shared,callbacks:o.callbacks},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=n:t.next=n,r.lastBaseUpdate=n}var qu=!1;function Ni(){if(qu){var t=cr;if(t!==null)throw t}}function wi(t,n,r,o){qu=!1;var u=t.updateQueue;_a=!1;var f=u.firstBaseUpdate,y=u.lastBaseUpdate,_=u.shared.pending;if(_!==null){u.shared.pending=null;var z=_,K=z.next;z.next=null,y===null?f=K:y.next=K,y=z;var ie=t.alternate;ie!==null&&(ie=ie.updateQueue,_=ie.lastBaseUpdate,_!==y&&(_===null?ie.firstBaseUpdate=K:_.next=K,ie.lastBaseUpdate=z))}if(f!==null){var ue=u.baseState;y=0,ie=K=z=null,_=f;do{var J=_.lane&-536870913,ne=J!==_.lane;if(ne?(tt&J)===J:(o&J)===J){J!==0&&J===or&&(qu=!0),ie!==null&&(ie=ie.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var we=t,Re=_;J=n;var St=r;switch(Re.tag){case 1:if(we=Re.payload,typeof we=="function"){ue=we.call(St,ue,J);break e}ue=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Re.payload,J=typeof we=="function"?we.call(St,ue,J):we,J==null)break e;ue=j({},ue,J);break e;case 2:_a=!0}}J=_.callback,J!==null&&(t.flags|=64,ne&&(t.flags|=8192),ne=u.callbacks,ne===null?u.callbacks=[J]:ne.push(J))}else ne={lane:J,tag:_.tag,payload:_.payload,callback:_.callback,next:null},ie===null?(K=ie=ne,z=ue):ie=ie.next=ne,y|=J;if(_=_.next,_===null){if(_=u.shared.pending,_===null)break;ne=_,_=ne.next,ne.next=null,u.lastBaseUpdate=ne,u.shared.pending=null}}while(!0);ie===null&&(z=ue),u.baseState=z,u.firstBaseUpdate=K,u.lastBaseUpdate=ie,f===null&&(u.shared.lanes=0),Oa|=y,t.lanes=y,t.memoizedState=ue}}function hp(t,n){if(typeof t!="function")throw Error(i(191,t));t.call(n)}function xp(t,n){var r=t.callbacks;if(r!==null)for(t.callbacks=null,t=0;tf?f:8;var y=R.T,_={};R.T=_,om(t,!1,n,r);try{var z=u(),K=R.S;if(K!==null&&K(_,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var ie=BS(z,o);Ci(t,n,ie,tn(t))}else Ci(t,n,o,tn(t))}catch(ue){Ci(t,n,{then:function(){},status:"rejected",reason:ue},tn())}finally{O.p=f,y!==null&&_.types!==null&&(y.types=_.types),R.T=y}}function VS(){}function rm(t,n,r,o){if(t.tag!==5)throw Error(i(476));var u=Ip(t).queue;$p(t,u,n,L,r===null?VS:function(){return Wp(t),r(o)})}function Ip(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ta,lastRenderedState:L},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ta,lastRenderedState:r},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function Wp(t){var n=Ip(t);n.next===null&&(n=t.alternate.memoizedState),Ci(t,n.next.queue,{},tn())}function im(){return gs(qi)}function Xp(){return Qt().memoizedState}function Kp(){return Qt().memoizedState}function GS(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var r=tn();t=Ca(r);var o=ka(n,t,r);o!==null&&(Fs(o,n,r),bi(o,n,r)),n={cache:Pu()},t.payload=n;return}n=n.return}}function $S(t,n,r){var o=tn();r={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},xc(t)?Zp(n,r):(r=_u(t,n,r,o),r!==null&&(Fs(r,t,o),Jp(r,n,o)))}function Qp(t,n,r){var o=tn();Ci(t,n,r,o)}function Ci(t,n,r,o){var u={lane:o,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(xc(t))Zp(n,u);else{var f=t.alternate;if(t.lanes===0&&(f===null||f.lanes===0)&&(f=n.lastRenderedReducer,f!==null))try{var y=n.lastRenderedState,_=f(y,r);if(u.hasEagerState=!0,u.eagerState=_,Xs(_,y))return Xo(t,n,u,0),Et===null&&Wo(),!1}catch{}finally{}if(r=_u(t,n,u,o),r!==null)return Fs(r,t,o),Jp(r,n,o),!0}return!1}function om(t,n,r,o){if(o={lane:2,revertLane:Hm(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},xc(t)){if(n)throw Error(i(479))}else n=_u(t,r,o,2),n!==null&&Fs(n,t,2)}function xc(t){var n=t.alternate;return t===Ye||n!==null&&n===Ye}function Zp(t,n){fr=oc=!0;var r=t.pending;r===null?n.next=n:(n.next=r.next,r.next=n),t.pending=n}function Jp(t,n,r){if((r&4194048)!==0){var o=n.lanes;o&=t.pendingLanes,r|=o,n.lanes=r,ax(t,r)}}var ki={readContext:gs,use:uc,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useLayoutEffect:It,useInsertionEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useSyncExternalStore:It,useId:It,useHostTransitionStatus:It,useFormState:It,useActionState:It,useOptimistic:It,useMemoCache:It,useCacheRefresh:It};ki.useEffectEvent=It;var eg={readContext:gs,use:uc,useCallback:function(t,n){return As().memoizedState=[t,n===void 0?null:n],t},useContext:gs,useEffect:Lp,useImperativeHandle:function(t,n,r){r=r!=null?r.concat([t]):null,fc(4194308,4,Fp.bind(null,n,t),r)},useLayoutEffect:function(t,n){return fc(4194308,4,t,n)},useInsertionEffect:function(t,n){fc(4,2,t,n)},useMemo:function(t,n){var r=As();n=n===void 0?null:n;var o=t();if(gl){Qe(!0);try{t()}finally{Qe(!1)}}return r.memoizedState=[o,n],o},useReducer:function(t,n,r){var o=As();if(r!==void 0){var u=r(n);if(gl){Qe(!0);try{r(n)}finally{Qe(!1)}}}else u=n;return o.memoizedState=o.baseState=u,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:u},o.queue=t,t=t.dispatch=$S.bind(null,Ye,t),[o.memoizedState,t]},useRef:function(t){var n=As();return t={current:t},n.memoizedState=t},useState:function(t){t=tm(t);var n=t.queue,r=Qp.bind(null,Ye,n);return n.dispatch=r,[t.memoizedState,r]},useDebugValue:am,useDeferredValue:function(t,n){var r=As();return lm(r,t,n)},useTransition:function(){var t=tm(!1);return t=$p.bind(null,Ye,t.queue,!0,!1),As().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,r){var o=Ye,u=As();if(nt){if(r===void 0)throw Error(i(407));r=r()}else{if(r=n(),Et===null)throw Error(i(349));(tt&127)!==0||bp(o,n,r)}u.memoizedState=r;var f={value:r,getSnapshot:n};return u.queue=f,Lp(wp.bind(null,o,f,t),[t]),o.flags|=2048,xr(9,{destroy:void 0},Np.bind(null,o,f,r,n),null),r},useId:function(){var t=As(),n=Et.identifierPrefix;if(nt){var r=zn,o=Rn;r=(o&~(1<<32-pt(o)-1)).toString(32)+r,n="_"+n+"R_"+r,r=cc++,0<\/script>",f=f.removeChild(f.firstChild);break;case"select":f=typeof o.is=="string"?y.createElement("select",{is:o.is}):y.createElement("select"),o.multiple?f.multiple=!0:o.size&&(f.size=o.size);break;default:f=typeof o.is=="string"?y.createElement(u,{is:o.is}):y.createElement(u)}}f[xs]=n,f[zs]=o;e:for(y=n.child;y!==null;){if(y.tag===5||y.tag===6)f.appendChild(y.stateNode);else if(y.tag!==4&&y.tag!==27&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===n)break e;for(;y.sibling===null;){if(y.return===null||y.return===n)break e;y=y.return}y.sibling.return=y.return,y=y.sibling}n.stateNode=f;e:switch(js(f,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&na(n)}}return Ht(n),Nm(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,r),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==o&&na(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(i(166));if(t=ve.current,rr(n)){if(t=n.stateNode,r=n.memoizedProps,o=null,u=ps,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}t[xs]=n,t=!!(t.nodeValue===r||o!==null&&o.suppressHydrationWarning===!0||jv(t.nodeValue,r)),t||wa(n,!0)}else t=zc(t).createTextNode(o),t[xs]=n,n.stateNode=t}return Ht(n),null;case 31:if(r=n.memoizedState,t===null||t.memoizedState!==null){if(o=rr(n),r!==null){if(t===null){if(!o)throw Error(i(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(i(557));t[xs]=n}else dl(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ht(n),t=!1}else r=Ou(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),t=!0;if(!t)return n.flags&256?(Zs(n),n):(Zs(n),null);if((n.flags&128)!==0)throw Error(i(558))}return Ht(n),null;case 13:if(o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(u=rr(n),o!==null&&o.dehydrated!==null){if(t===null){if(!u)throw Error(i(318));if(u=n.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(i(317));u[xs]=n}else dl(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Ht(n),u=!1}else u=Ou(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=u),u=!0;if(!u)return n.flags&256?(Zs(n),n):(Zs(n),null)}return Zs(n),(n.flags&128)!==0?(n.lanes=r,n):(r=o!==null,t=t!==null&&t.memoizedState!==null,r&&(o=n.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),f=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(f=o.memoizedState.cachePool.pool),f!==u&&(o.flags|=2048)),r!==t&&r&&(n.child.flags|=8192),yc(n,n.updateQueue),Ht(n),null);case 4:return Q(),t===null&&Vm(n.stateNode.containerInfo),Ht(n),null;case 10:return Jn(n.type),Ht(n),null;case 19:if(F(Kt),o=n.memoizedState,o===null)return Ht(n),null;if(u=(n.flags&128)!==0,f=o.rendering,f===null)if(u)Ei(o,!1);else{if(Wt!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(f=ic(t),f!==null){for(n.flags|=128,Ei(o,!1),t=f.updateQueue,n.updateQueue=t,yc(n,t),n.subtreeFlags=0,t=r,r=n.child;r!==null;)Qx(r,t),r=r.sibling;return W(Kt,Kt.current&1|2),nt&&Qn(n,o.treeForkCount),n.child}t=t.sibling}o.tail!==null&&ke()>_c&&(n.flags|=128,u=!0,Ei(o,!1),n.lanes=4194304)}else{if(!u)if(t=ic(f),t!==null){if(n.flags|=128,u=!0,t=t.updateQueue,n.updateQueue=t,yc(n,t),Ei(o,!0),o.tail===null&&o.tailMode==="hidden"&&!f.alternate&&!nt)return Ht(n),null}else 2*ke()-o.renderingStartTime>_c&&r!==536870912&&(n.flags|=128,u=!0,Ei(o,!1),n.lanes=4194304);o.isBackwards?(f.sibling=n.child,n.child=f):(t=o.last,t!==null?t.sibling=f:n.child=f,o.last=f)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=ke(),t.sibling=null,r=Kt.current,W(Kt,u?r&1|2:r&1),nt&&Qn(n,o.treeForkCount),t):(Ht(n),null);case 22:case 23:return Zs(n),Gu(),o=n.memoizedState!==null,t!==null?t.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(r&536870912)!==0&&(n.flags&128)===0&&(Ht(n),n.subtreeFlags&6&&(n.flags|=8192)):Ht(n),r=n.updateQueue,r!==null&&yc(n,r.retryQueue),r=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==r&&(n.flags|=2048),t!==null&&F(fl),null;case 24:return r=null,t!==null&&(r=t.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),Jn(Jt),Ht(n),null;case 25:return null;case 30:return null}throw Error(i(156,n.tag))}function QS(t,n){switch(Mu(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return Jn(Jt),Q(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return $e(n),null;case 31:if(n.memoizedState!==null){if(Zs(n),n.alternate===null)throw Error(i(340));dl()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(Zs(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(i(340));dl()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return F(Kt),null;case 4:return Q(),null;case 10:return Jn(n.type),null;case 22:case 23:return Zs(n),Gu(),t!==null&&F(fl),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return Jn(Jt),null;case 25:return null;default:return null}}function Sg(t,n){switch(Mu(n),n.tag){case 3:Jn(Jt),Q();break;case 26:case 27:case 5:$e(n);break;case 4:Q();break;case 31:n.memoizedState!==null&&Zs(n);break;case 13:Zs(n);break;case 19:F(Kt);break;case 10:Jn(n.type);break;case 22:case 23:Zs(n),Gu(),t!==null&&F(fl);break;case 24:Jn(Jt)}}function Mi(t,n){try{var r=n.updateQueue,o=r!==null?r.lastEffect:null;if(o!==null){var u=o.next;r=u;do{if((r.tag&t)===t){o=void 0;var f=r.create,y=r.inst;o=f(),y.destroy=o}r=r.next}while(r!==u)}}catch(_){jt(n,n.return,_)}}function Ma(t,n,r){try{var o=n.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var f=u.next;o=f;do{if((o.tag&t)===t){var y=o.inst,_=y.destroy;if(_!==void 0){y.destroy=void 0,u=n;var z=r,K=_;try{K()}catch(ie){jt(u,z,ie)}}}o=o.next}while(o!==f)}}catch(ie){jt(n,n.return,ie)}}function _g(t){var n=t.updateQueue;if(n!==null){var r=t.stateNode;try{xp(n,r)}catch(o){jt(t,t.return,o)}}}function Cg(t,n,r){r.props=vl(t.type,t.memoizedProps),r.state=t.memoizedState;try{r.componentWillUnmount()}catch(o){jt(t,n,o)}}function Di(t,n){try{var r=t.ref;if(r!==null){switch(t.tag){case 26:case 27:case 5:var o=t.stateNode;break;case 30:o=t.stateNode;break;default:o=t.stateNode}typeof r=="function"?t.refCleanup=r(o):r.current=o}}catch(u){jt(t,n,u)}}function Pn(t,n){var r=t.ref,o=t.refCleanup;if(r!==null)if(typeof o=="function")try{o()}catch(u){jt(t,n,u)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(u){jt(t,n,u)}else r.current=null}function kg(t){var n=t.type,r=t.memoizedProps,o=t.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&o.focus();break e;case"img":r.src?o.src=r.src:r.srcSet&&(o.srcset=r.srcSet)}}catch(u){jt(t,t.return,u)}}function wm(t,n,r){try{var o=t.stateNode;j_(o,t.type,r,n),o[zs]=n}catch(u){jt(t,t.return,u)}}function Tg(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&La(t.type)||t.tag===4}function Sm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Tg(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&La(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function _m(t,n,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(t,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(t),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=Wn));else if(o!==4&&(o===27&&La(t.type)&&(r=t.stateNode,n=null),t=t.child,t!==null))for(_m(t,n,r),t=t.sibling;t!==null;)_m(t,n,r),t=t.sibling}function bc(t,n,r){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?r.insertBefore(t,n):r.appendChild(t);else if(o!==4&&(o===27&&La(t.type)&&(r=t.stateNode),t=t.child,t!==null))for(bc(t,n,r),t=t.sibling;t!==null;)bc(t,n,r),t=t.sibling}function Eg(t){var n=t.stateNode,r=t.memoizedProps;try{for(var o=t.type,u=n.attributes;u.length;)n.removeAttributeNode(u[0]);js(n,o,r),n[xs]=t,n[zs]=r}catch(f){jt(t,t.return,f)}}var aa=!1,ss=!1,Cm=!1,Mg=typeof WeakSet=="function"?WeakSet:Set,ds=null;function ZS(t,n){if(t=t.containerInfo,Im=Yc,t=Yx(t),ju(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var o=r.getSelection&&r.getSelection();if(o&&o.rangeCount!==0){r=o.anchorNode;var u=o.anchorOffset,f=o.focusNode;o=o.focusOffset;try{r.nodeType,f.nodeType}catch{r=null;break e}var y=0,_=-1,z=-1,K=0,ie=0,ue=t,J=null;t:for(;;){for(var ne;ue!==r||u!==0&&ue.nodeType!==3||(_=y+u),ue!==f||o!==0&&ue.nodeType!==3||(z=y+o),ue.nodeType===3&&(y+=ue.nodeValue.length),(ne=ue.firstChild)!==null;)J=ue,ue=ne;for(;;){if(ue===t)break t;if(J===r&&++K===u&&(_=y),J===f&&++ie===o&&(z=y),(ne=ue.nextSibling)!==null)break;ue=J,J=ue.parentNode}ue=ne}r=_===-1||z===-1?null:{start:_,end:z}}else r=null}r=r||{start:0,end:0}}else r=null;for(Wm={focusedElem:t,selectionRange:r},Yc=!1,ds=n;ds!==null;)if(n=ds,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,ds=t;else for(;ds!==null;){switch(n=ds,f=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.updateQueue,t=t!==null?t.events:null,t!==null))for(r=0;r title"))),js(f,o,r),f[xs]=t,cs(f),o=f;break e;case"link":var y=Pv("link","href",u).get(o+(r.href||""));if(y){for(var _=0;_St&&(y=St,St=Re,Re=y);var V=Hx(_,Re),H=Hx(_,St);if(V&&H&&(ne.rangeCount!==1||ne.anchorNode!==V.node||ne.anchorOffset!==V.offset||ne.focusNode!==H.node||ne.focusOffset!==H.offset)){var X=ue.createRange();X.setStart(V.node,V.offset),ne.removeAllRanges(),Re>St?(ne.addRange(X),ne.extend(H.node,H.offset)):(X.setEnd(H.node,H.offset),ne.addRange(X))}}}}for(ue=[],ne=_;ne=ne.parentNode;)ne.nodeType===1&&ue.push({element:ne,left:ne.scrollLeft,top:ne.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_r?32:r,R.T=null,r=Am,Am=null;var f=Ra,y=ca;if(ls=0,yr=Ra=null,ca=0,(xt&6)!==0)throw Error(i(331));var _=xt;if(xt|=4,Fg(f.current),Bg(f,f.current,y,r),xt=_,Li(0,!1),ge&&typeof ge.onPostCommitFiberRoot=="function")try{ge.onPostCommitFiberRoot(se,f)}catch{}return!0}finally{O.p=u,R.T=o,lv(t,n)}}function iv(t,n,r){n=un(r,n),n=mm(t.stateNode,n,2),t=ka(t,n,2),t!==null&&(ni(t,2),Ln(t))}function jt(t,n,r){if(t.tag===3)iv(t,t,r);else for(;n!==null;){if(n.tag===3){iv(n,t,r);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Aa===null||!Aa.has(o))){t=un(r,t),r=og(2),o=ka(n,r,2),o!==null&&(cg(r,o,n,t),ni(o,2),Ln(o));break}}n=n.return}}function Lm(t,n,r){var o=t.pingCache;if(o===null){o=t.pingCache=new t_;var u=new Set;o.set(n,u)}else u=o.get(n),u===void 0&&(u=new Set,o.set(n,u));u.has(r)||(Em=!0,u.add(r),t=r_.bind(null,t,n,r),n.then(t,t))}function r_(t,n,r){var o=t.pingCache;o!==null&&o.delete(n),t.pingedLanes|=t.suspendedLanes&r,t.warmLanes&=~r,Et===t&&(tt&r)===r&&(Wt===4||Wt===3&&(tt&62914560)===tt&&300>ke()-Sc?(xt&2)===0&&br(t,0):Mm|=r,jr===tt&&(jr=0)),Ln(t)}function ov(t,n){n===0&&(n=ql()),t=ol(t,n),t!==null&&(ni(t,n),Ln(t))}function i_(t){var n=t.memoizedState,r=0;n!==null&&(r=n.retryLane),ov(t,r)}function o_(t,n){var r=0;switch(t.tag){case 31:case 13:var o=t.stateNode,u=t.memoizedState;u!==null&&(r=u.retryLane);break;case 19:o=t.stateNode;break;case 22:o=t.stateNode._retryCache;break;default:throw Error(i(314))}o!==null&&o.delete(n),ov(t,r)}function c_(t,n){return ln(t,n)}var Dc=null,wr=null,Bm=!1,Oc=!1,Um=!1,Pa=0;function Ln(t){t!==wr&&t.next===null&&(wr===null?Dc=wr=t:wr=wr.next=t),Oc=!0,Bm||(Bm=!0,u_())}function Li(t,n){if(!Um&&Oc){Um=!0;do for(var r=!1,o=Dc;o!==null;){if(t!==0){var u=o.pendingLanes;if(u===0)var f=0;else{var y=o.suspendedLanes,_=o.pingedLanes;f=(1<<31-pt(42|t)+1)-1,f&=u&~(y&~_),f=f&201326741?f&201326741|1:f?f|2:0}f!==0&&(r=!0,mv(o,f))}else f=tt,f=Yl(o,o===Et?f:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(f&3)===0||sl(o,f)||(r=!0,mv(o,f));o=o.next}while(r);Um=!1}}function d_(){cv()}function cv(){Oc=Bm=!1;var t=0;Pa!==0&&b_()&&(t=Pa);for(var n=ke(),r=null,o=Dc;o!==null;){var u=o.next,f=dv(o,n);f===0?(o.next=null,r===null?Dc=u:r.next=u,u===null&&(wr=r)):(r=o,(t!==0||(f&3)!==0)&&(Oc=!0)),o=u}ls!==0&&ls!==5||Li(t),Pa!==0&&(Pa=0)}function dv(t,n){for(var r=t.suspendedLanes,o=t.pingedLanes,u=t.expirationTimes,f=t.pendingLanes&-62914561;0_)break;var ie=z.transferSize,ue=z.initiatorType;ie&&yv(ue)&&(z=z.responseEnd,y+=ie*(z<_?1:(_-K)/(z-K)))}if(--o,n+=8*(f+y)/(u.duration/1e3),t++,10"u"?null:document;function Ov(t,n,r){var o=Sr;if(o&&typeof n=="string"&&n){var u=cn(n);u='link[rel="'+t+'"][href="'+u+'"]',typeof r=="string"&&(u+='[crossorigin="'+r+'"]'),Dv.has(u)||(Dv.add(u),t={rel:t,crossOrigin:r,href:n},o.querySelector(u)===null&&(n=o.createElement("link"),js(n,"link",t),cs(n),o.head.appendChild(n)))}}function M_(t){da.D(t),Ov("dns-prefetch",t,null)}function D_(t,n){da.C(t,n),Ov("preconnect",t,n)}function O_(t,n,r){da.L(t,n,r);var o=Sr;if(o&&t&&n){var u='link[rel="preload"][as="'+cn(n)+'"]';n==="image"&&r&&r.imageSrcSet?(u+='[imagesrcset="'+cn(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(u+='[imagesizes="'+cn(r.imageSizes)+'"]')):u+='[href="'+cn(t)+'"]';var f=u;switch(n){case"style":f=_r(t);break;case"script":f=Cr(t)}gn.has(f)||(t=j({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:t,as:n},r),gn.set(f,t),o.querySelector(u)!==null||n==="style"&&o.querySelector(Fi(f))||n==="script"&&o.querySelector(Yi(f))||(n=o.createElement("link"),js(n,"link",t),cs(n),o.head.appendChild(n)))}}function A_(t,n){da.m(t,n);var r=Sr;if(r&&t){var o=n&&typeof n.as=="string"?n.as:"script",u='link[rel="modulepreload"][as="'+cn(o)+'"][href="'+cn(t)+'"]',f=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":f=Cr(t)}if(!gn.has(f)&&(t=j({rel:"modulepreload",href:t},n),gn.set(f,t),r.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(Yi(f)))return}o=r.createElement("link"),js(o,"link",t),cs(o),r.head.appendChild(o)}}}function R_(t,n,r){da.S(t,n,r);var o=Sr;if(o&&t){var u=Il(o).hoistableStyles,f=_r(t);n=n||"default";var y=u.get(f);if(!y){var _={loading:0,preload:null};if(y=o.querySelector(Fi(f)))_.loading=5;else{t=j({rel:"stylesheet",href:t,"data-precedence":n},r),(r=gn.get(f))&&tf(t,r);var z=y=o.createElement("link");cs(z),js(z,"link",t),z._p=new Promise(function(K,ie){z.onload=K,z.onerror=ie}),z.addEventListener("load",function(){_.loading|=1}),z.addEventListener("error",function(){_.loading|=2}),_.loading|=4,Lc(y,n,o)}y={type:"stylesheet",instance:y,count:1,state:_},u.set(f,y)}}}function z_(t,n){da.X(t,n);var r=Sr;if(r&&t){var o=Il(r).hoistableScripts,u=Cr(t),f=o.get(u);f||(f=r.querySelector(Yi(u)),f||(t=j({src:t,async:!0},n),(n=gn.get(u))&&sf(t,n),f=r.createElement("script"),cs(f),js(f,"link",t),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},o.set(u,f))}}function P_(t,n){da.M(t,n);var r=Sr;if(r&&t){var o=Il(r).hoistableScripts,u=Cr(t),f=o.get(u);f||(f=r.querySelector(Yi(u)),f||(t=j({src:t,async:!0,type:"module"},n),(n=gn.get(u))&&sf(t,n),f=r.createElement("script"),cs(f),js(f,"link",t),r.head.appendChild(f)),f={type:"script",instance:f,count:1,state:null},o.set(u,f))}}function Av(t,n,r,o){var u=(u=ve.current)?Pc(u):null;if(!u)throw Error(i(446));switch(t){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=_r(r.href),r=Il(u).hoistableStyles,o=r.get(n),o||(o={type:"style",instance:null,count:0,state:null},r.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){t=_r(r.href);var f=Il(u).hoistableStyles,y=f.get(t);if(y||(u=u.ownerDocument||u,y={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},f.set(t,y),(f=u.querySelector(Fi(t)))&&!f._p&&(y.instance=f,y.state.loading=5),gn.has(t)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},gn.set(t,r),f||L_(u,t,r,y.state))),n&&o===null)throw Error(i(528,""));return y}if(n&&o!==null)throw Error(i(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Cr(r),r=Il(u).hoistableScripts,o=r.get(n),o||(o={type:"script",instance:null,count:0,state:null},r.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,t))}}function _r(t){return'href="'+cn(t)+'"'}function Fi(t){return'link[rel="stylesheet"]['+t+"]"}function Rv(t){return j({},t,{"data-precedence":t.precedence,precedence:null})}function L_(t,n,r,o){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=t.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),js(n,"link",r),cs(n),t.head.appendChild(n))}function Cr(t){return'[src="'+cn(t)+'"]'}function Yi(t){return"script[async]"+t}function zv(t,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var o=t.querySelector('style[data-href~="'+cn(r.href)+'"]');if(o)return n.instance=o,cs(o),o;var u=j({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return o=(t.ownerDocument||t).createElement("style"),cs(o),js(o,"style",u),Lc(o,r.precedence,t),n.instance=o;case"stylesheet":u=_r(r.href);var f=t.querySelector(Fi(u));if(f)return n.state.loading|=4,n.instance=f,cs(f),f;o=Rv(r),(u=gn.get(u))&&tf(o,u),f=(t.ownerDocument||t).createElement("link"),cs(f);var y=f;return y._p=new Promise(function(_,z){y.onload=_,y.onerror=z}),js(f,"link",o),n.state.loading|=4,Lc(f,r.precedence,t),n.instance=f;case"script":return f=Cr(r.src),(u=t.querySelector(Yi(f)))?(n.instance=u,cs(u),u):(o=r,(u=gn.get(f))&&(o=j({},r),sf(o,u)),t=t.ownerDocument||t,u=t.createElement("script"),cs(u),js(u,"link",o),t.head.appendChild(u),n.instance=u);case"void":return null;default:throw Error(i(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,Lc(o,r.precedence,t));return n.instance}function Lc(t,n,r){for(var o=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,f=u,y=0;y title"):null)}function B_(t,n,r){if(r===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return t=n.disabled,typeof n.precedence=="string"&&t==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Bv(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function U_(t,n,r,o){if(r.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var u=_r(o.href),f=n.querySelector(Fi(u));if(f){n=f._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=Uc.bind(t),n.then(t,t)),r.state.loading|=4,r.instance=f,cs(f);return}f=n.ownerDocument||n,o=Rv(o),(u=gn.get(u))&&tf(o,u),f=f.createElement("link"),cs(f);var y=f;y._p=new Promise(function(_,z){y.onload=_,y.onerror=z}),js(f,"link",o),r.instance=f}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(r,n),(n=r.state.preload)&&(r.state.loading&3)===0&&(t.count++,r=Uc.bind(t),n.addEventListener("load",r),n.addEventListener("error",r))}}var nf=0;function H_(t,n){return t.stylesheets&&t.count===0&&Fc(t,t.stylesheets),0nf?50:800)+n);return t.unsuspend=r,function(){t.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Uc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Fc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Hc=null;function Fc(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Hc=new Map,n.forEach(F_,t),Hc=null,Uc.call(t))}function F_(t,n){if(!(n.state.loading&4)){var r=Hc.get(t);if(r)var o=r.get(null);else{r=new Map,Hc.set(t,r);for(var u=t.querySelectorAll("link[data-precedence],style[data-precedence]"),f=0;f"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(a){console.error(a)}}return s(),mf.exports=Z2(),mf.exports}var eC=J2();function Ry(s,a){return function(){return s.apply(a,arguments)}}const{toString:tC}=Object.prototype,{getPrototypeOf:yh}=Object,{iterator:Dd,toStringTag:zy}=Symbol,Od=(s=>a=>{const l=tC.call(a);return s[l]||(s[l]=l.slice(8,-1).toLowerCase())})(Object.create(null)),On=s=>(s=s.toLowerCase(),a=>Od(a)===s),Ad=s=>a=>typeof a===s,{isArray:Xr}=Array,Vr=Ad("undefined");function yo(s){return s!==null&&!Vr(s)&&s.constructor!==null&&!Vr(s.constructor)&&qs(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const Py=On("ArrayBuffer");function sC(s){let a;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?a=ArrayBuffer.isView(s):a=s&&s.buffer&&Py(s.buffer),a}const nC=Ad("string"),qs=Ad("function"),Ly=Ad("number"),bo=s=>s!==null&&typeof s=="object",aC=s=>s===!0||s===!1,id=s=>{if(Od(s)!=="object")return!1;const a=yh(s);return(a===null||a===Object.prototype||Object.getPrototypeOf(a)===null)&&!(zy in s)&&!(Dd in s)},lC=s=>{if(!bo(s)||yo(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},rC=On("Date"),iC=On("File"),oC=On("Blob"),cC=On("FileList"),dC=s=>bo(s)&&qs(s.pipe),uC=s=>{let a;return s&&(typeof FormData=="function"&&s instanceof FormData||qs(s.append)&&((a=Od(s))==="formdata"||a==="object"&&qs(s.toString)&&s.toString()==="[object FormData]"))},mC=On("URLSearchParams"),[fC,hC,xC,pC]=["ReadableStream","Request","Response","Headers"].map(On),gC=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function No(s,a,{allOwnKeys:l=!1}={}){if(s===null||typeof s>"u")return;let i,c;if(typeof s!="object"&&(s=[s]),Xr(s))for(i=0,c=s.length;i0;)if(c=l[i],a===c.toLowerCase())return c;return null}const wl=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Uy=s=>!Vr(s)&&s!==wl;function Uf(){const{caseless:s,skipUndefined:a}=Uy(this)&&this||{},l={},i=(c,d)=>{const m=s&&By(l,d)||d;id(l[m])&&id(c)?l[m]=Uf(l[m],c):id(c)?l[m]=Uf({},c):Xr(c)?l[m]=c.slice():(!a||!Vr(c))&&(l[m]=c)};for(let c=0,d=arguments.length;c(No(a,(c,d)=>{l&&qs(c)?s[d]=Ry(c,l):s[d]=c},{allOwnKeys:i}),s),jC=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),yC=(s,a,l,i)=>{s.prototype=Object.create(a.prototype,i),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:a.prototype}),l&&Object.assign(s.prototype,l)},bC=(s,a,l,i)=>{let c,d,m;const h={};if(a=a||{},s==null)return a;do{for(c=Object.getOwnPropertyNames(s),d=c.length;d-- >0;)m=c[d],(!i||i(m,s,a))&&!h[m]&&(a[m]=s[m],h[m]=!0);s=l!==!1&&yh(s)}while(s&&(!l||l(s,a))&&s!==Object.prototype);return a},NC=(s,a,l)=>{s=String(s),(l===void 0||l>s.length)&&(l=s.length),l-=a.length;const i=s.indexOf(a,l);return i!==-1&&i===l},wC=s=>{if(!s)return null;if(Xr(s))return s;let a=s.length;if(!Ly(a))return null;const l=new Array(a);for(;a-- >0;)l[a]=s[a];return l},SC=(s=>a=>s&&a instanceof s)(typeof Uint8Array<"u"&&yh(Uint8Array)),_C=(s,a)=>{const i=(s&&s[Dd]).call(s);let c;for(;(c=i.next())&&!c.done;){const d=c.value;a.call(s,d[0],d[1])}},CC=(s,a)=>{let l;const i=[];for(;(l=s.exec(a))!==null;)i.push(l);return i},kC=On("HTMLFormElement"),TC=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(l,i,c){return i.toUpperCase()+c}),ij=(({hasOwnProperty:s})=>(a,l)=>s.call(a,l))(Object.prototype),EC=On("RegExp"),Hy=(s,a)=>{const l=Object.getOwnPropertyDescriptors(s),i={};No(l,(c,d)=>{let m;(m=a(c,d,s))!==!1&&(i[d]=m||c)}),Object.defineProperties(s,i)},MC=s=>{Hy(s,(a,l)=>{if(qs(s)&&["arguments","caller","callee"].indexOf(l)!==-1)return!1;const i=s[l];if(qs(i)){if(a.enumerable=!1,"writable"in a){a.writable=!1;return}a.set||(a.set=()=>{throw Error("Can not rewrite read-only method '"+l+"'")})}})},DC=(s,a)=>{const l={},i=c=>{c.forEach(d=>{l[d]=!0})};return Xr(s)?i(s):i(String(s).split(a)),l},OC=()=>{},AC=(s,a)=>s!=null&&Number.isFinite(s=+s)?s:a;function RC(s){return!!(s&&qs(s.append)&&s[zy]==="FormData"&&s[Dd])}const zC=s=>{const a=new Array(10),l=(i,c)=>{if(bo(i)){if(a.indexOf(i)>=0)return;if(yo(i))return i;if(!("toJSON"in i)){a[c]=i;const d=Xr(i)?[]:{};return No(i,(m,h)=>{const p=l(m,c+1);!Vr(p)&&(d[h]=p)}),a[c]=void 0,d}}return i};return l(s,0)},PC=On("AsyncFunction"),LC=s=>s&&(bo(s)||qs(s))&&qs(s.then)&&qs(s.catch),Fy=((s,a)=>s?setImmediate:a?((l,i)=>(wl.addEventListener("message",({source:c,data:d})=>{c===wl&&d===l&&i.length&&i.shift()()},!1),c=>{i.push(c),wl.postMessage(l,"*")}))(`axios@${Math.random()}`,[]):l=>setTimeout(l))(typeof setImmediate=="function",qs(wl.postMessage)),BC=typeof queueMicrotask<"u"?queueMicrotask.bind(wl):typeof process<"u"&&process.nextTick||Fy,UC=s=>s!=null&&qs(s[Dd]),te={isArray:Xr,isArrayBuffer:Py,isBuffer:yo,isFormData:uC,isArrayBufferView:sC,isString:nC,isNumber:Ly,isBoolean:aC,isObject:bo,isPlainObject:id,isEmptyObject:lC,isReadableStream:fC,isRequest:hC,isResponse:xC,isHeaders:pC,isUndefined:Vr,isDate:rC,isFile:iC,isBlob:oC,isRegExp:EC,isFunction:qs,isStream:dC,isURLSearchParams:mC,isTypedArray:SC,isFileList:cC,forEach:No,merge:Uf,extend:vC,trim:gC,stripBOM:jC,inherits:yC,toFlatObject:bC,kindOf:Od,kindOfTest:On,endsWith:NC,toArray:wC,forEachEntry:_C,matchAll:CC,isHTMLForm:kC,hasOwnProperty:ij,hasOwnProp:ij,reduceDescriptors:Hy,freezeMethods:MC,toObjectSet:DC,toCamelCase:TC,noop:OC,toFiniteNumber:AC,findKey:By,global:wl,isContextDefined:Uy,isSpecCompliantForm:RC,toJSONObject:zC,isAsyncFn:PC,isThenable:LC,setImmediate:Fy,asap:BC,isIterable:UC};function qe(s,a,l,i,c){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",a&&(this.code=a),l&&(this.config=l),i&&(this.request=i),c&&(this.response=c,this.status=c.status?c.status:null)}te.inherits(qe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:te.toJSONObject(this.config),code:this.code,status:this.status}}});const Yy=qe.prototype,qy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(s=>{qy[s]={value:s}});Object.defineProperties(qe,qy);Object.defineProperty(Yy,"isAxiosError",{value:!0});qe.from=(s,a,l,i,c,d)=>{const m=Object.create(Yy);te.toFlatObject(s,m,function(g){return g!==Error.prototype},v=>v!=="isAxiosError");const h=s&&s.message?s.message:"Error",p=a==null&&s?s.code:a;return qe.call(m,h,p,l,i,c),s&&m.cause==null&&Object.defineProperty(m,"cause",{value:s,configurable:!0}),m.name=s&&s.name||"Error",d&&Object.assign(m,d),m};const HC=null;function Hf(s){return te.isPlainObject(s)||te.isArray(s)}function Vy(s){return te.endsWith(s,"[]")?s.slice(0,-2):s}function oj(s,a,l){return s?s.concat(a).map(function(c,d){return c=Vy(c),!l&&d?"["+c+"]":c}).join(l?".":""):a}function FC(s){return te.isArray(s)&&!s.some(Hf)}const YC=te.toFlatObject(te,{},null,function(a){return/^is[A-Z]/.test(a)});function Rd(s,a,l){if(!te.isObject(s))throw new TypeError("target must be an object");a=a||new FormData,l=te.toFlatObject(l,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,N){return!te.isUndefined(N[C])});const i=l.metaTokens,c=l.visitor||g,d=l.dots,m=l.indexes,p=(l.Blob||typeof Blob<"u"&&Blob)&&te.isSpecCompliantForm(a);if(!te.isFunction(c))throw new TypeError("visitor must be a function");function v(S){if(S===null)return"";if(te.isDate(S))return S.toISOString();if(te.isBoolean(S))return S.toString();if(!p&&te.isBlob(S))throw new qe("Blob is not supported. Use a Buffer instead.");return te.isArrayBuffer(S)||te.isTypedArray(S)?p&&typeof Blob=="function"?new Blob([S]):Buffer.from(S):S}function g(S,C,N){let T=S;if(S&&!N&&typeof S=="object"){if(te.endsWith(C,"{}"))C=i?C:C.slice(0,-2),S=JSON.stringify(S);else if(te.isArray(S)&&FC(S)||(te.isFileList(S)||te.endsWith(C,"[]"))&&(T=te.toArray(S)))return C=Vy(C),T.forEach(function(M,k){!(te.isUndefined(M)||M===null)&&a.append(m===!0?oj([C],k,d):m===null?C:C+"[]",v(M))}),!1}return Hf(S)?!0:(a.append(oj(N,C,d),v(S)),!1)}const j=[],b=Object.assign(YC,{defaultVisitor:g,convertValue:v,isVisitable:Hf});function w(S,C){if(!te.isUndefined(S)){if(j.indexOf(S)!==-1)throw Error("Circular reference detected in "+C.join("."));j.push(S),te.forEach(S,function(T,P){(!(te.isUndefined(T)||T===null)&&c.call(a,T,te.isString(P)?P.trim():P,C,b))===!0&&w(T,C?C.concat(P):[P])}),j.pop()}}if(!te.isObject(s))throw new TypeError("data must be an object");return w(s),a}function cj(s){const a={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return a[i]})}function bh(s,a){this._pairs=[],s&&Rd(s,this,a)}const Gy=bh.prototype;Gy.append=function(a,l){this._pairs.push([a,l])};Gy.toString=function(a){const l=a?function(i){return a.call(this,i,cj)}:cj;return this._pairs.map(function(c){return l(c[0])+"="+l(c[1])},"").join("&")};function qC(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $y(s,a,l){if(!a)return s;const i=l&&l.encode||qC;te.isFunction(l)&&(l={serialize:l});const c=l&&l.serialize;let d;if(c?d=c(a,l):d=te.isURLSearchParams(a)?a.toString():new bh(a,l).toString(i),d){const m=s.indexOf("#");m!==-1&&(s=s.slice(0,m)),s+=(s.indexOf("?")===-1?"?":"&")+d}return s}class dj{constructor(){this.handlers=[]}use(a,l,i){return this.handlers.push({fulfilled:a,rejected:l,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(a){this.handlers[a]&&(this.handlers[a]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(a){te.forEach(this.handlers,function(i){i!==null&&a(i)})}}const Iy={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},VC=typeof URLSearchParams<"u"?URLSearchParams:bh,GC=typeof FormData<"u"?FormData:null,$C=typeof Blob<"u"?Blob:null,IC={isBrowser:!0,classes:{URLSearchParams:VC,FormData:GC,Blob:$C},protocols:["http","https","file","blob","url","data"]},Nh=typeof window<"u"&&typeof document<"u",Ff=typeof navigator=="object"&&navigator||void 0,WC=Nh&&(!Ff||["ReactNative","NativeScript","NS"].indexOf(Ff.product)<0),XC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",KC=Nh&&window.location.href||"http://localhost",QC=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Nh,hasStandardBrowserEnv:WC,hasStandardBrowserWebWorkerEnv:XC,navigator:Ff,origin:KC},Symbol.toStringTag,{value:"Module"})),Ss={...QC,...IC};function ZC(s,a){return Rd(s,new Ss.classes.URLSearchParams,{visitor:function(l,i,c,d){return Ss.isNode&&te.isBuffer(l)?(this.append(i,l.toString("base64")),!1):d.defaultVisitor.apply(this,arguments)},...a})}function JC(s){return te.matchAll(/\w+|\[(\w*)]/g,s).map(a=>a[0]==="[]"?"":a[1]||a[0])}function ek(s){const a={},l=Object.keys(s);let i;const c=l.length;let d;for(i=0;i=l.length;return m=!m&&te.isArray(c)?c.length:m,p?(te.hasOwnProp(c,m)?c[m]=[c[m],i]:c[m]=i,!h):((!c[m]||!te.isObject(c[m]))&&(c[m]=[]),a(l,i,c[m],d)&&te.isArray(c[m])&&(c[m]=ek(c[m])),!h)}if(te.isFormData(s)&&te.isFunction(s.entries)){const l={};return te.forEachEntry(s,(i,c)=>{a(JC(i),c,l,0)}),l}return null}function tk(s,a,l){if(te.isString(s))try{return(a||JSON.parse)(s),te.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(l||JSON.stringify)(s)}const wo={transitional:Iy,adapter:["xhr","http","fetch"],transformRequest:[function(a,l){const i=l.getContentType()||"",c=i.indexOf("application/json")>-1,d=te.isObject(a);if(d&&te.isHTMLForm(a)&&(a=new FormData(a)),te.isFormData(a))return c?JSON.stringify(Wy(a)):a;if(te.isArrayBuffer(a)||te.isBuffer(a)||te.isStream(a)||te.isFile(a)||te.isBlob(a)||te.isReadableStream(a))return a;if(te.isArrayBufferView(a))return a.buffer;if(te.isURLSearchParams(a))return l.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),a.toString();let h;if(d){if(i.indexOf("application/x-www-form-urlencoded")>-1)return ZC(a,this.formSerializer).toString();if((h=te.isFileList(a))||i.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return Rd(h?{"files[]":a}:a,p&&new p,this.formSerializer)}}return d||c?(l.setContentType("application/json",!1),tk(a)):a}],transformResponse:[function(a){const l=this.transitional||wo.transitional,i=l&&l.forcedJSONParsing,c=this.responseType==="json";if(te.isResponse(a)||te.isReadableStream(a))return a;if(a&&te.isString(a)&&(i&&!this.responseType||c)){const m=!(l&&l.silentJSONParsing)&&c;try{return JSON.parse(a,this.parseReviver)}catch(h){if(m)throw h.name==="SyntaxError"?qe.from(h,qe.ERR_BAD_RESPONSE,this,null,this.response):h}}return a}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ss.classes.FormData,Blob:Ss.classes.Blob},validateStatus:function(a){return a>=200&&a<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};te.forEach(["delete","get","head","post","put","patch"],s=>{wo.headers[s]={}});const sk=te.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),nk=s=>{const a={};let l,i,c;return s&&s.split(` `).forEach(function(m){c=m.indexOf(":"),l=m.substring(0,c).trim().toLowerCase(),i=m.substring(c+1).trim(),!(!l||a[l]&&sk[l])&&(l==="set-cookie"?a[l]?a[l].push(i):a[l]=[i]:a[l]=a[l]?a[l]+", "+i:i)}),a},uj=Symbol("internals");function Xi(s){return s&&String(s).trim().toLowerCase()}function od(s){return s===!1||s==null?s:te.isArray(s)?s.map(od):String(s)}function ak(s){const a=Object.create(null),l=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=l.exec(s);)a[i[1]]=i[2];return a}const lk=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function xf(s,a,l,i,c){if(te.isFunction(i))return i.call(this,a,l);if(c&&(a=l),!!te.isString(a)){if(te.isString(i))return a.indexOf(i)!==-1;if(te.isRegExp(i))return i.test(a)}}function rk(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(a,l,i)=>l.toUpperCase()+i)}function ik(s,a){const l=te.toCamelCase(" "+a);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+l,{value:function(c,d,m){return this[i].call(this,a,c,d,m)},configurable:!0})})}let Vs=class{constructor(a){a&&this.set(a)}set(a,l,i){const c=this;function d(h,p,v){const g=Xi(p);if(!g)throw new Error("header name must be a non-empty string");const j=te.findKey(c,g);(!j||c[j]===void 0||v===!0||v===void 0&&c[j]!==!1)&&(c[j||p]=od(h))}const m=(h,p)=>te.forEach(h,(v,g)=>d(v,g,p));if(te.isPlainObject(a)||a instanceof this.constructor)m(a,l);else if(te.isString(a)&&(a=a.trim())&&!lk(a))m(nk(a),l);else if(te.isObject(a)&&te.isIterable(a)){let h={},p,v;for(const g of a){if(!te.isArray(g))throw TypeError("Object iterator must return a key-value pair");h[v=g[0]]=(p=h[v])?te.isArray(p)?[...p,g[1]]:[p,g[1]]:g[1]}m(h,l)}else a!=null&&d(l,a,i);return this}get(a,l){if(a=Xi(a),a){const i=te.findKey(this,a);if(i){const c=this[i];if(!l)return c;if(l===!0)return ak(c);if(te.isFunction(l))return l.call(this,c,i);if(te.isRegExp(l))return l.exec(c);throw new TypeError("parser must be boolean|regexp|function")}}}has(a,l){if(a=Xi(a),a){const i=te.findKey(this,a);return!!(i&&this[i]!==void 0&&(!l||xf(this,this[i],i,l)))}return!1}delete(a,l){const i=this;let c=!1;function d(m){if(m=Xi(m),m){const h=te.findKey(i,m);h&&(!l||xf(i,i[h],h,l))&&(delete i[h],c=!0)}}return te.isArray(a)?a.forEach(d):d(a),c}clear(a){const l=Object.keys(this);let i=l.length,c=!1;for(;i--;){const d=l[i];(!a||xf(this,this[d],d,a,!0))&&(delete this[d],c=!0)}return c}normalize(a){const l=this,i={};return te.forEach(this,(c,d)=>{const m=te.findKey(i,d);if(m){l[m]=od(c),delete l[d];return}const h=a?rk(d):String(d).trim();h!==d&&delete l[d],l[h]=od(c),i[h]=!0}),this}concat(...a){return this.constructor.concat(this,...a)}toJSON(a){const l=Object.create(null);return te.forEach(this,(i,c)=>{i!=null&&i!==!1&&(l[c]=a&&te.isArray(i)?i.join(", "):i)}),l}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([a,l])=>a+": "+l).join(` `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(a){return a instanceof this?a:new this(a)}static concat(a,...l){const i=new this(a);return l.forEach(c=>i.set(c)),i}static accessor(a){const i=(this[uj]=this[uj]={accessors:{}}).accessors,c=this.prototype;function d(m){const h=Xi(m);i[h]||(ik(c,m),i[h]=!0)}return te.isArray(a)?a.forEach(d):d(a),this}};Vs.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);te.reduceDescriptors(Vs.prototype,({value:s},a)=>{let l=a[0].toUpperCase()+a.slice(1);return{get:()=>s,set(i){this[l]=i}}});te.freezeMethods(Vs);function pf(s,a){const l=this||wo,i=a||l,c=Vs.from(i.headers);let d=i.data;return te.forEach(s,function(h){d=h.call(l,d,c.normalize(),a?a.status:void 0)}),c.normalize(),d}function Xy(s){return!!(s&&s.__CANCEL__)}function Kr(s,a,l){qe.call(this,s??"canceled",qe.ERR_CANCELED,a,l),this.name="CanceledError"}te.inherits(Kr,qe,{__CANCEL__:!0});function Ky(s,a,l){const i=l.config.validateStatus;!l.status||!i||i(l.status)?s(l):a(new qe("Request failed with status code "+l.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(l.status/100)-4],l.config,l.request,l))}function ok(s){const a=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return a&&a[1]||""}function ck(s,a){s=s||10;const l=new Array(s),i=new Array(s);let c=0,d=0,m;return a=a!==void 0?a:1e3,function(p){const v=Date.now(),g=i[d];m||(m=v),l[c]=p,i[c]=v;let j=d,b=0;for(;j!==c;)b+=l[j++],j=j%s;if(c=(c+1)%s,c===d&&(d=(d+1)%s),v-m{l=g,c=null,d&&(clearTimeout(d),d=null),s(...v)};return[(...v)=>{const g=Date.now(),j=g-l;j>=i?m(v,g):(c=v,d||(d=setTimeout(()=>{d=null,m(c)},i-j)))},()=>c&&m(c)]}const gd=(s,a,l=3)=>{let i=0;const c=ck(50,250);return dk(d=>{const m=d.loaded,h=d.lengthComputable?d.total:void 0,p=m-i,v=c(p),g=m<=h;i=m;const j={loaded:m,total:h,progress:h?m/h:void 0,bytes:p,rate:v||void 0,estimated:v&&h&&g?(h-m)/v:void 0,event:d,lengthComputable:h!=null,[a?"download":"upload"]:!0};s(j)},l)},mj=(s,a)=>{const l=s!=null;return[i=>a[0]({lengthComputable:l,total:s,loaded:i}),a[1]]},fj=s=>(...a)=>te.asap(()=>s(...a)),uk=Ss.hasStandardBrowserEnv?((s,a)=>l=>(l=new URL(l,Ss.origin),s.protocol===l.protocol&&s.host===l.host&&(a||s.port===l.port)))(new URL(Ss.origin),Ss.navigator&&/(msie|trident)/i.test(Ss.navigator.userAgent)):()=>!0,mk=Ss.hasStandardBrowserEnv?{write(s,a,l,i,c,d,m){if(typeof document>"u")return;const h=[`${s}=${encodeURIComponent(a)}`];te.isNumber(l)&&h.push(`expires=${new Date(l).toUTCString()}`),te.isString(i)&&h.push(`path=${i}`),te.isString(c)&&h.push(`domain=${c}`),d===!0&&h.push("secure"),te.isString(m)&&h.push(`SameSite=${m}`),document.cookie=h.join("; ")},read(s){if(typeof document>"u")return null;const a=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return a?decodeURIComponent(a[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function fk(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function hk(s,a){return a?s.replace(/\/?\/$/,"")+"/"+a.replace(/^\/+/,""):s}function Qy(s,a,l){let i=!fk(a);return s&&(i||l==!1)?hk(s,a):a}const hj=s=>s instanceof Vs?{...s}:s;function El(s,a){a=a||{};const l={};function i(v,g,j,b){return te.isPlainObject(v)&&te.isPlainObject(g)?te.merge.call({caseless:b},v,g):te.isPlainObject(g)?te.merge({},g):te.isArray(g)?g.slice():g}function c(v,g,j,b){if(te.isUndefined(g)){if(!te.isUndefined(v))return i(void 0,v,j,b)}else return i(v,g,j,b)}function d(v,g){if(!te.isUndefined(g))return i(void 0,g)}function m(v,g){if(te.isUndefined(g)){if(!te.isUndefined(v))return i(void 0,v)}else return i(void 0,g)}function h(v,g,j){if(j in a)return i(v,g);if(j in s)return i(void 0,v)}const p={url:d,method:d,data:d,baseURL:m,transformRequest:m,transformResponse:m,paramsSerializer:m,timeout:m,timeoutMessage:m,withCredentials:m,withXSRFToken:m,adapter:m,responseType:m,xsrfCookieName:m,xsrfHeaderName:m,onUploadProgress:m,onDownloadProgress:m,decompress:m,maxContentLength:m,maxBodyLength:m,beforeRedirect:m,transport:m,httpAgent:m,httpsAgent:m,cancelToken:m,socketPath:m,responseEncoding:m,validateStatus:h,headers:(v,g,j)=>c(hj(v),hj(g),j,!0)};return te.forEach(Object.keys({...s,...a}),function(g){const j=p[g]||c,b=j(s[g],a[g],g);te.isUndefined(b)&&j!==h||(l[g]=b)}),l}const Zy=s=>{const a=El({},s);let{data:l,withXSRFToken:i,xsrfHeaderName:c,xsrfCookieName:d,headers:m,auth:h}=a;if(a.headers=m=Vs.from(m),a.url=$y(Qy(a.baseURL,a.url,a.allowAbsoluteUrls),s.params,s.paramsSerializer),h&&m.set("Authorization","Basic "+btoa((h.username||"")+":"+(h.password?unescape(encodeURIComponent(h.password)):""))),te.isFormData(l)){if(Ss.hasStandardBrowserEnv||Ss.hasStandardBrowserWebWorkerEnv)m.setContentType(void 0);else if(te.isFunction(l.getHeaders)){const p=l.getHeaders(),v=["content-type","content-length"];Object.entries(p).forEach(([g,j])=>{v.includes(g.toLowerCase())&&m.set(g,j)})}}if(Ss.hasStandardBrowserEnv&&(i&&te.isFunction(i)&&(i=i(a)),i||i!==!1&&uk(a.url))){const p=c&&d&&mk.read(d);p&&m.set(c,p)}return a},xk=typeof XMLHttpRequest<"u",pk=xk&&function(s){return new Promise(function(l,i){const c=Zy(s);let d=c.data;const m=Vs.from(c.headers).normalize();let{responseType:h,onUploadProgress:p,onDownloadProgress:v}=c,g,j,b,w,S;function C(){w&&w(),S&&S(),c.cancelToken&&c.cancelToken.unsubscribe(g),c.signal&&c.signal.removeEventListener("abort",g)}let N=new XMLHttpRequest;N.open(c.method.toUpperCase(),c.url,!0),N.timeout=c.timeout;function T(){if(!N)return;const M=Vs.from("getAllResponseHeaders"in N&&N.getAllResponseHeaders()),D={data:!h||h==="text"||h==="json"?N.responseText:N.response,status:N.status,statusText:N.statusText,headers:M,config:s,request:N};Ky(function(E){l(E),C()},function(E){i(E),C()},D),N=null}"onloadend"in N?N.onloadend=T:N.onreadystatechange=function(){!N||N.readyState!==4||N.status===0&&!(N.responseURL&&N.responseURL.indexOf("file:")===0)||setTimeout(T)},N.onabort=function(){N&&(i(new qe("Request aborted",qe.ECONNABORTED,s,N)),N=null)},N.onerror=function(k){const D=k&&k.message?k.message:"Network Error",A=new qe(D,qe.ERR_NETWORK,s,N);A.event=k||null,i(A),N=null},N.ontimeout=function(){let k=c.timeout?"timeout of "+c.timeout+"ms exceeded":"timeout exceeded";const D=c.transitional||Iy;c.timeoutErrorMessage&&(k=c.timeoutErrorMessage),i(new qe(k,D.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,s,N)),N=null},d===void 0&&m.setContentType(null),"setRequestHeader"in N&&te.forEach(m.toJSON(),function(k,D){N.setRequestHeader(D,k)}),te.isUndefined(c.withCredentials)||(N.withCredentials=!!c.withCredentials),h&&h!=="json"&&(N.responseType=c.responseType),v&&([b,S]=gd(v,!0),N.addEventListener("progress",b)),p&&N.upload&&([j,w]=gd(p),N.upload.addEventListener("progress",j),N.upload.addEventListener("loadend",w)),(c.cancelToken||c.signal)&&(g=M=>{N&&(i(!M||M.type?new Kr(null,s,N):M),N.abort(),N=null)},c.cancelToken&&c.cancelToken.subscribe(g),c.signal&&(c.signal.aborted?g():c.signal.addEventListener("abort",g)));const P=ok(c.url);if(P&&Ss.protocols.indexOf(P)===-1){i(new qe("Unsupported protocol "+P+":",qe.ERR_BAD_REQUEST,s));return}N.send(d||null)})},gk=(s,a)=>{const{length:l}=s=s?s.filter(Boolean):[];if(a||l){let i=new AbortController,c;const d=function(v){if(!c){c=!0,h();const g=v instanceof Error?v:this.reason;i.abort(g instanceof qe?g:new Kr(g instanceof Error?g.message:g))}};let m=a&&setTimeout(()=>{m=null,d(new qe(`timeout ${a} of ms exceeded`,qe.ETIMEDOUT))},a);const h=()=>{s&&(m&&clearTimeout(m),m=null,s.forEach(v=>{v.unsubscribe?v.unsubscribe(d):v.removeEventListener("abort",d)}),s=null)};s.forEach(v=>v.addEventListener("abort",d));const{signal:p}=i;return p.unsubscribe=()=>te.asap(h),p}},vk=function*(s,a){let l=s.byteLength;if(l{const c=jk(s,a);let d=0,m,h=p=>{m||(m=!0,i&&i(p))};return new ReadableStream({async pull(p){try{const{done:v,value:g}=await c.next();if(v){h(),p.close();return}let j=g.byteLength;if(l){let b=d+=j;l(b)}p.enqueue(new Uint8Array(g))}catch(v){throw h(v),v}},cancel(p){return h(p),c.return()}},{highWaterMark:2})},pj=64*1024,{isFunction:Zc}=te,bk=(({Request:s,Response:a})=>({Request:s,Response:a}))(te.global),{ReadableStream:gj,TextEncoder:vj}=te.global,jj=(s,...a)=>{try{return!!s(...a)}catch{return!1}},Nk=s=>{s=te.merge.call({skipUndefined:!0},bk,s);const{fetch:a,Request:l,Response:i}=s,c=a?Zc(a):typeof fetch=="function",d=Zc(l),m=Zc(i);if(!c)return!1;const h=c&&Zc(gj),p=c&&(typeof vj=="function"?(S=>C=>S.encode(C))(new vj):async S=>new Uint8Array(await new l(S).arrayBuffer())),v=d&&h&&jj(()=>{let S=!1;const C=new l(Ss.origin,{body:new gj,method:"POST",get duplex(){return S=!0,"half"}}).headers.has("Content-Type");return S&&!C}),g=m&&h&&jj(()=>te.isReadableStream(new i("").body)),j={stream:g&&(S=>S.body)};c&&["text","arrayBuffer","blob","formData","stream"].forEach(S=>{!j[S]&&(j[S]=(C,N)=>{let T=C&&C[S];if(T)return T.call(C);throw new qe(`Response type '${S}' is not supported`,qe.ERR_NOT_SUPPORT,N)})});const b=async S=>{if(S==null)return 0;if(te.isBlob(S))return S.size;if(te.isSpecCompliantForm(S))return(await new l(Ss.origin,{method:"POST",body:S}).arrayBuffer()).byteLength;if(te.isArrayBufferView(S)||te.isArrayBuffer(S))return S.byteLength;if(te.isURLSearchParams(S)&&(S=S+""),te.isString(S))return(await p(S)).byteLength},w=async(S,C)=>{const N=te.toFiniteNumber(S.getContentLength());return N??b(C)};return async S=>{let{url:C,method:N,data:T,signal:P,cancelToken:M,timeout:k,onDownloadProgress:D,onUploadProgress:A,responseType:E,headers:B,withCredentials:Y="same-origin",fetchOptions:G}=Zy(S),$=a||fetch;E=E?(E+"").toLowerCase():"text";let oe=gk([P,M&&M.toAbortSignal()],k),je=null;const ae=oe&&oe.unsubscribe&&(()=>{oe.unsubscribe()});let me;try{if(A&&v&&N!=="get"&&N!=="head"&&(me=await w(B,T))!==0){let xe=new l(C,{method:"POST",body:T,duplex:"half"}),F;if(te.isFormData(T)&&(F=xe.headers.get("content-type"))&&B.setContentType(F),xe.body){const[W,fe]=mj(me,gd(fj(A)));T=xj(xe.body,pj,W,fe)}}te.isString(Y)||(Y=Y?"include":"omit");const R=d&&"credentials"in l.prototype,O={...G,signal:oe,method:N.toUpperCase(),headers:B.normalize().toJSON(),body:T,duplex:"half",credentials:R?Y:void 0};je=d&&new l(C,O);let L=await(d?$(je,G):$(C,O));const ee=g&&(E==="stream"||E==="response");if(g&&(D||ee&&ae)){const xe={};["status","statusText","headers"].forEach(I=>{xe[I]=L[I]});const F=te.toFiniteNumber(L.headers.get("content-length")),[W,fe]=D&&mj(F,gd(fj(D),!0))||[];L=new i(xj(L.body,pj,W,()=>{fe&&fe(),ae&&ae()}),xe)}E=E||"text";let le=await j[te.findKey(j,E)||"text"](L,S);return!ee&&ae&&ae(),await new Promise((xe,F)=>{Ky(xe,F,{data:le,headers:Vs.from(L.headers),status:L.status,statusText:L.statusText,config:S,request:je})})}catch(R){throw ae&&ae(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,S,je),{cause:R.cause||R}):qe.from(R,R&&R.code,S,je)}}},wk=new Map,Jy=s=>{let a=s&&s.env||{};const{fetch:l,Request:i,Response:c}=a,d=[i,c,l];let m=d.length,h=m,p,v,g=wk;for(;h--;)p=d[h],v=g.get(p),v===void 0&&g.set(p,v=h?new Map:Nk(a)),g=v;return v};Jy();const wh={http:HC,xhr:pk,fetch:{get:Jy}};te.forEach(wh,(s,a)=>{if(s){try{Object.defineProperty(s,"name",{value:a})}catch{}Object.defineProperty(s,"adapterName",{value:a})}});const yj=s=>`- ${s}`,Sk=s=>te.isFunction(s)||s===null||s===!1;function _k(s,a){s=te.isArray(s)?s:[s];const{length:l}=s;let i,c;const d={};for(let m=0;m`adapter ${p} `+(v===!1?"is not supported by the environment":"is not available in the build"));let h=l?m.length>1?`since : `+m.map(yj).join(` `):" "+yj(m[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+h,"ERR_NOT_SUPPORT")}return c}const eb={getAdapter:_k,adapters:wh};function gf(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Kr(null,s)}function bj(s){return gf(s),s.headers=Vs.from(s.headers),s.data=pf.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),eb.getAdapter(s.adapter||wo.adapter,s)(s).then(function(i){return gf(s),i.data=pf.call(s,s.transformResponse,i),i.headers=Vs.from(i.headers),i},function(i){return Xy(i)||(gf(s),i&&i.response&&(i.response.data=pf.call(s,s.transformResponse,i.response),i.response.headers=Vs.from(i.response.headers))),Promise.reject(i)})}const tb="1.13.2",zd={};["object","boolean","number","function","string","symbol"].forEach((s,a)=>{zd[s]=function(i){return typeof i===s||"a"+(a<1?"n ":" ")+s}});const Nj={};zd.transitional=function(a,l,i){function c(d,m){return"[Axios v"+tb+"] Transitional option '"+d+"'"+m+(i?". "+i:"")}return(d,m,h)=>{if(a===!1)throw new qe(c(m," has been removed"+(l?" in "+l:"")),qe.ERR_DEPRECATED);return l&&!Nj[m]&&(Nj[m]=!0,console.warn(c(m," has been deprecated since v"+l+" and will be removed in the near future"))),a?a(d,m,h):!0}};zd.spelling=function(a){return(l,i)=>(console.warn(`${i} is likely a misspelling of ${a}`),!0)};function Ck(s,a,l){if(typeof s!="object")throw new qe("options must be an object",qe.ERR_BAD_OPTION_VALUE);const i=Object.keys(s);let c=i.length;for(;c-- >0;){const d=i[c],m=a[d];if(m){const h=s[d],p=h===void 0||m(h,d,s);if(p!==!0)throw new qe("option "+d+" must be "+p,qe.ERR_BAD_OPTION_VALUE);continue}if(l!==!0)throw new qe("Unknown option "+d,qe.ERR_BAD_OPTION)}}const cd={assertOptions:Ck,validators:zd},Bn=cd.validators;let kl=class{constructor(a){this.defaults=a||{},this.interceptors={request:new dj,response:new dj}}async request(a,l){try{return await this._request(a,l)}catch(i){if(i instanceof Error){let c={};Error.captureStackTrace?Error.captureStackTrace(c):c=new Error;const d=c.stack?c.stack.replace(/^.+\n/,""):"";try{i.stack?d&&!String(i.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(i.stack+=` `+d):i.stack=d}catch{}}throw i}}_request(a,l){typeof a=="string"?(l=l||{},l.url=a):l=a||{},l=El(this.defaults,l);const{transitional:i,paramsSerializer:c,headers:d}=l;i!==void 0&&cd.assertOptions(i,{silentJSONParsing:Bn.transitional(Bn.boolean),forcedJSONParsing:Bn.transitional(Bn.boolean),clarifyTimeoutError:Bn.transitional(Bn.boolean)},!1),c!=null&&(te.isFunction(c)?l.paramsSerializer={serialize:c}:cd.assertOptions(c,{encode:Bn.function,serialize:Bn.function},!0)),l.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?l.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:l.allowAbsoluteUrls=!0),cd.assertOptions(l,{baseUrl:Bn.spelling("baseURL"),withXsrfToken:Bn.spelling("withXSRFToken")},!0),l.method=(l.method||this.defaults.method||"get").toLowerCase();let m=d&&te.merge(d.common,d[l.method]);d&&te.forEach(["delete","get","head","post","put","patch","common"],S=>{delete d[S]}),l.headers=Vs.concat(m,d);const h=[];let p=!0;this.interceptors.request.forEach(function(C){typeof C.runWhen=="function"&&C.runWhen(l)===!1||(p=p&&C.synchronous,h.unshift(C.fulfilled,C.rejected))});const v=[];this.interceptors.response.forEach(function(C){v.push(C.fulfilled,C.rejected)});let g,j=0,b;if(!p){const S=[bj.bind(this),void 0];for(S.unshift(...h),S.push(...v),b=S.length,g=Promise.resolve(l);j{if(!i._listeners)return;let d=i._listeners.length;for(;d-- >0;)i._listeners[d](c);i._listeners=null}),this.promise.then=c=>{let d;const m=new Promise(h=>{i.subscribe(h),d=h}).then(c);return m.cancel=function(){i.unsubscribe(d)},m},a(function(d,m,h){i.reason||(i.reason=new Kr(d,m,h),l(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(a){if(this.reason){a(this.reason);return}this._listeners?this._listeners.push(a):this._listeners=[a]}unsubscribe(a){if(!this._listeners)return;const l=this._listeners.indexOf(a);l!==-1&&this._listeners.splice(l,1)}toAbortSignal(){const a=new AbortController,l=i=>{a.abort(i)};return this.subscribe(l),a.signal.unsubscribe=()=>this.unsubscribe(l),a.signal}static source(){let a;return{token:new sb(function(c){a=c}),cancel:a}}};function Tk(s){return function(l){return s.apply(null,l)}}function Ek(s){return te.isObject(s)&&s.isAxiosError===!0}const Yf={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Yf).forEach(([s,a])=>{Yf[a]=s});function nb(s){const a=new kl(s),l=Ry(kl.prototype.request,a);return te.extend(l,kl.prototype,a,{allOwnKeys:!0}),te.extend(l,a,null,{allOwnKeys:!0}),l.create=function(c){return nb(El(s,c))},l}const $t=nb(wo);$t.Axios=kl;$t.CanceledError=Kr;$t.CancelToken=kk;$t.isCancel=Xy;$t.VERSION=tb;$t.toFormData=Rd;$t.AxiosError=qe;$t.Cancel=$t.CanceledError;$t.all=function(a){return Promise.all(a)};$t.spread=Tk;$t.isAxiosError=Ek;$t.mergeConfig=El;$t.AxiosHeaders=Vs;$t.formToJSON=s=>Wy(te.isHTMLForm(s)?new FormData(s):s);$t.getAdapter=eb.getAdapter;$t.HttpStatusCode=Yf;$t.default=$t;const{Axios:c6,AxiosError:d6,CanceledError:u6,isCancel:m6,CancelToken:f6,VERSION:h6,all:x6,Cancel:p6,isAxiosError:g6,spread:v6,toFormData:j6,AxiosHeaders:y6,HttpStatusCode:b6,formToJSON:N6,getAdapter:w6,mergeConfig:S6}=$t,Mk=(s,a)=>{const l=new Array(s.length+a.length);for(let i=0;i({classGroupId:s,validator:a}),ab=(s=new Map,a=null,l)=>({nextPart:s,validators:a,classGroupId:l}),vd="-",wj=[],Ok="arbitrary..",Ak=s=>{const a=zk(s),{conflictingClassGroups:l,conflictingClassGroupModifiers:i}=s;return{getClassGroupId:m=>{if(m.startsWith("[")&&m.endsWith("]"))return Rk(m);const h=m.split(vd),p=h[0]===""&&h.length>1?1:0;return lb(h,p,a)},getConflictingClassGroupIds:(m,h)=>{if(h){const p=i[m],v=l[m];return p?v?Mk(v,p):p:v||wj}return l[m]||wj}}},lb=(s,a,l)=>{if(s.length-a===0)return l.classGroupId;const c=s[a],d=l.nextPart.get(c);if(d){const v=lb(s,a+1,d);if(v)return v}const m=l.validators;if(m===null)return;const h=a===0?s.join(vd):s.slice(a).join(vd),p=m.length;for(let v=0;vs.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const a=s.slice(1,-1),l=a.indexOf(":"),i=a.slice(0,l);return i?Ok+i:void 0})(),zk=s=>{const{theme:a,classGroups:l}=s;return Pk(l,a)},Pk=(s,a)=>{const l=ab();for(const i in s){const c=s[i];Sh(c,l,i,a)}return l},Sh=(s,a,l,i)=>{const c=s.length;for(let d=0;d{if(typeof s=="string"){Bk(s,a,l);return}if(typeof s=="function"){Uk(s,a,l,i);return}Hk(s,a,l,i)},Bk=(s,a,l)=>{const i=s===""?a:rb(a,s);i.classGroupId=l},Uk=(s,a,l,i)=>{if(Fk(s)){Sh(s(i),a,l,i);return}a.validators===null&&(a.validators=[]),a.validators.push(Dk(l,s))},Hk=(s,a,l,i)=>{const c=Object.entries(s),d=c.length;for(let m=0;m{let l=s;const i=a.split(vd),c=i.length;for(let d=0;d"isThemeGetter"in s&&s.isThemeGetter===!0,Yk=s=>{if(s<1)return{get:()=>{},set:()=>{}};let a=0,l=Object.create(null),i=Object.create(null);const c=(d,m)=>{l[d]=m,a++,a>s&&(a=0,i=l,l=Object.create(null))};return{get(d){let m=l[d];if(m!==void 0)return m;if((m=i[d])!==void 0)return c(d,m),m},set(d,m){d in l?l[d]=m:c(d,m)}}},qf="!",Sj=":",qk=[],_j=(s,a,l,i,c)=>({modifiers:s,hasImportantModifier:a,baseClassName:l,maybePostfixModifierPosition:i,isExternal:c}),Vk=s=>{const{prefix:a,experimentalParseClassName:l}=s;let i=c=>{const d=[];let m=0,h=0,p=0,v;const g=c.length;for(let C=0;Cp?v-p:void 0;return _j(d,w,b,S)};if(a){const c=a+Sj,d=i;i=m=>m.startsWith(c)?d(m.slice(c.length)):_j(qk,!1,m,void 0,!0)}if(l){const c=i;i=d=>l({className:d,parseClassName:c})}return i},Gk=s=>{const a=new Map;return s.orderSensitiveModifiers.forEach((l,i)=>{a.set(l,1e6+i)}),l=>{const i=[];let c=[];for(let d=0;d0&&(c.sort(),i.push(...c),c=[]),i.push(m)):c.push(m)}return c.length>0&&(c.sort(),i.push(...c)),i}},$k=s=>({cache:Yk(s.cacheSize),parseClassName:Vk(s),sortModifiers:Gk(s),...Ak(s)}),Ik=/\s+/,Wk=(s,a)=>{const{parseClassName:l,getClassGroupId:i,getConflictingClassGroupIds:c,sortModifiers:d}=a,m=[],h=s.trim().split(Ik);let p="";for(let v=h.length-1;v>=0;v-=1){const g=h[v],{isExternal:j,modifiers:b,hasImportantModifier:w,baseClassName:S,maybePostfixModifierPosition:C}=l(g);if(j){p=g+(p.length>0?" "+p:p);continue}let N=!!C,T=i(N?S.substring(0,C):S);if(!T){if(!N){p=g+(p.length>0?" "+p:p);continue}if(T=i(S),!T){p=g+(p.length>0?" "+p:p);continue}N=!1}const P=b.length===0?"":b.length===1?b[0]:d(b).join(":"),M=w?P+qf:P,k=M+T;if(m.indexOf(k)>-1)continue;m.push(k);const D=c(T,N);for(let A=0;A0?" "+p:p)}return p},Xk=(...s)=>{let a=0,l,i,c="";for(;a{if(typeof s=="string")return s;let a,l="";for(let i=0;i{let l,i,c,d;const m=p=>{const v=a.reduce((g,j)=>j(g),s());return l=$k(v),i=l.cache.get,c=l.cache.set,d=h,h(p)},h=p=>{const v=i(p);if(v)return v;const g=Wk(p,l);return c(p,g),g};return d=m,(...p)=>d(Xk(...p))},Qk=[],rs=s=>{const a=l=>l[s]||Qk;return a.isThemeGetter=!0,a},ob=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,cb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Zk=/^\d+\/\d+$/,Jk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eT=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,tT=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sT=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nT=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Tr=s=>Zk.test(s),Ke=s=>!!s&&!Number.isNaN(Number(s)),qa=s=>!!s&&Number.isInteger(Number(s)),vf=s=>s.endsWith("%")&&Ke(s.slice(0,-1)),ua=s=>Jk.test(s),aT=()=>!0,lT=s=>eT.test(s)&&!tT.test(s),db=()=>!1,rT=s=>sT.test(s),iT=s=>nT.test(s),oT=s=>!Se(s)&&!_e(s),cT=s=>Qr(s,fb,db),Se=s=>ob.test(s),bl=s=>Qr(s,hb,lT),jf=s=>Qr(s,hT,Ke),Cj=s=>Qr(s,ub,db),dT=s=>Qr(s,mb,iT),Jc=s=>Qr(s,xb,rT),_e=s=>cb.test(s),Ki=s=>Zr(s,hb),uT=s=>Zr(s,xT),kj=s=>Zr(s,ub),mT=s=>Zr(s,fb),fT=s=>Zr(s,mb),ed=s=>Zr(s,xb,!0),Qr=(s,a,l)=>{const i=ob.exec(s);return i?i[1]?a(i[1]):l(i[2]):!1},Zr=(s,a,l=!1)=>{const i=cb.exec(s);return i?i[1]?a(i[1]):l:!1},ub=s=>s==="position"||s==="percentage",mb=s=>s==="image"||s==="url",fb=s=>s==="length"||s==="size"||s==="bg-size",hb=s=>s==="length",hT=s=>s==="number",xT=s=>s==="family-name",xb=s=>s==="shadow",pT=()=>{const s=rs("color"),a=rs("font"),l=rs("text"),i=rs("font-weight"),c=rs("tracking"),d=rs("leading"),m=rs("breakpoint"),h=rs("container"),p=rs("spacing"),v=rs("radius"),g=rs("shadow"),j=rs("inset-shadow"),b=rs("text-shadow"),w=rs("drop-shadow"),S=rs("blur"),C=rs("perspective"),N=rs("aspect"),T=rs("ease"),P=rs("animate"),M=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],D=()=>[...k(),_e,Se],A=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],B=()=>[_e,Se,p],Y=()=>[Tr,"full","auto",...B()],G=()=>[qa,"none","subgrid",_e,Se],$=()=>["auto",{span:["full",qa,_e,Se]},qa,_e,Se],oe=()=>[qa,"auto",_e,Se],je=()=>["auto","min","max","fr",_e,Se],ae=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],me=()=>["start","end","center","stretch","center-safe","end-safe"],R=()=>["auto",...B()],O=()=>[Tr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...B()],L=()=>[s,_e,Se],ee=()=>[...k(),kj,Cj,{position:[_e,Se]}],le=()=>["no-repeat",{repeat:["","x","y","space","round"]}],xe=()=>["auto","cover","contain",mT,cT,{size:[_e,Se]}],F=()=>[vf,Ki,bl],W=()=>["","none","full",v,_e,Se],fe=()=>["",Ke,Ki,bl],I=()=>["solid","dashed","dotted","double"],ve=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],de=()=>[Ke,vf,kj,Cj],Ce=()=>["","none",S,_e,Se],Q=()=>["none",Ke,_e,Se],Oe=()=>["none",Ke,_e,Se],$e=()=>[Ke,_e,Se],re=()=>[Tr,"full",...B()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ua],breakpoint:[ua],color:[aT],container:[ua],"drop-shadow":[ua],ease:["in","out","in-out"],font:[oT],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ua],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ua],shadow:[ua],spacing:["px",Ke],text:[ua],"text-shadow":[ua],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Tr,Se,_e,N]}],container:["container"],columns:[{columns:[Ke,Se,_e,h]}],"break-after":[{"break-after":M()}],"break-before":[{"break-before":M()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:D()}],overflow:[{overflow:A()}],"overflow-x":[{"overflow-x":A()}],"overflow-y":[{"overflow-y":A()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Y()}],"inset-x":[{"inset-x":Y()}],"inset-y":[{"inset-y":Y()}],start:[{start:Y()}],end:[{end:Y()}],top:[{top:Y()}],right:[{right:Y()}],bottom:[{bottom:Y()}],left:[{left:Y()}],visibility:["visible","invisible","collapse"],z:[{z:[qa,"auto",_e,Se]}],basis:[{basis:[Tr,"full","auto",h,...B()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ke,Tr,"auto","initial","none",Se]}],grow:[{grow:["",Ke,_e,Se]}],shrink:[{shrink:["",Ke,_e,Se]}],order:[{order:[qa,"first","last","none",_e,Se]}],"grid-cols":[{"grid-cols":G()}],"col-start-end":[{col:$()}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":G()}],"row-start-end":[{row:$()}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":je()}],"auto-rows":[{"auto-rows":je()}],gap:[{gap:B()}],"gap-x":[{"gap-x":B()}],"gap-y":[{"gap-y":B()}],"justify-content":[{justify:[...ae(),"normal"]}],"justify-items":[{"justify-items":[...me(),"normal"]}],"justify-self":[{"justify-self":["auto",...me()]}],"align-content":[{content:["normal",...ae()]}],"align-items":[{items:[...me(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...me(),{baseline:["","last"]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...me(),"baseline"]}],"place-self":[{"place-self":["auto",...me()]}],p:[{p:B()}],px:[{px:B()}],py:[{py:B()}],ps:[{ps:B()}],pe:[{pe:B()}],pt:[{pt:B()}],pr:[{pr:B()}],pb:[{pb:B()}],pl:[{pl:B()}],m:[{m:R()}],mx:[{mx:R()}],my:[{my:R()}],ms:[{ms:R()}],me:[{me:R()}],mt:[{mt:R()}],mr:[{mr:R()}],mb:[{mb:R()}],ml:[{ml:R()}],"space-x":[{"space-x":B()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":B()}],"space-y-reverse":["space-y-reverse"],size:[{size:O()}],w:[{w:[h,"screen",...O()]}],"min-w":[{"min-w":[h,"screen","none",...O()]}],"max-w":[{"max-w":[h,"screen","none","prose",{screen:[m]},...O()]}],h:[{h:["screen","lh",...O()]}],"min-h":[{"min-h":["screen","lh","none",...O()]}],"max-h":[{"max-h":["screen","lh",...O()]}],"font-size":[{text:["base",l,Ki,bl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,_e,jf]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vf,Se]}],"font-family":[{font:[uT,Se,a]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[c,_e,Se]}],"line-clamp":[{"line-clamp":[Ke,"none",_e,jf]}],leading:[{leading:[d,...B()]}],"list-image":[{"list-image":["none",_e,Se]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",_e,Se]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...I(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ke,"from-font","auto",_e,bl]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[Ke,"auto",_e,Se]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:B()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",_e,Se]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",_e,Se]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ee()}],"bg-repeat":[{bg:le()}],"bg-size":[{bg:xe()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qa,_e,Se],radial:["",_e,Se],conic:[qa,_e,Se]},fT,dT]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:fe()}],"border-w-x":[{"border-x":fe()}],"border-w-y":[{"border-y":fe()}],"border-w-s":[{"border-s":fe()}],"border-w-e":[{"border-e":fe()}],"border-w-t":[{"border-t":fe()}],"border-w-r":[{"border-r":fe()}],"border-w-b":[{"border-b":fe()}],"border-w-l":[{"border-l":fe()}],"divide-x":[{"divide-x":fe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":fe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...I(),"hidden","none"]}],"divide-style":[{divide:[...I(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...I(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ke,_e,Se]}],"outline-w":[{outline:["",Ke,Ki,bl]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",g,ed,Jc]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",j,ed,Jc]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:fe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[Ke,bl]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":fe()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",b,ed,Jc]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[Ke,_e,Se]}],"mix-blend":[{"mix-blend":[...ve(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ve()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ke]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[_e,Se]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[Ke]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ee()}],"mask-repeat":[{mask:le()}],"mask-size":[{mask:xe()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",_e,Se]}],filter:[{filter:["","none",_e,Se]}],blur:[{blur:Ce()}],brightness:[{brightness:[Ke,_e,Se]}],contrast:[{contrast:[Ke,_e,Se]}],"drop-shadow":[{"drop-shadow":["","none",w,ed,Jc]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",Ke,_e,Se]}],"hue-rotate":[{"hue-rotate":[Ke,_e,Se]}],invert:[{invert:["",Ke,_e,Se]}],saturate:[{saturate:[Ke,_e,Se]}],sepia:[{sepia:["",Ke,_e,Se]}],"backdrop-filter":[{"backdrop-filter":["","none",_e,Se]}],"backdrop-blur":[{"backdrop-blur":Ce()}],"backdrop-brightness":[{"backdrop-brightness":[Ke,_e,Se]}],"backdrop-contrast":[{"backdrop-contrast":[Ke,_e,Se]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ke,_e,Se]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ke,_e,Se]}],"backdrop-invert":[{"backdrop-invert":["",Ke,_e,Se]}],"backdrop-opacity":[{"backdrop-opacity":[Ke,_e,Se]}],"backdrop-saturate":[{"backdrop-saturate":[Ke,_e,Se]}],"backdrop-sepia":[{"backdrop-sepia":["",Ke,_e,Se]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":B()}],"border-spacing-x":[{"border-spacing-x":B()}],"border-spacing-y":[{"border-spacing-y":B()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",_e,Se]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ke,"initial",_e,Se]}],ease:[{ease:["linear","initial",T,_e,Se]}],delay:[{delay:[Ke,_e,Se]}],animate:[{animate:["none",P,_e,Se]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[C,_e,Se]}],"perspective-origin":[{"perspective-origin":D()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:Oe()}],"scale-x":[{"scale-x":Oe()}],"scale-y":[{"scale-y":Oe()}],"scale-z":[{"scale-z":Oe()}],"scale-3d":["scale-3d"],skew:[{skew:$e()}],"skew-x":[{"skew-x":$e()}],"skew-y":[{"skew-y":$e()}],transform:[{transform:[_e,Se,"","none","gpu","cpu"]}],"transform-origin":[{origin:D()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:re()}],"translate-x":[{"translate-x":re()}],"translate-y":[{"translate-y":re()}],"translate-z":[{"translate-z":re()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",_e,Se]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":B()}],"scroll-mx":[{"scroll-mx":B()}],"scroll-my":[{"scroll-my":B()}],"scroll-ms":[{"scroll-ms":B()}],"scroll-me":[{"scroll-me":B()}],"scroll-mt":[{"scroll-mt":B()}],"scroll-mr":[{"scroll-mr":B()}],"scroll-mb":[{"scroll-mb":B()}],"scroll-ml":[{"scroll-ml":B()}],"scroll-p":[{"scroll-p":B()}],"scroll-px":[{"scroll-px":B()}],"scroll-py":[{"scroll-py":B()}],"scroll-ps":[{"scroll-ps":B()}],"scroll-pe":[{"scroll-pe":B()}],"scroll-pt":[{"scroll-pt":B()}],"scroll-pr":[{"scroll-pr":B()}],"scroll-pb":[{"scroll-pb":B()}],"scroll-pl":[{"scroll-pl":B()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",_e,Se]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[Ke,Ki,bl,jf]}],stroke:[{stroke:["none",...L()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},gT=Kk(pT);function Z(...s){return gT(iy(s))}const Ue=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("rounded-xl border bg-card text-card-foreground shadow",s),...a}));Ue.displayName="Card";const ot=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("flex flex-col space-y-1.5 p-6",s),...a}));ot.displayName="CardHeader";const ct=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("font-semibold leading-none tracking-tight",s),...a}));ct.displayName="CardTitle";const us=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("text-sm text-muted-foreground",s),...a}));us.displayName="CardDescription";const gt=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("p-6 pt-0",s),...a}));gt.displayName="CardContent";const pb=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("flex items-center p-6 pt-0",s),...a}));pb.displayName="CardFooter";var yf="rovingFocusGroup.onEntryFocus",vT={bubbles:!1,cancelable:!0},So="RovingFocusGroup",[Vf,gb,jT]=_d(So),[yT,Pd]=Dn(So,[jT]),[bT,NT]=yT(So),vb=x.forwardRef((s,a)=>e.jsx(Vf.Provider,{scope:s.__scopeRovingFocusGroup,children:e.jsx(Vf.Slot,{scope:s.__scopeRovingFocusGroup,children:e.jsx(wT,{...s,ref:a})})}));vb.displayName=So;var wT=x.forwardRef((s,a)=>{const{__scopeRovingFocusGroup:l,orientation:i,loop:c=!1,dir:d,currentTabStopId:m,defaultCurrentTabStopId:h,onCurrentTabStopIdChange:p,onEntryFocus:v,preventScrollOnEntryFocus:g=!1,...j}=s,b=x.useRef(null),w=Tt(a,b),S=xo(d),[C,N]=Qa({prop:m,defaultProp:h??null,onChange:p,caller:So}),[T,P]=x.useState(!1),M=ws(v),k=gb(l),D=x.useRef(!1),[A,E]=x.useState(0);return x.useEffect(()=>{const B=b.current;if(B)return B.addEventListener(yf,M),()=>B.removeEventListener(yf,M)},[M]),e.jsx(bT,{scope:l,orientation:i,dir:S,loop:c,currentTabStopId:C,onItemFocus:x.useCallback(B=>N(B),[N]),onItemShiftTab:x.useCallback(()=>P(!0),[]),onFocusableItemAdd:x.useCallback(()=>E(B=>B+1),[]),onFocusableItemRemove:x.useCallback(()=>E(B=>B-1),[]),children:e.jsx(dt.div,{tabIndex:T||A===0?-1:0,"data-orientation":i,...j,ref:w,style:{outline:"none",...s.style},onMouseDown:be(s.onMouseDown,()=>{D.current=!0}),onFocus:be(s.onFocus,B=>{const Y=!D.current;if(B.target===B.currentTarget&&Y&&!T){const G=new CustomEvent(yf,vT);if(B.currentTarget.dispatchEvent(G),!G.defaultPrevented){const $=k().filter(R=>R.focusable),oe=$.find(R=>R.active),je=$.find(R=>R.id===C),me=[oe,je,...$].filter(Boolean).map(R=>R.ref.current);bb(me,g)}}D.current=!1}),onBlur:be(s.onBlur,()=>P(!1))})})}),jb="RovingFocusGroupItem",yb=x.forwardRef((s,a)=>{const{__scopeRovingFocusGroup:l,focusable:i=!0,active:c=!1,tabStopId:d,children:m,...h}=s,p=jn(),v=d||p,g=NT(jb,l),j=g.currentTabStopId===v,b=gb(l),{onFocusableItemAdd:w,onFocusableItemRemove:S,currentTabStopId:C}=g;return x.useEffect(()=>{if(i)return w(),()=>S()},[i,w,S]),e.jsx(Vf.ItemSlot,{scope:l,id:v,focusable:i,active:c,children:e.jsx(dt.span,{tabIndex:j?0:-1,"data-orientation":g.orientation,...h,ref:a,onMouseDown:be(s.onMouseDown,N=>{i?g.onItemFocus(v):N.preventDefault()}),onFocus:be(s.onFocus,()=>g.onItemFocus(v)),onKeyDown:be(s.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){g.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const T=CT(N,g.orientation,g.dir);if(T!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let M=b().filter(k=>k.focusable).map(k=>k.ref.current);if(T==="last")M.reverse();else if(T==="prev"||T==="next"){T==="prev"&&M.reverse();const k=M.indexOf(N.currentTarget);M=g.loop?kT(M,k+1):M.slice(k+1)}setTimeout(()=>bb(M))}}),children:typeof m=="function"?m({isCurrentTabStop:j,hasTabStop:C!=null}):m})})});yb.displayName=jb;var ST={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _T(s,a){return a!=="rtl"?s:s==="ArrowLeft"?"ArrowRight":s==="ArrowRight"?"ArrowLeft":s}function CT(s,a,l){const i=_T(s.key,l);if(!(a==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(a==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return ST[i]}function bb(s,a=!1){const l=document.activeElement;for(const i of s)if(i===l||(i.focus({preventScroll:a}),document.activeElement!==l))return}function kT(s,a){return s.map((l,i)=>s[(a+i)%s.length])}var Nb=vb,wb=yb,Ld="Tabs",[TT]=Dn(Ld,[Pd]),Sb=Pd(),[ET,_h]=TT(Ld),_b=x.forwardRef((s,a)=>{const{__scopeTabs:l,value:i,onValueChange:c,defaultValue:d,orientation:m="horizontal",dir:h,activationMode:p="automatic",...v}=s,g=xo(h),[j,b]=Qa({prop:i,onChange:c,defaultProp:d??"",caller:Ld});return e.jsx(ET,{scope:l,baseId:jn(),value:j,onValueChange:b,orientation:m,dir:g,activationMode:p,children:e.jsx(dt.div,{dir:g,"data-orientation":m,...v,ref:a})})});_b.displayName=Ld;var Cb="TabsList",kb=x.forwardRef((s,a)=>{const{__scopeTabs:l,loop:i=!0,...c}=s,d=_h(Cb,l),m=Sb(l);return e.jsx(Nb,{asChild:!0,...m,orientation:d.orientation,dir:d.dir,loop:i,children:e.jsx(dt.div,{role:"tablist","aria-orientation":d.orientation,...c,ref:a})})});kb.displayName=Cb;var Tb="TabsTrigger",Eb=x.forwardRef((s,a)=>{const{__scopeTabs:l,value:i,disabled:c=!1,...d}=s,m=_h(Tb,l),h=Sb(l),p=Ob(m.baseId,i),v=Ab(m.baseId,i),g=i===m.value;return e.jsx(wb,{asChild:!0,...h,focusable:!c,active:g,children:e.jsx(dt.button,{type:"button",role:"tab","aria-selected":g,"aria-controls":v,"data-state":g?"active":"inactive","data-disabled":c?"":void 0,disabled:c,id:p,...d,ref:a,onMouseDown:be(s.onMouseDown,j=>{!c&&j.button===0&&j.ctrlKey===!1?m.onValueChange(i):j.preventDefault()}),onKeyDown:be(s.onKeyDown,j=>{[" ","Enter"].includes(j.key)&&m.onValueChange(i)}),onFocus:be(s.onFocus,()=>{const j=m.activationMode!=="manual";!g&&!c&&j&&m.onValueChange(i)})})})});Eb.displayName=Tb;var Mb="TabsContent",Db=x.forwardRef((s,a)=>{const{__scopeTabs:l,value:i,forceMount:c,children:d,...m}=s,h=_h(Mb,l),p=Ob(h.baseId,i),v=Ab(h.baseId,i),g=i===h.value,j=x.useRef(g);return x.useEffect(()=>{const b=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(b)},[]),e.jsx(Is,{present:c||g,children:({present:b})=>e.jsx(dt.div,{"data-state":g?"active":"inactive","data-orientation":h.orientation,role:"tabpanel","aria-labelledby":p,hidden:!b,id:v,tabIndex:0,...m,ref:a,style:{...s.style,animationDuration:j.current?"0s":void 0},children:b&&d})})});Db.displayName=Mb;function Ob(s,a){return`${s}-trigger-${a}`}function Ab(s,a){return`${s}-content-${a}`}var MT=_b,Rb=kb,zb=Eb,Pb=Db;const Ml=MT,$a=x.forwardRef(({className:s,...a},l)=>e.jsx(Rb,{ref:l,className:Z("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",s),...a}));$a.displayName=Rb.displayName;const bt=x.forwardRef(({className:s,...a},l)=>e.jsx(zb,{ref:l,className:Z("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",s),...a}));bt.displayName=zb.displayName;const Vt=x.forwardRef(({className:s,...a},l)=>e.jsx(Pb,{ref:l,className:Z("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",s),...a}));Vt.displayName=Pb.displayName;function DT(s,a){return x.useReducer((l,i)=>a[l][i]??l,s)}var Ch="ScrollArea",[Lb]=Dn(Ch),[OT,bn]=Lb(Ch),Bb=x.forwardRef((s,a)=>{const{__scopeScrollArea:l,type:i="hover",dir:c,scrollHideDelay:d=600,...m}=s,[h,p]=x.useState(null),[v,g]=x.useState(null),[j,b]=x.useState(null),[w,S]=x.useState(null),[C,N]=x.useState(null),[T,P]=x.useState(0),[M,k]=x.useState(0),[D,A]=x.useState(!1),[E,B]=x.useState(!1),Y=Tt(a,$=>p($)),G=xo(c);return e.jsx(OT,{scope:l,type:i,dir:G,scrollHideDelay:d,scrollArea:h,viewport:v,onViewportChange:g,content:j,onContentChange:b,scrollbarX:w,onScrollbarXChange:S,scrollbarXEnabled:D,onScrollbarXEnabledChange:A,scrollbarY:C,onScrollbarYChange:N,scrollbarYEnabled:E,onScrollbarYEnabledChange:B,onCornerWidthChange:P,onCornerHeightChange:k,children:e.jsx(dt.div,{dir:G,...m,ref:Y,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":M+"px",...s.style}})})});Bb.displayName=Ch;var Ub="ScrollAreaViewport",Hb=x.forwardRef((s,a)=>{const{__scopeScrollArea:l,children:i,nonce:c,...d}=s,m=bn(Ub,l),h=x.useRef(null),p=Tt(a,h,m.onViewportChange);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:c}),e.jsx(dt.div,{"data-radix-scroll-area-viewport":"",...d,ref:p,style:{overflowX:m.scrollbarXEnabled?"scroll":"hidden",overflowY:m.scrollbarYEnabled?"scroll":"hidden",...s.style},children:e.jsx("div",{ref:m.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});Hb.displayName=Ub;var Vn="ScrollAreaScrollbar",kh=x.forwardRef((s,a)=>{const{forceMount:l,...i}=s,c=bn(Vn,s.__scopeScrollArea),{onScrollbarXEnabledChange:d,onScrollbarYEnabledChange:m}=c,h=s.orientation==="horizontal";return x.useEffect(()=>(h?d(!0):m(!0),()=>{h?d(!1):m(!1)}),[h,d,m]),c.type==="hover"?e.jsx(AT,{...i,ref:a,forceMount:l}):c.type==="scroll"?e.jsx(RT,{...i,ref:a,forceMount:l}):c.type==="auto"?e.jsx(Fb,{...i,ref:a,forceMount:l}):c.type==="always"?e.jsx(Th,{...i,ref:a}):null});kh.displayName=Vn;var AT=x.forwardRef((s,a)=>{const{forceMount:l,...i}=s,c=bn(Vn,s.__scopeScrollArea),[d,m]=x.useState(!1);return x.useEffect(()=>{const h=c.scrollArea;let p=0;if(h){const v=()=>{window.clearTimeout(p),m(!0)},g=()=>{p=window.setTimeout(()=>m(!1),c.scrollHideDelay)};return h.addEventListener("pointerenter",v),h.addEventListener("pointerleave",g),()=>{window.clearTimeout(p),h.removeEventListener("pointerenter",v),h.removeEventListener("pointerleave",g)}}},[c.scrollArea,c.scrollHideDelay]),e.jsx(Is,{present:l||d,children:e.jsx(Fb,{"data-state":d?"visible":"hidden",...i,ref:a})})}),RT=x.forwardRef((s,a)=>{const{forceMount:l,...i}=s,c=bn(Vn,s.__scopeScrollArea),d=s.orientation==="horizontal",m=Ud(()=>p("SCROLL_END"),100),[h,p]=DT("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return x.useEffect(()=>{if(h==="idle"){const v=window.setTimeout(()=>p("HIDE"),c.scrollHideDelay);return()=>window.clearTimeout(v)}},[h,c.scrollHideDelay,p]),x.useEffect(()=>{const v=c.viewport,g=d?"scrollLeft":"scrollTop";if(v){let j=v[g];const b=()=>{const w=v[g];j!==w&&(p("SCROLL"),m()),j=w};return v.addEventListener("scroll",b),()=>v.removeEventListener("scroll",b)}},[c.viewport,d,p,m]),e.jsx(Is,{present:l||h!=="hidden",children:e.jsx(Th,{"data-state":h==="hidden"?"hidden":"visible",...i,ref:a,onPointerEnter:be(s.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:be(s.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),Fb=x.forwardRef((s,a)=>{const l=bn(Vn,s.__scopeScrollArea),{forceMount:i,...c}=s,[d,m]=x.useState(!1),h=s.orientation==="horizontal",p=Ud(()=>{if(l.viewport){const v=l.viewport.offsetWidth{const{orientation:l="vertical",...i}=s,c=bn(Vn,s.__scopeScrollArea),d=x.useRef(null),m=x.useRef(0),[h,p]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),v=$b(h.viewport,h.content),g={...i,sizes:h,onSizesChange:p,hasThumb:v>0&&v<1,onThumbChange:b=>d.current=b,onThumbPointerUp:()=>m.current=0,onThumbPointerDown:b=>m.current=b};function j(b,w){return HT(b,m.current,h,w)}return l==="horizontal"?e.jsx(zT,{...g,ref:a,onThumbPositionChange:()=>{if(c.viewport&&d.current){const b=c.viewport.scrollLeft,w=Tj(b,h,c.dir);d.current.style.transform=`translate3d(${w}px, 0, 0)`}},onWheelScroll:b=>{c.viewport&&(c.viewport.scrollLeft=b)},onDragScroll:b=>{c.viewport&&(c.viewport.scrollLeft=j(b,c.dir))}}):l==="vertical"?e.jsx(PT,{...g,ref:a,onThumbPositionChange:()=>{if(c.viewport&&d.current){const b=c.viewport.scrollTop,w=Tj(b,h);d.current.style.transform=`translate3d(0, ${w}px, 0)`}},onWheelScroll:b=>{c.viewport&&(c.viewport.scrollTop=b)},onDragScroll:b=>{c.viewport&&(c.viewport.scrollTop=j(b))}}):null}),zT=x.forwardRef((s,a)=>{const{sizes:l,onSizesChange:i,...c}=s,d=bn(Vn,s.__scopeScrollArea),[m,h]=x.useState(),p=x.useRef(null),v=Tt(a,p,d.onScrollbarXChange);return x.useEffect(()=>{p.current&&h(getComputedStyle(p.current))},[p]),e.jsx(qb,{"data-orientation":"horizontal",...c,ref:v,sizes:l,style:{bottom:0,left:d.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:d.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Bd(l)+"px",...s.style},onThumbPointerDown:g=>s.onThumbPointerDown(g.x),onDragScroll:g=>s.onDragScroll(g.x),onWheelScroll:(g,j)=>{if(d.viewport){const b=d.viewport.scrollLeft+g.deltaX;s.onWheelScroll(b),Wb(b,j)&&g.preventDefault()}},onResize:()=>{p.current&&d.viewport&&m&&i({content:d.viewport.scrollWidth,viewport:d.viewport.offsetWidth,scrollbar:{size:p.current.clientWidth,paddingStart:yd(m.paddingLeft),paddingEnd:yd(m.paddingRight)}})}})}),PT=x.forwardRef((s,a)=>{const{sizes:l,onSizesChange:i,...c}=s,d=bn(Vn,s.__scopeScrollArea),[m,h]=x.useState(),p=x.useRef(null),v=Tt(a,p,d.onScrollbarYChange);return x.useEffect(()=>{p.current&&h(getComputedStyle(p.current))},[p]),e.jsx(qb,{"data-orientation":"vertical",...c,ref:v,sizes:l,style:{top:0,right:d.dir==="ltr"?0:void 0,left:d.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Bd(l)+"px",...s.style},onThumbPointerDown:g=>s.onThumbPointerDown(g.y),onDragScroll:g=>s.onDragScroll(g.y),onWheelScroll:(g,j)=>{if(d.viewport){const b=d.viewport.scrollTop+g.deltaY;s.onWheelScroll(b),Wb(b,j)&&g.preventDefault()}},onResize:()=>{p.current&&d.viewport&&m&&i({content:d.viewport.scrollHeight,viewport:d.viewport.offsetHeight,scrollbar:{size:p.current.clientHeight,paddingStart:yd(m.paddingTop),paddingEnd:yd(m.paddingBottom)}})}})}),[LT,Yb]=Lb(Vn),qb=x.forwardRef((s,a)=>{const{__scopeScrollArea:l,sizes:i,hasThumb:c,onThumbChange:d,onThumbPointerUp:m,onThumbPointerDown:h,onThumbPositionChange:p,onDragScroll:v,onWheelScroll:g,onResize:j,...b}=s,w=bn(Vn,l),[S,C]=x.useState(null),N=Tt(a,Y=>C(Y)),T=x.useRef(null),P=x.useRef(""),M=w.viewport,k=i.content-i.viewport,D=ws(g),A=ws(p),E=Ud(j,10);function B(Y){if(T.current){const G=Y.clientX-T.current.left,$=Y.clientY-T.current.top;v({x:G,y:$})}}return x.useEffect(()=>{const Y=G=>{const $=G.target;S?.contains($)&&D(G,k)};return document.addEventListener("wheel",Y,{passive:!1}),()=>document.removeEventListener("wheel",Y,{passive:!1})},[M,S,k,D]),x.useEffect(A,[i,A]),Gr(S,E),Gr(w.content,E),e.jsx(LT,{scope:l,scrollbar:S,hasThumb:c,onThumbChange:ws(d),onThumbPointerUp:ws(m),onThumbPositionChange:A,onThumbPointerDown:ws(h),children:e.jsx(dt.div,{...b,ref:N,style:{position:"absolute",...b.style},onPointerDown:be(s.onPointerDown,Y=>{Y.button===0&&(Y.target.setPointerCapture(Y.pointerId),T.current=S.getBoundingClientRect(),P.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",w.viewport&&(w.viewport.style.scrollBehavior="auto"),B(Y))}),onPointerMove:be(s.onPointerMove,B),onPointerUp:be(s.onPointerUp,Y=>{const G=Y.target;G.hasPointerCapture(Y.pointerId)&&G.releasePointerCapture(Y.pointerId),document.body.style.webkitUserSelect=P.current,w.viewport&&(w.viewport.style.scrollBehavior=""),T.current=null})})})}),jd="ScrollAreaThumb",Vb=x.forwardRef((s,a)=>{const{forceMount:l,...i}=s,c=Yb(jd,s.__scopeScrollArea);return e.jsx(Is,{present:l||c.hasThumb,children:e.jsx(BT,{ref:a,...i})})}),BT=x.forwardRef((s,a)=>{const{__scopeScrollArea:l,style:i,...c}=s,d=bn(jd,l),m=Yb(jd,l),{onThumbPositionChange:h}=m,p=Tt(a,j=>m.onThumbChange(j)),v=x.useRef(void 0),g=Ud(()=>{v.current&&(v.current(),v.current=void 0)},100);return x.useEffect(()=>{const j=d.viewport;if(j){const b=()=>{if(g(),!v.current){const w=FT(j,h);v.current=w,h()}};return h(),j.addEventListener("scroll",b),()=>j.removeEventListener("scroll",b)}},[d.viewport,g,h]),e.jsx(dt.div,{"data-state":m.hasThumb?"visible":"hidden",...c,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:be(s.onPointerDownCapture,j=>{const w=j.target.getBoundingClientRect(),S=j.clientX-w.left,C=j.clientY-w.top;m.onThumbPointerDown({x:S,y:C})}),onPointerUp:be(s.onPointerUp,m.onThumbPointerUp)})});Vb.displayName=jd;var Eh="ScrollAreaCorner",Gb=x.forwardRef((s,a)=>{const l=bn(Eh,s.__scopeScrollArea),i=!!(l.scrollbarX&&l.scrollbarY);return l.type!=="scroll"&&i?e.jsx(UT,{...s,ref:a}):null});Gb.displayName=Eh;var UT=x.forwardRef((s,a)=>{const{__scopeScrollArea:l,...i}=s,c=bn(Eh,l),[d,m]=x.useState(0),[h,p]=x.useState(0),v=!!(d&&h);return Gr(c.scrollbarX,()=>{const g=c.scrollbarX?.offsetHeight||0;c.onCornerHeightChange(g),p(g)}),Gr(c.scrollbarY,()=>{const g=c.scrollbarY?.offsetWidth||0;c.onCornerWidthChange(g),m(g)}),v?e.jsx(dt.div,{...i,ref:a,style:{width:d,height:h,position:"absolute",right:c.dir==="ltr"?0:void 0,left:c.dir==="rtl"?0:void 0,bottom:0,...s.style}}):null});function yd(s){return s?parseInt(s,10):0}function $b(s,a){const l=s/a;return isNaN(l)?0:l}function Bd(s){const a=$b(s.viewport,s.content),l=s.scrollbar.paddingStart+s.scrollbar.paddingEnd,i=(s.scrollbar.size-l)*a;return Math.max(i,18)}function HT(s,a,l,i="ltr"){const c=Bd(l),d=c/2,m=a||d,h=c-m,p=l.scrollbar.paddingStart+m,v=l.scrollbar.size-l.scrollbar.paddingEnd-h,g=l.content-l.viewport,j=i==="ltr"?[0,g]:[g*-1,0];return Ib([p,v],j)(s)}function Tj(s,a,l="ltr"){const i=Bd(a),c=a.scrollbar.paddingStart+a.scrollbar.paddingEnd,d=a.scrollbar.size-c,m=a.content-a.viewport,h=d-i,p=l==="ltr"?[0,m]:[m*-1,0],v=rh(s,p);return Ib([0,m],[0,h])(v)}function Ib(s,a){return l=>{if(s[0]===s[1]||a[0]===a[1])return a[0];const i=(a[1]-a[0])/(s[1]-s[0]);return a[0]+i*(l-s[0])}}function Wb(s,a){return s>0&&s{})=>{let l={left:s.scrollLeft,top:s.scrollTop},i=0;return(function c(){const d={left:s.scrollLeft,top:s.scrollTop},m=l.left!==d.left,h=l.top!==d.top;(m||h)&&a(),l=d,i=window.requestAnimationFrame(c)})(),()=>window.cancelAnimationFrame(i)};function Ud(s,a){const l=ws(s),i=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(i.current),[]),x.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(l,a)},[l,a])}function Gr(s,a){const l=ws(a);oy(()=>{let i=0;if(s){const c=new ResizeObserver(()=>{cancelAnimationFrame(i),i=window.requestAnimationFrame(l)});return c.observe(s),()=>{window.cancelAnimationFrame(i),c.unobserve(s)}}},[s,l])}var Xb=Bb,YT=Hb,qT=Gb;const Ct=x.forwardRef(({className:s,children:a,...l},i)=>e.jsxs(Xb,{ref:i,className:Z("relative overflow-hidden",s),...l,children:[e.jsx(YT,{className:"h-full w-full rounded-[inherit]",children:a}),e.jsx(Kb,{}),e.jsx(qT,{})]}));Ct.displayName=Xb.displayName;const Kb=x.forwardRef(({className:s,orientation:a="vertical",...l},i)=>e.jsx(kh,{ref:i,orientation:a,className:Z("flex touch-none select-none transition-colors",a==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",a==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",s),...l,children:e.jsx(Vb,{className:"relative flex-1 rounded-full bg-border"})}));Kb.displayName=kh.displayName;function Ej({className:s,...a}){return e.jsx("div",{className:Z("animate-pulse rounded-md bg-primary/10",s),...a})}function VT(s,a=[]){let l=[];function i(d,m){const h=x.createContext(m);h.displayName=d+"Context";const p=l.length;l=[...l,m];const v=j=>{const{scope:b,children:w,...S}=j,C=b?.[s]?.[p]||h,N=x.useMemo(()=>S,Object.values(S));return e.jsx(C.Provider,{value:N,children:w})};v.displayName=d+"Provider";function g(j,b){const w=b?.[s]?.[p]||h,S=x.useContext(w);if(S)return S;if(m!==void 0)return m;throw new Error(`\`${j}\` must be used within \`${d}\``)}return[v,g]}const c=()=>{const d=l.map(m=>x.createContext(m));return function(h){const p=h?.[s]||d;return x.useMemo(()=>({[`__scope${s}`]:{...h,[s]:p}}),[h,p])}};return c.scopeName=s,[i,GT(c,...a)]}function GT(...s){const a=s[0];if(s.length===1)return a;const l=()=>{const i=s.map(c=>({useScope:c(),scopeName:c.scopeName}));return function(d){const m=i.reduce((h,{useScope:p,scopeName:v})=>{const j=p(d)[`__scope${v}`];return{...h,...j}},{});return x.useMemo(()=>({[`__scope${a.scopeName}`]:m}),[m])}};return l.scopeName=a.scopeName,l}var $T=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Qb=$T.reduce((s,a)=>{const l=ih(`Primitive.${a}`),i=x.forwardRef((c,d)=>{const{asChild:m,...h}=c,p=m?l:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(p,{...h,ref:d})});return i.displayName=`Primitive.${a}`,{...s,[a]:i}},{}),Mh="Progress",Dh=100,[IT]=VT(Mh),[WT,XT]=IT(Mh),Zb=x.forwardRef((s,a)=>{const{__scopeProgress:l,value:i=null,max:c,getValueLabel:d=KT,...m}=s;(c||c===0)&&!Mj(c)&&console.error(QT(`${c}`,"Progress"));const h=Mj(c)?c:Dh;i!==null&&!Dj(i,h)&&console.error(ZT(`${i}`,"Progress"));const p=Dj(i,h)?i:null,v=bd(p)?d(p,h):void 0;return e.jsx(WT,{scope:l,value:p,max:h,children:e.jsx(Qb.div,{"aria-valuemax":h,"aria-valuemin":0,"aria-valuenow":bd(p)?p:void 0,"aria-valuetext":v,role:"progressbar","data-state":t0(p,h),"data-value":p??void 0,"data-max":h,...m,ref:a})})});Zb.displayName=Mh;var Jb="ProgressIndicator",e0=x.forwardRef((s,a)=>{const{__scopeProgress:l,...i}=s,c=XT(Jb,l);return e.jsx(Qb.div,{"data-state":t0(c.value,c.max),"data-value":c.value??void 0,"data-max":c.max,...i,ref:a})});e0.displayName=Jb;function KT(s,a){return`${Math.round(s/a*100)}%`}function t0(s,a){return s==null?"indeterminate":s===a?"complete":"loading"}function bd(s){return typeof s=="number"}function Mj(s){return bd(s)&&!isNaN(s)&&s>0}function Dj(s,a){return bd(s)&&!isNaN(s)&&s<=a&&s>=0}function QT(s,a){return`Invalid prop \`max\` of value \`${s}\` supplied to \`${a}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Dh}\`.`}function ZT(s,a){return`Invalid prop \`value\` of value \`${s}\` supplied to \`${a}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${Dh} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var s0=Zb,JT=e0;const _o=x.forwardRef(({className:s,value:a,...l},i)=>e.jsx(s0,{ref:i,className:Z("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",s),...l,children:e.jsx(JT,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));_o.displayName=s0.displayName;const eE={light:"",dark:".dark"},n0=x.createContext(null);function a0(){const s=x.useContext(n0);if(!s)throw new Error("useChart must be used within a ");return s}const Dr=x.forwardRef(({id:s,className:a,children:l,config:i,...c},d)=>{const m=x.useId(),h=`chart-${s||m.replace(/:/g,"")}`;return e.jsx(n0.Provider,{value:{config:i},children:e.jsxs("div",{"data-chart":h,ref:d,className:Z("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",a),...c,children:[e.jsx(tE,{id:h,config:i}),e.jsx(l2,{children:l})]})})});Dr.displayName="Chart";const tE=({id:s,config:a})=>{const l=Object.entries(a).filter(([,i])=>i.theme||i.color);return l.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(eE).map(([i,c])=>` ${c} [data-chart=${s}] { ${l.map(([d,m])=>{const h=m.theme?.[i]||m.color;return h?` --color-${d}: ${h};`:null}).join(` `)} } `).join(` `)}}):null},Qi=r2,Or=x.forwardRef(({active:s,payload:a,className:l,indicator:i="dot",hideLabel:c=!1,hideIndicator:d=!1,label:m,labelFormatter:h,labelClassName:p,formatter:v,color:g,nameKey:j,labelKey:b},w)=>{const{config:S}=a0(),C=x.useMemo(()=>{if(c||!a?.length)return null;const[T]=a,P=`${b||T?.dataKey||T?.name||"value"}`,M=Gf(S,T,P),k=!b&&typeof m=="string"?S[m]?.label||m:M?.label;return h?e.jsx("div",{className:Z("font-medium",p),children:h(k,a)}):k?e.jsx("div",{className:Z("font-medium",p),children:k}):null},[m,h,a,c,p,S,b]);if(!s||!a?.length)return null;const N=a.length===1&&i!=="dot";return e.jsxs("div",{ref:w,className:Z("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",l),children:[N?null:C,e.jsx("div",{className:"grid gap-1.5",children:a.filter(T=>T.type!=="none").map((T,P)=>{const M=`${j||T.name||T.dataKey||"value"}`,k=Gf(S,T,M),D=g||T.payload.fill||T.color;return e.jsx("div",{className:Z("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",i==="dot"&&"items-center"),children:v&&T?.value!==void 0&&T.name?v(T.value,T.name,T,P,T.payload):e.jsxs(e.Fragment,{children:[k?.icon?e.jsx(k.icon,{}):!d&&e.jsx("div",{className:Z("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":i==="dot","w-1":i==="line","w-0 border-[1.5px] border-dashed bg-transparent":i==="dashed","my-0.5":N&&i==="dashed"}),style:{"--color-bg":D,"--color-border":D}}),e.jsxs("div",{className:Z("flex flex-1 justify-between leading-none",N?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[N?C:null,e.jsx("span",{className:"text-muted-foreground",children:k?.label||T.name})]}),T.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:T.value.toLocaleString()})]})]})},T.dataKey)})})]})});Or.displayName="ChartTooltip";const sE=i2,l0=x.forwardRef(({className:s,hideIcon:a=!1,payload:l,verticalAlign:i="bottom",nameKey:c},d)=>{const{config:m}=a0();return l?.length?e.jsx("div",{ref:d,className:Z("flex items-center justify-center gap-4",i==="top"?"pb-3":"pt-3",s),children:l.filter(h=>h.type!=="none").map(h=>{const p=`${c||h.dataKey||"value"}`,v=Gf(m,h,p);return e.jsxs("div",{className:Z("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[v?.icon&&!a?e.jsx(v.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:h.color}}),v?.label]},h.value)})}):null});l0.displayName="ChartLegend";function Gf(s,a,l){if(typeof a!="object"||a===null)return;const i="payload"in a&&typeof a.payload=="object"&&a.payload!==null?a.payload:void 0;let c=l;return l in a&&typeof a[l]=="string"?c=a[l]:i&&l in i&&typeof i[l]=="string"&&(c=i[l]),c in s?s[c]:s[l]}const Oj=s=>typeof s=="boolean"?`${s}`:s===0?"0":s,Aj=iy,Jr=(s,a)=>l=>{var i;if(a?.variants==null)return Aj(s,l?.class,l?.className);const{variants:c,defaultVariants:d}=a,m=Object.keys(c).map(v=>{const g=l?.[v],j=d?.[v];if(g===null)return null;const b=Oj(g)||Oj(j);return c[v][b]}),h=l&&Object.entries(l).reduce((v,g)=>{let[j,b]=g;return b===void 0||(v[j]=b),v},{}),p=a==null||(i=a.compoundVariants)===null||i===void 0?void 0:i.reduce((v,g)=>{let{class:j,className:b,...w}=g;return Object.entries(w).every(S=>{let[C,N]=S;return Array.isArray(N)?N.includes({...d,...h}[C]):{...d,...h}[C]===N})?[...v,j,b]:v},[]);return Aj(s,m,p,l?.class,l?.className)},io=Jr("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"}}),q=x.forwardRef(({className:s,variant:a,size:l,asChild:i=!1,...c},d)=>{const m=i?f2:"button";return e.jsx(m,{className:Z(io({variant:a,size:l,className:s})),ref:d,...c})});q.displayName="Button";function nE(){const[s,a]=x.useState(null),[l,i]=x.useState(!0),[c,d]=x.useState(0),[m,h]=x.useState(24),[p,v]=x.useState(!0),[g,j]=x.useState(null),[b,w]=x.useState(!0),S=x.useCallback(async()=>{try{w(!0);const Y=await $t.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");j({hitokoto:Y.data.hitokoto,from:Y.data.from||Y.data.from_who||"未知"})}catch(Y){console.error("获取一言失败:",Y),j({hitokoto:"人生就像一盒巧克力,你永远不知道下一颗是什么味道。",from:"阿甘正传"})}finally{w(!1)}},[]),C=x.useCallback(async()=>{try{const Y=localStorage.getItem("access-token"),G=await $t.get(`/api/webui/statistics/dashboard?hours=${m}`,{headers:{Authorization:`Bearer ${Y}`}});a(G.data),i(!1),d(100)}catch(Y){console.error("Failed to fetch dashboard data:",Y),i(!1),d(100)}},[m]);if(x.useEffect(()=>{if(!l)return;d(0);const Y=setTimeout(()=>d(15),200),G=setTimeout(()=>d(30),800),$=setTimeout(()=>d(45),2e3),oe=setTimeout(()=>d(60),4e3),je=setTimeout(()=>d(75),6500),ae=setTimeout(()=>d(85),9e3),me=setTimeout(()=>d(92),11e3);return()=>{clearTimeout(Y),clearTimeout(G),clearTimeout($),clearTimeout(oe),clearTimeout(je),clearTimeout(ae),clearTimeout(me)}},[l]),x.useEffect(()=>{C(),S()},[C,S]),x.useEffect(()=>{if(!p)return;const Y=setInterval(()=>{C()},3e4);return()=>clearInterval(Y)},[p,C]),l||!s)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(xa,{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(_o,{value:c,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c,"%"]})]})]})});const{summary:N,model_stats:T,hourly_data:P,daily_data:M,recent_activity:k}=s,D=Y=>{const G=Math.floor(Y/3600),$=Math.floor(Y%3600/60);return`${G}小时${$}分钟`},A=Y=>new Date(Y).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),E=T.slice(0,6).map(Y=>({name:Y.model_name,value:Y.request_count,fill:`hsl(var(--chart-${T.indexOf(Y)%5+1}))`})),B={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(Ct,{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(Ml,{value:m.toString(),onValueChange:Y=>h(Number(Y)),children:e.jsxs($a,{className:"grid grid-cols-3 w-full sm:w-auto",children:[e.jsx(bt,{value:"24",children:"24小时"}),e.jsx(bt,{value:"168",children:"7天"}),e.jsx(bt,{value:"720",children:"30天"})]})}),e.jsxs(q,{variant:p?"default":"outline",size:"sm",onClick:()=>v(!p),className:"gap-2",children:[e.jsx(xa,{className:`h-4 w-4 ${p?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"自动刷新"})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:C,children:e.jsx(xa,{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(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"总请求数"}),e.jsx(C2,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-2xl font-bold",children:N.total_requests.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["最近",m<48?m+"小时":Math.floor(m/24)+"天"]})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"总花费"}),e.jsx(k2,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:["¥",N.total_cost.toFixed(2)]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.cost_per_hour>0?`¥${N.cost_per_hour.toFixed(2)}/小时`:"暂无数据"})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"Token消耗"}),e.jsx(T2,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(N.total_tokens/1e3).toFixed(1),"K"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:N.tokens_per_hour>0?`${(N.tokens_per_hour/1e3).toFixed(1)}K/小时`:"暂无数据"})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"平均响应"}),e.jsx(ao,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[N.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(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"在线时长"}),e.jsx(_l,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(gt,{children:e.jsx("div",{className:"text-xl font-bold",children:D(N.online_time)})})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"消息处理"}),e.jsx(po,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-xl font-bold",children:N.total_messages.toLocaleString()}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["回复 ",N.total_replies.toLocaleString()," 条"]})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"成本效率"}),e.jsx(E2,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-xl font-bold",children:N.total_messages>0?`¥${(N.total_cost/N.total_messages*100).toFixed(2)}`:"¥0.00"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"每100条消息"})]})]})]}),e.jsxs(Ml,{defaultValue:"trends",className:"space-y-4",children:[e.jsxs($a,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[e.jsx(bt,{value:"trends",children:"趋势"}),e.jsx(bt,{value:"models",children:"模型"}),e.jsx(bt,{value:"activity",children:"活动"}),e.jsx(bt,{value:"daily",children:"日统计"})]}),e.jsxs(Vt,{value:"trends",className:"space-y-4",children:[e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"请求趋势"}),e.jsxs(us,{children:["最近",m,"小时的请求量变化"]})]}),e.jsx(gt,{children:e.jsx(Dr,{config:B,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(o2,{data:P,children:[e.jsx(Xc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Kc,{dataKey:"timestamp",tickFormatter:Y=>A(Y),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ii,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Or,{labelFormatter:Y=>A(Y)})}),e.jsx(c2,{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(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"花费趋势"}),e.jsx(us,{children:"API调用成本变化"})]}),e.jsx(gt,{children:e.jsx(Dr,{config:B,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(uf,{data:P,children:[e.jsx(Xc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Kc,{dataKey:"timestamp",tickFormatter:Y=>A(Y),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ii,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Or,{labelFormatter:Y=>A(Y)})}),e.jsx(Qc,{dataKey:"cost",fill:"var(--color-cost)"})]})})})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"Token消耗"}),e.jsx(us,{children:"Token使用量变化"})]}),e.jsx(gt,{children:e.jsx(Dr,{config:B,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:e.jsxs(uf,{data:P,children:[e.jsx(Xc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Kc,{dataKey:"timestamp",tickFormatter:Y=>A(Y),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ii,{stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Or,{labelFormatter:Y=>A(Y)})}),e.jsx(Qc,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})]})]})]}),e.jsx(Vt,{value:"models",className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"模型请求分布"}),e.jsx(us,{children:"各模型使用占比"})]}),e.jsx(gt,{children:e.jsx(Dr,{config:Object.fromEntries(T.slice(0,6).map((Y,G)=>[Y.model_name,{label:Y.model_name,color:`hsl(var(--chart-${G%5+1}))`}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:e.jsxs(d2,{children:[e.jsx(Qi,{content:e.jsx(Or,{})}),e.jsx(u2,{data:E,cx:"50%",cy:"50%",labelLine:!1,label:({name:Y,percent:G})=>`${Y} ${G?(G*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:E.map((Y,G)=>e.jsx(m2,{fill:Y.fill},`cell-${G}`))})]})})})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"模型详细统计"}),e.jsx(us,{children:"请求数、花费和性能"})]}),e.jsx(gt,{children:e.jsx(Ct,{className:"h-[300px] sm:h-[400px]",children:e.jsx("div",{className:"space-y-3",children:T.map((Y,G)=>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:Y.model_name}),e.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--chart-${G%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:Y.request_count.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1 font-medium",children:["¥",Y.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:[(Y.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:[Y.avg_response_time.toFixed(2),"s"]})]})]})]},G))})})})]})]})}),e.jsx(Vt,{value:"activity",children:e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"最近活动"}),e.jsx(us,{children:"最新的API调用记录"})]}),e.jsx(gt,{children:e.jsx(Ct,{className:"h-[400px] sm:h-[500px]",children:e.jsx("div",{className:"space-y-2",children:k.map((Y,G)=>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:Y.model}),e.jsx("div",{className:"text-xs text-muted-foreground",children:Y.request_type})]}),e.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:A(Y.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:Y.tokens})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"花费:"}),e.jsxs("span",{className:"ml-1",children:["¥",Y.cost.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"耗时:"}),e.jsxs("span",{className:"ml-1",children:[Y.time_cost.toFixed(2),"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"状态:"}),e.jsx("span",{className:`ml-1 ${Y.status==="success"?"text-green-600":"text-red-600"}`,children:Y.status})]})]})]},G))})})})]})}),e.jsx(Vt,{value:"daily",children:e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"每日统计"}),e.jsx(us,{children:"最近7天的数据汇总"})]}),e.jsx(gt,{children:e.jsx(Dr,{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(uf,{data:M,children:[e.jsx(Xc,{strokeDasharray:"3 3",stroke:"hsl(var(--muted-foreground) / 0.2)"}),e.jsx(Kc,{dataKey:"timestamp",tickFormatter:Y=>{const G=new Date(Y);return`${G.getMonth()+1}/${G.getDate()}`},stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ii,{yAxisId:"left",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ii,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--muted-foreground))",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Qi,{content:e.jsx(Or,{labelFormatter:Y=>new Date(Y).toLocaleDateString("zh-CN")})}),e.jsx(sE,{content:e.jsx(l0,{})}),e.jsx(Qc,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),e.jsx(Qc,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]}),e.jsxs(Ue,{className:"border-2 border-primary/20",children:[e.jsx(ot,{className:"pb-3",children:e.jsx(ct,{className:"text-lg",children:"每日一言"})}),e.jsx(gt,{children:b?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ej,{className:"h-6 w-3/4"}),e.jsx(Ej,{className:"h-4 w-1/4"})]}):g?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-lg font-medium leading-relaxed italic",children:['"',g.hitokoto,'"']}),e.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["—— ",g.from]})]}):null})]})]})})}const aE={theme:"system",setTheme:()=>null},r0=x.createContext(aE),Oh=()=>{const s=x.useContext(r0);if(s===void 0)throw new Error("useTheme must be used within a ThemeProvider");return s},lE=(s,a,l)=>{const i=document.documentElement.classList.contains("no-animations");if(!document.startViewTransition||i){a(s);return}const c=l.clientX,d=l.clientY,m=Math.hypot(Math.max(c,innerWidth-c),Math.max(d,innerHeight-d));document.startViewTransition(()=>{a(s)}).ready.then(()=>{document.documentElement.animate({clipPath:[`circle(0px at ${c}px ${d}px)`,`circle(${m}px at ${c}px ${d}px)`]},{duration:500,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})})},i0=x.createContext(void 0),o0=()=>{const s=x.useContext(i0);if(s===void 0)throw new Error("useAnimation must be used within an AnimationProvider");return s};var Hd="Switch",[rE]=Dn(Hd),[iE,oE]=rE(Hd),c0=x.forwardRef((s,a)=>{const{__scopeSwitch:l,name:i,checked:c,defaultChecked:d,required:m,disabled:h,value:p="on",onCheckedChange:v,form:g,...j}=s,[b,w]=x.useState(null),S=Tt(a,M=>w(M)),C=x.useRef(!1),N=b?g||!!b.closest("form"):!0,[T,P]=Qa({prop:c,defaultProp:d??!1,onChange:v,caller:Hd});return e.jsxs(iE,{scope:l,checked:T,disabled:h,children:[e.jsx(dt.button,{type:"button",role:"switch","aria-checked":T,"aria-required":m,"data-state":f0(T),"data-disabled":h?"":void 0,disabled:h,value:p,...j,ref:S,onClick:be(s.onClick,M=>{P(k=>!k),N&&(C.current=M.isPropagationStopped(),C.current||M.stopPropagation())})}),N&&e.jsx(m0,{control:b,bubbles:!C.current,name:i,value:p,checked:T,required:m,disabled:h,form:g,style:{transform:"translateX(-100%)"}})]})});c0.displayName=Hd;var d0="SwitchThumb",u0=x.forwardRef((s,a)=>{const{__scopeSwitch:l,...i}=s,c=oE(d0,l);return e.jsx(dt.span,{"data-state":f0(c.checked),"data-disabled":c.disabled?"":void 0,...i,ref:a})});u0.displayName=d0;var cE="SwitchBubbleInput",m0=x.forwardRef(({__scopeSwitch:s,control:a,checked:l,bubbles:i=!0,...c},d)=>{const m=x.useRef(null),h=Tt(m,d),p=cy(l),v=dy(a);return x.useEffect(()=>{const g=m.current;if(!g)return;const j=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(j,"checked").set;if(p!==l&&w){const S=new Event("click",{bubbles:i});w.call(g,l),g.dispatchEvent(S)}},[p,l,i]),e.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:l,...c,tabIndex:-1,ref:h,style:{...c.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});m0.displayName=cE;function f0(s){return s?"checked":"unchecked"}var h0=c0,dE=u0;const Ze=x.forwardRef(({className:s,...a},l)=>e.jsx(h0,{className:Z("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...a,ref:l,children:e.jsx(dE,{className:Z("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")})}));Ze.displayName=h0.displayName;const uE=Jr("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),U=x.forwardRef(({className:s,...a},l)=>e.jsx(uy,{ref:l,className:Z(uE(),s),...a}));U.displayName=uy.displayName;const pe=x.forwardRef(({className:s,type:a,...l},i)=>e.jsx("input",{type:a,className:Z("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",s),ref:i,...l}));pe.displayName="Input";const mE=1,fE=1e6;let bf=0;function hE(){return bf=(bf+1)%Number.MAX_SAFE_INTEGER,bf.toString()}const Nf=new Map,Rj=s=>{if(Nf.has(s))return;const a=setTimeout(()=>{Nf.delete(s),no({type:"REMOVE_TOAST",toastId:s})},fE);Nf.set(s,a)},xE=(s,a)=>{switch(a.type){case"ADD_TOAST":return{...s,toasts:[a.toast,...s.toasts].slice(0,mE)};case"UPDATE_TOAST":return{...s,toasts:s.toasts.map(l=>l.id===a.toast.id?{...l,...a.toast}:l)};case"DISMISS_TOAST":{const{toastId:l}=a;return l?Rj(l):s.toasts.forEach(i=>{Rj(i.id)}),{...s,toasts:s.toasts.map(i=>i.id===l||l===void 0?{...i,open:!1}:i)}}case"REMOVE_TOAST":return a.toastId===void 0?{...s,toasts:[]}:{...s,toasts:s.toasts.filter(l=>l.id!==a.toastId)}}},dd=[];let ud={toasts:[]};function no(s){ud=xE(ud,s),dd.forEach(a=>{a(ud)})}function pE({...s}){const a=hE(),l=c=>no({type:"UPDATE_TOAST",toast:{...c,id:a}}),i=()=>no({type:"DISMISS_TOAST",toastId:a});return no({type:"ADD_TOAST",toast:{...s,id:a,open:!0,onOpenChange:c=>{c||i()}}}),{id:a,dismiss:i,update:l}}function Es(){const[s,a]=x.useState(ud);return x.useEffect(()=>(dd.push(a),()=>{const l=dd.indexOf(a);l>-1&&dd.splice(l,1)}),[s]),{...s,toast:pE,dismiss:l=>no({type:"DISMISS_TOAST",toastId:l})}}const gE=[{id:"minLength",label:"长度至少 10 位",description:"Token 长度必须大于等于 10 个字符",validate:s=>s.length>=10},{id:"hasUppercase",label:"包含大写字母",description:"至少包含一个大写字母 (A-Z)",validate:s=>/[A-Z]/.test(s)},{id:"hasLowercase",label:"包含小写字母",description:"至少包含一个小写字母 (a-z)",validate:s=>/[a-z]/.test(s)},{id:"hasSpecialChar",label:"包含特殊符号",description:"至少包含一个特殊符号 (!@#$%^&*()_+-=[]{}|;:,.<>?/)",validate:s=>/[!@#$%^&*()_+\-=[\]{}|;:,.<>?/]/.test(s)}];function vE(s){const a=gE.map(i=>({id:i.id,label:i.label,description:i.description,passed:i.validate(s)}));return{isValid:a.every(i=>i.passed),rules:a}}const Ah="0.11.5 Beta",Rh="MaiBot Dashboard",jE=`${Rh} v${Ah}`,yE=(s="v")=>`${s}${Ah}`,bs=mh,x0=my,bE=oh,p0=x.forwardRef(({className:s,...a},l)=>e.jsx(Cd,{ref:l,className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...a}));p0.displayName=Cd.displayName;const ms=x.forwardRef(({className:s,children:a,...l},i)=>e.jsxs(bE,{children:[e.jsx(p0,{}),e.jsxs(kd,{ref:i,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...l,children:[a,e.jsxs(ch,{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(go,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ms.displayName=kd.displayName;const fs=({className:s,...a})=>e.jsx("div",{className:Z("flex flex-col space-y-1.5 text-center sm:text-left",s),...a});fs.displayName="DialogHeader";const $s=({className:s,...a})=>e.jsx("div",{className:Z("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});$s.displayName="DialogFooter";const hs=x.forwardRef(({className:s,...a},l)=>e.jsx(dh,{ref:l,className:Z("text-lg font-semibold leading-none tracking-tight",s),...a}));hs.displayName=dh.displayName;const ks=x.forwardRef(({className:s,...a},l)=>e.jsx(uh,{ref:l,className:Z("text-sm text-muted-foreground",s),...a}));ks.displayName=uh.displayName;var NE=Symbol("radix.slottable");function wE(s){const a=({children:l})=>e.jsx(e.Fragment,{children:l});return a.displayName=`${s}.Slottable`,a.__radixId=NE,a}var g0="AlertDialog",[SE]=Dn(g0,[fy]),ga=fy(),v0=s=>{const{__scopeAlertDialog:a,...l}=s,i=ga(a);return e.jsx(mh,{...i,...l,modal:!0})};v0.displayName=g0;var _E="AlertDialogTrigger",j0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,...i}=s,c=ga(l);return e.jsx(my,{...c,...i,ref:a})});j0.displayName=_E;var CE="AlertDialogPortal",y0=s=>{const{__scopeAlertDialog:a,...l}=s,i=ga(a);return e.jsx(oh,{...i,...l})};y0.displayName=CE;var kE="AlertDialogOverlay",b0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,...i}=s,c=ga(l);return e.jsx(Cd,{...c,...i,ref:a})});b0.displayName=kE;var Br="AlertDialogContent",[TE,EE]=SE(Br),ME=wE("AlertDialogContent"),N0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,children:i,...c}=s,d=ga(l),m=x.useRef(null),h=Tt(a,m),p=x.useRef(null);return e.jsx(h2,{contentName:Br,titleName:w0,docsSlug:"alert-dialog",children:e.jsx(TE,{scope:l,cancelRef:p,children:e.jsxs(kd,{role:"alertdialog",...d,...c,ref:h,onOpenAutoFocus:be(c.onOpenAutoFocus,v=>{v.preventDefault(),p.current?.focus({preventScroll:!0})}),onPointerDownOutside:v=>v.preventDefault(),onInteractOutside:v=>v.preventDefault(),children:[e.jsx(ME,{children:i}),e.jsx(OE,{contentRef:m})]})})})});N0.displayName=Br;var w0="AlertDialogTitle",S0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,...i}=s,c=ga(l);return e.jsx(dh,{...c,...i,ref:a})});S0.displayName=w0;var _0="AlertDialogDescription",C0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,...i}=s,c=ga(l);return e.jsx(uh,{...c,...i,ref:a})});C0.displayName=_0;var DE="AlertDialogAction",k0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,...i}=s,c=ga(l);return e.jsx(ch,{...c,...i,ref:a})});k0.displayName=DE;var T0="AlertDialogCancel",E0=x.forwardRef((s,a)=>{const{__scopeAlertDialog:l,...i}=s,{cancelRef:c}=EE(T0,l),d=ga(l),m=Tt(a,c);return e.jsx(ch,{...d,...i,ref:m})});E0.displayName=T0;var OE=({contentRef:s})=>{const a=`\`${Br}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${Br}\` by passing a \`${_0}\` component as a child, which also benefits sighted users by adding visible context to the dialog. Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Br}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return x.useEffect(()=>{document.getElementById(s.current?.getAttribute("aria-describedby"))||console.warn(a)},[a,s]),null},AE=v0,RE=j0,zE=y0,M0=b0,D0=N0,O0=k0,A0=E0,R0=S0,z0=C0;const Ft=AE,_s=RE,PE=zE,P0=x.forwardRef(({className:s,...a},l)=>e.jsx(M0,{className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...a,ref:l}));P0.displayName=M0.displayName;const Ot=x.forwardRef(({className:s,...a},l)=>e.jsxs(PE,{children:[e.jsx(P0,{}),e.jsx(D0,{ref:l,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...a})]}));Ot.displayName=D0.displayName;const At=({className:s,...a})=>e.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",s),...a});At.displayName="AlertDialogHeader";const Rt=({className:s,...a})=>e.jsx("div",{className:Z("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});Rt.displayName="AlertDialogFooter";const zt=x.forwardRef(({className:s,...a},l)=>e.jsx(R0,{ref:l,className:Z("text-lg font-semibold",s),...a}));zt.displayName=R0.displayName;const Pt=x.forwardRef(({className:s,...a},l)=>e.jsx(z0,{ref:l,className:Z("text-sm text-muted-foreground",s),...a}));Pt.displayName=z0.displayName;const Lt=x.forwardRef(({className:s,...a},l)=>e.jsx(O0,{ref:l,className:Z(io(),s),...a}));Lt.displayName=O0.displayName;const Bt=x.forwardRef(({className:s,...a},l)=>e.jsx(A0,{ref:l,className:Z(io({variant:"outline"}),"mt-2 sm:mt-0",s),...a}));Bt.displayName=A0.displayName;function LE(){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(Ml,{defaultValue:"appearance",className:"w-full",children:[e.jsxs($a,{className:"grid w-full grid-cols-2 sm:grid-cols-4 gap-0.5 sm:gap-1 h-auto p-1",children:[e.jsxs(bt,{value:"appearance",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Ty,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"外观"})]}),e.jsxs(bt,{value:"security",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(M2,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"安全"})]}),e.jsxs(bt,{value:"other",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Tn,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"其他"})]}),e.jsxs(bt,{value:"about",className:"gap-1 sm:gap-2 text-xs sm:text-sm px-2 sm:px-3 py-2",children:[e.jsx(Fr,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4",strokeWidth:2,fill:"none"}),e.jsx("span",{children:"关于"})]})]}),e.jsxs(Ct,{className:"h-[calc(100vh-240px)] sm:h-[calc(100vh-280px)] mt-4 sm:mt-6",children:[e.jsx(Vt,{value:"appearance",className:"mt-0",children:e.jsx(BE,{})}),e.jsx(Vt,{value:"security",className:"mt-0",children:e.jsx(UE,{})}),e.jsx(Vt,{value:"other",className:"mt-0",children:e.jsx(HE,{})}),e.jsx(Vt,{value:"about",className:"mt-0",children:e.jsx(FE,{})})]})]})]})}function zj(s){const a=document.documentElement,i={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%)"}}[s];if(i)a.style.setProperty("--primary",i.hsl),i.gradient?(a.style.setProperty("--primary-gradient",i.gradient),a.classList.add("has-gradient")):(a.style.removeProperty("--primary-gradient"),a.classList.remove("has-gradient"));else if(s.startsWith("#")){const c=d=>{d=d.replace("#","");const m=parseInt(d.substring(0,2),16)/255,h=parseInt(d.substring(2,4),16)/255,p=parseInt(d.substring(4,6),16)/255,v=Math.max(m,h,p),g=Math.min(m,h,p);let j=0,b=0;const w=(v+g)/2;if(v!==g){const S=v-g;switch(b=w>.5?S/(2-v-g):S/(v+g),v){case m:j=((h-p)/S+(hlocalStorage.getItem("accent-color")||"blue");x.useEffect(()=>{const v=localStorage.getItem("accent-color")||"blue";zj(v)},[]);const p=v=>{h(v),localStorage.setItem("accent-color",v),zj(v)};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(wf,{value:"light",current:s,onChange:a,label:"浅色",description:"始终使用浅色主题"}),e.jsx(wf,{value:"dark",current:s,onChange:a,label:"深色",description:"始终使用深色主题"}),e.jsx(wf,{value:"system",current:s,onChange:a,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(vn,{value:"blue",current:m,onChange:p,label:"蓝色",colorClass:"bg-blue-500"}),e.jsx(vn,{value:"purple",current:m,onChange:p,label:"紫色",colorClass:"bg-purple-500"}),e.jsx(vn,{value:"green",current:m,onChange:p,label:"绿色",colorClass:"bg-green-500"}),e.jsx(vn,{value:"orange",current:m,onChange:p,label:"橙色",colorClass:"bg-orange-500"}),e.jsx(vn,{value:"pink",current:m,onChange:p,label:"粉色",colorClass:"bg-pink-500"}),e.jsx(vn,{value:"red",current:m,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(vn,{value:"gradient-sunset",current:m,onChange:p,label:"日落",colorClass:"bg-gradient-to-r from-orange-500 to-pink-500"}),e.jsx(vn,{value:"gradient-ocean",current:m,onChange:p,label:"海洋",colorClass:"bg-gradient-to-r from-blue-500 to-cyan-500"}),e.jsx(vn,{value:"gradient-forest",current:m,onChange:p,label:"森林",colorClass:"bg-gradient-to-r from-green-500 to-emerald-500"}),e.jsx(vn,{value:"gradient-aurora",current:m,onChange:p,label:"极光",colorClass:"bg-gradient-to-r from-purple-500 to-pink-500"}),e.jsx(vn,{value:"gradient-fire",current:m,onChange:p,label:"烈焰",colorClass:"bg-gradient-to-r from-red-500 to-orange-500"}),e.jsx(vn,{value:"gradient-twilight",current:m,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:m.startsWith("#")?m:"#3b82f6",onChange:v=>p(v.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(pe,{type:"text",value:m,onChange:v=>p(v.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(U,{htmlFor:"animations",className:"text-base font-medium cursor-pointer",children:"启用动画效果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后将禁用所有过渡动画和特效,提升性能"})]}),e.jsx(Ze,{id:"animations",checked:l,onCheckedChange:i})]})}),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(U,{htmlFor:"waves-background",className:"text-base font-medium cursor-pointer",children:"登录页波浪背景"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"关闭后登录页将使用纯色背景,适合低性能设备"})]}),e.jsx(Ze,{id:"waves-background",checked:c,onCheckedChange:d})]})})]})]})]})}function UE(){const s=qn(),[a,l]=x.useState(""),[i,c]=x.useState(""),[d,m]=x.useState(!1),[h,p]=x.useState(!1),[v,g]=x.useState(!1),[j,b]=x.useState(!1),[w,S]=x.useState(!1),[C,N]=x.useState(!1),[T,P]=x.useState(""),[M,k]=x.useState(!1),{toast:D}=Es(),A=x.useMemo(()=>vE(i),[i]),E=()=>localStorage.getItem("access-token")||"",B=async ae=>{try{await navigator.clipboard.writeText(ae),S(!0),D({title:"复制成功",description:"Token 已复制到剪贴板"}),setTimeout(()=>S(!1),2e3)}catch{D({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},Y=async()=>{if(!i.trim()){D({title:"输入错误",description:"请输入新的 Token",variant:"destructive"});return}if(!A.isValid){const ae=A.rules.filter(me=>!me.passed).map(me=>me.label).join(", ");D({title:"格式错误",description:`Token 不符合要求: ${ae}`,variant:"destructive"});return}g(!0);try{const ae=E(),me=await fetch("/api/webui/auth/update",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`},body:JSON.stringify({new_token:i.trim()})}),R=await me.json();me.ok&&R.success?(localStorage.setItem("access-token",i.trim()),c(""),a&&l(i.trim()),D({title:"更新成功",description:"Access Token 已更新,即将跳转到登录页"}),setTimeout(()=>{localStorage.removeItem("access-token"),s({to:"/auth"})},1500)):D({title:"更新失败",description:R.message||"无法更新 Token",variant:"destructive"})}catch(ae){console.error("更新 Token 错误:",ae),D({title:"更新失败",description:"连接服务器失败",variant:"destructive"})}finally{g(!1)}},G=async()=>{b(!0);try{const ae=E(),me=await fetch("/api/webui/auth/regenerate",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ae}`}}),R=await me.json();me.ok&&R.success?(localStorage.setItem("access-token",R.token),l(R.token),P(R.token),N(!0),k(!1),D({title:"生成成功",description:"新的 Access Token 已生成,请及时保存"})):D({title:"生成失败",description:R.message||"无法生成新 Token",variant:"destructive"})}catch(ae){console.error("生成 Token 错误:",ae),D({title:"生成失败",description:"连接服务器失败",variant:"destructive"})}finally{b(!1)}},$=async()=>{try{await navigator.clipboard.writeText(T),k(!0),D({title:"复制成功",description:"Token 已复制到剪贴板"})}catch{D({title:"复制失败",description:"请手动复制 Token",variant:"destructive"})}},oe=()=>{N(!1),setTimeout(()=>{P(""),k(!1)},300),setTimeout(()=>{localStorage.removeItem("access-token"),s({to:"/auth"})},500)},je=ae=>{ae||oe()};return e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx(bs,{open:C,onOpenChange:je,children:e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(fs,{children:[e.jsxs(hs,{className:"flex items-center gap-2",children:[e.jsx(Lr,{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(U,{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:T})]}),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(Lr,{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($s,{className:"gap-2 sm:gap-0",children:[e.jsx(q,{variant:"outline",onClick:$,className:"gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(Cl,{className:"h-4 w-4 text-green-500"}),"已复制"]}):e.jsxs(e.Fragment,{children:[e.jsx(Df,{className:"h-4 w-4"}),"复制 Token"]})}),e.jsx(q,{onClick:oe,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(U,{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(pe,{id:"current-token",type:d?"text":"password",value:a||E(),readOnly:!0,className:"pr-10 font-mono text-sm",placeholder:"点击查看按钮显示 Token"}),e.jsx("button",{onClick:()=>{a||l(E()),m(!d)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:d?"隐藏":"显示",children:d?e.jsx(Of,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(q,{variant:"outline",size:"icon",onClick:()=>B(E()),title:"复制到剪贴板",className:"flex-shrink-0",children:w?e.jsx(Cl,{className:"h-4 w-4 text-green-500"}):e.jsx(Df,{className:"h-4 w-4"})}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(q,{variant:"outline",disabled:j,className:"gap-2 flex-1 sm:flex-none",children:[e.jsx(xa,{className:Z("h-4 w-4",j&&"animate-spin")}),e.jsx("span",{className:"hidden sm:inline",children:"重新生成"}),e.jsx("span",{className:"sm:hidden",children:"生成"})]})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认重新生成 Token"}),e.jsx(Pt,{children:"这将生成一个新的 64 位安全令牌,并使当前 Token 立即失效。 您需要使用新 Token 重新登录系统。此操作不可撤销,确定要继续吗?"})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:G,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(U,{htmlFor:"new-token",className:"text-sm",children:"新的访问令牌"}),e.jsxs("div",{className:"relative",children:[e.jsx(pe,{id:"new-token",type:h?"text":"password",value:i,onChange:ae=>c(ae.target.value),className:"pr-10 font-mono text-sm",placeholder:"输入自定义 Token"}),e.jsx("button",{onClick:()=>p(!h),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-accent rounded",title:h?"隐藏":"显示",children:h?e.jsx(Of,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Mn,{className:"h-4 w-4 text-muted-foreground"})})]}),i&&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:A.rules.map(ae=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[ae.passed?e.jsx(Ys,{className:"h-4 w-4 text-green-500 flex-shrink-0"}):e.jsx(Af,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:Z(ae.passed?"text-green-600 dark:text-green-400":"text-muted-foreground"),children:ae.label})]},ae.id))}),A.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(Cl,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Token 格式正确,可以使用"})]})})]})]}),e.jsx(q,{onClick:Y,disabled:v||!A.isValid||!i,className:"w-full sm:w-auto",children:v?"更新中...":"更新自定义 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 HE(){const s=qn(),{toast:a}=Es(),[l,i]=x.useState(!1),c=async()=>{i(!0);try{const d=localStorage.getItem("access-token"),m=await fetch("/api/webui/setup/reset",{method:"POST",headers:{Authorization:`Bearer ${d}`}}),h=await m.json();m.ok&&h.success?(a({title:"重置成功",description:"即将进入初次配置向导"}),setTimeout(()=>{s({to:"/setup"})},1e3)):a({title:"重置失败",description:h.message||"无法重置配置状态",variant:"destructive"})}catch(d){console.error("重置配置状态错误:",d),a({title:"重置失败",description:"连接服务器失败",variant:"destructive"})}finally{i(!1)}};return e.jsx("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.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(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(q,{variant:"outline",disabled:l,className:"gap-2",children:[e.jsx(D2,{className:Z("h-4 w-4",l&&"animate-spin")}),"重新进行初次配置"]})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认重新配置"}),e.jsx(Pt,{children:"这将带您重新进入初次配置向导。您可以重新设置系统的基础配置项。确定要继续吗?"})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:c,children:"确认重置"})]})]})]})]})]})})}function FE(){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",children:["关于 ",Rh]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("p",{children:["版本: ",Ah]}),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(Ct,{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(qt,{name:"React",description:"用户界面构建库",license:"MIT"}),e.jsx(qt,{name:"shadcn/ui",description:"优雅的 React 组件库",license:"MIT"}),e.jsx(qt,{name:"Radix UI",description:"无样式的可访问组件库",license:"MIT"}),e.jsx(qt,{name:"Tailwind CSS",description:"实用优先的 CSS 框架",license:"MIT"}),e.jsx(qt,{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(qt,{name:"TanStack Router",description:"类型安全的路由库",license:"MIT"}),e.jsx(qt,{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(qt,{name:"React Hook Form",description:"高性能表单库",license:"MIT"}),e.jsx(qt,{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(qt,{name:"clsx",description:"条件 className 构建工具",license:"MIT"}),e.jsx(qt,{name:"tailwind-merge",description:"Tailwind 类名合并工具",license:"MIT"}),e.jsx(qt,{name:"class-variance-authority",description:"组件变体管理",license:"Apache-2.0"}),e.jsx(qt,{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(qt,{name:"Framer Motion",description:"React 动画库",license:"MIT"}),e.jsx(qt,{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(qt,{name:"FastAPI",description:"现代化 Python Web 框架",license:"MIT"}),e.jsx(qt,{name:"Uvicorn",description:"ASGI 服务器",license:"BSD-3-Clause"}),e.jsx(qt,{name:"Pydantic",description:"数据验证库",license:"MIT"}),e.jsx(qt,{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(qt,{name:"TypeScript",description:"JavaScript 的超集",license:"Apache-2.0"}),e.jsx(qt,{name:"Vite",description:"下一代前端构建工具",license:"MIT"}),e.jsx(qt,{name:"ESLint",description:"JavaScript 代码检查工具",license:"MIT"}),e.jsx(qt,{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 qt({name:s,description:a,license:l}){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:s}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:a})]}),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:l})]})}function wf({value:s,current:a,onChange:l,label:i,description:c}){const d=a===s;return e.jsxs("button",{onClick:()=>l(s),className:Z("relative rounded-lg border-2 p-3 sm:p-4 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",d?"border-primary bg-accent":"border-border"),children:[d&&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:i}),e.jsx("div",{className:"text-[10px] sm:text-xs text-muted-foreground",children:c})]}),e.jsxs("div",{className:"mt-2 sm:mt-3 flex gap-1",children:[s==="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"})]}),s==="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"})]}),s==="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 vn({value:s,current:a,onChange:l,label:i,colorClass:c}){const d=a===s;return e.jsxs("button",{onClick:()=>l(s),className:Z("relative rounded-lg border-2 p-2 sm:p-3 text-left transition-all","hover:border-primary/50 hover:bg-accent/50",d?"border-primary bg-accent":"border-border"),children:[d&&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:Z("h-8 w-8 sm:h-10 sm:w-10 rounded-full",c)}),e.jsx("div",{className:"text-[10px] sm:text-xs font-medium text-center",children:i})]})]})}class YE{grad3;p;perm;constructor(a=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 l=0;l<256;l++)this.p[l]=Math.floor(Math.random()*256);this.perm=[];for(let l=0;l<512;l++)this.perm[l]=this.p[l&255]}dot(a,l,i){return a[0]*l+a[1]*i}mix(a,l,i){return(1-i)*a+i*l}fade(a){return a*a*a*(a*(a*6-15)+10)}perlin2(a,l){const i=Math.floor(a)&255,c=Math.floor(l)&255;a-=Math.floor(a),l-=Math.floor(l);const d=this.fade(a),m=this.fade(l),h=this.perm[i]+c,p=this.perm[h],v=this.perm[h+1],g=this.perm[i+1]+c,j=this.perm[g],b=this.perm[g+1];return this.mix(this.mix(this.dot(this.grad3[p%12],a,l),this.dot(this.grad3[j%12],a-1,l),d),this.mix(this.dot(this.grad3[v%12],a,l-1),this.dot(this.grad3[b%12],a-1,l-1),d),m)}}function qE(){const s=x.useRef(null),a=x.useRef(null),l=x.useRef(void 0),i=x.useRef({mouse:{x:-10,y:0,lx:0,ly:0,sx:0,sy:0,v:0,vs:0,a:0,set:!1},lines:[],paths:[],noise:new YE(Math.random()),bounding:null});return x.useEffect(()=>{const c=a.current,d=s.current;if(!c||!d)return;const m=i.current,h=()=>{const C=c.getBoundingClientRect();m.bounding=C,d.style.width=`${C.width}px`,d.style.height=`${C.height}px`},p=()=>{if(!m.bounding)return;const{width:C,height:N}=m.bounding;m.lines=[],m.paths.forEach(Y=>Y.remove()),m.paths=[];const T=10,P=32,M=C+200,k=N+30,D=Math.ceil(M/T),A=Math.ceil(k/P),E=(C-T*D)/2,B=(N-P*A)/2;for(let Y=0;Y<=D;Y++){const G=[];for(let oe=0;oe<=A;oe++){const je={x:E+T*Y,y:B+P*oe,wave:{x:0,y:0},cursor:{x:0,y:0,vx:0,vy:0}};G.push(je)}const $=document.createElementNS("http://www.w3.org/2000/svg","path");d.appendChild($),m.paths.push($),m.lines.push(G)}},v=C=>{const{lines:N,mouse:T,noise:P}=m;N.forEach(M=>{M.forEach(k=>{const D=P.perlin2((k.x+C*.0125)*.002,(k.y+C*.005)*.0015)*12;k.wave.x=Math.cos(D)*32,k.wave.y=Math.sin(D)*16;const A=k.x-T.sx,E=k.y-T.sy,B=Math.hypot(A,E),Y=Math.max(175,T.vs);if(B{const T={x:C.x+C.wave.x+(N?C.cursor.x:0),y:C.y+C.wave.y+(N?C.cursor.y:0)};return T.x=Math.round(T.x*10)/10,T.y=Math.round(T.y*10)/10,T},j=()=>{const{lines:C,paths:N}=m;C.forEach((T,P)=>{let M=g(T[0],!1),k=`M ${M.x} ${M.y}`;T.forEach((D,A)=>{const E=A===T.length-1;M=g(D,!E),k+=`L ${M.x} ${M.y}`}),N[P].setAttribute("d",k)})},b=C=>{const{mouse:N}=m;N.sx+=(N.x-N.sx)*.1,N.sy+=(N.y-N.sy)*.1;const T=N.x-N.lx,P=N.y-N.ly,M=Math.hypot(T,P);N.v=M,N.vs+=(M-N.vs)*.1,N.vs=Math.min(100,N.vs),N.lx=N.x,N.ly=N.y,N.a=Math.atan2(P,T),c&&(c.style.setProperty("--x",`${N.sx}px`),c.style.setProperty("--y",`${N.sy}px`)),v(C),j(),l.current=requestAnimationFrame(b)},w=C=>{if(!m.bounding)return;const{mouse:N}=m;N.x=C.pageX-m.bounding.left,N.y=C.pageY-m.bounding.top+window.scrollY,N.set||(N.sx=N.x,N.sy=N.y,N.lx=N.x,N.ly=N.y,N.set=!0)},S=()=>{h(),p()};return h(),p(),window.addEventListener("resize",S),window.addEventListener("mousemove",w),l.current=requestAnimationFrame(b),()=>{window.removeEventListener("resize",S),window.removeEventListener("mousemove",w),l.current&&cancelAnimationFrame(l.current)}},[]),e.jsxs("div",{ref:a,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:s,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 VE(){const s=qn();x.useEffect(()=>{localStorage.getItem("access-token")||s({to:"/auth"})},[s])}function L0(){return!!localStorage.getItem("access-token")}function GE(){const[s,a]=x.useState(""),[l,i]=x.useState(!1),[c,d]=x.useState(""),m=qn(),{enableWavesBackground:h,setEnableWavesBackground:p}=o0(),{theme:v,setTheme:g}=Oh();x.useEffect(()=>{L0()&&m({to:"/"})},[m]);const b=v==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":v,w=()=>{g(b==="dark"?"light":"dark")},S=async C=>{if(C.preventDefault(),d(""),!s.trim()){d("请输入 Access Token");return}i(!0);try{const N=await fetch("/api/webui/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:s.trim()})}),T=await N.json();if(N.ok&&T.valid){localStorage.setItem("access-token",s.trim());const P=await fetch("/api/webui/setup/status",{method:"GET",headers:{Authorization:`Bearer ${s.trim()}`}}),M=await P.json();P.ok&&M.is_first_setup?m({to:"/setup"}):m({to:"/"})}else d(T.message||"Token 验证失败,请检查后重试")}catch(N){console.error("Token 验证错误:",N),d("连接服务器失败,请检查网络连接")}finally{i(!1)}};return e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-background p-4",children:[h&&e.jsx(qE,{}),e.jsxs(Ue,{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:w,className:"absolute right-4 top-4 rounded-lg p-2 hover:bg-accent transition-colors z-10 text-foreground",title:b==="dark"?"切换到浅色模式":"切换到深色模式",children:b==="dark"?e.jsx(Rf,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"}):e.jsx(zf,{className:"h-5 w-5",strokeWidth:2.5,fill:"none"})}),e.jsxs(ot,{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(Zv,{className:"h-8 w-8 text-primary",strokeWidth:2,fill:"none"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ct,{className:"text-2xl font-bold",children:"欢迎使用 MaiBot"}),e.jsx(us,{className:"text-base",children:"请输入您的 Access Token 以继续访问系统"})]})]}),e.jsx(gt,{children:e.jsxs("form",{onSubmit:S,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"token",className:"text-sm font-medium",children:"Access Token"}),e.jsxs("div",{className:"relative",children:[e.jsx(O2,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground",strokeWidth:2,fill:"none"}),e.jsx(pe,{id:"token",type:"password",placeholder:"请输入您的 Access Token",value:s,onChange:C=>a(C.target.value),className:Z("pl-10",c&&"border-red-500 focus-visible:ring-red-500"),disabled:l,autoFocus:!0,autoComplete:"off"})]})]}),c&&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(Tl,{className:"h-4 w-4 flex-shrink-0",strokeWidth:2,fill:"none"}),e.jsx("span",{children:c})]}),e.jsx(q,{type:"submit",className:"w-full",disabled:l,children:l?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(bs,{children:[e.jsx(x0,{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(A2,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我没有 Token,我该去哪里获得 Token?"]})}),e.jsxs(ms,{className:"sm:max-w-md",children:[e.jsxs(fs,{children:[e.jsxs(hs,{className:"flex items-center gap-2",children:[e.jsx(Zv,{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(R2,{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(ph,{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(Tl,{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(Ft,{children:[e.jsx(_s,{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(ao,{className:"h-4 w-4",strokeWidth:2,fill:"none"}),"我觉得这个界面很卡怎么办?"]})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(ao,{className:"h-5 w-5 text-primary",strokeWidth:2,fill:"none"}),"关闭背景动画"]}),e.jsx(Pt,{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(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>p(!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:jE})})]})}const Dt=x.forwardRef(({className:s,...a},l)=>e.jsx("textarea",{className:Z("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",s),ref:l,...a}));Dt.displayName="Textarea";var $E=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],IE=$E.reduce((s,a)=>{const l=ih(`Primitive.${a}`),i=x.forwardRef((c,d)=>{const{asChild:m,...h}=c,p=m?l:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(p,{...h,ref:d})});return i.displayName=`Primitive.${a}`,{...s,[a]:i}},{}),WE="Separator",Pj="horizontal",XE=["horizontal","vertical"],B0=x.forwardRef((s,a)=>{const{decorative:l,orientation:i=Pj,...c}=s,d=KE(i)?i:Pj,h=l?{role:"none"}:{"aria-orientation":d==="vertical"?d:void 0,role:"separator"};return e.jsx(IE.div,{"data-orientation":d,...h,...c,ref:a})});B0.displayName=WE;function KE(s){return XE.includes(s)}var U0=B0;const oo=x.forwardRef(({className:s,orientation:a="horizontal",decorative:l=!0,...i},c)=>e.jsx(U0,{ref:c,decorative:l,orientation:a,className:Z("shrink-0 bg-border",a==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...i}));oo.displayName=U0.displayName;const QE=Jr("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 _t({className:s,variant:a,...l}){return e.jsx("div",{className:Z(QE({variant:a}),s),...l})}function ZE({config:s,onChange:a}){const l=c=>{c.trim()&&!s.alias_names.includes(c.trim())&&a({...s,alias_names:[...s.alias_names,c.trim()]})},i=c=>{a({...s,alias_names:s.alias_names.filter((d,m)=>m!==c)})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"qq_account",children:"QQ账号 *"}),e.jsx(pe,{id:"qq_account",type:"number",placeholder:"请输入机器人的QQ账号",value:s.qq_account||"",onChange:c=>a({...s,qq_account:Number(c.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人登录使用的QQ账号"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"nickname",children:"昵称 *"}),e.jsx(pe,{id:"nickname",placeholder:"请输入机器人的昵称",value:s.nickname,onChange:c=>a({...s,nickname:c.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的主要称呼名称"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{children:"别名"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:s.alias_names.map((c,d)=>e.jsxs(_t,{variant:"secondary",className:"gap-1",children:[c,e.jsx("button",{type:"button",onClick:()=>i(d),className:"ml-1 hover:text-destructive",children:e.jsx(go,{className:"h-3 w-3"})})]},d))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pe,{id:"alias_input",placeholder:"输入别名后按回车添加",onKeyPress:c=>{c.key==="Enter"&&(l(c.target.value),c.target.value="")}}),e.jsx(q,{type:"button",variant:"outline",onClick:()=>{const c=document.getElementById("alias_input");c&&(l(c.value),c.value="")},children:"添加"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人的其他称呼,可以添加多个"})]})]})}function JE({config:s,onChange:a}){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"personality",children:"人格特征 *"}),e.jsx(Dt,{id:"personality",placeholder:"描述机器人的人格特质和身份特征(建议120字以内)",value:s.personality,onChange:l=>a({...s,personality:l.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:是一个女大学生,现在在读大二,会刷贴吧"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"reply_style",children:"表达风格 *"}),e.jsx(Dt,{id:"reply_style",placeholder:"描述机器人说话的表达风格、表达习惯",value:s.reply_style,onChange:l=>a({...s,reply_style:l.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"例如:回复平淡一些,简短一些,说中文,参考贴吧、知乎和微博的回复风格"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"interest",children:"兴趣 *"}),e.jsx(Dt,{id:"interest",placeholder:"描述机器人感兴趣的话题",value:s.interest,onChange:l=>a({...s,interest:l.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"会影响机器人对什么话题进行回复"})]}),e.jsx(oo,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"plan_style",children:"群聊说话规则 *"}),e.jsx(Dt,{id:"plan_style",placeholder:"机器人在群聊中的行为风格和规则",value:s.plan_style,onChange:l=>a({...s,plan_style:l.target.value}),rows:4}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在群聊中如何行动,例如回复频率、条件等"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"private_plan_style",children:"私聊说话规则 *"}),e.jsx(Dt,{id:"private_plan_style",placeholder:"机器人在私聊中的行为风格和规则",value:s.private_plan_style,onChange:l=>a({...s,private_plan_style:l.target.value}),rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"定义机器人在私聊中的行为方式"})]})]})}function e4({config:s,onChange:a}){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(U,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[(s.emoji_chance*100).toFixed(0),"%"]})]}),e.jsx(pe,{id:"emoji_chance",type:"range",min:"0",max:"1",step:"0.1",value:s.emoji_chance,onChange:l=>a({...s,emoji_chance:Number(l.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"机器人发送表情包的概率"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"max_reg_num",children:"最大表情包数量"}),e.jsx(pe,{id:"max_reg_num",type:"number",min:"1",max:"200",value:s.max_reg_num,onChange:l=>a({...s,max_reg_num:Number(l.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(U,{htmlFor:"do_replace",children:"达到最大数量时替换"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后会删除旧表情包,关闭则不再收集新表情包"})]}),e.jsx(Ze,{id:"do_replace",checked:s.do_replace,onCheckedChange:l=>a({...s,do_replace:l})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(pe,{id:"check_interval",type:"number",min:"1",max:"120",value:s.check_interval,onChange:l=>a({...s,check_interval:Number(l.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查表情包注册、破损、删除的时间间隔"})]}),e.jsx(oo,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(U,{htmlFor:"steal_emoji",children:"偷取表情包"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人将一些表情包据为己有"})]}),e.jsx(Ze,{id:"steal_emoji",checked:s.steal_emoji,onCheckedChange:l=>a({...s,steal_emoji:l})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(U,{htmlFor:"content_filtration",children:"启用表情包过滤"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只保存符合要求的表情包"})]}),e.jsx(Ze,{id:"content_filtration",checked:s.content_filtration,onCheckedChange:l=>a({...s,content_filtration:l})})]}),s.content_filtration&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(pe,{id:"filtration_prompt",placeholder:"例如:符合公序良俗",value:s.filtration_prompt,onChange:l=>a({...s,filtration_prompt:l.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"描述表情包应该符合的要求"})]})]})}function t4({config:s,onChange:a}){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(U,{htmlFor:"enable_tool",children:"启用工具系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人使用各种工具增强功能"})]}),e.jsx(Ze,{id:"enable_tool",checked:s.enable_tool,onCheckedChange:l=>a({...s,enable_tool:l})})]}),e.jsx(oo,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(U,{htmlFor:"enable_mood",children:"启用情绪系统"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"让机器人具有情绪变化能力"})]}),e.jsx(Ze,{id:"enable_mood",checked:s.enable_mood,onCheckedChange:l=>a({...s,enable_mood:l})})]}),s.enable_mood&&e.jsxs("div",{className:"ml-6 space-y-6 border-l-2 border-primary/20 pl-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"mood_update_threshold",children:"情绪更新阈值"}),e.jsx(pe,{id:"mood_update_threshold",type:"number",min:"0.1",max:"10",step:"0.1",value:s.mood_update_threshold||1,onChange:l=>a({...s,mood_update_threshold:Number(l.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"值越高,情绪更新越慢"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(U,{htmlFor:"emotion_style",children:"情感特征"}),e.jsx(Dt,{id:"emotion_style",placeholder:"描述情绪的变化情况,例如:情绪较为稳定,但遭遇特定事件时起伏较大",value:s.emotion_style||"",onChange:l=>a({...s,emotion_style:l.target.value}),rows:2}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响机器人的情绪变化方式"})]})]}),e.jsx(oo,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(U,{htmlFor:"all_global",children:"启用全局黑话模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"允许机器人学习和使用群组黑话"})]}),e.jsx(Ze,{id:"all_global",checked:s.all_global,onCheckedChange:l=>a({...s,all_global:l})})]})]})}async function Fe(s,a){const l=await fetch(s,a);if(l.status===401)throw localStorage.removeItem("access-token"),window.location.href="/auth",new Error("认证失败,请重新登录");return l}function Ie(){return{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("access-token")}`}}async function s4(){const s=await Fe("/api/webui/config/bot",{method:"GET",headers:Ie()});if(!s.ok)throw new Error("读取Bot配置失败");const l=(await s.json()).config.bot||{};return{qq_account:l.qq_account||0,nickname:l.nickname||"",alias_names:l.alias_names||[]}}async function n4(){const s=await Fe("/api/webui/config/bot",{method:"GET",headers:Ie()});if(!s.ok)throw new Error("读取人格配置失败");const l=(await s.json()).config.personality||{};return{personality:l.personality||"",reply_style:l.reply_style||"",interest:l.interest||"",plan_style:l.plan_style||"",private_plan_style:l.private_plan_style||""}}async function a4(){const s=await Fe("/api/webui/config/bot",{method:"GET",headers:Ie()});if(!s.ok)throw new Error("读取表情包配置失败");const l=(await s.json()).config.emoji||{};return{emoji_chance:l.emoji_chance??.4,max_reg_num:l.max_reg_num??40,do_replace:l.do_replace??!0,check_interval:l.check_interval??10,steal_emoji:l.steal_emoji??!0,content_filtration:l.content_filtration??!1,filtration_prompt:l.filtration_prompt||""}}async function l4(){const s=await Fe("/api/webui/config/bot",{method:"GET",headers:Ie()});if(!s.ok)throw new Error("读取其他配置失败");const l=(await s.json()).config,i=l.tool||{},c=l.mood||{},d=l.jargon||{};return{enable_tool:i.enable_tool??!0,enable_mood:c.enable_mood??!1,mood_update_threshold:c.mood_update_threshold,emotion_style:c.emotion_style,all_global:d.all_global??!0}}async function r4(s){const a=await Fe("/api/webui/config/bot/section/bot",{method:"POST",headers:Ie(),body:JSON.stringify(s)});if(!a.ok){const l=await a.json();throw new Error(l.detail||"保存Bot基础配置失败")}return await a.json()}async function i4(s){const a=await Fe("/api/webui/config/bot/section/personality",{method:"POST",headers:Ie(),body:JSON.stringify(s)});if(!a.ok){const l=await a.json();throw new Error(l.detail||"保存人格配置失败")}return await a.json()}async function o4(s){const a=await Fe("/api/webui/config/bot/section/emoji",{method:"POST",headers:Ie(),body:JSON.stringify(s)});if(!a.ok){const l=await a.json();throw new Error(l.detail||"保存表情包配置失败")}return await a.json()}async function c4(s){const a=[];a.push(Fe("/api/webui/config/bot/section/tool",{method:"POST",headers:Ie(),body:JSON.stringify({enable_tool:s.enable_tool})})),a.push(Fe("/api/webui/config/bot/section/jargon",{method:"POST",headers:Ie(),body:JSON.stringify({all_global:s.all_global})}));const l={enable_mood:s.enable_mood};s.enable_mood&&(l.mood_update_threshold=s.mood_update_threshold||1,l.emotion_style=s.emotion_style||""),a.push(Fe("/api/webui/config/bot/section/mood",{method:"POST",headers:Ie(),body:JSON.stringify(l)}));const i=await Promise.all(a);for(const c of i)if(!c.ok){const d=await c.json();throw new Error(d.detail||"保存其他配置失败")}return{success:!0}}async function Lj(){const s=localStorage.getItem("access-token"),a=await Fe("/api/webui/setup/complete",{method:"POST",headers:{Authorization:`Bearer ${s}`}});if(!a.ok){const l=await a.json();throw new Error(l.message||"标记配置完成失败")}return await a.json()}function d4(){const s=qn(),{toast:a}=Es(),[l,i]=x.useState(0),[c,d]=x.useState(!1),[m,h]=x.useState(!1),[p,v]=x.useState(!0),[g,j]=x.useState({qq_account:0,nickname:"",alias_names:[]}),[b,w]=x.useState({personality:"是一个女大学生,现在在读大二,会刷贴吧。",reply_style:"请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。",interest:"对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题",plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用 2.如果相同的内容已经被执行,请不要重复执行 3.请控制你的发言频率,不要太过频繁的发言 4.如果有人对你感到厌烦,请减少回复 5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对`,private_plan_style:`1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用 2.如果相同的内容已经被执行,请不要重复执行 3.某句话如果已经被回复过,不要重复回复`}),[S,C]=x.useState({emoji_chance:.4,max_reg_num:40,do_replace:!0,check_interval:10,steal_emoji:!0,content_filtration:!1,filtration_prompt:"符合公序良俗"}),[N,T]=x.useState({enable_tool:!0,enable_mood:!1,mood_update_threshold:1,emotion_style:"情绪较为稳定,但遭遇特定事件的时候起伏较大",all_global:!0}),P=[{id:"bot-basic",title:"Bot基础",description:"配置机器人的基本信息",icon:P2},{id:"personality",title:"人格配置",description:"定义机器人的性格和说话风格",icon:Ey},{id:"emoji",title:"表情包",description:"配置表情包相关设置",icon:gh},{id:"other",title:"其他设置",description:"工具、情绪系统等配置",icon:Tn},{id:"complete",title:"完成设置",description:"后续配置提示",icon:ao}],M=(l+1)/P.length*100;x.useEffect(()=>{(async()=>{try{v(!0);const[$,oe,je,ae]=await Promise.all([s4(),n4(),a4(),l4()]);j($),w(oe),C(je),T(ae)}catch($){a({title:"加载配置失败",description:$ instanceof Error?$.message:"无法加载现有配置,将使用默认值",variant:"destructive"})}finally{v(!1)}})()},[a]);const k=async()=>{h(!0);try{switch(l){case 0:await r4(g);break;case 1:await i4(b);break;case 2:await o4(S);break;case 3:await c4(N);break}return a({title:"保存成功",description:`${P[l].title}配置已保存`}),!0}catch(G){return a({title:"保存失败",description:G instanceof Error?G.message:"未知错误",variant:"destructive"}),!1}finally{h(!1)}},D=async()=>{await k()&&l{l>0&&i(l-1)},E=async()=>{d(!0);try{if(!await k()){d(!1);return}await Lj(),a({title:"配置完成",description:"所有配置已保存,正在跳转..."}),setTimeout(()=>{s({to:"/"})},500)}catch(G){a({title:"完成失败",description:G instanceof Error?G.message:"未知错误",variant:"destructive"})}finally{d(!1)}},B=async()=>{try{await Lj(),s({to:"/"})}catch(G){a({title:"跳过失败",description:G instanceof Error?G.message:"未知错误",variant:"destructive"})}},Y=()=>{switch(l){case 0:return e.jsx(ZE,{config:g,onChange:j});case 1:return e.jsx(JE,{config:b,onChange:w});case 2:return e.jsx(e4,{config:S,onChange:C});case 3:return e.jsx(t4,{config:N,onChange:T});case 4:return e.jsxs("div",{className:"space-y-6 text-center py-8",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(ao,{className:"h-8 w-8 text-primary",strokeWidth:2})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-xl font-semibold",children:"模型配置"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:"为了让机器人正常工作,您需要配置 AI 模型提供商和模型。"})]}),e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-6 max-w-md mx-auto text-left space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/20 flex items-center justify-center text-primary text-sm font-semibold",children:"1"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"配置 API 提供商"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:'在"系统设置 → 模型配置 → API 提供商"中添加您的 API 提供商信息'})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/20 flex items-center justify-center text-primary text-sm font-semibold",children:"2"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"添加模型"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:'在"系统设置 → 模型配置 → 模型列表"中添加需要使用的模型'})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/20 flex items-center justify-center text-primary text-sm font-semibold",children:"3"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"配置模型任务"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:'在"系统设置 → 模型配置 → 模型任务配置"中为不同任务分配模型'})]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"💡 提示:完成向导后,您可以在系统设置中进行详细的模型配置"})]});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.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"})]}),p?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(z2,{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:["让我们一起完成 ",Rh," 的初始配置"]})]}),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:["步骤 ",l+1," / ",P.length]}),e.jsxs("span",{className:"font-medium text-primary",children:[Math.round(M),"%"]})]}),e.jsx(_o,{value:M,className:"h-2"})]}),e.jsx("div",{className:"mb-6 md:mb-8 flex justify-between",children:P.map((G,$)=>{const oe=G.icon;return e.jsxs("div",{className:Z("flex flex-1 flex-col items-center gap-1 md:gap-2",$s({to:"/"}),className:"gap-2 w-full sm:w-auto",children:[e.jsx(fd,{className:"h-4 w-4"}),"返回首页"]}),e.jsxs(q,{size:"lg",variant:"outline",onClick:()=>window.history.back(),className:"gap-2 w-full sm:w-auto",children:[e.jsx(My,{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:"如果您认为这是一个错误,请联系系统管理员"})})]})})}var F0=["PageUp","PageDown"],Y0=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],q0={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ei="Slider",[$f,u4,m4]=_d(ei),[V0]=Dn(ei,[m4]),[f4,Fd]=V0(ei),G0=x.forwardRef((s,a)=>{const{name:l,min:i=0,max:c=100,step:d=1,orientation:m="horizontal",disabled:h=!1,minStepsBetweenThumbs:p=0,defaultValue:v=[i],value:g,onValueChange:j=()=>{},onValueCommit:b=()=>{},inverted:w=!1,form:S,...C}=s,N=x.useRef(new Set),T=x.useRef(0),M=m==="horizontal"?h4:x4,[k=[],D]=Qa({prop:g,defaultProp:v,onChange:$=>{[...N.current][T.current]?.focus(),j($)}}),A=x.useRef(k);function E($){const oe=y4(k,$);G($,oe)}function B($){G($,T.current)}function Y(){const $=A.current[T.current];k[T.current]!==$&&b(k)}function G($,oe,{commit:je}={commit:!1}){const ae=S4(d),me=_4(Math.round(($-i)/d)*d+i,ae),R=rh(me,[i,c]);D((O=[])=>{const L=v4(O,R,oe);if(w4(L,p*d)){T.current=L.indexOf(R);const ee=String(L)!==String(O);return ee&&je&&b(L),ee?L:O}else return O})}return e.jsx(f4,{scope:s.__scopeSlider,name:l,disabled:h,min:i,max:c,valueIndexToChangeRef:T,thumbs:N.current,values:k,orientation:m,form:S,children:e.jsx($f.Provider,{scope:s.__scopeSlider,children:e.jsx($f.Slot,{scope:s.__scopeSlider,children:e.jsx(M,{"aria-disabled":h,"data-disabled":h?"":void 0,...C,ref:a,onPointerDown:be(C.onPointerDown,()=>{h||(A.current=k)}),min:i,max:c,inverted:w,onSlideStart:h?void 0:E,onSlideMove:h?void 0:B,onSlideEnd:h?void 0:Y,onHomeKeyDown:()=>!h&&G(i,0,{commit:!0}),onEndKeyDown:()=>!h&&G(c,k.length-1,{commit:!0}),onStepKeyDown:({event:$,direction:oe})=>{if(!h){const me=F0.includes($.key)||$.shiftKey&&Y0.includes($.key)?10:1,R=T.current,O=k[R],L=d*me*oe;G(O+L,R,{commit:!0})}}})})})})});G0.displayName=ei;var[$0,I0]=V0(ei,{startEdge:"left",endEdge:"right",size:"width",direction:1}),h4=x.forwardRef((s,a)=>{const{min:l,max:i,dir:c,inverted:d,onSlideStart:m,onSlideMove:h,onSlideEnd:p,onStepKeyDown:v,...g}=s,[j,b]=x.useState(null),w=Tt(a,M=>b(M)),S=x.useRef(void 0),C=xo(c),N=C==="ltr",T=N&&!d||!N&&d;function P(M){const k=S.current||j.getBoundingClientRect(),D=[0,k.width],E=zh(D,T?[l,i]:[i,l]);return S.current=k,E(M-k.left)}return e.jsx($0,{scope:s.__scopeSlider,startEdge:T?"left":"right",endEdge:T?"right":"left",direction:T?1:-1,size:"width",children:e.jsx(W0,{dir:C,"data-orientation":"horizontal",...g,ref:w,style:{...g.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const k=P(M.clientX);m?.(k)},onSlideMove:M=>{const k=P(M.clientX);h?.(k)},onSlideEnd:()=>{S.current=void 0,p?.()},onStepKeyDown:M=>{const D=q0[T?"from-left":"from-right"].includes(M.key);v?.({event:M,direction:D?-1:1})}})})}),x4=x.forwardRef((s,a)=>{const{min:l,max:i,inverted:c,onSlideStart:d,onSlideMove:m,onSlideEnd:h,onStepKeyDown:p,...v}=s,g=x.useRef(null),j=Tt(a,g),b=x.useRef(void 0),w=!c;function S(C){const N=b.current||g.current.getBoundingClientRect(),T=[0,N.height],M=zh(T,w?[i,l]:[l,i]);return b.current=N,M(C-N.top)}return e.jsx($0,{scope:s.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:e.jsx(W0,{"data-orientation":"vertical",...v,ref:j,style:{...v.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:C=>{const N=S(C.clientY);d?.(N)},onSlideMove:C=>{const N=S(C.clientY);m?.(N)},onSlideEnd:()=>{b.current=void 0,h?.()},onStepKeyDown:C=>{const T=q0[w?"from-bottom":"from-top"].includes(C.key);p?.({event:C,direction:T?-1:1})}})})}),W0=x.forwardRef((s,a)=>{const{__scopeSlider:l,onSlideStart:i,onSlideMove:c,onSlideEnd:d,onHomeKeyDown:m,onEndKeyDown:h,onStepKeyDown:p,...v}=s,g=Fd(ei,l);return e.jsx(dt.span,{...v,ref:a,onKeyDown:be(s.onKeyDown,j=>{j.key==="Home"?(m(j),j.preventDefault()):j.key==="End"?(h(j),j.preventDefault()):F0.concat(Y0).includes(j.key)&&(p(j),j.preventDefault())}),onPointerDown:be(s.onPointerDown,j=>{const b=j.target;b.setPointerCapture(j.pointerId),j.preventDefault(),g.thumbs.has(b)?b.focus():i(j)}),onPointerMove:be(s.onPointerMove,j=>{j.target.hasPointerCapture(j.pointerId)&&c(j)}),onPointerUp:be(s.onPointerUp,j=>{const b=j.target;b.hasPointerCapture(j.pointerId)&&(b.releasePointerCapture(j.pointerId),d(j))})})}),X0="SliderTrack",K0=x.forwardRef((s,a)=>{const{__scopeSlider:l,...i}=s,c=Fd(X0,l);return e.jsx(dt.span,{"data-disabled":c.disabled?"":void 0,"data-orientation":c.orientation,...i,ref:a})});K0.displayName=X0;var If="SliderRange",Q0=x.forwardRef((s,a)=>{const{__scopeSlider:l,...i}=s,c=Fd(If,l),d=I0(If,l),m=x.useRef(null),h=Tt(a,m),p=c.values.length,v=c.values.map(b=>eN(b,c.min,c.max)),g=p>1?Math.min(...v):0,j=100-Math.max(...v);return e.jsx(dt.span,{"data-orientation":c.orientation,"data-disabled":c.disabled?"":void 0,...i,ref:h,style:{...s.style,[d.startEdge]:g+"%",[d.endEdge]:j+"%"}})});Q0.displayName=If;var Wf="SliderThumb",Z0=x.forwardRef((s,a)=>{const l=u4(s.__scopeSlider),[i,c]=x.useState(null),d=Tt(a,h=>c(h)),m=x.useMemo(()=>i?l().findIndex(h=>h.ref.current===i):-1,[l,i]);return e.jsx(p4,{...s,ref:d,index:m})}),p4=x.forwardRef((s,a)=>{const{__scopeSlider:l,index:i,name:c,...d}=s,m=Fd(Wf,l),h=I0(Wf,l),[p,v]=x.useState(null),g=Tt(a,P=>v(P)),j=p?m.form||!!p.closest("form"):!0,b=dy(p),w=m.values[i],S=w===void 0?0:eN(w,m.min,m.max),C=j4(i,m.values.length),N=b?.[h.size],T=N?b4(N,S,h.direction):0;return x.useEffect(()=>{if(p)return m.thumbs.add(p),()=>{m.thumbs.delete(p)}},[p,m.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[h.startEdge]:`calc(${S}% + ${T}px)`},children:[e.jsx($f.ItemSlot,{scope:s.__scopeSlider,children:e.jsx(dt.span,{role:"slider","aria-label":s["aria-label"]||C,"aria-valuemin":m.min,"aria-valuenow":w,"aria-valuemax":m.max,"aria-orientation":m.orientation,"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,tabIndex:m.disabled?void 0:0,...d,ref:g,style:w===void 0?{display:"none"}:s.style,onFocus:be(s.onFocus,()=>{m.valueIndexToChangeRef.current=i})})}),j&&e.jsx(J0,{name:c??(m.name?m.name+(m.values.length>1?"[]":""):void 0),form:m.form,value:w},i)]})});Z0.displayName=Wf;var g4="RadioBubbleInput",J0=x.forwardRef(({__scopeSlider:s,value:a,...l},i)=>{const c=x.useRef(null),d=Tt(c,i),m=cy(a);return x.useEffect(()=>{const h=c.current;if(!h)return;const p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"value").set;if(m!==a&&g){const j=new Event("input",{bubbles:!0});g.call(h,a),h.dispatchEvent(j)}},[m,a]),e.jsx(dt.input,{style:{display:"none"},...l,ref:d,defaultValue:a})});J0.displayName=g4;function v4(s=[],a,l){const i=[...s];return i[l]=a,i.sort((c,d)=>c-d)}function eN(s,a,l){const d=100/(l-a)*(s-a);return rh(d,[0,100])}function j4(s,a){return a>2?`Value ${s+1} of ${a}`:a===2?["Minimum","Maximum"][s]:void 0}function y4(s,a){if(s.length===1)return 0;const l=s.map(c=>Math.abs(c-a)),i=Math.min(...l);return l.indexOf(i)}function b4(s,a,l){const i=s/2,d=zh([0,50],[0,i]);return(i-d(a)*l)*l}function N4(s){return s.slice(0,-1).map((a,l)=>s[l+1]-a)}function w4(s,a){if(a>0){const l=N4(s);return Math.min(...l)>=a}return!0}function zh(s,a){return l=>{if(s[0]===s[1]||a[0]===a[1])return a[0];const i=(a[1]-a[0])/(s[1]-s[0]);return a[0]+i*(l-s[0])}}function S4(s){return(String(s).split(".")[1]||"").length}function _4(s,a){const l=Math.pow(10,a);return Math.round(s*l)/l}var tN=G0,C4=K0,k4=Q0,T4=Z0;const Yd=x.forwardRef(({className:s,...a},l)=>e.jsxs(tN,{ref:l,className:Z("relative flex w-full touch-none select-none items-center",s),...a,children:[e.jsx(C4,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(k4,{className:"absolute h-full bg-primary"})}),e.jsx(T4,{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"})]}));Yd.displayName=tN.displayName;const rt=y2,it=b2,at=x.forwardRef(({className:s,children:a,...l},i)=>e.jsxs(hy,{ref:i,className:Z("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",s),...l,children:[a,e.jsx(x2,{asChild:!0,children:e.jsx(lo,{className:"h-4 w-4 opacity-50"})})]}));at.displayName=hy.displayName;const sN=x.forwardRef(({className:s,...a},l)=>e.jsx(xy,{ref:l,className:Z("flex cursor-default items-center justify-center py-1",s),...a,children:e.jsx(Pf,{className:"h-4 w-4"})}));sN.displayName=xy.displayName;const nN=x.forwardRef(({className:s,...a},l)=>e.jsx(py,{ref:l,className:Z("flex cursor-default items-center justify-center py-1",s),...a,children:e.jsx(lo,{className:"h-4 w-4"})}));nN.displayName=py.displayName;const lt=x.forwardRef(({className:s,children:a,position:l="popper",...i},c)=>e.jsx(p2,{children:e.jsxs(gy,{ref:c,className:Z("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]",l==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:l,...i,children:[e.jsx(sN,{}),e.jsx(g2,{className:Z("p-1",l==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(nN,{})]})}));lt.displayName=gy.displayName;const E4=x.forwardRef(({className:s,...a},l)=>e.jsx(vy,{ref:l,className:Z("px-2 py-1.5 text-sm font-semibold",s),...a}));E4.displayName=vy.displayName;const ye=x.forwardRef(({className:s,children:a,...l},i)=>e.jsxs(jy,{ref:i,className:Z("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",s),...l,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(v2,{children:e.jsx(Cl,{className:"h-4 w-4"})})}),e.jsx(j2,{children:a})]}));ye.displayName=jy.displayName;const M4=x.forwardRef(({className:s,...a},l)=>e.jsx(yy,{ref:l,className:Z("-mx-1 my-1 h-px bg-muted",s),...a}));M4.displayName=yy.displayName;function D4(s){const a=O4(s),l=x.forwardRef((i,c)=>{const{children:d,...m}=i,h=x.Children.toArray(d),p=h.find(R4);if(p){const v=p.props.children,g=h.map(j=>j===p?x.Children.count(v)>1?x.Children.only(null):x.isValidElement(v)?v.props.children:null:j);return e.jsx(a,{...m,ref:c,children:x.isValidElement(v)?x.cloneElement(v,void 0,g):null})}return e.jsx(a,{...m,ref:c,children:d})});return l.displayName=`${s}.Slot`,l}function O4(s){const a=x.forwardRef((l,i)=>{const{children:c,...d}=l;if(x.isValidElement(c)){const m=P4(c),h=z4(d,c.props);return c.type!==x.Fragment&&(h.ref=i?Ga(i,m):m),x.cloneElement(c,h)}return x.Children.count(c)>1?x.Children.only(null):null});return a.displayName=`${s}.SlotClone`,a}var A4=Symbol("radix.slottable");function R4(s){return x.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===A4}function z4(s,a){const l={...a};for(const i in a){const c=s[i],d=a[i];/^on[A-Z]/.test(i)?c&&d?l[i]=(...h)=>{const p=d(...h);return c(...h),p}:c&&(l[i]=c):i==="style"?l[i]={...c,...d}:i==="className"&&(l[i]=[c,d].filter(Boolean).join(" "))}return{...s,...l}}function P4(s){let a=Object.getOwnPropertyDescriptor(s.props,"ref")?.get,l=a&&"isReactWarning"in a&&a.isReactWarning;return l?s.ref:(a=Object.getOwnPropertyDescriptor(s,"ref")?.get,l=a&&"isReactWarning"in a&&a.isReactWarning,l?s.props.ref:s.props.ref||s.ref)}var qd="Popover",[aN]=Dn(qd,[Wr]),Co=Wr(),[L4,Za]=aN(qd),lN=s=>{const{__scopePopover:a,children:l,open:i,defaultOpen:c,onOpenChange:d,modal:m=!1}=s,h=Co(a),p=x.useRef(null),[v,g]=x.useState(!1),[j,b]=Qa({prop:i,defaultProp:c??!1,onChange:d,caller:qd});return e.jsx(Ed,{...h,children:e.jsx(L4,{scope:a,contentId:jn(),triggerRef:p,open:j,onOpenChange:b,onOpenToggle:x.useCallback(()=>b(w=>!w),[b]),hasCustomAnchor:v,onCustomAnchorAdd:x.useCallback(()=>g(!0),[]),onCustomAnchorRemove:x.useCallback(()=>g(!1),[]),modal:m,children:l})})};lN.displayName=qd;var rN="PopoverAnchor",B4=x.forwardRef((s,a)=>{const{__scopePopover:l,...i}=s,c=Za(rN,l),d=Co(l),{onCustomAnchorAdd:m,onCustomAnchorRemove:h}=c;return x.useEffect(()=>(m(),()=>h()),[m,h]),e.jsx(Md,{...d,...i,ref:a})});B4.displayName=rN;var iN="PopoverTrigger",oN=x.forwardRef((s,a)=>{const{__scopePopover:l,...i}=s,c=Za(iN,l),d=Co(l),m=Tt(a,c.triggerRef),h=e.jsx(dt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":c.open,"aria-controls":c.contentId,"data-state":fN(c.open),...i,ref:m,onClick:be(s.onClick,c.onOpenToggle)});return c.hasCustomAnchor?h:e.jsx(Md,{asChild:!0,...d,children:h})});oN.displayName=iN;var Ph="PopoverPortal",[U4,H4]=aN(Ph,{forceMount:void 0}),cN=s=>{const{__scopePopover:a,forceMount:l,children:i,container:c}=s,d=Za(Ph,a);return e.jsx(U4,{scope:a,forceMount:l,children:e.jsx(Is,{present:l||d.open,children:e.jsx(Td,{asChild:!0,container:c,children:i})})})};cN.displayName=Ph;var $r="PopoverContent",dN=x.forwardRef((s,a)=>{const l=H4($r,s.__scopePopover),{forceMount:i=l.forceMount,...c}=s,d=Za($r,s.__scopePopover);return e.jsx(Is,{present:i||d.open,children:d.modal?e.jsx(Y4,{...c,ref:a}):e.jsx(q4,{...c,ref:a})})});dN.displayName=$r;var F4=D4("PopoverContent.RemoveScroll"),Y4=x.forwardRef((s,a)=>{const l=Za($r,s.__scopePopover),i=x.useRef(null),c=Tt(a,i),d=x.useRef(!1);return x.useEffect(()=>{const m=i.current;if(m)return by(m)},[]),e.jsx(Ny,{as:F4,allowPinchZoom:!0,children:e.jsx(uN,{...s,ref:c,trapFocus:l.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:be(s.onCloseAutoFocus,m=>{m.preventDefault(),d.current||l.triggerRef.current?.focus()}),onPointerDownOutside:be(s.onPointerDownOutside,m=>{const h=m.detail.originalEvent,p=h.button===0&&h.ctrlKey===!0,v=h.button===2||p;d.current=v},{checkForDefaultPrevented:!1}),onFocusOutside:be(s.onFocusOutside,m=>m.preventDefault(),{checkForDefaultPrevented:!1})})})}),q4=x.forwardRef((s,a)=>{const l=Za($r,s.__scopePopover),i=x.useRef(!1),c=x.useRef(!1);return e.jsx(uN,{...s,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:d=>{s.onCloseAutoFocus?.(d),d.defaultPrevented||(i.current||l.triggerRef.current?.focus(),d.preventDefault()),i.current=!1,c.current=!1},onInteractOutside:d=>{s.onInteractOutside?.(d),d.defaultPrevented||(i.current=!0,d.detail.originalEvent.type==="pointerdown"&&(c.current=!0));const m=d.target;l.triggerRef.current?.contains(m)&&d.preventDefault(),d.detail.originalEvent.type==="focusin"&&c.current&&d.preventDefault()}})}),uN=x.forwardRef((s,a)=>{const{__scopePopover:l,trapFocus:i,onOpenAutoFocus:c,onCloseAutoFocus:d,disableOutsidePointerEvents:m,onEscapeKeyDown:h,onPointerDownOutside:p,onFocusOutside:v,onInteractOutside:g,...j}=s,b=Za($r,l),w=Co(l);return wy(),e.jsx(Sy,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:c,onUnmountAutoFocus:d,children:e.jsx(fh,{asChild:!0,disableOutsidePointerEvents:m,onInteractOutside:g,onEscapeKeyDown:h,onPointerDownOutside:p,onFocusOutside:v,onDismiss:()=>b.onOpenChange(!1),children:e.jsx(hh,{"data-state":fN(b.open),role:"dialog",id:b.contentId,...w,...j,ref:a,style:{...j.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),mN="PopoverClose",V4=x.forwardRef((s,a)=>{const{__scopePopover:l,...i}=s,c=Za(mN,l);return e.jsx(dt.button,{type:"button",...i,ref:a,onClick:be(s.onClick,()=>c.onOpenChange(!1))})});V4.displayName=mN;var G4="PopoverArrow",$4=x.forwardRef((s,a)=>{const{__scopePopover:l,...i}=s,c=Co(l);return e.jsx(xh,{...c,...i,ref:a})});$4.displayName=G4;function fN(s){return s?"open":"closed"}var I4=lN,W4=oN,X4=cN,hN=dN;const Ia=I4,Wa=W4,pa=x.forwardRef(({className:s,align:a="center",sideOffset:l=4,...i},c)=>e.jsx(X4,{children:e.jsx(hN,{ref:c,align:a,sideOffset:l,className:Z("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]",s),...i})}));pa.displayName=hN.displayName;const ti="/api/webui/config";async function K4(){const a=await(await Fe(`${ti}/bot`)).json();if(!a.success)throw new Error("获取配置数据失败");return a.config}async function Ur(){const a=await(await Fe(`${ti}/model`)).json();if(!a.success)throw new Error("获取模型配置数据失败");return a.config}async function Bj(s){const l=await(await Fe(`${ti}/bot`,{method:"POST",headers:Ie(),body:JSON.stringify(s)})).json();if(!l.success)throw new Error(l.message||"保存配置失败")}async function Nd(s){const l=await(await Fe(`${ti}/model`,{method:"POST",headers:Ie(),body:JSON.stringify(s)})).json();if(!l.success)throw new Error(l.message||"保存配置失败")}async function Q4(s,a){const i=await(await Fe(`${ti}/bot/section/${s}`,{method:"POST",headers:Ie(),body:JSON.stringify(a)})).json();if(!i.success)throw new Error(i.message||`保存配置节 ${s} 失败`)}async function Xf(s,a){const i=await(await Fe(`${ti}/model/section/${s}`,{method:"POST",headers:Ie(),body:JSON.stringify(a)})).json();if(!i.success)throw new Error(i.message||`保存配置节 ${s} 失败`)}const Z4=$t.create({baseURL:"",timeout:1e4});async function Lh(){try{return(await Z4.post("/api/webui/system/restart")).data}catch(s){throw console.error("重启麦麦失败:",s),s}}const J4=Jr("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"}}),Vd=x.forwardRef(({className:s,variant:a,...l},i)=>e.jsx("div",{ref:i,role:"alert",className:Z(J4({variant:a}),s),...l}));Vd.displayName="Alert";const eM=x.forwardRef(({className:s,...a},l)=>e.jsx("h5",{ref:l,className:Z("mb-1 font-medium leading-none tracking-tight",s),...a}));eM.displayName="AlertTitle";const Gd=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{ref:l,className:Z("text-sm [&_p]:leading-relaxed",s),...a}));Gd.displayName="AlertDescription";function Bh({onRestartComplete:s,onRestartFailed:a}){const[l,i]=x.useState(0),[c,d]=x.useState("restarting"),[m,h]=x.useState(0),[p,v]=x.useState(0);x.useEffect(()=>{const b=setInterval(()=>{i(C=>C>=90?C:C+1)},200),w=setInterval(()=>{h(C=>C+1)},1e3),S=setTimeout(()=>{d("checking"),g()},3e3);return()=>{clearInterval(b),clearInterval(w),clearTimeout(S)}},[]);const g=()=>{const w=async()=>{try{if(v(C=>C+1),(await fetch("/api/webui/system/status",{method:"GET",headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(3e3)})).ok)i(100),d("success"),setTimeout(()=>{s?.()},1500);else throw new Error("Status check failed")}catch{p<60?setTimeout(w,2e3):(d("failed"),a?.())}};w()},j=b=>{const w=Math.floor(b/60),S=b%60;return`${w}:${S.toString().padStart(2,"0")}`};return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center",children:e.jsxs("div",{className:"max-w-md w-full mx-4 space-y-8",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[c==="restarting"&&e.jsxs(e.Fragment,{children:[e.jsx(ro,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"正在重启麦麦"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"请稍候,麦麦正在重启中..."})]}),c==="checking"&&e.jsxs(e.Fragment,{children:[e.jsx(ro,{className:"h-16 w-16 text-primary animate-spin"}),e.jsx("h2",{className:"text-2xl font-bold",children:"检查服务状态"}),e.jsxs("p",{className:"text-muted-foreground text-center",children:["等待服务恢复... (尝试 ",p,"/60)"]})]}),c==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(Ys,{className:"h-16 w-16 text-green-500"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启成功"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"正在跳转到登录页面..."})]}),c==="failed"&&e.jsxs(e.Fragment,{children:[e.jsx(Tl,{className:"h-16 w-16 text-destructive"}),e.jsx("h2",{className:"text-2xl font-bold",children:"重启超时"}),e.jsx("p",{className:"text-muted-foreground text-center",children:"服务未能在预期时间内恢复,请手动检查或刷新页面"})]})]}),c!=="failed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_o,{value:l,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[l,"%"]}),e.jsxs("span",{children:["已用时: ",j(m)]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[c==="restarting"&&"🔄 配置已保存,正在重启主程序...",c==="checking"&&"⏳ 正在等待服务恢复,请勿关闭页面...",c==="success"&&"✅ 配置已生效,服务运行正常",c==="failed"&&"⚠️ 如果长时间无响应,请尝试手动重启"]})}),c==="failed"&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"flex-1 px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"刷新页面"}),e.jsx("button",{onClick:()=>{d("checking"),v(0),g()},className:"flex-1 px-4 py-2 bg-secondary text-secondary-foreground rounded-md hover:bg-secondary/90",children:"重试检测"})]})]})})}function tM(){const[s,a]=x.useState(!0),[l,i]=x.useState(!1),[c,d]=x.useState(!1),[m,h]=x.useState(!1),[p,v]=x.useState(!1),[g,j]=x.useState(!1),{toast:b}=Es(),[w,S]=x.useState(null),[C,N]=x.useState(null),[T,P]=x.useState(null),[M,k]=x.useState(null),[D,A]=x.useState(null),[E,B]=x.useState(null),[Y,G]=x.useState(null),[$,oe]=x.useState(null),[je,ae]=x.useState(null),[me,R]=x.useState(null),[O,L]=x.useState(null),[ee,le]=x.useState(null),[xe,F]=x.useState(null),[W,fe]=x.useState(null),[I,ve]=x.useState(null),[de,Ce]=x.useState(null),[Q,Oe]=x.useState(null),[$e,re]=x.useState(null),Pe=x.useRef(null),ze=x.useRef(!0),Zt=x.useRef({}),Rs=x.useCallback(async()=>{try{a(!0);const ke=await K4();Zt.current=ke,S(ke.bot),N(ke.personality);const is=ke.chat;is.talk_value_rules||(is.talk_value_rules=[]),P(is),k(ke.expression),A(ke.emoji),B(ke.memory),G(ke.tool),oe(ke.mood),ae(ke.voice),R(ke.lpmm_knowledge),L(ke.keyword_reaction),le(ke.response_post_process),F(ke.chinese_typo),fe(ke.response_splitter),ve(ke.log),Ce(ke.debug),Oe(ke.maim_message),re(ke.telemetry),h(!1),ze.current=!1}catch(ke){console.error("加载配置失败:",ke),b({title:"加载失败",description:"无法加载配置文件",variant:"destructive"})}finally{a(!1)}},[b]);x.useEffect(()=>{Rs()},[Rs]);const An=x.useCallback(async(ke,is)=>{if(!ze.current)try{d(!0),await Q4(ke,is),h(!1)}catch(he){console.error(`自动保存 ${ke} 失败:`,he),h(!0)}finally{d(!1)}},[]),Le=x.useCallback((ke,is)=>{ze.current||(h(!0),Pe.current&&clearTimeout(Pe.current),Pe.current=setTimeout(()=>{An(ke,is)},2e3))},[An]);x.useEffect(()=>{w&&!ze.current&&Le("bot",w)},[w,Le]),x.useEffect(()=>{C&&!ze.current&&Le("personality",C)},[C,Le]),x.useEffect(()=>{T&&!ze.current&&Le("chat",T)},[T,Le]),x.useEffect(()=>{M&&!ze.current&&Le("expression",M)},[M,Le]),x.useEffect(()=>{D&&!ze.current&&Le("emoji",D)},[D,Le]),x.useEffect(()=>{E&&!ze.current&&Le("memory",E)},[E,Le]),x.useEffect(()=>{Y&&!ze.current&&Le("tool",Y)},[Y,Le]),x.useEffect(()=>{$&&!ze.current&&Le("mood",$)},[$,Le]),x.useEffect(()=>{je&&!ze.current&&Le("voice",je)},[je,Le]),x.useEffect(()=>{me&&!ze.current&&Le("lpmm_knowledge",me)},[me,Le]),x.useEffect(()=>{O&&!ze.current&&Le("keyword_reaction",O)},[O,Le]),x.useEffect(()=>{ee&&!ze.current&&Le("response_post_process",ee)},[ee,Le]),x.useEffect(()=>{xe&&!ze.current&&Le("chinese_typo",xe)},[xe,Le]),x.useEffect(()=>{W&&!ze.current&&Le("response_splitter",W)},[W,Le]),x.useEffect(()=>{I&&!ze.current&&Le("log",I)},[I,Le]),x.useEffect(()=>{de&&!ze.current&&Le("debug",de)},[de,Le]),x.useEffect(()=>{Q&&!ze.current&&Le("maim_message",Q)},[Q,Le]),x.useEffect(()=>{$e&&!ze.current&&Le("telemetry",$e)},[$e,Le]);const Nn=async()=>{try{i(!0),Pe.current&&clearTimeout(Pe.current);const ke={...Zt.current,bot:w,personality:C,chat:T,expression:M,emoji:D,memory:E,tool:Y,mood:$,voice:je,lpmm_knowledge:me,keyword_reaction:O,response_post_process:ee,chinese_typo:xe,response_splitter:W,log:I,debug:de,maim_message:Q,telemetry:$e};await Bj(ke),h(!1),b({title:"保存成功",description:"麦麦主程序配置已保存"})}catch(ke){console.error("保存配置失败:",ke),b({title:"保存失败",description:ke.message,variant:"destructive"})}finally{i(!1)}},ln=async()=>{try{v(!0),Lh().catch(()=>{}),j(!0)}catch(ke){console.error("重启失败:",ke),j(!1),b({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),v(!1)}},rn=async()=>{try{i(!0),Pe.current&&clearTimeout(Pe.current);const ke={...Zt.current,bot:w,personality:C,chat:T,expression:M,emoji:D,memory:E,tool:Y,mood:$,voice:je,lpmm_knowledge:me,keyword_reaction:O,response_post_process:ee,chinese_typo:xe,response_splitter:W,log:I,debug:de,maim_message:Q,telemetry:$e};await Bj(ke),h(!1),b({title:"保存成功",description:"配置已保存,即将重启麦麦..."}),await new Promise(is=>setTimeout(is,500)),await ln()}catch(ke){console.error("保存失败:",ke),b({title:"保存失败",description:ke.message,variant:"destructive"})}finally{i(!1)}},Xt=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},Ds=()=>{j(!1),v(!1),b({title:"重启失败",description:"服务器未能在预期时间内恢复,请手动检查",variant:"destructive"})};return s?e.jsx(Ct,{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(Ct,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"麦麦主程序配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理麦麦的核心功能和行为设置"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs(q,{onClick:Nn,disabled:l||c||!m||p,size:"sm",variant:"outline",className:"flex-1 sm:flex-none",children:[e.jsx(vh,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),l?"保存中...":c?"自动保存中...":m?"保存配置":"已保存"]}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(q,{disabled:l||c||p,size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(jh,{className:"mr-2 h-4 w-4"}),p?"重启中...":m?"保存并重启":"重启麦麦"]})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认重启麦麦?"}),e.jsx(Pt,{children:m?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:m?rn:ln,children:m?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(Vd,{children:[e.jsx(Fr,{className:"h-4 w-4"}),e.jsxs(Gd,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Ml,{defaultValue:"bot",className:"w-full",children:[e.jsx("div",{className:"overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0",children:e.jsxs($a,{className:"inline-flex w-auto min-w-full sm:grid sm:w-full sm:grid-cols-5 lg:grid-cols-10",children:[e.jsx(bt,{value:"bot",className:"flex-shrink-0",children:"基本信息"}),e.jsx(bt,{value:"personality",className:"flex-shrink-0",children:"人格"}),e.jsx(bt,{value:"chat",className:"flex-shrink-0",children:"聊天"}),e.jsx(bt,{value:"expression",className:"flex-shrink-0",children:"表达"}),e.jsx(bt,{value:"features",className:"flex-shrink-0",children:"功能"}),e.jsx(bt,{value:"processing",className:"flex-shrink-0",children:"处理"}),e.jsx(bt,{value:"mood",className:"flex-shrink-0",children:"情绪"}),e.jsx(bt,{value:"voice",className:"flex-shrink-0",children:"语音"}),e.jsx(bt,{value:"lpmm",className:"flex-shrink-0",children:"知识库"}),e.jsx(bt,{value:"other",className:"flex-shrink-0",children:"其他"})]})}),e.jsx(Vt,{value:"bot",className:"space-y-4",children:w&&e.jsx(sM,{config:w,onChange:S})}),e.jsx(Vt,{value:"personality",className:"space-y-4",children:C&&e.jsx(nM,{config:C,onChange:N})}),e.jsx(Vt,{value:"chat",className:"space-y-4",children:T&&e.jsx(aM,{config:T,onChange:P})}),e.jsx(Vt,{value:"expression",className:"space-y-4",children:M&&e.jsx(lM,{config:M,onChange:k})}),e.jsx(Vt,{value:"features",className:"space-y-4",children:D&&E&&Y&&e.jsx(rM,{emojiConfig:D,memoryConfig:E,toolConfig:Y,onEmojiChange:A,onMemoryChange:B,onToolChange:G})}),e.jsx(Vt,{value:"processing",className:"space-y-4",children:O&&ee&&xe&&W&&e.jsx(iM,{keywordReactionConfig:O,responsePostProcessConfig:ee,chineseTypoConfig:xe,responseSplitterConfig:W,onKeywordReactionChange:L,onResponsePostProcessChange:le,onChineseTypoChange:F,onResponseSplitterChange:fe})}),e.jsx(Vt,{value:"mood",className:"space-y-4",children:$&&e.jsx(oM,{config:$,onChange:oe})}),e.jsx(Vt,{value:"voice",className:"space-y-4",children:je&&e.jsx(cM,{config:je,onChange:ae})}),e.jsx(Vt,{value:"lpmm",className:"space-y-4",children:me&&e.jsx(dM,{config:me,onChange:R})}),e.jsxs(Vt,{value:"other",className:"space-y-4",children:[I&&e.jsx(uM,{config:I,onChange:ve}),de&&e.jsx(mM,{config:de,onChange:Ce}),Q&&e.jsx(fM,{config:Q,onChange:Oe}),$e&&e.jsx(hM,{config:$e,onChange:re})]})]}),g&&e.jsx(Bh,{onRestartComplete:Xt,onRestartFailed:Ds})]})})}function sM({config:s,onChange:a}){const l=()=>{a({...s,platforms:[...s.platforms,""]})},i=p=>{a({...s,platforms:s.platforms.filter((v,g)=>g!==p)})},c=(p,v)=>{const g=[...s.platforms];g[p]=v,a({...s,platforms:g})},d=()=>{a({...s,alias_names:[...s.alias_names,""]})},m=p=>{a({...s,alias_names:s.alias_names.filter((v,g)=>g!==p)})},h=(p,v)=>{const g=[...s.alias_names];g[p]=v,a({...s,alias_names:g})};return e.jsx("div",{className:"rounded-lg border bg-card 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(U,{htmlFor:"platform",children:"平台"}),e.jsx(pe,{id:"platform",value:s.platform,onChange:p=>a({...s,platform:p.target.value}),placeholder:"qq"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"qq_account",children:"QQ账号"}),e.jsx(pe,{id:"qq_account",value:s.qq_account,onChange:p=>a({...s,qq_account:p.target.value}),placeholder:"123456789"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"nickname",children:"昵称"}),e.jsx(pe,{id:"nickname",value:s.nickname,onChange:p=>a({...s,nickname:p.target.value}),placeholder:"麦麦"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(U,{children:"其他平台账号"}),e.jsxs(q,{onClick:l,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[s.platforms.map((p,v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pe,{value:p,onChange:g=>c(v,g.target.value),placeholder:"wx:114514"}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"icon",variant:"outline",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除平台账号 "',p||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>i(v),children:"删除"})]})]})]})]},v)),s.platforms.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无其他平台账号"})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(U,{children:"别名"}),e.jsxs(q,{onClick:d,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加"]})]}),e.jsxs("div",{className:"space-y-2",children:[s.alias_names.map((p,v)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pe,{value:p,onChange:g=>h(v,g.target.value),placeholder:"小麦"}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"icon",variant:"outline",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除别名 "',p||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>m(v),children:"删除"})]})]})]})]},v)),s.alias_names.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"暂无别名"})]})]})]})]})})}function nM({config:s,onChange:a}){const l=()=>{a({...s,states:[...s.states,""]})},i=d=>{a({...s,states:s.states.filter((m,h)=>h!==d)})},c=(d,m)=>{const h=[...s.states];h[d]=m,a({...s,states:h})};return e.jsx("div",{className:"rounded-lg border bg-card 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(U,{htmlFor:"personality",children:"人格特质"}),e.jsx(Dt,{id:"personality",value:s.personality,onChange:d=>a({...s,personality:d.target.value}),placeholder:"描述人格特质和身份特征(建议120字以内)",rows:3}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"建议120字以内,描述人格特质和身份特征"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"reply_style",children:"表达风格"}),e.jsx(Dt,{id:"reply_style",value:s.reply_style,onChange:d=>a({...s,reply_style:d.target.value}),placeholder:"描述说话的表达风格和习惯",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"interest",children:"兴趣"}),e.jsx(Dt,{id:"interest",value:s.interest,onChange:d=>a({...s,interest:d.target.value}),placeholder:"会影响麦麦对什么话题进行回复",rows:2})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"plan_style",children:"说话规则与行为风格"}),e.jsx(Dt,{id:"plan_style",value:s.plan_style,onChange:d=>a({...s,plan_style:d.target.value}),placeholder:"麦麦的说话规则和行为风格",rows:5})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"visual_style",children:"识图规则"}),e.jsx(Dt,{id:"visual_style",value:s.visual_style,onChange:d=>a({...s,visual_style:d.target.value}),placeholder:"识图时的处理规则",rows:3})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"private_plan_style",children:"私聊规则"}),e.jsx(Dt,{id:"private_plan_style",value:s.private_plan_style,onChange:d=>a({...s,private_plan_style:d.target.value}),placeholder:"私聊的说话规则和行为风格",rows:4})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(U,{children:"状态列表(人格多样性)"}),e.jsxs(q,{onClick:l,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加状态"]})]}),e.jsx("div",{className:"space-y-2",children:s.states.map((d,m)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Dt,{value:d,onChange:h=>c(m,h.target.value),placeholder:"描述一个人格状态",rows:2}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"icon",variant:"outline",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsx(Pt,{children:"确定要删除这个人格状态吗?此操作无法撤销。"})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>i(m),children:"删除"})]})]})]})]},m))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"state_probability",children:"状态替换概率"}),e.jsx(pe,{id:"state_probability",type:"number",step:"0.1",min:"0",max:"1",value:s.state_probability,onChange:d=>a({...s,state_probability:parseFloat(d.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"每次构建人格时替换 personality 的概率(0.0-1.0)"})]})]})]})})}function aM({config:s,onChange:a}){const l=()=>{a({...s,talk_value_rules:[...s.talk_value_rules,{target:"",time:"00:00-23:59",value:1}]})},i=h=>{a({...s,talk_value_rules:s.talk_value_rules.filter((p,v)=>v!==h)})},c=(h,p,v)=>{const g=[...s.talk_value_rules];g[h]={...g[h],[p]:v},a({...s,talk_value_rules:g})},d=({value:h,onChange:p})=>{const[v,g]=x.useState("00"),[j,b]=x.useState("00"),[w,S]=x.useState("23"),[C,N]=x.useState("59");x.useEffect(()=>{const P=h.split("-");if(P.length===2){const[M,k]=P,[D,A]=M.split(":"),[E,B]=k.split(":");D&&g(D.padStart(2,"0")),A&&b(A.padStart(2,"0")),E&&S(E.padStart(2,"0")),B&&N(B.padStart(2,"0"))}},[h]);const T=(P,M,k,D)=>{const A=`${P}:${M}-${k}:${D}`;p(A)};return e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",className:"w-full justify-start font-mono text-sm",children:[e.jsx(_l,{className:"h-4 w-4 mr-2"}),h||"选择时间段"]})}),e.jsx(pa,{className:"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(U,{className:"text-xs",children:"小时"}),e.jsxs(rt,{value:v,onValueChange:P=>{g(P),T(P,j,w,C)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:Array.from({length:24},(P,M)=>M).map(P=>e.jsx(ye,{value:P.toString().padStart(2,"0"),children:P.toString().padStart(2,"0")},P))})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-xs",children:"分钟"}),e.jsxs(rt,{value:j,onValueChange:P=>{b(P),T(v,P,w,C)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:Array.from({length:60},(P,M)=>M).map(P=>e.jsx(ye,{value:P.toString().padStart(2,"0"),children:P.toString().padStart(2,"0")},P))})]})]})]})]}),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(U,{className:"text-xs",children:"小时"}),e.jsxs(rt,{value:w,onValueChange:P=>{S(P),T(v,j,P,C)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:Array.from({length:24},(P,M)=>M).map(P=>e.jsx(ye,{value:P.toString().padStart(2,"0"),children:P.toString().padStart(2,"0")},P))})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-xs",children:"分钟"}),e.jsxs(rt,{value:C,onValueChange:P=>{N(P),T(v,j,w,P)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:Array.from({length:60},(P,M)=>M).map(P=>e.jsx(ye,{value:P.toString().padStart(2,"0"),children:P.toString().padStart(2,"0")},P))})]})]})]})]})]})})]})},m=({rule:h})=>{const p=`{ target = "${h.target}", time = "${h.time}", value = ${h.value.toFixed(1)} }`;return e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(pa,{className:"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:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})};return e.jsxs("div",{className:"rounded-lg border bg-card 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(U,{htmlFor:"talk_value",children:"聊天频率(基础值)"}),e.jsx(pe,{id:"talk_value",type:"number",step:"0.1",min:"0",max:"1",value:s.talk_value,onChange:h=>a({...s,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(U,{htmlFor:"mentioned_bot_reply",children:"提及回复增幅"}),e.jsx(pe,{id:"mentioned_bot_reply",type:"number",step:"0.1",min:"0",max:"1",value:s.mentioned_bot_reply,onChange:h=>a({...s,mentioned_bot_reply:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"提及时回复概率增幅,1 为 100% 回复"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"max_context_size",children:"上下文长度"}),e.jsx(pe,{id:"max_context_size",type:"number",min:"1",value:s.max_context_size,onChange:h=>a({...s,max_context_size:parseInt(h.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"planner_smooth",children:"规划器平滑"}),e.jsx(pe,{id:"planner_smooth",type:"number",step:"1",min:"0",value:s.planner_smooth,onChange:h=>a({...s,planner_smooth:parseFloat(h.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"增大数值会减小 planner 负荷,推荐 1-5,0 为关闭"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"enable_talk_value_rules",checked:s.enable_talk_value_rules,onCheckedChange:h=>a({...s,enable_talk_value_rules:h})}),e.jsx(U,{htmlFor:"enable_talk_value_rules",className:"cursor-pointer",children:"启用动态发言频率规则"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"include_planner_reasoning",checked:s.include_planner_reasoning,onCheckedChange:h=>a({...s,include_planner_reasoning:h})}),e.jsx(U,{htmlFor:"include_planner_reasoning",className:"cursor-pointer",children:"将 planner 推理加入 replyer"})]})]})]}),s.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(q,{onClick:l,size:"sm",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),s.talk_value_rules&&s.talk_value_rules.length>0?e.jsx("div",{className:"space-y-4",children:s.talk_value_rules.map((h,p)=>e.jsxs("div",{className:"rounded-lg border p-4 bg-muted/50 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["规则 #",p+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{rule:h}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{variant:"ghost",size:"sm",children:e.jsx(ft,{className:"h-4 w-4 text-destructive"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:["确定要删除规则 #",p+1," 吗?此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>i(p),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(rt,{value:h.target===""?"global":"specific",onValueChange:v=>{v==="global"?c(p,"target",""):c(p,"target","qq::group")},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"global",children:"全局配置"}),e.jsx(ye,{value:"specific",children:"详细配置"})]})]})]}),h.target!==""&&(()=>{const v=h.target.split(":"),g=v[0]||"qq",j=v[1]||"",b=v[2]||"group";return e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"平台"}),e.jsxs(rt,{value:g,onValueChange:w=>{c(p,"target",`${w}:${j}:${b}`)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"qq",children:"QQ"}),e.jsx(ye,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(pe,{value:j,onChange:w=>{c(p,"target",`${g}:${w.target.value}:${b}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"类型"}),e.jsxs(rt,{value:b,onValueChange:w=>{c(p,"target",`${g}:${j}:${w}`)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"group",children:"群组(group)"}),e.jsx(ye,{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(U,{className:"text-xs font-medium",children:"时间段 (Time)"}),e.jsx(d,{value:h.time,onChange:v=>c(p,"time",v)}),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(U,{htmlFor:`rule-value-${p}`,className:"text-xs font-medium",children:"发言频率值 (Value)"}),e.jsx(pe,{id:`rule-value-${p}`,type:"number",step:"0.01",min:"0",max:"1",value:h.value,onChange:v=>{const g=parseFloat(v.target.value);isNaN(g)||c(p,"value",Math.max(0,Math.min(1,g)))},className:"w-20 h-8 text-xs"})]}),e.jsx(Yd,{value:[h.value],onValueChange:v=>c(p,"value",v[0]),min:0,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 (完全沉默)"}),e.jsx("span",{children:"0.5"}),e.jsx("span",{children:"1.0 (正常)"})]})]})]})]},p))}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:'暂无规则,点击"添加规则"按钮创建'})}),e.jsxs("div",{className:"mt-4 p-4 bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:[e.jsx("h5",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"📝 规则说明"}),e.jsxs("ul",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 为空"}),":全局规则,对所有聊天生效"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"Target 指定"}),":仅对特定聊天流生效(格式:platform:id:type)"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"优先级"}),":先匹配具体聊天流规则,再匹配全局规则"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"时间支持跨夜"}),":例如 23:00-02:00 表示晚上11点到次日凌晨2点"]}),e.jsxs("li",{children:["• ",e.jsx("strong",{children:"数值范围"}),":建议 0-1,0 表示完全沉默,1 表示正常发言"]})]})]})]})]})}function lM({config:s,onChange:a}){const l=()=>{a({...s,learning_list:[...s.learning_list,["","enable","enable","1.0"]]})},i=b=>{a({...s,learning_list:s.learning_list.filter((w,S)=>S!==b)})},c=(b,w,S)=>{const C=[...s.learning_list];C[b][w]=S,a({...s,learning_list:C})},d=({rule:b})=>{const w=`["${b[0]}", "${b[1]}", "${b[2]}", "${b[3]}"]`;return e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(pa,{className:"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 文件中的格式"})]})})]})},m=({member:b,groupIndex:w,memberIndex:S,availableChatIds:C})=>{const N=C.includes(b)||b==="*",[T,P]=x.useState(!N);return e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1 flex gap-2",children:T?e.jsxs(e.Fragment,{children:[e.jsx(pe,{value:b,onChange:M=>j(w,S,M.target.value),placeholder:'输入 "*" 或 "qq:123456:group"',className:"flex-1"}),C.length>0&&e.jsx(q,{size:"sm",variant:"outline",onClick:()=>P(!1),title:"切换到下拉选择",children:"下拉"})]}):e.jsxs(e.Fragment,{children:[e.jsxs(rt,{value:b,onValueChange:M=>j(w,S,M),children:[e.jsx(at,{className:"flex-1",children:e.jsx(it,{placeholder:"选择聊天流"})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"*",children:"* (全局共享)"}),C.map((M,k)=>e.jsx(ye,{value:M,children:M},k))]})]}),e.jsx(q,{size:"sm",variant:"outline",onClick:()=>P(!0),title:"切换到手动输入",children:"输入"})]})}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"icon",variant:"outline",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除组成员 "',b||"(空)",'" 吗?此操作无法撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>g(w,S),children:"删除"})]})]})]})]})},h=()=>{a({...s,expression_groups:[...s.expression_groups,[]]})},p=b=>{a({...s,expression_groups:s.expression_groups.filter((w,S)=>S!==b)})},v=b=>{const w=[...s.expression_groups];w[b]=[...w[b],""],a({...s,expression_groups:w})},g=(b,w)=>{const S=[...s.expression_groups];S[b]=S[b].filter((C,N)=>N!==w),a({...s,expression_groups:S})},j=(b,w,S)=>{const C=[...s.expression_groups];C[b][w]=S,a({...s,expression_groups:C})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card 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(q,{onClick:l,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加规则"]})]}),e.jsxs("div",{className:"space-y-4",children:[s.learning_list.map((b,w)=>{const S=s.learning_list.some((k,D)=>D!==w&&k[0]===""),C=b[0]==="",N=b[0].split(":"),T=N[0]||"qq",P=N[1]||"",M=N[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," ",C&&"(全局配置)"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{rule:b}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"sm",variant:"ghost",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:["确定要删除学习规则 ",w+1," 吗?此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>i(w),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"配置类型"}),e.jsxs(rt,{value:C?"global":"specific",onValueChange:k=>{k==="global"?c(w,0,""):c(w,0,"qq::group")},disabled:S&&!C,children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"global",children:"全局配置"}),e.jsx(ye,{value:"specific",disabled:S&&!C,children:"详细配置"})]})]}),S&&!C&&e.jsx("p",{className:"text-xs text-amber-600",children:"已存在全局配置,无法创建新的全局配置"})]}),!C&&e.jsxs("div",{className:"grid gap-4 p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"平台"}),e.jsxs(rt,{value:T,onValueChange:k=>{c(w,0,`${k}:${P}:${M}`)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"qq",children:"QQ"}),e.jsx(ye,{value:"wx",children:"微信"})]})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"群 ID"}),e.jsx(pe,{value:P,onChange:k=>{c(w,0,`${T}:${k.target.value}:${M}`)},placeholder:"输入群 ID",className:"font-mono text-sm"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"类型"}),e.jsxs(rt,{value:M,onValueChange:k=>{c(w,0,`${T}:${P}:${k}`)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"group",children:"群组(group)"}),e.jsx(ye,{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(U,{className:"text-xs font-medium",children:"使用学到的表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦使用从聊天中学到的表达方式"})]}),e.jsx(Ze,{checked:b[1]==="enable",onCheckedChange:k=>c(w,1,k?"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(U,{className:"text-xs font-medium",children:"学习表达"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"允许麦麦从聊天中学习新的表达方式"})]}),e.jsx(Ze,{checked:b[2]==="enable",onCheckedChange:k=>c(w,2,k?"enable":"disable")})]})}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(U,{className:"text-xs font-medium",children:"学习强度"}),e.jsx(pe,{type:"number",step:"0.1",min:"0",max:"5",value:b[3],onChange:k=>{const D=parseFloat(k.target.value);isNaN(D)||c(w,3,Math.max(0,Math.min(5,D)).toFixed(1))},className:"w-20 h-8 text-xs"})]}),e.jsx(Yd,{value:[parseFloat(b[3])||1],onValueChange:k=>c(w,3,k[0].toFixed(1)),min:0,max:5,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0 (不学习)"}),e.jsx("span",{children:"2.5"}),e.jsx("span",{children:"5.0 (快速学习)"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"影响学习频率,最短学习间隔 = 300/学习强度(秒)"})]})]})]},w)}),s.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-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(q,{onClick:h,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加共享组"]})]}),e.jsxs("div",{className:"space-y-4",children:[s.expression_groups.map((b,w)=>{const S=s.learning_list.map(C=>C[0]).filter(C=>C!=="");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(q,{onClick:()=>v(w),size:"sm",variant:"outline",children:e.jsx(ys,{className:"h-4 w-4"})}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"sm",variant:"ghost",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:["确定要删除共享组 ",w+1," 吗?此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>p(w),children:"删除"})]})]})]})]})]}),e.jsx("div",{className:"space-y-2",children:b.map((C,N)=>e.jsx(m,{member:C,groupIndex:w,memberIndex:N,availableChatIds:S},N))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'提示:可以从下拉框选择已配置的聊天流,或手动输入。输入 "*" 启用全局共享'})]},w)}),s.expression_groups.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'暂无共享组,点击"添加共享组"开始配置'})]})]})})]})}function rM({emojiConfig:s,memoryConfig:a,toolConfig:l,onEmojiChange:i,onMemoryChange:c,onToolChange:d}){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"工具设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"enable_tool",checked:l.enable_tool,onCheckedChange:m=>d({...l,enable_tool:m})}),e.jsx(U,{htmlFor:"enable_tool",className:"cursor-pointer",children:"启用工具系统"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"允许麦麦使用各种工具来增强功能"})]})}),e.jsx("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"记忆设置"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"max_agent_iterations",children:"记忆思考深度"}),e.jsx(pe,{id:"max_agent_iterations",type:"number",min:"1",value:a.max_agent_iterations,onChange:m=>c({...a,max_agent_iterations:parseInt(m.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"最低为 1(不深入思考)"})]})]})}),e.jsx("div",{className:"rounded-lg border bg-card 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(U,{htmlFor:"emoji_chance",children:"表情包激活概率"}),e.jsx(pe,{id:"emoji_chance",type:"number",step:"0.1",min:"0",max:"1",value:s.emoji_chance,onChange:m=>i({...s,emoji_chance:parseFloat(m.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"范围 0-1,越大越容易发送表情包"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"max_reg_num",children:"最大注册数量"}),e.jsx(pe,{id:"max_reg_num",type:"number",min:"1",value:s.max_reg_num,onChange:m=>i({...s,max_reg_num:parseInt(m.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"麦麦最多可以注册的表情包数量"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"check_interval",children:"检查间隔(分钟)"}),e.jsx(pe,{id:"check_interval",type:"number",min:"1",value:s.check_interval,onChange:m=>i({...s,check_interval:parseInt(m.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(Ze,{id:"do_replace",checked:s.do_replace,onCheckedChange:m=>i({...s,do_replace:m})}),e.jsx(U,{htmlFor:"do_replace",className:"cursor-pointer",children:"达到最大数量时替换表情包"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"steal_emoji",checked:s.steal_emoji,onCheckedChange:m=>i({...s,steal_emoji:m})}),e.jsx(U,{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(Ze,{id:"content_filtration",checked:s.content_filtration,onCheckedChange:m=>i({...s,content_filtration:m})}),e.jsx(U,{htmlFor:"content_filtration",className:"cursor-pointer",children:"启用表情包过滤"})]}),s.content_filtration&&e.jsxs("div",{className:"grid gap-2 pl-6 border-l-2 border-primary/20",children:[e.jsx(U,{htmlFor:"filtration_prompt",children:"过滤要求"}),e.jsx(pe,{id:"filtration_prompt",value:s.filtration_prompt,onChange:m=>i({...s,filtration_prompt:m.target.value}),placeholder:"符合公序良俗"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"只有符合此要求的表情包才会被保存"})]})]})]})})]})}function iM({keywordReactionConfig:s,responsePostProcessConfig:a,chineseTypoConfig:l,responseSplitterConfig:i,onKeywordReactionChange:c,onResponsePostProcessChange:d,onChineseTypoChange:m,onResponseSplitterChange:h}){const p=()=>{c({...s,regex_rules:[...s.regex_rules,{regex:[""],reaction:""}]})},v=k=>{c({...s,regex_rules:s.regex_rules.filter((D,A)=>A!==k)})},g=(k,D,A)=>{const E=[...s.regex_rules];D==="regex"&&typeof A=="string"?E[k]={...E[k],regex:[A]}:D==="reaction"&&typeof A=="string"&&(E[k]={...E[k],reaction:A}),c({...s,regex_rules:E})},j=({regex:k,reaction:D,onRegexChange:A,onReactionChange:E})=>{const[B,Y]=x.useState(!1),[G,$]=x.useState(""),[oe,je]=x.useState(null),[ae,me]=x.useState(""),[R,O]=x.useState({}),[L,ee]=x.useState(""),le=x.useRef(null),[xe,F]=x.useState("build"),W=de=>de.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),fe=(de,Ce=0)=>{const Q=le.current;if(!Q)return;const Oe=Q.selectionStart||0,$e=Q.selectionEnd||0,re=k.substring(0,Oe)+de+k.substring($e);A(re),setTimeout(()=>{const Pe=Oe+de.length+Ce;Q.setSelectionRange(Pe,Pe),Q.focus()},0)};x.useEffect(()=>{if(!k||!G){je(null),O({}),ee(D),me("");return}try{const de=W(k),Ce=new RegExp(de,"g"),Q=G.match(Ce);je(Q),me("");const $e=new RegExp(de).exec(G);if($e&&$e.groups){O($e.groups);let re=D;Object.entries($e.groups).forEach(([Pe,ze])=>{re=re.replace(new RegExp(`\\[${Pe}\\]`,"g"),ze||"")}),ee(re)}else O({}),ee(D)}catch(de){me(de.message),je(null),O({}),ee(D)}},[k,G,D]);const I=()=>{if(!G||!oe||oe.length===0)return e.jsx("span",{className:"text-muted-foreground",children:G||"请输入测试文本"});try{const de=W(k),Ce=new RegExp(de,"g");let Q=0;const Oe=[];let $e;for(;($e=Ce.exec(G))!==null;)$e.index>Q&&Oe.push(e.jsx("span",{children:G.substring(Q,$e.index)},`text-${Q}`)),Oe.push(e.jsx("span",{className:"bg-yellow-200 dark:bg-yellow-900 font-semibold",children:$e[0]},`match-${$e.index}`)),Q=$e.index+$e[0].length;return Q)",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\\S+)",desc:"捕获一个词语"},{label:"捕获句子",pattern:"(?P.+)",desc:"捕获整个句子"},{label:"捕获数字",pattern:"(?P\\d+)",desc:"捕获一个或多个数字"},{label:"可选词语",pattern:"(?:词语1|词语2)",desc:"匹配多个可选项之一"}]}];return e.jsxs(bs,{open:B,onOpenChange:Y,children:[e.jsx(x0,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",children:[e.jsx(hd,{className:"h-4 w-4 mr-1"}),"正则编辑器"]})}),e.jsxs(ms,{className:"max-w-[95vw] sm:max-w-[900px] max-h-[90vh]",children:[e.jsxs(fs,{children:[e.jsx(hs,{children:"正则表达式编辑器"}),e.jsx(ks,{className:"text-sm",children:"使用可视化工具构建正则表达式,并实时测试效果"})]}),e.jsx(Ct,{className:"max-h-[calc(90vh-120px)]",children:e.jsxs(Ml,{value:xe,onValueChange:de=>F(de),className:"w-full",children:[e.jsxs($a,{className:"grid w-full grid-cols-2",children:[e.jsx(bt,{value:"build",children:"🔧 构建器"}),e.jsx(bt,{value:"test",children:"🧪 测试器"})]}),e.jsxs(Vt,{value:"build",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-sm font-medium",children:"正则表达式"}),e.jsx(pe,{ref:le,value:k,onChange:de=>A(de.target.value),className:"font-mono text-sm",placeholder:"点击下方按钮构建正则表达式..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-sm font-medium",children:"Reaction 内容"}),e.jsx(Dt,{value:D,onChange:de=>E(de.target.value),placeholder:"使用 [捕获组名] 引用捕获的内容...",rows:3,className:"text-sm"})]}),e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[ve.map(de=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h5",{className:"text-xs font-semibold text-primary",children:de.category}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:de.items.map(Ce=>e.jsx(q,{variant:"outline",size:"sm",className:"justify-start h-auto py-2 px-3",onClick:()=>fe(Ce.pattern,Ce.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:Ce.label}),e.jsx("code",{className:"ml-auto text-xs bg-muted px-1.5 py-0.5 rounded font-mono",children:Ce.pattern})]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:Ce.desc})]})},Ce.label))})]},de.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(q,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>A("^(?P\\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\\S","{1,20}",")是这样的$"]}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「某事物是这样的」并捕获事物名称"})]})}),e.jsx(q,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>A("(?:[^,。.\\s]+,\\s*)?我(?:也)?[没沒]要求你\\s*(?P.+?)[.。,,]?$"),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.+?)[.。,,]?$"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"匹配「我没要求你做某事」并捕获具体行为"})]})}),e.jsx(q,{variant:"outline",size:"sm",className:"w-full justify-start h-auto py-2 px-3",onClick:()=>A("(?P.+?)(?:是|为什么|怎么)"),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.+?)(?:是|为什么|怎么)"}),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(Vt,{value:"test",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-sm font-medium",children:"当前正则表达式"}),e.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs break-all",children:k||"(未设置)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"test-text",className:"text-sm font-medium",children:"测试文本"}),e.jsx(Dt,{id:"test-text",value:G,onChange:de=>$(de.target.value),placeholder:`在此输入要测试的文本... 例如:打游戏是这样的`,className:"min-h-[100px] text-sm"})]}),ae&&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:ae})]}),!ae&&G&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:oe&&oe.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:["匹配成功 (",oe.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(U,{className:"text-sm font-medium",children:"匹配高亮"}),e.jsx(Ct,{className:"h-40 rounded-md bg-muted p-3",children:e.jsx("div",{className:"text-sm break-words",children:I()})})]}),Object.keys(R).length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-sm font-medium",children:"命名捕获组"}),e.jsx(Ct,{className:"h-32 rounded-md border p-3",children:e.jsx("div",{className:"space-y-2",children:Object.entries(R).map(([de,Ce])=>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:["[",de,"]"]}),e.jsx("span",{className:"text-muted-foreground",children:"="}),e.jsx("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:Ce})]},de))})})]}),Object.keys(R).length>0&&D&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{className:"text-sm font-medium",children:"Reaction 替换预览"}),e.jsx(Ct,{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:L})}),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:"如需修改正则,切换回构建器标签页"})]})]})]})]})})]})]})},b=()=>{c({...s,keyword_rules:[...s.keyword_rules,{keywords:[],reaction:""}]})},w=k=>{c({...s,keyword_rules:s.keyword_rules.filter((D,A)=>A!==k)})},S=(k,D,A)=>{const E=[...s.keyword_rules];typeof A=="string"&&(E[k]={...E[k],reaction:A}),c({...s,keyword_rules:E})},C=k=>{const D=[...s.keyword_rules];D[k]={...D[k],keywords:[...D[k].keywords||[],""]},c({...s,keyword_rules:D})},N=(k,D)=>{const A=[...s.keyword_rules];A[k]={...A[k],keywords:(A[k].keywords||[]).filter((E,B)=>B!==D)},c({...s,keyword_rules:A})},T=(k,D,A)=>{const E=[...s.keyword_rules],B=[...E[k].keywords||[]];B[D]=A,E[k]={...E[k],keywords:B},c({...s,keyword_rules:E})},P=({rule:k})=>{const D=`{ regex = [${(k.regex||[]).map(A=>`"${A}"`).join(", ")}], reaction = "${k.reaction}" }`;return e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(pa,{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(Ct,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs break-all",children:D})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"这是保存到 bot_config.toml 文件中的格式"})]})})]})},M=({rule:k})=>{const D=`[[keyword_reaction.keyword_rules]] keywords = [${(k.keywords||[]).map(A=>`"${A}"`).join(", ")}] reaction = "${k.reaction}"`;return e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"预览"]})}),e.jsx(pa,{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(Ct,{className:"h-60 rounded-md bg-muted p-3",children:e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all",children:D})}),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-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(q,{onClick:p,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加正则规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[s.regex_rules.map((k,D)=>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:["正则规则 ",D+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{regex:k.regex&&k.regex[0]||"",reaction:k.reaction,onRegexChange:A=>g(D,"regex",A),onReactionChange:A=>g(D,"reaction",A)}),e.jsx(P,{rule:k}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"sm",variant:"ghost",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:["确定要删除正则规则 ",D+1," 吗?此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>v(D),children:"删除"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"正则表达式(Python 语法)"}),e.jsx(pe,{value:k.regex&&k.regex[0]||"",onChange:A=>g(D,"regex",A.target.value),placeholder:"例如:^(?P\\\\S{1,20})是这样的$ (点击正则编辑器按钮可视化构建)",className:"font-mono text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'支持命名捕获组 (?Ppattern),可在 reaction 中使用 [name] 引用。点击"正则编辑器"可视化构建和测试!'})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Dt,{value:k.reaction,onChange:A=>g(D,"reaction",A.target.value),placeholder:`触发后麦麦的反应... 可以使用 [捕获组名] 来引用正则表达式中的内容`,rows:3,className:"text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"使用 [捕获组名] 引用正则表达式中的命名捕获组,例如 [n] 会被替换为捕获的内容"})]})]})]},D)),s.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(q,{onClick:b,size:"sm",variant:"outline",children:[e.jsx(ys,{className:"h-4 w-4 mr-1"}),"添加关键词规则"]})]}),e.jsxs("div",{className:"space-y-3",children:[s.keyword_rules.map((k,D)=>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:["关键词规则 ",D+1]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{rule:k}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(q,{size:"sm",variant:"ghost",children:e.jsx(ft,{className:"h-4 w-4"})})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:["确定要删除关键词规则 ",D+1," 吗?此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>w(D),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(U,{className:"text-xs font-medium",children:"关键词列表"}),e.jsxs(q,{onClick:()=>C(D),size:"sm",variant:"ghost",children:[e.jsx(ys,{className:"h-3 w-3 mr-1"}),"添加关键词"]})]}),e.jsxs("div",{className:"space-y-2",children:[(k.keywords||[]).map((A,E)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{value:A,onChange:B=>T(D,E,B.target.value),placeholder:"关键词",className:"flex-1"}),e.jsx(q,{onClick:()=>N(D,E),size:"sm",variant:"ghost",children:e.jsx(ft,{className:"h-4 w-4"})})]},E)),(!k.keywords||k.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(U,{className:"text-xs font-medium",children:"反应内容"}),e.jsx(Dt,{value:k.reaction,onChange:A=>S(D,"reaction",A.target.value),placeholder:"触发后麦麦的反应...",rows:3,className:"text-sm"})]})]})]},D)),s.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-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(Ze,{id:"enable_response_post_process",checked:a.enable_response_post_process,onCheckedChange:k=>d({...a,enable_response_post_process:k})}),e.jsx(U,{htmlFor:"enable_response_post_process",className:"cursor-pointer",children:"启用回复后处理"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"包括错别字生成器和回复分割器"})]}),a.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(Ze,{id:"enable_chinese_typo",checked:l.enable,onCheckedChange:k=>m({...l,enable:k})}),e.jsx(U,{htmlFor:"enable_chinese_typo",className:"cursor-pointer font-semibold",children:"中文错别字生成器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"为回复添加随机错别字,让麦麦的回复更自然"}),l.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(U,{htmlFor:"error_rate",className:"text-xs font-medium",children:"单字替换概率"}),e.jsx(pe,{id:"error_rate",type:"number",step:"0.001",min:"0",max:"1",value:l.error_rate,onChange:k=>m({...l,error_rate:parseFloat(k.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"min_freq",className:"text-xs font-medium",children:"最小字频阈值"}),e.jsx(pe,{id:"min_freq",type:"number",min:"0",value:l.min_freq,onChange:k=>m({...l,min_freq:parseInt(k.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"tone_error_rate",className:"text-xs font-medium",children:"声调错误概率"}),e.jsx(pe,{id:"tone_error_rate",type:"number",step:"0.01",min:"0",max:"1",value:l.tone_error_rate,onChange:k=>m({...l,tone_error_rate:parseFloat(k.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"word_replace_rate",className:"text-xs font-medium",children:"整词替换概率"}),e.jsx(pe,{id:"word_replace_rate",type:"number",step:"0.001",min:"0",max:"1",value:l.word_replace_rate,onChange:k=>m({...l,word_replace_rate:parseFloat(k.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(Ze,{id:"enable_response_splitter",checked:i.enable,onCheckedChange:k=>h({...i,enable:k})}),e.jsx(U,{htmlFor:"enable_response_splitter",className:"cursor-pointer font-semibold",children:"回复分割器"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"控制回复的长度和句子数量"}),i.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(U,{htmlFor:"max_length",className:"text-xs font-medium",children:"最大长度"}),e.jsx(pe,{id:"max_length",type:"number",min:"1",value:i.max_length,onChange:k=>h({...i,max_length:parseInt(k.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"回复允许的最大字符数"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"max_sentence_num",className:"text-xs font-medium",children:"最大句子数"}),e.jsx(pe,{id:"max_sentence_num",type:"number",min:"1",value:i.max_sentence_num,onChange:k=>h({...i,max_sentence_num:parseInt(k.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(Ze,{id:"enable_kaomoji_protection",checked:i.enable_kaomoji_protection,onCheckedChange:k=>h({...i,enable_kaomoji_protection:k})}),e.jsx(U,{htmlFor:"enable_kaomoji_protection",className:"cursor-pointer",children:"启用颜文字保护"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"enable_overflow_return_all",checked:i.enable_overflow_return_all,onCheckedChange:k=>h({...i,enable_overflow_return_all:k})}),e.jsx(U,{htmlFor:"enable_overflow_return_all",className:"cursor-pointer",children:"超出时一次性返回全部"})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-2",children:"当句子数量超出限制时,合并后一次性返回所有内容"})]})]})})]})]})]})}function oM({config:s,onChange:a}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"情绪设置"}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{checked:s.enable_mood,onCheckedChange:l=>a({...s,enable_mood:l})}),e.jsx(U,{className:"cursor-pointer",children:"启用情绪系统"})]}),s.enable_mood&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"情绪更新阈值"}),e.jsx(pe,{type:"number",min:"1",value:s.mood_update_threshold,onChange:l=>a({...s,mood_update_threshold:parseInt(l.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"越高,更新越慢"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"情感特征"}),e.jsx(Dt,{value:s.emotion_style,onChange:l=>a({...s,emotion_style:l.target.value}),placeholder:"影响情绪的变化情况",rows:2})]})]})]})]})}function cM({config:s,onChange:a}){return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"语音设置"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{checked:s.enable_asr,onCheckedChange:l=>a({...s,enable_asr:l})}),e.jsx(U,{className:"cursor-pointer",children:"启用语音识别"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"启用后麦麦可以识别语音消息,需要配置语音识别模型"})]})}function dM({config:s,onChange:a}){return e.jsxs("div",{className:"rounded-lg border bg-card 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(Ze,{checked:s.enable,onCheckedChange:l=>a({...s,enable:l})}),e.jsx(U,{className:"cursor-pointer",children:"启用 LPMM 知识库"})]}),s.enable&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"LPMM 模式"}),e.jsxs(rt,{value:s.lpmm_mode,onValueChange:l=>a({...s,lpmm_mode:l}),children:[e.jsx(at,{children:e.jsx(it,{placeholder:"选择 LPMM 模式"})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"classic",children:"经典模式"}),e.jsx(ye,{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(U,{children:"同义词搜索 TopK"}),e.jsx(pe,{type:"number",min:"1",value:s.rag_synonym_search_top_k,onChange:l=>a({...s,rag_synonym_search_top_k:parseInt(l.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"同义词阈值"}),e.jsx(pe,{type:"number",step:"0.1",min:"0",max:"1",value:s.rag_synonym_threshold,onChange:l=>a({...s,rag_synonym_threshold:parseFloat(l.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"实体提取线程数"}),e.jsx(pe,{type:"number",min:"1",value:s.info_extraction_workers,onChange:l=>a({...s,info_extraction_workers:parseInt(l.target.value)})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"嵌入向量维度"}),e.jsx(pe,{type:"number",min:"1",value:s.embedding_dimension,onChange:l=>a({...s,embedding_dimension:parseInt(l.target.value)})})]})]})]})]})]})}function uM({config:s,onChange:a}){const[l,i]=x.useState(""),[c,d]=x.useState("WARNING"),m=()=>{l&&!s.suppress_libraries.includes(l)&&(a({...s,suppress_libraries:[...s.suppress_libraries,l]}),i(""))},h=w=>{a({...s,suppress_libraries:s.suppress_libraries.filter(S=>S!==w)})},p=()=>{l&&!s.library_log_levels[l]&&(a({...s,library_log_levels:{...s.library_log_levels,[l]:c}}),i(""),d("WARNING"))},v=w=>{const S={...s.library_log_levels};delete S[w],a({...s,library_log_levels:S})},g=["DEBUG","INFO","WARNING","ERROR","CRITICAL"],j=["FULL","compact","lite"],b=["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(U,{children:"日期格式"}),e.jsx(pe,{value:s.date_style,onChange:w=>a({...s,date_style:w.target.value}),placeholder:"例如: m-d H:i:s"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"m=月, d=日, H=时, i=分, s=秒"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"日志级别样式"}),e.jsxs(rt,{value:s.log_level_style,onValueChange:w=>a({...s,log_level_style:w}),children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:j.map(w=>e.jsx(ye,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"日志文本颜色"}),e.jsxs(rt,{value:s.color_text,onValueChange:w=>a({...s,color_text:w}),children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:b.map(w=>e.jsx(ye,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"全局日志级别"}),e.jsxs(rt,{value:s.log_level,onValueChange:w=>a({...s,log_level:w}),children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:g.map(w=>e.jsx(ye,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"控制台日志级别"}),e.jsxs(rt,{value:s.console_log_level,onValueChange:w=>a({...s,console_log_level:w}),children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:g.map(w=>e.jsx(ye,{value:w,children:w},w))})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"文件日志级别"}),e.jsxs(rt,{value:s.file_log_level,onValueChange:w=>a({...s,file_log_level:w}),children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsx(lt,{children:g.map(w=>e.jsx(ye,{value:w,children:w},w))})]})]})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"mb-2 block",children:"完全屏蔽的库"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(pe,{value:l,onChange:w=>i(w.target.value),placeholder:"输入库名",className:"flex-1",onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),m())}}),e.jsx(q,{onClick:m,size:"sm",className:"flex-shrink-0",children:e.jsx(ys,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.suppress_libraries.map(w=>e.jsxs("div",{className:"flex items-center gap-1 bg-secondary px-3 py-1 rounded-md",children:[e.jsx("span",{className:"text-sm",children:w}),e.jsx(q,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>h(w),children:e.jsx(ft,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},w))})]}),e.jsxs("div",{children:[e.jsx(U,{className:"mb-2 block",children:"特定库的日志级别"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(pe,{value:l,onChange:w=>i(w.target.value),placeholder:"输入库名",className:"flex-1"}),e.jsxs(rt,{value:c,onValueChange:d,children:[e.jsx(at,{className:"w-32",children:e.jsx(it,{})}),e.jsx(lt,{children:g.map(w=>e.jsx(ye,{value:w,children:w},w))})]}),e.jsx(q,{onClick:p,size:"sm",children:e.jsx(ys,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:Object.entries(s.library_log_levels).map(([w,S])=>e.jsxs("div",{className:"flex items-center justify-between bg-secondary px-3 py-2 rounded-md",children:[e.jsx("span",{className:"text-sm font-medium",children:w}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:S}),e.jsx(q,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>v(w),children:e.jsx(ft,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]})]},w))})]})]})}function mM({config:s,onChange:a}){return e.jsxs("div",{className:"rounded-lg border bg-card 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(U,{children:"显示 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否在日志中显示提示词"})]}),e.jsx(Ze,{checked:s.show_prompt,onCheckedChange:l=>a({...s,show_prompt:l})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(U,{children:"显示回复器 Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的提示词"})]}),e.jsx(Ze,{checked:s.show_replyer_prompt,onCheckedChange:l=>a({...s,show_replyer_prompt:l})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(U,{children:"显示回复器推理"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示回复器的推理过程"})]}),e.jsx(Ze,{checked:s.show_replyer_reasoning,onCheckedChange:l=>a({...s,show_replyer_reasoning:l})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(U,{children:"显示 Jargon Prompt"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否显示术语相关的提示词"})]}),e.jsx(Ze,{checked:s.show_jargon_prompt,onCheckedChange:l=>a({...s,show_jargon_prompt:l})})]})]})]})}function fM({config:s,onChange:a}){const[l,i]=x.useState(""),c=()=>{l&&!s.auth_token.includes(l)&&(a({...s,auth_token:[...s.auth_token,l]}),i(""))},d=m=>{a({...s,auth_token:s.auth_token.filter((h,p)=>p!==m)})};return e.jsxs("div",{className:"rounded-lg border bg-card p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"MaimMessage 服务配置"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(U,{children:"启用自定义服务器"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"是否使用自定义的 MaimMessage 服务器"})]}),e.jsx(Ze,{checked:s.use_custom,onCheckedChange:m=>a({...s,use_custom:m})})]}),s.use_custom&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"主机地址"}),e.jsx(pe,{value:s.host,onChange:m=>a({...s,host:m.target.value}),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"端口号"}),e.jsx(pe,{type:"number",value:s.port,onChange:m=>a({...s,port:parseInt(m.target.value)}),placeholder:"8090"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"连接模式"}),e.jsxs(rt,{value:s.mode,onValueChange:m=>a({...s,mode:m}),children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"ws",children:"WebSocket (ws)"}),e.jsx(ye,{value:"tcp",children:"TCP"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{checked:s.use_wss,onCheckedChange:m=>a({...s,use_wss:m}),disabled:s.mode!=="ws"}),e.jsx(U,{children:"使用 WSS 安全连接"})]})]}),s.use_wss&&s.mode==="ws"&&e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"SSL 证书文件路径"}),e.jsx(pe,{value:s.cert_file,onChange:m=>a({...s,cert_file:m.target.value}),placeholder:"cert.pem"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"SSL 密钥文件路径"}),e.jsx(pe,{value:s.key_file,onChange:m=>a({...s,key_file:m.target.value}),placeholder:"key.pem"})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"mb-2 block",children:"认证令牌"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"用于 API 验证,为空则不启用验证"}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(pe,{value:l,onChange:m=>i(m.target.value),placeholder:"输入认证令牌",onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),c())}}),e.jsx(q,{onClick:c,size:"sm",children:e.jsx(ys,{className:"h-4 w-4",strokeWidth:2,fill:"none"})})]}),e.jsx("div",{className:"space-y-2",children:s.auth_token.map((m,h)=>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:m}),e.jsx(q,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>d(h),children:e.jsx(ft,{className:"h-3 w-3",strokeWidth:2,fill:"none"})})]},h))})]})]})}function hM({config:s,onChange:a}){return e.jsxs("div",{className:"rounded-lg border bg-card 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(U,{children:"启用统计信息发送"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"发送匿名统计信息,帮助我们了解全球有多少只麦麦在运行"})]}),e.jsx(Ze,{checked:s.enable,onCheckedChange:l=>a({...s,enable:l})})]})]})}const Rl=x.forwardRef(({className:s,...a},l)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:l,className:Z("w-full caption-bottom text-sm",s),...a})}));Rl.displayName="Table";const zl=x.forwardRef(({className:s,...a},l)=>e.jsx("thead",{ref:l,className:Z("[&_tr]:border-b",s),...a}));zl.displayName="TableHeader";const Pl=x.forwardRef(({className:s,...a},l)=>e.jsx("tbody",{ref:l,className:Z("[&_tr:last-child]:border-0",s),...a}));Pl.displayName="TableBody";const xM=x.forwardRef(({className:s,...a},l)=>e.jsx("tfoot",{ref:l,className:Z("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",s),...a}));xM.displayName="TableFooter";const ns=x.forwardRef(({className:s,...a},l)=>e.jsx("tr",{ref:l,className:Z("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",s),...a}));ns.displayName="TableRow";const He=x.forwardRef(({className:s,...a},l)=>e.jsx("th",{ref:l,className:Z("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a}));He.displayName="TableHead";const Ae=x.forwardRef(({className:s,...a},l)=>e.jsx("td",{ref:l,className:Z("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",s),...a}));Ae.displayName="TableCell";const pM=x.forwardRef(({className:s,...a},l)=>e.jsx("caption",{ref:l,className:Z("mt-4 text-sm text-muted-foreground",s),...a}));pM.displayName="TableCaption";const Cs=x.forwardRef(({className:s,...a},l)=>e.jsx(_y,{ref:l,className:Z("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",s),...a,children:e.jsx(N2,{className:Z("grid place-content-center text-current"),children:e.jsx(Cl,{className:"h-4 w-4"})})}));Cs.displayName=_y.displayName;function gM(){const[s,a]=x.useState([]),[l,i]=x.useState(!0),[c,d]=x.useState(!1),[m,h]=x.useState(!1),[p,v]=x.useState(!1),[g,j]=x.useState(!1),[b,w]=x.useState(!1),[S,C]=x.useState(!1),[N,T]=x.useState(null),[P,M]=x.useState(null),[k,D]=x.useState(!1),[A,E]=x.useState(null),[B,Y]=x.useState(!1),[G,$]=x.useState(""),[oe,je]=x.useState(new Set),[ae,me]=x.useState(!1),[R,O]=x.useState(1),[L,ee]=x.useState(20),[le,xe]=x.useState(""),{toast:F}=Es(),W=x.useRef(null),fe=x.useRef(!0);x.useEffect(()=>{I()},[]);const I=async()=>{try{i(!0);const he=await Ur();a(he.api_providers||[]),v(!1),fe.current=!1}catch(he){console.error("加载配置失败:",he)}finally{i(!1)}},ve=async()=>{try{j(!0),Lh().catch(()=>{}),w(!0)}catch(he){console.error("重启失败:",he),w(!1),F({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),j(!1)}},de=async()=>{try{d(!0),W.current&&clearTimeout(W.current);const he=await Ur();he.api_providers=s,await Nd(he),v(!1),F({title:"保存成功",description:"正在重启麦麦..."}),await ve()}catch(he){console.error("保存配置失败:",he),F({title:"保存失败",description:he.message,variant:"destructive"}),d(!1)}},Ce=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},Q=()=>{w(!1),j(!1),F({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},Oe=x.useCallback(async he=>{if(!fe.current)try{h(!0),await Xf("api_providers",he),v(!1)}catch(Ee){console.error("自动保存失败:",Ee),v(!0)}finally{h(!1)}},[]);x.useEffect(()=>{if(!fe.current)return v(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{Oe(s)},2e3),()=>{W.current&&clearTimeout(W.current)}},[s,Oe]);const $e=async()=>{try{d(!0),W.current&&clearTimeout(W.current);const he=await Ur();he.api_providers=s,await Nd(he),v(!1),F({title:"保存成功",description:"模型提供商配置已保存"})}catch(he){console.error("保存配置失败:",he),F({title:"保存失败",description:he.message,variant:"destructive"})}finally{d(!1)}},re=(he,Ee)=>{T(he||{name:"",base_url:"",api_key:"",client_type:"openai",max_retry:2,timeout:30,retry_interval:10}),M(Ee),Y(!1),C(!0)},Pe=async()=>{if(N?.api_key)try{await navigator.clipboard.writeText(N.api_key),F({title:"复制成功",description:"API Key 已复制到剪贴板"})}catch{F({title:"复制失败",description:"无法访问剪贴板",variant:"destructive"})}},ze=()=>{if(!N)return;const he={...N,max_retry:N.max_retry??2,timeout:N.timeout??30,retry_interval:N.retry_interval??10};if(P!==null){const Ee=[...s];Ee[P]=he,a(Ee)}else a([...s,he]);C(!1),T(null),M(null)},Zt=he=>{if(!he&&N){const Ee={...N,max_retry:N.max_retry??2,timeout:N.timeout??30,retry_interval:N.retry_interval??10};T(Ee)}C(he)},Rs=he=>{E(he),D(!0)},An=()=>{if(A!==null){const he=s.filter((Ee,Ve)=>Ve!==A);a(he),F({title:"删除成功",description:"提供商已从列表中移除"})}D(!1),E(null)},Le=he=>{const Ee=new Set(oe);Ee.has(he)?Ee.delete(he):Ee.add(he),je(Ee)},Nn=()=>{if(oe.size===Xt.length)je(new Set);else{const he=Xt.map((Ee,Ve)=>s.findIndex(Os=>Os===Xt[Ve]));je(new Set(he))}},ln=()=>{if(oe.size===0){F({title:"提示",description:"请先选择要删除的提供商",variant:"default"});return}me(!0)},rn=()=>{const he=s.filter((Ee,Ve)=>!oe.has(Ve));a(he),je(new Set),me(!1),F({title:"批量删除成功",description:`已删除 ${oe.size} 个提供商`})},Xt=s.filter(he=>{if(!G)return!0;const Ee=G.toLowerCase();return he.name.toLowerCase().includes(Ee)||he.base_url.toLowerCase().includes(Ee)||he.client_type.toLowerCase().includes(Ee)}),Ds=Math.ceil(Xt.length/L),ke=Xt.slice((R-1)*L,R*L),is=()=>{const he=parseInt(le);he>=1&&he<=Ds&&(O(he),xe(""))};return l?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:"模型提供商配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理 API 提供商配置"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[oe.size>0&&e.jsxs(q,{onClick:ln,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ft,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",oe.size,")"]}),e.jsxs(q,{onClick:()=>re(null,null),size:"sm",className:"w-full sm:w-auto",children:[e.jsx(ys,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"添加提供商"]}),e.jsxs(q,{onClick:$e,disabled:c||m||!p||g,size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(vh,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),c?"保存中...":m?"自动保存中...":p?"保存配置":"已保存"]}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(q,{disabled:c||m||g,size:"sm",className:"w-full sm:w-auto",children:[e.jsx(jh,{className:"mr-2 h-4 w-4"}),g?"重启中...":p?"保存并重启":"重启麦麦"]})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认重启麦麦?"}),e.jsx(Pt,{children:p?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:p?de:ve,children:p?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(Vd,{children:[e.jsx(Fr,{className:"h-4 w-4"}),e.jsxs(Gd,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Ct,{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(Gs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{placeholder:"搜索提供商名称、URL 或类型...",value:G,onChange:he=>$(he.target.value),className:"pl-9"})]}),G&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Xt.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:Xt.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:G?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'}):ke.map((he,Ee)=>{const Ve=s.findIndex(Os=>Os===he);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.jsx("h3",{className:"font-semibold text-base truncate",children:he.name}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 break-all",children:he.base_url})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>re(he,Ve),children:[e.jsx(Yr,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(q,{size:"sm",onClick:()=>Rs(Ve),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{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:he.client_type})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"最大重试"}),e.jsx("p",{className:"font-medium",children:he.max_retry})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"超时(秒)"}),e.jsx("p",{className:"font-medium",children:he.timeout})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"重试间隔(秒)"}),e.jsx("p",{className:"font-medium",children:he.retry_interval})]})]})]},Ee)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsxs(Rl,{children:[e.jsx(zl,{children:e.jsxs(ns,{children:[e.jsx(He,{className:"w-12",children:e.jsx(Cs,{checked:oe.size===Xt.length&&Xt.length>0,onCheckedChange:Nn})}),e.jsx(He,{children:"名称"}),e.jsx(He,{children:"基础URL"}),e.jsx(He,{children:"客户端类型"}),e.jsx(He,{className:"text-right",children:"最大重试"}),e.jsx(He,{className:"text-right",children:"超时(秒)"}),e.jsx(He,{className:"text-right",children:"重试间隔(秒)"}),e.jsx(He,{className:"text-right",children:"操作"})]})}),e.jsx(Pl,{children:ke.length===0?e.jsx(ns,{children:e.jsx(Ae,{colSpan:8,className:"text-center text-muted-foreground py-8",children:G?"未找到匹配的提供商":'暂无提供商配置,点击"添加提供商"开始配置'})}):ke.map((he,Ee)=>{const Ve=s.findIndex(Os=>Os===he);return e.jsxs(ns,{children:[e.jsx(Ae,{children:e.jsx(Cs,{checked:oe.has(Ve),onCheckedChange:()=>Le(Ve)})}),e.jsx(Ae,{className:"font-medium",children:he.name}),e.jsx(Ae,{className:"max-w-xs truncate",title:he.base_url,children:he.base_url}),e.jsx(Ae,{children:he.client_type}),e.jsx(Ae,{className:"text-right",children:he.max_retry}),e.jsx(Ae,{className:"text-right",children:he.timeout}),e.jsx(Ae,{className:"text-right",children:he.retry_interval}),e.jsx(Ae,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>re(he,Ve),children:[e.jsx(Yr,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(q,{size:"sm",onClick:()=>Rs(Ve),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},Ee)})})]})}),Xt.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(U,{htmlFor:"page-size-provider",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(rt,{value:L.toString(),onValueChange:he=>{ee(parseInt(he)),O(1),je(new Set)},children:[e.jsx(at,{id:"page-size-provider",className:"w-20",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"10",children:"10"}),e.jsx(ye,{value:"20",children:"20"}),e.jsx(ye,{value:"50",children:"50"}),e.jsx(ye,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(R-1)*L+1," 到"," ",Math.min(R*L,Xt.length)," 条,共 ",Xt.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>O(1),disabled:R===1,className:"hidden sm:flex",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>O(he=>Math.max(1,he-1)),disabled:R===1,children:[e.jsx(Ol,{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(pe,{type:"number",value:le,onChange:he=>xe(he.target.value),onKeyDown:he=>he.key==="Enter"&&is(),placeholder:R.toString(),className:"w-16 h-8 text-center",min:1,max:Ds}),e.jsx(q,{variant:"outline",size:"sm",onClick:is,disabled:!le,className:"h-8",children:"跳转"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>O(he=>he+1),disabled:R>=Ds,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Al,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>O(Ds),disabled:R>=Ds,className:"hidden sm:flex",children:e.jsx(jo,{className:"h-4 w-4"})})]})]})]}),e.jsx(bs,{open:S,onOpenChange:Zt,children:e.jsxs(ms,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{children:P!==null?"编辑提供商":"添加提供商"}),e.jsx(ks,{children:"配置 API 提供商的连接信息和参数"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"name",children:"名称 *"}),e.jsx(pe,{id:"name",value:N?.name||"",onChange:he=>T(Ee=>Ee?{...Ee,name:he.target.value}:null),placeholder:"例如: DeepSeek, SiliconFlow"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"base_url",children:"基础 URL *"}),e.jsx(pe,{id:"base_url",value:N?.base_url||"",onChange:he=>T(Ee=>Ee?{...Ee,base_url:he.target.value}:null),placeholder:"https://api.example.com/v1"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"api_key",children:"API Key *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(pe,{id:"api_key",type:B?"text":"password",value:N?.api_key||"",onChange:he=>T(Ee=>Ee?{...Ee,api_key:he.target.value}:null),placeholder:"sk-...",className:"flex-1"}),e.jsx(q,{type:"button",variant:"outline",size:"icon",onClick:()=>Y(!B),title:B?"隐藏密钥":"显示密钥",children:B?e.jsx(Of,{className:"h-4 w-4"}):e.jsx(Mn,{className:"h-4 w-4"})}),e.jsx(q,{type:"button",variant:"outline",size:"icon",onClick:Pe,title:"复制密钥",children:e.jsx(Df,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"client_type",children:"客户端类型"}),e.jsxs(rt,{value:N?.client_type||"openai",onValueChange:he=>T(Ee=>Ee?{...Ee,client_type:he}:null),children:[e.jsx(at,{id:"client_type",children:e.jsx(it,{placeholder:"选择客户端类型"})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"openai",children:"OpenAI"}),e.jsx(ye,{value:"gemini",children:"Gemini"})]})]})]}),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(U,{htmlFor:"max_retry",children:"最大重试"}),e.jsx(pe,{id:"max_retry",type:"number",min:"0",value:N?.max_retry??"",onChange:he=>{const Ee=he.target.value===""?null:parseInt(he.target.value);T(Ve=>Ve?{...Ve,max_retry:Ee}:null)},placeholder:"默认: 2"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"timeout",children:"超时(秒)"}),e.jsx(pe,{id:"timeout",type:"number",min:"1",value:N?.timeout??"",onChange:he=>{const Ee=he.target.value===""?null:parseInt(he.target.value);T(Ve=>Ve?{...Ve,timeout:Ee}:null)},placeholder:"默认: 30"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"retry_interval",children:"重试间隔(秒)"}),e.jsx(pe,{id:"retry_interval",type:"number",min:"1",value:N?.retry_interval??"",onChange:he=>{const Ee=he.target.value===""?null:parseInt(he.target.value);T(Ve=>Ve?{...Ve,retry_interval:Ee}:null)},placeholder:"默认: 10"})]})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>C(!1),children:"取消"}),e.jsx(q,{onClick:ze,children:"保存"})]})]})}),e.jsx(Ft,{open:k,onOpenChange:D,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除提供商 "',A!==null?s[A]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:An,children:"删除"})]})]})}),e.jsx(Ft,{open:ae,onOpenChange:me,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认批量删除"}),e.jsxs(Pt,{children:["确定要删除选中的 ",oe.size," 个提供商吗? 此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:rn,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),b&&e.jsx(Bh,{onRestartComplete:Ce,onRestartFailed:Q})]})}var Uj=1,vM=.9,jM=.8,yM=.17,Sf=.1,_f=.999,bM=.9999,NM=.99,wM=/[\\\/_+.#"@\[\(\{&]/,SM=/[\\\/_+.#"@\[\(\{&]/g,_M=/[\s-]/,xN=/[\s-]/g;function Kf(s,a,l,i,c,d,m){if(d===a.length)return c===s.length?Uj:NM;var h=`${c},${d}`;if(m[h]!==void 0)return m[h];for(var p=i.charAt(d),v=l.indexOf(p,c),g=0,j,b,w,S;v>=0;)j=Kf(s,a,l,i,v+1,d+1,m),j>g&&(v===c?j*=Uj:wM.test(s.charAt(v-1))?(j*=jM,w=s.slice(c,v-1).match(SM),w&&c>0&&(j*=Math.pow(_f,w.length))):_M.test(s.charAt(v-1))?(j*=vM,S=s.slice(c,v-1).match(xN),S&&c>0&&(j*=Math.pow(_f,S.length))):(j*=yM,c>0&&(j*=Math.pow(_f,v-c))),s.charAt(v)!==a.charAt(d)&&(j*=bM)),(jj&&(j=b*Sf)),j>g&&(g=j),v=l.indexOf(p,v+1);return m[h]=g,g}function Hj(s){return s.toLowerCase().replace(xN," ")}function CM(s,a,l){return s=l&&l.length>0?`${s+" "+l.join(" ")}`:s,Kf(s,a,Hj(s),Hj(a),0,0,{})}var kM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ja=kM.reduce((s,a)=>{const l=ih(`Primitive.${a}`),i=x.forwardRef((c,d)=>{const{asChild:m,...h}=c,p=m?l:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(p,{...h,ref:d})});return i.displayName=`Primitive.${a}`,{...s,[a]:i}},{}),Zi='[cmdk-group=""]',Cf='[cmdk-group-items=""]',TM='[cmdk-group-heading=""]',pN='[cmdk-item=""]',Fj=`${pN}:not([aria-disabled="true"])`,Qf="cmdk-item-select",Ar="data-value",EM=(s,a,l)=>CM(s,a,l),gN=x.createContext(void 0),ko=()=>x.useContext(gN),vN=x.createContext(void 0),Uh=()=>x.useContext(vN),jN=x.createContext(void 0),yN=x.forwardRef((s,a)=>{let l=Rr(()=>{var F,W;return{search:"",value:(W=(F=s.value)!=null?F:s.defaultValue)!=null?W:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=Rr(()=>new Set),c=Rr(()=>new Map),d=Rr(()=>new Map),m=Rr(()=>new Set),h=bN(s),{label:p,children:v,value:g,onValueChange:j,filter:b,shouldFilter:w,loop:S,disablePointerSelection:C=!1,vimBindings:N=!0,...T}=s,P=jn(),M=jn(),k=jn(),D=x.useRef(null),A=HM();Dl(()=>{if(g!==void 0){let F=g.trim();l.current.value=F,E.emit()}},[g]),Dl(()=>{A(6,je)},[]);let E=x.useMemo(()=>({subscribe:F=>(m.current.add(F),()=>m.current.delete(F)),snapshot:()=>l.current,setState:(F,W,fe)=>{var I,ve,de,Ce;if(!Object.is(l.current[F],W)){if(l.current[F]=W,F==="search")oe(),G(),A(1,$);else if(F==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Q=document.getElementById(k);Q?Q.focus():(I=document.getElementById(P))==null||I.focus()}if(A(7,()=>{var Q;l.current.selectedItemId=(Q=ae())==null?void 0:Q.id,E.emit()}),fe||A(5,je),((ve=h.current)==null?void 0:ve.value)!==void 0){let Q=W??"";(Ce=(de=h.current).onValueChange)==null||Ce.call(de,Q);return}}E.emit()}},emit:()=>{m.current.forEach(F=>F())}}),[]),B=x.useMemo(()=>({value:(F,W,fe)=>{var I;W!==((I=d.current.get(F))==null?void 0:I.value)&&(d.current.set(F,{value:W,keywords:fe}),l.current.filtered.items.set(F,Y(W,fe)),A(2,()=>{G(),E.emit()}))},item:(F,W)=>(i.current.add(F),W&&(c.current.has(W)?c.current.get(W).add(F):c.current.set(W,new Set([F]))),A(3,()=>{oe(),G(),l.current.value||$(),E.emit()}),()=>{d.current.delete(F),i.current.delete(F),l.current.filtered.items.delete(F);let fe=ae();A(4,()=>{oe(),fe?.getAttribute("id")===F&&$(),E.emit()})}),group:F=>(c.current.has(F)||c.current.set(F,new Set),()=>{d.current.delete(F),c.current.delete(F)}),filter:()=>h.current.shouldFilter,label:p||s["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:P,inputId:k,labelId:M,listInnerRef:D}),[]);function Y(F,W){var fe,I;let ve=(I=(fe=h.current)==null?void 0:fe.filter)!=null?I:EM;return F?ve(F,l.current.search,W):0}function G(){if(!l.current.search||h.current.shouldFilter===!1)return;let F=l.current.filtered.items,W=[];l.current.filtered.groups.forEach(I=>{let ve=c.current.get(I),de=0;ve.forEach(Ce=>{let Q=F.get(Ce);de=Math.max(Q,de)}),W.push([I,de])});let fe=D.current;me().sort((I,ve)=>{var de,Ce;let Q=I.getAttribute("id"),Oe=ve.getAttribute("id");return((de=F.get(Oe))!=null?de:0)-((Ce=F.get(Q))!=null?Ce:0)}).forEach(I=>{let ve=I.closest(Cf);ve?ve.appendChild(I.parentElement===ve?I:I.closest(`${Cf} > *`)):fe.appendChild(I.parentElement===fe?I:I.closest(`${Cf} > *`))}),W.sort((I,ve)=>ve[1]-I[1]).forEach(I=>{var ve;let de=(ve=D.current)==null?void 0:ve.querySelector(`${Zi}[${Ar}="${encodeURIComponent(I[0])}"]`);de?.parentElement.appendChild(de)})}function $(){let F=me().find(fe=>fe.getAttribute("aria-disabled")!=="true"),W=F?.getAttribute(Ar);E.setState("value",W||void 0)}function oe(){var F,W,fe,I;if(!l.current.search||h.current.shouldFilter===!1){l.current.filtered.count=i.current.size;return}l.current.filtered.groups=new Set;let ve=0;for(let de of i.current){let Ce=(W=(F=d.current.get(de))==null?void 0:F.value)!=null?W:"",Q=(I=(fe=d.current.get(de))==null?void 0:fe.keywords)!=null?I:[],Oe=Y(Ce,Q);l.current.filtered.items.set(de,Oe),Oe>0&&ve++}for(let[de,Ce]of c.current)for(let Q of Ce)if(l.current.filtered.items.get(Q)>0){l.current.filtered.groups.add(de);break}l.current.filtered.count=ve}function je(){var F,W,fe;let I=ae();I&&(((F=I.parentElement)==null?void 0:F.firstChild)===I&&((fe=(W=I.closest(Zi))==null?void 0:W.querySelector(TM))==null||fe.scrollIntoView({block:"nearest"})),I.scrollIntoView({block:"nearest"}))}function ae(){var F;return(F=D.current)==null?void 0:F.querySelector(`${pN}[aria-selected="true"]`)}function me(){var F;return Array.from(((F=D.current)==null?void 0:F.querySelectorAll(Fj))||[])}function R(F){let W=me()[F];W&&E.setState("value",W.getAttribute(Ar))}function O(F){var W;let fe=ae(),I=me(),ve=I.findIndex(Ce=>Ce===fe),de=I[ve+F];(W=h.current)!=null&&W.loop&&(de=ve+F<0?I[I.length-1]:ve+F===I.length?I[0]:I[ve+F]),de&&E.setState("value",de.getAttribute(Ar))}function L(F){let W=ae(),fe=W?.closest(Zi),I;for(;fe&&!I;)fe=F>0?BM(fe,Zi):UM(fe,Zi),I=fe?.querySelector(Fj);I?E.setState("value",I.getAttribute(Ar)):O(F)}let ee=()=>R(me().length-1),le=F=>{F.preventDefault(),F.metaKey?ee():F.altKey?L(1):O(1)},xe=F=>{F.preventDefault(),F.metaKey?R(0):F.altKey?L(-1):O(-1)};return x.createElement(Ja.div,{ref:a,tabIndex:-1,...T,"cmdk-root":"",onKeyDown:F=>{var W;(W=T.onKeyDown)==null||W.call(T,F);let fe=F.nativeEvent.isComposing||F.keyCode===229;if(!(F.defaultPrevented||fe))switch(F.key){case"n":case"j":{N&&F.ctrlKey&&le(F);break}case"ArrowDown":{le(F);break}case"p":case"k":{N&&F.ctrlKey&&xe(F);break}case"ArrowUp":{xe(F);break}case"Home":{F.preventDefault(),R(0);break}case"End":{F.preventDefault(),ee();break}case"Enter":{F.preventDefault();let I=ae();if(I){let ve=new Event(Qf);I.dispatchEvent(ve)}}}}},x.createElement("label",{"cmdk-label":"",htmlFor:B.inputId,id:B.labelId,style:YM},p),$d(s,F=>x.createElement(vN.Provider,{value:E},x.createElement(gN.Provider,{value:B},F))))}),MM=x.forwardRef((s,a)=>{var l,i;let c=jn(),d=x.useRef(null),m=x.useContext(jN),h=ko(),p=bN(s),v=(i=(l=p.current)==null?void 0:l.forceMount)!=null?i:m?.forceMount;Dl(()=>{if(!v)return h.item(c,m?.id)},[v]);let g=NN(c,d,[s.value,s.children,d],s.keywords),j=Uh(),b=Xa(A=>A.value&&A.value===g.current),w=Xa(A=>v||h.filter()===!1?!0:A.search?A.filtered.items.get(c)>0:!0);x.useEffect(()=>{let A=d.current;if(!(!A||s.disabled))return A.addEventListener(Qf,S),()=>A.removeEventListener(Qf,S)},[w,s.onSelect,s.disabled]);function S(){var A,E;C(),(E=(A=p.current).onSelect)==null||E.call(A,g.current)}function C(){j.setState("value",g.current,!0)}if(!w)return null;let{disabled:N,value:T,onSelect:P,forceMount:M,keywords:k,...D}=s;return x.createElement(Ja.div,{ref:Ga(d,a),...D,id:c,"cmdk-item":"",role:"option","aria-disabled":!!N,"aria-selected":!!b,"data-disabled":!!N,"data-selected":!!b,onPointerMove:N||h.getDisablePointerSelection()?void 0:C,onClick:N?void 0:S},s.children)}),DM=x.forwardRef((s,a)=>{let{heading:l,children:i,forceMount:c,...d}=s,m=jn(),h=x.useRef(null),p=x.useRef(null),v=jn(),g=ko(),j=Xa(w=>c||g.filter()===!1?!0:w.search?w.filtered.groups.has(m):!0);Dl(()=>g.group(m),[]),NN(m,h,[s.value,s.heading,p]);let b=x.useMemo(()=>({id:m,forceMount:c}),[c]);return x.createElement(Ja.div,{ref:Ga(h,a),...d,"cmdk-group":"",role:"presentation",hidden:j?void 0:!0},l&&x.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:v},l),$d(s,w=>x.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":l?v:void 0},x.createElement(jN.Provider,{value:b},w))))}),OM=x.forwardRef((s,a)=>{let{alwaysRender:l,...i}=s,c=x.useRef(null),d=Xa(m=>!m.search);return!l&&!d?null:x.createElement(Ja.div,{ref:Ga(c,a),...i,"cmdk-separator":"",role:"separator"})}),AM=x.forwardRef((s,a)=>{let{onValueChange:l,...i}=s,c=s.value!=null,d=Uh(),m=Xa(v=>v.search),h=Xa(v=>v.selectedItemId),p=ko();return x.useEffect(()=>{s.value!=null&&d.setState("search",s.value)},[s.value]),x.createElement(Ja.input,{ref:a,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":h,id:p.inputId,type:"text",value:c?s.value:m,onChange:v=>{c||d.setState("search",v.target.value),l?.(v.target.value)}})}),RM=x.forwardRef((s,a)=>{let{children:l,label:i="Suggestions",...c}=s,d=x.useRef(null),m=x.useRef(null),h=Xa(v=>v.selectedItemId),p=ko();return x.useEffect(()=>{if(m.current&&d.current){let v=m.current,g=d.current,j,b=new ResizeObserver(()=>{j=requestAnimationFrame(()=>{let w=v.offsetHeight;g.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return b.observe(v),()=>{cancelAnimationFrame(j),b.unobserve(v)}}},[]),x.createElement(Ja.div,{ref:Ga(d,a),...c,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":i,id:p.listId},$d(s,v=>x.createElement("div",{ref:Ga(m,p.listInnerRef),"cmdk-list-sizer":""},v)))}),zM=x.forwardRef((s,a)=>{let{open:l,onOpenChange:i,overlayClassName:c,contentClassName:d,container:m,...h}=s;return x.createElement(mh,{open:l,onOpenChange:i},x.createElement(oh,{container:m},x.createElement(Cd,{"cmdk-overlay":"",className:c}),x.createElement(kd,{"aria-label":s.label,"cmdk-dialog":"",className:d},x.createElement(yN,{ref:a,...h}))))}),PM=x.forwardRef((s,a)=>Xa(l=>l.filtered.count===0)?x.createElement(Ja.div,{ref:a,...s,"cmdk-empty":"",role:"presentation"}):null),LM=x.forwardRef((s,a)=>{let{progress:l,children:i,label:c="Loading...",...d}=s;return x.createElement(Ja.div,{ref:a,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c},$d(s,m=>x.createElement("div",{"aria-hidden":!0},m)))}),Ws=Object.assign(yN,{List:RM,Item:MM,Input:AM,Group:DM,Separator:OM,Dialog:zM,Empty:PM,Loading:LM});function BM(s,a){let l=s.nextElementSibling;for(;l;){if(l.matches(a))return l;l=l.nextElementSibling}}function UM(s,a){let l=s.previousElementSibling;for(;l;){if(l.matches(a))return l;l=l.previousElementSibling}}function bN(s){let a=x.useRef(s);return Dl(()=>{a.current=s}),a}var Dl=typeof window>"u"?x.useEffect:x.useLayoutEffect;function Rr(s){let a=x.useRef();return a.current===void 0&&(a.current=s()),a}function Xa(s){let a=Uh(),l=()=>s(a.snapshot());return x.useSyncExternalStore(a.subscribe,l,l)}function NN(s,a,l,i=[]){let c=x.useRef(),d=ko();return Dl(()=>{var m;let h=(()=>{var v;for(let g of l){if(typeof g=="string")return g.trim();if(typeof g=="object"&&"current"in g)return g.current?(v=g.current.textContent)==null?void 0:v.trim():c.current}})(),p=i.map(v=>v.trim());d.value(s,h,p),(m=a.current)==null||m.setAttribute(Ar,h),c.current=h}),c}var HM=()=>{let[s,a]=x.useState(),l=Rr(()=>new Map);return Dl(()=>{l.current.forEach(i=>i()),l.current=new Map},[s]),(i,c)=>{l.current.set(i,c),a({})}};function FM(s){let a=s.type;return typeof a=="function"?a(s.props):"render"in a?a.render(s.props):s}function $d({asChild:s,children:a},l){return s&&x.isValidElement(a)?x.cloneElement(FM(a),{ref:a.ref},l(a.props.children)):l(a)}var YM={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const wN=x.forwardRef(({className:s,...a},l)=>e.jsx(Ws,{ref:l,className:Z("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...a}));wN.displayName=Ws.displayName;const SN=x.forwardRef(({className:s,...a},l)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(Gs,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ws.Input,{ref:l,className:Z("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...a})]}));SN.displayName=Ws.Input.displayName;const _N=x.forwardRef(({className:s,...a},l)=>e.jsx(Ws.List,{ref:l,className:Z("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...a}));_N.displayName=Ws.List.displayName;const CN=x.forwardRef((s,a)=>e.jsx(Ws.Empty,{ref:a,className:"py-6 text-center text-sm",...s}));CN.displayName=Ws.Empty.displayName;const kN=x.forwardRef(({className:s,...a},l)=>e.jsx(Ws.Group,{ref:l,className:Z("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...a}));kN.displayName=Ws.Group.displayName;const qM=x.forwardRef(({className:s,...a},l)=>e.jsx(Ws.Separator,{ref:l,className:Z("-mx-1 h-px bg-border",s),...a}));qM.displayName=Ws.Separator.displayName;const TN=x.forwardRef(({className:s,...a},l)=>e.jsx(Ws.Item,{ref:l,className:Z("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",s),...a}));TN.displayName=Ws.Item.displayName;function VM({options:s,selected:a,onChange:l,placeholder:i="选择选项...",emptyText:c="未找到选项",className:d}){const[m,h]=x.useState(!1),p=g=>{a.includes(g)?l(a.filter(j=>j!==g)):l([...a,g])},v=g=>{l(a.filter(j=>j!==g))};return e.jsxs(Ia,{open:m,onOpenChange:h,children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",role:"combobox","aria-expanded":m,className:Z("w-full justify-between min-h-10 h-auto",d),children:[e.jsx("div",{className:"flex gap-1 flex-wrap flex-1",children:a.length===0?e.jsx("span",{className:"text-muted-foreground",children:i}):a.map(g=>{const j=s.find(b=>b.value===g);return e.jsxs(_t,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80",onClick:b=>{b.stopPropagation(),v(g)},children:[j?.label||g,e.jsx(go,{className:"ml-1 h-3 w-3",strokeWidth:2,fill:"none"})]},g)})}),e.jsx(U2,{className:"ml-2 h-4 w-4 shrink-0 opacity-50",strokeWidth:2,fill:"none"})]})}),e.jsx(pa,{className:"w-full p-0",align:"start",children:e.jsxs(wN,{children:[e.jsx(SN,{placeholder:"搜索...",className:"h-9"}),e.jsxs(_N,{children:[e.jsx(CN,{children:c}),e.jsx(kN,{children:s.map(g=>{const j=a.includes(g.value);return e.jsxs(TN,{value:g.value,onSelect:()=>p(g.value),children:[e.jsx("div",{className:Z("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",j?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(Cl,{className:"h-3 w-3",strokeWidth:2,fill:"none"})}),e.jsx("span",{children:g.label})]},g.value)})})]})]})})]})}function GM(){const[s,a]=x.useState([]),[l,i]=x.useState([]),[c,d]=x.useState([]),[m,h]=x.useState(null),[p,v]=x.useState(!0),[g,j]=x.useState(!1),[b,w]=x.useState(!1),[S,C]=x.useState(!1),[N,T]=x.useState(!1),[P,M]=x.useState(!1),[k,D]=x.useState(!1),[A,E]=x.useState(null),[B,Y]=x.useState(null),[G,$]=x.useState(!1),[oe,je]=x.useState(null),[ae,me]=x.useState(""),[R,O]=x.useState(new Set),[L,ee]=x.useState(!1),[le,xe]=x.useState(1),[F,W]=x.useState(20),[fe,I]=x.useState(""),{toast:ve}=Es(),de=x.useRef(null),Ce=x.useRef(null),Q=x.useRef(!0);x.useEffect(()=>{Oe()},[]);const Oe=async()=>{try{v(!0);const se=await Ur(),ge=se.models||[];a(ge),d(ge.map(pt=>pt.name));const Qe=se.api_providers||[];i(Qe.map(pt=>pt.name)),h(se.model_task_config||null),C(!1),Q.current=!1}catch(se){console.error("加载配置失败:",se)}finally{v(!1)}},$e=async()=>{try{T(!0),Lh().catch(()=>{}),M(!0)}catch(se){console.error("重启失败:",se),M(!1),ve({title:"重启失败",description:"无法发送重启请求,请手动重启",variant:"destructive"}),T(!1)}},re=async()=>{try{j(!0),de.current&&clearTimeout(de.current),Ce.current&&clearTimeout(Ce.current);const se=await Ur();se.models=s,se.model_task_config=m,await Nd(se),C(!1),ve({title:"保存成功",description:"正在重启麦麦..."}),await $e()}catch(se){console.error("保存配置失败:",se),ve({title:"保存失败",description:se.message,variant:"destructive"}),j(!1)}},Pe=()=>{localStorage.removeItem("access-token"),window.location.href="/auth"},ze=()=>{M(!1),T(!1),ve({title:"重启超时",description:"服务未能在预期时间内恢复,请手动检查或刷新页面",variant:"destructive"})},Zt=x.useCallback(async se=>{if(!Q.current)try{w(!0),await Xf("models",se),C(!1)}catch(ge){console.error("自动保存模型列表失败:",ge),C(!0)}finally{w(!1)}},[]),Rs=x.useCallback(async se=>{if(!Q.current)try{w(!0),await Xf("model_task_config",se),C(!1)}catch(ge){console.error("自动保存任务配置失败:",ge),C(!0)}finally{w(!1)}},[]);x.useEffect(()=>{if(!Q.current)return C(!0),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{Zt(s)},2e3),()=>{de.current&&clearTimeout(de.current)}},[s,Zt]),x.useEffect(()=>{if(!(Q.current||!m))return C(!0),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{Rs(m)},2e3),()=>{Ce.current&&clearTimeout(Ce.current)}},[m,Rs]);const An=async()=>{try{j(!0),de.current&&clearTimeout(de.current),Ce.current&&clearTimeout(Ce.current);const se=await Ur();se.models=s,se.model_task_config=m,await Nd(se),C(!1),ve({title:"保存成功",description:"模型配置已保存"}),await Oe()}catch(se){console.error("保存配置失败:",se),ve({title:"保存失败",description:se.message,variant:"destructive"})}finally{j(!1)}},Le=(se,ge)=>{E(se||{model_identifier:"",name:"",api_provider:l[0]||"",price_in:0,price_out:0,force_stream_mode:!1,extra_params:{}}),Y(ge),D(!0)},Nn=()=>{if(!A)return;const se={...A,price_in:A.price_in??0,price_out:A.price_out??0};let ge;B!==null?(ge=[...s],ge[B]=se):ge=[...s,se],a(ge),d(ge.map(Qe=>Qe.name)),D(!1),E(null),Y(null)},ln=se=>{if(!se&&A){const ge={...A,price_in:A.price_in??0,price_out:A.price_out??0};E(ge)}D(se)},rn=se=>{je(se),$(!0)},Xt=()=>{if(oe!==null){const se=s.filter((ge,Qe)=>Qe!==oe);a(se),d(se.map(ge=>ge.name)),ve({title:"删除成功",description:"模型已从列表中移除"})}$(!1),je(null)},Ds=se=>{const ge=new Set(R);ge.has(se)?ge.delete(se):ge.add(se),O(ge)},ke=()=>{if(R.size===Ve.length)O(new Set);else{const se=Ve.map((ge,Qe)=>s.findIndex(pt=>pt===Ve[Qe]));O(new Set(se))}},is=()=>{if(R.size===0){ve({title:"提示",description:"请先选择要删除的模型",variant:"default"});return}ee(!0)},he=()=>{const se=s.filter((ge,Qe)=>!R.has(Qe));a(se),d(se.map(ge=>ge.name)),O(new Set),ee(!1),ve({title:"批量删除成功",description:`已删除 ${R.size} 个模型`})},Ee=(se,ge,Qe)=>{m&&h({...m,[se]:{...m[se],[ge]:Qe}})},Ve=s.filter(se=>{if(!ae)return!0;const ge=ae.toLowerCase();return se.name.toLowerCase().includes(ge)||se.model_identifier.toLowerCase().includes(ge)||se.api_provider.toLowerCase().includes(ge)}),Os=Math.ceil(Ve.length/F),$n=Ve.slice((le-1)*F,le*F),Hl=()=>{const se=parseInt(fe);se>=1&&se<=Os&&(xe(se),I(""))},Fl=se=>m?[m.utils?.model_list||[],m.utils_small?.model_list||[],m.tool_use?.model_list||[],m.replyer?.model_list||[],m.planner?.model_list||[],m.vlm?.model_list||[],m.voice?.model_list||[],m.embedding?.model_list||[],m.lpmm_entity_extract?.model_list||[],m.lpmm_rdf_build?.model_list||[],m.lpmm_qa?.model_list||[]].some(Qe=>Qe.includes(se)):!1;return p?e.jsx(Ct,{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(Ct,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"模型配置"}),e.jsx("p",{className:"text-muted-foreground mt-1 sm:mt-2 text-sm sm:text-base",children:"管理模型和任务配置"})]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsxs(q,{onClick:An,disabled:g||b||!S||N,size:"sm",variant:"outline",className:"flex-1 sm:flex-none",children:[e.jsx(vh,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),g?"保存中...":b?"自动保存中...":S?"保存配置":"已保存"]}),e.jsxs(Ft,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs(q,{disabled:g||b||N,size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(jh,{className:"mr-2 h-4 w-4"}),N?"重启中...":S?"保存并重启":"重启麦麦"]})}),e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认重启麦麦?"}),e.jsx(Pt,{children:S?"当前有未保存的配置更改。点击确认将先保存配置,然后重启麦麦使新配置生效。重启过程中麦麦将暂时离线。":"即将重启麦麦主程序。重启过程中麦麦将暂时离线,配置将在重启后生效。"})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:S?re:$e,children:S?"保存并重启":"确认重启"})]})]})]})]})]}),e.jsxs(Vd,{children:[e.jsx(Fr,{className:"h-4 w-4"}),e.jsxs(Gd,{children:["配置更新后需要",e.jsx("strong",{children:"重启麦麦"}),'才能生效。你可以点击右上角的"保存并重启"按钮一键完成保存和重启。']})]}),e.jsxs(Ml,{defaultValue:"models",className:"w-full",children:[e.jsxs($a,{className:"grid w-full max-w-full sm:max-w-md grid-cols-2",children:[e.jsx(bt,{value:"models",children:"模型配置"}),e.jsx(bt,{value:"tasks",children:"模型任务配置"})]}),e.jsxs(Vt,{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:[R.size>0&&e.jsxs(q,{onClick:is,size:"sm",variant:"destructive",className:"w-full sm:w-auto",children:[e.jsx(ft,{className:"mr-2 h-4 w-4",strokeWidth:2,fill:"none"}),"批量删除 (",R.size,")"]}),e.jsxs(q,{onClick:()=>Le(null,null),size:"sm",variant:"outline",className:"w-full sm:w-auto",children:[e.jsx(ys,{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(Gs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{placeholder:"搜索模型名称、标识符或提供商...",value:ae,onChange:se=>me(se.target.value),className:"pl-9"})]}),ae&&e.jsxs("p",{className:"text-sm text-muted-foreground whitespace-nowrap",children:["找到 ",Ve.length," 个结果"]})]}),e.jsx("div",{className:"md:hidden space-y-3",children:$n.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8 rounded-lg border bg-card",children:ae?"未找到匹配的模型":"暂无模型配置"}):$n.map((se,ge)=>{const Qe=s.findIndex(tl=>tl===se),pt=Fl(se.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:se.name}),e.jsx(_t,{variant:pt?"default":"secondary",className:pt?"bg-green-600 hover:bg-green-700":"",children:pt?"已使用":"未使用"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",title:se.model_identifier,children:se.model_identifier})]}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>Le(se,Qe),children:[e.jsx(Yr,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(q,{size:"sm",onClick:()=>rn(Qe),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{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:se.api_provider})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"强制流式"}),e.jsx("p",{className:"font-medium",children:se.force_stream_mode?"是":"否"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输入价格"}),e.jsxs("p",{className:"font-medium",children:["¥",se.price_in,"/M"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"输出价格"}),e.jsxs("p",{className:"font-medium",children:["¥",se.price_out,"/M"]})]})]})]},ge)})}),e.jsx("div",{className:"hidden md:block rounded-lg border bg-card overflow-hidden",children:e.jsxs(Rl,{children:[e.jsx(zl,{children:e.jsxs(ns,{children:[e.jsx(He,{className:"w-12",children:e.jsx(Cs,{checked:R.size===Ve.length&&Ve.length>0,onCheckedChange:ke})}),e.jsx(He,{className:"w-24",children:"使用状态"}),e.jsx(He,{children:"模型名称"}),e.jsx(He,{children:"模型标识符"}),e.jsx(He,{children:"提供商"}),e.jsx(He,{className:"text-right",children:"输入价格"}),e.jsx(He,{className:"text-right",children:"输出价格"}),e.jsx(He,{className:"text-center",children:"强制流式"}),e.jsx(He,{className:"text-right",children:"操作"})]})}),e.jsx(Pl,{children:$n.length===0?e.jsx(ns,{children:e.jsx(Ae,{colSpan:9,className:"text-center text-muted-foreground py-8",children:ae?"未找到匹配的模型":"暂无模型配置"})}):$n.map((se,ge)=>{const Qe=s.findIndex(tl=>tl===se),pt=Fl(se.name);return e.jsxs(ns,{children:[e.jsx(Ae,{children:e.jsx(Cs,{checked:R.has(Qe),onCheckedChange:()=>Ds(Qe)})}),e.jsx(Ae,{children:e.jsx(_t,{variant:pt?"default":"secondary",className:pt?"bg-green-600 hover:bg-green-700":"",children:pt?"已使用":"未使用"})}),e.jsx(Ae,{className:"font-medium",children:se.name}),e.jsx(Ae,{className:"max-w-xs truncate",title:se.model_identifier,children:se.model_identifier}),e.jsx(Ae,{children:se.api_provider}),e.jsxs(Ae,{className:"text-right",children:["¥",se.price_in,"/M"]}),e.jsxs(Ae,{className:"text-right",children:["¥",se.price_out,"/M"]}),e.jsx(Ae,{className:"text-center",children:se.force_stream_mode?"是":"否"}),e.jsx(Ae,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>Le(se,Qe),children:[e.jsx(Yr,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"编辑"]}),e.jsxs(q,{size:"sm",onClick:()=>rn(Qe),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{className:"h-4 w-4 mr-1",strokeWidth:2,fill:"none"}),"删除"]})]})})]},ge)})})]})}),Ve.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(U,{htmlFor:"page-size-model",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(rt,{value:F.toString(),onValueChange:se=>{W(parseInt(se)),xe(1),O(new Set)},children:[e.jsx(at,{id:"page-size-model",className:"w-20",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"10",children:"10"}),e.jsx(ye,{value:"20",children:"20"}),e.jsx(ye,{value:"50",children:"50"}),e.jsx(ye,{value:"100",children:"100"})]})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["显示 ",(le-1)*F+1," 到"," ",Math.min(le*F,Ve.length)," 条,共 ",Ve.length," 条"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>xe(1),disabled:le===1,className:"hidden sm:flex",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>xe(se=>Math.max(1,se-1)),disabled:le===1,children:[e.jsx(Ol,{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(pe,{type:"number",value:fe,onChange:se=>I(se.target.value),onKeyDown:se=>se.key==="Enter"&&Hl(),placeholder:le.toString(),className:"w-16 h-8 text-center",min:1,max:Os}),e.jsx(q,{variant:"outline",size:"sm",onClick:Hl,disabled:!fe,className:"h-8",children:"跳转"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>xe(se=>se+1),disabled:le>=Os,children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Al,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>xe(Os),disabled:le>=Os,className:"hidden sm:flex",children:e.jsx(jo,{className:"h-4 w-4"})})]})]})]}),e.jsxs(Vt,{value:"tasks",className:"space-y-6 mt-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"为不同的任务配置使用的模型和参数"}),m&&e.jsxs("div",{className:"grid gap-4 sm:gap-6",children:[e.jsx(Cn,{title:"组件模型 (utils)",description:"用于表情包、取名、关系、情绪变化等组件",taskConfig:m.utils,modelNames:c,onChange:(se,ge)=>Ee("utils",se,ge)}),e.jsx(Cn,{title:"组件小模型 (utils_small)",description:"消耗量较大的组件,建议使用速度较快的小模型",taskConfig:m.utils_small,modelNames:c,onChange:(se,ge)=>Ee("utils_small",se,ge)}),e.jsx(Cn,{title:"工具调用模型 (tool_use)",description:"需要使用支持工具调用的模型",taskConfig:m.tool_use,modelNames:c,onChange:(se,ge)=>Ee("tool_use",se,ge)}),e.jsx(Cn,{title:"首要回复模型 (replyer)",description:"用于表达器和表达方式学习",taskConfig:m.replyer,modelNames:c,onChange:(se,ge)=>Ee("replyer",se,ge)}),e.jsx(Cn,{title:"决策模型 (planner)",description:"负责决定麦麦该什么时候回复",taskConfig:m.planner,modelNames:c,onChange:(se,ge)=>Ee("planner",se,ge)}),e.jsx(Cn,{title:"图像识别模型 (vlm)",description:"视觉语言模型",taskConfig:m.vlm,modelNames:c,onChange:(se,ge)=>Ee("vlm",se,ge),hideTemperature:!0}),e.jsx(Cn,{title:"语音识别模型 (voice)",description:"语音转文字",taskConfig:m.voice,modelNames:c,onChange:(se,ge)=>Ee("voice",se,ge),hideTemperature:!0,hideMaxTokens:!0}),e.jsx(Cn,{title:"嵌入模型 (embedding)",description:"用于向量化",taskConfig:m.embedding,modelNames:c,onChange:(se,ge)=>Ee("embedding",se,ge),hideTemperature:!0,hideMaxTokens:!0}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"LPMM 知识库模型"}),e.jsx(Cn,{title:"实体提取模型 (lpmm_entity_extract)",description:"从文本中提取实体",taskConfig:m.lpmm_entity_extract,modelNames:c,onChange:(se,ge)=>Ee("lpmm_entity_extract",se,ge)}),e.jsx(Cn,{title:"RDF 构建模型 (lpmm_rdf_build)",description:"构建知识图谱",taskConfig:m.lpmm_rdf_build,modelNames:c,onChange:(se,ge)=>Ee("lpmm_rdf_build",se,ge)}),e.jsx(Cn,{title:"问答模型 (lpmm_qa)",description:"知识库问答",taskConfig:m.lpmm_qa,modelNames:c,onChange:(se,ge)=>Ee("lpmm_qa",se,ge)})]})]})]})]}),e.jsx(bs,{open:k,onOpenChange:ln,children:e.jsxs(ms,{className:"max-w-[95vw] sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{children:B!==null?"编辑模型":"添加模型"}),e.jsx(ks,{children:"配置模型的基本信息和参数"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"model_name",children:"模型名称 *"}),e.jsx(pe,{id:"model_name",value:A?.name||"",onChange:se=>E(ge=>ge?{...ge,name:se.target.value}:null),placeholder:"例如: qwen3-30b"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"用于在任务配置中引用此模型"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"model_identifier",children:"模型标识符 *"}),e.jsx(pe,{id:"model_identifier",value:A?.model_identifier||"",onChange:se=>E(ge=>ge?{...ge,model_identifier:se.target.value}:null),placeholder:"Qwen/Qwen3-30B-A3B-Instruct-2507"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"API 提供商提供的模型 ID"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"api_provider",children:"API 提供商 *"}),e.jsxs(rt,{value:A?.api_provider||"",onValueChange:se=>E(ge=>ge?{...ge,api_provider:se}:null),children:[e.jsx(at,{id:"api_provider",children:e.jsx(it,{placeholder:"选择提供商"})}),e.jsx(lt,{children:l.map(se=>e.jsx(ye,{value:se,children:se},se))})]})]}),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(U,{htmlFor:"price_in",children:"输入价格 (¥/M token)"}),e.jsx(pe,{id:"price_in",type:"number",step:"0.1",min:"0",value:A?.price_in??"",onChange:se=>{const ge=se.target.value===""?null:parseFloat(se.target.value);E(Qe=>Qe?{...Qe,price_in:ge}:null)},placeholder:"默认: 0"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{htmlFor:"price_out",children:"输出价格 (¥/M token)"}),e.jsx(pe,{id:"price_out",type:"number",step:"0.1",min:"0",value:A?.price_out??"",onChange:se=>{const ge=se.target.value===""?null:parseFloat(se.target.value);E(Qe=>Qe?{...Qe,price_out:ge}:null)},placeholder:"默认: 0"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"force_stream_mode",checked:A?.force_stream_mode||!1,onCheckedChange:se=>E(ge=>ge?{...ge,force_stream_mode:se}:null)}),e.jsx(U,{htmlFor:"force_stream_mode",className:"cursor-pointer",children:"强制流式输出模式"})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>D(!1),children:"取消"}),e.jsx(q,{onClick:Nn,children:"保存"})]})]})}),e.jsx(Ft,{open:G,onOpenChange:$,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除模型 "',oe!==null?s[oe]?.name:"",'" 吗? 此操作无法撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:Xt,children:"删除"})]})]})}),e.jsx(Ft,{open:L,onOpenChange:ee,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认批量删除"}),e.jsxs(Pt,{children:["确定要删除选中的 ",R.size," 个模型吗? 此操作无法撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:he,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})}),P&&e.jsx(Bh,{onRestartComplete:Pe,onRestartFailed:ze})]})})}function Cn({title:s,description:a,taskConfig:l,modelNames:i,onChange:c,hideTemperature:d=!1,hideMaxTokens:m=!1}){const h=p=>{c("model_list",p)};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:s}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:a})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"模型列表"}),e.jsx(VM,{options:i.map(p=>({label:p,value:p})),selected:l.model_list||[],onChange:h,placeholder:"选择模型...",emptyText:"暂无可用模型"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[!d&&e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(U,{children:"温度"}),e.jsx(pe,{type:"number",step:"0.1",min:"0",max:"1",value:l.temperature??.3,onChange:p=>{const v=parseFloat(p.target.value);!isNaN(v)&&v>=0&&v<=1&&c("temperature",v)},className:"w-20 h-8 text-sm"})]}),e.jsx(Yd,{value:[l.temperature??.3],onValueChange:p=>c("temperature",p[0]),min:0,max:1,step:.1,className:"w-full"})]}),!m&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(U,{children:"最大 Token"}),e.jsx(pe,{type:"number",step:"1",min:"1",value:l.max_tokens??1024,onChange:p=>c("max_tokens",parseInt(p.target.value))})]})]})]})]})}const va="/api/webui/emoji";async function $M(s){const a=new URLSearchParams;s.page&&a.append("page",s.page.toString()),s.page_size&&a.append("page_size",s.page_size.toString()),s.search&&a.append("search",s.search),s.is_registered!==void 0&&a.append("is_registered",s.is_registered.toString()),s.is_banned!==void 0&&a.append("is_banned",s.is_banned.toString()),s.format&&a.append("format",s.format),s.sort_by&&a.append("sort_by",s.sort_by),s.sort_order&&a.append("sort_order",s.sort_order);const l=await Fe(`${va}/list?${a}`,{headers:Ie()});if(!l.ok)throw new Error(`获取表情包列表失败: ${l.statusText}`);return l.json()}async function IM(s){const a=await Fe(`${va}/${s}`,{headers:Ie()});if(!a.ok)throw new Error(`获取表情包详情失败: ${a.statusText}`);return a.json()}async function WM(s,a){const l=await Fe(`${va}/${s}`,{method:"PATCH",headers:Ie(),body:JSON.stringify(a)});if(!l.ok)throw new Error(`更新表情包失败: ${l.statusText}`);return l.json()}async function XM(s){const a=await Fe(`${va}/${s}`,{method:"DELETE",headers:Ie()});if(!a.ok)throw new Error(`删除表情包失败: ${a.statusText}`);return a.json()}async function KM(){const s=await Fe(`${va}/stats/summary`,{headers:Ie()});if(!s.ok)throw new Error(`获取统计数据失败: ${s.statusText}`);return s.json()}async function QM(s){const a=await Fe(`${va}/${s}/register`,{method:"POST",headers:Ie()});if(!a.ok)throw new Error(`注册表情包失败: ${a.statusText}`);return a.json()}async function ZM(s){const a=await Fe(`${va}/${s}/ban`,{method:"POST",headers:Ie()});if(!a.ok)throw new Error(`封禁表情包失败: ${a.statusText}`);return a.json()}function Zf(s){const a=localStorage.getItem("access-token");return`${va}/${s}/thumbnail?token=${encodeURIComponent(a||"")}`}async function JM(s){const a=await Fe(`${va}/batch/delete`,{method:"POST",headers:Ie(),body:JSON.stringify({emoji_ids:s})});if(!a.ok){const l=await a.json();throw new Error(l.detail||"批量删除失败")}return a.json()}function eD(){const[s,a]=x.useState([]),[l,i]=x.useState(null),[c,d]=x.useState(!1),[m,h]=x.useState(1),[p,v]=x.useState(0),[g,j]=x.useState(20),[b,w]=x.useState(""),[S,C]=x.useState("all"),[N,T]=x.useState("all"),[P,M]=x.useState("all"),[k,D]=x.useState(null),[A,E]=x.useState(!1),[B,Y]=x.useState(!1),[G,$]=x.useState(!1),[oe,je]=x.useState(new Set),[ae,me]=x.useState(!1),[R,O]=x.useState(""),{toast:L}=Es(),ee=x.useCallback(async()=>{try{d(!0);const re=await $M({page:m,page_size:g,search:b||void 0,is_registered:S==="all"?void 0:S==="registered",is_banned:N==="all"?void 0:N==="banned",format:P==="all"?void 0:P,sort_by:"usage_count",sort_order:"desc"});a(re.data),v(re.total)}catch(re){const Pe=re instanceof Error?re.message:"加载表情包列表失败";L({title:"错误",description:Pe,variant:"destructive"})}finally{d(!1)}},[m,g,b,S,N,P,L]),le=async()=>{try{const re=await KM();i(re.data)}catch(re){console.error("加载统计数据失败:",re)}};x.useEffect(()=>{ee()},[ee]),x.useEffect(()=>{le()},[]);const xe=async re=>{try{const Pe=await IM(re.id);D(Pe.data),E(!0)}catch(Pe){const ze=Pe instanceof Error?Pe.message:"加载详情失败";L({title:"错误",description:ze,variant:"destructive"})}},F=re=>{D(re),Y(!0)},W=re=>{D(re),$(!0)},fe=async()=>{if(k)try{await XM(k.id),L({title:"成功",description:"表情包已删除"}),$(!1),D(null),ee(),le()}catch(re){const Pe=re instanceof Error?re.message:"删除失败";L({title:"错误",description:Pe,variant:"destructive"})}},I=async re=>{try{await QM(re.id),L({title:"成功",description:"表情包已注册"}),ee(),le()}catch(Pe){const ze=Pe instanceof Error?Pe.message:"注册失败";L({title:"错误",description:ze,variant:"destructive"})}},ve=async re=>{try{await ZM(re.id),L({title:"成功",description:"表情包已封禁"}),ee(),le()}catch(Pe){const ze=Pe instanceof Error?Pe.message:"封禁失败";L({title:"错误",description:ze,variant:"destructive"})}},de=re=>{const Pe=new Set(oe);Pe.has(re)?Pe.delete(re):Pe.add(re),je(Pe)},Ce=()=>{oe.size===s.length&&s.length>0?je(new Set):je(new Set(s.map(re=>re.id)))},Q=async()=>{try{const re=await JM(Array.from(oe));L({title:"批量删除完成",description:re.message}),je(new Set),me(!1),ee(),le()}catch(re){L({title:"批量删除失败",description:re instanceof Error?re.message:"批量删除失败",variant:"destructive"})}},Oe=()=>{const re=parseInt(R),Pe=Math.ceil(p/g);re>=1&&re<=Pe?(h(re),O("")):L({title:"无效的页码",description:`请输入1-${Pe}之间的页码`,variant:"destructive"})},$e=l?.formats?Object.keys(l.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",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.jsx(Ct,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 sm:space-y-6 pr-4",children:[l&&e.jsxs("div",{className:"grid gap-4 grid-cols-2 lg:grid-cols-4",children:[e.jsx(Ue,{children:e.jsxs(ot,{className:"pb-2",children:[e.jsx(us,{children:"总数"}),e.jsx(ct,{className:"text-2xl",children:l.total})]})}),e.jsx(Ue,{children:e.jsxs(ot,{className:"pb-2",children:[e.jsx(us,{children:"已注册"}),e.jsx(ct,{className:"text-2xl text-green-600",children:l.registered})]})}),e.jsx(Ue,{children:e.jsxs(ot,{className:"pb-2",children:[e.jsx(us,{children:"已封禁"}),e.jsx(ct,{className:"text-2xl text-red-600",children:l.banned})]})}),e.jsx(Ue,{children:e.jsxs(ot,{className:"pb-2",children:[e.jsx(us,{children:"未注册"}),e.jsx(ct,{className:"text-2xl text-gray-600",children:l.unregistered})]})})]}),e.jsxs(Ue,{children:[e.jsx(ot,{children:e.jsxs(ct,{className:"flex items-center gap-2",children:[e.jsx(Lf,{className:"h-5 w-5"}),"搜索和筛选"]})}),e.jsxs(gt,{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(U,{children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(Gs,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{placeholder:"描述或哈希值...",value:b,onChange:re=>{w(re.target.value),h(1)},className:"pl-8"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:"注册状态"}),e.jsxs(rt,{value:S,onValueChange:re=>{C(re),h(1)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部"}),e.jsx(ye,{value:"registered",children:"已注册"}),e.jsx(ye,{value:"unregistered",children:"未注册"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:"封禁状态"}),e.jsxs(rt,{value:N,onValueChange:re=>{T(re),h(1)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部"}),e.jsx(ye,{value:"banned",children:"已封禁"}),e.jsx(ye,{value:"unbanned",children:"未封禁"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{children:"格式"}),e.jsxs(rt,{value:P,onValueChange:re=>{M(re),h(1)},children:[e.jsx(at,{children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部"}),$e.map(re=>e.jsxs(ye,{value:re,children:[re.toUpperCase()," (",l?.formats[re],")"]},re))]})]})]})]}),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.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(U,{htmlFor:"emoji-page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(rt,{value:g.toString(),onValueChange:re=>{j(parseInt(re)),h(1),je(new Set)},children:[e.jsx(at,{id:"emoji-page-size",className:"w-20",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"10",children:"10"}),e.jsx(ye,{value:"20",children:"20"}),e.jsx(ye,{value:"50",children:"50"}),e.jsx(ye,{value:"100",children:"100"})]})]}),oe.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>je(new Set),children:"取消选择"}),e.jsxs(q,{variant:"destructive",size:"sm",onClick:()=>me(!0),children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"批量删除"]})]})]})]}),e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsxs(q,{variant:"outline",size:"sm",onClick:ee,disabled:c,children:[e.jsx(xa,{className:`h-4 w-4 mr-2 ${c?"animate-spin":""}`}),"刷新"]})})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"表情包列表"}),e.jsxs(us,{children:["共 ",p," 个表情包,当前第 ",m," 页"]})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"hidden md:block rounded-md border overflow-hidden",children:e.jsxs(Rl,{children:[e.jsx(zl,{children:e.jsxs(ns,{children:[e.jsx(He,{className:"w-12",children:e.jsx(Cs,{checked:s.length>0&&oe.size===s.length,onCheckedChange:Ce,"aria-label":"全选"})}),e.jsx(He,{className:"w-16",children:"预览"}),e.jsx(He,{children:"描述"}),e.jsx(He,{children:"格式"}),e.jsx(He,{children:"情绪标签"}),e.jsx(He,{className:"text-center",children:"状态"}),e.jsx(He,{className:"text-right",children:"使用次数"}),e.jsx(He,{className:"text-right",children:"操作"})]})}),e.jsx(Pl,{children:s.length===0?e.jsx(ns,{children:e.jsx(Ae,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):s.map(re=>e.jsxs(ns,{children:[e.jsx(Ae,{children:e.jsx(Cs,{checked:oe.has(re.id),onCheckedChange:()=>de(re.id),"aria-label":`选择 ${re.description}`})}),e.jsx(Ae,{children:e.jsx("div",{className:"w-20 h-20 bg-muted rounded flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:Zf(re.id),alt:re.description||"表情包",className:"w-full h-full object-cover",onError:Pe=>{const ze=Pe.target;ze.style.display="none";const Zt=ze.parentElement;Zt&&(Zt.innerHTML='')}})})}),e.jsx(Ae,{children:e.jsxs("div",{className:"space-y-1 max-w-xs",children:[e.jsx("div",{className:"font-medium truncate",title:re.description||"无描述",children:re.description||"无描述"}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono",children:[re.emoji_hash.slice(0,16),"..."]})]})}),e.jsx(Ae,{children:e.jsx(_t,{variant:"outline",children:re.format.toUpperCase()})}),e.jsx(Ae,{children:e.jsx(Yj,{emotions:re.emotion})}),e.jsx(Ae,{className:"align-middle",children:e.jsxs("div",{className:"flex gap-2 justify-center",children:[re.is_registered&&e.jsxs(_t,{variant:"default",className:"bg-green-600",children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"已注册"]}),re.is_banned&&e.jsxs(_t,{variant:"destructive",children:[e.jsx(Af,{className:"h-3 w-3 mr-1"}),"已封禁"]})]})}),e.jsx(Ae,{className:"text-right font-mono",children:re.usage_count}),e.jsx(Ae,{children:e.jsxs("div",{className:"flex items-center justify-end gap-1 flex-wrap",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>xe(re),children:[e.jsx(Fr,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(q,{variant:"default",size:"sm",onClick:()=>F(re),children:[e.jsx(qr,{className:"h-4 w-4 mr-1"}),"编辑"]}),!re.is_registered&&e.jsxs(q,{size:"sm",onClick:()=>I(re),className:"bg-green-600 hover:bg-green-700 text-white",children:[e.jsx(Ys,{className:"h-4 w-4 mr-1"}),"注册"]}),!re.is_banned&&e.jsxs(q,{size:"sm",onClick:()=>ve(re),className:"bg-orange-600 hover:bg-orange-700 text-white",children:[e.jsx(Jv,{className:"h-4 w-4 mr-1"}),"封禁"]}),e.jsxs(q,{size:"sm",onClick:()=>W(re),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},re.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3",children:s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):s.map(re=>e.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-16 h-16 bg-muted rounded flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:Zf(re.id),alt:re.description||"表情包",className:"w-full h-full object-cover",onError:Pe=>{const ze=Pe.target;ze.style.display="none";const Zt=ze.parentElement;Zt&&(Zt.innerHTML='')}})})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsxs("div",{className:"min-w-0 w-full overflow-hidden",children:[e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",title:re.description||"无描述",children:re.description||"无描述"}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono line-clamp-1 w-full break-all",children:[re.emoji_hash.slice(0,16),"..."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 items-center min-w-0",children:[e.jsx(_t,{variant:"outline",className:"text-xs flex-shrink-0",children:re.format.toUpperCase()}),re.is_registered&&e.jsxs(_t,{variant:"default",className:"bg-green-600 text-xs flex-shrink-0",children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"已注册"]}),re.is_banned&&e.jsxs(_t,{variant:"destructive",className:"text-xs flex-shrink-0",children:[e.jsx(Af,{className:"h-3 w-3 mr-1"}),"已封禁"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:["使用: ",re.usage_count]})]}),re.emotion&&re.emotion.length>0&&e.jsx("div",{className:"min-w-0 overflow-hidden",children:e.jsx(Yj,{emotions:re.emotion})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>xe(re),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Fr,{className:"h-3 w-3 mr-1"}),"详情"]}),e.jsxs(q,{variant:"default",size:"sm",onClick:()=>F(re),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(qr,{className:"h-3 w-3 mr-1"}),"编辑"]}),!re.is_registered&&e.jsxs(q,{size:"sm",onClick:()=>I(re),className:"text-xs px-2 py-1 h-auto flex-shrink-0 bg-green-600 hover:bg-green-700 text-white",children:[e.jsx(Ys,{className:"h-3 w-3 mr-1"}),"注册"]}),!re.is_banned&&e.jsxs(q,{size:"sm",onClick:()=>ve(re),className:"text-xs px-2 py-1 h-auto flex-shrink-0 bg-orange-600 hover:bg-orange-700 text-white",children:[e.jsx(Jv,{className:"h-3 w-3 mr-1"}),"封禁"]}),e.jsxs(q,{size:"sm",onClick:()=>W(re),className:"text-xs px-2 py-1 h-auto flex-shrink-0 bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},re.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:["显示 ",(m-1)*g+1," 到"," ",Math.min(m*g,p)," 条,共 ",p," 条"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>h(1),disabled:m===1,className:"hidden sm:flex",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>h(re=>Math.max(1,re-1)),disabled:m===1,children:[e.jsx(Ol,{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(pe,{type:"number",value:R,onChange:re=>O(re.target.value),onKeyDown:re=>re.key==="Enter"&&Oe(),placeholder:m.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(p/g)}),e.jsx(q,{variant:"outline",size:"sm",onClick:Oe,disabled:!R,className:"h-8",children:"跳转"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>h(re=>re+1),disabled:m>=Math.ceil(p/g),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Al,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>h(Math.ceil(p/g)),disabled:m>=Math.ceil(p/g),className:"hidden sm:flex",children:e.jsx(jo,{className:"h-4 w-4"})})]})]})]})]}),e.jsx(tD,{emoji:k,open:A,onOpenChange:E}),e.jsx(sD,{emoji:k,open:B,onOpenChange:Y,onSuccess:()=>{ee(),le()}})]})}),e.jsx(Ft,{open:ae,onOpenChange:me,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认批量删除"}),e.jsxs(Pt,{children:["你确定要删除选中的 ",oe.size," 个表情包吗?此操作不可撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:Q,children:"确认删除"})]})]})}),e.jsx(bs,{open:G,onOpenChange:$,children:e.jsxs(ms,{children:[e.jsxs(fs,{children:[e.jsx(hs,{children:"确认删除"}),e.jsx(ks,{children:"确定要删除这个表情包吗?此操作无法撤销。"})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>$(!1),children:"取消"}),e.jsx(q,{variant:"destructive",onClick:fe,children:"删除"})]})]})})]})}function tD({emoji:s,open:a,onOpenChange:l}){if(!s)return null;const i=c=>c?new Date(c*1e3).toLocaleString("zh-CN"):"-";return e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(fs,{children:e.jsx(hs,{children:"表情包详情"})}),e.jsx(Ct,{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:Zf(s.id),alt:s.description||"表情包",className:"w-full h-full object-cover",onError:c=>{const d=c.target;d.style.display="none";const m=d.parentElement;m&&(m.innerHTML='')}})})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"ID"}),e.jsx("div",{className:"mt-1 font-mono",children:s.id})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"格式"}),e.jsx("div",{className:"mt-1",children:e.jsx(_t,{variant:"outline",children:s.format.toUpperCase()})})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"文件路径"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:s.full_path})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"哈希值"}),e.jsx("div",{className:"mt-1 font-mono text-sm break-all bg-muted p-2 rounded",children:s.emoji_hash})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"描述"}),e.jsx("div",{className:"mt-1",children:s.description||"-"})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"情绪标签"}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:(()=>{const c=s.emotion?s.emotion.split(/[,,]/).map(d=>d.trim()).filter(Boolean):[];return c.length>0?c.map((d,m)=>e.jsx(_t,{variant:"secondary",children:d},m)):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(U,{className:"text-muted-foreground",children:"状态"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[s.is_registered&&e.jsx(_t,{variant:"default",className:"bg-green-600",children:"已注册"}),s.is_banned&&e.jsx(_t,{variant:"destructive",children:"已封禁"}),!s.is_registered&&!s.is_banned&&e.jsx(_t,{variant:"outline",children:"未注册"})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"使用次数"}),e.jsx("div",{className:"mt-1 font-mono text-lg",children:s.usage_count})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"记录时间"}),e.jsx("div",{className:"mt-1 text-sm",children:i(s.record_time)})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"注册时间"}),e.jsx("div",{className:"mt-1 text-sm",children:i(s.register_time)})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-muted-foreground",children:"最后使用"}),e.jsx("div",{className:"mt-1 text-sm",children:i(s.last_used_time)})]})]})})]})})}function sD({emoji:s,open:a,onOpenChange:l,onSuccess:i}){const[c,d]=x.useState(""),[m,h]=x.useState(""),[p,v]=x.useState(!1),[g,j]=x.useState(!1),[b,w]=x.useState(!1),{toast:S}=Es();x.useEffect(()=>{s&&(d(s.description||""),h(s.emotion||""),v(s.is_registered),j(s.is_banned))},[s]);const C=async()=>{if(s)try{w(!0);const N=m.split(/[,,]/).map(T=>T.trim()).filter(Boolean).join(",");await WM(s.id,{description:c||void 0,emotion:N||void 0,is_registered:p,is_banned:g}),S({title:"成功",description:"表情包信息已更新"}),l(!1),i()}catch(N){const T=N instanceof Error?N.message:"保存失败";S({title:"错误",description:T,variant:"destructive"})}finally{w(!1)}};return s?e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl",children:[e.jsxs(fs,{children:[e.jsx(hs,{children:"编辑表情包"}),e.jsx(ks,{children:"修改表情包的描述和标签信息"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(U,{children:"描述"}),e.jsx(Dt,{value:c,onChange:N=>d(N.target.value),placeholder:"输入表情包描述...",rows:3,className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(U,{children:"情绪标签"}),e.jsx(pe,{value:m,onChange:N=>h(N.target.value),placeholder:"使用逗号分隔多个标签,如:开心, 微笑, 快乐",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(Cs,{id:"is_registered",checked:p,onCheckedChange:N=>v(N===!0)}),e.jsx(U,{htmlFor:"is_registered",className:"cursor-pointer",children:"已注册"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Cs,{id:"is_banned",checked:g,onCheckedChange:N=>j(N===!0)}),e.jsx(U,{htmlFor:"is_banned",className:"cursor-pointer",children:"已封禁"})]})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>l(!1),children:"取消"}),e.jsx(q,{onClick:C,disabled:b,children:b?"保存中...":"保存"})]})]})}):null}function Yj({emotions:s}){const a=s?s.split(/[,,]/).map(d=>d.trim()).filter(Boolean):[];if(a.length===0)return e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"});const l=(d,m=6)=>d.length<=m?d:d.slice(0,m)+"...",i=a.slice(0,3),c=a.length-3;return e.jsxs("div",{className:"flex flex-wrap gap-1 max-w-full overflow-hidden",children:[i.map((d,m)=>e.jsx(_t,{variant:"secondary",className:"text-xs flex-shrink-0",title:d,children:l(d)},m)),c>0&&e.jsxs(_t,{variant:"outline",className:"text-xs flex-shrink-0",title:`还有 ${c} 个标签: ${a.slice(3).join(", ")}`,children:["+",c]})]})}const Ll="/api/webui/expression";async function nD(s){const a=new URLSearchParams;s.page&&a.append("page",s.page.toString()),s.page_size&&a.append("page_size",s.page_size.toString()),s.search&&a.append("search",s.search),s.chat_id&&a.append("chat_id",s.chat_id);const l=await Fe(`${Ll}/list?${a}`,{headers:Ie()});if(!l.ok){const i=await l.json();throw new Error(i.detail||"获取表达方式列表失败")}return l.json()}async function aD(s){const a=await Fe(`${Ll}/${s}`,{headers:Ie()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取表达方式详情失败")}return a.json()}async function lD(s){const a=await Fe(`${Ll}/`,{method:"POST",headers:Ie(),body:JSON.stringify(s)});if(!a.ok){const l=await a.json();throw new Error(l.detail||"创建表达方式失败")}return a.json()}async function rD(s,a){const l=await Fe(`${Ll}/${s}`,{method:"PATCH",headers:Ie(),body:JSON.stringify(a)});if(!l.ok){const i=await l.json();throw new Error(i.detail||"更新表达方式失败")}return l.json()}async function iD(s){const a=await Fe(`${Ll}/${s}`,{method:"DELETE",headers:Ie()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"删除表达方式失败")}return a.json()}async function oD(s){const a=await Fe(`${Ll}/batch/delete`,{method:"POST",headers:Ie(),body:JSON.stringify({ids:s})});if(!a.ok){const l=await a.json();throw new Error(l.detail||"批量删除表达方式失败")}return a.json()}async function cD(){const s=await Fe(`${Ll}/stats/summary`,{headers:Ie()});if(!s.ok){const a=await s.json();throw new Error(a.detail||"获取统计数据失败")}return s.json()}function dD(){const[s,a]=x.useState([]),[l,i]=x.useState(!0),[c,d]=x.useState(0),[m,h]=x.useState(1),[p,v]=x.useState(20),[g,j]=x.useState(""),[b,w]=x.useState(null),[S,C]=x.useState(!1),[N,T]=x.useState(!1),[P,M]=x.useState(!1),[k,D]=x.useState(null),[A,E]=x.useState(new Set),[B,Y]=x.useState(!1),[G,$]=x.useState(""),[oe,je]=x.useState({total:0,recent_7days:0,chat_count:0,top_chats:{}}),{toast:ae}=Es(),me=async()=>{try{i(!0);const I=await nD({page:m,page_size:p,search:g||void 0});a(I.data),d(I.total)}catch(I){ae({title:"加载失败",description:I instanceof Error?I.message:"无法加载表达方式",variant:"destructive"})}finally{i(!1)}},R=async()=>{try{const I=await cD();je(I.data)}catch(I){console.error("加载统计数据失败:",I)}};x.useEffect(()=>{me(),R()},[m,p,g]);const O=async I=>{try{const ve=await aD(I.id);w(ve.data),C(!0)}catch(ve){ae({title:"加载详情失败",description:ve instanceof Error?ve.message:"无法加载表达方式详情",variant:"destructive"})}},L=I=>{w(I),T(!0)},ee=async I=>{try{await iD(I.id),ae({title:"删除成功",description:`已删除表达方式: ${I.situation}`}),D(null),me(),R()}catch(ve){ae({title:"删除失败",description:ve instanceof Error?ve.message:"无法删除表达方式",variant:"destructive"})}},le=I=>{const ve=new Set(A);ve.has(I)?ve.delete(I):ve.add(I),E(ve)},xe=()=>{A.size===s.length&&s.length>0?E(new Set):E(new Set(s.map(I=>I.id)))},F=async()=>{try{await oD(Array.from(A)),ae({title:"批量删除成功",description:`已删除 ${A.size} 个表达方式`}),E(new Set),Y(!1),me(),R()}catch(I){ae({title:"批量删除失败",description:I instanceof Error?I.message:"无法批量删除表达方式",variant:"destructive"})}},W=()=>{const I=parseInt(G),ve=Math.ceil(c/p);I>=1&&I<=ve?(h(I),$("")):ae({title:"无效的页码",description:`请输入1-${ve}之间的页码`,variant:"destructive"})},fe=I=>I?new Date(I*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.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(po,{className:"h-8 w-8",strokeWidth:2}),"表达方式管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦的表达方式和话术模板"})]}),e.jsxs(q,{onClick:()=>M(!0),className:"gap-2",children:[e.jsx(ys,{className:"h-4 w-4"}),"新增表达方式"]})]})}),e.jsx(Ct,{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:oe.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:oe.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:oe.chat_count})]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx(U,{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(Gs,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{id:"search",placeholder:"搜索情境、风格或上下文...",value:g,onChange:I=>j(I.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:A.size>0&&e.jsxs("span",{children:["已选择 ",A.size," 个表达方式"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(rt,{value:p.toString(),onValueChange:I=>{v(parseInt(I)),h(1),E(new Set)},children:[e.jsx(at,{id:"page-size",className:"w-20",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"10",children:"10"}),e.jsx(ye,{value:"20",children:"20"}),e.jsx(ye,{value:"50",children:"50"}),e.jsx(ye,{value:"100",children:"100"})]})]}),A.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>E(new Set),children:"取消选择"}),e.jsxs(q,{variant:"destructive",size:"sm",onClick:()=>Y(!0),children:[e.jsx(ft,{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(zl,{children:e.jsxs(ns,{children:[e.jsx(He,{className:"w-12",children:e.jsx(Cs,{checked:A.size===s.length&&s.length>0,onCheckedChange:xe})}),e.jsx(He,{children:"情境"}),e.jsx(He,{children:"风格"}),e.jsx(He,{children:"聊天ID"}),e.jsx(He,{children:"最后活跃"}),e.jsx(He,{className:"text-right",children:"操作"})]})}),e.jsx(Pl,{children:l?e.jsx(ns,{children:e.jsx(Ae,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):s.length===0?e.jsx(ns,{children:e.jsx(Ae,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):s.map(I=>e.jsxs(ns,{children:[e.jsx(Ae,{children:e.jsx(Cs,{checked:A.has(I.id),onCheckedChange:()=>le(I.id)})}),e.jsx(Ae,{className:"font-medium max-w-xs truncate",children:I.situation}),e.jsx(Ae,{className:"max-w-xs truncate",children:I.style}),e.jsx(Ae,{className:"font-mono text-sm",children:I.chat_id}),e.jsx(Ae,{className:"text-sm text-muted-foreground",children:fe(I.last_active_time)}),e.jsx(Ae,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>O(I),children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(q,{variant:"default",size:"sm",onClick:()=>L(I),children:[e.jsx(qr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(q,{size:"sm",onClick:()=>D(I),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},I.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:l?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):s.map(I=>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(Cs,{checked:A.has(I.id),onCheckedChange:()=>le(I.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:I.situation,children:I.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:I.style,children:I.style})]})]})]}),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:"聊天ID"}),e.jsx("p",{className:"font-mono text-xs truncate",children:I.chat_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"最后活跃"}),e.jsx("p",{className:"text-xs",children:fe(I.last_active_time)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>O(I),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>L(I),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(qr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>D(I),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(ft,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},I.id))}),c>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:["共 ",c," 条记录,第 ",m," / ",Math.ceil(c/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>h(1),disabled:m===1,className:"hidden sm:flex",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>h(m-1),disabled:m===1,children:[e.jsx(Ol,{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(pe,{type:"number",value:G,onChange:I=>$(I.target.value),onKeyDown:I=>I.key==="Enter"&&W(),placeholder:m.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(c/p)}),e.jsx(q,{variant:"outline",size:"sm",onClick:W,disabled:!G,className:"h-8",children:"跳转"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>h(m+1),disabled:m>=Math.ceil(c/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Al,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>h(Math.ceil(c/p)),disabled:m>=Math.ceil(c/p),className:"hidden sm:flex",children:e.jsx(jo,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(uD,{expression:b,open:S,onOpenChange:C}),e.jsx(mD,{open:P,onOpenChange:M,onSuccess:()=>{me(),R(),M(!1)}}),e.jsx(fD,{expression:b,open:N,onOpenChange:T,onSuccess:()=>{me(),R(),T(!1)}}),e.jsx(Ft,{open:!!k,onOpenChange:()=>D(null),children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除表达方式 "',k?.situation,'" 吗? 此操作不可撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>k&&ee(k),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(hD,{open:B,onOpenChange:Y,onConfirm:F,count:A.size})]})}function uD({expression:s,open:a,onOpenChange:l}){if(!s)return null;const i=c=>c?new Date(c*1e3).toLocaleString("zh-CN"):"-";return e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{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(Er,{label:"情境",value:s.situation}),e.jsx(Er,{label:"风格",value:s.style}),e.jsx(Er,{icon:xd,label:"聊天ID",value:s.chat_id,mono:!0}),e.jsx(Er,{icon:xd,label:"记录ID",value:s.id.toString(),mono:!0})]}),s.context&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:"上下文"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:s.context})]}),s.up_content&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:"上文内容"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:s.up_content})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Er,{icon:_l,label:"最后活跃",value:i(s.last_active_time)}),e.jsx(Er,{icon:_l,label:"创建时间",value:i(s.create_date)})]})]}),e.jsx($s,{children:e.jsx(q,{onClick:()=>l(!1),children:"关闭"})})]})})}function Er({icon:s,label:a,value:l,mono:i=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(U,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s&&e.jsx(s,{className:"h-3 w-3"}),a]}),e.jsx("div",{className:Z("text-sm",i&&"font-mono",!l&&"text-muted-foreground"),children:l||"-"})]})}function mD({open:s,onOpenChange:a,onSuccess:l}){const[i,c]=x.useState({situation:"",style:"",context:"",up_content:"",chat_id:""}),[d,m]=x.useState(!1),{toast:h}=Es(),p=async()=>{if(!i.situation||!i.style||!i.chat_id){h({title:"验证失败",description:"请填写必填字段:情境、风格和聊天ID",variant:"destructive"});return}try{m(!0),await lD(i),h({title:"创建成功",description:"表达方式已创建"}),c({situation:"",style:"",context:"",up_content:"",chat_id:""}),l()}catch(v){h({title:"创建失败",description:v instanceof Error?v.message:"无法创建表达方式",variant:"destructive"})}finally{m(!1)}};return e.jsx(bs,{open:s,onOpenChange:a,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{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(U,{htmlFor:"situation",children:["情境 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(pe,{id:"situation",value:i.situation,onChange:v=>c({...i,situation:v.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{htmlFor:"style",children:["风格 ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(pe,{id:"style",value:i.style,onChange:v=>c({...i,style:v.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(U,{htmlFor:"chat_id",children:["聊天ID ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(pe,{id:"chat_id",value:i.chat_id,onChange:v=>c({...i,chat_id:v.target.value}),placeholder:"关联的聊天ID"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"context",children:"上下文"}),e.jsx(Dt,{id:"context",value:i.context,onChange:v=>c({...i,context:v.target.value}),placeholder:"上下文信息(可选)",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"up_content",children:"上文内容"}),e.jsx(Dt,{id:"up_content",value:i.up_content,onChange:v=>c({...i,up_content:v.target.value}),placeholder:"上文内容(可选)",rows:3})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>a(!1),children:"取消"}),e.jsx(q,{onClick:p,disabled:d,children:d?"创建中...":"创建"})]})]})})}function fD({expression:s,open:a,onOpenChange:l,onSuccess:i}){const[c,d]=x.useState({}),[m,h]=x.useState(!1),{toast:p}=Es();x.useEffect(()=>{s&&d({situation:s.situation,style:s.style,context:s.context||"",up_content:s.up_content||"",chat_id:s.chat_id})},[s]);const v=async()=>{if(s)try{h(!0),await rD(s.id,c),p({title:"保存成功",description:"表达方式已更新"}),i()}catch(g){p({title:"保存失败",description:g instanceof Error?g.message:"无法更新表达方式",variant:"destructive"})}finally{h(!1)}};return s?e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{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(U,{htmlFor:"edit_situation",children:"情境"}),e.jsx(pe,{id:"edit_situation",value:c.situation||"",onChange:g=>d({...c,situation:g.target.value}),placeholder:"描述使用场景"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit_style",children:"风格"}),e.jsx(pe,{id:"edit_style",value:c.style||"",onChange:g=>d({...c,style:g.target.value}),placeholder:"描述表达风格"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit_chat_id",children:"聊天ID"}),e.jsx(pe,{id:"edit_chat_id",value:c.chat_id||"",onChange:g=>d({...c,chat_id:g.target.value}),placeholder:"关联的聊天ID"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit_context",children:"上下文"}),e.jsx(Dt,{id:"edit_context",value:c.context||"",onChange:g=>d({...c,context:g.target.value}),placeholder:"上下文信息",rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit_up_content",children:"上文内容"}),e.jsx(Dt,{id:"edit_up_content",value:c.up_content||"",onChange:g=>d({...c,up_content:g.target.value}),placeholder:"上文内容",rows:3})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>l(!1),children:"取消"}),e.jsx(q,{onClick:v,disabled:m,children:m?"保存中...":"保存"})]})]})}):null}function hD({open:s,onOpenChange:a,onConfirm:l,count:i}){return e.jsx(Ft,{open:s,onOpenChange:a,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认批量删除"}),e.jsxs(Pt,{children:["您即将删除 ",i," 个表达方式,此操作无法撤销。确定要继续吗?"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:l,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"确认删除"})]})]})})}const si="/api/webui/person";async function xD(s){const a=new URLSearchParams;s.page&&a.append("page",s.page.toString()),s.page_size&&a.append("page_size",s.page_size.toString()),s.search&&a.append("search",s.search),s.is_known!==void 0&&a.append("is_known",s.is_known.toString()),s.platform&&a.append("platform",s.platform);const l=await Fe(`${si}/list?${a}`,{headers:Ie()});if(!l.ok){const i=await l.json();throw new Error(i.detail||"获取人物列表失败")}return l.json()}async function pD(s){const a=await Fe(`${si}/${s}`,{headers:Ie()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"获取人物详情失败")}return a.json()}async function gD(s,a){const l=await Fe(`${si}/${s}`,{method:"PATCH",headers:Ie(),body:JSON.stringify(a)});if(!l.ok){const i=await l.json();throw new Error(i.detail||"更新人物信息失败")}return l.json()}async function vD(s){const a=await Fe(`${si}/${s}`,{method:"DELETE",headers:Ie()});if(!a.ok){const l=await a.json();throw new Error(l.detail||"删除人物信息失败")}return a.json()}async function jD(){const s=await Fe(`${si}/stats/summary`,{headers:Ie()});if(!s.ok){const a=await s.json();throw new Error(a.detail||"获取统计数据失败")}return s.json()}async function yD(s){const a=await Fe(`${si}/batch/delete`,{method:"POST",headers:Ie(),body:JSON.stringify({person_ids:s})});if(!a.ok){const l=await a.json();throw new Error(l.detail||"批量删除失败")}return a.json()}function bD(){const[s,a]=x.useState([]),[l,i]=x.useState(!0),[c,d]=x.useState(0),[m,h]=x.useState(1),[p,v]=x.useState(20),[g,j]=x.useState(""),[b,w]=x.useState(void 0),[S,C]=x.useState(void 0),[N,T]=x.useState(null),[P,M]=x.useState(!1),[k,D]=x.useState(!1),[A,E]=x.useState(null),[B,Y]=x.useState({total:0,known:0,unknown:0,platforms:{}}),[G,$]=x.useState(new Set),[oe,je]=x.useState(!1),[ae,me]=x.useState(""),{toast:R}=Es(),O=async()=>{try{i(!0);const Q=await xD({page:m,page_size:p,search:g||void 0,is_known:b,platform:S});a(Q.data),d(Q.total)}catch(Q){R({title:"加载失败",description:Q instanceof Error?Q.message:"无法加载人物信息",variant:"destructive"})}finally{i(!1)}},L=async()=>{try{const Q=await jD();Y(Q.data)}catch(Q){console.error("加载统计数据失败:",Q)}};x.useEffect(()=>{O(),L()},[m,p,g,b,S]);const ee=async Q=>{try{const Oe=await pD(Q.person_id);T(Oe.data),M(!0)}catch(Oe){R({title:"加载详情失败",description:Oe instanceof Error?Oe.message:"无法加载人物详情",variant:"destructive"})}},le=Q=>{T(Q),D(!0)},xe=async Q=>{try{await vD(Q.person_id),R({title:"删除成功",description:`已删除人物信息: ${Q.person_name||Q.nickname||Q.user_id}`}),E(null),O(),L()}catch(Oe){R({title:"删除失败",description:Oe instanceof Error?Oe.message:"无法删除人物信息",variant:"destructive"})}},F=x.useMemo(()=>Object.keys(B.platforms),[B.platforms]),W=Q=>{const Oe=new Set(G);Oe.has(Q)?Oe.delete(Q):Oe.add(Q),$(Oe)},fe=()=>{G.size===s.length&&s.length>0?$(new Set):$(new Set(s.map(Q=>Q.person_id)))},I=()=>{if(G.size===0){R({title:"未选择任何人物",description:"请先选择要删除的人物",variant:"destructive"});return}je(!0)},ve=async()=>{try{const Q=await yD(Array.from(G));R({title:"批量删除完成",description:Q.message}),$(new Set),je(!1),O(),L()}catch(Q){R({title:"批量删除失败",description:Q instanceof Error?Q.message:"批量删除失败",variant:"destructive"})}},de=()=>{const Q=parseInt(ae),Oe=Math.ceil(c/p);Q>=1&&Q<=Oe?(h(Q),me("")):R({title:"无效的页码",description:`请输入1-${Oe}之间的页码`,variant:"destructive"})},Ce=Q=>Q?new Date(Q*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(H2,{className:"h-8 w-8",strokeWidth:2}),"人物信息管理"]}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"管理麦麦认识的所有人物信息"})]})})}),e.jsx(Ct,{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:B.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:B.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:B.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(U,{htmlFor:"search",children:"搜索"}),e.jsxs("div",{className:"relative mt-1.5",children:[e.jsx(Gs,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{id:"search",placeholder:"搜索名称、昵称或用户ID...",value:g,onChange:Q=>j(Q.target.value),className:"pl-9"})]})]}),e.jsxs("div",{children:[e.jsx(U,{htmlFor:"filter-known",children:"认识状态"}),e.jsxs(rt,{value:b===void 0?"all":b.toString(),onValueChange:Q=>{w(Q==="all"?void 0:Q==="true"),h(1)},children:[e.jsx(at,{id:"filter-known",className:"mt-1.5",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部"}),e.jsx(ye,{value:"true",children:"已认识"}),e.jsx(ye,{value:"false",children:"未认识"})]})]})]}),e.jsxs("div",{children:[e.jsx(U,{htmlFor:"filter-platform",children:"平台"}),e.jsxs(rt,{value:S||"all",onValueChange:Q=>{C(Q==="all"?void 0:Q),h(1)},children:[e.jsx(at,{id:"filter-platform",className:"mt-1.5",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部平台"}),F.map(Q=>e.jsxs(ye,{value:Q,children:[Q," (",B.platforms[Q],")"]},Q))]})]})]})]}),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:G.size>0&&e.jsxs("span",{children:["已选择 ",G.size," 个人物"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{htmlFor:"page-size",className:"text-sm whitespace-nowrap",children:"每页显示"}),e.jsxs(rt,{value:p.toString(),onValueChange:Q=>{v(parseInt(Q)),h(1),$(new Set)},children:[e.jsx(at,{id:"page-size",className:"w-20",children:e.jsx(it,{})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"10",children:"10"}),e.jsx(ye,{value:"20",children:"20"}),e.jsx(ye,{value:"50",children:"50"}),e.jsx(ye,{value:"100",children:"100"})]})]}),G.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>$(new Set),children:"取消选择"}),e.jsxs(q,{variant:"destructive",size:"sm",onClick:I,children:[e.jsx(ft,{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(zl,{children:e.jsxs(ns,{children:[e.jsx(He,{className:"w-12",children:e.jsx(Cs,{checked:s.length>0&&G.size===s.length,onCheckedChange:fe,"aria-label":"全选"})}),e.jsx(He,{children:"状态"}),e.jsx(He,{children:"名称"}),e.jsx(He,{children:"昵称"}),e.jsx(He,{children:"平台"}),e.jsx(He,{children:"用户ID"}),e.jsx(He,{children:"最后更新"}),e.jsx(He,{className:"text-right",children:"操作"})]})}),e.jsx(Pl,{children:l?e.jsx(ns,{children:e.jsx(Ae,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"加载中..."})}):s.length===0?e.jsx(ns,{children:e.jsx(Ae,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"暂无数据"})}):s.map(Q=>e.jsxs(ns,{children:[e.jsx(Ae,{children:e.jsx(Cs,{checked:G.has(Q.person_id),onCheckedChange:()=>W(Q.person_id),"aria-label":`选择 ${Q.person_name||Q.nickname||Q.user_id}`})}),e.jsx(Ae,{children:e.jsx("div",{className:Z("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",Q.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:Q.is_known?"已认识":"未认识"})}),e.jsx(Ae,{className:"font-medium",children:Q.person_name||e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(Ae,{children:Q.nickname||"-"}),e.jsx(Ae,{children:Q.platform}),e.jsx(Ae,{className:"font-mono text-sm",children:Q.user_id}),e.jsx(Ae,{className:"text-sm text-muted-foreground",children:Ce(Q.last_know)}),e.jsx(Ae,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(q,{variant:"default",size:"sm",onClick:()=>ee(Q),children:[e.jsx(Mn,{className:"h-4 w-4 mr-1"}),"详情"]}),e.jsxs(q,{variant:"default",size:"sm",onClick:()=>le(Q),children:[e.jsx(qr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsxs(q,{size:"sm",onClick:()=>E(Q),className:"bg-red-600 hover:bg-red-700 text-white",children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"删除"]})]})})]},Q.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3 p-4",children:l?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"暂无数据"}):s.map(Q=>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(Cs,{checked:G.has(Q.person_id),onCheckedChange:()=>W(Q.person_id),className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:Z("inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium mb-2",Q.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:Q.is_known?"已认识":"未认识"}),e.jsx("h3",{className:"font-semibold text-sm line-clamp-1 w-full break-all",children:Q.person_name||e.jsx("span",{className:"text-muted-foreground",children:"未命名"})}),Q.nickname&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-1 w-full break-all",children:["昵称: ",Q.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:Q.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:Q.user_id,children:Q.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:Ce(Q.last_know)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 pt-2 border-t overflow-hidden",children:[e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>ee(Q),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(Mn,{className:"h-3 w-3 mr-1"}),"查看"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>le(Q),className:"text-xs px-2 py-1 h-auto flex-shrink-0",children:[e.jsx(qr,{className:"h-3 w-3 mr-1"}),"编辑"]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>E(Q),className:"text-xs px-2 py-1 h-auto flex-shrink-0 text-destructive hover:text-destructive",children:[e.jsx(ft,{className:"h-3 w-3 mr-1"}),"删除"]})]})]},Q.id))}),c>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:["共 ",c," 条记录,第 ",m," / ",Math.ceil(c/p)," 页"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>h(1),disabled:m===1,className:"hidden sm:flex",children:e.jsx(vo,{className:"h-4 w-4"})}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>h(m-1),disabled:m===1,children:[e.jsx(Ol,{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(pe,{type:"number",value:ae,onChange:Q=>me(Q.target.value),onKeyDown:Q=>Q.key==="Enter"&&de(),placeholder:m.toString(),className:"w-16 h-8 text-center",min:1,max:Math.ceil(c/p)}),e.jsx(q,{variant:"outline",size:"sm",onClick:de,disabled:!ae,className:"h-8",children:"跳转"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:()=>h(m+1),disabled:m>=Math.ceil(c/p),children:[e.jsx("span",{className:"hidden sm:inline",children:"下一页"}),e.jsx(Al,{className:"h-4 w-4 sm:ml-1"})]}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>h(Math.ceil(c/p)),disabled:m>=Math.ceil(c/p),className:"hidden sm:flex",children:e.jsx(jo,{className:"h-4 w-4"})})]})]})]})]})}),e.jsx(ND,{person:N,open:P,onOpenChange:M}),e.jsx(wD,{person:N,open:k,onOpenChange:D,onSuccess:()=>{O(),L(),D(!1)}}),e.jsx(Ft,{open:!!A,onOpenChange:()=>E(null),children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认删除"}),e.jsxs(Pt,{children:['确定要删除人物信息 "',A?.person_name||A?.nickname||A?.user_id,'" 吗? 此操作不可撤销。']})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:()=>A&&xe(A),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"删除"})]})]})}),e.jsx(Ft,{open:oe,onOpenChange:je,children:e.jsxs(Ot,{children:[e.jsxs(At,{children:[e.jsx(zt,{children:"确认批量删除"}),e.jsxs(Pt,{children:["确定要删除选中的 ",G.size," 个人物信息吗? 此操作不可撤销。"]})]}),e.jsxs(Rt,{children:[e.jsx(Bt,{children:"取消"}),e.jsx(Lt,{onClick:ve,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"批量删除"})]})]})})]})}function ND({person:s,open:a,onOpenChange:l}){if(!s)return null;const i=c=>c?new Date(c*1e3).toLocaleString("zh-CN"):"-";return e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{children:"人物详情"}),e.jsxs(ks,{children:["查看 ",s.person_name||s.nickname||s.user_id," 的完整信息"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ma,{icon:Ey,label:"人物名称",value:s.person_name}),e.jsx(ma,{icon:po,label:"昵称",value:s.nickname}),e.jsx(ma,{icon:xd,label:"用户ID",value:s.user_id,mono:!0}),e.jsx(ma,{icon:xd,label:"人物ID",value:s.person_id,mono:!0}),e.jsx(ma,{label:"平台",value:s.platform}),e.jsx(ma,{label:"状态",value:s.is_known?"已认识":"未认识"})]}),s.name_reason&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:"名称设定原因"}),e.jsx("p",{className:"mt-1 text-sm",children:s.name_reason})]}),s.memory_points&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:"个人印象"}),e.jsx("p",{className:"mt-1 text-sm whitespace-pre-wrap",children:s.memory_points})]}),s.group_nick_name&&s.group_nick_name.length>0&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3",children:[e.jsx(U,{className:"text-xs text-muted-foreground",children:"群昵称"}),e.jsx("div",{className:"mt-2 space-y-1",children:s.group_nick_name.map((c,d)=>e.jsxs("div",{className:"text-sm flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:c.group_id}),e.jsx("span",{children:"→"}),e.jsx("span",{children:c.group_nick_name})]},d))})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(ma,{icon:_l,label:"认识时间",value:i(s.know_times)}),e.jsx(ma,{icon:_l,label:"首次记录",value:i(s.know_since)}),e.jsx(ma,{icon:_l,label:"最后更新",value:i(s.last_know)})]})]}),e.jsx($s,{children:e.jsx(q,{onClick:()=>l(!1),children:"关闭"})})]})})}function ma({icon:s,label:a,value:l,mono:i=!1}){return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(U,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[s&&e.jsx(s,{className:"h-3 w-3"}),a]}),e.jsx("div",{className:Z("text-sm",i&&"font-mono",!l&&"text-muted-foreground"),children:l||"-"})]})}function wD({person:s,open:a,onOpenChange:l,onSuccess:i}){const[c,d]=x.useState({}),[m,h]=x.useState(!1),{toast:p}=Es();x.useEffect(()=>{s&&d({person_name:s.person_name||"",name_reason:s.name_reason||"",nickname:s.nickname||"",memory_points:s.memory_points||"",is_known:s.is_known})},[s]);const v=async()=>{if(s)try{h(!0),await gD(s.person_id,c),p({title:"保存成功",description:"人物信息已更新"}),i()}catch(g){p({title:"保存失败",description:g instanceof Error?g.message:"无法更新人物信息",variant:"destructive"})}finally{h(!1)}};return s?e.jsx(bs,{open:a,onOpenChange:l,children:e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(fs,{children:[e.jsx(hs,{children:"编辑人物信息"}),e.jsxs(ks,{children:["修改 ",s.person_name||s.nickname||s.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(U,{htmlFor:"person_name",children:"人物名称"}),e.jsx(pe,{id:"person_name",value:c.person_name||"",onChange:g=>d({...c,person_name:g.target.value}),placeholder:"为这个人设置一个名称"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"nickname",children:"昵称"}),e.jsx(pe,{id:"nickname",value:c.nickname||"",onChange:g=>d({...c,nickname:g.target.value}),placeholder:"昵称"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"name_reason",children:"名称设定原因"}),e.jsx(Dt,{id:"name_reason",value:c.name_reason||"",onChange:g=>d({...c,name_reason:g.target.value}),placeholder:"为什么这样称呼这个人?",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"memory_points",children:"个人印象"}),e.jsx(Dt,{id:"memory_points",value:c.memory_points||"",onChange:g=>d({...c,memory_points:g.target.value}),placeholder:"对这个人的印象和记忆点...",rows:4})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{children:[e.jsx(U,{htmlFor:"is_known",className:"text-base font-medium",children:"已认识"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"标记是否已经认识这个人"})]}),e.jsx(Ze,{id:"is_known",checked:c.is_known,onCheckedChange:g=>d({...c,is_known:g})})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>l(!1),children:"取消"}),e.jsx(q,{onClick:v,disabled:m,children:m?"保存中...":"保存"})]})]})}):null}function SD(s,a,l="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:s,timeZoneName:l}).format(a).split(/\s/g).slice(2).join(" ")}const _D={},Ji={};function Sl(s,a){try{const i=(_D[s]||=new Intl.DateTimeFormat("en-US",{timeZone:s,timeZoneName:"longOffset"}).format)(a).split("GMT")[1];return i in Ji?Ji[i]:qj(i,i.split(":"))}catch{if(s in Ji)return Ji[s];const l=s?.match(CD);return l?qj(s,l.slice(1)):NaN}}const CD=/([+-]\d\d):?(\d\d)?/;function qj(s,a){const l=+(a[0]||0),i=+(a[1]||0),c=+(a[2]||0)/60;return Ji[s]=l*60+i>0?l*60+i+c:l*60-i-c}class Yn extends Date{constructor(...a){super(),a.length>1&&typeof a[a.length-1]=="string"&&(this.timeZone=a.pop()),this.internal=new Date,isNaN(Sl(this.timeZone,this))?this.setTime(NaN):a.length?typeof a[0]=="number"&&(a.length===1||a.length===2&&typeof a[1]!="number")?this.setTime(a[0]):typeof a[0]=="string"?this.setTime(+new Date(a[0])):a[0]instanceof Date?this.setTime(+a[0]):(this.setTime(+new Date(...a)),EN(this),Jf(this)):this.setTime(Date.now())}static tz(a,...l){return l.length?new Yn(...l,a):new Yn(Date.now(),a)}withTimeZone(a){return new Yn(+this,a)}getTimezoneOffset(){const a=-Sl(this.timeZone,this);return a>0?Math.floor(a):Math.ceil(a)}setTime(a){return Date.prototype.setTime.apply(this,arguments),Jf(this),+this}[Symbol.for("constructDateFrom")](a){return new Yn(+new Date(a),this.timeZone)}}const Vj=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(s=>{if(!Vj.test(s))return;const a=s.replace(Vj,"$1UTC");Yn.prototype[a]&&(s.startsWith("get")?Yn.prototype[s]=function(){return this.internal[a]()}:(Yn.prototype[s]=function(){return Date.prototype[a].apply(this.internal,arguments),kD(this),+this},Yn.prototype[a]=function(){return Date.prototype[a].apply(this,arguments),Jf(this),+this}))});function Jf(s){s.internal.setTime(+s),s.internal.setUTCSeconds(s.internal.getUTCSeconds()-Math.round(-Sl(s.timeZone,s)*60))}function kD(s){Date.prototype.setFullYear.call(s,s.internal.getUTCFullYear(),s.internal.getUTCMonth(),s.internal.getUTCDate()),Date.prototype.setHours.call(s,s.internal.getUTCHours(),s.internal.getUTCMinutes(),s.internal.getUTCSeconds(),s.internal.getUTCMilliseconds()),EN(s)}function EN(s){const a=Sl(s.timeZone,s),l=a>0?Math.floor(a):Math.ceil(a),i=new Date(+s);i.setUTCHours(i.getUTCHours()-1);const c=-new Date(+s).getTimezoneOffset(),d=-new Date(+i).getTimezoneOffset(),m=c-d,h=Date.prototype.getHours.apply(s)!==s.internal.getUTCHours();m&&h&&s.internal.setUTCMinutes(s.internal.getUTCMinutes()+m);const p=c-l;p&&Date.prototype.setUTCMinutes.call(s,Date.prototype.getUTCMinutes.call(s)+p);const v=new Date(+s);v.setUTCSeconds(0);const g=c>0?v.getSeconds():(v.getSeconds()-60)%60,j=Math.round(-(Sl(s.timeZone,s)*60))%60;(j||g)&&(s.internal.setUTCSeconds(s.internal.getUTCSeconds()+j),Date.prototype.setUTCSeconds.call(s,Date.prototype.getUTCSeconds.call(s)+j+g));const b=Sl(s.timeZone,s),w=b>0?Math.floor(b):Math.ceil(b),C=-new Date(+s).getTimezoneOffset()-w,N=w!==l,T=C-p;if(N&&T){Date.prototype.setUTCMinutes.call(s,Date.prototype.getUTCMinutes.call(s)+T);const P=Sl(s.timeZone,s),M=P>0?Math.floor(P):Math.ceil(P),k=w-M;k&&(s.internal.setUTCMinutes(s.internal.getUTCMinutes()+k),Date.prototype.setUTCMinutes.call(s,Date.prototype.getUTCMinutes.call(s)+k))}}class Ns extends Yn{static tz(a,...l){return l.length?new Ns(...l,a):new Ns(Date.now(),a)}toISOString(){const[a,l,i]=this.tzComponents(),c=`${a}${l}:${i}`;return this.internal.toISOString().slice(0,-1)+c}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[a,l,i,c]=this.internal.toUTCString().split(" ");return`${a?.slice(0,-1)} ${i} ${l} ${c}`}toTimeString(){const a=this.internal.toUTCString().split(" ")[4],[l,i,c]=this.tzComponents();return`${a} GMT${l}${i}${c} (${SD(this.timeZone,this)})`}toLocaleString(a,l){return Date.prototype.toLocaleString.call(this,a,{...l,timeZone:l?.timeZone||this.timeZone})}toLocaleDateString(a,l){return Date.prototype.toLocaleDateString.call(this,a,{...l,timeZone:l?.timeZone||this.timeZone})}toLocaleTimeString(a,l){return Date.prototype.toLocaleTimeString.call(this,a,{...l,timeZone:l?.timeZone||this.timeZone})}tzComponents(){const a=this.getTimezoneOffset(),l=a>0?"-":"+",i=String(Math.floor(Math.abs(a)/60)).padStart(2,"0"),c=String(Math.abs(a)%60).padStart(2,"0");return[l,i,c]}withTimeZone(a){return new Ns(+this,a)}[Symbol.for("constructDateFrom")](a){return new Ns(+new Date(a),this.timeZone)}}const MN=6048e5,TD=864e5,Gj=Symbol.for("constructDateFrom");function as(s,a){return typeof s=="function"?s(a):s&&typeof s=="object"&&Gj in s?s[Gj](a):s instanceof Date?new s.constructor(a):new Date(a)}function kt(s,a){return as(a||s,s)}function DN(s,a,l){const i=kt(s,l?.in);return isNaN(a)?as(s,NaN):(a&&i.setDate(i.getDate()+a),i)}function ON(s,a,l){const i=kt(s,l?.in);if(isNaN(a))return as(s,NaN);if(!a)return i;const c=i.getDate(),d=as(s,i.getTime());d.setMonth(i.getMonth()+a+1,0);const m=d.getDate();return c>=m?d:(i.setFullYear(d.getFullYear(),d.getMonth(),c),i)}let ED={};function To(){return ED}function Ka(s,a){const l=To(),i=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??l.weekStartsOn??l.locale?.options?.weekStartsOn??0,c=kt(s,a?.in),d=c.getDay(),m=(d=d.getTime()?i+1:l.getTime()>=h.getTime()?i:i-1}function $j(s){const a=kt(s),l=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()));return l.setUTCFullYear(a.getFullYear()),+s-+l}function Bl(s,...a){const l=as.bind(null,s||a.find(i=>typeof i=="object"));return a.map(l)}function uo(s,a){const l=kt(s,a?.in);return l.setHours(0,0,0,0),l}function RN(s,a,l){const[i,c]=Bl(l?.in,s,a),d=uo(i),m=uo(c),h=+d-$j(d),p=+m-$j(m);return Math.round((h-p)/TD)}function MD(s,a){const l=AN(s,a),i=as(s,0);return i.setFullYear(l,0,4),i.setHours(0,0,0,0),co(i)}function DD(s,a,l){return DN(s,a*7,l)}function OD(s,a,l){return ON(s,a*12,l)}function AD(s,a){let l,i=a?.in;return s.forEach(c=>{!i&&typeof c=="object"&&(i=as.bind(null,c));const d=kt(c,i);(!l||l{!i&&typeof c=="object"&&(i=as.bind(null,c));const d=kt(c,i);(!l||l>d||isNaN(+d))&&(l=d)}),as(i,l||NaN)}function zD(s,a,l){const[i,c]=Bl(l?.in,s,a);return+uo(i)==+uo(c)}function zN(s){return s instanceof Date||typeof s=="object"&&Object.prototype.toString.call(s)==="[object Date]"}function PD(s){return!(!zN(s)&&typeof s!="number"||isNaN(+kt(s)))}function LD(s,a,l){const[i,c]=Bl(l?.in,s,a),d=i.getFullYear()-c.getFullYear(),m=i.getMonth()-c.getMonth();return d*12+m}function BD(s,a){const l=kt(s,a?.in),i=l.getMonth();return l.setFullYear(l.getFullYear(),i+1,0),l.setHours(23,59,59,999),l}function PN(s,a){const[l,i]=Bl(s,a.start,a.end);return{start:l,end:i}}function UD(s,a){const{start:l,end:i}=PN(a?.in,s);let c=+l>+i;const d=c?+l:+i,m=c?i:l;m.setHours(0,0,0,0),m.setDate(1);let h=1;const p=[];for(;+m<=d;)p.push(as(l,m)),m.setMonth(m.getMonth()+h);return c?p.reverse():p}function HD(s,a){const l=kt(s,a?.in);return l.setDate(1),l.setHours(0,0,0,0),l}function FD(s,a){const l=kt(s,a?.in),i=l.getFullYear();return l.setFullYear(i+1,0,0),l.setHours(23,59,59,999),l}function LN(s,a){const l=kt(s,a?.in);return l.setFullYear(l.getFullYear(),0,1),l.setHours(0,0,0,0),l}function YD(s,a){const{start:l,end:i}=PN(a?.in,s);let c=+l>+i;const d=c?+l:+i,m=c?i:l;m.setHours(0,0,0,0),m.setMonth(0,1);let h=1;const p=[];for(;+m<=d;)p.push(as(l,m)),m.setFullYear(m.getFullYear()+h);return c?p.reverse():p}function BN(s,a){const l=To(),i=a?.weekStartsOn??a?.locale?.options?.weekStartsOn??l.weekStartsOn??l.locale?.options?.weekStartsOn??0,c=kt(s,a?.in),d=c.getDay(),m=(d{let i;const c=VD[s];return typeof c=="string"?i=c:a===1?i=c.one:i=c.other.replace("{{count}}",a.toString()),l?.addSuffix?l.comparison&&l.comparison>0?"in "+i:i+" ago":i};function Hr(s){return(a={})=>{const l=a.width?String(a.width):s.defaultWidth;return s.formats[l]||s.formats[s.defaultWidth]}}const $D={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ID={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},WD={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},XD={date:Hr({formats:$D,defaultWidth:"full"}),time:Hr({formats:ID,defaultWidth:"full"}),dateTime:Hr({formats:WD,defaultWidth:"full"})},KD={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},QD=(s,a,l,i)=>KD[s];function Hn(s){return(a,l)=>{const i=l?.context?String(l.context):"standalone";let c;if(i==="formatting"&&s.formattingValues){const m=s.defaultFormattingWidth||s.defaultWidth,h=l?.width?String(l.width):m;c=s.formattingValues[h]||s.formattingValues[m]}else{const m=s.defaultWidth,h=l?.width?String(l.width):s.defaultWidth;c=s.values[h]||s.values[m]}const d=s.argumentCallback?s.argumentCallback(a):a;return c[d]}}const ZD={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},JD={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},eO={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},tO={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},sO={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},nO={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},aO=(s,a)=>{const l=Number(s),i=l%100;if(i>20||i<10)switch(i%10){case 1:return l+"st";case 2:return l+"nd";case 3:return l+"rd"}return l+"th"},lO={ordinalNumber:aO,era:Hn({values:ZD,defaultWidth:"wide"}),quarter:Hn({values:JD,defaultWidth:"wide",argumentCallback:s=>s-1}),month:Hn({values:eO,defaultWidth:"wide"}),day:Hn({values:tO,defaultWidth:"wide"}),dayPeriod:Hn({values:sO,defaultWidth:"wide",formattingValues:nO,defaultFormattingWidth:"wide"})};function Fn(s){return(a,l={})=>{const i=l.width,c=i&&s.matchPatterns[i]||s.matchPatterns[s.defaultMatchWidth],d=a.match(c);if(!d)return null;const m=d[0],h=i&&s.parsePatterns[i]||s.parsePatterns[s.defaultParseWidth],p=Array.isArray(h)?iO(h,j=>j.test(m)):rO(h,j=>j.test(m));let v;v=s.valueCallback?s.valueCallback(p):p,v=l.valueCallback?l.valueCallback(v):v;const g=a.slice(m.length);return{value:v,rest:g}}}function rO(s,a){for(const l in s)if(Object.prototype.hasOwnProperty.call(s,l)&&a(s[l]))return l}function iO(s,a){for(let l=0;l{const i=a.match(s.matchPattern);if(!i)return null;const c=i[0],d=a.match(s.parsePattern);if(!d)return null;let m=s.valueCallback?s.valueCallback(d[0]):d[0];m=l.valueCallback?l.valueCallback(m):m;const h=a.slice(c.length);return{value:m,rest:h}}}const oO=/^(\d+)(th|st|nd|rd)?/i,cO=/\d+/i,dO={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},uO={any:[/^b/i,/^(a|c)/i]},mO={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},fO={any:[/1/i,/2/i,/3/i,/4/i]},hO={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},xO={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},pO={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},gO={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},vO={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},jO={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},yO={ordinalNumber:UN({matchPattern:oO,parsePattern:cO,valueCallback:s=>parseInt(s,10)}),era:Fn({matchPatterns:dO,defaultMatchWidth:"wide",parsePatterns:uO,defaultParseWidth:"any"}),quarter:Fn({matchPatterns:mO,defaultMatchWidth:"wide",parsePatterns:fO,defaultParseWidth:"any",valueCallback:s=>s+1}),month:Fn({matchPatterns:hO,defaultMatchWidth:"wide",parsePatterns:xO,defaultParseWidth:"any"}),day:Fn({matchPatterns:pO,defaultMatchWidth:"wide",parsePatterns:gO,defaultParseWidth:"any"}),dayPeriod:Fn({matchPatterns:vO,defaultMatchWidth:"any",parsePatterns:jO,defaultParseWidth:"any"})},Hh={code:"en-US",formatDistance:GD,formatLong:XD,formatRelative:QD,localize:lO,match:yO,options:{weekStartsOn:0,firstWeekContainsDate:1}};function bO(s,a){const l=kt(s,a?.in);return RN(l,LN(l))+1}function HN(s,a){const l=kt(s,a?.in),i=+co(l)-+MD(l);return Math.round(i/MN)+1}function FN(s,a){const l=kt(s,a?.in),i=l.getFullYear(),c=To(),d=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??c.firstWeekContainsDate??c.locale?.options?.firstWeekContainsDate??1,m=as(a?.in||s,0);m.setFullYear(i+1,0,d),m.setHours(0,0,0,0);const h=Ka(m,a),p=as(a?.in||s,0);p.setFullYear(i,0,d),p.setHours(0,0,0,0);const v=Ka(p,a);return+l>=+h?i+1:+l>=+v?i:i-1}function NO(s,a){const l=To(),i=a?.firstWeekContainsDate??a?.locale?.options?.firstWeekContainsDate??l.firstWeekContainsDate??l.locale?.options?.firstWeekContainsDate??1,c=FN(s,a),d=as(a?.in||s,0);return d.setFullYear(c,0,i),d.setHours(0,0,0,0),Ka(d,a)}function YN(s,a){const l=kt(s,a?.in),i=+Ka(l,a)-+NO(l,a);return Math.round(i/MN)+1}function yt(s,a){const l=s<0?"-":"",i=Math.abs(s).toString().padStart(a,"0");return l+i}const Va={y(s,a){const l=s.getFullYear(),i=l>0?l:1-l;return yt(a==="yy"?i%100:i,a.length)},M(s,a){const l=s.getMonth();return a==="M"?String(l+1):yt(l+1,2)},d(s,a){return yt(s.getDate(),a.length)},a(s,a){const l=s.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return l.toUpperCase();case"aaa":return l;case"aaaaa":return l[0];case"aaaa":default:return l==="am"?"a.m.":"p.m."}},h(s,a){return yt(s.getHours()%12||12,a.length)},H(s,a){return yt(s.getHours(),a.length)},m(s,a){return yt(s.getMinutes(),a.length)},s(s,a){return yt(s.getSeconds(),a.length)},S(s,a){const l=a.length,i=s.getMilliseconds(),c=Math.trunc(i*Math.pow(10,l-3));return yt(c,a.length)}},Mr={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Ij={G:function(s,a,l){const i=s.getFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return l.era(i,{width:"abbreviated"});case"GGGGG":return l.era(i,{width:"narrow"});case"GGGG":default:return l.era(i,{width:"wide"})}},y:function(s,a,l){if(a==="yo"){const i=s.getFullYear(),c=i>0?i:1-i;return l.ordinalNumber(c,{unit:"year"})}return Va.y(s,a)},Y:function(s,a,l,i){const c=FN(s,i),d=c>0?c:1-c;if(a==="YY"){const m=d%100;return yt(m,2)}return a==="Yo"?l.ordinalNumber(d,{unit:"year"}):yt(d,a.length)},R:function(s,a){const l=AN(s);return yt(l,a.length)},u:function(s,a){const l=s.getFullYear();return yt(l,a.length)},Q:function(s,a,l){const i=Math.ceil((s.getMonth()+1)/3);switch(a){case"Q":return String(i);case"QQ":return yt(i,2);case"Qo":return l.ordinalNumber(i,{unit:"quarter"});case"QQQ":return l.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return l.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return l.quarter(i,{width:"wide",context:"formatting"})}},q:function(s,a,l){const i=Math.ceil((s.getMonth()+1)/3);switch(a){case"q":return String(i);case"qq":return yt(i,2);case"qo":return l.ordinalNumber(i,{unit:"quarter"});case"qqq":return l.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return l.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return l.quarter(i,{width:"wide",context:"standalone"})}},M:function(s,a,l){const i=s.getMonth();switch(a){case"M":case"MM":return Va.M(s,a);case"Mo":return l.ordinalNumber(i+1,{unit:"month"});case"MMM":return l.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return l.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return l.month(i,{width:"wide",context:"formatting"})}},L:function(s,a,l){const i=s.getMonth();switch(a){case"L":return String(i+1);case"LL":return yt(i+1,2);case"Lo":return l.ordinalNumber(i+1,{unit:"month"});case"LLL":return l.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return l.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return l.month(i,{width:"wide",context:"standalone"})}},w:function(s,a,l,i){const c=YN(s,i);return a==="wo"?l.ordinalNumber(c,{unit:"week"}):yt(c,a.length)},I:function(s,a,l){const i=HN(s);return a==="Io"?l.ordinalNumber(i,{unit:"week"}):yt(i,a.length)},d:function(s,a,l){return a==="do"?l.ordinalNumber(s.getDate(),{unit:"date"}):Va.d(s,a)},D:function(s,a,l){const i=bO(s);return a==="Do"?l.ordinalNumber(i,{unit:"dayOfYear"}):yt(i,a.length)},E:function(s,a,l){const i=s.getDay();switch(a){case"E":case"EE":case"EEE":return l.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return l.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return l.day(i,{width:"short",context:"formatting"});case"EEEE":default:return l.day(i,{width:"wide",context:"formatting"})}},e:function(s,a,l,i){const c=s.getDay(),d=(c-i.weekStartsOn+8)%7||7;switch(a){case"e":return String(d);case"ee":return yt(d,2);case"eo":return l.ordinalNumber(d,{unit:"day"});case"eee":return l.day(c,{width:"abbreviated",context:"formatting"});case"eeeee":return l.day(c,{width:"narrow",context:"formatting"});case"eeeeee":return l.day(c,{width:"short",context:"formatting"});case"eeee":default:return l.day(c,{width:"wide",context:"formatting"})}},c:function(s,a,l,i){const c=s.getDay(),d=(c-i.weekStartsOn+8)%7||7;switch(a){case"c":return String(d);case"cc":return yt(d,a.length);case"co":return l.ordinalNumber(d,{unit:"day"});case"ccc":return l.day(c,{width:"abbreviated",context:"standalone"});case"ccccc":return l.day(c,{width:"narrow",context:"standalone"});case"cccccc":return l.day(c,{width:"short",context:"standalone"});case"cccc":default:return l.day(c,{width:"wide",context:"standalone"})}},i:function(s,a,l){const i=s.getDay(),c=i===0?7:i;switch(a){case"i":return String(c);case"ii":return yt(c,a.length);case"io":return l.ordinalNumber(c,{unit:"day"});case"iii":return l.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return l.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return l.day(i,{width:"short",context:"formatting"});case"iiii":default:return l.day(i,{width:"wide",context:"formatting"})}},a:function(s,a,l){const c=s.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return l.dayPeriod(c,{width:"abbreviated",context:"formatting"});case"aaa":return l.dayPeriod(c,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return l.dayPeriod(c,{width:"narrow",context:"formatting"});case"aaaa":default:return l.dayPeriod(c,{width:"wide",context:"formatting"})}},b:function(s,a,l){const i=s.getHours();let c;switch(i===12?c=Mr.noon:i===0?c=Mr.midnight:c=i/12>=1?"pm":"am",a){case"b":case"bb":return l.dayPeriod(c,{width:"abbreviated",context:"formatting"});case"bbb":return l.dayPeriod(c,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return l.dayPeriod(c,{width:"narrow",context:"formatting"});case"bbbb":default:return l.dayPeriod(c,{width:"wide",context:"formatting"})}},B:function(s,a,l){const i=s.getHours();let c;switch(i>=17?c=Mr.evening:i>=12?c=Mr.afternoon:i>=4?c=Mr.morning:c=Mr.night,a){case"B":case"BB":case"BBB":return l.dayPeriod(c,{width:"abbreviated",context:"formatting"});case"BBBBB":return l.dayPeriod(c,{width:"narrow",context:"formatting"});case"BBBB":default:return l.dayPeriod(c,{width:"wide",context:"formatting"})}},h:function(s,a,l){if(a==="ho"){let i=s.getHours()%12;return i===0&&(i=12),l.ordinalNumber(i,{unit:"hour"})}return Va.h(s,a)},H:function(s,a,l){return a==="Ho"?l.ordinalNumber(s.getHours(),{unit:"hour"}):Va.H(s,a)},K:function(s,a,l){const i=s.getHours()%12;return a==="Ko"?l.ordinalNumber(i,{unit:"hour"}):yt(i,a.length)},k:function(s,a,l){let i=s.getHours();return i===0&&(i=24),a==="ko"?l.ordinalNumber(i,{unit:"hour"}):yt(i,a.length)},m:function(s,a,l){return a==="mo"?l.ordinalNumber(s.getMinutes(),{unit:"minute"}):Va.m(s,a)},s:function(s,a,l){return a==="so"?l.ordinalNumber(s.getSeconds(),{unit:"second"}):Va.s(s,a)},S:function(s,a){return Va.S(s,a)},X:function(s,a,l){const i=s.getTimezoneOffset();if(i===0)return"Z";switch(a){case"X":return Xj(i);case"XXXX":case"XX":return Nl(i);case"XXXXX":case"XXX":default:return Nl(i,":")}},x:function(s,a,l){const i=s.getTimezoneOffset();switch(a){case"x":return Xj(i);case"xxxx":case"xx":return Nl(i);case"xxxxx":case"xxx":default:return Nl(i,":")}},O:function(s,a,l){const i=s.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Wj(i,":");case"OOOO":default:return"GMT"+Nl(i,":")}},z:function(s,a,l){const i=s.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Wj(i,":");case"zzzz":default:return"GMT"+Nl(i,":")}},t:function(s,a,l){const i=Math.trunc(+s/1e3);return yt(i,a.length)},T:function(s,a,l){return yt(+s,a.length)}};function Wj(s,a=""){const l=s>0?"-":"+",i=Math.abs(s),c=Math.trunc(i/60),d=i%60;return d===0?l+String(c):l+String(c)+a+yt(d,2)}function Xj(s,a){return s%60===0?(s>0?"-":"+")+yt(Math.abs(s)/60,2):Nl(s,a)}function Nl(s,a=""){const l=s>0?"-":"+",i=Math.abs(s),c=yt(Math.trunc(i/60),2),d=yt(i%60,2);return l+c+a+d}const Kj=(s,a)=>{switch(s){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});case"PPPP":default:return a.date({width:"full"})}},qN=(s,a)=>{switch(s){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});case"pppp":default:return a.time({width:"full"})}},wO=(s,a)=>{const l=s.match(/(P+)(p+)?/)||[],i=l[1],c=l[2];if(!c)return Kj(s,a);let d;switch(i){case"P":d=a.dateTime({width:"short"});break;case"PP":d=a.dateTime({width:"medium"});break;case"PPP":d=a.dateTime({width:"long"});break;case"PPPP":default:d=a.dateTime({width:"full"});break}return d.replace("{{date}}",Kj(i,a)).replace("{{time}}",qN(c,a))},SO={p:qN,P:wO},_O=/^D+$/,CO=/^Y+$/,kO=["D","DD","YY","YYYY"];function TO(s){return _O.test(s)}function EO(s){return CO.test(s)}function MO(s,a,l){const i=DO(s,a,l);if(console.warn(i),kO.includes(s))throw new RangeError(i)}function DO(s,a,l){const i=s[0]==="Y"?"years":"days of the month";return`Use \`${s.toLowerCase()}\` instead of \`${s}\` (in \`${a}\`) for formatting ${i} to the input \`${l}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const OO=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,AO=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,RO=/^'([^]*?)'?$/,zO=/''/g,PO=/[a-zA-Z]/;function md(s,a,l){const i=To(),c=l?.locale??i.locale??Hh,d=l?.firstWeekContainsDate??l?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,m=l?.weekStartsOn??l?.locale?.options?.weekStartsOn??i.weekStartsOn??i.locale?.options?.weekStartsOn??0,h=kt(s,l?.in);if(!PD(h))throw new RangeError("Invalid time value");let p=a.match(AO).map(g=>{const j=g[0];if(j==="p"||j==="P"){const b=SO[j];return b(g,c.formatLong)}return g}).join("").match(OO).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const j=g[0];if(j==="'")return{isToken:!1,value:LO(g)};if(Ij[j])return{isToken:!0,value:g};if(j.match(PO))throw new RangeError("Format string contains an unescaped latin alphabet character `"+j+"`");return{isToken:!1,value:g}});c.localize.preprocessor&&(p=c.localize.preprocessor(h,p));const v={firstWeekContainsDate:d,weekStartsOn:m,locale:c};return p.map(g=>{if(!g.isToken)return g.value;const j=g.value;(!l?.useAdditionalWeekYearTokens&&EO(j)||!l?.useAdditionalDayOfYearTokens&&TO(j))&&MO(j,a,String(s));const b=Ij[j[0]];return b(h,j,c.localize,v)}).join("")}function LO(s){const a=s.match(RO);return a?a[1].replace(zO,"'"):s}function BO(s,a){const l=kt(s,a?.in),i=l.getFullYear(),c=l.getMonth(),d=as(l,0);return d.setFullYear(i,c+1,0),d.setHours(0,0,0,0),d.getDate()}function UO(s,a){return kt(s,a?.in).getMonth()}function HO(s,a){return kt(s,a?.in).getFullYear()}function FO(s,a){return+kt(s)>+kt(a)}function YO(s,a){return+kt(s)<+kt(a)}function qO(s,a,l){const[i,c]=Bl(l?.in,s,a);return+Ka(i,l)==+Ka(c,l)}function VO(s,a,l){const[i,c]=Bl(l?.in,s,a);return i.getFullYear()===c.getFullYear()&&i.getMonth()===c.getMonth()}function GO(s,a,l){const[i,c]=Bl(l?.in,s,a);return i.getFullYear()===c.getFullYear()}function $O(s,a,l){const i=kt(s,l?.in),c=i.getFullYear(),d=i.getDate(),m=as(s,0);m.setFullYear(c,a,15),m.setHours(0,0,0,0);const h=BO(m);return i.setMonth(a,Math.min(d,h)),i}function IO(s,a,l){const i=kt(s,l?.in);return isNaN(+i)?as(s,NaN):(i.setFullYear(a),i)}const Qj=5,WO=4;function XO(s,a){const l=a.startOfMonth(s),i=l.getDay()>0?l.getDay():7,c=a.addDays(s,-i+1),d=a.addDays(c,Qj*7-1);return a.getMonth(s)===a.getMonth(d)?Qj:WO}function VN(s,a){const l=a.startOfMonth(s),i=l.getDay();return i===1?l:i===0?a.addDays(l,-6):a.addDays(l,-1*(i-1))}function KO(s,a){const l=VN(s,a),i=XO(s,a);return a.addDays(l,i*7-1)}class nn{constructor(a,l){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?Ns.tz(this.options.timeZone):new this.Date,this.newDate=(i,c,d)=>this.overrides?.newDate?this.overrides.newDate(i,c,d):this.options.timeZone?new Ns(i,c,d,this.options.timeZone):new Date(i,c,d),this.addDays=(i,c)=>this.overrides?.addDays?this.overrides.addDays(i,c):DN(i,c),this.addMonths=(i,c)=>this.overrides?.addMonths?this.overrides.addMonths(i,c):ON(i,c),this.addWeeks=(i,c)=>this.overrides?.addWeeks?this.overrides.addWeeks(i,c):DD(i,c),this.addYears=(i,c)=>this.overrides?.addYears?this.overrides.addYears(i,c):OD(i,c),this.differenceInCalendarDays=(i,c)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(i,c):RN(i,c),this.differenceInCalendarMonths=(i,c)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(i,c):LD(i,c),this.eachMonthOfInterval=i=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(i):UD(i),this.eachYearOfInterval=i=>{const c=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(i):YD(i),d=new Set(c.map(h=>this.getYear(h)));if(d.size===c.length)return c;const m=[];return d.forEach(h=>{m.push(new Date(h,0,1))}),m},this.endOfBroadcastWeek=i=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(i):KO(i,this),this.endOfISOWeek=i=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(i):qD(i),this.endOfMonth=i=>this.overrides?.endOfMonth?this.overrides.endOfMonth(i):BD(i),this.endOfWeek=(i,c)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(i,c):BN(i,this.options),this.endOfYear=i=>this.overrides?.endOfYear?this.overrides.endOfYear(i):FD(i),this.format=(i,c,d)=>{const m=this.overrides?.format?this.overrides.format(i,c,this.options):md(i,c,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(m):m},this.getISOWeek=i=>this.overrides?.getISOWeek?this.overrides.getISOWeek(i):HN(i),this.getMonth=(i,c)=>this.overrides?.getMonth?this.overrides.getMonth(i,this.options):UO(i,this.options),this.getYear=(i,c)=>this.overrides?.getYear?this.overrides.getYear(i,this.options):HO(i,this.options),this.getWeek=(i,c)=>this.overrides?.getWeek?this.overrides.getWeek(i,this.options):YN(i,this.options),this.isAfter=(i,c)=>this.overrides?.isAfter?this.overrides.isAfter(i,c):FO(i,c),this.isBefore=(i,c)=>this.overrides?.isBefore?this.overrides.isBefore(i,c):YO(i,c),this.isDate=i=>this.overrides?.isDate?this.overrides.isDate(i):zN(i),this.isSameDay=(i,c)=>this.overrides?.isSameDay?this.overrides.isSameDay(i,c):zD(i,c),this.isSameMonth=(i,c)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(i,c):VO(i,c),this.isSameYear=(i,c)=>this.overrides?.isSameYear?this.overrides.isSameYear(i,c):GO(i,c),this.max=i=>this.overrides?.max?this.overrides.max(i):AD(i),this.min=i=>this.overrides?.min?this.overrides.min(i):RD(i),this.setMonth=(i,c)=>this.overrides?.setMonth?this.overrides.setMonth(i,c):$O(i,c),this.setYear=(i,c)=>this.overrides?.setYear?this.overrides.setYear(i,c):IO(i,c),this.startOfBroadcastWeek=(i,c)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(i,this):VN(i,this),this.startOfDay=i=>this.overrides?.startOfDay?this.overrides.startOfDay(i):uo(i),this.startOfISOWeek=i=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(i):co(i),this.startOfMonth=i=>this.overrides?.startOfMonth?this.overrides.startOfMonth(i):HD(i),this.startOfWeek=(i,c)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(i,this.options):Ka(i,this.options),this.startOfYear=i=>this.overrides?.startOfYear?this.overrides.startOfYear(i):LN(i),this.options={locale:Hh,...a},this.overrides=l}getDigitMap(){const{numerals:a="latn"}=this.options,l=new Intl.NumberFormat("en-US",{numberingSystem:a}),i={};for(let c=0;c<10;c++)i[c.toString()]=l.format(c);return i}replaceDigits(a){const l=this.getDigitMap();return a.replace(/\d/g,i=>l[i]||i)}formatNumber(a){return this.replaceDigits(a.toString())}getMonthYearOrder(){const a=this.options.locale?.code;return a&&nn.yearFirstLocales.has(a)?"year-first":"month-first"}formatMonthYear(a){const{locale:l,timeZone:i,numerals:c}=this.options,d=l?.code;if(d&&nn.yearFirstLocales.has(d))try{return new Intl.DateTimeFormat(d,{month:"long",year:"numeric",timeZone:i,numberingSystem:c}).format(a)}catch{}const m=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(a,m)}}nn.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Gn=new nn;class GN{constructor(a,l,i=Gn){this.date=a,this.displayMonth=l,this.outside=!!(l&&!i.isSameMonth(a,l)),this.dateLib=i}isEqualTo(a){return this.dateLib.isSameDay(a.date,this.date)&&this.dateLib.isSameMonth(a.displayMonth,this.displayMonth)}}class QO{constructor(a,l){this.date=a,this.weeks=l}}class ZO{constructor(a,l){this.days=l,this.weekNumber=a}}function JO(s){return Ne.createElement("button",{...s})}function eA(s){return Ne.createElement("span",{...s})}function tA(s){const{size:a=24,orientation:l="left",className:i}=s;return Ne.createElement("svg",{className:i,width:a,height:a,viewBox:"0 0 24 24"},l==="up"&&Ne.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),l==="down"&&Ne.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),l==="left"&&Ne.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),l==="right"&&Ne.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function sA(s){const{day:a,modifiers:l,...i}=s;return Ne.createElement("td",{...i})}function nA(s){const{day:a,modifiers:l,...i}=s,c=Ne.useRef(null);return Ne.useEffect(()=>{l.focused&&c.current?.focus()},[l.focused]),Ne.createElement("button",{ref:c,...i})}var Me;(function(s){s.Root="root",s.Chevron="chevron",s.Day="day",s.DayButton="day_button",s.CaptionLabel="caption_label",s.Dropdowns="dropdowns",s.Dropdown="dropdown",s.DropdownRoot="dropdown_root",s.Footer="footer",s.MonthGrid="month_grid",s.MonthCaption="month_caption",s.MonthsDropdown="months_dropdown",s.Month="month",s.Months="months",s.Nav="nav",s.NextMonthButton="button_next",s.PreviousMonthButton="button_previous",s.Week="week",s.Weeks="weeks",s.Weekday="weekday",s.Weekdays="weekdays",s.WeekNumber="week_number",s.WeekNumberHeader="week_number_header",s.YearsDropdown="years_dropdown"})(Me||(Me={}));var Gt;(function(s){s.disabled="disabled",s.hidden="hidden",s.outside="outside",s.focused="focused",s.today="today"})(Gt||(Gt={}));var En;(function(s){s.range_end="range_end",s.range_middle="range_middle",s.range_start="range_start",s.selected="selected"})(En||(En={}));var sn;(function(s){s.weeks_before_enter="weeks_before_enter",s.weeks_before_exit="weeks_before_exit",s.weeks_after_enter="weeks_after_enter",s.weeks_after_exit="weeks_after_exit",s.caption_after_enter="caption_after_enter",s.caption_after_exit="caption_after_exit",s.caption_before_enter="caption_before_enter",s.caption_before_exit="caption_before_exit"})(sn||(sn={}));function aA(s){const{options:a,className:l,components:i,classNames:c,...d}=s,m=[c[Me.Dropdown],l].join(" "),h=a?.find(({value:p})=>p===d.value);return Ne.createElement("span",{"data-disabled":d.disabled,className:c[Me.DropdownRoot]},Ne.createElement(i.Select,{className:m,...d},a?.map(({value:p,label:v,disabled:g})=>Ne.createElement(i.Option,{key:p,value:p,disabled:g},v))),Ne.createElement("span",{className:c[Me.CaptionLabel],"aria-hidden":!0},h?.label,Ne.createElement(i.Chevron,{orientation:"down",size:18,className:c[Me.Chevron]})))}function lA(s){return Ne.createElement("div",{...s})}function rA(s){return Ne.createElement("div",{...s})}function iA(s){const{calendarMonth:a,displayIndex:l,...i}=s;return Ne.createElement("div",{...i},s.children)}function oA(s){const{calendarMonth:a,displayIndex:l,...i}=s;return Ne.createElement("div",{...i})}function cA(s){return Ne.createElement("table",{...s})}function dA(s){return Ne.createElement("div",{...s})}const $N=x.createContext(void 0);function Eo(){const s=x.useContext($N);if(s===void 0)throw new Error("useDayPicker() must be used within a custom component.");return s}function uA(s){const{components:a}=Eo();return Ne.createElement(a.Dropdown,{...s})}function mA(s){const{onPreviousClick:a,onNextClick:l,previousMonth:i,nextMonth:c,...d}=s,{components:m,classNames:h,labels:{labelPrevious:p,labelNext:v}}=Eo(),g=x.useCallback(b=>{c&&l?.(b)},[c,l]),j=x.useCallback(b=>{i&&a?.(b)},[i,a]);return Ne.createElement("nav",{...d},Ne.createElement(m.PreviousMonthButton,{type:"button",className:h[Me.PreviousMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":p(i),onClick:j},Ne.createElement(m.Chevron,{disabled:i?void 0:!0,className:h[Me.Chevron],orientation:"left"})),Ne.createElement(m.NextMonthButton,{type:"button",className:h[Me.NextMonthButton],tabIndex:c?void 0:-1,"aria-disabled":c?void 0:!0,"aria-label":v(c),onClick:g},Ne.createElement(m.Chevron,{disabled:c?void 0:!0,orientation:"right",className:h[Me.Chevron]})))}function fA(s){const{components:a}=Eo();return Ne.createElement(a.Button,{...s})}function hA(s){return Ne.createElement("option",{...s})}function xA(s){const{components:a}=Eo();return Ne.createElement(a.Button,{...s})}function pA(s){const{rootRef:a,...l}=s;return Ne.createElement("div",{...l,ref:a})}function gA(s){return Ne.createElement("select",{...s})}function vA(s){const{week:a,...l}=s;return Ne.createElement("tr",{...l})}function jA(s){return Ne.createElement("th",{...s})}function yA(s){return Ne.createElement("thead",{"aria-hidden":!0},Ne.createElement("tr",{...s}))}function bA(s){const{week:a,...l}=s;return Ne.createElement("th",{...l})}function NA(s){return Ne.createElement("th",{...s})}function wA(s){return Ne.createElement("tbody",{...s})}function SA(s){const{components:a}=Eo();return Ne.createElement(a.Dropdown,{...s})}const _A=Object.freeze(Object.defineProperty({__proto__:null,Button:JO,CaptionLabel:eA,Chevron:tA,Day:sA,DayButton:nA,Dropdown:aA,DropdownNav:lA,Footer:rA,Month:iA,MonthCaption:oA,MonthGrid:cA,Months:dA,MonthsDropdown:uA,Nav:mA,NextMonthButton:fA,Option:hA,PreviousMonthButton:xA,Root:pA,Select:gA,Week:vA,WeekNumber:bA,WeekNumberHeader:NA,Weekday:jA,Weekdays:yA,Weeks:wA,YearsDropdown:SA},Symbol.toStringTag,{value:"Module"}));function fa(s,a,l=!1,i=Gn){let{from:c,to:d}=s;const{differenceInCalendarDays:m,isSameDay:h}=i;return c&&d?(m(d,c)<0&&([c,d]=[d,c]),m(a,c)>=(l?1:0)&&m(d,a)>=(l?1:0)):!l&&d?h(d,a):!l&&c?h(c,a):!1}function IN(s){return!!(s&&typeof s=="object"&&"before"in s&&"after"in s)}function Fh(s){return!!(s&&typeof s=="object"&&"from"in s)}function WN(s){return!!(s&&typeof s=="object"&&"after"in s)}function XN(s){return!!(s&&typeof s=="object"&&"before"in s)}function KN(s){return!!(s&&typeof s=="object"&&"dayOfWeek"in s)}function QN(s,a){return Array.isArray(s)&&s.every(a.isDate)}function ha(s,a,l=Gn){const i=Array.isArray(a)?a:[a],{isSameDay:c,differenceInCalendarDays:d,isAfter:m}=l;return i.some(h=>{if(typeof h=="boolean")return h;if(l.isDate(h))return c(s,h);if(QN(h,l))return h.includes(s);if(Fh(h))return fa(h,s,!1,l);if(KN(h))return Array.isArray(h.dayOfWeek)?h.dayOfWeek.includes(s.getDay()):h.dayOfWeek===s.getDay();if(IN(h)){const p=d(h.before,s),v=d(h.after,s),g=p>0,j=v<0;return m(h.before,h.after)?j&&g:g||j}return WN(h)?d(s,h.after)>0:XN(h)?d(h.before,s)>0:typeof h=="function"?h(s):!1})}function CA(s,a,l,i,c){const{disabled:d,hidden:m,modifiers:h,showOutsideDays:p,broadcastCalendar:v,today:g}=a,{isSameDay:j,isSameMonth:b,startOfMonth:w,isBefore:S,endOfMonth:C,isAfter:N}=c,T=l&&w(l),P=i&&C(i),M={[Gt.focused]:[],[Gt.outside]:[],[Gt.disabled]:[],[Gt.hidden]:[],[Gt.today]:[]},k={};for(const D of s){const{date:A,displayMonth:E}=D,B=!!(E&&!b(A,E)),Y=!!(T&&S(A,T)),G=!!(P&&N(A,P)),$=!!(d&&ha(A,d,c)),oe=!!(m&&ha(A,m,c))||Y||G||!v&&!p&&B||v&&p===!1&&B,je=j(A,g??c.today());B&&M.outside.push(D),$&&M.disabled.push(D),oe&&M.hidden.push(D),je&&M.today.push(D),h&&Object.keys(h).forEach(ae=>{const me=h?.[ae];me&&ha(A,me,c)&&(k[ae]?k[ae].push(D):k[ae]=[D])})}return D=>{const A={[Gt.focused]:!1,[Gt.disabled]:!1,[Gt.hidden]:!1,[Gt.outside]:!1,[Gt.today]:!1},E={};for(const B in M){const Y=M[B];A[B]=Y.some(G=>G===D)}for(const B in k)E[B]=k[B].some(Y=>Y===D);return{...A,...E}}}function kA(s,a,l={}){return Object.entries(s).filter(([,c])=>c===!0).reduce((c,[d])=>(l[d]?c.push(l[d]):a[Gt[d]]?c.push(a[Gt[d]]):a[En[d]]&&c.push(a[En[d]]),c),[a[Me.Day]])}function TA(s){return{..._A,...s}}function EA(s){const a={"data-mode":s.mode??void 0,"data-required":"required"in s?s.required:void 0,"data-multiple-months":s.numberOfMonths&&s.numberOfMonths>1||void 0,"data-week-numbers":s.showWeekNumber||void 0,"data-broadcast-calendar":s.broadcastCalendar||void 0,"data-nav-layout":s.navLayout||void 0};return Object.entries(s).forEach(([l,i])=>{l.startsWith("data-")&&(a[l]=i)}),a}function Yh(){const s={};for(const a in Me)s[Me[a]]=`rdp-${Me[a]}`;for(const a in Gt)s[Gt[a]]=`rdp-${Gt[a]}`;for(const a in En)s[En[a]]=`rdp-${En[a]}`;for(const a in sn)s[sn[a]]=`rdp-${sn[a]}`;return s}function ZN(s,a,l){return(l??new nn(a)).formatMonthYear(s)}const MA=ZN;function DA(s,a,l){return(l??new nn(a)).format(s,"d")}function OA(s,a=Gn){return a.format(s,"LLLL")}function AA(s,a,l){return(l??new nn(a)).format(s,"cccccc")}function RA(s,a=Gn){return s<10?a.formatNumber(`0${s.toLocaleString()}`):a.formatNumber(`${s.toLocaleString()}`)}function zA(){return""}function JN(s,a=Gn){return a.format(s,"yyyy")}const PA=JN,LA=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:ZN,formatDay:DA,formatMonthCaption:MA,formatMonthDropdown:OA,formatWeekNumber:RA,formatWeekNumberHeader:zA,formatWeekdayName:AA,formatYearCaption:PA,formatYearDropdown:JN},Symbol.toStringTag,{value:"Module"}));function BA(s){return s?.formatMonthCaption&&!s.formatCaption&&(s.formatCaption=s.formatMonthCaption),s?.formatYearCaption&&!s.formatYearDropdown&&(s.formatYearDropdown=s.formatYearCaption),{...LA,...s}}function UA(s,a,l,i,c){const{startOfMonth:d,startOfYear:m,endOfYear:h,eachMonthOfInterval:p,getMonth:v}=c;return p({start:m(s),end:h(s)}).map(b=>{const w=i.formatMonthDropdown(b,c),S=v(b),C=a&&bd(l)||!1;return{value:S,label:w,disabled:C}})}function HA(s,a={},l={}){let i={...a?.[Me.Day]};return Object.entries(s).filter(([,c])=>c===!0).forEach(([c])=>{i={...i,...l?.[c]}}),i}function FA(s,a,l){const i=s.today(),c=a?s.startOfISOWeek(i):s.startOfWeek(i),d=[];for(let m=0;m<7;m++){const h=s.addDays(c,m);d.push(h)}return d}function YA(s,a,l,i,c=!1){if(!s||!a)return;const{startOfYear:d,endOfYear:m,eachYearOfInterval:h,getYear:p}=i,v=d(s),g=m(a),j=h({start:v,end:g});return c&&j.reverse(),j.map(b=>{const w=l.formatYearDropdown(b,i);return{value:p(b),label:w,disabled:!1}})}function ew(s,a,l,i){let c=(i??new nn(l)).format(s,"PPPP");return a.today&&(c=`Today, ${c}`),a.selected&&(c=`${c}, selected`),c}const qA=ew;function tw(s,a,l){return(l??new nn(a)).formatMonthYear(s)}const VA=tw;function GA(s,a,l,i){let c=(i??new nn(l)).format(s,"PPPP");return a?.today&&(c=`Today, ${c}`),c}function $A(s){return"Choose the Month"}function IA(){return""}function WA(s){return"Go to the Next Month"}function XA(s){return"Go to the Previous Month"}function KA(s,a,l){return(l??new nn(a)).format(s,"cccc")}function QA(s,a){return`Week ${s}`}function ZA(s){return"Week Number"}function JA(s){return"Choose the Year"}const eR=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:VA,labelDay:qA,labelDayButton:ew,labelGrid:tw,labelGridcell:GA,labelMonthDropdown:$A,labelNav:IA,labelNext:WA,labelPrevious:XA,labelWeekNumber:QA,labelWeekNumberHeader:ZA,labelWeekday:KA,labelYearDropdown:JA},Symbol.toStringTag,{value:"Module"})),Mo=s=>s instanceof HTMLElement?s:null,kf=s=>[...s.querySelectorAll("[data-animated-month]")??[]],tR=s=>Mo(s.querySelector("[data-animated-month]")),Tf=s=>Mo(s.querySelector("[data-animated-caption]")),Ef=s=>Mo(s.querySelector("[data-animated-weeks]")),sR=s=>Mo(s.querySelector("[data-animated-nav]")),nR=s=>Mo(s.querySelector("[data-animated-weekdays]"));function aR(s,a,{classNames:l,months:i,focused:c,dateLib:d}){const m=x.useRef(null),h=x.useRef(i),p=x.useRef(!1);x.useLayoutEffect(()=>{const v=h.current;if(h.current=i,!a||!s.current||!(s.current instanceof HTMLElement)||i.length===0||v.length===0||i.length!==v.length)return;const g=d.isSameMonth(i[0].date,v[0].date),j=d.isAfter(i[0].date,v[0].date),b=j?l[sn.caption_after_enter]:l[sn.caption_before_enter],w=j?l[sn.weeks_after_enter]:l[sn.weeks_before_enter],S=m.current,C=s.current.cloneNode(!0);if(C instanceof HTMLElement?(kf(C).forEach(M=>{if(!(M instanceof HTMLElement))return;const k=tR(M);k&&M.contains(k)&&M.removeChild(k);const D=Tf(M);D&&D.classList.remove(b);const A=Ef(M);A&&A.classList.remove(w)}),m.current=C):m.current=null,p.current||g||c)return;const N=S instanceof HTMLElement?kf(S):[],T=kf(s.current);if(T?.every(P=>P instanceof HTMLElement)&&N&&N.every(P=>P instanceof HTMLElement)){p.current=!0,s.current.style.isolation="isolate";const P=sR(s.current);P&&(P.style.zIndex="1"),T.forEach((M,k)=>{const D=N[k];if(!D)return;M.style.position="relative",M.style.overflow="hidden";const A=Tf(M);A&&A.classList.add(b);const E=Ef(M);E&&E.classList.add(w);const B=()=>{p.current=!1,s.current&&(s.current.style.isolation=""),P&&(P.style.zIndex=""),A&&A.classList.remove(b),E&&E.classList.remove(w),M.style.position="",M.style.overflow="",M.contains(D)&&M.removeChild(D)};D.style.pointerEvents="none",D.style.position="absolute",D.style.overflow="hidden",D.setAttribute("aria-hidden","true");const Y=nR(D);Y&&(Y.style.opacity="0");const G=Tf(D);G&&(G.classList.add(j?l[sn.caption_before_exit]:l[sn.caption_after_exit]),G.addEventListener("animationend",B));const $=Ef(D);$&&$.classList.add(j?l[sn.weeks_before_exit]:l[sn.weeks_after_exit]),M.insertBefore(D,M.firstChild)})}})}function lR(s,a,l,i){const c=s[0],d=s[s.length-1],{ISOWeek:m,fixedWeeks:h,broadcastCalendar:p}=l??{},{addDays:v,differenceInCalendarDays:g,differenceInCalendarMonths:j,endOfBroadcastWeek:b,endOfISOWeek:w,endOfMonth:S,endOfWeek:C,isAfter:N,startOfBroadcastWeek:T,startOfISOWeek:P,startOfWeek:M}=i,k=p?T(c,i):m?P(c):M(c),D=p?b(d):m?w(S(d)):C(S(d)),A=g(D,k),E=j(d,c)+1,B=[];for(let $=0;$<=A;$++){const oe=v(k,$);if(a&&N(oe,a))break;B.push(oe)}const G=(p?35:42)*E;if(h&&B.length{const c=i.weeks.reduce((d,m)=>d.concat(m.days.slice()),a.slice());return l.concat(c.slice())},a.slice())}function iR(s,a,l,i){const{numberOfMonths:c=1}=l,d=[];for(let m=0;ma)break;d.push(h)}return d}function Zj(s,a,l,i){const{month:c,defaultMonth:d,today:m=i.today(),numberOfMonths:h=1}=s;let p=c||d||m;const{differenceInCalendarMonths:v,addMonths:g,startOfMonth:j}=i;if(l&&v(l,p){const T=l.broadcastCalendar?j(N,i):l.ISOWeek?b(N):w(N),P=l.broadcastCalendar?d(N):l.ISOWeek?m(h(N)):p(h(N)),M=a.filter(E=>E>=T&&E<=P),k=l.broadcastCalendar?35:42;if(l.fixedWeeks&&M.length{const Y=k-M.length;return B>P&&B<=c(P,Y)});M.push(...E)}const D=M.reduce((E,B)=>{const Y=l.ISOWeek?v(B):g(B),G=E.find(oe=>oe.weekNumber===Y),$=new GN(B,N,i);return G?G.days.push($):E.push(new ZO(Y,[$])),E},[]),A=new QO(N,D);return C.push(A),C},[]);return l.reverseMonths?S.reverse():S}function cR(s,a){let{startMonth:l,endMonth:i}=s;const{startOfYear:c,startOfDay:d,startOfMonth:m,endOfMonth:h,addYears:p,endOfYear:v,newDate:g,today:j}=a,{fromYear:b,toYear:w,fromMonth:S,toMonth:C}=s;!l&&S&&(l=S),!l&&b&&(l=a.newDate(b,0,1)),!i&&C&&(i=C),!i&&w&&(i=g(w,11,31));const N=s.captionLayout==="dropdown"||s.captionLayout==="dropdown-years";return l?l=m(l):b?l=g(b,0,1):!l&&N&&(l=c(p(s.today??j(),-100))),i?i=h(i):w?i=g(w,11,31):!i&&N&&(i=v(s.today??j())),[l&&d(l),i&&d(i)]}function dR(s,a,l,i){if(l.disableNavigation)return;const{pagedNavigation:c,numberOfMonths:d=1}=l,{startOfMonth:m,addMonths:h,differenceInCalendarMonths:p}=i,v=c?d:1,g=m(s);if(!a)return h(g,v);if(!(p(a,s)l.concat(i.weeks.slice()),a.slice())}function Id(s,a){const[l,i]=x.useState(s);return[a===void 0?l:a,i]}function fR(s,a){const[l,i]=cR(s,a),{startOfMonth:c,endOfMonth:d}=a,m=Zj(s,l,i,a),[h,p]=Id(m,s.month?m:void 0);x.useEffect(()=>{const A=Zj(s,l,i,a);p(A)},[s.timeZone]);const v=iR(h,i,s,a),g=lR(v,s.endMonth?d(s.endMonth):void 0,s,a),j=oR(v,g,s,a),b=mR(j),w=rR(j),S=uR(h,l,s,a),C=dR(h,i,s,a),{disableNavigation:N,onMonthChange:T}=s,P=A=>b.some(E=>E.days.some(B=>B.isEqualTo(A))),M=A=>{if(N)return;let E=c(A);l&&Ec(i)&&(E=c(i)),p(E),T?.(E)};return{months:j,weeks:b,days:w,navStart:l,navEnd:i,previousMonth:S,nextMonth:C,goToMonth:M,goToDay:A=>{P(A)||M(A.date)}}}var Un;(function(s){s[s.Today=0]="Today",s[s.Selected=1]="Selected",s[s.LastFocused=2]="LastFocused",s[s.FocusedModifier=3]="FocusedModifier"})(Un||(Un={}));function Jj(s){return!s[Gt.disabled]&&!s[Gt.hidden]&&!s[Gt.outside]}function hR(s,a,l,i){let c,d=-1;for(const m of s){const h=a(m);Jj(h)&&(h[Gt.focused]&&dJj(a(m)))),c}function xR(s,a,l,i,c,d,m){const{ISOWeek:h,broadcastCalendar:p}=d,{addDays:v,addMonths:g,addWeeks:j,addYears:b,endOfBroadcastWeek:w,endOfISOWeek:S,endOfWeek:C,max:N,min:T,startOfBroadcastWeek:P,startOfISOWeek:M,startOfWeek:k}=m;let A={day:v,week:j,month:g,year:b,startOfWeek:E=>p?P(E,m):h?M(E):k(E),endOfWeek:E=>p?w(E):h?S(E):C(E)}[s](l,a==="after"?1:-1);return a==="before"&&i?A=N([i,A]):a==="after"&&c&&(A=T([c,A])),A}function sw(s,a,l,i,c,d,m,h=0){if(h>365)return;const p=xR(s,a,l.date,i,c,d,m),v=!!(d.disabled&&ha(p,d.disabled,m)),g=!!(d.hidden&&ha(p,d.hidden,m)),j=p,b=new GN(p,j,m);return!v&&!g?b:sw(s,a,b,i,c,d,m,h+1)}function pR(s,a,l,i,c){const{autoFocus:d}=s,[m,h]=x.useState(),p=hR(a.days,l,i||(()=>!1),m),[v,g]=x.useState(d?p:void 0);return{isFocusTarget:C=>!!p?.isEqualTo(C),setFocused:g,focused:v,blur:()=>{h(v),g(void 0)},moveFocus:(C,N)=>{if(!v)return;const T=sw(C,N,v,a.navStart,a.navEnd,s,c);T&&(s.disableNavigation&&!a.days.some(M=>M.isEqualTo(T))||(a.goToDay(T),g(T)))}}}function gR(s,a){const{selected:l,required:i,onSelect:c}=s,[d,m]=Id(l,c?l:void 0),h=c?l:d,{isSameDay:p}=a,v=w=>h?.some(S=>p(S,w))??!1,{min:g,max:j}=s;return{selected:h,select:(w,S,C)=>{let N=[...h??[]];if(v(w)){if(h?.length===g||i&&h?.length===1)return;N=h?.filter(T=>!p(T,w))}else h?.length===j?N=[w]:N=[...N,w];return c||m(N),c?.(N,w,S,C),N},isSelected:v}}function vR(s,a,l=0,i=0,c=!1,d=Gn){const{from:m,to:h}=a||{},{isSameDay:p,isAfter:v,isBefore:g}=d;let j;if(!m&&!h)j={from:s,to:l>0?void 0:s};else if(m&&!h)p(m,s)?l===0?j={from:m,to:s}:c?j={from:m,to:void 0}:j=void 0:g(s,m)?j={from:s,to:m}:j={from:m,to:s};else if(m&&h)if(p(m,s)&&p(h,s))c?j={from:m,to:h}:j=void 0;else if(p(m,s))j={from:m,to:l>0?void 0:s};else if(p(h,s))j={from:s,to:l>0?void 0:s};else if(g(s,m))j={from:s,to:h};else if(v(s,m))j={from:m,to:s};else if(v(s,h))j={from:m,to:s};else throw new Error("Invalid range");if(j?.from&&j?.to){const b=d.differenceInCalendarDays(j.to,j.from);i>0&&b>i?j={from:s,to:void 0}:l>1&&btypeof h!="function").some(h=>typeof h=="boolean"?h:l.isDate(h)?fa(s,h,!1,l):QN(h,l)?h.some(p=>fa(s,p,!1,l)):Fh(h)?h.from&&h.to?ey(s,{from:h.from,to:h.to},l):!1:KN(h)?jR(s,h.dayOfWeek,l):IN(h)?l.isAfter(h.before,h.after)?ey(s,{from:l.addDays(h.after,1),to:l.addDays(h.before,-1)},l):ha(s.from,h,l)||ha(s.to,h,l):WN(h)||XN(h)?ha(s.from,h,l)||ha(s.to,h,l):!1))return!0;const m=i.filter(h=>typeof h=="function");if(m.length){let h=s.from;const p=l.differenceInCalendarDays(s.to,s.from);for(let v=0;v<=p;v++){if(m.some(g=>g(h)))return!0;h=l.addDays(h,1)}}return!1}function bR(s,a){const{disabled:l,excludeDisabled:i,selected:c,required:d,onSelect:m}=s,[h,p]=Id(c,m?c:void 0),v=m?c:h;return{selected:v,select:(b,w,S)=>{const{min:C,max:N}=s,T=b?vR(b,v,C,N,d,a):void 0;return i&&l&&T?.from&&T.to&&yR({from:T.from,to:T.to},l,a)&&(T.from=b,T.to=void 0),m||p(T),m?.(T,b,w,S),T},isSelected:b=>v&&fa(v,b,!1,a)}}function NR(s,a){const{selected:l,required:i,onSelect:c}=s,[d,m]=Id(l,c?l:void 0),h=c?l:d,{isSameDay:p}=a;return{selected:h,select:(j,b,w)=>{let S=j;return!i&&h&&h&&p(j,h)&&(S=void 0),c||m(S),c?.(S,j,b,w),S},isSelected:j=>h?p(h,j):!1}}function wR(s,a){const l=NR(s,a),i=gR(s,a),c=bR(s,a);switch(s.mode){case"single":return l;case"multiple":return i;case"range":return c;default:return}}function SR(s){let a=s;a.timeZone&&(a={...s},a.today&&(a.today=new Ns(a.today,a.timeZone)),a.month&&(a.month=new Ns(a.month,a.timeZone)),a.defaultMonth&&(a.defaultMonth=new Ns(a.defaultMonth,a.timeZone)),a.startMonth&&(a.startMonth=new Ns(a.startMonth,a.timeZone)),a.endMonth&&(a.endMonth=new Ns(a.endMonth,a.timeZone)),a.mode==="single"&&a.selected?a.selected=new Ns(a.selected,a.timeZone):a.mode==="multiple"&&a.selected?a.selected=a.selected?.map(We=>new Ns(We,a.timeZone)):a.mode==="range"&&a.selected&&(a.selected={from:a.selected.from?new Ns(a.selected.from,a.timeZone):void 0,to:a.selected.to?new Ns(a.selected.to,a.timeZone):void 0}));const{components:l,formatters:i,labels:c,dateLib:d,locale:m,classNames:h}=x.useMemo(()=>{const We={...Hh,...a.locale};return{dateLib:new nn({locale:We,weekStartsOn:a.broadcastCalendar?1:a.weekStartsOn,firstWeekContainsDate:a.firstWeekContainsDate,useAdditionalWeekYearTokens:a.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:a.useAdditionalDayOfYearTokens,timeZone:a.timeZone,numerals:a.numerals},a.dateLib),components:TA(a.components),formatters:BA(a.formatters),labels:{...eR,...a.labels},locale:We,classNames:{...Yh(),...a.classNames}}},[a.locale,a.broadcastCalendar,a.weekStartsOn,a.firstWeekContainsDate,a.useAdditionalWeekYearTokens,a.useAdditionalDayOfYearTokens,a.timeZone,a.numerals,a.dateLib,a.components,a.formatters,a.labels,a.classNames]),{captionLayout:p,mode:v,navLayout:g,numberOfMonths:j=1,onDayBlur:b,onDayClick:w,onDayFocus:S,onDayKeyDown:C,onDayMouseEnter:N,onDayMouseLeave:T,onNextClick:P,onPrevClick:M,showWeekNumber:k,styles:D}=a,{formatCaption:A,formatDay:E,formatMonthDropdown:B,formatWeekNumber:Y,formatWeekNumberHeader:G,formatWeekdayName:$,formatYearDropdown:oe}=i,je=fR(a,d),{days:ae,months:me,navStart:R,navEnd:O,previousMonth:L,nextMonth:ee,goToMonth:le}=je,xe=CA(ae,a,R,O,d),{isSelected:F,select:W,selected:fe}=wR(a,d)??{},{blur:I,focused:ve,isFocusTarget:de,moveFocus:Ce,setFocused:Q}=pR(a,je,xe,F??(()=>!1),d),{labelDayButton:Oe,labelGridcell:$e,labelGrid:re,labelMonthDropdown:Pe,labelNav:ze,labelPrevious:Zt,labelNext:Rs,labelWeekday:An,labelWeekNumber:Le,labelWeekNumberHeader:Nn,labelYearDropdown:ln}=c,rn=x.useMemo(()=>FA(d,a.ISOWeek),[d,a.ISOWeek]),Xt=v!==void 0||w!==void 0,Ds=x.useCallback(()=>{L&&(le(L),M?.(L))},[L,le,M]),ke=x.useCallback(()=>{ee&&(le(ee),P?.(ee))},[le,ee,P]),is=x.useCallback((We,Mt)=>Be=>{Be.preventDefault(),Be.stopPropagation(),Q(We),W?.(We.date,Mt,Be),w?.(We.date,Mt,Be)},[W,w,Q]),he=x.useCallback((We,Mt)=>Be=>{Q(We),S?.(We.date,Mt,Be)},[S,Q]),Ee=x.useCallback((We,Mt)=>Be=>{I(),b?.(We.date,Mt,Be)},[I,b]),Ve=x.useCallback((We,Mt)=>Be=>{const ht={ArrowLeft:[Be.shiftKey?"month":"day",a.dir==="rtl"?"after":"before"],ArrowRight:[Be.shiftKey?"month":"day",a.dir==="rtl"?"before":"after"],ArrowDown:[Be.shiftKey?"year":"week","after"],ArrowUp:[Be.shiftKey?"year":"week","before"],PageUp:[Be.shiftKey?"year":"month","before"],PageDown:[Be.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(ht[Be.key]){Be.preventDefault(),Be.stopPropagation();const[os,Xe]=ht[Be.key];Ce(os,Xe)}C?.(We.date,Mt,Be)},[Ce,C,a.dir]),Os=x.useCallback((We,Mt)=>Be=>{N?.(We.date,Mt,Be)},[N]),$n=x.useCallback((We,Mt)=>Be=>{T?.(We.date,Mt,Be)},[T]),Hl=x.useCallback(We=>Mt=>{const Be=Number(Mt.target.value),ht=d.setMonth(d.startOfMonth(We),Be);le(ht)},[d,le]),Fl=x.useCallback(We=>Mt=>{const Be=Number(Mt.target.value),ht=d.setYear(d.startOfMonth(We),Be);le(ht)},[d,le]),{className:se,style:ge}=x.useMemo(()=>({className:[h[Me.Root],a.className].filter(Boolean).join(" "),style:{...D?.[Me.Root],...a.style}}),[h,a.className,a.style,D]),Qe=EA(a),pt=x.useRef(null);aR(pt,!!a.animate,{classNames:h,months:me,focused:ve,dateLib:d});const tl={dayPickerProps:a,selected:fe,select:W,isSelected:F,months:me,nextMonth:ee,previousMonth:L,goToMonth:le,getModifiers:xe,components:l,classNames:h,styles:D,labels:c,formatters:i};return Ne.createElement($N.Provider,{value:tl},Ne.createElement(l.Root,{rootRef:a.animate?pt:void 0,className:se,style:ge,dir:a.dir,id:a.id,lang:a.lang,nonce:a.nonce,title:a.title,role:a.role,"aria-label":a["aria-label"],"aria-labelledby":a["aria-labelledby"],...Qe},Ne.createElement(l.Months,{className:h[Me.Months],style:D?.[Me.Months]},!a.hideNavigation&&!g&&Ne.createElement(l.Nav,{"data-animated-nav":a.animate?"true":void 0,className:h[Me.Nav],style:D?.[Me.Nav],"aria-label":ze(),onPreviousClick:Ds,onNextClick:ke,previousMonth:L,nextMonth:ee}),me.map((We,Mt)=>Ne.createElement(l.Month,{"data-animated-month":a.animate?"true":void 0,className:h[Me.Month],style:D?.[Me.Month],key:Mt,displayIndex:Mt,calendarMonth:We},g==="around"&&!a.hideNavigation&&Mt===0&&Ne.createElement(l.PreviousMonthButton,{type:"button",className:h[Me.PreviousMonthButton],tabIndex:L?void 0:-1,"aria-disabled":L?void 0:!0,"aria-label":Zt(L),onClick:Ds,"data-animated-button":a.animate?"true":void 0},Ne.createElement(l.Chevron,{disabled:L?void 0:!0,className:h[Me.Chevron],orientation:a.dir==="rtl"?"right":"left"})),Ne.createElement(l.MonthCaption,{"data-animated-caption":a.animate?"true":void 0,className:h[Me.MonthCaption],style:D?.[Me.MonthCaption],calendarMonth:We,displayIndex:Mt},p?.startsWith("dropdown")?Ne.createElement(l.DropdownNav,{className:h[Me.Dropdowns],style:D?.[Me.Dropdowns]},(()=>{const Be=p==="dropdown"||p==="dropdown-months"?Ne.createElement(l.MonthsDropdown,{key:"month",className:h[Me.MonthsDropdown],"aria-label":Pe(),classNames:h,components:l,disabled:!!a.disableNavigation,onChange:Hl(We.date),options:UA(We.date,R,O,i,d),style:D?.[Me.Dropdown],value:d.getMonth(We.date)}):Ne.createElement("span",{key:"month"},B(We.date,d)),ht=p==="dropdown"||p==="dropdown-years"?Ne.createElement(l.YearsDropdown,{key:"year",className:h[Me.YearsDropdown],"aria-label":ln(d.options),classNames:h,components:l,disabled:!!a.disableNavigation,onChange:Fl(We.date),options:YA(R,O,i,d,!!a.reverseYears),style:D?.[Me.Dropdown],value:d.getYear(We.date)}):Ne.createElement("span",{key:"year"},oe(We.date,d));return d.getMonthYearOrder()==="year-first"?[ht,Be]:[Be,ht]})(),Ne.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},A(We.date,d.options,d))):Ne.createElement(l.CaptionLabel,{className:h[Me.CaptionLabel],role:"status","aria-live":"polite"},A(We.date,d.options,d))),g==="around"&&!a.hideNavigation&&Mt===j-1&&Ne.createElement(l.NextMonthButton,{type:"button",className:h[Me.NextMonthButton],tabIndex:ee?void 0:-1,"aria-disabled":ee?void 0:!0,"aria-label":Rs(ee),onClick:ke,"data-animated-button":a.animate?"true":void 0},Ne.createElement(l.Chevron,{disabled:ee?void 0:!0,className:h[Me.Chevron],orientation:a.dir==="rtl"?"left":"right"})),Mt===j-1&&g==="after"&&!a.hideNavigation&&Ne.createElement(l.Nav,{"data-animated-nav":a.animate?"true":void 0,className:h[Me.Nav],style:D?.[Me.Nav],"aria-label":ze(),onPreviousClick:Ds,onNextClick:ke,previousMonth:L,nextMonth:ee}),Ne.createElement(l.MonthGrid,{role:"grid","aria-multiselectable":v==="multiple"||v==="range","aria-label":re(We.date,d.options,d)||void 0,className:h[Me.MonthGrid],style:D?.[Me.MonthGrid]},!a.hideWeekdays&&Ne.createElement(l.Weekdays,{"data-animated-weekdays":a.animate?"true":void 0,className:h[Me.Weekdays],style:D?.[Me.Weekdays]},k&&Ne.createElement(l.WeekNumberHeader,{"aria-label":Nn(d.options),className:h[Me.WeekNumberHeader],style:D?.[Me.WeekNumberHeader],scope:"col"},G()),rn.map(Be=>Ne.createElement(l.Weekday,{"aria-label":An(Be,d.options,d),className:h[Me.Weekday],key:String(Be),style:D?.[Me.Weekday],scope:"col"},$(Be,d.options,d)))),Ne.createElement(l.Weeks,{"data-animated-weeks":a.animate?"true":void 0,className:h[Me.Weeks],style:D?.[Me.Weeks]},We.weeks.map(Be=>Ne.createElement(l.Week,{className:h[Me.Week],key:Be.weekNumber,style:D?.[Me.Week],week:Be},k&&Ne.createElement(l.WeekNumber,{week:Be,style:D?.[Me.WeekNumber],"aria-label":Le(Be.weekNumber,{locale:m}),className:h[Me.WeekNumber],scope:"row",role:"rowheader"},Y(Be.weekNumber,d)),Be.days.map(ht=>{const{date:os}=ht,Xe=xe(ht);if(Xe[Gt.focused]=!Xe.hidden&&!!ve?.isEqualTo(ht),Xe[En.selected]=F?.(os)||Xe.selected,Fh(fe)){const{from:ql,to:nl}=fe;Xe[En.range_start]=!!(ql&&nl&&d.isSameDay(os,ql)),Xe[En.range_end]=!!(ql&&nl&&d.isSameDay(os,nl)),Xe[En.range_middle]=fa(fe,os,!0,d)}const Yl=HA(Xe,D,a.modifiersStyles),sl=kA(Xe,h,a.modifiersClassNames),Zd=!Xt&&!Xe.hidden?$e(os,Xe,d.options,d):void 0;return Ne.createElement(l.Day,{key:`${d.format(os,"yyyy-MM-dd")}_${d.format(ht.displayMonth,"yyyy-MM")}`,day:ht,modifiers:Xe,className:sl.join(" "),style:Yl,role:"gridcell","aria-selected":Xe.selected||void 0,"aria-label":Zd,"data-day":d.format(os,"yyyy-MM-dd"),"data-month":ht.outside?d.format(os,"yyyy-MM"):void 0,"data-selected":Xe.selected||void 0,"data-disabled":Xe.disabled||void 0,"data-hidden":Xe.hidden||void 0,"data-outside":ht.outside||void 0,"data-focused":Xe.focused||void 0,"data-today":Xe.today||void 0},!Xe.hidden&&Xt?Ne.createElement(l.DayButton,{className:h[Me.DayButton],style:D?.[Me.DayButton],type:"button",day:ht,modifiers:Xe,disabled:Xe.disabled||void 0,tabIndex:de(ht)?0:-1,"aria-label":Oe(os,Xe,d.options,d),onClick:is(ht,Xe),onBlur:Ee(ht,Xe),onFocus:he(ht,Xe),onKeyDown:Ve(ht,Xe),onMouseEnter:Os(ht,Xe),onMouseLeave:$n(ht,Xe)},E(os,d.options,d)):!Xe.hidden&&E(ht.date,d.options,d))})))))))),a.footer&&Ne.createElement(l.Footer,{className:h[Me.Footer],style:D?.[Me.Footer],role:"status","aria-live":"polite"},a.footer)))}function ty({className:s,classNames:a,showOutsideDays:l=!0,captionLayout:i="label",buttonVariant:c="ghost",formatters:d,components:m,...h}){const p=Yh();return e.jsx(SR,{showOutsideDays:l,className:Z("bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,s),captionLayout:i,formatters:{formatMonthDropdown:v=>v.toLocaleString("default",{month:"short"}),...d},classNames:{root:Z("w-fit",p.root),months:Z("relative flex flex-col gap-4 md:flex-row",p.months),month:Z("flex w-full flex-col gap-4",p.month),nav:Z("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",p.nav),button_previous:Z(io({variant:c}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_previous),button_next:Z(io({variant:c}),"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",p.button_next),month_caption:Z("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",p.month_caption),dropdowns:Z("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",p.dropdowns),dropdown_root:Z("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:Z("bg-popover absolute inset-0 opacity-0",p.dropdown),caption_label:Z("select-none font-medium",i==="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:Z("flex",p.weekdays),weekday:Z("text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",p.weekday),week:Z("mt-2 flex w-full",p.week),week_number_header:Z("w-[--cell-size] select-none",p.week_number_header),week_number:Z("text-muted-foreground select-none text-[0.8rem]",p.week_number),day:Z("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:Z("bg-accent rounded-l-md",p.range_start),range_middle:Z("rounded-none",p.range_middle),range_end:Z("bg-accent rounded-r-md",p.range_end),today:Z("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",p.today),outside:Z("text-muted-foreground aria-selected:text-muted-foreground",p.outside),disabled:Z("text-muted-foreground opacity-50",p.disabled),hidden:Z("invisible",p.hidden),...a},components:{Root:({className:v,rootRef:g,...j})=>e.jsx("div",{"data-slot":"calendar",ref:g,className:Z(v),...j}),Chevron:({className:v,orientation:g,...j})=>g==="left"?e.jsx(Ol,{className:Z("size-4",v),...j}):g==="right"?e.jsx(Al,{className:Z("size-4",v),...j}):e.jsx(lo,{className:Z("size-4",v),...j}),DayButton:_R,WeekNumber:({children:v,...g})=>e.jsx("td",{...g,children:e.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:v})}),...m},...h})}function _R({className:s,day:a,modifiers:l,...i}){const c=Yh(),d=x.useRef(null);return x.useEffect(()=>{l.focused&&d.current?.focus()},[l.focused]),e.jsx(q,{ref:d,variant:"ghost",size:"icon","data-day":a.date.toLocaleDateString(),"data-selected-single":l.selected&&!l.range_start&&!l.range_end&&!l.range_middle,"data-range-start":l.range_start,"data-range-end":l.range_end,"data-range-middle":l.range_middle,className:Z("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",c.day,s),...i})}class CR{ws=null;reconnectTimeout=null;reconnectAttempts=0;maxReconnectAttempts=10;heartbeatInterval=null;logCallbacks=new Set;connectionCallbacks=new Set;isConnected=!1;logCache=[];maxCacheSize=1e3;getWebSocketUrl(){{const a=window.location.protocol==="https:"?"wss:":"ws:",l=window.location.host;return`${a}//${l}/ws/logs`}}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;const a=this.getWebSocketUrl();try{this.ws=new WebSocket(a),this.ws.onopen=()=>{this.isConnected=!0,this.reconnectAttempts=0,this.notifyConnection(!0),this.startHeartbeat()},this.ws.onmessage=l=>{try{if(l.data==="pong")return;const i=JSON.parse(l.data);this.notifyLog(i)}catch(i){console.error("解析日志消息失败:",i)}},this.ws.onerror=l=>{console.error("❌ WebSocket 错误:",l),this.isConnected=!1,this.notifyConnection(!1)},this.ws.onclose=()=>{this.isConnected=!1,this.notifyConnection(!1),this.stopHeartbeat(),this.attemptReconnect()}}catch(l){console.error("创建 WebSocket 连接失败:",l),this.attemptReconnect()}}attemptReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return;this.reconnectAttempts+=1;const a=Math.min(1e3*this.reconnectAttempts,1e4);this.reconnectTimeout=window.setTimeout(()=>{this.connect()},a)}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(a){return this.logCallbacks.add(a),()=>this.logCallbacks.delete(a)}onConnectionChange(a){return this.connectionCallbacks.add(a),a(this.isConnected),()=>this.connectionCallbacks.delete(a)}notifyLog(a){this.logCache.some(i=>i.id===a.id)||(this.logCache.push(a),this.logCache.length>this.maxCacheSize&&(this.logCache=this.logCache.slice(-this.maxCacheSize)),this.logCallbacks.forEach(i=>{try{i(a)}catch(c){console.error("日志回调执行失败:",c)}}))}notifyConnection(a){this.connectionCallbacks.forEach(l=>{try{l(a)}catch(i){console.error("连接状态回调执行失败:",i)}})}getAllLogs(){return[...this.logCache]}clearLogs(){this.logCache=[]}getConnectionStatus(){return this.isConnected}}const zr=new CR;typeof window<"u"&&zr.connect();const kR={lessThanXSeconds:{one:"不到 1 秒",other:"不到 {{count}} 秒"},xSeconds:{one:"1 秒",other:"{{count}} 秒"},halfAMinute:"半分钟",lessThanXMinutes:{one:"不到 1 分钟",other:"不到 {{count}} 分钟"},xMinutes:{one:"1 分钟",other:"{{count}} 分钟"},xHours:{one:"1 小时",other:"{{count}} 小时"},aboutXHours:{one:"大约 1 小时",other:"大约 {{count}} 小时"},xDays:{one:"1 天",other:"{{count}} 天"},aboutXWeeks:{one:"大约 1 个星期",other:"大约 {{count}} 个星期"},xWeeks:{one:"1 个星期",other:"{{count}} 个星期"},aboutXMonths:{one:"大约 1 个月",other:"大约 {{count}} 个月"},xMonths:{one:"1 个月",other:"{{count}} 个月"},aboutXYears:{one:"大约 1 年",other:"大约 {{count}} 年"},xYears:{one:"1 年",other:"{{count}} 年"},overXYears:{one:"超过 1 年",other:"超过 {{count}} 年"},almostXYears:{one:"将近 1 年",other:"将近 {{count}} 年"}},TR=(s,a,l)=>{let i;const c=kR[s];return typeof c=="string"?i=c:a===1?i=c.one:i=c.other.replace("{{count}}",String(a)),l?.addSuffix?l.comparison&&l.comparison>0?i+"内":i+"前":i},ER={full:"y'年'M'月'd'日' EEEE",long:"y'年'M'月'd'日'",medium:"yyyy-MM-dd",short:"yy-MM-dd"},MR={full:"zzzz a h:mm:ss",long:"z a h:mm:ss",medium:"a h:mm:ss",short:"a h:mm"},DR={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}} {{time}}",short:"{{date}} {{time}}"},OR={date:Hr({formats:ER,defaultWidth:"full"}),time:Hr({formats:MR,defaultWidth:"full"}),dateTime:Hr({formats:DR,defaultWidth:"full"})};function sy(s,a,l){const i="eeee p";return qO(s,a,l)?i:s.getTime()>a.getTime()?"'下个'"+i:"'上个'"+i}const AR={lastWeek:sy,yesterday:"'昨天' p",today:"'今天' p",tomorrow:"'明天' p",nextWeek:sy,other:"PP p"},RR=(s,a,l,i)=>{const c=AR[s];return typeof c=="function"?c(a,l,i):c},zR={narrow:["前","公元"],abbreviated:["前","公元"],wide:["公元前","公元"]},PR={narrow:["1","2","3","4"],abbreviated:["第一季","第二季","第三季","第四季"],wide:["第一季度","第二季度","第三季度","第四季度"]},LR={narrow:["一","二","三","四","五","六","七","八","九","十","十一","十二"],abbreviated:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],wide:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]},BR={narrow:["日","一","二","三","四","五","六"],short:["日","一","二","三","四","五","六"],abbreviated:["周日","周一","周二","周三","周四","周五","周六"],wide:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},UR={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},HR={narrow:{am:"上",pm:"下",midnight:"凌晨",noon:"午",morning:"早",afternoon:"下午",evening:"晚",night:"夜"},abbreviated:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"},wide:{am:"上午",pm:"下午",midnight:"凌晨",noon:"中午",morning:"早晨",afternoon:"中午",evening:"晚上",night:"夜间"}},FR=(s,a)=>{const l=Number(s);switch(a?.unit){case"date":return l.toString()+"日";case"hour":return l.toString()+"时";case"minute":return l.toString()+"分";case"second":return l.toString()+"秒";default:return"第 "+l.toString()}},YR={ordinalNumber:FR,era:Hn({values:zR,defaultWidth:"wide"}),quarter:Hn({values:PR,defaultWidth:"wide",argumentCallback:s=>s-1}),month:Hn({values:LR,defaultWidth:"wide"}),day:Hn({values:BR,defaultWidth:"wide"}),dayPeriod:Hn({values:UR,defaultWidth:"wide",formattingValues:HR,defaultFormattingWidth:"wide"})},qR=/^(第\s*)?\d+(日|时|分|秒)?/i,VR=/\d+/i,GR={narrow:/^(前)/i,abbreviated:/^(前)/i,wide:/^(公元前|公元)/i},$R={any:[/^(前)/i,/^(公元)/i]},IR={narrow:/^[1234]/i,abbreviated:/^第[一二三四]刻/i,wide:/^第[一二三四]刻钟/i},WR={any:[/(1|一)/i,/(2|二)/i,/(3|三)/i,/(4|四)/i]},XR={narrow:/^(一|二|三|四|五|六|七|八|九|十[二一])/i,abbreviated:/^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,wide:/^(一|二|三|四|五|六|七|八|九|十[二一])月/i},KR={narrow:[/^一/i,/^二/i,/^三/i,/^四/i,/^五/i,/^六/i,/^七/i,/^八/i,/^九/i,/^十(?!(一|二))/i,/^十一/i,/^十二/i],any:[/^一|1/i,/^二|2/i,/^三|3/i,/^四|4/i,/^五|5/i,/^六|6/i,/^七|7/i,/^八|8/i,/^九|9/i,/^十(?!(一|二))|10/i,/^十一|11/i,/^十二|12/i]},QR={narrow:/^[一二三四五六日]/i,short:/^[一二三四五六日]/i,abbreviated:/^周[一二三四五六日]/i,wide:/^星期[一二三四五六日]/i},ZR={any:[/日/i,/一/i,/二/i,/三/i,/四/i,/五/i,/六/i]},JR={any:/^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i},e3={any:{am:/^上午?/i,pm:/^下午?/i,midnight:/^午夜/i,noon:/^[中正]午/i,morning:/^早上/i,afternoon:/^下午/i,evening:/^晚上?/i,night:/^凌晨/i}},t3={ordinalNumber:UN({matchPattern:qR,parsePattern:VR,valueCallback:s=>parseInt(s,10)}),era:Fn({matchPatterns:GR,defaultMatchWidth:"wide",parsePatterns:$R,defaultParseWidth:"any"}),quarter:Fn({matchPatterns:IR,defaultMatchWidth:"wide",parsePatterns:WR,defaultParseWidth:"any",valueCallback:s=>s+1}),month:Fn({matchPatterns:XR,defaultMatchWidth:"wide",parsePatterns:KR,defaultParseWidth:"any"}),day:Fn({matchPatterns:QR,defaultMatchWidth:"wide",parsePatterns:ZR,defaultParseWidth:"any"}),dayPeriod:Fn({matchPatterns:JR,defaultMatchWidth:"any",parsePatterns:e3,defaultParseWidth:"any"})},td={code:"zh-CN",formatDistance:TR,formatLong:OR,formatRelative:RR,localize:YR,match:t3,options:{weekStartsOn:1,firstWeekContainsDate:4}};function s3(){const[s,a]=x.useState([]),[l,i]=x.useState(""),[c,d]=x.useState("all"),[m,h]=x.useState("all"),[p,v]=x.useState(void 0),[g,j]=x.useState(void 0),[b,w]=x.useState(!0),[S,C]=x.useState(!1),N=x.useRef(null),T=x.useRef(null);x.useEffect(()=>{const $=zr.getAllLogs();a($);const oe=zr.onLog(()=>{a(zr.getAllLogs())}),je=zr.onConnectionChange(ae=>{C(ae)});return()=>{oe(),je()}},[]),x.useEffect(()=>{b&&T.current&&T.current.scrollIntoView({behavior:"smooth",block:"end"})},[s,b]);const P=x.useMemo(()=>{const $=new Set(s.map(oe=>oe.module));return Array.from($).sort()},[s]),M=$=>{switch($){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"}},k=$=>{switch($){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"}},D=()=>{window.location.reload()},A=()=>{zr.clearLogs(),a([])},E=()=>{const $=G.map(me=>`${me.timestamp} [${me.level.padEnd(8)}] [${me.module}] ${me.message}`).join(` `),oe=new Blob([$],{type:"text/plain;charset=utf-8"}),je=URL.createObjectURL(oe),ae=document.createElement("a");ae.href=je,ae.download=`logs-${md(new Date,"yyyy-MM-dd-HHmmss")}.txt`,ae.click(),URL.revokeObjectURL(je)},B=()=>{w(!b)},Y=()=>{v(void 0),j(void 0)},G=x.useMemo(()=>s.filter($=>{const oe=l===""||$.message.toLowerCase().includes(l.toLowerCase())||$.module.toLowerCase().includes(l.toLowerCase()),je=c==="all"||$.level===c,ae=m==="all"||$.module===m;let me=!0;if(p||g){const R=new Date($.timestamp);if(p){const O=new Date(p);O.setHours(0,0,0,0),me=me&&R>=O}if(g){const O=new Date(g);O.setHours(23,59,59,999),me=me&&R<=O}}return oe&&je&&ae&&me}),[s,l,c,m,p,g]);return e.jsx(Ct,{className:"h-full",children:e.jsxs("div",{className:"space-y-4 p-3 sm:p-4 lg:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold",children:"日志查看器"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"实时查看和分析麦麦运行日志"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Z("h-2.5 w-2.5 sm:h-3 sm:w-3 rounded-full",S?"bg-green-500 animate-pulse":"bg-red-500")}),e.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground",children:S?"已连接":"未连接"})]})]}),e.jsx(Ue,{className:"p-3 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Gs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{placeholder:"搜索日志...",value:l,onChange:$=>i($.target.value),className:"pl-9 h-9 text-sm"})]}),e.jsxs(rt,{value:c,onValueChange:d,children:[e.jsxs(at,{className:"w-full sm:w-[140px] lg:w-[180px] h-9 text-sm",children:[e.jsx(Lf,{className:"h-4 w-4 mr-2"}),e.jsx(it,{placeholder:"级别"})]}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部级别"}),e.jsx(ye,{value:"DEBUG",children:"DEBUG"}),e.jsx(ye,{value:"INFO",children:"INFO"}),e.jsx(ye,{value:"WARNING",children:"WARNING"}),e.jsx(ye,{value:"ERROR",children:"ERROR"}),e.jsx(ye,{value:"CRITICAL",children:"CRITICAL"})]})]}),e.jsxs(rt,{value:m,onValueChange:h,children:[e.jsxs(at,{className:"w-full sm:w-[160px] lg:w-[200px] h-9 text-sm",children:[e.jsx(Lf,{className:"h-4 w-4 mr-2"}),e.jsx(it,{placeholder:"模块"})]}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部模块"}),P.map($=>e.jsx(ye,{value:$,children:$},$))]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:gap-4",children:[e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",className:Z("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!p&&"text-muted-foreground"),children:[e.jsx(ej,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:p?md(p,"PPP",{locale:td}):"开始日期"})]})}),e.jsx(pa,{className:"w-auto p-0",align:"start",children:e.jsx(ty,{mode:"single",selected:p,onSelect:v,initialFocus:!0,locale:td})})]}),e.jsxs(Ia,{children:[e.jsx(Wa,{asChild:!0,children:e.jsxs(q,{variant:"outline",size:"sm",className:Z("w-full sm:w-[200px] lg:w-[240px] justify-start text-left font-normal h-9",!g&&"text-muted-foreground"),children:[e.jsx(ej,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-sm",children:g?md(g,"PPP",{locale:td}):"结束日期"})]})}),e.jsx(pa,{className:"w-auto p-0",align:"start",children:e.jsx(ty,{mode:"single",selected:g,onSelect:j,initialFocus:!0,locale:td})})]}),(p||g)&&e.jsxs(q,{variant:"outline",size:"sm",onClick:Y,className:"w-full sm:w-auto h-9",children:[e.jsx(go,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline text-sm",children:"清除时间筛选"}),e.jsx("span",{className:"sm:hidden text-sm",children:"清除"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(q,{variant:b?"default":"outline",size:"sm",onClick:B,className:"flex-1 sm:flex-none h-9",children:[b?e.jsx(F2,{className:"h-4 w-4"}):e.jsx(Y2,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:b?"自动滚动":"已暂停"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:D,className:"flex-1 sm:flex-none h-9",children:[e.jsx(xa,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"刷新"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:A,className:"flex-1 sm:flex-none h-9",children:[e.jsx(ft,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"清空"})]}),e.jsxs(q,{variant:"outline",size:"sm",onClick:E,className:"flex-1 sm:flex-none h-9",children:[e.jsx(Bf,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-2 text-sm",children:"导出"})]})]}),e.jsx("div",{className:"flex-1 hidden sm:block"}),e.jsxs("div",{className:"text-xs sm:text-sm text-muted-foreground flex items-center justify-center sm:justify-end",children:[e.jsxs("span",{className:"font-mono",children:[G.length," / ",s.length]}),e.jsx("span",{className:"ml-1",children:"条日志"})]})]})]})}),e.jsx(Ue,{className:"bg-black dark:bg-gray-950 border-gray-800 dark:border-gray-900",children:e.jsx(Ct,{className:"h-[calc(100vh-280px)] sm:h-[calc(100vh-320px)] lg:h-[calc(100vh-400px)]",children:e.jsxs("div",{ref:N,className:"p-2 sm:p-3 lg:p-4 font-mono text-xs sm:text-sm space-y-1",children:[G.length===0?e.jsx("div",{className:"text-gray-500 dark:text-gray-600 text-center py-8 text-sm",children:"暂无日志数据"}):G.map($=>e.jsxs("div",{className:Z("py-2 px-2 sm:px-3 rounded hover:bg-white/5 transition-colors group",k($.level)),children:[e.jsxs("div",{className:"flex flex-col gap-1 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-xs",children:$.timestamp}),e.jsxs("span",{className:Z("text-xs font-semibold",M($.level)),children:["[",$.level,"]"]})]}),e.jsx("div",{className:"text-cyan-400 dark:text-cyan-500 text-xs truncate",children:$.module}),e.jsx("div",{className:"text-gray-300 dark:text-gray-400 text-xs break-all",children:$.message})]}),e.jsxs("div",{className:"hidden sm:flex gap-3 items-start",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-600 flex-shrink-0 w-[140px] lg:w-[180px] text-xs lg:text-sm",children:$.timestamp}),e.jsxs("span",{className:Z("flex-shrink-0 w-[70px] lg:w-[80px] font-semibold text-xs lg:text-sm",M($.level)),children:["[",$.level,"]"]}),e.jsx("span",{className:"text-cyan-400 dark:text-cyan-500 flex-shrink-0 w-[120px] lg:w-[150px] truncate text-xs lg:text-sm",children:$.module}),e.jsx("span",{className:"text-gray-300 dark:text-gray-400 flex-1 break-all text-xs lg:text-sm",children:$.message})]})]},$.id)),e.jsx("div",{ref:T,className:"h-4"})]})})})]})})}const n3="Mai-with-u",a3="plugin-repo",l3="main",r3="plugin_details.json";async function i3(){try{const s=await Fe("/api/webui/plugins/fetch-raw",{method:"POST",headers:Ie(),body:JSON.stringify({owner:n3,repo:a3,branch:l3,file_path:r3})});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const a=await s.json();if(!a.success||!a.data)throw new Error(a.error||"获取插件列表失败");return JSON.parse(a.data).filter(c=>!c?.id||!c?.manifest?(console.warn("跳过无效插件数据:",c),!1):!c.manifest.name||!c.manifest.version?(console.warn("跳过缺少必需字段的插件:",c.id),!1):!0).map(c=>({id:c.id,manifest:{manifest_version:c.manifest.manifest_version||1,name:c.manifest.name,version:c.manifest.version,description:c.manifest.description||"",author:c.manifest.author||{name:"Unknown"},license:c.manifest.license||"Unknown",host_application:c.manifest.host_application||{min_version:"0.0.0"},homepage_url:c.manifest.homepage_url,repository_url:c.manifest.repository_url,keywords:c.manifest.keywords||[],categories:c.manifest.categories||[],default_locale:c.manifest.default_locale||"zh-CN",locales_path:c.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!1,published_at:new Date().toISOString(),updated_at:new Date().toISOString()}))}catch(s){throw console.error("Failed to fetch plugin list:",s),s}}async function o3(){try{const s=await Fe("/api/webui/plugins/git-status");if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}catch(s){return console.error("Failed to check Git status:",s),{installed:!1,error:"无法检测 Git 安装状态"}}}async function c3(){try{const s=await Fe("/api/webui/plugins/version");if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}catch(s){return console.error("Failed to get Maimai version:",s),{version:"0.0.0",version_major:0,version_minor:0,version_patch:0}}}function d3(s,a,l){const i=s.split(".").map(h=>parseInt(h)||0),c=i[0]||0,d=i[1]||0,m=i[2]||0;if(l.version_majorparseInt(j)||0),p=h[0]||0,v=h[1]||0,g=h[2]||0;if(l.version_major>p||l.version_major===p&&l.version_minor>v||l.version_major===p&&l.version_minor===v&&l.version_patch>g)return!1}return!0}function u3(s,a){const l=window.location.protocol==="https:"?"wss:":"ws:",i=window.location.host,c=new WebSocket(`${l}//${i}/api/webui/ws/plugin-progress`);return c.onopen=()=>{console.log("Plugin progress WebSocket connected");const d=setInterval(()=>{c.readyState===WebSocket.OPEN?c.send("ping"):clearInterval(d)},3e4)},c.onmessage=d=>{try{if(d.data==="pong")return;const m=JSON.parse(d.data);s(m)}catch(m){console.error("Failed to parse progress data:",m)}},c.onerror=d=>{console.error("Plugin progress WebSocket error:",d),a?.(d)},c.onclose=()=>{console.log("Plugin progress WebSocket disconnected")},c}async function sd(){try{const s=await Fe("/api/webui/plugins/installed",{headers:Ie()});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);const a=await s.json();if(!a.success)throw new Error(a.message||"获取已安装插件列表失败");return a.plugins||[]}catch(s){return console.error("Failed to get installed plugins:",s),[]}}function nd(s,a){return a.some(l=>l.id===s)}function ad(s,a){const l=a.find(i=>i.id===s);if(l)return l.manifest?.version||l.version}async function m3(s,a,l="main"){const i=await Fe("/api/webui/plugins/install",{method:"POST",headers:Ie(),body:JSON.stringify({plugin_id:s,repository_url:a,branch:l})});if(!i.ok){const c=await i.json();throw new Error(c.detail||"安装失败")}return await i.json()}async function f3(s){const a=await Fe("/api/webui/plugins/uninstall",{method:"POST",headers:Ie(),body:JSON.stringify({plugin_id:s})});if(!a.ok){const l=await a.json();throw new Error(l.detail||"卸载失败")}return await a.json()}async function h3(s,a,l="main"){const i=await Fe("/api/webui/plugins/update",{method:"POST",headers:Ie(),body:JSON.stringify({plugin_id:s,repository_url:a,branch:l})});if(!i.ok){const c=await i.json();throw new Error(c.detail||"更新失败")}return await i.json()}const ny={"Group Management":"群组管理","Entertainment & Interaction":"娱乐互动","Utility Tools":"实用工具","Content Generation":"内容生成",Multimedia:"多媒体","External Integration":"外部集成","Data Analysis & Insights":"数据分析与洞察",Other:"其他"};function x3(){const s=qn(),[a,l]=x.useState(null),[i,c]=x.useState(""),[d,m]=x.useState("all"),[h,p]=x.useState("all"),[v,g]=x.useState(!1),[j,b]=x.useState([]),[w,S]=x.useState(!0),[C,N]=x.useState(null),[T,P]=x.useState(null),[M,k]=x.useState(null),[D,A]=x.useState(null),[,E]=x.useState([]),{toast:B}=Es();x.useEffect(()=>{let O=null,L=!1;return(async()=>{if(O=u3(le=>{L||(k(le),le.stage==="success"?setTimeout(()=>{L||k(null)},2e3):le.stage==="error"&&(S(!1),N(le.error||"加载失败")))},le=>{console.error("WebSocket error:",le),L||B({title:"WebSocket 连接失败",description:"无法实时显示加载进度",variant:"destructive"})}),await new Promise(le=>{if(!O){le();return}const xe=()=>{O&&O.readyState===WebSocket.OPEN?(console.log("WebSocket connected, starting to load plugins"),le()):O&&O.readyState===WebSocket.CLOSED?(console.warn("WebSocket closed before loading plugins"),le()):setTimeout(xe,100)};xe()}),!L){const le=await o3();P(le),le.installed||B({title:"Git 未安装",description:le.error||"请先安装 Git 才能使用插件安装功能",variant:"destructive"})}if(!L){const le=await c3();A(le)}if(!L)try{S(!0),N(null);const le=await i3();if(!L){const xe=await sd();E(xe);const F=le.map(W=>{const fe=nd(W.id,xe),I=ad(W.id,xe);return{...W,installed:fe,installed_version:I}});for(const W of xe)!F.some(I=>I.id===W.id)&&W.manifest&&F.push({id:W.id,manifest:{manifest_version:W.manifest.manifest_version||1,name:W.manifest.name,version:W.manifest.version,description:W.manifest.description||"",author:W.manifest.author,license:W.manifest.license||"Unknown",host_application:W.manifest.host_application,homepage_url:W.manifest.homepage_url,repository_url:W.manifest.repository_url,keywords:W.manifest.keywords||[],categories:W.manifest.categories||[],default_locale:W.manifest.default_locale||"zh-CN",locales_path:W.manifest.locales_path},downloads:0,rating:0,review_count:0,installed:!0,installed_version:W.manifest.version,published_at:new Date().toISOString(),updated_at:new Date().toISOString()});b(F)}}catch(le){if(!L){const xe=le instanceof Error?le.message:"加载插件列表失败";N(xe),B({title:"加载失败",description:xe,variant:"destructive"})}}finally{L||S(!1)}})(),()=>{L=!0,O&&O.close()}},[B]);const Y=O=>{if(!O.installed&&D&&!G(O))return e.jsxs(_t,{variant:"destructive",className:"gap-1",children:[e.jsx(Tl,{className:"h-3 w-3"}),"不兼容"]});if(O.installed){const L=O.installed_version?.trim(),ee=O.manifest.version?.trim();if(L!==ee){const le=L?.split(".").map(Number)||[0,0,0],xe=ee?.split(".").map(Number)||[0,0,0];for(let F=0;F<3;F++){if((xe[F]||0)>(le[F]||0))return e.jsxs(_t,{variant:"outline",className:"gap-1 text-orange-600 border-orange-600",children:[e.jsx(Tl,{className:"h-3 w-3"}),"可更新"]});if((xe[F]||0)<(le[F]||0))break}}return e.jsxs(_t,{variant:"default",className:"gap-1",children:[e.jsx(Ys,{className:"h-3 w-3"}),"已安装"]})}return null},G=O=>!D||!O.manifest?.host_application?!0:d3(O.manifest.host_application.min_version,O.manifest.host_application.max_version,D),$=O=>{if(!O.installed||!O.installed_version||!O.manifest?.version)return!1;const L=O.installed_version.trim(),ee=O.manifest.version.trim();if(L===ee)return!1;const le=L.split(".").map(Number),xe=ee.split(".").map(Number);for(let F=0;F<3;F++){if((xe[F]||0)>(le[F]||0))return!0;if((xe[F]||0)<(le[F]||0))return!1}return!1},oe=j.filter(O=>{if(!O.manifest)return console.warn("[过滤] 跳过无 manifest 的插件:",O.id),!1;const L=i===""||O.manifest.name?.toLowerCase().includes(i.toLowerCase())||O.manifest.description?.toLowerCase().includes(i.toLowerCase())||O.manifest.keywords&&O.manifest.keywords.some(F=>F.toLowerCase().includes(i.toLowerCase())),ee=d==="all"||O.manifest.categories&&O.manifest.categories.includes(d);let le=!0;h==="installed"?le=O.installed===!0:h==="updates"&&(le=O.installed===!0&&$(O));const xe=!v||!D||G(O);return L&&ee&&le&&xe}),je=()=>{l(null)},ae=async O=>{if(!T?.installed){B({title:"无法安装",description:"Git 未安装",variant:"destructive"});return}if(D&&!G(O)){B({title:"无法安装",description:"插件与当前麦麦版本不兼容",variant:"destructive"});return}try{await m3(O.id,O.manifest.repository_url||"","main"),B({title:"安装成功",description:`${O.manifest.name} 已成功安装`});const L=await sd();E(L),b(ee=>ee.map(le=>{if(le.id===O.id){const xe=nd(le.id,L),F=ad(le.id,L);return{...le,installed:xe,installed_version:F}}return le}))}catch(L){B({title:"安装失败",description:L instanceof Error?L.message:"未知错误",variant:"destructive"})}},me=async O=>{try{await f3(O.id),B({title:"卸载成功",description:`${O.manifest.name} 已成功卸载`});const L=await sd();E(L),b(ee=>ee.map(le=>{if(le.id===O.id){const xe=nd(le.id,L),F=ad(le.id,L);return{...le,installed:xe,installed_version:F}}return le}))}catch(L){B({title:"卸载失败",description:L instanceof Error?L.message:"未知错误",variant:"destructive"})}},R=async O=>{if(!T?.installed){B({title:"无法更新",description:"Git 未安装",variant:"destructive"});return}try{const L=await h3(O.id,O.manifest.repository_url||"","main");B({title:"更新成功",description:`${O.manifest.name} 已从 ${L.old_version} 更新到 ${L.new_version}`});const ee=await sd();E(ee),b(le=>le.map(xe=>{if(xe.id===O.id){const F=nd(xe.id,ee),W=ad(xe.id,ee);return{...xe,installed:F,installed_version:W}}return xe}))}catch(L){B({title:"更新失败",description:L instanceof Error?L.message:"未知错误",variant:"destructive"})}};return e.jsx(Ct,{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(q,{onClick:()=>s({to:"/plugin-mirrors"}),children:[e.jsx(q2,{className:"h-4 w-4 mr-2"}),"配置镜像源"]})]}),T&&!T.installed&&e.jsxs(Ue,{className:"border-orange-600 bg-orange-50 dark:bg-orange-950/20",children:[e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lr,{className:"h-5 w-5 text-orange-600"}),e.jsxs("div",{children:[e.jsx(ct,{className:"text-lg text-orange-900 dark:text-orange-100",children:"Git 未安装"}),e.jsx(us,{className:"text-orange-800 dark:text-orange-200",children:T.error||"请先安装 Git 才能使用插件安装功能"})]})]})}),e.jsx(gt,{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(Ue,{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(Gs,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(pe,{placeholder:"搜索插件...",value:i,onChange:O=>c(O.target.value),className:"pl-9"})]}),e.jsxs(rt,{value:d,onValueChange:m,children:[e.jsx(at,{className:"w-full sm:w-[200px]",children:e.jsx(it,{placeholder:"选择分类"})}),e.jsxs(lt,{children:[e.jsx(ye,{value:"all",children:"全部分类"}),e.jsx(ye,{value:"Group Management",children:"群组管理"}),e.jsx(ye,{value:"Entertainment & Interaction",children:"娱乐互动"}),e.jsx(ye,{value:"Utility Tools",children:"实用工具"}),e.jsx(ye,{value:"Content Generation",children:"内容生成"}),e.jsx(ye,{value:"Multimedia",children:"多媒体"}),e.jsx(ye,{value:"External Integration",children:"外部集成"}),e.jsx(ye,{value:"Data Analysis & Insights",children:"数据分析与洞察"}),e.jsx(ye,{value:"Other",children:"其他"})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Cs,{id:"compatible-only",checked:v,onCheckedChange:O=>g(O===!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(Ml,{value:h,onValueChange:p,className:"w-full",children:e.jsxs($a,{className:"grid w-full grid-cols-3",children:[e.jsxs(bt,{value:"all",children:["全部插件 (",j.length,")"]}),e.jsxs(bt,{value:"installed",children:["已安装 (",j.filter(O=>O.installed).length,")"]}),e.jsxs(bt,{value:"updates",children:["可更新 (",j.filter(O=>O.installed&&$(O)).length,")"]})]})}),M&&M.stage==="loading"&&e.jsx(Ue,{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(ro,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm font-medium",children:[M.operation==="fetch"&&"加载插件列表",M.operation==="install"&&`安装插件${M.plugin_id?`: ${M.plugin_id}`:""}`,M.operation==="uninstall"&&`卸载插件${M.plugin_id?`: ${M.plugin_id}`:""}`,M.operation==="update"&&`更新插件${M.plugin_id?`: ${M.plugin_id}`:""}`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[M.progress,"%"]})]}),e.jsx(_o,{value:M.progress,className:"h-2"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:M.message}),M.operation==="fetch"&&M.total_plugins>0&&e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["已加载 ",M.loaded_plugins," / ",M.total_plugins," 个插件"]})]})}),M&&M.stage==="error"&&M.error&&e.jsx(Ue,{className:"border-destructive bg-destructive/10",children:e.jsx(ot,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lr,{className:"h-5 w-5 text-destructive"}),e.jsxs("div",{children:[e.jsx(ct,{className:"text-lg text-destructive",children:"加载失败"}),e.jsx(us,{className:"text-destructive/80",children:M.error})]})]})})}),w?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(ro,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"加载插件列表中..."})]}):C?e.jsx(Ue,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Lr,{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:C}),e.jsx(q,{onClick:()=>window.location.reload(),children:"重新加载"})]})}):oe.length===0?e.jsx(Ue,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Gs,{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:i||d!=="all"?"尝试调整搜索条件或筛选器":"暂无可用插件"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:oe.map(O=>e.jsxs(Ue,{className:"flex flex-col hover:shadow-lg transition-shadow h-full",children:[e.jsxs(ot,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(ct,{className:"text-xl",children:O.manifest?.name||O.id}),e.jsxs("div",{className:"flex flex-col gap-1",children:[O.manifest?.categories&&O.manifest.categories[0]&&e.jsx(_t,{variant:"secondary",className:"text-xs whitespace-nowrap",children:ny[O.manifest.categories[0]]||O.manifest.categories[0]}),Y(O)]})]}),e.jsx(us,{className:"line-clamp-2",children:O.manifest?.description||"无描述"})]}),e.jsx(gt,{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(Bf,{className:"h-4 w-4"}),e.jsx("span",{children:O.downloads.toLocaleString()})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(tj,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsx("span",{children:O.rating.toFixed(1)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[O.manifest?.keywords&&O.manifest.keywords.slice(0,3).map(L=>e.jsx(_t,{variant:"outline",className:"text-xs",children:L},L)),O.manifest?.keywords&&O.manifest.keywords.length>3&&e.jsxs(_t,{variant:"outline",className:"text-xs",children:["+",O.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",O.manifest?.version||"unknown"," · ",O.manifest?.author?.name||"Unknown"]}),O.manifest?.host_application&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:"支持:"}),e.jsxs("span",{className:"font-medium",children:[O.manifest.host_application.min_version,O.manifest.host_application.max_version?` - ${O.manifest.host_application.max_version}`:" - 最新版本"]})]})]})]})}),e.jsx(pb,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center justify-end gap-2 w-full",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:()=>l(O),children:"查看详情"}),O.installed?$(O)?e.jsxs(q,{size:"sm",disabled:!T?.installed,title:T?.installed?void 0:"Git 未安装",onClick:()=>R(O),children:[e.jsx(xa,{className:"h-4 w-4 mr-1"}),"更新"]}):e.jsxs(q,{variant:"destructive",size:"sm",disabled:!T?.installed,title:T?.installed?void 0:"Git 未安装",onClick:()=>me(O),children:[e.jsx(ft,{className:"h-4 w-4 mr-1"}),"卸载"]}):e.jsxs(q,{size:"sm",disabled:!T?.installed||M?.operation==="install"||D!==null&&!G(O),title:T?.installed?D!==null&&!G(O)?`不兼容当前版本 (需要 ${O.manifest?.host_application?.min_version||"未知"}${O.manifest?.host_application?.max_version?` - ${O.manifest.host_application.max_version}`:"+"},当前 ${D?.version})`:void 0:"Git 未安装",onClick:()=>ae(O),children:[e.jsx(Bf,{className:"h-4 w-4 mr-1"}),M?.operation==="install"&&M?.plugin_id===O.id?"安装中...":"安装"]})]})})]},O.id))}),e.jsx(bs,{open:a!==null,onOpenChange:je,children:a&&a.manifest&&e.jsxs(ms,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(fs,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(hs,{className:"text-2xl",children:a.manifest.name}),e.jsxs(ks,{children:["作者: ",a.manifest.author?.name||"Unknown",a.manifest.author?.url&&e.jsx("a",{href:a.manifest.author.url,target:"_blank",rel:"noopener noreferrer",className:"ml-2 text-primary hover:underline",children:e.jsx(so,{className:"h-3 w-3 inline"})})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[a.manifest.categories&&a.manifest.categories[0]&&e.jsx(_t,{variant:"secondary",children:ny[a.manifest.categories[0]]||a.manifest.categories[0]}),Y(a)]})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["v",a.manifest?.version||"unknown"]}),a.installed&&a.installed_version&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["已安装: v",a.installed_version]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"下载量"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.downloads.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"评分"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(tj,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.rating.toFixed(1)," (",a.review_count,")"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"许可证"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.manifest.license||"Unknown"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"支持版本"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.manifest.host_application?.min_version||"未知",a.manifest.host_application?.max_version?` - ${a.manifest.host_application.max_version}`:" - 最新版本"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"关键词"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.manifest.keywords&&a.manifest.keywords.map(O=>e.jsx(_t,{variant:"outline",children:O},O))})]}),a.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"详细说明"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-line",children:a.detailed_description})]}),!a.detailed_description&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"说明"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.manifest.description||"无描述"})]}),e.jsxs("div",{className:"space-y-2",children:[a.manifest.homepage_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"主页: "}),e.jsx("a",{href:a.manifest.homepage_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:a.manifest.homepage_url})]}),a.manifest.repository_url&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"仓库: "}),e.jsx("a",{href:a.manifest.repository_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:a.manifest.repository_url})]})]})]}),e.jsxs($s,{children:[a.manifest.homepage_url&&e.jsxs(q,{onClick:()=>window.open(a.manifest.homepage_url,"_blank"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"访问主页"]}),a.manifest.repository_url&&e.jsxs(q,{variant:"outline",onClick:()=>window.open(a.manifest.repository_url,"_blank"),children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"查看仓库"]})]})]})})]})})}function p3(){return e.jsx(Ct,{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("div",{className:"flex gap-2",children:[e.jsxs(q,{variant:"outline",size:"sm",children:[e.jsx(xa,{className:"h-4 w-4 mr-2"}),"刷新"]}),e.jsxs(q,{size:"sm",children:[e.jsx(Tn,{className:"h-4 w-4 mr-2"}),"全局设置"]})]})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"已安装插件"}),e.jsx(pd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-2xl font-bold",children:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"正在加载..."})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"已启用"}),e.jsx(Ys,{className:"h-4 w-4 text-green-600"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-2xl font-bold",children:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"运行中的插件"})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"已禁用"}),e.jsx(Tl,{className:"h-4 w-4 text-orange-600"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-2xl font-bold",children:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"未激活的插件"})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(ct,{className:"text-sm font-medium",children:"可更新"}),e.jsx(xa,{className:"h-4 w-4 text-blue-600"})]}),e.jsxs(gt,{children:[e.jsx("div",{className:"text-2xl font-bold",children:"0"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"有新版本可用"})]})]})]}),e.jsxs(Ue,{children:[e.jsxs(ot,{children:[e.jsx(ct,{children:"已安装的插件"}),e.jsx(us,{children:"查看和管理已安装插件的配置"})]}),e.jsx(gt,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 space-y-4",children:[e.jsx(pd,{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:"插件配置功能开发中"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"即将支持插件的启用/禁用、参数配置等功能"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(q,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:"/plugins",children:[e.jsx(so,{className:"h-4 w-4 mr-2"}),"前往插件市场"]})})})]})})]}),e.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[e.jsxs(Ue,{children:[e.jsx(ot,{children:e.jsx(ct,{className:"text-base",children:"即将推出的功能"})}),e.jsx(gt,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-1 mt-0.5",children:e.jsx(Ys,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"插件启用/禁用"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"快速切换插件运行状态"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-1 mt-0.5",children:e.jsx(Ys,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"配置参数编辑"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"可视化编辑插件配置文件"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-1 mt-0.5",children:e.jsx(Ys,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"依赖管理"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"查看和安装插件依赖包"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-1 mt-0.5",children:e.jsx(Ys,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"插件日志"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"查看插件运行日志和错误信息"})]})]})]})})]}),e.jsxs(Ue,{children:[e.jsx(ot,{children:e.jsx(ct,{className:"text-base",children:"开发者工具"})}),e.jsx(gt,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-1 mt-0.5",children:e.jsx(Tn,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"热重载"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"无需重启即可重新加载插件"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-1 mt-0.5",children:e.jsx(Tn,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"配置验证"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"检查配置文件格式和完整性"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-1 mt-0.5",children:e.jsx(Tn,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"性能监控"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"监控插件的资源占用情况"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-full bg-blue-500/10 p-1 mt-0.5",children:e.jsx(Tn,{className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"调试模式"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"详细的调试信息和错误追踪"})]})]})]})})]})]}),e.jsx(Ue,{className:"border-blue-200 bg-blue-50 dark:bg-blue-950/20 dark:border-blue-900",children:e.jsx(gt,{className:"pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Tl,{className:"h-5 w-5 text-blue-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-blue-900 dark:text-blue-100",children:"开发进行中"}),e.jsxs("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:["插件配置功能正在积极开发中。目前您可以通过",e.jsx("strong",{children:"插件市场"}),"安装和卸载插件,完整的配置管理功能即将推出。"]})]})]})})})]})})}function g3(){const s=qn(),{toast:a}=Es(),[l,i]=x.useState([]),[c,d]=x.useState(!0),[m,h]=x.useState(null),[p,v]=x.useState(null),[g,j]=x.useState(!1),[b,w]=x.useState(!1),[S,C]=x.useState({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),N=x.useCallback(async()=>{try{d(!0),h(null);const E=localStorage.getItem("access-token"),B=await fetch("/api/webui/plugins/mirrors",{headers:{Authorization:`Bearer ${E}`}});if(!B.ok)throw new Error("获取镜像源列表失败");const Y=await B.json();i(Y.mirrors||[])}catch(E){const B=E instanceof Error?E.message:"加载镜像源失败";h(B),a({title:"加载失败",description:B,variant:"destructive"})}finally{d(!1)}},[a]);x.useEffect(()=>{N()},[N]);const T=async()=>{try{const E=localStorage.getItem("access-token"),B=await fetch("/api/webui/plugins/mirrors",{method:"POST",headers:{Authorization:`Bearer ${E}`,"Content-Type":"application/json"},body:JSON.stringify(S)});if(!B.ok){const Y=await B.json();throw new Error(Y.detail||"添加镜像源失败")}a({title:"添加成功",description:"镜像源已添加"}),j(!1),C({id:"",name:"",raw_prefix:"",clone_prefix:"",enabled:!0,priority:1}),N()}catch(E){a({title:"添加失败",description:E instanceof Error?E.message:"未知错误",variant:"destructive"})}},P=async()=>{if(p)try{const E=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${p.id}`,{method:"PUT",headers:{Authorization:`Bearer ${E}`,"Content-Type":"application/json"},body:JSON.stringify({name:S.name,raw_prefix:S.raw_prefix,clone_prefix:S.clone_prefix,enabled:S.enabled,priority:S.priority})})).ok)throw new Error("更新镜像源失败");a({title:"更新成功",description:"镜像源已更新"}),w(!1),v(null),N()}catch(E){a({title:"更新失败",description:E instanceof Error?E.message:"未知错误",variant:"destructive"})}},M=async E=>{if(confirm("确定要删除这个镜像源吗?"))try{const B=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${B}`}})).ok)throw new Error("删除镜像源失败");a({title:"删除成功",description:"镜像源已删除"}),N()}catch(B){a({title:"删除失败",description:B instanceof Error?B.message:"未知错误",variant:"destructive"})}},k=async E=>{try{const B=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${E.id}`,{method:"PUT",headers:{Authorization:`Bearer ${B}`,"Content-Type":"application/json"},body:JSON.stringify({enabled:!E.enabled})})).ok)throw new Error("更新状态失败");N()}catch(B){a({title:"更新失败",description:B instanceof Error?B.message:"未知错误",variant:"destructive"})}},D=E=>{v(E),C({id:E.id,name:E.name,raw_prefix:E.raw_prefix,clone_prefix:E.clone_prefix,enabled:E.enabled,priority:E.priority}),w(!0)},A=async(E,B)=>{const Y=B==="up"?E.priority-1:E.priority+1;if(!(Y<1))try{const G=localStorage.getItem("access-token");if(!(await fetch(`/api/webui/plugins/mirrors/${E.id}`,{method:"PUT",headers:{Authorization:`Bearer ${G}`,"Content-Type":"application/json"},body:JSON.stringify({priority:Y})})).ok)throw new Error("更新优先级失败");N()}catch(G){a({title:"更新失败",description:G instanceof Error?G.message:"未知错误",variant:"destructive"})}};return e.jsx(Ct,{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(q,{variant:"ghost",size:"icon",onClick:()=>s({to:"/plugins"}),children:e.jsx(My,{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(q,{onClick:()=>j(!0),children:[e.jsx(ys,{className:"h-4 w-4 mr-2"}),"添加镜像源"]})]}),c?e.jsx(Ue,{className:"p-6",children:e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ro,{className:"h-8 w-8 animate-spin text-primary"})})}):m?e.jsx(Ue,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Lr,{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:m}),e.jsx(q,{onClick:N,children:"重新加载"})]})}):e.jsxs(Ue,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsxs(Rl,{children:[e.jsx(zl,{children:e.jsxs(ns,{children:[e.jsx(He,{children:"状态"}),e.jsx(He,{children:"名称"}),e.jsx(He,{children:"ID"}),e.jsx(He,{children:"优先级"}),e.jsx(He,{className:"text-right",children:"操作"})]})}),e.jsx(Pl,{children:l.map(E=>e.jsxs(ns,{children:[e.jsx(Ae,{children:e.jsx(Ze,{checked:E.enabled,onCheckedChange:()=>k(E)})}),e.jsx(Ae,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:E.name}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Raw: ",E.raw_prefix]})]})}),e.jsx(Ae,{children:e.jsx(_t,{variant:"outline",children:E.id})}),e.jsx(Ae,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono",children:E.priority}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(q,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>A(E,"up"),disabled:E.priority===1,children:e.jsx(Pf,{className:"h-3 w-3"})}),e.jsx(q,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>A(E,"down"),children:e.jsx(lo,{className:"h-3 w-3"})})]})]})}),e.jsx(Ae,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(q,{variant:"ghost",size:"icon",onClick:()=>D(E),children:e.jsx(Yr,{className:"h-4 w-4"})}),e.jsx(q,{variant:"ghost",size:"icon",onClick:()=>M(E.id),children:e.jsx(ft,{className:"h-4 w-4 text-destructive"})})]})})]},E.id))})]})}),e.jsx("div",{className:"md:hidden p-4 space-y-4",children:l.map(E=>e.jsx(Ue,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:E.name}),E.enabled&&e.jsx(_t,{variant:"default",className:"text-xs",children:"启用"})]}),e.jsx(_t,{variant:"outline",className:"mt-1 text-xs",children:E.id})]}),e.jsx(Ze,{checked:E.enabled,onCheckedChange:()=>k(E)})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Raw: "}),e.jsx("span",{className:"break-all",children:E.raw_prefix})]}),e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"优先级: "}),e.jsx("span",{className:"font-mono",children:E.priority})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t",children:[e.jsxs(q,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>D(E),children:[e.jsx(Yr,{className:"h-4 w-4 mr-1"}),"编辑"]}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>A(E,"up"),disabled:E.priority===1,children:e.jsx(Pf,{className:"h-4 w-4"})}),e.jsx(q,{variant:"outline",size:"sm",onClick:()=>A(E,"down"),children:e.jsx(lo,{className:"h-4 w-4"})}),e.jsx(q,{variant:"destructive",size:"sm",onClick:()=>M(E.id),children:e.jsx(ft,{className:"h-4 w-4"})})]})]})},E.id))})]}),e.jsx(bs,{open:g,onOpenChange:j,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(fs,{children:[e.jsx(hs,{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(U,{htmlFor:"add-id",children:"镜像源 ID *"}),e.jsx(pe,{id:"add-id",placeholder:"例如: my-mirror",value:S.id,onChange:E=>C({...S,id:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"add-name",children:"名称 *"}),e.jsx(pe,{id:"add-name",placeholder:"例如: 我的镜像源",value:S.name,onChange:E=>C({...S,name:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"add-raw",children:"Raw 文件前缀 *"}),e.jsx(pe,{id:"add-raw",placeholder:"https://example.com/raw",value:S.raw_prefix,onChange:E=>C({...S,raw_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"add-clone",children:"克隆前缀 *"}),e.jsx(pe,{id:"add-clone",placeholder:"https://example.com/clone",value:S.clone_prefix,onChange:E=>C({...S,clone_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"add-priority",children:"优先级"}),e.jsx(pe,{id:"add-priority",type:"number",min:"1",value:S.priority,onChange:E=>C({...S,priority:parseInt(E.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"add-enabled",checked:S.enabled,onCheckedChange:E=>C({...S,enabled:E})}),e.jsx(U,{htmlFor:"add-enabled",children:"启用此镜像源"})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>j(!1),children:"取消"}),e.jsx(q,{onClick:T,children:"添加"})]})]})}),e.jsx(bs,{open:b,onOpenChange:w,children:e.jsxs(ms,{className:"max-w-lg",children:[e.jsxs(fs,{children:[e.jsx(hs,{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(U,{children:"镜像源 ID"}),e.jsx(pe,{value:S.id,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit-name",children:"名称 *"}),e.jsx(pe,{id:"edit-name",value:S.name,onChange:E=>C({...S,name:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit-raw",children:"Raw 文件前缀 *"}),e.jsx(pe,{id:"edit-raw",value:S.raw_prefix,onChange:E=>C({...S,raw_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit-clone",children:"克隆前缀 *"}),e.jsx(pe,{id:"edit-clone",value:S.clone_prefix,onChange:E=>C({...S,clone_prefix:E.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(U,{htmlFor:"edit-priority",children:"优先级"}),e.jsx(pe,{id:"edit-priority",type:"number",min:"1",value:S.priority,onChange:E=>C({...S,priority:parseInt(E.target.value)||1})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"数字越小优先级越高"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ze,{id:"edit-enabled",checked:S.enabled,onCheckedChange:E=>C({...S,enabled:E})}),e.jsx(U,{htmlFor:"edit-enabled",children:"启用此镜像源"})]})]}),e.jsxs($s,{children:[e.jsx(q,{variant:"outline",onClick:()=>w(!1),children:"取消"}),e.jsx(q,{onClick:P,children:"保存"})]})]})})]})})}const v3=Jr("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"}}),nw=x.forwardRef(({className:s,size:a,abbrTitle:l,children:i,...c},d)=>e.jsx("kbd",{className:Z(v3({size:a,className:s})),ref:d,...c,children:l?e.jsx("abbr",{title:l,children:i}):i}));nw.displayName="Kbd";const j3=[{icon:fd,title:"首页",description:"查看仪表板概览",path:"/",category:"概览"},{icon:ph,title:"麦麦主程序配置",description:"配置麦麦的核心设置",path:"/config/bot",category:"配置"},{icon:Dy,title:"麦麦模型提供商配置",description:"配置模型提供商",path:"/config/modelProvider",category:"配置"},{icon:Oy,title:"麦麦模型配置",description:"配置模型参数",path:"/config/model",category:"配置"},{icon:gh,title:"表情包管理",description:"管理麦麦的表情包",path:"/resource/emoji",category:"资源"},{icon:po,title:"表达方式管理",description:"管理麦麦的表达方式",path:"/resource/expression",category:"资源"},{icon:Ay,title:"人物信息管理",description:"管理人物信息",path:"/resource/person",category:"资源"},{icon:V2,title:"统计信息",description:"查看使用统计",path:"/statistics",category:"监控"},{icon:pd,title:"插件市场",description:"浏览和安装插件",path:"/plugins",category:"扩展"},{icon:hd,title:"日志查看器",description:"查看系统日志",path:"/logs",category:"监控"},{icon:Tn,title:"系统设置",description:"配置系统参数",path:"/settings",category:"系统"}];function y3({open:s,onOpenChange:a}){const[l,i]=x.useState(""),[c,d]=x.useState(0),m=qn(),h=j3.filter(g=>g.title.toLowerCase().includes(l.toLowerCase())||g.description.toLowerCase().includes(l.toLowerCase())||g.category.toLowerCase().includes(l.toLowerCase()));x.useEffect(()=>{s&&(i(""),d(0))},[s]);const p=x.useCallback(g=>{m({to:g}),a(!1)},[m,a]),v=x.useCallback(g=>{g.key==="ArrowDown"?(g.preventDefault(),d(j=>(j+1)%h.length)):g.key==="ArrowUp"?(g.preventDefault(),d(j=>(j-1+h.length)%h.length)):g.key==="Enter"&&h[c]&&(g.preventDefault(),p(h[c].path))},[h,c,p]);return e.jsx(bs,{open:s,onOpenChange:a,children:e.jsxs(ms,{className:"max-w-2xl p-0 gap-0",children:[e.jsxs(fs,{className:"px-4 pt-4 pb-0",children:[e.jsx(hs,{className:"sr-only",children:"搜索"}),e.jsxs("div",{className:"relative",children:[e.jsx(Gs,{className:"absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),e.jsx(pe,{value:l,onChange:g=>{i(g.target.value),d(0)},onKeyDown:v,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(Ct,{className:"h-[400px]",children:h.length>0?e.jsx("div",{className:"p-2",children:h.map((g,j)=>{const b=g.icon;return e.jsxs("button",{onClick:()=>p(g.path),onMouseEnter:()=>d(j),className:Z("w-full flex items-center gap-3 px-3 py-2.5 rounded-md text-left transition-colors",j===c?"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:g.title}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:g.description})]}),e.jsx("div",{className:"text-xs text-muted-foreground px-2 py-1 bg-muted rounded",children:g.category})]},g.path)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Gs,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"未找到匹配的页面":"输入关键词开始搜索"})]})})}),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 b3(s){const a=N3(s),l=x.forwardRef((i,c)=>{const{children:d,...m}=i,h=x.Children.toArray(d),p=h.find(S3);if(p){const v=p.props.children,g=h.map(j=>j===p?x.Children.count(v)>1?x.Children.only(null):x.isValidElement(v)?v.props.children:null:j);return e.jsx(a,{...m,ref:c,children:x.isValidElement(v)?x.cloneElement(v,void 0,g):null})}return e.jsx(a,{...m,ref:c,children:d})});return l.displayName=`${s}.Slot`,l}function N3(s){const a=x.forwardRef((l,i)=>{const{children:c,...d}=l;if(x.isValidElement(c)){const m=C3(c),h=_3(d,c.props);return c.type!==x.Fragment&&(h.ref=i?Ga(i,m):m),x.cloneElement(c,h)}return x.Children.count(c)>1?x.Children.only(null):null});return a.displayName=`${s}.SlotClone`,a}var w3=Symbol("radix.slottable");function S3(s){return x.isValidElement(s)&&typeof s.type=="function"&&"__radixId"in s.type&&s.type.__radixId===w3}function _3(s,a){const l={...a};for(const i in a){const c=s[i],d=a[i];/^on[A-Z]/.test(i)?c&&d?l[i]=(...h)=>{const p=d(...h);return c(...h),p}:c&&(l[i]=c):i==="style"?l[i]={...c,...d}:i==="className"&&(l[i]=[c,d].filter(Boolean).join(" "))}return{...s,...l}}function C3(s){let a=Object.getOwnPropertyDescriptor(s.props,"ref")?.get,l=a&&"isReactWarning"in a&&a.isReactWarning;return l?s.ref:(a=Object.getOwnPropertyDescriptor(s,"ref")?.get,l=a&&"isReactWarning"in a&&a.isReactWarning,l?s.props.ref:s.props.ref||s.ref)}var eh=["Enter"," "],k3=["ArrowDown","PageUp","Home"],aw=["ArrowUp","PageDown","End"],T3=[...k3,...aw],E3={ltr:[...eh,"ArrowRight"],rtl:[...eh,"ArrowLeft"]},M3={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Do="Menu",[mo,D3,O3]=_d(Do),[Ul,lw]=Dn(Do,[O3,Wr,Pd]),Oo=Wr(),rw=Pd(),[iw,el]=Ul(Do),[A3,Ao]=Ul(Do),ow=s=>{const{__scopeMenu:a,open:l=!1,children:i,dir:c,onOpenChange:d,modal:m=!0}=s,h=Oo(a),[p,v]=x.useState(null),g=x.useRef(!1),j=ws(d),b=xo(c);return x.useEffect(()=>{const w=()=>{g.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>g.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),e.jsx(Ed,{...h,children:e.jsx(iw,{scope:a,open:l,onOpenChange:j,content:p,onContentChange:v,children:e.jsx(A3,{scope:a,onClose:x.useCallback(()=>j(!1),[j]),isUsingKeyboardRef:g,dir:b,modal:m,children:i})})})};ow.displayName=Do;var R3="MenuAnchor",qh=x.forwardRef((s,a)=>{const{__scopeMenu:l,...i}=s,c=Oo(l);return e.jsx(Md,{...c,...i,ref:a})});qh.displayName=R3;var Vh="MenuPortal",[z3,cw]=Ul(Vh,{forceMount:void 0}),dw=s=>{const{__scopeMenu:a,forceMount:l,children:i,container:c}=s,d=el(Vh,a);return e.jsx(z3,{scope:a,forceMount:l,children:e.jsx(Is,{present:l||d.open,children:e.jsx(Td,{asChild:!0,container:c,children:i})})})};dw.displayName=Vh;var yn="MenuContent",[P3,Gh]=Ul(yn),uw=x.forwardRef((s,a)=>{const l=cw(yn,s.__scopeMenu),{forceMount:i=l.forceMount,...c}=s,d=el(yn,s.__scopeMenu),m=Ao(yn,s.__scopeMenu);return e.jsx(mo.Provider,{scope:s.__scopeMenu,children:e.jsx(Is,{present:i||d.open,children:e.jsx(mo.Slot,{scope:s.__scopeMenu,children:m.modal?e.jsx(L3,{...c,ref:a}):e.jsx(B3,{...c,ref:a})})})})}),L3=x.forwardRef((s,a)=>{const l=el(yn,s.__scopeMenu),i=x.useRef(null),c=Tt(a,i);return x.useEffect(()=>{const d=i.current;if(d)return by(d)},[]),e.jsx($h,{...s,ref:c,trapFocus:l.open,disableOutsidePointerEvents:l.open,disableOutsideScroll:!0,onFocusOutside:be(s.onFocusOutside,d=>d.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>l.onOpenChange(!1)})}),B3=x.forwardRef((s,a)=>{const l=el(yn,s.__scopeMenu);return e.jsx($h,{...s,ref:a,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>l.onOpenChange(!1)})}),U3=b3("MenuContent.ScrollLock"),$h=x.forwardRef((s,a)=>{const{__scopeMenu:l,loop:i=!1,trapFocus:c,onOpenAutoFocus:d,onCloseAutoFocus:m,disableOutsidePointerEvents:h,onEntryFocus:p,onEscapeKeyDown:v,onPointerDownOutside:g,onFocusOutside:j,onInteractOutside:b,onDismiss:w,disableOutsideScroll:S,...C}=s,N=el(yn,l),T=Ao(yn,l),P=Oo(l),M=rw(l),k=D3(l),[D,A]=x.useState(null),E=x.useRef(null),B=Tt(a,E,N.onContentChange),Y=x.useRef(0),G=x.useRef(""),$=x.useRef(0),oe=x.useRef(null),je=x.useRef("right"),ae=x.useRef(0),me=S?Ny:x.Fragment,R=S?{as:U3,allowPinchZoom:!0}:void 0,O=ee=>{const le=G.current+ee,xe=k().filter(de=>!de.disabled),F=document.activeElement,W=xe.find(de=>de.ref.current===F)?.textValue,fe=xe.map(de=>de.textValue),I=Q3(fe,le,W),ve=xe.find(de=>de.textValue===I)?.ref.current;(function de(Ce){G.current=Ce,window.clearTimeout(Y.current),Ce!==""&&(Y.current=window.setTimeout(()=>de(""),1e3))})(le),ve&&setTimeout(()=>ve.focus())};x.useEffect(()=>()=>window.clearTimeout(Y.current),[]),wy();const L=x.useCallback(ee=>je.current===oe.current?.side&&J3(ee,oe.current?.area),[]);return e.jsx(P3,{scope:l,searchRef:G,onItemEnter:x.useCallback(ee=>{L(ee)&&ee.preventDefault()},[L]),onItemLeave:x.useCallback(ee=>{L(ee)||(E.current?.focus(),A(null))},[L]),onTriggerLeave:x.useCallback(ee=>{L(ee)&&ee.preventDefault()},[L]),pointerGraceTimerRef:$,onPointerGraceIntentChange:x.useCallback(ee=>{oe.current=ee},[]),children:e.jsx(me,{...R,children:e.jsx(Sy,{asChild:!0,trapped:c,onMountAutoFocus:be(d,ee=>{ee.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:m,children:e.jsx(fh,{asChild:!0,disableOutsidePointerEvents:h,onEscapeKeyDown:v,onPointerDownOutside:g,onFocusOutside:j,onInteractOutside:b,onDismiss:w,children:e.jsx(Nb,{asChild:!0,...M,dir:T.dir,orientation:"vertical",loop:i,currentTabStopId:D,onCurrentTabStopIdChange:A,onEntryFocus:be(p,ee=>{T.isUsingKeyboardRef.current||ee.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(hh,{role:"menu","aria-orientation":"vertical","data-state":Tw(N.open),"data-radix-menu-content":"",dir:T.dir,...P,...C,ref:B,style:{outline:"none",...C.style},onKeyDown:be(C.onKeyDown,ee=>{const xe=ee.target.closest("[data-radix-menu-content]")===ee.currentTarget,F=ee.ctrlKey||ee.altKey||ee.metaKey,W=ee.key.length===1;xe&&(ee.key==="Tab"&&ee.preventDefault(),!F&&W&&O(ee.key));const fe=E.current;if(ee.target!==fe||!T3.includes(ee.key))return;ee.preventDefault();const ve=k().filter(de=>!de.disabled).map(de=>de.ref.current);aw.includes(ee.key)&&ve.reverse(),X3(ve)}),onBlur:be(s.onBlur,ee=>{ee.currentTarget.contains(ee.target)||(window.clearTimeout(Y.current),G.current="")}),onPointerMove:be(s.onPointerMove,fo(ee=>{const le=ee.target,xe=ae.current!==ee.clientX;if(ee.currentTarget.contains(le)&&xe){const F=ee.clientX>ae.current?"right":"left";je.current=F,ae.current=ee.clientX}}))})})})})})})});uw.displayName=yn;var H3="MenuGroup",Ih=x.forwardRef((s,a)=>{const{__scopeMenu:l,...i}=s;return e.jsx(dt.div,{role:"group",...i,ref:a})});Ih.displayName=H3;var F3="MenuLabel",mw=x.forwardRef((s,a)=>{const{__scopeMenu:l,...i}=s;return e.jsx(dt.div,{...i,ref:a})});mw.displayName=F3;var wd="MenuItem",ay="menu.itemSelect",Wd=x.forwardRef((s,a)=>{const{disabled:l=!1,onSelect:i,...c}=s,d=x.useRef(null),m=Ao(wd,s.__scopeMenu),h=Gh(wd,s.__scopeMenu),p=Tt(a,d),v=x.useRef(!1),g=()=>{const j=d.current;if(!l&&j){const b=new CustomEvent(ay,{bubbles:!0,cancelable:!0});j.addEventListener(ay,w=>i?.(w),{once:!0}),Cy(j,b),b.defaultPrevented?v.current=!1:m.onClose()}};return e.jsx(fw,{...c,ref:p,disabled:l,onClick:be(s.onClick,g),onPointerDown:j=>{s.onPointerDown?.(j),v.current=!0},onPointerUp:be(s.onPointerUp,j=>{v.current||j.currentTarget?.click()}),onKeyDown:be(s.onKeyDown,j=>{const b=h.searchRef.current!=="";l||b&&j.key===" "||eh.includes(j.key)&&(j.currentTarget.click(),j.preventDefault())})})});Wd.displayName=wd;var fw=x.forwardRef((s,a)=>{const{__scopeMenu:l,disabled:i=!1,textValue:c,...d}=s,m=Gh(wd,l),h=rw(l),p=x.useRef(null),v=Tt(a,p),[g,j]=x.useState(!1),[b,w]=x.useState("");return x.useEffect(()=>{const S=p.current;S&&w((S.textContent??"").trim())},[d.children]),e.jsx(mo.ItemSlot,{scope:l,disabled:i,textValue:c??b,children:e.jsx(wb,{asChild:!0,...h,focusable:!i,children:e.jsx(dt.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...d,ref:v,onPointerMove:be(s.onPointerMove,fo(S=>{i?m.onItemLeave(S):(m.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:be(s.onPointerLeave,fo(S=>m.onItemLeave(S))),onFocus:be(s.onFocus,()=>j(!0)),onBlur:be(s.onBlur,()=>j(!1))})})})}),Y3="MenuCheckboxItem",hw=x.forwardRef((s,a)=>{const{checked:l=!1,onCheckedChange:i,...c}=s;return e.jsx(jw,{scope:s.__scopeMenu,checked:l,children:e.jsx(Wd,{role:"menuitemcheckbox","aria-checked":Sd(l)?"mixed":l,...c,ref:a,"data-state":Kh(l),onSelect:be(c.onSelect,()=>i?.(Sd(l)?!0:!l),{checkForDefaultPrevented:!1})})})});hw.displayName=Y3;var xw="MenuRadioGroup",[q3,V3]=Ul(xw,{value:void 0,onValueChange:()=>{}}),pw=x.forwardRef((s,a)=>{const{value:l,onValueChange:i,...c}=s,d=ws(i);return e.jsx(q3,{scope:s.__scopeMenu,value:l,onValueChange:d,children:e.jsx(Ih,{...c,ref:a})})});pw.displayName=xw;var gw="MenuRadioItem",vw=x.forwardRef((s,a)=>{const{value:l,...i}=s,c=V3(gw,s.__scopeMenu),d=l===c.value;return e.jsx(jw,{scope:s.__scopeMenu,checked:d,children:e.jsx(Wd,{role:"menuitemradio","aria-checked":d,...i,ref:a,"data-state":Kh(d),onSelect:be(i.onSelect,()=>c.onValueChange?.(l),{checkForDefaultPrevented:!1})})})});vw.displayName=gw;var Wh="MenuItemIndicator",[jw,G3]=Ul(Wh,{checked:!1}),yw=x.forwardRef((s,a)=>{const{__scopeMenu:l,forceMount:i,...c}=s,d=G3(Wh,l);return e.jsx(Is,{present:i||Sd(d.checked)||d.checked===!0,children:e.jsx(dt.span,{...c,ref:a,"data-state":Kh(d.checked)})})});yw.displayName=Wh;var $3="MenuSeparator",bw=x.forwardRef((s,a)=>{const{__scopeMenu:l,...i}=s;return e.jsx(dt.div,{role:"separator","aria-orientation":"horizontal",...i,ref:a})});bw.displayName=$3;var I3="MenuArrow",Nw=x.forwardRef((s,a)=>{const{__scopeMenu:l,...i}=s,c=Oo(l);return e.jsx(xh,{...c,...i,ref:a})});Nw.displayName=I3;var Xh="MenuSub",[W3,ww]=Ul(Xh),Sw=s=>{const{__scopeMenu:a,children:l,open:i=!1,onOpenChange:c}=s,d=el(Xh,a),m=Oo(a),[h,p]=x.useState(null),[v,g]=x.useState(null),j=ws(c);return x.useEffect(()=>(d.open===!1&&j(!1),()=>j(!1)),[d.open,j]),e.jsx(Ed,{...m,children:e.jsx(iw,{scope:a,open:i,onOpenChange:j,content:v,onContentChange:g,children:e.jsx(W3,{scope:a,contentId:jn(),triggerId:jn(),trigger:h,onTriggerChange:p,children:l})})})};Sw.displayName=Xh;var eo="MenuSubTrigger",_w=x.forwardRef((s,a)=>{const l=el(eo,s.__scopeMenu),i=Ao(eo,s.__scopeMenu),c=ww(eo,s.__scopeMenu),d=Gh(eo,s.__scopeMenu),m=x.useRef(null),{pointerGraceTimerRef:h,onPointerGraceIntentChange:p}=d,v={__scopeMenu:s.__scopeMenu},g=x.useCallback(()=>{m.current&&window.clearTimeout(m.current),m.current=null},[]);return x.useEffect(()=>g,[g]),x.useEffect(()=>{const j=h.current;return()=>{window.clearTimeout(j),p(null)}},[h,p]),e.jsx(qh,{asChild:!0,...v,children:e.jsx(fw,{id:c.triggerId,"aria-haspopup":"menu","aria-expanded":l.open,"aria-controls":c.contentId,"data-state":Tw(l.open),...s,ref:Ga(a,c.onTriggerChange),onClick:j=>{s.onClick?.(j),!(s.disabled||j.defaultPrevented)&&(j.currentTarget.focus(),l.open||l.onOpenChange(!0))},onPointerMove:be(s.onPointerMove,fo(j=>{d.onItemEnter(j),!j.defaultPrevented&&!s.disabled&&!l.open&&!m.current&&(d.onPointerGraceIntentChange(null),m.current=window.setTimeout(()=>{l.onOpenChange(!0),g()},100))})),onPointerLeave:be(s.onPointerLeave,fo(j=>{g();const b=l.content?.getBoundingClientRect();if(b){const w=l.content?.dataset.side,S=w==="right",C=S?-5:5,N=b[S?"left":"right"],T=b[S?"right":"left"];d.onPointerGraceIntentChange({area:[{x:j.clientX+C,y:j.clientY},{x:N,y:b.top},{x:T,y:b.top},{x:T,y:b.bottom},{x:N,y:b.bottom}],side:w}),window.clearTimeout(h.current),h.current=window.setTimeout(()=>d.onPointerGraceIntentChange(null),300)}else{if(d.onTriggerLeave(j),j.defaultPrevented)return;d.onPointerGraceIntentChange(null)}})),onKeyDown:be(s.onKeyDown,j=>{const b=d.searchRef.current!=="";s.disabled||b&&j.key===" "||E3[i.dir].includes(j.key)&&(l.onOpenChange(!0),l.content?.focus(),j.preventDefault())})})})});_w.displayName=eo;var Cw="MenuSubContent",kw=x.forwardRef((s,a)=>{const l=cw(yn,s.__scopeMenu),{forceMount:i=l.forceMount,...c}=s,d=el(yn,s.__scopeMenu),m=Ao(yn,s.__scopeMenu),h=ww(Cw,s.__scopeMenu),p=x.useRef(null),v=Tt(a,p);return e.jsx(mo.Provider,{scope:s.__scopeMenu,children:e.jsx(Is,{present:i||d.open,children:e.jsx(mo.Slot,{scope:s.__scopeMenu,children:e.jsx($h,{id:h.contentId,"aria-labelledby":h.triggerId,...c,ref:v,align:"start",side:m.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:g=>{m.isUsingKeyboardRef.current&&p.current?.focus(),g.preventDefault()},onCloseAutoFocus:g=>g.preventDefault(),onFocusOutside:be(s.onFocusOutside,g=>{g.target!==h.trigger&&d.onOpenChange(!1)}),onEscapeKeyDown:be(s.onEscapeKeyDown,g=>{m.onClose(),g.preventDefault()}),onKeyDown:be(s.onKeyDown,g=>{const j=g.currentTarget.contains(g.target),b=M3[m.dir].includes(g.key);j&&b&&(d.onOpenChange(!1),h.trigger?.focus(),g.preventDefault())})})})})})});kw.displayName=Cw;function Tw(s){return s?"open":"closed"}function Sd(s){return s==="indeterminate"}function Kh(s){return Sd(s)?"indeterminate":s?"checked":"unchecked"}function X3(s){const a=document.activeElement;for(const l of s)if(l===a||(l.focus(),document.activeElement!==a))return}function K3(s,a){return s.map((l,i)=>s[(a+i)%s.length])}function Q3(s,a,l){const c=a.length>1&&Array.from(a).every(v=>v===a[0])?a[0]:a,d=l?s.indexOf(l):-1;let m=K3(s,Math.max(d,0));c.length===1&&(m=m.filter(v=>v!==l));const p=m.find(v=>v.toLowerCase().startsWith(c.toLowerCase()));return p!==l?p:void 0}function Z3(s,a){const{x:l,y:i}=s;let c=!1;for(let d=0,m=a.length-1;di!=b>i&&l<(j-v)*(i-g)/(b-g)+v&&(c=!c)}return c}function J3(s,a){if(!a)return!1;const l={x:s.clientX,y:s.clientY};return Z3(l,a)}function fo(s){return a=>a.pointerType==="mouse"?s(a):void 0}var e5=ow,t5=qh,s5=dw,n5=uw,a5=Ih,l5=mw,r5=Wd,i5=hw,o5=pw,c5=vw,d5=yw,u5=bw,m5=Nw,f5=Sw,h5=_w,x5=kw,Qh="ContextMenu",[p5]=Dn(Qh,[lw]),Ms=lw(),[g5,Ew]=p5(Qh),Mw=s=>{const{__scopeContextMenu:a,children:l,onOpenChange:i,dir:c,modal:d=!0}=s,[m,h]=x.useState(!1),p=Ms(a),v=ws(i),g=x.useCallback(j=>{h(j),v(j)},[v]);return e.jsx(g5,{scope:a,open:m,onOpenChange:g,modal:d,children:e.jsx(e5,{...p,dir:c,open:m,onOpenChange:g,modal:d,children:l})})};Mw.displayName=Qh;var Dw="ContextMenuTrigger",Ow=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,disabled:i=!1,...c}=s,d=Ew(Dw,l),m=Ms(l),h=x.useRef({x:0,y:0}),p=x.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...h.current})}),v=x.useRef(0),g=x.useCallback(()=>window.clearTimeout(v.current),[]),j=b=>{h.current={x:b.clientX,y:b.clientY},d.onOpenChange(!0)};return x.useEffect(()=>g,[g]),x.useEffect(()=>void(i&&g()),[i,g]),e.jsxs(e.Fragment,{children:[e.jsx(t5,{...m,virtualRef:p}),e.jsx(dt.span,{"data-state":d.open?"open":"closed","data-disabled":i?"":void 0,...c,ref:a,style:{WebkitTouchCallout:"none",...s.style},onContextMenu:i?s.onContextMenu:be(s.onContextMenu,b=>{g(),j(b),b.preventDefault()}),onPointerDown:i?s.onPointerDown:be(s.onPointerDown,ld(b=>{g(),v.current=window.setTimeout(()=>j(b),700)})),onPointerMove:i?s.onPointerMove:be(s.onPointerMove,ld(g)),onPointerCancel:i?s.onPointerCancel:be(s.onPointerCancel,ld(g)),onPointerUp:i?s.onPointerUp:be(s.onPointerUp,ld(g))})]})});Ow.displayName=Dw;var v5="ContextMenuPortal",Aw=s=>{const{__scopeContextMenu:a,...l}=s,i=Ms(a);return e.jsx(s5,{...i,...l})};Aw.displayName=v5;var Rw="ContextMenuContent",zw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ew(Rw,l),d=Ms(l),m=x.useRef(!1);return e.jsx(n5,{...d,...i,ref:a,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:h=>{s.onCloseAutoFocus?.(h),!h.defaultPrevented&&m.current&&h.preventDefault(),m.current=!1},onInteractOutside:h=>{s.onInteractOutside?.(h),!h.defaultPrevented&&!c.modal&&(m.current=!0)},style:{...s.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});zw.displayName=Rw;var j5="ContextMenuGroup",y5=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(a5,{...c,...i,ref:a})});y5.displayName=j5;var b5="ContextMenuLabel",Pw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(l5,{...c,...i,ref:a})});Pw.displayName=b5;var N5="ContextMenuItem",Lw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(r5,{...c,...i,ref:a})});Lw.displayName=N5;var w5="ContextMenuCheckboxItem",Bw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(i5,{...c,...i,ref:a})});Bw.displayName=w5;var S5="ContextMenuRadioGroup",_5=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(o5,{...c,...i,ref:a})});_5.displayName=S5;var C5="ContextMenuRadioItem",Uw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(c5,{...c,...i,ref:a})});Uw.displayName=C5;var k5="ContextMenuItemIndicator",Hw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(d5,{...c,...i,ref:a})});Hw.displayName=k5;var T5="ContextMenuSeparator",Fw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(u5,{...c,...i,ref:a})});Fw.displayName=T5;var E5="ContextMenuArrow",M5=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(m5,{...c,...i,ref:a})});M5.displayName=E5;var Yw="ContextMenuSub",qw=s=>{const{__scopeContextMenu:a,children:l,onOpenChange:i,open:c,defaultOpen:d}=s,m=Ms(a),[h,p]=Qa({prop:c,defaultProp:d??!1,onChange:i,caller:Yw});return e.jsx(f5,{...m,open:h,onOpenChange:p,children:l})};qw.displayName=Yw;var D5="ContextMenuSubTrigger",Vw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(h5,{...c,...i,ref:a})});Vw.displayName=D5;var O5="ContextMenuSubContent",Gw=x.forwardRef((s,a)=>{const{__scopeContextMenu:l,...i}=s,c=Ms(l);return e.jsx(x5,{...c,...i,ref:a,style:{...s.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Gw.displayName=O5;function ld(s){return a=>a.pointerType!=="mouse"?s(a):void 0}var A5=Mw,R5=Ow,z5=Aw,$w=zw,Iw=Pw,Ww=Lw,Xw=Bw,Kw=Uw,Qw=Hw,Zw=Fw,P5=qw,Jw=Vw,e1=Gw;const L5=A5,B5=R5,U5=P5,t1=x.forwardRef(({className:s,inset:a,children:l,...i},c)=>e.jsxs(Jw,{ref:c,className:Z("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",a&&"pl-8",s),...i,children:[l,e.jsx(Al,{className:"ml-auto h-4 w-4"})]}));t1.displayName=Jw.displayName;const s1=x.forwardRef(({className:s,...a},l)=>e.jsx(e1,{ref:l,className:Z("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 origin-[--radix-context-menu-content-transform-origin]",s),...a}));s1.displayName=e1.displayName;const n1=x.forwardRef(({className:s,...a},l)=>e.jsx(z5,{children:e.jsx($w,{ref:l,className:Z("z-50 max-h-[--radix-context-menu-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-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 origin-[--radix-context-menu-content-transform-origin]",s),...a})}));n1.displayName=$w.displayName;const kn=x.forwardRef(({className:s,inset:a,...l},i)=>e.jsx(Ww,{ref:i,className:Z("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",s),...l}));kn.displayName=Ww.displayName;const H5=x.forwardRef(({className:s,children:a,checked:l,...i},c)=>e.jsxs(Xw,{ref:c,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:l,...i,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Qw,{children:e.jsx(Cl,{className:"h-4 w-4"})})}),a]}));H5.displayName=Xw.displayName;const F5=x.forwardRef(({className:s,children:a,...l},i)=>e.jsxs(Kw,{ref:i,className:Z("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...l,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Qw,{children:e.jsx(G2,{className:"h-2 w-2 fill-current"})})}),a]}));F5.displayName=Kw.displayName;const Y5=x.forwardRef(({className:s,inset:a,...l},i)=>e.jsx(Iw,{ref:i,className:Z("px-2 py-1.5 text-sm font-semibold text-foreground",a&&"pl-8",s),...l}));Y5.displayName=Iw.displayName;const to=x.forwardRef(({className:s,...a},l)=>e.jsx(Zw,{ref:l,className:Z("-mx-1 my-1 h-px bg-border",s),...a}));to.displayName=Zw.displayName;const Pr=({className:s,...a})=>e.jsx("span",{className:Z("ml-auto text-xs tracking-widest text-muted-foreground",s),...a});Pr.displayName="ContextMenuShortcut";var q5=Symbol("radix.slottable");function V5(s){const a=({children:l})=>e.jsx(e.Fragment,{children:l});return a.displayName=`${s}.Slottable`,a.__radixId=q5,a}var[Xd]=Dn("Tooltip",[Wr]),Kd=Wr(),a1="TooltipProvider",G5=700,th="tooltip.open",[$5,Zh]=Xd(a1),l1=s=>{const{__scopeTooltip:a,delayDuration:l=G5,skipDelayDuration:i=300,disableHoverableContent:c=!1,children:d}=s,m=x.useRef(!0),h=x.useRef(!1),p=x.useRef(0);return x.useEffect(()=>{const v=p.current;return()=>window.clearTimeout(v)},[]),e.jsx($5,{scope:a,isOpenDelayedRef:m,delayDuration:l,onOpen:x.useCallback(()=>{window.clearTimeout(p.current),m.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>m.current=!0,i)},[i]),isPointerInTransitRef:h,onPointerInTransitChange:x.useCallback(v=>{h.current=v},[]),disableHoverableContent:c,children:d})};l1.displayName=a1;var ho="Tooltip",[I5,Ro]=Xd(ho),r1=s=>{const{__scopeTooltip:a,children:l,open:i,defaultOpen:c,onOpenChange:d,disableHoverableContent:m,delayDuration:h}=s,p=Zh(ho,s.__scopeTooltip),v=Kd(a),[g,j]=x.useState(null),b=jn(),w=x.useRef(0),S=m??p.disableHoverableContent,C=h??p.delayDuration,N=x.useRef(!1),[T,P]=Qa({prop:i,defaultProp:c??!1,onChange:E=>{E?(p.onOpen(),document.dispatchEvent(new CustomEvent(th))):p.onClose(),d?.(E)},caller:ho}),M=x.useMemo(()=>T?N.current?"delayed-open":"instant-open":"closed",[T]),k=x.useCallback(()=>{window.clearTimeout(w.current),w.current=0,N.current=!1,P(!0)},[P]),D=x.useCallback(()=>{window.clearTimeout(w.current),w.current=0,P(!1)},[P]),A=x.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{N.current=!0,P(!0),w.current=0},C)},[C,P]);return x.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),e.jsx(Ed,{...v,children:e.jsx(I5,{scope:a,contentId:b,open:T,stateAttribute:M,trigger:g,onTriggerChange:j,onTriggerEnter:x.useCallback(()=>{p.isOpenDelayedRef.current?A():k()},[p.isOpenDelayedRef,A,k]),onTriggerLeave:x.useCallback(()=>{S?D():(window.clearTimeout(w.current),w.current=0)},[D,S]),onOpen:k,onClose:D,disableHoverableContent:S,children:l})})};r1.displayName=ho;var sh="TooltipTrigger",i1=x.forwardRef((s,a)=>{const{__scopeTooltip:l,...i}=s,c=Ro(sh,l),d=Zh(sh,l),m=Kd(l),h=x.useRef(null),p=Tt(a,h,c.onTriggerChange),v=x.useRef(!1),g=x.useRef(!1),j=x.useCallback(()=>v.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",j),[j]),e.jsx(Md,{asChild:!0,...m,children:e.jsx(dt.button,{"aria-describedby":c.open?c.contentId:void 0,"data-state":c.stateAttribute,...i,ref:p,onPointerMove:be(s.onPointerMove,b=>{b.pointerType!=="touch"&&!g.current&&!d.isPointerInTransitRef.current&&(c.onTriggerEnter(),g.current=!0)}),onPointerLeave:be(s.onPointerLeave,()=>{c.onTriggerLeave(),g.current=!1}),onPointerDown:be(s.onPointerDown,()=>{c.open&&c.onClose(),v.current=!0,document.addEventListener("pointerup",j,{once:!0})}),onFocus:be(s.onFocus,()=>{v.current||c.onOpen()}),onBlur:be(s.onBlur,c.onClose),onClick:be(s.onClick,c.onClose)})})});i1.displayName=sh;var Jh="TooltipPortal",[W5,X5]=Xd(Jh,{forceMount:void 0}),o1=s=>{const{__scopeTooltip:a,forceMount:l,children:i,container:c}=s,d=Ro(Jh,a);return e.jsx(W5,{scope:a,forceMount:l,children:e.jsx(Is,{present:l||d.open,children:e.jsx(Td,{asChild:!0,container:c,children:i})})})};o1.displayName=Jh;var Ir="TooltipContent",c1=x.forwardRef((s,a)=>{const l=X5(Ir,s.__scopeTooltip),{forceMount:i=l.forceMount,side:c="top",...d}=s,m=Ro(Ir,s.__scopeTooltip);return e.jsx(Is,{present:i||m.open,children:m.disableHoverableContent?e.jsx(d1,{side:c,...d,ref:a}):e.jsx(K5,{side:c,...d,ref:a})})}),K5=x.forwardRef((s,a)=>{const l=Ro(Ir,s.__scopeTooltip),i=Zh(Ir,s.__scopeTooltip),c=x.useRef(null),d=Tt(a,c),[m,h]=x.useState(null),{trigger:p,onClose:v}=l,g=c.current,{onPointerInTransitChange:j}=i,b=x.useCallback(()=>{h(null),j(!1)},[j]),w=x.useCallback((S,C)=>{const N=S.currentTarget,T={x:S.clientX,y:S.clientY},P=tz(T,N.getBoundingClientRect()),M=sz(T,P),k=nz(C.getBoundingClientRect()),D=lz([...M,...k]);h(D),j(!0)},[j]);return x.useEffect(()=>()=>b(),[b]),x.useEffect(()=>{if(p&&g){const S=N=>w(N,g),C=N=>w(N,p);return p.addEventListener("pointerleave",S),g.addEventListener("pointerleave",C),()=>{p.removeEventListener("pointerleave",S),g.removeEventListener("pointerleave",C)}}},[p,g,w,b]),x.useEffect(()=>{if(m){const S=C=>{const N=C.target,T={x:C.clientX,y:C.clientY},P=p?.contains(N)||g?.contains(N),M=!az(T,m);P?b():M&&(b(),v())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[p,g,m,v,b]),e.jsx(d1,{...s,ref:d})}),[Q5,Z5]=Xd(ho,{isInside:!1}),J5=V5("TooltipContent"),d1=x.forwardRef((s,a)=>{const{__scopeTooltip:l,children:i,"aria-label":c,onEscapeKeyDown:d,onPointerDownOutside:m,...h}=s,p=Ro(Ir,l),v=Kd(l),{onClose:g}=p;return x.useEffect(()=>(document.addEventListener(th,g),()=>document.removeEventListener(th,g)),[g]),x.useEffect(()=>{if(p.trigger){const j=b=>{b.target?.contains(p.trigger)&&g()};return window.addEventListener("scroll",j,{capture:!0}),()=>window.removeEventListener("scroll",j,{capture:!0})}},[p.trigger,g]),e.jsx(fh,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:j=>j.preventDefault(),onDismiss:g,children:e.jsxs(hh,{"data-state":p.stateAttribute,...v,...h,ref:a,style:{...h.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(J5,{children:i}),e.jsx(Q5,{scope:l,isInside:!0,children:e.jsx(w2,{id:p.contentId,role:"tooltip",children:c||i})})]})})});c1.displayName=Ir;var u1="TooltipArrow",ez=x.forwardRef((s,a)=>{const{__scopeTooltip:l,...i}=s,c=Kd(l);return Z5(u1,l).isInside?null:e.jsx(xh,{...c,...i,ref:a})});ez.displayName=u1;function tz(s,a){const l=Math.abs(a.top-s.y),i=Math.abs(a.bottom-s.y),c=Math.abs(a.right-s.x),d=Math.abs(a.left-s.x);switch(Math.min(l,i,c,d)){case d:return"left";case c:return"right";case l:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function sz(s,a,l=5){const i=[];switch(a){case"top":i.push({x:s.x-l,y:s.y+l},{x:s.x+l,y:s.y+l});break;case"bottom":i.push({x:s.x-l,y:s.y-l},{x:s.x+l,y:s.y-l});break;case"left":i.push({x:s.x+l,y:s.y-l},{x:s.x+l,y:s.y+l});break;case"right":i.push({x:s.x-l,y:s.y-l},{x:s.x-l,y:s.y+l});break}return i}function nz(s){const{top:a,right:l,bottom:i,left:c}=s;return[{x:c,y:a},{x:l,y:a},{x:l,y:i},{x:c,y:i}]}function az(s,a){const{x:l,y:i}=s;let c=!1;for(let d=0,m=a.length-1;di!=b>i&&l<(j-v)*(i-g)/(b-g)+v&&(c=!c)}return c}function lz(s){const a=s.slice();return a.sort((l,i)=>l.xi.x?1:l.yi.y?1:0),rz(a)}function rz(s){if(s.length<=1)return s.slice();const a=[];for(let i=0;i=2;){const d=a[a.length-1],m=a[a.length-2];if((d.x-m.x)*(c.y-m.y)>=(d.y-m.y)*(c.x-m.x))a.pop();else break}a.push(c)}a.pop();const l=[];for(let i=s.length-1;i>=0;i--){const c=s[i];for(;l.length>=2;){const d=l[l.length-1],m=l[l.length-2];if((d.x-m.x)*(c.y-m.y)>=(d.y-m.y)*(c.x-m.x))l.pop();else break}l.push(c)}return l.pop(),a.length===1&&l.length===1&&a[0].x===l[0].x&&a[0].y===l[0].y?a:a.concat(l)}var iz=l1,oz=r1,cz=i1,dz=o1,m1=c1;const uz=iz,mz=oz,fz=cz,f1=x.forwardRef(({className:s,sideOffset:a=4,...l},i)=>e.jsx(dz,{children:e.jsx(m1,{ref:i,sideOffset:a,className:Z("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]",s),...l})}));f1.displayName=m1.displayName;function hz({children:s}){VE();const[a,l]=x.useState(!0),[i,c]=x.useState(!1),[d,m]=x.useState(!1),{theme:h,setTheme:p}=Oh(),v=K_(),g=qn();x.useEffect(()=>{const C=N=>{(N.metaKey||N.ctrlKey)&&N.key==="k"&&(N.preventDefault(),m(!0))};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[]);const j=[{title:"概览",items:[{icon:fd,label:"首页",path:"/"}]},{title:"麦麦配置编辑",items:[{icon:ph,label:"麦麦主程序配置",path:"/config/bot"},{icon:Dy,label:"麦麦模型提供商配置",path:"/config/modelProvider"},{icon:Oy,label:"麦麦模型配置",path:"/config/model"}]},{title:"麦麦资源管理",items:[{icon:gh,label:"表情包管理",path:"/resource/emoji"},{icon:po,label:"表达方式管理",path:"/resource/expression"},{icon:Ay,label:"人物信息管理",path:"/resource/person"}]},{title:"扩展与监控",items:[{icon:pd,label:"插件市场",path:"/plugins"},{icon:$2,label:"插件配置",path:"/plugin-config"},{icon:hd,label:"日志查看器",path:"/logs"}]},{title:"系统",items:[{icon:Tn,label:"系统设置",path:"/settings"}]}],w=h==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":h,S=()=>{localStorage.removeItem("access-token"),g({to:"/auth"})};return e.jsx(uz,{delayDuration:300,children:e.jsxs("div",{className:"flex h-screen overflow-hidden",children:[e.jsxs("aside",{className:Z("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",a?"lg:w-64":"lg:w-16",i?"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:Z("relative flex items-center justify-center flex-1 transition-all overflow-hidden","lg:flex-1",!a&&"lg:flex-none lg:w-8"),children:[e.jsxs("div",{className:Z("flex items-baseline gap-2",!a&&"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:yE()})]}),!a&&e.jsx("span",{className:"hidden lg:block font-bold text-primary-gradient text-2xl",children:"M"})]})}),e.jsx("nav",{className:"flex-1 overflow-y-auto p-4",children:e.jsx("ul",{className:Z("space-y-6",!a&&"lg:space-y-3"),children:j.map((C,N)=>e.jsxs("li",{children:[e.jsx("div",{className:Z("px-3 h-[1.25rem]","mb-2",!a&&"lg:mb-1 lg:invisible"),children:e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground/60 whitespace-nowrap",children:C.title})}),!a&&N>0&&e.jsx("div",{className:"hidden lg:block mb-2 border-t border-border"}),e.jsx("ul",{className:"space-y-1",children:C.items.map(T=>{const P=v({to:T.path}),M=T.icon,k=e.jsxs(e.Fragment,{children:[P&&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:Z("flex items-center transition-all duration-300",a?"gap-3":"lg:gap-0"),children:[e.jsx(M,{className:Z("h-5 w-5 flex-shrink-0",P&&"text-primary"),strokeWidth:2,fill:"none"}),e.jsx("span",{className:Z("text-sm font-medium whitespace-nowrap transition-all duration-300",P&&"font-semibold",a?"opacity-100 max-w-[200px]":"lg:opacity-0 lg:max-w-0 lg:overflow-hidden"),children:T.label})]})]});return e.jsx("li",{className:"relative",children:e.jsxs(mz,{children:[e.jsx(fz,{asChild:!0,children:e.jsx(Q_,{to:T.path,className:Z("relative flex items-center rounded-lg py-2 transition-all duration-300","hover:bg-accent hover:text-accent-foreground",P?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground",a?"px-3":"lg:px-0 lg:justify-center"),onClick:()=>c(!1),children:k})}),!a&&e.jsx(f1,{side:"right",className:"hidden lg:block",children:e.jsx("p",{children:T.label})})]})},T.path)})})]},C.title))})})]}),i&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 lg:hidden",onClick:()=>c(!1)}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("header",{className:"flex h-16 items-center justify-between border-b bg-card/80 backdrop-blur-md px-4 sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>c(!i),className:"rounded-lg p-2 hover:bg-accent lg:hidden",children:e.jsx(I2,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>l(!a),className:"hidden rounded-lg p-2 hover:bg-accent lg:block",title:a?"收起侧边栏":"展开侧边栏",children:e.jsx(Ol,{className:Z("h-5 w-5 transition-transform",!a&&"rotate-180")})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>m(!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(Gs,{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(nw,{size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsx(y3,{open:d,onOpenChange:m}),e.jsxs(q,{variant:"ghost",size:"sm",onClick:()=>window.open("https://docs.mai-mai.org","_blank"),className:"gap-2",title:"查看麦麦文档",children:[e.jsx(W2,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"麦麦文档"})]}),e.jsx("button",{onClick:C=>{lE(w==="dark"?"light":"dark",p,C)},className:"rounded-lg p-2 hover:bg-accent",title:w==="dark"?"切换到浅色模式":"切换到深色模式",children:w==="dark"?e.jsx(Rf,{className:"h-5 w-5"}):e.jsx(zf,{className:"h-5 w-5"})}),e.jsx("div",{className:"h-6 w-px bg-border"}),e.jsxs(q,{variant:"ghost",size:"sm",onClick:S,className:"gap-2",title:"登出系统",children:[e.jsx(sj,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"登出"})]})]})]}),e.jsxs(L5,{children:[e.jsx(B5,{asChild:!0,children:e.jsx("main",{className:"flex-1 overflow-hidden bg-background",children:s})}),e.jsxs(n1,{className:"w-64",children:[e.jsxs(kn,{onClick:()=>g({to:"/"}),children:[e.jsx(fd,{className:"mr-2 h-4 w-4"}),"首页"]}),e.jsxs(kn,{onClick:()=>g({to:"/settings"}),children:[e.jsx(Tn,{className:"mr-2 h-4 w-4"}),"系统设置"]}),e.jsxs(kn,{onClick:()=>g({to:"/logs"}),children:[e.jsx(hd,{className:"mr-2 h-4 w-4"}),"日志查看器"]}),e.jsx(to,{}),e.jsxs(U5,{children:[e.jsxs(t1,{children:[e.jsx(Ty,{className:"mr-2 h-4 w-4"}),"切换主题"]}),e.jsxs(s1,{className:"w-48",children:[e.jsxs(kn,{onClick:()=>p("light"),disabled:h==="light",children:[e.jsx(Rf,{className:"mr-2 h-4 w-4"}),"浅色",h==="light"&&e.jsx(Pr,{children:"✓"})]}),e.jsxs(kn,{onClick:()=>p("dark"),disabled:h==="dark",children:[e.jsx(zf,{className:"mr-2 h-4 w-4"}),"深色",h==="dark"&&e.jsx(Pr,{children:"✓"})]}),e.jsxs(kn,{onClick:()=>p("system"),disabled:h==="system",children:[e.jsx(Tn,{className:"mr-2 h-4 w-4"}),"跟随系统",h==="system"&&e.jsx(Pr,{children:"✓"})]})]})]}),e.jsx(to,{}),e.jsxs(kn,{onClick:()=>window.location.reload(),children:[e.jsx(X2,{className:"mr-2 h-4 w-4"}),"刷新页面",e.jsx(Pr,{children:"⌘R"})]}),e.jsxs(kn,{onClick:()=>m(!0),children:[e.jsx(Gs,{className:"mr-2 h-4 w-4"}),"搜索",e.jsx(Pr,{children:"⌘K"})]}),e.jsx(to,{}),e.jsxs(kn,{onClick:()=>window.open("https://docs.mai-mai.org","_blank"),children:[e.jsx(so,{className:"mr-2 h-4 w-4"}),"麦麦文档"]}),e.jsx(to,{}),e.jsxs(kn,{onClick:S,className:"text-destructive focus:text-destructive",children:[e.jsx(sj,{className:"mr-2 h-4 w-4"}),"登出系统"]})]})]})]})]})})}const zo=Z_({component:()=>e.jsxs(e.Fragment,{children:[e.jsx(ry,{}),!1]}),beforeLoad:()=>{if(window.location.pathname==="/"&&!L0())throw e2({to:"/auth"})}}),xz=Ts({getParentRoute:()=>zo,path:"/auth",component:GE}),pz=Ts({getParentRoute:()=>zo,path:"/setup",component:d4}),an=Ts({getParentRoute:()=>zo,id:"protected",component:()=>e.jsx(hz,{children:e.jsx(ry,{})})}),gz=Ts({getParentRoute:()=>an,path:"/",component:nE}),vz=Ts({getParentRoute:()=>an,path:"/config/bot",component:tM}),jz=Ts({getParentRoute:()=>an,path:"/config/modelProvider",component:gM}),yz=Ts({getParentRoute:()=>an,path:"/config/model",component:GM}),bz=Ts({getParentRoute:()=>an,path:"/resource/emoji",component:eD}),Nz=Ts({getParentRoute:()=>an,path:"/resource/expression",component:dD}),wz=Ts({getParentRoute:()=>an,path:"/resource/person",component:bD}),Sz=Ts({getParentRoute:()=>an,path:"/logs",component:s3}),_z=Ts({getParentRoute:()=>an,path:"/plugins",component:x3}),Cz=Ts({getParentRoute:()=>an,path:"/plugin-config",component:p3}),kz=Ts({getParentRoute:()=>an,path:"/plugin-mirrors",component:g3}),Tz=Ts({getParentRoute:()=>an,path:"/settings",component:LE}),Ez=Ts({getParentRoute:()=>zo,path:"*",component:H0}),Mz=zo.addChildren([xz,pz,an.addChildren([gz,vz,jz,yz,bz,Nz,wz,_z,Cz,kz,Sz,Tz]),Ez]),Dz=J_({routeTree:Mz,defaultNotFoundComponent:H0});function Oz({children:s,defaultTheme:a="system",storageKey:l="ui-theme",...i}){const[c,d]=x.useState(()=>localStorage.getItem(l)||a);x.useEffect(()=>{const h=window.document.documentElement;if(h.classList.remove("light","dark"),c==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";h.classList.add(p);return}h.classList.add(c)},[c]),x.useEffect(()=>{const h=localStorage.getItem("accent-color");if(h){const p=document.documentElement,g={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%)"}}[h];g&&(p.style.setProperty("--primary",g.hsl),g.gradient?(p.style.setProperty("--primary-gradient",g.gradient),p.classList.add("has-gradient")):(p.style.removeProperty("--primary-gradient"),p.classList.remove("has-gradient")))}},[]);const m={theme:c,setTheme:h=>{localStorage.setItem(l,h),d(h)}};return e.jsx(r0.Provider,{...i,value:m,children:s})}function Az({children:s,defaultEnabled:a=!0,defaultWavesEnabled:l=!0,storageKey:i="enable-animations",wavesStorageKey:c="enable-waves-background"}){const[d,m]=x.useState(()=>{const g=localStorage.getItem(i);return g!==null?g==="true":a}),[h,p]=x.useState(()=>{const g=localStorage.getItem(c);return g!==null?g==="true":l});x.useEffect(()=>{const g=document.documentElement;d?g.classList.remove("no-animations"):g.classList.add("no-animations"),localStorage.setItem(i,String(d))},[d,i]),x.useEffect(()=>{localStorage.setItem(c,String(h))},[h,c]);const v={enableAnimations:d,setEnableAnimations:m,enableWavesBackground:h,setEnableWavesBackground:p};return e.jsx(i0.Provider,{value:v,children:s})}var ex="ToastProvider",[tx,Rz,zz]=_d("Toast"),[h1]=Dn("Toast",[zz]),[Pz,Qd]=h1(ex),x1=s=>{const{__scopeToast:a,label:l="Notification",duration:i=5e3,swipeDirection:c="right",swipeThreshold:d=50,children:m}=s,[h,p]=x.useState(null),[v,g]=x.useState(0),j=x.useRef(!1),b=x.useRef(!1);return l.trim()||console.error(`Invalid prop \`label\` supplied to \`${ex}\`. Expected non-empty \`string\`.`),e.jsx(tx.Provider,{scope:a,children:e.jsx(Pz,{scope:a,label:l,duration:i,swipeDirection:c,swipeThreshold:d,toastCount:v,viewport:h,onViewportChange:p,onToastAdd:x.useCallback(()=>g(w=>w+1),[]),onToastRemove:x.useCallback(()=>g(w=>w-1),[]),isFocusedToastEscapeKeyDownRef:j,isClosePausedRef:b,children:m})})};x1.displayName=ex;var p1="ToastViewport",Lz=["F8"],nh="toast.viewportPause",ah="toast.viewportResume",g1=x.forwardRef((s,a)=>{const{__scopeToast:l,hotkey:i=Lz,label:c="Notifications ({hotkey})",...d}=s,m=Qd(p1,l),h=Rz(l),p=x.useRef(null),v=x.useRef(null),g=x.useRef(null),j=x.useRef(null),b=Tt(a,j,m.onViewportChange),w=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),S=m.toastCount>0;x.useEffect(()=>{const N=T=>{i.length!==0&&i.every(M=>T[M]||T.code===M)&&j.current?.focus()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[i]),x.useEffect(()=>{const N=p.current,T=j.current;if(S&&N&&T){const P=()=>{if(!m.isClosePausedRef.current){const A=new CustomEvent(nh);T.dispatchEvent(A),m.isClosePausedRef.current=!0}},M=()=>{if(m.isClosePausedRef.current){const A=new CustomEvent(ah);T.dispatchEvent(A),m.isClosePausedRef.current=!1}},k=A=>{!N.contains(A.relatedTarget)&&M()},D=()=>{N.contains(document.activeElement)||M()};return N.addEventListener("focusin",P),N.addEventListener("focusout",k),N.addEventListener("pointermove",P),N.addEventListener("pointerleave",D),window.addEventListener("blur",P),window.addEventListener("focus",M),()=>{N.removeEventListener("focusin",P),N.removeEventListener("focusout",k),N.removeEventListener("pointermove",P),N.removeEventListener("pointerleave",D),window.removeEventListener("blur",P),window.removeEventListener("focus",M)}}},[S,m.isClosePausedRef]);const C=x.useCallback(({tabbingDirection:N})=>{const P=h().map(M=>{const k=M.ref.current,D=[k,...Kz(k)];return N==="forwards"?D:D.reverse()});return(N==="forwards"?P.reverse():P).flat()},[h]);return x.useEffect(()=>{const N=j.current;if(N){const T=P=>{const M=P.altKey||P.ctrlKey||P.metaKey;if(P.key==="Tab"&&!M){const D=document.activeElement,A=P.shiftKey;if(P.target===N&&A){v.current?.focus();return}const Y=C({tabbingDirection:A?"backwards":"forwards"}),G=Y.findIndex($=>$===D);Mf(Y.slice(G+1))?P.preventDefault():A?v.current?.focus():g.current?.focus()}};return N.addEventListener("keydown",T),()=>N.removeEventListener("keydown",T)}},[h,C]),e.jsxs(S2,{ref:p,role:"region","aria-label":c.replace("{hotkey}",w),tabIndex:-1,style:{pointerEvents:S?void 0:"none"},children:[S&&e.jsx(lh,{ref:v,onFocusFromOutsideViewport:()=>{const N=C({tabbingDirection:"forwards"});Mf(N)}}),e.jsx(tx.Slot,{scope:l,children:e.jsx(dt.ol,{tabIndex:-1,...d,ref:b})}),S&&e.jsx(lh,{ref:g,onFocusFromOutsideViewport:()=>{const N=C({tabbingDirection:"backwards"});Mf(N)}})]})});g1.displayName=p1;var v1="ToastFocusProxy",lh=x.forwardRef((s,a)=>{const{__scopeToast:l,onFocusFromOutsideViewport:i,...c}=s,d=Qd(v1,l);return e.jsx(ky,{tabIndex:0,...c,ref:a,style:{position:"fixed"},onFocus:m=>{const h=m.relatedTarget;!d.viewport?.contains(h)&&i()}})});lh.displayName=v1;var Po="Toast",Bz="toast.swipeStart",Uz="toast.swipeMove",Hz="toast.swipeCancel",Fz="toast.swipeEnd",j1=x.forwardRef((s,a)=>{const{forceMount:l,open:i,defaultOpen:c,onOpenChange:d,...m}=s,[h,p]=Qa({prop:i,defaultProp:c??!0,onChange:d,caller:Po});return e.jsx(Is,{present:l||h,children:e.jsx(Vz,{open:h,...m,ref:a,onClose:()=>p(!1),onPause:ws(s.onPause),onResume:ws(s.onResume),onSwipeStart:be(s.onSwipeStart,v=>{v.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:be(s.onSwipeMove,v=>{const{x:g,y:j}=v.detail.delta;v.currentTarget.setAttribute("data-swipe","move"),v.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${g}px`),v.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${j}px`)}),onSwipeCancel:be(s.onSwipeCancel,v=>{v.currentTarget.setAttribute("data-swipe","cancel"),v.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),v.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),v.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),v.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:be(s.onSwipeEnd,v=>{const{x:g,y:j}=v.detail.delta;v.currentTarget.setAttribute("data-swipe","end"),v.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),v.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),v.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${g}px`),v.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${j}px`),p(!1)})})})});j1.displayName=Po;var[Yz,qz]=h1(Po,{onClose(){}}),Vz=x.forwardRef((s,a)=>{const{__scopeToast:l,type:i="foreground",duration:c,open:d,onClose:m,onEscapeKeyDown:h,onPause:p,onResume:v,onSwipeStart:g,onSwipeMove:j,onSwipeCancel:b,onSwipeEnd:w,...S}=s,C=Qd(Po,l),[N,T]=x.useState(null),P=Tt(a,ae=>T(ae)),M=x.useRef(null),k=x.useRef(null),D=c||C.duration,A=x.useRef(0),E=x.useRef(D),B=x.useRef(0),{onToastAdd:Y,onToastRemove:G}=C,$=ws(()=>{N?.contains(document.activeElement)&&C.viewport?.focus(),m()}),oe=x.useCallback(ae=>{!ae||ae===1/0||(window.clearTimeout(B.current),A.current=new Date().getTime(),B.current=window.setTimeout($,ae))},[$]);x.useEffect(()=>{const ae=C.viewport;if(ae){const me=()=>{oe(E.current),v?.()},R=()=>{const O=new Date().getTime()-A.current;E.current=E.current-O,window.clearTimeout(B.current),p?.()};return ae.addEventListener(nh,R),ae.addEventListener(ah,me),()=>{ae.removeEventListener(nh,R),ae.removeEventListener(ah,me)}}},[C.viewport,D,p,v,oe]),x.useEffect(()=>{d&&!C.isClosePausedRef.current&&oe(D)},[d,D,C.isClosePausedRef,oe]),x.useEffect(()=>(Y(),()=>G()),[Y,G]);const je=x.useMemo(()=>N?C1(N):null,[N]);return C.viewport?e.jsxs(e.Fragment,{children:[je&&e.jsx(Gz,{__scopeToast:l,role:"status","aria-live":i==="foreground"?"assertive":"polite",children:je}),e.jsx(Yz,{scope:l,onClose:$,children:t2.createPortal(e.jsx(tx.ItemSlot,{scope:l,children:e.jsx(_2,{asChild:!0,onEscapeKeyDown:be(h,()=>{C.isFocusedToastEscapeKeyDownRef.current||$(),C.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(dt.li,{tabIndex:0,"data-state":d?"open":"closed","data-swipe-direction":C.swipeDirection,...S,ref:P,style:{userSelect:"none",touchAction:"none",...s.style},onKeyDown:be(s.onKeyDown,ae=>{ae.key==="Escape"&&(h?.(ae.nativeEvent),ae.nativeEvent.defaultPrevented||(C.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:be(s.onPointerDown,ae=>{ae.button===0&&(M.current={x:ae.clientX,y:ae.clientY})}),onPointerMove:be(s.onPointerMove,ae=>{if(!M.current)return;const me=ae.clientX-M.current.x,R=ae.clientY-M.current.y,O=!!k.current,L=["left","right"].includes(C.swipeDirection),ee=["left","up"].includes(C.swipeDirection)?Math.min:Math.max,le=L?ee(0,me):0,xe=L?0:ee(0,R),F=ae.pointerType==="touch"?10:2,W={x:le,y:xe},fe={originalEvent:ae,delta:W};O?(k.current=W,rd(Uz,j,fe,{discrete:!1})):ly(W,C.swipeDirection,F)?(k.current=W,rd(Bz,g,fe,{discrete:!1}),ae.target.setPointerCapture(ae.pointerId)):(Math.abs(me)>F||Math.abs(R)>F)&&(M.current=null)}),onPointerUp:be(s.onPointerUp,ae=>{const me=k.current,R=ae.target;if(R.hasPointerCapture(ae.pointerId)&&R.releasePointerCapture(ae.pointerId),k.current=null,M.current=null,me){const O=ae.currentTarget,L={originalEvent:ae,delta:me};ly(me,C.swipeDirection,C.swipeThreshold)?rd(Fz,w,L,{discrete:!0}):rd(Hz,b,L,{discrete:!0}),O.addEventListener("click",ee=>ee.preventDefault(),{once:!0})}})})})}),C.viewport)})]}):null}),Gz=s=>{const{__scopeToast:a,children:l,...i}=s,c=Qd(Po,a),[d,m]=x.useState(!1),[h,p]=x.useState(!1);return Wz(()=>m(!0)),x.useEffect(()=>{const v=window.setTimeout(()=>p(!0),1e3);return()=>window.clearTimeout(v)},[]),h?null:e.jsx(Td,{asChild:!0,children:e.jsx(ky,{...i,children:d&&e.jsxs(e.Fragment,{children:[c.label," ",l]})})})},$z="ToastTitle",y1=x.forwardRef((s,a)=>{const{__scopeToast:l,...i}=s;return e.jsx(dt.div,{...i,ref:a})});y1.displayName=$z;var Iz="ToastDescription",b1=x.forwardRef((s,a)=>{const{__scopeToast:l,...i}=s;return e.jsx(dt.div,{...i,ref:a})});b1.displayName=Iz;var N1="ToastAction",w1=x.forwardRef((s,a)=>{const{altText:l,...i}=s;return l.trim()?e.jsx(_1,{altText:l,asChild:!0,children:e.jsx(sx,{...i,ref:a})}):(console.error(`Invalid prop \`altText\` supplied to \`${N1}\`. Expected non-empty \`string\`.`),null)});w1.displayName=N1;var S1="ToastClose",sx=x.forwardRef((s,a)=>{const{__scopeToast:l,...i}=s,c=qz(S1,l);return e.jsx(_1,{asChild:!0,children:e.jsx(dt.button,{type:"button",...i,ref:a,onClick:be(s.onClick,c.onClose)})})});sx.displayName=S1;var _1=x.forwardRef((s,a)=>{const{__scopeToast:l,altText:i,...c}=s;return e.jsx(dt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":i||void 0,...c,ref:a})});function C1(s){const a=[];return Array.from(s.childNodes).forEach(i=>{if(i.nodeType===i.TEXT_NODE&&i.textContent&&a.push(i.textContent),Xz(i)){const c=i.ariaHidden||i.hidden||i.style.display==="none",d=i.dataset.radixToastAnnounceExclude==="";if(!c)if(d){const m=i.dataset.radixToastAnnounceAlt;m&&a.push(m)}else a.push(...C1(i))}}),a}function rd(s,a,l,{discrete:i}){const c=l.originalEvent.currentTarget,d=new CustomEvent(s,{bubbles:!0,cancelable:!0,detail:l});a&&c.addEventListener(s,a,{once:!0}),i?Cy(c,d):c.dispatchEvent(d)}var ly=(s,a,l=0)=>{const i=Math.abs(s.x),c=Math.abs(s.y),d=i>c;return a==="left"||a==="right"?d&&i>l:!d&&c>l};function Wz(s=()=>{}){const a=ws(s);oy(()=>{let l=0,i=0;return l=window.requestAnimationFrame(()=>i=window.requestAnimationFrame(a)),()=>{window.cancelAnimationFrame(l),window.cancelAnimationFrame(i)}},[a])}function Xz(s){return s.nodeType===s.ELEMENT_NODE}function Kz(s){const a=[],l=document.createTreeWalker(s,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const c=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||c?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;l.nextNode();)a.push(l.currentNode);return a}function Mf(s){const a=document.activeElement;return s.some(l=>l===a?!0:(l.focus(),document.activeElement!==a))}var Qz=x1,k1=g1,T1=j1,E1=y1,M1=b1,D1=w1,O1=sx;const Zz=Qz,A1=x.forwardRef(({className:s,...a},l)=>e.jsx(k1,{ref:l,className:Z("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",s),...a}));A1.displayName=k1.displayName;const Jz=Jr("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-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),R1=x.forwardRef(({className:s,variant:a,...l},i)=>e.jsx(T1,{ref:i,className:Z(Jz({variant:a}),s),...l}));R1.displayName=T1.displayName;const e6=x.forwardRef(({className:s,...a},l)=>e.jsx(D1,{ref:l,className:Z("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",s),...a}));e6.displayName=D1.displayName;const z1=x.forwardRef(({className:s,...a},l)=>e.jsx(O1,{ref:l,className:Z("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",s),"toast-close":"",...a,children:e.jsx(go,{className:"h-4 w-4"})}));z1.displayName=O1.displayName;const P1=x.forwardRef(({className:s,...a},l)=>e.jsx(E1,{ref:l,className:Z("text-sm font-semibold [&+div]:text-xs",s),...a}));P1.displayName=E1.displayName;const L1=x.forwardRef(({className:s,...a},l)=>e.jsx(M1,{ref:l,className:Z("text-sm opacity-90",s),...a}));L1.displayName=M1.displayName;function t6(){const{toasts:s}=Es();return e.jsxs(Zz,{children:[s.map(function({id:a,title:l,description:i,action:c,...d}){return e.jsxs(R1,{...d,children:[e.jsxs("div",{className:"grid gap-1",children:[l&&e.jsx(P1,{children:l}),i&&e.jsx(L1,{children:i})]}),c,e.jsx(z1,{})]},a)}),e.jsx(A1,{})]})}eC.createRoot(document.getElementById("root")).render(e.jsx(x.StrictMode,{children:e.jsx(Oz,{defaultTheme:"system",children:e.jsxs(Az,{children:[e.jsx(s2,{router:Dz}),e.jsx(t6,{})]})})}));