@workflow/web 4.1.0-beta.33 → 4.1.0-beta.34

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.
Files changed (130) hide show
  1. package/build/client/assets/{_basePickBy-BSvRKJRE.js → _basePickBy-DHDscq_f.js} +1 -1
  2. package/build/client/assets/{_baseUniq-Cab7DZbu.js → _baseUniq-BKX8gPoI.js} +1 -1
  3. package/build/client/assets/{arc-b7TbQmwf.js → arc--nRtbI8K.js} +1 -1
  4. package/build/client/assets/{architectureDiagram-VXUJARFQ-Ji8dOswE.js → architectureDiagram-VXUJARFQ-_Qc-tmxG.js} +1 -1
  5. package/build/client/assets/{blockDiagram-VD42YOAC-CX2Wzsv1.js → blockDiagram-VD42YOAC-dlWy-WHR.js} +1 -1
  6. package/build/client/assets/{c4Diagram-YG6GDRKO-DqBbtKFb.js → c4Diagram-YG6GDRKO-KwMhvreD.js} +1 -1
  7. package/build/client/assets/channel-Dzz8OuVo.js +1 -0
  8. package/build/client/assets/{chunk-4BX2VUAB-CsPvZKuB.js → chunk-4BX2VUAB-B4nDiCVl.js} +1 -1
  9. package/build/client/assets/{chunk-55IACEB6-C4xaF8F-.js → chunk-55IACEB6-C255NtjG.js} +1 -1
  10. package/build/client/assets/{chunk-B4BG7PRW-DUd2h51q.js → chunk-B4BG7PRW-DrawBXGd.js} +1 -1
  11. package/build/client/assets/{chunk-DI55MBZ5-DD4LiUfc.js → chunk-DI55MBZ5-06r_lbX1.js} +1 -1
  12. package/build/client/assets/{chunk-FMBD7UC4-BB-smuzA.js → chunk-FMBD7UC4-BC40KRYB.js} +1 -1
  13. package/build/client/assets/{chunk-QN33PNHL-CNrK2tOA.js → chunk-QN33PNHL-sjb1wNJd.js} +1 -1
  14. package/build/client/assets/{chunk-QZHKN3VN-DmUQnaxW.js → chunk-QZHKN3VN-DnAziOBQ.js} +1 -1
  15. package/build/client/assets/{chunk-TZMSLE5B-Dwo3zeAN.js → chunk-TZMSLE5B-VkRv8IvH.js} +1 -1
  16. package/build/client/assets/classDiagram-2ON5EDUG-DABRK9Qx.js +1 -0
  17. package/build/client/assets/classDiagram-v2-WZHVMYZB-DABRK9Qx.js +1 -0
  18. package/build/client/assets/clone-j6wLTJEP.js +1 -0
  19. package/build/client/assets/{code-block-IT6T5CEO-CNZ5MxhC.js → code-block-IT6T5CEO-BOexmHI_.js} +1 -1
  20. package/build/client/assets/{cose-bilkent-S5V4N54A-BV-y7VDL.js → cose-bilkent-S5V4N54A-Bt5Edg9U.js} +1 -1
  21. package/build/client/assets/{dagre-6UL2VRFP-BJTkZs6c.js → dagre-6UL2VRFP-YWTvJR0y.js} +1 -1
  22. package/build/client/assets/{diagram-PSM6KHXK-BaDYUHAJ.js → diagram-PSM6KHXK-BLq_k4Yr.js} +1 -1
  23. package/build/client/assets/{diagram-QEK2KX5R-DO4MlVP9.js → diagram-QEK2KX5R-BI3cylAU.js} +1 -1
  24. package/build/client/assets/{diagram-S2PKOQOG--N35p3Fa.js → diagram-S2PKOQOG-Edzm6MKm.js} +1 -1
  25. package/build/client/assets/{erDiagram-Q2GNP2WA-DlpgBGum.js → erDiagram-Q2GNP2WA-Cnz8iVxF.js} +1 -1
  26. package/build/client/assets/{flowDiagram-NV44I4VS-GKLhP-VT.js → flowDiagram-NV44I4VS-HZaVPGp0.js} +1 -1
  27. package/build/client/assets/{ganttDiagram-JELNMOA3-BGT2qQ9m.js → ganttDiagram-JELNMOA3-tGMRJ7F2.js} +1 -1
  28. package/build/client/assets/{gitGraphDiagram-NY62KEGX-BjzGiQgq.js → gitGraphDiagram-NY62KEGX-BWBaaTab.js} +1 -1
  29. package/build/client/assets/{graph-CV0EOvGG.js → graph-Cjwr8MRV.js} +1 -1
  30. package/build/client/assets/{home-D5hRpWJP.js → home-DjQfihAH.js} +3 -3
  31. package/build/client/assets/{infoDiagram-WHAUD3N6-C8BGiPuO.js → infoDiagram-WHAUD3N6-zxf98IY_.js} +1 -1
  32. package/build/client/assets/{journeyDiagram-XKPGCS4Q-C-NZgKD8.js → journeyDiagram-XKPGCS4Q-BYSsRfkq.js} +1 -1
  33. package/build/client/assets/{kanban-definition-3W4ZIXB7-CmCrGz6m.js → kanban-definition-3W4ZIXB7-DwifGaQE.js} +1 -1
  34. package/build/client/assets/{layout-CGeWZKGg.js → layout-ZKGw0hWT.js} +1 -1
  35. package/build/client/assets/{manifest-cd7ef090.js → manifest-9c74fca4.js} +1 -1
  36. package/build/client/assets/mermaid-VLURNSYL-DFbTcPsZ.js +467 -0
  37. package/build/client/assets/mermaid-VLURNSYL-DKxHcEOp.css +1 -0
  38. package/build/client/assets/{mermaid.core-CCG8erLJ.js → mermaid.core-CAJGJsUa.js} +5 -5
  39. package/build/client/assets/{mindmap-definition-VGOIOE7T-CriYhHk6.js → mindmap-definition-VGOIOE7T-Brr4Ue8p.js} +1 -1
  40. package/build/client/assets/{pieDiagram-ADFJNKIX-BO7R9v-y.js → pieDiagram-ADFJNKIX-BZBT_6SI.js} +1 -1
  41. package/build/client/assets/{quadrantDiagram-AYHSOK5B-B5XzeB0n.js → quadrantDiagram-AYHSOK5B-B5SsXhND.js} +1 -1
  42. package/build/client/assets/{requirementDiagram-UZGBJVZJ-Ctzr7pHT.js → requirementDiagram-UZGBJVZJ-C_2tqoJn.js} +1 -1
  43. package/build/client/assets/root-1lSMDQJV.css +1 -0
  44. package/build/client/assets/{root-ZDvxwknh.js → root-Dj7SY8Pc.js} +1 -1
  45. package/build/client/assets/run-detail-CjlkBO0W.js +34 -0
  46. package/build/client/assets/{sankeyDiagram-TZEHDZUN-3998XFH6.js → sankeyDiagram-TZEHDZUN-DDokcrb5.js} +1 -1
  47. package/build/client/assets/{sequenceDiagram-WL72ISMW--TYcsXLK.js → sequenceDiagram-WL72ISMW-bQjozZq_.js} +1 -1
  48. package/build/client/assets/server-build-CSzEkmuy.css +1 -0
  49. package/build/client/assets/{stateDiagram-FKZM4ZOC-KFOT_-fi.js → stateDiagram-FKZM4ZOC-BsdcjN4g.js} +1 -1
  50. package/build/client/assets/stateDiagram-v2-4FDKWEC3-zx6ygxzt.js +1 -0
  51. package/build/client/assets/{timeline-definition-IT6M3QCI-BWpMX-Al.js → timeline-definition-IT6M3QCI-BdQl6KLI.js} +1 -1
  52. package/build/client/assets/{treemap-KMMF4GRG-BoG-yO-d.js → treemap-KMMF4GRG-BlxmRVP8.js} +1 -1
  53. package/build/client/assets/use-workflow-graph-jEZXDidH.js +161 -0
  54. package/build/client/assets/worker-D-HfgUMl.js +1 -0
  55. package/build/client/assets/{xychartDiagram-PRI3JC2R-TErXr7lU.js → xychartDiagram-PRI3JC2R-SMO1MIZH.js} +1 -1
  56. package/build/server/assets/{_basePickBy-CX5bp78g.js → _basePickBy-DDu9sZ05.js} +2 -2
  57. package/build/server/assets/{_baseUniq-DRbeMsjX.js → _baseUniq-CPezvtNf.js} +1 -1
  58. package/build/server/assets/{app-Ct2AiOlb.js → app-tswq4nS6.js} +1 -1
  59. package/build/server/assets/{arc-t9dVPERH.js → arc-COFK4tNT.js} +1 -1
  60. package/build/server/assets/{architecture-U656AL7Q-y8nc6yoa.js → architecture-U656AL7Q-D8-7L2pd.js} +9 -9
  61. package/build/server/assets/{architectureDiagram-VXUJARFQ-65LZOjwE.js → architectureDiagram-VXUJARFQ-Dmds_6dm.js} +10 -10
  62. package/build/server/assets/{blockDiagram-VD42YOAC-DTb4W0Pg.js → blockDiagram-VD42YOAC-CXaPa5qT.js} +10 -10
  63. package/build/server/assets/{c4Diagram-YG6GDRKO-Dr9EimIQ.js → c4Diagram-YG6GDRKO-C3a1-A9U.js} +6 -6
  64. package/build/server/assets/{channel-CeTZ6cfq.js → channel-Cqc0_Vqq.js} +1 -1
  65. package/build/server/assets/{chunk-4BX2VUAB-BSqKh-tP.js → chunk-4BX2VUAB-BgHKdQkc.js} +1 -1
  66. package/build/server/assets/{chunk-55IACEB6-tU3Z2y0r.js → chunk-55IACEB6-BS3kwVef.js} +2 -2
  67. package/build/server/assets/{chunk-B4BG7PRW-AgB7GYhY.js → chunk-B4BG7PRW-DRp6hZKh.js} +5 -5
  68. package/build/server/assets/{chunk-DI55MBZ5-CnFyUXi5.js → chunk-DI55MBZ5-D-k1Hmln.js} +3 -3
  69. package/build/server/assets/{chunk-FMBD7UC4-C4D6Vih_.js → chunk-FMBD7UC4-ypfWW--F.js} +1 -1
  70. package/build/server/assets/{chunk-QN33PNHL-BWUiZFmI.js → chunk-QN33PNHL-vSeUi0io.js} +1 -1
  71. package/build/server/assets/{chunk-QZHKN3VN-awnfUhvo.js → chunk-QZHKN3VN-CJweWAVV.js} +1 -1
  72. package/build/server/assets/{chunk-TZMSLE5B-BrA0CaNT.js → chunk-TZMSLE5B-BG7b2aOM.js} +1 -1
  73. package/build/server/assets/{classDiagram-2ON5EDUG-Cmc4RXkN.js → classDiagram-2ON5EDUG-B1pjby_P.js} +9 -9
  74. package/build/server/assets/{classDiagram-v2-WZHVMYZB-Cmc4RXkN.js → classDiagram-v2-WZHVMYZB-B1pjby_P.js} +9 -9
  75. package/build/server/assets/{clone-DNbOTSdB.js → clone-CXCQCPMW.js} +1 -1
  76. package/build/server/assets/{code-block-IT6T5CEO-_Bf5MAq6.js → code-block-IT6T5CEO-CFv2mhYI.js} +4 -4
  77. package/build/server/assets/{cose-bilkent-S5V4N54A-CaReuWZP.js → cose-bilkent-S5V4N54A-Cjbmp-ES.js} +5 -5
  78. package/build/server/assets/{dagre-6UL2VRFP-COsY4Lyv.js → dagre-6UL2VRFP-BbWNd8fN.js} +10 -10
  79. package/build/server/assets/{diagram-PSM6KHXK-Dm0Fe5sv.js → diagram-PSM6KHXK-Dl23OO_-.js} +11 -11
  80. package/build/server/assets/{diagram-QEK2KX5R-CCIvnOol.js → diagram-QEK2KX5R-CNO3f8cc.js} +10 -10
  81. package/build/server/assets/{diagram-S2PKOQOG-2MfjgdUt.js → diagram-S2PKOQOG-Drj3AuMx.js} +10 -10
  82. package/build/server/assets/{erDiagram-Q2GNP2WA-C9fdzOgi.js → erDiagram-Q2GNP2WA-BrRdaTe4.js} +8 -8
  83. package/build/server/assets/{flowDiagram-NV44I4VS-M2lc5NSN.js → flowDiagram-NV44I4VS-eQV3TE_c.js} +9 -9
  84. package/build/server/assets/{ganttDiagram-JELNMOA3-C6yOZXI7.js → ganttDiagram-JELNMOA3-D4gxbiXq.js} +6 -6
  85. package/build/server/assets/{gitGraph-F6HP7TQM-CgNkNcS7.js → gitGraph-F6HP7TQM-x0JoiISN.js} +9 -9
  86. package/build/server/assets/{gitGraphDiagram-NY62KEGX-BohvofvN.js → gitGraphDiagram-NY62KEGX-OFqTvfp8.js} +11 -11
  87. package/build/server/assets/{graph-Ulmn-yXw.js → graph-gP5x0CkQ.js} +2 -2
  88. package/build/server/assets/{info-NVLQJR56-B3PAkPx_.js → info-NVLQJR56-r2B6fs17.js} +9 -9
  89. package/build/server/assets/{infoDiagram-WHAUD3N6-CSjKOLrY.js → infoDiagram-WHAUD3N6-ClKO2as2.js} +9 -9
  90. package/build/server/assets/{journeyDiagram-XKPGCS4Q-CejSWxVS.js → journeyDiagram-XKPGCS4Q-Br1X2sDn.js} +8 -8
  91. package/build/server/assets/{kanban-definition-3W4ZIXB7-BhuBMvlP.js → kanban-definition-3W4ZIXB7-DpE4JZsR.js} +6 -6
  92. package/build/server/assets/{layout-B-L3j8Rc.js → layout-oT-uoF-3.js} +4 -4
  93. package/build/server/assets/{linear-Dp71QvUo.js → linear-BOu-nm13.js} +1 -1
  94. package/build/server/assets/{mermaid-VLURNSYL-CdyI-shq.js → mermaid-VLURNSYL-BBI-ZyxS.js} +4 -4
  95. package/build/server/assets/{mermaid-parser.core-DdkPioAn.js → mermaid-parser.core-COrs4xZP.js} +11 -11
  96. package/build/server/assets/{mermaid.core-CemR7tEN.js → mermaid.core-DSfg9DTI.js} +32 -32
  97. package/build/server/assets/{mindmap-definition-VGOIOE7T-B4vd6EZB.js → mindmap-definition-VGOIOE7T-Dls2nsge.js} +7 -7
  98. package/build/server/assets/{packet-BFZMPI3H-DUWEPgP3.js → packet-BFZMPI3H-DYdsV9oG.js} +9 -9
  99. package/build/server/assets/{pie-7BOR55EZ-DHneZ_Ix.js → pie-7BOR55EZ-Ib4gWu3n.js} +9 -9
  100. package/build/server/assets/{pieDiagram-ADFJNKIX-Bzr8lGKZ.js → pieDiagram-ADFJNKIX-B2HEjzVX.js} +11 -11
  101. package/build/server/assets/{quadrantDiagram-AYHSOK5B-Dl_o12VO.js → quadrantDiagram-AYHSOK5B-DAo4x7XW.js} +6 -6
  102. package/build/server/assets/{radar-NHE76QYJ-CnmLDbJw.js → radar-NHE76QYJ-EcIj4-c2.js} +9 -9
  103. package/build/server/assets/{requirementDiagram-UZGBJVZJ-Cbh0w4zx.js → requirementDiagram-UZGBJVZJ-5NKwD2mU.js} +7 -7
  104. package/build/server/assets/{sankeyDiagram-TZEHDZUN-BOPcYcn_.js → sankeyDiagram-TZEHDZUN-CLeMeI5j.js} +5 -5
  105. package/build/server/assets/{sequenceDiagram-WL72ISMW-BKMEdsnU.js → sequenceDiagram-WL72ISMW-ow3l4Fri.js} +7 -7
  106. package/build/server/assets/{server-build-D669WCiG.js → server-build-CuKE6nMq.js} +7782 -2600
  107. package/build/server/assets/{stateDiagram-FKZM4ZOC-DA26FXV3.js → stateDiagram-FKZM4ZOC-DzFqDl8d.js} +12 -12
  108. package/build/server/assets/{stateDiagram-v2-4FDKWEC3-B_ssjkDp.js → stateDiagram-v2-4FDKWEC3-CvVm2xRM.js} +8 -8
  109. package/build/server/assets/{timeline-definition-IT6M3QCI-BPsZLSW8.js → timeline-definition-IT6M3QCI-Bl1QIB4i.js} +6 -6
  110. package/build/server/assets/{token-PtbssUN9.js → token-B0LCPjeP.js} +3 -3
  111. package/build/server/assets/{token-util-DCZzRns1.js → token-util-CIfvkrUB.js} +1 -1
  112. package/build/server/assets/{token-util-C4BdVs1n.js → token-util-Cu8l3cno.js} +2 -2
  113. package/build/server/assets/{treemap-KMMF4GRG-CbDzD3EG.js → treemap-KMMF4GRG-DwpOgdit.js} +9 -9
  114. package/build/server/assets/{xychartDiagram-PRI3JC2R-CSYLDeXX.js → xychartDiagram-PRI3JC2R--odlRvS3.js} +6 -6
  115. package/build/server/index.js +1 -1
  116. package/package.json +6 -6
  117. package/build/client/assets/channel-BB5IrGvL.js +0 -1
  118. package/build/client/assets/classDiagram-2ON5EDUG-BeXXmaeG.js +0 -1
  119. package/build/client/assets/classDiagram-v2-WZHVMYZB-BeXXmaeG.js +0 -1
  120. package/build/client/assets/clone-BAxTKVXy.js +0 -1
  121. package/build/client/assets/katex-BbEIqZs1.js +0 -261
  122. package/build/client/assets/mermaid-VLURNSYL-BJjrZ9jp.css +0 -1
  123. package/build/client/assets/mermaid-VLURNSYL-DZspIWfV.js +0 -478
  124. package/build/client/assets/root-AOcWXHD9.css +0 -1
  125. package/build/client/assets/run-detail-DPyEEMdn.js +0 -24
  126. package/build/client/assets/server-build-YTP8tmIR.css +0 -1
  127. package/build/client/assets/stateDiagram-v2-4FDKWEC3-B_evGZn5.js +0 -1
  128. package/build/client/assets/use-workflow-graph-CSOGwdVi.js +0 -149
  129. package/build/client/assets/worker-DIhmOA3S.js +0 -1
  130. package/build/server/assets/katex-B7AUlPkp.js +0 -14519
