Files
mai-bot/dashboard/dist/assets/index-C5U4NsIF.js

8 lines
50 KiB
JavaScript

import{r as h,j as t,R as ye,L as X}from"./router-zNjPR4CY.js";import{P as _t}from"./utils-DjBw3JGv.js";import{g as M,u as yt,x as $e,M as wt,N as Nt,S as we,T as Be,O as qe,P as q,B as A,C as b,b as _,d as y,f as w,Q as Ne,R as ae,e as V}from"./index-CuOHsLf7.js";import{S as kt}from"./skeleton-CXI2IV_v.js";import{P as Et}from"./progress-C6-hh8fF.js";import{T as Ct,L as Tt,R as St,g as It,C as oe,X as ie,Y as Z,h as Dt,B as ke,j as ce,P as At,k as Lt,l as Rt}from"./charts-C6WIfXk3.js";import{B as le}from"./badge-CDs67obV.js";import{R as Ot,u as Mt,a as Pt}from"./restart-overlay-B44c6hlE.js";import{u as Ft,a as Kt,g as $t,E as Bt}from"./expression-reviewer-HNWlEaz6.js";import{R as de,F as Ee,a5 as Q,a6 as qt,e as Vt,W as zt,_ as Ve,a7 as Ht,a8 as Ut,a9 as Yt,s as Wt,aa as Gt,ab as Xt,n as ze,j as Zt,ac as Qt,D as Jt,ad as es,ae as ts}from"./icons-DTcdLw9j.js";import"./misc-BwRzHX8c.js";import"./radix-C-ZuImoP.js";import"./system-api-DeeJapvB.js";import"./checkbox-DWiVrbnx.js";import"./select-DGqIoF9r.js";import"./pagination-DX-kWu7G.js";const ss={light:"",dark:".dark"},nt=h.createContext(null);function at(){const s=h.useContext(nt);if(!s)throw new Error("useChart must be used within a <ChartContainer />");return s}const U=h.forwardRef(({id:s,className:e,children:r,config:n,...a},i)=>{const c=h.useId(),l=`chart-${s||c.replace(/:/g,"")}`;return t.jsx(nt,{value:{config:n},children:t.jsxs("div",{"data-chart":l,ref:i,className:M("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",e),...a,children:[t.jsx(rs,{id:l,config:n}),t.jsx(St,{children:r})]})})});U.displayName="Chart";const rs=({id:s,config:e})=>{const r=Object.entries(e).filter(([,n])=>n.theme||n.color);return r.length?t.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(ss).map(([n,a])=>`
${a} [data-chart=${s}] {
${r.map(([i,c])=>{const l=c.theme?.[n]||c.color;return l?` --color-${i}: ${l};`:null}).join(`
`)}
}
`).join(`
`)}}):null},J=Ct,Y=h.forwardRef(({active:s,payload:e,className:r,indicator:n="dot",hideLabel:a=!1,hideIndicator:i=!1,label:c,labelFormatter:l,labelClassName:m,formatter:f,color:u,nameKey:j,labelKey:v},F)=>{const{config:L}=at(),S=h.useMemo(()=>{if(a||!e?.length)return null;const[x]=e,K=`${v||x?.dataKey||x?.name||"value"}`,R=Se(L,x,K),D=!v&&typeof c=="string"?L[c]?.label||c:R?.label;return l?t.jsx("div",{className:M("font-medium",m),children:l(D,e)}):D?t.jsx("div",{className:M("font-medium",m),children:D}):null},[c,l,e,a,m,L,v]);if(!s||!e?.length)return null;const I=e.length===1&&n!=="dot";return t.jsxs("div",{ref:F,className:M("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[I?null:S,t.jsx("div",{className:"grid gap-1.5",children:e.filter(x=>x.type!=="none").map((x,K)=>{const R=`${j||x.name||x.dataKey||"value"}`,D=Se(L,x,R),$=u||x.payload.fill||x.color;return t.jsx("div",{className:M("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:f&&x?.value!==void 0&&x.name?f(x.value,x.name,x,K,x.payload):t.jsxs(t.Fragment,{children:[D?.icon?t.jsx(D.icon,{}):!i&&t.jsx("div",{className:M("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":I&&n==="dashed"}),style:{"--color-bg":$,"--color-border":$}}),t.jsxs("div",{className:M("flex flex-1 justify-between leading-none",I?"items-end":"items-center"),children:[t.jsxs("div",{className:"grid gap-1.5",children:[I?S:null,t.jsx("span",{className:"text-muted-foreground",children:D?.label||x.name})]}),x.value&&t.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:x.value.toLocaleString()})]})]})},x.dataKey)})})]})});Y.displayName="ChartTooltip";const ns=Tt,ot=h.forwardRef(({className:s,hideIcon:e=!1,payload:r,verticalAlign:n="bottom",nameKey:a},i)=>{const{config:c}=at();return r?.length?t.jsx("div",{ref:i,className:M("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",s),children:r.filter(l=>l.type!=="none").map(l=>{const m=`${a||l.dataKey||"value"}`,f=Se(c,l,m);return t.jsxs("div",{className:M("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[f?.icon&&!e?t.jsx(f.icon,{}):t.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:l.color}}),f?.label]},l.value)})}):null});ot.displayName="ChartLegend";function Se(s,e,r){if(typeof e!="object"||e===null)return;const n="payload"in e&&typeof e.payload=="object"&&e.payload!==null?e.payload:void 0;let a=r;return r in e&&typeof e[r]=="string"?a=e[r]:n&&r in n&&typeof n[r]=="string"&&(a=n[r]),a in s?s[a]:s[r]}function as(s,e,r){return Math.max(e,Math.min(s,r))}const k={toVector(s,e){return s===void 0&&(s=e),Array.isArray(s)?s:[s,s]},add(s,e){return[s[0]+e[0],s[1]+e[1]]},sub(s,e){return[s[0]-e[0],s[1]-e[1]]},addTo(s,e){s[0]+=e[0],s[1]+=e[1]},subTo(s,e){s[0]-=e[0],s[1]-=e[1]}};function He(s,e,r){return e===0||Math.abs(e)===1/0?Math.pow(s,r*5):s*e*r/(e+r*s)}function Ue(s,e,r,n=.15){return n===0?as(s,e,r):s<e?-He(e-s,r-e,n)+e:s>r?+He(s-r,r-e,n)+r:s}function os(s,[e,r],[n,a]){const[[i,c],[l,m]]=s;return[Ue(e,i,c,n),Ue(r,l,m,a)]}function is(s,e){if(typeof s!="object"||s===null)return s;var r=s[Symbol.toPrimitive];if(r!==void 0){var n=r.call(s,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(s)}function cs(s){var e=is(s,"string");return typeof e=="symbol"?e:String(e)}function N(s,e,r){return e=cs(e),e in s?Object.defineProperty(s,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):s[e]=r,s}function Ye(s,e){var r=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),r.push.apply(r,n)}return r}function g(s){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ye(Object(r),!0).forEach(function(n){N(s,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(r)):Ye(Object(r)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(r,n))})}return s}const it={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function We(s){return s?s[0].toUpperCase()+s.slice(1):""}const ls=["enter","leave"];function ds(s=!1,e){return s&&!ls.includes(e)}function us(s,e="",r=!1){const n=it[s],a=n&&n[e]||e;return"on"+We(s)+We(a)+(ds(r,a)?"Capture":"")}const hs=["gotpointercapture","lostpointercapture"];function ms(s){let e=s.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=hs.includes(e)?"capturecapture":"capture",a=!!~e.indexOf(n);return a&&(e=e.replace("capture","")),{device:e,capture:a,passive:r}}function fs(s,e=""){const r=it[s],n=r&&r[e]||e;return s+n}function xs(s){return"touches"in s}function ps(s){return Array.from(s.touches).filter(e=>{var r,n;return e.target===s.currentTarget||((r=s.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Ie(s,e){try{const r=e.clientX-s.clientX,n=e.clientY-s.clientY,a=(e.clientX+s.clientX)/2,i=(e.clientY+s.clientY)/2,c=Math.hypot(r,n);return{angle:-(Math.atan2(r,n)*180)/Math.PI,distance:c,origin:[a,i]}}catch{}return null}function gs(s){return ps(s).map(e=>e.identifier)}function Ge(s,e){const[r,n]=Array.from(s.touches).filter(a=>e.includes(a.identifier));return Ie(r,n)}const Xe=40,Ze=800;function js(s){let{deltaX:e,deltaY:r,deltaMode:n}=s;return n===1?(e*=Xe,r*=Xe):n===2&&(e*=Ze,r*=Ze),[e,r]}function vs(s){const e={};if("buttons"in s&&(e.buttons=s.buttons),"shiftKey"in s){const{shiftKey:r,altKey:n,metaKey:a,ctrlKey:i}=s;Object.assign(e,{shiftKey:r,altKey:n,metaKey:a,ctrlKey:i})}return e}function he(s,...e){return typeof s=="function"?s(...e):s}function bs(){}function _s(...s){return s.length===0?bs:s.length===1?s[0]:function(){let e;for(const r of s)e=r.apply(this,arguments)||e;return e}}function Qe(s,e){return Object.assign({},e,s||{})}const ys=32;class ws{constructor(e,r,n){this.ctrl=e,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:r,ingKey:n,args:a}=this;r[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=a,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?he(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:a}=this;r.args=this.args;let i=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,vs(e)),a.down=a.pressed=a.buttons%2===1||a.touches>0,i=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const P=r._delta.map(Math.abs);k.addTo(r._distance,P)}this.axisIntent&&this.axisIntent(e);const[c,l]=r._movement,[m,f]=n.threshold,{_step:u,values:j}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(c)>=m&&j[0]),u[1]===!1&&(u[1]=Math.abs(l)>=f&&j[1])):(u[0]===!1&&(u[0]=Math.abs(c)>=m&&Math.sign(c)*m),u[1]===!1&&(u[1]=Math.abs(l)>=f&&Math.sign(l)*f)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const v=[0,0];if(n.hasCustomTransform){const[P,te]=j;v[0]=u[0]!==!1?P-u[0]:0,v[1]=u[1]!==!1?te-u[1]:0}else v[0]=u[0]!==!1?c-u[0]:0,v[1]=u[1]!==!1?l-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(v);const F=r.offset,L=r._active&&!r._blocked||r.active;L&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=a[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=he(n.bounds,r)),this.setup&&this.setup()),r.movement=v,this.computeOffset()));const[S,I]=r.offset,[[x,K],[R,D]]=r._bounds;r.overflow=[S<x?-1:S>K?1:0,I<R?-1:I>D?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const $=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=os(r._bounds,r.offset,$),r.delta=k.sub(r.offset,F),this.computeMovement(),L&&(!r.last||i>ys)){r.delta=k.sub(r.offset,F);const P=r.delta.map(Math.abs);k.addTo(r.distance,P),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&i>0&&(r.velocity=[P[0]/i,P[1]/i],r.timeDelta=i)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const a=this.handler(g(g(g({},r),e),{},{[this.aliasKey]:e.values}));a!==void 0&&(e.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}const Ns=s=>s,Je=.15,ct={enabled(s=!0){return s},eventOptions(s,e,r){return g(g({},r.shared.eventOptions),s)},preventDefault(s=!1){return s},triggerAllEvents(s=!1){return s},rubberband(s=0){switch(s){case!0:return[Je,Je];case!1:return[0,0];default:return k.toVector(s)}},from(s){if(typeof s=="function")return s;if(s!=null)return k.toVector(s)},transform(s,e,r){const n=s||r.shared.transform;return this.hasCustomTransform=!!n,n||Ns},threshold(s){return k.toVector(s,0)}},ks=0,me=g(g({},ct),{},{axis(s,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(s=ks){return s},bounds(s={}){if(typeof s=="function")return i=>me.bounds(s(i));if("current"in s)return()=>s.current;if(typeof HTMLElement=="function"&&s instanceof HTMLElement)return s;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:a=1/0}=s;return[[e,r],[n,a]]}}),ee=typeof window<"u"&&window.document&&window.document.createElement;function lt(){return ee&&"ontouchstart"in window}function Es(){return lt()||ee&&window.navigator.maxTouchPoints>1}function Cs(){return ee&&"onpointerdown"in window}function Ts(){return ee&&"exitPointerLock"in window.document}function Ss(){try{return"constructor"in GestureEvent}catch{return!1}}const T={isBrowser:ee,gesture:Ss(),touch:lt(),touchscreen:Es(),pointer:Cs(),pointerLock:Ts()},Is=250,Ds=180,As=.5,Ls=50,Rs=250,Os=10,et={mouse:0,touch:0,pen:8};g(g({},me),{},{device(s,e,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&T.pointerLock,T.touch&&r?"touch":this.pointerLock?"mouse":T.pointer&&!a?"pointer":T.touch?"touch":"mouse"},preventScrollAxis(s,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&s?Is:void 0,!(!T.touchscreen||r===!1))return s||(r!==void 0?"y":void 0)},pointerCapture(s,e,{pointer:{capture:r=!0,buttons:n=1,keys:a=!0}={}}){return this.pointerButtons=n,this.keys=a,!this.pointerLock&&this.device==="pointer"&&r},threshold(s,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:a=void 0}){const i=k.toVector(s,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,i},swipe({velocity:s=As,distance:e=Ls,duration:r=Rs}={}){return{velocity:this.transform(k.toVector(s)),distance:this.transform(k.toVector(e)),duration:r}},delay(s=0){switch(s){case!0:return Ds;case!1:return 0;default:return s}},axisThreshold(s){return s?g(g({},et),s):et},keyboardDisplacement(s=Os){return s}});function Ms(s){const[e,r]=s.overflow,[n,a]=s._delta,[i,c]=s._direction;(e<0&&n>0&&i<0||e>0&&n<0&&i>0)&&(s._movement[0]=s._movementBound[0]),(r<0&&a>0&&c<0||r>0&&a<0&&c>0)&&(s._movement[1]=s._movementBound[1])}const Ps=30,Fs=100;class Ks extends ws{constructor(...e){super(...e),N(this,"ingKey","pinching"),N(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const e=this.state;e._touchIds=[],e.canceled=!1,e.cancel=this.cancel.bind(this),e.turns=0}computeOffset(){const{type:e,movement:r,lastOffset:n}=this.state;e==="wheel"?this.state.offset=k.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:e,lastOffset:r}=this.state;this.state.movement=[e[0]/r[0],e[1]-r[1]]}axisIntent(){const e=this.state,[r,n]=e._movement;if(!e.axis){const a=Math.abs(r)*Ps-Math.abs(n);a<0?e.axis="angle":a>0&&(e.axis="scale")}}restrictToAxis(e){this.config.lockDirection&&(this.state.axis==="scale"?e[1]=0:this.state.axis==="angle"&&(e[0]=0))}cancel(){const e=this.state;e.canceled||setTimeout(()=>{e.canceled=!0,e._active=!1,this.compute(),this.emit()},0)}touchStart(e){this.ctrl.setEventIds(e);const r=this.state,n=this.ctrl.touchIds;if(r._active&&r._touchIds.every(i=>n.has(i))||n.size<2)return;this.start(e),r._touchIds=Array.from(n).slice(0,2);const a=Ge(e,r._touchIds);a&&this.pinchStart(e,a)}pointerStart(e){if(e.buttons!=null&&e.buttons%2!==1)return;this.ctrl.setEventIds(e),e.target.setPointerCapture(e.pointerId);const r=this.state,n=r._pointerEvents,a=this.ctrl.pointerIds;if(r._active&&Array.from(n.keys()).every(c=>a.has(c))||(n.size<2&&n.set(e.pointerId,e),r._pointerEvents.size<2))return;this.start(e);const i=Ie(...Array.from(n.values()));i&&this.pinchStart(e,i)}pinchStart(e,r){const n=this.state;n.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(e),this.emit()}touchMove(e){if(!this.state._active)return;const r=Ge(e,this.state._touchIds);r&&this.pinchMove(e,r)}pointerMove(e){const r=this.state._pointerEvents;if(r.has(e.pointerId)&&r.set(e.pointerId,e),!this.state._active)return;const n=Ie(...Array.from(r.values()));n&&this.pinchMove(e,n)}pinchMove(e,r){const n=this.state,a=n._values[1],i=r.angle-a;let c=0;Math.abs(i)>270&&(c+=Math.sign(i)),this.computeValues([r.distance,r.angle-360*c]),n.origin=r.origin,n.turns=c,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(e),this.emit()}touchEnd(e){this.ctrl.setEventIds(e),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(e),this.emit())}pointerEnd(e){const r=this.state;this.ctrl.setEventIds(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}r._pointerEvents.has(e.pointerId)&&r._pointerEvents.delete(e.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(e),this.emit())}gestureStart(e){e.cancelable&&e.preventDefault();const r=this.state;r._active||(this.start(e),this.computeValues([e.scale,e.rotation]),r.origin=[e.clientX,e.clientY],this.compute(e),this.emit())}gestureMove(e){if(e.cancelable&&e.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([e.scale,e.rotation]),r.origin=[e.clientX,e.clientY];const n=r._movement;r._movement=[e.scale-1,e.rotation],r._delta=k.sub(r._movement,n),this.compute(e),this.emit()}gestureEnd(e){this.state._active&&(this.state._active=!1,this.compute(e),this.emit())}wheel(e){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>e[n]):!e[r])||(this.state._active?this.wheelChange(e):this.wheelStart(e),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(e){this.start(e),this.wheelChange(e)}wheelChange(e){"uv"in e||e.cancelable&&e.preventDefault();const n=this.state;n._delta=[-js(e)[1]/Fs*n.offset[0],0],k.addTo(n._movement,n._delta),Ms(n),this.state.origin=[e.clientX,e.clientY],this.compute(e),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(e){const r=this.config.device;r&&(e(r,"start",this[r+"Start"].bind(this)),e(r,"change",this[r+"Move"].bind(this)),e(r,"end",this[r+"End"].bind(this)),e(r,"cancel",this[r+"End"].bind(this)),e("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&e("wheel","",this.wheel.bind(this),{passive:!1})}}const $s=g(g({},ct),{},{device(s,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!T.touch&&T.gesture)return"gesture";if(T.touch&&n)return"touch";if(T.touchscreen){if(T.pointer)return"pointer";if(T.touch)return"touch"}},bounds(s,e,{scaleBounds:r={},angleBounds:n={}}){const a=c=>{const l=Qe(he(r,c),{min:-1/0,max:1/0});return[l.min,l.max]},i=c=>{const l=Qe(he(n,c),{min:-1/0,max:1/0});return[l.min,l.max]};return typeof r!="function"&&typeof n!="function"?[a(),i()]:c=>[a(c),i(c)]},threshold(s,e,r){return this.lockDirection=r.axis==="lock",k.toVector(s,this.lockDirection?[.1,3]:0)},modifierKey(s){return s===void 0?"ctrlKey":s},pinchOnWheel(s=!0){return s}});g(g({},me),{},{mouseOnly:(s=!0)=>s});g(g({},me),{},{mouseOnly:(s=!0)=>s});const dt=new Map,De=new Map;function Bs(s){dt.set(s.key,s.engine),De.set(s.key,s.resolver)}const qs={key:"pinch",engine:Ks,resolver:$s};function Vs(s,e){if(s==null)return{};var r={},n=Object.keys(s),a,i;for(i=0;i<n.length;i++)a=n[i],!(e.indexOf(a)>=0)&&(r[a]=s[a]);return r}function zs(s,e){if(s==null)return{};var r=Vs(s,e),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);for(a=0;a<i.length;a++)n=i[a],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(r[n]=s[n])}return r}const Hs={target(s){if(s)return()=>"current"in s?s.current:s},enabled(s=!0){return s},window(s=T.isBrowser?window:void 0){return s},eventOptions({passive:s=!0,capture:e=!1}={}){return{passive:s,capture:e}},transform(s){return s}},Us=["target","eventOptions","window","enabled","transform"];function ue(s={},e){const r={};for(const[n,a]of Object.entries(e))switch(typeof a){case"function":r[n]=a.call(r,s[n],n,s);break;case"object":r[n]=ue(s[n],a);break;case"boolean":a&&(r[n]=s[n]);break}return r}function Ys(s,e,r={}){const n=s,{target:a,eventOptions:i,window:c,enabled:l,transform:m}=n,f=zs(n,Us);if(r.shared=ue({target:a,eventOptions:i,window:c,enabled:l,transform:m},Hs),e){const u=De.get(e);r[e]=ue(g({shared:r.shared},f),u)}else for(const u in f){const j=De.get(u);j&&(r[u]=ue(g({shared:r.shared},f[u]),j))}return r}class ut{constructor(e,r){N(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,a,i){const c=this._listeners,l=fs(r,n),m=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},f=g(g({},m),i);e.addEventListener(l,a,f);const u=()=>{e.removeEventListener(l,a,f),c.delete(u)};return c.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class Ws{constructor(){N(this,"_timeouts",new Map)}add(e,r,n=140,...a){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...a))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>{window.clearTimeout(e)}),this._timeouts.clear()}}class Gs{constructor(e){N(this,"gestures",new Set),N(this,"_targetEventStore",new ut(this)),N(this,"gestureEventStores",{}),N(this,"gestureTimeoutStores",{}),N(this,"handlers",{}),N(this,"config",{}),N(this,"pointerIds",new Set),N(this,"touchIds",new Set),N(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Xs(this,e)}setEventIds(e){if(xs(e))return this.touchIds=new Set(gs(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=Ys(e,r,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const r=this.config.shared,n={};let a;if(!(r.target&&(a=r.target(),!a))){if(r.enabled){for(const c of this.gestures){const l=this.config[c],m=tt(n,l.eventOptions,!!a);if(l.enabled){const f=dt.get(c);new f(this,e,c).bind(m)}}const i=tt(n,r.eventOptions,!!a);for(const c in this.nativeHandlers)i(c,"",l=>this.nativeHandlers[c](g(g({},this.state.shared),{},{event:l,args:e})),void 0,!0)}for(const i in n)n[i]=_s(...n[i]);if(!a)return n;for(const i in n){const{device:c,capture:l,passive:m}=ms(i);this._targetEventStore.add(a,c,"",n[i],{capture:l,passive:m})}}}}function H(s,e){s.gestures.add(e),s.gestureEventStores[e]=new ut(s,e),s.gestureTimeoutStores[e]=new Ws}function Xs(s,e){e.drag&&H(s,"drag"),e.wheel&&H(s,"wheel"),e.scroll&&H(s,"scroll"),e.move&&H(s,"move"),e.pinch&&H(s,"pinch"),e.hover&&H(s,"hover")}const tt=(s,e,r)=>(n,a,i,c={},l=!1)=>{var m,f;const u=(m=c.capture)!==null&&m!==void 0?m:e.capture,j=(f=c.passive)!==null&&f!==void 0?f:e.passive;let v=l?n:us(n,a,u);r&&j&&(v+="Passive"),s[v]=s[v]||[],s[v].push(i)};function Zs(s,e={},r,n){const a=ye.useMemo(()=>new Gs(s),[]);if(a.applyHandlers(s,n),a.applyConfig(e,r),ye.useEffect(a.effect.bind(a)),ye.useEffect(()=>a.clean.bind(a),[]),e.target===void 0)return a.bind.bind(a)}function Qs(s,e){return Bs(qs),Zs({pinch:s},e||{},"pinch")}const Js=Kt("div");function Ce({children:s,className:e,"aria-label":r,minScale:n=.5,maxScale:a=4}){const i=h.useRef(null),[c,l]=Ft(()=>({scale:1,config:{tension:300,friction:40}}));return Qs(({offset:[m],first:f,last:u})=>{const j=Math.min(Math.max(m,n*.85),a*1.15),v=j<n?n+(j-n)*.3:j>a?a+(j-a)*.3:j;l.start({scale:v,immediate:f}),u&&(m<n||m>a)&&l.start({scale:Math.min(Math.max(m,n),a),config:{tension:200,friction:30}})},{target:i,scaleBounds:{min:n*.85,max:a*1.15},rubberband:!0,preventDefault:!0,eventOptions:{passive:!1}}),t.jsx("div",{ref:i,role:"img","aria-label":r,className:M("overflow-hidden touch-none select-none",e),style:{touchAction:"none"},children:t.jsx(Js,{style:c,className:"w-full h-full origin-center",children:s})})}function _r(){return t.jsx(Ot,{children:t.jsx(tr,{})})}const Te="https://github.com/Mai-with-u/MaiBot/releases",st="https://pypi.org/project/maibot-dashboard/",er=s=>{const e=[];for(let r=0;r<s;r++){const n=r*137.508%360;e.push(`hsl(${n}, 70%, 55%)`)}return e};function rt({enabled:s,label:e}){return t.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs text-muted-foreground",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${s?"bg-green-500 shadow-[0_0_0_3px_rgba(34,197,94,0.18)]":"bg-muted-foreground/30"}`}),t.jsx("span",{children:e})]})}function tr(){const{t:s}=yt(),[e,r]=h.useState(null),[n,a]=h.useState(!0),[i,c]=h.useState(0),[l,m]=h.useState(24),[f,u]=h.useState(!1),[j,v]=h.useState(null),[F,L]=h.useState(!0),[S,I]=h.useState(null),[x,K]=h.useState(null),[R,D]=h.useState(null),[$,P]=h.useState(null),[te,Ae]=h.useState({memoryEnabled:!1,visualEnabled:!1}),[ht,Le]=h.useState(!1),[fe,mt]=h.useState(0),{triggerRestart:ft,isRestarting:xe}=Mt(),E=h.useRef(!0),O=h.useRef(null);h.useEffect(()=>(E.current=!0,()=>{E.current=!1,O.current&&(clearInterval(O.current),O.current=null)}),[]),h.useEffect(()=>{let o=!0;return(async()=>o&&(K(null),D(null),P({current_version:Ne,latest_version:null,has_update:!1,package_name:"maibot-dashboard",pypi_url:st})))(),()=>{o=!1}},[]);const pe=h.useCallback(async()=>{try{const o=await $t();o.success&&E.current&&mt(o.data.unchecked)}catch(o){console.error("获取审核统计失败:",o)}},[]),ge=h.useCallback(async()=>{try{L(!0);const o=await _t.get("https://v1.hitokoto.cn/?c=a&c=b&c=c&c=d&c=h&c=i&c=k");E.current&&v({hitokoto:o.data.hitokoto,from:o.data.from||o.data.from_who||s("home.unknownSource")})}catch(o){console.error("获取一言失败:",o),E.current&&v({hitokoto:s("home.hitokotoFallback"),from:s("home.hitokotoFallbackFrom")})}finally{E.current&&L(!1)}},[s]),se=h.useCallback(async()=>{try{const o=await $e("/api/webui/system/status");if(!E.current)return;if(o.ok){const d=await o.json();I(d)}else I(null)}catch(o){console.error("获取机器人状态失败:",o),E.current&&I(null)}},[]),re=h.useCallback(async()=>{try{const[o,d]=await Promise.all([wt(),Nt()]);if(!E.current||!o.success)return;const z=o.data,_e=((z.config??z).a_memorix??{}).plugin??{},ne=d.success?d.data:{},Ke=((ne.config??ne).model_task_config??{}).vlm??{},vt=(Array.isArray(Ke.model_list)?Ke.model_list:[]).some(bt=>String(bt??"").trim().length>0);Ae({memoryEnabled:_e.enabled===!0,visualEnabled:vt})}catch(o){console.error("获取功能启用状态失败:",o),E.current&&Ae({memoryEnabled:!1,visualEnabled:!1})}},[]),xt=async()=>{await ft()},W=h.useCallback(async()=>{try{const o=await $e(`/api/webui/statistics/dashboard?hours=${l}`);if(!E.current)return;if(o.ok){const d=await o.json();r(d)}a(!1),c(100)}catch(o){console.error("Failed to fetch dashboard data:",o),E.current&&(a(!1),c(100))}},[l]);if(h.useEffect(()=>{if(!n)return;c(0);const o=setTimeout(()=>c(15),200),d=setTimeout(()=>c(30),800),z=setTimeout(()=>c(45),2e3),Pe=setTimeout(()=>c(60),4e3),Fe=setTimeout(()=>c(75),6500),_e=setTimeout(()=>c(85),9e3),ne=setTimeout(()=>c(92),11e3);return()=>{clearTimeout(o),clearTimeout(d),clearTimeout(z),clearTimeout(Pe),clearTimeout(Fe),clearTimeout(_e),clearTimeout(ne)}},[n]),h.useEffect(()=>{W(),ge(),se(),re(),pe()},[W,ge,se,re,pe]),h.useEffect(()=>{if(O.current&&(clearInterval(O.current),O.current=null),!!f)return O.current=setInterval(()=>{E.current&&(W(),se(),re())},3e4),()=>{O.current&&(clearInterval(O.current),O.current=null)}},[f,W,se,re]),n||!e)return t.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-200px)]",children:t.jsxs("div",{className:"text-center space-y-6 w-full max-w-md px-4",children:[t.jsx(de,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-lg font-medium",children:s("home.loading")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:s("home.loadingHint")})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Et,{value:i,className:"h-2"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[i,"%"]})]})]})});const{summary:pt,model_stats:G=[],hourly_data:je=[],daily_data:gt=[],recent_activity:jt=[]}=e,p=pt??{total_requests:0,total_cost:0,total_tokens:0,online_time:0,total_messages:0,total_replies:0,avg_response_time:0,cost_per_hour:0,tokens_per_hour:0},Re=o=>{const d=Math.floor(o/3600),z=Math.floor(o%3600/60);return s("home.time.hoursMinutes",{hours:d,minutes:z})},C=o=>{const d=o.toLocaleString("zh-CN");return o>=1e9?{display:`${(o/1e9).toFixed(2)}B`,exact:d,needsExact:!0}:o>=1e6?{display:`${(o/1e6).toFixed(2)}M`,exact:d,needsExact:!0}:o>=1e4?{display:`${(o/1e3).toFixed(1)}K`,exact:d,needsExact:!0}:o>=1e3?{display:`${(o/1e3).toFixed(2)}K`,exact:d,needsExact:!0}:{display:d,exact:d,needsExact:!1}},ve=o=>{const d=`¥${o.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`;return o>=1e6?{display:`¥${(o/1e6).toFixed(2)}M`,exact:d,needsExact:!0}:o>=1e4?{display:`¥${(o/1e3).toFixed(1)}K`,exact:d,needsExact:!0}:o>=1e3?{display:`¥${(o/1e3).toFixed(2)}K`,exact:d,needsExact:!0}:{display:d,exact:d,needsExact:!1}},B=o=>new Date(o).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),Oe=er(G.length),Me=G.map((o,d)=>({name:o.model_name,value:o.request_count,fill:Oe[d]})),be={requests:{label:s("home.charts.requests"),color:"hsl(var(--color-chart-1))"},cost:{label:s("home.charts.cost"),color:"hsl(var(--color-chart-2))"},tokens:{label:"Tokens",color:"hsl(var(--color-chart-3))"}};return t.jsx(we,{className:"h-full",children:t.jsxs("div",{className:"space-y-4 sm:space-y-6 p-4 sm:p-6",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:s("home.title")}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s("home.subtitle")})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(Be,{value:l.toString(),onValueChange:o=>m(Number(o)),children:t.jsxs(qe,{className:"grid grid-cols-3 w-full sm:w-auto",children:[t.jsx(q,{value:"24",children:s("home.timeRange.24h")}),t.jsx(q,{value:"168",children:s("home.timeRange.7d")}),t.jsx(q,{value:"720",children:s("home.timeRange.30d")})]})}),t.jsxs(A,{variant:f?"default":"outline",size:"sm",onClick:()=>u(!f),className:"gap-2",children:[t.jsx(de,{className:`h-4 w-4 ${f?"animate-spin":""}`}),t.jsx("span",{className:"hidden sm:inline",children:s("home.autoRefresh")})]}),t.jsx(A,{variant:"outline",size:"sm",onClick:W,children:t.jsx(de,{className:"h-4 w-4"})})]})]}),t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg border border-dashed border-muted-foreground/30 bg-muted/20",children:[F?t.jsx(kt,{className:"h-5 flex-1"}):j?t.jsxs("p",{className:"flex-1 text-sm text-muted-foreground italic truncate",children:['"',j.hitokoto,'" —— ',j.from]}):null,t.jsx(A,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:ge,disabled:F,children:t.jsx(de,{className:`h-3.5 w-3.5 ${F?"animate-spin":""}`})})]}),t.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.4fr)_max-content]",children:[t.jsxs(b,{className:"lg:col-span-1",children:[t.jsx(_,{className:"pb-3",children:t.jsxs(y,{className:"text-sm font-medium flex items-center gap-2",children:[t.jsx(Ee,{className:"h-4 w-4"}),"麦麦版本"]})}),t.jsx(w,{children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"主程序版本"}),t.jsx(le,{variant:"secondary",className:"border border-primary/20 bg-primary/10 px-2 py-0.5 font-semibold text-primary",children:S?.version?`v${S.version}`:"未知"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:"WebUI 版本"}),t.jsxs(le,{variant:"secondary",className:"border border-primary/20 bg-primary/10 px-2 py-0.5 font-semibold text-primary",children:["v",Ne]})]}),t.jsxs("div",{className:"hidden",children:["最新版本 v",$?.latest_version||Ne]}),t.jsx("div",{className:"hidden",children:t.jsxs("a",{href:R?.url||Te,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 transition-colors hover:text-muted-foreground",children:["最新版本 ",R?`v${R.version}`:"GitHub Releases",t.jsx(Q,{className:"h-3 w-3"})]})}),t.jsxs("div",{className:"space-y-1 border-t border-border/50 pt-2 text-xs text-muted-foreground/60",children:[t.jsxs("a",{href:x?.url||Te,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 transition-colors hover:text-muted-foreground",children:[t.jsx("span",{children:"查看主程序发布页"}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:["GitHub Releases",t.jsx(Q,{className:"h-3 w-3"})]})]}),t.jsxs("a",{href:R?.url||Te,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 transition-colors hover:text-muted-foreground",children:[t.jsx("span",{children:"查看测试版发布页"}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:["GitHub Releases",t.jsx(Q,{className:"h-3 w-3"})]})]}),t.jsxs("a",{href:$?.pypi_url||st,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 transition-colors hover:text-muted-foreground",children:[t.jsx("span",{children:"查看 WebUI 发布页"}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:["PyPI",t.jsx(Q,{className:"h-3 w-3"})]})]})]})]})})]}),t.jsxs(b,{className:"lg:col-span-1",children:[t.jsx(_,{className:"pb-3",children:t.jsxs(y,{className:"text-sm font-medium flex items-center gap-2",children:[t.jsx(qt,{className:"h-4 w-4"}),s("home.botStatus.title")]})}),t.jsx(w,{children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[t.jsx("div",{className:"flex items-center gap-2",children:S?.running?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-3 w-3 rounded-full bg-green-500 animate-pulse"}),t.jsxs(le,{variant:"outline",className:"whitespace-nowrap text-green-600 border-green-300 bg-green-50",children:[t.jsx(Vt,{className:"h-3 w-3 mr-1"}),s("home.botStatus.running")]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"h-3 w-3 rounded-full bg-red-500"}),t.jsxs(le,{variant:"outline",className:"whitespace-nowrap text-red-600 border-red-300 bg-red-50",children:[t.jsx(zt,{className:"h-3 w-3 mr-1"}),s("home.botStatus.stopped")]})]})}),S&&t.jsx("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:t.jsx("span",{children:s("home.botStatus.uptime",{time:Re(S.uptime)})})})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(rt,{enabled:te.visualEnabled,label:"启用视觉"}),t.jsx(rt,{enabled:te.memoryEnabled,label:"启用记忆"})]})]})})]}),t.jsxs(b,{children:[t.jsx(_,{className:"pb-3",children:t.jsxs(y,{className:"text-sm font-medium flex items-center gap-2",children:[t.jsx(Ve,{className:"h-4 w-4"}),s("home.quickActions.title")]})}),t.jsx(w,{children:t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs(A,{variant:"outline",size:"sm",onClick:xt,disabled:xe,className:"gap-2",children:[t.jsx(Ht,{className:`h-4 w-4 ${xe?"animate-spin":""}`}),s(xe?"home.quickActions.restarting":"home.quickActions.restart")]}),t.jsxs(A,{variant:"outline",size:"sm",onClick:()=>Le(!0),className:"gap-2",children:[t.jsx(Ut,{className:"h-4 w-4"}),s("home.quickActions.expressionReview"),fe>0&&t.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs rounded-full bg-orange-500 text-white",children:fe>99?"99+":fe})]}),t.jsx(A,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:t.jsxs(X,{to:"/logs",children:[t.jsx(Ee,{className:"h-4 w-4"}),s("home.quickActions.viewLogs")]})}),t.jsx(A,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:t.jsxs(X,{to:"/plugins",children:[t.jsx(Yt,{className:"h-4 w-4"}),s("home.quickActions.pluginManage")]})}),t.jsx(A,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:t.jsxs(X,{to:"/settings",children:[t.jsx(Wt,{className:"h-4 w-4"}),s("home.quickActions.systemSettings")]})}),t.jsx(A,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:t.jsxs("a",{href:"/maibot_statistics.html",target:"_blank",rel:"noopener noreferrer",children:[t.jsx(Gt,{className:"h-4 w-4"}),"详细统计数据",t.jsx(Q,{className:"h-3.5 w-3.5"})]})})]})})]}),t.jsxs(b,{className:"lg:w-[190px]",children:[t.jsx(_,{className:"pb-3",children:t.jsxs(y,{className:"text-sm font-medium flex items-center gap-2",children:[t.jsx(Xt,{className:"h-4 w-4"}),s("home.survey.title")]})}),t.jsx(w,{children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(A,{variant:"outline",size:"sm",asChild:!0,className:"w-full justify-start gap-2",children:t.jsxs(X,{to:"/survey/webui-feedback",children:[t.jsx(Ee,{className:"h-4 w-4"}),s("home.survey.webui")]})}),t.jsx(A,{variant:"outline",size:"sm",asChild:!0,className:"w-full justify-start gap-2",children:t.jsxs(X,{to:"/survey/maibot-feedback",children:[t.jsx(ze,{className:"h-4 w-4"}),s("home.survey.maibot")]})})]})})]})]}),t.jsxs("div",{className:"grid gap-4 grid-cols-1 xs:grid-cols-2 lg:grid-cols-4",children:[t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.totalRequests")}),t.jsx(Zt,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(w,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:[C(p.total_requests).display,C(p.total_requests).needsExact&&t.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",C(p.total_requests).exact,")"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("home.stats.recentPeriod",{range:l<48?l+s("home.stats.hours"):Math.floor(l/24)+s("home.stats.days")})})]})]}),t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.totalCost")}),t.jsx(Qt,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(w,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:[ve(p.total_cost).display,ve(p.total_cost).needsExact&&t.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",ve(p.total_cost).exact,")"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:p.cost_per_hour>0?s("home.stats.perHour",{value:`¥${p.cost_per_hour.toFixed(2)}`}):s("home.stats.noData")})]})]}),t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.tokenUsage")}),t.jsx(Jt,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(w,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:[C(p.total_tokens).display,C(p.total_tokens).needsExact&&t.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",C(p.total_tokens).exact,")"]})]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:p.tokens_per_hour>0?s("home.stats.perHour",{value:C(p.tokens_per_hour).display}):s("home.stats.noData")})]})]}),t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.avgResponse")}),t.jsx(Ve,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(w,{children:[t.jsxs("div",{className:"text-2xl font-bold",children:[p.avg_response_time.toFixed(2),"s"]}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("home.stats.avgResponseDesc")})]})]})]}),t.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-3",children:[t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.onlineTime")}),t.jsx(es,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsx(w,{children:t.jsxs("div",{className:"text-xl font-bold",children:[Re(p.online_time),t.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",p.online_time.toLocaleString(),s("home.stats.seconds"),")"]})]})})]}),t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.messageProcessing")}),t.jsx(ze,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(w,{children:[t.jsxs("div",{className:"text-xl font-bold",children:[C(p.total_messages).display,C(p.total_messages).needsExact&&t.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-1",children:["(",C(p.total_messages).exact,")"]})]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s("home.stats.replied",{num:C(p.total_replies).display}),C(p.total_replies).needsExact&&t.jsxs("span",{children:["(",C(p.total_replies).exact,")"]})]})]})]}),t.jsxs(b,{children:[t.jsxs(_,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[t.jsx(y,{className:"text-sm font-medium",children:s("home.stats.costEfficiency")}),t.jsx(ts,{className:"h-4 w-4 text-muted-foreground"})]}),t.jsxs(w,{children:[t.jsx("div",{className:"text-xl font-bold",children:p.total_messages>0?`¥${(p.total_cost/p.total_messages*100).toFixed(2)}`:"¥0.00"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("home.stats.per100Messages")})]})]})]}),t.jsxs(Be,{defaultValue:"trends",className:"space-y-4",children:[t.jsxs(qe,{className:"grid w-full grid-cols-2 sm:grid-cols-4",children:[t.jsx(q,{value:"trends",children:s("home.charts.tabs.trends")}),t.jsx(q,{value:"models",children:s("home.charts.tabs.models")}),t.jsx(q,{value:"activity",children:s("home.charts.tabs.activity")}),t.jsx(q,{value:"daily",children:s("home.charts.tabs.daily")})]}),t.jsxs(ae,{value:"trends",className:"space-y-4",children:[t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.requestTrend")}),t.jsx(V,{children:s("home.charts.requestTrendDesc",{hours:l})})]}),t.jsx(w,{children:t.jsx(Ce,{"aria-label":s("home.ariaLabel.requestTrend"),children:t.jsx(U,{config:be,className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:t.jsxs(It,{data:je,children:[t.jsx(oe,{strokeDasharray:"3 3",stroke:"hsl(var(--color-muted-foreground) / 0.2)"}),t.jsx(ie,{dataKey:"timestamp",tickFormatter:o=>B(o),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(Z,{stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(J,{content:t.jsx(Y,{labelFormatter:o=>B(o)})}),t.jsx(Dt,{type:"monotone",dataKey:"requests",stroke:"var(--color-requests)",strokeWidth:2})]})})})})]}),t.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.costTrend")}),t.jsx(V,{children:s("home.charts.costTrendDesc")})]}),t.jsx(w,{children:t.jsx(Ce,{"aria-label":s("home.ariaLabel.costTrend"),children:t.jsx(U,{config:be,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:t.jsxs(ke,{data:je,children:[t.jsx(oe,{strokeDasharray:"3 3",stroke:"hsl(var(--color-muted-foreground) / 0.2)"}),t.jsx(ie,{dataKey:"timestamp",tickFormatter:o=>B(o),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(Z,{stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(J,{content:t.jsx(Y,{labelFormatter:o=>B(o)})}),t.jsx(ce,{dataKey:"cost",fill:"var(--color-cost)"})]})})})})]}),t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.tokenUsage")}),t.jsx(V,{children:s("home.charts.tokenUsageDesc")})]}),t.jsx(w,{children:t.jsx(Ce,{"aria-label":s("home.ariaLabel.tokenUsage"),children:t.jsx(U,{config:be,className:"h-[250px] sm:h-[300px] w-full aspect-auto",children:t.jsxs(ke,{data:je,children:[t.jsx(oe,{strokeDasharray:"3 3",stroke:"hsl(var(--color-muted-foreground) / 0.2)"}),t.jsx(ie,{dataKey:"timestamp",tickFormatter:o=>B(o),angle:-45,textAnchor:"end",height:60,stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(Z,{stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(J,{content:t.jsx(Y,{labelFormatter:o=>B(o)})}),t.jsx(ce,{dataKey:"tokens",fill:"var(--color-tokens)"})]})})})})]})]})]}),t.jsx(ae,{value:"models",className:"space-y-4",children:t.jsxs("div",{className:"grid gap-4 grid-cols-1 lg:grid-cols-2",children:[t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.modelDistribution")}),t.jsx(V,{children:s("home.charts.modelDistributionDesc",{count:G.length})})]}),t.jsx(w,{children:t.jsx(U,{config:Object.fromEntries(G.map((o,d)=>[o.model_name,{label:o.model_name,color:Oe[d]}])),className:"h-[300px] sm:h-[400px] w-full aspect-auto",children:t.jsxs(At,{children:[t.jsx(J,{content:t.jsx(Y,{})}),t.jsx(Lt,{data:Me,cx:"50%",cy:"50%",labelLine:!1,label:({name:o,percent:d})=>d&&d<.05?"":`${o} ${d?(d*100).toFixed(0):0}%`,outerRadius:100,dataKey:"value",children:Me.map((o,d)=>t.jsx(Rt,{fill:o.fill},`cell-${d}`))})]})})})]}),t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.modelDetails")}),t.jsx(V,{children:s("home.charts.modelDetailsDesc")})]}),t.jsx(w,{children:t.jsx(we,{className:"h-[300px] sm:h-[400px]",children:t.jsx("div",{className:"space-y-3",children:G.map((o,d)=>t.jsxs("div",{className:"p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"font-semibold text-sm truncate flex-1 min-w-0",children:o.model_name}),t.jsx("div",{className:"w-3 h-3 rounded-full ml-2 flex-shrink-0",style:{backgroundColor:`hsl(var(--color-chart-${d%5+1}))`}})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{children:[t.jsxs("span",{className:"text-muted-foreground",children:[s("home.charts.requestCount"),":"]}),t.jsx("span",{className:"ml-1 font-medium",children:o.request_count.toLocaleString()})]}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-muted-foreground",children:[s("home.charts.costLabel"),":"]}),t.jsxs("span",{className:"ml-1 font-medium",children:["¥",o.total_cost.toFixed(2)]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),t.jsxs("span",{className:"ml-1 font-medium",children:[(o.total_tokens/1e3).toFixed(1),"K"]})]}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-muted-foreground",children:[s("home.charts.avgTime"),":"]}),t.jsxs("span",{className:"ml-1 font-medium",children:[o.avg_response_time.toFixed(2),"s"]})]})]})]},d))})})})]})]})}),t.jsx(ae,{value:"activity",children:t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.recentActivity")}),t.jsx(V,{children:s("home.charts.recentActivityDesc")})]}),t.jsx(w,{children:t.jsx(we,{className:"h-[400px] sm:h-[500px]",children:t.jsx("div",{className:"space-y-2",children:jt.map((o,d)=>t.jsxs("div",{className:"p-3 sm:p-4 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium text-sm truncate",children:o.model}),t.jsx("div",{className:"text-xs text-muted-foreground",children:o.request_type})]}),t.jsx("div",{className:"text-xs text-muted-foreground flex-shrink-0",children:B(o.timestamp)})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Tokens:"}),t.jsx("span",{className:"ml-1",children:o.tokens})]}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-muted-foreground",children:[s("home.charts.costLabel"),":"]}),t.jsxs("span",{className:"ml-1",children:["¥",o.cost.toFixed(4)]})]}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-muted-foreground",children:[s("home.charts.timeCost"),":"]}),t.jsxs("span",{className:"ml-1",children:[o.time_cost.toFixed(2),"s"]})]}),t.jsxs("div",{children:[t.jsxs("span",{className:"text-muted-foreground",children:[s("home.charts.status"),":"]}),t.jsx("span",{className:`ml-1 ${o.status==="success"?"text-green-600":"text-red-600"}`,children:o.status})]})]})]},d))})})})]})}),t.jsx(ae,{value:"daily",children:t.jsxs(b,{children:[t.jsxs(_,{children:[t.jsx(y,{children:s("home.charts.dailyStats")}),t.jsx(V,{children:s("home.charts.dailyStatsDesc")})]}),t.jsx(w,{children:t.jsx(U,{config:{requests:{label:s("home.charts.requests"),color:"hsl(var(--color-chart-1))"},cost:{label:s("home.charts.cost"),color:"hsl(var(--color-chart-2))"}},className:"h-[400px] sm:h-[500px] w-full aspect-auto",children:t.jsxs(ke,{data:gt,children:[t.jsx(oe,{strokeDasharray:"3 3",stroke:"hsl(var(--color-muted-foreground) / 0.2)"}),t.jsx(ie,{dataKey:"timestamp",tickFormatter:o=>{const d=new Date(o);return`${d.getMonth()+1}/${d.getDate()}`},stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(Z,{yAxisId:"left",stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(Z,{yAxisId:"right",orientation:"right",stroke:"hsl(var(--color-muted-foreground))",tick:{fill:"hsl(var(--color-muted-foreground))"}}),t.jsx(J,{content:t.jsx(Y,{labelFormatter:o=>new Date(o).toLocaleDateString("zh-CN")})}),t.jsx(ns,{content:t.jsx(ot,{})}),t.jsx(ce,{yAxisId:"left",dataKey:"requests",fill:"var(--color-requests)"}),t.jsx(ce,{yAxisId:"right",dataKey:"cost",fill:"var(--color-cost)"})]})})})]})})]}),t.jsx(Pt,{}),t.jsx(Bt,{open:ht,onOpenChange:o=>{Le(o),o||pe()}})]})})}export{_r as IndexPage};