1import{e as v,j as e}from"./react-vendor-COA9LC9C.js";import{aG as R,B as b,N as B}from"./index-DNOAzpau.js";import{C as i,a as c}from"./card-Bhwb9Q_i.js";import{B as T}from"./badge-DrtwPH22.js";import{S as I,c as q,d as F,a as O,b as n}from"./select-BFdcQUEM.js";import{R as w}from"./refresh-cw-DA3-O9KH.js";import{T as V}from"./trash-2-E8_iP2eX.js";import{U as C}from"./users-CbtO2I6G.js";import{C as $}from"./circle-x-B9xvCvI6.js";import{I as M}from"./info-ew_Hfwgh.js";import{A as P}from"./activity-DFrZ12fN.js";import{C as U}from"./clock-wB7lCu2r.js";import"./ui-vendor-DZhVfNUY.js";import"./data-vendor-DLQwpBlT.js";import"./chevron-down-D5Z2D8kh.js";import"./chevron-up-CrQ6hfrt.js";const z={info:{icon:M,color:"text-blue-500 border-blue-200 bg-blue-50",bg:"",label:"INFO"},warn:{icon:B,color:"text-amber-500 border-amber-200 bg-amber-50",bg:"bg-amber-50/30",label:"WARN"},error:{icon:$,color:"text-red-500 border-red-200 bg-red-50",bg:"bg-red-50/40",label:"ERROR"}};function W(t){try{return new Date(t).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{return t}}function G({logs:t}){const d=t.length,x=t.filter(r=>r.level==="error").length,j=t.filter(r=>r.level==="warn").length;t.filter(r=>r.level==="info").length;const o=t.reduce((r,m)=>{const h=m.details?.peak??m.details?.total??0;return Math.max(r,h)},0),f=new Set(t.map(r=>r.details?.hostname).filter(Boolean));return e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3 mb-4",children:[e.jsx(i,{children:e.jsxs(c,{className:"pt-4 pb-3 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Total Events"})]}),e.jsx("p",{className:"text-2xl font-bold",children:d})]})}),e.jsx(i,{children:e.jsxs(c,{className:"pt-4 pb-3 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-500 mb-1",children:[e.jsx(B,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Warnings"})]}),e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:j})]})}),e.jsx(i,{children:e.jsxs(c,{className:"pt-4 pb-3 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-500 mb-1",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Errors"})]}),e.jsx("p",{className:"text-2xl font-bold text-red-600",children:x})]})}),e.jsx(i,{children:e.jsxs(c,{className:"pt-4 pb-3 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-purple-500 mb-1",children:[e.jsx(C,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Peak Concurrent"})]}),e.jsx("p",{className:"text-2xl font-bold text-purple-600",children:o})]})}),e.jsx(i,{children:e.jsxs(c,{className:"pt-4 pb-3 px-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-500 mb-1",children:[e.jsx(U,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Unique Sites"})]}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:f.size})]})})]})}function ie(){const[t,d]=v.useState(!0),[x,j]=v.useState(100),[o,f]=v.useState("all"),{data:r,isLoading:m,refetch:h}=R.adminLogs.query.useQuery({categories:["concurrency"],limit:500,ascending:!1},{refetchInterval:t?5e3:!1,staleTime:3e3}),S=R.adminLogs.clear.useMutation({onSuccess:()=>h()}),u=(r??[]).filter(s=>{const g=(s.details?.total??0)>=10,a=s.level==="error";return!(!g&&!a||o!=="all"&&s.level!==o)}).slice(0,x);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"并忥å¿"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"æ¾ç¤ºè¶
è¿ 10 人并åçæ report çäºä»¶ï¼ä»¥åéåè¶
æ¶/é误ãæå¤æ¾ç¤º 100 æ¡ã"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{variant:t?"default":"outline",size:"sm",className:"h-8 gap-1.5 text-xs",onClick:()=>d(s=>!s),children:[e.jsx(w,{className:`h-3.5 w-3.5 ${t?"animate-spin":""}`}),"Auto-refresh ",t?"ON":"OFF"]}),e.jsxs(b,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs",onClick:()=>h(),children:[e.jsx(w,{className:"h-3.5 w-3.5"}),"Refresh"]}),e.jsxs(b,{variant:"outline",size:"sm",className:"h-8 gap-1.5 text-xs text-destructive hover:text-destructive",onClick:()=>S.mutate(),disabled:S.isPending,children:[e.jsx(V,{className:"h-3.5 w-3.5"}),"Clear All"]})]})]}),e.jsx(G,{logs:u}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(I,{value:o,onValueChange:s=>
1f(s),children:[e.jsx(q,{className:"w-36 h-8 text-sm",children:e.jsx(F,{placeholder:"All Levels"})}),e.jsxs(O,{children:[e.jsx(n,{value:"all",children:"All Levels"}),e.jsx(n,{value:"warn",children:"Warnings"}),e.jsx(n,{value:"error",children:"Errors"}),e.jsx(n,{value:"info",children:"Info"})]})]}),e.jsxs(I,{value:String(x),onValueChange:s=>j(Number(s)),children:[e.jsx(q,{className:"w-32 h-8 text-sm",children:e.jsx(F,{})}),e.jsxs(O,{children:[e.jsx(n,{value:"50",children:"Last 50"}),e.jsx(n,{value:"100",children:"Last 100"})]})]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:[u.length," entries shown",(r?.length??0)>0&&e.jsxs("span",{className:"ml-1 text-muted-foreground/60",children:["(total concurrency logs: ",r?.filter(s=>(s.details?.total??0)>=10||s.level==="error").length??0,")"]})]})]}),e.jsx(i,{children:e.jsx(c,{className:"p-0",children:m?e.jsxs("div",{className:"flex items-center justify-center py-16 text-muted-foreground text-sm",children:[e.jsx(w,{className:"h-4 w-4 animate-spin mr-2"}),"Loading concurrency logs..."]}):u.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground",children:[e.jsx(C,{className:"h-8 w-8 mb-3 opacity-30"}),e.jsx("p",{className:"text-sm font-medium",children:"No high-concurrency events yet."}),e.jsx("p",{className:"text-xs mt-1 text-center max-w-xs",children:"Events will appear here when 10+ users generate reports simultaneously, or when queue timeouts/errors occur."})]}):e.jsx("div",{className:"divide-y",children:u.map(s=>{const l=z[s.level]??z.info,g=l.icon,a=s.details??{},p=a.total,y=a.active,L=a.queued,k=a.peak,N=a.waitedSec,A=a.durationSec,E=a.hostname;return e.jsxs("div",{className:`flex gap-3 px-4 py-3 hover:bg-muted/30 transition-colors ${l.bg}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(g,{className:`h-4 w-4 ${s.level==="error"?"text-red-500":s.level==="warn"?"text-amber-500":"text-blue-400"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:W(s.timestamp)}),e.jsx(T,{variant:"outline",className:`text-[10px] px-1.5 py-0 h-4 font-medium ${l.color}`,children:l.label}),p!==void 0&&e.jsxs(T,{variant:"outline",className:`text-[10px] px-1.5 py-0 h-4 font-medium ${p>=20?"text-red-600 border-red-200 bg-red-50":p>=10?"text-amber-600 border-amber-200 bg-amber-50":"text-muted-foreground"}`,children:[e.jsx(C,{className:"h-2.5 w-2.5 mr-0.5"}),p," concurrent"]})]}),e.jsx("p",{className:"text-sm text-foreground leading-snug",children:s.message}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-xs text-muted-foreground",children:[E&&e.jsx("span",{className:"font-mono bg-muted/50 px-1.5 py-0.5 rounded",children:E}),y!==void 0&&e.jsxs("span",{children:["active: ",e.jsx("strong",{children:y}),"/3"]}),L!==void 0&&e.jsxs("span",{children:["queued: ",e.jsx("strong",{children:L})]}),k!==void 0&&e.jsxs("span",{children:["peak: ",e.jsx("strong",{className:"text-purple-600",children:k})]}),N!==void 0&&e.jsxs("span",{className:N>60?"text-amber-600 font-medium":"",children:["waited: ",e.jsxs("strong",{children:[N,"s"]})]}),A!==void 0&&e.jsxs("span",{children:["duration: ",e.jsxs("strong",{children:[A,"s"]})]})]})]}),e.jsxs("div",{className:"flex-shrink-0 text-[10px] text-muted-foreground/50 font-mono mt-0.5",children:["#",s.id]})]},s.id)})})})})]})}export{ie as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.