@workflow/web 4.1.0-beta.36 → 4.1.0-beta.37
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/build/client/assets/encryption-8OvC6eoJ.js +1 -0
- package/build/client/assets/{highlighted-body-B3W2YXNL-DCpvexQb.js → highlighted-body-B3W2YXNL-BO6bNJzI.js} +1 -1
- package/build/client/assets/{home-DrlgsY_n.js → home-bWDrLREI.js} +1 -1
- package/build/client/assets/{manifest-5132e9b8.js → manifest-daa82ff1.js} +1 -1
- package/build/client/assets/{mermaid-3ZIDBTTL-Ddgw_y0p.js → mermaid-3ZIDBTTL-CJ6mkUFN.js} +71 -66
- package/build/client/assets/{root-DKF4DBnS.js → root-Ckv-c9_b.js} +1 -1
- package/build/client/assets/run-detail-EcdnCjQk.js +41 -0
- package/build/client/assets/{use-workflow-graph-CUAynhYD.js → use-workflow-graph-JKiMb5g6.js} +1 -1
- package/build/server/assets/{app-BMiBNdAl.js → app-CatvtWxS.js} +1 -1
- package/build/server/assets/{highlighted-body-B3W2YXNL-CzB1YMLj.js → highlighted-body-B3W2YXNL-DoOhy3wX.js} +2 -2
- package/build/server/assets/{mermaid-3ZIDBTTL-Dqygs4_q.js → mermaid-3ZIDBTTL-uuxw6-ur.js} +2 -2
- package/build/server/assets/{server-build-Up-_dwCR.js → server-build-XXW48t5z.js} +1633 -1198
- package/build/server/assets/{token-DbisGEEb.js → token-C58qysN7.js} +3 -3
- package/build/server/assets/{token-lkNtm8QO.js → token-CLFHo1Az.js} +2 -2
- package/build/server/assets/{token-util-DNmL7drj.js → token-util-C6iVpF77.js} +2 -2
- package/build/server/assets/{token-util-pehEj9SJ.js → token-util-CbxhzlWz.js} +1 -1
- package/build/server/assets/{token-util-BtczqLw5.js → token-util-CcopqG1U.js} +2 -2
- package/build/server/index.js +1 -1
- package/package.json +6 -6
- package/build/client/assets/run-detail-DKgwr7Ee.js +0 -36
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{R as X,j as n,r as m,A as qo,f as Yo,x as Ra,y as Zo,z as Aa,w as Da,C as Ma}from"./index-DklpUtP3.js";import{U as lr,V as cr,B as It,j as Xo,q as Jo,Y as _a,Z as La,S as Qo,R as es,p as Oa,o as Ha,X as ts,Q as Bt,_ as Fa,G as Pa,$ as Re,u as Nr,W as Rt,a0 as Ba,v as ht,a1 as Tr,a2 as za,t as rs,a3 as Wa,s as $a,a4 as Ur,w as Tn,l as Va,m as Ga,a5 as Ua,a6 as Ka,a7 as qa,a8 as Ya,a9 as Za,aa as Xa,ab as Ja,ac as Qa,ad as qn,J as Er,ae as ns,af as ei,ag as ti,ah as Yn,ai as ct,aj as dt,F as dn,ak as ri,al as ni,am as oi,an as si,r as ai,A as un,C as fn,c as mn,d as pn,a as Tt,ao as ii,e as li,b as hr,T as ci,M as di,N as gr,K as ui,O as xr,y as fi,ap as mi,I as pi}from"./use-workflow-graph-JKiMb5g6.js";import{c as dr,t as he,I as Dt,J as He,M as Rr,_ as hi,N as gi,O as lt,U as xi,W as vi,X as os,Y as Mt,Z as ft,$ as re,a0 as yi,a1 as bi,a2 as Kr,a3 as Ve,a4 as vr,a5 as Ar,a6 as zt,a7 as wt,a8 as ss,a9 as qt,aa as qr,ab as wi,ac as Ii,ad as Ni,ae as ji,af as ki,ag as Si,ah as Ci,ai as jr,aj as Oe,ak as as,k as Dr,E as hn,al as Ti,am as Yr,i as Zr,F as Xt,an as Ei,ao as En,z as jt,ap as Ri,d as qe,aq as is,ar as Ai,as as Di,at as Mi,T as gn,a as xn,b as vn,au as _i,L as Mr,u as Li,av as Oi,B as Hi,aw as Fi}from"./mermaid-3ZIDBTTL-CJ6mkUFN.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 Pi=[["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"}]],Bi=dr("circle-question-mark",Pi);/**
|
|
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 zi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Wi=dr("info",zi);/**
|
|
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 $i=[["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"}]],Xr=dr("list",$i);/**
|
|
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 Vi=[["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"}]],Gi=dr("lock-open",Vi);/**
|
|
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 Ui=[["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"}]],Ki=dr("type",Ui),Br=0,kt=1,Gt=2,ls=4;function Zn(e){return()=>e}function qi(e){e()}function cs(e,t){return r=>e(t(r))}function Xn(e,t){return()=>e(t)}function Yi(e,t){return r=>e(t,r)}function Rn(e){return e!==void 0}function Zi(...e){return()=>{e.map(qi)}}function Ut(){}function zr(e,t){return t(e),e}function Xi(e,t){return t(e)}function we(...e){return e}function ve(e,t){return e(kt,t)}function le(e,t){e(Br,t)}function An(e){e(Gt)}function Se(e){return e(ls)}function J(e,t){return ve(e,Yi(t,Br))}function tt(e,t){const r=e(kt,o=>{r(),t(o)});return r}function Jn(e){let t,r;return o=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{o(t)},e)}}function ds(e,t){return e===t}function be(e=ds){let t;return r=>o=>{e(t,o)||(t=o,r(o))}}function se(e){return t=>r=>{e(r)&&t(r)}}function G(e){return t=>cs(t,e)}function it(e){return t=>()=>{t(e)}}function L(e,...t){const r=Ji(...t);return((o,s)=>{switch(o){case Gt:An(e);return;case kt:return ve(e,r(s))}})}function ut(e,t){return r=>o=>{r(t=e(t,o))}}function _t(e){return t=>r=>{e>0?e--:t(r)}}function pt(e){let t=null,r;return o=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,o(t)},e))}}function de(...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);ve(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 Ji(...e){return t=>e.reduceRight(Xi,t)}function Qi(e){let t,r;const o=()=>t==null?void 0:t();return function(s,a){switch(s){case kt:return a?r===a?void 0:(o(),r=a,t=ve(e,a),t):(o(),Ut);case Gt:o(),r=null;return}}}function H(e){let t=e;const r=fe();return((o,s)=>{switch(o){case Br:t=s;break;case kt:{s(t);break}case ls:return t}return r(o,s)})}function Be(e,t){return zr(H(t),r=>J(e,r))}function fe(){const e=[];return((t,r)=>{switch(t){case Br:e.slice().forEach(o=>{o(r)});return;case Gt:e.splice(0,e.length);return;case kt:return e.push(r),()=>{const o=e.indexOf(r);o>-1&&e.splice(o,1)}}})}function Ke(e){return zr(fe(),t=>J(e,t))}function xe(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:el(),singleton:r}}const el=()=>Symbol();function tl(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 Ee(...e){const t=fe(),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);ve(a,d=>{r[i]=d,o=o|l,o===s&&le(t,r)})}),function(a,i){switch(a){case Gt:{An(t);return}case kt:return o===s&&i(r),ve(t,i)}}}function oe(e,t=ds){return L(e,be(t))}function yn(...e){return function(t,r){switch(t){case Gt:return;case kt:return Zi(...e.map(o=>ve(o,r)))}}}var Ge=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ge||{});const rl={0:"debug",3:"error",1:"log",2:"warn"},nl=()=>typeof globalThis>"u"?window:globalThis,St=xe(()=>{const e=H(3);return{log:H((t,r,o=1)=>{var s;const a=(s=nl().VIRTUOSO_LOG_LEVEL)!=null?s:Se(e);o>=a&&console[rl[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function Ot(e,t,r){return Dn(e,t,r).callbackRef}function Dn(e,t,r){const o=X.useRef(null);let s=i=>{};const a=X.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 ol(e,t,r,o,s,a,i,l,d){const c=X.useCallback(f=>{const u=sl(f.children,t,l?"offsetWidth":"offsetHeight",s);let h=f.parentElement;for(;!h.dataset.virtuosoScroller;)h=h.parentElement;const v=h.lastElementChild.dataset.viewportType==="window";let b;v&&(b=h.ownerDocument.defaultView);const j=i?l?i.scrollLeft:i.scrollTop:v?l?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:l?h.scrollLeft:h.scrollTop,w=i?l?i.scrollWidth:i.scrollHeight:v?l?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:l?h.scrollWidth:h.scrollHeight,x=i?l?i.offsetWidth:i.offsetHeight:v?l?b.innerWidth:b.innerHeight:l?h.offsetWidth:h.offsetHeight;o({scrollHeight:w,scrollTop:Math.max(j,0),viewportHeight:x}),a==null||a(l?Qn("column-gap",getComputedStyle(f).columnGap,s):Qn("row-gap",getComputedStyle(f).rowGap,s)),u!==null&&e(u)},[e,t,s,a,i,o,l]);return Dn(c,r,d)}function sl(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),f=t(l,r);if(f===0&&o("Zero-sized element, this should not happen",{child:l},Ge.ERROR),f===c)continue;const u=a[a.length-1];a.length===0||u.size!==f||u.endIndex!==d-1?a.push({endIndex:d,size:f,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,Ge.WARN),t==="normal"?0:parseInt(t??"0",10)}function us(e,t,r){const o=X.useRef(null),s=X.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const c=d.getBoundingClientRect(),f=c.width;let u,h;if(t){const v=t.getBoundingClientRect(),b=c.top-v.top;h=v.height-Math.max(0,b),u=b+t.scrollTop}else{const v=i.current.ownerDocument.defaultView;h=v.innerHeight-Math.max(0,c.top),u=c.top+v.scrollY}o.current={offsetTop:u,visibleHeight:h,visibleWidth:f},e(o.current)},[e,t]),{callbackRef:a,ref:i}=Dn(s,!0,r),l=X.useCallback(()=>{s(i.current)},[s,i]);return X.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 We=xe(()=>{const e=fe(),t=fe(),r=H(0),o=fe(),s=H(0),a=fe(),i=fe(),l=H(0),d=H(0),c=H(0),f=H(0),u=fe(),h=fe(),v=H(!1),b=H(!1),j=H(!1);return J(L(e,G(({scrollTop:w})=>w)),t),J(L(e,G(({scrollHeight:w})=>w)),i),J(t,s),{deviation:r,fixedFooterHeight:c,fixedHeaderHeight:d,footerHeight:f,headerHeight:l,horizontalDirection:b,scrollBy:h,scrollContainerState:e,scrollHeight:i,scrollingInProgress:v,scrollTo:u,scrollTop:t,skipAnimationFrameInResizeObserver:j,smoothScrollTargetReached:o,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),er={lvl:0};function fs(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 ye(e){return e===er}function tr(e,t){if(!ye(e))return t===e.k?e.v:t<e.k?tr(e.l,t):tr(e.r,t)}function nt(e,t,r="k"){if(ye(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const o=nt(e.r,t,r);return o[0]===-1/0?[e.k,e.v]:o}return nt(e.l,t,r)}function Ue(e,t,r){return ye(e)?hs(t,r,1):t===e.k?Ae(e,{k:t,v:r}):t<e.k?eo(Ae(e,{l:Ue(e.l,t,r)})):eo(Ae(e,{r:Ue(e.r,t,r)}))}function Wt(){return er}function $t(e,t,r){if(ye(e))return[];const o=nt(e,t)[0];return al(wn(e,o,r))}function bn(e,t){if(ye(e))return er;const{k:r,l:o,r:s}=e;if(t===r){if(ye(o))return s;if(ye(s))return o;{const[a,i]=ps(o);return kr(Ae(e,{k:a,l:ms(o),v:i}))}}else return t<r?kr(Ae(e,{l:bn(o,t)})):kr(Ae(e,{r:bn(s,t)}))}function At(e){return ye(e)?[]:[...At(e.l),{k:e.k,v:e.v},...At(e.r)]}function wn(e,t,r){if(ye(e))return[];const{k:o,l:s,r:a,v:i}=e;let l=[];return o>t&&(l=l.concat(wn(s,t,r))),o>=t&&o<=r&&l.push({k:o,v:i}),o<=r&&(l=l.concat(wn(a,t,r))),l}function kr(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(Jr(t))return gs(Ae(e,{lvl:r-1}));if(!ye(t)&&!ye(t.r))return Ae(t.r,{l:Ae(t,{r:t.r.l}),lvl:r,r:Ae(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Jr(e))return In(Ae(e,{lvl:r-1}));if(!ye(o)&&!ye(o.l)){const s=o.l,a=Jr(s)?o.lvl-1:o.lvl;return Ae(s,{l:Ae(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:In(Ae(o,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Ae(e,t){return hs(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 ms(e){return ye(e.r)?e.l:kr(Ae(e,{r:ms(e.r)}))}function Jr(e){return ye(e)||e.lvl>e.r.lvl}function ps(e){return ye(e.r)?[e.k,e.v]:ps(e.r)}function hs(e,t,r,o=er,s=er){return{k:e,l:o,lvl:r,r:s,v:t}}function eo(e){return In(gs(e))}function gs(e){const{l:t}=e;return!ye(t)&&t.lvl===e.lvl?Ae(t,{r:Ae(e,{l:t.r})}):e}function In(e){const{lvl:t,r}=e;return!ye(r)&&!ye(r.r)&&r.lvl===t&&r.r.lvl===t?Ae(r,{l:Ae(e,{r:r.l}),lvl:t+1}):e}function al(e){return fs(e,({k:t,v:r})=>({index:t,value:r}))}function xs(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function rr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Mn=xe(()=>({recalcInProgress:H(!1)}),[],{singleton:!0});function vs(e,t,r){return e[_r(e,t,r)]}function _r(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 il(e,t,r,o){const s=_r(e,t,o),a=_r(e,r,o,s);return e.slice(s,a+1)}function Nt(e,t){return Math.round(e.getBoundingClientRect()[t])}function Wr(e){return!ye(e.groupOffsetTree)}function _n({index:e},t){return t===e?0:t<e?-1:1}function ll(){return{groupIndices:[],groupOffsetTree:Wt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Wt()}}function cl(e,t){let r=ye(e)?0:1/0;for(const o of t){const{endIndex:s,size:a,startIndex:i}=o;if(r=Math.min(r,i),ye(e)){e=Ue(e,0,a);continue}const l=$t(e,i-1,s+1);if(l.some(gl(o)))continue;let d=!1,c=!1;for(const{end:f,start:u,value:h}of l)d?(s>=u||a===h)&&(e=bn(e,u)):(c=h!==a,d=!0),f>s&&s>=u&&h!==a&&(e=Ue(e,s+1,h));c&&(e=Ue(e,i,a))}return[e,r]}function dl(e){return typeof e.groupIndex<"u"}function ul({offset:e},t){return t===e?0:t<e?-1:1}function nr(e,t,r){if(t.length===0)return 0;const{index:o,offset:s,size:a}=vs(t,e,_n),i=e-o,l=a*i+(i-1)*r+s;return l>0?l+r:l}function ys(e,t){if(!Wr(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function bs(e,t,r){if(dl(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?r:e.index;let s=ys(o,t);return s=Math.max(0,s,Math.min(r,s)),s}}function fl(e,t,r,o=0){return o>0&&(t=Math.max(t,vs(e,o,_n).offset)),fs(il(e,t,r,ul),hl)}function ml(e,[t,r,o,s]){t.length>0&&o("received item sizes",t,Ge.DEBUG);const a=e.sizeTree;let i=a,l=0;if(r.length>0&&ye(a)&&t.length===2){const h=t[0].size,v=t[1].size;i=r.reduce((b,j)=>Ue(Ue(b,j,h),j+1,v),i)}else[i,l]=cl(i,t);if(i===a)return e;const{lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u}=Nn(e.offsetTree,l,i,s);return{groupIndices:r,groupOffsetTree:r.reduce((h,v)=>Ue(h,v,nr(v,u,s)),Wt()),lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u,sizeTree:i}}function pl(e){return At(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 to(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 Nn(e,t,r,o){let s=e,a=0,i=0,l=0,d=0;if(t!==0){d=_r(s,t-1,_n),l=s[d].offset;const c=nt(r,t-1);a=c[0],i=c[1],s.length&&s[d].size===nt(r,t)[1]&&(d-=1),s=s.slice(0,d+1)}else s=[];for(const{start:c,value:f}of $t(r,t,1/0)){const u=c-a,h=u*i+l+u*o;s.push({index:c,offset:h,size:f}),a=c,l=h,i=f}return{lastIndex:a,lastOffset:l,lastSize:i,offsetTree:s}}function hl(e){return{index:e.index,value:e}}function gl(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 xl={offsetHeight:"height",offsetWidth:"width"},mt=xe(([{log:e},{recalcInProgress:t}])=>{const r=fe(),o=fe(),s=Be(o,0),a=fe(),i=fe(),l=H(0),d=H([]),c=H(void 0),f=H(void 0),u=H(void 0),h=H(void 0),v=H((p,y)=>Nt(p,xl[y])),b=H(void 0),j=H(0),w=ll(),x=Be(L(r,de(d,e,j),ut(ml,w),be()),w),g=Be(L(d,be(),ut((p,y)=>({current:y,prev:p.current}),{current:[],prev:[]}),G(({prev:p})=>p)),[]);J(L(d,se(p=>p.length>0),de(x,j),G(([p,y,k])=>{const T=p.reduce((D,_,C)=>Ue(D,_,nr(_,y.offsetTree,k)||C),Wt());return{...y,groupIndices:p,groupOffsetTree:T}})),x),J(L(o,de(x),se(([p,{lastIndex:y}])=>p<y),G(([p,{lastIndex:y,lastSize:k}])=>[{endIndex:y,size:k,startIndex:p}])),r),J(c,f);const I=Be(L(c,G(p=>p===void 0)),!0);J(L(f,se(p=>p!==void 0&&ye(Se(x).sizeTree)),G(p=>{const y=Se(u),k=Se(d).length>0;return y?k?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:p,startIndex:1}]:[]:[{endIndex:0,size:p,startIndex:0}]})),r),J(L(h,se(p=>p!==void 0&&p.length>0&&ye(Se(x).sizeTree)),G(p=>{const y=[];let k=p[0],T=0;for(let D=1;D<p.length;D++){const _=p[D];_!==k&&(y.push({endIndex:D-1,size:k,startIndex:T}),k=_,T=D)}return y.push({endIndex:p.length-1,size:k,startIndex:T}),y})),r),J(L(d,de(u,f),se(([,p,y])=>p!==void 0&&y!==void 0),G(([p,y,k])=>{const T=[];for(let D=0;D<p.length;D++){const _=p[D],C=p[D+1];T.push({startIndex:_,endIndex:_,size:y}),C!==void 0&&T.push({startIndex:_+1,endIndex:C-1,size:k})}return T})),r);const N=Ke(L(r,de(x),ut(({sizes:p},[y,k])=>({changed:k!==p,sizes:k}),{changed:!1,sizes:w}),G(p=>p.changed)));ve(L(l,ut((p,y)=>({diff:p.prev-y,prev:y}),{diff:0,prev:0}),G(p=>p.diff)),p=>{const{groupIndices:y}=Se(x);if(p>0)le(t,!0),le(a,p+to(p,y));else if(p<0){const k=Se(g);k.length>0&&(p-=to(-p,k)),le(i,p)}}),ve(L(l,de(e)),([p,y])=>{p<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},Ge.ERROR)});const S=Ke(a);J(L(a,de(x),G(([p,y])=>{const k=y.groupIndices.length>0,T=[],D=y.lastSize;if(k){const _=tr(y.sizeTree,0);let C=0,E=0;for(;C<p;){const F=y.groupIndices[E],O=y.groupIndices.length===E+1?1/0:y.groupIndices[E+1]-F-1;T.push({endIndex:F,size:_,startIndex:F}),T.push({endIndex:F+1+O-1,size:D,startIndex:F+1}),E++,C+=O+1}const M=At(y.sizeTree);return C!==p&&M.shift(),M.reduce((F,{k:O,v:z})=>{let $=F.ranges;return F.prevSize!==0&&($=[...F.ranges,{endIndex:O+p-1,size:F.prevSize,startIndex:F.prevIndex}]),{prevIndex:O+p,prevSize:z,ranges:$}},{prevIndex:p,prevSize:0,ranges:T}).ranges}return At(y.sizeTree).reduce((_,{k:C,v:E})=>({prevIndex:C+p,prevSize:E,ranges:[..._.ranges,{endIndex:C+p-1,size:_.prevSize,startIndex:_.prevIndex}]}),{prevIndex:0,prevSize:D,ranges:[]}).ranges})),r);const R=Ke(L(i,de(x,j),G(([p,{offsetTree:y},k])=>{const T=-p;return nr(T,y,k)})));return J(L(i,de(x,j),G(([p,y,k])=>{if(y.groupIndices.length>0){if(ye(y.sizeTree))return y;let T=Wt();const D=Se(g);let _=0,C=0,E=0;for(;_<-p;){E=D[C];const M=D[C+1]-E-1;C++,_+=M+1}if(T=At(y.sizeTree).reduce((M,{k:F,v:O})=>Ue(M,Math.max(0,F+p),O),T),_!==-p){const M=tr(y.sizeTree,E);T=Ue(T,0,M);const F=nt(y.sizeTree,-p+1)[1];T=Ue(T,1,F)}return{...y,sizeTree:T,...Nn(y.offsetTree,0,T,k)}}else{const T=At(y.sizeTree).reduce((D,{k:_,v:C})=>Ue(D,Math.max(0,_+p),C),Wt());return{...y,sizeTree:T,...Nn(y.offsetTree,0,T,k)}}})),x),{beforeUnshiftWith:S,data:b,defaultItemSize:f,firstItemIndex:l,fixedItemSize:c,fixedGroupSize:u,gap:j,groupIndices:d,heightEstimates:h,itemSize:v,listRefresh:N,shiftWith:i,shiftWithOffset:R,sizeRanges:r,sizes:x,statefulTotalCount:s,totalCount:o,trackItemSizes:I,unshiftWith:a}},we(St,Mn),{singleton:!0});function vl(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const ws=xe(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:o,scrollTop:s}])=>{const a=fe(),i=fe(),l=Ke(L(a,G(vl)));return J(L(l,G(d=>d.totalCount)),r),J(L(l,G(d=>d.groupIndices)),e),J(L(Ee(s,t,o),se(([d,c])=>Wr(c)),G(([d,c,f])=>nt(c.groupOffsetTree,Math.max(d-f,0),"v")[0]),be(),G(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},we(mt,We)),Ct=xe(([{log:e}])=>{const t=H(!1),r=Ke(L(t,se(o=>o),be()));return ve(t,o=>{o&&Se(e)("props updated",{},Ge.DEBUG)}),{didMount:r,propsReady:t}},we(St),{singleton:!0}),yl=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Is(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!yl)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ur=xe(([{gap:e,listRefresh:t,sizes:r,totalCount:o},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:i,headerHeight:l,scrollingInProgress:d,scrollTo:c,smoothScrollTargetReached:f,viewportHeight:u},{log:h}])=>{const v=fe(),b=fe(),j=H(0);let w=null,x=null,g=null;function I(){w&&(w(),w=null),g&&(g(),g=null),x&&(clearTimeout(x),x=null),le(d,!1)}return J(L(v,de(r,u,o,j,l,i,h),de(e,a,s),G(([[N,S,R,p,y,k,T,D],_,C,E])=>{const M=Is(N),{align:F,behavior:O,offset:z}=M,$=p-1,Q=bs(M,S,$);let P=nr(Q,S.offsetTree,_)+k;F==="end"?(P+=C+nt(S.sizeTree,Q)[1]-R+E,Q===$&&(P+=T)):F==="center"?P+=(C+nt(S.sizeTree,Q)[1]-R+E)/2:P-=y,z&&(P+=z);const V=W=>{I(),W?(D("retrying to scroll to",{location:N},Ge.DEBUG),le(v,N)):(le(b,!0),D("list did not change, scroll successful",{},Ge.DEBUG))};if(I(),O==="smooth"){let W=!1;g=ve(t,K=>{W=W||K}),w=tt(f,()=>{V(W)})}else w=tt(L(t,bl(150)),V);return x=setTimeout(()=>{I()},1200),le(d,!0),D("scrolling from index to",{behavior:O,index:Q,top:P},Ge.DEBUG),{behavior:O,top:P}})),c),{scrollTargetReached:b,scrollToIndex:v,topListHeight:j}},we(mt,We,St),{singleton:!0});function bl(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(r))}}}function Ln(e,t){e==0?t():requestAnimationFrame(()=>{Ln(e-1,t)})}function On(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const fr=xe(([{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 J(L(i,de(d),se(([f,u])=>!!u),it(!1)),l),J(L(i,de(d),se(([f,u])=>!!u),it(!1)),c),ve(L(Ee(t,i),de(l,r,e,c),se(([[,f],u,{sizeTree:h},v,b])=>f&&(!ye(h)||Rn(v))&&!u&&!b),de(d)),([,f])=>{tt(s,()=>{le(c,!0)}),Ln(4,()=>{tt(o,()=>{le(l,!0)}),le(a,f)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:l}},we(mt,We,ur,Ct),{singleton:!0});function Ns(e,t){return Math.abs(e-t)<1.01}const or="up",Jt="down",wl="none",Il={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Nl=0,mr=xe(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:o,scrollTop:s,viewportHeight:a}])=>{const i=H(!1),l=H(!0),d=fe(),c=fe(),f=H(4),u=H(Nl),h=Be(L(yn(L(oe(s),_t(1),it(!0)),L(oe(s),_t(1),it(!1),Jn(100))),be()),!1),v=Be(L(yn(L(r,it(!0)),L(r,it(!1),Jn(200))),be()),!1);J(L(Ee(oe(s),oe(u)),G(([g,I])=>g<=I),be()),l),J(L(l,pt(50)),c);const b=Ke(L(Ee(o,oe(a),oe(t),oe(e),oe(f)),ut((g,[{scrollHeight:I,scrollTop:N},S,R,p,y])=>{const k=N+S-I>-y,T={scrollHeight:I,scrollTop:N,viewportHeight:S};if(k){let _,C;return N>g.state.scrollTop?(_="SCROLLED_DOWN",C=g.state.scrollTop-N):(_="SIZE_DECREASED",C=g.state.scrollTop-N||g.scrollTopDelta),{atBottom:!0,atBottomBecause:_,scrollTopDelta:C,state:T}}let D;return T.scrollHeight>g.state.scrollHeight?D="SIZE_INCREASED":S<g.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":N<g.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:T}},Il),be((g,I)=>g&&g.atBottom===I.atBottom))),j=Be(L(o,ut((g,{scrollHeight:I,scrollTop:N,viewportHeight:S})=>{if(Ns(g.scrollHeight,I))return{changed:!1,jump:0,scrollHeight:I,scrollTop:N};{const R=I-(N+S)<1;return g.scrollTop!==N&&R?{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}),se(g=>g.changed),G(g=>g.jump)),0);J(L(b,G(g=>g.atBottom)),i),J(L(i,pt(50)),d);const w=H(Jt);J(L(o,G(({scrollTop:g})=>g),be(),ut((g,I)=>Se(v)?{direction:g.direction,prevScrollTop:I}:{direction:I<g.prevScrollTop?or:Jt,prevScrollTop:I},{direction:Jt,prevScrollTop:0}),G(g=>g.direction)),w),J(L(o,pt(50),it(wl)),w);const x=H(0);return J(L(h,se(g=>!g),it(0)),x),J(L(s,pt(100),de(h),se(([g,I])=>I),ut(([g,I],[N])=>[I,N],[0,0]),G(([g,I])=>I-g)),x),{atBottomState:b,atBottomStateChange:d,atBottomThreshold:f,atTopStateChange:c,atTopThreshold:u,isAtBottom:i,isAtTop:l,isScrolling:h,lastJumpDueToItemResize:j,scrollDirection:w,scrollVelocity:x}},we(We)),sr="top",ar="bottom",ro="none";function no(e,t,r){return typeof e=="number"?r===or&&t===sr||r===Jt&&t===ar?e:0:r===or?t===sr?e.main:e.reverse:t===ar?e.main:e.reverse}function oo(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const Hn=xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:o,viewportHeight:s}])=>{const a=fe(),i=H(0),l=H(0),d=H(0),c=Be(L(Ee(oe(o),oe(s),oe(r),oe(a,rr),oe(d),oe(i),oe(t),oe(e),oe(l)),G(([f,u,h,[v,b],j,w,x,g,I])=>{const N=f-g,S=w+x,R=Math.max(h-N,0);let p=ro;const y=oo(I,sr),k=oo(I,ar);return v-=g,v+=h+x,b+=h+x,b-=g,v>f+S-y&&(p=or),b<f-R+u+k&&(p=Jt),p!==ro?[Math.max(N-h-no(j,sr,p)-y,0),N-R-x+u+no(j,ar,p)+k]:null}),se(f=>f!=null),be(rr)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:c}},we(We),{singleton:!0});function jl(e,t,r){if(Wr(t)){const o=ys(e,t);return[{index:nt(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 Qr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Sr(e,t,r,o,s,a){const{lastIndex:i,lastOffset:l,lastSize:d}=s;let c=0,f=0;if(e.length>0){c=e[0].offset;const j=e[e.length-1];f=j.offset+j.size}const u=r-i,h=l+u*d+(u-1)*o,v=c,b=h-f;return{bottom:f,firstItemIndex:a,items:so(e,s,a),offsetBottom:b,offsetTop:c,top:v,topItems:so(t,s,a),topListHeight:t.reduce((j,w)=>w.size+j,0),totalCount:r}}function js(e,t,r,o,s,a){let i=0;if(r.groupIndices.length>0)for(const f of r.groupIndices){if(f-i>=e)break;i++}const l=e+i,d=On(t,l),c=Array.from({length:l}).map((f,u)=>({data:a[u+d],index:u+d,offset:0,size:0}));return Sr(c,[],l,s,r,o)}function so(e,t,r){if(e.length===0)return[];if(!Wr(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=$t(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 f;c.index===l.start?f={index:d,type:"group"}:f={groupIndex:d,index:c.index-(d+1)+r},a.push({...f,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return a}function ao(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const Ht=xe(([{data:e,firstItemIndex:t,gap:r,sizes:o,totalCount:s},a,{listBoundary:i,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:c,scrolledToInitialItem:f},{topListHeight:u},h,{didMount:v},{recalcInProgress:b}])=>{const j=H([]),w=H(0),x=fe(),g=H(0);J(a.topItemsIndexes,j);const I=Be(L(Ee(v,b,oe(d,rr),oe(s),oe(o),oe(c),f,oe(j),oe(t),oe(r),oe(g),e),se(([p,y,,k,,,,,,,,T])=>{const D=T&&T.length!==k;return p&&!y&&!D}),G(([,,[p,y],k,T,D,_,C,E,M,F,O])=>{var z,$,Q,P;const V=T,{offsetTree:W,sizeTree:K}=V,U=Se(w);if(k===0)return{...Qr,totalCount:k};if(p===0&&y===0)return U===0?{...Qr,totalCount:k}:js(U,D,T,E,M,O||[]);if(ye(K))return U>0?null:Sr(jl(On(D,k),V,O),[],k,M,V,E);const Y=[];if(C.length>0){const q=C[0],te=C[C.length-1];let me=0;for(const pe of $t(K,q,te)){const ce=pe.value,ie=Math.max(pe.start,q),Ie=Math.min(pe.end,te);for(let Ne=ie;Ne<=Ie;Ne++)Y.push({data:O==null?void 0:O[Ne],index:Ne,offset:me,size:ce}),me+=ce}}if(!_)return Sr([],Y,k,M,V,E);const ee=C.length>0?C[C.length-1]+1:0,A=fl(W,p,y,ee);if(A.length===0)return null;const B=k-1,ne=zr([],q=>{for(const te of A){const me=te.value;let pe=me.offset,ce=te.start;const ie=me.size;if(me.offset<p){ce+=Math.floor((p-me.offset+M)/(ie+M));const Ne=ce-te.start;pe+=Ne*ie+Ne*M}ce<ee&&(pe+=(ee-ce)*ie,ce=ee);const Ie=Math.min(te.end,B);for(let Ne=ce;Ne<=Ie&&!(pe>=y);Ne++)q.push({data:O==null?void 0:O[Ne],index:Ne,offset:pe,size:ie}),pe+=ie+M}}),ue=ao(F,sr),ge=ao(F,ar);if(ne.length>0&&(ue>0||ge>0)){const q=ne[0],te=ne[ne.length-1];if(ue>0&&q.index>ee){const me=Math.min(ue,q.index-ee),pe=[];let ce=q.offset;for(let ie=q.index-1;ie>=q.index-me;ie--){const Ie=($=(z=$t(K,ie,ie)[0])==null?void 0:z.value)!=null?$:q.size;ce-=Ie+M,pe.unshift({data:O==null?void 0:O[ie],index:ie,offset:ce,size:Ie})}ne.unshift(...pe)}if(ge>0&&te.index<B){const me=Math.min(ge,B-te.index);let pe=te.offset+te.size+M;for(let ce=te.index+1;ce<=te.index+me;ce++){const ie=(P=(Q=$t(K,ce,ce)[0])==null?void 0:Q.value)!=null?P:te.size;ne.push({data:O==null?void 0:O[ce],index:ce,offset:pe,size:ie}),pe+=ie+M}}}return Sr(ne,Y,k,M,V,E)}),se(p=>p!==null),be()),Qr);J(L(e,se(Rn),G(p=>p==null?void 0:p.length)),s),J(L(I,G(p=>p.topListHeight)),u),J(u,l),J(L(I,G(p=>[p.top,p.bottom])),i),J(L(I,G(p=>p.items)),x);const N=Ke(L(I,se(({items:p})=>p.length>0),de(s,e),se(([{items:p},y])=>p[p.length-1].originalIndex===y-1),G(([,p,y])=>[p-1,y]),be(rr),G(([p])=>p))),S=Ke(L(I,pt(200),se(({items:p,topItems:y})=>p.length>0&&p[0].originalIndex===y.length),G(({items:p})=>p[0].index),be())),R=Ke(L(I,se(({items:p})=>p.length>0),G(({items:p})=>{let y=0,k=p.length-1;for(;p[y].type==="group"&&y<k;)y++;for(;p[k].type==="group"&&k>y;)k--;return{endIndex:p[k].index,startIndex:p[y].index}}),be(xs)));return{endReached:N,initialItemCount:w,itemsRendered:x,listState:I,minOverscanItemCount:g,rangeChanged:R,startReached:S,topItemsIndexes:j,...h}},we(mt,ws,Hn,fr,ur,mr,Ct,Mn),{singleton:!0}),ks=xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:o},{listState:s}])=>{const a=fe(),i=Be(L(Ee(r,e,o,t,s),G(([l,d,c,f,u])=>l+d+c+f+u.offsetBottom+u.bottom)),0);return J(oe(i),a),{totalListHeight:i,totalListHeightChanged:a}},we(We,Ht),{singleton:!0}),kl=xe(([{viewportHeight:e},{totalListHeight:t}])=>{const r=H(!1),o=Be(L(Ee(r,e,t),se(([s])=>s),G(([,s,a])=>Math.max(0,s-a)),pt(0),be()),0);return{alignToBottom:r,paddingTopAddition:o}},we(We,ks),{singleton:!0}),Ss=xe(()=>({context:H(null)})),Sl=({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,Cs=xe(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:i,scrollTop:l,viewportHeight:d},{scrollToIndex:c}])=>{const f=fe();return J(L(f,de(t,d,r,a,s,o,l),de(e),G(([[u,h,v,b,j,w,x,g],I])=>{const{align:N,behavior:S,calculateViewLocation:R=Sl,done:p,...y}=u,k=bs(u,h,b-1),T=nr(k,h.offsetTree,I)+j+w,D=T+nt(h.sizeTree,k)[1],_=g+w,C=g+v-x,E=R({itemBottom:D,itemTop:T,locationParams:{align:N,behavior:S,...y},viewportBottom:C,viewportTop:_});return E?p&&tt(L(i,se(M=>!M),_t(Se(i)?1:2)),p):p==null||p(),E}),se(u=>u!==null)),c),{scrollIntoView:f}},we(mt,We,ur,Ht,St),{singleton:!0});function io(e){return e?e==="smooth"?"smooth":"auto":!1}const Cl=(e,t)=>typeof e=="function"?io(e(t)):t&&io(e),Tl=xe(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:o},{atBottomState:s,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:d,propsReady:c},{log:f},{scrollingInProgress:u},{context:h},{scrollIntoView:v}])=>{const b=H(!1),j=fe();let w=null;function x(S){le(i,{align:"end",behavior:S,index:"LAST"})}ve(L(Ee(L(oe(t),_t(1)),d),de(oe(b),a,l,u),G(([[S,R],p,y,k,T])=>{let D=R&&k,_="auto";return D&&(_=Cl(p,y||T),D=D&&!!_),{followOutputBehavior:_,shouldFollow:D,totalCount:S}}),se(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:R})=>{w&&(w(),w=null),Se(r)?requestAnimationFrame(()=>{Se(f)("following output to ",{totalCount:R},Ge.DEBUG),x(S)}):w=tt(e,()=>{Se(f)("following output to ",{totalCount:R},Ge.DEBUG),x(S),w=null})});function g(S){const R=tt(s,p=>{S&&!p.atBottom&&p.notAtBottomBecause==="SIZE_INCREASED"&&!w&&(Se(f)("scrolling to bottom due to increased size",{},Ge.DEBUG),x("auto"))});setTimeout(R,100)}ve(L(Ee(oe(b),t,c),se(([S,,R])=>S&&R),ut(({value:S},[,R])=>({refreshed:S===R,value:R}),{refreshed:!1,value:0}),se(({refreshed:S})=>S),de(b,t)),([,S])=>{Se(l)&&g(S!==!1)}),ve(j,()=>{g(Se(b)!==!1)}),ve(Ee(oe(b),s),([S,R])=>{S&&!R.atBottom&&R.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&x("auto")});const I=H(null),N=fe();return J(yn(L(oe(o),G(S=>{var R;return(R=S==null?void 0:S.length)!=null?R:0})),L(oe(t))),N),ve(L(Ee(L(N,_t(1)),d),de(oe(I),l,u,h),G(([[S,R],p,y,k,T])=>R&&y&&(p==null?void 0:p({context:T,totalCount:S,scrollingInProgress:k}))),se(S=>!!S),pt(0)),S=>{w&&(w(),w=null),Se(r)?requestAnimationFrame(()=>{Se(f)("scrolling into view",{}),le(v,S)}):w=tt(e,()=>{Se(f)("scrolling into view",{}),le(v,S),w=null})}),{autoscrollToBottom:j,followOutput:b,scrollIntoViewOnChange:I}},we(mt,mr,ur,fr,Ct,St,We,Ss,Cs)),El=xe(([{data:e,firstItemIndex:t,gap:r,sizes:o},{initialTopMostItemIndex:s},{initialItemCount:a,listState:i},{didMount:l}])=>(J(L(l,de(a),se(([,d])=>d!==0),de(s,o,t,r,e),G(([[,d],c,f,u,h,v=[]])=>js(d,c,f,u,h,v))),i),{}),we(mt,fr,Ht,Ct),{singleton:!0}),Rl=xe(([{didMount:e},{scrollTo:t},{listState:r}])=>{const o=H(0);return ve(L(e,de(o),se(([,s])=>s!==0),G(([,s])=>({top:s}))),s=>{tt(L(r,_t(1),se(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{le(t,s)})})}),{initialScrollTop:o}},we(Ct,We,Ht),{singleton:!0}),Ts=xe(([{scrollVelocity:e}])=>{const t=H(!1),r=fe(),o=H(!1);return J(L(e,de(o,t,r),se(([s,a])=>!!a),G(([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}),be()),t),ve(L(Ee(t,e,r),de(o)),([[s,a,i],l])=>{s&&l&&l.change&&l.change(a,i)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:r,scrollVelocity:e}},we(mr),{singleton:!0}),Fn=xe(([{scrollContainerState:e,scrollTo:t}])=>{const r=fe(),o=fe(),s=fe(),a=H(!1),i=H(void 0);return J(L(Ee(r,o),G(([{scrollHeight:l,scrollTop:d,viewportHeight:c},{offsetTop:f}])=>({scrollHeight:l,scrollTop:Math.max(0,d-f),viewportHeight:c}))),e),J(L(t,de(o),G(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),s),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:o}},we(We)),Al=xe(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:o},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:d}])=>{const c=fe(),f=H(void 0),u=H(null),h=H(null);return J(l,u),J(d,h),ve(L(c,de(t,o,i,u,h,r)),([v,b,j,w,x,g,I])=>{const N=pl(b.sizeTree);w&&x!==null&&g!==null&&(j=x.scrollTop-g.offsetTop),j-=I,v({ranges:N,scrollTop:j})}),J(L(f,se(Rn),G(Dl)),s),J(L(a,de(f),se(([,v])=>v!==void 0),be(),G(([,v])=>v.ranges)),e),{getState:c,restoreStateFrom:f}},we(mt,We,fr,Ct,Fn));function Dl(e){return{align:"start",index:0,offset:e.scrollTop}}const Ml=xe(([{topItemsIndexes:e}])=>{const t=H(0);return J(L(t,se(r=>r>=0),G(r=>Array.from({length:r}).map((o,s)=>s))),e),{topItemCount:t}},we(Ht));function Es(e){let t=!1,r;return(()=>(t||(t=!0,r=e()),r))}const _l=Es(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Ll=xe(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:o},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:l},{listState:d},{beforeUnshiftWith:c,gap:f,shiftWithOffset:u,sizes:h},{log:v},{recalcInProgress:b}])=>{const j=Ke(L(d,de(i),ut(([,x,g,I],[{bottom:N,items:S,offsetBottom:R,totalCount:p},y])=>{const k=N+R;let T=0;return g===p&&x.length>0&&S.length>0&&(S[0].originalIndex===0&&x[0].originalIndex===0||(T=k-I,T!==0&&(T+=y))),[T,S,p,k]},[0,[],0,0]),se(([x])=>x!==0),de(o,l,r,s,v,b),se(([,x,g,I,,,N])=>!N&&!I&&x!==0&&g===or),G(([[x],,,,,g])=>(g("Upward scrolling compensation",{amount:x},Ge.DEBUG),x))));function w(x){x>0?(le(t,{behavior:"auto",top:-x}),le(e,0)):(le(e,0),le(t,{behavior:"auto",top:-x}))}return ve(L(j,de(e,a)),([x,g,I])=>{I&&_l()?le(e,g-x):w(-x)}),ve(L(Ee(Be(a,!1),e,b),se(([x,g,I])=>!x&&!I&&g!==0),G(([x,g])=>g),pt(1)),w),J(L(u,G(x=>({top:-x}))),t),ve(L(c,de(h,f),G(([x,{groupIndices:g,lastSize:I,sizeTree:N},S])=>{function R(p){return p*(I+S)}if(g.length===0)return R(x);{let p=0;const y=tr(N,0);let k=0,T=0;for(;k<x;){k++,p+=y;let D=g.length===T+1?1/0:g[T+1]-g[T]-1;k+D>x&&(p-=y,D=x-k+1),k+=D,p+=R(D),T++}return p}})),x=>{le(e,x),requestAnimationFrame(()=>{le(t,{top:x}),requestAnimationFrame(()=>{le(e,0),le(b,!1)})})}),{deviation:e}},we(We,mr,Ht,mt,St,Mn)),Ol=xe(([e,t,r,o,s,a,i,l,d,c,f])=>({...e,...t,...r,...o,...s,...a,...i,...l,...d,...c,...f}),we(Hn,El,Ct,Ts,ks,Rl,kl,Fn,Cs,St,Ss)),Rs=xe(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:o,fixedGroupSize:s,gap:a,groupIndices:i,heightEstimates:l,itemSize:d,sizeRanges:c,sizes:f,statefulTotalCount:u,totalCount:h,trackItemSizes:v},{initialItemFinalLocationReached:b,initialTopMostItemIndex:j,scrolledToInitialItem:w},x,g,I,N,{scrollToIndex:S},R,{topItemCount:p},{groupCounts:y},k])=>{const{listState:T,minOverscanItemCount:D,topItemsIndexes:_,rangeChanged:C,...E}=N;return J(C,k.scrollSeekRangeChanged),J(L(k.windowViewportRect,G(M=>M.visibleHeight)),x.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:p,topItemsIndexes:_,totalCount:h,...I,groupIndices:i,itemSize:d,listState:T,minOverscanItemCount:D,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:v,rangeChanged:C,...E,...k,...x,sizes:f,...g}},we(mt,fr,We,Al,Tl,Ht,ur,Ll,Ml,ws,Ol));function Hl(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 yr=typeof document<"u"?X.useLayoutEffect:X.useEffect;function As(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=X.createContext({});function d(w,x){w.propsReady&&le(w.propsReady,!1);for(const g of o){const I=w[t.required[g]];le(I,x[g])}for(const g of s)if(g in x){const I=w[t.optional[g]];le(I,x[g])}w.propsReady&&le(w.propsReady,!0)}function c(w){return a.reduce((x,g)=>(x[g]=I=>{const N=w[t.methods[g]];le(N,I)},x),{})}function f(w){return i.reduce((x,g)=>(x[g]=Qi(w[t.events[g]]),x),{})}const u=X.forwardRef((w,x)=>{const{children:g,...I}=w,[N]=X.useState(()=>zr(tl(e),p=>{d(p,I)})),[S]=X.useState(Xn(f,N));yr(()=>{for(const p of i)p in I&&ve(S[p],I[p]);return()=>{Object.values(S).map(An)}},[I,S,N]),yr(()=>{d(N,I)}),X.useImperativeHandle(x,Zn(c(N)));const R=r;return n.jsx(l.Provider,{value:N,children:r?n.jsx(R,{...Hl([...o,...s,...i],I),children:g}):g})}),h=w=>{const x=X.useContext(l);return X.useCallback(g=>{le(x[w],g)},[x,w])},v=w=>{const x=X.useContext(l)[w],g=X.useCallback(I=>ve(x,I),[x]);return X.useSyncExternalStore(g,()=>Se(x),()=>Se(x))},b=w=>{const x=X.useContext(l)[w],[g,I]=X.useState(Xn(Se,x));return yr(()=>ve(x,N=>{N!==g&&I(Zn(N))}),[x,g]),g},j=X.version.startsWith("18")?v:b;return{Component:u,useEmitter:(w,x)=>{const g=X.useContext(l)[w];yr(()=>ve(g,x),[x,g])},useEmitterValue:j,usePublisher:h}}const Ds=X.createContext(void 0),Ms=X.createContext(void 0),_s=typeof document<"u"?X.useLayoutEffect:X.useEffect;function en(e){return"self"in e}function Fl(e){return"body"in e}function Ls(e,t,r,o=Ut,s,a){const i=X.useRef(null),l=X.useRef(null),d=X.useRef(null),c=X.useCallback(h=>{let v,b,j;const w=h.target;if(Fl(w)||en(w)){const g=en(w)?w:w.defaultView;j=a?g.scrollX:g.scrollY,v=a?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight,b=a?g.innerWidth:g.innerHeight}else j=a?w.scrollLeft:w.scrollTop,v=a?w.scrollWidth:w.scrollHeight,b=a?w.offsetWidth:w.offsetHeight;const x=()=>{e({scrollHeight:v,scrollTop:Math.max(j,0),viewportHeight:b})};h.suppressFlushSync?x():qo.flushSync(x),l.current!==null&&(j===l.current||j<=0||j===v-b)&&(l.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);X.useEffect(()=>{const h=s||i.current;return o(s||i.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{o(null),h.removeEventListener("scroll",c)}},[i,c,r,o,s]);function f(h){const v=i.current;if(!v||(a?"offsetWidth"in v&&v.offsetWidth===0:"offsetHeight"in v&&v.offsetHeight===0))return;const b=h.behavior==="smooth";let j,w,x;en(v)?(w=Math.max(Nt(v.document.documentElement,a?"width":"height"),a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight),j=a?v.innerWidth:v.innerHeight,x=a?window.scrollX:window.scrollY):(w=v[a?"scrollWidth":"scrollHeight"],j=Nt(v,a?"width":"height"),x=v[a?"scrollLeft":"scrollTop"]);const g=w-j;if(h.top=Math.ceil(Math.max(Math.min(g,h.top),0)),Ns(j,w)||h.top===x){e({scrollHeight:w,scrollTop:x,viewportHeight:j}),b&&t(!0);return}b?(l.current=h.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,t(!0)},1e3)):l.current=null,a&&(h={behavior:h.behavior,left:h.top}),v.scrollTo(h)}function u(h){a&&(h={behavior:h.behavior,left:h.top}),i.current.scrollBy(h)}return{scrollByCallback:u,scrollerRef:i,scrollToCallback:f}}const tn="-webkit-sticky",lo="sticky",Pn=Es(()=>{if(typeof document>"u")return lo;const e=document.createElement("div");return e.style.position=tn,e.style.position===tn?tn:lo});function Bn(e){return e}const Pl=xe(()=>{const e=H(l=>`Item ${l}`),t=H(l=>`Group ${l}`),r=H({}),o=H(Bn),s=H("div"),a=H(Ut),i=(l,d=null)=>Be(L(r,G(c=>c[l]),be()),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")}}),Bl=xe(([e,t])=>({...e,...t}),we(Rs,Pl)),zl=({height:e})=>n.jsx("div",{style:{height:e}}),Wl={overflowAnchor:"none",position:Pn(),zIndex:1},Os={overflowAnchor:"none"},$l={...Os,display:"inline-block",height:"100%"},co=X.memo(function({showTopList:e=!1}){const t=ae("listState"),r=Xe("sizeRanges"),o=ae("useWindowScroll"),s=ae("customScrollParent"),a=Xe("windowScrollContainerState"),i=Xe("scrollContainerState"),l=s||o?a:i,d=ae("itemContent"),c=ae("context"),f=ae("groupContent"),u=ae("trackItemSizes"),h=ae("itemSize"),v=ae("log"),b=Xe("gap"),j=ae("horizontalDirection"),{callbackRef:w}=ol(r,h,u,e?Ut:l,v,b,s,j,ae("skipAnimationFrameInResizeObserver")),[x,g]=X.useState(0);zn("deviation",E=>{x!==E&&g(E)});const I=ae("EmptyPlaceholder"),N=ae("ScrollSeekPlaceholder")||zl,S=ae("ListComponent"),R=ae("ItemComponent"),p=ae("GroupComponent"),y=ae("computeItemKey"),k=ae("isSeeking"),T=ae("groupIndices").length>0,D=ae("alignToBottom"),_=ae("initialItemFinalLocationReached"),C=e?{}:{boxSizing:"border-box",...j?{display:"inline-block",height:"100%",marginLeft:x!==0?x:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:x!==0?x:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},..._?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&I?n.jsx(I,{...Pe(I,c)}):n.jsx(S,{...Pe(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:C,children:(e?t.topItems:t.items).map(E=>{const M=E.originalIndex,F=y(M+t.firstItemIndex,E.data,c);return k?m.createElement(N,{...Pe(N,c),height:E.size,index:E.index,key:F,type:E.type||"item",...E.type==="group"?{}:{groupIndex:E.groupIndex}}):E.type==="group"?m.createElement(p,{...Pe(p,c),"data-index":M,"data-item-index":E.index,"data-known-size":E.size,key:F,style:Wl},f(E.index,c)):m.createElement(R,{...Pe(R,c),...Kl(R,E.data),"data-index":M,"data-item-group-index":E.groupIndex,"data-item-index":E.index,"data-known-size":E.size,key:F,style:j?$l:Os},T?d(E.index,E.groupIndex,E.data,c):d(E.index,E.data,c))})})}),Vl={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Gl={outline:"none",overflowX:"auto",position:"relative"},$r=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Ul={position:Pn(),top:0,width:"100%",zIndex:1};function Pe(e,t){if(typeof e!="string")return{context:t}}function Kl(e,t){return{item:typeof e=="string"?void 0:t}}const ql=X.memo(function(){const e=ae("HeaderComponent"),t=Xe("headerHeight"),r=ae("HeaderFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,ae("skipAnimationFrameInResizeObserver")),s=ae("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null}),Yl=X.memo(function(){const e=ae("FooterComponent"),t=Xe("footerHeight"),r=ae("HeaderFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,ae("skipAnimationFrameInResizeObserver")),s=ae("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null});function Hs({useEmitter:e,useEmitterValue:t,usePublisher:r}){return X.memo(function({children:o,style:s,context:a,...i}){const l=r("scrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),f=t("scrollerRef"),u=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:v,scrollToCallback:b}=Ls(l,c,d,f,void 0,u);return e("scrollTo",b),e("scrollBy",h),n.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:v,style:{...u?Gl:Vl,...s},tabIndex:0,...i,...Pe(d,a),children:o})})}function Fs({useEmitter:e,useEmitterValue:t,usePublisher:r}){return X.memo(function({children:o,style:s,context:a,...i}){const l=r("windowScrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),f=t("totalListHeight"),u=t("deviation"),h=t("customScrollParent"),v=X.useRef(null),b=t("scrollerRef"),{scrollByCallback:j,scrollerRef:w,scrollToCallback:x}=Ls(l,c,d,b,h);return _s(()=>{var g;return w.current=h||((g=v.current)==null?void 0:g.ownerDocument.defaultView),()=>{w.current=null}},[w,h]),e("windowScrollTo",x),e("scrollBy",j),n.jsx(d,{ref:v,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...f!==0?{height:f+u}:{}},...i,...Pe(d,a),children:o})})}const Zl=({children:e})=>{const t=X.useContext(Ds),r=Xe("viewportHeight"),o=Xe("fixedItemHeight"),s=ae("alignToBottom"),a=ae("horizontalDirection"),i=X.useMemo(()=>cs(r,d=>Nt(d,a?"width":"height")),[r,a]),l=Ot(i,!0,ae("skipAnimationFrameInResizeObserver"));return X.useEffect(()=>{t&&(r(t.viewportHeight),o(t.itemHeight))},[t,r,o]),n.jsx("div",{"data-viewport-type":"element",ref:l,style:$r(s),children:e})},Xl=({children:e})=>{const t=X.useContext(Ds),r=Xe("windowViewportRect"),o=Xe("fixedItemHeight"),s=ae("customScrollParent"),a=us(r,s,ae("skipAnimationFrameInResizeObserver")),i=ae("alignToBottom");return X.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:$r(i),children:e})},Jl=({children:e})=>{const t=ae("TopItemListComponent")||"div",r=ae("headerHeight"),o={...Ul,marginTop:`${r}px`},s=ae("context");return n.jsx(t,{style:o,...Pe(t,s),children:e})},Ql=X.memo(function(e){const t=ae("useWindowScroll"),r=ae("topItemsIndexes").length>0,o=ae("customScrollParent"),s=ae("context");return n.jsxs(o||t?rc:tc,{...e,context:s,children:[r&&n.jsx(Jl,{children:n.jsx(co,{showTopList:!0})}),n.jsxs(o||t?Xl:Zl,{children:[n.jsx(ql,{}),n.jsx(co,{}),n.jsx(Yl,{})]})]})}),{Component:ec,useEmitter:zn,useEmitterValue:ae,usePublisher:Xe}=As(Bl,{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"}},Ql),tc=Hs({useEmitter:zn,useEmitterValue:ae,usePublisher:Xe}),rc=Fs({useEmitter:zn,useEmitterValue:ae,usePublisher:Xe}),nc=ec,oc=xe(()=>{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(Bn),l=H(Ut),d=(c,f=null)=>Be(L(a,G(u=>u[c]),be()),f);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")}});we(Rs,oc);Pn();const uo={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},sc={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:fo,floor:Lr,max:Qt,min:rn,round:mo}=Math;function po(e,t,r){return Array.from({length:t-e+1}).map((o,s)=>({data:r===null?null:r[s+e],index:s+e}))}function ac(e){return{...sc,items:e}}function br(e,t){return e&&e.width===t.width&&e.height===t.height}function ic(e,t){return e&&e.column===t.column&&e.row===t.row}const lc=xe(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:o},{footerHeight:s,headerHeight:a,scrollBy:i,scrollContainerState:l,scrollTo:d,scrollTop:c,smoothScrollTargetReached:f,viewportHeight:u},h,v,{didMount:b,propsReady:j},{customScrollParent:w,useWindowScroll:x,windowScrollContainerState:g,windowScrollTo:I,windowViewportRect:N},S])=>{const R=H(0),p=H(0),y=H(uo),k=H({height:0,width:0}),T=H({height:0,width:0}),D=fe(),_=fe(),C=H(0),E=H(null),M=H({column:0,row:0}),F=fe(),O=fe(),z=H(!1),$=H(0),Q=H(!0),P=H(!1),V=H(!1);ve(L(b,de($),se(([A,B])=>!!B)),()=>{le(Q,!1)}),ve(L(Ee(b,Q,T,k,$,P),se(([A,B,ne,ue,,ge])=>A&&!B&&ne.height!==0&&ue.height!==0&&!ge)),([,,,,A])=>{le(P,!0),Ln(1,()=>{le(D,A)}),tt(L(c),()=>{le(t,[0,0]),le(Q,!0)})}),J(L(O,se(A=>A!=null&&A.scrollTop>0),it(0)),p),ve(L(b,de(O),se(([,A])=>A!=null)),([,A])=>{A&&(le(k,A.viewport),le(T,A.item),le(M,A.gap),A.scrollTop>0&&(le(z,!0),tt(L(c,_t(1)),B=>{le(z,!1)}),le(d,{top:A.scrollTop})))}),J(L(k,G(({height:A})=>A)),u),J(L(Ee(oe(k,br),oe(T,br),oe(M,(A,B)=>A&&A.column===B.column&&A.row===B.row),oe(c)),G(([A,B,ne,ue])=>({gap:ne,item:B,scrollTop:ue,viewport:A}))),F),J(L(Ee(oe(R),o,oe(M,ic),oe(T,br),oe(k,br),oe(E),oe(p),oe(z),oe(Q),oe($)),se(([,,,,,,,A])=>!A),G(([A,[B,ne],ue,ge,q,te,me,,pe,ce])=>{const{column:ie,row:Ie}=ue,{height:Ne,width:Qe}=ge,{width:st}=q;if(me===0&&(A===0||st===0))return uo;if(Qe===0){const Fe=On(ce,A),De=Fe+Math.max(me-1,0);return ac(po(Fe,De,te))}const at=Ps(st,Qe,ie);let Ye,Ce;pe?B===0&&ne===0&&me>0?(Ye=0,Ce=me-1):(Ye=at*Lr((B+Ie)/(Ne+Ie)),Ce=at*fo((ne+Ie)/(Ne+Ie))-1,Ce=rn(A-1,Qt(Ce,at-1)),Ye=rn(Ce,Qt(0,Ye))):(Ye=0,Ce=-1);const Z=po(Ye,Ce,te),{bottom:je,top:Te}=ho(q,ue,ge,Z),_e=fo(A/at),Le=_e*Ne+(_e-1)*Ie-je;return{bottom:je,itemHeight:Ne,items:Z,itemWidth:Qe,offsetBottom:Le,offsetTop:Te,top:Te}})),y),J(L(E,se(A=>A!==null),G(A=>A.length)),R),J(L(Ee(k,T,y,M),se(([A,B,{items:ne}])=>ne.length>0&&B.height!==0&&A.height!==0),G(([A,B,{items:ne},ue])=>{const{bottom:ge,top:q}=ho(A,ue,B,ne);return[q,ge]}),be(rr)),t);const W=H(!1);J(L(c,de(W),G(([A,B])=>B||A!==0)),W);const K=Ke(L(Ee(y,R),se(([{items:A}])=>A.length>0),de(W),se(([[A,B],ne])=>{const ue=A.items[A.items.length-1].index===B-1;return(ne||A.bottom>0&&A.itemHeight>0&&A.offsetBottom===0&&A.items.length===B)&&ue}),G(([[,A]])=>A-1),be())),U=Ke(L(oe(y),se(({items:A})=>A.length>0&&A[0].index===0),it(0),be())),Y=Ke(L(oe(y),de(z),se(([{items:A},B])=>A.length>0&&!B),G(([{items:A}])=>({endIndex:A[A.length-1].index,startIndex:A[0].index})),be(xs),pt(0)));J(Y,v.scrollSeekRangeChanged),J(L(D,de(k,T,R,M),G(([A,B,ne,ue,ge])=>{const q=Is(A),{align:te,behavior:me,offset:pe}=q;let ce=q.index;ce==="LAST"&&(ce=ue-1),ce=Qt(0,ce,rn(ue-1,ce));let ie=jn(B,ge,ne,ce);return te==="end"?ie=mo(ie-B.height+ne.height):te==="center"&&(ie=mo(ie-B.height/2+ne.height/2)),pe&&(ie+=pe),{behavior:me,top:ie}})),d);const ee=Be(L(y,G(A=>A.offsetBottom+A.bottom)),0);return J(L(N,G(A=>({height:A.visibleHeight,width:A.visibleWidth}))),k),{customScrollParent:w,data:E,deviation:C,footerHeight:s,gap:M,headerHeight:a,increaseViewportBy:e,initialItemCount:p,itemDimensions:T,overscan:r,restoreStateFrom:O,scrollBy:i,scrollContainerState:l,scrollHeight:_,scrollTo:d,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:f,totalCount:R,useWindowScroll:x,viewportDimensions:k,windowScrollContainerState:g,windowScrollTo:I,windowViewportRect:N,...v,gridState:y,horizontalDirection:V,initialTopMostItemIndex:$,totalListHeight:ee,...h,endReached:K,propsReady:j,rangeChanged:Y,startReached:U,stateChanged:F,stateRestoreInProgress:z,...S}},we(Hn,We,mr,Ts,Ct,Fn,St));function Ps(e,t,r){return Qt(1,Lr((e+r)/(Lr(t)+r)))}function ho(e,t,r,o){const{height:s}=r;if(s===void 0||o.length===0)return{bottom:0,top:0};const a=jn(e,t,r,o[0].index);return{bottom:jn(e,t,r,o[o.length-1].index)+s,top:a}}function jn(e,t,r,o){const s=Ps(e.width,r.width,t.column),a=Lr(o/s),i=a*r.height+Qt(0,a-1)*t.row;return i>0?i+t.row:i}const cc=xe(()=>{const e=H(u=>`Item ${u}`),t=H({}),r=H(null),o=H("virtuoso-grid-item"),s=H("virtuoso-grid-list"),a=H(Bn),i=H("div"),l=H(Ut),d=(u,h=null)=>Be(L(t,G(v=>v[u]),be()),h),c=H(!1),f=H(!1);return J(oe(f),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:f,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),dc=xe(([e,t])=>({...e,...t}),we(lc,cc)),uc=X.memo(function(){const e=ke("gridState"),t=ke("listClassName"),r=ke("itemClassName"),o=ke("itemContent"),s=ke("computeItemKey"),a=ke("isSeeking"),i=Je("scrollHeight"),l=ke("ItemComponent"),d=ke("ListComponent"),c=ke("ScrollSeekPlaceholder"),f=ke("context"),u=Je("itemDimensions"),h=Je("gap"),v=ke("log"),b=ke("stateRestoreInProgress"),j=Je("reportReadyState"),w=Ot(X.useMemo(()=>x=>{const g=x.parentElement.parentElement.scrollHeight;i(g);const I=x.firstChild;if(I){const{height:N,width:S}=I.getBoundingClientRect();u({height:N,width:S})}h({column:go("column-gap",getComputedStyle(x).columnGap,v),row:go("row-gap",getComputedStyle(x).rowGap,v)})},[i,u,h,v]),!0,!1);return _s(()=>{e.itemHeight>0&&e.itemWidth>0&&j(!0)},[e]),b?null:n.jsx(d,{className:t,ref:w,...Pe(d,f),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(x=>{const g=s(x.index,x.data,f);return a?n.jsx(c,{...Pe(c,f),height:e.itemHeight,index:x.index,width:e.itemWidth},g):m.createElement(l,{...Pe(l,f),className:r,"data-index":x.index,key:g},o(x.index,x.data,f))})})}),fc=X.memo(function(){const e=ke("HeaderComponent"),t=Je("headerHeight"),r=ke("headerFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,!1),s=ke("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null}),mc=X.memo(function(){const e=ke("FooterComponent"),t=Je("footerHeight"),r=ke("headerFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,!1),s=ke("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null}),pc=({children:e})=>{const t=X.useContext(Ms),r=Je("itemDimensions"),o=Je("viewportDimensions"),s=Ot(X.useMemo(()=>a=>{o(a.getBoundingClientRect())},[o]),!0,!1);return X.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:$r(!1),children:e})},hc=({children:e})=>{const t=X.useContext(Ms),r=Je("windowViewportRect"),o=Je("itemDimensions"),s=ke("customScrollParent"),a=us(r,s,!1);return X.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:$r(!1),children:e})},gc=X.memo(function({...e}){const t=ke("useWindowScroll"),r=ke("customScrollParent"),o=r||t?vc:xc,s=r||t?hc:pc,a=ke("context");return n.jsx(o,{...e,...Pe(o,a),children:n.jsxs(s,{children:[n.jsx(fc,{}),n.jsx(uc,{}),n.jsx(mc,{})]})})}),{useEmitter:Bs,useEmitterValue:ke,usePublisher:Je}=As(dc,{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"}},gc),xc=Hs({useEmitter:Bs,useEmitterValue:ke,usePublisher:Je}),vc=Fs({useEmitter:Bs,useEmitterValue:ke,usePublisher:Je});function go(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Ge.WARN),t==="normal"?0:parseInt(t??"0",10)}function ir(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function Or({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(()=>{he.success("Copied to clipboard")}).catch(()=>{he.error("Failed to copy")})},children:n.jsx(lr,{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 yc=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),Wn={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},zs="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function bc(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function wc(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Ic(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 Nc(e,t){var s;const r=new Map;if(e)for(const a of e){const i=cr(String(a.stepName));r.set(a.stepId,(i==null?void 0:i.shortName)??a.stepName)}const o=t!=null&&t.workflowName?((s=It(t.workflowName))==null?void 0:s.shortName)??t.workflowName:null;return{correlationNameMap:r,workflowName:o}}function jc(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 kn(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 Sn=36,kc=20,nn="var(--ds-gray-500)";function xo({isFirst:e,isLast:t,isRunLevel:r,statusDotColor:o,pulse:s=!1,hasSelection:a,showBranch:i,showLaneLine:l,isLaneStart:d,isLaneEnd:c,continuationOnly:f=!1}){const u=r?8:6,h=r?5:6,v=a&&!i&&!r?.3:1;return n.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:Sn,minHeight:f?0:void 0},children:[n.jsx("div",{style:{position:"absolute",left:8,top:f?0:e?"50%":0,bottom:f?0:t?"50%":0,width:2,backgroundColor:nn,zIndex:0}}),!f&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{position:"absolute",left:h,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*v,animation:zs,zIndex:1}}),n.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:o,opacity:v,transition:"opacity 150ms",zIndex:2}})]}),i&&n.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:Sn-9,height:2,backgroundColor:nn,zIndex:0}})]}),l&&n.jsx("div",{style:{position:"absolute",left:kc,top:f?0:d?"50%":0,bottom:f?0:c?"50%":0,width:2,backgroundColor:nn,zIndex:0}})]})}function vo({value:e,className:t}){const[r,o]=m.useState(!1),s=m.useRef(null);m.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const a=m.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:Wn,"aria-label":`Copy ${e}`,children:r?n.jsx(Jo,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):n.jsx(lr,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function Cr(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return Cr(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(Cr);if(e!==null&&typeof e=="object"){if(e.constructor!==Object)return e;const t={};for(const[r,o]of Object.entries(e))t[r]=Cr(o);return t}return e}function Sc(e,t){if(!t||!yc.has(t)||e==null||typeof e!="object")return null;const r=e;return ir(r.error)?r.error:ir(r)?r:null}function Cc({data:e,eventType:t}){const r=m.useMemo(()=>Sc(e,t),[e,t]),[o,s]=m.useState(!1),a=m.useRef(null),i=m.useMemo(()=>Cr(e),[e]);m.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const l=m.useMemo(()=>{try{return JSON.stringify(i,null,2)}catch{return String(i)}},[i]),d=m.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(Or,{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(Rr,{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:{...Wn,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:o?n.jsxs(n.Fragment,{children:[n.jsx(Jo,{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(lr,{className:"h-3 w-3"}),n.jsx("span",{children:"Copy"})]})})]})}function Tc({event:e,index:t,isFirst:r,isLast:o,activeGroupKey:s,selectedGroupKey:a,selectedGroupRange:i,correlationNameMap:l,workflowName:d,durationMap:c,onSelectGroup:f,onHoverGroup:u,onLoadEventData:h,encryptionKey:v}){const[b,j]=m.useState(!1),[w,x]=m.useState(!1),[g,I]=m.useState(null),[N,S]=m.useState(null),[R,p]=m.useState(!1),y=e.correlationId??(kn(e.eventType)?"__run__":void 0);m.useEffect(()=>{a!==void 0&&a!==y&&j(!1)},[a,y]);const k=Ic(e.eventType),T=new Date(e.createdAt),D="eventData"in e&&e.eventData!=null,_=kn(e.eventType),C=_?d??"-":e.correlationId?l.get(e.correlationId)??"-":"-",E=e.correlationId??(_?"__run__":""),M=E?c.get(E):void 0,F=s!==void 0,O=y!==void 0&&y===s,z=F&&!O,$=F&&O,Q=F&&O&&!_,P=i!==null&&t>=i.first&&t<=i.last,V=i!==null&&t===i.first,W=i!==null&&t===i.last,K=m.useCallback(async()=>{if(!(g!==null||D)){x(!0),S(null);try{if(!h){S("Event details unavailable");return}const B=await h(e);B!=null&&I(B)}catch(B){S(B instanceof Error?B.message:"Failed to load event details")}finally{x(!1),p(!0)}}},[e,g,D,h]);m.useEffect(()=>{v&&R&&h&&(I(null),p(!1),h(e).then(B=>{B!=null&&I(B),p(!0)}).catch(()=>{p(!0)}))},[v]);const U=m.useCallback(B=>{B.stopPropagation();const ne=!b;j(ne),ne&&g===null&&!D&&K()},[b,g,D,K]),Y=m.useCallback(()=>{f(a===y?void 0:y)},[a,y,f]),ee=D?e.eventData:g,A=z?.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:Y,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&Y()},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(xo,{isFirst:r,isLast:o&&!b,isRunLevel:_,statusDotColor:k,pulse:$,hasSelection:F,showBranch:Q,showLaneLine:P,isLaneStart:V,isLaneEnd:W}),n.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:A,transition:"opacity 150ms"},children:[n.jsx("button",{type:"button",onClick:U,className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded hover:bg-[var(--ds-gray-alpha-200)] transition-colors",style:{...Wn,border:"1px solid var(--ds-gray-alpha-400)"},"aria-label":b?"Collapse details":"Expand details",children:n.jsx(Xo,{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:bc(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:[$&&n.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:k,opacity:.75,animation:zs}}),n.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:k}})]}),wc(e.eventType)]})}),n.jsx("div",{className:"text-xs flex-1 min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",title:C!=="-"?C:void 0,children:C}),n.jsx(vo,{value:e.correlationId||"",className:"font-mono text-xs"}),n.jsx(vo,{value:e.eventId,className:"font-mono text-xs"})]})]}),b&&n.jsxs("div",{className:"flex",children:[n.jsx(xo,{isFirst:!1,isLast:o,isRunLevel:_,hasSelection:F,showBranch:!1,showLaneLine:P&&!W,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:A,transition:"opacity 150ms"},children:[((M==null?void 0:M.queued)!==void 0||(M==null?void 0:M.ran)!==void 0)&&n.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[M.queued!==void 0&&M.queued>0&&n.jsxs("span",{children:["Queued for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:Dt(M.queued)})]}),M.ran!==void 0&&n.jsxs("span",{children:["Ran for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:Dt(M.ran)})]})]}),ee!=null?n.jsx(Cc,{data:ee,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||!D&&!R&&e.correlationId?n.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[n.jsx(He,{className:"h-3",style:{width:"75%"}}),n.jsx(He,{className:"h-3",style:{width:"50%"}}),n.jsx(He,{className:"h-3",style:{width:"60%"}})]}):n.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function Ec({events:e,steps:t,run:r,onLoadEventData:o,hasMoreEvents:s=!1,isLoadingMoreEvents:a=!1,onLoadMoreEvents:i,encryptionKey:l}){const d=m.useMemo(()=>!e||e.length===0?[]:[...e].sort((y,k)=>new Date(y.createdAt).getTime()-new Date(k.createdAt).getTime()),[e]),{correlationNameMap:c,workflowName:f}=m.useMemo(()=>Nc(t??null,r??null),[t,r]),u=m.useMemo(()=>jc(d),[d]),[h,v]=m.useState(void 0),[b,j]=m.useState(void 0),w=m.useCallback(y=>{v(y)},[]),x=m.useCallback(y=>{j(y)},[]),g=h??b,I=m.useMemo(()=>{if(!g||g==="__run__")return null;let y=-1,k=-1;for(let T=0;T<d.length;T++)d[T].correlationId===g&&(y===-1&&(y=T),k=T);return y>=0?{first:y,last:k}:null},[g,d]),[N,S]=m.useState(""),R=m.useRef(null),p=m.useMemo(()=>{const y=[];for(let k=0;k<d.length;k++){const T=d[k];y.push({text:[T.eventId,T.correlationId??""].join(" ").toLowerCase(),groupKey:T.correlationId??(kn(T.eventType)?"__run__":void 0),eventId:T.eventId,index:k})}return y},[d]);return m.useEffect(()=>{var T;const y=N.trim().toLowerCase();if(!y){v(void 0);return}const k=p.find(D=>D.text.includes(y));k&&(v(k.groupKey),(T=R.current)==null||T.scrollToIndex({index:k.index,align:"center",behavior:"smooth"}))},[N,p]),!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:N,onChange:y=>S(y.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:Sn}}),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(nc,{ref:R,totalCount:d.length,overscan:20,defaultItemHeight:40,endReached:()=>{!s||a||i==null||i()},itemContent:y=>n.jsx(Tc,{event:d[y],index:y,isFirst:y===0,isLast:y===d.length-1,activeGroupKey:g,selectedGroupKey:h,selectedGroupRange:I,correlationNameMap:c,workflowName:f,durationMap:u,onSelectGroup:w,onHoverGroup:x,onLoadEventData:o,encryptionKey:l}),components:{Footer:()=>n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"px-3 pt-3 flex justify-center",children:n.jsx("button",{type:"button",onClick:()=>void(i==null?void 0:i()),disabled:a,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:a?"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:[d.length," event",d.length!==1?"s":""," total"]})]})},style:{flex:1,minHeight:0}})]})}function Rc({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(Ac,{message:t},r))})}function Ac({message:e}){const t=e.role,r=_c(e.content),o=Mc(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(Dc,{part:s,role:t},a))})]})}function Dc({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(hi,{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(Rr,{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(Rr,{data:e.output,expandLevel:1})})]}):null}function Mc(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 _c(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 Lc=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 Ws({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(Lc(e)).then(()=>{he.success("Copied to clipboard")}).catch(()=>{he.error("Failed to copy")})},children:n.jsx(lr,{size:12})}),n.jsx(Rr,{data:e})]})}function ze({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 ${s??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)"},children: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 Oc({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 Hc({tabs:e,activeTab:t,onTabChange:r,ariaLabel:o,children:s}){const a=m.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(Oc,{active:t===i.id,onClick:()=>r(i.id),children:i.label},i.id))}),n.jsx("div",{role:"tabpanel",children:s})]})}const Fc=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function Pc({conversation:e,args:t}){const[r,o]=m.useState("conversation");return n.jsx(ze,{summary:`Input (${e.length} messages)`,children:n.jsx(Hc,{tabs:Fc,activeTab:r,onTabChange:o,ariaLabel:"Conversation view",children:r==="conversation"?n.jsx(Rc,{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:$e(s)},a)):$e(t)})})})}function Kt(){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(os,{className:"h-3 w-3"}),n.jsx("span",{className:"font-medium",children:"Encrypted"})]})}function $e(e){return n.jsx(Ws,{data:e})}const yt=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,yo=["workflowName","moduleSpecifier","stepName","status","stepId","hookId","eventId","runId","attempt","token","correlationId","eventType","deploymentId","specVersion","workflowCoreVersion","ownerId","projectId","environment","executionContext","createdAt","startedAt","updatedAt","completedAt","expiredAt","retryAfter","error","metadata","eventData","input","output","resumeAt"],bo=(e,t)=>{const r=yo.indexOf(e)||0,o=yo.indexOf(t)||0;return r-o},Bc={workflowCoreVersion:"@workflow/core version"},zc=e=>Bc[e]??e,Wc=e=>{const t=String(e),r=cr(t);if(r)return r.moduleSpecifier;const o=It(t);return o?o.moduleSpecifier:t},$s=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},Vs=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),$c=e=>{const t=$s(e);return t?Vs(t):"-"},Et=e=>{const t=$s(e);return t?Vs(t):null},Yt={workflowName:e=>{var t;return((t=It(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>Wc(e),stepName:e=>{var t;return((t=cr(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),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:Et,startedAt:Et,updatedAt:Et,completedAt:Et,expiredAt:Et,retryAfter:Et,resumeAt:Et,metadata:e=>yt(e)?lt(e)?n.jsx(Kt,{}):$e(e):null,input:(e,t)=>{if(lt(e))return n.jsx(Kt,{});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=yt(a),f=yt(i),u=yt(s);if(t!=null&&t.stepName&&xi(t.stepName)){const h=vi(s);if(h&&h.length>0)return n.jsxs(n.Fragment,{children:[n.jsx(Pc,{conversation:h,args:s}),c&&n.jsx(ze,{summary:"Closure Variables",children:$e(a)}),f&&n.jsx(ze,{summary:"This Value",children:$e(i)})]})}return!u&&!c&&!f?n.jsx(ze,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):n.jsxs(n.Fragment,{children:[n.jsx(ze,{summary:`Input (${l} ${d})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(s)?s.map((h,v)=>n.jsx("div",{className:"mt-2 first:mt-0",children:$e(h)},v)):$e(s)}),c&&n.jsx(ze,{summary:"Closure Variables",children:$e(a)}),f&&n.jsx(ze,{summary:"this",children:$e(i)})]})}const r=Array.isArray(e)?e.length:0,o=r===1?"argument":"arguments";return yt(e)?n.jsx(ze,{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:$e(s)},a)):$e(e)}):n.jsx(ze,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>yt(e)?lt(e)?n.jsx(Kt,{}):n.jsx(ze,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:$e(e)}):null,error:e=>lt(e)?n.jsx(Kt,{}):yt(e)?ir(e)?n.jsx(ze,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:n.jsx(Or,{value:e})}):n.jsx(ze,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:$e(e)}):null,eventData:e=>lt(e)?n.jsx(Kt,{}):yt(e)?n.jsx(ze,{summary:"Event Data",children:$e(e)}):null},wo=["input","output","error","metadata","eventData"],Vc=()=>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."})}),Gc=({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(ze,{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(He,{className:"h-4 w-[38%]"}),n.jsx(He,{className:"mt-2 h-4 w-[88%]"}),n.jsx(He,{className:"mt-2 h-4 w-[72%]"})]})]})}const i=Yt[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},Uc=({data:e,moduleSpecifier:t,isLoading:r,error:o,expiredAt:s,onStreamClick:a})=>{const i=m.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=>!wo.includes(b)).sort(bo),c=Object.keys(i).filter(b=>wo.includes(b)).sort(bo),f=d.filter(b=>{const j=Yt[b];return j?j(i[b])!==null:!1}),u=m.useMemo(()=>{const b=[...f],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 x=b.indexOf("stepName");return x!==-1?(b.splice(x+1,0,"moduleSpecifier"),b):(b.unshift("moduleSpecifier"),b)},[f]),h=m.useMemo(()=>({stepName:i.stepName}),[i.stepName]),v=m.useCallback(b=>{navigator.clipboard.writeText(b).then(()=>{he.success("moduleSpecifier copied")}).catch(()=>{he.error("Failed to copy moduleSpecifier")})},[]);return n.jsx(gi.Provider,{value:a,children:n.jsxs("div",{children:[f.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 N;const w=(N=Yt[b])==null?void 0:N.call(Yt,i[b]),x=b==="moduleSpecifier",g=typeof w=="string"?w:String(w??i.moduleSpecifier??""),I=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:"text-[14px] first-letter:uppercase",style:{color:"var(--ds-gray-700)"},children:zc(b)}),x?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:()=>v(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})]}),I?n.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},b)})}),o?n.jsx(_a,{title:"Failed to load resource details",details:o.message,className:"my-4"}):l?n.jsx(Vc,{}):n.jsx(n.Fragment,{children:c.map(b=>n.jsx(Gc,{isLoading:r,attribute:b,value:i[b],context:h},b))})]})})},Kc=new Set(["step_failed","step_retrying"]),qc=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function Yc({event:e,onLoadEventData:t,encryptionKey:r}){const[o,s]=m.useState(null),[a,i]=m.useState(!1),[l,d]=m.useState(null),c=m.useRef(!1),f="eventData"in e&&e.eventData!=null?e.eventData:null,u=f??o,h=qc.has(e.eventType),v=m.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=m.useCallback(async()=>{f||o!==null||a||(c.current=!0,await v())},[f,o,a,v]);m.useEffect(()=>{r&&c.current&&o!==null&&(s(null),v())},[r]);const j=new Date(e.createdAt);return n.jsxs(ze,{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:$c(j.getTime())})]}),onToggle:h?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(He,{className:"h-4 w-[35%]"}),n.jsx(He,{className:"mt-2 h-4 w-[90%]"}),n.jsx(He,{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(Zc,{eventType:e.eventType,data:u})})]})}function Zc({eventType:e,data:t}){if(Kc.has(e)&&t!=null&&typeof t=="object"){const r=t;if(ir(r.error))return n.jsx(Or,{value:r.error});if(ir(r))return n.jsx(Or,{value:r})}return n.jsx(Ws,{data:t})}function Xc({events:e,isLoading:t=!1,error:r,onLoadEventData:o,encryptionKey:s}){const a=m.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(He,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(He,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(He,{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(Yc,{event:i,onLoadEventData:o,encryptionKey:s},i.eventId))}):null]})}function Jc(e){return e!==null&&typeof e=="object"&&"stepId"in e}function Qc(e){return e!==null&&typeof e=="object"&&"runId"in e}function wr(e){return e!==null&&typeof e=="object"&&"hookId"in e}function ed({run:e,hooks:t,onStreamClick:r,spanDetailData:o,spanDetailError:s,spanDetailLoading:a,onSpanSelect:i,onWakeUpSleep:l,onLoadEventData:d,onResolveHook:c,encryptionKey:f,selectedSpan:u}){const[h,v]=m.useState(!1),[b,j]=m.useState(!1),[w,x]=m.useState(!1),[g,I]=m.useState(new Set),N=u==null?void 0:u.data,S=u==null?void 0:u.rawEvents,R=(S==null?void 0:S.length)??0,{resource:p,resourceId:y,runId:k}=m.useMemo(()=>{if(!u)return{resource:void 0,resourceId:void 0,runId:void 0};const V=u.resource;return V==="step"&&Jc(N)?{resource:"step",resourceId:N.stepId,runId:N.runId}:V==="run"&&Qc(N)?{resource:"run",resourceId:N.runId,runId:void 0}:V==="hook"&&wr(N)?{resource:"hook",resourceId:N.hookId,runId:void 0}:V==="sleep"?{resource:"sleep",resourceId:u.spanId,runId:void 0}:{resource:void 0,resourceId:void 0,runId:void 0}},[u,N]);m.useEffect(()=>{p&&y&&["run","step","hook","sleep"].includes(p)&&i({resource:p,resourceId:y,runId:k})},[p,y,k,i]);const T=m.useMemo(()=>p!=="sleep"||!S||["completed","failed","cancelled"].includes(e.status)||!S.some(U=>U.eventType==="wait_created")?!1:!S.some(U=>U.eventType==="wait_completed"),[p,S,R,e.status]),D=m.useMemo(()=>!(p!=="hook"||!S||!y||g.has(y)||["completed","failed","cancelled"].includes(e.status)||S.some(K=>K.eventType==="hook_disposed")),[p,y,S,R,e.status,g]),_=s??void 0,C=a??!1,E=m.useMemo(()=>{if(p!=="hook"||!y)return;if(wr(o)&&o.token)return o.token;const V=t==null?void 0:t.find(W=>W.hookId===y);if(V!=null&&V.token)return V.token;if(wr(N)&&N.token)return N.token},[p,y,o,N,t]);m.useEffect(()=>{_&&u&&p&&he.error(`Failed to load ${p} details`,{description:_.message})},[_,p,u]);const M=async()=>{if(!(h||!y)){if(!l){he.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{v(!0),(await l(e.runId,y)).stoppedCount>0?he.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):he.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(V){console.error("Failed to wake up run:",V),he.error("Failed to wake up run",{description:V instanceof Error?V.message:"An unknown error occurred"})}finally{v(!1)}}},F=m.useCallback(async V=>{if(!w){if(!c){he.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!E){he.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{x(!0);const W=o??N,K=wr(W)?W:void 0;await c(E,V,K),he.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),j(!1),y&&I(U=>new Set(U).add(y))}catch(W){console.error("Failed to resolve hook:",W),he.error("Failed to resolve hook",{description:W instanceof Error?W.message:"An unknown error occurred"})}finally{x(!1)}}},[c,E,w,o,N]);if(!u||!p||!y)return null;const O=p==="sleep"?N:o??N,z=m.useMemo(()=>{const V=O,W=V.stepName,K=V.workflowName;if(typeof W=="string")return W;if(typeof K=="string")return K;if(typeof e.workflowName=="string")return e.workflowName},[O,e.workflowName]),$=p.charAt(0).toUpperCase()+p.slice(1),Q=p==="sleep"&&T||p==="hook"&&D,P=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.jsx("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:$}),n.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:P})]}),n.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:y,children:y})]})})}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[Q&&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:[p==="sleep"&&T&&n.jsxs("button",{type:"button",onClick:M,disabled:h,className:Mt("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",h?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[n.jsx(La,{className:"h-4 w-4"}),h?"Waking up...":"Wake Up Sleep"]}),p==="hook"&&D&&n.jsxs("button",{type:"button",onClick:()=>j(!0),disabled:w,className:Mt("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(Qo,{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(Uc,{data:O,moduleSpecifier:z,expiredAt:e.expiredAt,isLoading:C,error:_??void 0,onStreamClick:r})]}),p!=="run"&&S&&n.jsx("section",{children:n.jsx(Xc,{events:S,onLoadEventData:d,encryptionKey:f})})]})]}),n.jsx(es,{isOpen:b,onClose:()=>j(!1),onSubmit:F,isSubmitting:w})]})}function td(e){const t=m.useRef(e);t.current=e,m.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 Io(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 rd({scale:e,isLive:t=!1}){const{state:{root:r}}=ft(),[,o]=m.useState(0);m.useEffect(()=>{if(!t)return;const h=setInterval(()=>o(v=>v+1),1e3);return()=>clearInterval(h)},[t]);const s=r.duration,a=e>0?e:s>0?1/s:1;let l=Io(50/a);l=Math.max(1,l);let d=l*a;const c=1e3;s/l>c&&(l=Io(s/c),d=l*a);const f=Math.ceil(s/l),u=Math.ceil(100/d)||1;return n.jsx("div",{className:re.markersContainer,children:n.jsx("div",{"aria-hidden":!0,className:re.markers,style:{width:Math.floor(r.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${d}px`},children:new Array(f).fill(null).map((h,v)=>{const b=v%u===0;return n.jsx("span",{className:Mt(re.marker,!b&&re.notch),children:b?n.jsxs("span",{className:re.markerLabel,children:[yi(l*v),n.jsx("span",{className:re.markerClockTime,children:bi(r.startTime+l*v)})]}):null},String(v))})})})}function nd({events:e,root:t,scale:r}){const o=m.useMemo(()=>e.filter(s=>s.event.showVerticalLine!==!1),[e]);return n.jsx("div",{className:re.eventMarkersContainer,children:n.jsx("div",{"aria-hidden":!0,className:re.eventMarkers,style:{width:Math.floor(t.duration*r)},children:o.map(s=>n.jsx("span",{className:Mt(re.eventMarker),style:{left:Math.floor((s.timestamp-t.startTime)*r),...s.event.color&&{borderLeftColor:s.event.color}}},s.key))})})}const No=2;function od({memoCacheRef:e,timelineRef:t,root:r,spans:o,events:s,scale:a,dispatch:i,scrollSnapshotRef:l}){const d=m.useRef(!1),c=m.useRef(o);c.current=o;const f=m.useRef(s);f.current=s;const u=m.useRef(null),{style:h,setStyle:v}=Kr(u),b=m.useRef(null),j=m.useRef(null),{style:w,setStyle:x}=Kr(j),g=m.useRef(void 0),I=m.useRef(null),{style:N,setStyle:S}=Kr(I),R=m.useRef(0);m.useEffect(()=>{const y=t.current;if(!y)return;let k=R.current,T=0,D=!1,_=!1,C=!1,E=!1,M=0,F=0;const O=Date.now()+500,z=()=>{g.current||(g.current=y.getBoundingClientRect())},$=q=>g.current?(q-Ar-Ve)/(zt+wt):0,Q=()=>{const q=e.current;for(const te of c.current)te.isHovered&&(te.isHovered=!1,q.set(te.span.spanId,{}));i({type:"forceRender"})};let P=0;const V=()=>{var Ne,Qe,st,at,Ye,Ce,Z,je;if(!d.current)return;g.current||z();const q=g.current;if(!q)return;const{scrollLeft:te,scrollTop:me}=y,pe=Math.max(0,Math.min(k+te-q.left-Ve,r.duration*a)),ce=`${pe-te+Ve}px`;x("left",ce),v("left",ce);const ie=r.startTime+pe/a,Ie=ie-r.startTime;if(Ie<0||Ie>r.duration?(Ne=b.current)==null||Ne.removeAttribute("data-text"):(Qe=b.current)==null||Qe.setAttribute("data-text",vr(Ie)),D){const Te=k-T,_e=Math.abs(Te);if(!C){if(_e<4)return;C=!0,S("display","flex"),Q()}Te>0?(S("left",""),S("right","0")):(S("left","0"),S("right","")),S("width",`${_e}px`);const Fe=Math.max(0,Math.min(T+te-q.left-Ve,r.duration*a))/a;let De,et;Fe<Ie?(De=Fe,et=Ie):(De=Ie,et=Fe),(st=I.current)==null||st.setAttribute("data-range",`${vr(De)} — ${vr(et)}`),(at=I.current)==null||at.setAttribute("data-duration",`${vr(et-De)} selected`)}if(Date.now()<O){P=requestAnimationFrame(V);return}if(te!==M||me!==F){M=te,F=me,P=requestAnimationFrame(V);return}if(k-q.left<128?(Ye=b.current)==null||Ye.setAttribute("data-align","left"):k-q.left>q.width-128?(Ce=b.current)==null||Ce.setAttribute("data-align","right"):(Z=b.current)==null||Z.removeAttribute("data-align"),!C&&!_){const Te=e.current,_e=$(me)-No,Le=$(me+q.height)+No;for(const Me of c.current){const Ze=Me.row>=_e&&Me.row<=Le&&ie>=Me.startTime&&ie<=Me.endTime;Me.isHovered!==Ze&&(Me.isHovered=Ze,Te.set(Me.span.spanId,{}))}const De=12/a;let et=null,vt=1/0;for(const Me of f.current){const Ze=Math.abs(Me.timestamp-ie);Ze<=De&&Ze<vt&&(vt=Ze,et=Me)}for(const Me of f.current){const Ze=Me===et;if(Me.isHovered===Ze)continue;Me.isHovered=Ze;const Kn=(je=Me.ref)==null?void 0:je.current;Kn&&Kn.setAttribute("data-hovered",String(Ze))}i({type:"forceRender"})}};P=requestAnimationFrame(V);const W=q=>{q.pointerType==="mouse"&&(d.current=!0)},K=()=>{d.current&&(d.current=!1,Q())},U=({clientX:q})=>{k=q,R.current=k,cancelAnimationFrame(P),P=requestAnimationFrame(V)},Y=q=>{q.preventDefault()},ee=q=>{var te;if(q.button===2)E=!0,q.preventDefault();else{if(q.button!==0)return;E=!1}(te=t.current)!=null&&te.contains(q.target)?(T=k,D=!0):(_=!0,requestAnimationFrame(Q))},A=q=>{if(_=!1,!D||(D=!1,!C))return;if(C=!1,S("display",""),S("left",""),S("right",""),S("width",""),q.preventDefault(),q.stopImmediatePropagation(),E){E=!1;return}g.current||z();const te=g.current;if(!te)return;const{scrollLeft:me}=y,pe=Math.max(0,Math.min((T+me-te.left-Ve)/a,r.duration)),ce=Math.max(0,Math.min((k+me-te.left-Ve)/a,r.duration));i({type:"scaleToRange",t1:pe+r.startTime,t2:ce+r.startTime})},B=q=>{D&&q.key==="Escape"&&(E=!0,A(q))},ne=()=>{g.current=void 0,p.current=void 0,cancelAnimationFrame(P),P=requestAnimationFrame(V)},ue=()=>{cancelAnimationFrame(P),P=requestAnimationFrame(V)},ge=new ResizeObserver(()=>{g.current=void 0});return ge.observe(y),window.addEventListener("mousemove",U),y.addEventListener("contextmenu",Y),window.addEventListener("mousedown",ee),window.addEventListener("mouseup",A),window.addEventListener("blur",A),window.addEventListener("keydown",B,!0),window.addEventListener("scroll",ne),y.addEventListener("scroll",ue),y.addEventListener("pointerenter",W),y.addEventListener("pointerleave",K),()=>{ge.disconnect(),window.removeEventListener("mousemove",U),y.removeEventListener("contextmenu",Y),window.removeEventListener("mousedown",ee),window.removeEventListener("mouseup",A),window.removeEventListener("blur",A),window.removeEventListener("keydown",B,!0),window.removeEventListener("scroll",ne),y.removeEventListener("scroll",ue),y.removeEventListener("pointerenter",W),y.removeEventListener("pointerleave",K),cancelAnimationFrame(P),R.current=k,Q()}},[i,r,a,x,v,S,e,t,l]);const p=m.useRef(void 0);return td(y=>{const k=t.current;if(!k)return;g.current??(g.current=k.getBoundingClientRect());const T=g.current,D=Math.max(0,Math.min(R.current-T.left-Ve,T.width-2*Ve));let _=0,C=p.current;(C==null?void 0:C.anchorX)===D?_=C.anchorT:(_=(k.scrollLeft+D)/a,C={anchorT:_,anchorX:D},p.current=C),i({type:"trackpadScale",delta:y/64,anchorT:_,anchorX:D})}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:re.cursorMarkerStickyParent,children:n.jsx("div",{className:re.cursorMarkerLabelContainer,ref:u,style:h,children:n.jsx("div",{className:re.cursorMarkerLabel,ref:b})})}),n.jsx("div",{className:re.cursorMarkerStickyParent,children:n.jsx("div",{className:re.cursorMarkerContainer,ref:j,style:w,children:n.jsx("div",{className:re.cursorMarker,children:n.jsx("div",{className:re.cursorSelection,ref:I,style:N})})})})]})}function sd({height:e,width:t,value:r,placeholder:o,onChange:s}){return n.jsxs("label",{className:re.searchInputLabel,children:[n.jsx("div",{className:re.searchInputPrefix,children:n.jsx(ad,{})}),n.jsx("input",{type:"search",value:r,placeholder:o,onChange:s,style:{height:e,width:t}})]})}function ad(){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 id(){return n.jsx("nav",{className:re.searchBar,children:n.jsx(ld,{})})}function ld(){const{dispatch:e}=ft(),[t,r]=m.useState("");return m.useEffect(()=>{const o=setTimeout(()=>e({type:"setFilter",filter:t}),100);return()=>{clearTimeout(o)}},[e,t]),n.jsx("div",{className:re.searchInput,children:n.jsx(sd,{height:ss,onChange:o=>r(o.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}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:"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 dd({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 ud({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 fd(){const{dispatch:e}=ft(),t=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),r=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),o=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return n.jsxs("div",{className:re.zoomButtonGroup,children:[n.jsx("button",{"aria-label":"Zoom Out",className:re.zoomButton,onClick:r,type:"button",children:n.jsx(dd,{size:18})}),n.jsx("div",{className:re.divider}),n.jsx("button",{"aria-label":"Reset Zoom",className:re.zoomButton,onClick:o,type:"button",children:n.jsx(ud,{size:18})}),n.jsx("div",{className:re.divider}),n.jsx("button",{"aria-label":"Zoom In",className:re.zoomButton,onClick:t,type:"button",children:n.jsx(cd,{size:18})})]})}const md=e=>{const{spans:t}=e,r={startTime:0,endTime:0,duration:0,depth:0,children:[]},o={},s=new Map,a=u=>{const h=s.get(u);if(h)return h;const v=s.size+1;return s.set(u,v),v};let i=!1;for(const u of t){const h=qt(u.startTime),v=qt(u.endTime),b=qt(u.duration);v>r.endTime&&(r.endTime=v,r.duration=v-r.startTime),(r.startTime===0||h<r.startTime)&&(r.startTime=h,r.duration=r.endTime-h);const j=u.resource.startsWith("vercel.");j||(i=!0);const w=j&&(u.resource!=="vercel.serverless-runtime"||!("http.method"in u.attributes)),x=w?0:a(u.resource);let g;w&&(g=`▲ ${u.name}`),o[u.spanId]={parent:null,startTime:h,endTime:v,duration:b,span:u,depth:0,label:g,events:pd(u),isVercel:w,children:[],resourceIndex:x,activeStartTime:u.activeStartTime?qt(u.activeStartTime):void 0}}const l=(u,h)=>{let v;h?(v=o[h],v||(v=r)):v=r,u.parent=v,v.children.push(u)},d=u=>{"parent"in u&&(u.depth=u.parent.depth+1);for(const h of u.children)d(h)};let c=1;const f=(u,h)=>{if("parent"in u&&u.span.name===h){let v=u.endTime;const b=R=>R.children.length?R.children.map(b).sort((p,y)=>p.duration-y.duration)[0]||R:R.span.name==="waitUntil"?(v=R.startTime,R.parent):R,j=b(u),w=`instrumentation-hint-${c++}`,x=u.duration*.05,g=u.startTime+x,I=Math.max(g+x,Math.min(v-u.duration*.01,u.endTime-x)),N=I-g,S={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:qr(g),endTime:qr(I),duration:qr(N)},depth:u.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return j.children.push(S),o[w]=S,!0}for(const v of u.children)if(f(v,h))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(f(r,u))break}return{root:r,map:o}},pd=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((r,o)=>({key:`${t}${o}`,timestamp:qt(r.timestamp),event:r})).sort((r,o)=>r.timestamp-o.timestamp)},jo=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function on(){return[]}const hd=(e,t=!1)=>{const{state:r,dispatch:o}=ft(),{root:s,filter:a,scale:i,timelineRef:l,timelineWidth:d,spanMap:c,scrollSnapshotRef:f,selected:u,memoCacheRef:h}=r,v=gd(r.timelineHeight),b=m.useRef(0),[j,w]=m.useState(on),[x,g]=m.useState(on),[I,N]=m.useState(on),[S,R]=m.useState(-1),p=m.useRef(void 0);return m.useEffect(()=>{var y;return(y=p.current)==null?void 0:y.call(p,a)},[a]),m.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,h.current.set(k.span.spanId,{}))}o({type:"forceRender"})}},[j,e,o,h]),m.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=_=>{var E;const C=_.data;switch(C.type){case"setRowsResult":{if((C==null?void 0:C.requestId)!==k)return;if(C.isEnd)for(const M of C.rows)for(const F of M)F.span=((E=c[F.span.spanId])==null?void 0:E.span)??F.span;w(C.rows);break}case"updateHighlight":{if((C==null?void 0:C.requestId)!==k)return;const{matches:M}=C;w(F=>{for(const O of F)for(const z of O){const $=M.has(z.span.spanId);z.isHighlighted!==$&&(z.isHighlighted=$,h.current.set(z.span.spanId,{}))}return F}),o({type:"forceRender"});break}}};y.addEventListener("message",T);const D={requestId:k,type:"calculateSpanPositions",root:s};return y.postMessage(D),p.current=_=>{const C=_.trim().toLocaleLowerCase();if(!C){w(M=>M.map(F=>F.map(O=>(O.isHighlighted=void 0,{...O}))));return}k=++b.current;const E={type:"filterSpans",requestId:k,root:s,filter:C};y.postMessage(E)},()=>{y.terminate()}},[s,c,o,h]),m.useEffect(()=>{if(!j.length)return;if(t){const U=[],Y=[];for(const ee of j)for(const A of ee)jo(A)&&(U.push(A),A.events&&Y.push(...A.events));g(U),N(Y),R(i);return}const y=l.current;let k=f.current,T=!1,D=!1,_=0,C=0;const E=Math.max(500,d*.5),M=new Array(j.length).fill(null),F=()=>{D=!0;const U=Math.min(1+C+Math.ceil((k==null?void 0:k.endRow)??Number.POSITIVE_INFINITY),j.length);for(let Y=U;Y--;){if(M[Y])continue;const ee=O(Y);if(Math.abs(ee)>C){if(D=!1,ee>0)continue;break}const A=[],B=j[Y];if(B){for(const ne of B){if(!jo(ne))continue;const ue=z(ne);_=Math.max(ue,_),A.push({d:ue,span:ne})}M[Y]=A}}},O=U=>k?U<k.startRow?U-k.startRow:U>k.endRow?U-k.endRow:0:0,z=U=>{if(!k)return 0;let Y=0;U.endTime<k.startTime?Y=k.startTime-U.endTime:U.startTime>k.endTime&&(Y=U.startTime-k.endTime);const ee=Math.abs(O(U.row));return!Y&&!ee?0:Math.sqrt((Y/i)**2+(ee*zt+wt)**2)},$=()=>{if(!y)return;const{scrollLeft:U,scrollTop:Y}=y,ee=0,A=U/i,B=(Y-Ar-Ve)/(zt+wt),ne=B+Math.ceil(v/(zt+wt));k={anchorT:A,anchorX:ee,scrollLeft:U,scrollTop:Y,startTime:s.startTime+U/i,endTime:s.startTime+(U+d)/i,startRow:B,endRow:ne,scale:i},f.current=k;for(let ue=M.length;ue--;)M[ue]=null};let Q=0;const P=()=>{(T||!k)&&(T=!1,$()),F();const U=[],Y=[];for(const ee of M)if(ee)for(const{d:A,span:B}of ee)A>C||(U.push(B),B.events&&Y.push(...B.events));C<E&&(!D||C<_)&&(C=Math.min(E,C+100),Q=requestAnimationFrame(P)),g(U),N(Y),R(i)};P();let V=Date.now();const W=U=>{(U.ctrlKey||U.metaKey)&&(V=Date.now())};y==null||y.addEventListener("wheel",W);const K=()=>{Date.now()-V<=50||(T=!0,cancelAnimationFrame(Q),Q=requestAnimationFrame(P))};return y==null||y.addEventListener("scroll",K),()=>{cancelAnimationFrame(Q),y==null||y.removeEventListener("wheel",W),y==null||y.removeEventListener("scroll",K)}},[j,s,i,f,l,d,v,t]),m.useEffect(()=>{var T;if(!u)return;let y;for(const D of x)if(D.span.spanId===u.span.spanId){y=D;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")}},[x,u]),{rows:j,spans:x,events:I,scale:S}};function gd(e){const[t,r]=m.useState(e);return m.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 ko={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 xd({trace:e=ko,className:t="",scrollLock:r=!1,height:o,withPanel:s=!1,highlightedSpans:a,eagerRender:i=!1,isLive:l=!1}){const d=e===ko,{state:c,dispatch:f}=ft(),{timelineRef:u,scrollSnapshotRef:h}=c,v=c.memoCacheRef.current,b=((a==null?void 0:a.length)??0)>0,j=m.useRef(!1),w=m.useRef(""),x=m.useRef(null),g=m.useRef({}),I=m.useRef(null);m.useEffect(()=>{const{root:C,map:E}=md(e),M=!j.current;j.current=!0;const F=Object.keys(E).sort().map(O=>{const z=E[O].events,$=(z==null?void 0:z.length)??0,Q=$?z==null?void 0:z[0]:void 0,P=$?z==null?void 0:z[$-1]:void 0,V=`${(Q==null?void 0:Q.event.name)??"none"}@${(Q==null?void 0:Q.timestamp)??0}|${(P==null?void 0:P.event.name)??"none"}@${(P==null?void 0:P.timestamp)??0}`;return`${O}:${$}:${V}`}).join(",");if(!M&&F===w.current&&x.current){const O=x.current,z=g.current;let $=!1;(O.endTime!==C.endTime||O.duration!==C.duration)&&(O.endTime=C.endTime,O.duration=C.duration,$=!0);for(const[Q,P]of Object.entries(E)){const V=z[Q];V&&((V.endTime!==P.endTime||V.duration!==P.duration)&&(V.endTime=P.endTime,V.duration=P.duration,$=!0),Object.assign(V.span,P.span))}if(!$)return;f({type:"forceRender"});return}w.current=F,x.current=C,g.current=E,f({type:M?"setRoot":"updateRoot",root:C,spanMap:E,resources:e.resources||[]})},[f,e]);const{rows:N,spans:S,events:R,scale:p}=hd(a,i),y=m.useRef(null);m.useLayoutEffect(()=>{const C=y.current;if(!C)return;const E=()=>{const F=2*Ve,O=C.getBoundingClientRect(),z=O.width-F,$=O.height,Q=I.current;Q&&Q.width===z&&Q.height===$||(I.current={width:z,height:$},f({type:"setSize",width:z,height:$}))};E();const M=new ResizeObserver(E);return M.observe(C),window.addEventListener("resize",E),()=>{M.disconnect(),window.removeEventListener("resize",E)}},[f]);const k=m.useRef({t:0,x:-1,y:-1,spanId:""}),T=m.useCallback(C=>{const E=k.current,M=Date.now(),{clientX:F,clientY:O}=C,z=Math.sqrt((F-E.x)**2+(O-E.y)**2);if(M-E.t<=500&&z<=8){if(C.stopPropagation(),C.preventDefault(),!E.spanId){f({type:"resetScale"});return}f({type:"select",id:E.spanId}),f({type:"scaleToNode",id:E.spanId});return}const $=C.target;if(!$.closest(`.${String(re.timeline)}`))return;const Q=$.closest("[data-span-id]"),P=(Q==null?void 0:Q.dataset.spanId)||"";k.current={x:F,y:O,t:M,spanId:P},P&&(f({type:"toggleSelection",id:P}),C.stopPropagation())},[f]);m.useLayoutEffect(()=>{const C=u.current;if(!C)return;const E=h.current;E&&(C.scrollLeft=E.anchorT*p-E.anchorX,h.current=void 0)},[h,u,p]),m.useEffect(()=>{var M;const C=(M=c.selected)==null?void 0:M.span.spanId;if(!C)return;const E=setTimeout(()=>{const F=c.timelineRef.current,O=F==null?void 0:F.querySelector(`[data-span-id="${C}"]`);if(!F||!O)return;const z=F.getBoundingClientRect(),$=O.getBoundingClientRect();$.width<z.width&&($.left<z.left||$.right>z.right||$.top<z.top||$.bottom>z.bottom)&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(E)}},[c.selected,c.timelineRef]),m.useEffect(()=>{const C=E=>{E.key==="Escape"&&f({type:"escape"})};return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[f]),m.useEffect(()=>{if(!r)return;const C=document.documentElement,E=document.body;C.style.overflow="clip",E.style.overflow="clip";const M=F=>{F!=null&&F.cancelable?F.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return M(),window.addEventListener("scroll",M,{passive:!1}),()=>{C.style.overflow="",E.style.overflow="",window.removeEventListener("scroll",M)}},[r]);const D=Math.max(c.timelineHeight-c.scrollbarWidth,Ar+wt+N.length*(zt+wt)-wt+84),_=!!(c.isMobile&&c.selected);return n.jsxs("div",{className:Mt(re.traceViewer,d&&re.skeleton,t),onClickCapture:T,ref:y,style:{height:o,"--timeline-padding":`${Ve}px`,"--row-height":`${zt}px`,"--row-padding":`${wt}px`,"--search-height":`${b?0:ss}px`,"--search-gap":`${b?2:Ni}px`,"--map-height":`${Ii}px`,"--timeline-width":`${c.timelineWidth}px`,"--timeline-height":`${c.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(c.root.duration*c.scale)}px`,"--panel-width":`${c.panelWidth}px`,"--panel-height":`${c.panelHeight}px`,"--height":`${c.height}px`,"--scrollbar-width":`${c.scrollbarWidth}px`,"--marker-height":`${Ar}px`,"--marker-notch-height":`${wi}px`},children:[b?null:n.jsx(id,{}),n.jsx(ji,{rows:N,scale:p,timelineRef:u}),n.jsxs("div",{className:Mt(re.traceViewerContent,_&&re.inert),children:[n.jsx("div",{className:re.timeline,ref:u,children:n.jsx("div",{style:{position:"relative",width:c.timelineWidth,height:c.timelineHeight-Ve*2,padding:Ve,paddingBottom:0},children:n.jsxs("div",{className:re.traceNode,style:{width:c.root.duration*p||void 0,height:D-Ve*2},children:[n.jsx(rd,{scale:p,isLive:l}),n.jsx(nd,{events:R,root:c.root,scale:p}),n.jsx(od,{dispatch:f,events:R,memoCacheRef:c.memoCacheRef,root:c.root,scale:p,scrollSnapshotRef:h,spans:S,timelineRef:u}),n.jsx(ki,{cacheKey:v.get(""),cache:v,customSpanClassNameFunc:c.customSpanClassNameFunc,customSpanEventClassNameFunc:c.customSpanEventClassNameFunc,isLive:l,root:c.root,scale:p,scrollSnapshotRef:h,spans:S})]})})}),n.jsx("div",{className:re.zoomButtonTraceViewer,children:n.jsx(fd,{})})]}),s?n.jsx("div",{className:Mt(re.spanDetailPanelTraceViewer,!c.selected&&re.hidden,c.isMobile&&re.mobile),children:n.jsx(Si,{attached:!0})}):null]})}function So(e,t=!1){if(t&&e==="pending")return re.spanPendingStriped;switch(e){case"running":return re.spanRunning;case"pending":return re.spanPending;case"completed":return re.spanCompleted;case"cancelled":return re.spanCancelled;case"failed":return re.spanFailed;default:return""}}function vd(e){return String(e).toLowerCase().endsWith("sleep")}const yd=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&&vd(s))return re.spanSleep;const a=(o==null?void 0:o.status)==="pending";return So(o==null?void 0:o.status,a)}if(r==="run"){const o=t.data;return So(o==null?void 0:o.status,!1)}return r==="hook"?re.spanHook:r==="sleep"?re.spanSleep:""},bd=e=>{const t=e.event.name;return t==="step_failed"||t==="run_failed"?re.eventFailed:t==="step_retrying"?re.eventRetrying:t==="hook_created"||t==="hook_received"||t==="hook_disposed"?re.eventHook:re.eventDefault};function wd(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function rt(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 Co(e){const t=e[0]*1e3,r=e[1]/1e6;return t+r}function Vr(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 pr={name:"workflow-development-kit",version:"4.0.0"},Id=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function Gr(e,t=!0){return e.filter(r=>t?Id.has(r.eventType):!0).map(r=>({name:r.eventType,timestamp:rt(r.createdAt),attributes:{eventId:r.eventId,correlationId:r.correlationId,eventData:"eventData"in r?r.eventData:void 0},showVerticalLine:wd(r.eventType)}))}const Gs=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 Nd(e,t,r){const o=Gs(e);if(!o)return null;const s=new Date(t.completedAt||r)??r,a=(o==null?void 0:o.createdAt)??r,i=(o==null?void 0:o.completedAt)??s,l=rt(a),d=rt(i),c=Vr(a,i),f=Gr(e,!1);return{spanId:o.waitId,name:"sleep",kind:1,resource:"sleep",library:pr,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:o},links:[],events:f,duration:c,startTime:l,endTime:d}}function jd(e,t,r,o){const s=r??new Date,a=cr(String(e.stepName)),{input:i,output:l,error:d,...c}=e,f={resource:"step",data:c},u="step",h=new Date(e.completedAt??o??s),v=Gr(t,!1),b=new Date(e.createdAt);let j=e.startedAt?new Date(e.startedAt):void 0;const w=t.find(x=>x.eventType==="step_started");return w&&(j=new Date(w.createdAt)),{spanId:String(e.stepId),name:(a==null?void 0:a.shortName)??"",kind:1,resource:u,library:pr,status:{code:0},traceFlags:1,attributes:f,links:[],events:v,startTime:rt(b),endTime:rt(h),duration:Vr(b,h),activeStartTime:j&&j.getTime()>b.getTime()?rt(j):void 0}}const kd=e=>{var a;const t=e.find(i=>i.eventType==="hook_created");if(!t)return null;const r=e.filter(i=>i.eventType==="hook_received"),o=e.filter(i=>i.eventType==="hook_disposed"),s=r.at(-1);return{hookId:t.correlationId,runId:t.runId,createdAt:t.createdAt,receivedCount:r.length,lastReceivedAt:(s==null?void 0:s.createdAt)||void 0,disposedAt:((a=o.at(-1))==null?void 0:a.createdAt)||void 0}};function Sd(e,t,r){const o=kd(e);if(!o)return null;const s=Gr(e,!1),a=new Date(t.completedAt||r)??r,i=o.disposedAt||a;return{spanId:String(o.hookId),name:String(o.hookId),kind:1,resource:"hook",library:pr,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:o},links:[],events:s,startTime:rt(o.createdAt),endTime:rt(i),duration:Vr(o.createdAt,i)}}function Cd(e,t,r){var v;const o=r??new Date,{input:s,output:a,error:i,...l}=e,d={resource:"run",data:l},c=new Date(e.createdAt),f=e.startedAt?new Date(e.startedAt):void 0,u=e.completedAt??o,h=Gr(t,!1);return{spanId:String(e.runId),name:String(((v=It(e.workflowName))==null?void 0:v.shortName)??"?"),kind:1,resource:"run",library:pr,status:{code:0},traceFlags:1,attributes:d,links:[],events:h,startTime:rt(c),endTime:rt(u),duration:Vr(c,u),activeStartTime:f&&f.getTime()>c.getTime()?rt(f):void 0}}function Td(e){const{state:t,dispatch:r}=ft(),o=m.useRef(t);o.current=t,m.useEffect(()=>{if(!e)return;let s=0;const a=()=>{const{root:c}=o.current;if(c.startTime){const f=Date.now();f>c.endTime&&(c.endTime=f,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 f=(c.width-c.scrollbarWidth)/c.root.duration;(Math.abs(f-l)>l*.001||l===0)&&(l=f,r({type:"detectBaseScale"}))}i=requestAnimationFrame(d)};return i=requestAnimationFrame(d),()=>{cancelAnimationFrame(s),cancelAnimationFrame(i)}},[e,r])}const Ed=450,Rd=240;function Ad({menu:e,items:t,onClose:r}){const o=m.useRef(null);m.useEffect(()=>{const i=f=>{o.current&&!o.current.contains(f.target)&&r()},l=f=>{f.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]=m.useState({x:e.x,y:e.y});return m.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:Yo.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 Dd({trace:e,run:t,hooks:r,isLive:o,onWakeUpSleep:s,onCancelRun:a,onResolveHook:i,onLoadMoreSpans:l,hasMoreSpans:d=!1,isLoadingMoreSpans:c=!1,children:f}){const{state:u,dispatch:h}=ft();Td(o);const[v,b]=m.useState(null),[j,w]=m.useState(null),[x,g]=m.useState(!1),[I,N]=m.useState(new Set),S=m.useMemo(()=>{const C=new Map;for(const E of e.spans)C.set(E.spanId,E);return C},[e.spans]),R=m.useMemo(()=>{const C=new Map;for(const E of r)C.set(E.hookId,E);return C},[r]),p=m.useCallback(async C=>{if(!(x||!j||!i)){if(!j.token){he.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{g(!0),await i(j.token,C,j),he.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),N(E=>new Set(E).add(j.hookId)),w(null)}catch(E){console.error("Failed to resolve hook:",E),he.error("Failed to resolve hook",{description:E instanceof Error?E.message:"An unknown error occurred"})}finally{g(!1)}}},[i,j,x]),y=m.useCallback(C=>{const M=C.target.closest("[data-span-id]");if(!M)return;const F=M.dataset.spanId;if(!F)return;C.preventDefault(),C.stopPropagation();const O=S.get(F);if(!O)return;const z=O.attributes.resource??"unknown",$=O.attributes.data,Q=!($!=null&&$.completedAt)&&!($!=null&&$.disposedAt);b({x:C.clientX,y:C.clientY,spanId:F,spanName:O.name,resourceType:z,isActive:Q})},[S]),k=m.useRef(null);m.useEffect(()=>{const C=k.current;if(!C)return;const E=M=>{y(M)};return C.addEventListener("contextmenu",E),()=>{C.removeEventListener("contextmenu",E)}},[y]);const T=m.useRef(!1);m.useEffect(()=>{const C=u.timelineRef.current;if(!C||!l||!d)return;const E=200,M=()=>{T.current||c||!d||C.scrollHeight-C.scrollTop-C.clientHeight>E||(T.current=!0,Promise.resolve(l()).finally(()=>{T.current=!1}))};return C.addEventListener("scroll",M),M(),()=>{C.removeEventListener("scroll",M)}},[u.timelineRef,l,d,c]);const D=m.useCallback(()=>{b(null)},[]),_=m.useCallback(C=>{var F,O;const E=[],M=!t.completedAt;if(C.resourceType==="sleep"&&C.isActive&&M&&s&&E.push({label:"Wake Up Sleep",icon:n.jsx(Fa,{className:"h-3.5 w-3.5"}),action:()=>{s(t.runId,C.spanId).then(z=>{z.stoppedCount>0?he.success("Sleep woken up",{description:`Woke up ${String(z.stoppedCount)} sleep${z.stoppedCount>1?"s":""}`}):he.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(z=>{he.error("Failed to wake up sleep",{description:z instanceof Error?z.message:"An unknown error occurred"})})}}),C.resourceType==="hook"&&M&&i){const z=R.get(C.spanId),$=S.get(C.spanId),Q=(F=$==null?void 0:$.attributes)==null?void 0:F.data,P=!!(Q!=null&&Q.disposedAt)||!!((O=$==null?void 0:$.events)!=null&&O.some(V=>V.name==="hook_disposed"))||I.has(C.spanId);z!=null&&z.token&&!P&&E.push({label:"Resolve Hook",icon:n.jsx(Qo,{className:"h-3.5 w-3.5"}),action:()=>{w(z)}})}return C.resourceType==="run"&&M&&a&&E.push({label:"Cancel Run",icon:n.jsx(Pa,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{a(t.runId).catch(z=>{he.error("Failed to cancel run",{description:z instanceof Error?z.message:"An unknown error occurred"})})}}),E.push({label:"View Details",icon:n.jsx(Wi,{className:"h-3.5 w-3.5"}),action:()=>{h({type:"select",id:C.spanId})}}),E.push({label:"Copy Name",icon:n.jsx(Ki,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(C.spanName).then(()=>{he.success("Name copied to clipboard")}).catch(()=>{he.error("Failed to copy name")})}}),E.push({label:"Copy ID",icon:n.jsx(lr,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(C.spanId).then(()=>{he.success("ID copied to clipboard")}).catch(()=>{he.error("Failed to copy ID")})}}),E},[h,s,a,i,R,S,I,t.runId,t.completedAt]);return n.jsxs("div",{className:"relative w-full h-full",ref:k,children:[f,v?n.jsx(Ad,{menu:v,items:_(v),onClose:D}):null,n.jsx(es,{isOpen:j!==null,onClose:()=>w(null),onSubmit:p,isSubmitting:x})]})}const Md=e=>e==="wait_created"||e==="wait_completed",_d=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed",Ir=(e,t,r)=>{const o=e.get(t);if(o){o.push(r);return}e.set(t,[r])},Ld=(e,t,r)=>{const o=new Map,s=new Map,a=[],i=new Map,l=new Map,d=new Set(t.map(f=>f.stepId)),c=new Set(r.map(f=>f.hookId));for(const f of e){const u=f.correlationId;if(!u){a.push(f);continue}if(Md(f.eventType)){Ir(i,u,f);continue}if(_d(f.eventType)){Ir(l,u,f);continue}if(d.has(u)){Ir(o,u,f);continue}if(c.has(u)){Ir(s,u,f);continue}a.push(f)}return{eventsByStepId:o,eventsByHookId:s,runLevelEvents:a,timerEvents:i,hookEvents:l}},Od=(e,t,r,o)=>{const s=new Date(e.completedAt||o),a=t.map(d=>{const c=r.eventsByStepId.get(d.stepId)||[];return jd(d,c,o,s)}),i=Array.from(r.hookEvents.values()).map(d=>Sd(d,e,o)).filter(d=>d!==null),l=Array.from(r.timerEvents.values()).map(d=>Nd(d,e,o)).filter(d=>d!==null);return{runSpan:Cd(e,r.runLevelEvents,o),spans:[...a,...i,...l]}},Hd=(e,t)=>{const r=[e,...t.slice().sort((o,s)=>{const a=Co(o.startTime),i=Co(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}})},Fd=(e,t,r,o,s)=>{const a=Ld(o,t,r),{runSpan:i,spans:l}=Od(e,t,a,s),d=Hd(i,l);return{traceId:e.runId,rootSpanId:e.runId,spans:d,resources:[{name:"workflow",attributes:{"service.name":pr.name}}]}};function Pd({onSelectionChange:e}){const{state:t}=ft(),{selected:r}=t,o=m.useRef(e);return o.current=e,m.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}=ft();return m.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function zd({selectRequest:e}){const{dispatch:t}=ft();return m.useEffect(()=>{e!=null&&e.id&&t({type:"select",id:e.id})},[t,e]),null}function Wd({onResize:e}){const t=m.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})}const $d=({run:e,steps:t,hooks:r,events:o,isLoading:s,error:a,spanDetailData:i,spanDetailLoading:l,spanDetailError:d,onWakeUpSleep:c,onResolveHook:f,onCancelRun:u,onStreamClick:h,onSpanSelect:v,onLoadEventData:b,onLoadMoreSpans:j,hasMoreSpans:w=!1,isLoadingMoreSpans:x=!1,encryptionKey:g})=>{const[I,N]=m.useState(null),[S,R]=m.useState(Ed),[p,y]=m.useState(0),[k,T]=m.useState(null),D=!!(e&&!e.completedAt),_=m.useMemo(()=>{if(e)return Fd(e,t,r,o,new Date)},[e,t,r,o]);m.useEffect(()=>{a&&!s&&(console.error(a),he.error("Error loading workflow trace data",{description:a.message}))},[a,s]);const C=m.useCallback(W=>{v==null||v(W)},[v]),E=m.useCallback(W=>{if(W){const K=W.spanId,U=K?o.filter(Y=>Y.correlationId===K):[];N({...W,rawEvents:U})}else N(null)},[o]);m.useEffect(()=>{const W=I==null?void 0:I.spanId;if(!W)return;const K=o.filter(U=>U.correlationId===W);N(U=>{if(!U||U.spanId!==W)return U;const Y=U.rawEvents??[];return Y.length===K.length&&Y.every((A,B)=>{var ne;return A.eventId===((ne=K[B])==null?void 0:ne.eventId)})?U:{...U,rawEvents:K}})},[o,I==null?void 0:I.spanId]);const M=m.useCallback(()=>{N(null),y(W=>W+1)},[]),F=m.useCallback(W=>{R(K=>Math.max(Rd,K+W))},[]),O=m.useMemo(()=>!(I!=null&&I.spanId)||!_?-1:_.spans.findIndex(W=>W.spanId===I.spanId),[I==null?void 0:I.spanId,_]),z=O>0,$=O>=0&&_!=null&&O<_.spans.length-1,Q=m.useCallback(()=>{var K;if(!_||O<=0)return;const W=(K=_.spans[O-1])==null?void 0:K.spanId;W&&T({id:W,token:Date.now()})},[O,_]),P=m.useCallback(()=>{var K;if(!_||O<0)return;const W=(K=_.spans[O+1])==null?void 0:K.spanId;W&&T({id:W,token:Date.now()})},[O,_]),V=m.useMemo(()=>{var Y,ee;if(!(I!=null&&I.data))return;const W=I.data,K=W.stepName,U=W.workflowName;return(K?(Y=cr(K))==null?void 0:Y.shortName:void 0)??(U?(ee=It(U))==null?void 0:ee.shortName:void 0)??K??U??W.hookId??"Details"},[I==null?void 0:I.data]);return s||!_?n.jsxs("div",{className:"relative w-full h-full",children:[n.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),n.jsx(He,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),n.jsxs("div",{className:"p-2 relative w-full",children:[n.jsx(He,{className:"w-full mt-6 h-[20px]"}),n.jsx(He,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),n.jsx(He,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),n.jsx(He,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]}):n.jsxs("div",{className:"relative w-full h-full flex",children:[n.jsx("div",{className:"flex-1 min-w-0 relative",children:n.jsxs(Ci,{customSpanClassNameFunc:yd,customSpanEventClassNameFunc:bd,children:[n.jsx(Pd,{onSelectionChange:E}),n.jsx(Bd,{triggerDeselect:p}),n.jsx(zd,{selectRequest:k}),n.jsx(Dd,{trace:_,run:e,hooks:r,isLive:D,onWakeUpSleep:c,onCancelRun:u,onResolveHook:f,onLoadMoreSpans:j,hasMoreSpans:w,isLoadingMoreSpans:x,children:n.jsx(xd,{eagerRender:!0,height:"100%",isLive:D,trace:_})})]})}),I&&n.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:S,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx(Wd,{onResize:F}),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:V,children:V})}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("button",{type:"button","aria-label":"Previous span",onClick:Q,disabled:!z,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:z?"pointer":"not-allowed",opacity:z?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:W=>{z&&(W.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:n.jsx(Oa,{size:16})}),n.jsx("button",{type:"button","aria-label":"Next span",onClick:P,disabled:!$,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:$?"pointer":"not-allowed",opacity:$?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:W=>{$&&(W.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:n.jsx(Ha,{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:M,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:W=>{W.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:n.jsx(ts,{size:16})})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(Bt,{title:"Failed to load entity details",children:n.jsx(ed,{run:e,hooks:r,onStreamClick:h,spanDetailData:i??null,spanDetailError:d,spanDetailLoading:l,onSpanSelect:C,onWakeUpSleep:c,onLoadEventData:b,onResolveHook:f,encryptionKey:g,selectedSpan:I})})})]})]})};async function Vd(e,t,r,o={}){const s=o.resolveData??"all";let a,i;if(t==="run")a=await Nr(hn(e,r,s)),i=a.runId;else if(t==="step"){const{runId:l}=o;if(!l)throw new Rt("runId is required for step resource",{layer:"client"});a=await Nr(Ti(e,l,r,s)),i=a.stepId}else if(t==="hook")a=await Nr(as(e,r,s)),i=a.hookId;else throw new Rt(`Unknown resource type: ${t}`,{layer:"client"});return{data:a,correlationId:i}}function Us(e,t,r,o={}){const{refreshInterval:s=0,runId:a,enabled:i=!0,encryptionKey:l}=o,[d,c]=m.useState(null),[f,u]=m.useState(i),[h,v]=m.useState(null),b=m.useCallback(async w=>l?jr(w,l):Oe(w),[l]),j=m.useCallback(async()=>{if(!i){u(!1);return}if(c(null),v(null),t==="hook"){const{error:w,result:x}=await Re(as(e,r,"all"));if(w){v(w);return}try{c(await b(x))}catch(g){v(g instanceof Error?g:new Error(String(g)))}return}if(t==="sleep"){const{error:w,result:x}=await Re(Dr(e,r,{sortOrder:"asc",limit:100,withData:!0}));if(w){v(w);return}try{const g=await Promise.all(x.data.map(b)),I=Gs(g);if(I===null){v(new Error(`Failed to load ${t} details: missing required event data`));return}c(I)}catch(g){v(g instanceof Error?g:new Error(String(g)))}return}u(!0);try{const{data:w}=await Vd(e,t,r,{runId:a});c(await b(w))}catch(w){w instanceof Error?v(w):v(new Error(String(w)));return}finally{u(!1)}},[e,t,r,a,i,b]);return m.useEffect(()=>{j()},[j]),m.useEffect(()=>{if(!s||s<=0)return;const w=setInterval(j,s);return()=>clearInterval(w)},[s,j]),{data:d,loading:f,error:h,refresh:j}}const Gd=1e3;function Zt(e,t,r){const o=[...e,...t],s=new Map(o.map(a=>[a[r],a]));return Array.from(s.values())}async function sn(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 f=l?c.data.map(l):c.data;return r(h=>Zt(h,f,a)),(i==="onHasMore"?!!(c.cursor&&c.hasMore):!!c.cursor)&&o(c.cursor),!0}return!1}const an=10,Ft=50,Ud=2e3,Kd=5e3;async function qd(e,t){let r=[],o;for(;;){const{error:s,result:a}=await Re(Dr(e,t,{cursor:o,sortOrder:"asc",limit:1e3}));if(s||(r=[...r,...a.data],!a.hasMore||!a.cursor||r.length>=Gd))break;o=a.cursor}return r}async function To(e,t){return t.length===0?[]:(await Promise.all(t.map(o=>qd(e,o)))).flat()}function Yd(e,t,r={}){const{live:o=!1}=r,[s,a]=m.useState(null),[i,l]=m.useState([]),[d,c]=m.useState([]),[f,u]=m.useState([]),[h,v]=m.useState(!0),[b,j]=m.useState(!1),[w,x]=m.useState(null),[g,I]=m.useState(),[N,S]=m.useState(),[R,p]=m.useState(),[y,k]=m.useState(!1),[T,D]=m.useState(!1),[_,C]=m.useState(!1),[E,M]=m.useState(!1),F=m.useRef(!1),[O,z]=m.useState(!1),$=m.useCallback(async()=>{var ce;if(F.current)return;F.current=!0,v(!0),j(!0),x(null);const[Y,ee,A,B]=await Promise.all([Re(hn(e,t)),Re(Yr(e,t,{sortOrder:"asc",limit:Ft})),Re(Zr(e,{runId:t,sortOrder:"asc",limit:Ft})),Re(Xt(e,t,{sortOrder:"asc",limit:Ft}))]);Y.error?x(Y.error):a(Oe(Y.result));const ne=ee.error?[]:ee.result.data.map(Oe),ue=A.error?[]:A.result.data.map(Oe),ge=B.error?[]:B.result.data.map(Oe),q=[...ne.map(ie=>ie.stepId),...ue.map(ie=>ie.hookId)],me=(await To(e,q)).map(Oe);l(ne),c(ue),u(Zt([],[...ge,...me],"eventId")),I(ee.error||!ee.result.hasMore?void 0:ee.result.cursor),S(A.error||!A.result.hasMore?void 0:A.result.cursor),p(B.error||!B.result.hasMore?void 0:B.result.cursor),k(!!(!ee.error&&ee.result.hasMore)),D(!!(!A.error&&A.result.hasMore)),C(!!(!B.error&&B.result.hasMore));const pe=[Y,ee,A,B];if(v(!1),j(!1),z(!0),F.current=!1,!Y.error){const ie=(ce=pe.find(Ie=>Ie.error))==null?void 0:ce.error;ie&&x(ie)}},[e,t]),Q=m.useCallback(async()=>{var Y,ee,A,B,ne,ue;if(!(F.current||!O||E)&&!(!y&&!T&&!_)){M(!0);try{const[ge,q,te]=await Promise.all([y?Re(Yr(e,t,{cursor:g,sortOrder:"asc",limit:Ft})):Promise.resolve({error:null,result:null}),T?Re(Zr(e,{runId:t,cursor:N,sortOrder:"asc",limit:Ft})):Promise.resolve({error:null,result:null}),_?Re(Xt(e,t,{cursor:R,sortOrder:"asc",limit:Ft})):Promise.resolve({error:null,result:null})]);ge.error&&x(ge.error),q.error&&x(q.error),te.error&&x(te.error);const me=((Y=ge.result)==null?void 0:Y.data.map(Oe))??[],pe=((ee=q.result)==null?void 0:ee.data.map(Oe))??[],ce=((A=te.result)==null?void 0:A.data.map(Oe))??[];me.length>0&&l(Ce=>Zt(Ce,me,"stepId")),pe.length>0&&c(Ce=>Zt(Ce,pe,"hookId"));const ie=[...me.map(Ce=>Ce.stepId),...pe.map(Ce=>Ce.hookId)],Ne=(await To(e,ie)).map(Oe),Qe=[...ce,...Ne];Qe.length>0&&u(Ce=>Zt(Ce,Qe,"eventId"));const st=ge.error?y:!!(ge.result&&ge.result.hasMore),at=q.error?T:!!(q.result&&q.result.hasMore),Ye=te.error?_:!!(te.result&&te.result.hasMore);k(st),D(at),C(Ye),ge.error||I((B=ge.result)!=null&&B.hasMore?ge.result.cursor:void 0),q.error||S((ne=q.result)!=null&&ne.hasMore?q.result.cursor:void 0),te.error||p((ue=te.result)!=null&&ue.hasMore?te.result.cursor:void 0)}finally{M(!1)}}},[e,t,O,E,y,T,_,g,N,R]),P=m.useCallback(async()=>{if(s!=null&&s.completedAt)return!1;const{error:Y,result:ee}=await Re(hn(e,t));return Y?(x(Y),!1):(a(Oe(ee)),!0)},[e,t,s==null?void 0:s.completedAt]),V=m.useCallback(()=>sn({fetchFn:()=>Re(Yr(e,t,{cursor:g,sortOrder:"asc",limit:an})),setItems:l,setCursor:I,setError:x,idKey:"stepId",cursorStrategy:"onHasMore",transform:Oe}),[e,t,g]),W=m.useCallback(()=>sn({fetchFn:()=>Re(Zr(e,{runId:t,cursor:N,sortOrder:"asc",limit:an})),setItems:c,setCursor:S,setError:x,idKey:"hookId",transform:Oe}),[e,t,N]),K=m.useCallback(()=>sn({fetchFn:()=>Re(Xt(e,t,{cursor:R,sortOrder:"asc",limit:an})),setItems:u,setCursor:p,setError:x,idKey:"eventId",transform:Oe}),[e,t,R]),U=m.useCallback(async(Y=!1)=>{if(F.current||!O)return{foundNewItems:!1};let ee=!1;try{const[A,B,ne,ue]=await Promise.all([Y?Promise.resolve(!1):P(),V(),Y?Promise.resolve(!1):W(),Y?Promise.resolve(!1):K()]);ee=B||ne||ue}catch(A){console.error("Update error:",A)}return{foundNewItems:ee}},[V,W,K,O,P]);return m.useEffect(()=>{$()},[$]),m.useEffect(()=>{if(!o||!O||s!=null&&s.completedAt)return;const Y=setInterval(()=>{U()},Kd),ee=setInterval(()=>{U(!0)},Ud);return()=>{clearInterval(Y),clearInterval(ee)}},[o,O,U,s==null?void 0:s.completedAt]),{run:s??{},steps:i,hooks:d,events:f,loading:h,auxiliaryDataLoading:b,error:w,update:U,loadMoreTraceData:Q,hasMoreTraceData:y||T||_,isLoadingMoreTraceData:E}}function Zd(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function Xd(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&&Zd(i)?new Rt(i.message,{layer:"client",cause:i.cause,request:i.request}):new Rt(`Failed to read stream: ${a.status}`,{layer:"client"})}if(!a.body)throw new Rt("Failed to read stream: no body",{layer:"client"});return a.body}catch(s){throw s instanceof Rt?s:new Rt("Failed to read stream",{layer:"client",cause:s})}}async function Jd(e,t){return Nr(Ei(e,t))}const Qd=1e4;function eu(e,t,r=Qd){const[o,s]=m.useState([]),[a,i]=m.useState(!0),[l,d]=m.useState(null),c=m.useCallback(async()=>{i(!0),d(null);try{const f=await Jd(e,t);s(f)}catch(f){d(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}},[e,t]);return m.useEffect(()=>{c()},[c]),m.useEffect(()=>{if(!r||r<=0)return;const f=setInterval(c,r);return()=>clearInterval(f)},[r,c]),{streams:o,loading:a,error:l,refresh:c}}var tu=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],gt=tu.reduce((e,t)=>{const r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,l=a?En: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 ru(e,t){e&&Yo.flushSync(()=>e.dispatchEvent(t))}var nu="DismissableLayer",Cn="dismissableLayer.update",ou="dismissableLayer.pointerDownOutside",su="dismissableLayer.focusOutside",Eo,Ks=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qs=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,c=m.useContext(Ks),[f,u]=m.useState(null),h=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=m.useState({}),b=jt(t,p=>u(p)),j=Array.from(c.layers),[w]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=j.indexOf(w),g=f?j.indexOf(f):-1,I=c.layersWithOutsidePointerEventsDisabled.size>0,N=g>=x,S=lu(p=>{const y=p.target,k=[...c.branches].some(T=>T.contains(y));!N||k||(s==null||s(p),i==null||i(p),p.defaultPrevented||l==null||l())},h),R=cu(p=>{const y=p.target;[...c.branches].some(T=>T.contains(y))||(a==null||a(p),i==null||i(p),p.defaultPrevented||l==null||l())},h);return Ba(p=>{g===c.layers.size-1&&(o==null||o(p),!p.defaultPrevented&&l&&(p.preventDefault(),l()))},h),m.useEffect(()=>{if(f)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Eo=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),Ro(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=Eo)}},[f,h,r,c]),m.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),Ro())},[f,c]),m.useEffect(()=>{const p=()=>v({});return document.addEventListener(Cn,p),()=>document.removeEventListener(Cn,p)},[]),n.jsx(gt.div,{...d,ref:b,style:{pointerEvents:I?N?"auto":"none":void 0,...e.style},onFocusCapture:ht(e.onFocusCapture,R.onFocusCapture),onBlurCapture:ht(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:ht(e.onPointerDownCapture,S.onPointerDownCapture)})});qs.displayName=nu;var au="DismissableLayerBranch",iu=m.forwardRef((e,t)=>{const r=m.useContext(Ks),o=m.useRef(null),s=jt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(gt.div,{...e,ref:s})});iu.displayName=au;function lu(e,t=globalThis==null?void 0:globalThis.document){const r=Tr(e),o=m.useRef(!1),s=m.useRef(()=>{});return m.useEffect(()=>{const a=l=>{if(l.target&&!o.current){let d=function(){Ys(ou,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 cu(e,t=globalThis==null?void 0:globalThis.document){const r=Tr(e),o=m.useRef(!1);return m.useEffect(()=>{const s=a=>{a.target&&!o.current&&Ys(su,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 Ro(){const e=new CustomEvent(Cn);document.dispatchEvent(e)}function Ys(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?ru(s,a):s.dispatchEvent(a)}var ln="focusScope.autoFocusOnMount",cn="focusScope.autoFocusOnUnmount",Ao={bubbles:!1,cancelable:!0},du="FocusScope",Zs=m.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=m.useState(null),c=Tr(s),f=Tr(a),u=m.useRef(null),h=jt(t,j=>d(j)),v=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let j=function(I){if(v.paused||!l)return;const N=I.target;l.contains(N)?u.current=N:bt(u.current,{select:!0})},w=function(I){if(v.paused||!l)return;const N=I.relatedTarget;N!==null&&(l.contains(N)||bt(u.current,{select:!0}))},x=function(I){if(document.activeElement===document.body)for(const S of I)S.removedNodes.length>0&&bt(l)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const g=new MutationObserver(x);return l&&g.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),g.disconnect()}}},[o,l,v.paused]),m.useEffect(()=>{if(l){Mo.add(v);const j=document.activeElement;if(!l.contains(j)){const x=new CustomEvent(ln,Ao);l.addEventListener(ln,c),l.dispatchEvent(x),x.defaultPrevented||(uu(gu(Xs(l)),{select:!0}),document.activeElement===j&&bt(l))}return()=>{l.removeEventListener(ln,c),setTimeout(()=>{const x=new CustomEvent(cn,Ao);l.addEventListener(cn,f),l.dispatchEvent(x),x.defaultPrevented||bt(j??document.body,{select:!0}),l.removeEventListener(cn,f),Mo.remove(v)},0)}}},[l,c,f,v]);const b=m.useCallback(j=>{if(!r&&!o||v.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,x=document.activeElement;if(w&&x){const g=j.currentTarget,[I,N]=fu(g);I&&N?!j.shiftKey&&x===N?(j.preventDefault(),r&&bt(I,{select:!0})):j.shiftKey&&x===I&&(j.preventDefault(),r&&bt(N,{select:!0})):x===g&&j.preventDefault()}},[r,o,v.paused]);return n.jsx(gt.div,{tabIndex:-1,...i,ref:h,onKeyDown:b})});Zs.displayName=du;function uu(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(bt(o,{select:t}),document.activeElement!==r)return}function fu(e){const t=Xs(e),r=Do(t,e),o=Do(t.reverse(),e);return[r,o]}function Xs(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 Do(e,t){for(const r of e)if(!mu(r,{upTo:t}))return r}function mu(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 pu(e){return e instanceof HTMLInputElement&&"select"in e}function bt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&pu(e)&&t&&e.select()}}var Mo=hu();function hu(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=_o(e,t),e.unshift(t)},remove(t){var r;e=_o(e,t),(r=e[0])==null||r.resume()}}}function _o(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function gu(e){return e.filter(t=>t.tagName!=="A")}var xu="Portal",Js=m.forwardRef((e,t)=>{var l;const{container:r,...o}=e,[s,a]=m.useState(!1);za(()=>a(!0),[]);const i=r||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?qo.createPortal(n.jsx(gt.div,{...o,ref:t}),i):null});Js.displayName=xu;var $n="Dialog",[Qs,ea]=rs($n),[vu,ot]=Qs($n),ta=e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=m.useRef(null),d=m.useRef(null),[c=!1,f]=$a({prop:o,defaultProp:s,onChange:a});return n.jsx(vu,{scope:t,triggerRef:l,contentRef:d,contentId:Ur(),titleId:Ur(),descriptionId:Ur(),open:c,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:r})};ta.displayName=$n;var ra="DialogTrigger",na=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(ra,r),a=jt(t,s.triggerRef);return n.jsx(gt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Un(s.open),...o,ref:a,onClick:ht(e.onClick,s.onOpenToggle)})});na.displayName=ra;var Vn="DialogPortal",[yu,oa]=Qs(Vn,{forceMount:void 0}),sa=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:s}=e,a=ot(Vn,t);return n.jsx(yu,{scope:t,forceMount:r,children:m.Children.map(o,i=>n.jsx(Tn,{present:r||a.open,children:n.jsx(Js,{asChild:!0,container:s,children:i})}))})};sa.displayName=Vn;var Hr="DialogOverlay",aa=m.forwardRef((e,t)=>{const r=oa(Hr,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=ot(Hr,e.__scopeDialog);return a.modal?n.jsx(Tn,{present:o||a.open,children:n.jsx(bu,{...s,ref:t})}):null});aa.displayName=Hr;var bu=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(Hr,r);return n.jsx(Ga,{as:En,allowPinchZoom:!0,shards:[s.contentRef],children:n.jsx(gt.div,{"data-state":Un(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),Lt="DialogContent",ia=m.forwardRef((e,t)=>{const r=oa(Lt,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=ot(Lt,e.__scopeDialog);return n.jsx(Tn,{present:o||a.open,children:a.modal?n.jsx(wu,{...s,ref:t}):n.jsx(Iu,{...s,ref:t})})});ia.displayName=Lt;var wu=m.forwardRef((e,t)=>{const r=ot(Lt,e.__scopeDialog),o=m.useRef(null),s=jt(t,r.contentRef,o);return m.useEffect(()=>{const a=o.current;if(a)return Va(a)},[]),n.jsx(la,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ht(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ht(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:ht(e.onFocusOutside,a=>a.preventDefault())})}),Iu=m.forwardRef((e,t)=>{const r=ot(Lt,e.__scopeDialog),o=m.useRef(!1),s=m.useRef(!1);return n.jsx(la,{...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()}})}),la=m.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=ot(Lt,r),d=m.useRef(null),c=jt(t,d);return Ua(),n.jsxs(n.Fragment,{children:[n.jsx(Zs,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:a,children:n.jsx(qs,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Un(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(ju,{titleId:l.titleId}),n.jsx(Su,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Gn="DialogTitle",ca=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(Gn,r);return n.jsx(gt.h2,{id:s.titleId,...o,ref:t})});ca.displayName=Gn;var da="DialogDescription",ua=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(da,r);return n.jsx(gt.p,{id:s.descriptionId,...o,ref:t})});ua.displayName=da;var fa="DialogClose",ma=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(fa,r);return n.jsx(gt.button,{type:"button",...o,ref:t,onClick:ht(e.onClick,()=>s.onOpenChange(!1))})});ma.displayName=fa;function Un(e){return e?"open":"closed"}var pa="DialogTitleWarning",[Nu,ha]=Wa(pa,{contentName:Lt,titleName:Gn,docsSlug:"dialog"}),ju=({titleId:e})=>{const t=ha(pa),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 m.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},ku="DialogDescriptionWarning",Su=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ha(ku).contentName}}.`;return m.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},Cu=ta,Tu=na,Eu=sa,Ru=aa,Au=ia,Du=ca,Mu=ua,ga=ma,xa="AlertDialog",[_u]=rs(xa,[ea]),xt=ea(),va=e=>{const{__scopeAlertDialog:t,...r}=e,o=xt(t);return n.jsx(Cu,{...o,...r,modal:!0})};va.displayName=xa;var Lu="AlertDialogTrigger",Ou=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Tu,{...s,...o,ref:t})});Ou.displayName=Lu;var Hu="AlertDialogPortal",ya=e=>{const{__scopeAlertDialog:t,...r}=e,o=xt(t);return n.jsx(Eu,{...o,...r})};ya.displayName=Hu;var Fu="AlertDialogOverlay",ba=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Ru,{...s,...o,ref:t})});ba.displayName=Fu;var Vt="AlertDialogContent",[Pu,Bu]=_u(Vt),wa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:o,...s}=e,a=xt(r),i=m.useRef(null),l=jt(t,i),d=m.useRef(null);return n.jsx(Nu,{contentName:Vt,titleName:Ia,docsSlug:"alert-dialog",children:n.jsx(Pu,{scope:r,cancelRef:d,children:n.jsxs(Au,{role:"alertdialog",...a,...s,ref:l,onOpenAutoFocus:ht(s.onOpenAutoFocus,c=>{var f;c.preventDefault(),(f=d.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[n.jsx(Ri,{children:o}),n.jsx(Wu,{contentRef:i})]})})})});wa.displayName=Vt;var Ia="AlertDialogTitle",Na=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Du,{...s,...o,ref:t})});Na.displayName=Ia;var ja="AlertDialogDescription",ka=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Mu,{...s,...o,ref:t})});ka.displayName=ja;var zu="AlertDialogAction",Sa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(ga,{...s,...o,ref:t})});Sa.displayName=zu;var Ca="AlertDialogCancel",Ta=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,{cancelRef:s}=Bu(Ca,r),a=xt(r),i=jt(t,s);return n.jsx(ga,{...a,...o,ref:i})});Ta.displayName=Ca;var Wu=({contentRef:e})=>{const t=`\`${Vt}\` requires a description for the component to be accessible for screen reader users.
|
|
33
|
+
|
|
34
|
+
You can add a description to the \`${Vt}\` by passing a \`${ja}\` 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 \`${Vt}\`. 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 m.useEffect(()=>{var o;document.getElementById((o=e.current)==null?void 0:o.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},$u=va,Vu=ya,Gu=ba,Uu=wa,Ku=Sa,qu=Ta,Yu=Na,Zu=ka;function Lo({...e}){return n.jsx($u,{"data-slot":"alert-dialog",...e})}function Xu({...e}){return n.jsx(Vu,{"data-slot":"alert-dialog-portal",...e})}function Ju({className:e,...t}){return n.jsx(Gu,{"data-slot":"alert-dialog-overlay",className:qe("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 Oo({className:e,onSubmit:t,...r}){return n.jsxs(Xu,{children:[n.jsx(Ju,{}),n.jsx(Uu,{"data-slot":"alert-dialog-content",className:qe("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 Ho({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-header",className:qe("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Fo({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-footer",className:qe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Po({className:e,...t}){return n.jsx(Yu,{"data-slot":"alert-dialog-title",className:qe("text-lg font-semibold",e),...t})}function Bo({className:e,...t}){return n.jsx(Zu,{"data-slot":"alert-dialog-description",className:qe("text-muted-foreground text-sm",e),...t})}function zo({className:e,...t}){return n.jsx(Ku,{className:qe(is(),e),...t})}function Wo({className:e,...t}){return n.jsx(qu,{className:qe(is({variant:"outline"}),e),...t})}function Qu({...e}){return n.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function ef({className:e,...t}){return n.jsx("ol",{"data-slot":"breadcrumb-list",className:qe("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...t})}function $o({className:e,...t}){return n.jsx("li",{"data-slot":"breadcrumb-item",className:qe("inline-flex items-center gap-1.5",e),...t})}function tf({asChild:e,className:t,...r}){const o=e?En:"a";return n.jsx(o,{"data-slot":"breadcrumb-link",className:qe("hover:text-foreground transition-colors",t),...r})}function rf({className:e,...t}){return n.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:qe("text-foreground font-normal",e),...t})}function nf({children:e,className:t,...r}){return n.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:qe("[&>svg]:size-3.5",t),...r,children:e??n.jsx(Xo,{})})}const Pt={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function Fr(e){return e.replace(/\/\/\.\.\//g,"//")}function of(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 Pr(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function sf(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=Fr(i.data.stepId),d=t.get(l)||[];d.push(i),t.set(l,d);const c=Pr(l);if(c){const f=r.get(c)||[];f.push(i),r.set(c,f)}}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 f=Pr(Fr(i.data.stepId));if(f){const u=a.get(f)||[];u.includes(i)||(u.push(i),a.set(f,u))}}}}return{byStepId:t,byFunctionName:r,primitivesByLabel:o,agentNodes:s,toolNodes:a}}function af(e,t,r){var d,c,f,u;const o=new Map,s=new Set(e),a=new Map;for(const h of t.nodes){const v=(d=h.metadata)==null?void 0:d.parallelGroupId;if(v){const b=a.get(v)||{nodes:[]};b.nodes.push(h),b.method=(c=h.metadata)==null?void 0:c.parallelMethod,a.set(v,b)}}const i=new Map;for(const[h,v]of a)if(v.method==="race"){let b,j;for(const w of v.nodes){const x=r.get(w.id);if(x){for(const g of x)if(g.status==="completed"&&g.completedAt){const I=new Date(g.completedAt);(!j||I<j)&&(j=I,b=w.id)}}}b&&i.set(h,b)}const l=h=>{const v=o.get(h.id);v?v.traversalCount++:o.set(h.id,{edgeId:h.id,traversalCount:1,timings:[]})};for(const h of t.edges){const v=t.nodes.find(I=>I.id===h.source),b=t.nodes.find(I=>I.id===h.target);if(!v||!b)continue;const j=s.has(h.source),w=s.has(h.target);if(!j&&!w)continue;if(h.type==="conditional"){j&&w&&l(h);continue}const x=(f=v.metadata)==null?void 0:f.parallelGroupId,g=(u=v.metadata)==null?void 0:u.parallelMethod;x&&g==="race"?i.get(x)===h.source&&w&&l(h):(j&&w||j&&h.type==="parallel"&&w)&&l(h)}return o}function lf(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 cf(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 df(e,t,r,o,s,a,i){const l=Fr(t),d=s.get(l)||0;s.set(l,d+1);let c=r.get(l)||[],f="step-id";if(c.length===0){const b=Pr(l);b&&(c=o.get(b)||[],f="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:f,strategy:c.length===1?"single-node-multiple-invocations":"occurrence-based"}),!u)return;const h=e.map((b,j)=>of(b,u.id,j,e.length));if(c.length===1){const b=a.get(u.id)||[];a.set(u.id,[...b,...h])}else a.set(u.id,h);return i.includes(u.id)||i.push(u.id),h[h.length-1].status==="running"?u.id:void 0}function uf(e,t,r,o){const s=new Map,a=new Map;for(const x of e){if(!x.correlationId)continue;const g=a.get(x.correlationId)||[];g.push(x),a.set(x.correlationId,g)}let i;const l=t.get(Pt.sleep)||[],d=new Set;for(const x of e)x.eventType==="wait_created"&&x.correlationId&&d.add(x.correlationId);const c=Array.from(d).sort((x,g)=>{var p,y;const I=a.get(x)||[],N=a.get(g)||[],S=(p=I.find(k=>k.eventType==="wait_created"))==null?void 0:p.createdAt,R=(y=N.find(k=>k.eventType==="wait_created"))==null?void 0:y.createdAt;return!S||!R?0:new Date(S).getTime()-new Date(R).getTime()});for(const x of c){const g=a.get(x)||[],I=g.find(C=>C.eventType==="wait_created"),N=g.find(C=>C.eventType==="wait_completed");if(!I)continue;const S=s.get(Pt.sleep)||0;s.set(Pt.sleep,S+1);const R=l.length===1?l[0]:l[S];if(!R)continue;let p="running";N&&(p="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,D={nodeId:R.id,attemptNumber:1,status:p,startedAt:y,completedAt:k,duration:T},_=r.get(R.id)||[];r.set(R.id,[..._,D]),o.includes(R.id)||o.push(R.id),p==="running"&&(i=R.id)}const f=[...t.get(Pt.createHook)||[],...t.get(Pt.createWebhook)||[]],u=new Set;for(const x of e)x.eventType==="hook_created"&&x.correlationId&&u.add(x.correlationId);const h=Array.from(u).sort((x,g)=>{var p,y;const I=a.get(x)||[],N=a.get(g)||[],S=(p=I.find(k=>k.eventType==="hook_created"))==null?void 0:p.createdAt,R=(y=N.find(k=>k.eventType==="hook_created"))==null?void 0:y.createdAt;return!S||!R?0:new Date(S).getTime()-new Date(R).getTime()});let v=0;for(const x of h){const I=(a.get(x)||[]).find(T=>T.eventType==="hook_created");if(!I)continue;const N=f.length===1?f[0]:f[v];if(v++,!N)continue;const S="completed",R=new Date(I.createdAt).toISOString(),p=new Date(I.createdAt).toISOString(),y={nodeId:N.id,attemptNumber:1,status:S,startedAt:R,completedAt:p,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(Pt.awaitWebhook)||[],j=new Set;for(const x of e)x.eventType==="hook_received"&&x.correlationId&&j.add(x.correlationId);let w=0;for(const x of h){const g=b.length===1?b[0]:b[w];if(w++,!g)continue;const I=a.get(x)||[],N=I.find(_=>_.eventType==="hook_created"),S=I.find(_=>_.eventType==="hook_received");let R,p,y,k=0;S?(R="completed",p=N?new Date(N.createdAt).toISOString():new Date(S.createdAt).toISOString(),y=new Date(S.createdAt).toISOString(),k=new Date(y).getTime()-new Date(p).getTime()):N?(R="running",p=new Date(N.createdAt).toISOString()):R="pending";const T={nodeId:g.id,attemptNumber:1,status:R,startedAt:p,completedAt:y,duration:k},D=r.get(g.id)||[];r.set(g.id,[...D,T]),o.includes(g.id)||o.push(g.id)}return i}function ff(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 f={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,[f]),a.includes(c.id)||a.push(c.id)}for(const c of t){const f=Pr(c.stepName);if(!f)continue;const u=o.get(f);if(!u||u.length===0)continue;const h=u[0];let v;switch(c.status){case"completed":v="completed";break;case"failed":v="failed";break;case"running":v="running";break;case"cancelled":v="cancelled";break;case"pending":default:v="pending";break}const b=c.completedAt&&c.startedAt?new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime():void 0,j={nodeId:h.id,stepId:c.stepId,attemptNumber:c.attempt,status:v,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(h.id)||[];s.set(h.id,[...w,j]),a.includes(h.id)||a.push(h.id)}for(const c of i){const f=((d=c.metadata)==null?void 0:d.isToolsCollection)===!0;if(c.data.nodeKind==="tool"&&f&&!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 mf(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 f=(i=c.metadata)==null?void 0:i.conditionalId;if(f){const u=a.get(f)||{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(f,u)}}for(const c of s){const f=c.id.match(/^(cond_\d+)_node$/);if(!f)continue;const u=f[1],h=a.get(u);if(!h)continue;const v=h.thenNodes.some(j=>t.has(j.id)),b=h.elseNodes.some(j=>t.has(j.id));if(v||b){const j=[...h.thenNodes,...h.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 S=N[0];S.startedAt&&(!w||S.startedAt<w)&&(w=S.startedAt)}}const x=o.startedAt?new Date(o.startedAt).toISOString():void 0,g={nodeId:c.id,attemptNumber:1,status:"completed",startedAt:w||x,completedAt:w||x};t.set(c.id,[g])}if(!r.includes(c.id)){const w=j.map(x=>r.indexOf(x.id)).filter(x=>x>=0);if(w.length>0){const x=Math.min(...w);x>=0&&x<r.length?r.splice(x,0,c.id):r.push(c.id)}else r.push(c.id)}}}}function pf(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}),lf(e,o,a,s);const l=[...t].sort((N,S)=>new Date(N.createdAt).getTime()-new Date(S.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:f,agentNodes:u,toolNodes:h}=sf(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?Fr(N.data.stepId):void 0,nodeKind:N.data.nodeKind})),nodesByStepId:Array.from(d.entries()).map(([N,S])=>({stepId:N,nodeIds:S.map(R=>R.id)}))});const v=new Map;let b=[],j=null,w=null;for(let N=0;N<=l.length;N++){const S=l[N];if(!S||S.stepId!==j){if(b.length>0&&w){const p=df(b,w,d,c,v,s,a);p&&(i=p)}S&&(b=[S],j=S.stepId,w=S.stepName)}else b.push(S)}const x=uf(r,f,s,a);x&&(i=x),ff(e,l,u,h,s,a,o.nodes),mf(o,s,a,e),cf(e,o,a,s);const g=af(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,S])=>{var R;return{nodeId:N,executionCount:S.length,latestStatus:(R=S[S.length-1])==null?void 0:R.status}})}),I}function hf(e,t){const[r,o]=m.useState([]),[s,a]=m.useState(!1),[i,l]=m.useState(null),d=m.useRef(null),c=m.useRef(0);return m.useEffect(()=>{if(o([]),l(null),c.current=0,!t){a(!1);return}let f=!0;const u=new AbortController;d.current=u,a(!0);const h=Mi(),v=()=>{f&&a(!1)},b=g=>{f&&(l(g instanceof Error?g.message:String(g)),a(!1))},j=g=>{if(f&&g!==void 0&&g!==null){const I=c.current++;let N;try{N=Di(g,h)}catch{N=g}const S=typeof N=="string"?N:JSON.stringify(N,null,2);o(R=>[...R,{id:I,text:S}])}},w=async g=>{var S;let I=new Uint8Array(0);const N=R=>{const p=new Uint8Array(I.length+R.length);p.set(I,0),p.set(R,I.length),I=p};for(;!((S=d.current)!=null&&S.signal.aborted);){const{value:R,done:p}=await g.read();if(p){v();break}for(N(R);I.length>=4;){const k=new DataView(I.buffer,I.byteOffset,I.byteLength).getUint32(0,!1);if(I.length<4+k)break;const T=I.slice(4,4+k);I=I.slice(4+k);try{const D=Ai(T);j(D)}catch(D){console.error("Failed to decode stream chunk:",D)}}}};return(async()=>{try{const I=(await Xd(e,t,void 0,u.signal)).getReader();await w(I)}catch(g){if(u.signal.aborted)return;b(g)}})(),()=>{f=!1,d.current&&d.current.abort()}},[e,t]),{chunks:r,isLive:s,error:i}}function gf({hasError:e,errorMessage:t}){return n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(gn,{children:[n.jsx(xn,{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(vn,{children:n.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${_i/1e3} seconds`})})]})})}function Vo(e){return e==="retrying"?"running":e}function xf({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(ct,{type:"target",position:dt.Top,className:"!bg-purple-500"}),n.jsx(ct,{type:"source",position:dt.Bottom,className:"!bg-purple-500"}),n.jsx(ct,{type:"source",position:dt.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(ct,{type:"target",position:dt.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})}function vf({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(ct,{type:"target",position:dt.Top,className:"!bg-muted"}),!s&&n.jsx(ct,{type:"source",position:dt.Bottom,className:"!bg-muted"})]})}function yf({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(ct,{type:"target",position:dt.Top,className:"!bg-red-500"}),n.jsx(ct,{type:"source",position:dt.Bottom,id:"bottom",className:"!bg-red-500"}),n.jsx(ct,{type:"source",position:dt.Left,id:"left",className:"!bg-red-500"}),n.jsx(ct,{type:"source",position:dt.Right,id:"right",className:"!bg-red-500"})]})}const bf={loopNode:xf,parallelGroup:Xa,executionNode:vf,diamondNode:yf},wf=Za(oi);function If(e,t){const r=ri(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 Go(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:ni(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(Er,{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(Er,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",Dt(s.duration,!0)]})]})]}):o}const Ea={...ei};function Uo(e,t){var d,c,f;const{nodes:r,groupNodes:o}=ns(e,Ea),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 h=(d=u.metadata)!=null&&d.parallelGroupId?`group_${u.metadata.parallelGroupId}`:null;h&&a.has(h)&&s.set(u.id,h)}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 h=t==null?void 0:t.nodeExecutions.get(u.id),v=If(u.data.nodeKind,h),b=(t==null?void 0:t.currentNode)===u.id,j=!!((c=u.metadata)!=null&&c.loopId),w=!!((f=u.metadata)!=null&&f.loopIsAwait),x=u.data.nodeKind==="conditional",g=x?"diamondNode":j?"loopNode":"executionNode",I=s.get(u.id);let N=u.position;if(I){const R=a.get(I);R&&(N={x:u.position.x-R.x,y:u.position.y-R.y})}const S=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:Go(u.data,u.metadata,h),executions:h,isLoopNode:!0,isAwaitLoop:w,nodeStyle:v,className:S}}):x?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:h,nodeStyle:v,className:S}}):i.push({id:u.id,type:g,position:N,parentId:I,extent:I?"parent":void 0,expandParent:!0,data:{...u.data,label:Go(u.data,u.metadata,h),executions:h,nodeStyle:v,className:S},style:{width:220}})}return i}function Ko(e,t){const{additionalEdges:r}=ns(e,Ea),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 ti(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:Yn.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 p of i.originalEdgeIds){const y=t==null?void 0:t.edgeTraversals.get(p);if(y&&y.traversalCount>0){l=y;break}}const d=l&&l.traversalCount>0,c=!!t,f=l!=null&&l.timings.length?l.timings.reduce((p,y)=>p+y,0)/l.timings.length:void 0;let u="bezier",h,v=i.label,b=!1;switch(i.type){case"parallel":u="smoothstep",h="4,4",v=void 0;break;case"loop":u="step",h="8,4";break;case"conditional":u="smoothstep",h="8,4",b=!0;break;default:u="bezier"}const w=d?"#22c55e":"#6b7280",x=d?void 0:h,g=c&&!d?.35:1,I=d?2.5:1,N=b?"#ffffff":"#6b7280",S=b?"#374151":"#f3f4f6",R=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(Er,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[l.traversalCount,"×"]}),f&&f>0&&n.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["~",Dt(f,!0)]})]}):v,labelStyle:{fill:N,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:S,fillOpacity:.95,stroke:R,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:Yn.ArrowClosed,width:d?14:10,height:d?14:10,color:w},style:{strokeWidth:I,stroke:w,opacity:g,strokeDasharray:x}}})}function Nf({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:f}=Us(t??{},"step",a??"",{runId:i}),u=(c==null?void 0:c.input)??(l==null?void 0:l.input),h=(c==null?void 0:c.output)??(l==null?void 0:l.output),v=(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:Dt(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(ts,{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(dn,{status:Vo(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:Dt(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()})]})]})]}),f&&a&&n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[n.jsx(Mr,{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)})})]})]}),h!==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(h,null,2)})})]})]}),v&&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 v=="object"?JSON.stringify(v,null,2):String(v)})})]})]}),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(dn,{status:Vo(b.status)}),b.duration!==void 0&&b.duration>0&&n.jsx("span",{className:"font-mono text-muted-foreground",children:Dt(b.duration)})]})]},b.attemptNumber))})]})]})]})]})}function jf({workflow:e,execution:t,env:r,onNodeClick:o}){const[s,a]=m.useState(null),i=320,l=m.useMemo(()=>Uo(e,t),[e,t]),d=m.useMemo(()=>Ko(e,t),[e,t]),[c,f,u]=Ka(l),[h,v,b]=qa(d);m.useEffect(()=>{f(x=>{const g=Uo(e,t),I=new Map(x.map(N=>[N.id,N.position]));return g.map(N=>({...N,position:I.get(N.id)??N.position}))}),v(Ko(e,t))},[e,t,f,v]);const j=m.useCallback((x,g)=>{const I=e.nodes.find(N=>N.id===g.id);if(I){const N=g.data.executions||[],S=N[N.length-1];a({nodeId:g.id,node:I,executions:N,stepId:S==null?void 0:S.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=m.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(Ya,{nodes:c,edges:h,onNodesChange:u,onEdgesChange:b,onNodeClick:j,nodeTypes:bf,edgeTypes:wf,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[n.jsx(Ja,{}),n.jsx(Qa,{}),n.jsx(qn,{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(qn,{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(Er,{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(Nf,{selectedNode:s,env:r,onClose:w})})]})}function kf({run:e,allSteps:t,allEvents:r,env:o}){const{manifest:s,loading:a,error:i}=pi(),l=m.useMemo(()=>{var v;if(!s||!e.workflowName)return null;const c=String(e.workflowName).trim(),f=s.workflows[c];if(f)return f;const u=(v=It(c))==null?void 0:v.shortName;return Object.values(s.workflows).find(b=>{var j;return b.workflowId===c||b.workflowName===c?!0:u?((j=It(b.workflowName))==null?void 0:j.shortName)===u:!1})??null},[s,e.workflowName]),d=m.useMemo(()=>!l||!e.runId?null:pf(e,t||[],r||[],l),[l,e,t,r]);return a?n.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[n.jsx(Mr,{className:"h-8 w-8 animate-spin text-muted-foreground"}),n.jsx("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):i?n.jsx("div",{className:"flex items-center justify-center w-full h-full p-4",children:n.jsxs(un,{variant:"destructive",className:"max-w-lg",children:[n.jsx(fn,{className:"h-4 w-4"}),n.jsx(mn,{children:"Error Loading Workflow Graph"}),n.jsx(pn,{children:i.message})]})}):l?n.jsx(jf,{workflow:l,execution:d||void 0,env:o}):n.jsx("div",{className:"flex items-center justify-center w-full h-full",children:n.jsxs(un,{className:"max-w-lg",children:[n.jsx(fn,{className:"h-4 w-4"}),n.jsx(mn,{children:"Workflow Graph Not Found"}),n.jsx(pn,{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."})]})})}const Sf=new Set(["run_created","run_started","run_completed","run_failed","run_cancelled"]);function Cf({runId:e,selectedId:t}){var Ce;const r=Ra(),[o]=Zo(),{serverConfig:s}=Li(),[a,i]=m.useState(!1),[l,d]=m.useState(!1),[c,f]=m.useState(!1),[u,h]=m.useState(!1),v=m.useMemo(()=>({}),[]),b=o.get("tab")||"trace",j=o.get("streamId"),w=m.useCallback(Z=>{const je=new URLSearchParams(o.toString());for(const[Te,_e]of Object.entries(Z))_e===null?je.delete(Te):je.set(Te,_e);r(`?${je.toString()}`,{preventScrollReset:!0})},[r,o]),x=m.useCallback(Z=>{w(Z==="trace"||Z==="graph"?{tab:Z,streamId:null}:{tab:Z})},[w]),g=m.useCallback(Z=>{w({streamId:Z})},[w]),I=m.useCallback(Z=>{w({tab:"streams",streamId:Z})},[w]),N=m.useCallback(async(Z,je)=>si(v,Z,{correlationIds:[je]}),[v]),S=m.useRef(null),R=m.useCallback(async(Z,je)=>{await ai(v,Z,je)},[v]),p=m.useCallback(async Z=>{if(!Sf.has(Z.eventType)&&Z.correlationId){const{error:De,result:et}=await Re(Dr(v,Z.correlationId,{sortOrder:"asc",limit:100,withData:!0}));if(De)throw De;const vt=et.data.find(Ze=>Ze.eventId===Z.eventId);if(!vt)return null;const Me=S.current?await jr(vt,S.current):Oe(vt);return"eventData"in Me?Me.eventData:null}const{error:Te,result:_e}=await Re(Xt(v,Z.runId,{sortOrder:"desc",limit:1e3,withData:!0}));if(Te)throw Te;let Le=_e.data.find(De=>De.eventId===Z.eventId);if(!Le){const{error:De,result:et}=await Re(Xt(v,Z.runId,{sortOrder:"asc",limit:1e3,withData:!0}));if(De)throw De;Le=et.data.find(vt=>vt.eventId===Z.eventId)}if(!Le)return null;const Fe=S.current?await jr(Le,S.current):Oe(Le);return"eventData"in Fe?Fe.eventData:null},[v]),y=m.useCallback(async(Z,je)=>{const{error:Te,result:_e}=await Re(Dr(v,Z,{sortOrder:"asc",limit:100,withData:!0}));if(Te)throw Te;const Le=_e.data.find(De=>De.eventId===je);if(!Le)return null;const Fe=S.current?await jr(Le,S.current):Oe(Le);return"eventData"in Fe?Fe.eventData:null},[v]),k=s.backendId==="local"||s.backendId==="@workflow/world-local",{run:T,steps:D,hooks:_,events:C,loading:E,auxiliaryDataLoading:M,error:F,update:O,loadMoreTraceData:z,hasMoreTraceData:$,isLoadingMoreTraceData:Q}=Yd(v,e,{live:!0}),P=T??{},[V,W]=m.useState(null);S.current=V;const[K,U]=m.useState(null),{data:Y,loading:ee,error:A,refresh:B}=Us(v,(K==null?void 0:K.resource)??"run",(K==null?void 0:K.resourceId)??"",{runId:K==null?void 0:K.runId,enabled:!!(K!=null&&K.resource&&(K!=null&&K.resourceId)&&K.resource!=="hook"),encryptionKey:V??void 0}),ne=m.useCallback(async()=>{if(V){B();return}const{error:Z,result:je}=await Re(Oi(v,e));if(Z){he.error(`Failed to fetch encryption key: ${Z.message}`);return}if(!je){he.error("Encryption is not configured for this deployment.");return}W(je)},[V,v,e,B]),ue=m.useCallback(Z=>{U(Z)},[]),{streams:ge,loading:q,error:te}=eu(v,e),{chunks:me,isLive:pe,error:ce}=hf(v,j),ie=()=>{f(!0)},Ie=async()=>{if(!a)try{i(!0),f(!1),await fi(v,e),await O(),he.success("Run cancelled successfully")}catch(Z){console.error("Failed to cancel run:",Z),he.error("Failed to cancel run",{description:Z instanceof Error?Z.message:"An unknown error occurred"})}finally{i(!1)}},Ne=()=>{h(!0)},Qe=async()=>{if(!l)try{d(!0),h(!1);const Z=await mi(v,P.runId);he.success("New run started successfully",{description:`Run ID: ${Z}`}),r(`/run/${Z}`)}catch(Z){console.error("Failed to re-run workflow:",Z),he.error("Failed to start new run",{description:Z instanceof Error?Z.message:"An unknown error occurred"})}finally{d(!1),h(!1)}};if(F&&!T)return n.jsxs(un,{variant:"destructive",className:"m-4",children:[n.jsx(fn,{className:"h-4 w-4"}),n.jsx(mn,{children:"Error loading workflow run"}),n.jsx(pn,{children:F.message})]});const st=(Ce=It(P.workflowName))==null?void 0:Ce.shortName;return n.jsxs(n.Fragment,{children:[n.jsx(Lo,{open:c,onOpenChange:f,children:n.jsxs(Oo,{children:[n.jsxs(Ho,{children:[n.jsx(Po,{children:"Cancel Workflow Run?"}),n.jsx(Bo,{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(Fo,{children:[n.jsx(Wo,{children:"Keep Running"}),n.jsx(zo,{onClick:Ie,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),n.jsx(Lo,{open:u,onOpenChange:h,children:n.jsxs(Oo,{children:[n.jsxs(Ho,{children:[n.jsx(Po,{children:"Replay Run?"}),n.jsx(Bo,{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(Fo,{children:[n.jsx(Wo,{children:"Cancel"}),n.jsx(zo,{onClick:Qe,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(Qu,{children:n.jsxs(ef,{children:[n.jsx($o,{children:n.jsx(tf,{asChild:!0,children:n.jsx(Aa,{to:"/",children:"Runs"})})}),n.jsx(nf,{}),n.jsx($o,{children:n.jsx(rf,{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:st||n.jsx(Tt,{className:"w-[260px] h-[28px]"})})}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(gf,{hasError:!1,errorMessage:""}),(lt(P.input)||lt(P.output)||lt(P.error)||D.some(Z=>lt(Z.input)||lt(Z.output)))&&n.jsxs(gn,{children:[n.jsx(xn,{asChild:!0,children:n.jsx("span",{children:n.jsxs(Hi,{variant:"outline",size:"sm",onClick:ne,disabled:!!V,children:[V?n.jsx(Gi,{className:"h-4 w-4"}):n.jsx(os,{className:"h-4 w-4"}),V?"Decrypted":"Decrypt"]})})}),n.jsx(vn,{children:V?n.jsx("p",{children:"Data has been decrypted for this workflow run. All encrypted input, output, and event data is now visible across all tabs."}):n.jsx("p",{children:"This run's data is end-to-end encrypted. Decrypt to reveal input, output, and event data across all tabs for this workflow run."})})]}),n.jsx(ii,{env:v,runId:e,runStatus:P.status,events:C,eventsLoading:M,loading:E,onRerunClick:Ne,onCancelClick:ie,callbacks:{onSuccess:O}})]})]}),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(dn,{status:P.status,context:P}):n.jsx(Tt,{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(),je=Math.floor(Z/1e3);if(je<60)return`${je}s`;const Te=Math.floor(je/60),_e=je%60;if(Te<60)return _e>0?`${Te}m ${_e}s`:`${Te}m`;const Le=Math.floor(Te/60),Fe=Te%60;return Fe>0?`${Le}h ${Fe}m`:`${Le}h`})():"-":n.jsx(Tt,{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(li,{text:P.runId,children:n.jsx("div",{className:"text-xs mt-0.5 font-mono",children:P.runId})}):n.jsx(Tt,{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(hr,{date:P.createdAt})}):n.jsx(Tt,{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(hr,{date:P.startedAt}):"-":n.jsx(Tt,{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(hr,{date:P.completedAt}):"-":n.jsx(Tt,{className:"w-[110px] h-[20px]"})})]}),P.expiredAt!=null&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs(gn,{children:[n.jsx(xn,{asChild:!0,children:n.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",n.jsx(Bi,{className:"w-3 h-3"})]})}),n.jsx(vn,{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(hr,{date:P.expiredAt})})]})]})]})]}),n.jsxs("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[n.jsxs(ci,{value:b,onValueChange:Z=>x(Z),className:"flex-1 flex flex-col min-h-0",children:[n.jsxs(di,{className:"mb-4 flex-none",children:[n.jsxs(gr,{value:"trace",className:"gap-2",children:[n.jsx(Xr,{className:"h-4 w-4"}),"Trace"]}),k&&n.jsxs(gr,{value:"graph",className:"gap-2",children:[n.jsx(ui,{className:"h-4 w-4"}),"Graph"]}),n.jsxs(gr,{value:"events",className:"gap-2",children:[n.jsx(Xr,{className:"h-4 w-4"}),"Events"]}),n.jsxs(gr,{value:"streams",className:"gap-2",children:[n.jsx(Xr,{className:"h-4 w-4"}),"Streams"]})]}),n.jsx(xr,{value:"trace",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{title:"Failed to load trace viewer",children:n.jsx("div",{className:"h-full",children:n.jsx($d,{error:F,steps:D,events:C,hooks:_,run:P,isLoading:E,spanDetailData:Y,spanDetailLoading:ee,spanDetailError:A,onSpanSelect:ue,onStreamClick:I,onWakeUpSleep:N,onResolveHook:R,onLoadEventData:y,onLoadMoreSpans:z,hasMoreSpans:$,isLoadingMoreSpans:Q,encryptionKey:V??void 0})})})}),n.jsx(xr,{value:"events",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{title:"Failed to load events list",children:n.jsx("div",{className:"h-full",children:n.jsx(Ec,{events:C,steps:D,run:P,onLoadEventData:p,encryptionKey:V??void 0})})})}),n.jsx(xr,{value:"streams",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{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 (",ge.length,")"]}),n.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:q?n.jsx("div",{className:"p-4 flex items-center justify-center",children:n.jsx(Mr,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):te?n.jsx("div",{className:"p-4 text-xs text-destructive",children:te.message}):ge.length===0?n.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):ge.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(Fi,{streamId:j,chunks:me,isLive:pe,error:ce}):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:ge.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),k&&n.jsx(xr,{value:"graph",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{title:"Failed to load execution graph",children:n.jsx("div",{className:"h-full min-h-[500px]",children:n.jsx(kf,{run:P,allSteps:D,allEvents:C,env:v})})})})]}),M&&n.jsxs("div",{className:"fixed flex items-center gap-2 left-8 bottom-8 bg-background border rounded-md px-4 py-2 shadow-lg",children:[n.jsx(Mr,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}const Af=Da(function(){const t=Ma(),[r]=Zo(),o=t.runId,s=r.get("stepId"),a=r.get("eventId"),i=r.get("hookId"),l=s||a||i||void 0;return n.jsx(Bt,{title:"Failed to load run details",children:n.jsx(Cf,{runId:o,selectedId:l})})});export{Af as default};
|