@inspectr/app 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -208,4 +208,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
208
208
|
${zn(Y.timestamp)}
|
|
209
209
|
Duration ${io(Y.duration)}`,nt=Wwe(Y.status),xt=`${Y.id||Y.operationId||Y.timestampMs||"op"}-${ce?.token||"all"}-${se}`;return l.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-stretch md:gap-4",children:[l.jsxs("div",{className:"w-full min-w-0 md:w-1/3 lg:w-1/5",children:[l.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[l.jsx("span",{className:`font-semibold uppercase ${kf(Y.method)}`,children:Y.method}),l.jsx("span",{className:"max-w-md truncate text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:Y.path||"/"}),l.jsxs("span",{className:"max-w-md truncate text-[11px] text-tremor-content-subtle dark:text-dark-tremor-content",children:["(",io(Y.duration),")"]})]}),l.jsx("div",{className:"text-[11px] text-tremor-content-subtle dark:text-dark-tremor-content",children:zn(Y.timestamp)})]}),l.jsx("div",{className:"w-full md:w-2/3 lg:w-4/5",children:l.jsxs("div",{className:"relative h-10 overflow-hidden rounded-tremor-small border border-dashed border-tremor-border bg-tremor-background-subtle dark:border-dark-tremor-border dark:bg-dark-tremor-background-subtle",children:[l.jsxs("div",{className:"absolute inset-0 pointer-events-none",children:[U.slice(1).map(gt=>l.jsx("div",{className:"absolute top-0 bottom-0 border-l border-tremor-border dark:border-dark-tremor-border",style:{left:`${gt.leftPercent}%`}},`day-boundary-${gt.key}`)),V.filter(gt=>gt.percent>0&>.percent<100).map(gt=>l.jsx("div",{className:"absolute top-1 bottom-1 border-l border-tremor-border opacity-40 dark:border-dark-tremor-border dark:opacity-50",style:{left:`${rc(gt.percent)}%`}},`grid-${gt.key}`))]}),l.jsxs("div",{className:`absolute inset-y-1 z-10 flex items-center overflow-hidden rounded ${nt} text-[10px] font-semibold uppercase tracking-wide text-white shadow-sm`,style:{left:`${Ve}%`,width:et,transform:Ie},title:st,children:[l.jsx("span",{className:"px-2 truncate",children:Y.method}),l.jsxs("span",{className:"px-2 truncate",children:["Duration ",io(Y.duration)]})]})]})})]},xt)})})]},fe.key))})]}):l.jsx(vl,{message:"Select a valid time range to view the timeline."})})]})}const wo=(...e)=>e.filter(Boolean).join(" "),e2e=e=>{if(!e)return null;try{return new URL(e)}catch{return null}},t2e=(e,t)=>{if(!e)return t??null;const r=Date.parse(e);return Number.isFinite(r)?r:t??null},_R=e=>{if(e==null)return"N/A";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},vj=e=>e?e.trace_id||e.traceId||"Trace":"Unknown trace",r2e=(e,t=0)=>{if(!e)return null;const r=e.request||{},n=e.response||{},o=e.timing||{},a=e.meta||{},i=r.url||"",s=e2e(i),c=r.timestamp||n.timestamp||a.timestamp||e.timestamp||null,u=t2e(c,t),d=Number.isFinite(Number(o.duration))?Number(o.duration):Number.isFinite(Number(e.duration))?Number(e.duration):null,f=Array.isArray(a.tags)?a.tags:Array.isArray(e.tags)?e.tags:[];return{id:e.operation_id||e.operationId||`operation-${t}`,method:(r.method||e.method||"GET").toUpperCase(),status:n.status??e.status??null,duration:d,timestamp:c,timestampMs:u,path:r.path||s?.pathname||i||"/",host:r.server||s?.host||"",url:i,request:r,response:n,timing:o,tags:Pf(f),correlationId:e.correlation_id||null,traceInfo:a.trace||null,raw:e}},n2e=(e,t)=>{if(e!=null&&e.first_seen&&e!=null&&e.last_seen){const o=Date.parse(e.first_seen),a=Date.parse(e.last_seen);if(Number.isFinite(o)&&Number.isFinite(a)&&a>=o)return a-o}if(!(t!=null&&t.length))return null;let r=null,n=null;return t.forEach((o,a)=>{const{start:i,end:s}=_b(o,a);r=r===null?i:Math.min(r,i),n=n===null?s:Math.max(n,s)}),r===null||n===null||n<r?null:n-r},_b=(e,t=0)=>{const r=Number.isFinite(e.timestampMs)?e.timestampMs:t,n=Number.isFinite(e.duration)?e.duration:0,o=r+n;return{start:r,duration:n,end:o}},o2e=e=>{if(!(e!=null&&e.length))return{start:0,end:1,duration:1};let t=null,r=null;if(e.forEach((o,a)=>{const{start:i,end:s}=_b(o,a);t=t===null?i:Math.min(t,i),r=r===null?s:Math.max(r,s)}),t===null||r===null)return{start:0,end:1,duration:1};const n=Math.max(r-t,1);return{start:t,end:r,duration:n}},IR=e=>e>=500?"bg-rose-500/80":e>=400?"bg-amber-500/80":e>=300?"bg-blue-500/70":e>=200?"bg-emerald-500/80":"bg-slate-400/70",DR=e=>e>=500?"bg-rose-500":e>=400?"bg-amber-500":e>=300?"bg-blue-500":e>=200?"bg-emerald-500":"bg-slate-400",a2e=e=>{var t;return(t=e?.raw)!=null&&t.meta?Object.entries(e.raw.meta).filter(([r])=>r!=="tags"&&r!=="trace").map(([r,n])=>({key:r,value:_R(n)})):[]},i2e=e=>{var t;const r=(t=e?.traceInfo)==null?void 0:t.generic;return!r||typeof r!="object"?[]:Object.entries(r).map(([n,o])=>({key:n,value:_R(o)}))},s2e=e=>{var t;if(!((t=e?.tags)!=null&&t.length))return null;const r=e.tags.find(n=>n.keyToken==="agent")||e.tags.find(n=>n.key==="agent");return r&&(r.value||r.display)||null},LR=({operation:e,mcpMeta:t})=>{var r,n;return l.jsxs("dl",{className:"divide-y divide-tremor-border text-sm dark:divide-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[l.jsx("dt",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Request time"}),l.jsx("dd",{className:"text-right text-tremor-content dark:text-dark-tremor-content",children:zn(e.timestamp)})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[l.jsx("dt",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Operation ID"}),l.jsx("dd",{className:"text-right text-sm font-mono text-tremor-content dark:text-dark-tremor-content",children:e.id})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[l.jsx("dt",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Correlation ID"}),l.jsx("dd",{className:"text-right text-sm font-mono text-tremor-content dark:text-dark-tremor-content",children:e.correlationId||"—"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[l.jsx("dt",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Trace ID"}),l.jsx("dd",{className:"text-right text-sm font-mono text-tremor-content dark:text-dark-tremor-content",children:((r=e.traceInfo)==null?void 0:r.trace_id)||"—"})]}),l.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[l.jsx("dt",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Trace source"}),l.jsx("dd",{className:"text-right text-tremor-content dark:text-dark-tremor-content",children:((n=e.traceInfo)==null?void 0:n.source)||"—"})]}),t!=null&&t.tokens?l.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[l.jsx("dt",{className:"text-tremor-content-subtle dark:text-dark-tremor-content",children:"Tokens"}),l.jsxs("dd",{className:"flex items-center gap-2 text-right text-tremor-content dark:text-dark-tremor-content",children:[l.jsxs(Wt,{color:"indigo",size:"xs",children:["Request ",t.tokens.request??"—"]}),l.jsxs(Wt,{color:"indigo",size:"xs",children:["Response ",t.tokens.response??"—"]}),l.jsxs(Wt,{color:"indigo",size:"xs",children:["Total ",t.tokens.total??"—"]})]})]}):null]})},r9=({headers:e=[]})=>e.length?l.jsx("div",{className:"max-h-60 overflow-auto",children:l.jsx("dl",{className:"divide-y divide-tremor-border dark:divide-dark-tremor-border",children:e.map((t,r)=>l.jsxs("div",{className:"flex items-start gap-3 px-3 py-1",children:[l.jsx("dt",{className:"w-40 shrink-0 text-[10px] font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:t.name}),l.jsx("dd",{className:"flex-1 text-[10px] text-tremor-content dark:text-dark-tremor-content",children:t.value||"—"})]},`${t.name}-${r}`))})}):l.jsx(bt,{className:"px-3 py-2 text-sm text-tremor-content-subtle dark:text-dark-tremor-content",children:"No headers"}),yj=e=>e?Array.isArray(e)?e.map(t=>({name:t.name??t.key??"",value:t.value})):typeof e=="object"?"name"in e&&"value"in e?[{name:e.name,value:e.value}]:Object.entries(e).map(([t,r])=>({name:t,value:r})):[]:[],n9=e=>{var t;const r=(t=yj(e).find(n=>{var o;return((o=n.name)==null?void 0:o.toLowerCase())==="content-type"}))==null?void 0:t.value;return!r||typeof r!="string"?null:r.split(";")[0].trim().toLowerCase()},o9=e=>!e||e.includes("json")?"json":e.includes("html")?"html":e.includes("xml")?"xml":e.includes("javascript")?"javascript":e.includes("css")?"css":e.includes("yaml")||e.includes("yml")?"yaml":e.includes("sql")?"sql":(e.startsWith("text/"),"plaintext"),a9=(e,t)=>{if(e==null)return"";if(typeof e=="string"){if(t!=null&&t.includes("json"))try{const r=JSON.parse(e);return JSON.stringify(r,null,2)}catch{return e}if(t!=null&&t.includes("xml"))try{return L8(e)}catch{return e}return e}if(typeof e=="object")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)};function RR({operation:e,isLoading:t}){var r,n,o,a,i,s,c,u,d,f,m,h,g,b,v,x;typeof window<"u"&&localStorage.getItem("debug")==="true"&&console.log("OP",e);const k=a2e(e),N=p.useMemo(()=>new Set(["proxy","ingress","inspectr"]),[]),j=k.filter($=>!N.has($.key)),E=k.filter($=>N.has($.key)),C=i2e(e),S=Array.isArray(e?.tags)?e.tags:[],T=yj((r=e?.request)==null?void 0:r.headers),A=yj((n=e?.response)==null?void 0:n.headers),M=((o=e?.meta)==null?void 0:o.mcp)||((i=(a=e?.raw)==null?void 0:a.meta)==null?void 0:i.mcp)||((c=(s=e?.meta)==null?void 0:s.trace)==null?void 0:c.mcp)||((f=(d=(u=e?.raw)==null?void 0:u.meta)==null?void 0:d.trace)==null?void 0:f.mcp)||{},_=n9((m=e?.request)==null?void 0:m.headers),I=n9((h=e?.response)==null?void 0:h.headers),F=a9((g=e?.request)==null?void 0:g.body,_),D=a9((b=e?.response)==null?void 0:b.body,I),R=o9(_),z=o9(I),H=p.useMemo(()=>({readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",fontSize:12,lineNumbers:"off",folding:!1}),[]);return e?l.jsxs("div",{className:"flex h-full flex-col",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Cu,{method:e.method}),l.jsx(Xn,{className:"text-lg text-tremor-content-strong dark:text-dark-tremor-content-strong",children:`${e.path||e.url||"Operation"}`})]}),l.jsx(bt,{className:"mt-1 text-sm text-tremor-content dark:text-dark-tremor-content",children:e.host||((v=e.request)==null?void 0:v.server)||"Unspecified host"})]}),l.jsxs("div",{className:"flex flex-col items-end gap-2",children:[l.jsx(El,{status:e.status}),l.jsx(Wt,{color:"blue",children:io(e.duration)})]})]}),l.jsxs("div",{className:"mt-6 space-y-5",children:[l.jsx(vo,{title:"Properties",resetKey:e?.id,defaultOpen:!0,children:l.jsx(LR,{operation:e,mcpMeta:M})}),l.jsx(vo,{title:`Request headers (${T.length})`,resetKey:e?.id,defaultOpen:!1,children:l.jsx(r9,{headers:T})}),l.jsx(vo,{title:"Request body",resetKey:e?.id,defaultOpen:!1,copyText:F,children:l.jsx("div",{className:"h-60 overflow-hidden",children:l.jsx(li,{value:F||"No request body",language:R,theme:ui(),beforeMount:ci,options:H,height:"100%"})})}),l.jsx(vo,{title:"Response body",resetKey:e?.id,defaultOpen:!1,copyText:D,children:l.jsx("div",{className:"h-[320px] overflow-hidden",children:l.jsx(li,{value:D||"No response body",language:z,theme:ui(),beforeMount:ci,options:H,height:"100%"})})}),l.jsx(vo,{title:`Response headers (${A.length})`,resetKey:e?.id,defaultOpen:!1,children:l.jsx(r9,{headers:A})}),S.length?l.jsxs("div",{children:[l.jsx(bt,{className:"text-xs font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:"Tags"}),l.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:S.map($=>l.jsx("span",{className:"inline-flex items-center rounded-full bg-gray-100 px-2.5 py-1 text-xs font-medium text-gray-700 dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content",children:$.display},$.token))})]}):null,j.length?l.jsx(vo,{title:"Metadata",resetKey:e?.id,defaultOpen:!1,children:l.jsx("div",{className:"px-3 py-2",children:l.jsx("div",{className:"mt-2 space-y-3",children:j.map($=>l.jsxs("div",{children:[l.jsx(bt,{className:"text-xs font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:$.key}),l.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-tremor-small bg-gray-900 px-3 py-2 text-xs text-gray-100 dark:bg-gray-800 dark:text-gray-100",children:$.value})]},$.key))})})}):null,E.length||C.length?l.jsx(vo,{title:"Advanced metadata",resetKey:e?.id,defaultOpen:!1,children:l.jsxs("div",{className:"divide-y divide-tremor-border text-sm dark:divide-dark-tremor-border",children:[(x=e.traceInfo)!=null&&x.generic&&C.length?l.jsxs("div",{className:"px-3 py-2",children:[l.jsx(bt,{className:"text-xs font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:"Trace metadata"}),l.jsx("div",{className:"mt-2 space-y-3",children:C.map($=>l.jsxs("div",{children:[l.jsx(bt,{className:"text-xs font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:$.key}),l.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-tremor-small bg-gray-900 px-3 py-2 text-xs text-gray-100 dark:bg-gray-800 dark:text-gray-100",children:$.value})]},$.key))})]}):null,E.map($=>l.jsxs("div",{className:"px-3 py-2",children:[l.jsx(bt,{className:"text-xs font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:$.key}),l.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap rounded-tremor-small bg-gray-900 px-3 py-2 text-xs text-gray-100 dark:bg-gray-800 dark:text-gray-100",children:$.value})]},$.key))]})}):null]})]}):l.jsx("div",{className:"flex h-full items-center justify-center text-sm text-tremor-content-subtle dark:text-dark-tremor-content",children:t?"Loading trace details…":"Select an Operation span to inspect its details."})}const i9=200,FR=({initialTraceId:e=null,initialOperationId:t=null,onTraceChange:r,onOperationChange:n,isActive:o=!0,listLimit:a=i9,detailLimit:i=i9}={})=>{var s,c;const{client:u}=Tr(),d=!!((s=u?.traces)!=null&&s.list&&(c=u?.traces)!=null&&c.get),[f,m]=p.useState([]),[h,g]=p.useState(null),[b,v]=p.useState(!1),[x,k]=p.useState(null),[N,j]=p.useState(e??null),[E,C]=p.useState(null),[S,T]=p.useState(null),[A,M]=p.useState([]),[_,I]=p.useState(!1),[F,D]=p.useState(null),[R,z]=p.useState(0),[H,$]=p.useState(1),[V,U]=p.useState(0),[B,X]=p.useState(t??null),K=p.useRef(r),ae=p.useRef(n),J=p.useRef(void 0),ee=p.useRef(void 0);p.useEffect(()=>{K.current=r},[r]),p.useEffect(()=>{ae.current=n},[n]),p.useEffect(()=>{e&&e!==N&&j(e)},[e]),p.useEffect(()=>{t&&t!==B&&X(t)},[t]),p.useEffect(()=>{if(!d||!o)return;let ne=!0;return v(!0),k(null),u.traces.list({limit:a}).then(oe=>{ne&&(m(Array.isArray(oe?.traces)?oe.traces:[]),g(oe?.meta||null))}).catch(oe=>{ne&&(k(oe),m([]),g(null))}).finally(()=>{ne&&v(!1)}),()=>{ne=!1}},[d,u,a,o,V]),p.useEffect(()=>{var ne;if(!f.length||N)return;const oe=e&&f.some(xe=>xe.trace_id===e)?e:((ne=f[0])==null?void 0:ne.trace_id)??null;oe&&oe!==N&&j(oe)},[f,N,e]),p.useEffect(()=>{$(1)},[N]),p.useEffect(()=>{if(!d||!o||!N){C(null),T(null),M([]),D(null);return}let ne=!0;return I(!0),D(null),u.traces.get(N,{page:H,limit:i}).then(oe=>{ne&&(C(oe?.trace||null),T(oe?.meta||null),M(Array.isArray(oe?.operations)?oe.operations:[]))}).catch(oe=>{ne&&(D(oe),C(null),T(null),M([]))}).finally(()=>{ne&&I(!1)}),()=>{ne=!1}},[d,u,N,i,o,R,H]);const te=p.useMemo(()=>Array.isArray(A)?A.map((ne,oe)=>r2e(ne,oe)).filter(Boolean).sort((ne,oe)=>{const xe=Number.isFinite(ne.timestampMs)?ne.timestampMs:0,Ce=Number.isFinite(oe.timestampMs)?oe.timestampMs:0;return xe-Ce}):[],[A]);p.useEffect(()=>{if(!te.length){B!==null&&X(null);return}if(B&&te.some(oe=>oe.id===B))return;const ne=t&&te.some(oe=>oe.id===t)?t:te[0].id;ne!==B&&X(ne)},[te,B,t]);const fe=p.useMemo(()=>B&&te.find(ne=>ne.id===B)||null,[te,B]),Y=p.useMemo(()=>E||f.find(ne=>ne.trace_id===N)||null,[E,f,N]),ce=Y?.sources||E?.sources||[],se=p.useMemo(()=>n2e(Y,te),[Y,te]),W=p.useMemo(()=>o2e(te),[te]);return p.useEffect(()=>{!o||typeof K.current!="function"||J.current!==N&&(J.current=N,K.current(N||null))},[N,o]),p.useEffect(()=>{!o||typeof ae.current!="function"||ee.current!==B&&(ee.current=B,ae.current(B||null))},[B,o]),p.useEffect(()=>{o||(v(!1),I(!1))},[o]),{supportsTraces:d,traceList:f,traceListMeta:h,isTraceListLoading:b,traceListError:x,traceDetail:E,traceDetailMeta:S,traceDetailError:F,isTraceDetailLoading:_,selectedTraceId:N,setSelectedTraceId:ne=>{if(!ne){j(null),X(null);return}ne!==N&&X(null),j(ne)},traceSummary:Y,traceSources:ce,traceDurationMs:se,normalizedOperations:te,timeline:W,selectedOperationId:B,setSelectedOperationId:ne=>{X(ne)},selectedOperation:fe,refreshTraceList:()=>U(ne=>ne+1),refreshTraceDetail:()=>z(ne=>ne+1),traceDetailPage:H,setTraceDetailPage:$}},s9=2;function l2e({operations:e=[],initialTraceId:t=null,initialOperationId:r=null,onTraceChange:n,onOperationChange:o,isActive:a=!0}){const{supportsTraces:i,traceList:s,traceListMeta:c,isTraceListLoading:u,traceListError:d,traceDetailError:f,traceDetailMeta:m,isTraceDetailLoading:h,selectedTraceId:g,setSelectedTraceId:b,traceSummary:v,traceSources:x,traceDurationMs:k,normalizedOperations:N,timeline:j,selectedOperationId:E,setSelectedOperationId:C,selectedOperation:S}=FR({initialTraceId:t,initialOperationId:r,onTraceChange:n,onOperationChange:o,isActive:a}),T=j.start,A=j.duration;if(!i)return l.jsx(Lt,{className:"rounded-tremor-small border border-dashed border-tremor-border p-6 text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"Trace exploration requires an Inspectr API version that exposes the /api/traces endpoints."});if(u&&!s.length)return l.jsx(Lt,{className:"rounded-tremor-small border border-tremor-border p-6 text-center text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"Loading traces…"});if(d&&!s.length)return l.jsxs(Lt,{className:"rounded-tremor-small border border-rose-200 bg-rose-50 p-6 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-900/20 dark:text-rose-300",children:["Failed to load traces: ",d.message||"Unexpected error"]});if(!s.length)return l.jsx(vl,{message:"No traces recorded yet. Start sending traffic to populate this view."});const M=v?.operation_count||N.length,_=I=>{var F;const D=Number.isFinite(I.timestampMs)?I.timestampMs:T,R=Number.isFinite(I.duration)?I.duration:0,z=(D-T)/A*100,H=Math.min(Math.max(z,0),100),$=R/A*100,V=Math.min(Math.max(Number.isFinite($)?$:s9,s9),100-H),U=E===I.id,B=`${I.method} ${I.path}`;return l.jsxs("button",{type:"button",onClick:()=>C(I.id),className:wo("w-full rounded-tremor-small border px-3 py-3 text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:border-dark-tremor-border",U?"border-tremor-brand bg-tremor-brand-faint ring-0 dark:border-tremor-brand":"border-transparent hover:border-slate-200 hover:bg-slate-50 dark:hover:border-slate-600 dark:hover:bg-dark-tremor-background-subtle"),children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:wo("h-2.5 w-2.5 rounded-full",DR(I.status??null))}),l.jsx("span",{className:"truncate text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:B})]}),l.jsxs("div",{className:"flex flex-col items-end gap-1 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[l.jsx("span",{children:io(I.duration)}),l.jsx("span",{children:zn(I.timestamp)})]})]}),l.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[l.jsx(Cu,{method:I.method}),l.jsx(El,{status:I.status}),(F=I.traceInfo)!=null&&F.source?l.jsx(Wt,{color:"blue",children:I.traceInfo.source}):null,I.host?l.jsx("span",{className:"truncate",children:I.host}):null]}),l.jsx("div",{className:"relative mt-3 h-2 rounded-full bg-slate-100 dark:bg-dark-tremor-background-subtle",children:l.jsx("span",{className:wo("absolute top-0 h-2 rounded-full transition-all",IR(I.status??null)),style:{left:`${H}%`,width:`${V}%`}})})]},I.id)};return l.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)]",children:[l.jsxs(Lt,{className:"rounded-tremor-small border border-tremor-border p-6 dark:border-dark-tremor-border",children:[l.jsxs(Cb,{justifyContent:"between",alignItems:"start",children:[l.jsxs("div",{children:[l.jsx(Xn,{className:"text-lg text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Trace explorer"}),l.jsx(bt,{className:"mt-1 text-sm text-tremor-content dark:text-dark-tremor-content",children:"Inspect spans collected for a trace and explore downstream requests."})]}),l.jsx(Wt,{color:f?"rose":"slate",children:`${M} ${M===1?"step":"steps"}`})]}),l.jsxs("div",{className:"mt-6 flex flex-col gap-4",children:[l.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{children:[l.jsx(bt,{className:"text-xs font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:"Trace"}),l.jsx(bt,{className:"text-sm text-tremor-content-strong dark:text-dark-tremor-content-strong",children:vj(v)})]}),x!=null&&x.length?l.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(I=>l.jsx(Wt,{color:"blue",children:I},I))}):null,l.jsxs("div",{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[v!=null&&v.first_seen?l.jsxs("div",{children:["First seen: ",zn(v.first_seen)]}):null,v!=null&&v.last_seen?l.jsxs("div",{children:["Last seen: ",zn(v.last_seen)]}):null,k!=null?l.jsxs("div",{children:["Observed duration: ",io(k)]}):null]})]}),l.jsx(N1,{className:"w-full sm:w-72 [&>button]:rounded-tremor-small",enableClear:!1,value:g??v?.trace_id??"",onValueChange:b,children:s.map(I=>l.jsx(Ji,{value:I.trace_id,children:vj(I)},I.trace_id))})]}),l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[l.jsxs("span",{children:["Page ",m?.page||c?.page||1," of"," ",c?.total_pages||m?.total_pages||1]}),l.jsx("span",{children:h?"Refreshing trace…":`Total operations: ${M}`})]}),f?l.jsxs(Lt,{className:"rounded-tremor-small border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-900/20 dark:text-rose-300",children:["Failed to load trace details: ",f.message||"Unexpected error"]}):null,l.jsx("div",{className:"space-y-4",children:N.length?N.map(I=>_(I)):l.jsx(Lt,{className:"rounded-tremor-small border border-dashed border-tremor-border p-6 text-center text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"No operations recorded for this trace."})})]})]}),l.jsx(Lt,{className:"rounded-tremor-small border border-tremor-border p-6 dark:border-dark-tremor-border",children:l.jsx(RR,{operation:S,isLoading:h})})]})}const l9=({items:e=[]})=>e.length?l.jsx("div",{className:"space-y-1 text-xs text-tremor-content dark:text-dark-tremor-content",children:e.map((t,r)=>{if(!t)return null;const{label:n,value:o}=t;return o==null||o===""?null:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx("span",{className:"font-mono text-tremor-content-strong dark:text-dark-tremor-content-strong",children:n}),l.jsx("span",{className:"flex-1 break-words",children:typeof o=="string"?o:JSON.stringify(o)})]},`${n}-${r}`)})}):null;function c2e({operation:e,isLoading:t}){var r,n,o,a,i,s,c,u,d,f,m,h,g,b,v,x,k,N,j,E,C,S,T,A,M,_,I,F,D;typeof window<"u"&&localStorage.getItem("debug")==="true"&&console.log("OP",e);const[R,z]=p.useState(!1),[H,$]=p.useState("structured"),V=p.useRef([]),U=((r=e?.meta)==null?void 0:r.mcp)||((o=(n=e?.raw)==null?void 0:n.meta)==null?void 0:o.mcp)||((i=(a=e?.meta)==null?void 0:a.trace)==null?void 0:i.mcp)||((u=(c=(s=e?.raw)==null?void 0:s.meta)==null?void 0:c.trace)==null?void 0:u.mcp)||{},B=typeof((d=e?.request)==null?void 0:d.body)=="string"?e.request.body:(f=e?.request)!=null&&f.body?JSON.stringify(e.request.body):"",X=typeof((m=e?.response)==null?void 0:m.body)=="string"?e.response.body:(h=e?.response)!=null&&h.body?JSON.stringify(e.response.body):"",K=y9((g=e?.response)==null?void 0:g.event_frames),ae=X||K||"",J=gp(B),ee=gp(ae),te=U.method||J?.method||"",fe=U.category||"";(b=ee?.result)!=null&&b.tools||ee?.tools;const Y=Array.isArray((v=e?.meta)==null?void 0:v.tags)&&e.meta.tags.some(ye=>typeof ye=="string"&&ye.startsWith("mcp.tool.")),ce=p.useMemo(()=>v9(te,ee),[te,ee]),se=ce.type==="toolsList"&&Array.isArray(ce.tools),W=te==="tools/call"||te==="tool/call"||Y,ne=ce.type==="promptsList",oe=te==="prompts/get",xe=ce.type==="resourcesList",Ce=te==="resources/read",Le=p.useMemo(()=>Array.isArray(ce.content)&&ce.content.length,[ce.content]),Oe=p.useMemo(()=>{const ye=[];return ce.structuredContent&&ye.push({key:"structured",label:"Structured content"}),Le&&ye.push({key:"content",label:"Content items"}),ye.push({key:"raw",label:"Raw content"}),ye},[ce.structuredContent,Le]);p.useEffect(()=>{z(!1),ce.structuredContent?$("structured"):$(Le?"content":"raw")},[e?.id]),se&&ce.tools.length&&(V.current=ce.tools);const Ve=(V.current||[]).find(ye=>{var ve;return ye.name===((ve=J?.params)==null?void 0:ve.name)}),et=((k=(x=ee?.result)==null?void 0:x.tool)==null?void 0:k.inputSchema)||Ve?.inputSchema||Array.isArray(ce.tools)&&((N=ce.tools.find(ye=>{var ve;return ye.name===((ve=J?.params)==null?void 0:ve.name)}))==null?void 0:N.inputSchema)||null,Ie=W?xF(((j=J?.params)==null?void 0:j.arguments)||{},et):{missing:[],extra:[]},st=ee?.result,nt=st?.mimeType||((E=st?.resource)==null?void 0:E.mimeType)||"",xt=J?JSON.stringify(J,null,2):B||"No request body",gt=ee?JSON.stringify(ee,null,2):X||"No response body",ft=p.useMemo(()=>({readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"on",fontSize:12,lineNumbers:"off",folding:!1}),[]),kt=()=>W?"Tool call":se?"Tools list":ne?"Prompts list":oe?"Prompt":xe?"Resources list":Ce?"Resource":"Typed view";return e?l.jsxs("div",{className:"flex h-full flex-col",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Cu,{method:e.method}),l.jsx(Xn,{className:"text-lg text-tremor-content-strong dark:text-dark-tremor-content-strong",children:`${e.path||e.url||"Operation"}`})]}),l.jsx(bt,{className:"mt-1 text-sm text-tremor-content dark:text-dark-tremor-content",children:e.host||((C=e.request)==null?void 0:C.server)||"Unspecified host"})]}),l.jsxs("div",{className:"flex flex-col items-end gap-2",children:[l.jsx(El,{status:e.status}),l.jsx(Wt,{color:"blue",children:io(e.duration)})]})]}),l.jsxs("div",{className:"mt-6 flex-1 space-y-5 pr-1",children:[l.jsx(vo,{title:"Properties",resetKey:e?.id,defaultOpen:!0,children:l.jsx(LR,{operation:e,mcpMeta:U})}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(bt,{className:"text-xs font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:"MCP"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(hc,{method:te||"",children:te||"Unknown method"}),fe?l.jsx(Wt,{color:"slate",size:"xs",children:fe}):null]})]}),l.jsxs(tu,{index:R?1:0,onIndexChange:ye=>z(ye===1),children:[l.jsxs(eu,{children:[l.jsx(yo,{children:kt()}),l.jsx(yo,{children:"Raw"})]}),l.jsxs(ru,{children:[l.jsx(xo,{children:l.jsxs("div",{className:"space-y-3",children:[se&&(S=ce.tools)!=null&&S.length?l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs(bt,{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:["Tools (",ce.tools.length,")"]})}),l.jsx("div",{className:"space-y-2",children:ce.tools.map(ye=>l.jsx(lR,{tool:ye},ye.name))})]}):null,W?l.jsx("div",{className:"space-y-2",children:l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsx("span",{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:"Tool:"}),l.jsx(hc,{method:te||"",children:((T=J?.params)==null?void 0:T.name)||"-"}),l.jsx("span",{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:"Result:"}),ee!=null&&ee.error?l.jsx(Wt,{color:"rose",size:"xs",children:"Error"}):l.jsx(Wt,{color:"emerald",size:"xs",children:"Success"})]}),l.jsxs("div",{className:"grid gap-3 md:grid-cols-1",children:[l.jsx(up,{validation:et?Ie:void 0,children:l.jsx(iR,{args:(A=J?.params)==null?void 0:A.arguments})}),l.jsx(dp,{children:ee?(()=>{var ye;const ve=((ye=Oe.find(Ke=>Ke.key===H))==null?void 0:ye.key)||Oe[0].key,Ae=Oe.findIndex(Ke=>Ke.key===ve),$e=ee?.result??ee??{};return l.jsxs(tu,{index:Ae,onIndexChange:Ke=>{var Nt;return $(((Nt=Oe[Ke])==null?void 0:Nt.key)||Oe[0].key)},children:[l.jsx(eu,{children:Oe.map(Ke=>l.jsx(yo,{children:Ke.label},Ke.key))}),l.jsx(ru,{children:Oe.map(Ke=>l.jsxs(xo,{children:[Ke.key==="structured"?l.jsx(Qa,{data:ce.structuredContent,title:"Structured content",copyText:JSON.stringify(ce.structuredContent,null,2)}):null,Ke.key==="content"?l.jsx(Qa,{data:ce.content,title:"Content items",copyText:JSON.stringify(ce.content,null,2),children:l.jsx(uR,{items:ce.content})}):null,Ke.key==="raw"?l.jsx(Qa,{data:$e,title:"Raw Output",copyText:JSON.stringify($e,null,2)}):null]},Ke.key))})]})})():l.jsx(bt,{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:"No result returned."})})]})]})}):null,ne&&Array.isArray(ce.prompts)?l.jsxs("div",{className:"space-y-2",children:[l.jsxs(bt,{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:["Prompts (",ce.prompts.length,")"]}),l.jsx("div",{className:"space-y-2",children:ce.prompts.map(ye=>{const ve=ye.arguments||[],Ae=ve.filter($e=>$e.required).length;return l.jsxs(Lt,{className:"space-y-1 rounded-tremor-small border border-tremor-border p-3 shadow-sm dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx(bt,{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:ye.title||ye.name}),ye.description?l.jsx(bt,{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:ye.description}):null]}),l.jsxs(Wt,{color:"slate",size:"xs",children:[ve.length," args",Ae?` (${Ae} required)`:""]})]}),ve.length?l.jsx("div",{className:"space-y-1",children:ve.map($e=>l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx("span",{className:"font-mono text-tremor-content-strong dark:text-dark-tremor-content-strong",children:$e.name}),l.jsx("span",{className:"flex-1 text-tremor-content dark:text-dark-tremor-content",children:$e.description||"No description"}),$e.required?l.jsx(Wt,{color:"rose",size:"xs",children:"required"}):null]},$e.name))}):null]},ye.name)})})]}):null,oe&&Array.isArray((M=ee?.result)==null?void 0:M.messages)?l.jsx("div",{className:"space-y-2",children:l.jsxs("div",{className:"grid gap-3",children:[l.jsx(up,{children:l.jsx(l9,{items:[{label:"name",value:((_=J?.params)==null?void 0:_.name)||((I=ee?.result)==null?void 0:I.name)||"—"},...Array.isArray((F=J?.params)==null?void 0:F.arguments)?J.params.arguments.map((ye,ve)=>({label:`arg ${ve+1}`,value:ye})):[]]})}),l.jsx(dp,{children:l.jsx("div",{className:"space-y-2",children:ee.result.messages.map((ye,ve)=>{var Ae;return l.jsx("div",{className:`flex ${ye.role==="assistant"?"justify-end":"justify-start"}`,children:l.jsx("div",{className:`max-w-xl rounded-tremor-small px-3 py-2 text-sm ${ye.role==="assistant"?"bg-tremor-brand-faint text-tremor-content-strong":"bg-tremor-background-subtle text-tremor-content dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content"}`,children:Array.isArray(ye.content)?ye.content.map(($e,Ke)=>l.jsx("div",{children:$e.text||"[content]"},Ke)):((Ae=ye.content)==null?void 0:Ae.text)||"[content]"})},ve)})})})]})}):null,xe&&Array.isArray(ce.resources)?l.jsxs("div",{className:"space-y-2",children:[l.jsxs(bt,{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:["Resources (",ce.resources.length,")"]}),l.jsx("div",{className:"divide-y divide-tremor-border text-sm dark:divide-dark-tremor-border",children:ce.resources.map(ye=>l.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-sm font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:ye.title||ye.name||ye.uri}),l.jsx("div",{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:ye.uri}),ye.description?l.jsx("div",{className:"text-xs text-tremor-content dark:text-dark-tremor-content",children:ye.description}):null]}),ye.mimeType?l.jsx(Wt,{color:"slate",size:"xs",children:ye.mimeType}):null,ye.size?l.jsx(Wt,{color:"slate",size:"xs",children:`${(ye.size/1024).toFixed(1)} KB`}):null]},ye.uri))})]}):null,Ce&&ee!=null&&ee.result?l.jsx("div",{className:"space-y-2",children:l.jsxs("div",{className:"grid gap-3",children:[l.jsx(up,{children:l.jsx(l9,{items:[{label:"uri",value:((D=J?.params)==null?void 0:D.uri)||st?.uri},nt?{label:"mime",value:nt}:null]})}),l.jsx(dp,{children:l.jsx(cR,{resource:st,mimeType:nt,editorOptions:ft})})]})}):null,!se&&!W&&!ne&&!oe&&!xe&&!Ce?l.jsx(bt,{className:"text-sm text-tremor-content-subtle dark:text-dark-tremor-content",children:"No typed MCP view available for this method. Switch to Raw JSON to inspect."}):null]})}),l.jsx(xo,{children:l.jsxs("div",{className:"space-y-3",children:[l.jsx(vo,{title:"HTTP Request",resetKey:e?.id,defaultOpen:!1,copyText:xt,children:l.jsx("div",{className:"h-60 overflow-hidden",children:l.jsx(li,{value:xt||"No request body",language:"json",theme:ui(),beforeMount:ci,options:ft,height:"100%"})})}),l.jsx(vo,{title:"HTTP Response",resetKey:e?.id,defaultOpen:!1,copyText:gt,children:l.jsx("div",{className:"h-[320px] overflow-hidden",children:l.jsx(li,{value:gt||"No response body",language:"json",theme:ui(),beforeMount:ci,options:ft,height:"100%"})})})]})})]})]})]})]})]}):l.jsx("div",{className:"flex h-full items-center justify-center text-sm text-tremor-content-subtle dark:text-dark-tremor-content",children:t?"Loading trace details…":"Select an Operation span to inspect its details."})}const ql=3;function $R({start:e,duration:t,status:r,total:n,baseStart:o,baseDuration:a,variant:i="status"}){if(!Number.isFinite(n)||n<=0)return l.jsx("div",{className:"h-2 w-full rounded-full bg-slate-200 dark:bg-dark-tremor-background-subtle"});const s=Number.isFinite(n)&&n>0?n:a,c=(e-o)/s*100,u=t/s*100,d=(h,g=0,b=100)=>Math.min(Math.max(h,g),b);let f=d(c),m=d(f+u)-f;return!Number.isFinite(m)||m<=0?(m=ql,f>=100&&(f=100-m)):m<ql&&(m=Math.min(100,f+ql)-f,m<ql&&(f=Math.max(0,100-ql),m=ql)),l.jsx("div",{className:"relative h-2 min-w-0 flex-1 overflow-hidden rounded-full bg-slate-200 dark:bg-dark-tremor-background-subtle",children:l.jsx("span",{className:wo("absolute top-0 h-2 rounded-full transition-all",i==="brand"?"bg-tremor-brand/80 dark:bg-tremor-brand/60":IR(r??null)),style:{left:`${f}%`,width:`${m}%`}})})}function u2e({operation:e,index:t,isSelected:r,onSelect:n,timelineWidth:o,baseStart:a,baseDuration:i,selectedOperationRef:s}){var c,u,d,f,m,h,g,b;const{start:v,duration:x}=_b(e,t),k=((c=e?.meta)==null?void 0:c.mcp)||((d=(u=e?.raw)==null?void 0:u.meta)==null?void 0:d.mcp)||((m=(f=e?.meta)==null?void 0:f.trace)==null?void 0:m.mcp)||((b=(g=(h=e?.raw)==null?void 0:h.meta)==null?void 0:g.trace)==null?void 0:b.mcp),N=k?.name||k?.method||null;return l.jsx("button",{ref:r?s:null,type:"button",onClick:n,className:wo("flex w-full items-center gap-3 rounded-tremor-small px-0 py-1.5 text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",r?"bg-tremor-brand-faint text-tremor-content-strong ring-0 dark:bg-tremor-brand-faint/40":"hover:bg-slate-100 dark:hover:bg-dark-tremor-background-subtle"),children:l.jsxs("div",{className:wo("grid w-full items-center gap-2 pl-0",o<45?"sm:grid-cols-[1.5rem_minmax(0,1fr)]":"sm:grid-cols-[1.5rem_minmax(0,1fr)_65%]"),children:[l.jsx("div",{className:"flex justify-center",children:l.jsx("span",{className:wo("h-2 w-2 rounded-full",DR(e.status??null))})}),l.jsxs("div",{className:"min-w-0 flex flex-col",children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[l.jsx(Cu,{method:e.method}),l.jsx("span",{className:"truncate",children:e.path}),N?l.jsx(hc,{method:k?.method||"",children:N}):null]}),l.jsx(bt,{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:zn(e.timestamp,{includeMilliseconds:!0})})]}),l.jsxs("div",{className:wo("min-w-0 items-center gap-3",o<45?"hidden":"flex"),children:[l.jsx(bt,{className:"w-20 shrink-0 text-right text-xs font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:io(e.duration)}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx($R,{start:v,duration:x,status:e.status,total:i,baseStart:a,baseDuration:i})}),l.jsx("div",{className:"w-10 shrink-0 flex justify-center",children:l.jsx(El,{status:e.status})})]})]})},e.id)}function d2e({group:e,isExpanded:t,onToggle:r,selectedOperationId:n,onOperationSelect:o,timelineWidth:a,baseStart:i,baseDuration:s,selectedOperationRef:c}){const u=e.operations.some(m=>m.id===n),{startMs:d,durationMs:f}=e;return l.jsxs("div",{className:wo("rounded-tremor-small border border-transparent bg-white/60 shadow-sm transition dark:bg-dark-tremor-background",u?"border-tremor-brand shadow-tremor-card dark:border-tremor-brand":"hover:border-slate-200 hover:shadow-tremor-card dark:hover:border-slate-700"),children:[l.jsx("button",{type:"button",onClick:()=>r(e.id),className:"flex w-full items-center gap-3 px-3 py-2 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",children:l.jsxs("div",{className:wo("grid w-full items-center gap-2 pl-0",a<45?"sm:grid-cols-[1.5rem_minmax(0,1fr)]":"sm:grid-cols-[1.5rem_minmax(0,1fr)_65%]"),children:[l.jsx("div",{className:"flex justify-center",children:l.jsx("span",{className:wo("flex h-6 w-6 shrink-0 items-center justify-center rounded-full border",t?"border-tremor-brand text-tremor-brand":"border-slate-300 text-slate-500 dark:border-slate-600 dark:text-slate-400"),"aria-hidden":!0,children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:wo("h-3.5 w-3.5 transition-transform",t?"rotate-180":"rotate-0"),children:l.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.084l3.71-3.854a.75.75 0 0 1 1.08 1.04l-4.25 4.417a.75.75 0 0 1-1.08 0L5.21 8.27a.75.75 0 0 1 .02-1.06z",clipRule:"evenodd"})})})}),l.jsxs("div",{className:"min-w-0 flex flex-col",children:[l.jsx("div",{className:"flex items-center gap-2 truncate",children:l.jsx(bt,{className:"truncate text-sm font-medium text-tremor-content-strong dark:text-dark-tremor-content-strong",children:e.label})}),e.subtitle?l.jsx(bt,{className:"truncate text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:e.subtitle}):null]}),l.jsxs("div",{className:wo("min-w-0 items-center gap-3",a<45?"hidden":"flex"),children:[l.jsx(bt,{className:"w-20 shrink-0 text-right text-xs font-semibold text-tremor-content-strong dark:text-dark-tremor-content-strong",children:io(f)}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx($R,{start:d??i,duration:f,total:s,baseStart:i,baseDuration:s,variant:"brand"})}),l.jsx("div",{className:"w-10 shrink-0 flex justify-center",children:l.jsx(Wt,{color:"slate",children:e.operations.length})})]})]})}),t?l.jsx("div",{className:"border-t border-tremor-border px-3 py-2 dark:border-dark-tremor-border",children:l.jsx("div",{className:"space-y-1",children:e.operations.map((m,h)=>l.jsx(u2e,{operation:m,index:h,isSelected:n===m.id,onSelect:()=>o(m.id),timelineWidth:a,baseStart:i,baseDuration:s,selectedOperationRef:c},m.id))})}):null]},e.id)}function f2e({onMouseDown:e,onDoubleClick:t}){return l.jsx("div",{className:"relative w-px cursor-col-resize bg-gray-300 dark:bg-dark-tremor-border",onMouseDown:e,children:l.jsx("button",{type:"button",className:"absolute left-1/2 top-1/2 z-10 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center rounded-md border border-gray-300 bg-white/80 px-0 py-2 text-gray-600 shadow-sm backdrop-blur-sm transition hover:bg-white dark:border-dark-tremor-border dark:bg-dark-tremor-background/80 dark:text-dark-tremor-content",title:"Drag to resize. Double-click to reset.","aria-label":"Resize panels",onMouseDown:r=>{r.preventDefault(),e?.(r)},onDoubleClick:r=>{r.preventDefault(),t?.(r)},children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"h-4 w-4","aria-hidden":!0,children:l.jsx("path",{d:"M8.5 7C9.32843 7 10 6.32843 10 5.5C10 4.67157 9.32843 4 8.5 4C7.67157 4 7 4.67157 7 5.5C7 6.32843 7.67157 7 8.5 7ZM8.5 13.5C9.32843 13.5 10 12.8284 10 12C10 11.1716 9.32843 10.5 8.5 10.5C7.67157 10.5 7 11.1716 7 12C7 12.8284 7.67157 13.5 8.5 13.5ZM10 18.5C10 19.3284 9.32843 20 8.5 20C7.67157 20 7 19.3284 7 18.5C7 17.6716 7.67157 17 8.5 17C9.32843 17 10 17.6716 10 18.5ZM15.5 7C16.3284 7 17 6.32843 17 5.5C17 4.67157 16.3284 4 15.5 4C14.6716 4 14 4.67157 14 5.5C14 6.32843 14.6716 7 15.5 7ZM17 12C17 12.8284 16.3284 13.5 15.5 13.5C14.6716 13.5 14 12.8284 14 12C14 11.1716 14.6716 10.5 15.5 10.5C16.3284 10.5 17 11.1716 17 12ZM15.5 20C16.3284 20 17 19.3284 17 18.5C17 17.6716 16.3284 17 15.5 17C14.6716 17 14 17.6716 14 18.5C14 19.3284 14.6716 20 15.5 20Z"})})})})}const m2e=({className:e="",...t})=>l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:`lucide lucide-chart-gantt-icon lucide-chart-gantt ${e}`,"aria-hidden":"true",...t,children:[l.jsx("path",{d:"M10 6h8"}),l.jsx("path",{d:"M12 16h6"}),l.jsx("path",{d:"M3 3v16a2 2 0 0 0 2 2h16"}),l.jsx("path",{d:"M8 11h7"})]}),p2e=({className:e="",...t})=>l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:` text-white ${e}`,"aria-hidden":"true",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 0 1-.659 1.591l-5.432 5.432a2.25 2.25 0 0 0-.659 1.591v2.927a2.25 2.25 0 0 1-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 0 0-.659-1.591L3.659 7.409A2.25 2.25 0 0 1 3 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0 1 12 3Z"})});function h2e({operationCount:e,onRefresh:t,isRefreshing:r,hasError:n,traceSources:o,onOpenFilters:a,activeFiltersCount:i=0}){const s=i>0?"bg-green-500 text-white":"bg-blue-500 text-white",c=i>0?"bg-green-700":"bg-blue-700";return l.jsxs(Cb,{justifyContent:"between",alignItems:"start",children:[l.jsx("div",{children:l.jsxs(Xn,{className:"flex items-center gap-2 text-lg text-tremor-content-strong dark:text-dark-tremor-content-strong",children:[l.jsx(m2e,{className:"h-4 w-4"}),l.jsx("span",{children:"Trace timeline"})]})}),l.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[a?l.jsxs("button",{type:"button",onClick:a,className:`relative inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs font-medium shadow-sm cursor-pointer ${s}`,children:[l.jsx(p2e,{className:"h-4 w-4"}),"Filters",i>0?l.jsx("span",{className:`absolute -top-1 -right-1 text-white text-[10px] font-bold w-4 h-4 flex items-center justify-center rounded-full ${c}`,children:i}):null]}):null,l.jsx("button",{type:"button",onClick:t,disabled:r,title:"Refresh trace",className:"inline-flex items-center gap-2 rounded border border-tremor-border px-3 py-1.5 text-xs font-medium text-tremor-content-strong shadow-sm transition hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-70 dark:border-dark-tremor-border dark:text-dark-tremor-content-strong dark:hover:bg-dark-tremor-background-subtle",children:r?"Refreshing…":"Refresh"}),o!=null&&o.length?l.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(u=>l.jsx(Wt,{color:"blue",children:u},u))}):null,l.jsx(Wt,{color:n?"rose":"slate",children:`${e} ${e===1?"step":"steps"}`})]})]})}function g2e({traceSummary:e,traceDurationMs:t,traceDetailMeta:r,traceListMeta:n,isTraceDetailLoading:o,operationCount:a,tokenTotals:i}){const s=c=>c==null?"—":c.toLocaleString();return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-tremor-content-subtle dark:text-dark-tremor-content",children:"Trace"}),l.jsx("span",{className:"text-sm text-tremor-content-strong dark:text-dark-tremor-content-strong",children:vj(e)})]}),i?l.jsxs("div",{className:"w-full flex flex-wrap items-center justify-between gap-4 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[l.jsxs("div",{className:"text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:["Estimated total tokens for ",a," operations:"]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-right text-tremor-content dark:text-dark-tremor-content",children:[l.jsxs(Wt,{color:"indigo",size:"xs",children:["Request ",s(i.request)]}),l.jsxs(Wt,{color:"indigo",size:"xs",children:["Response ",s(i.response)]}),l.jsxs(Wt,{color:"indigo",size:"xs",children:["Total ",s(i.total)]})]})]}):null,l.jsxs("div",{className:"w-full flex flex-wrap items-center justify-between gap-4 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[e!=null&&e.first_seen?l.jsxs("div",{children:["First step: ",zn(e.first_seen)]}):null,e!=null&&e.last_seen?l.jsxs("div",{children:["Last step: ",zn(e.last_seen)]}):null,t!=null?l.jsxs("div",{children:["Observed duration: ",io(t)]}):null]})]}),l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs text-tremor-content-subtle dark:text-dark-tremor-content",children:[l.jsxs("span",{children:["Page ",r?.page||n?.page||1," of"," ",n?.total_pages||r?.total_pages||1]}),l.jsx("span",{children:o?"Refreshing trace…":`Total operations: ${a}`})]})]})}function b2e({supportsTraces:e,isTraceListLoading:t,traceList:r,traceListError:n}){return e?t&&!r.length?l.jsx(Lt,{className:"rounded-tremor-small border border-tremor-border p-6 text-center text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"Loading traces…"}):n&&!r.length?l.jsxs(Lt,{className:"rounded-tremor-small border border-rose-200 bg-rose-50 p-6 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-900/20 dark:text-rose-300",children:["Failed to load traces: ",n.message||"Unexpected error"]}):r.length?null:l.jsx(vl,{message:"No traces recorded yet. Start sending traffic to populate this view."}):l.jsx(Lt,{className:"rounded-tremor-small border border-dashed border-tremor-border p-6 text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"Trace exploration requires an Inspectr API version that exposes the /api/traces endpoints."})}const v2e=({isOpen:e,onClose:t,filters:r,setFilters:n,statusOptions:o=[],methodOptions:a=[],tagOptions:i=[],mcpToolOptions:s=[],mcpResourceOptions:c=[],mcpPromptOptions:u=[],mcpCategoryOptions:d=[],mcpMethodOptions:f=[],hostOptions:m=[],hasMcpOperations:h=!1,persistFilters:g=!1,onPersistFiltersChange:b=()=>{}})=>{const v={blue:"bg-blue-500/10 text-blue-700 dark:bg-blue-500/5 dark:text-blue-200",indigo:"bg-indigo-500/10 text-indigo-700 dark:bg-indigo-500/5 dark:text-indigo-200",emerald:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/5 dark:text-emerald-200",amber:"bg-amber-500/10 text-amber-700 dark:bg-amber-500/5 dark:text-amber-200",slate:"bg-slate-500/10 text-slate-700 dark:bg-slate-500/5 dark:text-slate-200"},x=I=>{const F=Hh(I);return v[F]||v.slate},k=I=>()=>v[I]||v.slate,N=s.length>0||(r.mcpTool||[]).length>0,j=c.length>0||(r.mcpResource||[]).length>0,E=u.length>0||(r.mcpPrompt||[]).length>0,C=d.length>0||(r.mcpCategory||[]).length>0,S=f.length>0||(r.mcpMethod||[]).length>0,T=[...r.mcpTool||[],...r.mcpResource||[],...r.mcpPrompt||[],...r.mcpCategory||[],...r.mcpMethod||[]].length?!0:!!(r.tokenMin||r.tokenMax),A=h||T||N||j||E||C||S,M=()=>{n({})},_=I=>{n(F=>{const D={...F};return I.forEach(R=>{delete D[R]}),D})};return l.jsxs(l.Fragment,{children:[e&&l.jsx("div",{className:"fixed inset-0 bg-black opacity-50",style:{zIndex:9998},onClick:t}),l.jsxs("div",{className:`fixed top-0 left-0 h-full w-[420px] max-w-full bg-white dark:bg-dark-tremor-background shadow-xl dark:shadow-dark-tremor-shadow transform transition-transform duration-300 flex flex-col
|
|
210
210
|
${e?"translate-x-0":"-translate-x-full"}
|
|
211
|
-
`,style:{zIndex:9999},children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b border-gray-300 dark:border-dark-tremor-border bg-gray-50 dark:bg-dark-tremor-background-subtle",children:[l.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-dark-tremor-content-strong",children:"Filters"}),l.jsx("button",{onClick:t,className:"text-gray-600 dark:text-dark-tremor-content hover:text-gray-800 dark:hover:text-dark-tremor-content-strong focus:outline-none cursor-pointer border rounded px-1","aria-label":"Close",children:"×"})]}),l.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",children:l.jsxs("section",{className:"mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-gray-200 dark:border-dark-tremor-border",children:[l.jsx("h3",{className:"text-xs font-bold text-gray-600 dark:text-dark-tremor-content uppercase tracking-wide",children:"Filters"}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("label",{className:"flex items-center gap-1 text-[11px] font-medium text-gray-600 dark:text-dark-tremor-content-subtle",children:[l.jsx("input",{type:"checkbox",className:"h-3 w-3",checked:g,onChange:I=>b(I.target.checked)}),"Keep on reload"]}),l.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]})]}),l.jsxs("div",{className:"space-y-6 pt-4",children:[A?l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"MCP"}),l.jsx("button",{onClick:()=>_(["mcpTool","mcpResource","mcpPrompt","mcpMethod","mcpCategory","tokenMin","tokenMax"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),N&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Tool"}),l.jsx(un,{options:s,selected:r.mcpTool||[],onChange:I=>n(F=>({...F,mcpTool:I})),placeholder:"Add MCP tool...",colorFn:k("blue")})]}),j&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Resource"}),l.jsx(un,{options:c,selected:r.mcpResource||[],onChange:I=>n(F=>({...F,mcpResource:I})),placeholder:"Add MCP resource...",colorFn:k("emerald")})]}),E&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Prompt"}),l.jsx(un,{options:u,selected:r.mcpPrompt||[],onChange:I=>n(F=>({...F,mcpPrompt:I})),placeholder:"Add MCP prompt...",colorFn:k("indigo")})]}),S&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Method"}),l.jsx(un,{options:f,selected:r.mcpMethod||[],onChange:I=>n(F=>({...F,mcpMethod:I})),placeholder:"Add MCP method...",colorFn:x})]}),C&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Category"}),l.jsx(un,{options:d,selected:r.mcpCategory||[],onChange:I=>n(F=>({...F,mcpCategory:I})),placeholder:"Add MCP category...",colorFn:x})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Total Tokens"}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx("input",{type:"number",placeholder:"Min",value:r.tokenMin||"",onChange:I=>n(F=>({...F,tokenMin:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"}),l.jsx("input",{type:"number",placeholder:"Max",value:r.tokenMax||"",onChange:I=>n(F=>({...F,tokenMax:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]})]}):null,l.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"HTTP"}),l.jsx("button",{onClick:()=>_(["status","method","path"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Status"}),l.jsx(un,{options:o,selected:r.status||[],onChange:I=>n(F=>({...F,status:I})),placeholder:"Add status...",colorFn:nu})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Method"}),l.jsx(un,{options:a,selected:r.method||[],onChange:I=>n(F=>({...F,method:I})),placeholder:"Add method...",colorFn:Bh})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Path"}),l.jsx("input",{type:"text",placeholder:"e.g. /mcp",value:r.path||"",onChange:I=>n(F=>({...F,path:I.target.value})),className:"block w-full border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]}),l.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"Tags"}),l.jsx("button",{onClick:()=>_(["tags"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Tags"}),l.jsx(un,{options:i,selected:r.tags||[],onChange:I=>n(F=>({...F,tags:I})),placeholder:"Add tag..."})]})]}),l.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"Timing & Host"}),l.jsx("button",{onClick:()=>_(["durationMin","durationMax","host"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Duration (ms)"}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx("input",{type:"number",placeholder:"Min",value:r.durationMin||"",onChange:I=>n(F=>({...F,durationMin:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"}),l.jsx("input",{type:"number",placeholder:"Max",value:r.durationMax||"",onChange:I=>n(F=>({...F,durationMax:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Host"}),l.jsx(un,{options:m,selected:r.host||[],onChange:I=>n(F=>({...F,host:I})),placeholder:"Add host..."})]})]})]})]})})]})]})},ow=56,c9=30,u9=75,y2e="traceTimelineWidth",aw="calc(100vh - 64px)",x2e="traceTimelineFilters",k2e="traceTimelinePersistFilters",w2e=e=>{var t;if(!e.length)return"Trace group";const r=e[0];return s2e(r)||((t=r.traceInfo)==null?void 0:t.source)||(r.correlationId?`Correlation ${r.correlationId}`:null)||`${r.method} ${r.path}`},j2e=e=>{if(!e.length)return"";const t=e[0];return t.path||t.url||""},N2e=e=>e.length?e.reduce((t,r)=>Math.max(t,r.status??0),0):null,zl=e=>{const t=Number(e);return Number.isFinite(t)?t:null};function BR({operations:e=[],initialTraceId:t=null,initialOperationId:r=null,onTraceChange:n,onOperationChange:o,isActive:a=!0}){const{supportsTraces:i,traceList:s,traceListMeta:c,isTraceListLoading:u,traceListError:d,traceDetailError:f,traceDetailMeta:m,isTraceDetailLoading:h,selectedTraceId:g,traceSummary:b,traceSources:v,traceDurationMs:x,normalizedOperations:k,timeline:N,selectedOperationId:j,setSelectedOperationId:E,refreshTraceList:C,refreshTraceDetail:S,traceDetailPage:T,setTraceDetailPage:A}=FR({initialTraceId:t,initialOperationId:r,onTraceChange:n,onOperationChange:o,isActive:a}),[M,_]=p.useState(()=>new Set),[I,F]=_r(y2e,String(ow)),[D,R]=_r(k2e,"false"),[z,H]=_r(x2e,""),$=p.useMemo(()=>{const ye=Number(I);return Number.isFinite(ye)&&ye>=c9&&ye<=u9?ye:ow},[I]),V=p.useRef(!1),U=p.useRef(null),B=p.useRef(null),X=p.useRef(null),[K,ae]=p.useState(!1),J=D==="true",[ee,te]=p.useState({}),fe=N.start,Y=N.duration,ce=p.useMemo(()=>{if(!k.length)return[];const ye=($e,Ke)=>{if(!Array.isArray(Ke)||Ke.length===0)return!0;if(!$e)return!1;const Nt=Array.isArray($e)?$e:[$e],lt=new Set(Nt.map(Mt=>String(Mt).toLowerCase()));return Ke.some(Mt=>lt.has(String(Mt).toLowerCase()))},ve=($e,Ke)=>{if(!Array.isArray(Ke)||Ke.length===0)return!0;const Nt=JT(Ke);if(!Nt.length)return!0;const lt=Array.isArray($e)?$e.map(Mt=>Mt.token):[];return Nt.every(Mt=>lt.includes(Mt))},Ae=$e=>{var Ke,Nt,lt,Mt,De,ir,ar,Kt;const Re=((Ke=$e?.meta)==null?void 0:Ke.mcp)||((lt=(Nt=$e?.raw)==null?void 0:Nt.meta)==null?void 0:lt.mcp)||((De=(Mt=$e?.meta)==null?void 0:Mt.trace)==null?void 0:De.mcp)||((Kt=(ar=(ir=$e?.raw)==null?void 0:ir.meta)==null?void 0:ar.trace)==null?void 0:Kt.mcp),tr=Re?.tokens;if(!tr)return null;const rr=zl(tr.total);if(rr!==null)return rr;const Qe=zl(tr.request),Pt=zl(tr.response);return Qe!==null||Pt!==null?(Qe??0)+(Pt??0):null};return k.filter($e=>{var Ke,Nt;if(!$e)return!1;if(ee.status&&Array.isArray(ee.status)&&ee.status.length>0){const Re=$e.status!=null?String($e.status):"";if(!ee.status.includes(Re))return!1}if(ee.method&&Array.isArray(ee.method)&&ee.method.length>0){const Re=($e.method||"").toLowerCase();if(!ee.method.map(tr=>String(tr).toLowerCase()).includes(Re))return!1}if(ee.path&&!($e.path||$e.url||"").toLowerCase().includes(String(ee.path).toLowerCase())||ee.durationMin&&(!Number.isFinite($e.duration)||Number($e.duration)<Number(ee.durationMin))||ee.durationMax&&(!Number.isFinite($e.duration)||Number($e.duration)>Number(ee.durationMax)))return!1;if(ee.tokenMin){const Re=Ae($e);if(Re===null||Re<Number(ee.tokenMin))return!1}if(ee.tokenMax){const Re=Ae($e);if(Re===null||Re>Number(ee.tokenMax))return!1}if(ee.host&&Array.isArray(ee.host)&&ee.host.length>0){const Re=($e.host||"").toLowerCase();if(!ee.host.map(tr=>String(tr).toLowerCase()).some(tr=>Re.includes(tr)))return!1}if(ee.tags&&!ve($e.tags,ee.tags))return!1;const lt=((Ke=$e.raw)==null?void 0:Ke.meta)||{},Mt=lt.trace||{},De=lt.mcp||Mt.mcp||((Nt=$e.meta)==null?void 0:Nt.mcp)||null,ir=De?.category||"",ar=De?.method||"",Kt=De?.name||"";return!(ee.mcpCategory&&!ye(ir,ee.mcpCategory)||ee.mcpMethod&&!ye(ar,ee.mcpMethod)||ee.mcpTool&&ee.mcpTool.length>0&&!ye(ir==="tool"?Kt:"",ee.mcpTool)||ee.mcpResource&&ee.mcpResource.length>0&&!ye(ir==="resource"?Kt:"",ee.mcpResource)||ee.mcpPrompt&&ee.mcpPrompt.length>0&&!ye(ir==="prompt"?Kt:"",ee.mcpPrompt))})},[k,ee]),se=p.useMemo(()=>{if(!ce.length)return[];const ye=new Map;return ce.forEach((ve,Ae)=>{const $e=ve.correlationId||`__group-${Ae}`;ye.has($e)||ye.set($e,{id:$e,operations:[],startMs:null,endMs:null,order:Ae});const Ke=ye.get($e);Ke.operations.push(ve);const{start:Nt,end:lt}=_b(ve,Ae);Ke.startMs=Ke.startMs===null?Nt:Math.min(Ke.startMs,Nt),Ke.endMs=Ke.endMs===null?lt:Math.max(Ke.endMs,lt)}),Array.from(ye.values()).map(ve=>({...ve,label:w2e(ve.operations),subtitle:j2e(ve.operations),durationMs:ve.startMs!=null&&ve.endMs!=null?Math.max(ve.endMs-ve.startMs,0):0,maxStatus:N2e(ve.operations)})).sort((ve,Ae)=>(ve.startMs??0)-(Ae.startMs??0))},[ce]),W=h||u,ne=()=>{C(),S()};p.useEffect(()=>{if(!se.length){_(new Set);return}_(new Set(se.map(ye=>ye.id)))},[g,se]),p.useEffect(()=>{var ye;if(!ce.length||j&&ce.some(Ae=>Ae.id===j))return;const ve=((ye=ce[0])==null?void 0:ye.id)||null;ve&&ve!==j&&E(ve)},[ce,j,E]);const oe=p.useMemo(()=>j&&ce.find(ye=>ye.id===j)||null,[ce,j]);p.useEffect(()=>{if(!j||!se.length)return;const ye=se.find(ve=>ve.operations.some(Ae=>Ae.id===j));ye&&!M.has(ye.id)&&_(ve=>{const Ae=new Set(ve);return Ae.add(ye.id),Ae})},[j,se,M]),p.useEffect(()=>{if(!oe)return;const ye=setTimeout(()=>{B.current&&X.current!==j&&(B.current.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),X.current=j)},150);return()=>clearTimeout(ye)},[j,oe,M]);const xe=p.useCallback(()=>{V.current=!1},[]),Ce=p.useCallback(ye=>{if(!V.current||!U.current)return;const ve=U.current.getBoundingClientRect();if(!ve.width)return;const Ae=(ye.clientX-ve.left)/ve.width*100,$e=Math.min(Math.max(Ae,c9),u9);F(String($e))},[F]);p.useEffect(()=>(window.addEventListener("mousemove",Ce),window.addEventListener("mouseup",xe),()=>{window.removeEventListener("mousemove",Ce),window.removeEventListener("mouseup",xe)}),[Ce,xe]),p.useEffect(()=>{if(!J){H(null);return}if(z&&!Object.keys(ee||{}).length)try{const ye=JSON.parse(z);if(!ye||typeof ye!="object")return;te(ye)}catch{}},[J,z,ee,H]),p.useEffect(()=>{if(J){if(!Object.entries(ee||{}).some(([,ye])=>Array.isArray(ye)?ye.length>0:ye!==""&&ye!==null&&ye!==void 0)){H(null);return}H(JSON.stringify(ee))}},[ee,J,H]);const Le=p.useMemo(()=>{let ye=0,ve=0,Ae=0,$e=!1,Ke=!1,Nt=!1;return ce.forEach(lt=>{var Mt,De,ir,ar,Kt,Re,tr,rr;if(!lt)return;const Qe=((Mt=lt?.meta)==null?void 0:Mt.mcp)||((ir=(De=lt?.raw)==null?void 0:De.meta)==null?void 0:ir.mcp)||((Kt=(ar=lt?.meta)==null?void 0:ar.trace)==null?void 0:Kt.mcp)||((rr=(tr=(Re=lt?.raw)==null?void 0:Re.meta)==null?void 0:tr.trace)==null?void 0:rr.mcp),Pt=Qe?.tokens;if(!Pt)return;const At=zl(Pt.request),Lr=zl(Pt.response),Or=zl(Pt.total);At!==null&&($e=!0,ye+=At),Lr!==null&&(Ke=!0,ve+=Lr),Or!==null?(Nt=!0,Ae+=Or):(At!==null||Lr!==null)&&(Nt=!0,Ae+=(At??0)+(Lr??0))}),$e||Ke||Nt?{request:$e?ye:null,response:Ke?ve:null,total:Nt?Ae:null}:null},[ce]),Oe=ce.length,Ve=Object.entries(ee||{}).reduce((ye,[ve,Ae])=>Array.isArray(Ae)?Ae.length>0?ye+1:ye:Ae?ye+1:ye,0),et=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{ve?.status!=null&&ye.add(String(ve.status))}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),Ie=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{ve!=null&&ve.method&&ye.add(ve.method.toUpperCase())}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),st=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{Array.isArray(ve.tags)&&ve.tags.forEach(Ae=>ye.add(Ae.display))}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),nt=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{ve!=null&&ve.host&&ye.add(ve.host)}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),xt=p.useMemo(()=>{const ye=new Set,ve=new Set,Ae=new Set,$e=new Set,Ke=new Set;k.forEach(lt=>{var Mt,De;const ir=((Mt=lt?.raw)==null?void 0:Mt.meta)||{},ar=ir.trace||{},Kt=ir.mcp||ar.mcp||((De=lt?.meta)==null?void 0:De.mcp);Kt&&(Kt.category&&$e.add(Kt.category),Kt.method&&Ke.add(Kt.method),Kt.name&&Kt.category==="tool"&&ye.add(Kt.name),Kt.name&&Kt.category==="resource"&&ve.add(Kt.name),Kt.name&&Kt.category==="prompt"&&Ae.add(Kt.name))});const Nt=lt=>Array.from(lt).sort((Mt,De)=>Mt.localeCompare(De));return{tool:Nt(ye),resource:Nt(ve),prompt:Nt(Ae),category:Nt($e),method:Nt(Ke)}},[k]),gt=p.useMemo(()=>k.some(ye=>{var ve;if(!ye)return!1;const Ae=ye.meta||{},$e=((ve=ye.raw)==null?void 0:ve.meta)||{},Ke=Ae.trace||$e.trace||{},Nt=Ae.mcp||$e.mcp||Ke.mcp,lt=Ae.protocol==="mcp"||$e.protocol==="mcp";return!!(Nt&&Object.keys(Nt).length||lt)}),[k]);if(!i||u&&!s.length||d&&!s.length||!s.length)return l.jsx(b2e,{supportsTraces:i,isTraceListLoading:u,traceList:s,traceListError:d});const ft=ye=>{_(ve=>{const Ae=new Set(ve);return Ae.has(ye)?Ae.delete(ye):Ae.add(ye),Ae})},kt=ye=>{var ve;if(!ye)return!1;const Ae=ye.meta||{},$e=((ve=ye.raw)==null?void 0:ve.meta)||{},Ke=Ae.trace||$e.trace||{},Nt=Ae.mcp||$e.mcp||Ke.mcp,lt=Ae.protocol==="mcp"||$e.protocol==="mcp";return!!(Nt&&Object.keys(Nt).length||lt)};return l.jsxs("div",{ref:U,className:"flex flex-col gap-4 lg:flex-row",style:{maxHeight:aw},children:[l.jsxs(Lt,{id:"trace-timeline",className:"w-full overflow-y-auto rounded-tremor-small border border-tremor-border p-6 dark:border-dark-tremor-border",style:{width:`${$}%`,maxHeight:aw},children:[l.jsx(h2e,{operationCount:Oe,onRefresh:ne,isRefreshing:W,hasError:!!f,traceSources:v,onOpenFilters:()=>ae(!0),activeFiltersCount:Ve}),l.jsxs("div",{className:"mt-6 flex flex-col gap-4 min-w-0",children:[l.jsx(g2e,{traceSummary:b,traceDurationMs:x,traceDetailMeta:m,traceListMeta:c,isTraceDetailLoading:h,operationCount:Oe,tokenTotals:Le}),f?l.jsxs(Lt,{className:"rounded-tremor-small border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-900/20 dark:text-rose-300",children:["Failed to load trace details: ",f.message||"Unexpected error"]}):null,l.jsx("div",{className:"space-y-3",children:se.length?se.map(ye=>l.jsx(d2e,{group:ye,isExpanded:M.has(ye.id),onToggle:ft,selectedOperationId:j,onOperationSelect:E,timelineWidth:$,baseStart:fe,baseDuration:Y,selectedOperationRef:B},ye.id)):l.jsx(Lt,{className:"rounded-tremor-small border border-dashed border-tremor-border p-6 text-center text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"No operations recorded for this trace."})})]}),l.jsx(xj,{meta:m,currentPage:T,onPageChange:A,alwaysShow:!1})]}),l.jsx(f2e,{onMouseDown:()=>{V.current=!0},onDoubleClick:()=>{F(String(ow))}}),l.jsx(Lt,{id:"trace-details",className:"w-full overflow-y-auto rounded-tremor-small border border-tremor-border dark:border-dark-tremor-border",style:{width:`${100-$}%`,maxHeight:aw},children:kt(oe)?l.jsx(c2e,{operation:oe,isLoading:h}):l.jsx(RR,{operation:oe,isLoading:h})}),l.jsx(v2e,{isOpen:K,onClose:()=>ae(!1),filters:ee,setFilters:te,statusOptions:et,methodOptions:Ie,tagOptions:st,mcpToolOptions:xt.tool,mcpResourceOptions:xt.resource,mcpPromptOptions:xt.prompt,mcpCategoryOptions:xt.category,mcpMethodOptions:xt.method,hostOptions:nt,hasMcpOperations:gt,persistFilters:J,onPersistFiltersChange:ye=>R(ye?"true":"false")})]})}const E2e=e=>{if(!e)return null;try{return new URL(e)}catch{return null}},O2e=e=>{var t,r;if(!e)return null;const n=((t=e.raw)==null?void 0:t.data)||{},o=n.request||{},a=n.response||{},i=n.timing||{},s=(e.method||o.method||"GET").toUpperCase(),c=e.status_code??a.status??null,u=e.duration??i.duration,d=Number.isFinite(Number(u))?Number(u):null,f=e.time||o.timestamp||null,m=E2e(o.url||e.url||""),h=o.path||e.path||m?.pathname||o.url||e.url||"/",g=o.server||m?.host||"",b=Array.isArray((r=n.meta)==null?void 0:r.tags)?n.meta.tags:Array.isArray(e.tags)?e.tags:[],v=Pf(b);return{id:e.id,operationId:e.operation_id,method:s,status:c,duration:d,timestamp:f,timestampMs:f?Date.parse(f):null,path:h,host:g,url:o.url||e.url||"",request:o,response:a,timing:i,tags:v,raw:n}},S2e=e=>{if(!e)return"Unknown";const t=new Date(e);return Number.isNaN(t.getTime())?"Unknown":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})},d9=(e,t)=>`${e} ${t}`,Pd="trace",Ks="trace-timeline",il=["endpoint","list","table","timeline",Pd,Ks],C2e=il.indexOf(Pd),Gs=il.indexOf(Ks),HR=(e,t)=>e&&il.includes(e)?il.indexOf(e):t&&Gs>=0?Gs:0,P2e=()=>{if(typeof window>"u")return{tabIndex:0,traceId:null,traceOperationId:null};const{slug:e,params:t}=pi();if(e!=="insights")return{tabIndex:0,traceId:null,traceOperationId:null};const r=t.trace||null,n=t.traceOp||t.operation||null,o=t.view;return{tabIndex:HR(o,r),traceId:r,traceOperationId:n}};function A2e(){var e,t,r,n;const{client:o}=Tr(),a=p.useMemo(()=>P2e(),[]),[i,s]=p.useState(null),[c,u]=p.useState(null),[d,f]=p.useState(!1),[m,h]=p.useState({}),[g,b]=p.useState(a.tabIndex),[v,x]=p.useState({traceId:a.traceId,operationId:a.traceOperationId}),k=Gn(()=>Vr.db.events.orderBy("time").last(),[],null)||null,N=Gn(()=>Vr.db.events.orderBy("time").reverse().toArray(),[],[])||[],j=p.useMemo(()=>N.map(D=>O2e(D)).filter(Boolean).sort((D,R)=>(R.timestampMs||0)-(D.timestampMs||0)),[N]);p.useEffect(()=>{if(typeof window>"u")return;const D=()=>{const{slug:R,params:z}=pi();if(R!=="insights")return;const H=z.trace||null,$=z.traceOp||z.operation||null,V=z.view,U=HR(V,H);b(U),x(B=>B.traceId===H&&B.operationId===$?B:{traceId:H,operationId:$})};return D(),window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[]);const E=(D={})=>{if(typeof window>"u")return;const{slug:R,params:z}=pi(),H=R==="insights"?{...z}:{};Object.entries(D).forEach(([B,X])=>{X==null||X===""?delete H[B]:H[B]=String(X)});const $=new URLSearchParams;Object.entries(H).forEach(([B,X])=>{X!=null&&$.set(B,X)});const V=$.toString(),U=`#insights${V?`?${V}`:""}`;typeof window<"u"&&window.location.hash!==U&&window.history.replaceState(null,"",U)},C=D=>{b(D);const R=il[D]||"endpoint",z=R===Pd||R===Ks;E({view:R,trace:z?v.traceId??null:null,traceOp:z?v.operationId??null:null})},S=D=>{const R=v.traceId===D,z={traceId:D||null,operationId:R?v.operationId:null};if(v.traceId===z.traceId&&v.operationId===z.operationId)return;x(z);const H=il[g],$=H===Pd||H===Ks;E({view:$?H:Ks,trace:z.traceId??null,traceOp:z.operationId??null}),!$&&Gs>=0&&b(Gs)},T=D=>{const R={traceId:v.traceId,operationId:D||null};if(v.traceId===R.traceId&&v.operationId===R.operationId)return;x(R);const z=il[g],H=z===Pd||z===Ks;E({view:H?z:Ks,trace:R.traceId??null,traceOp:R.operationId??null}),!H&&Gs>=0&&b(Gs)};p.useEffect(()=>{var D;if(!((D=o?.operations)!=null&&D.summarize))return;let R=!0;return(async()=>{f(!0),u(null);try{const z=await o.operations.summarize();R&&(s(z),h({}))}catch(z){R&&u(z)}finally{R&&f(!1)}})(),()=>{R=!1}},[o,k?.id]),p.useEffect(()=>{var D,R;if(!((D=o?.operations)!=null&&D.getSeries)||!((R=i?.summaries)!=null&&R.length))return;let z=!0;return(async()=>{const H=i.summaries;await Promise.all(H.map(async $=>{const V=d9($.method,$.path);h(U=>({...U,[V]:{...U[V]||{},loading:!0,error:null}}));try{const U=await o.operations.getSeries({method:$.method,path:$.path,seriesLimit:Pwe});if(!z)return;h(B=>({...B,[V]:{...B[V]||{},loading:!1,data:U,error:null}}))}catch(U){if(!z)return;h(B=>({...B,[V]:{...B[V]||{},loading:!1,error:U}}))}}))})(),()=>{z=!1}},[o,i?.summaries]);const A=p.useMemo(()=>{var D;return(D=i?.summaries)!=null&&D.length?i.summaries.map(R=>{var z;const H=d9(R.method,R.path),$=m[H]||{},V=(((z=$.data)==null?void 0:z.series)||[]).slice(-40).map(U=>({time:S2e(U.ts),duration:U.duration??0,baseline:U.baseline??R.averageDuration??0}));return{...R,key:H,chartData:V,seriesLoading:$.loading??!1,seriesError:$.error||null}}):[]},[i,m]),M=((e=i?.totals)==null?void 0:e.totalOperations)??j.length,_=(t=i?.totals)==null?void 0:t.totalEndpoints,I=(r=i?.totals)==null?void 0:r.errorCount,F=(n=i?.totals)==null?void 0:n.averageDuration;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs(Lt,{className:"rounded-tremor-small border border-tremor-border dark:border-dark-tremor-border",children:[l.jsxs(Cb,{justifyContent:"between",alignItems:"start",children:[l.jsxs("div",{children:[l.jsx(Xn,{className:"text-lg text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Insights Explorer"}),l.jsx(bt,{className:"mt-1 text-sm text-tremor-content dark:text-dark-tremor-content",children:"Get more insights into the operations by grouping them by endpoint, as time line view, as rich cards, or in a compact table"})]}),l.jsx(Wt,{color:c?"rose":"slate",children:d?"Loading…":`Total ${M}`})]}),l.jsxs(Pb,{numItemsSm:1,numItemsLg:3,className:"mt-6 gap-4",children:[l.jsxs(Lt,{className:"bg-gray-50 shadow-none dark:bg-dark-tremor-background",children:[l.jsx(bt,{className:"text-sm text-tremor-content dark:text-dark-tremor-content",children:"Unique endpoints"}),l.jsx(oi,{className:"mt-2",children:_})]}),l.jsxs(Lt,{className:"bg-gray-50 shadow-none dark:bg-dark-tremor-background",children:[l.jsx(bt,{className:"text-sm text-tremor-content dark:text-dark-tremor-content",children:"Errors"}),l.jsxs(oi,{className:"mt-2",children:[I," ",l.jsxs("span",{className:"text-base font-normal text-tremor-content-subtle dark:text-dark-tremor-content",children:["(",M?Math.round(I/M*100):0,"%)"]})]})]}),l.jsxs(Lt,{className:"bg-gray-50 shadow-none dark:bg-dark-tremor-background",children:[l.jsx(bt,{className:"text-sm text-tremor-content dark:text-dark-tremor-content",children:"Avg duration"}),l.jsx(oi,{className:"mt-2",children:F?`${F}ms`:"N/A"})]})]})]}),l.jsxs(tu,{index:g,onIndexChange:C,children:[l.jsxs(eu,{children:[l.jsx(yo,{children:"Endpoint mode"}),l.jsx(yo,{children:"List mode"}),l.jsx(yo,{children:"Table mode"}),l.jsx(yo,{children:"Timeline mode"}),l.jsx(yo,{children:"Trace explorer"}),l.jsx(yo,{children:"Trace timeline"})]}),l.jsxs(ru,{className:"mt-6 space-y-6",children:[l.jsx(xo,{children:l.jsx(Owe,{endpoints:A,loading:d,error:c})}),l.jsx(xo,{children:l.jsx(Awe,{operations:j})}),l.jsx(xo,{children:l.jsx(Uwe,{operations:j})}),l.jsx(xo,{children:l.jsx(Zwe,{operations:j})}),l.jsx(xo,{children:l.jsx(l2e,{operations:j,initialTraceId:v.traceId,initialOperationId:v.operationId,onTraceChange:S,onOperationChange:T,isActive:g===C2e})}),l.jsx(xo,{children:l.jsx(BR,{operations:j,initialTraceId:v.traceId,initialOperationId:v.operationId,onTraceChange:S,onOperationChange:T,isActive:g===Gs})})]})]})]})}const f9=(e,t)=>{let r="#traces";return e&&(r+=`/${e}`,t&&(r+=`/${t}`)),r},m9=e=>{e&&(window.location.hash===e?window.dispatchEvent(new HashChangeEvent("hashchange")):window.location.hash=e)};function T2e({route:e}){var t,r;const n=e?.operationId||((t=e?.params)==null?void 0:t.trace)||null,o=e?.subTab||((r=e?.params)==null?void 0:r.operation)||null,[a,i]=p.useState(n),[s,c]=p.useState(o),[u,d]=p.useState(o||null),f=p.useRef(a),m=p.useRef(s),h=p.useRef(u),g=p.useRef({traceId:n,operationId:o});p.useEffect(()=>{f.current=a},[a]),p.useEffect(()=>{m.current=s},[s]),p.useEffect(()=>{h.current=u},[u]),p.useEffect(()=>{const j=g.current;if(n!==j.traceId||o!==j.operationId){g.current={traceId:n,operationId:o},i(n||null),c(o||null),d(o||null);return}n!==a&&i(n||null),o!==s&&c(o||null),!h.current&&o&&d(o)},[n,o,a,s]);const b=p.useCallback(j=>{if(!j)return;i(j),j!==f.current&&(d(null),c(null),m.current=null);const E=f9(j,j===f.current?m.current:null);m9(E)},[]),v=p.useCallback(j=>{if(!j)return;c(j);const E=f.current;if(!E)return;h.current||d(j);const C=f9(E,j);m9(C)},[]),x=p.useMemo(()=>a||"—",[a]),k=h.current||o||m.current||"",N=k?`#inspectr/${k}/request`:"#inspectr";return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsxs("a",{href:N,className:"inline-flex items-center gap-2 rounded-md border border-slate-300 px-3 py-1.5 text-sm font-medium text-slate-700 transition hover:border-slate-400 hover:bg-slate-100 dark:border-slate-700 dark:text-slate-200 dark:hover:border-slate-600 dark:hover:bg-dark-tremor-background-subtle",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4","aria-hidden":!0,children:l.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 1.06L4.56 9H16a.75.75 0 0 1 0 1.5H4.56l2.65 2.65a.75.75 0 0 1 0 1.06Z",clipRule:"evenodd"})}),"Back to request"]}),l.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-slate-600 dark:text-slate-300",children:["Trace ",x]})]}),l.jsx(BR,{initialTraceId:n,initialOperationId:o,onTraceChange:b,onOperationChange:v,isActive:!0})]})}function M2e(){const{client:e,setToast:t}=Tr(),[r,n]=p.useState(!1),[o,a]=p.useState(""),[i,s]=p.useState(null),[c,u]=p.useState(!1),[d,f]=p.useState(null);p.useEffect(()=>{const b=new URLSearchParams(window.location.search).get("openapi");b&&(a(b),n(!0),m())},[]);const m=async()=>{try{const b=await e.service.getHealth();f(b.mode)}catch{}},h=()=>{c||n(!1)},g=async()=>{u(!0),s(null);try{await e.mock.launch(o),t({message:"Mock launched",subMessage:"Serving mock from OpenAPI spec",type:"success"}),n(!1)}catch(b){console.error("Mock launch error",b),s(b.message||"Failed to launch mock"),u(!1)}};return r?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:h}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-3xl w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Configure Inspectr Mock"}),l.jsx("button",{onClick:h,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",disabled:c,children:"×"})]}),d==="proxy"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"mb-2 text-sm text-gray-700",children:"Inspectr lets you serve a mock API based on an OpenAPI spec."}),l.jsxs("div",{className:"mb-6 p-4 bg-yellow-50 border border-yellow-200 rounded",children:[l.jsxs("p",{className:"text-sm font-medium text-yellow-800",children:["Inspectr is currently running in ",l.jsx("strong",{children:"proxy"})," mode."]}),l.jsx("p",{className:"mt-2 text-sm text-yellow-800",children:"To switch to mock mode, restart Inspectr with:"}),l.jsxs("pre",{className:"mt-2 p-2 bg-gray-100 text-xs rounded overflow-auto",children:['npx @inspectr/inspectr --mock-backend="',o,'"']}),l.jsx(An,{textToCopy:`npx @inspectr/inspectr --mock-backend=${o}`})]}),l.jsx("p",{className:"mb-4 text-sm text-gray-700",children:"Follow the instructions above to start Inspectr as Mock server from the OpenAPI spec."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("button",{onClick:h,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Cancel"})})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"mb-2 text-sm text-gray-700",children:"Inspectr lets you serve a mock API based on an OpenAPI spec."}),l.jsxs("p",{className:"mb-4 text-sm text-gray-700",children:["You’re about to use ",l.jsx("b",{children:o})," for mock responses. This will replace any existing mock configuration or catch-mode settings."]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{htmlFor:"openapi-url",className:"block text-sm font-medium text-gray-700",children:"OpenAPI Spec URL"}),l.jsx("input",{id:"openapi-url",type:"url",value:o,onChange:b=>{a(b.target.value),s(null)},placeholder:"https://example.com/openapi.yaml",disabled:c,className:"mt-1 block w-full rounded-md shadow-sm sm:text-sm "+(i?"border-red-500 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500")}),i&&l.jsx("p",{className:"mt-2 text-sm text-red-600",children:i})]}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:h,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",disabled:c,children:"Cancel"}),l.jsx("button",{onClick:g,className:`px-4 py-2 text-white rounded ${c?"bg-gray-400 cursor-not-allowed":"bg-red-600 hover:bg-red-700"}`,disabled:c,children:c?"Loading…":"Confirm"})]})]})]})]}):null}function _2e({open:e,onClose:t}){const{client:r,setToast:n}=Tr(),[o,a]=p.useState("json"),[i,s]=p.useState(!1),[c,u]=p.useState("preset"),[d,f]=p.useState(""),[m,h]=p.useState(""),[g,b]=p.useState(""),[v]=Oa("feat_export_openapi"),[x]=Oa("feat_export_postman"),[k,N]=p.useState("");p.useEffect(()=>{e||N("")},[e]);const j=async()=>{s(!0),N("");try{const E={format:o};c==="preset"?d&&(E.preset=d):(m&&(E.since=new Date(m).toISOString()),g&&(E.until=new Date(g).toISOString()));const C=await r.operations.export(E),S=new Date,T=D=>D.toString().padStart(2,"0"),A=`${S.getFullYear()}-${T(S.getMonth()+1)}-${T(S.getDate())}-${T(S.getHours())}${T(S.getMinutes())}`,M=URL.createObjectURL(C),_=document.createElement("a");_.href=M;const I=o==="phar"?"phar":"json",F=o==="json"?"":`_${o}`;_.download=`inspectr_operations_${A}${F}.${I}`,_.click(),URL.revokeObjectURL(M),t&&t()}catch(E){console.error("Export failed",E);const C=E?.message||"Export failed";N(C),n({message:"Export failed",subMessage:C,type:"error"})}finally{s(!1)}};return e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Export Operations"}),l.jsx("button",{onClick:t,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",children:"×"})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Time Range"}),l.jsxs("div",{className:"mt-1 flex items-center space-x-4",children:[l.jsxs("label",{className:"inline-flex items-center",children:[l.jsx("input",{type:"radio",name:"timeOption",value:"preset",checked:c==="preset",onChange:()=>u("preset"),className:"form-radio"}),l.jsx("span",{className:"ml-2",children:"Preset"})]}),l.jsxs("label",{className:"inline-flex items-center",children:[l.jsx("input",{type:"radio",name:"timeOption",value:"custom",checked:c==="custom",onChange:()=>u("custom"),className:"form-radio"}),l.jsx("span",{className:"ml-2",children:"Custom"})]})]}),c==="preset"&&l.jsxs("select",{value:d,onChange:E=>f(E.target.value),className:"mt-2 block w-full rounded-md border-gray-300 shadow-sm sm:text-sm",children:[l.jsx("option",{value:"",children:"-- Select preset --"}),l.jsx("option",{value:"1h",children:"Last hour"}),l.jsx("option",{value:"24h",children:"Last 24 hours"}),l.jsx("option",{value:"7d",children:"Last 7 days"}),l.jsx("option",{value:"30d",children:"Last 30 days"}),l.jsx("option",{value:"start",children:"Since start Inspectr"}),l.jsx("option",{value:"first",children:"Since first operation"})]}),c==="custom"&&l.jsxs("div",{className:"mt-2 space-y-2",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm",children:"Since"}),l.jsx("input",{type:"datetime-local",value:m,onChange:E=>h(E.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm sm:text-sm"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm",children:"Until (optional)"}),l.jsx("input",{type:"datetime-local",value:g,onChange:E=>b(E.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm sm:text-sm"})]})]})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Format"}),l.jsxs("select",{value:o,onChange:E=>a(E.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",children:[l.jsx("option",{value:"json",children:"JSON"}),v&&l.jsx("option",{value:"openapi",children:"OpenAPI (preview)"}),x&&l.jsx("option",{value:"postman",children:"Postman (preview)"})]})]}),k&&l.jsx("p",{className:"mb-4 text-sm text-red-600",role:"alert",children:k}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Cancel"}),l.jsx("button",{onClick:j,disabled:i,className:`px-4 py-2 text-white rounded ${i?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"}`,children:i?"Exporting…":"Export"})]})]})]}):null}function I2e({open:e,onClose:t,onContinue:r,onCancelRecording:n,startTime:o}){const{client:a,setToast:i}=Tr(),[s,c]=p.useState("json"),[u,d]=p.useState(!1),[f]=Oa("feat_export_openapi"),[m]=Oa("feat_export_postman"),[h,g]=p.useState(""),b=Gn(async()=>o?await Vr.db.events.where("time").above(o).count():0,[o]);p.useEffect(()=>{e||g("")},[e]);const v=async()=>{d(!0),g("");try{const x=await a.operations.export({since:o,format:s}),k=new Date,N=A=>A.toString().padStart(2,"0"),j=`${k.getFullYear()}-${N(k.getMonth()+1)}-${N(k.getDate())}-${N(k.getHours())}${N(k.getMinutes())}`,E=URL.createObjectURL(x),C=document.createElement("a");C.href=E;const S=s==="phar"?"phar":"json",T=s==="json"?"":`_${s}`;C.download=`inspectr_operations_${j}${T}.${S}`,C.click(),URL.revokeObjectURL(E),t&&t()}catch(x){console.error("Export failed",x);const k=x?.message||"Export failed";g(k),i({message:"Export failed",subMessage:k,type:"error"})}finally{d(!1)}};return e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-lg w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Export Recording"}),l.jsx("button",{onClick:t,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",children:"×"})]}),l.jsxs("p",{className:"text-sm mb-4",children:[b," operations recorded since ",new Date(o).toLocaleString()]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Format"}),l.jsxs("select",{value:s,onChange:x=>c(x.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",children:[l.jsx("option",{value:"json",children:"JSON"}),f&&l.jsx("option",{value:"openapi",children:"OpenAPI (preview)"}),m&&l.jsx("option",{value:"postman",children:"Postman (preview)"})]})]}),h&&l.jsx("p",{className:"-mt-2 mb-4 text-sm text-red-600",role:"alert",children:h}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:r,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Continue Recording"}),l.jsx("button",{onClick:n,className:"px-4 py-2 bg-orange-200 text-gray-700 rounded hover:bg-orange-300",children:"Cancel Recording"}),l.jsx("button",{onClick:v,disabled:u,className:`px-4 py-2 text-white rounded ${u?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"}`,children:u?"Exporting…":"Export"})]})]})]}):null}function D2e({open:e,onClose:t}){const{client:r,setToast:n}=Tr(),[o,a]=p.useState(null),[i,s]=p.useState(!1),c=async()=>{if(o){s(!0);try{await r.operations.import(o),n({message:"Import completed",type:"success"}),t&&t()}catch(u){console.error("Import failed",u),n({message:"Import failed",subMessage:u.message,type:"error"})}finally{s(!1)}}};return e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Import Operations"}),l.jsx("button",{onClick:t,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",children:"×"})]}),l.jsx("div",{className:"mb-4",children:l.jsx("input",{type:"file",accept:".json",onChange:u=>a(u.target.files[0]),className:"mt-1 block w-full text-sm"})}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Cancel"}),l.jsx("button",{onClick:c,disabled:!o||i,className:`px-4 py-2 text-white rounded ${!o||i?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"}`,children:i?"Importing…":"Import"})]})]})]}):null}const L2e="inspectrVersionMuteUntil",p9=3*24*60*60*1e3;function R2e(){const{client:e}=Tr(),[t,r]=_r(L2e,""),[n,o]=p.useState(!1),[a,i]=p.useState(!1),[s,c]=p.useState(null);p.useEffect(()=>{var g;if(!((g=e?.service)!=null&&g.getVersion))return;const b=t?Date.parse(t):0;if(b&&b>Date.now()){i(!1),o(!1);return}let v=!1;return e.service.getVersion().then(x=>{if(!v)if(c(x),x!=null&&x.update_available)i(!0);else{i(!1),o(!1);const k=new Date(Date.now()+p9).toISOString();r(k)}}).catch(x=>{console.error("Version check failed",x)}),()=>{v=!0}},[e,t]);const u=()=>{o(!1)},d=()=>{const g=new Date(Date.now()+p9).toISOString();r(g),i(!1),u()},f=()=>{d()},m=()=>{window.open("https://inspectr.dev/docs/getting-started/upgrade","_blank","noopener,noreferrer")},h=()=>{s!=null&&s.update_available&&o(!0)};return a?l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-center gap-2 rounded-md border border-amber-400 bg-amber-500 px-1 py-1 text-xs font-semibold text-white shadow-sm transition hover:bg-amber-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[l.jsx("span",{className:"h-2 w-2 rounded-full bg-white/90 shadow-sm"}),l.jsx("span",{className:"uppercase tracking-wide",children:"Update available"})]}),l.jsx(ww,{show:n,as:p.Fragment,children:l.jsx(jm,{as:"div",className:"pointer-events-none fixed inset-x-0 top-6 z-40 flex justify-center px-4 sm:top-8",onClose:u,children:l.jsx(ww.Child,{as:p.Fragment,enter:"ease-out duration-200",enterFrom:"opacity-0 -translate-y-2",enterTo:"opacity-100 translate-y-0",leave:"ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-2",children:l.jsx(jm.Panel,{className:"pointer-events-auto relative w-full max-w-4xl overflow-hidden rounded-2xl border border-gray-200 bg-white p-6 shadow-xl dark:border-gray-800 dark:bg-gray-900",children:l.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:gap-6",children:[l.jsxs("div",{className:"flex items-start gap-3 sm:min-w-[220px]",children:[l.jsx("span",{className:"mt-1 flex h-12 w-12 items-center justify-center rounded-full bg-emerald-100 text-emerald-700 shadow-sm dark:bg-emerald-900/30 dark:text-emerald-200",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M19.4668 8.69379L19.7134 8.12811C20.1529 7.11947 20.9445 6.31641 21.9323 5.87708L22.6919 5.53922C23.1027 5.35653 23.1027 4.75881 22.6919 4.57612L21.9748 4.25714C20.9616 3.80651 20.1558 2.97373 19.7238 1.93083L19.4706 1.31953C19.2942 0.893489 18.7058 0.893489 18.5293 1.31953L18.2761 1.93083C17.8442 2.97373 17.0384 3.80651 16.0252 4.25714L15.3081 4.57612C14.8973 4.75881 14.8973 5.35653 15.3081 5.53922L16.0677 5.87708C17.0555 6.31641 17.8471 7.11947 18.2866 8.12811L18.5331 8.69379C18.7136 9.10792 19.2864 9.10792 19.4668 8.69379ZM5 6C4.68525 6 4.38886 6.14819 4.2 6.4L1.2 10.4C0.913337 10.7822 0.937093 11.3138 1.25671 11.669L10.2567 21.669C10.4464 21.8797 10.7165 22 11 22C11.2835 22 11.5537 21.8797 11.7433 21.669L20.7433 11.669L19.2567 10.331L11 19.5052L3.29335 10.9422L5.5 8H14V6H5Z"})})}),l.jsxs("div",{className:"space-y-1",children:[l.jsx(jm.Title,{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"New Inspectr version available"}),l.jsx(jm.Description,{className:"text-sm text-gray-700 dark:text-gray-200",children:s!=null&&s.latest_version?`Update to ${s.latest_version} to get the latest improvements.`:"A new build is ready for you. Grab the latest to get new features."}),l.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Current: ",s?.current_version||"Unknown"," • Latest:"," ",s?.latest_version||"—"]})]})]}),l.jsxs("div",{className:"flex flex-1 flex-wrap items-center justify-end gap-3",children:[l.jsx("button",{type:"button",onClick:f,className:"inline-flex items-center justify-center rounded-full px-4 py-2 text-sm font-semibold text-gray-700 transition hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:text-gray-200 dark:hover:bg-gray-800",children:"Skip"}),l.jsx("button",{type:"button",onClick:m,className:"inline-flex items-center justify-center rounded-full bg-emerald-600 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:bg-emerald-500 dark:hover:bg-emerald-400",children:"Update"})]})]})})})})})]}):null}function qR(...e){return e.filter(Boolean).join(" ")}const F2e=[{name:"Request History",slug:"inspectr",component:fR},{name:"Trace Explorer",slug:"traces",component:T2e,hidden:!0},{name:"Insights",slug:"insights",component:A2e},{name:"Statistics",slug:"statistics",component:eke},{name:"Usage",slug:"usage",component:F0e},{name:"Rules",slug:"rules",component:rwe},{name:"Settings",slug:"settings",component:jwe}],$2e=e=>l.jsx("svg",{fill:"currentColor",height:"24",width:"24",viewBox:"0 0 1648 1648",xmlns:"http://www.w3.org/2000/svg",...e,children:l.jsx("path",{d:"m610 216.654c-66.158 4.092-126.119 35.849-164.917 87.346-8.408 11.16-13.344 19.191-19.983 32.513-12.431 24.946-19.521 50.434-22.11 79.487-1.665 18.687-.854 826.238.841 837.939 7.867 54.284 32.465 101.134 70.706 134.667 16.297 14.291 32.283 24.657 53.963 34.991 16.889 8.05 34.568 13.468 60.5 18.541 9.019 1.764 52.201 1.795 61.5.044 26.487-4.989 43.97-10.341 61-18.675 15.131-7.406 21.53-11.135 60.5-35.267 20.813-12.887 23.095-14.298 29.5-18.24l13-8 13-8c6.901-4.247 12.593-7.767 29.54-18.271 5.796-3.593 12.771-7.863 15.5-9.49 2.728-1.626 8.56-5.19 12.96-7.921 4.4-2.73 72.575-44.711 151.5-93.29s150.925-92.918 160-98.531c9.075-5.612 24.15-14.936 33.5-20.719s23.075-14.234 30.5-18.78c85.169-52.142 120.029-73.942 130.014-81.304 40.974-30.211 68.344-69.764 81.788-118.194 13.864-49.94 8.549-104.847-14.809-153-16.836-34.708-41.252-62.432-74.993-85.154-4.125-2.778-17.625-11.26-30-18.849s-27-16.594-32.5-20.009c-5.5-3.416-109.45-67.427-231-142.246-306.386-188.593-335.221-206.352-350-215.553-30.562-19.028-59.301-29.911-90-34.083-11.697-1.59-30.408-2.514-39.5-1.952m-10.5 77.269c-39.541 6.402-76.013 29.73-97.661 62.467-13.001 19.66-19.718 38.39-22.802 63.584-1.472 12.028-1.434 802.191.04 818.026 1.861 19.998 6.142 35.48 14.415 52.133 17.942 36.114 53.025 64.18 91.508 73.203 3.575.839 8.975 2.118 12 2.844 8.221 1.973 40.343 1.613 49.971-.56 32.301-7.289 65.233-26.686 94.817-55.849 15.26-15.042 22.884-24.803 33.571-42.979 13.939-23.706 20.949-43.36 27.745-77.792 1.004-5.086 1.428-50 1.949-206.5.465-139.686 1.001-201.809 1.777-206 .611-3.3 1.608-9.15 2.217-13 1.672-10.583 4.039-21.117 7.191-32 8.179-28.247 20.714-55.13 37.188-79.751 24.262-36.262 53.189-63.572 93.074-87.872 4.95-3.016 12.825-7.435 17.5-9.82s8.95-4.668 9.5-5.074c3.565-2.63 34.688-13.266 52.465-17.93 6.2-1.627 11.49-3.174 11.754-3.439 1.003-1.002-1.016-2.602-10.967-8.689-5.639-3.449-16.552-10.172-24.252-14.94-13.435-8.319-31.76-19.604-58.5-36.029-6.875-4.222-16.1-9.911-20.5-12.641-7.667-4.758-73.088-45.103-122.5-75.546-75.227-46.348-108.509-66.591-116.5-70.86-9.422-5.033-25.23-10.76-37.043-13.419-7.967-1.794-40.076-2.843-47.957-1.567m473.5 305.564c-5.775.685-11.625 1.491-13 1.792-1.375.3-5.2 1.088-8.5 1.749-7.914 1.587-27.103 7.461-36.5 11.174-38.797 15.33-75.171 44.925-98.829 80.41-11.24 16.86-21.329 38.407-26.167 55.888-2.443 8.825-3.85 14.608-4.866 20-.621 3.3-1.653 8.475-2.292 11.5-.846 4.008-1.345 59.624-1.837 205-.618 182.331-.824 200.361-2.399 209.5-1.629 9.459-4.196 22.506-6.744 34.279-.628 2.903-.881 5.54-.561 5.859.596.596 455.986-279.084 472.195-290.001 17.547-11.819 36.335-33.412 46.291-53.203 3.956-7.863 9.527-23.924 11.597-33.434 4.848-22.272 3.572-48.26-3.506-71.387-6.907-22.572-18.055-40.93-35.316-58.158-12.705-12.681-16.829-15.485-79.066-53.756-7.15-4.397-15.7-9.654-19-11.684-3.3-2.029-8.925-5.504-12.5-7.722-53.826-33.397-67.199-40.611-88.616-47.8-29.343-9.85-61.599-13.421-90.384-10.006m-1066.25 1048.256c3.988.189 10.513.189 14.5 0 3.988-.19.725-.346-7.25-.346s-11.238.156-7.25.346",fillRule:"evenodd"})});function tje(){const[e]=Oa("feat_insights_display",!1,!0);Oa("feat_export_mcp_server",!1,!0),Oa("feat_rules_ui",!1,!0);const t=p.useMemo(()=>{let j=F2e;return e!==!0&&(j=j.filter(E=>E.slug!=="insights")),j},[e]),[r,n]=p.useState(()=>t[0]),{route:o,currentNav:a,handleTabClick:i}=S0e(t),s=p.useMemo(()=>t.filter(j=>!j.hidden),[t]),c=a.component,[u,d]=p.useState(!1),[f,m]=p.useState(!1),[h,g]=_r("recordStart",null),[b,v]=p.useState(()=>!!h);p.useEffect(()=>{v(!!h)},[h]),p.useEffect(()=>{a&&n(a)},[a]);const[x,k]=p.useState(!1),N=Gn(async()=>!b||!h?0:await Vr.db.events.where("time").above(h).count(),[b,h]);return l.jsxs(eU,{children:[l.jsx(M2e,{}),l.jsxs("div",{className:"flex flex-col min-h-screen",children:[l.jsx("div",{className:"border-b border-tremor-border dark:border-dark-tremor-border relative h-full overflow-hidden bg-gray-50 dark:bg-dark-tremor-background-subtle",children:l.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:l.jsxs("div",{className:"overflow flex h-16 sm:space-x-7 items-center",children:[l.jsx("div",{className:"hidden shrink-0 sm:flex sm:items-center",children:l.jsx("a",{href:"/",className:"p-1.5",children:l.jsx($2e,{className:"size-4 shrink-0 w-8 h-8 text-tremor-content-strong dark:text-dark-tremor-content-strong","aria-hidden":!0})})}),l.jsx("nav",{className:"flex-1 -mb-px flex space-x-6","aria-label":"Tabs",children:s.map(j=>j.slug==="inspectr"?l.jsx(H2e,{navItem:j,isActive:j.slug===a.slug,onClick:()=>i(j),isCurrent:j.name===r.name},j.slug):l.jsx("button",{onClick:()=>i(j),className:qR(j.slug===a.slug?"dark:text-tremor-dark-brand border-tremor-brand text-tremor-brand":"border-transparent text-tremor-content-emphasis hover:border-tremor-content-subtle hover:text-tremor-content-strong dark:text-dark-tremor-content-emphasis hover:dark:border-dark-tremor-content-subtle hover:dark:text-dark-tremor-content-strong","inline-flex items-center whitespace-nowrap border-b-2 px-2 py-2 text-tremor-default font-medium"),"aria-current":j.name===r.name?"page":void 0,children:j.name},j.slug))}),l.jsxs("div",{className:"ml-auto flex items-center space-x-2",children:[l.jsx(R2e,{}),l.jsx("button",{className:"px-2 py-1 text-cyan-500 hover:text-white border border-cyan-500 hover:bg-cyan-500 rounded text-xs",onClick:()=>d(!0),children:"Export"}),l.jsx("button",{className:"px-2 py-1 text-cyan-500 hover:text-white border border-cyan-500 hover:bg-cyan-500 rounded text-xs",onClick:()=>m(!0),children:"Import"}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{disabled:x,className:`px-2 py-1 rounded text-xs flex items-center border border-green-500 ${b?"text-white bg-green-500":"text-green-500 hover:text-white hover:bg-green-500"} `,onClick:()=>{b?N>0?k(!0):(v(!1),g(null)):(g(new Date().toISOString()),v(!0))},children:[l.jsx("span",{className:`mr-1 block w-2 h-2 ${b?"bg-red-600 animate-pulse":"bg-red-600 rounded-full"}`}),b?"Stop Recording":"Start Recording"]}),b&&N>0&&l.jsx("span",{className:"absolute -top-3 -right-2",children:l.jsx(jR,{count:N})})]})]})]})})}),l.jsx("div",{className:"flex-grow overflow-auto",children:["insights","statistics","settings","usage","rules","traces"].includes(a.slug)?l.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-950",children:l.jsx(c,{route:o},a.slug)}):l.jsx(fR,{route:o},"inspectr")}),l.jsx(B2e,{}),l.jsx(_2e,{open:u,onClose:()=>d(!1)}),l.jsx(D2e,{open:f,onClose:()=>m(!1)}),l.jsx(I2e,{open:x,onContinue:()=>{k(!1)},onCancelRecording:()=>{k(!1),v(!1),g(null)},onClose:()=>k(!1),startTime:h})]})]})}const B2e=()=>{const{toast:e,setToast:t}=Tr();return e?l.jsx(Jm,{message:e.message,subMessage:e.subMessage,type:e.type,onClose:()=>t(null)}):null},H2e=({navItem:e,isActive:t,onClick:r,isCurrent:n})=>{const{connectionStatus:o}=Tr(),[a,i]=_r("inspectrLastSeenAt",null),[s,c]=p.useState(()=>Ws(a)),u=Gn(async()=>{try{const h=await Vr.db.events.orderBy("time").last();return h?.time||null}catch{return null}},[]),d=Gn(async()=>{if(!s)return 0;try{return await Vr.db.events.where("time").above(s).count()}catch{return 0}},[s]);p.useEffect(()=>{const h=Ws(a);c(g=>{const b=Ws(g);return h?t||!b?h:fj(h,b)?b:h:b?g:null})},[a,t]);const f=o==="connected"?"green":o==="disconnected"?"red":"orange",m=()=>{const h=Ws(u)||new Date().toISOString();i(g=>{const b=Ws(g);return!b||fj(h,b)?h:b}),c(h),r&&r()};return l.jsxs("button",{onClick:m,className:qR(t?"dark:text-tremor-dark-brand border-tremor-brand text-tremor-brand":"border-transparent text-tremor-content-emphasis hover:border-tremor-content-subtle hover:text-tremor-content-strong dark:text-dark-tremor-content-emphasis hover:dark:border-dark-tremor-content-subtle hover:dark:text-dark-tremor-content-strong","inline-flex items-center whitespace-nowrap border-b-2 px-2 py-2 text-tremor-default font-medium relative"),"aria-current":n?"page":void 0,children:[e.name,!t&&d>0&&l.jsx("span",{className:"absolute -top-3 -right-2",children:l.jsx(jR,{count:d,color:f})})]},e.slug)};export{tje as Workspace};
|
|
211
|
+
`,style:{zIndex:9999},children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b border-gray-300 dark:border-dark-tremor-border bg-gray-50 dark:bg-dark-tremor-background-subtle",children:[l.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-dark-tremor-content-strong",children:"Filters"}),l.jsx("button",{onClick:t,className:"text-gray-600 dark:text-dark-tremor-content hover:text-gray-800 dark:hover:text-dark-tremor-content-strong focus:outline-none cursor-pointer border rounded px-1","aria-label":"Close",children:"×"})]}),l.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",children:l.jsxs("section",{className:"mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-gray-200 dark:border-dark-tremor-border",children:[l.jsx("h3",{className:"text-xs font-bold text-gray-600 dark:text-dark-tremor-content uppercase tracking-wide",children:"Filters"}),l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("label",{className:"flex items-center gap-1 text-[11px] font-medium text-gray-600 dark:text-dark-tremor-content-subtle",children:[l.jsx("input",{type:"checkbox",className:"h-3 w-3",checked:g,onChange:I=>b(I.target.checked)}),"Keep on reload"]}),l.jsx("button",{onClick:M,className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]})]}),l.jsxs("div",{className:"space-y-6 pt-4",children:[A?l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"MCP"}),l.jsx("button",{onClick:()=>_(["mcpTool","mcpResource","mcpPrompt","mcpMethod","mcpCategory","tokenMin","tokenMax"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),N&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Tool"}),l.jsx(un,{options:s,selected:r.mcpTool||[],onChange:I=>n(F=>({...F,mcpTool:I})),placeholder:"Add MCP tool...",colorFn:k("blue")})]}),j&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Resource"}),l.jsx(un,{options:c,selected:r.mcpResource||[],onChange:I=>n(F=>({...F,mcpResource:I})),placeholder:"Add MCP resource...",colorFn:k("emerald")})]}),E&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Prompt"}),l.jsx(un,{options:u,selected:r.mcpPrompt||[],onChange:I=>n(F=>({...F,mcpPrompt:I})),placeholder:"Add MCP prompt...",colorFn:k("indigo")})]}),S&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Method"}),l.jsx(un,{options:f,selected:r.mcpMethod||[],onChange:I=>n(F=>({...F,mcpMethod:I})),placeholder:"Add MCP method...",colorFn:x})]}),C&&l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"MCP Category"}),l.jsx(un,{options:d,selected:r.mcpCategory||[],onChange:I=>n(F=>({...F,mcpCategory:I})),placeholder:"Add MCP category...",colorFn:x})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Total Tokens"}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx("input",{type:"number",placeholder:"Min",value:r.tokenMin||"",onChange:I=>n(F=>({...F,tokenMin:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"}),l.jsx("input",{type:"number",placeholder:"Max",value:r.tokenMax||"",onChange:I=>n(F=>({...F,tokenMax:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]})]}):null,l.jsxs("div",{className:`space-y-4 ${A?"pt-4 border-t border-gray-200 dark:border-dark-tremor-border":""}`,children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"HTTP"}),l.jsx("button",{onClick:()=>_(["status","method","path"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Status"}),l.jsx(un,{options:o,selected:r.status||[],onChange:I=>n(F=>({...F,status:I})),placeholder:"Add status...",colorFn:nu})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Method"}),l.jsx(un,{options:a,selected:r.method||[],onChange:I=>n(F=>({...F,method:I})),placeholder:"Add method...",colorFn:Bh})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Path"}),l.jsx("input",{type:"text",placeholder:"e.g. /mcp",value:r.path||"",onChange:I=>n(F=>({...F,path:I.target.value})),className:"block w-full border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]}),l.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"Tags"}),l.jsx("button",{onClick:()=>_(["tags"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Tags"}),l.jsx(un,{options:i,selected:r.tags||[],onChange:I=>n(F=>({...F,tags:I})),placeholder:"Add tag..."})]})]}),l.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-dark-tremor-border",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-tremor-content-subtle",children:"Timing & Host"}),l.jsx("button",{onClick:()=>_(["durationMin","durationMax","host"]),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline cursor-pointer",children:"Reset"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Duration (ms)"}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx("input",{type:"number",placeholder:"Min",value:r.durationMin||"",onChange:I=>n(F=>({...F,durationMin:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"}),l.jsx("input",{type:"number",placeholder:"Max",value:r.durationMax||"",onChange:I=>n(F=>({...F,durationMax:I.target.value})),className:"w-1/2 border border-gray-300 dark:border-dark-tremor-border bg-white dark:bg-dark-tremor-background-subtle dark:text-dark-tremor-content rounded-md shadow-sm py-2 px-3 focus:ring-blue-500 focus:border-blue-500 sm:text-sm"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-dark-tremor-content mb-1",children:"Host"}),l.jsx(un,{options:m,selected:r.host||[],onChange:I=>n(F=>({...F,host:I})),placeholder:"Add host..."})]})]})]})]})})]})]})},ow=56,c9=30,u9=75,y2e="traceTimelineWidth",aw="calc(100vh - 64px)",x2e="traceTimelineFilters",k2e="traceTimelinePersistFilters",w2e=e=>{var t;if(!e.length)return"Trace group";const r=e[0];return s2e(r)||((t=r.traceInfo)==null?void 0:t.source)||(r.correlationId?`Correlation ${r.correlationId}`:null)||`${r.method} ${r.path}`},j2e=e=>{if(!e.length)return"";const t=e[0];return t.path||t.url||""},N2e=e=>e.length?e.reduce((t,r)=>Math.max(t,r.status??0),0):null,zl=e=>{const t=Number(e);return Number.isFinite(t)?t:null};function BR({operations:e=[],initialTraceId:t=null,initialOperationId:r=null,onTraceChange:n,onOperationChange:o,isActive:a=!0}){const{supportsTraces:i,traceList:s,traceListMeta:c,isTraceListLoading:u,traceListError:d,traceDetailError:f,traceDetailMeta:m,isTraceDetailLoading:h,selectedTraceId:g,traceSummary:b,traceSources:v,traceDurationMs:x,normalizedOperations:k,timeline:N,selectedOperationId:j,setSelectedOperationId:E,refreshTraceList:C,refreshTraceDetail:S,traceDetailPage:T,setTraceDetailPage:A}=FR({initialTraceId:t,initialOperationId:r,onTraceChange:n,onOperationChange:o,isActive:a}),[M,_]=p.useState(()=>new Set),[I,F]=_r(y2e,String(ow)),[D,R]=_r(k2e,"false"),[z,H]=_r(x2e,""),$=p.useMemo(()=>{const ye=Number(I);return Number.isFinite(ye)&&ye>=c9&&ye<=u9?ye:ow},[I]),V=p.useRef(!1),U=p.useRef(null),B=p.useRef(null),X=p.useRef(null),[K,ae]=p.useState(!1),J=D==="true",[ee,te]=p.useState({}),fe=N.start,Y=N.duration,ce=p.useMemo(()=>{if(!k.length)return[];const ye=($e,Ke)=>{if(!Array.isArray(Ke)||Ke.length===0)return!0;if(!$e)return!1;const Nt=Array.isArray($e)?$e:[$e],lt=new Set(Nt.map(Mt=>String(Mt).toLowerCase()));return Ke.some(Mt=>lt.has(String(Mt).toLowerCase()))},ve=($e,Ke)=>{if(!Array.isArray(Ke)||Ke.length===0)return!0;const Nt=JT(Ke);if(!Nt.length)return!0;const lt=Array.isArray($e)?$e.map(Mt=>Mt.token):[];return Nt.every(Mt=>lt.includes(Mt))},Ae=$e=>{var Ke,Nt,lt,Mt,De,ir,ar,Kt;const Re=((Ke=$e?.meta)==null?void 0:Ke.mcp)||((lt=(Nt=$e?.raw)==null?void 0:Nt.meta)==null?void 0:lt.mcp)||((De=(Mt=$e?.meta)==null?void 0:Mt.trace)==null?void 0:De.mcp)||((Kt=(ar=(ir=$e?.raw)==null?void 0:ir.meta)==null?void 0:ar.trace)==null?void 0:Kt.mcp),tr=Re?.tokens;if(!tr)return null;const rr=zl(tr.total);if(rr!==null)return rr;const Qe=zl(tr.request),Pt=zl(tr.response);return Qe!==null||Pt!==null?(Qe??0)+(Pt??0):null};return k.filter($e=>{var Ke,Nt;if(!$e)return!1;if(ee.status&&Array.isArray(ee.status)&&ee.status.length>0){const Re=$e.status!=null?String($e.status):"";if(!ee.status.includes(Re))return!1}if(ee.method&&Array.isArray(ee.method)&&ee.method.length>0){const Re=($e.method||"").toLowerCase();if(!ee.method.map(tr=>String(tr).toLowerCase()).includes(Re))return!1}if(ee.path&&!($e.path||$e.url||"").toLowerCase().includes(String(ee.path).toLowerCase())||ee.durationMin&&(!Number.isFinite($e.duration)||Number($e.duration)<Number(ee.durationMin))||ee.durationMax&&(!Number.isFinite($e.duration)||Number($e.duration)>Number(ee.durationMax)))return!1;if(ee.tokenMin){const Re=Ae($e);if(Re===null||Re<Number(ee.tokenMin))return!1}if(ee.tokenMax){const Re=Ae($e);if(Re===null||Re>Number(ee.tokenMax))return!1}if(ee.host&&Array.isArray(ee.host)&&ee.host.length>0){const Re=($e.host||"").toLowerCase();if(!ee.host.map(tr=>String(tr).toLowerCase()).some(tr=>Re.includes(tr)))return!1}if(ee.tags&&!ve($e.tags,ee.tags))return!1;const lt=((Ke=$e.raw)==null?void 0:Ke.meta)||{},Mt=lt.trace||{},De=lt.mcp||Mt.mcp||((Nt=$e.meta)==null?void 0:Nt.mcp)||null,ir=De?.category||"",ar=De?.method||"",Kt=De?.name||"";return!(ee.mcpCategory&&!ye(ir,ee.mcpCategory)||ee.mcpMethod&&!ye(ar,ee.mcpMethod)||ee.mcpTool&&ee.mcpTool.length>0&&!ye(ir==="tool"?Kt:"",ee.mcpTool)||ee.mcpResource&&ee.mcpResource.length>0&&!ye(ir==="resource"?Kt:"",ee.mcpResource)||ee.mcpPrompt&&ee.mcpPrompt.length>0&&!ye(ir==="prompt"?Kt:"",ee.mcpPrompt))})},[k,ee]),se=p.useMemo(()=>{if(!ce.length)return[];const ye=new Map;return ce.forEach((ve,Ae)=>{const $e=ve.correlationId||`__group-${Ae}`;ye.has($e)||ye.set($e,{id:$e,operations:[],startMs:null,endMs:null,order:Ae});const Ke=ye.get($e);Ke.operations.push(ve);const{start:Nt,end:lt}=_b(ve,Ae);Ke.startMs=Ke.startMs===null?Nt:Math.min(Ke.startMs,Nt),Ke.endMs=Ke.endMs===null?lt:Math.max(Ke.endMs,lt)}),Array.from(ye.values()).map(ve=>({...ve,label:w2e(ve.operations),subtitle:j2e(ve.operations),durationMs:ve.startMs!=null&&ve.endMs!=null?Math.max(ve.endMs-ve.startMs,0):0,maxStatus:N2e(ve.operations)})).sort((ve,Ae)=>(ve.startMs??0)-(Ae.startMs??0))},[ce]),W=h||u,ne=()=>{C(),S()};p.useEffect(()=>{if(!se.length){_(new Set);return}_(new Set(se.map(ye=>ye.id)))},[g,se]),p.useEffect(()=>{var ye;if(!ce.length||j&&ce.some(Ae=>Ae.id===j))return;const ve=((ye=ce[0])==null?void 0:ye.id)||null;ve&&ve!==j&&E(ve)},[ce,j,E]);const oe=p.useMemo(()=>j&&ce.find(ye=>ye.id===j)||null,[ce,j]);p.useEffect(()=>{if(!j||!se.length)return;const ye=se.find(ve=>ve.operations.some(Ae=>Ae.id===j));ye&&!M.has(ye.id)&&_(ve=>{const Ae=new Set(ve);return Ae.add(ye.id),Ae})},[j,se,M]),p.useEffect(()=>{if(!oe)return;const ye=setTimeout(()=>{B.current&&X.current!==j&&(B.current.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),X.current=j)},150);return()=>clearTimeout(ye)},[j,oe,M]);const xe=p.useCallback(()=>{V.current=!1},[]),Ce=p.useCallback(ye=>{if(!V.current||!U.current)return;const ve=U.current.getBoundingClientRect();if(!ve.width)return;const Ae=(ye.clientX-ve.left)/ve.width*100,$e=Math.min(Math.max(Ae,c9),u9);F(String($e))},[F]);p.useEffect(()=>(window.addEventListener("mousemove",Ce),window.addEventListener("mouseup",xe),()=>{window.removeEventListener("mousemove",Ce),window.removeEventListener("mouseup",xe)}),[Ce,xe]),p.useEffect(()=>{if(!J){H(null);return}if(z&&!Object.keys(ee||{}).length)try{const ye=JSON.parse(z);if(!ye||typeof ye!="object")return;te(ye)}catch{}},[J,z,ee,H]),p.useEffect(()=>{if(J){if(!Object.entries(ee||{}).some(([,ye])=>Array.isArray(ye)?ye.length>0:ye!==""&&ye!==null&&ye!==void 0)){H(null);return}H(JSON.stringify(ee))}},[ee,J,H]);const Le=p.useMemo(()=>{let ye=0,ve=0,Ae=0,$e=!1,Ke=!1,Nt=!1;return ce.forEach(lt=>{var Mt,De,ir,ar,Kt,Re,tr,rr;if(!lt)return;const Qe=((Mt=lt?.meta)==null?void 0:Mt.mcp)||((ir=(De=lt?.raw)==null?void 0:De.meta)==null?void 0:ir.mcp)||((Kt=(ar=lt?.meta)==null?void 0:ar.trace)==null?void 0:Kt.mcp)||((rr=(tr=(Re=lt?.raw)==null?void 0:Re.meta)==null?void 0:tr.trace)==null?void 0:rr.mcp),Pt=Qe?.tokens;if(!Pt)return;const At=zl(Pt.request),Lr=zl(Pt.response),Or=zl(Pt.total);At!==null&&($e=!0,ye+=At),Lr!==null&&(Ke=!0,ve+=Lr),Or!==null?(Nt=!0,Ae+=Or):(At!==null||Lr!==null)&&(Nt=!0,Ae+=(At??0)+(Lr??0))}),$e||Ke||Nt?{request:$e?ye:null,response:Ke?ve:null,total:Nt?Ae:null}:null},[ce]),Oe=ce.length,Ve=Object.entries(ee||{}).reduce((ye,[ve,Ae])=>Array.isArray(Ae)?Ae.length>0?ye+1:ye:Ae?ye+1:ye,0),et=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{ve?.status!=null&&ye.add(String(ve.status))}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),Ie=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{ve!=null&&ve.method&&ye.add(ve.method.toUpperCase())}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),st=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{Array.isArray(ve.tags)&&ve.tags.forEach(Ae=>ye.add(Ae.display))}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),nt=p.useMemo(()=>{const ye=new Set;return k.forEach(ve=>{ve!=null&&ve.host&&ye.add(ve.host)}),Array.from(ye).sort((ve,Ae)=>ve.localeCompare(Ae))},[k]),xt=p.useMemo(()=>{const ye=new Set,ve=new Set,Ae=new Set,$e=new Set,Ke=new Set;k.forEach(lt=>{var Mt,De;const ir=((Mt=lt?.raw)==null?void 0:Mt.meta)||{},ar=ir.trace||{},Kt=ir.mcp||ar.mcp||((De=lt?.meta)==null?void 0:De.mcp);Kt&&(Kt.category&&$e.add(Kt.category),Kt.method&&Ke.add(Kt.method),Kt.name&&Kt.category==="tool"&&ye.add(Kt.name),Kt.name&&Kt.category==="resource"&&ve.add(Kt.name),Kt.name&&Kt.category==="prompt"&&Ae.add(Kt.name))});const Nt=lt=>Array.from(lt).sort((Mt,De)=>Mt.localeCompare(De));return{tool:Nt(ye),resource:Nt(ve),prompt:Nt(Ae),category:Nt($e),method:Nt(Ke)}},[k]),gt=p.useMemo(()=>k.some(ye=>{var ve;if(!ye)return!1;const Ae=ye.meta||{},$e=((ve=ye.raw)==null?void 0:ve.meta)||{},Ke=Ae.trace||$e.trace||{},Nt=Ae.mcp||$e.mcp||Ke.mcp,lt=Ae.protocol==="mcp"||$e.protocol==="mcp";return!!(Nt&&Object.keys(Nt).length||lt)}),[k]);if(!i||u&&!s.length||d&&!s.length||!s.length)return l.jsx(b2e,{supportsTraces:i,isTraceListLoading:u,traceList:s,traceListError:d});const ft=ye=>{_(ve=>{const Ae=new Set(ve);return Ae.has(ye)?Ae.delete(ye):Ae.add(ye),Ae})},kt=ye=>{var ve;if(!ye)return!1;const Ae=ye.meta||{},$e=((ve=ye.raw)==null?void 0:ve.meta)||{},Ke=Ae.trace||$e.trace||{},Nt=Ae.mcp||$e.mcp||Ke.mcp,lt=Ae.protocol==="mcp"||$e.protocol==="mcp";return!!(Nt&&Object.keys(Nt).length||lt)};return l.jsxs("div",{ref:U,className:"flex flex-col gap-4 lg:flex-row",style:{maxHeight:aw},children:[l.jsxs(Lt,{id:"trace-timeline",className:"w-full overflow-y-auto rounded-tremor-small border border-tremor-border p-6 dark:border-dark-tremor-border",style:{width:`${$}%`,maxHeight:aw},children:[l.jsx(h2e,{operationCount:Oe,onRefresh:ne,isRefreshing:W,hasError:!!f,traceSources:v,onOpenFilters:()=>ae(!0),activeFiltersCount:Ve}),l.jsxs("div",{className:"mt-6 flex flex-col gap-4 min-w-0",children:[l.jsx(g2e,{traceSummary:b,traceDurationMs:x,traceDetailMeta:m,traceListMeta:c,isTraceDetailLoading:h,operationCount:Oe,tokenTotals:Le}),f?l.jsxs(Lt,{className:"rounded-tremor-small border border-rose-200 bg-rose-50 p-4 text-sm text-rose-700 dark:border-rose-900 dark:bg-rose-900/20 dark:text-rose-300",children:["Failed to load trace details: ",f.message||"Unexpected error"]}):null,l.jsx("div",{className:"space-y-3",children:se.length?se.map(ye=>l.jsx(d2e,{group:ye,isExpanded:M.has(ye.id),onToggle:ft,selectedOperationId:j,onOperationSelect:E,timelineWidth:$,baseStart:fe,baseDuration:Y,selectedOperationRef:B},ye.id)):l.jsx(Lt,{className:"rounded-tremor-small border border-dashed border-tremor-border p-6 text-center text-sm text-tremor-content-subtle dark:border-dark-tremor-border dark:text-dark-tremor-content",children:"No operations recorded for this trace."})})]}),l.jsx(xj,{meta:m,currentPage:T,onPageChange:A,alwaysShow:!1})]}),l.jsx(f2e,{onMouseDown:()=>{V.current=!0},onDoubleClick:()=>{F(String(ow))}}),l.jsx(Lt,{id:"trace-details",className:"w-full overflow-y-auto rounded-tremor-small border border-tremor-border dark:border-dark-tremor-border",style:{width:`${100-$}%`,maxHeight:aw},children:kt(oe)?l.jsx(c2e,{operation:oe,isLoading:h}):l.jsx(RR,{operation:oe,isLoading:h})}),l.jsx(v2e,{isOpen:K,onClose:()=>ae(!1),filters:ee,setFilters:te,statusOptions:et,methodOptions:Ie,tagOptions:st,mcpToolOptions:xt.tool,mcpResourceOptions:xt.resource,mcpPromptOptions:xt.prompt,mcpCategoryOptions:xt.category,mcpMethodOptions:xt.method,hostOptions:nt,hasMcpOperations:gt,persistFilters:J,onPersistFiltersChange:ye=>R(ye?"true":"false")})]})}const E2e=e=>{if(!e)return null;try{return new URL(e)}catch{return null}},O2e=e=>{var t,r;if(!e)return null;const n=((t=e.raw)==null?void 0:t.data)||{},o=n.request||{},a=n.response||{},i=n.timing||{},s=(e.method||o.method||"GET").toUpperCase(),c=e.status_code??a.status??null,u=e.duration??i.duration,d=Number.isFinite(Number(u))?Number(u):null,f=e.time||o.timestamp||null,m=E2e(o.url||e.url||""),h=o.path||e.path||m?.pathname||o.url||e.url||"/",g=o.server||m?.host||"",b=Array.isArray((r=n.meta)==null?void 0:r.tags)?n.meta.tags:Array.isArray(e.tags)?e.tags:[],v=Pf(b);return{id:e.id,operationId:e.operation_id,method:s,status:c,duration:d,timestamp:f,timestampMs:f?Date.parse(f):null,path:h,host:g,url:o.url||e.url||"",request:o,response:a,timing:i,tags:v,raw:n}},S2e=e=>{if(!e)return"Unknown";const t=new Date(e);return Number.isNaN(t.getTime())?"Unknown":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})},d9=(e,t)=>`${e} ${t}`,Pd="trace",Ks="trace-timeline",il=["endpoint","list","table","timeline",Pd,Ks],C2e=il.indexOf(Pd),Gs=il.indexOf(Ks),HR=(e,t)=>e&&il.includes(e)?il.indexOf(e):t&&Gs>=0?Gs:0,P2e=()=>{if(typeof window>"u")return{tabIndex:0,traceId:null,traceOperationId:null};const{slug:e,params:t}=pi();if(e!=="insights")return{tabIndex:0,traceId:null,traceOperationId:null};const r=t.trace||null,n=t.traceOp||t.operation||null,o=t.view;return{tabIndex:HR(o,r),traceId:r,traceOperationId:n}};function A2e(){var e,t,r,n;const{client:o}=Tr(),a=p.useMemo(()=>P2e(),[]),[i,s]=p.useState(null),[c,u]=p.useState(null),[d,f]=p.useState(!1),[m,h]=p.useState({}),[g,b]=p.useState(a.tabIndex),[v,x]=p.useState({traceId:a.traceId,operationId:a.traceOperationId}),k=Gn(()=>Vr.db.events.orderBy("time").last(),[],null)||null,N=Gn(()=>Vr.db.events.orderBy("time").reverse().toArray(),[],[])||[],j=p.useMemo(()=>N.map(D=>O2e(D)).filter(Boolean).sort((D,R)=>(R.timestampMs||0)-(D.timestampMs||0)),[N]);p.useEffect(()=>{if(typeof window>"u")return;const D=()=>{const{slug:R,params:z}=pi();if(R!=="insights")return;const H=z.trace||null,$=z.traceOp||z.operation||null,V=z.view,U=HR(V,H);b(U),x(B=>B.traceId===H&&B.operationId===$?B:{traceId:H,operationId:$})};return D(),window.addEventListener("hashchange",D),()=>window.removeEventListener("hashchange",D)},[]);const E=(D={})=>{if(typeof window>"u")return;const{slug:R,params:z}=pi(),H=R==="insights"?{...z}:{};Object.entries(D).forEach(([B,X])=>{X==null||X===""?delete H[B]:H[B]=String(X)});const $=new URLSearchParams;Object.entries(H).forEach(([B,X])=>{X!=null&&$.set(B,X)});const V=$.toString(),U=`#insights${V?`?${V}`:""}`;typeof window<"u"&&window.location.hash!==U&&window.history.replaceState(null,"",U)},C=D=>{b(D);const R=il[D]||"endpoint",z=R===Pd||R===Ks;E({view:R,trace:z?v.traceId??null:null,traceOp:z?v.operationId??null:null})},S=D=>{const R=v.traceId===D,z={traceId:D||null,operationId:R?v.operationId:null};if(v.traceId===z.traceId&&v.operationId===z.operationId)return;x(z);const H=il[g],$=H===Pd||H===Ks;E({view:$?H:Ks,trace:z.traceId??null,traceOp:z.operationId??null}),!$&&Gs>=0&&b(Gs)},T=D=>{const R={traceId:v.traceId,operationId:D||null};if(v.traceId===R.traceId&&v.operationId===R.operationId)return;x(R);const z=il[g],H=z===Pd||z===Ks;E({view:H?z:Ks,trace:R.traceId??null,traceOp:R.operationId??null}),!H&&Gs>=0&&b(Gs)};p.useEffect(()=>{var D;if(!((D=o?.operations)!=null&&D.summarize))return;let R=!0;return(async()=>{f(!0),u(null);try{const z=await o.operations.summarize();R&&(s(z),h({}))}catch(z){R&&u(z)}finally{R&&f(!1)}})(),()=>{R=!1}},[o,k?.id]),p.useEffect(()=>{var D,R;if(!((D=o?.operations)!=null&&D.getSeries)||!((R=i?.summaries)!=null&&R.length))return;let z=!0;return(async()=>{const H=i.summaries;await Promise.all(H.map(async $=>{const V=d9($.method,$.path);h(U=>({...U,[V]:{...U[V]||{},loading:!0,error:null}}));try{const U=await o.operations.getSeries({method:$.method,path:$.path,seriesLimit:Pwe});if(!z)return;h(B=>({...B,[V]:{...B[V]||{},loading:!1,data:U,error:null}}))}catch(U){if(!z)return;h(B=>({...B,[V]:{...B[V]||{},loading:!1,error:U}}))}}))})(),()=>{z=!1}},[o,i?.summaries]);const A=p.useMemo(()=>{var D;return(D=i?.summaries)!=null&&D.length?i.summaries.map(R=>{var z;const H=d9(R.method,R.path),$=m[H]||{},V=(((z=$.data)==null?void 0:z.series)||[]).slice(-40).map(U=>({time:S2e(U.ts),duration:U.duration??0,baseline:U.baseline??R.averageDuration??0}));return{...R,key:H,chartData:V,seriesLoading:$.loading??!1,seriesError:$.error||null}}):[]},[i,m]),M=((e=i?.totals)==null?void 0:e.totalOperations)??j.length,_=(t=i?.totals)==null?void 0:t.totalEndpoints,I=(r=i?.totals)==null?void 0:r.errorCount,F=(n=i?.totals)==null?void 0:n.averageDuration;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs(Lt,{className:"rounded-tremor-small border border-tremor-border dark:border-dark-tremor-border",children:[l.jsxs(Cb,{justifyContent:"between",alignItems:"start",children:[l.jsxs("div",{children:[l.jsx(Xn,{className:"text-lg text-tremor-content-strong dark:text-dark-tremor-content-strong",children:"Insights Explorer"}),l.jsx(bt,{className:"mt-1 text-sm text-tremor-content dark:text-dark-tremor-content",children:"Get more insights into the operations by grouping them by endpoint, as time line view, as rich cards, or in a compact table"})]}),l.jsx(Wt,{color:c?"rose":"slate",children:d?"Loading…":`Total ${M}`})]}),l.jsxs(Pb,{numItemsSm:1,numItemsLg:3,className:"mt-6 gap-4",children:[l.jsxs(Lt,{className:"bg-gray-50 shadow-none dark:bg-dark-tremor-background",children:[l.jsx(bt,{className:"text-sm text-tremor-content dark:text-dark-tremor-content",children:"Unique endpoints"}),l.jsx(oi,{className:"mt-2",children:_})]}),l.jsxs(Lt,{className:"bg-gray-50 shadow-none dark:bg-dark-tremor-background",children:[l.jsx(bt,{className:"text-sm text-tremor-content dark:text-dark-tremor-content",children:"Errors"}),l.jsxs(oi,{className:"mt-2",children:[I," ",l.jsxs("span",{className:"text-base font-normal text-tremor-content-subtle dark:text-dark-tremor-content",children:["(",M?Math.round(I/M*100):0,"%)"]})]})]}),l.jsxs(Lt,{className:"bg-gray-50 shadow-none dark:bg-dark-tremor-background",children:[l.jsx(bt,{className:"text-sm text-tremor-content dark:text-dark-tremor-content",children:"Avg duration"}),l.jsx(oi,{className:"mt-2",children:F?`${F}ms`:"N/A"})]})]})]}),l.jsxs(tu,{index:g,onIndexChange:C,children:[l.jsxs(eu,{children:[l.jsx(yo,{children:"Endpoint mode"}),l.jsx(yo,{children:"List mode"}),l.jsx(yo,{children:"Table mode"}),l.jsx(yo,{children:"Timeline mode"}),l.jsx(yo,{children:"Trace explorer"}),l.jsx(yo,{children:"Trace timeline"})]}),l.jsxs(ru,{className:"mt-6 space-y-6",children:[l.jsx(xo,{children:l.jsx(Owe,{endpoints:A,loading:d,error:c})}),l.jsx(xo,{children:l.jsx(Awe,{operations:j})}),l.jsx(xo,{children:l.jsx(Uwe,{operations:j})}),l.jsx(xo,{children:l.jsx(Zwe,{operations:j})}),l.jsx(xo,{children:l.jsx(l2e,{operations:j,initialTraceId:v.traceId,initialOperationId:v.operationId,onTraceChange:S,onOperationChange:T,isActive:g===C2e})}),l.jsx(xo,{children:l.jsx(BR,{operations:j,initialTraceId:v.traceId,initialOperationId:v.operationId,onTraceChange:S,onOperationChange:T,isActive:g===Gs})})]})]})]})}const f9=(e,t)=>{let r="#traces";return e&&(r+=`/${e}`,t&&(r+=`/${t}`)),r},m9=e=>{e&&(window.location.hash===e?window.dispatchEvent(new HashChangeEvent("hashchange")):window.location.hash=e)};function T2e({route:e}){var t,r;const n=e?.operationId||((t=e?.params)==null?void 0:t.trace)||null,o=e?.subTab||((r=e?.params)==null?void 0:r.operation)||null,[a,i]=p.useState(n),[s,c]=p.useState(o),[u,d]=p.useState(o||null),f=p.useRef(a),m=p.useRef(s),h=p.useRef(u),g=p.useRef({traceId:n,operationId:o});p.useEffect(()=>{f.current=a},[a]),p.useEffect(()=>{m.current=s},[s]),p.useEffect(()=>{h.current=u},[u]),p.useEffect(()=>{const j=g.current;if(n!==j.traceId||o!==j.operationId){g.current={traceId:n,operationId:o},i(n||null),c(o||null),d(o||null);return}n!==a&&i(n||null),o!==s&&c(o||null),!h.current&&o&&d(o)},[n,o,a,s]);const b=p.useCallback(j=>{if(!j)return;i(j),j!==f.current&&(d(null),c(null),m.current=null);const E=f9(j,j===f.current?m.current:null);m9(E)},[]),v=p.useCallback(j=>{if(!j)return;c(j);const E=f.current;if(!E)return;h.current||d(j);const C=f9(E,j);m9(C)},[]),x=p.useMemo(()=>a||"—",[a]),k=h.current||o||m.current||"",N=k?`#inspectr/${k}/request`:"#inspectr";return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsxs("a",{href:N,className:"inline-flex items-center gap-2 rounded-md border border-slate-300 px-3 py-1.5 text-sm font-medium text-slate-700 transition hover:border-slate-400 hover:bg-slate-100 dark:border-slate-700 dark:text-slate-200 dark:hover:border-slate-600 dark:hover:bg-dark-tremor-background-subtle",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-4 w-4","aria-hidden":!0,children:l.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 1.06L4.56 9H16a.75.75 0 0 1 0 1.5H4.56l2.65 2.65a.75.75 0 0 1 0 1.06Z",clipRule:"evenodd"})}),"Back to request"]}),l.jsxs("div",{className:"text-xs font-medium uppercase tracking-wide text-slate-600 dark:text-slate-300",children:["Trace ",x]})]}),l.jsx(BR,{initialTraceId:n,initialOperationId:o,onTraceChange:b,onOperationChange:v,isActive:!0})]})}function M2e(){const{client:e,setToast:t}=Tr(),[r,n]=p.useState(!1),[o,a]=p.useState(""),[i,s]=p.useState(null),[c,u]=p.useState(!1),[d,f]=p.useState(null);p.useEffect(()=>{const b=new URLSearchParams(window.location.search).get("openapi");b&&(a(b),n(!0),m())},[]);const m=async()=>{try{const b=await e.service.getHealth();f(b.mode)}catch{}},h=()=>{c||n(!1)},g=async()=>{u(!0),s(null);try{await e.mock.launch(o),t({message:"Mock launched",subMessage:"Serving mock from OpenAPI spec",type:"success"}),n(!1)}catch(b){console.error("Mock launch error",b),s(b.message||"Failed to launch mock"),u(!1)}};return r?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:h}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-3xl w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Configure Inspectr Mock"}),l.jsx("button",{onClick:h,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",disabled:c,children:"×"})]}),d==="proxy"?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"mb-2 text-sm text-gray-700",children:"Inspectr lets you serve a mock API based on an OpenAPI spec."}),l.jsxs("div",{className:"mb-6 p-4 bg-yellow-50 border border-yellow-200 rounded",children:[l.jsxs("p",{className:"text-sm font-medium text-yellow-800",children:["Inspectr is currently running in ",l.jsx("strong",{children:"proxy"})," mode."]}),l.jsx("p",{className:"mt-2 text-sm text-yellow-800",children:"To switch to mock mode, restart Inspectr with:"}),l.jsxs("pre",{className:"mt-2 p-2 bg-gray-100 text-xs rounded overflow-auto",children:['npx @inspectr/inspectr --mock-backend="',o,'"']}),l.jsx(An,{textToCopy:`npx @inspectr/inspectr --mock-backend=${o}`})]}),l.jsx("p",{className:"mb-4 text-sm text-gray-700",children:"Follow the instructions above to start Inspectr as Mock server from the OpenAPI spec."}),l.jsx("div",{className:"flex justify-end",children:l.jsx("button",{onClick:h,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Cancel"})})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"mb-2 text-sm text-gray-700",children:"Inspectr lets you serve a mock API based on an OpenAPI spec."}),l.jsxs("p",{className:"mb-4 text-sm text-gray-700",children:["You’re about to use ",l.jsx("b",{children:o})," for mock responses. This will replace any existing mock configuration or catch-mode settings."]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{htmlFor:"openapi-url",className:"block text-sm font-medium text-gray-700",children:"OpenAPI Spec URL"}),l.jsx("input",{id:"openapi-url",type:"url",value:o,onChange:b=>{a(b.target.value),s(null)},placeholder:"https://example.com/openapi.yaml",disabled:c,className:"mt-1 block w-full rounded-md shadow-sm sm:text-sm "+(i?"border-red-500 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500")}),i&&l.jsx("p",{className:"mt-2 text-sm text-red-600",children:i})]}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:h,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",disabled:c,children:"Cancel"}),l.jsx("button",{onClick:g,className:`px-4 py-2 text-white rounded ${c?"bg-gray-400 cursor-not-allowed":"bg-red-600 hover:bg-red-700"}`,disabled:c,children:c?"Loading…":"Confirm"})]})]})]})]}):null}function _2e({open:e,onClose:t}){const{client:r,setToast:n}=Tr(),[o,a]=p.useState("json"),[i,s]=p.useState(!1),[c,u]=p.useState("preset"),[d,f]=p.useState(""),[m,h]=p.useState(""),[g,b]=p.useState(""),[v]=Oa("feat_export_openapi"),[x]=Oa("feat_export_postman"),[k,N]=p.useState("");p.useEffect(()=>{e||N("")},[e]);const j=async()=>{s(!0),N("");try{const E={format:o};c==="preset"?d&&(E.preset=d):(m&&(E.since=new Date(m).toISOString()),g&&(E.until=new Date(g).toISOString()));const C=await r.operations.export(E),S=new Date,T=D=>D.toString().padStart(2,"0"),A=`${S.getFullYear()}-${T(S.getMonth()+1)}-${T(S.getDate())}-${T(S.getHours())}${T(S.getMinutes())}`,M=URL.createObjectURL(C),_=document.createElement("a");_.href=M;const I=o==="phar"?"phar":"json",F=o==="json"?"":`_${o}`;_.download=`inspectr_operations_${A}${F}.${I}`,_.click(),URL.revokeObjectURL(M),t&&t()}catch(E){console.error("Export failed",E);const C=E?.message||"Export failed";N(C),n({message:"Export failed",subMessage:C,type:"error"})}finally{s(!1)}};return e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Export Operations"}),l.jsx("button",{onClick:t,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",children:"×"})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Time Range"}),l.jsxs("div",{className:"mt-1 flex items-center space-x-4",children:[l.jsxs("label",{className:"inline-flex items-center",children:[l.jsx("input",{type:"radio",name:"timeOption",value:"preset",checked:c==="preset",onChange:()=>u("preset"),className:"form-radio"}),l.jsx("span",{className:"ml-2",children:"Preset"})]}),l.jsxs("label",{className:"inline-flex items-center",children:[l.jsx("input",{type:"radio",name:"timeOption",value:"custom",checked:c==="custom",onChange:()=>u("custom"),className:"form-radio"}),l.jsx("span",{className:"ml-2",children:"Custom"})]})]}),c==="preset"&&l.jsxs("select",{value:d,onChange:E=>f(E.target.value),className:"mt-2 block w-full rounded-md border-gray-300 shadow-sm sm:text-sm",children:[l.jsx("option",{value:"",children:"-- Select preset --"}),l.jsx("option",{value:"1h",children:"Last hour"}),l.jsx("option",{value:"24h",children:"Last 24 hours"}),l.jsx("option",{value:"7d",children:"Last 7 days"}),l.jsx("option",{value:"30d",children:"Last 30 days"}),l.jsx("option",{value:"start",children:"Since start Inspectr"}),l.jsx("option",{value:"first",children:"Since first operation"})]}),c==="custom"&&l.jsxs("div",{className:"mt-2 space-y-2",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm",children:"Since"}),l.jsx("input",{type:"datetime-local",value:m,onChange:E=>h(E.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm sm:text-sm"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm",children:"Until (optional)"}),l.jsx("input",{type:"datetime-local",value:g,onChange:E=>b(E.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm sm:text-sm"})]})]})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Format"}),l.jsxs("select",{value:o,onChange:E=>a(E.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",children:[l.jsx("option",{value:"json",children:"JSON"}),v&&l.jsx("option",{value:"openapi",children:"OpenAPI (preview)"}),x&&l.jsx("option",{value:"postman",children:"Postman (preview)"})]})]}),k&&l.jsx("p",{className:"mb-4 text-sm text-red-600",role:"alert",children:k}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Cancel"}),l.jsx("button",{onClick:j,disabled:i,className:`px-4 py-2 text-white rounded ${i?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"}`,children:i?"Exporting…":"Export"})]})]})]}):null}function I2e({open:e,onClose:t,onContinue:r,onCancelRecording:n,startTime:o}){const{client:a,setToast:i}=Tr(),[s,c]=p.useState("json"),[u,d]=p.useState(!1),[f]=Oa("feat_export_openapi"),[m]=Oa("feat_export_postman"),[h,g]=p.useState(""),b=Gn(async()=>o?await Vr.db.events.where("time").above(o).count():0,[o]);p.useEffect(()=>{e||g("")},[e]);const v=async()=>{d(!0),g("");try{const x=await a.operations.export({since:o,format:s}),k=new Date,N=A=>A.toString().padStart(2,"0"),j=`${k.getFullYear()}-${N(k.getMonth()+1)}-${N(k.getDate())}-${N(k.getHours())}${N(k.getMinutes())}`,E=URL.createObjectURL(x),C=document.createElement("a");C.href=E;const S=s==="phar"?"phar":"json",T=s==="json"?"":`_${s}`;C.download=`inspectr_operations_${j}${T}.${S}`,C.click(),URL.revokeObjectURL(E),t&&t()}catch(x){console.error("Export failed",x);const k=x?.message||"Export failed";g(k),i({message:"Export failed",subMessage:k,type:"error"})}finally{d(!1)}};return e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-lg w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Export Recording"}),l.jsx("button",{onClick:t,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",children:"×"})]}),l.jsxs("p",{className:"text-sm mb-4",children:[b," operations recorded since ",new Date(o).toLocaleString()]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Format"}),l.jsxs("select",{value:s,onChange:x=>c(x.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",children:[l.jsx("option",{value:"json",children:"JSON"}),f&&l.jsx("option",{value:"openapi",children:"OpenAPI (preview)"}),m&&l.jsx("option",{value:"postman",children:"Postman (preview)"})]})]}),h&&l.jsx("p",{className:"-mt-2 mb-4 text-sm text-red-600",role:"alert",children:h}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:r,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Continue Recording"}),l.jsx("button",{onClick:n,className:"px-4 py-2 bg-orange-200 text-gray-700 rounded hover:bg-orange-300",children:"Cancel Recording"}),l.jsx("button",{onClick:v,disabled:u,className:`px-4 py-2 text-white rounded ${u?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"}`,children:u?"Exporting…":"Export"})]})]})]}):null}function D2e({open:e,onClose:t}){const{client:r,setToast:n}=Tr(),[o,a]=p.useState(null),[i,s]=p.useState(!1),c=async()=>{if(o){s(!0);try{await r.operations.import(o),n({message:"Import completed",type:"success"}),t&&t()}catch(u){console.error("Import failed",u),n({message:"Import failed",subMessage:u.message,type:"error"})}finally{s(!1)}}};return e?l.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[l.jsx("div",{className:"absolute inset-0 bg-black opacity-50",onClick:t}),l.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6 z-10",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Import Operations"}),l.jsx("button",{onClick:t,className:"text-gray-600 hover:text-gray-800","aria-label":"Close",children:"×"})]}),l.jsx("div",{className:"mb-4",children:l.jsx("input",{type:"file",accept:".json",onChange:u=>a(u.target.files[0]),className:"mt-1 block w-full text-sm"})}),l.jsxs("div",{className:"flex justify-end space-x-3",children:[l.jsx("button",{onClick:t,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300",children:"Cancel"}),l.jsx("button",{onClick:c,disabled:!o||i,className:`px-4 py-2 text-white rounded ${!o||i?"bg-gray-400":"bg-blue-600 hover:bg-blue-700"}`,children:i?"Importing…":"Import"})]})]})]}):null}const L2e="inspectrVersionMuteUntil",p9=3*24*60*60*1e3;function R2e(){const{client:e}=Tr(),[t,r]=_r(L2e,""),[n,o]=p.useState(!1),[a,i]=p.useState(!1),[s,c]=p.useState(null);p.useEffect(()=>{var g;if(!((g=e?.service)!=null&&g.getVersion))return;const b=t?Date.parse(t):0;if(b&&b>Date.now()){i(!1),o(!1);return}let v=!1;return e.service.getVersion().then(x=>{if(!v)if(c(x),x!=null&&x.update_available)i(!0);else{i(!1),o(!1);const k=new Date(Date.now()+p9).toISOString();r(k)}}).catch(x=>{console.error("Version check failed",x)}),()=>{v=!0}},[e,t]);const u=()=>{o(!1)},d=()=>{const g=new Date(Date.now()+p9).toISOString();r(g),i(!1),u()},f=()=>{d()},m=()=>{window.open("https://inspectr.dev/docs/getting-started/upgrade","_blank","noopener,noreferrer")},h=()=>{s!=null&&s.update_available&&o(!0)};return a?l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-center gap-2 rounded-md border border-amber-400 bg-amber-500 px-1 py-1 text-xs font-semibold text-white shadow-sm transition hover:bg-amber-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:ring-offset-2",children:[l.jsx("span",{className:"h-2 w-2 rounded-full bg-white/90 shadow-sm"}),l.jsx("span",{className:"uppercase tracking-wide",children:"Update available"})]}),l.jsx(ww,{show:n,as:p.Fragment,children:l.jsx(jm,{as:"div",className:"pointer-events-none fixed inset-x-0 top-6 z-40 flex justify-center px-4 sm:top-8",onClose:u,children:l.jsx(ww.Child,{as:p.Fragment,enter:"ease-out duration-200",enterFrom:"opacity-0 -translate-y-2",enterTo:"opacity-100 translate-y-0",leave:"ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-2",children:l.jsx(jm.Panel,{className:"pointer-events-auto relative w-full max-w-4xl overflow-hidden rounded-2xl border border-gray-200 bg-white p-6 shadow-xl dark:border-gray-800 dark:bg-gray-900",children:l.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:gap-6",children:[l.jsxs("div",{className:"flex items-start gap-3 sm:min-w-[220px]",children:[l.jsx("span",{className:"mt-1 flex h-12 w-12 items-center justify-center rounded-full bg-emerald-100 text-emerald-700 shadow-sm dark:bg-emerald-900/30 dark:text-emerald-200",children:l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M19.4668 8.69379L19.7134 8.12811C20.1529 7.11947 20.9445 6.31641 21.9323 5.87708L22.6919 5.53922C23.1027 5.35653 23.1027 4.75881 22.6919 4.57612L21.9748 4.25714C20.9616 3.80651 20.1558 2.97373 19.7238 1.93083L19.4706 1.31953C19.2942 0.893489 18.7058 0.893489 18.5293 1.31953L18.2761 1.93083C17.8442 2.97373 17.0384 3.80651 16.0252 4.25714L15.3081 4.57612C14.8973 4.75881 14.8973 5.35653 15.3081 5.53922L16.0677 5.87708C17.0555 6.31641 17.8471 7.11947 18.2866 8.12811L18.5331 8.69379C18.7136 9.10792 19.2864 9.10792 19.4668 8.69379ZM5 6C4.68525 6 4.38886 6.14819 4.2 6.4L1.2 10.4C0.913337 10.7822 0.937093 11.3138 1.25671 11.669L10.2567 21.669C10.4464 21.8797 10.7165 22 11 22C11.2835 22 11.5537 21.8797 11.7433 21.669L20.7433 11.669L19.2567 10.331L11 19.5052L3.29335 10.9422L5.5 8H14V6H5Z"})})}),l.jsxs("div",{className:"space-y-1",children:[l.jsx(jm.Title,{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"New Inspectr version available"}),l.jsx(jm.Description,{className:"text-sm text-gray-700 dark:text-gray-200",children:s!=null&&s.latest_version?`Update to ${s.latest_version} to get the latest improvements.`:"A new build is ready for you. Grab the latest to get new features."}),l.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Current: ",s?.current_version||"Unknown"," • Latest:"," ",s?.latest_version||"—"]})]})]}),l.jsxs("div",{className:"flex flex-1 flex-wrap items-center justify-end gap-3",children:[l.jsx("button",{type:"button",onClick:f,className:"inline-flex items-center justify-center rounded-full px-4 py-2 text-sm font-semibold text-gray-700 transition hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:text-gray-200 dark:hover:bg-gray-800",children:"Skip"}),l.jsx("button",{type:"button",onClick:m,className:"inline-flex items-center justify-center rounded-full bg-emerald-600 px-4 py-2 text-sm font-semibold text-white shadow-sm transition hover:bg-emerald-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:bg-emerald-500 dark:hover:bg-emerald-400",children:"Update"})]})]})})})})})]}):null}function qR(...e){return e.filter(Boolean).join(" ")}const F2e=[{name:"Request History",slug:"inspectr",component:fR},{name:"Trace Explorer",slug:"traces",component:T2e,hidden:!0},{name:"Insights",slug:"insights",component:A2e},{name:"Statistics",slug:"statistics",component:eke},{name:"Usage",slug:"usage",component:F0e},{name:"Rules",slug:"rules",component:rwe},{name:"Settings",slug:"settings",component:jwe}],$2e=e=>l.jsx("svg",{fill:"currentColor",height:"24",width:"24",viewBox:"0 0 1648 1648",xmlns:"http://www.w3.org/2000/svg",...e,children:l.jsx("path",{d:"m610 216.654c-66.158 4.092-126.119 35.849-164.917 87.346-8.408 11.16-13.344 19.191-19.983 32.513-12.431 24.946-19.521 50.434-22.11 79.487-1.665 18.687-.854 826.238.841 837.939 7.867 54.284 32.465 101.134 70.706 134.667 16.297 14.291 32.283 24.657 53.963 34.991 16.889 8.05 34.568 13.468 60.5 18.541 9.019 1.764 52.201 1.795 61.5.044 26.487-4.989 43.97-10.341 61-18.675 15.131-7.406 21.53-11.135 60.5-35.267 20.813-12.887 23.095-14.298 29.5-18.24l13-8 13-8c6.901-4.247 12.593-7.767 29.54-18.271 5.796-3.593 12.771-7.863 15.5-9.49 2.728-1.626 8.56-5.19 12.96-7.921 4.4-2.73 72.575-44.711 151.5-93.29s150.925-92.918 160-98.531c9.075-5.612 24.15-14.936 33.5-20.719s23.075-14.234 30.5-18.78c85.169-52.142 120.029-73.942 130.014-81.304 40.974-30.211 68.344-69.764 81.788-118.194 13.864-49.94 8.549-104.847-14.809-153-16.836-34.708-41.252-62.432-74.993-85.154-4.125-2.778-17.625-11.26-30-18.849s-27-16.594-32.5-20.009c-5.5-3.416-109.45-67.427-231-142.246-306.386-188.593-335.221-206.352-350-215.553-30.562-19.028-59.301-29.911-90-34.083-11.697-1.59-30.408-2.514-39.5-1.952m-10.5 77.269c-39.541 6.402-76.013 29.73-97.661 62.467-13.001 19.66-19.718 38.39-22.802 63.584-1.472 12.028-1.434 802.191.04 818.026 1.861 19.998 6.142 35.48 14.415 52.133 17.942 36.114 53.025 64.18 91.508 73.203 3.575.839 8.975 2.118 12 2.844 8.221 1.973 40.343 1.613 49.971-.56 32.301-7.289 65.233-26.686 94.817-55.849 15.26-15.042 22.884-24.803 33.571-42.979 13.939-23.706 20.949-43.36 27.745-77.792 1.004-5.086 1.428-50 1.949-206.5.465-139.686 1.001-201.809 1.777-206 .611-3.3 1.608-9.15 2.217-13 1.672-10.583 4.039-21.117 7.191-32 8.179-28.247 20.714-55.13 37.188-79.751 24.262-36.262 53.189-63.572 93.074-87.872 4.95-3.016 12.825-7.435 17.5-9.82s8.95-4.668 9.5-5.074c3.565-2.63 34.688-13.266 52.465-17.93 6.2-1.627 11.49-3.174 11.754-3.439 1.003-1.002-1.016-2.602-10.967-8.689-5.639-3.449-16.552-10.172-24.252-14.94-13.435-8.319-31.76-19.604-58.5-36.029-6.875-4.222-16.1-9.911-20.5-12.641-7.667-4.758-73.088-45.103-122.5-75.546-75.227-46.348-108.509-66.591-116.5-70.86-9.422-5.033-25.23-10.76-37.043-13.419-7.967-1.794-40.076-2.843-47.957-1.567m473.5 305.564c-5.775.685-11.625 1.491-13 1.792-1.375.3-5.2 1.088-8.5 1.749-7.914 1.587-27.103 7.461-36.5 11.174-38.797 15.33-75.171 44.925-98.829 80.41-11.24 16.86-21.329 38.407-26.167 55.888-2.443 8.825-3.85 14.608-4.866 20-.621 3.3-1.653 8.475-2.292 11.5-.846 4.008-1.345 59.624-1.837 205-.618 182.331-.824 200.361-2.399 209.5-1.629 9.459-4.196 22.506-6.744 34.279-.628 2.903-.881 5.54-.561 5.859.596.596 455.986-279.084 472.195-290.001 17.547-11.819 36.335-33.412 46.291-53.203 3.956-7.863 9.527-23.924 11.597-33.434 4.848-22.272 3.572-48.26-3.506-71.387-6.907-22.572-18.055-40.93-35.316-58.158-12.705-12.681-16.829-15.485-79.066-53.756-7.15-4.397-15.7-9.654-19-11.684-3.3-2.029-8.925-5.504-12.5-7.722-53.826-33.397-67.199-40.611-88.616-47.8-29.343-9.85-61.599-13.421-90.384-10.006m-1066.25 1048.256c3.988.189 10.513.189 14.5 0 3.988-.19.725-.346-7.25-.346s-11.238.156-7.25.346",fillRule:"evenodd"})});function tje(){const[e]=Oa("feat_insights_display",!1,!0);Oa("feat_export_mcp_server",!1,!0),Oa("feat_rules_ui",!1,!0);const t=p.useMemo(()=>{let j=F2e;return e!==!0&&(j=j.filter(E=>E.slug!=="insights")),j},[e]),[r,n]=p.useState(()=>t[0]),{route:o,currentNav:a,handleTabClick:i}=S0e(t),s=p.useMemo(()=>t.filter(j=>!j.hidden),[t]),c=a.component,[u,d]=p.useState(!1),[f,m]=p.useState(!1),[h,g]=_r("recordStart",null),[b,v]=p.useState(()=>!!h);p.useEffect(()=>{v(!!h)},[h]),p.useEffect(()=>{a&&n(a)},[a]);const[x,k]=p.useState(!1),N=Gn(async()=>!b||!h?0:await Vr.db.events.where("time").above(h).count(),[b,h]);return l.jsxs(eU,{children:[l.jsx(M2e,{}),l.jsxs("div",{className:"flex flex-col min-h-screen",children:[l.jsx("div",{className:"border-b border-tremor-border dark:border-dark-tremor-border relative h-full overflow-hidden bg-gray-50 dark:bg-dark-tremor-background-subtle",children:l.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:l.jsxs("div",{className:"overflow flex h-16 sm:space-x-7 items-center",children:[l.jsx("div",{className:"hidden shrink-0 sm:flex sm:items-center",children:l.jsx("a",{href:"/",className:"p-1.5",children:l.jsx($2e,{className:"size-4 shrink-0 w-8 h-8 text-tremor-content-strong dark:text-dark-tremor-content-strong","aria-hidden":!0})})}),l.jsx("nav",{className:"flex-1 -mb-px flex space-x-6","aria-label":"Tabs",children:s.map(j=>j.slug==="inspectr"?l.jsx(H2e,{navItem:j,isActive:j.slug===a.slug,onClick:()=>i(j),isCurrent:j.name===r.name},j.slug):l.jsx("button",{onClick:()=>i(j),className:qR(j.slug===a.slug?"dark:text-tremor-dark-brand border-tremor-brand text-tremor-brand":"border-transparent text-tremor-content-emphasis hover:border-tremor-content-subtle hover:text-tremor-content-strong dark:text-dark-tremor-content-emphasis hover:dark:border-dark-tremor-content-subtle hover:dark:text-dark-tremor-content-strong","inline-flex items-center whitespace-nowrap border-b-2 px-2 py-2 text-tremor-default font-medium"),"aria-current":j.name===r.name?"page":void 0,children:j.name},j.slug))}),l.jsxs("div",{className:"ml-auto flex items-center space-x-2",children:[l.jsx(R2e,{}),l.jsx("button",{className:"px-2 py-1 text-cyan-500 hover:text-white border border-cyan-500 hover:bg-cyan-500 rounded text-xs",onClick:()=>d(!0),children:"Export"}),l.jsx("button",{className:"px-2 py-1 text-cyan-500 hover:text-white border border-cyan-500 hover:bg-cyan-500 rounded text-xs",onClick:()=>m(!0),children:"Import"}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{disabled:x,className:`px-2 py-1 rounded text-xs flex items-center border border-green-500 ${b?"text-white bg-green-500":"text-green-500 hover:text-white hover:bg-green-500"} `,onClick:()=>{b?N>0?k(!0):(v(!1),g(null)):(g(new Date().toISOString()),v(!0))},children:[l.jsx("span",{className:`mr-1 block w-2 h-2 ${b?"bg-red-600 animate-pulse":"bg-red-600 rounded-full"}`}),b?"Stop Recording":"Start Recording"]}),b&&N>0&&l.jsx("span",{className:"absolute -top-3 -right-2",children:l.jsx(jR,{count:N})})]})]})]})})}),l.jsx("div",{className:"flex-grow overflow-auto",children:["insights","statistics","settings","usage","rules","traces"].includes(a.slug)?l.jsx("div",{className:"p-4 bg-gray-50 dark:bg-gray-950",children:l.jsx(c,{route:o},a.slug)}):l.jsx(fR,{route:o},"inspectr")}),l.jsx(B2e,{}),l.jsx(_2e,{open:u,onClose:()=>d(!1)}),l.jsx(D2e,{open:f,onClose:()=>m(!1)}),l.jsx(I2e,{open:x,onContinue:()=>{k(!1)},onCancelRecording:()=>{k(!1),v(!1),g(null)},onClose:()=>k(!1),startTime:h})]})]})}const B2e=()=>{const{toast:e,setToast:t}=Tr();return e?l.jsx(Jm,{message:e.message,subMessage:e.subMessage,type:e.type,onClose:()=>t(null)}):null},H2e=({navItem:e,isActive:t,onClick:r,isCurrent:n})=>{const{connectionStatus:o}=Tr(),[a,i]=_r("inspectrLastSeenAt",null),[s,c]=p.useState(()=>Ws(a)),u=Gn(async()=>{try{const h=await Vr.db.events.orderBy("time").last();return h?.time||null}catch{return null}},[]),d=Gn(async()=>{if(!s)return 0;try{return await Vr.db.events.where("time").above(s).count()}catch{return 0}},[s]);p.useEffect(()=>{const h=Ws(a);c(g=>{const b=Ws(g);return h?t||!b?h:fj(h,b)?b:h:b?g:null})},[a,t]);const f=o==="connected"?"green":o==="disconnected"?"red":"orange",m=()=>{const h=Ws(u)||new Date().toISOString();i(g=>{const b=Ws(g);return!b||fj(h,b)?h:b}),c(h),r&&r()};return l.jsxs("button",{onClick:m,className:qR(t?"dark:text-tremor-dark-brand border-tremor-brand text-tremor-brand":"border-transparent text-tremor-content-emphasis hover:border-tremor-content-subtle hover:text-tremor-content-strong dark:text-dark-tremor-content-emphasis hover:dark:border-dark-tremor-content-subtle hover:dark:text-dark-tremor-content-strong","inline-flex items-center whitespace-nowrap border-b-2 px-2 py-2 text-tremor-default font-medium relative"),"aria-current":n?"page":void 0,children:[e.name,!t&&d>0&&l.jsx("span",{className:"absolute -top-3 -right-2",children:l.jsx(jR,{count:d,color:f})})]},e.slug)};export{tje as Workspace};
|
package/dist/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en" data-astro-cid-sckkx6r4> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><link rel="icon" type="image/icon" href="/favicon.ico"><meta name="description" content="Inspectr – Simplifying API and Webhook debugging"><title>Inspectr</title><link rel="stylesheet" href="/_astro/index.ChLTQM78.css"></head> <body class="text-sm" data-astro-cid-sckkx6r4> <style>astro-island,astro-slot,astro-static-slot{display:contents}</style><script>(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event("astro:only"));})();</script><script>(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>1/0*t},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,"Component");d(this,"hydrator");d(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},h=this.querySelectorAll("template[data-astro-template]");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let p;try{p=this.hasAttribute("props")?m(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute("props"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});d(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[h,{default:p}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),u=this.getAttribute("component-export")||"default";if(!u.includes("."))this.Component=h[u];else{this.Component=h;for(let f of u.split("."))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(`[astro-island] Error hydrating ${this.getAttribute("component-url")}`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",y)}})();</script><astro-island uid="DTaCv" component-url="/_astro/ui.
|
|
1
|
+
<!DOCTYPE html><html lang="en" data-astro-cid-sckkx6r4> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><link rel="icon" type="image/icon" href="/favicon.ico"><meta name="description" content="Inspectr – Simplifying API and Webhook debugging"><title>Inspectr</title><link rel="stylesheet" href="/_astro/index.ChLTQM78.css"></head> <body class="text-sm" data-astro-cid-sckkx6r4> <style>astro-island,astro-slot,astro-static-slot{display:contents}</style><script>(()=>{var e=async t=>{await(await t())()};(self.Astro||(self.Astro={})).only=e;window.dispatchEvent(new Event("astro:only"));})();</script><script>(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>1/0*t},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,"Component");d(this,"hydrator");d(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},h=this.querySelectorAll("template[data-astro-template]");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let p;try{p=this.hasAttribute("props")?m(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=` (export ${v})`),console.error(`[hydrate] Error parsing props for component ${s}`,this.getAttribute("props"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});d(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(`astro:${c}`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[h,{default:p}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),u=this.getAttribute("component-export")||"default";if(!u.includes("."))this.Component=h[u];else{this.Component=h;for(let f of u.split("."))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(`[astro-island] Error hydrating ${this.getAttribute("component-url")}`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",y)}})();</script><astro-island uid="DTaCv" component-url="/_astro/ui.BAaZ1ViK.js" component-export="Workspace" renderer-url="/_astro/client.D2J0eG9e.js" props="{}" ssr client="only" opts="{"name":"Workspace","value":"react"}"></astro-island> </body></html>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@inspectr/app",
|
|
3
3
|
"description": "Standalone Inspectr app for inspecting API requests & Webhook events.",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "1.7.
|
|
5
|
+
"version": "1.7.1",
|
|
6
6
|
"author": "Tim Haselaars",
|
|
7
7
|
"homepage": "https://inspectr.dev",
|
|
8
8
|
"bugs": "https://github.com/inspectr-hq/inspectr-app/issues",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@astrojs/react": "^4.4.2",
|
|
50
|
-
"@inspectr/ui": "^1.7.
|
|
50
|
+
"@inspectr/ui": "^1.7.1",
|
|
51
51
|
"@tailwindcss/vite": "^4.1.3",
|
|
52
52
|
"@types/react": "^18.3.20",
|
|
53
53
|
"@types/react-dom": "^18.3.6",
|