@workflow/web 4.1.0-beta.40 → 4.1.0-beta.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/build/client/assets/{highlighted-body-B3W2YXNL-BlfdcYh0.js → highlighted-body-B3W2YXNL-Zd0qPYE7.js} +1 -1
- package/build/client/assets/{home-Xl3EX8M3.js → home-C-j1J39E.js} +1 -1
- package/build/client/assets/{manifest-0e172cba.js → manifest-41615f41.js} +1 -1
- package/build/client/assets/mermaid-3ZIDBTTL-BMFG0Hnn.js +172 -0
- package/build/client/assets/{root-D-041AAq.js → root-EzkmXyJV.js} +1 -1
- package/build/client/assets/root-SL7uvdv2.css +1 -0
- package/build/client/assets/run-detail-C0ZpSKc-.js +36 -0
- package/build/client/assets/server-build-d6BKG46c.css +1 -0
- package/build/client/assets/{use-workflow-graph-C-GqGBPl.js → use-workflow-graph-DXipnqlR.js} +1 -1
- package/build/server/assets/{app-DLRJr3zg.js → app-BIqik-91.js} +1 -1
- package/build/server/assets/{highlighted-body-B3W2YXNL-7BMdhIzo.js → highlighted-body-B3W2YXNL-WkqeTqm-.js} +2 -2
- package/build/server/assets/{mermaid-3ZIDBTTL-C-mhM4Cx.js → mermaid-3ZIDBTTL-ClaETQoK.js} +2 -2
- package/build/server/assets/{server-build-B-uZ5KmC.js → server-build-Cyb0dncG.js} +1671 -1184
- package/build/server/assets/{token-mzBpVePm.js → token-Bjyd4X_e.js} +3 -3
- package/build/server/assets/{token-BRJJ012D.js → token-CTJIoJEi.js} +2 -2
- package/build/server/assets/{token-util-YAVqVR6-.js → token-util-D-4jXUkD.js} +2 -2
- package/build/server/assets/{token-util-C29I-on4.js → token-util-DoGNqK5w.js} +1 -1
- package/build/server/assets/{token-util-D7WmNSMO.js → token-util-Dp_pg92C.js} +2 -2
- package/build/server/index.js +1 -1
- package/package.json +5 -5
- package/server.js +4 -2
- package/build/client/assets/mermaid-3ZIDBTTL-RlQIshou.js +0 -172
- package/build/client/assets/root-9gRDb_Jz.css +0 -1
- package/build/client/assets/run-detail-BPOihWwO.js +0 -41
- package/build/client/assets/server-build-Dj97HEP4.css +0 -1
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import{R as K,j as n,r as h,A as zo,f as Wo,x as Ca,y as $o,z as Sa,w as Ta,C as Ea}from"./index-DklpUtP3.js";import{U as or,V as sr,B as xt,j as yn,q as Vo,Y as Aa,Z as Ra,S as Go,R as Uo,p as Da,o as Ma,X as Ko,Q as Ht,_ as _a,G as La,$ as Qe,u as yr,W as Tt,a0 as Oa,v as ct,a1 as jr,a2 as Ha,t as qo,a3 as Fa,s as Pa,a4 as Br,w as bn,l as Ba,m as za,a5 as Wa,a6 as $a,a7 as Va,a8 as Ga,a9 as Ua,aa as Ka,ab as qa,ac as Za,ad as Wn,J as kr,ae as Zo,af as Ya,ag as Xa,ah as $n,ai as et,aj as tt,F as en,ak as Ja,al as Qa,am as ei,an as ti,r as ri,A as tn,C as rn,c as nn,d as on,a as St,ao as ni,e as oi,b as fr,T as si,M as ai,N as mr,K as ii,O as pr,y as li,ap as ci,I as di}from"./use-workflow-graph-C-GqGBPl.js";import{c as ar,t as fe,H as At,I as Re,J as Cr,_ as ui,M as fi,N as at,O as mi,U as pi,W as Yo,X as Rt,Y as nt,Z as J,$ as hi,a0 as gi,a1 as zr,a2 as Fe,a3 as hr,a4 as Sr,a5 as Ft,a6 as gt,a7 as Xo,a8 as Ut,a9 as Wr,aa as xi,ab as vi,ac as yi,ad as bi,ae as wi,af as Ni,ag as Ii,ah as sn,ai as it,aj as Jo,k as br,E as an,ak as ji,al as ki,am as wn,z as yt,an as Ci,d as We,ao as Qo,ap as Si,aq as Ti,ar as Ei,as as Ai,T as es,a as ts,b as rs,at as Ri,L as Nn,u as Di,au as Vn,av as Mi,aw as _i}from"./mermaid-3ZIDBTTL-RlQIshou.js";import{importKey as Li,decrypt as Oi}from"./encryption-8OvC6eoJ.js";/**
|
|
2
|
-
* @license lucide-react v0.575.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Hi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Fi=ar("circle-question-mark",Hi);/**
|
|
7
|
-
* @license lucide-react v0.575.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Pi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Bi=ar("info",Pi);/**
|
|
12
|
-
* @license lucide-react v0.575.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const zi=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],$r=ar("list",zi);/**
|
|
17
|
-
* @license lucide-react v0.575.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Wi=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],$i=ar("lock-open",Wi);/**
|
|
22
|
-
* @license lucide-react v0.575.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Vi=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Gi=ar("type",Vi),_r=0,bt=1,Wt=2,ns=4;function Gn(e){return()=>e}function Ui(e){e()}function os(e,t){return r=>e(t(r))}function Un(e,t){return()=>e(t)}function Ki(e,t){return r=>e(t,r)}function In(e){return e!==void 0}function qi(...e){return()=>{e.map(Ui)}}function $t(){}function Lr(e,t){return t(e),e}function Zi(e,t){return t(e)}function Ne(...e){return e}function he(e,t){return e(bt,t)}function se(e,t){e(_r,t)}function jn(e){e(Wt)}function je(e){return e(ns)}function q(e,t){return he(e,Ki(t,_r))}function Ue(e,t){const r=e(bt,o=>{r(),t(o)});return r}function Kn(e){let t,r;return o=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{o(t)},e)}}function ss(e,t){return e===t}function we(e=ss){let t;return r=>o=>{e(t,o)||(t=o,r(o))}}function re(e){return t=>r=>{e(r)&&t(r)}}function V(e){return t=>os(t,e)}function Je(e){return t=>()=>{t(e)}}function M(e,...t){const r=Yi(...t);return((o,s)=>{switch(o){case Wt:jn(e);return;case bt:return he(e,r(s))}})}function rt(e,t){return r=>o=>{r(t=e(t,o))}}function Dt(e){return t=>r=>{e>0?e--:t(r)}}function lt(e){let t=null,r;return o=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,o(t)},e))}}function ie(...e){const t=new Array(e.length);let r=0,o=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);he(a,d=>{const c=r;r=r|l,t[i]=d,c!==s&&r===s&&o&&(o(),o=null)})}),a=>i=>{const l=()=>{a([i].concat(t))};r===s?l():o=l}}function Yi(...e){return t=>e.reduceRight(Zi,t)}function Xi(e){let t,r;const o=()=>t==null?void 0:t();return function(s,a){switch(s){case bt:return a?r===a?void 0:(o(),r=a,t=he(e,a),t):(o(),$t);case Wt:o(),r=null;return}}}function H(e){let t=e;const r=ce();return((o,s)=>{switch(o){case _r:t=s;break;case bt:{s(t);break}case ns:return t}return r(o,s)})}function Me(e,t){return Lr(H(t),r=>q(e,r))}function ce(){const e=[];return((t,r)=>{switch(t){case _r:e.slice().forEach(o=>{o(r)});return;case Wt:e.splice(0,e.length);return;case bt:return e.push(r),()=>{const o=e.indexOf(r);o>-1&&e.splice(o,1)}}})}function ze(e){return Lr(ce(),t=>q(e,t))}function me(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:Ji(),singleton:r}}const Ji=()=>Symbol();function Qi(e){const t=new Map,r=({constructor:o,dependencies:s,id:a,singleton:i})=>{if(i&&t.has(a))return t.get(a);const l=o(s.map(d=>r(d)));return i&&t.set(a,l),l};return r(e)}function Se(...e){const t=ce(),r=new Array(e.length);let o=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);he(a,d=>{r[i]=d,o=o|l,o===s&&se(t,r)})}),function(a,i){switch(a){case Wt:{jn(t);return}case bt:return o===s&&i(r),he(t,i)}}}function te(e,t=ss){return M(e,we(t))}function ln(...e){return function(t,r){switch(t){case Wt:return;case bt:return qi(...e.map(o=>he(o,r)))}}}var Pe=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Pe||{});const el={0:"debug",3:"error",1:"log",2:"warn"},tl=()=>typeof globalThis>"u"?window:globalThis,wt=me(()=>{const e=H(3);return{log:H((t,r,o=1)=>{var s;const a=(s=tl().VIRTUOSO_LOG_LEVEL)!=null?s:je(e);o>=a&&console[el[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function _t(e,t,r){return kn(e,t,r).callbackRef}function kn(e,t,r){const o=K.useRef(null);let s=i=>{};const a=K.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const d=i[0].target;d.offsetParent!==null&&e(d)};r?l():requestAnimationFrame(l)}):null,[e,r]);return s=i=>{i&&t?(a==null||a.observe(i),o.current=i):(o.current&&(a==null||a.unobserve(o.current)),o.current=null)},{callbackRef:s,ref:o}}function rl(e,t,r,o,s,a,i,l,d){const c=K.useCallback(p=>{const u=nl(p.children,t,l?"offsetWidth":"offsetHeight",s);let f=p.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const x=f.lastElementChild.dataset.viewportType==="window";let b;x&&(b=f.ownerDocument.defaultView);const j=i?l?i.scrollLeft:i.scrollTop:x?l?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:l?f.scrollLeft:f.scrollTop,w=i?l?i.scrollWidth:i.scrollHeight:x?l?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:l?f.scrollWidth:f.scrollHeight,v=i?l?i.offsetWidth:i.offsetHeight:x?l?b.innerWidth:b.innerHeight:l?f.offsetWidth:f.offsetHeight;o({scrollHeight:w,scrollTop:Math.max(j,0),viewportHeight:v}),a==null||a(l?qn("column-gap",getComputedStyle(p).columnGap,s):qn("row-gap",getComputedStyle(p).rowGap,s)),u!==null&&e(u)},[e,t,s,a,i,o,l]);return kn(c,r,d)}function nl(e,t,r,o){const s=e.length;if(s===0)return null;const a=[];for(let i=0;i<s;i++){const l=e.item(i);if(l.dataset.index===void 0)continue;const d=parseInt(l.dataset.index),c=parseFloat(l.dataset.knownSize),p=t(l,r);if(p===0&&o("Zero-sized element, this should not happen",{child:l},Pe.ERROR),p===c)continue;const u=a[a.length-1];a.length===0||u.size!==p||u.endIndex!==d-1?a.push({endIndex:d,size:p,startIndex:d}):a[a.length-1].endIndex++}return a}function qn(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Pe.WARN),t==="normal"?0:parseInt(t??"0",10)}function as(e,t,r){const o=K.useRef(null),s=K.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const c=d.getBoundingClientRect(),p=c.width;let u,f;if(t){const x=t.getBoundingClientRect(),b=c.top-x.top;f=x.height-Math.max(0,b),u=b+t.scrollTop}else{const x=i.current.ownerDocument.defaultView;f=x.innerHeight-Math.max(0,c.top),u=c.top+x.scrollY}o.current={offsetTop:u,visibleHeight:f,visibleWidth:p},e(o.current)},[e,t]),{callbackRef:a,ref:i}=kn(s,!0,r),l=K.useCallback(()=>{s(i.current)},[s,i]);return K.useEffect(()=>{var d;if(t){t.addEventListener("scroll",l);const c=new ResizeObserver(()=>{requestAnimationFrame(l)});return c.observe(t),()=>{t.removeEventListener("scroll",l),c.unobserve(t)}}else{const c=(d=i.current)==null?void 0:d.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",l),c==null||c.addEventListener("resize",l),()=>{c==null||c.removeEventListener("scroll",l),c==null||c.removeEventListener("resize",l)}}},[l,t,i]),a}const Oe=me(()=>{const e=ce(),t=ce(),r=H(0),o=ce(),s=H(0),a=ce(),i=ce(),l=H(0),d=H(0),c=H(0),p=H(0),u=ce(),f=ce(),x=H(!1),b=H(!1),j=H(!1);return q(M(e,V(({scrollTop:w})=>w)),t),q(M(e,V(({scrollHeight:w})=>w)),i),q(t,s),{deviation:r,fixedFooterHeight:c,fixedHeaderHeight:d,footerHeight:p,headerHeight:l,horizontalDirection:b,scrollBy:f,scrollContainerState:e,scrollHeight:i,scrollingInProgress:x,scrollTo:u,scrollTop:t,skipAnimationFrameInResizeObserver:j,smoothScrollTargetReached:o,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),Yt={lvl:0};function is(e,t){const r=e.length;if(r===0)return[];let{index:o,value:s}=t(e[0]);const a=[];for(let i=1;i<r;i++){const{index:l,value:d}=t(e[i]);a.push({end:l-1,start:o,value:s}),o=l,s=d}return a.push({end:1/0,start:o,value:s}),a}function ve(e){return e===Yt}function Xt(e,t){if(!ve(e))return t===e.k?e.v:t<e.k?Xt(e.l,t):Xt(e.r,t)}function qe(e,t,r="k"){if(ve(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const o=qe(e.r,t,r);return o[0]===-1/0?[e.k,e.v]:o}return qe(e.l,t,r)}function Be(e,t,r){return ve(e)?ds(t,r,1):t===e.k?Te(e,{k:t,v:r}):t<e.k?Zn(Te(e,{l:Be(e.l,t,r)})):Zn(Te(e,{r:Be(e.r,t,r)}))}function Pt(){return Yt}function Bt(e,t,r){if(ve(e))return[];const o=qe(e,t)[0];return ol(dn(e,o,r))}function cn(e,t){if(ve(e))return Yt;const{k:r,l:o,r:s}=e;if(t===r){if(ve(o))return s;if(ve(s))return o;{const[a,i]=cs(o);return wr(Te(e,{k:a,l:ls(o),v:i}))}}else return t<r?wr(Te(e,{l:cn(o,t)})):wr(Te(e,{r:cn(s,t)}))}function Et(e){return ve(e)?[]:[...Et(e.l),{k:e.k,v:e.v},...Et(e.r)]}function dn(e,t,r){if(ve(e))return[];const{k:o,l:s,r:a,v:i}=e;let l=[];return o>t&&(l=l.concat(dn(s,t,r))),o>=t&&o<=r&&l.push({k:o,v:i}),o<=r&&(l=l.concat(dn(a,t,r))),l}function wr(e){const{l:t,lvl:r,r:o}=e;if(o.lvl>=r-1&&t.lvl>=r-1)return e;if(r>o.lvl+1){if(Vr(t))return us(Te(e,{lvl:r-1}));if(!ve(t)&&!ve(t.r))return Te(t.r,{l:Te(t,{r:t.r.l}),lvl:r,r:Te(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Vr(e))return un(Te(e,{lvl:r-1}));if(!ve(o)&&!ve(o.l)){const s=o.l,a=Vr(s)?o.lvl-1:o.lvl;return Te(s,{l:Te(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:un(Te(o,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Te(e,t){return ds(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function ls(e){return ve(e.r)?e.l:wr(Te(e,{r:ls(e.r)}))}function Vr(e){return ve(e)||e.lvl>e.r.lvl}function cs(e){return ve(e.r)?[e.k,e.v]:cs(e.r)}function ds(e,t,r,o=Yt,s=Yt){return{k:e,l:o,lvl:r,r:s,v:t}}function Zn(e){return un(us(e))}function us(e){const{l:t}=e;return!ve(t)&&t.lvl===e.lvl?Te(t,{r:Te(e,{l:t.r})}):e}function un(e){const{lvl:t,r}=e;return!ve(r)&&!ve(r.r)&&r.lvl===t&&r.r.lvl===t?Te(r,{l:Te(e,{r:r.l}),lvl:t+1}):e}function ol(e){return is(e,({k:t,v:r})=>({index:t,value:r}))}function fs(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Jt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Cn=me(()=>({recalcInProgress:H(!1)}),[],{singleton:!0});function ms(e,t,r){return e[Tr(e,t,r)]}function Tr(e,t,r,o=0){let s=e.length-1;for(;o<=s;){const a=Math.floor((o+s)/2),i=e[a],l=r(i,t);if(l===0)return a;if(l===-1){if(s-o<2)return a-1;s=a-1}else{if(s===o)return a;o=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function sl(e,t,r,o){const s=Tr(e,t,o),a=Tr(e,r,o,s);return e.slice(s,a+1)}function vt(e,t){return Math.round(e.getBoundingClientRect()[t])}function Or(e){return!ve(e.groupOffsetTree)}function Sn({index:e},t){return t===e?0:t<e?-1:1}function al(){return{groupIndices:[],groupOffsetTree:Pt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Pt()}}function il(e,t){let r=ve(e)?0:1/0;for(const o of t){const{endIndex:s,size:a,startIndex:i}=o;if(r=Math.min(r,i),ve(e)){e=Be(e,0,a);continue}const l=Bt(e,i-1,s+1);if(l.some(pl(o)))continue;let d=!1,c=!1;for(const{end:p,start:u,value:f}of l)d?(s>=u||a===f)&&(e=cn(e,u)):(c=f!==a,d=!0),p>s&&s>=u&&f!==a&&(e=Be(e,s+1,f));c&&(e=Be(e,i,a))}return[e,r]}function ll(e){return typeof e.groupIndex<"u"}function cl({offset:e},t){return t===e?0:t<e?-1:1}function Qt(e,t,r){if(t.length===0)return 0;const{index:o,offset:s,size:a}=ms(t,e,Sn),i=e-o,l=a*i+(i-1)*r+s;return l>0?l+r:l}function ps(e,t){if(!Or(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function hs(e,t,r){if(ll(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?r:e.index;let s=ps(o,t);return s=Math.max(0,s,Math.min(r,s)),s}}function dl(e,t,r,o=0){return o>0&&(t=Math.max(t,ms(e,o,Sn).offset)),is(sl(e,t,r,cl),ml)}function ul(e,[t,r,o,s]){t.length>0&&o("received item sizes",t,Pe.DEBUG);const a=e.sizeTree;let i=a,l=0;if(r.length>0&&ve(a)&&t.length===2){const f=t[0].size,x=t[1].size;i=r.reduce((b,j)=>Be(Be(b,j,f),j+1,x),i)}else[i,l]=il(i,t);if(i===a)return e;const{lastIndex:d,lastOffset:c,lastSize:p,offsetTree:u}=fn(e.offsetTree,l,i,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,x)=>Be(f,x,Qt(x,u,s)),Pt()),lastIndex:d,lastOffset:c,lastSize:p,offsetTree:u,sizeTree:i}}function fl(e){return Et(e).map(({k:t,v:r},o,s)=>{const a=s[o+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function Yn(e,t){let r=0,o=0;for(;r<e;)r+=t[o+1]-t[o]-1,o++;return o-(r===e?0:1)}function fn(e,t,r,o){let s=e,a=0,i=0,l=0,d=0;if(t!==0){d=Tr(s,t-1,Sn),l=s[d].offset;const c=qe(r,t-1);a=c[0],i=c[1],s.length&&s[d].size===qe(r,t)[1]&&(d-=1),s=s.slice(0,d+1)}else s=[];for(const{start:c,value:p}of Bt(r,t,1/0)){const u=c-a,f=u*i+l+u*o;s.push({index:c,offset:f,size:p}),a=c,l=f,i=p}return{lastIndex:a,lastOffset:l,lastSize:i,offsetTree:s}}function ml(e){return{index:e.index,value:e}}function pl(e){const{endIndex:t,size:r,startIndex:o}=e;return s=>s.start===o&&(s.end===t||s.end===1/0)&&s.value===r}const hl={offsetHeight:"height",offsetWidth:"width"},ot=me(([{log:e},{recalcInProgress:t}])=>{const r=ce(),o=ce(),s=Me(o,0),a=ce(),i=ce(),l=H(0),d=H([]),c=H(void 0),p=H(void 0),u=H(void 0),f=H(void 0),x=H((m,y)=>vt(m,hl[y])),b=H(void 0),j=H(0),w=al(),v=Me(M(r,ie(d,e,j),rt(ul,w),we()),w),g=Me(M(d,we(),rt((m,y)=>({current:y,prev:m.current}),{current:[],prev:[]}),V(({prev:m})=>m)),[]);q(M(d,re(m=>m.length>0),ie(v,j),V(([m,y,k])=>{const T=m.reduce((S,A,R)=>Be(S,A,Qt(A,y.offsetTree,k)||R),Pt());return{...y,groupIndices:m,groupOffsetTree:T}})),v),q(M(o,ie(v),re(([m,{lastIndex:y}])=>m<y),V(([m,{lastIndex:y,lastSize:k}])=>[{endIndex:y,size:k,startIndex:m}])),r),q(c,p);const I=Me(M(c,V(m=>m===void 0)),!0);q(M(p,re(m=>m!==void 0&&ve(je(v).sizeTree)),V(m=>{const y=je(u),k=je(d).length>0;return y?k?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:m,startIndex:1}]:[]:[{endIndex:0,size:m,startIndex:0}]})),r),q(M(f,re(m=>m!==void 0&&m.length>0&&ve(je(v).sizeTree)),V(m=>{const y=[];let k=m[0],T=0;for(let S=1;S<m.length;S++){const A=m[S];A!==k&&(y.push({endIndex:S-1,size:k,startIndex:T}),k=A,T=S)}return y.push({endIndex:m.length-1,size:k,startIndex:T}),y})),r),q(M(d,ie(u,p),re(([,m,y])=>m!==void 0&&y!==void 0),V(([m,y,k])=>{const T=[];for(let S=0;S<m.length;S++){const A=m[S],R=m[S+1];T.push({startIndex:A,endIndex:A,size:y}),R!==void 0&&T.push({startIndex:A+1,endIndex:R-1,size:k})}return T})),r);const N=ze(M(r,ie(v),rt(({sizes:m},[y,k])=>({changed:k!==m,sizes:k}),{changed:!1,sizes:w}),V(m=>m.changed)));he(M(l,rt((m,y)=>({diff:m.prev-y,prev:y}),{diff:0,prev:0}),V(m=>m.diff)),m=>{const{groupIndices:y}=je(v);if(m>0)se(t,!0),se(a,m+Yn(m,y));else if(m<0){const k=je(g);k.length>0&&(m-=Yn(-m,k)),se(i,m)}}),he(M(l,ie(e)),([m,y])=>{m<0&&y("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},Pe.ERROR)});const C=ze(a);q(M(a,ie(v),V(([m,y])=>{const k=y.groupIndices.length>0,T=[],S=y.lastSize;if(k){const A=Xt(y.sizeTree,0);let R=0,F=0;for(;R<m;){const D=y.groupIndices[F],_=y.groupIndices.length===F+1?1/0:y.groupIndices[F+1]-D-1;T.push({endIndex:D,size:A,startIndex:D}),T.push({endIndex:D+1+_-1,size:S,startIndex:D+1}),F++,R+=_+1}const B=Et(y.sizeTree);return R!==m&&B.shift(),B.reduce((D,{k:_,v:P})=>{let U=D.ranges;return D.prevSize!==0&&(U=[...D.ranges,{endIndex:_+m-1,size:D.prevSize,startIndex:D.prevIndex}]),{prevIndex:_+m,prevSize:P,ranges:U}},{prevIndex:m,prevSize:0,ranges:T}).ranges}return Et(y.sizeTree).reduce((A,{k:R,v:F})=>({prevIndex:R+m,prevSize:F,ranges:[...A.ranges,{endIndex:R+m-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:S,ranges:[]}).ranges})),r);const E=ze(M(i,ie(v,j),V(([m,{offsetTree:y},k])=>{const T=-m;return Qt(T,y,k)})));return q(M(i,ie(v,j),V(([m,y,k])=>{if(y.groupIndices.length>0){if(ve(y.sizeTree))return y;let T=Pt();const S=je(g);let A=0,R=0,F=0;for(;A<-m;){F=S[R];const B=S[R+1]-F-1;R++,A+=B+1}if(T=Et(y.sizeTree).reduce((B,{k:D,v:_})=>Be(B,Math.max(0,D+m),_),T),A!==-m){const B=Xt(y.sizeTree,F);T=Be(T,0,B);const D=qe(y.sizeTree,-m+1)[1];T=Be(T,1,D)}return{...y,sizeTree:T,...fn(y.offsetTree,0,T,k)}}else{const T=Et(y.sizeTree).reduce((S,{k:A,v:R})=>Be(S,Math.max(0,A+m),R),Pt());return{...y,sizeTree:T,...fn(y.offsetTree,0,T,k)}}})),v),{beforeUnshiftWith:C,data:b,defaultItemSize:p,firstItemIndex:l,fixedItemSize:c,fixedGroupSize:u,gap:j,groupIndices:d,heightEstimates:f,itemSize:x,listRefresh:N,shiftWith:i,shiftWithOffset:E,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:o,trackItemSizes:I,unshiftWith:a}},Ne(wt,Cn),{singleton:!0});function gl(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const gs=me(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:o,scrollTop:s}])=>{const a=ce(),i=ce(),l=ze(M(a,V(gl)));return q(M(l,V(d=>d.totalCount)),r),q(M(l,V(d=>d.groupIndices)),e),q(M(Se(s,t,o),re(([d,c])=>Or(c)),V(([d,c,p])=>qe(c.groupOffsetTree,Math.max(d-p,0),"v")[0]),we(),V(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},Ne(ot,Oe)),Nt=me(([{log:e}])=>{const t=H(!1),r=ze(M(t,re(o=>o),we()));return he(t,o=>{o&&je(e)("props updated",{},Pe.DEBUG)}),{didMount:r,propsReady:t}},Ne(wt),{singleton:!0}),xl=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function xs(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!xl)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ir=me(([{gap:e,listRefresh:t,sizes:r,totalCount:o},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:i,headerHeight:l,scrollingInProgress:d,scrollTo:c,smoothScrollTargetReached:p,viewportHeight:u},{log:f}])=>{const x=ce(),b=ce(),j=H(0);let w=null,v=null,g=null;function I(){w&&(w(),w=null),g&&(g(),g=null),v&&(clearTimeout(v),v=null),se(d,!1)}return q(M(x,ie(r,u,o,j,l,i,f),ie(e,a,s),V(([[N,C,E,m,y,k,T,S],A,R,F])=>{const B=xs(N),{align:D,behavior:_,offset:P}=B,U=m-1,Q=hs(B,C,U);let z=Qt(Q,C.offsetTree,A)+k;D==="end"?(z+=R+qe(C.sizeTree,Q)[1]-E+F,Q===U&&(z+=T)):D==="center"?z+=(R+qe(C.sizeTree,Q)[1]-E+F)/2:z-=y,P&&(z+=P);const Y=L=>{I(),L?(S("retrying to scroll to",{location:N},Pe.DEBUG),se(x,N)):(se(b,!0),S("list did not change, scroll successful",{},Pe.DEBUG))};if(I(),_==="smooth"){let L=!1;g=he(t,W=>{L=L||W}),w=Ue(p,()=>{Y(L)})}else w=Ue(M(t,vl(150)),Y);return v=setTimeout(()=>{I()},1200),se(d,!0),S("scrolling from index to",{behavior:_,index:Q,top:z},Pe.DEBUG),{behavior:_,top:z}})),c),{scrollTargetReached:b,scrollToIndex:x,topListHeight:j}},Ne(ot,Oe,wt),{singleton:!0});function vl(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(r))}}}function Tn(e,t){e==0?t():requestAnimationFrame(()=>{Tn(e-1,t)})}function En(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const lr=me(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:o},{scrollTargetReached:s,scrollToIndex:a},{didMount:i}])=>{const l=H(!0),d=H(0),c=H(!0);return q(M(i,ie(d),re(([p,u])=>!!u),Je(!1)),l),q(M(i,ie(d),re(([p,u])=>!!u),Je(!1)),c),he(M(Se(t,i),ie(l,r,e,c),re(([[,p],u,{sizeTree:f},x,b])=>p&&(!ve(f)||In(x))&&!u&&!b),ie(d)),([,p])=>{Ue(s,()=>{se(c,!0)}),Tn(4,()=>{Ue(o,()=>{se(l,!0)}),se(a,p)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:l}},Ne(ot,Oe,ir,Nt),{singleton:!0});function vs(e,t){return Math.abs(e-t)<1.01}const er="up",qt="down",yl="none",bl={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},wl=0,cr=me(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:o,scrollTop:s,viewportHeight:a}])=>{const i=H(!1),l=H(!0),d=ce(),c=ce(),p=H(4),u=H(wl),f=Me(M(ln(M(te(s),Dt(1),Je(!0)),M(te(s),Dt(1),Je(!1),Kn(100))),we()),!1),x=Me(M(ln(M(r,Je(!0)),M(r,Je(!1),Kn(200))),we()),!1);q(M(Se(te(s),te(u)),V(([g,I])=>g<=I),we()),l),q(M(l,lt(50)),c);const b=ze(M(Se(o,te(a),te(t),te(e),te(p)),rt((g,[{scrollHeight:I,scrollTop:N},C,E,m,y])=>{const k=N+C-I>-y,T={scrollHeight:I,scrollTop:N,viewportHeight:C};if(k){let A,R;return N>g.state.scrollTop?(A="SCROLLED_DOWN",R=g.state.scrollTop-N):(A="SIZE_DECREASED",R=g.state.scrollTop-N||g.scrollTopDelta),{atBottom:!0,atBottomBecause:A,scrollTopDelta:R,state:T}}let S;return T.scrollHeight>g.state.scrollHeight?S="SIZE_INCREASED":C<g.state.viewportHeight?S="VIEWPORT_HEIGHT_DECREASING":N<g.state.scrollTop?S="SCROLLING_UPWARDS":S="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:S,state:T}},bl),we((g,I)=>g&&g.atBottom===I.atBottom))),j=Me(M(o,rt((g,{scrollHeight:I,scrollTop:N,viewportHeight:C})=>{if(vs(g.scrollHeight,I))return{changed:!1,jump:0,scrollHeight:I,scrollTop:N};{const E=I-(N+C)<1;return g.scrollTop!==N&&E?{changed:!0,jump:g.scrollTop-N,scrollHeight:I,scrollTop:N}:{changed:!0,jump:0,scrollHeight:I,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),re(g=>g.changed),V(g=>g.jump)),0);q(M(b,V(g=>g.atBottom)),i),q(M(i,lt(50)),d);const w=H(qt);q(M(o,V(({scrollTop:g})=>g),we(),rt((g,I)=>je(x)?{direction:g.direction,prevScrollTop:I}:{direction:I<g.prevScrollTop?er:qt,prevScrollTop:I},{direction:qt,prevScrollTop:0}),V(g=>g.direction)),w),q(M(o,lt(50),Je(yl)),w);const v=H(0);return q(M(f,re(g=>!g),Je(0)),v),q(M(s,lt(100),ie(f),re(([g,I])=>I),rt(([g,I],[N])=>[I,N],[0,0]),V(([g,I])=>I-g)),v),{atBottomState:b,atBottomStateChange:d,atBottomThreshold:p,atTopStateChange:c,atTopThreshold:u,isAtBottom:i,isAtTop:l,isScrolling:f,lastJumpDueToItemResize:j,scrollDirection:w,scrollVelocity:v}},Ne(Oe)),tr="top",rr="bottom",Xn="none";function Jn(e,t,r){return typeof e=="number"?r===er&&t===tr||r===qt&&t===rr?e:0:r===er?t===tr?e.main:e.reverse:t===rr?e.main:e.reverse}function Qn(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const An=me(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:o,viewportHeight:s}])=>{const a=ce(),i=H(0),l=H(0),d=H(0),c=Me(M(Se(te(o),te(s),te(r),te(a,Jt),te(d),te(i),te(t),te(e),te(l)),V(([p,u,f,[x,b],j,w,v,g,I])=>{const N=p-g,C=w+v,E=Math.max(f-N,0);let m=Xn;const y=Qn(I,tr),k=Qn(I,rr);return x-=g,x+=f+v,b+=f+v,b-=g,x>p+C-y&&(m=er),b<p-E+u+k&&(m=qt),m!==Xn?[Math.max(N-f-Jn(j,tr,m)-y,0),N-E-v+u+Jn(j,rr,m)+k]:null}),re(p=>p!=null),we(Jt)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:c}},Ne(Oe),{singleton:!0});function Nl(e,t,r){if(Or(t)){const o=ps(e,t);return[{index:qe(t.groupOffsetTree,o)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:o,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const Gr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Nr(e,t,r,o,s,a){const{lastIndex:i,lastOffset:l,lastSize:d}=s;let c=0,p=0;if(e.length>0){c=e[0].offset;const j=e[e.length-1];p=j.offset+j.size}const u=r-i,f=l+u*d+(u-1)*o,x=c,b=f-p;return{bottom:p,firstItemIndex:a,items:eo(e,s,a),offsetBottom:b,offsetTop:c,top:x,topItems:eo(t,s,a),topListHeight:t.reduce((j,w)=>w.size+j,0),totalCount:r}}function ys(e,t,r,o,s,a){let i=0;if(r.groupIndices.length>0)for(const p of r.groupIndices){if(p-i>=e)break;i++}const l=e+i,d=En(t,l),c=Array.from({length:l}).map((p,u)=>({data:a[u+d],index:u+d,offset:0,size:0}));return Nr(c,[],l,s,r,o)}function eo(e,t,r){if(e.length===0)return[];if(!Or(t))return e.map(c=>({...c,index:c.index+r,originalIndex:c.index}));const o=e[0].index,s=e[e.length-1].index,a=[],i=Bt(t.groupOffsetTree,o,s);let l,d=0;for(const c of e){(!l||l.end<c.index)&&(l=i.shift(),d=t.groupIndices.indexOf(l.start));let p;c.index===l.start?p={index:d,type:"group"}:p={groupIndex:d,index:c.index-(d+1)+r},a.push({...p,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return a}function to(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const Lt=me(([{data:e,firstItemIndex:t,gap:r,sizes:o,totalCount:s},a,{listBoundary:i,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:c,scrolledToInitialItem:p},{topListHeight:u},f,{didMount:x},{recalcInProgress:b}])=>{const j=H([]),w=H(0),v=ce(),g=H(0);q(a.topItemsIndexes,j);const I=Me(M(Se(x,b,te(d,Jt),te(s),te(o),te(c),p,te(j),te(t),te(r),te(g),e),re(([m,y,,k,,,,,,,,T])=>{const S=T&&T.length!==k;return m&&!y&&!S}),V(([,,[m,y],k,T,S,A,R,F,B,D,_])=>{var P,U,Q,z;const Y=T,{offsetTree:L,sizeTree:W}=Y,$=je(w);if(k===0)return{...Gr,totalCount:k};if(m===0&&y===0)return $===0?{...Gr,totalCount:k}:ys($,S,T,F,B,_||[]);if(ve(W))return $>0?null:Nr(Nl(En(S,k),Y,_),[],k,B,Y,F);const ee=[];if(R.length>0){const X=R[0],ae=R[R.length-1];let xe=0;for(const ye of Bt(W,X,ae)){const le=ye.value,ue=Math.max(ye.start,X),ke=Math.min(ye.end,ae);for(let Ce=ue;Ce<=ke;Ce++)ee.push({data:_==null?void 0:_[Ce],index:Ce,offset:xe,size:le}),xe+=le}}if(!A)return Nr([],ee,k,B,Y,F);const de=R.length>0?R[R.length-1]+1:0,O=dl(L,m,y,de);if(O.length===0)return null;const G=k-1,oe=Lr([],X=>{for(const ae of O){const xe=ae.value;let ye=xe.offset,le=ae.start;const ue=xe.size;if(xe.offset<m){le+=Math.floor((m-xe.offset+B)/(ue+B));const Ce=le-ae.start;ye+=Ce*ue+Ce*B}le<de&&(ye+=(de-le)*ue,le=de);const ke=Math.min(ae.end,G);for(let Ce=le;Ce<=ke&&!(ye>=y);Ce++)X.push({data:_==null?void 0:_[Ce],index:Ce,offset:ye,size:ue}),ye+=ue+B}}),ge=to(D,tr),Ee=to(D,rr);if(oe.length>0&&(ge>0||Ee>0)){const X=oe[0],ae=oe[oe.length-1];if(ge>0&&X.index>de){const xe=Math.min(ge,X.index-de),ye=[];let le=X.offset;for(let ue=X.index-1;ue>=X.index-xe;ue--){const ke=(U=(P=Bt(W,ue,ue)[0])==null?void 0:P.value)!=null?U:X.size;le-=ke+B,ye.unshift({data:_==null?void 0:_[ue],index:ue,offset:le,size:ke})}oe.unshift(...ye)}if(Ee>0&&ae.index<G){const xe=Math.min(Ee,G-ae.index);let ye=ae.offset+ae.size+B;for(let le=ae.index+1;le<=ae.index+xe;le++){const ue=(z=(Q=Bt(W,le,le)[0])==null?void 0:Q.value)!=null?z:ae.size;oe.push({data:_==null?void 0:_[le],index:le,offset:ye,size:ue}),ye+=ue+B}}}return Nr(oe,ee,k,B,Y,F)}),re(m=>m!==null),we()),Gr);q(M(e,re(In),V(m=>m==null?void 0:m.length)),s),q(M(I,V(m=>m.topListHeight)),u),q(u,l),q(M(I,V(m=>[m.top,m.bottom])),i),q(M(I,V(m=>m.items)),v);const N=ze(M(I,re(({items:m})=>m.length>0),ie(s,e),re(([{items:m},y])=>m[m.length-1].originalIndex===y-1),V(([,m,y])=>[m-1,y]),we(Jt),V(([m])=>m))),C=ze(M(I,lt(200),re(({items:m,topItems:y})=>m.length>0&&m[0].originalIndex===y.length),V(({items:m})=>m[0].index),we())),E=ze(M(I,re(({items:m})=>m.length>0),V(({items:m})=>{let y=0,k=m.length-1;for(;m[y].type==="group"&&y<k;)y++;for(;m[k].type==="group"&&k>y;)k--;return{endIndex:m[k].index,startIndex:m[y].index}}),we(fs)));return{endReached:N,initialItemCount:w,itemsRendered:v,listState:I,minOverscanItemCount:g,rangeChanged:E,startReached:C,topItemsIndexes:j,...f}},Ne(ot,gs,An,lr,ir,cr,Nt,Cn),{singleton:!0}),bs=me(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:o},{listState:s}])=>{const a=ce(),i=Me(M(Se(r,e,o,t,s),V(([l,d,c,p,u])=>l+d+c+p+u.offsetBottom+u.bottom)),0);return q(te(i),a),{totalListHeight:i,totalListHeightChanged:a}},Ne(Oe,Lt),{singleton:!0}),Il=me(([{viewportHeight:e},{totalListHeight:t}])=>{const r=H(!1),o=Me(M(Se(r,e,t),re(([s])=>s),V(([,s,a])=>Math.max(0,s-a)),lt(0),we()),0);return{alignToBottom:r,paddingTopAddition:o}},Ne(Oe,bs),{singleton:!0}),ws=me(()=>({context:H(null)})),jl=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:o,...s},viewportBottom:a,viewportTop:i})=>t<i?{...s,align:r??"start",behavior:o}:e>a?{...s,align:r??"end",behavior:o}:null,Ns=me(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:i,scrollTop:l,viewportHeight:d},{scrollToIndex:c}])=>{const p=ce();return q(M(p,ie(t,d,r,a,s,o,l),ie(e),V(([[u,f,x,b,j,w,v,g],I])=>{const{align:N,behavior:C,calculateViewLocation:E=jl,done:m,...y}=u,k=hs(u,f,b-1),T=Qt(k,f.offsetTree,I)+j+w,S=T+qe(f.sizeTree,k)[1],A=g+w,R=g+x-v,F=E({itemBottom:S,itemTop:T,locationParams:{align:N,behavior:C,...y},viewportBottom:R,viewportTop:A});return F?m&&Ue(M(i,re(B=>!B),Dt(je(i)?1:2)),m):m==null||m(),F}),re(u=>u!==null)),c),{scrollIntoView:p}},Ne(ot,Oe,ir,Lt,wt),{singleton:!0});function ro(e){return e?e==="smooth"?"smooth":"auto":!1}const kl=(e,t)=>typeof e=="function"?ro(e(t)):t&&ro(e),Cl=me(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:o},{atBottomState:s,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:d,propsReady:c},{log:p},{scrollingInProgress:u},{context:f},{scrollIntoView:x}])=>{const b=H(!1),j=ce();let w=null;function v(C){se(i,{align:"end",behavior:C,index:"LAST"})}he(M(Se(M(te(t),Dt(1)),d),ie(te(b),a,l,u),V(([[C,E],m,y,k,T])=>{let S=E&&k,A="auto";return S&&(A=kl(m,y||T),S=S&&!!A),{followOutputBehavior:A,shouldFollow:S,totalCount:C}}),re(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:E})=>{w&&(w(),w=null),je(r)?requestAnimationFrame(()=>{je(p)("following output to ",{totalCount:E},Pe.DEBUG),v(C)}):w=Ue(e,()=>{je(p)("following output to ",{totalCount:E},Pe.DEBUG),v(C),w=null})});function g(C){const E=Ue(s,m=>{C&&!m.atBottom&&m.notAtBottomBecause==="SIZE_INCREASED"&&!w&&(je(p)("scrolling to bottom due to increased size",{},Pe.DEBUG),v("auto"))});setTimeout(E,100)}he(M(Se(te(b),t,c),re(([C,,E])=>C&&E),rt(({value:C},[,E])=>({refreshed:C===E,value:E}),{refreshed:!1,value:0}),re(({refreshed:C})=>C),ie(b,t)),([,C])=>{je(l)&&g(C!==!1)}),he(j,()=>{g(je(b)!==!1)}),he(Se(te(b),s),([C,E])=>{C&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const I=H(null),N=ce();return q(ln(M(te(o),V(C=>{var E;return(E=C==null?void 0:C.length)!=null?E:0})),M(te(t))),N),he(M(Se(M(N,Dt(1)),d),ie(te(I),l,u,f),V(([[C,E],m,y,k,T])=>E&&y&&(m==null?void 0:m({context:T,totalCount:C,scrollingInProgress:k}))),re(C=>!!C),lt(0)),C=>{w&&(w(),w=null),je(r)?requestAnimationFrame(()=>{je(p)("scrolling into view",{}),se(x,C)}):w=Ue(e,()=>{je(p)("scrolling into view",{}),se(x,C),w=null})}),{autoscrollToBottom:j,followOutput:b,scrollIntoViewOnChange:I}},Ne(ot,cr,ir,lr,Nt,wt,Oe,ws,Ns)),Sl=me(([{data:e,firstItemIndex:t,gap:r,sizes:o},{initialTopMostItemIndex:s},{initialItemCount:a,listState:i},{didMount:l}])=>(q(M(l,ie(a),re(([,d])=>d!==0),ie(s,o,t,r,e),V(([[,d],c,p,u,f,x=[]])=>ys(d,c,p,u,f,x))),i),{}),Ne(ot,lr,Lt,Nt),{singleton:!0}),Tl=me(([{didMount:e},{scrollTo:t},{listState:r}])=>{const o=H(0);return he(M(e,ie(o),re(([,s])=>s!==0),V(([,s])=>({top:s}))),s=>{Ue(M(r,Dt(1),re(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{se(t,s)})})}),{initialScrollTop:o}},Ne(Nt,Oe,Lt),{singleton:!0}),Is=me(([{scrollVelocity:e}])=>{const t=H(!1),r=ce(),o=H(!1);return q(M(e,ie(o,t,r),re(([s,a])=>!!a),V(([s,a,i,l])=>{const{enter:d,exit:c}=a;if(i){if(c(s,l))return!1}else if(d(s,l))return!0;return i}),we()),t),he(M(Se(t,e,r),ie(o)),([[s,a,i],l])=>{s&&l&&l.change&&l.change(a,i)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:r,scrollVelocity:e}},Ne(cr),{singleton:!0}),Rn=me(([{scrollContainerState:e,scrollTo:t}])=>{const r=ce(),o=ce(),s=ce(),a=H(!1),i=H(void 0);return q(M(Se(r,o),V(([{scrollHeight:l,scrollTop:d,viewportHeight:c},{offsetTop:p}])=>({scrollHeight:l,scrollTop:Math.max(0,d-p),viewportHeight:c}))),e),q(M(t,ie(o),V(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),s),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:o}},Ne(Oe)),El=me(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:o},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:d}])=>{const c=ce(),p=H(void 0),u=H(null),f=H(null);return q(l,u),q(d,f),he(M(c,ie(t,o,i,u,f,r)),([x,b,j,w,v,g,I])=>{const N=fl(b.sizeTree);w&&v!==null&&g!==null&&(j=v.scrollTop-g.offsetTop),j-=I,x({ranges:N,scrollTop:j})}),q(M(p,re(In),V(Al)),s),q(M(a,ie(p),re(([,x])=>x!==void 0),we(),V(([,x])=>x.ranges)),e),{getState:c,restoreStateFrom:p}},Ne(ot,Oe,lr,Nt,Rn));function Al(e){return{align:"start",index:0,offset:e.scrollTop}}const Rl=me(([{topItemsIndexes:e}])=>{const t=H(0);return q(M(t,re(r=>r>=0),V(r=>Array.from({length:r}).map((o,s)=>s))),e),{topItemCount:t}},Ne(Lt));function js(e){let t=!1,r;return(()=>(t||(t=!0,r=e()),r))}const Dl=js(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ml=me(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:o},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:l},{listState:d},{beforeUnshiftWith:c,gap:p,shiftWithOffset:u,sizes:f},{log:x},{recalcInProgress:b}])=>{const j=ze(M(d,ie(i),rt(([,v,g,I],[{bottom:N,items:C,offsetBottom:E,totalCount:m},y])=>{const k=N+E;let T=0;return g===m&&v.length>0&&C.length>0&&(C[0].originalIndex===0&&v[0].originalIndex===0||(T=k-I,T!==0&&(T+=y))),[T,C,m,k]},[0,[],0,0]),re(([v])=>v!==0),ie(o,l,r,s,x,b),re(([,v,g,I,,,N])=>!N&&!I&&v!==0&&g===er),V(([[v],,,,,g])=>(g("Upward scrolling compensation",{amount:v},Pe.DEBUG),v))));function w(v){v>0?(se(t,{behavior:"auto",top:-v}),se(e,0)):(se(e,0),se(t,{behavior:"auto",top:-v}))}return he(M(j,ie(e,a)),([v,g,I])=>{I&&Dl()?se(e,g-v):w(-v)}),he(M(Se(Me(a,!1),e,b),re(([v,g,I])=>!v&&!I&&g!==0),V(([v,g])=>g),lt(1)),w),q(M(u,V(v=>({top:-v}))),t),he(M(c,ie(f,p),V(([v,{groupIndices:g,lastSize:I,sizeTree:N},C])=>{function E(m){return m*(I+C)}if(g.length===0)return E(v);{let m=0;const y=Xt(N,0);let k=0,T=0;for(;k<v;){k++,m+=y;let S=g.length===T+1?1/0:g[T+1]-g[T]-1;k+S>v&&(m-=y,S=v-k+1),k+=S,m+=E(S),T++}return m}})),v=>{se(e,v),requestAnimationFrame(()=>{se(t,{top:v}),requestAnimationFrame(()=>{se(e,0),se(b,!1)})})}),{deviation:e}},Ne(Oe,cr,Lt,ot,wt,Cn)),_l=me(([e,t,r,o,s,a,i,l,d,c,p])=>({...e,...t,...r,...o,...s,...a,...i,...l,...d,...c,...p}),Ne(An,Sl,Nt,Is,bs,Tl,Il,Rn,Ns,wt,ws)),ks=me(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:o,fixedGroupSize:s,gap:a,groupIndices:i,heightEstimates:l,itemSize:d,sizeRanges:c,sizes:p,statefulTotalCount:u,totalCount:f,trackItemSizes:x},{initialItemFinalLocationReached:b,initialTopMostItemIndex:j,scrolledToInitialItem:w},v,g,I,N,{scrollToIndex:C},E,{topItemCount:m},{groupCounts:y},k])=>{const{listState:T,minOverscanItemCount:S,topItemsIndexes:A,rangeChanged:R,...F}=N;return q(R,k.scrollSeekRangeChanged),q(M(k.windowViewportRect,V(B=>B.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:o,fixedGroupHeight:s,gap:a,groupCounts:y,heightEstimates:l,initialItemFinalLocationReached:b,initialTopMostItemIndex:j,scrolledToInitialItem:w,sizeRanges:c,topItemCount:m,topItemsIndexes:A,totalCount:f,...I,groupIndices:i,itemSize:d,listState:T,minOverscanItemCount:S,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:x,rangeChanged:R,...F,...k,...v,sizes:p,...g}},Ne(ot,lr,Oe,El,Cl,Lt,ir,Ml,Rl,gs,_l));function Ll(e,t){const r={},o={};let s=0;const a=e.length;for(;s<a;)o[e[s]]=1,s+=1;for(const i in t)Object.hasOwn(o,i)||(r[i]=t[i]);return r}const gr=typeof document<"u"?K.useLayoutEffect:K.useEffect;function Cs(e,t,r){const o=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),l=K.createContext({});function d(w,v){w.propsReady&&se(w.propsReady,!1);for(const g of o){const I=w[t.required[g]];se(I,v[g])}for(const g of s)if(g in v){const I=w[t.optional[g]];se(I,v[g])}w.propsReady&&se(w.propsReady,!0)}function c(w){return a.reduce((v,g)=>(v[g]=I=>{const N=w[t.methods[g]];se(N,I)},v),{})}function p(w){return i.reduce((v,g)=>(v[g]=Xi(w[t.events[g]]),v),{})}const u=K.forwardRef((w,v)=>{const{children:g,...I}=w,[N]=K.useState(()=>Lr(Qi(e),m=>{d(m,I)})),[C]=K.useState(Un(p,N));gr(()=>{for(const m of i)m in I&&he(C[m],I[m]);return()=>{Object.values(C).map(jn)}},[I,C,N]),gr(()=>{d(N,I)}),K.useImperativeHandle(v,Gn(c(N)));const E=r;return n.jsx(l.Provider,{value:N,children:r?n.jsx(E,{...Ll([...o,...s,...i],I),children:g}):g})}),f=w=>{const v=K.useContext(l);return K.useCallback(g=>{se(v[w],g)},[v,w])},x=w=>{const v=K.useContext(l)[w],g=K.useCallback(I=>he(v,I),[v]);return K.useSyncExternalStore(g,()=>je(v),()=>je(v))},b=w=>{const v=K.useContext(l)[w],[g,I]=K.useState(Un(je,v));return gr(()=>he(v,N=>{N!==g&&I(Gn(N))}),[v,g]),g},j=K.version.startsWith("18")?x:b;return{Component:u,useEmitter:(w,v)=>{const g=K.useContext(l)[w];gr(()=>he(g,v),[v,g])},useEmitterValue:j,usePublisher:f}}const Ss=K.createContext(void 0),Ts=K.createContext(void 0),Es=typeof document<"u"?K.useLayoutEffect:K.useEffect;function Ur(e){return"self"in e}function Ol(e){return"body"in e}function As(e,t,r,o=$t,s,a){const i=K.useRef(null),l=K.useRef(null),d=K.useRef(null),c=K.useCallback(f=>{let x,b,j;const w=f.target;if(Ol(w)||Ur(w)){const g=Ur(w)?w:w.defaultView;j=a?g.scrollX:g.scrollY,x=a?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight,b=a?g.innerWidth:g.innerHeight}else j=a?w.scrollLeft:w.scrollTop,x=a?w.scrollWidth:w.scrollHeight,b=a?w.offsetWidth:w.offsetHeight;const v=()=>{e({scrollHeight:x,scrollTop:Math.max(j,0),viewportHeight:b})};f.suppressFlushSync?v():zo.flushSync(v),l.current!==null&&(j===l.current||j<=0||j===x-b)&&(l.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);K.useEffect(()=>{const f=s||i.current;return o(s||i.current),c({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",c,{passive:!0}),()=>{o(null),f.removeEventListener("scroll",c)}},[i,c,r,o,s]);function p(f){const x=i.current;if(!x||(a?"offsetWidth"in x&&x.offsetWidth===0:"offsetHeight"in x&&x.offsetHeight===0))return;const b=f.behavior==="smooth";let j,w,v;Ur(x)?(w=Math.max(vt(x.document.documentElement,a?"width":"height"),a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight),j=a?x.innerWidth:x.innerHeight,v=a?window.scrollX:window.scrollY):(w=x[a?"scrollWidth":"scrollHeight"],j=vt(x,a?"width":"height"),v=x[a?"scrollLeft":"scrollTop"]);const g=w-j;if(f.top=Math.ceil(Math.max(Math.min(g,f.top),0)),vs(j,w)||f.top===v){e({scrollHeight:w,scrollTop:v,viewportHeight:j}),b&&t(!0);return}b?(l.current=f.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,t(!0)},1e3)):l.current=null,a&&(f={behavior:f.behavior,left:f.top}),x.scrollTo(f)}function u(f){a&&(f={behavior:f.behavior,left:f.top}),i.current.scrollBy(f)}return{scrollByCallback:u,scrollerRef:i,scrollToCallback:p}}const Kr="-webkit-sticky",no="sticky",Dn=js(()=>{if(typeof document>"u")return no;const e=document.createElement("div");return e.style.position=Kr,e.style.position===Kr?Kr:no});function Mn(e){return e}const Hl=me(()=>{const e=H(l=>`Item ${l}`),t=H(l=>`Group ${l}`),r=H({}),o=H(Mn),s=H("div"),a=H($t),i=(l,d=null)=>Me(M(r,V(c=>c[l]),we()),d);return{components:r,computeItemKey:o,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:s,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Fl=me(([e,t])=>({...e,...t}),Ne(ks,Hl)),Pl=({height:e})=>n.jsx("div",{style:{height:e}}),Bl={overflowAnchor:"none",position:Dn(),zIndex:1},Rs={overflowAnchor:"none"},zl={...Rs,display:"inline-block",height:"100%"},oo=K.memo(function({showTopList:e=!1}){const t=ne("listState"),r=$e("sizeRanges"),o=ne("useWindowScroll"),s=ne("customScrollParent"),a=$e("windowScrollContainerState"),i=$e("scrollContainerState"),l=s||o?a:i,d=ne("itemContent"),c=ne("context"),p=ne("groupContent"),u=ne("trackItemSizes"),f=ne("itemSize"),x=ne("log"),b=$e("gap"),j=ne("horizontalDirection"),{callbackRef:w}=rl(r,f,u,e?$t:l,x,b,s,j,ne("skipAnimationFrameInResizeObserver")),[v,g]=K.useState(0);_n("deviation",F=>{v!==F&&g(F)});const I=ne("EmptyPlaceholder"),N=ne("ScrollSeekPlaceholder")||Pl,C=ne("ListComponent"),E=ne("ItemComponent"),m=ne("GroupComponent"),y=ne("computeItemKey"),k=ne("isSeeking"),T=ne("groupIndices").length>0,S=ne("alignToBottom"),A=ne("initialItemFinalLocationReached"),R=e?{}:{boxSizing:"border-box",...j?{display:"inline-block",height:"100%",marginLeft:v!==0?v:S?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:S?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...A?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&I?n.jsx(I,{...De(I,c)}):n.jsx(C,{...De(C,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:R,children:(e?t.topItems:t.items).map(F=>{const B=F.originalIndex,D=y(B+t.firstItemIndex,F.data,c);return k?h.createElement(N,{...De(N,c),height:F.size,index:F.index,key:D,type:F.type||"item",...F.type==="group"?{}:{groupIndex:F.groupIndex}}):F.type==="group"?h.createElement(m,{...De(m,c),"data-index":B,"data-item-index":F.index,"data-known-size":F.size,key:D,style:Bl},p(F.index,c)):h.createElement(E,{...De(E,c),...Gl(E,F.data),"data-index":B,"data-item-group-index":F.groupIndex,"data-item-index":F.index,"data-known-size":F.size,key:D,style:j?zl:Rs},T?d(F.index,F.groupIndex,F.data,c):d(F.index,F.data,c))})})}),Wl={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},$l={outline:"none",overflowX:"auto",position:"relative"},Hr=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Vl={position:Dn(),top:0,width:"100%",zIndex:1};function De(e,t){if(typeof e!="string")return{context:t}}function Gl(e,t){return{item:typeof e=="string"?void 0:t}}const Ul=K.memo(function(){const e=ne("HeaderComponent"),t=$e("headerHeight"),r=ne("HeaderFooterTag"),o=_t(K.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,ne("skipAnimationFrameInResizeObserver")),s=ne("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null}),Kl=K.memo(function(){const e=ne("FooterComponent"),t=$e("footerHeight"),r=ne("HeaderFooterTag"),o=_t(K.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,ne("skipAnimationFrameInResizeObserver")),s=ne("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null});function Ds({useEmitter:e,useEmitterValue:t,usePublisher:r}){return K.memo(function({children:o,style:s,context:a,...i}){const l=r("scrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),p=t("scrollerRef"),u=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:x,scrollToCallback:b}=As(l,c,d,p,void 0,u);return e("scrollTo",b),e("scrollBy",f),n.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:x,style:{...u?$l:Wl,...s},tabIndex:0,...i,...De(d,a),children:o})})}function Ms({useEmitter:e,useEmitterValue:t,usePublisher:r}){return K.memo(function({children:o,style:s,context:a,...i}){const l=r("windowScrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),p=t("totalListHeight"),u=t("deviation"),f=t("customScrollParent"),x=K.useRef(null),b=t("scrollerRef"),{scrollByCallback:j,scrollerRef:w,scrollToCallback:v}=As(l,c,d,b,f);return Es(()=>{var g;return w.current=f||((g=x.current)==null?void 0:g.ownerDocument.defaultView),()=>{w.current=null}},[w,f]),e("windowScrollTo",v),e("scrollBy",j),n.jsx(d,{ref:x,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...p!==0?{height:p+u}:{}},...i,...De(d,a),children:o})})}const ql=({children:e})=>{const t=K.useContext(Ss),r=$e("viewportHeight"),o=$e("fixedItemHeight"),s=ne("alignToBottom"),a=ne("horizontalDirection"),i=K.useMemo(()=>os(r,d=>vt(d,a?"width":"height")),[r,a]),l=_t(i,!0,ne("skipAnimationFrameInResizeObserver"));return K.useEffect(()=>{t&&(r(t.viewportHeight),o(t.itemHeight))},[t,r,o]),n.jsx("div",{"data-viewport-type":"element",ref:l,style:Hr(s),children:e})},Zl=({children:e})=>{const t=K.useContext(Ss),r=$e("windowViewportRect"),o=$e("fixedItemHeight"),s=ne("customScrollParent"),a=as(r,s,ne("skipAnimationFrameInResizeObserver")),i=ne("alignToBottom");return K.useEffect(()=>{t&&(o(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,o]),n.jsx("div",{"data-viewport-type":"window",ref:a,style:Hr(i),children:e})},Yl=({children:e})=>{const t=ne("TopItemListComponent")||"div",r=ne("headerHeight"),o={...Vl,marginTop:`${r}px`},s=ne("context");return n.jsx(t,{style:o,...De(t,s),children:e})},Xl=K.memo(function(e){const t=ne("useWindowScroll"),r=ne("topItemsIndexes").length>0,o=ne("customScrollParent"),s=ne("context");return n.jsxs(o||t?ec:Ql,{...e,context:s,children:[r&&n.jsx(Yl,{children:n.jsx(oo,{showTopList:!0})}),n.jsxs(o||t?Zl:ql,{children:[n.jsx(Ul,{}),n.jsx(oo,{}),n.jsx(Kl,{})]})]})}),{Component:Jl,useEmitter:_n,useEmitterValue:ne,usePublisher:$e}=Cs(Fl,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Xl),Ql=Ds({useEmitter:_n,useEmitterValue:ne,usePublisher:$e}),ec=Ms({useEmitter:_n,useEmitterValue:ne,usePublisher:$e}),tc=Jl,rc=me(()=>{const e=H(c=>n.jsxs("td",{children:["Item $",c]})),t=H(null),r=H(c=>n.jsxs("td",{colSpan:1e3,children:["Group ",c]})),o=H(null),s=H(null),a=H({}),i=H(Mn),l=H($t),d=(c,p=null)=>Me(M(a,V(u=>u[c]),we()),p);return{components:a,computeItemKey:i,context:t,EmptyPlaceholder:d("EmptyPlaceholder"),FillerRow:d("FillerRow"),fixedFooterContent:s,fixedHeaderContent:o,itemContent:e,groupContent:r,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TableBodyComponent:d("TableBody","tbody"),TableComponent:d("Table","table"),TableFooterComponent:d("TableFoot","tfoot"),TableHeadComponent:d("TableHead","thead"),TableRowComponent:d("TableRow","tr"),GroupComponent:d("Group","tr")}});Ne(ks,rc);Dn();const so={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},nc={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ao,floor:Er,max:Zt,min:qr,round:io}=Math;function lo(e,t,r){return Array.from({length:t-e+1}).map((o,s)=>({data:r===null?null:r[s+e],index:s+e}))}function oc(e){return{...nc,items:e}}function xr(e,t){return e&&e.width===t.width&&e.height===t.height}function sc(e,t){return e&&e.column===t.column&&e.row===t.row}const ac=me(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:o},{footerHeight:s,headerHeight:a,scrollBy:i,scrollContainerState:l,scrollTo:d,scrollTop:c,smoothScrollTargetReached:p,viewportHeight:u},f,x,{didMount:b,propsReady:j},{customScrollParent:w,useWindowScroll:v,windowScrollContainerState:g,windowScrollTo:I,windowViewportRect:N},C])=>{const E=H(0),m=H(0),y=H(so),k=H({height:0,width:0}),T=H({height:0,width:0}),S=ce(),A=ce(),R=H(0),F=H(null),B=H({column:0,row:0}),D=ce(),_=ce(),P=H(!1),U=H(0),Q=H(!0),z=H(!1),Y=H(!1);he(M(b,ie(U),re(([O,G])=>!!G)),()=>{se(Q,!1)}),he(M(Se(b,Q,T,k,U,z),re(([O,G,oe,ge,,Ee])=>O&&!G&&oe.height!==0&&ge.height!==0&&!Ee)),([,,,,O])=>{se(z,!0),Tn(1,()=>{se(S,O)}),Ue(M(c),()=>{se(t,[0,0]),se(Q,!0)})}),q(M(_,re(O=>O!=null&&O.scrollTop>0),Je(0)),m),he(M(b,ie(_),re(([,O])=>O!=null)),([,O])=>{O&&(se(k,O.viewport),se(T,O.item),se(B,O.gap),O.scrollTop>0&&(se(P,!0),Ue(M(c,Dt(1)),G=>{se(P,!1)}),se(d,{top:O.scrollTop})))}),q(M(k,V(({height:O})=>O)),u),q(M(Se(te(k,xr),te(T,xr),te(B,(O,G)=>O&&O.column===G.column&&O.row===G.row),te(c)),V(([O,G,oe,ge])=>({gap:oe,item:G,scrollTop:ge,viewport:O}))),D),q(M(Se(te(E),o,te(B,sc),te(T,xr),te(k,xr),te(F),te(m),te(P),te(Q),te(U)),re(([,,,,,,,O])=>!O),V(([O,[G,oe],ge,Ee,X,ae,xe,,ye,le])=>{const{column:ue,row:ke}=ge,{height:Ce,width:It}=Ee,{width:ft}=X;if(xe===0&&(O===0||ft===0))return so;if(It===0){const kt=En(le,O),mt=kt+Math.max(xe-1,0);return oc(lo(kt,mt,ae))}const Z=_s(ft,It,ue);let pe,be;ye?G===0&&oe===0&&xe>0?(pe=0,be=xe-1):(pe=Z*Er((G+ke)/(Ce+ke)),be=Z*ao((oe+ke)/(Ce+ke))-1,be=qr(O-1,Zt(be,Z-1)),pe=qr(be,Zt(0,pe))):(pe=0,be=-1);const Ae=lo(pe,be,ae),{bottom:Ge,top:Ye}=co(X,ge,Ee,Ae),jt=ao(O/Z),ur=jt*Ce+(jt-1)*ke-Ge;return{bottom:Ge,itemHeight:Ce,items:Ae,itemWidth:It,offsetBottom:ur,offsetTop:Ye,top:Ye}})),y),q(M(F,re(O=>O!==null),V(O=>O.length)),E),q(M(Se(k,T,y,B),re(([O,G,{items:oe}])=>oe.length>0&&G.height!==0&&O.height!==0),V(([O,G,{items:oe},ge])=>{const{bottom:Ee,top:X}=co(O,ge,G,oe);return[X,Ee]}),we(Jt)),t);const L=H(!1);q(M(c,ie(L),V(([O,G])=>G||O!==0)),L);const W=ze(M(Se(y,E),re(([{items:O}])=>O.length>0),ie(L),re(([[O,G],oe])=>{const ge=O.items[O.items.length-1].index===G-1;return(oe||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===G)&&ge}),V(([[,O]])=>O-1),we())),$=ze(M(te(y),re(({items:O})=>O.length>0&&O[0].index===0),Je(0),we())),ee=ze(M(te(y),ie(P),re(([{items:O},G])=>O.length>0&&!G),V(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),we(fs),lt(0)));q(ee,x.scrollSeekRangeChanged),q(M(S,ie(k,T,E,B),V(([O,G,oe,ge,Ee])=>{const X=xs(O),{align:ae,behavior:xe,offset:ye}=X;let le=X.index;le==="LAST"&&(le=ge-1),le=Zt(0,le,qr(ge-1,le));let ue=mn(G,Ee,oe,le);return ae==="end"?ue=io(ue-G.height+oe.height):ae==="center"&&(ue=io(ue-G.height/2+oe.height/2)),ye&&(ue+=ye),{behavior:xe,top:ue}})),d);const de=Me(M(y,V(O=>O.offsetBottom+O.bottom)),0);return q(M(N,V(O=>({height:O.visibleHeight,width:O.visibleWidth}))),k),{customScrollParent:w,data:F,deviation:R,footerHeight:s,gap:B,headerHeight:a,increaseViewportBy:e,initialItemCount:m,itemDimensions:T,overscan:r,restoreStateFrom:_,scrollBy:i,scrollContainerState:l,scrollHeight:A,scrollTo:d,scrollToIndex:S,scrollTop:c,smoothScrollTargetReached:p,totalCount:E,useWindowScroll:v,viewportDimensions:k,windowScrollContainerState:g,windowScrollTo:I,windowViewportRect:N,...x,gridState:y,horizontalDirection:Y,initialTopMostItemIndex:U,totalListHeight:de,...f,endReached:W,propsReady:j,rangeChanged:ee,startReached:$,stateChanged:D,stateRestoreInProgress:P,...C}},Ne(An,Oe,cr,Is,Nt,Rn,wt));function _s(e,t,r){return Zt(1,Er((e+r)/(Er(t)+r)))}function co(e,t,r,o){const{height:s}=r;if(s===void 0||o.length===0)return{bottom:0,top:0};const a=mn(e,t,r,o[0].index);return{bottom:mn(e,t,r,o[o.length-1].index)+s,top:a}}function mn(e,t,r,o){const s=_s(e.width,r.width,t.column),a=Er(o/s),i=a*r.height+Zt(0,a-1)*t.row;return i>0?i+t.row:i}const ic=me(()=>{const e=H(u=>`Item ${u}`),t=H({}),r=H(null),o=H("virtuoso-grid-item"),s=H("virtuoso-grid-list"),a=H(Mn),i=H("div"),l=H($t),d=(u,f=null)=>Me(M(t,V(x=>x[u]),we()),f),c=H(!1),p=H(!1);return q(te(p),c),{components:t,computeItemKey:a,context:r,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:i,itemClassName:o,ItemComponent:d("Item","div"),itemContent:e,listClassName:s,ListComponent:d("List","div"),readyStateChanged:c,reportReadyState:p,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),lc=me(([e,t])=>({...e,...t}),Ne(ac,ic)),cc=K.memo(function(){const e=Ie("gridState"),t=Ie("listClassName"),r=Ie("itemClassName"),o=Ie("itemContent"),s=Ie("computeItemKey"),a=Ie("isSeeking"),i=Ve("scrollHeight"),l=Ie("ItemComponent"),d=Ie("ListComponent"),c=Ie("ScrollSeekPlaceholder"),p=Ie("context"),u=Ve("itemDimensions"),f=Ve("gap"),x=Ie("log"),b=Ie("stateRestoreInProgress"),j=Ve("reportReadyState"),w=_t(K.useMemo(()=>v=>{const g=v.parentElement.parentElement.scrollHeight;i(g);const I=v.firstChild;if(I){const{height:N,width:C}=I.getBoundingClientRect();u({height:N,width:C})}f({column:uo("column-gap",getComputedStyle(v).columnGap,x),row:uo("row-gap",getComputedStyle(v).rowGap,x)})},[i,u,f,x]),!0,!1);return Es(()=>{e.itemHeight>0&&e.itemWidth>0&&j(!0)},[e]),b?null:n.jsx(d,{className:t,ref:w,...De(d,p),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const g=s(v.index,v.data,p);return a?n.jsx(c,{...De(c,p),height:e.itemHeight,index:v.index,width:e.itemWidth},g):h.createElement(l,{...De(l,p),className:r,"data-index":v.index,key:g},o(v.index,v.data,p))})})}),dc=K.memo(function(){const e=Ie("HeaderComponent"),t=Ve("headerHeight"),r=Ie("headerFooterTag"),o=_t(K.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,!1),s=Ie("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null}),uc=K.memo(function(){const e=Ie("FooterComponent"),t=Ve("footerHeight"),r=Ie("headerFooterTag"),o=_t(K.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,!1),s=Ie("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...De(e,s)})}):null}),fc=({children:e})=>{const t=K.useContext(Ts),r=Ve("itemDimensions"),o=Ve("viewportDimensions"),s=_t(K.useMemo(()=>a=>{o(a.getBoundingClientRect())},[o]),!0,!1);return K.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,o,r]),n.jsx("div",{ref:s,style:Hr(!1),children:e})},mc=({children:e})=>{const t=K.useContext(Ts),r=Ve("windowViewportRect"),o=Ve("itemDimensions"),s=Ie("customScrollParent"),a=as(r,s,!1);return K.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,o]),n.jsx("div",{ref:a,style:Hr(!1),children:e})},pc=K.memo(function({...e}){const t=Ie("useWindowScroll"),r=Ie("customScrollParent"),o=r||t?gc:hc,s=r||t?mc:fc,a=Ie("context");return n.jsx(o,{...e,...De(o,a),children:n.jsxs(s,{children:[n.jsx(dc,{}),n.jsx(cc,{}),n.jsx(uc,{})]})})}),{useEmitter:Ls,useEmitterValue:Ie,usePublisher:Ve}=Cs(lc,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},pc),hc=Ds({useEmitter:Ls,useEmitterValue:Ie,usePublisher:Ve}),gc=Ms({useEmitter:Ls,useEmitterValue:Ie,usePublisher:Ve});function uo(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Pe.WARN),t==="normal"?0:parseInt(t??"0",10)}function nr(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function Ar({value:e}){const t=e.stack,r=typeof e.message=="string"?e.message:void 0,o=r?`${r}
|
|
27
|
-
|
|
28
|
-
${t}`:t;return n.jsxs("div",{className:"relative overflow-x-auto rounded-md border p-3 pt-9",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("button",{type:"button","aria-label":"Copy error",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border !bg-[var(--ds-background-100)] !text-[var(--ds-gray-800)] transition-transform transition-colors duration-100 hover:!bg-[var(--ds-gray-alpha-200)] active:!scale-95 active:!bg-[var(--ds-gray-alpha-300)]",style:{borderColor:"var(--ds-gray-300)"},onClick:()=>{navigator.clipboard.writeText(o).then(()=>{fe.success("Copied to clipboard")}).catch(()=>{fe.error("Failed to copy")})},children:n.jsx(or,{size:12})}),r&&n.jsx("p",{className:"pb-2 mb-2 text-xs font-semibold font-mono",style:{color:"var(--ds-red-900)",borderBottom:"1px solid var(--ds-gray-300)"},children:r}),n.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words overflow-auto m-0",style:{color:"var(--ds-gray-1000)"},children:t})]})}const xc=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),Ln={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},Os="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function vc(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function yc(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function bc(e){return e==="step_failed"||e==="run_failed"||e==="workflow_failed"?"var(--ds-red-700)":e==="run_cancelled"||e==="step_retrying"?"var(--ds-amber-700)":e==="step_completed"||e==="run_completed"||e==="workflow_completed"||e==="hook_disposed"||e==="wait_completed"?"var(--ds-green-700)":e==="step_started"||e==="run_started"||e==="workflow_started"||e==="hook_received"?"var(--ds-blue-700)":"var(--ds-gray-600)"}function wc(e,t){var s,a;const r=new Map;if(e){for(const i of e)if(i.eventType==="step_created"&&i.correlationId){const l=((s=i.eventData)==null?void 0:s.stepName)??"",d=sr(String(l));r.set(i.correlationId,(d==null?void 0:d.shortName)??l)}}const o=t!=null&&t.workflowName?((a=xt(t.workflowName))==null?void 0:a.shortName)??t.workflowName:null;return{correlationNameMap:r,workflowName:o}}function Nc(e){const t=new Map,r=new Map,o=new Map;for(const s of e){const a=new Date(s.createdAt).getTime(),i=s.correlationId??"__run__",l=s.eventType;if((l==="step_created"||l==="run_created")&&t.set(i,a),l==="step_started"||l==="run_started"||l==="workflow_started"){r.set(i,a),t.has(i)||t.set(i,a);const d=t.get(i),c=o.get(i)??{};d!==void 0&&(c.queued=a-d),o.set(i,c)}if(l==="step_completed"||l==="step_failed"||l==="run_completed"||l==="run_failed"||l==="run_cancelled"||l==="workflow_completed"||l==="workflow_failed"||l==="wait_completed"||l==="hook_disposed"){const d=r.get(i),c=o.get(i)??{};d!==void 0&&(c.ran=a-d),o.set(i,c)}}return o}function pn(e){return e==="run_created"||e==="run_started"||e==="run_completed"||e==="run_failed"||e==="run_cancelled"||e==="workflow_started"||e==="workflow_completed"||e==="workflow_failed"}const hn=36,Ic=20,Zr="var(--ds-gray-500)";function fo({isFirst:e,isLast:t,isRunLevel:r,statusDotColor:o,pulse:s=!1,hasSelection:a,showBranch:i,showLaneLine:l,isLaneStart:d,isLaneEnd:c,continuationOnly:p=!1}){const u=r?8:6,f=r?5:6,x=a&&!i&&!r?.3:1;return n.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:hn,minHeight:p?0:void 0},children:[n.jsx("div",{style:{position:"absolute",left:8,top:p?0:e?"50%":0,bottom:p?0:t?"50%":0,width:2,backgroundColor:Zr,zIndex:0}}),!p&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{position:"absolute",left:f,top:"50%",transform:"translateY(-50%)",width:u,height:u,zIndex:2},children:[n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:"var(--ds-background-100)",zIndex:0}}),s&&n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:o,opacity:.75*x,animation:Os,zIndex:1}}),n.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:o,opacity:x,transition:"opacity 150ms",zIndex:2}})]}),i&&n.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:hn-9,height:2,backgroundColor:Zr,zIndex:0}})]}),l&&n.jsx("div",{style:{position:"absolute",left:Ic,top:p?0:d?"50%":0,bottom:p?0:c?"50%":0,width:2,backgroundColor:Zr,zIndex:0}})]})}function mo({value:e,className:t}){const[r,o]=h.useState(!1),s=h.useRef(null);h.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const a=h.useCallback(i=>{i.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{o(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(!1),s.current=null},1500)})},[e]);return n.jsxs("div",{className:`group/copy flex items-center gap-1 flex-1 min-w-0 px-4 ${t??""}`,children:[n.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:e||"-"}),e?n.jsx("button",{type:"button",onClick:a,className:"flex-shrink-0 opacity-0 group-hover/copy:opacity-100 transition-opacity p-0.5 rounded hover:bg-[var(--ds-gray-alpha-200)]",style:Ln,"aria-label":`Copy ${e}`,children:r?n.jsx(Vo,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):n.jsx(or,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function Ir(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return Ir(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(Ir);if(e!==null&&typeof e=="object"){if(e.constructor!==Object)return e;const t={};for(const[r,o]of Object.entries(e))t[r]=Ir(o);return t}return e}function jc(e,t){if(!t||!xc.has(t)||e==null||typeof e!="object")return null;const r=e;return nr(r.error)?r.error:nr(r)?r:null}function kc({data:e,eventType:t}){const r=h.useMemo(()=>jc(e,t),[e,t]),[o,s]=h.useState(!1),a=h.useRef(null),i=h.useMemo(()=>Ir(e),[e]);h.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const l=h.useMemo(()=>{try{return JSON.stringify(i,null,2)}catch{return String(i)}},[i]),d=h.useCallback(c=>{c.stopPropagation(),navigator.clipboard.writeText(l).then(()=>{s(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{s(!1),a.current=null},1500)})},[l]);return r?n.jsx("div",{className:"p-2",children:n.jsx(Ar,{value:r})}):n.jsxs("div",{className:"relative group/payload",children:[n.jsx("div",{className:"overflow-x-auto p-2 text-[11px]",style:{color:"var(--ds-gray-1000)"},children:n.jsx(Cr,{data:i,expandLevel:2})}),n.jsx("button",{type:"button",onClick:d,className:"absolute bottom-2 right-2 opacity-0 group-hover/payload:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-md text-xs hover:bg-[var(--ds-gray-alpha-200)]",style:{...Ln,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:o?n.jsxs(n.Fragment,{children:[n.jsx(Vo,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}),n.jsx("span",{style:{color:"var(--ds-green-700)"},children:"Copied"})]}):n.jsxs(n.Fragment,{children:[n.jsx(or,{className:"h-3 w-3"}),n.jsx("span",{children:"Copy"})]})})]})}function Cc({event:e,index:t,isFirst:r,isLast:o,activeGroupKey:s,selectedGroupKey:a,selectedGroupRange:i,correlationNameMap:l,workflowName:d,durationMap:c,onSelectGroup:p,onHoverGroup:u,onLoadEventData:f,encryptionKey:x}){const[b,j]=h.useState(!1),[w,v]=h.useState(!1),[g,I]=h.useState(null),[N,C]=h.useState(null),[E,m]=h.useState(!1),y=e.correlationId??(pn(e.eventType)?"__run__":void 0);h.useEffect(()=>{a!==void 0&&a!==y&&j(!1)},[a,y]);const k=bc(e.eventType),T=new Date(e.createdAt),S="eventData"in e&&e.eventData!=null,A=pn(e.eventType),R=A?d??"-":e.correlationId?l.get(e.correlationId)??"-":"-",F=e.correlationId??(A?"__run__":""),B=F?c.get(F):void 0,D=s!==void 0,_=y!==void 0&&y===s,P=D&&!_,U=D&&_,Q=D&&_&&!A,z=i!==null&&t>=i.first&&t<=i.last,Y=i!==null&&t===i.first,L=i!==null&&t===i.last,W=h.useCallback(async()=>{if(!(g!==null||S)){v(!0),C(null);try{if(!f){C("Event details unavailable");return}const G=await f(e);G!=null&&I(G)}catch(G){C(G instanceof Error?G.message:"Failed to load event details")}finally{v(!1),m(!0)}}},[e,g,S,f]);h.useEffect(()=>{x&&E&&f&&(I(null),m(!1),f(e).then(G=>{G!=null&&I(G),m(!0)}).catch(()=>{m(!0)}))},[x]);const $=h.useCallback(G=>{G.stopPropagation();const oe=!b;j(oe),oe&&g===null&&!S&&W()},[b,g,S,W]),ee=h.useCallback(()=>{p(a===y?void 0:y)},[a,y,p]),de=S?e.eventData:g,O=P?.3:1;return n.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>u(y),onMouseLeave:()=>u(void 0),children:[n.jsxs("div",{role:"button",tabIndex:0,onClick:ee,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&ee()},className:"w-full text-left flex items-center gap-0 text-sm hover:bg-[var(--ds-gray-alpha-100)] transition-colors cursor-pointer",style:{minHeight:40},children:[n.jsx(fo,{isFirst:r,isLast:o&&!b,isRunLevel:A,statusDotColor:k,pulse:U,hasSelection:D,showBranch:Q,showLaneLine:z,isLaneStart:Y,isLaneEnd:L}),n.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:O,transition:"opacity 150ms"},children:[n.jsx("button",{type:"button",onClick:$,className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded hover:bg-[var(--ds-gray-alpha-200)] transition-colors",style:{...Ln,border:"1px solid var(--ds-gray-alpha-400)"},"aria-label":b?"Collapse details":"Expand details",children:n.jsx(yn,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-700)",transform:b?"rotate(90deg)":"rotate(0deg)"}})}),n.jsx("div",{className:"text-xs tabular-nums flex-1 min-w-0 px-4",style:{color:"var(--ds-gray-900)"},children:vc(T)}),n.jsx("div",{className:"text-xs font-medium flex-1 min-w-0 px-4",children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--ds-gray-900)"},children:[n.jsxs("span",{style:{position:"relative",display:"inline-flex",width:6,height:6,flexShrink:0},children:[U&&n.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:k,opacity:.75,animation:Os}}),n.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:k}})]}),yc(e.eventType)]})}),n.jsx("div",{className:"text-xs flex-1 min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",title:R!=="-"?R:void 0,children:R}),n.jsx(mo,{value:e.correlationId||"",className:"font-mono text-xs"}),n.jsx(mo,{value:e.eventId,className:"font-mono text-xs"})]})]}),b&&n.jsxs("div",{className:"flex",children:[n.jsx(fo,{isFirst:!1,isLast:o,isRunLevel:A,hasSelection:D,showBranch:!1,showLaneLine:z&&!L,isLaneStart:!1,isLaneEnd:!1,continuationOnly:!0}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsxs("div",{className:"flex-1 my-1.5 mr-3 ml-2 py-2 rounded-md border overflow-hidden",style:{borderColor:"var(--ds-gray-alpha-200)",opacity:O,transition:"opacity 150ms"},children:[((B==null?void 0:B.queued)!==void 0||(B==null?void 0:B.ran)!==void 0)&&n.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[B.queued!==void 0&&B.queued>0&&n.jsxs("span",{children:["Queued for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(B.queued)})]}),B.ran!==void 0&&n.jsxs("span",{children:["Ran for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(B.ran)})]})]}),de!=null?n.jsx(kc,{data:de,eventType:e.eventType}):N?n.jsx("div",{className:"rounded-md border p-3 text-xs",style:{borderColor:"var(--ds-red-400)",backgroundColor:"var(--ds-red-100)",color:"var(--ds-red-900)"},children:N}):w||!S&&!E&&e.correlationId?n.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[n.jsx(Re,{className:"h-3",style:{width:"75%"}}),n.jsx(Re,{className:"h-3",style:{width:"50%"}}),n.jsx(Re,{className:"h-3",style:{width:"60%"}})]}):n.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function Sc({events:e,run:t,onLoadEventData:r,hasMoreEvents:o=!1,isLoadingMoreEvents:s=!1,onLoadMoreEvents:a,encryptionKey:i}){const l=h.useMemo(()=>!e||e.length===0?[]:[...e].sort((m,y)=>new Date(m.createdAt).getTime()-new Date(y.createdAt).getTime()),[e]),{correlationNameMap:d,workflowName:c}=h.useMemo(()=>wc(e??null,t??null),[e,t]),p=h.useMemo(()=>Nc(l),[l]),[u,f]=h.useState(void 0),[x,b]=h.useState(void 0),j=h.useCallback(m=>{f(m)},[]),w=h.useCallback(m=>{b(m)},[]),v=u??x,g=h.useMemo(()=>{if(!v||v==="__run__")return null;let m=-1,y=-1;for(let k=0;k<l.length;k++)l[k].correlationId===v&&(m===-1&&(m=k),y=k);return m>=0?{first:m,last:y}:null},[v,l]),[I,N]=h.useState(""),C=h.useRef(null),E=h.useMemo(()=>{const m=[];for(let y=0;y<l.length;y++){const k=l[y];m.push({text:[k.eventId,k.correlationId??""].join(" ").toLowerCase(),groupKey:k.correlationId??(pn(k.eventType)?"__run__":void 0),eventId:k.eventId,index:y})}return m},[l]);return h.useEffect(()=>{var k;const m=I.trim().toLowerCase();if(!m){f(void 0);return}const y=E.find(T=>T.text.includes(m));y&&(f(y.groupKey),(k=C.current)==null||k.scrollToIndex({index:y.index,align:"center",behavior:"smooth"}))},[I,E]),!e||e.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--ds-gray-700)"},children:"No events found"}):n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[n.jsx("style",{children:"@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}"}),n.jsx("div",{style:{padding:6,backgroundColor:"var(--ds-background-100)"},children:n.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,boxShadow:"0 0 0 1px var(--ds-gray-alpha-400)",background:"var(--ds-background-100)",height:40},children:[n.jsx("div",{style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ds-gray-800)",flexShrink:0},children:n.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),n.jsx("input",{type:"search",placeholder:"Search by event ID or correlation ID…",value:I,onChange:m=>N(m.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]})}),n.jsxs("div",{className:"flex items-center gap-0 text-sm font-medium h-10 border-b flex-shrink-0",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx("div",{className:"flex-shrink-0",style:{width:hn}}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Time"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event Type"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Name"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Correlation ID"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event ID"})]}),n.jsx(tc,{ref:C,totalCount:l.length,overscan:20,defaultItemHeight:40,endReached:()=>{!o||s||a==null||a()},itemContent:m=>n.jsx(Cc,{event:l[m],index:m,isFirst:m===0,isLast:m===l.length-1,activeGroupKey:v,selectedGroupKey:u,selectedGroupRange:g,correlationNameMap:d,workflowName:c,durationMap:p,onSelectGroup:j,onHoverGroup:w,onLoadEventData:r,encryptionKey:i}),components:{Footer:()=>n.jsxs(n.Fragment,{children:[o&&n.jsx("div",{className:"px-3 pt-3 flex justify-center",children:n.jsx("button",{type:"button",onClick:()=>void(a==null?void 0:a()),disabled:s,className:"h-8 px-3 text-xs rounded-md border transition-colors disabled:opacity-60 disabled:cursor-not-allowed",style:{borderColor:"var(--ds-gray-alpha-400)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:s?"Loading more events...":"Load more"})}),n.jsxs("div",{className:"mt-4 pt-3 border-t text-xs px-3",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)"},children:[l.length," event",l.length!==1?"s":""," total"]})]})},style:{flex:1,minHeight:0}})]})}function Tc({messages:e}){return e.length===0?n.jsx("div",{className:"text-center py-8 text-[11px]",style:{color:"var(--ds-gray-600)"},children:"No messages"}):n.jsx("div",{className:"flex flex-col gap-3 p-3",children:e.map((t,r)=>n.jsx(Ec,{message:t},r))})}function Ec({message:e}){const t=e.role,r=Dc(e.content),o=Rc(t);return n.jsxs("div",{className:"rounded-md border text-[11px]",style:{backgroundColor:o.bg,borderColor:o.border},children:[n.jsx("div",{className:"px-2.5 py-1 border-b text-[10px] font-medium uppercase tracking-wide",style:{borderColor:o.border,color:o.label},children:t}),n.jsx("div",{className:"px-2.5 py-2 space-y-2",children:r.map((s,a)=>n.jsx(Ac,{part:s,role:t},a))})]})}function Ac({part:e,role:t}){return e.type==="text"?e.text?t==="assistant"?n.jsx("div",{className:"prose prose-sm max-w-none text-[11px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",style:{color:"var(--ds-gray-1000)"},children:n.jsx(ui,{children:e.text})}):n.jsx("div",{className:"whitespace-pre-wrap break-words",style:{color:"var(--ds-gray-1000)"},children:e.text}):null:e.type==="tool-call"?n.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-purple-100)",borderColor:"var(--ds-purple-300)"},children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[n.jsx("span",{children:"🔧"}),n.jsx("span",{style:{color:"var(--ds-purple-900)"},children:e.toolName})]}),e.input!=null&&n.jsx("div",{className:"mt-1.5 overflow-x-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.input=="string"?n.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.input}):n.jsx(Cr,{data:e.input})})]}):e.type==="tool-result"?n.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-green-100)",borderColor:"var(--ds-green-300)"},children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[n.jsx("span",{children:"✓"}),n.jsxs("span",{style:{color:"var(--ds-green-900)"},children:[e.toolName," result"]})]}),e.output!=null&&n.jsx("div",{className:"mt-1.5 overflow-x-auto max-h-[200px] overflow-y-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.output=="string"?n.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.output}):n.jsx(Cr,{data:e.output,expandLevel:1})})]}):null}function Rc(e){switch(e){case"user":return{bg:"var(--ds-blue-100)",border:"var(--ds-blue-300)",label:"var(--ds-blue-700)"};case"assistant":return{bg:"var(--ds-gray-100)",border:"var(--ds-gray-300)",label:"var(--ds-gray-700)"};case"system":return{bg:"var(--ds-amber-100)",border:"var(--ds-amber-300)",label:"var(--ds-amber-700)"};case"tool":return{bg:"var(--ds-green-50)",border:"var(--ds-green-300)",label:"var(--ds-green-700)"};default:return{bg:"var(--ds-gray-100)",border:"var(--ds-gray-300)",label:"var(--ds-gray-700)"}}}function Dc(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.map(t=>typeof t=="string"?{type:"text",text:t}:(t==null?void 0:t.type)==="text"?{type:"text",text:String(t.text??"")}:(t==null?void 0:t.type)==="tool-call"?{type:"tool-call",toolName:t.toolName,input:t.input}:(t==null?void 0:t.type)==="tool-result"?{type:"tool-result",toolName:t.toolName,output:t.output}:{type:"text",text:""}):[]}const Mc=e=>{if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||e===null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}};function Hs({data:e}){return n.jsxs("div",{className:"relative overflow-x-auto rounded-md border p-3 pt-9",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("button",{type:"button","aria-label":"Copy data",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border !bg-[var(--ds-background-100)] !text-[var(--ds-gray-800)] transition-transform transition-colors duration-100 hover:!bg-[var(--ds-gray-alpha-200)] active:!scale-95 active:!bg-[var(--ds-gray-alpha-300)]",style:{borderColor:"var(--ds-gray-300)"},onClick:()=>{navigator.clipboard.writeText(Mc(e)).then(()=>{fe.success("Copied to clipboard")}).catch(()=>{fe.error("Failed to copy")})},children:n.jsx(or,{size:12})}),n.jsx(Cr,{data:e})]})}function Le({summary:e,children:t,onToggle:r,disabled:o=!1,summaryClassName:s,contentClassName:a}){return o?n.jsx("div",{className:`rounded-md border px-2.5 py-1.5 text-xs ${s??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)",cursor:"not-allowed",opacity:.8},children:e}):n.jsxs("details",{className:"group",onToggle:i=>r==null?void 0:r(i.target.open),children:[n.jsx("summary",{className:`cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 [&::-webkit-details-marker]:hidden ${s??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)",listStyle:"none"},children:n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(yn,{size:14,className:"shrink-0 transition-transform group-open:rotate-90"}),e]})}),n.jsxs("div",{className:`relative pl-6 mt-3 ${a??""}`,children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3",style:{backgroundColor:"var(--ds-gray-400)"}}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg",style:{borderColor:"var(--ds-gray-400)"}}),n.jsx("div",{className:"absolute left-6 top-3 w-0 h-px -translate-y-px",style:{backgroundColor:"var(--ds-gray-400)"}}),n.jsx("div",{children:t})]})]})}function _c({active:e,onClick:t,children:r}){return n.jsx("button",{type:"button",role:"tab","aria-selected":e,tabIndex:e?0:-1,onClick:t,className:"px-3 py-1.5 text-[11px] font-medium transition-colors -mb-px",style:{backgroundColor:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:`2px solid ${e?"var(--ds-blue-600)":"transparent"}`,borderRadius:0,outline:"none",boxShadow:"none",cursor:"pointer",color:e?"var(--ds-gray-1000)":"var(--ds-gray-600)"},children:r})}function Lc({tabs:e,activeTab:t,onTabChange:r,ariaLabel:o,children:s}){const a=h.useCallback(i=>{if(i.key!=="ArrowRight"&&i.key!=="ArrowLeft")return;i.preventDefault();const l=e.findIndex(c=>c.id===t),d=i.key==="ArrowRight"?(l+1)%e.length:(l-1+e.length)%e.length;r(e[d].id)},[e,t,r]);return n.jsxs("div",{className:"rounded-md border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:[n.jsx("div",{className:"flex gap-1 border-b",role:"tablist","aria-label":o,onKeyDown:a,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:e.map(i=>n.jsx(_c,{active:t===i.id,onClick:()=>r(i.id),children:i.label},i.id))}),n.jsx("div",{role:"tabpanel",children:s})]})}const Oc=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function Hc({conversation:e,args:t}){const[r,o]=h.useState("conversation");return n.jsx(Le,{summary:`Input (${e.length} messages)`,children:n.jsx(Lc,{tabs:Oc,activeTab:r,onTabChange:o,ariaLabel:"Conversation view",children:r==="conversation"?n.jsx(Tc,{messages:e}):n.jsx("div",{className:"p-3",children:Array.isArray(t)?t.map((s,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:He(s)},a)):He(t)})})})}function Vt(){return n.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:[n.jsx(Yo,{className:"h-3 w-3"}),n.jsx("span",{className:"font-medium",children:"Encrypted"})]})}function He(e){return n.jsx(Hs,{data:e})}const pt=e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0,po=["workflowName","moduleSpecifier","stepName","status","stepId","hookId","eventId","runId","attempt","token","receivedCount","lastReceivedAt","disposedAt","correlationId","eventType","deploymentId","specVersion","workflowCoreVersion","ownerId","projectId","environment","executionContext","createdAt","startedAt","updatedAt","completedAt","expiredAt","retryAfter","error","metadata","eventData","input","output","resumeAt"],ho=(e,t)=>{const r=po.indexOf(e)||0,o=po.indexOf(t)||0;return r-o},Fc={workflowCoreVersion:"@workflow/core version",receivedCount:"times resolved"},Pc=e=>Fc[e]??e,Bc=e=>{const t=String(e),r=sr(t);if(r)return r.moduleSpecifier;const o=xt(t);return o?o.moduleSpecifier:t},Fs=e=>{if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="string"&&e.trim().length===0)return null;const t=typeof e=="number"?new Date(e):new Date(String(e));return Number.isNaN(t.getTime())?null:t},Ps=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),zc=e=>{const t=Fs(e);return t?Ps(t):"-"},st=e=>{const t=Fs(e);return t?Ps(t):null},Kt={workflowName:e=>{var t;return((t=xt(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>Bc(e),stepName:e=>{var t;return((t=sr(String(e)))==null?void 0:t.shortName)??"?"},runId:e=>String(e),stepId:e=>String(e),hookId:e=>String(e),eventId:e=>String(e),status:e=>String(e),attempt:e=>String(e),token:e=>String(e),isWebhook:e=>String(e),receivedCount:e=>String(e),lastReceivedAt:st,disposedAt:st,eventType:e=>String(e),correlationId:e=>String(e),deploymentId:e=>String(e),specVersion:e=>String(e),workflowCoreVersion:e=>String(e),ownerId:e=>null,projectId:e=>null,environment:e=>null,executionContext:e=>null,createdAt:st,startedAt:st,updatedAt:st,completedAt:st,expiredAt:st,retryAfter:st,resumeAt:st,metadata:e=>pt(e)?at(e)?n.jsx(Vt,{}):He(e):null,input:(e,t)=>{if(at(e))return n.jsx(Vt,{});if(e&&typeof e=="object"&&"args"in e){const{args:s,closureVars:a,thisVal:i}=e,l=Array.isArray(s)?s.length:0,d=l===1?"argument":"arguments",c=pt(a),p=pt(i),u=pt(s);if(t!=null&&t.stepName&&mi(t.stepName)){const f=pi(s);if(f&&f.length>0)return n.jsxs(n.Fragment,{children:[n.jsx(Hc,{conversation:f,args:s}),c&&n.jsx(Le,{summary:"Closure Variables",children:He(a)}),p&&n.jsx(Le,{summary:"This Value",children:He(i)})]})}return!u&&!c&&!p?n.jsx(Le,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):n.jsxs(n.Fragment,{children:[n.jsx(Le,{summary:`Input (${l} ${d})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(s)?s.map((f,x)=>n.jsx("div",{className:"mt-2 first:mt-0",children:He(f)},x)):He(s)}),c&&n.jsx(Le,{summary:"Closure Variables",children:He(a)}),p&&n.jsx(Le,{summary:"this",children:He(i)})]})}const r=Array.isArray(e)?e.length:0,o=r===1?"argument":"arguments";return pt(e)?n.jsx(Le,{summary:`Input (${r} ${o})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(e)?e.map((s,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:He(s)},a)):He(e)}):n.jsx(Le,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>pt(e)?at(e)?n.jsx(Vt,{}):n.jsx(Le,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:He(e)}):null,error:e=>at(e)?n.jsx(Vt,{}):pt(e)?nr(e)?n.jsx(Le,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:n.jsx(Ar,{value:e})}):n.jsx(Le,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:He(e)}):null,eventData:e=>at(e)?n.jsx(Vt,{}):pt(e)?n.jsx(Le,{summary:"Event Data",children:He(e)}):null},go=["input","output","error","metadata","eventData"],Wc=()=>n.jsx("div",{className:"text-copy-12 rounded-md border p-4 my-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:n.jsx("span",{children:"The data for this run has expired and is no longer available."})}),$c=({attribute:e,value:t,isLoading:r,inline:o=!1,context:s})=>{if(r&&(e==="input"||e==="output"||e==="eventData")){const d=e==="eventData"?"Event Data":e==="output"?"Output":"Input";return n.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"?"gap-2 my-3.5":"gap-0"}`,children:[n.jsx("span",{className:`${e==="input"||e==="output"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),n.jsx(Le,{summary:d,summaryClassName:"text-base py-2",disabled:!0}),n.jsxs("div",{className:"overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx(Re,{className:"h-4 w-[38%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[88%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[72%]"})]})]})}const i=Kt[e];if(!i)return null;const l=i(t,s);return l?o?n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:e}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--ds-gray-1000)"},children:l})]}):n.jsxs("div",{className:"relative",children:[typeof r=="boolean"&&r&&n.jsx("div",{className:"absolute top-9 right-4",children:n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2",style:{borderColor:"var(--ds-gray-900)"}})}),n.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"||e==="error"?"gap-2 my-3.5":"gap-0"}`,children:[n.jsx("span",{className:`${e==="input"||e==="output"||e==="error"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),n.jsx("span",{className:"text-xs",style:{color:"var(--ds-gray-1000)"},children:l})]},e)]}):null},Vc=({data:e,moduleSpecifier:t,isLoading:r,error:o,expiredAt:s,onStreamClick:a})=>{const i=h.useMemo(()=>{const b={...e},j=e.executionContext;return j!=null&&j.workflowCoreVersion&&(b.workflowCoreVersion=j.workflowCoreVersion),t?b.moduleSpecifier=t:typeof e.stepName=="string"?b.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(b.moduleSpecifier=e.workflowName),b},[e,t]),l=s!=null&&new Date(s)<new Date,d=Object.keys(i).filter(b=>!go.includes(b)).sort(ho),c=Object.keys(i).filter(b=>go.includes(b)).sort(ho),p=d.filter(b=>{const j=Kt[b];return j?j(i[b])!==null:!1}),u=h.useMemo(()=>{const b=[...p],j=b.indexOf("moduleSpecifier");if(j===-1)return b;b.splice(j,1);const w=b.indexOf("workflowName");if(w!==-1)return b.splice(w+1,0,"moduleSpecifier"),b;const v=b.indexOf("stepName");return v!==-1?(b.splice(v+1,0,"moduleSpecifier"),b):(b.unshift("moduleSpecifier"),b)},[p]),f=h.useMemo(()=>({stepName:i.stepName}),[i.stepName]),x=h.useCallback(b=>{navigator.clipboard.writeText(b).then(()=>{fe.success("moduleSpecifier copied")}).catch(()=>{fe.error("Failed to copy moduleSpecifier")})},[]);return n.jsx(fi.Provider,{value:a,children:n.jsxs("div",{children:[p.length>0&&n.jsx("div",{className:"mb-3 flex flex-col overflow-hidden rounded-lg border",style:{borderColor:"var(--ds-gray-300)"},children:u.map((b,j)=>{var C;const w=(C=Kt[b])==null?void 0:C.call(Kt,i[b]),v=b==="moduleSpecifier",g=typeof w=="string"?w:String(w??i.moduleSpecifier??""),I=b!=="workflowCoreVersion",N=j<u.length-1;return n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 rounded-sm px-2.5 py-1",children:[n.jsx("span",{className:I?"text-[14px] first-letter:uppercase":"text-[14px]",style:{color:"var(--ds-gray-700)"},children:Pc(b)}),v?n.jsx("button",{type:"button",className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)",background:"transparent",border:"none",padding:0},title:g,onClick:()=>x(g),children:g}):n.jsx("span",{className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},children:w})]}),N?n.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},b)})}),o?n.jsx(Aa,{title:"Failed to load resource details",details:o.message,className:"my-4"}):l?n.jsx(Wc,{}):n.jsx(n.Fragment,{children:c.map(b=>n.jsx($c,{isLoading:r,attribute:b,value:i[b],context:f},b))})]})})},Gc=new Set(["step_failed","step_retrying"]),Uc=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function Kc({event:e,onLoadEventData:t,encryptionKey:r}){const[o,s]=h.useState(null),[a,i]=h.useState(!1),[l,d]=h.useState(null),c=h.useRef(!1),p="eventData"in e&&e.eventData!=null?e.eventData:null,u=p??o,f=Uc.has(e.eventType),x=h.useCallback(async()=>{if(!(!t||!e.correlationId||!e.eventId))try{i(!0),d(null);const w=await t(e.correlationId,e.eventId);s(w)}catch(w){d(w instanceof Error?w.message:String(w))}finally{i(!1)}},[t,e.correlationId,e.eventId]),b=h.useCallback(async()=>{p||o!==null||a||(c.current=!0,await x())},[p,o,a,x]);h.useEffect(()=>{r&&c.current&&o!==null&&(s(null),x())},[r]);const j=new Date(e.createdAt);return n.jsxs(Le,{summaryClassName:"text-base py-2",summary:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",style:{color:"var(--ds-gray-1000)"},children:e.eventType})," ","-"," ",n.jsx("span",{style:{color:"var(--ds-gray-700)"},children:zc(j.getTime())})]}),onToggle:f?w=>{w&&b()}:void 0,children:[n.jsxs("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"eventId"}),n.jsx("span",{className:"max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},title:e.eventId,children:e.eventId})]}),e.correlationId&&n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"correlationId"}),n.jsx("span",{className:"max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},title:e.correlationId,children:e.correlationId})]})]}),a&&n.jsxs("div",{className:"mt-2 rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx(Re,{className:"h-4 w-[35%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[90%]"}),n.jsx(Re,{className:"mt-2 h-4 w-[75%]"})]}),l&&n.jsx("div",{className:"mt-2 rounded-md border p-2 text-sm",style:{borderColor:"var(--ds-red-300)",color:"var(--ds-red-700)"},children:l}),u!=null&&n.jsx("div",{className:"mt-2",children:n.jsx(qc,{eventType:e.eventType,data:u})})]})}function qc({eventType:e,data:t}){if(Gc.has(e)&&t!=null&&typeof t=="object"){const r=t;if(nr(r.error))return n.jsx(Ar,{value:r.error});if(nr(r))return n.jsx(Ar,{value:r})}return n.jsx(Hs,{data:t})}function Zc({events:e,isLoading:t=!1,error:r,onLoadEventData:o,encryptionKey:s}){const a=h.useMemo(()=>[...e].sort((i,l)=>new Date(i.createdAt).getTime()-new Date(l.createdAt).getTime()),[e]);return n.jsxs("div",{className:"mt-2",style:{color:"var(--ds-gray-1000)"},children:[n.jsxs("h3",{className:"text-heading-16 font-medium mt-4 mb-2",style:{color:"var(--ds-gray-1000)"},children:["Events ",!t&&`(${a.length})`]}),t?n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(Re,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(Re,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(Re,{className:"h-[48px] w-full rounded-lg border"})]}):null,!t&&!r&&a.length===0&&n.jsx("div",{className:"text-sm",children:"No events found"}),a.length>0&&!r?n.jsx("div",{className:"flex flex-col gap-4",children:a.map(i=>n.jsx(Kc,{event:i,onLoadEventData:o,encryptionKey:s},i.eventId))}):null]})}function Yc(e){return e!==null&&typeof e=="object"&&"stepId"in e}function Xc(e){return e!==null&&typeof e=="object"&&"runId"in e}function vr(e){return e!==null&&typeof e=="object"&&"hookId"in e}function Jc({run:e,onStreamClick:t,spanDetailData:r,spanDetailError:o,spanDetailLoading:s,onSpanSelect:a,onWakeUpSleep:i,onLoadEventData:l,onResolveHook:d,encryptionKey:c,onDecrypt:p,selectedSpan:u}){const[f,x]=h.useState(!1),[b,j]=h.useState(!1),[w,v]=h.useState(!1),[g,I]=h.useState(new Set),N=u==null?void 0:u.data,C=u==null?void 0:u.rawEvents,E=(C==null?void 0:C.length)??0,{resource:m,resourceId:y,runId:k}=h.useMemo(()=>{if(!u)return{resource:void 0,resourceId:void 0,runId:void 0};const L=u.resource;if(L==="step"&&Yc(N))return{resource:"step",resourceId:N.stepId,runId:N.runId};if(L==="run"&&Xc(N))return{resource:"run",resourceId:N.runId,runId:void 0};if(L==="hook"&&vr(N))return{resource:"hook",resourceId:N.hookId,runId:void 0};if(L==="sleep"){const W=N;return{resource:"sleep",resourceId:u.spanId,runId:W==null?void 0:W.runId}}return{resource:void 0,resourceId:void 0,runId:void 0}},[u,N]);h.useEffect(()=>{m&&y&&["run","step","hook","sleep"].includes(m)&&a({resource:m,resourceId:y,runId:k})},[m,y,k,a]);const T=h.useMemo(()=>m!=="sleep"||!C||["completed","failed","cancelled"].includes(e.status)||!C.some(ee=>ee.eventType==="wait_created")?!1:!C.some(ee=>ee.eventType==="wait_completed"),[m,C,E,e.status]),S=h.useMemo(()=>!(m!=="hook"||!C||!y||g.has(y)||["completed","failed","cancelled"].includes(e.status)||C.some($=>$.eventType==="hook_disposed")),[m,y,C,E,e.status,g]),A=o??void 0,R=s??!1,F=h.useMemo(()=>{if(!r)return!1;const L=r;return at(L.input)||at(L.output)||at(L.error)||at(L.metadata)},[r]),B=h.useMemo(()=>{if(!(m!=="hook"||!y)){if(vr(r)&&r.token)return r.token;if(vr(N)&&N.token)return N.token}},[m,y,r,N]);h.useEffect(()=>{A&&u&&m&&fe.error(`Failed to load ${m} details`,{description:A.message})},[A,m,u]);const D=async()=>{if(!(f||!y)){if(!i){fe.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{x(!0),(await i(e.runId,y)).stoppedCount>0?fe.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):fe.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(L){console.error("Failed to wake up run:",L),fe.error("Failed to wake up run",{description:L instanceof Error?L.message:"An unknown error occurred"})}finally{x(!1)}}},_=h.useCallback(async L=>{if(!w){if(!d){fe.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!B){fe.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0);const W=r??N,$=vr(W)?W:void 0;await d(B,L,$),fe.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),j(!1),y&&I(ee=>new Set(ee).add(y))}catch(W){console.error("Failed to resolve hook:",W),fe.error("Failed to resolve hook",{description:W instanceof Error?W.message:"An unknown error occurred"})}finally{v(!1)}}},[d,B,w,r,N]),P=r??N,U=h.useMemo(()=>{const L=P,W=L.stepName,$=L.workflowName;if(typeof W=="string")return W;if(typeof $=="string")return $;if(typeof e.workflowName=="string")return e.workflowName},[P,e.workflowName]);if(!u||!m||!y)return null;const Q=m.charAt(0).toUpperCase()+m.slice(1),z=m==="sleep"&&T||m==="hook"&&S,Y=e.completedAt?"Completed":"Live";return n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx("div",{className:"border-b px-3 py-3",style:{borderColor:"var(--ds-gray-200)"},children:n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-[13px] font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:Q}),n.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:Y})]}),n.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:y,children:y})]}),(F||c)&&p&&n.jsxs("button",{type:"button",onClick:p,disabled:!!c,className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium transition-colors flex-shrink-0",style:{borderColor:c?"var(--ds-green-400)":"var(--ds-gray-300)",color:c?"var(--ds-green-900)":"var(--ds-gray-900)",backgroundColor:c?"var(--ds-green-100)":"var(--ds-background-100)",cursor:c?"default":"pointer"},children:[c?n.jsx($i,{className:"h-3 w-3"}):n.jsx(Yo,{className:"h-3 w-3"}),c?"Decrypted":"Decrypt"]})]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[z&&n.jsxs("div",{className:"mb-4 rounded-lg border p-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[n.jsx("p",{className:"mb-2 px-1 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Actions"}),n.jsxs("div",{className:"flex flex-col gap-2",children:[m==="sleep"&&T&&n.jsxs("button",{type:"button",onClick:D,disabled:f,className:Rt("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium","disabled:opacity-50 disabled:cursor-not-allowed transition-colors",f?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[n.jsx(Ra,{className:"h-4 w-4"}),f?"Waking up...":"Wake Up Sleep"]}),m==="hook"&&S&&n.jsxs("button",{type:"button",onClick:()=>j(!0),disabled:w,className:Rt("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium","disabled:opacity-50 disabled:cursor-not-allowed transition-colors",w?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-gray-1000)",color:"var(--ds-background-100)"},children:[n.jsx(Go,{className:"h-4 w-4"}),"Resolve Hook"]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("section",{children:[n.jsx("h3",{className:"mb-2 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Details"}),n.jsx(Vc,{data:P,moduleSpecifier:U,expiredAt:e.expiredAt,isLoading:R,error:A??void 0,onStreamClick:t})]}),m!=="run"&&C&&n.jsx("section",{children:n.jsx(Zc,{events:C,onLoadEventData:l,encryptionKey:c})})]})]}),n.jsx(Uo,{isOpen:b,onClose:()=>j(!1),onSubmit:_,isSubmitting:w})]})}function Qc(e){const t=h.useRef(e);t.current=e,h.useEffect(()=>{let r=0,o=0;const s=()=>{t.current(r),r=0},a=i=>{if(!i.ctrlKey&&!i.metaKey)return;i.preventDefault();let l=-i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_PAGE:l*=window.innerHeight;break;case WheelEvent.DOM_DELTA_LINE:l*=20;break}r+=l,cancelAnimationFrame(o),o=requestAnimationFrame(s)};return window.addEventListener("wheel",a,{passive:!1}),()=>{window.removeEventListener("wheel",a),cancelAnimationFrame(o)}},[])}function xo(e){if(e<=0)return 1;const r=10**Math.floor(Math.log10(e)),o=e/r;return o<=1.5?r:o<=3.5?2*r:o<=7.5?5*r:10*r}function ed({scale:e,isLive:t=!1}){const{state:{root:r}}=nt(),[,o]=h.useState(0);h.useEffect(()=>{if(!t)return;const f=setInterval(()=>o(x=>x+1),1e3);return()=>clearInterval(f)},[t]);const s=r.duration,a=e>0?e:s>0?1/s:1;let l=xo(50/a);l=Math.max(1,l);let d=l*a;const c=1e3;s/l>c&&(l=xo(s/c),d=l*a);const p=Math.ceil(s/l),u=Math.ceil(100/d)||1;return n.jsx("div",{className:J.markersContainer,children:n.jsx("div",{"aria-hidden":!0,className:J.markers,style:{width:Math.floor(r.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${d}px`},children:new Array(p).fill(null).map((f,x)=>{const b=x%u===0;return n.jsx("span",{className:Rt(J.marker,!b&&J.notch),children:b?n.jsxs("span",{className:J.markerLabel,children:[hi(l*x),n.jsx("span",{className:J.markerClockTime,children:gi(r.startTime+l*x)})]}):null},String(x))})})})}function td({events:e,root:t,scale:r}){const o=h.useMemo(()=>e.filter(s=>s.event.showVerticalLine!==!1),[e]);return n.jsx("div",{className:J.eventMarkersContainer,children:n.jsx("div",{"aria-hidden":!0,className:J.eventMarkers,style:{width:Math.floor(t.duration*r)},children:o.map(s=>n.jsx("span",{className:Rt(J.eventMarker),style:{left:Math.floor((s.timestamp-t.startTime)*r),...s.event.color&&{borderLeftColor:s.event.color}}},s.key))})})}const vo=2;function rd({memoCacheRef:e,timelineRef:t,root:r,spans:o,events:s,scale:a,dispatch:i,scrollSnapshotRef:l}){const d=h.useRef(!1),c=h.useRef(o);c.current=o;const p=h.useRef(s);p.current=s;const u=h.useRef(null),{style:f,setStyle:x}=zr(u),b=h.useRef(null),j=h.useRef(null),{style:w,setStyle:v}=zr(j),g=h.useRef(void 0),I=h.useRef(null),{style:N,setStyle:C}=zr(I),E=h.useRef(0);h.useEffect(()=>{const y=t.current;if(!y)return;let k=E.current,T=0,S=!1,A=!1,R=!1,F=!1,B=0,D=0;const _=Date.now()+500,P=()=>{g.current||(g.current=y.getBoundingClientRect())},U=X=>g.current?(X-Sr-Fe)/(Ft+gt):0,Q=()=>{const X=e.current;for(const ae of c.current)ae.isHovered&&(ae.isHovered=!1,X.set(ae.span.spanId,{}));i({type:"forceRender"})};let z=0;const Y=()=>{var Ce,It,ft,Z,pe,be,Ae,Ge;if(!d.current)return;g.current||P();const X=g.current;if(!X)return;const{scrollLeft:ae,scrollTop:xe}=y,ye=Math.max(0,Math.min(k+ae-X.left-Fe,r.duration*a)),le=`${ye-ae+Fe}px`;v("left",le),x("left",le);const ue=r.startTime+ye/a,ke=ue-r.startTime;if(ke<0||ke>r.duration?(Ce=b.current)==null||Ce.removeAttribute("data-text"):(It=b.current)==null||It.setAttribute("data-text",hr(ke)),S){const Ye=k-T,jt=Math.abs(Ye);if(!R){if(jt<4)return;R=!0,C("display","flex"),Q()}Ye>0?(C("left",""),C("right","0")):(C("left","0"),C("right","")),C("width",`${jt}px`);const kt=Math.max(0,Math.min(T+ae-X.left-Fe,r.duration*a))/a;let mt,Ct;kt<ke?(mt=kt,Ct=ke):(mt=ke,Ct=kt),(ft=I.current)==null||ft.setAttribute("data-range",`${hr(mt)} — ${hr(Ct)}`),(Z=I.current)==null||Z.setAttribute("data-duration",`${hr(Ct-mt)} selected`)}if(Date.now()<_){z=requestAnimationFrame(Y);return}if(ae!==B||xe!==D){B=ae,D=xe,z=requestAnimationFrame(Y);return}if(k-X.left<128?(pe=b.current)==null||pe.setAttribute("data-align","left"):k-X.left>X.width-128?(be=b.current)==null||be.setAttribute("data-align","right"):(Ae=b.current)==null||Ae.removeAttribute("data-align"),!R&&!A){const Ye=e.current,jt=U(xe)-vo,ur=U(xe+X.height)+vo;for(const _e of c.current){const Xe=_e.row>=jt&&_e.row<=ur&&ue>=_e.startTime&&ue<=_e.endTime;_e.isHovered!==Xe&&(_e.isHovered=Xe,Ye.set(_e.span.spanId,{}))}const mt=12/a;let Ct=null,Bn=1/0;for(const _e of p.current){const Xe=Math.abs(_e.timestamp-ue);Xe<=mt&&Xe<Bn&&(Bn=Xe,Ct=_e)}for(const _e of p.current){const Xe=_e===Ct;if(_e.isHovered===Xe)continue;_e.isHovered=Xe;const zn=(Ge=_e.ref)==null?void 0:Ge.current;zn&&zn.setAttribute("data-hovered",String(Xe))}i({type:"forceRender"})}};z=requestAnimationFrame(Y);const L=X=>{X.pointerType==="mouse"&&(d.current=!0)},W=()=>{d.current&&(d.current=!1,Q())},$=({clientX:X})=>{k=X,E.current=k,cancelAnimationFrame(z),z=requestAnimationFrame(Y)},ee=X=>{X.preventDefault()},de=X=>{var ae;if(X.button===2)F=!0,X.preventDefault();else{if(X.button!==0)return;F=!1}(ae=t.current)!=null&&ae.contains(X.target)?(T=k,S=!0):(A=!0,requestAnimationFrame(Q))},O=X=>{if(A=!1,!S||(S=!1,!R))return;if(R=!1,C("display",""),C("left",""),C("right",""),C("width",""),X.preventDefault(),X.stopImmediatePropagation(),F){F=!1;return}g.current||P();const ae=g.current;if(!ae)return;const{scrollLeft:xe}=y,ye=Math.max(0,Math.min((T+xe-ae.left-Fe)/a,r.duration)),le=Math.max(0,Math.min((k+xe-ae.left-Fe)/a,r.duration));i({type:"scaleToRange",t1:ye+r.startTime,t2:le+r.startTime})},G=X=>{S&&X.key==="Escape"&&(F=!0,O(X))},oe=()=>{g.current=void 0,m.current=void 0,cancelAnimationFrame(z),z=requestAnimationFrame(Y)},ge=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(Y)},Ee=new ResizeObserver(()=>{g.current=void 0});return Ee.observe(y),window.addEventListener("mousemove",$),y.addEventListener("contextmenu",ee),window.addEventListener("mousedown",de),window.addEventListener("mouseup",O),window.addEventListener("blur",O),window.addEventListener("keydown",G,!0),window.addEventListener("scroll",oe),y.addEventListener("scroll",ge),y.addEventListener("pointerenter",L),y.addEventListener("pointerleave",W),()=>{Ee.disconnect(),window.removeEventListener("mousemove",$),y.removeEventListener("contextmenu",ee),window.removeEventListener("mousedown",de),window.removeEventListener("mouseup",O),window.removeEventListener("blur",O),window.removeEventListener("keydown",G,!0),window.removeEventListener("scroll",oe),y.removeEventListener("scroll",ge),y.removeEventListener("pointerenter",L),y.removeEventListener("pointerleave",W),cancelAnimationFrame(z),E.current=k,Q()}},[i,r,a,v,x,C,e,t,l]);const m=h.useRef(void 0);return Qc(y=>{const k=t.current;if(!k)return;g.current??(g.current=k.getBoundingClientRect());const T=g.current,S=Math.max(0,Math.min(E.current-T.left-Fe,T.width-2*Fe));let A=0,R=m.current;(R==null?void 0:R.anchorX)===S?A=R.anchorT:(A=(k.scrollLeft+S)/a,R={anchorT:A,anchorX:S},m.current=R),i({type:"trackpadScale",delta:y/64,anchorT:A,anchorX:S})}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:J.cursorMarkerStickyParent,children:n.jsx("div",{className:J.cursorMarkerLabelContainer,ref:u,style:f,children:n.jsx("div",{className:J.cursorMarkerLabel,ref:b})})}),n.jsx("div",{className:J.cursorMarkerStickyParent,children:n.jsx("div",{className:J.cursorMarkerContainer,ref:j,style:w,children:n.jsx("div",{className:J.cursorMarker,children:n.jsx("div",{className:J.cursorSelection,ref:I,style:N})})})})]})}function nd({height:e,width:t,value:r,placeholder:o,onChange:s}){return n.jsxs("label",{className:J.searchInputLabel,children:[n.jsx("div",{className:J.searchInputPrefix,children:n.jsx(od,{})}),n.jsx("input",{type:"search",value:r,placeholder:o,onChange:s,style:{height:e,width:t}})]})}function od(){return n.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function sd(){return n.jsx("nav",{className:J.searchBar,children:n.jsx(ad,{})})}function ad(){const{dispatch:e}=nt(),[t,r]=h.useState("");return h.useEffect(()=>{const o=setTimeout(()=>e({type:"setFilter",filter:t}),100);return()=>{clearTimeout(o)}},[e,t]),n.jsx("div",{className:J.searchInput,children:n.jsx(nd,{height:Xo,onChange:o=>r(o.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}function id({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Zoom In"}),n.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("path",{d:"M11 8v6M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),n.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ld({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Zoom Out"}),n.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("path",{d:"M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),n.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function cd({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Minus"}),n.jsx("path",{d:"M6 12h12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function dd(){const{dispatch:e}=nt(),t=h.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),r=h.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),o=h.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return n.jsxs("div",{className:J.zoomButtonGroup,children:[n.jsx("button",{"aria-label":"Zoom Out",className:J.zoomButton,onClick:r,type:"button",children:n.jsx(ld,{size:18})}),n.jsx("div",{className:J.divider}),n.jsx("button",{"aria-label":"Reset Zoom",className:J.zoomButton,onClick:o,type:"button",children:n.jsx(cd,{size:18})}),n.jsx("div",{className:J.divider}),n.jsx("button",{"aria-label":"Zoom In",className:J.zoomButton,onClick:t,type:"button",children:n.jsx(id,{size:18})})]})}const ud=e=>{const{spans:t}=e,r={startTime:0,endTime:0,duration:0,depth:0,children:[]},o={},s=new Map,a=u=>{const f=s.get(u);if(f)return f;const x=s.size+1;return s.set(u,x),x};let i=!1;for(const u of t){const f=Ut(u.startTime),x=Ut(u.endTime),b=Ut(u.duration);x>r.endTime&&(r.endTime=x,r.duration=x-r.startTime),(r.startTime===0||f<r.startTime)&&(r.startTime=f,r.duration=r.endTime-f);const j=u.resource.startsWith("vercel.");j||(i=!0);const w=j&&(u.resource!=="vercel.serverless-runtime"||!("http.method"in u.attributes)),v=w?0:a(u.resource);let g;w&&(g=`▲ ${u.name}`),o[u.spanId]={parent:null,startTime:f,endTime:x,duration:b,span:u,depth:0,label:g,events:fd(u),isVercel:w,children:[],resourceIndex:v,activeStartTime:u.activeStartTime?Ut(u.activeStartTime):void 0}}const l=(u,f)=>{let x;f?(x=o[f],x||(x=r)):x=r,u.parent=x,x.children.push(u)},d=u=>{"parent"in u&&(u.depth=u.parent.depth+1);for(const f of u.children)d(f)};let c=1;const p=(u,f)=>{if("parent"in u&&u.span.name===f){let x=u.endTime;const b=E=>E.children.length?E.children.map(b).sort((m,y)=>m.duration-y.duration)[0]||E:E.span.name==="waitUntil"?(x=E.startTime,E.parent):E,j=b(u),w=`instrumentation-hint-${c++}`,v=u.duration*.05,g=u.startTime+v,I=Math.max(g+v,Math.min(x-u.duration*.01,u.endTime-v)),N=I-g,C={parent:j,startTime:g,endTime:I,duration:N,span:{spanId:w,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Wr(g),endTime:Wr(I),duration:Wr(N)},depth:u.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return j.children.push(C),o[w]=C,!0}for(const x of u.children)if(p(x,f))return!0;return!1};for(const u of Object.values(o))l(u,u.span.parentSpanId);if(d(r),!i){for(const u of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(p(r,u))break}return{root:r,map:o}},fd=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((r,o)=>({key:`${t}${o}`,timestamp:Ut(r.timestamp),event:r})).sort((r,o)=>r.timestamp-o.timestamp)},yo=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function Yr(){return[]}const md=(e,t=!1)=>{const{state:r,dispatch:o}=nt(),{root:s,filter:a,scale:i,timelineRef:l,timelineWidth:d,spanMap:c,scrollSnapshotRef:p,selected:u,memoCacheRef:f}=r,x=pd(r.timelineHeight),b=h.useRef(0),[j,w]=h.useState(Yr),[v,g]=h.useState(Yr),[I,N]=h.useState(Yr),[C,E]=h.useState(-1),m=h.useRef(void 0);return h.useEffect(()=>{var y;return(y=m.current)==null?void 0:y.call(m,a)},[a]),h.useEffect(()=>{if(e!=null&&e.length){for(const y of j)for(const k of y){const T=e.includes(k.span.spanId);k.isHighlighted!==T&&(k.isHighlighted=T,f.current.set(k.span.spanId,{}))}o({type:"forceRender"})}},[j,e,o,f]),h.useEffect(()=>{if(!s.startTime)return;const y=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let k=++b.current;const T=A=>{var F;const R=A.data;switch(R.type){case"setRowsResult":{if((R==null?void 0:R.requestId)!==k)return;if(R.isEnd)for(const B of R.rows)for(const D of B)D.span=((F=c[D.span.spanId])==null?void 0:F.span)??D.span;w(R.rows);break}case"updateHighlight":{if((R==null?void 0:R.requestId)!==k)return;const{matches:B}=R;w(D=>{for(const _ of D)for(const P of _){const U=B.has(P.span.spanId);P.isHighlighted!==U&&(P.isHighlighted=U,f.current.set(P.span.spanId,{}))}return D}),o({type:"forceRender"});break}}};y.addEventListener("message",T);const S={requestId:k,type:"calculateSpanPositions",root:s};return y.postMessage(S),m.current=A=>{const R=A.trim().toLocaleLowerCase();if(!R){w(B=>B.map(D=>D.map(_=>(_.isHighlighted=void 0,{..._}))));return}k=++b.current;const F={type:"filterSpans",requestId:k,root:s,filter:R};y.postMessage(F)},()=>{y.terminate()}},[s,c,o,f]),h.useEffect(()=>{if(!j.length)return;if(t){const $=[],ee=[];for(const de of j)for(const O of de)yo(O)&&($.push(O),O.events&&ee.push(...O.events));g($),N(ee),E(i);return}const y=l.current;let k=p.current,T=!1,S=!1,A=0,R=0;const F=Math.max(500,d*.5),B=new Array(j.length).fill(null),D=()=>{S=!0;const $=Math.min(1+R+Math.ceil((k==null?void 0:k.endRow)??Number.POSITIVE_INFINITY),j.length);for(let ee=$;ee--;){if(B[ee])continue;const de=_(ee);if(Math.abs(de)>R){if(S=!1,de>0)continue;break}const O=[],G=j[ee];if(G){for(const oe of G){if(!yo(oe))continue;const ge=P(oe);A=Math.max(ge,A),O.push({d:ge,span:oe})}B[ee]=O}}},_=$=>k?$<k.startRow?$-k.startRow:$>k.endRow?$-k.endRow:0:0,P=$=>{if(!k)return 0;let ee=0;$.endTime<k.startTime?ee=k.startTime-$.endTime:$.startTime>k.endTime&&(ee=$.startTime-k.endTime);const de=Math.abs(_($.row));return!ee&&!de?0:Math.sqrt((ee/i)**2+(de*Ft+gt)**2)},U=()=>{if(!y)return;const{scrollLeft:$,scrollTop:ee}=y,de=0,O=$/i,G=(ee-Sr-Fe)/(Ft+gt),oe=G+Math.ceil(x/(Ft+gt));k={anchorT:O,anchorX:de,scrollLeft:$,scrollTop:ee,startTime:s.startTime+$/i,endTime:s.startTime+($+d)/i,startRow:G,endRow:oe,scale:i},p.current=k;for(let ge=B.length;ge--;)B[ge]=null};let Q=0;const z=()=>{(T||!k)&&(T=!1,U()),D();const $=[],ee=[];for(const de of B)if(de)for(const{d:O,span:G}of de)O>R||($.push(G),G.events&&ee.push(...G.events));R<F&&(!S||R<A)&&(R=Math.min(F,R+100),Q=requestAnimationFrame(z)),g($),N(ee),E(i)};z();let Y=Date.now();const L=$=>{($.ctrlKey||$.metaKey)&&(Y=Date.now())};y==null||y.addEventListener("wheel",L);const W=()=>{Date.now()-Y<=50||(T=!0,cancelAnimationFrame(Q),Q=requestAnimationFrame(z))};return y==null||y.addEventListener("scroll",W),()=>{cancelAnimationFrame(Q),y==null||y.removeEventListener("wheel",L),y==null||y.removeEventListener("scroll",W)}},[j,s,i,p,l,d,x,t]),h.useEffect(()=>{var T;if(!u)return;let y;for(const S of v)if(S.span.spanId===u.span.spanId){y=S;break}const k=(T=y==null?void 0:y.ref)==null?void 0:T.current;if(!(!y||!k))return y.isSelected=!0,k.setAttribute("data-selected",""),()=>{y.isSelected=!1,k.removeAttribute("data-selected")}},[v,u]),{rows:j,spans:v,events:I,scale:C}};function pd(e){const[t,r]=h.useState(e);return h.useEffect(()=>{if(t===e)return;let o=0,s=0;const a=()=>{if(++o<=3){s=requestAnimationFrame(a);return}r(e)};return a(),()=>{cancelAnimationFrame(s)}},[t,e]),t}const bo={traceId:"skeleton",spans:[{parentSpanId:"",spanId:"root",name:"root span",kind:1,resource:"vercel.runtime",startTime:[5e3,0],endTime:[6e3,0],duration:[1e3,0],library:{name:"vercel-site"},status:{code:1},attributes:{"vercel.ownerId":"team_abc"},traceFlags:1,events:[],links:[]}],resources:[{name:"vercel.runtime",attributes:{}}],rootSpanId:"root"};function hd({trace:e=bo,className:t="",scrollLock:r=!1,height:o,withPanel:s=!1,highlightedSpans:a,eagerRender:i=!1,isLive:l=!1,footer:d,knownDurationMs:c,hasMoreData:p=!1}){const u=e===bo,{state:f,dispatch:x}=nt(),{timelineRef:b,scrollSnapshotRef:j}=f,w=f.memoCacheRef.current,v=((a==null?void 0:a.length)??0)>0,g=h.useRef(!1),I=h.useRef(""),N=h.useRef(null),C=h.useRef({}),E=h.useRef(null);h.useEffect(()=>{const{root:D,map:_}=ud(e),P=!g.current;g.current=!0;const U=Object.keys(_).sort().map(Q=>{const z=_[Q].events,Y=(z==null?void 0:z.length)??0,L=Y?z==null?void 0:z[0]:void 0,W=Y?z==null?void 0:z[Y-1]:void 0,$=`${(L==null?void 0:L.event.name)??"none"}@${(L==null?void 0:L.timestamp)??0}|${(W==null?void 0:W.event.name)??"none"}@${(W==null?void 0:W.timestamp)??0}`;return`${Q}:${Y}:${$}`}).join(",");if(!P&&U===I.current&&N.current){const Q=N.current,z=C.current;let Y=!1;(Q.endTime!==D.endTime||Q.duration!==D.duration)&&(Q.endTime=D.endTime,Q.duration=D.duration,Y=!0);for(const[L,W]of Object.entries(_)){const $=z[L];$&&(($.endTime!==W.endTime||$.duration!==W.duration)&&($.endTime=W.endTime,$.duration=W.duration,Y=!0),Object.assign($.span,W.span))}if(!Y)return;x({type:"forceRender"});return}I.current=U,N.current=D,C.current=_,x({type:P?"setRoot":"updateRoot",root:D,spanMap:_,resources:e.resources||[]})},[x,e]);const{rows:m,spans:y,events:k,scale:T}=md(a,i),S=h.useRef(null);h.useLayoutEffect(()=>{const D=S.current;if(!D)return;const _=()=>{const U=2*Fe,Q=D.getBoundingClientRect(),z=Q.width-U,Y=Q.height,L=E.current;L&&L.width===z&&L.height===Y||(E.current={width:z,height:Y},x({type:"setSize",width:z,height:Y}))};_();const P=new ResizeObserver(_);return P.observe(D),window.addEventListener("resize",_),()=>{P.disconnect(),window.removeEventListener("resize",_)}},[x]);const A=h.useRef({t:0,x:-1,y:-1,spanId:""}),R=h.useCallback(D=>{const _=A.current,P=Date.now(),{clientX:U,clientY:Q}=D,z=Math.sqrt((U-_.x)**2+(Q-_.y)**2);if(P-_.t<=500&&z<=8){if(D.stopPropagation(),D.preventDefault(),!_.spanId){x({type:"resetScale"});return}x({type:"select",id:_.spanId}),x({type:"scaleToNode",id:_.spanId});return}const Y=D.target;if(!Y.closest(`.${String(J.timeline)}`))return;const L=Y.closest("[data-span-id]"),W=(L==null?void 0:L.dataset.spanId)||"";A.current={x:U,y:Q,t:P,spanId:W},W&&(x({type:"toggleSelection",id:W}),D.stopPropagation())},[x]);h.useLayoutEffect(()=>{const D=b.current;if(!D)return;const _=j.current;_&&(D.scrollLeft=_.anchorT*T-_.anchorX,j.current=void 0)},[j,b,T]),h.useEffect(()=>{var P;const D=(P=f.selected)==null?void 0:P.span.spanId;if(!D)return;const _=setTimeout(()=>{const U=f.timelineRef.current,Q=U==null?void 0:U.querySelector(`[data-span-id="${D}"]`);if(!U||!Q)return;const z=U.getBoundingClientRect(),Y=Q.getBoundingClientRect();Y.width<z.width&&(Y.left<z.left||Y.right>z.right||Y.top<z.top||Y.bottom>z.bottom)&&Q.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(_)}},[f.selected,f.timelineRef]),h.useEffect(()=>{const D=_=>{_.key==="Escape"&&x({type:"escape"})};return window.addEventListener("keydown",D),()=>{window.removeEventListener("keydown",D)}},[x]),h.useEffect(()=>{if(!r)return;const D=document.documentElement,_=document.body;D.style.overflow="clip",_.style.overflow="clip";const P=U=>{U!=null&&U.cancelable?U.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return P(),window.addEventListener("scroll",P,{passive:!1}),()=>{D.style.overflow="",_.style.overflow="",window.removeEventListener("scroll",P)}},[r]);const F=Math.max(f.timelineHeight-f.scrollbarWidth,Sr+gt+m.length*(Ft+gt)-gt+84),B=!!(f.isMobile&&f.selected);return n.jsxs("div",{className:Rt(J.traceViewer,u&&J.skeleton,t),onClickCapture:R,ref:S,style:{height:o,"--timeline-padding":`${Fe}px`,"--row-height":`${Ft}px`,"--row-padding":`${gt}px`,"--search-height":`${v?0:Xo}px`,"--search-gap":`${v?2:yi}px`,"--map-height":`${vi}px`,"--timeline-width":`${f.timelineWidth}px`,"--timeline-height":`${f.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(f.root.duration*f.scale)}px`,"--panel-width":`${f.panelWidth}px`,"--panel-height":`${f.panelHeight}px`,"--height":`${f.height}px`,"--scrollbar-width":`${f.scrollbarWidth}px`,"--marker-height":`${Sr}px`,"--marker-notch-height":`${xi}px`},children:[v?null:n.jsx(sd,{}),n.jsx(bi,{rows:m,scale:T,timelineRef:b}),n.jsxs("div",{className:Rt(J.traceViewerContent,B&&J.inert),children:[n.jsxs("div",{className:J.timeline,ref:b,children:[n.jsx("div",{style:{position:"relative",width:f.timelineWidth,minHeight:f.timelineHeight-Fe*2,padding:Fe,paddingBottom:0},children:n.jsxs("div",{className:J.traceNode,style:{width:f.root.duration*T||void 0,height:F-Fe*2},children:[n.jsx(ed,{scale:T,isLive:l}),n.jsx(td,{events:k,root:f.root,scale:T}),n.jsx(rd,{dispatch:x,events:k,memoCacheRef:f.memoCacheRef,root:f.root,scale:T,scrollSnapshotRef:j,spans:y,timelineRef:b}),n.jsx(wi,{cacheKey:w.get(""),cache:w,customSpanClassNameFunc:f.customSpanClassNameFunc,customSpanEventClassNameFunc:f.customSpanEventClassNameFunc,isLive:l,root:f.root,scale:T,scrollSnapshotRef:j,spans:y}),c!=null&&c>0&&(p||l)&&f.root.duration>0&&(()=>{const D=c*T,P=f.root.duration*T-D;if(P<4)return null;const U=Math.min(P*.05,20);return n.jsx("div",{style:{position:"absolute",top:0,left:D+U,width:P-U,height:"100%",pointerEvents:"none",zIndex:1,maskImage:"linear-gradient(to right, transparent 1%, black 3%)",WebkitMaskImage:"linear-gradient(to right, transparent 1%, black 3%)",background:"repeating-linear-gradient(-45deg, var(--ds-background-200) 0, var(--ds-background-200) 11px, var(--ds-gray-200) 11px, var(--ds-gray-200) 12px)"}})})()]})}),d]}),n.jsx("div",{className:J.zoomButtonTraceViewer,children:n.jsx(dd,{})})]}),s?n.jsx("div",{className:Rt(J.spanDetailPanelTraceViewer,!f.selected&&J.hidden,f.isMobile&&J.mobile),children:n.jsx(Ni,{attached:!0})}):null]})}function wo(e,t=!1){if(t&&e==="pending")return J.spanPendingStriped;switch(e){case"running":return J.spanRunning;case"pending":return J.spanPending;case"completed":return J.spanCompleted;case"cancelled":return J.spanCancelled;case"failed":return J.spanFailed;default:return""}}function gd(e){return String(e).toLowerCase().endsWith("sleep")}const xd=e=>{const t=e.span.attributes,r=t==null?void 0:t.resource;if(r==="step"){const o=t.data,s=o==null?void 0:o.stepName;if(s&&gd(s))return J.spanSleep;const a=(o==null?void 0:o.status)==="pending";return wo(o==null?void 0:o.status,a)}if(r==="run"){const o=t.data;return wo(o==null?void 0:o.status,!1)}return r==="hook"?J.spanHook:r==="sleep"?J.spanSleep:""},vd=e=>{const t=e.event.name;return t==="step_failed"||t==="run_failed"?J.eventFailed:t==="step_retrying"?J.eventRetrying:t==="hook_created"||t==="hook_received"||t==="hook_disposed"?J.eventHook:J.eventDefault};function yd(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function Ke(e){if(typeof e=="string"&&(e=new Date(e)),!e||!(e instanceof Date))return[0,0];const t=e.getTime(),r=Math.floor(t/1e3),o=t%1e3*1e6;return[r,o]}function gn(e){const t=e[0]*1e3,r=e[1]/1e6;return t+r}function Fr(e,t){if(typeof e=="string"&&(e=new Date(e)),typeof t=="string"&&(t=new Date(t)),!e||!(e instanceof Date))return[0,0];const o=(t&&t instanceof Date?t:new Date).getTime()-e.getTime(),s=Math.floor(o/1e3),a=o%1e3*1e6;return[s,a]}const dr={name:"workflow-development-kit",version:"4.0.0"},bd=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function Pr(e,t=!0){return e.filter(r=>t?bd.has(r.eventType):!0).map(r=>({name:r.eventType,timestamp:Ke(r.createdAt),attributes:{eventId:r.eventId,correlationId:r.correlationId,eventData:"eventData"in r?r.eventData:void 0},showVerticalLine:yd(r.eventType)}))}const Bs=e=>{var o;const t=e.find(s=>s.eventType==="wait_created");if(!t)return null;const r=e.find(s=>s.eventType==="wait_completed");return{waitId:t.correlationId,runId:t.runId,createdAt:t.createdAt,resumeAt:(o=t.eventData)==null?void 0:o.resumeAt,completedAt:r==null?void 0:r.createdAt}};function wd(e,t){const r=Bs(e);if(!r)return null;const o=r.createdAt,s=r.completedAt??t,a=Ke(o),i=Ke(s),l=Fr(o,s),d=Pr(e,!1);return{spanId:r.waitId,name:"sleep",kind:1,resource:"sleep",library:dr,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:r},links:[],events:d,duration:l,startTime:a,endTime:i}}const zs=e=>{var l;const t=e.find(d=>d.eventType==="step_created");if(!t)return null;let r="pending",o=0,s,a;for(const d of e)switch(d.eventType){case"step_started":r="running",o+=1,s||(s=d.createdAt),a=void 0;break;case"step_completed":r="completed",a=d.createdAt;break;case"step_failed":r="failed",a=d.createdAt;break;case"step_retrying":r="pending",a=void 0;break}o===0&&(o=1);const i=e[e.length-1];return{stepId:t.correlationId,runId:t.runId,stepName:((l=t.eventData)==null?void 0:l.stepName)??"",status:r,attempt:o,createdAt:t.createdAt,updatedAt:(i==null?void 0:i.createdAt)??t.createdAt,startedAt:s,completedAt:a,specVersion:t.specVersion}};function Nd(e,t){const r=zs(e);if(!r)return null;const o=sr(String(r.stepName)),s={resource:"step",data:r},a="step",i=new Date(r.completedAt??t),l=Pr(e,!1),d=new Date(r.createdAt);let c=r.startedAt?new Date(r.startedAt):void 0;const p=e.find(u=>u.eventType==="step_started");return p&&(c=new Date(p.createdAt)),{spanId:String(r.stepId),name:(o==null?void 0:o.shortName)??"",kind:1,resource:a,library:dr,status:{code:0},traceFlags:1,attributes:s,links:[],events:l,startTime:Ke(d),endTime:Ke(i),duration:Fr(d,i),activeStartTime:c&&c.getTime()>d.getTime()?Ke(c):void 0}}const Id=e=>{var a,i;const t=e.find(l=>l.eventType==="hook_created");if(!t)return null;const r=e.filter(l=>l.eventType==="hook_received"),o=e.filter(l=>l.eventType==="hook_disposed"),s=r.at(-1);return{hookId:t.correlationId,runId:t.runId,token:(a=t.eventData)==null?void 0:a.token,createdAt:t.createdAt,receivedCount:r.length,lastReceivedAt:(s==null?void 0:s.createdAt)||void 0,disposedAt:((i=o.at(-1))==null?void 0:i.createdAt)||void 0}};function jd(e,t){const r=Id(e);if(!r)return null;const o=Pr(e,!1),s=r.disposedAt||t;return{spanId:String(r.hookId),name:String(r.hookId),kind:1,resource:"hook",library:dr,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:r},links:[],events:o,startTime:Ke(r.createdAt),endTime:Ke(s),duration:Fr(r.createdAt,s)}}function kd(e,t,r){var x;const o=r??new Date,{input:s,output:a,error:i,...l}=e,d={resource:"run",data:l},c=new Date(e.createdAt),p=e.startedAt?new Date(e.startedAt):void 0,u=e.completedAt??o,f=Pr(t,!1);return{spanId:String(e.runId),name:String(((x=xt(e.workflowName))==null?void 0:x.shortName)??"?"),kind:1,resource:"run",library:dr,status:{code:0},traceFlags:1,attributes:d,links:[],events:f,startTime:Ke(c),endTime:Ke(u),duration:Fr(c,u),activeStartTime:p&&p.getTime()>c.getTime()?Ke(p):void 0}}const Cd=e=>e.startsWith("step_"),Sd=e=>e==="wait_created"||e==="wait_completed",Td=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed";function Xr(e,t,r){const o=e.get(t);if(o){o.push(r);return}e.set(t,[r])}function Ed(e){const t=new Map,r=[],o=new Map,s=new Map;for(const a of e){const i=a.correlationId;if(!i){r.push(a);continue}if(Sd(a.eventType)){Xr(o,i,a);continue}if(Td(a.eventType)){Xr(s,i,a);continue}if(Cd(a.eventType)){Xr(t,i,a);continue}r.push(a)}return{eventsByStepId:t,runLevelEvents:r,timerEvents:o,hookEvents:s}}function Ad(e,t){let r=new Date(t.createdAt).getTime();for(const o of e){const s=new Date(o.createdAt).getTime();s>r&&(r=s)}return new Date(r)}function Rd(e,t,r,o){const s=o,a=Array.from(t.eventsByStepId.values()).map(d=>Nd(d,s)).filter(d=>d!==null),i=Array.from(t.hookEvents.values()).map(d=>jd(d,s)).filter(d=>d!==null),l=Array.from(t.timerEvents.values()).map(d=>wd(d,s)).filter(d=>d!==null);return{runSpan:kd(e,t.runLevelEvents,r),spans:[...a,...i,...l]}}function Dd(e,t){const r=[e,...t.slice().sort((o,s)=>{const a=gn(o.startTime),i=gn(s.startTime);return a-i})];return r.map((o,s)=>{const a=s===0?void 0:String(r[s-1].spanId);return{...o,parentSpanId:a}})}function Md(e,t,r){const o=Ed(t),s=Ad(t,e),{runSpan:a,spans:i}=Rd(e,o,r,s),l=Dd(a,i),d=gn(a.startTime),c=s.getTime()-d;return{traceId:e.runId,rootSpanId:e.runId,spans:l,resources:[{name:"workflow",attributes:{"service.name":dr.name}}],knownDurationMs:Math.max(0,c)}}function _d(e){const{state:t,dispatch:r}=nt(),o=h.useRef(t);o.current=t,h.useEffect(()=>{if(!e)return;let s=0;const a=()=>{const{root:c}=o.current;if(c.startTime){const p=Date.now();p>c.endTime&&(c.endTime=p,c.duration=c.endTime-c.startTime)}s=requestAnimationFrame(a)};s=requestAnimationFrame(a);let i=0,l=0;const d=()=>{const c=o.current;if(c.root.duration>0){const p=(c.width-c.scrollbarWidth)/c.root.duration;(Math.abs(p-l)>l*.001||l===0)&&(l=p,r({type:"detectBaseScale"}))}i=requestAnimationFrame(d)};return i=requestAnimationFrame(d),()=>{cancelAnimationFrame(s),cancelAnimationFrame(i)}},[e,r])}const Ld=450,Od=240;function Hd({menu:e,items:t,onClose:r}){const o=h.useRef(null);h.useEffect(()=>{const i=p=>{o.current&&!o.current.contains(p.target)&&r()},l=p=>{p.key==="Escape"&&r()},d=()=>{r()},c=setTimeout(()=>{window.addEventListener("mousedown",i),window.addEventListener("keydown",l),window.addEventListener("scroll",d,!0)},0);return()=>{clearTimeout(c),window.removeEventListener("mousedown",i),window.removeEventListener("keydown",l),window.removeEventListener("scroll",d,!0)}},[r]);const[s,a]=h.useState({x:e.x,y:e.y});return h.useEffect(()=>{const i=o.current;if(!i)return;const l=i.getBoundingClientRect();let{x:d,y:c}=e;l.right>window.innerWidth&&(d=window.innerWidth-l.width-8),l.bottom>window.innerHeight&&(c=window.innerHeight-l.height-8),(d!==e.x||c!==e.y)&&a({x:d,y:c})},[e]),t.length===0?null:Wo.createPortal(n.jsxs("div",{ref:o,style:{position:"fixed",left:s.x,top:s.y,zIndex:99999,boxShadow:"var(--ds-shadow-menu)",borderRadius:12,background:"var(--ds-background-100)",padding:"var(--geist-space-gap-quarter, 4px)",fontSize:14,minWidth:180,overflowX:"hidden",overflowY:"auto"},children:[n.jsx("div",{style:{display:"block",color:"var(--ds-gray-900)",fontSize:"0.75rem",padding:"var(--geist-gap-quarter, 4px) var(--geist-space-2x, 8px)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:240,borderBottom:"1px solid var(--ds-gray-alpha-400)",marginBottom:4},children:e.spanName}),t.map(i=>n.jsxs("button",{type:"button",style:{outline:"none",cursor:i.disabled?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:8,padding:"0 var(--geist-space-2x, 8px)",height:40,textDecoration:"none",borderRadius:6,color:i.destructive?"var(--ds-red-900)":"var(--ds-gray-1000)",width:"100%",background:"transparent",border:"none",fontSize:14,textAlign:"left",opacity:i.disabled?.4:1,transition:"background 0.15s"},disabled:i.disabled,onMouseEnter:l=>{l.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},onClick:()=>{i.action(),r()},children:[i.icon??null,i.label]},i.label))]}),document.body)}function Fd({trace:e,run:t,isLive:r,onWakeUpSleep:o,onCancelRun:s,onResolveHook:a,onLoadMoreSpans:i,hasMoreSpans:l=!1,isLoadingMoreSpans:d=!1,children:c}){const{state:p,dispatch:u}=nt();_d(r);const[f,x]=h.useState(null),[b,j]=h.useState(null),[w,v]=h.useState(!1),[g,I]=h.useState(new Set),N=h.useMemo(()=>{const S=new Map;for(const A of e.spans)S.set(A.spanId,A);return S},[e.spans]),C=h.useCallback(async S=>{if(!(w||!b||!a)){if(!b.token){fe.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0),await a(b.token,S),fe.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),I(A=>new Set(A).add(b.hookId)),j(null)}catch(A){console.error("Failed to resolve hook:",A),fe.error("Failed to resolve hook",{description:A instanceof Error?A.message:"An unknown error occurred"})}finally{v(!1)}}},[a,b,w]),E=h.useCallback(S=>{const R=S.target.closest("[data-span-id]");if(!R)return;const F=R.dataset.spanId;if(!F)return;S.preventDefault(),S.stopPropagation();const B=N.get(F);if(!B)return;const D=B.attributes.resource??"unknown",_=B.attributes.data,P=!(_!=null&&_.completedAt)&&!(_!=null&&_.disposedAt);x({x:S.clientX,y:S.clientY,spanId:F,spanName:B.name,resourceType:D,isActive:P})},[N]),m=h.useRef(null);h.useEffect(()=>{const S=m.current;if(!S)return;const A=R=>{E(R)};return S.addEventListener("contextmenu",A),()=>{S.removeEventListener("contextmenu",A)}},[E]);const y=h.useRef(!1);h.useEffect(()=>{const S=p.timelineRef.current;if(!S||!i||!l)return;const A=200,R=()=>{y.current||d||!l||S.scrollHeight-S.scrollTop-S.clientHeight>A||(y.current=!0,Promise.resolve(i()).finally(()=>{y.current=!1}))};return S.addEventListener("scroll",R),R(),()=>{S.removeEventListener("scroll",R)}},[p.timelineRef,i,l,d]);const k=h.useCallback(()=>{x(null)},[]),T=h.useCallback(S=>{var F,B;const A=[],R=!t.completedAt;if(S.resourceType==="sleep"&&S.isActive&&R&&o&&A.push({label:"Wake Up Sleep",icon:n.jsx(_a,{className:"h-3.5 w-3.5"}),action:()=>{o(t.runId,S.spanId).then(D=>{D.stoppedCount>0?fe.success("Sleep woken up",{description:`Woke up ${String(D.stoppedCount)} sleep${D.stoppedCount>1?"s":""}`}):fe.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(D=>{fe.error("Failed to wake up sleep",{description:D instanceof Error?D.message:"An unknown error occurred"})})}}),S.resourceType==="hook"&&R&&a){const D=N.get(S.spanId),_=(F=D==null?void 0:D.attributes)==null?void 0:F.data,P=!!(_!=null&&_.disposedAt)||!!((B=D==null?void 0:D.events)!=null&&B.some(U=>U.name==="hook_disposed"))||g.has(S.spanId);_!=null&&_.token&&!P&&A.push({label:"Resolve Hook",icon:n.jsx(Go,{className:"h-3.5 w-3.5"}),action:()=>{j({hookId:S.spanId,token:_.token})}})}return S.resourceType==="run"&&R&&s&&A.push({label:"Cancel Run",icon:n.jsx(La,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{s(t.runId).catch(D=>{fe.error("Failed to cancel run",{description:D instanceof Error?D.message:"An unknown error occurred"})})}}),A.push({label:"View Details",icon:n.jsx(Bi,{className:"h-3.5 w-3.5"}),action:()=>{u({type:"select",id:S.spanId})}}),A.push({label:"Copy Name",icon:n.jsx(Gi,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(S.spanName).then(()=>{fe.success("Name copied to clipboard")}).catch(()=>{fe.error("Failed to copy name")})}}),A.push({label:"Copy ID",icon:n.jsx(or,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(S.spanId).then(()=>{fe.success("ID copied to clipboard")}).catch(()=>{fe.error("Failed to copy ID")})}}),A},[u,o,s,a,N,g,t.runId,t.completedAt]);return n.jsxs("div",{className:"relative w-full h-full",ref:m,children:[c,f?n.jsx(Hd,{menu:f,items:T(f),onClose:k}):null,n.jsx(Uo,{isOpen:b!==null,onClose:()=>j(null),onSubmit:C,isSubmitting:w})]})}function Pd({onSelectionChange:e}){const{state:t}=nt(),{selected:r}=t,o=h.useRef(e);return o.current=e,h.useEffect(()=>{var s,a;r?o.current({data:(s=r.span.attributes)==null?void 0:s.data,resource:(a=r.span.attributes)==null?void 0:a.resource,spanId:r.span.spanId}):o.current(null)},[r]),null}function Bd({triggerDeselect:e}){const{dispatch:t}=nt();return h.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function zd({selectRequest:e}){const{dispatch:t}=nt();return h.useEffect(()=>{e!=null&&e.id&&t({type:"select",id:e.id})},[t,e]),null}function Wd({onResize:e}){const t=h.useCallback(r=>{r.preventDefault();let o=r.clientX;const s=i=>{const l=o-i.clientX;o=i.clientX,e(l)},a=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",a)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",a)},[e]);return n.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-400/50 z-10",onPointerDown:t})}function $d({hasMore:e,isLive:t}){const r={color:"var(--ds-gray-900)"};return e?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs",style:r,children:[n.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading more events…"]}):t?n.jsx("div",{className:"flex items-center justify-center py-3 text-xs",style:r,children:"Waiting for more events…"}):n.jsx("div",{className:"flex items-center justify-center py-3 text-xs",style:r,children:"End of run"})}const Vd=({run:e,events:t,isLoading:r,error:o,spanDetailData:s,spanDetailLoading:a,spanDetailError:i,onWakeUpSleep:l,onResolveHook:d,onCancelRun:c,onStreamClick:p,onSpanSelect:u,onLoadEventData:f,onLoadMoreSpans:x,hasMoreSpans:b=!1,isLoadingMoreSpans:j=!1,encryptionKey:w,onDecrypt:v})=>{const[g,I]=h.useState(null),[N,C]=h.useState(Ld),[E,m]=h.useState(0),[y,k]=h.useState(null),T=!!(e&&!e.completedAt),S=h.useMemo(()=>{if(e!=null&&e.runId)return Md(e,t,new Date)},[e,t]),A=S;h.useEffect(()=>{o&&!r&&(console.error(o),fe.error("Error loading workflow trace data",{description:o.message}))},[o,r]);const R=h.useCallback(L=>{u==null||u(L)},[u]),F=h.useCallback(L=>{if(L){const W=L.spanId,$=W?t.filter(ee=>ee.correlationId===W):[];I({...L,rawEvents:$})}else I(null)},[t]);h.useEffect(()=>{const L=g==null?void 0:g.spanId;if(!L)return;const W=t.filter($=>$.correlationId===L);I($=>{if(!$||$.spanId!==L)return $;const ee=$.rawEvents??[];return ee.length===W.length&&ee.every((O,G)=>{var oe;return O.eventId===((oe=W[G])==null?void 0:oe.eventId)})?$:{...$,rawEvents:W}})},[t,g==null?void 0:g.spanId]);const B=h.useCallback(()=>{I(null),m(L=>L+1)},[]),D=h.useCallback(L=>{C(W=>Math.max(Od,W+L))},[]),_=h.useMemo(()=>!(g!=null&&g.spanId)||!A?-1:A.spans.findIndex(L=>L.spanId===g.spanId),[g==null?void 0:g.spanId,A]),P=_>0,U=_>=0&&A!=null&&_<A.spans.length-1,Q=h.useCallback(()=>{var W;if(!A||_<=0)return;const L=(W=A.spans[_-1])==null?void 0:W.spanId;L&&k({id:L,token:Date.now()})},[_,A]),z=h.useCallback(()=>{var W;if(!A||_<0)return;const L=(W=A.spans[_+1])==null?void 0:W.spanId;L&&k({id:L,token:Date.now()})},[_,A]),Y=h.useMemo(()=>{var ee,de;if(!(g!=null&&g.data))return;const L=g.data,W=L.stepName,$=L.workflowName;return(W?(ee=sr(W))==null?void 0:ee.shortName:void 0)??($?(de=xt($))==null?void 0:de.shortName:void 0)??W??$??L.hookId??"Details"},[g==null?void 0:g.data]);return A?n.jsxs("div",{className:"relative w-full h-full flex",children:[n.jsx("div",{className:"flex-1 min-w-0 relative",children:n.jsxs(Ii,{customSpanClassNameFunc:xd,customSpanEventClassNameFunc:vd,children:[n.jsx(Pd,{onSelectionChange:F}),n.jsx(Bd,{triggerDeselect:E}),n.jsx(zd,{selectRequest:y}),n.jsx(Fd,{trace:A,run:e,isLive:T,onWakeUpSleep:l,onCancelRun:c,onResolveHook:d,onLoadMoreSpans:x,hasMoreSpans:b,isLoadingMoreSpans:j,children:n.jsx(hd,{eagerRender:!0,height:"100%",isLive:T,trace:A,knownDurationMs:S==null?void 0:S.knownDurationMs,hasMoreData:b,footer:n.jsx($d,{hasMore:b,isLive:T})})})]})}),g&&n.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:N,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx(Wd,{onResize:D}),n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-y flex-shrink-0",style:{borderColor:"var(--ds-gray-200)"},children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--ds-gray-1000)"},title:Y,children:Y})}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("button",{type:"button","aria-label":"Previous span",onClick:Q,disabled:!P,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:P?"pointer":"not-allowed",opacity:P?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{P&&(L.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:n.jsx(Da,{size:16})}),n.jsx("button",{type:"button","aria-label":"Next span",onClick:z,disabled:!U,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:2,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:U?"pointer":"not-allowed",opacity:U?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{U&&(L.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:n.jsx(Ma,{size:16})})]}),n.jsx("div",{className:"flex items-center",style:{borderLeft:"1px solid var(--ds-gray-300)",marginLeft:6},children:n.jsx("button",{type:"button","aria-label":"Close panel",onClick:B,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:"pointer",flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{L.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:n.jsx(Ko,{size:16})})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(Ht,{title:"Failed to load entity details",children:n.jsx(Jc,{run:e,onStreamClick:p,spanDetailData:s??null,spanDetailError:i,spanDetailLoading:a,onSpanSelect:R,onWakeUpSleep:l,onLoadEventData:f,onResolveHook:d,encryptionKey:w,onDecrypt:v,selectedSpan:g})})})]})]}):n.jsxs("div",{className:"relative w-full h-full",children:[n.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),n.jsx(Re,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),n.jsxs("div",{className:"p-2 relative w-full",children:[n.jsx(Re,{className:"w-full mt-6 h-[20px]"}),n.jsx(Re,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),n.jsx(Re,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),n.jsx(Re,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]})};async function Gd(e,t,r,o={}){const s=o.resolveData??"all";let a,i;if(t==="run")a=await yr(an(e,r,s)),i=a.runId;else if(t==="step"){const{runId:l}=o;if(!l)throw new Tt("runId is required for step resource",{layer:"client"});a=await yr(ji(e,l,r,s)),i=a.stepId}else if(t==="hook")a=await yr(Jo(e,r,s)),i=a.hookId;else throw new Tt(`Unknown resource type: ${t}`,{layer:"client"});return{data:a,correlationId:i}}function Ws(e,t,r,o={}){const{refreshInterval:s=0,runId:a,enabled:i=!0,encryptionKey:l}=o,[d,c]=h.useState(null),[p,u]=h.useState(i),[f,x]=h.useState(null),b=h.useCallback(async w=>l?sn(w,l):it(w),[l]),j=h.useCallback(async()=>{if(!i){u(!1);return}if(c(null),x(null),u(!0),t==="hook"){try{const{error:w,result:v}=await Qe(Jo(e,r,"all"));if(w){x(w);return}try{c(await b(v))}catch(g){x(g instanceof Error?g:new Error(String(g)))}}finally{u(!1)}return}if(t==="sleep"){try{if(!a){x(new Error("runId is required for loading sleep details"));return}const{error:w,result:v}=await Qe(br(e,a,{sortOrder:"asc",limit:1e3,withData:!0}));if(w){x(w);return}try{const g=v.data.map(it),I=await Promise.all(g.filter(C=>C.correlationId===r).map(b)),N=Bs(I);if(N===null){x(new Error(`Failed to load ${t} details: missing required event data`));return}c(N)}catch(g){x(g instanceof Error?g:new Error(String(g)))}}finally{u(!1)}return}try{const{data:w}=await Gd(e,t,r,{runId:a});c(await b(w))}catch(w){w instanceof Error?x(w):x(new Error(String(w)));return}finally{u(!1)}},[e,t,r,a,i,b]);return h.useEffect(()=>{j()},[j]),h.useEffect(()=>{if(!s||s<=0)return;const w=setInterval(j,s);return()=>clearInterval(w)},[s,j]),{data:d,loading:p,error:f,refresh:j}}function xn(e,t,r){const o=[...e,...t],s=new Map(o.map(a=>[a[r],a]));return Array.from(s.values())}async function Ud(e){const{fetchFn:t,setItems:r,setCursor:o,setError:s,idKey:a,cursorStrategy:i="always",transform:l}=e,{error:d,result:c}=await t();if(d)return s(d),!1;if(c.data.length>0){const p=l?c.data.map(l):c.data;return r(f=>xn(f,p,a)),(i==="onHasMore"?!!(c.cursor&&c.hasMore):!!c.cursor)&&o(c.cursor),!0}return!1}const Kd=100,qd=500,Zd=100,Yd=5e3;function Xd(e,t,r={}){const{live:o=!1}=r,[s,a]=h.useState(null),[i,l]=h.useState([]),[d,c]=h.useState(!0),[p,u]=h.useState(null),[f,x]=h.useState(),[b,j]=h.useState(!1),[w,v]=h.useState(!1),g=h.useRef(!1),[I,N]=h.useState(!1),C=h.useCallback(async()=>{if(g.current)return;g.current=!0,c(!0),u(null);const[T,S]=await Promise.all([Qe(an(e,t,"none")),Qe(br(e,t,{sortOrder:"asc",limit:qd,withData:!0}))]);T.error?u(T.error):a(it(T.result));const A=S.error?[]:S.result.data.map(it);l(xn([],A,"eventId")),x(S.error||!S.result.hasMore?void 0:S.result.cursor),j(!!(!S.error&&S.result.hasMore)),c(!1),N(!0),g.current=!1,!T.error&&S.error&&u(S.error)},[e,t]),E=h.useCallback(async()=>{if(!(g.current||!I||w||!b)){v(!0);try{const T=await Qe(br(e,t,{cursor:f,sortOrder:"asc",limit:Zd,withData:!0}));if(T.error)u(T.error);else{const S=T.result.data.map(it);S.length>0&&l(A=>xn(A,S,"eventId")),j(!!T.result.hasMore),x(T.result.hasMore?T.result.cursor:void 0)}}finally{v(!1)}}},[e,t,I,w,b,f]),m=h.useCallback(async()=>{if(s!=null&&s.completedAt)return!1;const{error:T,result:S}=await Qe(an(e,t,"none"));return T?(u(T),!1):(u(null),a(it(S)),!0)},[e,t,s==null?void 0:s.completedAt]),y=h.useCallback(()=>Ud({fetchFn:()=>Qe(br(e,t,{cursor:f,sortOrder:"asc",limit:Kd,withData:!0})),setItems:l,setCursor:x,setError:u,idKey:"eventId",transform:it}),[e,t,f]),k=h.useCallback(async()=>{if(g.current||!I)return{foundNewItems:!1};let T=!1;try{const[S,A]=await Promise.all([m(),y()]);T=A}catch(S){console.error("Update error:",S)}return{foundNewItems:T}},[y,I,m]);return h.useEffect(()=>{C()},[C]),h.useEffect(()=>{if(!o||!I||s!=null&&s.completedAt)return;const T=setInterval(()=>{k()},Yd);return()=>{clearInterval(T)}},[o,I,k,s==null?void 0:s.completedAt]),{run:s??{},events:i,loading:d,error:p,update:k,loadMoreTraceData:E,hasMoreTraceData:b,isLoadingMoreTraceData:w}}function Jd(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function Qd(e,t,r,o){try{const s=`/api/stream/${encodeURIComponent(t)}${r!=null?`?startIndex=${r}`:""}`,a=await fetch(s,{signal:o});if(!a.ok){const i=await a.json().catch(()=>null);throw i&&Jd(i)?new Tt(i.message,{layer:"client",cause:i.cause,request:i.request}):new Tt(`Failed to read stream: ${a.status}`,{layer:"client"})}if(!a.body)throw new Tt("Failed to read stream: no body",{layer:"client"});return a.body}catch(s){throw s instanceof Tt?s:new Tt("Failed to read stream",{layer:"client",cause:s})}}async function eu(e,t){return yr(ki(e,t))}const tu=1e4;function ru(e,t,r=tu){const[o,s]=h.useState([]),[a,i]=h.useState(!0),[l,d]=h.useState(null),c=h.useCallback(async()=>{i(!0),d(null);try{const p=await eu(e,t);s(p)}catch(p){d(p instanceof Error?p:new Error(String(p)))}finally{i(!1)}},[e,t]);return h.useEffect(()=>{c()},[c]),h.useEffect(()=>{if(!r||r<=0)return;const p=setInterval(c,r);return()=>clearInterval(p)},[r,c]),{streams:o,loading:a,error:l,refresh:c}}var nu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],dt=nu.reduce((e,t)=>{const r=h.forwardRef((o,s)=>{const{asChild:a,...i}=o,l=a?wn:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(l,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ou(e,t){e&&Wo.flushSync(()=>e.dispatchEvent(t))}var su="DismissableLayer",vn="dismissableLayer.update",au="dismissableLayer.pointerDownOutside",iu="dismissableLayer.focusOutside",No,$s=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Vs=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,c=h.useContext($s),[p,u]=h.useState(null),f=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=h.useState({}),b=yt(t,m=>u(m)),j=Array.from(c.layers),[w]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=j.indexOf(w),g=p?j.indexOf(p):-1,I=c.layersWithOutsidePointerEventsDisabled.size>0,N=g>=v,C=du(m=>{const y=m.target,k=[...c.branches].some(T=>T.contains(y));!N||k||(s==null||s(m),i==null||i(m),m.defaultPrevented||l==null||l())},f),E=uu(m=>{const y=m.target;[...c.branches].some(T=>T.contains(y))||(a==null||a(m),i==null||i(m),m.defaultPrevented||l==null||l())},f);return Oa(m=>{g===c.layers.size-1&&(o==null||o(m),!m.defaultPrevented&&l&&(m.preventDefault(),l()))},f),h.useEffect(()=>{if(p)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(No=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(p)),c.layers.add(p),Io(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=No)}},[p,f,r,c]),h.useEffect(()=>()=>{p&&(c.layers.delete(p),c.layersWithOutsidePointerEventsDisabled.delete(p),Io())},[p,c]),h.useEffect(()=>{const m=()=>x({});return document.addEventListener(vn,m),()=>document.removeEventListener(vn,m)},[]),n.jsx(dt.div,{...d,ref:b,style:{pointerEvents:I?N?"auto":"none":void 0,...e.style},onFocusCapture:ct(e.onFocusCapture,E.onFocusCapture),onBlurCapture:ct(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:ct(e.onPointerDownCapture,C.onPointerDownCapture)})});Vs.displayName=su;var lu="DismissableLayerBranch",cu=h.forwardRef((e,t)=>{const r=h.useContext($s),o=h.useRef(null),s=yt(t,o);return h.useEffect(()=>{const a=o.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(dt.div,{...e,ref:s})});cu.displayName=lu;function du(e,t=globalThis==null?void 0:globalThis.document){const r=jr(e),o=h.useRef(!1),s=h.useRef(()=>{});return h.useEffect(()=>{const a=l=>{if(l.target&&!o.current){let d=function(){Gs(au,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=d,t.addEventListener("click",s.current,{once:!0})):d()}else t.removeEventListener("click",s.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function uu(e,t=globalThis==null?void 0:globalThis.document){const r=jr(e),o=h.useRef(!1);return h.useEffect(()=>{const s=a=>{a.target&&!o.current&&Gs(iu,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Io(){const e=new CustomEvent(vn);document.dispatchEvent(e)}function Gs(e,t,r,{discrete:o}){const s=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),o?ou(s,a):s.dispatchEvent(a)}var Jr="focusScope.autoFocusOnMount",Qr="focusScope.autoFocusOnUnmount",jo={bubbles:!1,cancelable:!0},fu="FocusScope",Us=h.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=h.useState(null),c=jr(s),p=jr(a),u=h.useRef(null),f=yt(t,j=>d(j)),x=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(o){let j=function(I){if(x.paused||!l)return;const N=I.target;l.contains(N)?u.current=N:ht(u.current,{select:!0})},w=function(I){if(x.paused||!l)return;const N=I.relatedTarget;N!==null&&(l.contains(N)||ht(u.current,{select:!0}))},v=function(I){if(document.activeElement===document.body)for(const C of I)C.removedNodes.length>0&&ht(l)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const g=new MutationObserver(v);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),g.disconnect()}}},[o,l,x.paused]),h.useEffect(()=>{if(l){Co.add(x);const j=document.activeElement;if(!l.contains(j)){const v=new CustomEvent(Jr,jo);l.addEventListener(Jr,c),l.dispatchEvent(v),v.defaultPrevented||(mu(vu(Ks(l)),{select:!0}),document.activeElement===j&&ht(l))}return()=>{l.removeEventListener(Jr,c),setTimeout(()=>{const v=new CustomEvent(Qr,jo);l.addEventListener(Qr,p),l.dispatchEvent(v),v.defaultPrevented||ht(j??document.body,{select:!0}),l.removeEventListener(Qr,p),Co.remove(x)},0)}}},[l,c,p,x]);const b=h.useCallback(j=>{if(!r&&!o||x.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,v=document.activeElement;if(w&&v){const g=j.currentTarget,[I,N]=pu(g);I&&N?!j.shiftKey&&v===N?(j.preventDefault(),r&&ht(I,{select:!0})):j.shiftKey&&v===I&&(j.preventDefault(),r&&ht(N,{select:!0})):v===g&&j.preventDefault()}},[r,o,x.paused]);return n.jsx(dt.div,{tabIndex:-1,...i,ref:f,onKeyDown:b})});Us.displayName=fu;function mu(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(ht(o,{select:t}),document.activeElement!==r)return}function pu(e){const t=Ks(e),r=ko(t,e),o=ko(t.reverse(),e);return[r,o]}function Ks(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const s=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||s?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function ko(e,t){for(const r of e)if(!hu(r,{upTo:t}))return r}function hu(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function gu(e){return e instanceof HTMLInputElement&&"select"in e}function ht(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&gu(e)&&t&&e.select()}}var Co=xu();function xu(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=So(e,t),e.unshift(t)},remove(t){var r;e=So(e,t),(r=e[0])==null||r.resume()}}}function So(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function vu(e){return e.filter(t=>t.tagName!=="A")}var yu="Portal",qs=h.forwardRef((e,t)=>{var l;const{container:r,...o}=e,[s,a]=h.useState(!1);Ha(()=>a(!0),[]);const i=r||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?zo.createPortal(n.jsx(dt.div,{...o,ref:t}),i):null});qs.displayName=yu;var On="Dialog",[Zs,Ys]=qo(On),[bu,Ze]=Zs(On),Xs=e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=h.useRef(null),d=h.useRef(null),[c=!1,p]=Pa({prop:o,defaultProp:s,onChange:a});return n.jsx(bu,{scope:t,triggerRef:l,contentRef:d,contentId:Br(),titleId:Br(),descriptionId:Br(),open:c,onOpenChange:p,onOpenToggle:h.useCallback(()=>p(u=>!u),[p]),modal:i,children:r})};Xs.displayName=On;var Js="DialogTrigger",Qs=h.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Ze(Js,r),a=yt(t,s.triggerRef);return n.jsx(dt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Pn(s.open),...o,ref:a,onClick:ct(e.onClick,s.onOpenToggle)})});Qs.displayName=Js;var Hn="DialogPortal",[wu,ea]=Zs(Hn,{forceMount:void 0}),ta=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:s}=e,a=Ze(Hn,t);return n.jsx(wu,{scope:t,forceMount:r,children:h.Children.map(o,i=>n.jsx(bn,{present:r||a.open,children:n.jsx(qs,{asChild:!0,container:s,children:i})}))})};ta.displayName=Hn;var Rr="DialogOverlay",ra=h.forwardRef((e,t)=>{const r=ea(Rr,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=Ze(Rr,e.__scopeDialog);return a.modal?n.jsx(bn,{present:o||a.open,children:n.jsx(Nu,{...s,ref:t})}):null});ra.displayName=Rr;var Nu=h.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Ze(Rr,r);return n.jsx(za,{as:wn,allowPinchZoom:!0,shards:[s.contentRef],children:n.jsx(dt.div,{"data-state":Pn(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),Mt="DialogContent",na=h.forwardRef((e,t)=>{const r=ea(Mt,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=Ze(Mt,e.__scopeDialog);return n.jsx(bn,{present:o||a.open,children:a.modal?n.jsx(Iu,{...s,ref:t}):n.jsx(ju,{...s,ref:t})})});na.displayName=Mt;var Iu=h.forwardRef((e,t)=>{const r=Ze(Mt,e.__scopeDialog),o=h.useRef(null),s=yt(t,r.contentRef,o);return h.useEffect(()=>{const a=o.current;if(a)return Ba(a)},[]),n.jsx(oa,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ct(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ct(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:ct(e.onFocusOutside,a=>a.preventDefault())})}),ju=h.forwardRef((e,t)=>{const r=Ze(Mt,e.__scopeDialog),o=h.useRef(!1),s=h.useRef(!1);return n.jsx(oa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(o.current||(l=r.triggerRef.current)==null||l.focus(),a.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:a=>{var d,c;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((c=r.triggerRef.current)==null?void 0:c.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),oa=h.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=Ze(Mt,r),d=h.useRef(null),c=yt(t,d);return Wa(),n.jsxs(n.Fragment,{children:[n.jsx(Us,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:a,children:n.jsx(Vs,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Pn(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(Cu,{titleId:l.titleId}),n.jsx(Tu,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Fn="DialogTitle",sa=h.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Ze(Fn,r);return n.jsx(dt.h2,{id:s.titleId,...o,ref:t})});sa.displayName=Fn;var aa="DialogDescription",ia=h.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Ze(aa,r);return n.jsx(dt.p,{id:s.descriptionId,...o,ref:t})});ia.displayName=aa;var la="DialogClose",ca=h.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Ze(la,r);return n.jsx(dt.button,{type:"button",...o,ref:t,onClick:ct(e.onClick,()=>s.onOpenChange(!1))})});ca.displayName=la;function Pn(e){return e?"open":"closed"}var da="DialogTitleWarning",[ku,ua]=Fa(da,{contentName:Mt,titleName:Fn,docsSlug:"dialog"}),Cu=({titleId:e})=>{const t=ua(da),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
29
|
-
|
|
30
|
-
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
31
|
-
|
|
32
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Su="DialogDescriptionWarning",Tu=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ua(Su).contentName}}.`;return h.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},Eu=Xs,Au=Qs,Ru=ta,Du=ra,Mu=na,_u=sa,Lu=ia,fa=ca,ma="AlertDialog",[Ou]=qo(ma,[Ys]),ut=Ys(),pa=e=>{const{__scopeAlertDialog:t,...r}=e,o=ut(t);return n.jsx(Eu,{...o,...r,modal:!0})};pa.displayName=ma;var Hu="AlertDialogTrigger",Fu=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ut(r);return n.jsx(Au,{...s,...o,ref:t})});Fu.displayName=Hu;var Pu="AlertDialogPortal",ha=e=>{const{__scopeAlertDialog:t,...r}=e,o=ut(t);return n.jsx(Ru,{...o,...r})};ha.displayName=Pu;var Bu="AlertDialogOverlay",ga=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ut(r);return n.jsx(Du,{...s,...o,ref:t})});ga.displayName=Bu;var zt="AlertDialogContent",[zu,Wu]=Ou(zt),xa=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:o,...s}=e,a=ut(r),i=h.useRef(null),l=yt(t,i),d=h.useRef(null);return n.jsx(ku,{contentName:zt,titleName:va,docsSlug:"alert-dialog",children:n.jsx(zu,{scope:r,cancelRef:d,children:n.jsxs(Mu,{role:"alertdialog",...a,...s,ref:l,onOpenAutoFocus:ct(s.onOpenAutoFocus,c=>{var p;c.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[n.jsx(Ci,{children:o}),n.jsx(Vu,{contentRef:i})]})})})});xa.displayName=zt;var va="AlertDialogTitle",ya=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ut(r);return n.jsx(_u,{...s,...o,ref:t})});ya.displayName=va;var ba="AlertDialogDescription",wa=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ut(r);return n.jsx(Lu,{...s,...o,ref:t})});wa.displayName=ba;var $u="AlertDialogAction",Na=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ut(r);return n.jsx(fa,{...s,...o,ref:t})});Na.displayName=$u;var Ia="AlertDialogCancel",ja=h.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,{cancelRef:s}=Wu(Ia,r),a=ut(r),i=yt(t,s);return n.jsx(fa,{...a,...o,ref:i})});ja.displayName=Ia;var Vu=({contentRef:e})=>{const t=`\`${zt}\` requires a description for the component to be accessible for screen reader users.
|
|
33
|
-
|
|
34
|
-
You can add a description to the \`${zt}\` by passing a \`${ba}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
35
|
-
|
|
36
|
-
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${zt}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
37
|
-
|
|
38
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return h.useEffect(()=>{var o;document.getElementById((o=e.current)==null?void 0:o.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Gu=pa,Uu=ha,Ku=ga,qu=xa,Zu=Na,Yu=ja,Xu=ya,Ju=wa;function To({...e}){return n.jsx(Gu,{"data-slot":"alert-dialog",...e})}function Qu({...e}){return n.jsx(Uu,{"data-slot":"alert-dialog-portal",...e})}function ef({className:e,...t}){return n.jsx(Ku,{"data-slot":"alert-dialog-overlay",className:We("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Eo({className:e,onSubmit:t,...r}){return n.jsxs(Qu,{children:[n.jsx(ef,{}),n.jsx(qu,{"data-slot":"alert-dialog-content",className:We("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),onSubmit:o=>{o.preventDefault(),t==null||t(o)},...r})]})}function Ao({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-header",className:We("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Ro({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-footer",className:We("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Do({className:e,...t}){return n.jsx(Xu,{"data-slot":"alert-dialog-title",className:We("text-lg font-semibold",e),...t})}function Mo({className:e,...t}){return n.jsx(Ju,{"data-slot":"alert-dialog-description",className:We("text-muted-foreground text-sm",e),...t})}function _o({className:e,...t}){return n.jsx(Zu,{className:We(Qo(),e),...t})}function Lo({className:e,...t}){return n.jsx(Yu,{className:We(Qo({variant:"outline"}),e),...t})}function tf({...e}){return n.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function rf({className:e,...t}){return n.jsx("ol",{"data-slot":"breadcrumb-list",className:We("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...t})}function Oo({className:e,...t}){return n.jsx("li",{"data-slot":"breadcrumb-item",className:We("inline-flex items-center gap-1.5",e),...t})}function nf({asChild:e,className:t,...r}){const o=e?wn:"a";return n.jsx(o,{"data-slot":"breadcrumb-link",className:We("hover:text-foreground transition-colors",t),...r})}function of({className:e,...t}){return n.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:We("text-foreground font-normal",e),...t})}function sf({children:e,className:t,...r}){return n.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:We("[&>svg]:size-3.5",t),...r,children:e??n.jsx(yn,{})})}const Ot={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function Dr(e){return e.replace(/\/\/\.\.\//g,"//")}function af(e,t,r,o){let s;switch(e.status){case"completed":s="completed";break;case"failed":s=r<o-1?"retrying":"failed";break;case"running":s="running";break;case"cancelled":s="cancelled";break;case"pending":default:s="pending";break}const a=e.completedAt&&e.startedAt?new Date(e.completedAt).getTime()-new Date(e.startedAt).getTime():void 0;return{nodeId:t,stepId:e.stepId,attemptNumber:e.attempt,status:s,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0,duration:a,input:e.input,output:e.output,error:e.error?{message:e.error.message,stack:e.error.stack||""}:void 0}}function Mr(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function lf(e){const t=new Map,r=new Map,o=new Map,s=[],a=new Map;for(const i of e){if(i.data.stepId){const l=Dr(i.data.stepId),d=t.get(l)||[];d.push(i),t.set(l,d);const c=Mr(l);if(c){const p=r.get(c)||[];p.push(i),r.set(c,p)}}if(i.data.nodeKind==="primitive"){const l=i.data.label,d=o.get(l)||[];d.push(i),o.set(l,d)}if(i.data.nodeKind==="agent"&&s.push(i),i.data.nodeKind==="tool"){const d=i.data.label.replace(/ \(tool\)$/,""),c=a.get(d)||[];if(c.push(i),a.set(d,c),i.data.stepId){const p=Mr(Dr(i.data.stepId));if(p){const u=a.get(p)||[];u.includes(i)||(u.push(i),a.set(p,u))}}}}return{byStepId:t,byFunctionName:r,primitivesByLabel:o,agentNodes:s,toolNodes:a}}function cf(e,t,r){var d,c,p,u;const o=new Map,s=new Set(e),a=new Map;for(const f of t.nodes){const x=(d=f.metadata)==null?void 0:d.parallelGroupId;if(x){const b=a.get(x)||{nodes:[]};b.nodes.push(f),b.method=(c=f.metadata)==null?void 0:c.parallelMethod,a.set(x,b)}}const i=new Map;for(const[f,x]of a)if(x.method==="race"){let b,j;for(const w of x.nodes){const v=r.get(w.id);if(v){for(const g of v)if(g.status==="completed"&&g.completedAt){const I=new Date(g.completedAt);(!j||I<j)&&(j=I,b=w.id)}}}b&&i.set(f,b)}const l=f=>{const x=o.get(f.id);x?x.traversalCount++:o.set(f.id,{edgeId:f.id,traversalCount:1,timings:[]})};for(const f of t.edges){const x=t.nodes.find(I=>I.id===f.source),b=t.nodes.find(I=>I.id===f.target);if(!x||!b)continue;const j=s.has(f.source),w=s.has(f.target);if(!j&&!w)continue;if(f.type==="conditional"){j&&w&&l(f);continue}const v=(p=x.metadata)==null?void 0:p.parallelGroupId,g=(u=x.metadata)==null?void 0:u.parallelMethod;v&&g==="race"?i.get(v)===f.source&&w&&l(f):(j&&w||j&&f.type==="parallel"&&w)&&l(f)}return o}function df(e,t,r,o){const s=t.nodes.find(a=>a.data.nodeKind==="workflow_start");s&&(r.push(s.id),o.set(s.id,[{nodeId:s.id,attemptNumber:1,status:"completed",startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0}]))}function uf(e,t,r,o){const s=t.nodes.find(i=>i.data.nodeKind==="workflow_end");if(!s||r.includes(s.id))return;let a;switch(e.status){case"completed":a="completed";break;case"failed":a="failed";break;case"cancelled":a="cancelled";break;case"running":a="running";break;case"pending":default:return}r.push(s.id),o.set(s.id,[{nodeId:s.id,attemptNumber:1,status:a,startedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0,completedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0}])}function ff(e,t,r,o,s,a,i){const l=Dr(t),d=s.get(l)||0;s.set(l,d+1);let c=r.get(l)||[],p="step-id";if(c.length===0){const b=Mr(l);b&&(c=o.get(b)||[],p="function-name")}const u=c.length===1?c[0]:c[d];if(console.log("[Graph Mapper] Processing step group:",{stepName:t,normalizedStepName:l,attempts:e.length,occurrenceIndex:d,totalNodesWithStepId:c.length,selectedNode:u==null?void 0:u.id,allNodesWithStepId:c.map(b=>b.id),matchStrategy:p,strategy:c.length===1?"single-node-multiple-invocations":"occurrence-based"}),!u)return;const f=e.map((b,j)=>af(b,u.id,j,e.length));if(c.length===1){const b=a.get(u.id)||[];a.set(u.id,[...b,...f])}else a.set(u.id,f);return i.includes(u.id)||i.push(u.id),f[f.length-1].status==="running"?u.id:void 0}function mf(e,t,r,o){const s=new Map,a=new Map;for(const v of e){if(!v.correlationId)continue;const g=a.get(v.correlationId)||[];g.push(v),a.set(v.correlationId,g)}let i;const l=t.get(Ot.sleep)||[],d=new Set;for(const v of e)v.eventType==="wait_created"&&v.correlationId&&d.add(v.correlationId);const c=Array.from(d).sort((v,g)=>{var m,y;const I=a.get(v)||[],N=a.get(g)||[],C=(m=I.find(k=>k.eventType==="wait_created"))==null?void 0:m.createdAt,E=(y=N.find(k=>k.eventType==="wait_created"))==null?void 0:y.createdAt;return!C||!E?0:new Date(C).getTime()-new Date(E).getTime()});for(const v of c){const g=a.get(v)||[],I=g.find(R=>R.eventType==="wait_created"),N=g.find(R=>R.eventType==="wait_completed");if(!I)continue;const C=s.get(Ot.sleep)||0;s.set(Ot.sleep,C+1);const E=l.length===1?l[0]:l[C];if(!E)continue;let m="running";N&&(m="completed");const y=new Date(I.createdAt).toISOString(),k=N?new Date(N.createdAt).toISOString():void 0,T=N?new Date(N.createdAt).getTime()-new Date(I.createdAt).getTime():void 0,S={nodeId:E.id,attemptNumber:1,status:m,startedAt:y,completedAt:k,duration:T},A=r.get(E.id)||[];r.set(E.id,[...A,S]),o.includes(E.id)||o.push(E.id),m==="running"&&(i=E.id)}const p=[...t.get(Ot.createHook)||[],...t.get(Ot.createWebhook)||[]],u=new Set;for(const v of e)v.eventType==="hook_created"&&v.correlationId&&u.add(v.correlationId);const f=Array.from(u).sort((v,g)=>{var m,y;const I=a.get(v)||[],N=a.get(g)||[],C=(m=I.find(k=>k.eventType==="hook_created"))==null?void 0:m.createdAt,E=(y=N.find(k=>k.eventType==="hook_created"))==null?void 0:y.createdAt;return!C||!E?0:new Date(C).getTime()-new Date(E).getTime()});let x=0;for(const v of f){const I=(a.get(v)||[]).find(T=>T.eventType==="hook_created");if(!I)continue;const N=p.length===1?p[0]:p[x];if(x++,!N)continue;const C="completed",E=new Date(I.createdAt).toISOString(),m=new Date(I.createdAt).toISOString(),y={nodeId:N.id,attemptNumber:1,status:C,startedAt:E,completedAt:m,duration:0},k=r.get(N.id)||[];r.set(N.id,[...k,y]),o.includes(N.id)||o.push(N.id)}const b=t.get(Ot.awaitWebhook)||[],j=new Set;for(const v of e)v.eventType==="hook_received"&&v.correlationId&&j.add(v.correlationId);let w=0;for(const v of f){const g=b.length===1?b[0]:b[w];if(w++,!g)continue;const I=a.get(v)||[],N=I.find(A=>A.eventType==="hook_created"),C=I.find(A=>A.eventType==="hook_received");let E,m,y,k=0;C?(E="completed",m=N?new Date(N.createdAt).toISOString():new Date(C.createdAt).toISOString(),y=new Date(C.createdAt).toISOString(),k=new Date(y).getTime()-new Date(m).getTime()):N?(E="running",m=new Date(N.createdAt).toISOString()):E="pending";const T={nodeId:g.id,attemptNumber:1,status:E,startedAt:m,completedAt:y,duration:k},S=r.get(g.id)||[];r.set(g.id,[...S,T]),o.includes(g.id)||o.push(g.id)}return i}function pf(e,t,r,o,s,a,i){var d;let l="pending";e.status==="completed"?l="completed":e.status==="failed"?l="failed":e.status==="running"&&(l="running");for(const c of r){const p={nodeId:c.id,attemptNumber:1,status:l,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(l==="completed"||l==="failed")?new Date(e.completedAt).toISOString():void 0};s.set(c.id,[p]),a.includes(c.id)||a.push(c.id)}for(const c of t){const p=Mr(c.stepName);if(!p)continue;const u=o.get(p);if(!u||u.length===0)continue;const f=u[0];let x;switch(c.status){case"completed":x="completed";break;case"failed":x="failed";break;case"running":x="running";break;case"cancelled":x="cancelled";break;case"pending":default:x="pending";break}const b=c.completedAt&&c.startedAt?new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime():void 0,j={nodeId:f.id,stepId:c.stepId,attemptNumber:c.attempt,status:x,startedAt:c.startedAt?new Date(c.startedAt).toISOString():void 0,completedAt:c.completedAt?new Date(c.completedAt).toISOString():void 0,duration:b,input:c.input,output:c.output,error:c.error},w=s.get(f.id)||[];s.set(f.id,[...w,j]),a.includes(f.id)||a.push(f.id)}for(const c of i){const p=((d=c.metadata)==null?void 0:d.isToolsCollection)===!0;if(c.data.nodeKind==="tool"&&p&&!s.has(c.id)){const u={nodeId:c.id,attemptNumber:1,status:l,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(l==="completed"||l==="failed")?new Date(e.completedAt).toISOString():void 0};s.set(c.id,[u]),a.includes(c.id)||a.push(c.id)}}}function hf(e,t,r,o){var i,l,d;const s=e.nodes.filter(c=>c.data.nodeKind==="conditional"),a=new Map;for(const c of e.nodes){const p=(i=c.metadata)==null?void 0:i.conditionalId;if(p){const u=a.get(p)||{thenNodes:[],elseNodes:[]};((l=c.metadata)==null?void 0:l.conditionalBranch)==="Then"?u.thenNodes.push(c):((d=c.metadata)==null?void 0:d.conditionalBranch)==="Else"&&u.elseNodes.push(c),a.set(p,u)}}for(const c of s){const p=c.id.match(/^(cond_\d+)_node$/);if(!p)continue;const u=p[1],f=a.get(u);if(!f)continue;const x=f.thenNodes.some(j=>t.has(j.id)),b=f.elseNodes.some(j=>t.has(j.id));if(x||b){const j=[...f.thenNodes,...f.elseNodes];if(!t.has(c.id)){let w;for(const I of j){const N=t.get(I.id);if(N&&N.length>0){const C=N[0];C.startedAt&&(!w||C.startedAt<w)&&(w=C.startedAt)}}const v=o.startedAt?new Date(o.startedAt).toISOString():void 0,g={nodeId:c.id,attemptNumber:1,status:"completed",startedAt:w||v,completedAt:w||v};t.set(c.id,[g])}if(!r.includes(c.id)){const w=j.map(v=>r.indexOf(v.id)).filter(v=>v>=0);if(w.length>0){const v=Math.min(...w);v>=0&&v<r.length?r.splice(v,0,c.id):r.push(c.id)}else r.push(c.id)}}}}function gf(e,t,r,o){const s=new Map,a=[];let i;console.log("[Graph Mapper] Mapping run to execution:",{runId:e.runId,workflowName:e.workflowName,graphNodes:o.nodes.length,stepsCount:t.length}),df(e,o,a,s);const l=[...t].sort((N,C)=>new Date(N.createdAt).getTime()-new Date(C.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",l.map(N=>({stepId:N.stepId,stepName:N.stepName,attempt:N.attempt,status:N.status,createdAt:N.createdAt})));const{byStepId:d,byFunctionName:c,primitivesByLabel:p,agentNodes:u,toolNodes:f}=lf(o.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:o.nodes.map(N=>({id:N.id,stepId:N.data.stepId,normalizedStepId:N.data.stepId?Dr(N.data.stepId):void 0,nodeKind:N.data.nodeKind})),nodesByStepId:Array.from(d.entries()).map(([N,C])=>({stepId:N,nodeIds:C.map(E=>E.id)}))});const x=new Map;let b=[],j=null,w=null;for(let N=0;N<=l.length;N++){const C=l[N];if(!C||C.stepId!==j){if(b.length>0&&w){const m=ff(b,w,d,c,x,s,a);m&&(i=m)}C&&(b=[C],j=C.stepId,w=C.stepName)}else b.push(C)}const v=mf(r,p,s,a);v&&(i=v),pf(e,l,u,f,s,a,o.nodes),hf(o,s,a,e),uf(e,o,a,s);const g=cf(a,o,s),I={runId:e.runId,status:e.status,nodeExecutions:s,edgeTraversals:g,currentNode:i,executionPath:a};return console.log("[Graph Mapper] Mapping complete:",{executionPath:a,nodeExecutionsCount:s.size,nodeExecutions:Array.from(s.entries()).map(([N,C])=>{var E;return{nodeId:N,executionCount:C.length,latestStatus:(E=C[C.length-1])==null?void 0:E.status}})}),I}const Gt=4;function xf(e,t,r,o){const[s,a]=h.useState([]),[i,l]=h.useState(!1),[d,c]=h.useState(null),p=h.useRef(null),u=h.useRef(0);return h.useEffect(()=>{if(a([]),c(null),u.current=0,!t){l(!1);return}let f=!0;const x=new AbortController;p.current=x,l(!0);const b=Ai();return(async()=>{try{const w=await Qd(e,t,void 0,x.signal),v=o?await Li(o):void 0,g=w.getReader();let I=new Uint8Array(0);const N=C=>{const E=new Uint8Array(I.length+C.length);E.set(I,0),E.set(C,I.length),I=E};for(;!x.signal.aborted;){const{value:C,done:E}=await g.read();if(E){f&&l(!1);break}for(N(C);I.length>=Gt;){const y=new DataView(I.buffer,I.byteOffset,I.byteLength).getUint32(0,!1);if(I.length<Gt+y)break;const k=I.slice(Gt,Gt+y);I=I.slice(Gt+y);try{const{format:T,payload:S}=Si(k);let A;if(T===Ti.ENCRYPTED){if(!v){f&&(c("This stream is encrypted. Click Decrypt to view."),l(!1)),g.cancel().catch(()=>{});return}A=await Oi(v,S)}else A=k;const R=Ei(A,b);if(f&&R!==void 0&&R!==null){const F=u.current++,B=typeof R=="string"?R:JSON.stringify(R,null,2);a(D=>[...D,{id:F,text:B}])}}catch(T){console.error("Failed to process stream frame:",T)}}}}catch(w){if(x.signal.aborted)return;f&&(c(w instanceof Error?w.message:String(w)),l(!1))}})(),()=>{f=!1,p.current&&p.current.abort()}},[e,t,r,o]),{chunks:s,isLive:i,error:d}}function vf({hasError:e,errorMessage:t}){return n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(es,{children:[n.jsx(ts,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${e?"bg-red-500":"bg-green-500 animate-pulse"}`}),n.jsx("span",{className:`text-xs $
|
|
39
|
-
hasError
|
|
40
|
-
? 'text-red-600 dark:text-red-400'
|
|
41
|
-
: 'text-muted-foreground'`,children:e?"Error":"Live"})]})}),n.jsx(rs,{children:n.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${Ri/1e3} seconds`})})]})})}function Ho(e){return e==="retrying"?"running":e}function yf({data:e,selected:t}){var o,s,a,i;const r=e;return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((o=r.nodeStyle)==null?void 0:o.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(s=r.nodeStyle)==null?void 0:s.backgroundColor,borderColor:((a=r.nodeStyle)==null?void 0:a.borderColor)??"#9ca3af",opacity:(i=r.nodeStyle)==null?void 0:i.opacity,boxShadow:t?"0 0 0 2px rgba(168, 85, 247, 0.5)":void 0},children:[r.label,n.jsx(et,{type:"target",position:tt.Top,className:"!bg-purple-500"}),n.jsx(et,{type:"source",position:tt.Bottom,className:"!bg-purple-500"}),n.jsx(et,{type:"source",position:tt.Left,id:"loop-out",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"30%"}}),n.jsx(et,{type:"target",position:tt.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})}function bf({data:e,selected:t}){var a,i,l,d;const r=e,o=r.nodeKind==="workflow_start",s=r.nodeKind==="workflow_end";return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((a=r.nodeStyle)==null?void 0:a.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(i=r.nodeStyle)==null?void 0:i.backgroundColor,borderColor:((l=r.nodeStyle)==null?void 0:l.borderColor)??"#9ca3af",opacity:(d=r.nodeStyle)==null?void 0:d.opacity,boxShadow:t?"0 0 0 2px rgba(59, 130, 246, 0.35)":void 0},children:[r.label,!o&&n.jsx(et,{type:"target",position:tt.Top,className:"!bg-muted"}),!s&&n.jsx(et,{type:"source",position:tt.Bottom,className:"!bg-muted"})]})}function wf({data:e,selected:t}){var s,a,i;const r=e,o=160;return n.jsxs("div",{className:`relative flex items-center justify-center ${r.className||""}`,style:{width:o,height:o},children:[n.jsx("div",{style:{width:o*.7,height:o*.7,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:(s=r.nodeStyle)==null?void 0:s.backgroundColor,borderColor:((a=r.nodeStyle)==null?void 0:a.borderColor)??"#ef4444",opacity:(i=r.nodeStyle)==null?void 0:i.opacity,boxShadow:t?"0 0 0 2px rgba(239, 68, 68, 0.5)":void 0}}),n.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{fontSize:11,fontWeight:600,padding:o*.25},title:typeof r.label=="string"?r.label:void 0,children:n.jsx("span",{className:"text-center line-clamp-3 overflow-hidden",children:r.label})}),n.jsx(et,{type:"target",position:tt.Top,className:"!bg-red-500"}),n.jsx(et,{type:"source",position:tt.Bottom,id:"bottom",className:"!bg-red-500"}),n.jsx(et,{type:"source",position:tt.Left,id:"left",className:"!bg-red-500"}),n.jsx(et,{type:"source",position:tt.Right,id:"right",className:"!bg-red-500"})]})}const Nf={loopNode:yf,parallelGroup:Ka,executionNode:bf,diamondNode:wf},If=Ua(ei);function jf(e,t){const r=Ja(e);if(!t||t.length===0)return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:"#9ca3af",opacity:.4};const o=t[t.length-1];let s="#9ca3af",a=2;switch(o.status){case"completed":s="#22c55e";break;case"failed":s="#ef4444",a=3;break;case"running":s="#3b82f6",a=2;break;case"retrying":s="#f97316";break;case"cancelled":s="#eab308";break;case"pending":s="#9ca3af";break}return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:s,borderWidth:a}}function Fo(e,t,r){const o=n.jsxs("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[n.jsx("div",{className:"flex-shrink-0",children:Qa(e.nodeKind,e.label)}),n.jsx("span",{className:"text-sm font-medium break-words whitespace-normal leading-tight flex-1 min-w-0",children:e.label})]});if(!r||r.length===0)return o;const s=r[r.length-1],a=r.length,i=a>1;return i||s.duration&&s.duration>0?n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[o,n.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[i&&n.jsxs(kr,{variant:"outline",className:"text-xs px-1.5 py-0 border-orange-500 text-orange-700 dark:text-orange-300",children:["↻ ",a,"x"]}),s.duration&&s.duration>0&&n.jsxs(kr,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",At(s.duration,!0)]})]})]}):o}const ka={...Ya};function Po(e,t){var d,c,p;const{nodes:r,groupNodes:o}=Zo(e,ka),s=new Map,a=new Map;for(const u of o)u.id.startsWith("group_")&&a.set(u.id,u.position);for(const u of r){const f=(d=u.metadata)!=null&&d.parallelGroupId?`group_${u.metadata.parallelGroupId}`:null;f&&a.has(f)&&s.set(u.id,f)}const i=[],l=o.filter(u=>u.id.startsWith("group_"));for(const u of l)i.push({id:u.id,type:"parallelGroup",position:u.position,style:{...u.style,cursor:"grab",zIndex:-1},data:u.data,selectable:!0,draggable:!0});for(const u of r){const f=t==null?void 0:t.nodeExecutions.get(u.id),x=jf(u.data.nodeKind,f),b=(t==null?void 0:t.currentNode)===u.id,j=!!((c=u.metadata)!=null&&c.loopId),w=!!((p=u.metadata)!=null&&p.loopIsAwait),v=u.data.nodeKind==="conditional",g=v?"diamondNode":j?"loopNode":"executionNode",I=s.get(u.id);let N=u.position;if(I){const E=a.get(I);E&&(N={x:u.position.x-E.x,y:u.position.y-E.y})}const C=b?"animate-pulse-subtle":"";j?i.push({id:u.id,type:g,position:N,parentId:I,extent:I?"parent":void 0,expandParent:!0,data:{...u.data,label:Fo(u.data,u.metadata,f),executions:f,isLoopNode:!0,isAwaitLoop:w,nodeStyle:x,className:C}}):v?i.push({id:u.id,type:g,position:N,parentId:I,extent:I?"parent":void 0,expandParent:!0,data:{...u.data,label:u.data.label,executions:f,nodeStyle:x,className:C}}):i.push({id:u.id,type:g,position:N,parentId:I,extent:I?"parent":void 0,expandParent:!0,data:{...u.data,label:Fo(u.data,u.metadata,f),executions:f,nodeStyle:x,className:C},style:{width:220}})}return i}function Bo(e,t){const{additionalEdges:r}=Zo(e,ka),s=[...e.edges.map(i=>i.type==="loop"?{...i,id:`loop_back_${i.source}_${i.target}`,isOriginal:!0}:{...i,isOriginal:!0}),...r.map(i=>({...i,isOriginal:!1}))];return Xa(s,e.nodes).map(i=>{if(i.type==="selfLoop")return{id:i.id,source:i.source,target:i.target,sourceHandle:i.sourceHandle,targetHandle:i.targetHandle,type:"selfLoop",label:i.label,markerEnd:{type:$n.ArrowClosed,width:12,height:12,color:"#a855f7"}};let l=t==null?void 0:t.edgeTraversals.get(i.id);if(!l&&i.isConsolidated&&i.originalEdgeIds)for(const m of i.originalEdgeIds){const y=t==null?void 0:t.edgeTraversals.get(m);if(y&&y.traversalCount>0){l=y;break}}const d=l&&l.traversalCount>0,c=!!t,p=l!=null&&l.timings.length?l.timings.reduce((m,y)=>m+y,0)/l.timings.length:void 0;let u="bezier",f,x=i.label,b=!1;switch(i.type){case"parallel":u="smoothstep",f="4,4",x=void 0;break;case"loop":u="step",f="8,4";break;case"conditional":u="smoothstep",f="8,4",b=!0;break;default:u="bezier"}const w=d?"#22c55e":"#6b7280",v=d?void 0:f,g=c&&!d?.35:1,I=d?2.5:1,N=b?"#ffffff":"#6b7280",C=b?"#374151":"#f3f4f6",E=b?"#4b5563":"#d1d5db";return{id:i.id,source:i.source,target:i.target,type:u,animated:d&&(t==null?void 0:t.status)==="running",label:l&&l.traversalCount>1?n.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[n.jsxs(kr,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[l.traversalCount,"×"]}),p&&p>0&&n.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["~",At(p,!0)]})]}):x,labelStyle:{fill:N,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:C,fillOpacity:.95,stroke:E,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:$n.ArrowClosed,width:d?14:10,height:d?14:10,color:w},style:{strokeWidth:I,stroke:w,opacity:g,strokeDasharray:v}}})}function kf({selectedNode:e,env:t,onClose:r}){const{node:o,executions:s,stepId:a,runId:i}=e,l=s[s.length-1],d=s.length>1,{data:c,loading:p}=Ws(t??{},"step",a??"",{runId:i}),u=(c==null?void 0:c.input)??(l==null?void 0:l.input),f=(c==null?void 0:c.output)??(l==null?void 0:l.output),x=(c==null?void 0:c.error)??(l==null?void 0:l.error);return n.jsxs("div",{className:"h-full flex flex-col bg-background border-l",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b flex-none",children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",title:o.data.label,children:o.data.label}),n.jsxs("div",{className:"flex items-center gap-2 flex-none",children:[(l==null?void 0:l.duration)!==void 0&&l.duration>0&&n.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:At(l.duration)}),n.jsx("div",{className:"w-px h-4 bg-border"}),n.jsx("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-muted transition-colors","aria-label":"Close panel",children:n.jsx(Ko,{className:"h-4 w-4 text-muted-foreground"})})]})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:[n.jsxs("div",{className:"flex flex-col divide-y rounded-lg border overflow-hidden mb-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"type"}),n.jsx("span",{className:"text-[11px] font-mono",children:o.data.nodeKind})]}),l&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"status"}),n.jsx(en,{status:Ho(l.status)})]}),l.duration!==void 0&&l.duration>0&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"duration"}),n.jsx("span",{className:"text-[11px] font-mono",children:At(l.duration)})]}),d&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"attempts"}),n.jsx("span",{className:"text-[11px] font-mono",children:s.length})]}),l.startedAt&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"startedAt"}),n.jsx("span",{className:"text-[11px] font-mono",children:new Date(l.startedAt).toLocaleString()})]}),l.completedAt&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"completedAt"}),n.jsx("span",{className:"text-[11px] font-mono",children:new Date(l.completedAt).toLocaleString()})]})]})]}),p&&a&&n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[n.jsx(Nn,{className:"h-3 w-3 animate-spin"}),n.jsx("span",{children:"Loading step data..."})]}),u!==void 0&&n.jsxs("details",{className:"group mb-3",children:[n.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[n.jsx("span",{className:"font-medium",children:"Input"}),n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Array.isArray(u)?u.length:1," args)"]})]}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:n.jsx("code",{children:JSON.stringify(u,null,2)})})]})]}),f!==void 0&&n.jsxs("details",{className:"group mb-3",children:[n.jsx("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:n.jsx("span",{className:"font-medium",children:"Output"})}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:n.jsx("code",{children:JSON.stringify(f,null,2)})})]})]}),x&&n.jsxs("details",{className:"group mb-3",open:!0,children:[n.jsx("summary",{className:"cursor-pointer rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 px-2.5 py-1.5 text-xs hover:brightness-95",children:n.jsx("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error"})}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-red-300"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-red-300"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border border-red-200 p-2.5 bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300 whitespace-pre-wrap max-h-64 overflow-y-auto",children:n.jsx("code",{children:typeof x=="object"?JSON.stringify(x,null,2):String(x)})})]})]}),d&&n.jsxs("details",{className:"group",children:[n.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[n.jsx("span",{className:"font-medium",children:"Attempt History"}),n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",s.length," attempts)"]})]}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",children:s.map(b=>n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-[11px]",children:[n.jsxs("span",{className:"text-muted-foreground",children:["Attempt ",b.attemptNumber]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(en,{status:Ho(b.status)}),b.duration!==void 0&&b.duration>0&&n.jsx("span",{className:"font-mono text-muted-foreground",children:At(b.duration)})]})]},b.attemptNumber))})]})]})]})]})}function Cf({workflow:e,execution:t,env:r,onNodeClick:o}){const[s,a]=h.useState(null),i=320,l=h.useMemo(()=>Po(e,t),[e,t]),d=h.useMemo(()=>Bo(e,t),[e,t]),[c,p,u]=$a(l),[f,x,b]=Va(d);h.useEffect(()=>{p(v=>{const g=Po(e,t),I=new Map(v.map(N=>[N.id,N.position]));return g.map(N=>({...N,position:I.get(N.id)??N.position}))}),x(Bo(e,t))},[e,t,p,x]);const j=h.useCallback((v,g)=>{const I=e.nodes.find(N=>N.id===g.id);if(I){const N=g.data.executions||[],C=N[N.length-1];a({nodeId:g.id,node:I,executions:N,stepId:C==null?void 0:C.stepId,runId:t==null?void 0:t.runId}),o&&N.length>0&&o(g.id,N)}},[e.nodes,t==null?void 0:t.runId,o]),w=h.useCallback(()=>{a(null)},[]);return n.jsxs("div",{className:"h-full w-full border rounded-lg bg-background relative overflow-hidden flex",children:[n.jsx("div",{className:"h-full flex-1 min-w-0",style:{width:s?`calc(100% - ${i}px)`:"100%"},children:n.jsxs(Ga,{nodes:c,edges:f,onNodesChange:u,onEdgesChange:b,onNodeClick:j,nodeTypes:Nf,edgeTypes:If,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[n.jsx(qa,{}),n.jsx(Za,{}),n.jsx(Wn,{position:"top-left",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-2 text-xs",children:n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("div",{className:"font-semibold text-[10px] text-muted-foreground mb-1",children:"Status"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-green-500 bg-background"}),n.jsx("span",{children:"Completed"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-red-500 bg-background"}),n.jsx("span",{children:"Failed"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-blue-500 bg-background"}),n.jsx("span",{children:"Running"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-yellow-500 bg-background"}),n.jsx("span",{children:"Cancelled"})]}),n.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-gray-400 bg-background"}),n.jsx("span",{children:"Pending"})]})]})}),t&&n.jsxs(Wn,{position:"top-right",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-3 text-xs space-y-1.5",children:[n.jsx("div",{className:"font-semibold text-sm",children:"Execution"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:"Status:"}),n.jsx(kr,{variant:t.status==="completed"?"default":t.status==="failed"?"destructive":t.status==="cancelled"?"outline":"secondary",className:"text-xs",children:t.status})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:"Progress:"}),n.jsxs("span",{className:"font-mono",children:[t.executionPath.length," / ",e.nodes.length]})]})]})]})}),s&&n.jsx("div",{className:"h-full flex-none",style:{width:i},children:n.jsx(kf,{selectedNode:s,env:r,onClose:w})})]})}function Sf({run:e,allEvents:t,env:r}){const{manifest:o,loading:s,error:a}=di(),i=h.useMemo(()=>{var x;if(!o||!e.workflowName)return null;const c=String(e.workflowName).trim(),p=o.workflows[c];if(p)return p;const u=(x=xt(c))==null?void 0:x.shortName;return Object.values(o.workflows).find(b=>{var j;return b.workflowId===c||b.workflowName===c?!0:u?((j=xt(b.workflowName))==null?void 0:j.shortName)===u:!1})??null},[o,e.workflowName]),l=h.useMemo(()=>{if(!t)return[];const c=new Map;for(const p of t)if(p.eventType.startsWith("step_")&&p.correlationId){const u=c.get(p.correlationId);u?u.push(p):c.set(p.correlationId,[p])}return Array.from(c.values()).map(zs).filter(p=>p!==null)},[t]),d=h.useMemo(()=>!i||!e.runId?null:gf(e,l,t||[],i),[i,e,l,t]);return s?n.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[n.jsx(Nn,{className:"h-8 w-8 animate-spin text-muted-foreground"}),n.jsx("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):a?n.jsx("div",{className:"flex items-center justify-center w-full h-full p-4",children:n.jsxs(tn,{variant:"destructive",className:"max-w-lg",children:[n.jsx(rn,{className:"h-4 w-4"}),n.jsx(nn,{children:"Error Loading Workflow Graph"}),n.jsx(on,{children:a.message})]})}):i?n.jsx(Cf,{workflow:i,execution:d||void 0,env:r}):n.jsx("div",{className:"flex items-center justify-center w-full h-full",children:n.jsxs(tn,{className:"max-w-lg",children:[n.jsx(rn,{className:"h-4 w-4"}),n.jsx(nn,{children:"Workflow Graph Not Found"}),n.jsx(on,{children:"Could not find the workflow graph for this run. The workflow may have been deleted or the graph manifest may need to be regenerated."})]})})}function Tf({runId:e,selectedId:t}){var ft;const r=Ca(),[o]=$o(),{serverConfig:s}=Di(),[a,i]=h.useState(!1),[l,d]=h.useState(!1),[c,p]=h.useState(!1),[u,f]=h.useState(!1),x=h.useMemo(()=>({}),[]),b=o.get("tab")||"trace",j=o.get("streamId"),w=h.useCallback(Z=>{const pe=new URLSearchParams(o.toString());for(const[be,Ae]of Object.entries(Z))Ae===null?pe.delete(be):pe.set(be,Ae);r(`?${pe.toString()}`,{preventScrollReset:!0})},[r,o]),v=h.useCallback(Z=>{w(Z==="trace"||Z==="graph"?{tab:Z,streamId:null}:{tab:Z})},[w]),g=h.useCallback(Z=>{w({streamId:Z})},[w]),I=h.useCallback(Z=>{w({tab:"streams",streamId:Z})},[w]),N=h.useCallback(async(Z,pe)=>ti(x,Z,{correlationIds:[pe]}),[x]),C=h.useRef(null),E=h.useCallback(async(Z,pe)=>{await ri(x,Z,pe)},[x]),m=h.useCallback(async Z=>{const{error:pe,result:be}=await Qe(Vn(x,Z.runId,Z.eventId,"all"));if(pe)throw pe;const Ae=C.current?await sn(be,C.current):it(be);return"eventData"in Ae?Ae.eventData:null},[x]),y=h.useCallback(async(Z,pe)=>{const{error:be,result:Ae}=await Qe(Vn(x,e,pe,"all"));if(be)throw be;const Ge=C.current?await sn(Ae,C.current):it(Ae);return"eventData"in Ge?Ge.eventData:null},[x,e]),k=s.backendId==="local"||s.backendId==="@workflow/world-local",{run:T,events:S,loading:A,error:R,update:F,loadMoreTraceData:B,hasMoreTraceData:D,isLoadingMoreTraceData:_}=Xd(x,e,{live:!0}),P=T??{},[U,Q]=h.useState(null);C.current=U;const[z,Y]=h.useState(null),{data:L,loading:W,error:$,refresh:ee}=Ws(x,(z==null?void 0:z.resource)??"run",(z==null?void 0:z.resourceId)??"",{runId:z==null?void 0:z.runId,enabled:!!(z!=null&&z.resource&&(z!=null&&z.resourceId)&&z.resource!=="hook"),encryptionKey:U??void 0}),de=h.useCallback(async()=>{if(U){ee();return}const{error:Z,result:pe}=await Qe(Mi(x,e));if(Z){fe.error(`Failed to fetch encryption key: ${Z.message}`);return}if(!pe){fe.error("Encryption is not configured for this deployment.");return}Q(pe)},[U,x,e,ee]),O=h.useCallback(Z=>{Y(Z)},[]),{streams:G,loading:oe,error:ge}=ru(x,e),{chunks:Ee,isLive:X,error:ae}=xf(x,j,e,U),xe=()=>{p(!0)},ye=async()=>{if(!a)try{i(!0),p(!1),await li(x,e),await F(),fe.success("Run cancelled successfully")}catch(Z){console.error("Failed to cancel run:",Z),fe.error("Failed to cancel run",{description:Z instanceof Error?Z.message:"An unknown error occurred"})}finally{i(!1)}},le=()=>{f(!0)},ue=async()=>{if(!l)try{d(!0),f(!1);const Z=await ci(x,P.runId);fe.success("New run started successfully",{description:`Run ID: ${Z}`}),r(`/run/${Z}`)}catch(Z){console.error("Failed to re-run workflow:",Z),fe.error("Failed to start new run",{description:Z instanceof Error?Z.message:"An unknown error occurred"})}finally{d(!1),f(!1)}};if(R&&!T)return n.jsxs(tn,{variant:"destructive",className:"m-4",children:[n.jsx(rn,{className:"h-4 w-4"}),n.jsx(nn,{children:"Error loading workflow run"}),n.jsx(on,{children:R.message})]});const ke=(ft=xt(P.workflowName))==null?void 0:ft.shortName;return n.jsxs(n.Fragment,{children:[n.jsx(To,{open:c,onOpenChange:p,children:n.jsxs(Eo,{children:[n.jsxs(Ao,{children:[n.jsx(Do,{children:"Cancel Workflow Run?"}),n.jsx(Mo,{children:"This will stop the workflow execution immediately, and no further steps will be executed. Partial workflow execution may occur. Are you sure you want to cancel the run?"})]}),n.jsxs(Ro,{children:[n.jsx(Lo,{children:"Keep Running"}),n.jsx(_o,{onClick:ye,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),n.jsx(To,{open:u,onOpenChange:f,children:n.jsxs(Eo,{children:[n.jsxs(Ao,{children:[n.jsx(Do,{children:"Replay Run?"}),n.jsx(Mo,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),n.jsxs(Ro,{children:[n.jsx(Lo,{children:"Cancel"}),n.jsx(_o,{onClick:ue,children:"Replay Run"})]})]})}),n.jsxs("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[n.jsxs("div",{className:"flex-none space-y-4",children:[n.jsx(tf,{children:n.jsxs(rf,{children:[n.jsx(Oo,{children:n.jsx(nf,{asChild:!0,children:n.jsx(Sa,{to:"/",children:"Runs"})})}),n.jsx(sf,{}),n.jsx(Oo,{children:n.jsx(of,{className:"font-mono text-xs",children:e})})]})}),n.jsxs("div",{className:"space-y-4 p-6 border rounded-lg",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsx("div",{className:"mb-4",children:n.jsx("h1",{className:"text-xl font-semibold",children:ke||n.jsx(St,{className:"w-[260px] h-[28px]"})})}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(vf,{hasError:!1,errorMessage:""}),n.jsx(ni,{env:x,runId:e,runStatus:P.status,events:S,eventsLoading:A,loading:A,onRerunClick:le,onCancelClick:xe,callbacks:{onSuccess:F}})]})]}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Status"}),P.status?n.jsx(en,{status:P.status,context:P}):n.jsx(St,{className:"w-[55px] h-[24px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Duration"}),n.jsx("div",{className:"text-xs",children:P.runId?P.startedAt?(()=>{const Z=(P.completedAt?new Date(P.completedAt).getTime():Date.now())-new Date(P.startedAt).getTime(),pe=Math.floor(Z/1e3);if(pe<60)return`${pe}s`;const be=Math.floor(pe/60),Ae=pe%60;if(be<60)return Ae>0?`${be}m ${Ae}s`:`${be}m`;const Ge=Math.floor(be/60),Ye=be%60;return Ye>0?`${Ge}h ${Ye}m`:`${Ge}h`})():"-":n.jsx(St,{className:"w-[60px] h-[20px]"})})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),P.runId?n.jsx(oi,{text:P.runId,children:n.jsx("div",{className:"text-xs mt-0.5 font-mono",children:P.runId})}):n.jsx(St,{className:"w-[280px] h-[20px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Queued"}),P.createdAt?n.jsx("div",{className:"text-xs",children:n.jsx(fr,{date:P.createdAt})}):n.jsx(St,{className:"w-[110px] h-[20px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Started"}),n.jsx("div",{className:"text-xs",children:P.runId?P.startedAt?n.jsx(fr,{date:P.startedAt}):"-":n.jsx(St,{className:"w-[110px] h-[20px]"})})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Completed"}),n.jsx("div",{className:"text-xs",children:P.runId?P.completedAt?n.jsx(fr,{date:P.completedAt}):"-":n.jsx(St,{className:"w-[110px] h-[20px]"})})]}),P.expiredAt!=null&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs(es,{children:[n.jsx(ts,{asChild:!0,children:n.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",n.jsx(Fi,{className:"w-3 h-3"})]})}),n.jsx(rs,{children:n.jsx("p",{children:"The storage data for this run has expired and is no longer available."})})]}),n.jsx("div",{className:"text-xs",children:n.jsx(fr,{date:P.expiredAt})})]})]})]})]}),n.jsx("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:n.jsxs(si,{value:b,onValueChange:Z=>v(Z),className:"flex-1 flex flex-col min-h-0",children:[n.jsxs(ai,{className:"mb-4 flex-none",children:[n.jsxs(mr,{value:"trace",className:"gap-2",children:[n.jsx($r,{className:"h-4 w-4"}),"Trace"]}),k&&n.jsxs(mr,{value:"graph",className:"gap-2",children:[n.jsx(ii,{className:"h-4 w-4"}),"Graph"]}),n.jsxs(mr,{value:"events",className:"gap-2",children:[n.jsx($r,{className:"h-4 w-4"}),"Events"]}),n.jsxs(mr,{value:"streams",className:"gap-2",children:[n.jsx($r,{className:"h-4 w-4"}),"Streams"]})]}),n.jsx(pr,{value:"trace",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load trace viewer",children:n.jsx("div",{className:"h-full",children:n.jsx(Vd,{error:R,events:S,run:P,isLoading:A,spanDetailData:L,spanDetailLoading:W,spanDetailError:$,onSpanSelect:O,onStreamClick:I,onWakeUpSleep:N,onResolveHook:E,onLoadEventData:y,onLoadMoreSpans:B,hasMoreSpans:D,isLoadingMoreSpans:_,encryptionKey:U??void 0,onDecrypt:de})})})}),n.jsx(pr,{value:"events",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load events list",children:n.jsx("div",{className:"h-full",children:n.jsx(Sc,{events:S,run:P,onLoadEventData:m,encryptionKey:U??void 0})})})}),n.jsx(pr,{value:"streams",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load stream data",children:n.jsxs("div",{className:"h-full flex gap-4",children:[n.jsxs("div",{className:"w-64 flex-shrink-0 border rounded-lg overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-background-100)"},children:[n.jsxs("div",{className:"px-3 py-2 border-b text-xs font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)"},children:["Streams (",G.length,")"]}),n.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:oe?n.jsx("div",{className:"p-4 flex items-center justify-center",children:n.jsx(Nn,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):ge?n.jsx("div",{className:"p-4 text-xs text-destructive",children:ge.message}):G.length===0?n.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):G.map(Z=>n.jsx("button",{type:"button",onClick:()=>g(Z),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:j===Z?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:Z,children:Z},Z))})]}),n.jsx("div",{className:"flex-1 min-w-0",children:j?n.jsx(_i,{streamId:j,chunks:Ee,isLive:X,error:ae}):n.jsx("div",{className:"h-full flex items-center justify-center rounded-lg border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:n.jsx("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:G.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),k&&n.jsx(pr,{value:"graph",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load execution graph",children:n.jsx("div",{className:"h-full min-h-[500px]",children:n.jsx(Sf,{run:P,allEvents:S,env:x})})})})]})})]})]})}const Mf=Ta(function(){const t=Ea(),[r]=$o(),o=t.runId,s=r.get("stepId"),a=r.get("eventId"),i=r.get("hookId"),l=s||a||i||void 0;return n.jsx(Ht,{title:"Failed to load run details",children:n.jsx(Tf,{runId:o,selectedId:l})})});export{Mf as default};
|