@@ -0,0 +1,34 @@
1
+ import{R as $,v as r,b as x,B as jo,f as ko,y as na,z as Co,A as ra,w as oa,D as sa}from"./index-DS8xNWtl.js";import{Q as wn,B as kt,j as So,p as To,U as tr,V as aa,Z as ia,S as Eo,R as Ro,X as Ao,O as Rt,Y as la,_ as ca,G as da,$ as ua,a0 as fa,a1 as ma,a2 as pa,a3 as Nr,a4 as ha,t as rt,a5 as dn,a6 as ga,s as Do,a7 as xa,q as va,a8 as Tn,v as nr,l as ba,m as ya,a9 as wa,aa as Na,ab as Ia,ac as ja,ad as ka,ae as Ca,af as Sa,ag as Ta,ah as Ea,ai as Ra,aj as Ir,J as un,ak as Mo,al as Aa,am as Da,an as jr,ao as Ye,ap as Ze,aq as Lo,F as Wn,ar as Ma,as as La,at as _a,au as Ha,r as Oa,av as Zt,aw as En,ax as Fa,ay as Pa,A as $n,C as Vn,c as Gn,d as Un,a as Nt,az as za,e as Ba,b as Jt,T as Wa,L as $a,M as Qt,K as Va,N as en,y as Ga,aA as Ua,I as Ka}from"./use-workflow-graph-jEZXDidH.js";import{c as Nn,E as jt,F as dt,G as Bt,_ as qa,H as Xa,I as Ya,J as Za,t as pe,K as mt,M as ot,N as q,O as Ja,Q as Qa,U as Rn,W as _e,X as tn,Y as fn,Z as At,$ as ut,a0 as _o,a1 as Ot,a2 as An,a3 as ei,a4 as ti,a5 as ni,a6 as ri,a7 as oi,a8 as si,a9 as ai,aa as rr,v as ht,ab as ii,d as Pe,ac as Ho,ad as li,ae as ci,T as Oo,a as Fo,b as Po,af as di,L as mn,u as ui,h as kr,x as Cr,ag as fi}from"./mermaid-VLURNSYL-DFbTcPsZ.js";import"./transform-BcRQlmJM.js";import"./value-BxRBhsAB.js";/**
2
+ * @license lucide-react v0.469.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 mi=Nn("CircleHelp",[["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"}]]);/**
7
+ * @license lucide-react v0.469.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const pi=Nn("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
12
+ * @license lucide-react v0.469.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 Dn=Nn("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
17
+ * @license lucide-react v0.469.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 hi=Nn("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]),In=0,gt=1,_t=2,zo=4;function Sr(e){return()=>e}function gi(e){e()}function Bo(e,t){return n=>e(t(n))}function Tr(e,t){return()=>e(t)}function xi(e,t){return n=>e(t,n)}function or(e){return e!==void 0}function vi(...e){return()=>{e.map(gi)}}function Ht(){}function jn(e,t){return t(e),e}function bi(e,t){return t(e)}function ge(...e){return e}function le(e,t){return e(gt,t)}function ee(e,t){e(In,t)}function sr(e){e(_t)}function Ee(e){return e(zo)}function U(e,t){return le(e,xi(t,In))}function Qe(e,t){const n=e(gt,o=>{n(),t(o)});return n}function Er(e){let t,n;return o=>s=>{t=s,n&&clearTimeout(n),n=setTimeout(()=>{o(t)},e)}}function Wo(e,t){return e===t}function he(e=Wo){let t;return n=>o=>{e(t,o)||(t=o,n(o))}}function X(e){return t=>n=>{e(n)&&t(n)}}function z(e){return t=>Bo(t,e)}function Xe(e){return t=>()=>{t(e)}}function M(e,...t){const n=yi(...t);return(o,s)=>{switch(o){case _t:sr(e);return;case gt:return le(e,n(s))}}}function Je(e,t){return n=>o=>{n(t=e(t,o))}}function Lt(e){return t=>n=>{e>0?e--:t(n)}}function ft(e){let t=null,n;return o=>s=>{t=s,!n&&(n=setTimeout(()=>{n=void 0,o(t)},e))}}function ne(...e){const t=new Array(e.length);let n=0,o=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,l)=>{const i=Math.pow(2,l);le(a,d=>{const c=n;n=n|i,t[l]=d,c!==s&&n===s&&o&&(o(),o=null)})}),a=>l=>{const i=()=>{a([l].concat(t))};n===s?i():o=i}}function yi(...e){return t=>e.reduceRight(bi,t)}function wi(e){let t,n;const o=()=>t==null?void 0:t();return function(s,a){switch(s){case gt:return a?n===a?void 0:(o(),n=a,t=le(e,a),t):(o(),Ht);case _t:o(),n=null;return}}}function O(e){let t=e;const n=se();return(o,s)=>{switch(o){case In:t=s;break;case gt:{s(t);break}case zo:return t}return n(o,s)}}function Re(e,t){return jn(O(t),n=>U(e,n))}function se(){const e=[];return(t,n)=>{switch(t){case In:e.slice().forEach(o=>{o(n)});return;case _t:e.splice(0,e.length);return;case gt:return e.push(n),()=>{const o=e.indexOf(n);o>-1&&e.splice(o,1)}}}}function Oe(e){return jn(se(),t=>U(e,t))}function ae(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:Ni(),singleton:n}}const Ni=()=>Symbol();function Ii(e){const t=new Map,n=({constructor:o,dependencies:s,id:a,singleton:l})=>{if(l&&t.has(a))return t.get(a);const i=o(s.map(d=>n(d)));return l&&t.set(a,i),i};return n(e)}function Ie(...e){const t=se(),n=new Array(e.length);let o=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,l)=>{const i=Math.pow(2,l);le(a,d=>{n[l]=d,o=o|i,o===s&&ee(t,n)})}),function(a,l){switch(a){case _t:{sr(t);return}case gt:return o===s&&l(n),le(t,l)}}}function Y(e,t=Wo){return M(e,he(t))}function Rr(...e){return function(t,n){switch(t){case _t:return;case gt:return vi(...e.map(o=>le(o,n)))}}}var Fe=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Fe||{});const ji={0:"debug",3:"error",1:"log",2:"warn"},ki=()=>typeof globalThis>"u"?window:globalThis,xt=ae(()=>{const e=O(3);return{log:O((t,n,o=1)=>{var s;const a=(s=ki().VIRTUOSO_LOG_LEVEL)!=null?s:Ee(e);o>=a&&console[ji[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0});function St(e,t,n){return ar(e,t,n).callbackRef}function ar(e,t,n){const o=$.useRef(null);let s=l=>{};const a=$.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(l=>{const i=()=>{const d=l[0].target;d.offsetParent!==null&&e(d)};n?i():requestAnimationFrame(i)}):null,[e,n]);return s=l=>{l&&t?(a==null||a.observe(l),o.current=l):(o.current&&(a==null||a.unobserve(o.current)),o.current=null)},{callbackRef:s,ref:o}}function Ci(e,t,n,o,s,a,l,i,d){const c=$.useCallback(f=>{const u=Si(f.children,t,i?"offsetWidth":"offsetHeight",s);let p=f.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const m=p.lastElementChild.dataset.viewportType==="window";let C;m&&(C=p.ownerDocument.defaultView);const v=l?i?l.scrollLeft:l.scrollTop:m?i?C.scrollX||C.document.documentElement.scrollLeft:C.scrollY||C.document.documentElement.scrollTop:i?p.scrollLeft:p.scrollTop,k=l?i?l.scrollWidth:l.scrollHeight:m?i?C.document.documentElement.scrollWidth:C.document.documentElement.scrollHeight:i?p.scrollWidth:p.scrollHeight,g=l?i?l.offsetWidth:l.offsetHeight:m?i?C.innerWidth:C.innerHeight:i?p.offsetWidth:p.offsetHeight;o({scrollHeight:k,scrollTop:Math.max(v,0),viewportHeight:g}),a==null||a(i?Ar("column-gap",getComputedStyle(f).columnGap,s):Ar("row-gap",getComputedStyle(f).rowGap,s)),u!==null&&e(u)},[e,t,s,a,l,o,i]);return ar(c,n,d)}function Si(e,t,n,o){const s=e.length;if(s===0)return null;const a=[];for(let l=0;l<s;l++){const i=e.item(l);if(i.dataset.index===void 0)continue;const d=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),f=t(i,n);if(f===0&&o("Zero-sized element, this should not happen",{child:i},Fe.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 Ar(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Fe.WARN),t==="normal"?0:parseInt(t??"0",10)}function $o(e,t,n){const o=$.useRef(null),s=$.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const c=d.getBoundingClientRect(),f=c.width;let u,p;if(t){const m=t.getBoundingClientRect(),C=c.top-m.top;p=m.height-Math.max(0,C),u=C+t.scrollTop}else{const m=l.current.ownerDocument.defaultView;p=m.innerHeight-Math.max(0,c.top),u=c.top+m.scrollY}o.current={offsetTop:u,visibleHeight:p,visibleWidth:f},e(o.current)},[e,t]),{callbackRef:a,ref:l}=ar(s,!0,n),i=$.useCallback(()=>{s(l.current)},[s,l]);return $.useEffect(()=>{var d;if(t){t.addEventListener("scroll",i);const c=new ResizeObserver(()=>{requestAnimationFrame(i)});return c.observe(t),()=>{t.removeEventListener("scroll",i),c.unobserve(t)}}else{const c=(d=l.current)==null?void 0:d.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",i),c==null||c.addEventListener("resize",i),()=>{c==null||c.removeEventListener("scroll",i),c==null||c.removeEventListener("resize",i)}}},[i,t,l]),a}const Me=ae(()=>{const e=se(),t=se(),n=O(0),o=se(),s=O(0),a=se(),l=se(),i=O(0),d=O(0),c=O(0),f=O(0),u=se(),p=se(),m=O(!1),C=O(!1),v=O(!1);return U(M(e,z(({scrollTop:k})=>k)),t),U(M(e,z(({scrollHeight:k})=>k)),l),U(t,s),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:d,footerHeight:f,headerHeight:i,horizontalDirection:C,scrollBy:p,scrollContainerState:e,scrollHeight:l,scrollingInProgress:m,scrollTo:u,scrollTop:t,skipAnimationFrameInResizeObserver:v,smoothScrollTargetReached:o,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),Wt={lvl:0};function Vo(e,t){const n=e.length;if(n===0)return[];let{index:o,value:s}=t(e[0]);const a=[];for(let l=1;l<n;l++){const{index:i,value:d}=t(e[l]);a.push({end:i-1,start:o,value:s}),o=i,s=d}return a.push({end:1/0,start:o,value:s}),a}function ue(e){return e===Wt}function $t(e,t){if(!ue(e))return t===e.k?e.v:t<e.k?$t(e.l,t):$t(e.r,t)}function $e(e,t,n="k"){if(ue(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const o=$e(e.r,t,n);return o[0]===-1/0?[e.k,e.v]:o}return $e(e.l,t,n)}function He(e,t,n){return ue(e)?Ko(t,n,1):t===e.k?Ne(e,{k:t,v:n}):t<e.k?Dr(Ne(e,{l:He(e.l,t,n)})):Dr(Ne(e,{r:He(e.r,t,n)}))}function Dt(){return Wt}function kn(e,t,n){if(ue(e))return[];const o=$e(e,t)[0];return Ti(qn(e,o,n))}function Kn(e,t){if(ue(e))return Wt;const{k:n,l:o,r:s}=e;if(t===n){if(ue(o))return s;if(ue(s))return o;{const[a,l]=Uo(o);return an(Ne(e,{k:a,l:Go(o),v:l}))}}else return t<n?an(Ne(e,{l:Kn(o,t)})):an(Ne(e,{r:Kn(s,t)}))}function It(e){return ue(e)?[]:[...It(e.l),{k:e.k,v:e.v},...It(e.r)]}function qn(e,t,n){if(ue(e))return[];const{k:o,l:s,r:a,v:l}=e;let i=[];return o>t&&(i=i.concat(qn(s,t,n))),o>=t&&o<=n&&i.push({k:o,v:l}),o<=n&&(i=i.concat(qn(a,t,n))),i}function an(e){const{l:t,lvl:n,r:o}=e;if(o.lvl>=n-1&&t.lvl>=n-1)return e;if(n>o.lvl+1){if(Mn(t))return qo(Ne(e,{lvl:n-1}));if(!ue(t)&&!ue(t.r))return Ne(t.r,{l:Ne(t,{r:t.r.l}),lvl:n,r:Ne(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(Mn(e))return Xn(Ne(e,{lvl:n-1}));if(!ue(o)&&!ue(o.l)){const s=o.l,a=Mn(s)?o.lvl-1:o.lvl;return Ne(s,{l:Ne(e,{lvl:n-1,r:s.l}),lvl:s.lvl+1,r:Xn(Ne(o,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Ne(e,t){return Ko(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 Go(e){return ue(e.r)?e.l:an(Ne(e,{r:Go(e.r)}))}function Mn(e){return ue(e)||e.lvl>e.r.lvl}function Uo(e){return ue(e.r)?[e.k,e.v]:Uo(e.r)}function Ko(e,t,n,o=Wt,s=Wt){return{k:e,l:o,lvl:n,r:s,v:t}}function Dr(e){return Xn(qo(e))}function qo(e){const{l:t}=e;return!ue(t)&&t.lvl===e.lvl?Ne(t,{r:Ne(e,{l:t.r})}):e}function Xn(e){const{lvl:t,r:n}=e;return!ue(n)&&!ue(n.r)&&n.lvl===t&&n.r.lvl===t?Ne(n,{l:Ne(e,{r:n.l}),lvl:t+1}):e}function Ti(e){return Vo(e,({k:t,v:n})=>({index:t,value:n}))}function Xo(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Vt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ir=ae(()=>({recalcInProgress:O(!1)}),[],{singleton:!0});function Yo(e,t,n){return e[pn(e,t,n)]}function pn(e,t,n,o=0){let s=e.length-1;for(;o<=s;){const a=Math.floor((o+s)/2),l=e[a],i=n(l,t);if(i===0)return a;if(i===-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 Ei(e,t,n,o){const s=pn(e,t,o),a=pn(e,n,o,s);return e.slice(s,a+1)}function pt(e,t){return Math.round(e.getBoundingClientRect()[t])}function Cn(e){return!ue(e.groupOffsetTree)}function lr({index:e},t){return t===e?0:t<e?-1:1}function Ri(){return{groupIndices:[],groupOffsetTree:Dt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Dt()}}function Ai(e,t){let n=ue(e)?0:1/0;for(const o of t){const{endIndex:s,size:a,startIndex:l}=o;if(n=Math.min(n,l),ue(e)){e=He(e,0,a);continue}const i=kn(e,l-1,s+1);if(i.some(Fi(o)))continue;let d=!1,c=!1;for(const{end:f,start:u,value:p}of i)d?(s>=u||a===p)&&(e=Kn(e,u)):(c=p!==a,d=!0),f>s&&s>=u&&p!==a&&(e=He(e,s+1,p));c&&(e=He(e,l,a))}return[e,n]}function Di(e){return typeof e.groupIndex<"u"}function Mi({offset:e},t){return t===e?0:t<e?-1:1}function Gt(e,t,n){if(t.length===0)return 0;const{index:o,offset:s,size:a}=Yo(t,e,lr),l=e-o,i=a*l+(l-1)*n+s;return i>0?i+n:i}function Zo(e,t){if(!Cn(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function Jo(e,t,n){if(Di(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?n:e.index;let s=Zo(o,t);return s=Math.max(0,s,Math.min(n,s)),s}}function Li(e,t,n,o=0){return o>0&&(t=Math.max(t,Yo(e,o,lr).offset)),Vo(Ei(e,t,n,Mi),Oi)}function _i(e,[t,n,o,s]){t.length>0&&o("received item sizes",t,Fe.DEBUG);const a=e.sizeTree;let l=a,i=0;if(n.length>0&&ue(a)&&t.length===2){const p=t[0].size,m=t[1].size;l=n.reduce((C,v)=>He(He(C,v,p),v+1,m),l)}else[l,i]=Ai(l,t);if(l===a)return e;const{lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u}=Yn(e.offsetTree,i,l,s);return{groupIndices:n,groupOffsetTree:n.reduce((p,m)=>He(p,m,Gt(m,u,s)),Dt()),lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u,sizeTree:l}}function Hi(e){return It(e).map(({k:t,v:n},o,s)=>{const a=s[o+1];return{endIndex:a?a.k-1:1/0,size:n,startIndex:t}})}function Mr(e,t){let n=0,o=0;for(;n<e;)n+=t[o+1]-t[o]-1,o++;return o-(n===e?0:1)}function Yn(e,t,n,o){let s=e,a=0,l=0,i=0,d=0;if(t!==0){d=pn(s,t-1,lr),i=s[d].offset;const c=$e(n,t-1);a=c[0],l=c[1],s.length&&s[d].size===$e(n,t)[1]&&(d-=1),s=s.slice(0,d+1)}else s=[];for(const{start:c,value:f}of kn(n,t,1/0)){const u=c-a,p=u*l+i+u*o;s.push({index:c,offset:p,size:f}),a=c,i=p,l=f}return{lastIndex:a,lastOffset:i,lastSize:l,offsetTree:s}}function Oi(e){return{index:e.index,value:e}}function Fi(e){const{endIndex:t,size:n,startIndex:o}=e;return s=>s.start===o&&(s.end===t||s.end===1/0)&&s.value===n}const Pi={offsetHeight:"height",offsetWidth:"width"},et=ae(([{log:e},{recalcInProgress:t}])=>{const n=se(),o=se(),s=Re(o,0),a=se(),l=se(),i=O(0),d=O([]),c=O(void 0),f=O(void 0),u=O((j,b)=>pt(j,Pi[b])),p=O(void 0),m=O(0),C=Ri(),v=Re(M(n,ne(d,e,m),Je(_i,C),he()),C),k=Re(M(d,he(),Je((j,b)=>({current:b,prev:j.current}),{current:[],prev:[]}),z(({prev:j})=>j)),[]);U(M(d,X(j=>j.length>0),ne(v,m),z(([j,b,w])=>{const y=j.reduce((S,A,L)=>He(S,A,Gt(A,b.offsetTree,w)||L),Dt());return{...b,groupIndices:j,groupOffsetTree:y}})),v),U(M(o,ne(v),X(([j,{lastIndex:b}])=>j<b),z(([j,{lastIndex:b,lastSize:w}])=>[{endIndex:b,size:w,startIndex:j}])),n),U(c,f);const g=Re(M(c,z(j=>j===void 0)),!0);U(M(f,X(j=>j!==void 0&&ue(Ee(v).sizeTree)),z(j=>[{endIndex:0,size:j,startIndex:0}])),n);const h=Oe(M(n,ne(v),Je(({sizes:j},[b,w])=>({changed:w!==j,sizes:w}),{changed:!1,sizes:C}),z(j=>j.changed)));le(M(i,Je((j,b)=>({diff:j.prev-b,prev:b}),{diff:0,prev:0}),z(j=>j.diff)),j=>{const{groupIndices:b}=Ee(v);if(j>0)ee(t,!0),ee(a,j+Mr(j,b));else if(j<0){const w=Ee(k);w.length>0&&(j-=Mr(-j,w)),ee(l,j)}}),le(M(i,ne(e)),([j,b])=>{j<0&&b("`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:i},Fe.ERROR)});const N=Oe(a);U(M(a,ne(v),z(([j,b])=>{const w=b.groupIndices.length>0,y=[],S=b.lastSize;if(w){const A=$t(b.sizeTree,0);let L=0,D=0;for(;L<j;){const T=b.groupIndices[D],H=b.groupIndices.length===D+1?1/0:b.groupIndices[D+1]-T-1;y.push({endIndex:T,size:A,startIndex:T}),y.push({endIndex:T+1+H-1,size:S,startIndex:T+1}),D++,L+=H+1}const E=It(b.sizeTree);return L!==j&&E.shift(),E.reduce((T,{k:H,v:P})=>{let F=T.ranges;return T.prevSize!==0&&(F=[...T.ranges,{endIndex:H+j-1,size:T.prevSize,startIndex:T.prevIndex}]),{prevIndex:H+j,prevSize:P,ranges:F}},{prevIndex:j,prevSize:0,ranges:y}).ranges}return It(b.sizeTree).reduce((A,{k:L,v:D})=>({prevIndex:L+j,prevSize:D,ranges:[...A.ranges,{endIndex:L+j-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:S,ranges:[]}).ranges})),n);const I=Oe(M(l,ne(v,m),z(([j,{offsetTree:b},w])=>{const y=-j;return Gt(y,b,w)})));return U(M(l,ne(v,m),z(([j,b,w])=>{if(b.groupIndices.length>0){if(ue(b.sizeTree))return b;let y=Dt();const S=Ee(k);let A=0,L=0,D=0;for(;A<-j;){D=S[L];const E=S[L+1]-D-1;L++,A+=E+1}if(y=It(b.sizeTree).reduce((E,{k:T,v:H})=>He(E,Math.max(0,T+j),H),y),A!==-j){const E=$t(b.sizeTree,D);y=He(y,0,E);const T=$e(b.sizeTree,-j+1)[1];y=He(y,1,T)}return{...b,sizeTree:y,...Yn(b.offsetTree,0,y,w)}}else{const y=It(b.sizeTree).reduce((S,{k:A,v:L})=>He(S,Math.max(0,A+j),L),Dt());return{...b,sizeTree:y,...Yn(b.offsetTree,0,y,w)}}})),v),{beforeUnshiftWith:N,data:p,defaultItemSize:f,firstItemIndex:i,fixedItemSize:c,gap:m,groupIndices:d,itemSize:u,listRefresh:h,shiftWith:l,shiftWithOffset:I,sizeRanges:n,sizes:v,statefulTotalCount:s,totalCount:o,trackItemSizes:g,unshiftWith:a}},ge(xt,ir),{singleton:!0});function zi(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const Qo=ae(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:o,scrollTop:s}])=>{const a=se(),l=se(),i=Oe(M(a,z(zi)));return U(M(i,z(d=>d.totalCount)),n),U(M(i,z(d=>d.groupIndices)),e),U(M(Ie(s,t,o),X(([d,c])=>Cn(c)),z(([d,c,f])=>$e(c.groupOffsetTree,Math.max(d-f,0),"v")[0]),he(),z(d=>[d])),l),{groupCounts:a,topItemsIndexes:l}},ge(et,Me)),vt=ae(([{log:e}])=>{const t=O(!1),n=Oe(M(t,X(o=>o),he()));return le(t,o=>{o&&Ee(e)("props updated",{},Fe.DEBUG)}),{didMount:n,propsReady:t}},ge(xt),{singleton:!0}),Bi=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function es(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Bi)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const Kt=ae(([{gap:e,listRefresh:t,sizes:n,totalCount:o},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:l,headerHeight:i,scrollingInProgress:d,scrollTo:c,smoothScrollTargetReached:f,viewportHeight:u},{log:p}])=>{const m=se(),C=se(),v=O(0);let k=null,g=null,h=null;function N(){k&&(k(),k=null),h&&(h(),h=null),g&&(clearTimeout(g),g=null),ee(d,!1)}return U(M(m,ne(n,u,o,v,i,l,p),ne(e,a,s),z(([[I,j,b,w,y,S,A,L],D,E,T])=>{const H=es(I),{align:P,behavior:F,offset:_}=H,B=w-1,V=Jo(H,j,B);let G=Gt(V,j.offsetTree,D)+S;P==="end"?(G+=E+$e(j.sizeTree,V)[1]-b+T,V===B&&(G+=A)):P==="center"?G+=(E+$e(j.sizeTree,V)[1]-b+T)/2:G-=y,_&&(G+=_);const oe=ve=>{N(),ve?(L("retrying to scroll to",{location:I},Fe.DEBUG),ee(m,I)):(ee(C,!0),L("list did not change, scroll successful",{},Fe.DEBUG))};if(N(),F==="smooth"){let ve=!1;h=le(t,be=>{ve=ve||be}),k=Qe(f,()=>{oe(ve)})}else k=Qe(M(t,Wi(150)),oe);return g=setTimeout(()=>{N()},1200),ee(d,!0),L("scrolling from index to",{behavior:F,index:V,top:G},Fe.DEBUG),{behavior:F,top:G}})),c),{scrollTargetReached:C,scrollToIndex:m,topListHeight:v}},ge(et,Me,xt),{singleton:!0});function Wi(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(n))}}}function cr(e,t){e==0?t():requestAnimationFrame(()=>{cr(e-1,t)})}function dr(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const qt=ae(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:o},{scrollTargetReached:s,scrollToIndex:a},{didMount:l}])=>{const i=O(!0),d=O(0),c=O(!0);return U(M(l,ne(d),X(([f,u])=>!!u),Xe(!1)),i),U(M(l,ne(d),X(([f,u])=>!!u),Xe(!1)),c),le(M(Ie(t,l),ne(i,n,e,c),X(([[,f],u,{sizeTree:p},m,C])=>f&&(!ue(p)||or(m))&&!u&&!C),ne(d)),([,f])=>{Qe(s,()=>{ee(c,!0)}),cr(4,()=>{Qe(o,()=>{ee(i,!0)}),ee(a,f)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:i}},ge(et,Me,Kt,vt),{singleton:!0});function ts(e,t){return Math.abs(e-t)<1.01}const Ut="up",Pt="down",$i="none",Vi={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Gi=0,Xt=ae(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:o,scrollTop:s,viewportHeight:a}])=>{const l=O(!1),i=O(!0),d=se(),c=se(),f=O(4),u=O(Gi),p=Re(M(Rr(M(Y(s),Lt(1),Xe(!0)),M(Y(s),Lt(1),Xe(!1),Er(100))),he()),!1),m=Re(M(Rr(M(n,Xe(!0)),M(n,Xe(!1),Er(200))),he()),!1);U(M(Ie(Y(s),Y(u)),z(([h,N])=>h<=N),he()),i),U(M(i,ft(50)),c);const C=Oe(M(Ie(o,Y(a),Y(t),Y(e),Y(f)),Je((h,[{scrollHeight:N,scrollTop:I},j,b,w,y])=>{const S=I+j-N>-y,A={scrollHeight:N,scrollTop:I,viewportHeight:j};if(S){let D,E;return I>h.state.scrollTop?(D="SCROLLED_DOWN",E=h.state.scrollTop-I):(D="SIZE_DECREASED",E=h.state.scrollTop-I||h.scrollTopDelta),{atBottom:!0,atBottomBecause:D,scrollTopDelta:E,state:A}}let L;return A.scrollHeight>h.state.scrollHeight?L="SIZE_INCREASED":j<h.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":I<h.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:A}},Vi),he((h,N)=>h&&h.atBottom===N.atBottom))),v=Re(M(o,Je((h,{scrollHeight:N,scrollTop:I,viewportHeight:j})=>{if(ts(h.scrollHeight,N))return{changed:!1,jump:0,scrollHeight:N,scrollTop:I};{const b=N-(I+j)<1;return h.scrollTop!==I&&b?{changed:!0,jump:h.scrollTop-I,scrollHeight:N,scrollTop:I}:{changed:!0,jump:0,scrollHeight:N,scrollTop:I}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),X(h=>h.changed),z(h=>h.jump)),0);U(M(C,z(h=>h.atBottom)),l),U(M(l,ft(50)),d);const k=O(Pt);U(M(o,z(({scrollTop:h})=>h),he(),Je((h,N)=>Ee(m)?{direction:h.direction,prevScrollTop:N}:{direction:N<h.prevScrollTop?Ut:Pt,prevScrollTop:N},{direction:Pt,prevScrollTop:0}),z(h=>h.direction)),k),U(M(o,ft(50),Xe($i)),k);const g=O(0);return U(M(p,X(h=>!h),Xe(0)),g),U(M(s,ft(100),ne(p),X(([h,N])=>!!N),Je(([h,N],[I])=>[N,I],[0,0]),z(([h,N])=>N-h)),g),{atBottomState:C,atBottomStateChange:d,atBottomThreshold:f,atTopStateChange:c,atTopThreshold:u,isAtBottom:l,isAtTop:i,isScrolling:p,lastJumpDueToItemResize:v,scrollDirection:k,scrollVelocity:g}},ge(Me)),hn="top",gn="bottom",Lr="none";function _r(e,t,n){return typeof e=="number"?n===Ut&&t===hn||n===Pt&&t===gn?e:0:n===Ut?t===hn?e.main:e.reverse:t===gn?e.main:e.reverse}function Hr(e,t){var n;return typeof e=="number"?e:(n=e[t])!=null?n:0}const ur=ae(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:o,viewportHeight:s}])=>{const a=se(),l=O(0),i=O(0),d=O(0),c=Re(M(Ie(Y(o),Y(s),Y(n),Y(a,Vt),Y(d),Y(l),Y(t),Y(e),Y(i)),z(([f,u,p,[m,C],v,k,g,h,N])=>{const I=f-h,j=k+g,b=Math.max(p-I,0);let w=Lr;const y=Hr(N,hn),S=Hr(N,gn);return m-=h,m+=p+g,C+=p+g,C-=h,m>f+j-y&&(w=Ut),C<f-b+u+S&&(w=Pt),w!==Lr?[Math.max(I-p-_r(v,hn,w)-y,0),I-b-g+u+_r(v,gn,w)+S]:null}),X(f=>f!=null),he(Vt)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:d,topListHeight:l,visibleRange:c}},ge(Me),{singleton:!0});function Ui(e,t,n){if(Cn(t)){const o=Zo(e,t);return[{index:$e(t.groupOffsetTree,o)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:o,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const Ln={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function ln(e,t,n,o,s,a){const{lastIndex:l,lastOffset:i,lastSize:d}=s;let c=0,f=0;if(e.length>0){c=e[0].offset;const v=e[e.length-1];f=v.offset+v.size}const u=n-l,p=i+u*d+(u-1)*o,m=c,C=p-f;return{bottom:f,firstItemIndex:a,items:Or(e,s,a),offsetBottom:C,offsetTop:c,top:m,topItems:Or(t,s,a),topListHeight:t.reduce((v,k)=>k.size+v,0),totalCount:n}}function ns(e,t,n,o,s,a){let l=0;if(n.groupIndices.length>0)for(const f of n.groupIndices){if(f-l>=e)break;l++}const i=e+l,d=dr(t,i),c=Array.from({length:i}).map((f,u)=>({data:a[u+d],index:u+d,offset:0,size:0}));return ln(c,[],i,s,n,o)}function Or(e,t,n){if(e.length===0)return[];if(!Cn(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const o=e[0].index,s=e[e.length-1].index,a=[],l=kn(t.groupOffsetTree,o,s);let i,d=0;for(const c of e){(!i||i.end<c.index)&&(i=l.shift(),d=t.groupIndices.indexOf(i.start));let f;c.index===i.start?f={index:d,type:"group"}:f={groupIndex:d,index:c.index-(d+1)+n},a.push({...f,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return a}const Tt=ae(([{data:e,firstItemIndex:t,gap:n,sizes:o,totalCount:s},a,{listBoundary:l,topListHeight:i,visibleRange:d},{initialTopMostItemIndex:c,scrolledToInitialItem:f},{topListHeight:u},p,{didMount:m},{recalcInProgress:C}])=>{const v=O([]),k=O(0),g=se();U(a.topItemsIndexes,v);const h=Re(M(Ie(m,C,Y(d,Vt),Y(s),Y(o),Y(c),f,Y(v),Y(t),Y(n),e),X(([b,w,,y,,,,,,,S])=>{const A=S&&S.length!==y;return b&&!w&&!A}),z(([,,[b,w],y,S,A,L,D,E,T,H])=>{const P=S,{offsetTree:F,sizeTree:_}=P,B=Ee(k);if(y===0)return{...Ln,totalCount:y};if(b===0&&w===0)return B===0?{...Ln,totalCount:y}:ns(B,A,S,E,T,H||[]);if(ue(_))return B>0?null:ln(Ui(dr(A,y),P,H),[],y,T,P,E);const V=[];if(D.length>0){const J=D[0],Q=D[D.length-1];let ie=0;for(const R of kn(_,J,Q)){const K=R.value,re=Math.max(R.start,J),ce=Math.min(R.end,Q);for(let fe=re;fe<=ce;fe++)V.push({data:H==null?void 0:H[fe],index:fe,offset:ie,size:K}),ie+=K}}if(!L)return ln([],V,y,T,P,E);const G=D.length>0?D[D.length-1]+1:0,oe=Li(F,b,w,G);if(oe.length===0)return null;const ve=y-1,be=jn([],J=>{for(const Q of oe){const ie=Q.value;let R=ie.offset,K=Q.start;const re=ie.size;if(ie.offset<b){K+=Math.floor((b-ie.offset+T)/(re+T));const fe=K-Q.start;R+=fe*re+fe*T}K<G&&(R+=(G-K)*re,K=G);const ce=Math.min(Q.end,ve);for(let fe=K;fe<=ce&&!(R>=w);fe++)J.push({data:H==null?void 0:H[fe],index:fe,offset:R,size:re}),R+=re+T}});return ln(be,V,y,T,P,E)}),X(b=>b!==null),he()),Ln);U(M(e,X(or),z(b=>b==null?void 0:b.length)),s),U(M(h,z(b=>b.topListHeight)),u),U(u,i),U(M(h,z(b=>[b.top,b.bottom])),l),U(M(h,z(b=>b.items)),g);const N=Oe(M(h,X(({items:b})=>b.length>0),ne(s,e),X(([{items:b},w])=>b[b.length-1].originalIndex===w-1),z(([,b,w])=>[b-1,w]),he(Vt),z(([b])=>b))),I=Oe(M(h,ft(200),X(({items:b,topItems:w})=>b.length>0&&b[0].originalIndex===w.length),z(({items:b})=>b[0].index),he())),j=Oe(M(h,X(({items:b})=>b.length>0),z(({items:b})=>{let w=0,y=b.length-1;for(;b[w].type==="group"&&w<y;)w++;for(;b[y].type==="group"&&y>w;)y--;return{endIndex:b[y].index,startIndex:b[w].index}}),he(Xo)));return{endReached:N,initialItemCount:k,itemsRendered:g,listState:h,rangeChanged:j,startReached:I,topItemsIndexes:v,...p}},ge(et,Qo,ur,qt,Kt,Xt,vt,ir),{singleton:!0}),rs=ae(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:o},{listState:s}])=>{const a=se(),l=Re(M(Ie(n,e,o,t,s),z(([i,d,c,f,u])=>i+d+c+f+u.offsetBottom+u.bottom)),0);return U(Y(l),a),{totalListHeight:l,totalListHeightChanged:a}},ge(Me,Tt),{singleton:!0}),Ki=ae(([{viewportHeight:e},{totalListHeight:t}])=>{const n=O(!1),o=Re(M(Ie(n,e,t),X(([s])=>s),z(([,s,a])=>Math.max(0,s-a)),ft(0),he()),0);return{alignToBottom:n,paddingTopAddition:o}},ge(Me,rs),{singleton:!0});function Fr(e){return e?e==="smooth"?"smooth":"auto":!1}const qi=(e,t)=>typeof e=="function"?Fr(e(t)):t&&Fr(e),Xi=ae(([{listRefresh:e,totalCount:t},{atBottomState:n,isAtBottom:o},{scrollToIndex:s},{scrolledToInitialItem:a},{didMount:l,propsReady:i},{log:d},{scrollingInProgress:c}])=>{const f=O(!1),u=se();let p=null;function m(v){ee(s,{align:"end",behavior:v,index:"LAST"})}le(M(Ie(M(Y(t),Lt(1)),l),ne(Y(f),o,a,c),z(([[v,k],g,h,N,I])=>{let j=k&&N,b="auto";return j&&(b=qi(g,h||I),j=j&&!!b),{followOutputBehavior:b,shouldFollow:j,totalCount:v}}),X(({shouldFollow:v})=>v)),({followOutputBehavior:v,totalCount:k})=>{p&&(p(),p=null),p=Qe(e,()=>{Ee(d)("following output to ",{totalCount:k},Fe.DEBUG),m(v),p=null})});function C(v){const k=Qe(n,g=>{v&&!g.atBottom&&g.notAtBottomBecause==="SIZE_INCREASED"&&!p&&(Ee(d)("scrolling to bottom due to increased size",{},Fe.DEBUG),m("auto"))});setTimeout(k,100)}return le(M(Ie(Y(f),t,i),X(([v,,k])=>v&&k),Je(({value:v},[,k])=>({refreshed:v===k,value:k}),{refreshed:!1,value:0}),X(({refreshed:v})=>v),ne(f,t)),([,v])=>{Ee(a)&&C(v!==!1)}),le(u,()=>{C(Ee(f)!==!1)}),le(Ie(Y(f),n),([v,k])=>{v&&!k.atBottom&&k.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&m("auto")}),{autoscrollToBottom:u,followOutput:f}},ge(et,Xt,Kt,qt,vt,xt,Me)),Yi=ae(([{data:e,firstItemIndex:t,gap:n,sizes:o},{initialTopMostItemIndex:s},{initialItemCount:a,listState:l},{didMount:i}])=>(U(M(i,ne(a),X(([,d])=>d!==0),ne(s,o,t,n,e),z(([[,d],c,f,u,p,m=[]])=>ns(d,c,f,u,p,m))),l),{}),ge(et,qt,Tt,vt),{singleton:!0}),Zi=ae(([{didMount:e},{scrollTo:t},{listState:n}])=>{const o=O(0);return le(M(e,ne(o),X(([,s])=>s!==0),z(([,s])=>({top:s}))),s=>{Qe(M(n,Lt(1),X(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{ee(t,s)})})}),{initialScrollTop:o}},ge(vt,Me,Tt),{singleton:!0}),Ji=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:o,...s},viewportBottom:a,viewportTop:l})=>t<l?{...s,align:n??"start",behavior:o}:e>a?{...s,align:n??"end",behavior:o}:null,Qi=ae(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:o,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:l,scrollTop:i,viewportHeight:d},{scrollToIndex:c}])=>{const f=se();return U(M(f,ne(t,d,n,a,s,o,i),ne(e),z(([[u,p,m,C,v,k,g,h],N])=>{const{align:I,behavior:j,calculateViewLocation:b=Ji,done:w,...y}=u,S=Jo(u,p,C-1),A=Gt(S,p.offsetTree,N)+v+k,L=A+$e(p.sizeTree,S)[1],D=h+k,E=h+m-g,T=b({itemBottom:L,itemTop:A,locationParams:{align:I,behavior:j,...y},viewportBottom:E,viewportTop:D});return T?w&&Qe(M(l,X(H=>!H),Lt(Ee(l)?1:2)),w):w&&w(),T}),X(u=>u!==null)),c),{scrollIntoView:f}},ge(et,Me,Kt,Tt,xt),{singleton:!0}),os=ae(([{scrollVelocity:e}])=>{const t=O(!1),n=se(),o=O(!1);return U(M(e,ne(o,t,n),X(([s,a])=>!!a),z(([s,a,l,i])=>{const{enter:d,exit:c}=a;if(l){if(c(s,i))return!1}else if(d(s,i))return!0;return l}),he()),t),le(M(Ie(t,e,n),ne(o)),([[s,a,l],i])=>{s&&i&&i.change&&i.change(a,l)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:n,scrollVelocity:e}},ge(Xt),{singleton:!0}),fr=ae(([{scrollContainerState:e,scrollTo:t}])=>{const n=se(),o=se(),s=se(),a=O(!1),l=O(void 0);return U(M(Ie(n,o),z(([{scrollHeight:i,scrollTop:d,viewportHeight:c},{offsetTop:f}])=>({scrollHeight:i,scrollTop:Math.max(0,d-f),viewportHeight:c}))),e),U(M(t,ne(o),z(([i,{offsetTop:d}])=>({...i,top:i.top+d}))),s),{customScrollParent:l,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:s,windowViewportRect:o}},ge(Me)),el=ae(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:o},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:l,windowScrollContainerState:i,windowViewportRect:d}])=>{const c=se(),f=O(void 0),u=O(null),p=O(null);return U(i,u),U(d,p),le(M(c,ne(t,o,l,u,p,n)),([m,C,v,k,g,h,N])=>{const I=Hi(C.sizeTree);k&&g!==null&&h!==null&&(v=g.scrollTop-h.offsetTop),v-=N,m({ranges:I,scrollTop:v})}),U(M(f,X(or),z(tl)),s),U(M(a,ne(f),X(([,m])=>m!==void 0),he(),z(([,m])=>m.ranges)),e),{getState:c,restoreStateFrom:f}},ge(et,Me,qt,vt,fr));function tl(e){return{align:"start",index:0,offset:e.scrollTop}}const nl=ae(([{topItemsIndexes:e}])=>{const t=O(0);return U(M(t,X(n=>n>=0),z(n=>Array.from({length:n}).map((o,s)=>s))),e),{topItemCount:t}},ge(Tt));function ss(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const rl=ss(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ol=ae(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:o},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:l,scrollDirection:i},{listState:d},{beforeUnshiftWith:c,gap:f,shiftWithOffset:u,sizes:p},{log:m},{recalcInProgress:C}])=>{const v=Oe(M(d,ne(l),Je(([,g,h,N],[{bottom:I,items:j,offsetBottom:b,totalCount:w},y])=>{const S=I+b;let A=0;return h===w&&g.length>0&&j.length>0&&(j[0].originalIndex===0&&g[0].originalIndex===0||(A=S-N,A!==0&&(A+=y))),[A,j,w,S]},[0,[],0,0]),X(([g])=>g!==0),ne(o,i,n,s,m,C),X(([,g,h,N,,,I])=>!I&&!N&&g!==0&&h===Ut),z(([[g],,,,,h])=>(h("Upward scrolling compensation",{amount:g},Fe.DEBUG),g))));function k(g){g>0?(ee(t,{behavior:"auto",top:-g}),ee(e,0)):(ee(e,0),ee(t,{behavior:"auto",top:-g}))}return le(M(v,ne(e,a)),([g,h,N])=>{N&&rl()?ee(e,h-g):k(-g)}),le(M(Ie(Re(a,!1),e,C),X(([g,h,N])=>!g&&!N&&h!==0),z(([g,h])=>h),ft(1)),k),U(M(u,z(g=>({top:-g}))),t),le(M(c,ne(p,f),z(([g,{groupIndices:h,lastSize:N,sizeTree:I},j])=>{function b(w){return w*(N+j)}if(h.length===0)return b(g);{let w=0;const y=$t(I,0);let S=0,A=0;for(;S<g;){S++,w+=y;let L=h.length===A+1?1/0:h[A+1]-h[A]-1;S+L>g&&(w-=y,L=g-S+1),S+=L,w+=b(L),A++}return w}})),g=>{ee(e,g),requestAnimationFrame(()=>{ee(t,{top:g}),requestAnimationFrame(()=>{ee(e,0),ee(C,!1)})})}),{deviation:e}},ge(Me,Xt,Tt,et,xt,ir)),sl=ae(([e,t,n,o,s,a,l,i,d,c])=>({...e,...t,...n,...o,...s,...a,...l,...i,...d,...c}),ge(ur,Yi,vt,os,rs,Zi,Ki,fr,Qi,xt)),as=ae(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:o,gap:s,groupIndices:a,itemSize:l,sizeRanges:i,sizes:d,statefulTotalCount:c,totalCount:f,trackItemSizes:u},{initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:C},v,k,g,{listState:h,topItemsIndexes:N,...I},{scrollToIndex:j},b,{topItemCount:w},{groupCounts:y},S])=>(U(I.rangeChanged,S.scrollSeekRangeChanged),U(M(S.windowViewportRect,z(A=>A.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:o,gap:s,groupCounts:y,initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:C,sizeRanges:i,topItemCount:w,topItemsIndexes:N,totalCount:f,...g,groupIndices:a,itemSize:l,listState:h,scrollToIndex:j,statefulTotalCount:c,trackItemSizes:u,...I,...S,...v,sizes:d,...k}),ge(et,qt,Me,el,Xi,Tt,Kt,ol,nl,Qo,sl));function al(e,t){const n={},o={};let s=0;const a=e.length;for(;s<a;)o[e[s]]=1,s+=1;for(const l in t)Object.hasOwn(o,l)||(n[l]=t[l]);return n}const nn=typeof document<"u"?$.useLayoutEffect:$.useEffect;function is(e,t,n){const o=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),l=Object.keys(t.events||{}),i=$.createContext({});function d(k,g){k.propsReady&&ee(k.propsReady,!1);for(const h of o){const N=k[t.required[h]];ee(N,g[h])}for(const h of s)if(h in g){const N=k[t.optional[h]];ee(N,g[h])}k.propsReady&&ee(k.propsReady,!0)}function c(k){return a.reduce((g,h)=>(g[h]=N=>{const I=k[t.methods[h]];ee(I,N)},g),{})}function f(k){return l.reduce((g,h)=>(g[h]=wi(k[t.events[h]]),g),{})}const u=$.forwardRef((k,g)=>{const{children:h,...N}=k,[I]=$.useState(()=>jn(Ii(e),w=>{d(w,N)})),[j]=$.useState(Tr(f,I));nn(()=>{for(const w of l)w in N&&le(j[w],N[w]);return()=>{Object.values(j).map(sr)}},[N,j,I]),nn(()=>{d(I,N)}),$.useImperativeHandle(g,Sr(c(I)));const b=n;return r.jsx(i.Provider,{value:I,children:n?r.jsx(b,{...al([...o,...s,...l],N),children:h}):h})}),p=k=>{const g=$.useContext(i);return $.useCallback(h=>{ee(g[k],h)},[g,k])},m=k=>{const g=$.useContext(i)[k],h=$.useCallback(N=>le(g,N),[g]);return $.useSyncExternalStore(h,()=>Ee(g),()=>Ee(g))},C=k=>{const g=$.useContext(i)[k],[h,N]=$.useState(Tr(Ee,g));return nn(()=>le(g,I=>{I!==h&&N(Sr(I))}),[g,h]),h},v=$.version.startsWith("18")?m:C;return{Component:u,useEmitter:(k,g)=>{const h=$.useContext(i)[k];nn(()=>le(h,g),[g,h])},useEmitterValue:v,usePublisher:p}}const ls=$.createContext(void 0),cs=$.createContext(void 0),ds=typeof document<"u"?$.useLayoutEffect:$.useEffect;function _n(e){return"self"in e}function il(e){return"body"in e}function us(e,t,n,o=Ht,s,a){const l=$.useRef(null),i=$.useRef(null),d=$.useRef(null),c=$.useCallback(p=>{let m,C,v;const k=p.target;if(il(k)||_n(k)){const h=_n(k)?k:k.defaultView;v=a?h.scrollX:h.scrollY,m=a?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight,C=a?h.innerWidth:h.innerHeight}else v=a?k.scrollLeft:k.scrollTop,m=a?k.scrollWidth:k.scrollHeight,C=a?k.offsetWidth:k.offsetHeight;const g=()=>{e({scrollHeight:m,scrollTop:Math.max(v,0),viewportHeight:C})};p.suppressFlushSync?g():jo.flushSync(g),i.current!==null&&(v===i.current||v<=0||v===m-C)&&(i.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);$.useEffect(()=>{const p=s||l.current;return o(s||l.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{o(null),p.removeEventListener("scroll",c)}},[l,c,n,o,s]);function f(p){const m=l.current;if(!m||(a?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const C=p.behavior==="smooth";let v,k,g;_n(m)?(k=Math.max(pt(m.document.documentElement,a?"width":"height"),a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),v=a?m.innerWidth:m.innerHeight,g=a?window.scrollX:window.scrollY):(k=m[a?"scrollWidth":"scrollHeight"],v=pt(m,a?"width":"height"),g=m[a?"scrollLeft":"scrollTop"]);const h=k-v;if(p.top=Math.ceil(Math.max(Math.min(h,p.top),0)),ts(v,k)||p.top===g){e({scrollHeight:k,scrollTop:g,viewportHeight:v}),C&&t(!0);return}C?(i.current=p.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,i.current=null,t(!0)},1e3)):i.current=null,a&&(p={behavior:p.behavior,left:p.top}),m.scrollTo(p)}function u(p){a&&(p={behavior:p.behavior,left:p.top}),l.current.scrollBy(p)}return{scrollByCallback:u,scrollerRef:l,scrollToCallback:f}}const Hn="-webkit-sticky",Pr="sticky",fs=ss(()=>{if(typeof document>"u")return Pr;const e=document.createElement("div");return e.style.position=Hn,e.style.position===Hn?Hn:Pr});function mr(e){return e}const ll=ae(()=>{const e=O(d=>`Item ${d}`),t=O(null),n=O(d=>`Group ${d}`),o=O({}),s=O(mr),a=O("div"),l=O(Ht),i=(d,c=null)=>Re(M(o,z(f=>f[d]),he()),c);return{components:o,computeItemKey:s,context:t,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:n,HeaderComponent:i("Header"),HeaderFooterTag:a,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),cl=ae(([e,t])=>({...e,...t}),ge(as,ll)),dl=({height:e})=>r.jsx("div",{style:{height:e}}),ul={overflowAnchor:"none",position:fs(),zIndex:1},ms={overflowAnchor:"none"},fl={...ms,display:"inline-block",height:"100%"},zr=$.memo(function({showTopList:e=!1}){const t=Z("listState"),n=ze("sizeRanges"),o=Z("useWindowScroll"),s=Z("customScrollParent"),a=ze("windowScrollContainerState"),l=ze("scrollContainerState"),i=s||o?a:l,d=Z("itemContent"),c=Z("context"),f=Z("groupContent"),u=Z("trackItemSizes"),p=Z("itemSize"),m=Z("log"),C=ze("gap"),v=Z("horizontalDirection"),{callbackRef:k}=Ci(n,p,u,e?Ht:i,m,C,s,v,Z("skipAnimationFrameInResizeObserver")),[g,h]=$.useState(0);pr("deviation",T=>{g!==T&&h(T)});const N=Z("EmptyPlaceholder"),I=Z("ScrollSeekPlaceholder")||dl,j=Z("ListComponent"),b=Z("ItemComponent"),w=Z("GroupComponent"),y=Z("computeItemKey"),S=Z("isSeeking"),A=Z("groupIndices").length>0,L=Z("alignToBottom"),D=Z("initialItemFinalLocationReached"),E=e?{}:{boxSizing:"border-box",...v?{display:"inline-block",height:"100%",marginLeft:g!==0?g:L?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:L?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...D?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&N?r.jsx(N,{...ke(N,c)}):r.jsx(j,{...ke(j,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:k,style:E,children:(e?t.topItems:t.items).map(T=>{const H=T.originalIndex,P=y(H+t.firstItemIndex,T.data,c);return S?x.createElement(I,{...ke(I,c),height:T.size,index:T.index,key:P,type:T.type||"item",...T.type==="group"?{}:{groupIndex:T.groupIndex}}):T.type==="group"?x.createElement(w,{...ke(w,c),"data-index":H,"data-item-index":T.index,"data-known-size":T.size,key:P,style:ul},f(T.index,c)):x.createElement(b,{...ke(b,c),...gl(b,T.data),"data-index":H,"data-item-group-index":T.groupIndex,"data-item-index":T.index,"data-known-size":T.size,key:P,style:v?fl:ms},A?d(T.index,T.groupIndex,T.data,c):d(T.index,T.data,c))})})}),ml={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},pl={outline:"none",overflowX:"auto",position:"relative"},Sn=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),hl={position:fs(),top:0,width:"100%",zIndex:1};function ke(e,t){if(typeof e!="string")return{context:t}}function gl(e,t){return{item:typeof e=="string"?void 0:t}}const xl=$.memo(function(){const e=Z("HeaderComponent"),t=ze("headerHeight"),n=Z("HeaderFooterTag"),o=St($.useMemo(()=>a=>{t(pt(a,"height"))},[t]),!0,Z("skipAnimationFrameInResizeObserver")),s=Z("context");return e?r.jsx(n,{ref:o,children:r.jsx(e,{...ke(e,s)})}):null}),vl=$.memo(function(){const e=Z("FooterComponent"),t=ze("footerHeight"),n=Z("HeaderFooterTag"),o=St($.useMemo(()=>a=>{t(pt(a,"height"))},[t]),!0,Z("skipAnimationFrameInResizeObserver")),s=Z("context");return e?r.jsx(n,{ref:o,children:r.jsx(e,{...ke(e,s)})}):null});function ps({useEmitter:e,useEmitterValue:t,usePublisher:n}){return $.memo(function({children:o,style:s,...a}){const l=n("scrollContainerState"),i=t("ScrollerComponent"),d=n("smoothScrollTargetReached"),c=t("scrollerRef"),f=t("context"),u=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:m,scrollToCallback:C}=us(l,d,i,c,void 0,u);return e("scrollTo",C),e("scrollBy",p),r.jsx(i,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...u?pl:ml,...s},tabIndex:0,...a,...ke(i,f),children:o})})}function hs({useEmitter:e,useEmitterValue:t,usePublisher:n}){return $.memo(function({children:o,style:s,...a}){const l=n("windowScrollContainerState"),i=t("ScrollerComponent"),d=n("smoothScrollTargetReached"),c=t("totalListHeight"),f=t("deviation"),u=t("customScrollParent"),p=t("context"),m=$.useRef(null),C=t("scrollerRef"),{scrollByCallback:v,scrollerRef:k,scrollToCallback:g}=us(l,d,i,C,u);return ds(()=>{var h;return k.current=u||((h=m.current)==null?void 0:h.ownerDocument.defaultView),()=>{k.current=null}},[k,u]),e("windowScrollTo",g),e("scrollBy",v),r.jsx(i,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...c!==0?{height:c+f}:{}},...a,...ke(i,p),children:o})})}const bl=({children:e})=>{const t=$.useContext(ls),n=ze("viewportHeight"),o=ze("fixedItemHeight"),s=Z("alignToBottom"),a=Z("horizontalDirection"),l=$.useMemo(()=>Bo(n,d=>pt(d,a?"width":"height")),[n,a]),i=St(l,!0,Z("skipAnimationFrameInResizeObserver"));return $.useEffect(()=>{t&&(n(t.viewportHeight),o(t.itemHeight))},[t,n,o]),r.jsx("div",{"data-viewport-type":"element",ref:i,style:Sn(s),children:e})},yl=({children:e})=>{const t=$.useContext(ls),n=ze("windowViewportRect"),o=ze("fixedItemHeight"),s=Z("customScrollParent"),a=$o(n,s,Z("skipAnimationFrameInResizeObserver")),l=Z("alignToBottom");return $.useEffect(()=>{t&&(o(t.itemHeight),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,o]),r.jsx("div",{"data-viewport-type":"window",ref:a,style:Sn(l),children:e})},wl=({children:e})=>{const t=Z("TopItemListComponent")||"div",n=Z("headerHeight"),o={...hl,marginTop:`${n}px`},s=Z("context");return r.jsx(t,{style:o,...ke(t,s),children:e})},Nl=$.memo(function(e){const t=Z("useWindowScroll"),n=Z("topItemsIndexes").length>0,o=Z("customScrollParent"),s=Z("context"),a=o||t?kl:jl,l=o||t?yl:bl;return r.jsxs(a,{...e,...ke(a,s),children:[n&&r.jsx(wl,{children:r.jsx(zr,{showTopList:!0})}),r.jsxs(l,{children:[r.jsx(xl,{}),r.jsx(zr,{}),r.jsx(vl,{})]})]})}),{Component:Il,useEmitter:pr,useEmitterValue:Z,usePublisher:ze}=is(cl,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",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"}},Nl),jl=ps({useEmitter:pr,useEmitterValue:Z,usePublisher:ze}),kl=hs({useEmitter:pr,useEmitterValue:Z,usePublisher:ze}),Cl=Il,Sl=ae(()=>{const e=O(d=>r.jsxs("td",{children:["Item $",d]})),t=O(null),n=O(null),o=O(null),s=O({}),a=O(mr),l=O(Ht),i=(d,c=null)=>Re(M(s,z(f=>f[d]),he()),c);return{components:s,computeItemKey:a,context:t,EmptyPlaceholder:i("EmptyPlaceholder"),FillerRow:i("FillerRow"),fixedFooterContent:o,fixedHeaderContent:n,itemContent:e,ScrollerComponent:i("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TableBodyComponent:i("TableBody","tbody"),TableComponent:i("Table","table"),TableFooterComponent:i("TableFoot","tfoot"),TableHeadComponent:i("TableHead","thead"),TableRowComponent:i("TableRow","tr")}});ge(as,Sl);const Br={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Tl={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Wr,floor:xn,max:zt,min:On,round:$r}=Math;function Vr(e,t,n){return Array.from({length:t-e+1}).map((o,s)=>({data:n===null?null:n[s+e],index:s+e}))}function El(e){return{...Tl,items:e}}function rn(e,t){return e&&e.width===t.width&&e.height===t.height}function Rl(e,t){return e&&e.column===t.column&&e.row===t.row}const Al=ae(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:o},{footerHeight:s,headerHeight:a,scrollBy:l,scrollContainerState:i,scrollTo:d,scrollTop:c,smoothScrollTargetReached:f,viewportHeight:u},p,m,{didMount:C,propsReady:v},{customScrollParent:k,useWindowScroll:g,windowScrollContainerState:h,windowScrollTo:N,windowViewportRect:I},j])=>{const b=O(0),w=O(0),y=O(Br),S=O({height:0,width:0}),A=O({height:0,width:0}),L=se(),D=se(),E=O(0),T=O(null),H=O({column:0,row:0}),P=se(),F=se(),_=O(!1),B=O(0),V=O(!0),G=O(!1),oe=O(!1);le(M(C,ne(B),X(([R,K])=>!!K)),()=>{ee(V,!1)}),le(M(Ie(C,V,A,S,B,G),X(([R,K,re,ce,,fe])=>R&&!K&&re.height!==0&&ce.height!==0&&!fe)),([,,,,R])=>{ee(G,!0),cr(1,()=>{ee(L,R)}),Qe(M(c),()=>{ee(t,[0,0]),ee(V,!0)})}),U(M(F,X(R=>R!=null&&R.scrollTop>0),Xe(0)),w),le(M(C,ne(F),X(([,R])=>R!=null)),([,R])=>{R&&(ee(S,R.viewport),ee(A,R.item),ee(H,R.gap),R.scrollTop>0&&(ee(_,!0),Qe(M(c,Lt(1)),K=>{ee(_,!1)}),ee(d,{top:R.scrollTop})))}),U(M(S,z(({height:R})=>R)),u),U(M(Ie(Y(S,rn),Y(A,rn),Y(H,(R,K)=>R&&R.column===K.column&&R.row===K.row),Y(c)),z(([R,K,re,ce])=>({gap:re,item:K,scrollTop:ce,viewport:R}))),P),U(M(Ie(Y(b),o,Y(H,Rl),Y(A,rn),Y(S,rn),Y(T),Y(w),Y(_),Y(V),Y(B)),X(([,,,,,,,R])=>!R),z(([R,[K,re],ce,fe,te,me,Ae,,Ge,Ce])=>{const{column:W,row:de}=ce,{height:ye,width:Se}=fe,{width:Te}=te;if(Ae===0&&(R===0||Te===0))return Br;if(Se===0){const yt=dr(Ce,R),it=yt+Math.max(Ae-1,0);return El(Vr(yt,it,me))}const je=gs(Te,Se,W);let we,Le;Ge?K===0&&re===0&&Ae>0?(we=0,Le=Ae-1):(we=je*xn((K+de)/(ye+de)),Le=je*Wr((re+de)/(ye+de))-1,Le=On(R-1,zt(Le,je-1)),we=On(Le,zt(0,we))):(we=0,Le=-1);const Ue=Vr(we,Le,me),{bottom:tt,top:nt}=Gr(te,ce,fe,Ue),bt=Wr(R/je),Yt=bt*ye+(bt-1)*de-tt;return{bottom:tt,itemHeight:ye,items:Ue,itemWidth:Se,offsetBottom:Yt,offsetTop:nt,top:nt}})),y),U(M(T,X(R=>R!==null),z(R=>R.length)),b),U(M(Ie(S,A,y,H),X(([R,K,{items:re}])=>re.length>0&&K.height!==0&&R.height!==0),z(([R,K,{items:re},ce])=>{const{bottom:fe,top:te}=Gr(R,ce,K,re);return[te,fe]}),he(Vt)),t);const ve=O(!1);U(M(c,ne(ve),z(([R,K])=>K||R!==0)),ve);const be=Oe(M(Ie(y,b),X(([{items:R}])=>R.length>0),ne(ve),X(([[R,K],re])=>{const ce=R.items[R.items.length-1].index===K-1;return(re||R.bottom>0&&R.itemHeight>0&&R.offsetBottom===0&&R.items.length===K)&&ce}),z(([[,R]])=>R-1),he())),J=Oe(M(Y(y),X(({items:R})=>R.length>0&&R[0].index===0),Xe(0),he())),Q=Oe(M(Y(y),ne(_),X(([{items:R},K])=>R.length>0&&!K),z(([{items:R}])=>({endIndex:R[R.length-1].index,startIndex:R[0].index})),he(Xo),ft(0)));U(Q,m.scrollSeekRangeChanged),U(M(L,ne(S,A,b,H),z(([R,K,re,ce,fe])=>{const te=es(R),{align:me,behavior:Ae,offset:Ge}=te;let Ce=te.index;Ce==="LAST"&&(Ce=ce-1),Ce=zt(0,Ce,On(ce-1,Ce));let W=Zn(K,fe,re,Ce);return me==="end"?W=$r(W-K.height+re.height):me==="center"&&(W=$r(W-K.height/2+re.height/2)),Ge&&(W+=Ge),{behavior:Ae,top:W}})),d);const ie=Re(M(y,z(R=>R.offsetBottom+R.bottom)),0);return U(M(I,z(R=>({height:R.visibleHeight,width:R.visibleWidth}))),S),{customScrollParent:k,data:T,deviation:E,footerHeight:s,gap:H,headerHeight:a,increaseViewportBy:e,initialItemCount:w,itemDimensions:A,overscan:n,restoreStateFrom:F,scrollBy:l,scrollContainerState:i,scrollHeight:D,scrollTo:d,scrollToIndex:L,scrollTop:c,smoothScrollTargetReached:f,totalCount:b,useWindowScroll:g,viewportDimensions:S,windowScrollContainerState:h,windowScrollTo:N,windowViewportRect:I,...m,gridState:y,horizontalDirection:oe,initialTopMostItemIndex:B,totalListHeight:ie,...p,endReached:be,propsReady:v,rangeChanged:Q,startReached:J,stateChanged:P,stateRestoreInProgress:_,...j}},ge(ur,Me,Xt,os,vt,fr,xt));function gs(e,t,n){return zt(1,xn((e+n)/(xn(t)+n)))}function Gr(e,t,n,o){const{height:s}=n;if(s===void 0||o.length===0)return{bottom:0,top:0};const a=Zn(e,t,n,o[0].index);return{bottom:Zn(e,t,n,o[o.length-1].index)+s,top:a}}function Zn(e,t,n,o){const s=gs(e.width,n.width,t.column),a=xn(o/s),l=a*n.height+zt(0,a-1)*t.row;return l>0?l+t.row:l}const Dl=ae(()=>{const e=O(u=>`Item ${u}`),t=O({}),n=O(null),o=O("virtuoso-grid-item"),s=O("virtuoso-grid-list"),a=O(mr),l=O("div"),i=O(Ht),d=(u,p=null)=>Re(M(t,z(m=>m[u]),he()),p),c=O(!1),f=O(!1);return U(Y(f),c),{components:t,computeItemKey:a,context:n,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:l,itemClassName:o,ItemComponent:d("Item","div"),itemContent:e,listClassName:s,ListComponent:d("List","div"),readyStateChanged:c,reportReadyState:f,ScrollerComponent:d("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),Ml=ae(([e,t])=>({...e,...t}),ge(Al,Dl)),Ll=$.memo(function(){const e=xe("gridState"),t=xe("listClassName"),n=xe("itemClassName"),o=xe("itemContent"),s=xe("computeItemKey"),a=xe("isSeeking"),l=Be("scrollHeight"),i=xe("ItemComponent"),d=xe("ListComponent"),c=xe("ScrollSeekPlaceholder"),f=xe("context"),u=Be("itemDimensions"),p=Be("gap"),m=xe("log"),C=xe("stateRestoreInProgress"),v=Be("reportReadyState"),k=St($.useMemo(()=>g=>{const h=g.parentElement.parentElement.scrollHeight;l(h);const N=g.firstChild;if(N){const{height:I,width:j}=N.getBoundingClientRect();u({height:I,width:j})}p({column:Ur("column-gap",getComputedStyle(g).columnGap,m),row:Ur("row-gap",getComputedStyle(g).rowGap,m)})},[l,u,p,m]),!0,!1);return ds(()=>{e.itemHeight>0&&e.itemWidth>0&&v(!0)},[e]),C?null:r.jsx(d,{className:t,ref:k,...ke(d,f),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const h=s(g.index,g.data,f);return a?r.jsx(c,{...ke(c,f),height:e.itemHeight,index:g.index,width:e.itemWidth},h):x.createElement(i,{...ke(i,f),className:n,"data-index":g.index,key:h},o(g.index,g.data,f))})})}),_l=$.memo(function(){const e=xe("HeaderComponent"),t=Be("headerHeight"),n=xe("headerFooterTag"),o=St($.useMemo(()=>a=>{t(pt(a,"height"))},[t]),!0,!1),s=xe("context");return e?r.jsx(n,{ref:o,children:r.jsx(e,{...ke(e,s)})}):null}),Hl=$.memo(function(){const e=xe("FooterComponent"),t=Be("footerHeight"),n=xe("headerFooterTag"),o=St($.useMemo(()=>a=>{t(pt(a,"height"))},[t]),!0,!1),s=xe("context");return e?r.jsx(n,{ref:o,children:r.jsx(e,{...ke(e,s)})}):null}),Ol=({children:e})=>{const t=$.useContext(cs),n=Be("itemDimensions"),o=Be("viewportDimensions"),s=St($.useMemo(()=>a=>{o(a.getBoundingClientRect())},[o]),!0,!1);return $.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,o,n]),r.jsx("div",{ref:s,style:Sn(!1),children:e})},Fl=({children:e})=>{const t=$.useContext(cs),n=Be("windowViewportRect"),o=Be("itemDimensions"),s=xe("customScrollParent"),a=$o(n,s,!1);return $.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),n({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,o]),r.jsx("div",{ref:a,style:Sn(!1),children:e})},Pl=$.memo(function({...e}){const t=xe("useWindowScroll"),n=xe("customScrollParent"),o=n||t?Bl:zl,s=n||t?Fl:Ol,a=xe("context");return r.jsx(o,{...e,...ke(o,a),children:r.jsxs(s,{children:[r.jsx(_l,{}),r.jsx(Ll,{}),r.jsx(Hl,{})]})})}),{useEmitter:xs,useEmitterValue:xe,usePublisher:Be}=is(Ml,{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"}},Pl),zl=ps({useEmitter:xs,useEmitterValue:xe,usePublisher:Be}),Bl=hs({useEmitter:xs,useEmitterValue:xe,usePublisher:Be});function Ur(e,t,n){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&n(`${e} was not resolved to pixel value correctly`,t,Fe.WARN),t==="normal"?0:parseInt(t??"0",10)}const hr={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},vs="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function Wl(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function $l(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Vl(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 Gl(e,t){var s;const n=new Map;if(e)for(const a of e){const l=wn(String(a.stepName));n.set(a.stepId,(l==null?void 0:l.shortName)??a.stepName)}const o=t!=null&&t.workflowName?((s=kt(t.workflowName))==null?void 0:s.shortName)??t.workflowName:null;return{correlationNameMap:n,workflowName:o}}function Ul(e){const t=new Map,n=new Map,o=new Map;for(const s of e){const a=new Date(s.createdAt).getTime(),l=s.correlationId??"__run__",i=s.eventType;if((i==="step_created"||i==="run_created")&&t.set(l,a),i==="step_started"||i==="run_started"||i==="workflow_started"){n.set(l,a),t.has(l)||t.set(l,a);const d=t.get(l),c=o.get(l)??{};d!==void 0&&(c.queued=a-d),o.set(l,c)}if(i==="step_completed"||i==="step_failed"||i==="run_completed"||i==="run_failed"||i==="run_cancelled"||i==="workflow_completed"||i==="workflow_failed"||i==="wait_completed"||i==="hook_disposed"){const d=n.get(l),c=o.get(l)??{};d!==void 0&&(c.ran=a-d),o.set(l,c)}}return o}function Jn(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 Qn=36,Kl=20,Fn="var(--ds-gray-500)";function Kr({isFirst:e,isLast:t,isRunLevel:n,statusDotColor:o,pulse:s=!1,hasSelection:a,showBranch:l,showLaneLine:i,isLaneStart:d,isLaneEnd:c,continuationOnly:f=!1}){const u=n?8:6,p=n?5:6,m=a&&!l&&!n?.3:1;return r.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:Qn,minHeight:f?0:void 0},children:[r.jsx("div",{style:{position:"absolute",left:8,top:f?0:e?"50%":0,bottom:f?0:t?"50%":0,width:2,backgroundColor:Fn,zIndex:0}}),!f&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{style:{position:"absolute",left:p,top:"50%",transform:"translateY(-50%)",width:u,height:u,zIndex:2},children:[r.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:"var(--ds-background-100)",zIndex:0}}),s&&r.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:o,opacity:.75*m,animation:vs,zIndex:1}}),r.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:o,opacity:m,transition:"opacity 150ms",zIndex:2}})]}),l&&r.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:Qn-9,height:2,backgroundColor:Fn,zIndex:0}})]}),i&&r.jsx("div",{style:{position:"absolute",left:Kl,top:f?0:d?"50%":0,bottom:f?0:c?"50%":0,width:2,backgroundColor:Fn,zIndex:0}})]})}function qr({value:e,className:t}){const[n,o]=x.useState(!1),s=x.useRef(null);x.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const a=x.useCallback(l=>{l.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 r.jsxs("div",{className:`group/copy flex items-center gap-1 flex-1 min-w-0 px-4 ${t??""}`,children:[r.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:e||"-"}),e?r.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:hr,"aria-label":`Copy ${e}`,children:n?r.jsx(To,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):r.jsx(tr,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function cn(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return cn(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(cn);if(e!==null&&typeof e=="object"){const t={};for(const[n,o]of Object.entries(e))t[n]=cn(o);return t}return e}function ql({data:e}){const[t,n]=x.useState(!1),o=x.useRef(null),s=x.useMemo(()=>cn(e),[e]);x.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);const a=x.useMemo(()=>{try{return JSON.stringify(s,null,2)}catch{return String(s)}},[s]),l=x.useCallback(i=>{i.stopPropagation(),navigator.clipboard.writeText(a).then(()=>{n(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{n(!1),o.current=null},1500)})},[a]);return r.jsxs("div",{className:"relative group/payload",children:[r.jsx("div",{className:"overflow-x-auto p-2 text-[11px]",style:{color:"var(--ds-gray-1000)"},children:r.jsx(Bt,{data:s,expandLevel:2})}),r.jsx("button",{type:"button",onClick:l,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:{...hr,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:t?r.jsxs(r.Fragment,{children:[r.jsx(To,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}),r.jsx("span",{style:{color:"var(--ds-green-700)"},children:"Copied"})]}):r.jsxs(r.Fragment,{children:[r.jsx(tr,{className:"h-3 w-3"}),r.jsx("span",{children:"Copy"})]})})]})}function Xl({event:e,index:t,isFirst:n,isLast:o,activeGroupKey:s,selectedGroupKey:a,selectedGroupRange:l,correlationNameMap:i,workflowName:d,durationMap:c,onSelectGroup:f,onHoverGroup:u,onLoadEventData:p}){const[m,C]=x.useState(!1),[v,k]=x.useState(!1),[g,h]=x.useState(null),[N,I]=x.useState(null),[j,b]=x.useState(!1),w=e.correlationId??(Jn(e.eventType)?"__run__":void 0);x.useEffect(()=>{a!==void 0&&a!==w&&C(!1)},[a,w]);const y=Vl(e.eventType),S=new Date(e.createdAt),A="eventData"in e&&e.eventData!=null,L=Jn(e.eventType),D=L?d??"-":e.correlationId?i.get(e.correlationId)??"-":"-",E=e.correlationId??(L?"__run__":""),T=E?c.get(E):void 0,H=s!==void 0,P=w!==void 0&&w===s,F=H&&!P,_=H&&P,B=H&&P&&!L,V=l!==null&&t>=l.first&&t<=l.last,G=l!==null&&t===l.first,oe=l!==null&&t===l.last,ve=x.useCallback(async()=>{if(!(g!==null||A)){k(!0),I(null);try{if(!p){I("Event details unavailable");return}const R=await p(e);R!=null&&h(R)}catch(R){I(R instanceof Error?R.message:"Failed to load event details")}finally{k(!1),b(!0)}}},[e,g,A,p]),be=x.useCallback(R=>{R.stopPropagation();const K=!m;C(K),K&&g===null&&!A&&ve()},[m,g,A,ve]),J=x.useCallback(()=>{f(a===w?void 0:w)},[a,w,f]),Q=A?e.eventData:g,ie=F?.3:1;return r.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>u(w),onMouseLeave:()=>u(void 0),children:[r.jsxs("div",{role:"button",tabIndex:0,onClick:J,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&J()},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:[r.jsx(Kr,{isFirst:n,isLast:o&&!m,isRunLevel:L,statusDotColor:y,pulse:_,hasSelection:H,showBranch:B,showLaneLine:V,isLaneStart:G,isLaneEnd:oe}),r.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:ie,transition:"opacity 150ms"},children:[r.jsx("button",{type:"button",onClick:be,className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded hover:bg-[var(--ds-gray-alpha-200)] transition-colors",style:{...hr,border:"1px solid var(--ds-gray-alpha-400)"},"aria-label":m?"Collapse details":"Expand details",children:r.jsx(So,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-700)",transform:m?"rotate(90deg)":"rotate(0deg)"}})}),r.jsx("div",{className:"text-xs tabular-nums flex-1 min-w-0 px-4",style:{color:"var(--ds-gray-900)"},children:Wl(S)}),r.jsx("div",{className:"text-xs font-medium flex-1 min-w-0 px-4",children:r.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--ds-gray-900)"},children:[r.jsxs("span",{style:{position:"relative",display:"inline-flex",width:6,height:6,flexShrink:0},children:[_&&r.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:y,opacity:.75,animation:vs}}),r.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:y}})]}),$l(e.eventType)]})}),r.jsx("div",{className:"text-xs flex-1 min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",title:D!=="-"?D:void 0,children:D}),r.jsx(qr,{value:e.correlationId||"",className:"font-mono text-xs"}),r.jsx(qr,{value:e.eventId,className:"font-mono text-xs"})]})]}),m&&r.jsxs("div",{className:"flex",children:[r.jsx(Kr,{isFirst:!1,isLast:o,isRunLevel:L,hasSelection:H,showBranch:!1,showLaneLine:V&&!oe,isLaneStart:!1,isLaneEnd:!1,continuationOnly:!0}),r.jsx("div",{className:"w-5 flex-shrink-0"}),r.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:ie,transition:"opacity 150ms"},children:[((T==null?void 0:T.queued)!==void 0||(T==null?void 0:T.ran)!==void 0)&&r.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[T.queued!==void 0&&T.queued>0&&r.jsxs("span",{children:["Queued for"," ",r.jsx("span",{className:"font-mono tabular-nums",children:jt(T.queued)})]}),T.ran!==void 0&&r.jsxs("span",{children:["Ran for"," ",r.jsx("span",{className:"font-mono tabular-nums",children:jt(T.ran)})]})]}),Q!=null?r.jsx(ql,{data:Q}):N?r.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}):v||!A&&!j&&e.correlationId?r.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[r.jsx(dt,{className:"h-3",style:{width:"75%"}}),r.jsx(dt,{className:"h-3",style:{width:"50%"}}),r.jsx(dt,{className:"h-3",style:{width:"60%"}})]}):r.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function Yl({events:e,steps:t,run:n,onLoadEventData:o,hasMoreEvents:s=!1,isLoadingMoreEvents:a=!1,onLoadMoreEvents:l}){const i=x.useMemo(()=>!e||e.length===0?[]:[...e].sort((w,y)=>new Date(w.createdAt).getTime()-new Date(y.createdAt).getTime()),[e]),{correlationNameMap:d,workflowName:c}=x.useMemo(()=>Gl(t??null,n??null),[t,n]),f=x.useMemo(()=>Ul(i),[i]),[u,p]=x.useState(void 0),[m,C]=x.useState(void 0),v=x.useCallback(w=>{p(w)},[]),k=x.useCallback(w=>{C(w)},[]),g=u??m,h=x.useMemo(()=>{if(!g||g==="__run__")return null;let w=-1,y=-1;for(let S=0;S<i.length;S++)i[S].correlationId===g&&(w===-1&&(w=S),y=S);return w>=0?{first:w,last:y}:null},[g,i]),[N,I]=x.useState(""),j=x.useRef(null),b=x.useMemo(()=>{const w=[];for(let y=0;y<i.length;y++){const S=i[y];w.push({text:[S.eventId,S.correlationId??""].join(" ").toLowerCase(),groupKey:S.correlationId??(Jn(S.eventType)?"__run__":void 0),eventId:S.eventId,index:y})}return w},[i]);return x.useEffect(()=>{var S;const w=N.trim().toLowerCase();if(!w){p(void 0);return}const y=b.find(A=>A.text.includes(w));y&&(p(y.groupKey),(S=j.current)==null||S.scrollToIndex({index:y.index,align:"center",behavior:"smooth"}))},[N,b]),!e||e.length===0?r.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--ds-gray-700)"},children:"No events found"}):r.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[r.jsx("style",{children:"@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}"}),r.jsx("div",{style:{padding:6,backgroundColor:"var(--ds-background-100)"},children:r.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:[r.jsx("div",{style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ds-gray-800)",flexShrink:0},children:r.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[r.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),r.jsx("input",{type:"search",placeholder:"Search by event ID or correlation ID…",value:N,onChange:w=>I(w.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]})}),r.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:[r.jsx("div",{className:"flex-shrink-0",style:{width:Qn}}),r.jsx("div",{className:"w-5 flex-shrink-0"}),r.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Time"}),r.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event Type"}),r.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Name"}),r.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Correlation ID"}),r.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event ID"})]}),r.jsx(Cl,{ref:j,totalCount:i.length,overscan:20,defaultItemHeight:40,endReached:()=>{!s||a||l==null||l()},itemContent:w=>r.jsx(Xl,{event:i[w],index:w,isFirst:w===0,isLast:w===i.length-1,activeGroupKey:g,selectedGroupKey:u,selectedGroupRange:h,correlationNameMap:d,workflowName:c,durationMap:f,onSelectGroup:v,onHoverGroup:k,onLoadEventData:o}),components:{Footer:()=>r.jsxs(r.Fragment,{children:[s&&r.jsx("div",{className:"px-3 pt-3 flex justify-center",children:r.jsx("button",{type:"button",onClick:()=>void(l==null?void 0:l()),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"})}),r.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:[i.length," event",i.length!==1?"s":""," total"]})]})},style:{flex:1,minHeight:0}})]})}function Zl({messages:e}){return e.length===0?r.jsx("div",{className:"text-center py-8 text-[11px]",style:{color:"var(--ds-gray-600)"},children:"No messages"}):r.jsx("div",{className:"flex flex-col gap-3 p-3",children:e.map((t,n)=>r.jsx(Jl,{message:t},n))})}function Jl({message:e}){const t=e.role,n=tc(e.content),o=ec(t);return r.jsxs("div",{className:"rounded-md border text-[11px]",style:{backgroundColor:o.bg,borderColor:o.border},children:[r.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}),r.jsx("div",{className:"px-2.5 py-2 space-y-2",children:n.map((s,a)=>r.jsx(Ql,{part:s,role:t},a))})]})}function Ql({part:e,role:t}){return e.type==="text"?e.text?t==="assistant"?r.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:r.jsx(qa,{children:e.text})}):r.jsx("div",{className:"whitespace-pre-wrap break-words",style:{color:"var(--ds-gray-1000)"},children:e.text}):null:e.type==="tool-call"?r.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-purple-100)",borderColor:"var(--ds-purple-300)"},children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[r.jsx("span",{children:"🔧"}),r.jsx("span",{style:{color:"var(--ds-purple-900)"},children:e.toolName})]}),e.input!=null&&r.jsx("div",{className:"mt-1.5 overflow-x-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.input=="string"?r.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.input}):r.jsx(Bt,{data:e.input})})]}):e.type==="tool-result"?r.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-green-100)",borderColor:"var(--ds-green-300)"},children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[r.jsx("span",{children:"✓"}),r.jsxs("span",{style:{color:"var(--ds-green-900)"},children:[e.toolName," result"]})]}),e.output!=null&&r.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"?r.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.output}):r.jsx(Bt,{data:e.output,expandLevel:1})})]}):null}function ec(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 tc(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:""}):[]}function qe({summary:e,children:t,onToggle:n}){return r.jsxs("details",{className:"group",onToggle:o=>n==null?void 0:n(o.target.open),children:[r.jsx("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)"},children:e}),r.jsxs("div",{className:"relative pl-6 mt-3",children:[r.jsx("div",{className:"absolute left-3 -top-3 w-px h-3",style:{backgroundColor:"var(--ds-gray-400)"}}),r.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)"}}),r.jsx("div",{className:"absolute left-6 top-3 w-0 h-px -translate-y-px",style:{backgroundColor:"var(--ds-gray-400)"}}),r.jsx("div",{children:t})]})]})}function Xr({active:e,onClick:t,children:n}){return r.jsx("button",{type:"button",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:n})}function nc({conversation:e,args:t}){const[n,o]=x.useState("conversation");return r.jsx(qe,{summary:`Input (${e.length} messages)`,children:r.jsxs("div",{className:"rounded-md border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:[r.jsxs("div",{className:"flex gap-1 border-b",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:[r.jsx(Xr,{active:n==="conversation",onClick:()=>o("conversation"),children:"Conversation"}),r.jsx(Xr,{active:n==="json",onClick:()=>o("json"),children:"Raw JSON"})]}),n==="conversation"?r.jsx(Zl,{messages:e}):r.jsx("div",{className:"p-3",children:Array.isArray(t)?t.map((s,a)=>r.jsx("div",{className:"mt-2 first:mt-0",children:We(s)},a)):We(t)})]})})}function We(e){return r.jsx("div",{className:"overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:r.jsx(Bt,{data:e})})}const Yr=["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"],Zr=(e,t)=>{const n=Yr.indexOf(e)||0,o=Yr.indexOf(t)||0;return n-o},rc={workflowCoreVersion:"@workflow/core version"},oc=e=>rc[e]??e,sc=e=>{const t=String(e),n=wn(t);if(n)return n.moduleSpecifier;const o=kt(t);return o?o.moduleSpecifier:t},lt=e=>{let t;return e instanceof Date?t=e:typeof e=="number"?t=new Date(e):typeof e=="string"?t=new Date(e):t=new Date(String(e)),t.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3})},Ft={workflowName:e=>{var t;return((t=kt(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>sc(e),stepName:e=>{var t;return((t=wn(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),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:lt,startedAt:lt,updatedAt:lt,completedAt:lt,expiredAt:lt,retryAfter:lt,resumeAt:lt,metadata:We,input:(e,t)=>{if(e&&typeof e=="object"&&"args"in e){const{args:o,closureVars:s}=e,a=Array.isArray(o)?o.length:0,l=s&&Object.keys(s).length>0;if(t!=null&&t.stepName&&Ya(t.stepName)){const i=Za(o);if(i&&i.length>0)return r.jsxs(r.Fragment,{children:[r.jsx(nc,{conversation:i,args:o}),l&&r.jsx(qe,{summary:"Closure Variables",children:We(s)})]})}return r.jsxs(r.Fragment,{children:[r.jsx(qe,{summary:`Input (${a} arguments)`,children:Array.isArray(o)?o.map((i,d)=>r.jsx("div",{className:"mt-2",children:We(i)},d)):We(o)}),l&&r.jsx(qe,{summary:"Closure Variables",children:We(s)})]})}const n=Array.isArray(e)?e.length:0;return r.jsx(qe,{summary:`Input (${n} arguments)`,children:Array.isArray(e)?e.map((o,s)=>r.jsx("div",{className:"mt-2",children:We(o)},s)):We(e)})},output:e=>r.jsx(qe,{summary:"Output",children:We(e)}),error:e=>{if(e&&typeof e=="object"&&"message"in e){const t=e;return r.jsx(qe,{summary:"Error",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[t.code&&r.jsxs("div",{children:[r.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:["Error Code:"," "]}),r.jsx("code",{className:"text-[11px]",style:{color:"var(--ds-gray-1000)"},children:t.code})]}),r.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-1000)",whiteSpace:"pre-wrap"},children:r.jsx("code",{children:t.stack||t.message})})]})})}return r.jsx(qe,{summary:"Error",children:r.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-1000)",whiteSpace:"pre-wrap"},children:r.jsx("code",{children:String(e)})})})},eventData:e=>r.jsx(qe,{summary:"Event Data",children:We(e)})},Jr=["input","output","error","metadata","eventData"],ac=()=>r.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:r.jsx("span",{children:"The data for this run has expired and is no longer available."})}),ic=({attribute:e,value:t,isLoading:n,inline:o=!1,context:s})=>{const a=Ft[e];if(!a)return null;const l=a(t,s);return l?o?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:e}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--ds-gray-1000)"},children:l})]}):r.jsxs("div",{className:"relative",children:[typeof n=="boolean"&&n&&r.jsx("div",{className:"absolute top-9 right-4",children:r.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2",style:{borderColor:"var(--ds-gray-900)"}})}),r.jsxs("div",{className:"flex flex-col gap-0 my-2",children:[r.jsx("span",{className:"text-xs font-medium",style:{color:"var(--ds-gray-700)"},children:e}),r.jsx("span",{className:"text-xs",style:{color:"var(--ds-gray-1000)"},children:l})]},e)]}):null},lc=({data:e,moduleSpecifier:t,isLoading:n,error:o,expiredAt:s,onStreamClick:a})=>{const l=x.useMemo(()=>{const m={...e},C=e.executionContext;return C!=null&&C.workflowCoreVersion&&(m.workflowCoreVersion=C.workflowCoreVersion),t?m.moduleSpecifier=t:typeof e.stepName=="string"?m.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(m.moduleSpecifier=e.workflowName),m},[e,t]),i=s!=null&&new Date(s)<new Date,d=Object.keys(l).filter(m=>!Jr.includes(m)).sort(Zr),c=Object.keys(l).filter(m=>Jr.includes(m)).sort(Zr),f=d.filter(m=>{const C=Ft[m];return C?C(l[m])!==null:!1}),u=x.useMemo(()=>{const m=[...f],C=m.indexOf("moduleSpecifier");if(C===-1)return m;m.splice(C,1);const v=m.indexOf("workflowName");if(v!==-1)return m.splice(v+1,0,"moduleSpecifier"),m;const k=m.indexOf("stepName");return k!==-1?(m.splice(k+1,0,"moduleSpecifier"),m):(m.unshift("moduleSpecifier"),m)},[f]),p=x.useMemo(()=>({stepName:l.stepName}),[l.stepName]);return r.jsx(Xa.Provider,{value:a,children:r.jsxs("div",{children:[f.length>0&&r.jsx("div",{className:"flex flex-col divide-y rounded-lg border mb-3 overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:u.map(m=>{var C;return r.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[r.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:oc(m)}),r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--ds-gray-1000)"},children:(C=Ft[m])==null?void 0:C.call(Ft,l[m])})]},m)})}),o?r.jsx(aa,{title:"Failed to load resource details",details:o.message,className:"my-4"}):i?r.jsx(ac,{}):c.map(m=>r.jsx(ic,{isLoading:n,attribute:m,value:l[m],context:p},m))]})})},cc=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function dc({event:e,onLoadEventData:t}){const[n,o]=x.useState(null),[s,a]=x.useState(!1),[l,i]=x.useState(null),d="eventData"in e&&e.eventData!=null?e.eventData:null,c=d??n,f=cc.has(e.eventType),u=x.useCallback(async()=>{if(!(d||n!==null||s)&&!(!t||!e.correlationId||!e.eventId))try{a(!0),i(null);const m=await t(e.correlationId,e.eventId);o(m)}catch(m){i(m instanceof Error?m.message:String(m))}finally{a(!1)}},[d,n,s,t,e.correlationId,e.eventId]),p=new Date(e.createdAt);return r.jsxs(qe,{summary:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-medium",style:{color:"var(--ds-gray-1000)"},children:e.eventType})," ","-"," ",r.jsx("span",{style:{color:"var(--ds-gray-700)"},children:lt(p.getTime())})]}),onToggle:f?m=>{m&&u()}:void 0,children:[r.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:[r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[r.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:"eventId"}),r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--ds-gray-1000)"},children:e.eventId})]}),e.correlationId&&r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[r.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:"correlationId"}),r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--ds-gray-1000)"},children:e.correlationId})]})]}),s&&r.jsx("div",{className:"mt-2 text-xs rounded-md border p-2",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-600)"},children:"Loading event data..."}),l&&r.jsx("div",{className:"mt-2 text-xs rounded-md border p-2",style:{borderColor:"var(--ds-red-300)",color:"var(--ds-red-700)"},children:l}),c!=null&&r.jsx("div",{className:"mt-2 overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:r.jsx(Bt,{data:c})})]})}function uc({events:e,isLoading:t=!1,error:n,onLoadEventData:o}){const s=x.useMemo(()=>[...e].sort((a,l)=>new Date(a.createdAt).getTime()-new Date(l.createdAt).getTime()),[e]);return r.jsxs("div",{className:"mt-2",style:{color:"var(--ds-gray-1000)"},children:[r.jsxs("h3",{className:"text-heading-16 font-medium mt-4 mb-2",style:{color:"var(--ds-gray-1000)"},children:["Events ",!t&&`(${s.length})`]}),t?r.jsx("div",{children:"Loading events..."}):null,!t&&!n&&s.length===0&&r.jsx("div",{className:"text-sm",children:"No events found"}),s.length>0&&!n?r.jsx("div",{className:"flex flex-col gap-2",children:s.map(a=>r.jsx(dc,{event:a,onLoadEventData:o},a.eventId))}):null]})}function fc(e){return e!==null&&typeof e=="object"&&"stepId"in e}function mc(e){return e!==null&&typeof e=="object"&&"runId"in e}function on(e){return e!==null&&typeof e=="object"&&"hookId"in e}function pc({run:e,hooks:t,onStreamClick:n,spanDetailData:o,spanDetailError:s,spanDetailLoading:a,onSpanSelect:l,onWakeUpSleep:i,onLoadEventData:d,onResolveHook:c,selectedSpan:f}){const[u,p]=x.useState(!1),[m,C]=x.useState(!1),[v,k]=x.useState(!1),[g,h]=x.useState(new Set),N=f==null?void 0:f.data,I=f==null?void 0:f.rawEvents,j=(I==null?void 0:I.length)??0,{resource:b,resourceId:w,runId:y}=x.useMemo(()=>{if(!f)return{resource:void 0,resourceId:void 0,runId:void 0};const _=f.resource;return _==="step"&&fc(N)?{resource:"step",resourceId:N.stepId,runId:N.runId}:_==="run"&&mc(N)?{resource:"run",resourceId:N.runId,runId:void 0}:_==="hook"&&on(N)?{resource:"hook",resourceId:N.hookId,runId:void 0}:_==="sleep"?{resource:"sleep",resourceId:f.spanId,runId:void 0}:{resource:void 0,resourceId:void 0,runId:void 0}},[f,N]);x.useEffect(()=>{b&&w&&["run","step","hook","sleep"].includes(b)&&l({resource:b,resourceId:w,runId:y})},[b,w,y,l]);const S=x.useMemo(()=>{if(b!=="sleep"||!I||["completed","failed","cancelled"].includes(e.status)||I.some(be=>be.eventType==="wait_completed"))return!1;const V=I.find(be=>be.eventType==="wait_created"),G=V==null?void 0:V.eventData,oe=G==null?void 0:G.resumeAt;return oe?new Date(oe).getTime()>Date.now():!1},[b,I,j,e.status]),A=x.useMemo(()=>!(b!=="hook"||!I||!w||g.has(w)||["completed","failed","cancelled"].includes(e.status)||I.some(V=>V.eventType==="hook_disposed")),[b,w,I,j,e.status,g]),L=s??void 0,D=a??!1,E=x.useMemo(()=>{if(b!=="hook"||!w)return;if(on(o)&&o.token)return o.token;const _=t==null?void 0:t.find(B=>B.hookId===w);if(_!=null&&_.token)return _.token;if(on(N)&&N.token)return N.token},[b,w,o,N,t]);x.useEffect(()=>{L&&f&&b&&pe.error(`Failed to load ${b} details`,{description:L.message})},[L,b,f]);const T=async()=>{if(!(u||!w)){if(!i){pe.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{p(!0),(await i(e.runId,w)).stoppedCount>0?pe.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):pe.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(_){console.error("Failed to wake up run:",_),pe.error("Failed to wake up run",{description:_ instanceof Error?_.message:"An unknown error occurred"})}finally{p(!1)}}},H=x.useCallback(async _=>{if(!v){if(!c){pe.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!E){pe.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{k(!0);const B=o??N,V=on(B)?B:void 0;await c(E,_,V),pe.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),C(!1),w&&h(G=>new Set(G).add(w))}catch(B){console.error("Failed to resolve hook:",B),pe.error("Failed to resolve hook",{description:B instanceof Error?B.message:"An unknown error occurred"})}finally{k(!1)}}},[c,E,v,o,N]);if(!f||!b||!w)return null;const P=b==="sleep"?N:o??N,F=x.useMemo(()=>{const _=P,B=_.stepName,V=_.workflowName;if(typeof B=="string")return B;if(typeof V=="string")return V;if(typeof e.workflowName=="string")return e.workflowName},[P,e.workflowName]);return r.jsxs("div",{className:mt("flex flex-col px-3"),style:{paddingTop:12,gap:16},children:[b==="sleep"&&S&&r.jsxs("div",{className:"mb-3 pb-3",style:{borderBottom:"1px solid var(--ds-gray-alpha-400)"},children:[r.jsxs("button",{type:"button",onClick:T,disabled:u,className:mt("flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md w-full","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",u?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[r.jsx(ia,{className:"h-4 w-4"}),u?"Waking up...":"Wake up"]}),r.jsx("p",{className:"mt-1.5 text-xs",style:{color:"var(--ds-gray-900)"},children:"Interrupt this sleep call and wake up the run."})]}),b==="hook"&&A&&r.jsxs("div",{className:"mb-3 pb-3",style:{borderBottom:"1px solid var(--ds-gray-alpha-400)"},children:[r.jsxs("button",{type:"button",onClick:()=>C(!0),disabled:v,className:mt("flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md w-full","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",v?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-gray-1000)",color:"var(--ds-background-100)"},children:[r.jsx(Eo,{className:"h-4 w-4"}),"Resolve Hook"]}),r.jsx("p",{className:"mt-1.5 text-xs",style:{color:"var(--ds-gray-900)"},children:"Send a JSON payload to resolve this hook."})]}),r.jsx(Ro,{isOpen:m,onClose:()=>C(!1),onSubmit:H,isSubmitting:v}),r.jsx(lc,{data:P,moduleSpecifier:F,expiredAt:e.expiredAt,isLoading:D,error:L??void 0,onStreamClick:n}),b!=="run"&&I&&r.jsx(uc,{events:I,onLoadEventData:d})]})}function hc(e){const t=x.useRef(e);t.current=e,x.useEffect(()=>{let n=0,o=0;const s=()=>{t.current(n),n=0},a=l=>{if(!l.ctrlKey&&!l.metaKey)return;l.preventDefault();let i=-l.deltaY;switch(l.deltaMode){case WheelEvent.DOM_DELTA_PAGE:i*=window.innerHeight;break;case WheelEvent.DOM_DELTA_LINE:i*=20;break}n+=i,cancelAnimationFrame(o),o=requestAnimationFrame(s)};return window.addEventListener("wheel",a,{passive:!1}),()=>{window.removeEventListener("wheel",a),cancelAnimationFrame(o)}},[])}function Qr(e){if(e<=0)return 1;const n=10**Math.floor(Math.log10(e)),o=e/n;return o<=1.5?n:o<=3.5?2*n:o<=7.5?5*n:10*n}function gc({scale:e,isLive:t=!1}){const{state:{root:n}}=ot(),[,o]=x.useState(0);x.useEffect(()=>{if(!t)return;const p=setInterval(()=>o(m=>m+1),1e3);return()=>clearInterval(p)},[t]);const s=n.duration,a=e>0?e:s>0?1/s:1;let i=Qr(50/a);i=Math.max(1,i);let d=i*a;const c=1e3;s/i>c&&(i=Qr(s/c),d=i*a);const f=Math.ceil(s/i),u=Math.ceil(100/d)||1;return r.jsx("div",{className:q.markersContainer,children:r.jsx("div",{"aria-hidden":!0,className:q.markers,style:{width:Math.floor(n.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${d}px`},children:new Array(f).fill(null).map((p,m)=>{const C=m%u===0;return r.jsx("span",{className:mt(q.marker,!C&&q.notch),children:C?r.jsxs("span",{className:q.markerLabel,children:[Ja(i*m),r.jsx("span",{className:q.markerClockTime,children:Qa(n.startTime+i*m)})]}):null},String(m))})})})}function xc({events:e,root:t,scale:n}){const o=x.useMemo(()=>e.filter(s=>s.event.showVerticalLine!==!1),[e]);return r.jsx("div",{className:q.eventMarkersContainer,children:r.jsx("div",{"aria-hidden":!0,className:q.eventMarkers,style:{width:Math.floor(t.duration*n)},children:o.map(s=>r.jsx("span",{className:mt(q.eventMarker),style:{left:Math.floor((s.timestamp-t.startTime)*n),...s.event.color&&{borderLeftColor:s.event.color}}},s.key))})})}const eo=2;function vc({memoCacheRef:e,timelineRef:t,root:n,spans:o,events:s,scale:a,dispatch:l,scrollSnapshotRef:i}){const d=x.useRef(!1),c=x.useRef(o);c.current=o;const f=x.useRef(s);f.current=s;const u=x.useRef(null),{style:p,setStyle:m}=Rn(u),C=x.useRef(null),v=x.useRef(null),{style:k,setStyle:g}=Rn(v),h=x.useRef(void 0),N=x.useRef(null),{style:I,setStyle:j}=Rn(N),b=x.useRef(0);x.useEffect(()=>{const y=t.current;if(!y)return;let S=b.current,A=0,L=!1,D=!1,E=!1,T=!1,H=0,P=0;const F=Date.now()+500,_=()=>{h.current||(h.current=y.getBoundingClientRect())},B=te=>h.current?(te-fn-_e)/(At+ut):0,V=()=>{const te=e.current;for(const me of c.current)me.isHovered&&(me.isHovered=!1,te.set(me.span.spanId,{}));l({type:"forceRender"})};let G=0;const oe=()=>{var ye,Se,Te,je,we,Le,Ue,tt;if(!d.current)return;h.current||_();const te=h.current;if(!te)return;const{scrollLeft:me,scrollTop:Ae}=y,Ge=Math.max(0,Math.min(S+me-te.left-_e,n.duration*a)),Ce=`${Ge-me+_e}px`;g("left",Ce),m("left",Ce);const W=n.startTime+Ge/a,de=W-n.startTime;if(de<0||de>n.duration?(ye=C.current)==null||ye.removeAttribute("data-text"):(Se=C.current)==null||Se.setAttribute("data-text",tn(de)),L){const nt=S-A,bt=Math.abs(nt);if(!E){if(bt<4)return;E=!0,j("display","flex"),V()}nt>0?(j("left",""),j("right","0")):(j("left","0"),j("right","")),j("width",`${bt}px`);const yt=Math.max(0,Math.min(A+me-te.left-_e,n.duration*a))/a;let it,wt;yt<de?(it=yt,wt=de):(it=de,wt=yt),(Te=N.current)==null||Te.setAttribute("data-range",`${tn(it)} — ${tn(wt)}`),(je=N.current)==null||je.setAttribute("data-duration",`${tn(wt-it)} selected`)}if(Date.now()<F){G=requestAnimationFrame(oe);return}if(me!==H||Ae!==P){H=me,P=Ae,G=requestAnimationFrame(oe);return}if(S-te.left<128?(we=C.current)==null||we.setAttribute("data-align","left"):S-te.left>te.width-128?(Le=C.current)==null||Le.setAttribute("data-align","right"):(Ue=C.current)==null||Ue.removeAttribute("data-align"),!E&&!D){const nt=e.current,bt=B(Ae)-eo,Yt=B(Ae+te.height)+eo;for(const De of c.current){const Ke=De.row>=bt&&De.row<=Yt&&W>=De.startTime&&W<=De.endTime;De.isHovered!==Ke&&(De.isHovered=Ke,nt.set(De.span.spanId,{}))}const it=12/a;let wt=null,yr=1/0;for(const De of f.current){const Ke=Math.abs(De.timestamp-W);Ke<=it&&Ke<yr&&(yr=Ke,wt=De)}for(const De of f.current){const Ke=De===wt;if(De.isHovered===Ke)continue;De.isHovered=Ke;const wr=(tt=De.ref)==null?void 0:tt.current;wr&&wr.setAttribute("data-hovered",String(Ke))}l({type:"forceRender"})}};G=requestAnimationFrame(oe);const ve=te=>{te.pointerType==="mouse"&&(d.current=!0)},be=()=>{d.current&&(d.current=!1,V())},J=({clientX:te})=>{S=te,b.current=S,cancelAnimationFrame(G),G=requestAnimationFrame(oe)},Q=te=>{te.preventDefault()},ie=te=>{var me;if(te.button===2)T=!0,te.preventDefault();else{if(te.button!==0)return;T=!1}(me=t.current)!=null&&me.contains(te.target)?(A=S,L=!0):(D=!0,requestAnimationFrame(V))},R=te=>{if(D=!1,!L||(L=!1,!E))return;if(E=!1,j("display",""),j("left",""),j("right",""),j("width",""),te.preventDefault(),te.stopImmediatePropagation(),T){T=!1;return}h.current||_();const me=h.current;if(!me)return;const{scrollLeft:Ae}=y,Ge=Math.max(0,Math.min((A+Ae-me.left-_e)/a,n.duration)),Ce=Math.max(0,Math.min((S+Ae-me.left-_e)/a,n.duration));l({type:"scaleToRange",t1:Ge+n.startTime,t2:Ce+n.startTime})},K=te=>{L&&te.key==="Escape"&&(T=!0,R(te))},re=()=>{h.current=void 0,w.current=void 0,cancelAnimationFrame(G),G=requestAnimationFrame(oe)},ce=()=>{cancelAnimationFrame(G),G=requestAnimationFrame(oe)},fe=new ResizeObserver(()=>{h.current=void 0});return fe.observe(y),window.addEventListener("mousemove",J),y.addEventListener("contextmenu",Q),window.addEventListener("mousedown",ie),window.addEventListener("mouseup",R),window.addEventListener("blur",R),window.addEventListener("keydown",K,!0),window.addEventListener("scroll",re),y.addEventListener("scroll",ce),y.addEventListener("pointerenter",ve),y.addEventListener("pointerleave",be),()=>{fe.disconnect(),window.removeEventListener("mousemove",J),y.removeEventListener("contextmenu",Q),window.removeEventListener("mousedown",ie),window.removeEventListener("mouseup",R),window.removeEventListener("blur",R),window.removeEventListener("keydown",K,!0),window.removeEventListener("scroll",re),y.removeEventListener("scroll",ce),y.removeEventListener("pointerenter",ve),y.removeEventListener("pointerleave",be),cancelAnimationFrame(G),b.current=S,V()}},[l,n,a,g,m,j,e,t,i]);const w=x.useRef(void 0);return hc(y=>{const S=t.current;if(!S)return;h.current??(h.current=S.getBoundingClientRect());const A=h.current,L=Math.max(0,Math.min(b.current-A.left-_e,A.width-2*_e));let D=0,E=w.current;(E==null?void 0:E.anchorX)===L?D=E.anchorT:(D=(S.scrollLeft+L)/a,E={anchorT:D,anchorX:L},w.current=E),l({type:"trackpadScale",delta:y/64,anchorT:D,anchorX:L})}),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:q.cursorMarkerStickyParent,children:r.jsx("div",{className:q.cursorMarkerLabelContainer,ref:u,style:p,children:r.jsx("div",{className:q.cursorMarkerLabel,ref:C})})}),r.jsx("div",{className:q.cursorMarkerStickyParent,children:r.jsx("div",{className:q.cursorMarkerContainer,ref:v,style:k,children:r.jsx("div",{className:q.cursorMarker,children:r.jsx("div",{className:q.cursorSelection,ref:N,style:I})})})})]})}function bc({height:e,width:t,value:n,placeholder:o,onChange:s}){return r.jsxs("label",{className:q.searchInputLabel,children:[r.jsx("div",{className:q.searchInputPrefix,children:r.jsx(yc,{})}),r.jsx("input",{type:"search",value:n,placeholder:o,onChange:s,style:{height:e,width:t}})]})}function yc(){return r.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[r.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),r.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function wc(){return r.jsx("nav",{className:q.searchBar,children:r.jsx(Nc,{})})}function Nc(){const{dispatch:e}=ot(),[t,n]=x.useState("");return x.useEffect(()=>{const o=setTimeout(()=>e({type:"setFilter",filter:t}),100);return()=>{clearTimeout(o)}},[e,t]),r.jsx("div",{className:q.searchInput,children:r.jsx(bc,{height:_o,onChange:o=>n(o.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}function Ic({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[r.jsx("title",{children:"Zoom In"}),r.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M11 8v6M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),r.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function jc({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[r.jsx("title",{children:"Zoom Out"}),r.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),r.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function kc({size:e=16}){return r.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[r.jsx("title",{children:"Minus"}),r.jsx("path",{d:"M6 12h12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Cc(){const{dispatch:e}=ot(),t=x.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),n=x.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),o=x.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return r.jsxs("div",{className:q.zoomButtonGroup,children:[r.jsx("button",{"aria-label":"Zoom Out",className:q.zoomButton,onClick:n,type:"button",children:r.jsx(jc,{size:18})}),r.jsx("div",{className:q.divider}),r.jsx("button",{"aria-label":"Reset Zoom",className:q.zoomButton,onClick:o,type:"button",children:r.jsx(kc,{size:18})}),r.jsx("div",{className:q.divider}),r.jsx("button",{"aria-label":"Zoom In",className:q.zoomButton,onClick:t,type:"button",children:r.jsx(Ic,{size:18})})]})}const Sc=e=>{const{spans:t}=e,n={startTime:0,endTime:0,duration:0,depth:0,children:[]},o={},s=new Map,a=u=>{const p=s.get(u);if(p)return p;const m=s.size+1;return s.set(u,m),m};let l=!1;for(const u of t){const p=Ot(u.startTime),m=Ot(u.endTime),C=Ot(u.duration);m>n.endTime&&(n.endTime=m,n.duration=m-n.startTime),(n.startTime===0||p<n.startTime)&&(n.startTime=p,n.duration=n.endTime-p);const v=u.resource.startsWith("vercel.");v||(l=!0);const k=v&&(u.resource!=="vercel.serverless-runtime"||!("http.method"in u.attributes)),g=k?0:a(u.resource);let h;k&&(h=`▲ ${u.name}`),o[u.spanId]={parent:null,startTime:p,endTime:m,duration:C,span:u,depth:0,label:h,events:Tc(u),isVercel:k,children:[],resourceIndex:g,activeStartTime:u.activeStartTime?Ot(u.activeStartTime):void 0}}const i=(u,p)=>{let m;p?(m=o[p],m||(m=n)):m=n,u.parent=m,m.children.push(u)},d=u=>{"parent"in u&&(u.depth=u.parent.depth+1);for(const p of u.children)d(p)};let c=1;const f=(u,p)=>{if("parent"in u&&u.span.name===p){let m=u.endTime;const C=b=>b.children.length?b.children.map(C).sort((w,y)=>w.duration-y.duration)[0]||b:b.span.name==="waitUntil"?(m=b.startTime,b.parent):b,v=C(u),k=`instrumentation-hint-${c++}`,g=u.duration*.05,h=u.startTime+g,N=Math.max(h+g,Math.min(m-u.duration*.01,u.endTime-g)),I=N-h,j={parent:v,startTime:h,endTime:N,duration:I,span:{spanId:k,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:An(h),endTime:An(N),duration:An(I)},depth:u.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return v.children.push(j),o[k]=j,!0}for(const m of u.children)if(f(m,p))return!0;return!1};for(const u of Object.values(o))i(u,u.span.parentSpanId);if(d(n),!l){for(const u of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(f(n,u))break}return{root:n,map:o}},Tc=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((n,o)=>({key:`${t}${o}`,timestamp:Ot(n.timestamp),event:n})).sort((n,o)=>n.timestamp-o.timestamp)},to=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function Pn(){return[]}const Ec=(e,t=!1)=>{const{state:n,dispatch:o}=ot(),{root:s,filter:a,scale:l,timelineRef:i,timelineWidth:d,spanMap:c,scrollSnapshotRef:f,selected:u,memoCacheRef:p}=n,m=Rc(n.timelineHeight),C=x.useRef(0),[v,k]=x.useState(Pn),[g,h]=x.useState(Pn),[N,I]=x.useState(Pn),[j,b]=x.useState(-1),w=x.useRef(void 0);return x.useEffect(()=>{var y;return(y=w.current)==null?void 0:y.call(w,a)},[a]),x.useEffect(()=>{if(e!=null&&e.length){for(const y of v)for(const S of y){const A=e.includes(S.span.spanId);S.isHighlighted!==A&&(S.isHighlighted=A,p.current.set(S.span.spanId,{}))}o({type:"forceRender"})}},[v,e,o,p]),x.useEffect(()=>{if(!s.startTime)return;const y=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let S=++C.current;const A=D=>{var T;const E=D.data;switch(E.type){case"setRowsResult":{if((E==null?void 0:E.requestId)!==S)return;if(E.isEnd)for(const H of E.rows)for(const P of H)P.span=((T=c[P.span.spanId])==null?void 0:T.span)??P.span;k(E.rows);break}case"updateHighlight":{if((E==null?void 0:E.requestId)!==S)return;const{matches:H}=E;k(P=>{for(const F of P)for(const _ of F){const B=H.has(_.span.spanId);_.isHighlighted!==B&&(_.isHighlighted=B,p.current.set(_.span.spanId,{}))}return P}),o({type:"forceRender"});break}}};y.addEventListener("message",A);const L={requestId:S,type:"calculateSpanPositions",root:s};return y.postMessage(L),w.current=D=>{const E=D.trim().toLocaleLowerCase();if(!E){k(H=>H.map(P=>P.map(F=>(F.isHighlighted=void 0,{...F}))));return}S=++C.current;const T={type:"filterSpans",requestId:S,root:s,filter:E};y.postMessage(T)},()=>{y.terminate()}},[s,c,o,p]),x.useEffect(()=>{if(!v.length)return;if(t){const J=[],Q=[];for(const ie of v)for(const R of ie)to(R)&&(J.push(R),R.events&&Q.push(...R.events));h(J),I(Q),b(l);return}const y=i.current;let S=f.current,A=!1,L=!1,D=0,E=0;const T=Math.max(500,d*.5),H=new Array(v.length).fill(null),P=()=>{L=!0;const J=Math.min(1+E+Math.ceil((S==null?void 0:S.endRow)??Number.POSITIVE_INFINITY),v.length);for(let Q=J;Q--;){if(H[Q])continue;const ie=F(Q);if(Math.abs(ie)>E){if(L=!1,ie>0)continue;break}const R=[],K=v[Q];if(K){for(const re of K){if(!to(re))continue;const ce=_(re);D=Math.max(ce,D),R.push({d:ce,span:re})}H[Q]=R}}},F=J=>S?J<S.startRow?J-S.startRow:J>S.endRow?J-S.endRow:0:0,_=J=>{if(!S)return 0;let Q=0;J.endTime<S.startTime?Q=S.startTime-J.endTime:J.startTime>S.endTime&&(Q=J.startTime-S.endTime);const ie=Math.abs(F(J.row));return!Q&&!ie?0:Math.sqrt((Q/l)**2+(ie*At+ut)**2)},B=()=>{if(!y)return;const{scrollLeft:J,scrollTop:Q}=y,ie=0,R=J/l,K=(Q-fn-_e)/(At+ut),re=K+Math.ceil(m/(At+ut));S={anchorT:R,anchorX:ie,scrollLeft:J,scrollTop:Q,startTime:s.startTime+J/l,endTime:s.startTime+(J+d)/l,startRow:K,endRow:re,scale:l},f.current=S;for(let ce=H.length;ce--;)H[ce]=null};let V=0;const G=()=>{(A||!S)&&(A=!1,B()),P();const J=[],Q=[];for(const ie of H)if(ie)for(const{d:R,span:K}of ie)R>E||(J.push(K),K.events&&Q.push(...K.events));E<T&&(!L||E<D)&&(E=Math.min(T,E+100),V=requestAnimationFrame(G)),h(J),I(Q),b(l)};G();let oe=Date.now();const ve=J=>{(J.ctrlKey||J.metaKey)&&(oe=Date.now())};y==null||y.addEventListener("wheel",ve);const be=()=>{Date.now()-oe<=50||(A=!0,cancelAnimationFrame(V),V=requestAnimationFrame(G))};return y==null||y.addEventListener("scroll",be),()=>{cancelAnimationFrame(V),y==null||y.removeEventListener("wheel",ve),y==null||y.removeEventListener("scroll",be)}},[v,s,l,f,i,d,m,t]),x.useEffect(()=>{var A;if(!u)return;let y;for(const L of g)if(L.span.spanId===u.span.spanId){y=L;break}const S=(A=y==null?void 0:y.ref)==null?void 0:A.current;if(!(!y||!S))return y.isSelected=!0,S.setAttribute("data-selected",""),()=>{y.isSelected=!1,S.removeAttribute("data-selected")}},[g,u]),{rows:v,spans:g,events:N,scale:j}};function Rc(e){const[t,n]=x.useState(e);return x.useEffect(()=>{if(t===e)return;let o=0,s=0;const a=()=>{if(++o<=3){s=requestAnimationFrame(a);return}n(e)};return a(),()=>{cancelAnimationFrame(s)}},[t,e]),t}const no={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 Ac({trace:e=no,className:t="",scrollLock:n=!1,height:o,withPanel:s=!1,highlightedSpans:a,eagerRender:l=!1,isLive:i=!1}){const d=e===no,{state:c,dispatch:f}=ot(),{timelineRef:u,scrollSnapshotRef:p}=c,m=c.memoCacheRef.current,C=((a==null?void 0:a.length)??0)>0,v=x.useRef(!1),k=x.useRef(""),g=x.useRef(null),h=x.useRef({}),N=x.useRef(null);x.useEffect(()=>{const{root:E,map:T}=Sc(e),H=!v.current;v.current=!0;const P=Object.keys(T).sort().map(F=>{const _=T[F].events,B=(_==null?void 0:_.length)??0,V=B?_==null?void 0:_[0]:void 0,G=B?_==null?void 0:_[B-1]:void 0,oe=`${(V==null?void 0:V.event.name)??"none"}@${(V==null?void 0:V.timestamp)??0}|${(G==null?void 0:G.event.name)??"none"}@${(G==null?void 0:G.timestamp)??0}`;return`${F}:${B}:${oe}`}).join(",");if(!H&&P===k.current&&g.current){const F=g.current,_=h.current;let B=!1;(F.endTime!==E.endTime||F.duration!==E.duration)&&(F.endTime=E.endTime,F.duration=E.duration,B=!0);for(const[V,G]of Object.entries(T)){const oe=_[V];oe&&((oe.endTime!==G.endTime||oe.duration!==G.duration)&&(oe.endTime=G.endTime,oe.duration=G.duration,B=!0),Object.assign(oe.span,G.span))}if(!B)return;f({type:"forceRender"});return}k.current=P,g.current=E,h.current=T,f({type:H?"setRoot":"updateRoot",root:E,spanMap:T,resources:e.resources||[]})},[f,e]);const{rows:I,spans:j,events:b,scale:w}=Ec(a,l),y=x.useRef(null);x.useLayoutEffect(()=>{const E=y.current;if(!E)return;const T=()=>{const P=2*_e,F=E.getBoundingClientRect(),_=F.width-P,B=F.height,V=N.current;V&&V.width===_&&V.height===B||(N.current={width:_,height:B},f({type:"setSize",width:_,height:B}))};T();const H=new ResizeObserver(T);return H.observe(E),window.addEventListener("resize",T),()=>{H.disconnect(),window.removeEventListener("resize",T)}},[f]);const S=x.useRef({t:0,x:-1,y:-1,spanId:""}),A=x.useCallback(E=>{const T=S.current,H=Date.now(),{clientX:P,clientY:F}=E,_=Math.sqrt((P-T.x)**2+(F-T.y)**2);if(H-T.t<=500&&_<=8){if(E.stopPropagation(),E.preventDefault(),!T.spanId){f({type:"resetScale"});return}f({type:"select",id:T.spanId}),f({type:"scaleToNode",id:T.spanId});return}const B=E.target;if(!B.closest(`.${String(q.timeline)}`))return;const V=B.closest("[data-span-id]"),G=(V==null?void 0:V.dataset.spanId)||"";S.current={x:P,y:F,t:H,spanId:G},G&&(f({type:"toggleSelection",id:G}),E.stopPropagation())},[f]);x.useLayoutEffect(()=>{const E=u.current;if(!E)return;const T=p.current;T&&(E.scrollLeft=T.anchorT*w-T.anchorX,p.current=void 0)},[p,u,w]),x.useEffect(()=>{var H;const E=(H=c.selected)==null?void 0:H.span.spanId;if(!E)return;const T=setTimeout(()=>{const P=c.timelineRef.current,F=P==null?void 0:P.querySelector(`[data-span-id="${E}"]`);if(!P||!F)return;const _=P.getBoundingClientRect(),B=F.getBoundingClientRect();B.width<_.width&&(B.left<_.left||B.right>_.right||B.top<_.top||B.bottom>_.bottom)&&F.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(T)}},[c.selected,c.timelineRef]),x.useEffect(()=>{const E=T=>{T.key==="Escape"&&f({type:"escape"})};return window.addEventListener("keydown",E),()=>{window.removeEventListener("keydown",E)}},[f]),x.useEffect(()=>{if(!n)return;const E=document.documentElement,T=document.body;E.style.overflow="clip",T.style.overflow="clip";const H=P=>{P!=null&&P.cancelable?P.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return H(),window.addEventListener("scroll",H,{passive:!1}),()=>{E.style.overflow="",T.style.overflow="",window.removeEventListener("scroll",H)}},[n]);const L=Math.max(c.timelineHeight-c.scrollbarWidth,fn+ut+I.length*(At+ut)-ut+84),D=!!(c.isMobile&&c.selected);return r.jsxs("div",{className:mt(q.traceViewer,d&&q.skeleton,t),onClickCapture:A,ref:y,style:{height:o,"--timeline-padding":`${_e}px`,"--row-height":`${At}px`,"--row-padding":`${ut}px`,"--search-height":`${C?0:_o}px`,"--search-gap":`${C?2:ni}px`,"--map-height":`${ti}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":`${fn}px`,"--marker-notch-height":`${ei}px`},children:[C?null:r.jsx(wc,{}),r.jsx(ri,{rows:I,scale:w,timelineRef:u}),r.jsxs("div",{className:mt(q.traceViewerContent,D&&q.inert),children:[r.jsx("div",{className:q.timeline,ref:u,children:r.jsx("div",{style:{position:"relative",width:c.timelineWidth,height:c.timelineHeight-_e*2,padding:_e,paddingBottom:0},children:r.jsxs("div",{className:q.traceNode,style:{width:c.root.duration*w||void 0,height:L-_e*2},children:[r.jsx(gc,{scale:w,isLive:i}),r.jsx(xc,{events:b,root:c.root,scale:w}),r.jsx(vc,{dispatch:f,events:b,memoCacheRef:c.memoCacheRef,root:c.root,scale:w,scrollSnapshotRef:p,spans:j,timelineRef:u}),r.jsx(oi,{cacheKey:m.get(""),cache:m,customSpanClassNameFunc:c.customSpanClassNameFunc,customSpanEventClassNameFunc:c.customSpanEventClassNameFunc,isLive:i,root:c.root,scale:w,scrollSnapshotRef:p,spans:j})]})})}),r.jsx("div",{className:q.zoomButtonTraceViewer,children:r.jsx(Cc,{})})]}),s?r.jsx("div",{className:mt(q.spanDetailPanelTraceViewer,!c.selected&&q.hidden,c.isMobile&&q.mobile),children:r.jsx(si,{attached:!0})}):null]})}function ro(e,t=!1){if(t&&e==="pending")return q.spanPendingStriped;switch(e){case"running":return q.spanRunning;case"pending":return q.spanPending;case"completed":return q.spanCompleted;case"cancelled":return q.spanCancelled;case"failed":return q.spanFailed;default:return""}}function Dc(e){return String(e).toLowerCase().endsWith("sleep")}const Mc=e=>{const t=e.span.attributes,n=t==null?void 0:t.resource;if(n==="step"){const o=t.data,s=o==null?void 0:o.stepName;if(s&&Dc(s))return q.spanSleep;const a=(o==null?void 0:o.status)==="pending";return ro(o==null?void 0:o.status,a)}if(n==="run"){const o=t.data;return ro(o==null?void 0:o.status,!1)}return n==="hook"?q.spanHook:n==="sleep"?q.spanSleep:""},Lc=e=>{const t=e.event.name;return t==="step_failed"||t==="run_failed"?q.eventFailed:t==="step_retrying"?q.eventRetrying:t==="hook_created"||t==="hook_received"||t==="hook_disposed"?q.eventHook:q.eventDefault};function _c(e){const{state:t,dispatch:n}=ot(),o=x.useRef(t);o.current=t,x.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 l=0,i=0;const d=()=>{const c=o.current;if(c.root.duration>0){const f=(c.width-c.scrollbarWidth)/c.root.duration;(Math.abs(f-i)>i*.001||i===0)&&(i=f,n({type:"detectBaseScale"}))}l=requestAnimationFrame(d)};return l=requestAnimationFrame(d),()=>{cancelAnimationFrame(s),cancelAnimationFrame(l)}},[e,n])}const Hc=380,Oc=240;function Fc({menu:e,items:t,onClose:n}){const o=x.useRef(null);x.useEffect(()=>{const l=f=>{o.current&&!o.current.contains(f.target)&&n()},i=f=>{f.key==="Escape"&&n()},d=()=>{n()},c=setTimeout(()=>{window.addEventListener("mousedown",l),window.addEventListener("keydown",i),window.addEventListener("scroll",d,!0)},0);return()=>{clearTimeout(c),window.removeEventListener("mousedown",l),window.removeEventListener("keydown",i),window.removeEventListener("scroll",d,!0)}},[n]);const[s,a]=x.useState({x:e.x,y:e.y});return x.useEffect(()=>{const l=o.current;if(!l)return;const i=l.getBoundingClientRect();let{x:d,y:c}=e;i.right>window.innerWidth&&(d=window.innerWidth-i.width-8),i.bottom>window.innerHeight&&(c=window.innerHeight-i.height-8),(d!==e.x||c!==e.y)&&a({x:d,y:c})},[e]),t.length===0?null:ko.createPortal(r.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:[r.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(l=>r.jsxs("button",{type:"button",style:{outline:"none",cursor:l.disabled?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:8,padding:"0 var(--geist-space-2x, 8px)",height:40,textDecoration:"none",borderRadius:6,color:l.destructive?"var(--ds-red-900)":"var(--ds-gray-1000)",width:"100%",background:"transparent",border:"none",fontSize:14,textAlign:"left",opacity:l.disabled?.4:1,transition:"background 0.15s"},disabled:l.disabled,onMouseEnter:i=>{i.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:i=>{i.currentTarget.style.background="transparent"},onClick:()=>{l.action(),n()},children:[l.icon??null,l.label]},l.label))]}),document.body)}function Pc({trace:e,run:t,hooks:n,isLive:o,onWakeUpSleep:s,onCancelRun:a,onResolveHook:l,children:i}){const{dispatch:d}=ot();_c(o);const[c,f]=x.useState(null),[u,p]=x.useState(null),[m,C]=x.useState(!1),[v,k]=x.useState(new Set),g=x.useMemo(()=>{const y=new Map;for(const S of e.spans)y.set(S.spanId,S);return y},[e.spans]),h=x.useMemo(()=>{const y=new Map;for(const S of n)y.set(S.hookId,S);return y},[n]),N=x.useCallback(async y=>{if(!(m||!u||!l)){if(!u.token){pe.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{C(!0),await l(u.token,y,u),pe.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),k(S=>new Set(S).add(u.hookId)),p(null)}catch(S){console.error("Failed to resolve hook:",S),pe.error("Failed to resolve hook",{description:S instanceof Error?S.message:"An unknown error occurred"})}finally{C(!1)}}},[l,u,m]),I=x.useCallback(y=>{const A=y.target.closest("[data-span-id]");if(!A)return;const L=A.dataset.spanId;if(!L)return;y.preventDefault(),y.stopPropagation();const D=g.get(L);if(!D)return;const E=D.attributes.resource??"unknown",T=D.attributes.data,H=!(T!=null&&T.completedAt)&&!(T!=null&&T.disposedAt);f({x:y.clientX,y:y.clientY,spanId:L,spanName:D.name,resourceType:E,isActive:H})},[g]),j=x.useRef(null);x.useEffect(()=>{const y=j.current;if(!y)return;const S=A=>{I(A)};return y.addEventListener("contextmenu",S),()=>{y.removeEventListener("contextmenu",S)}},[I]);const b=x.useCallback(()=>{f(null)},[]),w=x.useCallback(y=>{var L,D;const S=[],A=!t.completedAt;if(y.resourceType==="sleep"&&y.isActive&&A&&s&&S.push({label:"Wake Up Sleep",icon:r.jsx(ca,{className:"h-3.5 w-3.5"}),action:()=>{s(t.runId,y.spanId).then(E=>{E.stoppedCount>0?pe.success("Sleep woken up",{description:`Woke up ${String(E.stoppedCount)} sleep${E.stoppedCount>1?"s":""}`}):pe.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(E=>{pe.error("Failed to wake up sleep",{description:E instanceof Error?E.message:"An unknown error occurred"})})}}),y.resourceType==="hook"&&A&&l){const E=h.get(y.spanId),T=g.get(y.spanId),H=(L=T==null?void 0:T.attributes)==null?void 0:L.data,P=!!(H!=null&&H.disposedAt)||!!((D=T==null?void 0:T.events)!=null&&D.some(F=>F.name==="hook_disposed"))||v.has(y.spanId);E!=null&&E.token&&!P&&S.push({label:"Resolve Hook",icon:r.jsx(Eo,{className:"h-3.5 w-3.5"}),action:()=>{p(E)}})}return y.resourceType==="run"&&A&&a&&S.push({label:"Cancel Run",icon:r.jsx(da,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{a(t.runId).catch(E=>{pe.error("Failed to cancel run",{description:E instanceof Error?E.message:"An unknown error occurred"})})}}),S.push({label:"View Details",icon:r.jsx(pi,{className:"h-3.5 w-3.5"}),action:()=>{d({type:"select",id:y.spanId})}}),S.push({label:"Copy Name",icon:r.jsx(hi,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(y.spanName).then(()=>{pe.success("Name copied to clipboard")}).catch(()=>{pe.error("Failed to copy name")})}}),S.push({label:"Copy ID",icon:r.jsx(tr,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(y.spanId).then(()=>{pe.success("ID copied to clipboard")}).catch(()=>{pe.error("Failed to copy ID")})}}),S},[d,s,a,l,h,g,v,t.runId,t.completedAt]);return r.jsxs("div",{className:"relative w-full h-full",ref:j,children:[i,c?r.jsx(Fc,{menu:c,items:w(c),onClose:b}):null,r.jsx(Ro,{isOpen:u!==null,onClose:()=>p(null),onSubmit:N,isSubmitting:m})]})}const zc=e=>e==="wait_created"||e==="wait_completed",Bc=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed",sn=(e,t,n)=>{const o=e.get(t);if(o){o.push(n);return}e.set(t,[n])},Wc=(e,t,n)=>{const o=new Map,s=new Map,a=[],l=new Map,i=new Map,d=new Set(t.map(f=>f.stepId)),c=new Set(n.map(f=>f.hookId));for(const f of e){const u=f.correlationId;if(!u){a.push(f);continue}if(zc(f.eventType)){sn(l,u,f);continue}if(Bc(f.eventType)){sn(i,u,f);continue}if(d.has(u)){sn(o,u,f);continue}if(c.has(u)){sn(s,u,f);continue}a.push(f)}return{eventsByStepId:o,eventsByHookId:s,runLevelEvents:a,timerEvents:l,hookEvents:i}},$c=(e,t,n,o)=>{const s=new Date(e.completedAt||o),a=t.map(d=>{const c=n.eventsByStepId.get(d.stepId)||[];return ua(d,c,o,s)}),l=Array.from(n.hookEvents.values()).map(d=>fa(d,e,o)).filter(d=>d!==null),i=Array.from(n.timerEvents.values()).map(d=>ma(d,e,o)).filter(d=>d!==null);return{runSpan:pa(e,n.runLevelEvents,o),spans:[...a,...l,...i]}},Vc=(e,t)=>{const n=[e,...t.slice().sort((o,s)=>{const a=Nr(o.startTime),l=Nr(s.startTime);return a-l})];return n.map((o,s)=>{const a=s===0?void 0:String(n[s-1].spanId);return{...o,parentSpanId:a}})},Gc=(e,t,n,o,s)=>{const a=Wc(o,t,n),{runSpan:l,spans:i}=$c(e,t,a,s),d=Vc(l,i);return{traceId:e.runId,rootSpanId:e.runId,spans:d,resources:[{name:"workflow",attributes:{"service.name":la.name}}]}};function Uc({onSelectionChange:e}){const{state:t}=ot(),{selected:n}=t,o=x.useRef(e);return o.current=e,x.useEffect(()=>{var s,a;n?o.current({data:(s=n.span.attributes)==null?void 0:s.data,resource:(a=n.span.attributes)==null?void 0:a.resource,spanId:n.span.spanId}):o.current(null)},[n]),null}function Kc({triggerDeselect:e}){const{dispatch:t}=ot();return x.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function qc({onResize:e}){const t=x.useCallback(n=>{n.preventDefault();let o=n.clientX;const s=l=>{const i=o-l.clientX;o=l.clientX,e(i)},a=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",a)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",a)},[e]);return r.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 Xc=({run:e,steps:t,hooks:n,events:o,isLoading:s,error:a,spanDetailData:l,spanDetailLoading:i,spanDetailError:d,onWakeUpSleep:c,onResolveHook:f,onCancelRun:u,onStreamClick:p,onSpanSelect:m,onLoadEventData:C})=>{const[v,k]=x.useState(null),[g,h]=x.useState(Hc),[N,I]=x.useState(0),j=!!(e&&!e.completedAt),b=x.useMemo(()=>{if(e)return Gc(e,t,n,o,new Date)},[e,t,n,o]);x.useEffect(()=>{a&&!s&&(console.error(a),pe.error("Error loading workflow trace data",{description:a.message}))},[a,s]);const w=x.useCallback(D=>{m==null||m(D)},[m]),y=x.useCallback(D=>{if(D){const E=D.spanId,T=E?o.filter(H=>H.correlationId===E):[];k({...D,rawEvents:T})}else k(null)},[o]);x.useEffect(()=>{const D=v==null?void 0:v.spanId;if(!D)return;const E=o.filter(T=>T.correlationId===D);k(T=>{if(!T||T.spanId!==D)return T;const H=T.rawEvents??[];return H.length===E.length&&H.every((F,_)=>{var B;return F.eventId===((B=E[_])==null?void 0:B.eventId)})?T:{...T,rawEvents:E}})},[o,v==null?void 0:v.spanId]);const S=x.useCallback(()=>{k(null),I(D=>D+1)},[]),A=x.useCallback(D=>{h(E=>Math.max(Oc,E+D))},[]),L=x.useMemo(()=>{var H,P;if(!(v!=null&&v.data))return;const D=v.data,E=D.stepName,T=D.workflowName;return(E?(H=wn(E))==null?void 0:H.shortName:void 0)??(T?(P=kt(T))==null?void 0:P.shortName:void 0)??E??T??D.hookId??"Details"},[v==null?void 0:v.data]);return s||!b?r.jsxs("div",{className:"relative w-full h-full",children:[r.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),r.jsx(dt,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),r.jsxs("div",{className:"p-2 relative w-full",children:[r.jsx(dt,{className:"w-full mt-6 h-[20px]"}),r.jsx(dt,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),r.jsx(dt,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),r.jsx(dt,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]}):r.jsxs("div",{className:"relative w-full h-full flex",children:[r.jsx("div",{className:"flex-1 min-w-0 relative",children:r.jsxs(ai,{customSpanClassNameFunc:Mc,customSpanEventClassNameFunc:Lc,children:[r.jsx(Uc,{onSelectionChange:y}),r.jsx(Kc,{triggerDeselect:N}),r.jsx(Pc,{trace:b,run:e,hooks:n,isLive:j,onWakeUpSleep:c,onCancelRun:u,onResolveHook:f,children:r.jsx(Ac,{eagerRender:!0,height:"100%",isLive:j,trace:b})})]})}),v&&r.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:g,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[r.jsx(qc,{onResize:A}),r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b flex-shrink-0",style:{borderColor:"var(--ds-gray-200)"},children:[r.jsx("div",{className:"min-w-0 flex-1",children:r.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--ds-gray-1000)"},title:L,children:L})}),r.jsx("button",{type:"button","aria-label":"Close panel",onClick:S,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:8,padding:4,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-900)",cursor:"pointer",flexShrink:0,transition:"background 0.15s"},onMouseEnter:D=>{D.currentTarget.style.background="var(--ds-gray-alpha-200)"},onMouseLeave:D=>{D.currentTarget.style.background="transparent"},children:r.jsx(Ao,{size:16})})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:r.jsx(Rt,{title:"Failed to load entity details",children:r.jsx(pc,{run:e,hooks:n,onStreamClick:p,spanDetailData:l??null,spanDetailError:d,spanDetailLoading:i,onSpanSelect:w,onWakeUpSleep:c,onLoadEventData:C,onResolveHook:f,selectedSpan:v})})})]})]})};var Yc=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],st=Yc.reduce((e,t)=>{const n=x.forwardRef((o,s)=>{const{asChild:a,...l}=o,i=a?rr:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(i,{...l,ref:s})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Zc(e,t){e&&ko.flushSync(()=>e.dispatchEvent(t))}var Jc="DismissableLayer",er="dismissableLayer.update",Qc="dismissableLayer.pointerDownOutside",ed="dismissableLayer.focusOutside",oo,bs=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ys=x.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:l,onDismiss:i,...d}=e,c=x.useContext(bs),[f,u]=x.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=x.useState({}),C=ht(t,w=>u(w)),v=Array.from(c.layers),[k]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=v.indexOf(k),h=f?v.indexOf(f):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,I=h>=g,j=rd(w=>{const y=w.target,S=[...c.branches].some(A=>A.contains(y));!I||S||(s==null||s(w),l==null||l(w),w.defaultPrevented||i==null||i())},p),b=od(w=>{const y=w.target;[...c.branches].some(A=>A.contains(y))||(a==null||a(w),l==null||l(w),w.defaultPrevented||i==null||i())},p);return ha(w=>{h===c.layers.size-1&&(o==null||o(w),!w.defaultPrevented&&i&&(w.preventDefault(),i()))},p),x.useEffect(()=>{if(f)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(oo=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),so(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=oo)}},[f,p,n,c]),x.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),so())},[f,c]),x.useEffect(()=>{const w=()=>m({});return document.addEventListener(er,w),()=>document.removeEventListener(er,w)},[]),r.jsx(st.div,{...d,ref:C,style:{pointerEvents:N?I?"auto":"none":void 0,...e.style},onFocusCapture:rt(e.onFocusCapture,b.onFocusCapture),onBlurCapture:rt(e.onBlurCapture,b.onBlurCapture),onPointerDownCapture:rt(e.onPointerDownCapture,j.onPointerDownCapture)})});ys.displayName=Jc;var td="DismissableLayerBranch",nd=x.forwardRef((e,t)=>{const n=x.useContext(bs),o=x.useRef(null),s=ht(t,o);return x.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(st.div,{...e,ref:s})});nd.displayName=td;function rd(e,t=globalThis==null?void 0:globalThis.document){const n=dn(e),o=x.useRef(!1),s=x.useRef(()=>{});return x.useEffect(()=>{const a=i=>{if(i.target&&!o.current){let d=function(){ws(Qc,n,c,{discrete:!0})};const c={originalEvent:i};i.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},l=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(l),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function od(e,t=globalThis==null?void 0:globalThis.document){const n=dn(e),o=x.useRef(!1);return x.useEffect(()=>{const s=a=>{a.target&&!o.current&&ws(ed,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function so(){const e=new CustomEvent(er);document.dispatchEvent(e)}function ws(e,t,n,{discrete:o}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),o?Zc(s,a):s.dispatchEvent(a)}var zn="focusScope.autoFocusOnMount",Bn="focusScope.autoFocusOnUnmount",ao={bubbles:!1,cancelable:!0},sd="FocusScope",Ns=x.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...l}=e,[i,d]=x.useState(null),c=dn(s),f=dn(a),u=x.useRef(null),p=ht(t,v=>d(v)),m=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(o){let v=function(N){if(m.paused||!i)return;const I=N.target;i.contains(I)?u.current=I:ct(u.current,{select:!0})},k=function(N){if(m.paused||!i)return;const I=N.relatedTarget;I!==null&&(i.contains(I)||ct(u.current,{select:!0}))},g=function(N){if(document.activeElement===document.body)for(const j of N)j.removedNodes.length>0&&ct(i)};document.addEventListener("focusin",v),document.addEventListener("focusout",k);const h=new MutationObserver(g);return i&&h.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",k),h.disconnect()}}},[o,i,m.paused]),x.useEffect(()=>{if(i){lo.add(m);const v=document.activeElement;if(!i.contains(v)){const g=new CustomEvent(zn,ao);i.addEventListener(zn,c),i.dispatchEvent(g),g.defaultPrevented||(ad(ud(Is(i)),{select:!0}),document.activeElement===v&&ct(i))}return()=>{i.removeEventListener(zn,c),setTimeout(()=>{const g=new CustomEvent(Bn,ao);i.addEventListener(Bn,f),i.dispatchEvent(g),g.defaultPrevented||ct(v??document.body,{select:!0}),i.removeEventListener(Bn,f),lo.remove(m)},0)}}},[i,c,f,m]);const C=x.useCallback(v=>{if(!n&&!o||m.paused)return;const k=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,g=document.activeElement;if(k&&g){const h=v.currentTarget,[N,I]=id(h);N&&I?!v.shiftKey&&g===I?(v.preventDefault(),n&&ct(N,{select:!0})):v.shiftKey&&g===N&&(v.preventDefault(),n&&ct(I,{select:!0})):g===h&&v.preventDefault()}},[n,o,m.paused]);return r.jsx(st.div,{tabIndex:-1,...l,ref:p,onKeyDown:C})});Ns.displayName=sd;function ad(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(ct(o,{select:t}),document.activeElement!==n)return}function id(e){const t=Is(e),n=io(t,e),o=io(t.reverse(),e);return[n,o]}function Is(e){const t=[],n=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(;n.nextNode();)t.push(n.currentNode);return t}function io(e,t){for(const n of e)if(!ld(n,{upTo:t}))return n}function ld(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 cd(e){return e instanceof HTMLInputElement&&"select"in e}function ct(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&cd(e)&&t&&e.select()}}var lo=dd();function dd(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=co(e,t),e.unshift(t)},remove(t){var n;e=co(e,t),(n=e[0])==null||n.resume()}}}function co(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function ud(e){return e.filter(t=>t.tagName!=="A")}var fd="Portal",js=x.forwardRef((e,t)=>{var i;const{container:n,...o}=e,[s,a]=x.useState(!1);ga(()=>a(!0),[]);const l=n||s&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?jo.createPortal(r.jsx(st.div,{...o,ref:t}),l):null});js.displayName=fd;var gr="Dialog",[ks,Cs]=Do(gr),[md,Ve]=ks(gr),Ss=e=>{const{__scopeDialog:t,children:n,open:o,defaultOpen:s,onOpenChange:a,modal:l=!0}=e,i=x.useRef(null),d=x.useRef(null),[c=!1,f]=va({prop:o,defaultProp:s,onChange:a});return r.jsx(md,{scope:t,triggerRef:i,contentRef:d,contentId:Tn(),titleId:Tn(),descriptionId:Tn(),open:c,onOpenChange:f,onOpenToggle:x.useCallback(()=>f(u=>!u),[f]),modal:l,children:n})};Ss.displayName=gr;var Ts="DialogTrigger",Es=x.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Ve(Ts,n),a=ht(t,s.triggerRef);return r.jsx(st.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":br(s.open),...o,ref:a,onClick:rt(e.onClick,s.onOpenToggle)})});Es.displayName=Ts;var xr="DialogPortal",[pd,Rs]=ks(xr,{forceMount:void 0}),As=e=>{const{__scopeDialog:t,forceMount:n,children:o,container:s}=e,a=Ve(xr,t);return r.jsx(pd,{scope:t,forceMount:n,children:x.Children.map(o,l=>r.jsx(nr,{present:n||a.open,children:r.jsx(js,{asChild:!0,container:s,children:l})}))})};As.displayName=xr;var vn="DialogOverlay",Ds=x.forwardRef((e,t)=>{const n=Rs(vn,e.__scopeDialog),{forceMount:o=n.forceMount,...s}=e,a=Ve(vn,e.__scopeDialog);return a.modal?r.jsx(nr,{present:o||a.open,children:r.jsx(hd,{...s,ref:t})}):null});Ds.displayName=vn;var hd=x.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Ve(vn,n);return r.jsx(ya,{as:rr,allowPinchZoom:!0,shards:[s.contentRef],children:r.jsx(st.div,{"data-state":br(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),Ct="DialogContent",Ms=x.forwardRef((e,t)=>{const n=Rs(Ct,e.__scopeDialog),{forceMount:o=n.forceMount,...s}=e,a=Ve(Ct,e.__scopeDialog);return r.jsx(nr,{present:o||a.open,children:a.modal?r.jsx(gd,{...s,ref:t}):r.jsx(xd,{...s,ref:t})})});Ms.displayName=Ct;var gd=x.forwardRef((e,t)=>{const n=Ve(Ct,e.__scopeDialog),o=x.useRef(null),s=ht(t,n.contentRef,o);return x.useEffect(()=>{const a=o.current;if(a)return ba(a)},[]),r.jsx(Ls,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rt(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:rt(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&a.preventDefault()}),onFocusOutside:rt(e.onFocusOutside,a=>a.preventDefault())})}),xd=x.forwardRef((e,t)=>{const n=Ve(Ct,e.__scopeDialog),o=x.useRef(!1),s=x.useRef(!1);return r.jsx(Ls,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var l,i;(l=e.onCloseAutoFocus)==null||l.call(e,a),a.defaultPrevented||(o.current||(i=n.triggerRef.current)==null||i.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 l=a.target;((c=n.triggerRef.current)==null?void 0:c.contains(l))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),Ls=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...l}=e,i=Ve(Ct,n),d=x.useRef(null),c=ht(t,d);return wa(),r.jsxs(r.Fragment,{children:[r.jsx(Ns,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:a,children:r.jsx(ys,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":br(i.open),...l,ref:c,onDismiss:()=>i.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(bd,{titleId:i.titleId}),r.jsx(wd,{contentRef:d,descriptionId:i.descriptionId})]})]})}),vr="DialogTitle",_s=x.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Ve(vr,n);return r.jsx(st.h2,{id:s.titleId,...o,ref:t})});_s.displayName=vr;var Hs="DialogDescription",Os=x.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Ve(Hs,n);return r.jsx(st.p,{id:s.descriptionId,...o,ref:t})});Os.displayName=Hs;var Fs="DialogClose",Ps=x.forwardRef((e,t)=>{const{__scopeDialog:n,...o}=e,s=Ve(Fs,n);return r.jsx(st.button,{type:"button",...o,ref:t,onClick:rt(e.onClick,()=>s.onOpenChange(!1))})});Ps.displayName=Fs;function br(e){return e?"open":"closed"}var zs="DialogTitleWarning",[vd,Bs]=xa(zs,{contentName:Ct,titleName:vr,docsSlug:"dialog"}),bd=({titleId:e})=>{const t=Bs(zs),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
22
+
23
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
24
+
25
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return x.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},yd="DialogDescriptionWarning",wd=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Bs(yd).contentName}}.`;return x.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},Nd=Ss,Id=Es,jd=As,kd=Ds,Cd=Ms,Sd=_s,Td=Os,Ws=Ps,$s="AlertDialog",[Ed]=Do($s,[Cs]),at=Cs(),Vs=e=>{const{__scopeAlertDialog:t,...n}=e,o=at(t);return r.jsx(Nd,{...o,...n,modal:!0})};Vs.displayName=$s;var Rd="AlertDialogTrigger",Ad=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...o}=e,s=at(n);return r.jsx(Id,{...s,...o,ref:t})});Ad.displayName=Rd;var Dd="AlertDialogPortal",Gs=e=>{const{__scopeAlertDialog:t,...n}=e,o=at(t);return r.jsx(jd,{...o,...n})};Gs.displayName=Dd;var Md="AlertDialogOverlay",Us=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...o}=e,s=at(n);return r.jsx(kd,{...s,...o,ref:t})});Us.displayName=Md;var Mt="AlertDialogContent",[Ld,_d]=Ed(Mt),Ks=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:o,...s}=e,a=at(n),l=x.useRef(null),i=ht(t,l),d=x.useRef(null);return r.jsx(vd,{contentName:Mt,titleName:qs,docsSlug:"alert-dialog",children:r.jsx(Ld,{scope:n,cancelRef:d,children:r.jsxs(Cd,{role:"alertdialog",...a,...s,ref:i,onOpenAutoFocus:rt(s.onOpenAutoFocus,c=>{var f;c.preventDefault(),(f=d.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[r.jsx(ii,{children:o}),r.jsx(Od,{contentRef:l})]})})})});Ks.displayName=Mt;var qs="AlertDialogTitle",Xs=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...o}=e,s=at(n);return r.jsx(Sd,{...s,...o,ref:t})});Xs.displayName=qs;var Ys="AlertDialogDescription",Zs=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...o}=e,s=at(n);return r.jsx(Td,{...s,...o,ref:t})});Zs.displayName=Ys;var Hd="AlertDialogAction",Js=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...o}=e,s=at(n);return r.jsx(Ws,{...s,...o,ref:t})});Js.displayName=Hd;var Qs="AlertDialogCancel",ea=x.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...o}=e,{cancelRef:s}=_d(Qs,n),a=at(n),l=ht(t,s);return r.jsx(Ws,{...a,...o,ref:l})});ea.displayName=Qs;var Od=({contentRef:e})=>{const t=`\`${Mt}\` requires a description for the component to be accessible for screen reader users.
26
+
27
+ You can add a description to the \`${Mt}\` by passing a \`${Ys}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
28
+
29
+ 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 \`${Mt}\`. 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.
30
+
31
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return x.useEffect(()=>{var o;document.getElementById((o=e.current)==null?void 0:o.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Fd=Vs,Pd=Gs,zd=Us,Bd=Ks,Wd=Js,$d=ea,Vd=Xs,Gd=Zs;function uo({...e}){return r.jsx(Fd,{"data-slot":"alert-dialog",...e})}function Ud({...e}){return r.jsx(Pd,{"data-slot":"alert-dialog-portal",...e})}function Kd({className:e,...t}){return r.jsx(zd,{"data-slot":"alert-dialog-overlay",className:Pe("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 fo({className:e,onSubmit:t,...n}){return r.jsxs(Ud,{children:[r.jsx(Kd,{}),r.jsx(Bd,{"data-slot":"alert-dialog-content",className:Pe("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)},...n})]})}function mo({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-header",className:Pe("flex flex-col gap-2 text-center sm:text-left",e),...t})}function po({className:e,...t}){return r.jsx("div",{"data-slot":"alert-dialog-footer",className:Pe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function ho({className:e,...t}){return r.jsx(Vd,{"data-slot":"alert-dialog-title",className:Pe("text-lg font-semibold",e),...t})}function go({className:e,...t}){return r.jsx(Gd,{"data-slot":"alert-dialog-description",className:Pe("text-muted-foreground text-sm",e),...t})}function xo({className:e,...t}){return r.jsx(Wd,{className:Pe(Ho(),e),...t})}function vo({className:e,...t}){return r.jsx($d,{className:Pe(Ho({variant:"outline"}),e),...t})}function qd({...e}){return r.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function Xd({className:e,...t}){return r.jsx("ol",{"data-slot":"breadcrumb-list",className:Pe("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...t})}function bo({className:e,...t}){return r.jsx("li",{"data-slot":"breadcrumb-item",className:Pe("inline-flex items-center gap-1.5",e),...t})}function Yd({asChild:e,className:t,...n}){const o=e?rr:"a";return r.jsx(o,{"data-slot":"breadcrumb-link",className:Pe("hover:text-foreground transition-colors",t),...n})}function Zd({className:e,...t}){return r.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:Pe("text-foreground font-normal",e),...t})}function Jd({children:e,className:t,...n}){return r.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:Pe("[&>svg]:size-3.5",t),...n,children:e??r.jsx(So,{})})}const Et={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function bn(e){return e.replace(/\/\/\.\.\//g,"//")}function Qd(e,t,n,o){let s;switch(e.status){case"completed":s="completed";break;case"failed":s=n<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 yn(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function eu(e){const t=new Map,n=new Map,o=new Map,s=[],a=new Map;for(const l of e){if(l.data.stepId){const i=bn(l.data.stepId),d=t.get(i)||[];d.push(l),t.set(i,d);const c=yn(i);if(c){const f=n.get(c)||[];f.push(l),n.set(c,f)}}if(l.data.nodeKind==="primitive"){const i=l.data.label,d=o.get(i)||[];d.push(l),o.set(i,d)}if(l.data.nodeKind==="agent"&&s.push(l),l.data.nodeKind==="tool"){const d=l.data.label.replace(/ \(tool\)$/,""),c=a.get(d)||[];if(c.push(l),a.set(d,c),l.data.stepId){const f=yn(bn(l.data.stepId));if(f){const u=a.get(f)||[];u.includes(l)||(u.push(l),a.set(f,u))}}}}return{byStepId:t,byFunctionName:n,primitivesByLabel:o,agentNodes:s,toolNodes:a}}function tu(e,t,n){var d,c,f,u;const o=new Map,s=new Set(e),a=new Map;for(const p of t.nodes){const m=(d=p.metadata)==null?void 0:d.parallelGroupId;if(m){const C=a.get(m)||{nodes:[]};C.nodes.push(p),C.method=(c=p.metadata)==null?void 0:c.parallelMethod,a.set(m,C)}}const l=new Map;for(const[p,m]of a)if(m.method==="race"){let C,v;for(const k of m.nodes){const g=n.get(k.id);if(g){for(const h of g)if(h.status==="completed"&&h.completedAt){const N=new Date(h.completedAt);(!v||N<v)&&(v=N,C=k.id)}}}C&&l.set(p,C)}const i=p=>{const m=o.get(p.id);m?m.traversalCount++:o.set(p.id,{edgeId:p.id,traversalCount:1,timings:[]})};for(const p of t.edges){const m=t.nodes.find(N=>N.id===p.source),C=t.nodes.find(N=>N.id===p.target);if(!m||!C)continue;const v=s.has(p.source),k=s.has(p.target);if(!v&&!k)continue;if(p.type==="conditional"){v&&k&&i(p);continue}const g=(f=m.metadata)==null?void 0:f.parallelGroupId,h=(u=m.metadata)==null?void 0:u.parallelMethod;g&&h==="race"?l.get(g)===p.source&&k&&i(p):(v&&k||v&&p.type==="parallel"&&k)&&i(p)}return o}function nu(e,t,n,o){const s=t.nodes.find(a=>a.data.nodeKind==="workflow_start");s&&(n.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 ru(e,t,n,o){const s=t.nodes.find(l=>l.data.nodeKind==="workflow_end");if(!s||n.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}n.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 ou(e,t,n,o,s,a,l){const i=bn(t),d=s.get(i)||0;s.set(i,d+1);let c=n.get(i)||[],f="step-id";if(c.length===0){const C=yn(i);C&&(c=o.get(C)||[],f="function-name")}const u=c.length===1?c[0]:c[d];if(console.log("[Graph Mapper] Processing step group:",{stepName:t,normalizedStepName:i,attempts:e.length,occurrenceIndex:d,totalNodesWithStepId:c.length,selectedNode:u==null?void 0:u.id,allNodesWithStepId:c.map(C=>C.id),matchStrategy:f,strategy:c.length===1?"single-node-multiple-invocations":"occurrence-based"}),!u)return;const p=e.map((C,v)=>Qd(C,u.id,v,e.length));if(c.length===1){const C=a.get(u.id)||[];a.set(u.id,[...C,...p])}else a.set(u.id,p);return l.includes(u.id)||l.push(u.id),p[p.length-1].status==="running"?u.id:void 0}function su(e,t,n,o){const s=new Map,a=new Map;for(const g of e){if(!g.correlationId)continue;const h=a.get(g.correlationId)||[];h.push(g),a.set(g.correlationId,h)}let l;const i=t.get(Et.sleep)||[],d=new Set;for(const g of e)g.eventType==="wait_created"&&g.correlationId&&d.add(g.correlationId);const c=Array.from(d).sort((g,h)=>{var w,y;const N=a.get(g)||[],I=a.get(h)||[],j=(w=N.find(S=>S.eventType==="wait_created"))==null?void 0:w.createdAt,b=(y=I.find(S=>S.eventType==="wait_created"))==null?void 0:y.createdAt;return!j||!b?0:new Date(j).getTime()-new Date(b).getTime()});for(const g of c){const h=a.get(g)||[],N=h.find(E=>E.eventType==="wait_created"),I=h.find(E=>E.eventType==="wait_completed");if(!N)continue;const j=s.get(Et.sleep)||0;s.set(Et.sleep,j+1);const b=i.length===1?i[0]:i[j];if(!b)continue;let w="running";I&&(w="completed");const y=new Date(N.createdAt).toISOString(),S=I?new Date(I.createdAt).toISOString():void 0,A=I?new Date(I.createdAt).getTime()-new Date(N.createdAt).getTime():void 0,L={nodeId:b.id,attemptNumber:1,status:w,startedAt:y,completedAt:S,duration:A},D=n.get(b.id)||[];n.set(b.id,[...D,L]),o.includes(b.id)||o.push(b.id),w==="running"&&(l=b.id)}const f=[...t.get(Et.createHook)||[],...t.get(Et.createWebhook)||[]],u=new Set;for(const g of e)g.eventType==="hook_created"&&g.correlationId&&u.add(g.correlationId);const p=Array.from(u).sort((g,h)=>{var w,y;const N=a.get(g)||[],I=a.get(h)||[],j=(w=N.find(S=>S.eventType==="hook_created"))==null?void 0:w.createdAt,b=(y=I.find(S=>S.eventType==="hook_created"))==null?void 0:y.createdAt;return!j||!b?0:new Date(j).getTime()-new Date(b).getTime()});let m=0;for(const g of p){const N=(a.get(g)||[]).find(A=>A.eventType==="hook_created");if(!N)continue;const I=f.length===1?f[0]:f[m];if(m++,!I)continue;const j="completed",b=new Date(N.createdAt).toISOString(),w=new Date(N.createdAt).toISOString(),y={nodeId:I.id,attemptNumber:1,status:j,startedAt:b,completedAt:w,duration:0},S=n.get(I.id)||[];n.set(I.id,[...S,y]),o.includes(I.id)||o.push(I.id)}const C=t.get(Et.awaitWebhook)||[],v=new Set;for(const g of e)g.eventType==="hook_received"&&g.correlationId&&v.add(g.correlationId);let k=0;for(const g of p){const h=C.length===1?C[0]:C[k];if(k++,!h)continue;const N=a.get(g)||[],I=N.find(D=>D.eventType==="hook_created"),j=N.find(D=>D.eventType==="hook_received");let b,w,y,S=0;j?(b="completed",w=I?new Date(I.createdAt).toISOString():new Date(j.createdAt).toISOString(),y=new Date(j.createdAt).toISOString(),S=new Date(y).getTime()-new Date(w).getTime()):I?(b="running",w=new Date(I.createdAt).toISOString()):b="pending";const A={nodeId:h.id,attemptNumber:1,status:b,startedAt:w,completedAt:y,duration:S},L=n.get(h.id)||[];n.set(h.id,[...L,A]),o.includes(h.id)||o.push(h.id)}return l}function au(e,t,n,o,s,a,l){var d;let i="pending";e.status==="completed"?i="completed":e.status==="failed"?i="failed":e.status==="running"&&(i="running");for(const c of n){const f={nodeId:c.id,attemptNumber:1,status:i,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(i==="completed"||i==="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=yn(c.stepName);if(!f)continue;const u=o.get(f);if(!u||u.length===0)continue;const p=u[0];let m;switch(c.status){case"completed":m="completed";break;case"failed":m="failed";break;case"running":m="running";break;case"cancelled":m="cancelled";break;case"pending":default:m="pending";break}const C=c.completedAt&&c.startedAt?new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime():void 0,v={nodeId:p.id,stepId:c.stepId,attemptNumber:c.attempt,status:m,startedAt:c.startedAt?new Date(c.startedAt).toISOString():void 0,completedAt:c.completedAt?new Date(c.completedAt).toISOString():void 0,duration:C,input:c.input,output:c.output,error:c.error},k=s.get(p.id)||[];s.set(p.id,[...k,v]),a.includes(p.id)||a.push(p.id)}for(const c of l){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:i,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(i==="completed"||i==="failed")?new Date(e.completedAt).toISOString():void 0};s.set(c.id,[u]),a.includes(c.id)||a.push(c.id)}}}function iu(e,t,n,o){var l,i,d;const s=e.nodes.filter(c=>c.data.nodeKind==="conditional"),a=new Map;for(const c of e.nodes){const f=(l=c.metadata)==null?void 0:l.conditionalId;if(f){const u=a.get(f)||{thenNodes:[],elseNodes:[]};((i=c.metadata)==null?void 0:i.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],p=a.get(u);if(!p)continue;const m=p.thenNodes.some(v=>t.has(v.id)),C=p.elseNodes.some(v=>t.has(v.id));if(m||C){const v=[...p.thenNodes,...p.elseNodes];if(!t.has(c.id)){let k;for(const N of v){const I=t.get(N.id);if(I&&I.length>0){const j=I[0];j.startedAt&&(!k||j.startedAt<k)&&(k=j.startedAt)}}const g=o.startedAt?new Date(o.startedAt).toISOString():void 0,h={nodeId:c.id,attemptNumber:1,status:"completed",startedAt:k||g,completedAt:k||g};t.set(c.id,[h])}if(!n.includes(c.id)){const k=v.map(g=>n.indexOf(g.id)).filter(g=>g>=0);if(k.length>0){const g=Math.min(...k);g>=0&&g<n.length?n.splice(g,0,c.id):n.push(c.id)}else n.push(c.id)}}}}function lu(e,t,n,o){const s=new Map,a=[];let l;console.log("[Graph Mapper] Mapping run to execution:",{runId:e.runId,workflowName:e.workflowName,graphNodes:o.nodes.length,stepsCount:t.length}),nu(e,o,a,s);const i=[...t].sort((I,j)=>new Date(I.createdAt).getTime()-new Date(j.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",i.map(I=>({stepId:I.stepId,stepName:I.stepName,attempt:I.attempt,status:I.status,createdAt:I.createdAt})));const{byStepId:d,byFunctionName:c,primitivesByLabel:f,agentNodes:u,toolNodes:p}=eu(o.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:o.nodes.map(I=>({id:I.id,stepId:I.data.stepId,normalizedStepId:I.data.stepId?bn(I.data.stepId):void 0,nodeKind:I.data.nodeKind})),nodesByStepId:Array.from(d.entries()).map(([I,j])=>({stepId:I,nodeIds:j.map(b=>b.id)}))});const m=new Map;let C=[],v=null,k=null;for(let I=0;I<=i.length;I++){const j=i[I];if(!j||j.stepId!==v){if(C.length>0&&k){const w=ou(C,k,d,c,m,s,a);w&&(l=w)}j&&(C=[j],v=j.stepId,k=j.stepName)}else C.push(j)}const g=su(n,f,s,a);g&&(l=g),au(e,i,u,p,s,a,o.nodes),iu(o,s,a,e),ru(e,o,a,s);const h=tu(a,o,s),N={runId:e.runId,status:e.status,nodeExecutions:s,edgeTraversals:h,currentNode:l,executionPath:a};return console.log("[Graph Mapper] Mapping complete:",{executionPath:a,nodeExecutionsCount:s.size,nodeExecutions:Array.from(s.entries()).map(([I,j])=>{var b;return{nodeId:I,executionCount:j.length,latestStatus:(b=j[j.length-1])==null?void 0:b.status}})}),N}function cu(e,t){const[n,o]=x.useState([]),[s,a]=x.useState(!1),[l,i]=x.useState(null),d=x.useRef(null),c=x.useRef(0);return x.useEffect(()=>{if(o([]),i(null),c.current=0,!t){a(!1);return}let f=!0;const u=new AbortController;d.current=u,a(!0);const p=Ia(),m=()=>{f&&a(!1)},C=h=>{f&&(i(h instanceof Error?h.message:String(h)),a(!1))},v=h=>{if(f&&h!==void 0&&h!==null){const N=c.current++;let I;try{I=ci(h,p)}catch{I=h}const j=typeof I=="string"?I:JSON.stringify(I,null,2);o(b=>[...b,{id:N,text:j}])}},k=async h=>{var j;let N=new Uint8Array(0);const I=b=>{const w=new Uint8Array(N.length+b.length);w.set(N,0),w.set(b,N.length),N=w};for(;!((j=d.current)!=null&&j.signal.aborted);){const{value:b,done:w}=await h.read();if(w){m();break}for(I(b);N.length>=4;){const S=new DataView(N.buffer,N.byteOffset,N.byteLength).getUint32(0,!1);if(N.length<4+S)break;const A=N.slice(4,4+S);N=N.slice(4+S);try{const L=li(A);v(L)}catch(L){console.error("Failed to decode stream chunk:",L)}}}};return(async()=>{try{const N=(await Na(e,t,void 0,u.signal)).getReader();await k(N)}catch(h){if(u.signal.aborted)return;C(h)}})(),()=>{f=!1,d.current&&d.current.abort()}},[e,t]),{chunks:n,isLive:s,error:l}}function du({hasError:e,errorMessage:t}){return r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs(Oo,{children:[r.jsx(Fo,{asChild:!0,children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${e?"bg-red-500":"bg-green-500 animate-pulse"}`}),r.jsx("span",{className:`text-xs $
32
+ hasError
33
+ ? 'text-red-600 dark:text-red-400'
34
+ : 'text-muted-foreground'`,children:e?"Error":"Live"})]})}),r.jsx(Po,{children:r.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${di/1e3} seconds`})})]})})}function yo(e){return e==="retrying"?"running":e}function uu({data:e,selected:t}){var o,s,a,l;const n=e;return r.jsxs("div",{className:`relative ${n.className||""}`,style:{borderWidth:((o=n.nodeStyle)==null?void 0:o.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(s=n.nodeStyle)==null?void 0:s.backgroundColor,borderColor:((a=n.nodeStyle)==null?void 0:a.borderColor)??"#9ca3af",opacity:(l=n.nodeStyle)==null?void 0:l.opacity,boxShadow:t?"0 0 0 2px rgba(168, 85, 247, 0.5)":void 0},children:[n.label,r.jsx(Ye,{type:"target",position:Ze.Top,className:"!bg-purple-500"}),r.jsx(Ye,{type:"source",position:Ze.Bottom,className:"!bg-purple-500"}),r.jsx(Ye,{type:"source",position:Ze.Left,id:"loop-out",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"30%"}}),r.jsx(Ye,{type:"target",position:Ze.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})}function fu({data:e,selected:t}){var a,l,i,d;const n=e,o=n.nodeKind==="workflow_start",s=n.nodeKind==="workflow_end";return r.jsxs("div",{className:`relative ${n.className||""}`,style:{borderWidth:((a=n.nodeStyle)==null?void 0:a.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(l=n.nodeStyle)==null?void 0:l.backgroundColor,borderColor:((i=n.nodeStyle)==null?void 0:i.borderColor)??"#9ca3af",opacity:(d=n.nodeStyle)==null?void 0:d.opacity,boxShadow:t?"0 0 0 2px rgba(59, 130, 246, 0.35)":void 0},children:[n.label,!o&&r.jsx(Ye,{type:"target",position:Ze.Top,className:"!bg-muted"}),!s&&r.jsx(Ye,{type:"source",position:Ze.Bottom,className:"!bg-muted"})]})}function mu({data:e,selected:t}){var s,a,l;const n=e,o=160;return r.jsxs("div",{className:`relative flex items-center justify-center ${n.className||""}`,style:{width:o,height:o},children:[r.jsx("div",{style:{width:o*.7,height:o*.7,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:(s=n.nodeStyle)==null?void 0:s.backgroundColor,borderColor:((a=n.nodeStyle)==null?void 0:a.borderColor)??"#ef4444",opacity:(l=n.nodeStyle)==null?void 0:l.opacity,boxShadow:t?"0 0 0 2px rgba(239, 68, 68, 0.5)":void 0}}),r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{fontSize:11,fontWeight:600,padding:o*.25},title:typeof n.label=="string"?n.label:void 0,children:r.jsx("span",{className:"text-center line-clamp-3 overflow-hidden",children:n.label})}),r.jsx(Ye,{type:"target",position:Ze.Top,className:"!bg-red-500"}),r.jsx(Ye,{type:"source",position:Ze.Bottom,id:"bottom",className:"!bg-red-500"}),r.jsx(Ye,{type:"source",position:Ze.Left,id:"left",className:"!bg-red-500"}),r.jsx(Ye,{type:"source",position:Ze.Right,id:"right",className:"!bg-red-500"})]})}const pu={loopNode:uu,parallelGroup:Ta,executionNode:fu,diamondNode:mu},hu=Sa(_a);function gu(e,t){const n=Ma(e);if(!t||t.length===0)return{color:"hsl(var(--card-foreground))",backgroundColor:n,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:n,borderColor:s,borderWidth:a}}function wo(e,t,n){const o=r.jsxs("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[r.jsx("div",{className:"flex-shrink-0",children:La(e.nodeKind,e.label)}),r.jsx("span",{className:"text-sm font-medium break-words whitespace-normal leading-tight flex-1 min-w-0",children:e.label})]});if(!n||n.length===0)return o;const s=n[n.length-1],a=n.length,l=a>1;return l||s.duration&&s.duration>0?r.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[o,r.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[l&&r.jsxs(un,{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&&r.jsxs(un,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",jt(s.duration,!0)]})]})]}):o}const ta={...Aa};function No(e,t){var d,c,f;const{nodes:n,groupNodes:o}=Mo(e,ta),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 n){const p=(d=u.metadata)!=null&&d.parallelGroupId?`group_${u.metadata.parallelGroupId}`:null;p&&a.has(p)&&s.set(u.id,p)}const l=[],i=o.filter(u=>u.id.startsWith("group_"));for(const u of i)l.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 n){const p=t==null?void 0:t.nodeExecutions.get(u.id),m=gu(u.data.nodeKind,p),C=(t==null?void 0:t.currentNode)===u.id,v=!!((c=u.metadata)!=null&&c.loopId),k=!!((f=u.metadata)!=null&&f.loopIsAwait),g=u.data.nodeKind==="conditional",h=g?"diamondNode":v?"loopNode":"executionNode",N=s.get(u.id);let I=u.position;if(N){const b=a.get(N);b&&(I={x:u.position.x-b.x,y:u.position.y-b.y})}const j=C?"animate-pulse-subtle":"";v?l.push({id:u.id,type:h,position:I,parentId:N,extent:N?"parent":void 0,expandParent:!0,data:{...u.data,label:wo(u.data,u.metadata,p),executions:p,isLoopNode:!0,isAwaitLoop:k,nodeStyle:m,className:j}}):g?l.push({id:u.id,type:h,position:I,parentId:N,extent:N?"parent":void 0,expandParent:!0,data:{...u.data,label:u.data.label,executions:p,nodeStyle:m,className:j}}):l.push({id:u.id,type:h,position:I,parentId:N,extent:N?"parent":void 0,expandParent:!0,data:{...u.data,label:wo(u.data,u.metadata,p),executions:p,nodeStyle:m,className:j},style:{width:220}})}return l}function Io(e,t){const{additionalEdges:n}=Mo(e,ta),s=[...e.edges.map(l=>l.type==="loop"?{...l,id:`loop_back_${l.source}_${l.target}`,isOriginal:!0}:{...l,isOriginal:!0}),...n.map(l=>({...l,isOriginal:!1}))];return Da(s,e.nodes).map(l=>{if(l.type==="selfLoop")return{id:l.id,source:l.source,target:l.target,sourceHandle:l.sourceHandle,targetHandle:l.targetHandle,type:"selfLoop",label:l.label,markerEnd:{type:jr.ArrowClosed,width:12,height:12,color:"#a855f7"}};let i=t==null?void 0:t.edgeTraversals.get(l.id);if(!i&&l.isConsolidated&&l.originalEdgeIds)for(const w of l.originalEdgeIds){const y=t==null?void 0:t.edgeTraversals.get(w);if(y&&y.traversalCount>0){i=y;break}}const d=i&&i.traversalCount>0,c=!!t,f=i!=null&&i.timings.length?i.timings.reduce((w,y)=>w+y,0)/i.timings.length:void 0;let u="bezier",p,m=l.label,C=!1;switch(l.type){case"parallel":u="smoothstep",p="4,4",m=void 0;break;case"loop":u="step",p="8,4";break;case"conditional":u="smoothstep",p="8,4",C=!0;break;default:u="bezier"}const k=d?"#22c55e":"#6b7280",g=d?void 0:p,h=c&&!d?.35:1,N=d?2.5:1,I=C?"#ffffff":"#6b7280",j=C?"#374151":"#f3f4f6",b=C?"#4b5563":"#d1d5db";return{id:l.id,source:l.source,target:l.target,type:u,animated:d&&(t==null?void 0:t.status)==="running",label:i&&i.traversalCount>1?r.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[r.jsxs(un,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[i.traversalCount,"×"]}),f&&f>0&&r.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["~",jt(f,!0)]})]}):m,labelStyle:{fill:I,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:j,fillOpacity:.95,stroke:b,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:jr.ArrowClosed,width:d?14:10,height:d?14:10,color:k},style:{strokeWidth:N,stroke:k,opacity:h,strokeDasharray:g}}})}function xu({selectedNode:e,env:t,onClose:n}){const{node:o,executions:s,stepId:a,runId:l}=e,i=s[s.length-1],d=s.length>1,{data:c,loading:f}=Lo(t??{},"step",a??"",{runId:l}),u=(c==null?void 0:c.input)??(i==null?void 0:i.input),p=(c==null?void 0:c.output)??(i==null?void 0:i.output),m=(c==null?void 0:c.error)??(i==null?void 0:i.error);return r.jsxs("div",{className:"h-full flex flex-col bg-background border-l",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b flex-none",children:[r.jsx("span",{className:"text-xs font-medium truncate flex-1",title:o.data.label,children:o.data.label}),r.jsxs("div",{className:"flex items-center gap-2 flex-none",children:[(i==null?void 0:i.duration)!==void 0&&i.duration>0&&r.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:jt(i.duration)}),r.jsx("div",{className:"w-px h-4 bg-border"}),r.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-muted transition-colors","aria-label":"Close panel",children:r.jsx(Ao,{className:"h-4 w-4 text-muted-foreground"})})]})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:[r.jsxs("div",{className:"flex flex-col divide-y rounded-lg border overflow-hidden mb-3",children:[r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"type"}),r.jsx("span",{className:"text-[11px] font-mono",children:o.data.nodeKind})]}),i&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"status"}),r.jsx(Wn,{status:yo(i.status)})]}),i.duration!==void 0&&i.duration>0&&r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"duration"}),r.jsx("span",{className:"text-[11px] font-mono",children:jt(i.duration)})]}),d&&r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"attempts"}),r.jsx("span",{className:"text-[11px] font-mono",children:s.length})]}),i.startedAt&&r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"startedAt"}),r.jsx("span",{className:"text-[11px] font-mono",children:new Date(i.startedAt).toLocaleString()})]}),i.completedAt&&r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"completedAt"}),r.jsx("span",{className:"text-[11px] font-mono",children:new Date(i.completedAt).toLocaleString()})]})]})]}),f&&a&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[r.jsx(mn,{className:"h-3 w-3 animate-spin"}),r.jsx("span",{children:"Loading step data..."})]}),u!==void 0&&r.jsxs("details",{className:"group mb-3",children:[r.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[r.jsx("span",{className:"font-medium",children:"Input"}),r.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Array.isArray(u)?u.length:1," args)"]})]}),r.jsxs("div",{className:"relative pl-6 mt-3",children:[r.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),r.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),r.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:r.jsx("code",{children:JSON.stringify(u,null,2)})})]})]}),p!==void 0&&r.jsxs("details",{className:"group mb-3",children:[r.jsx("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:r.jsx("span",{className:"font-medium",children:"Output"})}),r.jsxs("div",{className:"relative pl-6 mt-3",children:[r.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),r.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),r.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:r.jsx("code",{children:JSON.stringify(p,null,2)})})]})]}),m&&r.jsxs("details",{className:"group mb-3",open:!0,children:[r.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:r.jsx("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error"})}),r.jsxs("div",{className:"relative pl-6 mt-3",children:[r.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-red-300"}),r.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-red-300"}),r.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:r.jsx("code",{children:typeof m=="object"?JSON.stringify(m,null,2):String(m)})})]})]}),d&&r.jsxs("details",{className:"group",children:[r.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[r.jsx("span",{className:"font-medium",children:"Attempt History"}),r.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",s.length," attempts)"]})]}),r.jsxs("div",{className:"relative pl-6 mt-3",children:[r.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),r.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),r.jsx("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",children:s.map(C=>r.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-[11px]",children:[r.jsxs("span",{className:"text-muted-foreground",children:["Attempt ",C.attemptNumber]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Wn,{status:yo(C.status)}),C.duration!==void 0&&C.duration>0&&r.jsx("span",{className:"font-mono text-muted-foreground",children:jt(C.duration)})]})]},C.attemptNumber))})]})]})]})]})}function vu({workflow:e,execution:t,env:n,onNodeClick:o}){const[s,a]=x.useState(null),l=320,i=x.useMemo(()=>No(e,t),[e,t]),d=x.useMemo(()=>Io(e,t),[e,t]),[c,f,u]=ja(i),[p,m,C]=ka(d);x.useEffect(()=>{f(g=>{const h=No(e,t),N=new Map(g.map(I=>[I.id,I.position]));return h.map(I=>({...I,position:N.get(I.id)??I.position}))}),m(Io(e,t))},[e,t,f,m]);const v=x.useCallback((g,h)=>{const N=e.nodes.find(I=>I.id===h.id);if(N){const I=h.data.executions||[],j=I[I.length-1];a({nodeId:h.id,node:N,executions:I,stepId:j==null?void 0:j.stepId,runId:t==null?void 0:t.runId}),o&&I.length>0&&o(h.id,I)}},[e.nodes,t==null?void 0:t.runId,o]),k=x.useCallback(()=>{a(null)},[]);return r.jsxs("div",{className:"h-full w-full border rounded-lg bg-background relative overflow-hidden flex",children:[r.jsx("div",{className:"h-full flex-1 min-w-0",style:{width:s?`calc(100% - ${l}px)`:"100%"},children:r.jsxs(Ca,{nodes:c,edges:p,onNodesChange:u,onEdgesChange:C,onNodeClick:v,nodeTypes:pu,edgeTypes:hu,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[r.jsx(Ea,{}),r.jsx(Ra,{}),r.jsx(Ir,{position:"top-left",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-2 text-xs",children:r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"font-semibold text-[10px] text-muted-foreground mb-1",children:"Status"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-4 rounded border-2 border-green-500 bg-background"}),r.jsx("span",{children:"Completed"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-4 rounded border-2 border-red-500 bg-background"}),r.jsx("span",{children:"Failed"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-4 rounded border-2 border-blue-500 bg-background"}),r.jsx("span",{children:"Running"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-4 rounded border-2 border-yellow-500 bg-background"}),r.jsx("span",{children:"Cancelled"})]}),r.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[r.jsx("div",{className:"w-6 h-4 rounded border-2 border-gray-400 bg-background"}),r.jsx("span",{children:"Pending"})]})]})}),t&&r.jsxs(Ir,{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:[r.jsx("div",{className:"font-semibold text-sm",children:"Execution"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Status:"}),r.jsx(un,{variant:t.status==="completed"?"default":t.status==="failed"?"destructive":t.status==="cancelled"?"outline":"secondary",className:"text-xs",children:t.status})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Progress:"}),r.jsxs("span",{className:"font-mono",children:[t.executionPath.length," / ",e.nodes.length]})]})]})]})}),s&&r.jsx("div",{className:"h-full flex-none",style:{width:l},children:r.jsx(xu,{selectedNode:s,env:n,onClose:k})})]})}function bu({run:e,allSteps:t,allEvents:n,env:o}){const{manifest:s,loading:a,error:l}=Ka(),i=x.useMemo(()=>{var m;if(!s||!e.workflowName)return null;const c=String(e.workflowName).trim(),f=s.workflows[c];if(f)return f;const u=(m=kt(c))==null?void 0:m.shortName;return Object.values(s.workflows).find(C=>{var v;return C.workflowId===c||C.workflowName===c?!0:u?((v=kt(C.workflowName))==null?void 0:v.shortName)===u:!1})??null},[s,e.workflowName]),d=x.useMemo(()=>!i||!e.runId?null:lu(e,t||[],n||[],i),[i,e,t,n]);return a?r.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[r.jsx(mn,{className:"h-8 w-8 animate-spin text-muted-foreground"}),r.jsx("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):l?r.jsx("div",{className:"flex items-center justify-center w-full h-full p-4",children:r.jsxs($n,{variant:"destructive",className:"max-w-lg",children:[r.jsx(Vn,{className:"h-4 w-4"}),r.jsx(Gn,{children:"Error Loading Workflow Graph"}),r.jsx(Un,{children:l.message})]})}):i?r.jsx(vu,{workflow:i,execution:d||void 0,env:o}):r.jsx("div",{className:"flex items-center justify-center w-full h-full",children:r.jsxs($n,{className:"max-w-lg",children:[r.jsx(Vn,{className:"h-4 w-4"}),r.jsx(Gn,{children:"Workflow Graph Not Found"}),r.jsx(Un,{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 yu=new Set(["run_created","run_started","run_completed","run_failed","run_cancelled"]);function wu({runId:e,selectedId:t}){var Ce;const n=na(),[o]=Co(),{serverConfig:s}=ui(),[a,l]=x.useState(!1),[i,d]=x.useState(!1),[c,f]=x.useState(!1),[u,p]=x.useState(!1),m=x.useMemo(()=>({}),[]),C=o.get("tab")||"trace",v=o.get("streamId"),k=x.useCallback(W=>{const de=new URLSearchParams(o.toString());for(const[ye,Se]of Object.entries(W))Se===null?de.delete(ye):de.set(ye,Se);n(`?${de.toString()}`,{preventScrollReset:!0})},[n,o]),g=x.useCallback(W=>{k(W==="trace"||W==="graph"?{tab:W,streamId:null}:{tab:W})},[k]),h=x.useCallback(W=>{k({streamId:W})},[k]),N=x.useCallback(W=>{k({tab:"streams",streamId:W})},[k]),I=x.useCallback(async(W,de)=>Ha(m,W,{correlationIds:[de]}),[m]),j=x.useCallback(async(W,de)=>{await Oa(m,W,de)},[m]),b=x.useCallback(async W=>{if(!yu.has(W.eventType)&&W.correlationId){const{error:we,result:Le}=await Zt(kr(m,W.correlationId,{sortOrder:"asc",limit:100,withData:!0}));if(we)throw we;const Ue=Le.data.find(nt=>nt.eventId===W.eventId),tt=Ue?En(Ue):null;return tt&&"eventData"in tt?tt.eventData:null}const{error:ye,result:Se}=await Zt(Cr(m,W.runId,{sortOrder:"desc",limit:1e3,withData:!0}));if(ye)throw ye;let Te=Se.data.find(we=>we.eventId===W.eventId);if(!Te){const{error:we,result:Le}=await Zt(Cr(m,W.runId,{sortOrder:"asc",limit:1e3,withData:!0}));if(we)throw we;Te=Le.data.find(Ue=>Ue.eventId===W.eventId)}const je=Te?En(Te):null;return je&&"eventData"in je?je.eventData:null},[m]),w=x.useCallback(async(W,de)=>{const{error:ye,result:Se}=await Zt(kr(m,W,{sortOrder:"asc",limit:100,withData:!0}));if(ye)throw ye;const Te=Se.data.find(we=>we.eventId===de),je=Te?En(Te):null;return je&&"eventData"in je?je.eventData:null},[m]),y=s.backendId==="local"||s.backendId==="@workflow/world-local",{run:S,steps:A,hooks:L,events:D,loading:E,auxiliaryDataLoading:T,error:H,update:P}=Fa(m,e,{live:!0}),F=S??{},[_,B]=x.useState(null),{data:V,loading:G,error:oe}=Lo(m,(_==null?void 0:_.resource)??"run",(_==null?void 0:_.resourceId)??"",{runId:_==null?void 0:_.runId,enabled:!!(_!=null&&_.resource&&(_!=null&&_.resourceId)&&_.resource!=="hook")}),ve=x.useCallback(W=>{B(W)},[]),{streams:be,loading:J,error:Q}=Pa(m,e),{chunks:ie,isLive:R,error:K}=cu(m,v),re=()=>{f(!0)},ce=async()=>{if(!a)try{l(!0),f(!1),await Ga(m,e),await P(),pe.success("Run cancelled successfully")}catch(W){console.error("Failed to cancel run:",W),pe.error("Failed to cancel run",{description:W instanceof Error?W.message:"An unknown error occurred"})}finally{l(!1)}},fe=()=>{p(!0)},te=async()=>{if(!i)try{d(!0),p(!1);const W=await Ua(m,F.runId);pe.success("New run started successfully",{description:`Run ID: ${W}`}),n(`/run/${W}`)}catch(W){console.error("Failed to re-run workflow:",W),pe.error("Failed to start new run",{description:W instanceof Error?W.message:"An unknown error occurred"})}finally{d(!1),p(!1)}};if(H&&!S)return r.jsxs($n,{variant:"destructive",className:"m-4",children:[r.jsx(Vn,{className:"h-4 w-4"}),r.jsx(Gn,{children:"Error loading workflow run"}),r.jsx(Un,{children:H.message})]});const me=(Ce=kt(F.workflowName))==null?void 0:Ce.shortName;return r.jsxs(r.Fragment,{children:[r.jsx(uo,{open:c,onOpenChange:f,children:r.jsxs(fo,{children:[r.jsxs(mo,{children:[r.jsx(ho,{children:"Cancel Workflow Run?"}),r.jsx(go,{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?"})]}),r.jsxs(po,{children:[r.jsx(vo,{children:"Keep Running"}),r.jsx(xo,{onClick:ce,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),r.jsx(uo,{open:u,onOpenChange:p,children:r.jsxs(fo,{children:[r.jsxs(mo,{children:[r.jsx(ho,{children:"Replay Run?"}),r.jsx(go,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),r.jsxs(po,{children:[r.jsx(vo,{children:"Cancel"}),r.jsx(xo,{onClick:te,children:"Replay Run"})]})]})}),r.jsxs("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[r.jsxs("div",{className:"flex-none space-y-4",children:[r.jsx(qd,{children:r.jsxs(Xd,{children:[r.jsx(bo,{children:r.jsx(Yd,{asChild:!0,children:r.jsx(ra,{to:"/",children:"Runs"})})}),r.jsx(Jd,{}),r.jsx(bo,{children:r.jsx(Zd,{className:"font-mono text-xs",children:e})})]})}),r.jsxs("div",{className:"space-y-4 p-6 border rounded-lg",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsx("div",{className:"mb-4",children:r.jsx("h1",{className:"text-xl font-semibold",children:me||r.jsx(Nt,{className:"w-[260px] h-[28px]"})})}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx(du,{hasError:!1,errorMessage:""}),r.jsx(za,{env:m,runId:e,runStatus:F.status,events:D,eventsLoading:T,loading:E,onRerunClick:fe,onCancelClick:re,callbacks:{onSuccess:P}})]})]}),r.jsxs("div",{className:"flex items-start gap-8",children:[r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:"Status"}),F.status?r.jsx(Wn,{status:F.status,context:F}):r.jsx(Nt,{className:"w-[55px] h-[24px]"})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:"Duration"}),r.jsx("div",{className:"text-xs",children:F.runId?F.startedAt?(()=>{const W=(F.completedAt?new Date(F.completedAt).getTime():Date.now())-new Date(F.startedAt).getTime(),de=Math.floor(W/1e3);if(de<60)return`${de}s`;const ye=Math.floor(de/60),Se=de%60;if(ye<60)return Se>0?`${ye}m ${Se}s`:`${ye}m`;const Te=Math.floor(ye/60),je=ye%60;return je>0?`${Te}h ${je}m`:`${Te}h`})():"-":r.jsx(Nt,{className:"w-[60px] h-[20px]"})})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),F.runId?r.jsx(Ba,{text:F.runId,children:r.jsx("div",{className:"text-xs mt-0.5 font-mono",children:F.runId})}):r.jsx(Nt,{className:"w-[280px] h-[20px]"})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:"Queued"}),F.createdAt?r.jsx("div",{className:"text-xs",children:r.jsx(Jt,{date:F.createdAt})}):r.jsx(Nt,{className:"w-[110px] h-[20px]"})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:"Started"}),r.jsx("div",{className:"text-xs",children:F.runId?F.startedAt?r.jsx(Jt,{date:F.startedAt}):"-":r.jsx(Nt,{className:"w-[110px] h-[20px]"})})]}),r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:"Completed"}),r.jsx("div",{className:"text-xs",children:F.runId?F.completedAt?r.jsx(Jt,{date:F.completedAt}):"-":r.jsx(Nt,{className:"w-[110px] h-[20px]"})})]}),F.expiredAt!=null&&r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(Oo,{children:[r.jsx(Fo,{asChild:!0,children:r.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",r.jsx(mi,{className:"w-3 h-3"})]})}),r.jsx(Po,{children:r.jsx("p",{children:"The storage data for this run has expired and is no longer available."})})]}),r.jsx("div",{className:"text-xs",children:r.jsx(Jt,{date:F.expiredAt})})]})]})]})]}),r.jsxs("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[r.jsxs(Wa,{value:C,onValueChange:W=>g(W),className:"flex-1 flex flex-col min-h-0",children:[r.jsxs($a,{className:"mb-4 flex-none",children:[r.jsxs(Qt,{value:"trace",className:"gap-2",children:[r.jsx(Dn,{className:"h-4 w-4"}),"Trace"]}),y&&r.jsxs(Qt,{value:"graph",className:"gap-2",children:[r.jsx(Va,{className:"h-4 w-4"}),"Graph"]}),r.jsxs(Qt,{value:"events",className:"gap-2",children:[r.jsx(Dn,{className:"h-4 w-4"}),"Events"]}),r.jsxs(Qt,{value:"streams",className:"gap-2",children:[r.jsx(Dn,{className:"h-4 w-4"}),"Streams"]})]}),r.jsx(en,{value:"trace",className:"mt-0 flex-1 min-h-0",children:r.jsx(Rt,{title:"Failed to load trace viewer",children:r.jsx("div",{className:"h-full",children:r.jsx(Xc,{error:H,steps:A,events:D,hooks:L,run:F,isLoading:E,spanDetailData:V,spanDetailLoading:G,spanDetailError:oe,onSpanSelect:ve,onStreamClick:N,onWakeUpSleep:I,onResolveHook:j,onLoadEventData:w})})})}),r.jsx(en,{value:"events",className:"mt-0 flex-1 min-h-0",children:r.jsx(Rt,{title:"Failed to load events list",children:r.jsx("div",{className:"h-full",children:r.jsx(Yl,{events:D,steps:A,run:F,onLoadEventData:b})})})}),r.jsx(en,{value:"streams",className:"mt-0 flex-1 min-h-0",children:r.jsx(Rt,{title:"Failed to load stream data",children:r.jsxs("div",{className:"h-full flex gap-4",children:[r.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:[r.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 (",be.length,")"]}),r.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:J?r.jsx("div",{className:"p-4 flex items-center justify-center",children:r.jsx(mn,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):Q?r.jsx("div",{className:"p-4 text-xs text-destructive",children:Q.message}):be.length===0?r.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):be.map(W=>r.jsx("button",{type:"button",onClick:()=>h(W),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:v===W?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:W,children:W},W))})]}),r.jsx("div",{className:"flex-1 min-w-0",children:v?r.jsx(fi,{streamId:v,chunks:ie,isLive:R,error:K}):r.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:r.jsx("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:be.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),y&&r.jsx(en,{value:"graph",className:"mt-0 flex-1 min-h-0",children:r.jsx(Rt,{title:"Failed to load execution graph",children:r.jsx("div",{className:"h-full min-h-[500px]",children:r.jsx(bu,{run:F,allSteps:A,allEvents:D,env:m})})})})]}),T&&r.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:[r.jsx(mn,{className:"size-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}const Su=oa(function(){const t=sa(),[n]=Co(),o=t.runId,s=n.get("stepId"),a=n.get("eventId"),l=n.get("hookId"),i=s||a||l||void 0;return r.jsx(Rt,{title:"Failed to load run details",children:r.jsx(wu,{runId:o,selectedId:i})})});export{Su as default};