import{c as fe,r as g,h as ka,i as Sa,t as se,q as $e,s as qt,g as _a,j as n,A as ce,k as O,S as qe,B as R,y as Ta,T as Vt,f as U,z as gt,D as vt,G as yt,p as ke,H as bt,J as wt,K as jt,M as Pa,I as Nt,N as Oa}from"./index-CVadajdu.js";import{C as Fa,e as _e,f as zt,u as Wa,a as Ea,P as Ya,b as Ia,c as Ra,d as La,Q as Aa}from"./QuickAccessCards-BzW1ADdW.js";import{F as Ha,D as Ba,T as $a,a as qa,b as pe,c as Va,f as We,d as za,e as Ee,C as Qt,g as Ve,S as Xt,u as Qa,h as Xa,i as Ga,j as Ka,k as Ua}from"./scroll-area-BztS27C7.js";import{C as ze,a as pt,b as Dt,d as Mt}from"./card-CsYbfw5u.js";import{R as Gt}from"./switch-mwVZiWJC.js";import{I as Qe,L as G}from"./label-BUE-Cnqf.js";import{S as Ja}from"./search-BGN3gvnC.js";import{S as Za}from"./skeleton-DuPMrAED.js";import{D as Xe,a as Kt,b as Ut,c as Jt,d as er,e as tr,f as Ct,P as ar,C as kt}from"./ConfirmDialog-ZeEptXE9.js";import{C as rr}from"./circle-x-C3nqej9T.js";import{Z as nr}from"./zap-CTbKT1PS.js";import"./index-Sp1L2CHJ.js";/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const sr=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],or=fe("CircleCheckBig",sr);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ir=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],St=fe("CircleCheck",ir);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const lr=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ge=fe("Database",lr);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const cr=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],dr=fe("Eye",cr);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ur=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ke=fe("Hash",ur);/**
 * @license lucide-react v0.479.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const mr=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],fr=fe("Timer",mr);function hr(e,a=500){const[t,r]=g.useState(e);return g.useEffect(()=>{const s=setTimeout(()=>{r(e)},a);return()=>{clearTimeout(s)}},[e,a]),t}function xr(){const e=ka();return Sa({mutationFn:a=>qt.traces.clearByProjectId(a),onSuccess:(a,t)=>{e.invalidateQueries({queryKey:$e.traces.byProject(t)}),e.invalidateQueries({queryKey:$e.projects.metrics(t)}),se.success("Project traces cleared",{description:"All traces for this project have been successfully cleared"})},onError:a=>{console.error("Failed to clear project traces:",a),se.error("Error clearing project traces",{description:"Could not clear the project traces"})}})}function gr(e,a){return{..._a({queryKey:$e.traces.byProjectWithOptions(e,a),queryFn:()=>qt.traces.getByProjectId(e,a),enabled:!!e,refetchInterval:5e3})}}function vr({debounceTimeout:e=500}={}){const[a,t]=g.useState(""),[r,s]=g.useState(!1),[o,i]=g.useState({status:[]}),l=hr(a,e),c=g.useMemo(()=>o.status.length>0||!!o.fromDate||!!o.toDate||o.minDuration!==void 0||o.maxDuration!==void 0,[o]),u=g.useCallback(()=>{s(!0)},[]),d=g.useCallback(m=>{i(m),s(!1)},[]),f=g.useCallback(()=>{i({status:[]}),t(""),s(!1)},[]);return{searchQuery:l,inputValue:a,setSearchQuery:t,filterModalOpen:r,openFilterModal:u,setFilterModalOpen:s,filters:o,handleApplyFilters:d,handleResetFilters:f,filtersActive:c}}function yr(e){const[a,t]=g.useState({}),r=g.useMemo(()=>Object.values(a).filter(Boolean).length,[a]),s=g.useCallback(l=>{if(l){const c={};e.forEach(u=>{c[u.id]=!0}),t(c)}else t({})},[e]),o=g.useCallback((l,c)=>{t(u=>({...u,[l]:c}))},[]),i=g.useCallback(()=>{t({})},[]);return{selectedTraces:a,selectedCount:r,handleSelectAll:s,handleSelectRow:o,resetSelection:i}}function br(e="desc"){const[a,t]=g.useState(e),[r,s]=g.useState([{id:"startTime",desc:e==="desc"}]),o=g.useCallback(()=>{const l=a==="desc"?"asc":"desc";t(l),s([{id:"startTime",desc:l==="desc"}])},[a]),i=g.useCallback(()=>{t(e),s([{id:"startTime",desc:e==="desc"}])},[e]);return{sortDirection:a,sorting:r,handleToggleSortDirection:o,setSorting:s,resetSort:i}}function wr(){const[e,a]=g.useState(!1),[t,r]=g.useState(null),s=g.useCallback(i=>{r(i),a(!0)},[]),o=g.useCallback(()=>{a(!1),r(null)},[]);return{isDetailSheetOpen:e,currentTraceDetail:t,openDetailSheet:s,closeDetailSheet:o,setIsDetailSheetOpen:a}}const Ze=6048e5,jr=864e5,De=43200,_t=1440,Tt=Symbol.for("constructDateFrom");function P(e,a){return typeof e=="function"?e(a):e&&typeof e=="object"&&Tt in e?e[Tt](a):e instanceof Date?new e.constructor(a):new Date(a)}function D(e,a){return P(a||e,e)}function F(e,a,t){const r=D(e,t==null?void 0:t.in);return isNaN(a)?P((t==null?void 0:t.in)||e,NaN):(a&&r.setDate(r.getDate()+a),r)}function H(e,a,t){const r=D(e,t==null?void 0:t.in);if(isNaN(a))return P((t==null?void 0:t.in)||e,NaN);if(!a)return r;const s=r.getDate(),o=P((t==null?void 0:t.in)||e,r.getTime());o.setMonth(r.getMonth()+a+1,0);const i=o.getDate();return s>=i?o:(r.setFullYear(o.getFullYear(),o.getMonth(),s),r)}let Nr={};function he(){return Nr}function q(e,a){var l,c,u,d;const t=he(),r=(a==null?void 0:a.weekStartsOn)??((c=(l=a==null?void 0:a.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??t.weekStartsOn??((d=(u=t.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=D(e,a==null?void 0:a.in),o=s.getDay(),i=(o<r?7:0)+o-r;return s.setDate(s.getDate()-i),s.setHours(0,0,0,0),s}function oe(e,a){return q(e,{...a,weekStartsOn:1})}function Zt(e,a){const t=D(e,a==null?void 0:a.in),r=t.getFullYear(),s=P(t,0);s.setFullYear(r+1,0,4),s.setHours(0,0,0,0);const o=oe(s),i=P(t,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const l=oe(i);return t.getTime()>=o.getTime()?r+1:t.getTime()>=l.getTime()?r:r-1}function de(e){const a=D(e),t=new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds()));return t.setUTCFullYear(a.getFullYear()),+e-+t}function J(e,...a){const t=P.bind(null,e||a.find(r=>typeof r=="object"));return a.map(t)}function ue(e,a){const t=D(e,a==null?void 0:a.in);return t.setHours(0,0,0,0),t}function $(e,a,t){const[r,s]=J(t==null?void 0:t.in,e,a),o=ue(r),i=ue(s),l=+o-de(o),c=+i-de(i);return Math.round((l-c)/jr)}function pr(e,a){const t=Zt(e,a),r=P(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),oe(r)}function Ue(e,a,t){return F(e,a*7,t)}function Dr(e,a,t){return H(e,a*12,t)}function Mr(e,a){let t,r=a==null?void 0:a.in;return e.forEach(s=>{!r&&typeof s=="object"&&(r=P.bind(null,s));const o=D(s,r);(!t||t<o||isNaN(+o))&&(t=o)}),P(r,t||NaN)}function Cr(e,a){let t,r=a==null?void 0:a.in;return e.forEach(s=>{!r&&typeof s=="object"&&(r=P.bind(null,s));const o=D(s,r);(!t||t>o||isNaN(+o))&&(t=o)}),P(r,t||NaN)}function Me(e,a){const t=+D(e)-+D(a);return t<0?-1:t>0?1:t}function kr(e){return P(e,Date.now())}function E(e,a,t){const[r,s]=J(t==null?void 0:t.in,e,a);return+ue(r)==+ue(s)}function et(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Sr(e){return!(!et(e)&&typeof e!="number"||isNaN(+D(e)))}function me(e,a,t){const[r,s]=J(t==null?void 0:t.in,e,a),o=r.getFullYear()-s.getFullYear(),i=r.getMonth()-s.getMonth();return o*12+i}function _r(e,a,t){const[r,s]=J(t==null?void 0:t.in,e,a),o=q(r,t),i=q(s,t),l=+o-de(o),c=+i-de(i);return Math.round((l-c)/Ze)}function Tr(e){return a=>{const r=(e?Math[e]:Math.trunc)(a);return r===0?0:r}}function Pr(e,a){return+D(e)-+D(a)}function Or(e,a){const t=D(e,a==null?void 0:a.in);return t.setHours(23,59,59,999),t}function Te(e,a){const t=D(e,a==null?void 0:a.in),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function Fr(e,a){const t=D(e,a==null?void 0:a.in);return+Or(t,a)==+Te(t,a)}function Wr(e,a,t){const[r,s,o]=J(t==null?void 0:t.in,e,e,a),i=Me(s,o),l=Math.abs(me(s,o));if(l<1)return 0;s.getMonth()===1&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-i*l);let c=Me(s,o)===-i;Fr(r)&&l===1&&Me(r,o)===1&&(c=!1);const u=i*(l-+c);return u===0?0:u}function Er(e,a,t){const r=Pr(e,a)/1e3;return Tr(t==null?void 0:t.roundingMethod)(r)}function Y(e,a){const t=D(e,a==null?void 0:a.in);return t.setDate(1),t.setHours(0,0,0,0),t}function ea(e,a){const t=D(e,a==null?void 0:a.in);return t.setFullYear(t.getFullYear(),0,1),t.setHours(0,0,0,0),t}function tt(e,a){var l,c,u,d;const t=he(),r=(a==null?void 0:a.weekStartsOn)??((c=(l=a==null?void 0:a.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??t.weekStartsOn??((d=(u=t.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=D(e,a==null?void 0:a.in),o=s.getDay(),i=(o<r?-7:0)+6-(o-r);return s.setDate(s.getDate()+i),s.setHours(23,59,59,999),s}function ta(e,a){return tt(e,{...a,weekStartsOn:1})}const Yr={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Ir=(e,a,t)=>{let r;const s=Yr[e];return typeof s=="string"?r=s:a===1?r=s.one:r=s.other.replace("{{count}}",a.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+r:r+" ago":r};function Ye(e){return(a={})=>{const t=a.width?String(a.width):e.defaultWidth;return e.formats[t]||e.formats[e.defaultWidth]}}const Rr={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Lr={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Ar={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Hr={date:Ye({formats:Rr,defaultWidth:"full"}),time:Ye({formats:Lr,defaultWidth:"full"}),dateTime:Ye({formats:Ar,defaultWidth:"full"})},Br={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},$r=(e,a,t,r)=>Br[e];function ve(e){return(a,t)=>{const r=t!=null&&t.context?String(t.context):"standalone";let s;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,l=t!=null&&t.width?String(t.width):i;s=e.formattingValues[l]||e.formattingValues[i]}else{const i=e.defaultWidth,l=t!=null&&t.width?String(t.width):e.defaultWidth;s=e.values[l]||e.values[i]}const o=e.argumentCallback?e.argumentCallback(a):a;return s[o]}}const qr={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Vr={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},zr={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Qr={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Xr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Gr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Kr=(e,a)=>{const t=Number(e),r=t%100;if(r>20||r<10)switch(r%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},Ur={ordinalNumber:Kr,era:ve({values:qr,defaultWidth:"wide"}),quarter:ve({values:Vr,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ve({values:zr,defaultWidth:"wide"}),day:ve({values:Qr,defaultWidth:"wide"}),dayPeriod:ve({values:Xr,defaultWidth:"wide",formattingValues:Gr,defaultFormattingWidth:"wide"})};function ye(e){return(a,t={})=>{const r=t.width,s=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=a.match(s);if(!o)return null;const i=o[0],l=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?Zr(l,f=>f.test(i)):Jr(l,f=>f.test(i));let u;u=e.valueCallback?e.valueCallback(c):c,u=t.valueCallback?t.valueCallback(u):u;const d=a.slice(i.length);return{value:u,rest:d}}}function Jr(e,a){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&a(e[t]))return t}function Zr(e,a){for(let t=0;t<e.length;t++)if(a(e[t]))return t}function en(e){return(a,t={})=>{const r=a.match(e.matchPattern);if(!r)return null;const s=r[0],o=a.match(e.parsePattern);if(!o)return null;let i=e.valueCallback?e.valueCallback(o[0]):o[0];i=t.valueCallback?t.valueCallback(i):i;const l=a.slice(s.length);return{value:i,rest:l}}}const tn=/^(\d+)(th|st|nd|rd)?/i,an=/\d+/i,rn={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},nn={any:[/^b/i,/^(a|c)/i]},sn={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},on={any:[/1/i,/2/i,/3/i,/4/i]},ln={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},cn={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},dn={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},un={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},mn={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},fn={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},hn={ordinalNumber:en({matchPattern:tn,parsePattern:an,valueCallback:e=>parseInt(e,10)}),era:ye({matchPatterns:rn,defaultMatchWidth:"wide",parsePatterns:nn,defaultParseWidth:"any"}),quarter:ye({matchPatterns:sn,defaultMatchWidth:"wide",parsePatterns:on,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ye({matchPatterns:ln,defaultMatchWidth:"wide",parsePatterns:cn,defaultParseWidth:"any"}),day:ye({matchPatterns:dn,defaultMatchWidth:"wide",parsePatterns:un,defaultParseWidth:"any"}),dayPeriod:ye({matchPatterns:mn,defaultMatchWidth:"any",parsePatterns:fn,defaultParseWidth:"any"})},at={code:"en-US",formatDistance:Ir,formatLong:Hr,formatRelative:$r,localize:Ur,match:hn,options:{weekStartsOn:0,firstWeekContainsDate:1}};function xn(e,a){const t=D(e,a==null?void 0:a.in);return $(t,ea(t))+1}function aa(e,a){const t=D(e,a==null?void 0:a.in),r=+oe(t)-+pr(t);return Math.round(r/Ze)+1}function ra(e,a){var d,f,m,h;const t=D(e,a==null?void 0:a.in),r=t.getFullYear(),s=he(),o=(a==null?void 0:a.firstWeekContainsDate)??((f=(d=a==null?void 0:a.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??s.firstWeekContainsDate??((h=(m=s.locale)==null?void 0:m.options)==null?void 0:h.firstWeekContainsDate)??1,i=P((a==null?void 0:a.in)||e,0);i.setFullYear(r+1,0,o),i.setHours(0,0,0,0);const l=q(i,a),c=P((a==null?void 0:a.in)||e,0);c.setFullYear(r,0,o),c.setHours(0,0,0,0);const u=q(c,a);return+t>=+l?r+1:+t>=+u?r:r-1}function gn(e,a){var l,c,u,d;const t=he(),r=(a==null?void 0:a.firstWeekContainsDate)??((c=(l=a==null?void 0:a.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??t.firstWeekContainsDate??((d=(u=t.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,s=ra(e,a),o=P((a==null?void 0:a.in)||e,0);return o.setFullYear(s,0,r),o.setHours(0,0,0,0),q(o,a)}function na(e,a){const t=D(e,a==null?void 0:a.in),r=+q(t,a)-+gn(t,a);return Math.round(r/Ze)+1}function C(e,a){const t=e<0?"-":"",r=Math.abs(e).toString().padStart(a,"0");return t+r}const K={y(e,a){const t=e.getFullYear(),r=t>0?t:1-t;return C(a==="yy"?r%100:r,a.length)},M(e,a){const t=e.getMonth();return a==="M"?String(t+1):C(t+1,2)},d(e,a){return C(e.getDate(),a.length)},a(e,a){const t=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(e,a){return C(e.getHours()%12||12,a.length)},H(e,a){return C(e.getHours(),a.length)},m(e,a){return C(e.getMinutes(),a.length)},s(e,a){return C(e.getSeconds(),a.length)},S(e,a){const t=a.length,r=e.getMilliseconds(),s=Math.trunc(r*Math.pow(10,t-3));return C(s,a.length)}},le={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Pt={G:function(e,a,t){const r=e.getFullYear()>0?1:0;switch(a){case"G":case"GG":case"GGG":return t.era(r,{width:"abbreviated"});case"GGGGG":return t.era(r,{width:"narrow"});case"GGGG":default:return t.era(r,{width:"wide"})}},y:function(e,a,t){if(a==="yo"){const r=e.getFullYear(),s=r>0?r:1-r;return t.ordinalNumber(s,{unit:"year"})}return K.y(e,a)},Y:function(e,a,t,r){const s=ra(e,r),o=s>0?s:1-s;if(a==="YY"){const i=o%100;return C(i,2)}return a==="Yo"?t.ordinalNumber(o,{unit:"year"}):C(o,a.length)},R:function(e,a){const t=Zt(e);return C(t,a.length)},u:function(e,a){const t=e.getFullYear();return C(t,a.length)},Q:function(e,a,t){const r=Math.ceil((e.getMonth()+1)/3);switch(a){case"Q":return String(r);case"QQ":return C(r,2);case"Qo":return t.ordinalNumber(r,{unit:"quarter"});case"QQQ":return t.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,a,t){const r=Math.ceil((e.getMonth()+1)/3);switch(a){case"q":return String(r);case"qq":return C(r,2);case"qo":return t.ordinalNumber(r,{unit:"quarter"});case"qqq":return t.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,a,t){const r=e.getMonth();switch(a){case"M":case"MM":return K.M(e,a);case"Mo":return t.ordinalNumber(r+1,{unit:"month"});case"MMM":return t.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(r,{width:"wide",context:"formatting"})}},L:function(e,a,t){const r=e.getMonth();switch(a){case"L":return String(r+1);case"LL":return C(r+1,2);case"Lo":return t.ordinalNumber(r+1,{unit:"month"});case"LLL":return t.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(r,{width:"wide",context:"standalone"})}},w:function(e,a,t,r){const s=na(e,r);return a==="wo"?t.ordinalNumber(s,{unit:"week"}):C(s,a.length)},I:function(e,a,t){const r=aa(e);return a==="Io"?t.ordinalNumber(r,{unit:"week"}):C(r,a.length)},d:function(e,a,t){return a==="do"?t.ordinalNumber(e.getDate(),{unit:"date"}):K.d(e,a)},D:function(e,a,t){const r=xn(e);return a==="Do"?t.ordinalNumber(r,{unit:"dayOfYear"}):C(r,a.length)},E:function(e,a,t){const r=e.getDay();switch(a){case"E":case"EE":case"EEE":return t.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(r,{width:"short",context:"formatting"});case"EEEE":default:return t.day(r,{width:"wide",context:"formatting"})}},e:function(e,a,t,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(a){case"e":return String(o);case"ee":return C(o,2);case"eo":return t.ordinalNumber(o,{unit:"day"});case"eee":return t.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(s,{width:"short",context:"formatting"});case"eeee":default:return t.day(s,{width:"wide",context:"formatting"})}},c:function(e,a,t,r){const s=e.getDay(),o=(s-r.weekStartsOn+8)%7||7;switch(a){case"c":return String(o);case"cc":return C(o,a.length);case"co":return t.ordinalNumber(o,{unit:"day"});case"ccc":return t.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(s,{width:"narrow",context:"standalone"});case"cccccc":return t.day(s,{width:"short",context:"standalone"});case"cccc":default:return t.day(s,{width:"wide",context:"standalone"})}},i:function(e,a,t){const r=e.getDay(),s=r===0?7:r;switch(a){case"i":return String(s);case"ii":return C(s,a.length);case"io":return t.ordinalNumber(s,{unit:"day"});case"iii":return t.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(r,{width:"short",context:"formatting"});case"iiii":default:return t.day(r,{width:"wide",context:"formatting"})}},a:function(e,a,t){const s=e.getHours()/12>=1?"pm":"am";switch(a){case"a":case"aa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(e,a,t){const r=e.getHours();let s;switch(r===12?s=le.noon:r===0?s=le.midnight:s=r/12>=1?"pm":"am",a){case"b":case"bb":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(e,a,t){const r=e.getHours();let s;switch(r>=17?s=le.evening:r>=12?s=le.afternoon:r>=4?s=le.morning:s=le.night,a){case"B":case"BB":case"BBB":return t.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(e,a,t){if(a==="ho"){let r=e.getHours()%12;return r===0&&(r=12),t.ordinalNumber(r,{unit:"hour"})}return K.h(e,a)},H:function(e,a,t){return a==="Ho"?t.ordinalNumber(e.getHours(),{unit:"hour"}):K.H(e,a)},K:function(e,a,t){const r=e.getHours()%12;return a==="Ko"?t.ordinalNumber(r,{unit:"hour"}):C(r,a.length)},k:function(e,a,t){let r=e.getHours();return r===0&&(r=24),a==="ko"?t.ordinalNumber(r,{unit:"hour"}):C(r,a.length)},m:function(e,a,t){return a==="mo"?t.ordinalNumber(e.getMinutes(),{unit:"minute"}):K.m(e,a)},s:function(e,a,t){return a==="so"?t.ordinalNumber(e.getSeconds(),{unit:"second"}):K.s(e,a)},S:function(e,a){return K.S(e,a)},X:function(e,a,t){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(a){case"X":return Ft(r);case"XXXX":case"XX":return ne(r);case"XXXXX":case"XXX":default:return ne(r,":")}},x:function(e,a,t){const r=e.getTimezoneOffset();switch(a){case"x":return Ft(r);case"xxxx":case"xx":return ne(r);case"xxxxx":case"xxx":default:return ne(r,":")}},O:function(e,a,t){const r=e.getTimezoneOffset();switch(a){case"O":case"OO":case"OOO":return"GMT"+Ot(r,":");case"OOOO":default:return"GMT"+ne(r,":")}},z:function(e,a,t){const r=e.getTimezoneOffset();switch(a){case"z":case"zz":case"zzz":return"GMT"+Ot(r,":");case"zzzz":default:return"GMT"+ne(r,":")}},t:function(e,a,t){const r=Math.trunc(+e/1e3);return C(r,a.length)},T:function(e,a,t){return C(+e,a.length)}};function Ot(e,a=""){const t=e>0?"-":"+",r=Math.abs(e),s=Math.trunc(r/60),o=r%60;return o===0?t+String(s):t+String(s)+a+C(o,2)}function Ft(e,a){return e%60===0?(e>0?"-":"+")+C(Math.abs(e)/60,2):ne(e,a)}function ne(e,a=""){const t=e>0?"-":"+",r=Math.abs(e),s=C(Math.trunc(r/60),2),o=C(r%60,2);return t+s+a+o}const Wt=(e,a)=>{switch(e){case"P":return a.date({width:"short"});case"PP":return a.date({width:"medium"});case"PPP":return a.date({width:"long"});case"PPPP":default:return a.date({width:"full"})}},sa=(e,a)=>{switch(e){case"p":return a.time({width:"short"});case"pp":return a.time({width:"medium"});case"ppp":return a.time({width:"long"});case"pppp":default:return a.time({width:"full"})}},vn=(e,a)=>{const t=e.match(/(P+)(p+)?/)||[],r=t[1],s=t[2];if(!s)return Wt(e,a);let o;switch(r){case"P":o=a.dateTime({width:"short"});break;case"PP":o=a.dateTime({width:"medium"});break;case"PPP":o=a.dateTime({width:"long"});break;case"PPPP":default:o=a.dateTime({width:"full"});break}return o.replace("{{date}}",Wt(r,a)).replace("{{time}}",sa(s,a))},yn={p:sa,P:vn},bn=/^D+$/,wn=/^Y+$/,jn=["D","DD","YY","YYYY"];function Nn(e){return bn.test(e)}function pn(e){return wn.test(e)}function Dn(e,a,t){const r=Mn(e,a,t);if(console.warn(r),jn.includes(e))throw new RangeError(r)}function Mn(e,a,t){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${a}\`) for formatting ${r} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Cn=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,kn=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Sn=/^'([^]*?)'?$/,_n=/''/g,Tn=/[a-zA-Z]/;function T(e,a,t){var d,f,m,h,x,v,y,p;const r=he(),s=(t==null?void 0:t.locale)??r.locale??at,o=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((h=(m=r.locale)==null?void 0:m.options)==null?void 0:h.firstWeekContainsDate)??1,i=(t==null?void 0:t.weekStartsOn)??((v=(x=t==null?void 0:t.locale)==null?void 0:x.options)==null?void 0:v.weekStartsOn)??r.weekStartsOn??((p=(y=r.locale)==null?void 0:y.options)==null?void 0:p.weekStartsOn)??0,l=D(e,t==null?void 0:t.in);if(!Sr(l))throw new RangeError("Invalid time value");let c=a.match(kn).map(b=>{const M=b[0];if(M==="p"||M==="P"){const k=yn[M];return k(b,s.formatLong)}return b}).join("").match(Cn).map(b=>{if(b==="''")return{isToken:!1,value:"'"};const M=b[0];if(M==="'")return{isToken:!1,value:Pn(b)};if(Pt[M])return{isToken:!0,value:b};if(M.match(Tn))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:b}});s.localize.preprocessor&&(c=s.localize.preprocessor(l,c));const u={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return c.map(b=>{if(!b.isToken)return b.value;const M=b.value;(!(t!=null&&t.useAdditionalWeekYearTokens)&&pn(M)||!(t!=null&&t.useAdditionalDayOfYearTokens)&&Nn(M))&&Dn(M,a,String(e));const k=Pt[M[0]];return k(l,M,s.localize,u)}).join("")}function Pn(e){const a=e.match(Sn);return a?a[1].replace(_n,"'"):e}function On(e,a,t){const r=he(),s=(t==null?void 0:t.locale)??r.locale??at,o=2520,i=Me(e,a);if(isNaN(i))throw new RangeError("Invalid time value");const l=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:i}),[c,u]=J(t==null?void 0:t.in,...i>0?[a,e]:[e,a]),d=Er(u,c),f=(de(u)-de(c))/1e3,m=Math.round((d-f)/60);let h;if(m<2)return t!=null&&t.includeSeconds?d<5?s.formatDistance("lessThanXSeconds",5,l):d<10?s.formatDistance("lessThanXSeconds",10,l):d<20?s.formatDistance("lessThanXSeconds",20,l):d<40?s.formatDistance("halfAMinute",0,l):d<60?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",1,l):m===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",m,l);if(m<45)return s.formatDistance("xMinutes",m,l);if(m<90)return s.formatDistance("aboutXHours",1,l);if(m<_t){const x=Math.round(m/60);return s.formatDistance("aboutXHours",x,l)}else{if(m<o)return s.formatDistance("xDays",1,l);if(m<De){const x=Math.round(m/_t);return s.formatDistance("xDays",x,l)}else if(m<De*2)return h=Math.round(m/De),s.formatDistance("aboutXMonths",h,l)}if(h=Wr(u,c),h<12){const x=Math.round(m/De);return s.formatDistance("xMonths",x,l)}else{const x=h%12,v=Math.trunc(h/12);return x<3?s.formatDistance("aboutXYears",v,l):x<9?s.formatDistance("overXYears",v,l):s.formatDistance("almostXYears",v+1,l)}}function Fn(e,a){return On(e,kr(e),a)}function Wn(e,a){const t=D(e,a==null?void 0:a.in),r=t.getFullYear(),s=t.getMonth(),o=P(t,0);return o.setFullYear(r,s+1,0),o.setHours(0,0,0,0),o.getDate()}function En(e){return Math.trunc(+D(e)/1e3)}function Yn(e,a){const t=D(e,a==null?void 0:a.in),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),D(t,a==null?void 0:a.in)}function In(e,a){const t=D(e,a==null?void 0:a.in);return _r(Yn(t,a),Y(t,a),a)+1}function Je(e,a){return+D(e)>+D(a)}function oa(e,a){return+D(e)<+D(a)}function rt(e,a,t){const[r,s]=J(t==null?void 0:t.in,e,a);return r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()}function Rn(e,a,t){const[r,s]=J(t==null?void 0:t.in,e,a);return r.getFullYear()===s.getFullYear()}function Ie(e,a,t){return F(e,-a,t)}function Re(e,a,t){const r=D(e,t==null?void 0:t.in),s=r.getFullYear(),o=r.getDate(),i=P(e,0);i.setFullYear(s,a,15),i.setHours(0,0,0,0);const l=Wn(i);return r.setMonth(a,Math.min(o,l)),r}function Et(e,a,t){const r=D(e,t==null?void 0:t.in);return isNaN(+r)?P(e,NaN):(r.setFullYear(a),r)}function Ln({sortDirection:e,onToggleSortDirection:a,displayedTraceCount:t,isLoading:r,onRefresh:s}){return n.jsxs("div",{className:"flex items-center justify-between p-6 pb-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ce,{className:"h-5 w-5 text-blue-600"}),n.jsx("h3",{className:"text-xl font-semibold text-gray-900",children:"Traces"})]}),n.jsx("p",{className:"text-sm text-gray-600",children:r?"Loading traces...":t!==void 0?n.jsxs(n.Fragment,{children:[t," trace",t!==1?"s":""," found",t>0&&n.jsxs("span",{className:"ml-2 text-xs text-gray-500",children:["• Last updated ",Fn(new Date,{addSuffix:!0})]})]}):"Traces"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(O,{variant:"outline",size:"sm",onClick:a,className:"border-gray-200 hover:bg-gray-50",children:["Sort ",e==="desc"?"↓":"↑"]}),n.jsxs(O,{variant:"outline",size:"sm",onClick:s,className:"border-gray-200 hover:bg-gray-50",disabled:r,children:[n.jsx(Gt,{className:`h-4 w-4 mr-2 ${r?"animate-spin":""}`}),"Refresh"]})]})]})}function An({searchQuery:e,onSearchQueryChange:a,onOpenFilterModal:t,selectedCount:r,onDeleteSelected:s,onExportSelected:o,onCopySelected:i,isLoading:l}){return n.jsxs("div",{className:"flex items-center justify-between gap-4 px-6 py-4 border-t border-gray-100",children:[n.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[n.jsxs("div",{className:"relative flex-1 max-w-sm",children:[n.jsx(Ja,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4"}),n.jsx(Qe,{placeholder:"Search traces...",value:e,onChange:c=>a(c.target.value),className:"pl-10 border-gray-200 focus:border-blue-500 focus:ring-blue-500",disabled:l})]}),n.jsxs(O,{variant:"outline",size:"sm",onClick:t,className:"border-gray-200 hover:bg-gray-50",disabled:l,children:[n.jsx(Ha,{className:"h-4 w-4 mr-2"}),"Filter"]})]}),r>0&&n.jsxs(n.Fragment,{children:[n.jsx(qe,{orientation:"vertical",className:"h-6"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(R,{variant:"secondary",className:"text-sm",children:[r," selected"]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(O,{variant:"outline",size:"sm",onClick:i,className:"border-gray-200 hover:bg-gray-50",children:[n.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Copy"]}),n.jsxs(O,{variant:"outline",size:"sm",onClick:o,className:"border-gray-200 hover:bg-gray-50",children:[n.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Export"]}),n.jsxs(O,{variant:"outline",size:"sm",onClick:s,className:"border-red-200 text-red-600 hover:bg-red-50",children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})]})}function Hn({table:e,columns:a,isLoading:t,isError:r,traces:s,selectedTraces:o,isFiltered:i,onRetry:l,onClearFilters:c}){var u;return r?n.jsx("div",{className:"border-t border-gray-100",children:n.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6",children:[n.jsx(Fa,{className:"h-12 w-12 text-red-400 mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Error loading traces"}),n.jsx("p",{className:"text-sm text-gray-500 mb-4 text-center",children:"There was a problem loading the traces. Please try again."}),n.jsxs(O,{onClick:l,variant:"outline",children:[n.jsx(Gt,{className:"h-4 w-4 mr-2"}),"Try Again"]})]})}):n.jsx("div",{className:"border-t border-gray-100",children:n.jsxs($a,{children:[n.jsx(qa,{children:e.getHeaderGroups().map(d=>n.jsx(pe,{className:"border-b border-gray-100 bg-gray-50/50",children:d.headers.map(f=>n.jsx(Va,{className:"font-semibold text-gray-700 py-4",children:f.isPlaceholder?null:f.column.getCanSort()?n.jsxs(O,{variant:"ghost",onClick:f.column.getToggleSortingHandler(),className:"-ml-4 h-auto p-0 hover:bg-transparent font-semibold text-gray-700 hover:text-gray-900",children:[We(f.column.columnDef.header,f.getContext()),f.column.getIsSorted()==="asc"&&" ↑",f.column.getIsSorted()==="desc"&&" ↓"]}):We(f.column.columnDef.header,f.getContext())},f.id))},d.id))}),n.jsx(za,{children:t?(s.length>0?s:Array.from({length:5})).map((d,f)=>n.jsx(pe,{className:"border-b border-gray-50",children:a.map((m,h)=>n.jsx(Ee,{className:"py-6",children:n.jsx(Za,{className:"h-4 w-full"})},h))},f)):(u=e.getRowModel().rows)!=null&&u.length?e.getRowModel().rows.map((d,f)=>n.jsx(pe,{"data-state":o[d.original.id]?"selected":void 0,className:`
                  ${f%2===0?"bg-white/60":"bg-gray-50/60"} 
                  ${o[d.original.id]?"bg-gradient-to-r from-blue-50/80 to-blue-100/60 border-l-4 border-blue-500 shadow-sm":""}
                  hover:bg-gradient-to-r hover:from-blue-50/70 hover:to-blue-100/50 hover:shadow-md hover:scale-[1.01] transition-all duration-300 border-b border-gray-200/60
                  data-[state=selected]:bg-gradient-to-r data-[state=selected]:from-blue-50/80 data-[state=selected]:to-blue-100/60
                  cursor-pointer
                `,children:d.getVisibleCells().map(m=>n.jsx(Ee,{className:"py-5 px-6 text-gray-900",style:{width:m.column.getSize()!==150?m.column.getSize():void 0},children:We(m.column.columnDef.cell,m.getContext())},m.id))},d.id)):n.jsx(pe,{children:n.jsx(Ee,{colSpan:a.length,className:"h-32 text-center",children:n.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[n.jsx(ce,{className:"h-12 w-12 text-gray-300"}),n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium text-gray-900",children:i?"No traces match your filters":"No traces found"}),n.jsx("p",{className:"text-xs text-gray-500",children:i?"Try adjusting your search or filters":"Traces will appear here when they are created"})]}),i&&n.jsx(O,{variant:"outline",size:"sm",onClick:c,children:"Clear filters"})]})})})})]})})}function Bn({currentPage:e,hasNextPage:a,onPrevPage:t,onNextPage:r,isLoading:s,currentTraceCount:o,pageSize:i}){const l=e>0,c=a&&!s;return n.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-gray-100",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs("div",{className:"text-sm text-gray-600",children:["Page ",n.jsx("span",{className:"font-medium",children:e+1})]}),o>0&&n.jsxs("div",{className:"text-xs text-gray-500",children:["Showing ",o," traces"]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(O,{variant:"outline",size:"sm",onClick:t,disabled:!l||s,className:"border-gray-200 hover:bg-gray-50 disabled:opacity-50",children:[n.jsx(Qt,{className:"h-4 w-4 mr-1"}),"Previous"]}),n.jsxs(O,{variant:"outline",size:"sm",onClick:r,disabled:!c,className:"border-gray-200 hover:bg-gray-50 disabled:opacity-50",children:["Next",n.jsx(_e,{className:"h-4 w-4 ml-1"})]})]})]})}var N=function(){return N=Object.assign||function(a){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(a[o]=t[o])}return a},N.apply(this,arguments)};function $n(e,a){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&a.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)a.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(t[r[s]]=e[r[s]]);return t}function ia(e,a,t){for(var r=0,s=a.length,o;r<s;r++)(o||!(r in a))&&(o||(o=Array.prototype.slice.call(a,0,r)),o[r]=a[r]);return e.concat(o||Array.prototype.slice.call(a))}function be(e){return e.mode==="multiple"}function we(e){return e.mode==="range"}function Pe(e){return e.mode==="single"}var qn={root:"rdp",multiple_months:"rdp-multiple_months",with_weeknumber:"rdp-with_weeknumber",vhidden:"rdp-vhidden",button_reset:"rdp-button_reset",button:"rdp-button",caption:"rdp-caption",caption_start:"rdp-caption_start",caption_end:"rdp-caption_end",caption_between:"rdp-caption_between",caption_label:"rdp-caption_label",caption_dropdowns:"rdp-caption_dropdowns",dropdown:"rdp-dropdown",dropdown_month:"rdp-dropdown_month",dropdown_year:"rdp-dropdown_year",dropdown_icon:"rdp-dropdown_icon",months:"rdp-months",month:"rdp-month",table:"rdp-table",tbody:"rdp-tbody",tfoot:"rdp-tfoot",head:"rdp-head",head_row:"rdp-head_row",head_cell:"rdp-head_cell",nav:"rdp-nav",nav_button:"rdp-nav_button",nav_button_previous:"rdp-nav_button_previous",nav_button_next:"rdp-nav_button_next",nav_icon:"rdp-nav_icon",row:"rdp-row",weeknumber:"rdp-weeknumber",cell:"rdp-cell",day:"rdp-day",day_today:"rdp-day_today",day_outside:"rdp-day_outside",day_selected:"rdp-day_selected",day_disabled:"rdp-day_disabled",day_hidden:"rdp-day_hidden",day_range_start:"rdp-day_range_start",day_range_end:"rdp-day_range_end",day_range_middle:"rdp-day_range_middle"};function Vn(e,a){return T(e,"LLLL y",a)}function zn(e,a){return T(e,"d",a)}function Qn(e,a){return T(e,"LLLL",a)}function Xn(e){return"".concat(e)}function Gn(e,a){return T(e,"cccccc",a)}function Kn(e,a){return T(e,"yyyy",a)}var Un=Object.freeze({__proto__:null,formatCaption:Vn,formatDay:zn,formatMonthCaption:Qn,formatWeekNumber:Xn,formatWeekdayName:Gn,formatYearCaption:Kn}),Jn=function(e,a,t){return T(e,"do MMMM (EEEE)",t)},Zn=function(){return"Month: "},es=function(){return"Go to next month"},ts=function(){return"Go to previous month"},as=function(e,a){return T(e,"cccc",a)},rs=function(e){return"Week n. ".concat(e)},ns=function(){return"Year: "},ss=Object.freeze({__proto__:null,labelDay:Jn,labelMonthDropdown:Zn,labelNext:es,labelPrevious:ts,labelWeekNumber:rs,labelWeekday:as,labelYearDropdown:ns});function os(){var e="buttons",a=qn,t=at,r={},s={},o=1,i={},l=new Date;return{captionLayout:e,classNames:a,formatters:Un,labels:ss,locale:t,modifiersClassNames:r,modifiers:s,numberOfMonths:o,styles:i,today:l,mode:"default"}}function is(e){var a=e.fromYear,t=e.toYear,r=e.fromMonth,s=e.toMonth,o=e.fromDate,i=e.toDate;return r?o=Y(r):a&&(o=new Date(a,0,1)),s?i=Te(s):t&&(i=new Date(t,11,31)),{fromDate:o?ue(o):void 0,toDate:i?ue(i):void 0}}var la=g.createContext(void 0);function ls(e){var a,t=e.initialProps,r=os(),s=is(t),o=s.fromDate,i=s.toDate,l=(a=t.captionLayout)!==null&&a!==void 0?a:r.captionLayout;l!=="buttons"&&(!o||!i)&&(l="buttons");var c;(Pe(t)||be(t)||we(t))&&(c=t.onSelect);var u=N(N(N({},r),t),{captionLayout:l,classNames:N(N({},r.classNames),t.classNames),components:N({},t.components),formatters:N(N({},r.formatters),t.formatters),fromDate:o,labels:N(N({},r.labels),t.labels),mode:t.mode||r.mode,modifiers:N(N({},r.modifiers),t.modifiers),modifiersClassNames:N(N({},r.modifiersClassNames),t.modifiersClassNames),onSelect:c,styles:N(N({},r.styles),t.styles),toDate:i});return n.jsx(la.Provider,{value:u,children:e.children})}function S(){var e=g.useContext(la);if(!e)throw new Error("useDayPicker must be used within a DayPickerProvider.");return e}function ca(e){var a=S(),t=a.locale,r=a.classNames,s=a.styles,o=a.formatters.formatCaption;return n.jsx("div",{className:r.caption_label,style:s.caption_label,"aria-live":"polite",role:"presentation",id:e.id,children:o(e.displayMonth,{locale:t})})}function cs(e){return n.jsx("svg",N({width:"8px",height:"8px",viewBox:"0 0 120 120","data-testid":"iconDropdown"},e,{children:n.jsx("path",{d:"M4.22182541,48.2218254 C8.44222828,44.0014225 15.2388494,43.9273804 19.5496459,47.9996989 L19.7781746,48.2218254 L60,88.443 L100.221825,48.2218254 C104.442228,44.0014225 111.238849,43.9273804 115.549646,47.9996989 L115.778175,48.2218254 C119.998577,52.4422283 120.07262,59.2388494 116.000301,63.5496459 L115.778175,63.7781746 L67.7781746,111.778175 C63.5577717,115.998577 56.7611506,116.07262 52.4503541,112.000301 L52.2218254,111.778175 L4.22182541,63.7781746 C-0.0739418023,59.4824074 -0.0739418023,52.5175926 4.22182541,48.2218254 Z",fill:"currentColor",fillRule:"nonzero"})}))}function da(e){var a,t,r=e.onChange,s=e.value,o=e.children,i=e.caption,l=e.className,c=e.style,u=S(),d=(t=(a=u.components)===null||a===void 0?void 0:a.IconDropdown)!==null&&t!==void 0?t:cs;return n.jsxs("div",{className:l,style:c,children:[n.jsx("span",{className:u.classNames.vhidden,children:e["aria-label"]}),n.jsx("select",{name:e.name,"aria-label":e["aria-label"],className:u.classNames.dropdown,style:u.styles.dropdown,value:s,onChange:r,children:o}),n.jsxs("div",{className:u.classNames.caption_label,style:u.styles.caption_label,"aria-hidden":"true",children:[i,n.jsx(d,{className:u.classNames.dropdown_icon,style:u.styles.dropdown_icon})]})]})}function ds(e){var a,t=S(),r=t.fromDate,s=t.toDate,o=t.styles,i=t.locale,l=t.formatters.formatMonthCaption,c=t.classNames,u=t.components,d=t.labels.labelMonthDropdown;if(!r)return n.jsx(n.Fragment,{});if(!s)return n.jsx(n.Fragment,{});var f=[];if(Rn(r,s))for(var m=Y(r),h=r.getMonth();h<=s.getMonth();h++)f.push(Re(m,h));else for(var m=Y(new Date),h=0;h<=11;h++)f.push(Re(m,h));var x=function(y){var p=Number(y.target.value),b=Re(Y(e.displayMonth),p);e.onChange(b)},v=(a=u==null?void 0:u.Dropdown)!==null&&a!==void 0?a:da;return n.jsx(v,{name:"months","aria-label":d(),className:c.dropdown_month,style:o.dropdown_month,onChange:x,value:e.displayMonth.getMonth(),caption:l(e.displayMonth,{locale:i}),children:f.map(function(y){return n.jsx("option",{value:y.getMonth(),children:l(y,{locale:i})},y.getMonth())})})}function us(e){var a,t=e.displayMonth,r=S(),s=r.fromDate,o=r.toDate,i=r.locale,l=r.styles,c=r.classNames,u=r.components,d=r.formatters.formatYearCaption,f=r.labels.labelYearDropdown,m=[];if(!s)return n.jsx(n.Fragment,{});if(!o)return n.jsx(n.Fragment,{});for(var h=s.getFullYear(),x=o.getFullYear(),v=h;v<=x;v++)m.push(Et(ea(new Date),v));var y=function(b){var M=Et(Y(t),Number(b.target.value));e.onChange(M)},p=(a=u==null?void 0:u.Dropdown)!==null&&a!==void 0?a:da;return n.jsx(p,{name:"years","aria-label":f(),className:c.dropdown_year,style:l.dropdown_year,onChange:y,value:t.getFullYear(),caption:d(t,{locale:i}),children:m.map(function(b){return n.jsx("option",{value:b.getFullYear(),children:d(b,{locale:i})},b.getFullYear())})})}function ms(e,a){var t=g.useState(e),r=t[0],s=t[1],o=a===void 0?r:a;return[o,s]}function fs(e){var a=e.month,t=e.defaultMonth,r=e.today,s=a||t||r||new Date,o=e.toDate,i=e.fromDate,l=e.numberOfMonths,c=l===void 0?1:l;if(o&&me(o,s)<0){var u=-1*(c-1);s=H(o,u)}return i&&me(s,i)<0&&(s=i),Y(s)}function hs(){var e=S(),a=fs(e),t=ms(a,e.month),r=t[0],s=t[1],o=function(i){var l;if(!e.disableNavigation){var c=Y(i);s(c),(l=e.onMonthChange)===null||l===void 0||l.call(e,c)}};return[r,o]}function xs(e,a){for(var t=a.reverseMonths,r=a.numberOfMonths,s=Y(e),o=Y(H(s,r)),i=me(o,s),l=[],c=0;c<i;c++){var u=H(s,c);l.push(u)}return t&&(l=l.reverse()),l}function gs(e,a){if(!a.disableNavigation){var t=a.toDate,r=a.pagedNavigation,s=a.numberOfMonths,o=s===void 0?1:s,i=r?o:1,l=Y(e);if(!t)return H(l,i);var c=me(t,e);if(!(c<o))return H(l,i)}}function vs(e,a){if(!a.disableNavigation){var t=a.fromDate,r=a.pagedNavigation,s=a.numberOfMonths,o=s===void 0?1:s,i=r?o:1,l=Y(e);if(!t)return H(l,-i);var c=me(l,t);if(!(c<=0))return H(l,-i)}}var ua=g.createContext(void 0);function ys(e){var a=S(),t=hs(),r=t[0],s=t[1],o=xs(r,a),i=gs(r,a),l=vs(r,a),c=function(f){return o.some(function(m){return rt(f,m)})},u=function(f,m){c(f)||(m&&oa(f,m)?s(H(f,1+a.numberOfMonths*-1)):s(f))},d={currentMonth:r,displayMonths:o,goToMonth:s,goToDate:u,previousMonth:l,nextMonth:i,isDateDisplayed:c};return n.jsx(ua.Provider,{value:d,children:e.children})}function je(){var e=g.useContext(ua);if(!e)throw new Error("useNavigation must be used within a NavigationProvider");return e}function Yt(e){var a,t=S(),r=t.classNames,s=t.styles,o=t.components,i=je().goToMonth,l=function(d){i(H(d,e.displayIndex?-e.displayIndex:0))},c=(a=o==null?void 0:o.CaptionLabel)!==null&&a!==void 0?a:ca,u=n.jsx(c,{id:e.id,displayMonth:e.displayMonth});return n.jsxs("div",{className:r.caption_dropdowns,style:s.caption_dropdowns,children:[n.jsx("div",{className:r.vhidden,children:u}),n.jsx(ds,{onChange:l,displayMonth:e.displayMonth}),n.jsx(us,{onChange:l,displayMonth:e.displayMonth})]})}function bs(e){return n.jsx("svg",N({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.jsx("path",{d:"M69.490332,3.34314575 C72.6145263,0.218951416 77.6798462,0.218951416 80.8040405,3.34314575 C83.8617626,6.40086786 83.9268205,11.3179931 80.9992143,14.4548388 L80.8040405,14.6568542 L35.461,60 L80.8040405,105.343146 C83.8617626,108.400868 83.9268205,113.317993 80.9992143,116.454839 L80.8040405,116.656854 C77.7463184,119.714576 72.8291931,119.779634 69.6923475,116.852028 L69.490332,116.656854 L18.490332,65.6568542 C15.4326099,62.5991321 15.367552,57.6820069 18.2951583,54.5451612 L18.490332,54.3431458 L69.490332,3.34314575 Z",fill:"currentColor",fillRule:"nonzero"})}))}function ws(e){return n.jsx("svg",N({width:"16px",height:"16px",viewBox:"0 0 120 120"},e,{children:n.jsx("path",{d:"M49.8040405,3.34314575 C46.6798462,0.218951416 41.6145263,0.218951416 38.490332,3.34314575 C35.4326099,6.40086786 35.367552,11.3179931 38.2951583,14.4548388 L38.490332,14.6568542 L83.8333725,60 L38.490332,105.343146 C35.4326099,108.400868 35.367552,113.317993 38.2951583,116.454839 L38.490332,116.656854 C41.5480541,119.714576 46.4651794,119.779634 49.602025,116.852028 L49.8040405,116.656854 L100.804041,65.6568542 C103.861763,62.5991321 103.926821,57.6820069 100.999214,54.5451612 L100.804041,54.3431458 L49.8040405,3.34314575 Z",fill:"currentColor"})}))}var Se=g.forwardRef(function(e,a){var t=S(),r=t.classNames,s=t.styles,o=[r.button_reset,r.button];e.className&&o.push(e.className);var i=o.join(" "),l=N(N({},s.button_reset),s.button);return e.style&&Object.assign(l,e.style),n.jsx("button",N({},e,{ref:a,type:"button",className:i,style:l}))});function js(e){var a,t,r=S(),s=r.dir,o=r.locale,i=r.classNames,l=r.styles,c=r.labels,u=c.labelPrevious,d=c.labelNext,f=r.components;if(!e.nextMonth&&!e.previousMonth)return n.jsx(n.Fragment,{});var m=u(e.previousMonth,{locale:o}),h=[i.nav_button,i.nav_button_previous].join(" "),x=d(e.nextMonth,{locale:o}),v=[i.nav_button,i.nav_button_next].join(" "),y=(a=f==null?void 0:f.IconRight)!==null&&a!==void 0?a:ws,p=(t=f==null?void 0:f.IconLeft)!==null&&t!==void 0?t:bs;return n.jsxs("div",{className:i.nav,style:l.nav,children:[!e.hidePrevious&&n.jsx(Se,{name:"previous-month","aria-label":m,className:h,style:l.nav_button_previous,disabled:!e.previousMonth,onClick:e.onPreviousClick,children:s==="rtl"?n.jsx(y,{className:i.nav_icon,style:l.nav_icon}):n.jsx(p,{className:i.nav_icon,style:l.nav_icon})}),!e.hideNext&&n.jsx(Se,{name:"next-month","aria-label":x,className:v,style:l.nav_button_next,disabled:!e.nextMonth,onClick:e.onNextClick,children:s==="rtl"?n.jsx(p,{className:i.nav_icon,style:l.nav_icon}):n.jsx(y,{className:i.nav_icon,style:l.nav_icon})})]})}function It(e){var a=S().numberOfMonths,t=je(),r=t.previousMonth,s=t.nextMonth,o=t.goToMonth,i=t.displayMonths,l=i.findIndex(function(x){return rt(e.displayMonth,x)}),c=l===0,u=l===i.length-1,d=a>1&&(c||!u),f=a>1&&(u||!c),m=function(){r&&o(r)},h=function(){s&&o(s)};return n.jsx(js,{displayMonth:e.displayMonth,hideNext:d,hidePrevious:f,nextMonth:s,previousMonth:r,onPreviousClick:m,onNextClick:h})}function Ns(e){var a,t=S(),r=t.classNames,s=t.disableNavigation,o=t.styles,i=t.captionLayout,l=t.components,c=(a=l==null?void 0:l.CaptionLabel)!==null&&a!==void 0?a:ca,u;return s?u=n.jsx(c,{id:e.id,displayMonth:e.displayMonth}):i==="dropdown"?u=n.jsx(Yt,{displayMonth:e.displayMonth,id:e.id}):i==="dropdown-buttons"?u=n.jsxs(n.Fragment,{children:[n.jsx(Yt,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),n.jsx(It,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):u=n.jsxs(n.Fragment,{children:[n.jsx(c,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(It,{displayMonth:e.displayMonth,id:e.id})]}),n.jsx("div",{className:r.caption,style:o.caption,children:u})}function ps(e){var a=S(),t=a.footer,r=a.styles,s=a.classNames.tfoot;return t?n.jsx("tfoot",{className:s,style:r.tfoot,children:n.jsx("tr",{children:n.jsx("td",{colSpan:8,children:t})})}):n.jsx(n.Fragment,{})}function Ds(e,a,t){for(var r=t?oe(new Date):q(new Date,{locale:e,weekStartsOn:a}),s=[],o=0;o<7;o++){var i=F(r,o);s.push(i)}return s}function Ms(){var e=S(),a=e.classNames,t=e.styles,r=e.showWeekNumber,s=e.locale,o=e.weekStartsOn,i=e.ISOWeek,l=e.formatters.formatWeekdayName,c=e.labels.labelWeekday,u=Ds(s,o,i);return n.jsxs("tr",{style:t.head_row,className:a.head_row,children:[r&&n.jsx("td",{style:t.head_cell,className:a.head_cell}),u.map(function(d,f){return n.jsx("th",{scope:"col",className:a.head_cell,style:t.head_cell,"aria-label":c(d,{locale:s}),children:l(d,{locale:s})},f)})]})}function Cs(){var e,a=S(),t=a.classNames,r=a.styles,s=a.components,o=(e=s==null?void 0:s.HeadRow)!==null&&e!==void 0?e:Ms;return n.jsx("thead",{style:r.head,className:t.head,children:n.jsx(o,{})})}function ks(e){var a=S(),t=a.locale,r=a.formatters.formatDay;return n.jsx(n.Fragment,{children:r(e.date,{locale:t})})}var nt=g.createContext(void 0);function Ss(e){if(!be(e.initialProps)){var a={selected:void 0,modifiers:{disabled:[]}};return n.jsx(nt.Provider,{value:a,children:e.children})}return n.jsx(_s,{initialProps:e.initialProps,children:e.children})}function _s(e){var a=e.initialProps,t=e.children,r=a.selected,s=a.min,o=a.max,i=function(u,d,f){var m,h;(m=a.onDayClick)===null||m===void 0||m.call(a,u,d,f);var x=!!(d.selected&&s&&(r==null?void 0:r.length)===s);if(!x){var v=!!(!d.selected&&o&&(r==null?void 0:r.length)===o);if(!v){var y=r?ia([],r):[];if(d.selected){var p=y.findIndex(function(b){return E(u,b)});y.splice(p,1)}else y.push(u);(h=a.onSelect)===null||h===void 0||h.call(a,y,u,d,f)}}},l={disabled:[]};r&&l.disabled.push(function(u){var d=o&&r.length>o-1,f=r.some(function(m){return E(m,u)});return!!(d&&!f)});var c={selected:r,onDayClick:i,modifiers:l};return n.jsx(nt.Provider,{value:c,children:t})}function st(){var e=g.useContext(nt);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function Ts(e,a){var t=a||{},r=t.from,s=t.to;return r&&s?E(s,e)&&E(r,e)?void 0:E(s,e)?{from:s,to:void 0}:E(r,e)?void 0:Je(r,e)?{from:e,to:s}:{from:r,to:e}:s?Je(e,s)?{from:s,to:e}:{from:e,to:s}:r?oa(e,r)?{from:e,to:r}:{from:r,to:e}:{from:e,to:void 0}}var ot=g.createContext(void 0);function Ps(e){if(!we(e.initialProps)){var a={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return n.jsx(ot.Provider,{value:a,children:e.children})}return n.jsx(Os,{initialProps:e.initialProps,children:e.children})}function Os(e){var a=e.initialProps,t=e.children,r=a.selected,s=r||{},o=s.from,i=s.to,l=a.min,c=a.max,u=function(h,x,v){var y,p;(y=a.onDayClick)===null||y===void 0||y.call(a,h,x,v);var b=Ts(h,r);(p=a.onSelect)===null||p===void 0||p.call(a,b,h,x,v)},d={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(d.range_start=[o],i?(d.range_end=[i],E(o,i)||(d.range_middle=[{after:o,before:i}])):d.range_end=[o]):i&&(d.range_start=[i],d.range_end=[i]),l&&(o&&!i&&d.disabled.push({after:Ie(o,l-1),before:F(o,l-1)}),o&&i&&d.disabled.push({after:o,before:F(o,l-1)}),!o&&i&&d.disabled.push({after:Ie(i,l-1),before:F(i,l-1)})),c){if(o&&!i&&(d.disabled.push({before:F(o,-c+1)}),d.disabled.push({after:F(o,c-1)})),o&&i){var f=$(i,o)+1,m=c-f;d.disabled.push({before:Ie(o,m)}),d.disabled.push({after:F(i,m)})}!o&&i&&(d.disabled.push({before:F(i,-c+1)}),d.disabled.push({after:F(i,c-1)}))}return n.jsx(ot.Provider,{value:{selected:r,onDayClick:u,modifiers:d},children:t})}function it(){var e=g.useContext(ot);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function Ce(e){return Array.isArray(e)?ia([],e):e!==void 0?[e]:[]}function Fs(e){var a={};return Object.entries(e).forEach(function(t){var r=t[0],s=t[1];a[r]=Ce(s)}),a}var B;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(B||(B={}));var Ws=B.Selected,z=B.Disabled,Es=B.Hidden,Ys=B.Today,Le=B.RangeEnd,Ae=B.RangeMiddle,He=B.RangeStart,Is=B.Outside;function Rs(e,a,t){var r,s=(r={},r[Ws]=Ce(e.selected),r[z]=Ce(e.disabled),r[Es]=Ce(e.hidden),r[Ys]=[e.today],r[Le]=[],r[Ae]=[],r[He]=[],r[Is]=[],r);return e.fromDate&&s[z].push({before:e.fromDate}),e.toDate&&s[z].push({after:e.toDate}),be(e)?s[z]=s[z].concat(a.modifiers[z]):we(e)&&(s[z]=s[z].concat(t.modifiers[z]),s[He]=t.modifiers[He],s[Ae]=t.modifiers[Ae],s[Le]=t.modifiers[Le]),s}var ma=g.createContext(void 0);function Ls(e){var a=S(),t=st(),r=it(),s=Rs(a,t,r),o=Fs(a.modifiers),i=N(N({},s),o);return n.jsx(ma.Provider,{value:i,children:e.children})}function fa(){var e=g.useContext(ma);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function As(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function Hs(e){return!!(e&&typeof e=="object"&&"from"in e)}function Bs(e){return!!(e&&typeof e=="object"&&"after"in e)}function $s(e){return!!(e&&typeof e=="object"&&"before"in e)}function qs(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function Vs(e,a){var t,r=a.from,s=a.to;if(r&&s){var o=$(s,r)<0;o&&(t=[s,r],r=t[0],s=t[1]);var i=$(e,r)>=0&&$(s,e)>=0;return i}return s?E(s,e):r?E(r,e):!1}function zs(e){return et(e)}function Qs(e){return Array.isArray(e)&&e.every(et)}function Xs(e,a){return a.some(function(t){if(typeof t=="boolean")return t;if(zs(t))return E(e,t);if(Qs(t))return t.includes(e);if(Hs(t))return Vs(e,t);if(qs(t))return t.dayOfWeek.includes(e.getDay());if(As(t)){var r=$(t.before,e),s=$(t.after,e),o=r>0,i=s<0,l=Je(t.before,t.after);return l?i&&o:o||i}return Bs(t)?$(e,t.after)>0:$s(t)?$(t.before,e)>0:typeof t=="function"?t(e):!1})}function lt(e,a,t){var r=Object.keys(a).reduce(function(o,i){var l=a[i];return Xs(e,l)&&o.push(i),o},[]),s={};return r.forEach(function(o){return s[o]=!0}),t&&!rt(e,t)&&(s.outside=!0),s}function Gs(e,a){for(var t=Y(e[0]),r=Te(e[e.length-1]),s,o,i=t;i<=r;){var l=lt(i,a),c=!l.disabled&&!l.hidden;if(!c){i=F(i,1);continue}if(l.selected)return i;l.today&&!o&&(o=i),s||(s=i),i=F(i,1)}return o||s}var Ks=365;function ha(e,a){var t=a.moveBy,r=a.direction,s=a.context,o=a.modifiers,i=a.retry,l=i===void 0?{count:0,lastFocused:e}:i,c=s.weekStartsOn,u=s.fromDate,d=s.toDate,f=s.locale,m={day:F,week:Ue,month:H,year:Dr,startOfWeek:function(y){return s.ISOWeek?oe(y):q(y,{locale:f,weekStartsOn:c})},endOfWeek:function(y){return s.ISOWeek?ta(y):tt(y,{locale:f,weekStartsOn:c})}},h=m[t](e,r==="after"?1:-1);r==="before"&&u?h=Mr([u,h]):r==="after"&&d&&(h=Cr([d,h]));var x=!0;if(o){var v=lt(h,o);x=!v.disabled&&!v.hidden}return x?h:l.count>Ks?l.lastFocused:ha(h,{moveBy:t,direction:r,context:s,modifiers:o,retry:N(N({},l),{count:l.count+1})})}var xa=g.createContext(void 0);function Us(e){var a=je(),t=fa(),r=g.useState(),s=r[0],o=r[1],i=g.useState(),l=i[0],c=i[1],u=Gs(a.displayMonths,t),d=s??(l&&a.isDateDisplayed(l))?l:u,f=function(){c(s),o(void 0)},m=function(y){o(y)},h=S(),x=function(y,p){if(s){var b=ha(s,{moveBy:y,direction:p,context:h,modifiers:t});E(s,b)||(a.goToDate(b,s),m(b))}},v={focusedDay:s,focusTarget:d,blur:f,focus:m,focusDayAfter:function(){return x("day","after")},focusDayBefore:function(){return x("day","before")},focusWeekAfter:function(){return x("week","after")},focusWeekBefore:function(){return x("week","before")},focusMonthBefore:function(){return x("month","before")},focusMonthAfter:function(){return x("month","after")},focusYearBefore:function(){return x("year","before")},focusYearAfter:function(){return x("year","after")},focusStartOfWeek:function(){return x("startOfWeek","before")},focusEndOfWeek:function(){return x("endOfWeek","after")}};return n.jsx(xa.Provider,{value:v,children:e.children})}function ct(){var e=g.useContext(xa);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function Js(e,a){var t=fa(),r=lt(e,t,a);return r}var dt=g.createContext(void 0);function Zs(e){if(!Pe(e.initialProps)){var a={selected:void 0};return n.jsx(dt.Provider,{value:a,children:e.children})}return n.jsx(eo,{initialProps:e.initialProps,children:e.children})}function eo(e){var a=e.initialProps,t=e.children,r=function(o,i,l){var c,u,d;if((c=a.onDayClick)===null||c===void 0||c.call(a,o,i,l),i.selected&&!a.required){(u=a.onSelect)===null||u===void 0||u.call(a,void 0,o,i,l);return}(d=a.onSelect)===null||d===void 0||d.call(a,o,o,i,l)},s={selected:a.selected,onDayClick:r};return n.jsx(dt.Provider,{value:s,children:t})}function ga(){var e=g.useContext(dt);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function to(e,a){var t=S(),r=ga(),s=st(),o=it(),i=ct(),l=i.focusDayAfter,c=i.focusDayBefore,u=i.focusWeekAfter,d=i.focusWeekBefore,f=i.blur,m=i.focus,h=i.focusMonthBefore,x=i.focusMonthAfter,v=i.focusYearBefore,y=i.focusYearAfter,p=i.focusStartOfWeek,b=i.focusEndOfWeek,M=function(j){var w,I,ge,ie;Pe(t)?(w=r.onDayClick)===null||w===void 0||w.call(r,e,a,j):be(t)?(I=s.onDayClick)===null||I===void 0||I.call(s,e,a,j):we(t)?(ge=o.onDayClick)===null||ge===void 0||ge.call(o,e,a,j):(ie=t.onDayClick)===null||ie===void 0||ie.call(t,e,a,j)},k=function(j){var w;m(e),(w=t.onDayFocus)===null||w===void 0||w.call(t,e,a,j)},L=function(j){var w;f(),(w=t.onDayBlur)===null||w===void 0||w.call(t,e,a,j)},A=function(j){var w;(w=t.onDayMouseEnter)===null||w===void 0||w.call(t,e,a,j)},V=function(j){var w;(w=t.onDayMouseLeave)===null||w===void 0||w.call(t,e,a,j)},Q=function(j){var w;(w=t.onDayPointerEnter)===null||w===void 0||w.call(t,e,a,j)},Z=function(j){var w;(w=t.onDayPointerLeave)===null||w===void 0||w.call(t,e,a,j)},ee=function(j){var w;(w=t.onDayTouchCancel)===null||w===void 0||w.call(t,e,a,j)},Oe=function(j){var w;(w=t.onDayTouchEnd)===null||w===void 0||w.call(t,e,a,j)},X=function(j){var w;(w=t.onDayTouchMove)===null||w===void 0||w.call(t,e,a,j)},te=function(j){var w;(w=t.onDayTouchStart)===null||w===void 0||w.call(t,e,a,j)},Fe=function(j){var w;(w=t.onDayKeyUp)===null||w===void 0||w.call(t,e,a,j)},xe=function(j){var w;switch(j.key){case"ArrowLeft":j.preventDefault(),j.stopPropagation(),t.dir==="rtl"?l():c();break;case"ArrowRight":j.preventDefault(),j.stopPropagation(),t.dir==="rtl"?c():l();break;case"ArrowDown":j.preventDefault(),j.stopPropagation(),u();break;case"ArrowUp":j.preventDefault(),j.stopPropagation(),d();break;case"PageUp":j.preventDefault(),j.stopPropagation(),j.shiftKey?v():h();break;case"PageDown":j.preventDefault(),j.stopPropagation(),j.shiftKey?y():x();break;case"Home":j.preventDefault(),j.stopPropagation(),p();break;case"End":j.preventDefault(),j.stopPropagation(),b();break}(w=t.onDayKeyDown)===null||w===void 0||w.call(t,e,a,j)},W={onClick:M,onFocus:k,onBlur:L,onKeyDown:xe,onKeyUp:Fe,onMouseEnter:A,onMouseLeave:V,onPointerEnter:Q,onPointerLeave:Z,onTouchCancel:ee,onTouchEnd:Oe,onTouchMove:X,onTouchStart:te};return W}function ao(){var e=S(),a=ga(),t=st(),r=it(),s=Pe(e)?a.selected:be(e)?t.selected:we(e)?r.selected:void 0;return s}function ro(e){return Object.values(B).includes(e)}function no(e,a){var t=[e.classNames.day];return Object.keys(a).forEach(function(r){var s=e.modifiersClassNames[r];if(s)t.push(s);else if(ro(r)){var o=e.classNames["day_".concat(r)];o&&t.push(o)}}),t}function so(e,a){var t=N({},e.styles.day);return Object.keys(a).forEach(function(r){var s;t=N(N({},t),(s=e.modifiersStyles)===null||s===void 0?void 0:s[r])}),t}function oo(e,a,t){var r,s,o,i=S(),l=ct(),c=Js(e,a),u=to(e,c),d=ao(),f=!!(i.onDayClick||i.mode!=="default");g.useEffect(function(){var A;c.outside||l.focusedDay&&f&&E(l.focusedDay,e)&&((A=t.current)===null||A===void 0||A.focus())},[l.focusedDay,e,t,f,c.outside]);var m=no(i,c).join(" "),h=so(i,c),x=!!(c.outside&&!i.showOutsideDays||c.hidden),v=(o=(s=i.components)===null||s===void 0?void 0:s.DayContent)!==null&&o!==void 0?o:ks,y=n.jsx(v,{date:e,displayMonth:a,activeModifiers:c}),p={style:h,className:m,children:y,role:"gridcell"},b=l.focusTarget&&E(l.focusTarget,e)&&!c.outside,M=l.focusedDay&&E(l.focusedDay,e),k=N(N(N({},p),(r={disabled:c.disabled,role:"gridcell"},r["aria-selected"]=c.selected,r.tabIndex=M||b?0:-1,r)),u),L={isButton:f,isHidden:x,activeModifiers:c,selectedDays:d,buttonProps:k,divProps:p};return L}function io(e){var a=g.useRef(null),t=oo(e.date,e.displayMonth,a);return t.isHidden?n.jsx("div",{role:"gridcell"}):t.isButton?n.jsx(Se,N({name:"day",ref:a},t.buttonProps)):n.jsx("div",N({},t.divProps))}function lo(e){var a=e.number,t=e.dates,r=S(),s=r.onWeekNumberClick,o=r.styles,i=r.classNames,l=r.locale,c=r.labels.labelWeekNumber,u=r.formatters.formatWeekNumber,d=u(Number(a),{locale:l});if(!s)return n.jsx("span",{className:i.weeknumber,style:o.weeknumber,children:d});var f=c(Number(a),{locale:l}),m=function(h){s(a,t,h)};return n.jsx(Se,{name:"week-number","aria-label":f,className:i.weeknumber,style:o.weeknumber,onClick:m,children:d})}function co(e){var a,t,r=S(),s=r.styles,o=r.classNames,i=r.showWeekNumber,l=r.components,c=(a=l==null?void 0:l.Day)!==null&&a!==void 0?a:io,u=(t=l==null?void 0:l.WeekNumber)!==null&&t!==void 0?t:lo,d;return i&&(d=n.jsx("td",{className:o.cell,style:s.cell,children:n.jsx(u,{number:e.weekNumber,dates:e.dates})})),n.jsxs("tr",{className:o.row,style:s.row,children:[d,e.dates.map(function(f){return n.jsx("td",{className:o.cell,style:s.cell,role:"presentation",children:n.jsx(c,{displayMonth:e.displayMonth,date:f})},En(f))})]})}function Rt(e,a,t){for(var r=t!=null&&t.ISOWeek?ta(a):tt(a,t),s=t!=null&&t.ISOWeek?oe(e):q(e,t),o=$(r,s),i=[],l=0;l<=o;l++)i.push(F(s,l));var c=i.reduce(function(u,d){var f=t!=null&&t.ISOWeek?aa(d):na(d,t),m=u.find(function(h){return h.weekNumber===f});return m?(m.dates.push(d),u):(u.push({weekNumber:f,dates:[d]}),u)},[]);return c}function uo(e,a){var t=Rt(Y(e),Te(e),a);if(a!=null&&a.useFixedWeeks){var r=In(e,a);if(r<6){var s=t[t.length-1],o=s.dates[s.dates.length-1],i=Ue(o,6-r),l=Rt(Ue(o,1),i,a);t.push.apply(t,l)}}return t}function mo(e){var a,t,r,s=S(),o=s.locale,i=s.classNames,l=s.styles,c=s.hideHead,u=s.fixedWeeks,d=s.components,f=s.weekStartsOn,m=s.firstWeekContainsDate,h=s.ISOWeek,x=uo(e.displayMonth,{useFixedWeeks:!!u,ISOWeek:h,locale:o,weekStartsOn:f,firstWeekContainsDate:m}),v=(a=d==null?void 0:d.Head)!==null&&a!==void 0?a:Cs,y=(t=d==null?void 0:d.Row)!==null&&t!==void 0?t:co,p=(r=d==null?void 0:d.Footer)!==null&&r!==void 0?r:ps;return n.jsxs("table",{id:e.id,className:i.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!c&&n.jsx(v,{}),n.jsx("tbody",{className:i.tbody,style:l.tbody,children:x.map(function(b){return n.jsx(y,{displayMonth:e.displayMonth,dates:b.dates,weekNumber:b.weekNumber},b.weekNumber)})}),n.jsx(p,{displayMonth:e.displayMonth})]})}function fo(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var ho=fo()?g.useLayoutEffect:g.useEffect,Be=!1,xo=0;function Lt(){return"react-day-picker-".concat(++xo)}function go(e){var a,t=e??(Be?Lt():null),r=g.useState(t),s=r[0],o=r[1];return ho(function(){s===null&&o(Lt())},[]),g.useEffect(function(){Be===!1&&(Be=!0)},[]),(a=e??s)!==null&&a!==void 0?a:void 0}function vo(e){var a,t,r=S(),s=r.dir,o=r.classNames,i=r.styles,l=r.components,c=je().displayMonths,u=go(r.id?"".concat(r.id,"-").concat(e.displayIndex):void 0),d=r.id?"".concat(r.id,"-grid-").concat(e.displayIndex):void 0,f=[o.month],m=i.month,h=e.displayIndex===0,x=e.displayIndex===c.length-1,v=!h&&!x;s==="rtl"&&(a=[h,x],x=a[0],h=a[1]),h&&(f.push(o.caption_start),m=N(N({},m),i.caption_start)),x&&(f.push(o.caption_end),m=N(N({},m),i.caption_end)),v&&(f.push(o.caption_between),m=N(N({},m),i.caption_between));var y=(t=l==null?void 0:l.Caption)!==null&&t!==void 0?t:Ns;return n.jsxs("div",{className:f.join(" "),style:m,children:[n.jsx(y,{id:u,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),n.jsx(mo,{id:d,"aria-labelledby":u,displayMonth:e.displayMonth})]},e.displayIndex)}function yo(e){var a=S(),t=a.classNames,r=a.styles;return n.jsx("div",{className:t.months,style:r.months,children:e.children})}function bo(e){var a,t,r=e.initialProps,s=S(),o=ct(),i=je(),l=g.useState(!1),c=l[0],u=l[1];g.useEffect(function(){s.initialFocus&&o.focusTarget&&(c||(o.focus(o.focusTarget),u(!0)))},[s.initialFocus,c,o.focus,o.focusTarget,o]);var d=[s.classNames.root,s.className];s.numberOfMonths>1&&d.push(s.classNames.multiple_months),s.showWeekNumber&&d.push(s.classNames.with_weeknumber);var f=N(N({},s.styles.root),s.style),m=Object.keys(r).filter(function(x){return x.startsWith("data-")}).reduce(function(x,v){var y;return N(N({},x),(y={},y[v]=r[v],y))},{}),h=(t=(a=r.components)===null||a===void 0?void 0:a.Months)!==null&&t!==void 0?t:yo;return n.jsx("div",N({className:d.join(" "),style:f,dir:s.dir,id:s.id,nonce:r.nonce,title:r.title,lang:r.lang},m,{children:n.jsx(h,{children:i.displayMonths.map(function(x,v){return n.jsx(vo,{displayIndex:v,displayMonth:x},v)})})}))}function wo(e){var a=e.children,t=$n(e,["children"]);return n.jsx(ls,{initialProps:t,children:n.jsx(ys,{children:n.jsx(Zs,{initialProps:t,children:n.jsx(Ss,{initialProps:t,children:n.jsx(Ps,{initialProps:t,children:n.jsx(Ls,{children:n.jsx(Us,{children:a})})})})})})})}function jo(e){return n.jsx(wo,N({},e,{children:n.jsx(bo,{initialProps:e})}))}function At({className:e,classNames:a,showOutsideDays:t=!0,...r}){return n.jsx(jo,{showOutsideDays:t,className:U("p-3",e),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:U(gt({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:U("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",r.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:U(gt({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...a},components:{IconLeft:({className:s,...o})=>n.jsx(Qt,{className:U("size-4",s),...o}),IconRight:({className:s,...o})=>n.jsx(_e,{className:U("size-4",s),...o})},...r})}const No=[{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}];function po({open:e,onOpenChange:a,filters:t,onApply:r,onReset:s,projectId:o}){const[i,l]=g.useState(t),[c,u]=g.useState(t.fromDate?new Date(t.fromDate):void 0),[d,f]=g.useState(t.toDate?new Date(t.toDate):void 0);g.useEffect(()=>{l(t),u(t.fromDate?new Date(t.fromDate):void 0),f(t.toDate?new Date(t.toDate):void 0)},[t]);const m=(v,y)=>{l(p=>({...p,status:y?[...p.status,v]:p.status.filter(b=>b!==v)}))},h=()=>{const v={...i,fromDate:c?c.toISOString():void 0,toDate:d?d.toISOString():void 0};r(v)},x=()=>{l({status:[]}),u(void 0),f(void 0),s()};return n.jsx(Xe,{open:e,onOpenChange:a,children:n.jsxs(Kt,{className:"sm:max-w-[425px]",children:[n.jsxs(Ut,{children:[n.jsx(Jt,{children:"Filter Traces"}),n.jsx(er,{children:"Apply filters to narrow down the traces displayed in the table."})]}),n.jsxs("div",{className:"space-y-6 py-4",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsx(G,{className:"text-sm font-medium",children:"Status"}),n.jsx("div",{className:"space-y-2",children:No.map(v=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Ve,{id:`status-${v.value}`,checked:i.status.includes(v.value),onCheckedChange:y=>m(v.value,!!y)}),n.jsx(G,{htmlFor:`status-${v.value}`,className:"text-sm font-normal cursor-pointer",children:v.label})]},v.value))})]}),n.jsx(qe,{}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(G,{className:"text-sm font-medium",children:"Date Range"}),n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(G,{htmlFor:"from-date",className:"text-xs text-gray-500",children:"From"}),n.jsxs(vt,{children:[n.jsx(yt,{asChild:!0,children:n.jsxs(O,{variant:"outline",className:U("w-full justify-start text-left font-normal",!c&&"text-muted-foreground"),children:[n.jsx(ke,{className:"mr-2 h-4 w-4"}),c?T(c,"PPP"):"Pick a date"]})}),n.jsx(bt,{className:"w-auto p-0",children:n.jsx(At,{mode:"single",selected:c,onSelect:u,initialFocus:!0})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(G,{htmlFor:"to-date",className:"text-xs text-gray-500",children:"To"}),n.jsxs(vt,{children:[n.jsx(yt,{asChild:!0,children:n.jsxs(O,{variant:"outline",className:U("w-full justify-start text-left font-normal",!d&&"text-muted-foreground"),children:[n.jsx(ke,{className:"mr-2 h-4 w-4"}),d?T(d,"PPP"):"Pick a date"]})}),n.jsx(bt,{className:"w-auto p-0",children:n.jsx(At,{mode:"single",selected:d,onSelect:f,initialFocus:!0})})]})]})]})]}),n.jsx(qe,{}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(G,{className:"text-sm font-medium",children:"Duration (ms)"}),n.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(G,{htmlFor:"min-duration",className:"text-xs text-gray-500",children:"Min"}),n.jsx(Qe,{id:"min-duration",type:"number",placeholder:"0",value:i.minDuration||"",onChange:v=>l(y=>({...y,minDuration:v.target.value?Number(v.target.value):void 0}))})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(G,{htmlFor:"max-duration",className:"text-xs text-gray-500",children:"Max"}),n.jsx(Qe,{id:"max-duration",type:"number",placeholder:"1000",value:i.maxDuration||"",onChange:v=>l(y=>({...y,maxDuration:v.target.value?Number(v.target.value):void 0}))})]})]})]})]}),n.jsxs(tr,{children:[n.jsx(O,{variant:"outline",onClick:x,children:"Reset"}),n.jsx(O,{onClick:h,children:"Apply Filters"})]})]})})}const Ht=e=>e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`,Do=({span:e})=>e.metadata&&Object.keys(e.metadata).length>0?n.jsxs(Xe,{children:[n.jsx(Ct,{asChild:!0,children:n.jsx("button",{className:"flex items-center justify-center w-5 h-5 rounded hover:bg-blue-100 transition-colors",title:"View span metadata",children:n.jsx(Nt,{className:"w-3 h-3 text-blue-600 hover:text-blue-800"})})}),n.jsxs(Kt,{className:"max-w-2xl max-h-[80vh] overflow-hidden",children:[n.jsx(Ut,{children:n.jsxs(Jt,{className:"flex items-center gap-2",children:[n.jsx(Ge,{className:"h-5 w-5 text-blue-600"}),"Span Metadata: ",e.name]})}),n.jsx(Xt,{className:"max-h-[60vh] pr-4",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"bg-gray-50 rounded-lg p-4",children:[n.jsxs("h4",{className:"font-semibold text-gray-900 mb-3 flex items-center gap-2",children:[n.jsx(Ke,{className:"h-4 w-4 text-gray-600"}),"Span Information"]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-sm",children:[n.jsxs("div",{children:[n.jsx("span",{className:"font-medium text-gray-600",children:"ID:"}),n.jsx("p",{className:"font-mono text-gray-900 break-all",children:e.id})]}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium text-gray-600",children:"Name:"}),n.jsx("p",{className:"text-gray-900",children:e.name})]}),e.parentSpanId&&n.jsxs("div",{children:[n.jsx("span",{className:"font-medium text-gray-600",children:"Parent Span ID:"}),n.jsx("p",{className:"font-mono text-gray-900 break-all",children:e.parentSpanId})]}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium text-gray-600",children:"Status:"}),n.jsx(R,{className:`ml-2 ${e.status==="completed"?"bg-green-100 text-green-800":e.status==="failed"?"bg-red-100 text-red-800":"bg-blue-100 text-blue-800"}`,children:e.status})]})]})]}),n.jsxs("div",{className:"bg-blue-50 rounded-lg p-4",children:[n.jsxs("h4",{className:"font-semibold text-gray-900 mb-3 flex items-center gap-2",children:[n.jsx(Ge,{className:"h-4 w-4 text-blue-600"}),"Metadata"]}),n.jsx("div",{className:"space-y-3",children:Object.entries(e.metadata).map(([t,r])=>n.jsx("div",{className:"border-b border-blue-200 last:border-b-0 pb-2 last:pb-0",children:n.jsx("div",{className:"flex items-start gap-3",children:n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("div",{className:"font-medium text-blue-900 text-sm break-all",children:t}),n.jsx("div",{className:"mt-1 text-sm text-gray-700",children:typeof r=="object"?n.jsx("pre",{className:"bg-white rounded p-2 text-xs font-mono overflow-x-auto border border-blue-200",children:JSON.stringify(r,null,2)}):n.jsx("span",{className:"font-mono break-all",children:String(r)})})]})})},t))})]})]})})]})]}):n.jsx(Xe,{children:n.jsx(Ct,{asChild:!0,children:n.jsx("button",{className:"flex items-center justify-center w-5 h-5 rounded hover:bg-gray-200 transition-colors opacity-50 cursor-not-allowed",title:"No metadata available",disabled:!0,children:n.jsx(Nt,{className:"w-3 h-3 text-gray-400"})})})}),va=(e,a=0,t=new Set)=>{const r=[];for(const s of e){const o=s.spans?s.spans.length>0:!1;r.push({...s,level:a,hasChildren:o}),o&&!t.has(s.id)&&r.push(...va((s==null?void 0:s.spans)??[],a+1,t))}return r};function Mo({open:e,onOpenChange:a,trace:t}){const[r,s]=g.useState(new Set),o=m=>{s(h=>{const x=new Set(h);return x.has(m)?x.delete(m):x.add(m),x})};if(!t)return n.jsx(wt,{open:e,onOpenChange:a,children:n.jsx(jt,{className:"w-[100vw] !max-w-[100vw] h-[100vh] overflow-hidden !w-[100vw] bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50",children:n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsxs("div",{className:"text-center space-y-6",children:[n.jsx("div",{className:"inline-flex items-center justify-center p-6 bg-gradient-to-r from-blue-500 to-purple-600 rounded-3xl text-white shadow-xl",children:n.jsx(ce,{className:"h-12 w-12"})}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"text-2xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"No Trace Selected"}),n.jsx("p",{className:"text-gray-600 max-w-md mx-auto",children:"Select a trace from the table to view detailed information about its execution and spans."})]})]})})})});const i=new Date(t.startTime),l=t.endTime?new Date(t.endTime):null,c=l?l.getTime()-i.getTime():null,u=t.spans||[],d=va(u,0,r),f=t.status||"running";return n.jsx(wt,{open:e,onOpenChange:a,children:n.jsxs(jt,{className:"w-[100vw] !max-w-[100vw] h-[100vh] overflow-hidden !w-[100vw] bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50",children:[n.jsx("div",{className:"bg-gradient-to-r from-blue-500 to-purple-600 text-white p-8 -m-6 mb-8 shadow-xl",children:n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("div",{className:"p-3 bg-white/20 rounded-2xl backdrop-blur-sm",children:n.jsx(ce,{className:"h-8 w-8"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold",children:"Trace Details"}),n.jsx("p",{className:"text-blue-100 text-lg mt-1",children:"Comprehensive trace execution analysis"})]})]})}),n.jsx(Xt,{className:"h-[calc(100vh-200px)] px-2",children:n.jsxs("div",{className:"space-y-8",children:[n.jsxs(ze,{className:"border-0 shadow-xl bg-white/80 backdrop-blur-sm",children:[n.jsx(pt,{className:"pb-6",children:n.jsxs(Dt,{className:"flex items-center gap-3 text-2xl",children:[n.jsx("div",{className:"p-2 bg-gradient-to-r from-blue-500 to-purple-600 rounded-xl text-white",children:n.jsx(Ge,{className:"h-6 w-6"})}),n.jsx("span",{className:"bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"Basic Information"})]})}),n.jsx(Mt,{className:"space-y-6",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[n.jsx(Ke,{className:"h-4 w-4 text-blue-600"}),"TRACE NAME"]}),n.jsx("div",{className:"p-4 bg-gradient-to-r from-blue-50 to-indigo-50 rounded-xl border border-blue-200/50 shadow-sm",children:n.jsx("p",{className:"font-mono text-sm text-gray-900 break-all",children:t.name})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[n.jsx(Ke,{className:"h-4 w-4 text-purple-600"}),"TRACE ID"]}),n.jsx("div",{className:"p-4 bg-gradient-to-r from-purple-50 to-pink-50 rounded-xl border border-purple-200/50 shadow-sm",children:n.jsx("p",{className:"font-mono text-sm text-gray-900 break-all",children:t.id})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[n.jsx(ke,{className:"h-4 w-4 text-green-600"}),"START TIME"]}),n.jsx("div",{className:"p-4 bg-gradient-to-r from-green-50 to-emerald-50 rounded-xl border border-green-200/50 shadow-sm",children:n.jsx("p",{className:"font-mono text-sm text-gray-900",children:T(i,"MMM dd, yyyy HH:mm:ss")})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[n.jsx(ke,{className:"h-4 w-4 text-orange-600"}),"END TIME"]}),n.jsx("div",{className:"p-4 bg-gradient-to-r from-orange-50 to-amber-50 rounded-xl border border-orange-200/50 shadow-sm",children:n.jsx("p",{className:"font-mono text-sm text-gray-900",children:l?T(l,"MMM dd, yyyy HH:mm:ss"):"In Progress"})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[n.jsx(fr,{className:"h-4 w-4 text-cyan-600"}),"DURATION"]}),n.jsx("div",{className:"p-4 bg-gradient-to-r from-cyan-50 to-sky-50 rounded-xl border border-cyan-200/50 shadow-sm",children:n.jsx("p",{className:"font-mono text-sm text-gray-900",children:c!==null?Ht(c):"N/A"})})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-700",children:[n.jsx(ce,{className:"h-4 w-4 text-indigo-600"}),"STATUS"]}),n.jsxs("div",{className:"p-4 bg-gradient-to-r from-indigo-50 to-violet-50 rounded-xl border border-indigo-200/50 shadow-sm",children:[f==="completed"&&n.jsxs(R,{className:"bg-gradient-to-r from-green-500 to-emerald-600 text-white border-0 shadow-lg text-sm px-4 py-2",children:[n.jsx(or,{className:"h-4 w-4 mr-2"}),"Completed"]}),f==="failed"&&n.jsxs(R,{className:"bg-gradient-to-r from-red-500 to-rose-600 text-white border-0 shadow-lg text-sm px-4 py-2",children:[n.jsx(rr,{className:"h-4 w-4 mr-2"}),"Failed"]}),f==="running"&&n.jsxs(R,{className:"bg-gradient-to-r from-blue-500 to-cyan-600 text-white border-0 shadow-lg text-sm px-4 py-2",children:[n.jsx(zt,{className:"h-4 w-4 mr-2"}),"Running"]})]})]})]})})]}),n.jsxs(ze,{className:"border-0 shadow-xl bg-white/80 backdrop-blur-sm",children:[n.jsx(pt,{className:"pb-6",children:n.jsxs(Dt,{className:"flex items-center gap-3 text-2xl",children:[n.jsx("div",{className:"p-2 bg-gradient-to-r from-green-500 to-blue-600 rounded-xl text-white",children:n.jsx(nr,{className:"h-6 w-6"})}),n.jsx("span",{className:"bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent",children:"Spans"}),n.jsxs(R,{className:"ml-auto bg-gradient-to-r from-green-500 to-blue-600 text-white border-0 shadow-lg text-base px-4 py-2",children:[d.length," ",d.length===1?"span":"spans"]})]})}),n.jsx(Mt,{children:d.length>0?n.jsx("div",{className:"space-y-6",children:n.jsx("div",{className:"bg-gradient-to-r from-white to-gray-50/50 rounded-2xl border border-gray-200/50 shadow-lg p-6",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h4",{className:"text-lg font-semibold text-gray-900",children:"Timeline Visualization"}),n.jsx("div",{className:"text-sm text-gray-600 font-mono",children:i&&l?n.jsxs("span",{children:[T(i,"HH:mm:ss")," → ",T(l,"HH:mm:ss")]}):n.jsx("span",{children:"Timeline"})})]}),n.jsx("div",{className:"space-y-3",children:d.map((m,h)=>{var V,Q;const x=m.startTime?new Date(m.startTime).getTime():0,v=m.endTime?new Date(m.endTime).getTime():Date.now(),y=i.getTime(),b=(l?l.getTime():Date.now())-y,M=b>0?(x-y)/b*100:0,k=b>0?(v-x)/b*100:100,L=["from-blue-500 to-blue-600","from-purple-500 to-purple-600","from-green-500 to-green-600","from-orange-500 to-orange-600","from-pink-500 to-pink-600","from-cyan-500 to-cyan-600","from-indigo-500 to-indigo-600","from-red-500 to-red-600"],A=L[h%L.length];return n.jsxs("div",{className:"relative",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{className:"flex items-center gap-3",style:{marginLeft:`${m.level*20}px`},children:[m.hasChildren?n.jsx("button",{onClick:()=>o(m.id),className:"flex items-center justify-center w-5 h-5 rounded hover:bg-gray-200 transition-colors",title:r.has(m.id)?"Expand children":"Collapse children",children:r.has(m.id)?n.jsx(_e,{className:"w-3 h-3 text-gray-600"}):n.jsx(Pa,{className:"w-3 h-3 text-gray-600"})}):n.jsx("div",{className:"w-5 h-5 flex items-center justify-center",children:m.level>0&&n.jsx("div",{className:"w-1 h-1 bg-gray-400 rounded-full"})}),m.level>0&&n.jsxs("div",{className:"flex items-center",children:[[...Array(m.level)].map((Z,ee)=>n.jsx("div",{className:"w-4 h-px bg-gray-300 mr-1"},ee)),n.jsx("div",{className:"w-2 h-2 border-l border-b border-gray-300 mr-2"})]}),n.jsx("div",{className:`w-3 h-3 rounded-full bg-gradient-to-r ${A}`}),n.jsx("span",{className:"text-sm font-medium text-gray-900 truncate max-w-xs",children:m.name||`Span ${h+1}`}),m.level>0&&n.jsxs(R,{variant:"outline",className:"text-xs px-2 py-1 bg-gray-50",children:["L",m.level]}),m.hasChildren&&n.jsxs(R,{variant:"outline",className:"text-xs px-2 py-1 bg-blue-50 text-blue-700",children:[(V=m.spans)==null?void 0:V.length," child",((Q=m==null?void 0:m.spans)==null?void 0:Q.length)!==1?"ren":""]})]}),n.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600",children:[m.startTime&&m.endTime&&n.jsx(R,{variant:"outline",className:"text-xs px-2 py-1",children:Ht(v-x)}),n.jsx(Do,{span:m})]})]}),n.jsxs("div",{className:"relative h-8 bg-gray-100 rounded-lg overflow-hidden",style:{marginLeft:`${m.level*20}px`},children:[n.jsx("div",{className:"absolute inset-0 flex",children:[...Array(10)].map((Z,ee)=>n.jsx("div",{className:"flex-1 border-r border-gray-200 last:border-r-0"},ee))}),n.jsx("div",{className:`absolute top-1 bottom-1 bg-gradient-to-r ${A} rounded shadow-sm transition-all duration-300 hover:shadow-md`,style:{left:`${Math.max(0,Math.min(M,100))}%`,width:`${Math.max(1,Math.min(k,100-Math.max(0,M)))}%`},children:n.jsx("div",{className:"h-full flex items-center justify-center text-white text-xs font-medium px-2",children:k>15&&n.jsx("span",{className:"truncate",children:m.startTime&&T(new Date(m.startTime),"HH:mm:ss")})})})]}),n.jsx("div",{className:"mt-2 text-xs text-gray-500 font-mono pl-6",style:{marginLeft:`${m.level*20}px`},children:m.startTime&&n.jsxs("span",{children:["Start: ",T(new Date(m.startTime),"HH:mm:ss.SSS"),m.endTime&&n.jsxs("span",{className:"ml-4",children:["End: ",T(new Date(m.endTime),"HH:mm:ss.SSS")]})]})})]},m.id||h)})}),n.jsxs("div",{className:"mt-6 pt-4 border-t border-gray-200",children:[n.jsxs("div",{className:"flex justify-between text-xs text-gray-500 font-mono",children:[n.jsx("span",{children:"0%"}),n.jsx("span",{children:"25%"}),n.jsx("span",{children:"50%"}),n.jsx("span",{children:"75%"}),n.jsx("span",{children:"100%"})]}),n.jsx("div",{className:"mt-1 text-xs text-gray-400 text-center",children:"Timeline Progress"})]})]})})}):n.jsxs("div",{className:"text-center py-20",children:[n.jsx("div",{className:"inline-flex items-center justify-center p-6 bg-gradient-to-r from-gray-100 to-gray-200 rounded-3xl mb-6",children:n.jsx(dr,{className:"h-12 w-12 text-gray-500"})}),n.jsx("h3",{className:"text-2xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent mb-3",children:"No spans found for this trace"}),n.jsx("p",{className:"text-gray-600 max-w-md mx-auto text-lg",children:"Spans will appear here when available"})]})})]})]})})]})})}function Co(e){const[a,t]=g.useState(void 0),[r,s]=g.useState([void 0]),[o,i]=g.useState(0),l=g.useCallback(d=>{const f=[...r.slice(0,o+1),d];s(f),t(d),i(o+1)},[r,o]),c=g.useCallback(()=>{if(o>0){const d=r[o-1];t(d),i(o-1)}},[r,o]),u=g.useCallback(()=>{t(void 0),s([void 0]),i(0)},[]);return{cursor:a,currentPage:o,handleNextPage:l,handlePrevPage:c,resetPagination:u}}const ko=e=>e<100?"bg-green-500":e<500?"bg-yellow-500":e<1e3?"bg-orange-500":"bg-red-500",Bt=e=>e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(2)}s`:`${(e/6e4).toFixed(2)}m`;function So({selectedTraces:e,onSelectAll:a,onSelectRow:t,onViewTrace:r,onDeleteTrace:s,currentTraces:o}){return[{id:"select",header:({table:i})=>{const l=o.length>0&&o.every(u=>e[u.id]),c=o.some(u=>e[u.id])&&!l;return n.jsx(Ve,{checked:l,ref:u=>{u&&(u.indeterminate=c)},onCheckedChange:u=>a(!!u),"aria-label":"Select all",className:"translate-y-[2px]"})},cell:({row:i})=>n.jsx(Ve,{checked:!!e[i.original.id],onCheckedChange:l=>t(i.original.id,!!l),"aria-label":"Select row",className:"translate-y-[2px]"}),enableSorting:!1,enableHiding:!1},{accessorKey:"startTime",header:"Start Time",enableSorting:!0,cell:({row:i})=>{const l=new Date(i.getValue("startTime"));return n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"text-sm font-medium text-gray-900",children:T(l,"MMM dd, HH:mm:ss")}),n.jsx("div",{className:"text-xs text-gray-500",children:T(l,"yyyy")})]})}},{accessorKey:"name",header:"Trace Name",cell:({row:i})=>{const l=new Date(i.getValue("startTime"));return n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"font-medium text-gray-900",children:i.getValue("name")}),n.jsxs("div",{className:"text-xs text-gray-500 flex items-center gap-1",children:[n.jsx(zt,{className:"h-3 w-3"}),T(l,"HH:mm:ss")]})]})}},{accessorKey:"duration",header:"Duration",cell:({row:i,table:l})=>{const c=i.getValue("status"),u=new Date(i.getValue("startTime")),d=i.original.endTime;console.log({startTime:u,endTime:d});const m=l.getRowModel().rows.map(b=>b.original).map(b=>{const M=new Date(b.startTime).getTime();if(b.endTime){const k=new Date(b.endTime).getTime();return Math.max(0,k-M)}else if(b.status==="running"){const k=new Date().getTime();return Math.max(0,k-M)}return 0}),h=m.length>0?Math.max(...m):1;if(!d&&c==="running"){const M=Math.max(0,new Date().getTime()-u.getTime()),k=Bt(M),L=h>0?Math.min(M/h*100,100):0;return n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"flex items-center",children:n.jsx("span",{className:"text-sm font-mono font-medium text-gray-900",children:k})}),n.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:n.jsx("div",{className:"bg-blue-500 h-2 rounded-full animate-pulse",style:{width:`${L}%`}})})]})}if(!d)return n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"flex items-center",children:n.jsx("span",{className:"text-sm font-mono font-medium text-gray-500",children:"-"})}),n.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:n.jsx("div",{className:"bg-gray-300 h-2 rounded-full",style:{width:"0%"}})})]});const x=Math.max(0,new Date(d).getTime()-u.getTime()),v=Bt(x),y=ko(x),p=h>0?Math.min(x/h*100,100):0;return n.jsxs("div",{className:"space-y-2",children:[n.jsx("div",{className:"flex items-center",children:n.jsx("span",{className:"text-sm font-mono font-medium text-gray-900",children:v})}),n.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2",children:n.jsx("div",{className:`h-2 rounded-full transition-all duration-300 ${y}`,style:{width:`${p}%`}})})]})}},{accessorKey:"spans",header:"Spans",cell:({row:i})=>{const l=i.getValue("spans"),c=(l==null?void 0:l.length)||0;return n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(R,{variant:"outline",className:"text-purple-600 border-purple-200",children:c}),n.jsx("span",{className:"text-xs text-gray-500",children:c===1?"span":"spans"})]})}},{accessorKey:"status",header:"Status",cell:({row:i})=>{const l=i.getValue("status"),c=new Date(i.getValue("startTime")),d=new Date().getTime()-c.getTime()<3e5;switch(l){case"running":return n.jsxs(R,{variant:"outline",className:"text-blue-600 border-blue-200",children:[n.jsx(ce,{className:"h-3 w-3 mr-1 animate-pulse"}),"Running"]});case"failed":return n.jsxs(R,{variant:"outline",className:"text-red-600 border-red-200",children:[n.jsx(St,{className:"h-3 w-3 mr-1"}),"Failed"]});case"completed":default:return n.jsxs(R,{variant:"outline",className:`${d?"text-green-600 border-green-200":"text-gray-600 border-gray-200"}`,children:[n.jsx(St,{className:"h-3 w-3 mr-1"}),"Completed"]})}}},{id:"actions",header:"",cell:({row:i})=>{const l=i.original;return n.jsx(O,{variant:"ghost",size:"icon",onClick:()=>r(l),className:"rounded-full hover:bg-blue-50 hover:border-blue-200 border border-transparent transition-all duration-200 group","aria-label":"View trace details",children:n.jsx(_e,{className:"h-4 w-4 text-gray-600 group-hover:text-blue-600 transition-colors"})})},size:50}]}const _o=500,$t=20;function To({projectId:e}){const{searchQuery:a,inputValue:t,setSearchQuery:r,filterModalOpen:s,openFilterModal:o,setFilterModalOpen:i,filters:l,handleApplyFilters:c,handleResetFilters:u,filtersActive:d}=vr({debounceTimeout:_o}),{sortDirection:f,sorting:m,handleToggleSortDirection:h,setSorting:x,resetSort:v}=br("desc"),{cursor:y,currentPage:p,handleNextPage:b,handlePrevPage:M,resetPagination:k}=Co(),{isDetailSheetOpen:L,currentTraceDetail:A,openDetailSheet:V,setIsDetailSheetOpen:Q}=wr(),[Z,ee]=g.useState([]),Oe={limit:$t,sortDirection:f,...l.status.length>0?{status:l.status}:{},...l.fromDate?{fromDate:l.fromDate}:{},...l.toDate?{toDate:l.toDate}:{},...l.minDuration!==void 0?{minDuration:l.minDuration}:{},...l.maxDuration!==void 0?{maxDuration:l.maxDuration}:{},...a?{nameContains:a}:{},...y?{cursor:y}:{}},{data:X,isLoading:te,isError:Fe,refetch:xe}=gr(e,Oe),W=(X==null?void 0:X.traces)??[],j=(X==null?void 0:X.hasNextPage)||!1,w=g.useCallback(()=>{if(j&&W.length>0){const _=W[W.length-1];return console.log("get next cursor",{cursor:y,latestTrace:_}),{id:_.id,timestamp:_.startTime}}return null},[j,W]),{selectedTraces:I,selectedCount:ge,handleSelectAll:ie,handleSelectRow:ut,resetSelection:ae}=yr(W),ya=g.useCallback(_=>{c(_),k(),ae()},[c,k,ae]),mt=g.useCallback(()=>{u(),k(),v(),ae()},[u,k,v,ae]),ba=g.useCallback(()=>{h(),k(),ae()},[h,k,ae]),wa=g.useCallback(()=>{const _=w();_&&b(_)},[b,w]),ja=g.useCallback(()=>{M()},[M]);g.useCallback(()=>{k(),xe()},[k,xe]);const ft=g.useCallback(_=>{V(_)},[V]),ht=g.useCallback(_=>{se.info(`Mock Deleting trace ${_}...`,{description:"This is a placeholder. Actual deletion would be implemented here."})},[]),Na=()=>{const _=Object.keys(I).filter(Ne=>I[Ne]);se.info(`Mock Deleting ${_.length} traces...`,{description:"This is a placeholder. Actual deletion would be implemented here."}),ae()},pa=()=>{const _=Object.keys(I).filter(Ne=>I[Ne]);se.info(`Mock Exporting ${_.length} traces...`,{description:"This is a placeholder. Actual export would be implemented here."})},Da=()=>{const _=Object.keys(I).filter(re=>I[re]),Ca=W.filter(re=>_.includes(re.id)).map(re=>`[${new Date(re.startTime).toLocaleString()}] ${re.name} (${re.id})`).join(`
`);navigator.clipboard.writeText(Ca).then(()=>{se.success(`Copied ${_.length} traces to clipboard`)}).catch(()=>{se.error("Failed to copy traces to clipboard")})},xt=g.useMemo(()=>So({selectedTraces:I,onSelectAll:_=>ie(_),onSelectRow:ut,onViewTrace:ft,onDeleteTrace:ht,currentTraces:W}),[I,ie,ut,ft,ht,W]),Ma=Qa({data:W,columns:xt,getCoreRowModel:Ka(),getSortedRowModel:Ga(),getFilteredRowModel:Xa(),onSortingChange:x,onColumnFiltersChange:ee,state:{sorting:m,columnFilters:Z},manualPagination:!0,manualSorting:!0,manualFiltering:!0,enableRowSelection:!0,onRowSelectionChange:()=>{},debugTable:!1});return n.jsxs(n.Fragment,{children:[n.jsx(po,{open:s,onOpenChange:i,filters:l,onApply:ya,onReset:mt,projectId:e}),n.jsxs(ze,{className:"bg-white/60 backdrop-blur-sm border-gray-200/50 shadow-lg w-full",children:[n.jsx(Ln,{filters:l,sortDirection:f,onOpenFilterModal:o,onToggleSortDirection:ba,displayedTraceCount:te?void 0:W.length,isLoading:te}),n.jsx(An,{searchQuery:t,onSearchQueryChange:r,onOpenFilterModal:o,selectedCount:ge,onDeleteSelected:Na,onExportSelected:pa,onCopySelected:Da,isLoading:te}),n.jsx(Hn,{table:Ma,columns:xt,isLoading:te,isError:Fe,traces:W,selectedTraces:I,isFiltered:d||!!a,onRetry:()=>{k(),xe()},onClearFilters:mt}),n.jsx(Bn,{currentPage:p,hasNextPage:j,onPrevPage:ja,onNextPage:wa,isLoading:te,currentTraceCount:W.length,pageSize:$t})]}),n.jsx(Mo,{open:L,onOpenChange:Q,trace:A})]})}function Po({projectId:e}){const{data:a,isLoading:t,isError:r}=Wa(e),{data:s,isLoading:o}=Ua(e),i=xr(),[l,c]=g.useState(!1),{editModalOpen:u,setEditModalOpen:d,deleteDialogOpen:f,setDeleteDialogOpen:m,autoRefresh:h,setAutoRefresh:x,handleRefresh:v,handleDeleteProject:y,handleConfirmDelete:p,handleEditProject:b,handleEditSubmit:M,updateProject:k,deleteProject:L}=Ea(e),A=()=>{c(!0)},V=()=>{i.mutate(e,{onSuccess:()=>{c(!1)}})},Q=t||o;return g.useEffect(()=>{if(!h)return;const Z=setInterval(()=>{v()},5e3);return()=>clearInterval(Z)},[h,e,v]),e?t?n.jsx(Ia,{}):r||!a?n.jsx(Ra,{projectId:e,project:a}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"min-h-full bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 p-6",children:n.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[n.jsx(La,{project:a,isRefreshing:Q,autoRefresh:h,onAutoRefreshChange:x,onEdit:b,onDelete:y,onRefresh:v}),n.jsx(Aa,{projectId:a.id,currentPage:"traces"}),n.jsxs("div",{className:"bg-white/60 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-lg p-6",children:[n.jsxs("div",{className:"flex justify-between items-center mb-6",children:[n.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Project Traces"}),n.jsxs(O,{variant:"outline",size:"sm",onClick:A,className:"transition-all hover:border-orange-500/50 hover:bg-orange-50 text-orange-600 hover:text-orange-700",children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Clear All Traces"]})]}),n.jsx(To,{projectId:a.id})]})]})}),n.jsx(ar,{open:u,onOpenChange:d,initialData:a?{name:a.name,description:a.description}:void 0,onSubmit:M,loading:k.isPending,mode:"edit"}),n.jsx(kt,{open:f,onOpenChange:m,title:"Delete Project?",description:"This will permanently delete the project and all its logs. This action cannot be undone.",onConfirm:p,loading:L.isPending,confirmLabel:"Delete"}),n.jsx(kt,{open:l,onOpenChange:c,title:"Clear All Traces?",description:"This will permanently delete all traces for this project. The project itself will remain, but all trace data will be lost. This action cannot be undone.",onConfirm:V,loading:i.isPending,confirmLabel:"Clear Traces"})]}):n.jsx(Ya,{})}const qo=()=>{const{projectId:e}=Oa.useParams();return n.jsx(Po,{projectId:e})};export{qo as component};
