@ensocode/server 0.3.15-beta.241 → 0.3.15-beta.244

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 (173) hide show
  1. package/out/phone/assets/{EditDiff-CSimrAEO.js → EditDiff-Dl1v7xzD.js} +1 -1
  2. package/out/phone/assets/{ReadFileView-Jn3R6r7-.js → ReadFileView-DnbZC0ty.js} +1 -1
  3. package/out/phone/assets/{abnfDiagram-VCTEODGH-fmoMWTbJ.js → abnfDiagram-VCTEODGH-Co7grfeK.js} +1 -1
  4. package/out/phone/assets/architecture-7GRP2DOG-CPQkhXxx.js +1 -0
  5. package/out/phone/assets/{architectureDiagram-5GKGNRK7-BVfM9qLh.js → architectureDiagram-5GKGNRK7-63szDTwV.js} +1 -1
  6. package/out/phone/assets/{blockDiagram-I7D4REHJ-DVsjIiEb.js → blockDiagram-I7D4REHJ-DiqufW2M.js} +1 -1
  7. package/out/phone/assets/{c4Diagram-7LVT6UL2-VdOATGT-.js → c4Diagram-7LVT6UL2-DEkuGuT5.js} +1 -1
  8. package/out/phone/assets/channel-CTU5U1Gc.js +1 -0
  9. package/out/phone/assets/{chunk-4HAMMTFA-BlmRWgVl.js → chunk-4HAMMTFA-BBPCzb9_.js} +1 -1
  10. package/out/phone/assets/{chunk-75Z2AOVW-B1Xx4VYV.js → chunk-75Z2AOVW-CvsXKk5y.js} +1 -1
  11. package/out/phone/assets/{chunk-DU6HZSFF-jZXKN9D0.js → chunk-DU6HZSFF-DFN-6z2K.js} +1 -1
  12. package/out/phone/assets/{chunk-F27PBJKO-pe6xAY-J.js → chunk-F27PBJKO-CxbPevJY.js} +1 -1
  13. package/out/phone/assets/{chunk-GMAD6QVW-DwzdtwGU.js → chunk-GMAD6QVW-BKkB3y89.js} +1 -1
  14. package/out/phone/assets/{chunk-GVQU2GXP-CCk8aXOq.js → chunk-GVQU2GXP-BmuuVTk9.js} +1 -1
  15. package/out/phone/assets/{chunk-IMKFNOWR-bNUmZDqg.js → chunk-IMKFNOWR-DtyReyu7.js} +1 -1
  16. package/out/phone/assets/{chunk-L3NEJ4N5-CUdCK-p_.js → chunk-L3NEJ4N5-CYQouxRc.js} +1 -1
  17. package/out/phone/assets/{chunk-OSK3NFVY-BTXa5Alc.js → chunk-OSK3NFVY-C8s892Xu.js} +1 -1
  18. package/out/phone/assets/{chunk-P2QGCYS3-CF2JAuy1.js → chunk-P2QGCYS3-Wo7i2bF8.js} +1 -1
  19. package/out/phone/assets/{chunk-POPQ4Y6H-BAnwlIFk.js → chunk-POPQ4Y6H-Cs3x8DIB.js} +1 -1
  20. package/out/phone/assets/{chunk-PWAF6VOD-BlFR6i6J.js → chunk-PWAF6VOD-JEGLXjtH.js} +1 -1
  21. package/out/phone/assets/{chunk-SHT3W25Y-DtR-NqyN.js → chunk-SHT3W25Y-DtlDK80W.js} +1 -1
  22. package/out/phone/assets/{chunk-SVP7TREG-DuaEOvLw.js → chunk-SVP7TREG-DCDTtBi2.js} +1 -1
  23. package/out/phone/assets/{chunk-TICWLB2K-BG4Kei8c.js → chunk-TICWLB2K-DH_cShpv.js} +1 -1
  24. package/out/phone/assets/classDiagram-ZZMXUADV-CAp7xfKw.js +1 -0
  25. package/out/phone/assets/classDiagram-v2-VYDZK3BY-CAp7xfKw.js +1 -0
  26. package/out/phone/assets/{codeHighlighter-KH77fp0H.js → codeHighlighter-oIs6aBXZ.js} +1 -1
  27. package/out/phone/assets/{cynefin-OW5HDTMX-n2BfpVsu.js → cynefin-OW5HDTMX-DWY8sMmw.js} +1 -1
  28. package/out/phone/assets/{cynefinDiagram-5FMLGOSQ-DZqrq3oc.js → cynefinDiagram-5FMLGOSQ-DystTHhc.js} +1 -1
  29. package/out/phone/assets/{dagre-GXQ25YYZ-HVsu_rPg.js → dagre-GXQ25YYZ-CjIk5Pm7.js} +1 -1
  30. package/out/phone/assets/{desk-z_cqgI4L.js → desk-Dc-PsOnl.js} +1 -1
  31. package/out/phone/assets/{diagram-S7CK7UJ4-BZMmnDF5.js → diagram-S7CK7UJ4-CY0PD39z.js} +1 -1
  32. package/out/phone/assets/{diagram-UQ7AKVKN-D8T63tql.js → diagram-UQ7AKVKN-CwX9S12n.js} +1 -1
  33. package/out/phone/assets/{diagram-VSXAHHWV-qPVtZ3Wt.js → diagram-VSXAHHWV-Bk_rb32-.js} +1 -1
  34. package/out/phone/assets/{diagram-VX7I27RA-CyEJ3aas.js → diagram-VX7I27RA-C3JVMUBL.js} +1 -1
  35. package/out/phone/assets/{diagram-Z3DM3KII-O3aOm1L8.js → diagram-Z3DM3KII-Drf5stHv.js} +1 -1
  36. package/out/phone/assets/{ebnfDiagram-PWID7BFC-Csdlx5oS.js → ebnfDiagram-PWID7BFC-Cz19FBqO.js} +1 -1
  37. package/out/phone/assets/{erDiagram-RLTQ6QDP-DcUkeTEM.js → erDiagram-RLTQ6QDP-BXmpqk2p.js} +1 -1
  38. package/out/phone/assets/eventmodeling-NTZA5JFV-3NMIapix.js +1 -0
  39. package/out/phone/assets/flowDiagram-HODETNUW-DEM4t2yp.js +1 -0
  40. package/out/phone/assets/{ganttDiagram-EL5Y4UJY-BsohogYF.js → ganttDiagram-EL5Y4UJY-Bum0_E5J.js} +1 -1
  41. package/out/phone/assets/{gitGraph-4MIJSDKK-bJ82NwBa.js → gitGraph-4MIJSDKK-BCw9r0Vf.js} +1 -1
  42. package/out/phone/assets/{gitGraphDiagram-WWUBYQGX-B4kVWOxs.js → gitGraphDiagram-WWUBYQGX-BrS3oYOR.js} +1 -1
  43. package/out/phone/assets/{info-A6RAGUB7-CtAEx6Uj.js → info-A6RAGUB7-CdAqHFpo.js} +1 -1
  44. package/out/phone/assets/{infoDiagram-27XIBGKW-NWXJXWIa.js → infoDiagram-27XIBGKW-eIHi-wVl.js} +1 -1
  45. package/out/phone/assets/{ishikawaDiagram-5VMMS53U-DNZOHXyU.js → ishikawaDiagram-5VMMS53U--ZByOgbd.js} +1 -1
  46. package/out/phone/assets/{journeyDiagram-3NMN7TZE-BILq8KCa.js → journeyDiagram-3NMN7TZE-Cez_oRvQ.js} +1 -1
  47. package/out/phone/assets/{kanban-definition-UXKFOSKX-DdZ5jVxU.js → kanban-definition-UXKFOSKX-CzRnvsUw.js} +1 -1
  48. package/out/phone/assets/{line-Bo8uZJ4I.js → line-BI6dRkfB.js} +1 -1
  49. package/out/phone/assets/main-6fqTYTkO.css +2 -0
  50. package/out/phone/assets/{main-C6jVGXbp.js → main-Bb-GRoqY.js} +37 -37
  51. package/out/phone/assets/{mermaid-parser.core-B1syl2rc.js → mermaid-parser.core-hbmkLOwJ.js} +3 -3
  52. package/out/phone/assets/{mermaid.core-96kZPVvg.js → mermaid.core-DyabQfxY.js} +4 -4
  53. package/out/phone/assets/{mindmap-definition-YA3MSWOX-CLzIHVmQ.js → mindmap-definition-YA3MSWOX-BsrANfeL.js} +1 -1
  54. package/out/phone/assets/{packet-AYTQ26CC-BBgqe8hX.js → packet-AYTQ26CC-C10GNvQY.js} +1 -1
  55. package/out/phone/assets/{pegDiagram-XKGWAZYB-CY_VEopq.js → pegDiagram-XKGWAZYB-BJZdvuYe.js} +1 -1
  56. package/out/phone/assets/{pie-WAS4IAKB-of52Xr-X.js → pie-WAS4IAKB-BO4lKzBO.js} +1 -1
  57. package/out/phone/assets/{pieDiagram-E7YTZNPT-mIG2cHsC.js → pieDiagram-E7YTZNPT-CebvsUnG.js} +1 -1
  58. package/out/phone/assets/{quadrantDiagram-AXDQQJYC-ZC2ztpMA.js → quadrantDiagram-AXDQQJYC-DAIoWitA.js} +1 -1
  59. package/out/phone/assets/{radar-RG4KPBEZ-BXO_8eMD.js → radar-RG4KPBEZ-BSvMj116.js} +1 -1
  60. package/out/phone/assets/{railroad-74A4TZTK-DSFZE_CO.js → railroad-74A4TZTK-CC8n5mQv.js} +1 -1
  61. package/out/phone/assets/railroad-abnf-HS5TGJTU-CFJfM9dh.js +1 -0
  62. package/out/phone/assets/railroad-ebnf-LZEXJU2U-B_0R-wZF.js +1 -0
  63. package/out/phone/assets/railroad-peg-WCYAUIDC-ObEBCIxG.js +1 -0
  64. package/out/phone/assets/{railroadDiagram-O6MQD6OU-BhKGjvYs.js → railroadDiagram-O6MQD6OU-BzydbcBb.js} +1 -1
  65. package/out/phone/assets/{requirementDiagram-BXWQKSXE-DhYI3BgP.js → requirementDiagram-BXWQKSXE-CKe0Zr83.js} +1 -1
  66. package/out/phone/assets/{sankeyDiagram-P5KCCOFB-DUXZpMXR.js → sankeyDiagram-P5KCCOFB-CJworGIH.js} +1 -1
  67. package/out/phone/assets/{sequenceDiagram-WJ2MYXX4-BK3O5pAz.js → sequenceDiagram-WJ2MYXX4-DdpCJT7e.js} +1 -1
  68. package/out/phone/assets/{shellUpdate-DrB0t4Vm.js → shellUpdate-B-mV7z4A.js} +1 -1
  69. package/out/phone/assets/{stateDiagram-D77RDMKH-DrRcKs0R.js → stateDiagram-D77RDMKH-D-IrCDnR.js} +1 -1
  70. package/out/phone/assets/stateDiagram-v2-MP3YSRHH-D6EyGCQb.js +1 -0
  71. package/out/phone/assets/{swimlanes-42K2YHIH-BCd-QVVh.js → swimlanes-42K2YHIH-Cy0iyaFc.js} +1 -1
  72. package/out/phone/assets/swimlanesDiagram-VR7AAH4N-BgU-mVRE.js +8 -0
  73. package/out/phone/assets/{timeline-definition-24CTP7MA-DXe2OX47.js → timeline-definition-24CTP7MA-DmctHGEI.js} +1 -1
  74. package/out/phone/assets/{treeView-Q6P3EWNA-BRe0XDzs.js → treeView-Q6P3EWNA-DJ3NLlKQ.js} +1 -1
  75. package/out/phone/assets/{treemap-WGGIJYW6-s1q2y2HB.js → treemap-WGGIJYW6-Wu9CYVkP.js} +1 -1
  76. package/out/phone/assets/{vennDiagram-4TSXK5OY-BGrxD8PX.js → vennDiagram-4TSXK5OY-C9U0vhBw.js} +1 -1
  77. package/out/phone/assets/{wardley-WFR3VGLG-DO2WbZKB.js → wardley-WFR3VGLG-Bux_FNX8.js} +1 -1
  78. package/out/phone/assets/{wardleyDiagram-VM6X3IG4-BBOgHvB9.js → wardleyDiagram-VM6X3IG4-YeXD-Py0.js} +1 -1
  79. package/out/phone/assets/{xychartDiagram-S5SC5T6Z-CWe0eCMj.js → xychartDiagram-S5SC5T6Z-6G4BJgCo.js} +1 -1
  80. package/out/phone/desk.html +3 -3
  81. package/out/phone/index.html +4 -4
  82. package/out/phone/sw.js +2 -2
  83. package/out/renderer/assets/{EditDiff-Bd8hj9gf.js → EditDiff-Dq1ru-27.js} +1 -1
  84. package/out/renderer/assets/{ReadFileView-Bbb7V3MH.js → ReadFileView-DRDsV4Qh.js} +1 -1
  85. package/out/renderer/assets/{SidePanel-DML0yRbK.js → SidePanel-BzHQWaD_.js} +1 -1
  86. package/out/renderer/assets/{abnfDiagram-VCTEODGH-BLYUgV98.js → abnfDiagram-VCTEODGH-BvoAbCWQ.js} +1 -1
  87. package/out/renderer/assets/{arc-CDA8kxTv.js → arc-CJC8vTfi.js} +1 -1
  88. package/out/renderer/assets/{architectureDiagram-5GKGNRK7-D-JOyWkI.js → architectureDiagram-5GKGNRK7-DUaKoTV1.js} +1 -1
  89. package/out/renderer/assets/{blockDiagram-I7D4REHJ-BZq1xS_g.js → blockDiagram-I7D4REHJ-Ctrde6gr.js} +1 -1
  90. package/out/renderer/assets/{c4Diagram-7LVT6UL2-DlrUI2mr.js → c4Diagram-7LVT6UL2-m237al85.js} +1 -1
  91. package/out/renderer/assets/channel-4OCJMTsH.js +1 -0
  92. package/out/renderer/assets/{chunk-2Q5K7J3B-Ecw5ByAe.js → chunk-2Q5K7J3B-DxInKfng.js} +1 -1
  93. package/out/renderer/assets/{chunk-5VM5RSS4-Bp_nwDzN.js → chunk-5VM5RSS4-DYWVp5wB.js} +1 -1
  94. package/out/renderer/assets/{chunk-F27PBJKO-B4M0cyLW.js → chunk-F27PBJKO-B4co86fQ.js} +1 -1
  95. package/out/renderer/assets/{chunk-IMKFNOWR-D3R3u0O-.js → chunk-IMKFNOWR-BhBcruMO.js} +1 -1
  96. package/out/renderer/assets/{chunk-JWPE2WC7-B09_gtdy.js → chunk-JWPE2WC7-C_OTocS8.js} +1 -1
  97. package/out/renderer/assets/{chunk-POPQ4Y6H-BvmgIk3A.js → chunk-POPQ4Y6H-DuPM2iNq.js} +1 -1
  98. package/out/renderer/assets/{chunk-SVP7TREG-DTaIzWhf.js → chunk-SVP7TREG-BBAC9v6R.js} +1 -1
  99. package/out/renderer/assets/{chunk-TICWLB2K-u974J_2J.js → chunk-TICWLB2K-N6m7s6mw.js} +1 -1
  100. package/out/renderer/assets/{chunk-XXDRQBXY-Bb-N5juq.js → chunk-XXDRQBXY-B1Gr5MJz.js} +1 -1
  101. package/out/renderer/assets/classDiagram-ZZMXUADV-lVKI638e.js +1 -0
  102. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-lVKI638e.js +1 -0
  103. package/out/renderer/assets/{cose-bilkent-JH36ORCC-_0KSMiyp.js → cose-bilkent-JH36ORCC-BGacAdLc.js} +1 -1
  104. package/out/renderer/assets/{cynefin-OW5HDTMX-DlJWTqrV.js → cynefin-OW5HDTMX-CstxFU_f.js} +1 -1
  105. package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-YX_IQLVF.js → cynefinDiagram-5FMLGOSQ-B2A_z92b.js} +1 -1
  106. package/out/renderer/assets/{dagre-GXQ25YYZ-BacZro1G.js → dagre-GXQ25YYZ-B2Cuq6s4.js} +1 -1
  107. package/out/renderer/assets/{diagram-S7CK7UJ4-BdZsvDfO.js → diagram-S7CK7UJ4-sPp6xmTo.js} +1 -1
  108. package/out/renderer/assets/{diagram-UQ7AKVKN-Bx7HSPaR.js → diagram-UQ7AKVKN-C1nSgHxc.js} +1 -1
  109. package/out/renderer/assets/{diagram-VSXAHHWV-DRNaDs0S.js → diagram-VSXAHHWV-DyrFmlyo.js} +1 -1
  110. package/out/renderer/assets/{diagram-VX7I27RA-ykxcOFfg.js → diagram-VX7I27RA-C1YDNDgn.js} +1 -1
  111. package/out/renderer/assets/{diagram-Z3DM3KII-C8r2pseZ.js → diagram-Z3DM3KII-vDjTMVCb.js} +1 -1
  112. package/out/renderer/assets/{ebnfDiagram-PWID7BFC-XQ7lDc9Y.js → ebnfDiagram-PWID7BFC-go5p9rJU.js} +1 -1
  113. package/out/renderer/assets/{erDiagram-RLTQ6QDP-vKyTFhvS.js → erDiagram-RLTQ6QDP--7HBypuL.js} +1 -1
  114. package/out/renderer/assets/{flowDiagram-HODETNUW-CfrgUHAS.js → flowDiagram-HODETNUW-BhISSZBS.js} +1 -1
  115. package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-kLRdxejO.js → ganttDiagram-EL5Y4UJY-BcBSKfXJ.js} +1 -1
  116. package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-CORDJ_Ay.js → gitGraphDiagram-WWUBYQGX-CKps0oQ_.js} +1 -1
  117. package/out/renderer/assets/{index-ZFFgI5ss.js → index-DOMKWUhA.js} +267 -267
  118. package/out/renderer/assets/index-VOhKg_w1.css +1 -0
  119. package/out/renderer/assets/{infoDiagram-27XIBGKW-Cw6TRc_C.js → infoDiagram-27XIBGKW-Cuwh5obU.js} +1 -1
  120. package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-SOVuP3c1.js → ishikawaDiagram-5VMMS53U-BLMUHtbz.js} +1 -1
  121. package/out/renderer/assets/{journeyDiagram-3NMN7TZE-3HTZmvUQ.js → journeyDiagram-3NMN7TZE-CdyKTe8S.js} +1 -1
  122. package/out/renderer/assets/{kanban-definition-UXKFOSKX-DpYipMmA.js → kanban-definition-UXKFOSKX-CLmlyeai.js} +1 -1
  123. package/out/renderer/assets/{layout-BwXeh9aP.js → layout-Blff8S_S.js} +1 -1
  124. package/out/renderer/assets/{linear-CR8355iJ.js → linear-E24BfEe_.js} +1 -1
  125. package/out/renderer/assets/{mermaid.core-0Y0k-IR7.js → mermaid.core-tBzIgBPK.js} +5 -5
  126. package/out/renderer/assets/{mindmap-definition-YA3MSWOX-FWFQgIj6.js → mindmap-definition-YA3MSWOX-Ctunlg4e.js} +1 -1
  127. package/out/renderer/assets/{pegDiagram-XKGWAZYB-DM8j81UL.js → pegDiagram-XKGWAZYB-BGUDmJ0t.js} +1 -1
  128. package/out/renderer/assets/{pieDiagram-E7YTZNPT-XB2jUWtG.js → pieDiagram-E7YTZNPT-BV3SKGcw.js} +1 -1
  129. package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-D9zVY5gu.js → quadrantDiagram-AXDQQJYC-Cto7yY8W.js} +1 -1
  130. package/out/renderer/assets/{railroadDiagram-O6MQD6OU-BREkmdyd.js → railroadDiagram-O6MQD6OU--eLvppDh.js} +1 -1
  131. package/out/renderer/assets/{requirementDiagram-BXWQKSXE-c-zsytxs.js → requirementDiagram-BXWQKSXE-Dom34Gkz.js} +1 -1
  132. package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-B5k-1ijv.js → sankeyDiagram-P5KCCOFB-CN11JSQo.js} +1 -1
  133. package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-CSN_Fh8d.js → sequenceDiagram-WJ2MYXX4-9uQUwoRg.js} +1 -1
  134. package/out/renderer/assets/{sessionChanges-BEUiNgR0.js → sessionChanges-DLMjbWOi.js} +1 -1
  135. package/out/renderer/assets/{sizeCapture-INFHLROL-BKTOVTma.js → sizeCapture-INFHLROL-C1rIYWoA.js} +1 -1
  136. package/out/renderer/assets/{stateDiagram-D77RDMKH-D9ZZYX6G.js → stateDiagram-D77RDMKH-M3C0QecZ.js} +1 -1
  137. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-B8HJtGSb.js +1 -0
  138. package/out/renderer/assets/{swimlanes-42K2YHIH-DP7c5A76.js → swimlanes-42K2YHIH-DnLqJear.js} +1 -1
  139. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-CNAGwVvM.js +8 -0
  140. package/out/renderer/assets/{timeline-definition-24CTP7MA-C0HwGCXi.js → timeline-definition-24CTP7MA-DJcjXRdy.js} +1 -1
  141. package/out/renderer/assets/{vennDiagram-4TSXK5OY-DRKPfvIL.js → vennDiagram-4TSXK5OY-B7cvho9j.js} +1 -1
  142. package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-DU1_TBlT.js → wardleyDiagram-VM6X3IG4-BE0YuPQP.js} +1 -1
  143. package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-cRKyBsyE.js → xychartDiagram-S5SC5T6Z-D6oIwCDT.js} +1 -1
  144. package/out/renderer/index.html +2 -2
  145. package/out/renderer/web-preload.js +1 -1
  146. package/out/server/agent.js +4 -4
  147. package/out/server/chunks/{builtinOccupancy-K9RUDw3l.js → builtinOccupancy-DvzfBkum.js} +3 -3
  148. package/out/server/chunks/{dispatchModel-JnEtucdi.js → dispatchModel-0Gu9nhKa.js} +2 -2
  149. package/out/server/chunks/{loadProvider-B5WmMMag.js → loadProvider-CDXRBHj8.js} +2 -2
  150. package/out/server/chunks/{menuSkills-C-pqhzrG.js → menuSkills-C0v0R3gX.js} +3 -3
  151. package/out/server/chunks/{projectCode-CCHyotEp.js → projectCode-CxP4jjhK.js} +2 -2
  152. package/out/server/chunks/{web-B6yI7DUY.js → web-Dw5EcbGj.js} +2 -2
  153. package/out/server/chunks/{workflowPresets-_DQtzohi.js → workflowPresets-CI-duJC2.js} +2 -2
  154. package/out/server/index.js +212 -318
  155. package/package.json +1 -1
  156. package/out/phone/assets/architecture-7GRP2DOG-sqU8jFuM.js +0 -1
  157. package/out/phone/assets/channel-CbOf5_bF.js +0 -1
  158. package/out/phone/assets/classDiagram-ZZMXUADV-CIWF3pyh.js +0 -1
  159. package/out/phone/assets/classDiagram-v2-VYDZK3BY-CIWF3pyh.js +0 -1
  160. package/out/phone/assets/eventmodeling-NTZA5JFV-jAd-hKjz.js +0 -1
  161. package/out/phone/assets/flowDiagram-HODETNUW-CcxYFoAM.js +0 -1
  162. package/out/phone/assets/main-Bk2Gcz5l.css +0 -2
  163. package/out/phone/assets/railroad-abnf-HS5TGJTU-Ch8xudvg.js +0 -1
  164. package/out/phone/assets/railroad-ebnf-LZEXJU2U-C3gTYu9G.js +0 -1
  165. package/out/phone/assets/railroad-peg-WCYAUIDC-r4pSaJqV.js +0 -1
  166. package/out/phone/assets/stateDiagram-v2-MP3YSRHH-DBTJhEN5.js +0 -1
  167. package/out/phone/assets/swimlanesDiagram-VR7AAH4N-CY5PGCyR.js +0 -8
  168. package/out/renderer/assets/channel-BNg-RaaW.js +0 -1
  169. package/out/renderer/assets/classDiagram-ZZMXUADV-BpOHaGYe.js +0 -1
  170. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-BpOHaGYe.js +0 -1
  171. package/out/renderer/assets/index-CtOLwaEJ.css +0 -1
  172. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-BRGfinuA.js +0 -1
  173. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-CffafTS2.js +0 -8
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-aPuBvESs.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/html-BsvMqTlf.js","assets/javascript-DcMHgNcu.js","assets/css-DlBQoFxe.js","assets/angular-ts-ocjSXnvf.js","assets/scss-BaZL6t2Y.js","assets/apl-D8Zaj6f9.js","assets/xml-C01ajBW7.js","assets/java-D7h0NA_A.js","assets/json-DePJdKYk.js","assets/astro-CbVusc_k.js","assets/typescript-BTGs5etX.js","assets/postcss-BXeXVLqQ.js","assets/tsx-DvWhG4dC.js","assets/blade-BuKMbjJR.js","assets/html-derivative-D9FvRNj4.js","assets/sql-DvarVTMJ.js","assets/bsl-_VjlB9mv.js","assets/sdbl-bTVj8UrX.js","assets/c-BNQJhXlP.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/chapel-CFMD-Djs.js","assets/cobol-qSrRm_BU.js","assets/coffee-BP03ytLP.js","assets/cpp-CUBNVKxn.js","assets/regexp-I2jnduhj.js","assets/glsl-CyFpZtQv.js","assets/crystal-CCpd0BXH.js","assets/shellscript-B51zB43X.js","assets/edge-k_uo0VIr.js","assets/elixir-CJS91GrO.js","assets/elm-Bmx6Fs0i.js","assets/erb-yi0ZozmI.js","assets/ruby-D1ky9XZ0.js","assets/haml-Dds4VdNJ.js","assets/graphql-BIyAKkG2.js","assets/jsx-BUUYi3qs.js","assets/lua-Z49wBRLR.js","assets/yaml-BWCS3NLV.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-xMC7jr7x.js","assets/gdshader-CBce3t8t.js","assets/gdscript-DYvRD3hg.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-C-RR1FSc.js","assets/glimmer-js-Di6EiJvU.js","assets/glimmer-ts-C2P-EwIP.js","assets/hack-DDi4pUY-.js","assets/handlebars-C81KA5yo.js","assets/http-c4_vT9ST.js","assets/hurl-BqZA9I9Q.js","assets/csv-Dx-8-gkx.js","assets/hxml-Dcm88srW.js","assets/haxe-C8oCnwJJ.js","assets/jinja-CixBDh_U.js","assets/jison-Ru_S5AEn.js","assets/julia-CaY0JZD0.js","assets/r-CvCSiWB_.js","assets/just-Q4EdCjF5.js","assets/perl-BtArmf81.js","assets/latex-t1iljvl0.js","assets/tex-JPaUWOrn.js","assets/liquid-DEL4RHa9.js","assets/marko-DYWPPmCl.js","assets/less-DVTAwKKz.js","assets/mdc-CsAWFGA9.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BrbrEdla.js","assets/nim-BjwzhXka.js","assets/org-TFl3N09_.js","assets/clojure-DqKBuwfJ.js","assets/csharp-oqKa8noW.js","assets/dart-CnvKMtbv.js","assets/docker-IyjqRm3v.js","assets/go-rLFTqkRN.js","assets/groovy-CacY0gHj.js","assets/ini-B5eOa1yu.js","assets/make-Dixweg8N.js","assets/objective-c-D1A_Heim.js","assets/ocaml-O90oeIOV.js","assets/php-Cx25uSIP.js","assets/vb-DOwzaHZ0.js","assets/raku-B3gFvitq.js","assets/rust-Cfkwpbl8.js","assets/scala-BiFt_7mu.js","assets/zig-CMLA9XwU.js","assets/xsl-CCLNyvR3.js","assets/pug-B4bk2kWf.js","assets/qml-g4UDed-8.js","assets/razor-BSt2ayLr.js","assets/rst-BucurtmO.js","assets/cmake-Bj61d0ZC.js","assets/sas-CUQt684o.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-B-KBpmJs.js","assets/soy-D5xCHD_M.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-8TbiBYrm.js","assets/surrealql-DalIYx4r.js","assets/svelte-D4FIy7cP.js","assets/templ-DP4lTcEq.js","assets/ts-tags-CNUq3so9.js","assets/twig-Chu5fnNS.js","assets/typst--WwEKe8X.js","assets/bat-qdxAdBWQ.js","assets/bibtex-Ci_nEsc7.js","assets/jsonc-CYpm1nAK.js","assets/log-BNLmms1o.js","assets/powershell-CCSX75yM.js","assets/swift-CyEgAFGc.js","assets/system-verilog-Dh5ihWbf.js","assets/verilog-B2gwz-sJ.js","assets/vue-DjCn01CB.js","assets/vue-html-BXjKVtKk.js","assets/vue-vine-By_xyXdL.js","assets/stylus-B6D30XZt.js","assets/mermaid.core-96kZPVvg.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-oBChb5qS.js","assets/chunk-DU6HZSFF-jZXKN9D0.js","assets/chunk-75Z2AOVW-B1Xx4VYV.js","assets/dist-B_J_HbC0.js","assets/chunk-PWAF6VOD-BlFR6i6J.js","assets/chunk-GMAD6QVW-DwzdtwGU.js","assets/chunk-P2QGCYS3-CF2JAuy1.js","assets/chunk-4HAMMTFA-BlmRWgVl.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-CCk8aXOq.js","assets/chunk-OSK3NFVY-BTXa5Alc.js","assets/line-Bo8uZJ4I.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-CUdCK-p_.js","assets/EditDiff-CSimrAEO.js","assets/shellUpdate-DrB0t4Vm.js","assets/codeHighlighter-KH77fp0H.js","assets/ReadFileView-Jn3R6r7-.js","assets/jsQR-B1eQcpQl.js"])))=>i.map(i=>d[i]);
2
- import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{A as r,At as i,B as a,Bt as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,F as p,Ft as m,G as h,Gt as g,H as _,Ht as v,I as y,It as b,L as x,Lt as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,P as k,Pt as A,R as j,Rt as M,S as N,St as P,T as F,Tt as I,U as L,Ut as R,V as ee,Vt as z,W as B,Wt as V,_ as te,a as H,at as ne,b as re,c as ie,ct as ae,d as oe,dt as se,f as ce,ft as le,g as ue,h as de,ht as fe,it as pe,j as me,jt as he,k as ge,kt as _e,l as ve,lt as ye,m as be,mt as xe,n as Se,o as Ce,ot as we,p as Te,rt as Ee,s as De,t as Oe,tt as ke,ut as Ae,vt as je,w as Me,wt as Ne,y as Pe,z as Fe,zt as Ie}from"./shellUpdate-DrB0t4Vm.js";function Le(){window.electronAPI||Object.defineProperty(window,"electronAPI",{value:{git:{diffHead:async()=>({ok:!1,error:`unavailable`})},changes:{readSnapshots:async()=>({}),writeSnapshots:async()=>!1},workspaceFiles:{listDir:async()=>({ok:!1,error:`unavailable`}),read:async()=>({ok:!1,error:`unavailable`}),write:async()=>({ok:!1,error:`unavailable`}),watchStart:async()=>({ok:!1,error:`unavailable`}),watchStop:async()=>({ok:!1,error:`unavailable`}),onChange:()=>()=>void 0,search:async()=>({ok:!1,error:`unavailable`})},files:{read:async()=>null,search:async()=>[],pathForFile:()=>null},agentRegistry:{list:async()=>null},agent:{stopTask:async()=>({ok:!1,error:`not supported on phone`}),stopSubagent:async()=>({ok:!1,error:`not supported on phone`})},providers:{listOauth:async()=>[],getOauthUsage:async()=>null}},writable:!1})}function Re(e){let t=window.electronAPI?.agent;t&&(t.stopTask=async(t,n)=>(e.stopTask(t,n),{ok:!0}),t.stopSubagent=async(t,n)=>(e.stopSubagent(t,n),{ok:!0}))}Le();var ze=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Be=n(((e,t)=>{t.exports=ze()})),Ve=n((e=>{var t=g();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),He=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ve()})),Ue=n((e=>{var t=Be(),n=g(),r=He();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function ee(e){return{current:e}}function z(e){0>R||(e.current=L[R],L[R]=null,R--)}function B(e,t){R++,L[R]=e.current,e.current=t}var V=ee(null),te=ee(null),H=ee(null),ne=ee(null);function re(e,t){switch(B(H,t),B(te,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(V),B(V,e)}function ie(){z(V),z(te),z(H)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=V.current,n=Kd(t,e.type);t!==n&&(B(te,e),B(V,n))}function oe(e){te.current===e&&(z(V),z(te)),ne.current===e&&(z(ne),np._currentValue=I)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-aPuBvESs.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/html-BsvMqTlf.js","assets/javascript-DcMHgNcu.js","assets/css-DlBQoFxe.js","assets/angular-ts-ocjSXnvf.js","assets/scss-BaZL6t2Y.js","assets/apl-D8Zaj6f9.js","assets/xml-C01ajBW7.js","assets/java-D7h0NA_A.js","assets/json-DePJdKYk.js","assets/astro-CbVusc_k.js","assets/typescript-BTGs5etX.js","assets/postcss-BXeXVLqQ.js","assets/tsx-DvWhG4dC.js","assets/blade-BuKMbjJR.js","assets/html-derivative-D9FvRNj4.js","assets/sql-DvarVTMJ.js","assets/bsl-_VjlB9mv.js","assets/sdbl-bTVj8UrX.js","assets/c-BNQJhXlP.js","assets/cairo-DLTphjLi.js","assets/python-gzcpVVnB.js","assets/chapel-CFMD-Djs.js","assets/cobol-qSrRm_BU.js","assets/coffee-BP03ytLP.js","assets/cpp-CUBNVKxn.js","assets/regexp-I2jnduhj.js","assets/glsl-CyFpZtQv.js","assets/crystal-CCpd0BXH.js","assets/shellscript-B51zB43X.js","assets/edge-k_uo0VIr.js","assets/elixir-CJS91GrO.js","assets/elm-Bmx6Fs0i.js","assets/erb-yi0ZozmI.js","assets/ruby-D1ky9XZ0.js","assets/haml-Dds4VdNJ.js","assets/graphql-BIyAKkG2.js","assets/jsx-BUUYi3qs.js","assets/lua-Z49wBRLR.js","assets/yaml-BWCS3NLV.js","assets/erlang-Cphh6RMH.js","assets/markdown-BYOwaDjH.js","assets/fortran-fixed-form-DEKoE2YW.js","assets/fortran-free-form-CYNrtFtB.js","assets/fsharp-D13ZGOAj.js","assets/gdresource-xMC7jr7x.js","assets/gdshader-CBce3t8t.js","assets/gdscript-DYvRD3hg.js","assets/git-commit-BSykSTBG.js","assets/diff-woXpYk--.js","assets/git-rebase-C-RR1FSc.js","assets/glimmer-js-Di6EiJvU.js","assets/glimmer-ts-C2P-EwIP.js","assets/hack-DDi4pUY-.js","assets/handlebars-C81KA5yo.js","assets/http-c4_vT9ST.js","assets/hurl-BqZA9I9Q.js","assets/csv-Dx-8-gkx.js","assets/hxml-Dcm88srW.js","assets/haxe-C8oCnwJJ.js","assets/jinja-CixBDh_U.js","assets/jison-Ru_S5AEn.js","assets/julia-CaY0JZD0.js","assets/r-CvCSiWB_.js","assets/just-Q4EdCjF5.js","assets/perl-BtArmf81.js","assets/latex-t1iljvl0.js","assets/tex-JPaUWOrn.js","assets/liquid-DEL4RHa9.js","assets/marko-DYWPPmCl.js","assets/less-DVTAwKKz.js","assets/mdc-CsAWFGA9.js","assets/nextflow-BJtWHP5T.js","assets/nextflow-groovy-DJMQeKeT.js","assets/nginx-BrbrEdla.js","assets/nim-BjwzhXka.js","assets/org-TFl3N09_.js","assets/clojure-DqKBuwfJ.js","assets/csharp-oqKa8noW.js","assets/dart-CnvKMtbv.js","assets/docker-IyjqRm3v.js","assets/go-rLFTqkRN.js","assets/groovy-CacY0gHj.js","assets/ini-B5eOa1yu.js","assets/make-Dixweg8N.js","assets/objective-c-D1A_Heim.js","assets/ocaml-O90oeIOV.js","assets/php-Cx25uSIP.js","assets/vb-DOwzaHZ0.js","assets/raku-B3gFvitq.js","assets/rust-Cfkwpbl8.js","assets/scala-BiFt_7mu.js","assets/zig-CMLA9XwU.js","assets/xsl-CCLNyvR3.js","assets/pug-B4bk2kWf.js","assets/qml-g4UDed-8.js","assets/razor-BSt2ayLr.js","assets/rst-BucurtmO.js","assets/cmake-Bj61d0ZC.js","assets/sas-CUQt684o.js","assets/shaderlab-TOUzSsQk.js","assets/hlsl-Cvrh5tZx.js","assets/shellsession-B-KBpmJs.js","assets/soy-D5xCHD_M.js","assets/sparql-D_iOobhT.js","assets/turtle-ByJddavk.js","assets/stata-8TbiBYrm.js","assets/surrealql-DalIYx4r.js","assets/svelte-D4FIy7cP.js","assets/templ-DP4lTcEq.js","assets/ts-tags-CNUq3so9.js","assets/twig-Chu5fnNS.js","assets/typst--WwEKe8X.js","assets/bat-qdxAdBWQ.js","assets/bibtex-Ci_nEsc7.js","assets/jsonc-CYpm1nAK.js","assets/log-BNLmms1o.js","assets/powershell-CCSX75yM.js","assets/swift-CyEgAFGc.js","assets/system-verilog-Dh5ihWbf.js","assets/verilog-B2gwz-sJ.js","assets/vue-DjCn01CB.js","assets/vue-html-BXjKVtKk.js","assets/vue-vine-By_xyXdL.js","assets/stylus-B6D30XZt.js","assets/mermaid.core-DyabQfxY.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-oBChb5qS.js","assets/chunk-DU6HZSFF-DFN-6z2K.js","assets/chunk-75Z2AOVW-CvsXKk5y.js","assets/dist-B_J_HbC0.js","assets/chunk-PWAF6VOD-JEGLXjtH.js","assets/chunk-GMAD6QVW-BKkB3y89.js","assets/chunk-P2QGCYS3-Wo7i2bF8.js","assets/chunk-4HAMMTFA-BBPCzb9_.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-GVQU2GXP-BmuuVTk9.js","assets/chunk-OSK3NFVY-C8s892Xu.js","assets/line-BI6dRkfB.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/graphlib-DS17s2tU.js","assets/chunk-L3NEJ4N5-CYQouxRc.js","assets/EditDiff-Dl1v7xzD.js","assets/shellUpdate-B-mV7z4A.js","assets/codeHighlighter-oIs6aBXZ.js","assets/ReadFileView-DnbZC0ty.js","assets/jsQR-B1eQcpQl.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{A as r,At as i,B as a,Bt as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,F as p,Ft as m,G as h,Gt as g,H as _,Ht as v,I as y,It as b,L as x,Lt as S,M as C,Mt as w,N as T,Nt as E,O as D,Ot as O,P as k,Pt as A,R as j,Rt as M,S as N,St as P,T as F,Tt as I,U as L,Ut as R,V as ee,Vt as z,W as B,Wt as V,_ as te,a as H,at as ne,b as re,c as ie,ct as ae,d as oe,dt as se,f as ce,ft as le,g as ue,h as de,ht as fe,it as pe,j as me,jt as he,k as ge,kt as _e,l as ve,lt as ye,m as be,mt as xe,n as Se,o as Ce,ot as we,p as Te,rt as Ee,s as De,t as Oe,tt as ke,ut as Ae,vt as je,w as Me,wt as Ne,y as Pe,z as Fe,zt as Ie}from"./shellUpdate-B-mV7z4A.js";function Le(){window.electronAPI||Object.defineProperty(window,"electronAPI",{value:{git:{diffHead:async()=>({ok:!1,error:`unavailable`})},changes:{readSnapshots:async()=>({}),writeSnapshots:async()=>!1},workspaceFiles:{listDir:async()=>({ok:!1,error:`unavailable`}),read:async()=>({ok:!1,error:`unavailable`}),write:async()=>({ok:!1,error:`unavailable`}),watchStart:async()=>({ok:!1,error:`unavailable`}),watchStop:async()=>({ok:!1,error:`unavailable`}),onChange:()=>()=>void 0,search:async()=>({ok:!1,error:`unavailable`})},files:{read:async()=>null,search:async()=>[],pathForFile:()=>null},agentRegistry:{list:async()=>null},agent:{stopTask:async()=>({ok:!1,error:`not supported on phone`}),stopSubagent:async()=>({ok:!1,error:`not supported on phone`})},providers:{listOauth:async()=>[],getOauthUsage:async()=>null}},writable:!1})}function Re(e){let t=window.electronAPI?.agent;t&&(t.stopTask=async(t,n)=>(e.stopTask(t,n),{ok:!0}),t.stopSubagent=async(t,n)=>(e.stopSubagent(t,n),{ok:!0}))}Le();var ze=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Be=n(((e,t)=>{t.exports=ze()})),Ve=n((e=>{var t=g();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),He=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ve()})),Ue=n((e=>{var t=Be(),n=g(),r=He();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function ee(e){return{current:e}}function z(e){0>R||(e.current=L[R],L[R]=null,R--)}function B(e,t){R++,L[R]=e.current,e.current=t}var V=ee(null),te=ee(null),H=ee(null),ne=ee(null);function re(e,t){switch(B(H,t),B(te,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(V),B(V,e)}function ie(){z(V),z(te),z(H)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=V.current,n=Kd(t,e.type);t!==n&&(B(te,e),B(V,n))}function oe(e){te.current===e&&(z(V),z(te)),ne.current===e&&(z(ne),np._currentValue=I)}var se,ce;function le(e){if(se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);se=t&&t[1]||``,ce=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+se+e+ce}var ue=!1;function de(e,t){if(!e||ue)return``;ue=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
5
  `),l=s.split(`
@@ -159,34 +159,34 @@ XID_Start XIDS`.split(/\s/).map(e=>[_h(e),e])),dg=new Map([[`s`,Yh(383)],[Yh(383
159
159
  ]`:`(?>\r
160
160
  ?|[
161
161
  \v\f…\u2028\u2029])`),t));else if(c===`posix`){if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${Yh(e.codePointAt(0)-1)}${Yh(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Lg(Pg(`[${e}]`),t))}else n(Lg(Fg(Pg(mg.get(u)),l),t))}else if(c===`property`)ug.has(_h(u))||(e.key=`sc`);else if(c===`space`)n(Ig(uh(`space`,{negate:l}),t));else if(c===`word`)n(Lg(Fg(Pg(cg),l),t));else throw Error(`Unexpected character set kind "${c}"`)}},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`){if(!c.enable&&!c.disable)r();else{let e=oh({flags:c});e.body[0].body=o(),i(Lg(e,t),{traverse:!0})}}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&Bm(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error(Xh`Uses "\K" in a way that's unsupported`);let o=sh({behind:!0});o.body[0].body=a(),i(Lg(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Lg(sh({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=oh();t.body[0].body.push(e.body),e.body=Lg(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=jg(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error(Xh`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Ng(n)&&(n=Og(n,t),e.ref=n)}},xg={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Ig(Dg(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&eg(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=eg(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=$h(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&(n.type!==`CapturingGroup`||n.name!==a&&n.number!==a););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Dg(0):Eg(o,r.groupOriginByCopy,null),l=c;if(!s){let e=kg(Tee(o,e=>e.type===`Group`&&!!e.flags)),t=e?$h(r.globalFlags,e):r.globalFlags;wg(t,r.currentFlags)||(l=oh({flags:Eee(t)}),l.body[0].body.push(c))}n(Lg(l,t),{traverse:!s})}},Sg={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>Tg(t,e));i.length?i.length>1?n(Lg(oh({atomic:!0,body:i.reverse().map(e=>$m({body:[th(e.number)]}))}),t)):e.ref=i[0].number:n(Lg(sh({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=nh();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Cg(e){bh(e,{"*"({node:e,parent:t}){e.parent=t}})}function wg(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Tg(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=Ag(n.parent);for(let r of t){if(r===n)break;if(r===e||Mg(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Eg(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Eg(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Dg(e){let t=lh(e);return t.isRecursive=!0,t}function Tee(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Og(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function kg(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Eee({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Ag(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function jg(e){let t=e.find(e=>e.kind===`search_start`||kee(e,{negate:!1})||!Dee(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=jg(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Mg(e,t){let n=Ag(e)??[];for(let e of n)if(e===t||Mg(e,t))return!0;return!1}function Dee({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Oee(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function kee(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Bm(e.body[0],{type:`Assertion`,kind:`search_start`})}function Ng(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Pg(e,t){let n=Um(e,{...t,unicodePropertyMap:ug}).body;return n.length>1||n[0].body.length>1?oh({body:n}):n[0].body[0]}function Fg(e,t){return e.negate=t,e}function Ig(e,t){return e.parent=t,e}function Lg(e,t){return Cg(e),e.parent=t,e}function Aee(e,t){let n=ag(t),r=tg(n.target,`ES2024`),i=tg(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];bh(e,jee,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,ng(Mee[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&eg(f._captureTransfers,e.transferTo,[]).push(t)}),f}var jee={"*":{enter({node:e},t){if(Hg(e)){let n=t.getCurrentModI();t.pushModI(e.flags?$h({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Hg(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){zg(Yh(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Bg(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&vg.has(e.value)&&t.setHasCasedChar()}},Mee={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?Xh`\B`:Xh`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=Yh(e),r=Vg(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&zg(n)){let e=lg(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);Zh.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(Ug)&&(o=[rh(45),...o.filter(e=>!Ug(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||Zh.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=oh(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=$m({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(Zh.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=Vg(n,i),o=Vg(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Lee(Bg(e)).forEach(e=>{s.add(Array.isArray(e)?`${Vg(e[0],i)}-${Vg(e[1],i)}`:Vg(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:Xh`[^\n]`;if(e===`digit`)return t?Xh`\D`:Xh`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&vg.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Xh`\P`:Xh`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?Xh`\W`:Xh`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=$h(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${Ree(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+zee(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:Xh`\g<${t}&R=${r}>`}},Nee=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),Pee=new Set([`-`,`\\`,`]`,`^`,`[`]),Fee=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),Rg=new Map([[9,Xh`\t`],[10,Xh`\n`],[11,Xh`\v`],[12,Xh`\f`],[13,Xh`\r`],[8232,Xh`\u2028`],[8233,Xh`\u2029`],[65279,Xh`\uFEFF`]]),Iee=/^\p{Cased}$/u;function zg(e){return Iee.test(e)}function Bg(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=Yh(e);if(!zg(t))continue;let o=lg(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function Vg(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Rg.has(e))return Rg.get(e);if(e<32||e>126&&e<160||e>262143||t&&Bee(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?Fee:Pee:Nee,a=Yh(e);return(i.has(a)?`\\`:``)+a}function Lee(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function Ree(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function zee({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function Hg({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function Bee(e){return e>47&&e<58}function Ug({type:e,value:t}){return e===`Character`&&t===45}var Vee=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=Uee(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(Hee(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=Wee(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function Hee(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function Uee(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)eg(n,t,{}).transferTo=e;return n}function Wee(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function Gee(e,t){let n=Kee(e,t);return n.options?new Vee(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Kee(e,t){let n=ag(t),r=yg(Um(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:ug}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Aee(r,n),a=Uh(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=Nh(Ih(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}function qee(e,t){return Gee(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Wg(e={}){let t={target:`auto`,cache:new Map,...e};return t.regexConstructor||=e=>qee(e,{target:t.target}),{createScanner(e){return new em(e,t)},createString(e){return{content:e}}}}var Jee=[`markdown`,`typescript`,`tsx`,`javascript`,`jsx`,`json`,`css`,`html`,`html-derivative`,`python`,`rust`,`go`,`shellscript`,`yaml`],Gg=null;function Yee(){return Gg??=Qp({themes:[`github-dark`,`github-light`],langs:[...Jee],engine:Wg()}),Gg}var Xee=200,Zee=20971520,Kg=new Map,qg=0;function Qee(e){let t=Kg.get(e);return t!==void 0&&(Kg.delete(e),Kg.set(e,t)),t}function Jg(e,t){if(!Kg.has(e))for(Kg.set(e,t),qg+=t.length*2;(Kg.size>Xee||qg>Zee)&&Kg.size>0;){let e=Kg.keys().next().value;qg-=(Kg.get(e)?.length??0)*2,Kg.delete(e)}}async function Yg(e,t,n=!0){let r=`${t}${e}`;if(n){let e=Qee(r);if(e!==void 0)return e}try{let i=await Yee(),a=i.getLoadedLanguages().includes(t)?t:`text`,o=i.codeToHtml(e,{lang:a,themes:{light:`github-light`,dark:`github-dark`},defaultColor:`light`});return n&&Jg(r,o),o}catch(e){return console.error(`snippet highlight failed:`,e),null}}var Xg={command:Kn,"file-edit":Bt,"file-write":Vt,mcp:En};function Zg({kind:e,summary:t}){let[n,r]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(e!==`command`)return;let n=!0;return Yg(t,`shellscript`).then(e=>{n&&r({summary:t,html:e})}),()=>{n=!1}},[e,t]);let i=n?.summary===t?n.html:null,a=(0,K.jsx)(Fs,{text:t,className:`absolute top-1 right-1 z-10 rounded-md bg-background/80 p-1 text-muted-foreground backdrop-blur`});return e===`command`&&i!=null?(0,K.jsxs)(`div`,{className:`relative mt-1.5`,children:[(0,K.jsx)(`div`,{className:`max-h-24 overflow-auto rounded-md text-xs leading-relaxed [&_pre]:m-0 [&_pre]:py-1.5 [&_pre]:pr-7 [&_pre]:pl-2 [&_pre]:font-mono [&_pre]:whitespace-pre-wrap`,dangerouslySetInnerHTML:{__html:i}}),a]}):(0,K.jsxs)(`div`,{className:`relative mt-1.5`,children:[(0,K.jsx)(`pre`,{className:`max-h-24 overflow-auto rounded-md bg-muted/50 py-1.5 pr-7 pl-2 font-mono text-xs whitespace-pre-wrap`,children:t}),a]})}var Qg={timeout:`Auto-managed review timed out. Please decide.`,error:`Auto-managed review failed. Please decide.`,invalid:`Auto-managed review returned no valid decision. Please decide.`},$g=()=>typeof window>`u`||window.electronAPI?.remote?void 0:window.electronAPI?.dcg,e_={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`};function t_({guard:e}){let{t}=q(),n=e.ruleId===o;return(0,K.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,K.jsxs)(`p`,{className:`text-destructive`,children:[t(e.reason),` `,(0,K.jsx)(`code`,{className:`rounded bg-muted/60 px-1 font-mono text-[10px] text-muted-foreground`,children:e.ruleId})]}),(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:t(n?`Safety floor rule — still requires confirmation in full-access mode. Click Adjust to target a specific subdirectory or session temp folder, or Allow once.`:`Blocked by built-in guard — still requires confirmation in full-access mode. Review the command, click Adjust, or Allow once.`)})]})}function n_({guard:e}){let{t,locale:n}=q(),[r,i]=(0,U.useState)(null),a=e.decision===`warn`,o=e.decision===void 0||e.decision===`deny`,s=ws(e.ruleId),[c,l]=(0,U.useState)(!1);(0,U.useEffect)(()=>{if(!o)return;let t=!0;return l(!1),$g()?.ruleState(e.ruleId).then(n=>{t&&n&&i({ruleId:e.ruleId,state:n})}).catch(()=>{}),()=>{t=!1}},[e.ruleId,o]);let u=r?.ruleId===e.ruleId?r.state:null,d=n===`zh`?bs(e):{what:e.reason};return(0,K.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,K.jsxs)(`p`,{className:a?`text-muted-foreground`:`text-destructive`,title:e.ruleId,children:[e.severity&&(0,K.jsx)(`span`,{className:`mr-1 rounded bg-muted px-1 text-[10px]`,children:t(e_[e.severity])}),t(a?`dcg notice: {{reason}}`:`dcg: {{reason}}`,{reason:d.what}),(0,K.jsx)(`code`,{className:`ml-1 rounded bg-muted/60 px-1 font-mono text-[10px] text-muted-foreground`,children:e.ruleId})]}),!a&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:s?e.decision===`ask`?t(`Guard rule requires confirmation each time — still prompts in full-access mode. Click Adjust for a safer command, or Allow once.`):t(`Triggered by command guard — still prompts in full-access mode. Click Adjust to change the command or path, or manage exemptions in Settings (auto-suggested after 5 allows).`):t(`High-risk safety floor (cannot be exempted) — still requires confirmation in full-access mode. Click Adjust for a safer command or path, or Allow once.`)}),e.matched&&(0,K.jsxs)(`p`,{className:`text-muted-foreground`,children:[t(`Matched`),`:`,` `,(0,K.jsx)(`code`,{className:`rounded bg-muted/60 px-1 font-mono`,children:e.matched})]}),d.why&&(0,K.jsxs)(`p`,{className:`text-muted-foreground`,children:[t(`Why it is dangerous`),`: `,d.why]}),d.alt&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,K.jsxs)(`span`,{children:[t(`Safer alternative`),`:`]}),(0,K.jsx)(`code`,{className:`rounded bg-muted/60 px-1 font-mono`,children:d.alt}),(0,K.jsx)(Fs,{text:d.alt,className:`p-0.5`})]}),e.explanation&&(0,K.jsxs)(`details`,{className:`text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:t(`dcg explanation`)}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.explanation})]}),u?.suggestExempt&&(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-amber-600 dark:text-amber-400`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:t(`Allow "{{rule}}" automatically in new conversations? You can revoke this anytime in Settings.`,{rule:e.ruleId})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{l(!1),$g()?.ruleExempt(e.ruleId).then(t=>{t&&i({ruleId:e.ruleId,state:t})}).catch(()=>{})},className:`font-medium underline underline-offset-2`,children:t(`Confirm exemption`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`text-muted-foreground underline underline-offset-2`,children:t(`Cancel`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:t(`You have allowed this rule {{count}} times. Allow it automatically from now on?`,{count:u.allowCount})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(!0),className:`underline underline-offset-2`,children:t(`Always allow this rule`)})]})}),u?.exempt&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:t(`This rule is allowed automatically in new conversations until dcg is updated.`)})]})}var r_=400;function i_({approvals:e,onRespond:t,allowSession:n=!0,handoff:r=!0,clockOffset:i}){let{t:a}=q(),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(null),u=e[0],d=u?.requestId,f=Is(u?.phase===`reviewing`?void 0:u?.expiresAt,i);if((0,U.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>l(d),r_);return()=>clearTimeout(e)},[d]),!u)return null;let p=Xg[u.kind]??In,m=u.phase===`reviewing`,h=c!==u.requestId||o===u.requestId||f!==void 0&&f<=0,g=e=>{e!==`review`&&s(u.requestId),e===`allow`&&u.guard&&(u.guard.decision===void 0||u.guard.decision===`deny`)&&!u.guard.ruleId.startsWith(`enso.`)&&$g()?.ruleAllowed(u.guard.ruleId).catch(()=>{}),t(u.requestId,e)};return(0,K.jsxs)(`div`,{"data-enso":`approval`,className:`mb-1 rounded-lg border border-border/60 bg-muted/20 px-2.5 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(In,{className:`h-3.5 w-3.5 shrink-0 text-amber-500`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:a(m?`Assistant reviewing…`:`Approval required`)}),(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-muted-foreground`,children:[(0,K.jsx)(p,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate font-mono`,children:u.toolCallId&&Es(u.toolCallId)?`${a(`Isolated sandbox`)} › ${Ns(u.tool,a)}`:Ns(u.tool,a)})]}),u.protected&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-destructive/15 px-1.5 text-[10px] text-destructive`,children:js(u.protected,a)}),(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,K.jsx)(Ls,{remainingMs:f,expiredLabel:`Timed out · denied`}),e.length>1&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`1/`,e.length]})]})]}),u.reviewFallback&&(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-amber-600 dark:text-amber-400`,children:a(Qg[u.reviewFallback])}),u.guard&&(u.guard.ruleId.startsWith(`enso.`)?(0,K.jsx)(t_,{guard:u.guard}):(0,K.jsx)(n_,{guard:u.guard})),u.summary&&(0,K.jsx)(Zg,{kind:u.kind,summary:u.summary}),!m&&(0,K.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-1.5`,children:[r&&u.kind===`command`&&(0,K.jsx)(`button`,{type:`button`,disabled:h,title:a(`Send back for a safer command`),onClick:()=>g(`revise`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:a(`Adjust`)}),r&&(0,K.jsx)(`button`,{type:`button`,disabled:h,title:a(`Let the assistant decide`),onClick:()=>g(`review`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:a(`Assistant review`)}),(0,K.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>g(`deny`),className:`rounded-md px-2.5 py-1 text-xs text-destructive transition-colors hover:bg-destructive/10 disabled:opacity-50`,children:a(`Deny`)}),n&&!u.protected&&!u.mandatory&&(0,K.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>g(`allowSession`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:a(`Always allow this session`)}),(0,K.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>g(`allow`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:a(`Allow`)})]})]})}function a_(e){return e>=0&&e<9?String(e+1):null}function o_(e,t){let n=t===void 0?-1:e?.indexOf(t)??-1;return n>=0?n:0}function s_(e,t,n){return n===`ArrowDown`?Math.min(e+1,t-1):n===`ArrowUp`?Math.max(e-1,0):null}function c_({asks:e,onAnswer:t,clockOffset:n,autoFocus:r=!0}){let{t:i}=q(),a=(0,U.useRef)(null),o=(0,U.useRef)(null),s=(0,U.useRef)([]),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(!1),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(()=>new Set),g=e.filter(e=>e.answered),_=e.find(e=>!e.answered),v=_?.requestId,y=Is(_?.expiresAt,n),b=v!==void 0&&m.has(v),x=_?.options,S=_?.recommended,C=e=>{let t=s.current[e];x&&e<x.length&&t?t.focus():a.current?.focus()};if((0,U.useEffect)(()=>{if(!r||!v||b)return;let e=o_(x,S),t=s.current[e];x&&e<x.length&&t?t.focus():a.current?.focus()},[r,v,b]),(0,U.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=()=>d(e.scrollHeight-e.scrollTop-e.clientHeight>1);t();let n=new ResizeObserver(t);return n.observe(e),e.addEventListener(`scroll`,t,{passive:!0}),()=>{n.disconnect(),e.removeEventListener(`scroll`,t)}},[v,b]),!_)return g.length>0?(0,K.jsx)(l_,{asks:g}):null;let w=f===_.requestId||y!==void 0&&y<=0,T=e=>{e.trim()&&(p(_.requestId),l(``),t(_.requestId,e.trim()))},E=()=>h(e=>e.has(_.requestId)?e:new Set(e).add(_.requestId));return b?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(l_,{asks:g}),(0,K.jsxs)(`button`,{type:`button`,"data-enso":`ask-later`,onClick:()=>h(e=>{let t=new Set(e);return t.delete(_.requestId),t}),className:`mb-1 flex w-full items-center gap-2 rounded-lg border border-dashed border-border/60 px-2.5 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,children:[(0,K.jsx)(ln,{className:`h-3.5 w-3.5 shrink-0 text-blue-500`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:_.question}),e.length>1&&(0,K.jsxs)(`span`,{className:`shrink-0 text-[10px] tabular-nums`,children:[`1/`,e.length]}),(0,K.jsx)(vt,{className:`h-3 w-3 shrink-0`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(l_,{asks:g}),(0,K.jsxs)(`div`,{"data-enso":`ask`,className:`mb-1 flex max-h-[60dvh] min-h-0 flex-col rounded-lg border border-border/60 bg-muted/20 px-2.5 py-2`,onKeyDown:e=>{if(e.nativeEvent.isComposing||w)return;if(e.key===`Escape`){e.preventDefault(),E();return}let t=e.target,n=(x?.length??0)+1,r=t===a.current?n-1:s.current.indexOf(t),i=r>=0?s_(r,n,e.key):null;if(i!==null){e.preventDefault(),C(i);return}if(t instanceof HTMLInputElement&&(t.value.length>0||e.key===`Enter`))return;let o=Number(e.key)-1,c=x?.[o];if(a_(o)&&c){e.preventDefault(),T(c);return}t instanceof HTMLButtonElement&&r>=0&&(e.key===`Process`?a.current?.focus():e.key.length===1&&e.key!==` `&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),l(t=>t+e.key),a.current?.focus()))},children:[(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(ln,{className:`h-3.5 w-3.5 shrink-0 text-blue-500`}),_.relay&&(0,K.jsx)(`span`,{"data-enso":`ask-relay`,className:`min-w-0 rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground [overflow-wrap:anywhere]`,children:i(`Handed to {{name}}`,{name:_.relay.name})}),(0,K.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:E,className:`rounded-md px-1.5 py-0.5 text-[10px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:i(`Later`)}),(0,K.jsx)(Ls,{remainingMs:y,expiredLabel:`Timed out · no answer`}),e.length>1&&(0,K.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`1/`,e.length]})]})]}),(0,K.jsx)(`div`,{ref:o,"data-enso":`ask-question`,className:G(`mt-1.5 min-h-5 min-w-0 overflow-y-auto overscroll-contain text-xs leading-relaxed whitespace-pre-wrap [overflow-wrap:anywhere]`,u&&`[mask-image:linear-gradient(to_bottom,#000_calc(100%_-_1.5rem),transparent)]`),children:_.question}),x&&x.length>0&&(0,K.jsx)(`div`,{"data-enso":`ask-options`,className:`mt-2 flex max-h-[30dvh] shrink-0 flex-col gap-1.5 overflow-y-auto overscroll-contain`,children:x.map((e,t)=>{let n=a_(t);return(0,K.jsxs)(`button`,{ref:e=>{s.current[t]=e},type:`button`,disabled:w,onClick:()=>T(e),className:`flex items-center gap-2 rounded-md border border-border/60 px-2 py-1 text-left text-xs text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus:border-ring focus:bg-muted focus:text-foreground disabled:opacity-50`,children:[n&&(0,K.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center rounded bg-muted font-mono text-[10px] text-muted-foreground`,children:n}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:e}),e===S&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-success/15 px-1.5 text-[10px] text-success`,children:i(`Recommended`)})]},e)})}),(0,K.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`input`,{ref:a,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||e.key===`Enter`&&T(c)},disabled:w,placeholder:i(`Type an answer…`),className:`h-7 min-w-0 flex-1 rounded-md border bg-transparent px-2 text-xs outline-none focus:ring-1 focus:ring-ring disabled:opacity-50`}),(0,K.jsx)(`button`,{type:`button`,disabled:w||!c.trim(),onClick:()=>T(c),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Fn,{className:`h-3.5 w-3.5`})})]})]})]})}function l_({asks:e}){let{t}=q();return e.length===0?null:(0,K.jsx)(`div`,{"data-enso":`ask-settled`,className:`mb-1 space-y-1`,children:e.map(e=>{let n=e.answered;if(!n)return null;let r=n.by===`timeout`?t(`No answer in time`):n.by===`relay`?t(`{{name}} answered: {{answer}}`,{name:n.name??t(`Secretary`),answer:n.answer??``}):t(`Answered: {{answer}}`,{answer:n.answer??``});return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-dashed border-border/60 px-2.5 py-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(ln,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.question}),(0,K.jsx)(`span`,{className:`shrink-0`,children:r})]},e.requestId)})})}var u_=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function d_(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function f_(e){return`nodeType`in e}function p_(e){return e?d_(e)?e:f_(e)?e.ownerDocument?.defaultView??window:window:window}function m_(e){let{Document:t}=p_(e);return e instanceof t}function h_(e){return!d_(e)&&e instanceof p_(e).HTMLElement}function g_(e){return e instanceof p_(e).SVGElement}function __(e){return e?d_(e)?e.document:f_(e)?m_(e)?e:h_(e)||g_(e)?e.ownerDocument:document:document:document}var v_=u_?U.useLayoutEffect:U.useEffect;function y_(e){let t=(0,U.useRef)(e);return v_(()=>{t.current=e}),(0,U.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function b_(e,t){t===void 0&&(t=[e]);let n=(0,U.useRef)(e);return v_(()=>{n.current!==e&&(n.current=e)},t),n}function x_(e){let t=y_(e),n=(0,U.useRef)(null);return[n,(0,U.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}var S_={};function C_(e,t){return(0,U.useMemo)(()=>{if(t)return t;let n=S_[e]==null?0:S_[e]+1;return S_[e]=n,e+`-`+n},[e,t])}function w_(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var T_=w_(-1);function E_(e){return`clientX`in e&&`clientY`in e}function D_(e){if(!e)return!1;let{TouchEvent:t}=p_(e.target);return t&&e instanceof t}function O_(e){if(D_(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return E_(e)?{x:e.clientX,y:e.clientY}:null}var k_;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(k_||={});function A_(){}var j_=Object.freeze({x:0,y:0}),M_;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(M_||={});var N_=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function P_(e){let{EventTarget:t}=p_(e);return e instanceof t?e:__(e)}function F_(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var I_;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(I_||={});function L_(e){e.preventDefault()}function R_(e){e.stopPropagation()}var z_;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(z_||={}),z_.Space,z_.Enter,z_.Esc,z_.Space,z_.Enter,z_.Tab;function B_(e){return!!(e&&`distance`in e)}function V_(e){return!!(e&&`delay`in e)}var H_=class{constructor(e,t,n){n===void 0&&(n=P_(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=__(i),this.documentListeners=new N_(this.document),this.listeners=new N_(n),this.windowListeners=new N_(p_(i)),this.initialCoordinates=O_(r)??j_,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(I_.Resize,this.handleCancel),this.windowListeners.add(I_.DragStart,L_),this.windowListeners.add(I_.VisibilityChange,this.handleCancel),this.windowListeners.add(I_.ContextMenu,L_),this.documentListeners.add(I_.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(V_(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(B_(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(I_.Click,R_,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(I_.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=O_(e)??j_,s=T_(n,o);if(!t&&a){if(B_(a)){if(a.tolerance!=null&&F_(s,a.tolerance))return this.handleCancel();if(F_(s,a.distance))return this.handleStart()}if(V_(a)&&F_(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===z_.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},U_={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},W_=class extends H_{constructor(e){let{event:t}=e,n=__(t.target);super(e,U_,n)}};W_.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var G_={move:{name:`mousemove`},end:{name:`mouseup`}},K_;(function(e){e[e.RightClick=2]=`RightClick`})(K_||={});var q_=class extends H_{constructor(e){super(e,G_,__(e.event.target))}};q_.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==K_.RightClick&&(r?.({event:n}),!0)}}];var J_={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Y_=class extends H_{constructor(e){super(e,J_)}static setup(){return window.addEventListener(J_.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(J_.move.name,e)};function e(){}}};Y_.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var X_;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(X_||={});var Z_;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Z_||={}),M_.Backward,M_.Forward,M_.Backward,M_.Forward;var Q_;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Q_||={});var $_;(function(e){e.Optimized=`optimized`})($_||={});function ev(e){let{callback:t,disabled:n}=e,r=y_(t),i=(0,U.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,U.useEffect)(()=>()=>i?.disconnect(),[i]),i}Q_.WhileDragging,$_.Optimized;var tv={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:A_,draggableNodes:new Map,over:null,measureDroppableContainers:A_},nv=(0,U.createContext)(tv);({...j_});var rv;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(rv||={});var iv=`Droppable`,av={timeout:25};function ov(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=C_(iv),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,U.useContext)(nv),u=(0,U.useRef)({disabled:n}),d=(0,U.useRef)(!1),f=(0,U.useRef)(null),p=(0,U.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...av,...i},_=b_(h??r),v=ev({callback:(0,U.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=x_((0,U.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=b_(t);return(0,U.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,U.useEffect)(()=>(s({type:k_.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:k_.UnregisterDroppable,key:a,id:r})),[r]),(0,U.useEffect)(()=>{n!==u.current.disabled&&(s({type:k_.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}var sv=/["[\]\n]/g;function cv(e,t){return typeof e==`string`?e.replace(sv,` `).replace(/\s+/g,` `).trim().slice(0,t):``}function lv(e){return`[Selected UI element "${cv(e.label,80)}" — path: ${cv(e.path,300)}; text: ${cv(e.text,200)}]`}var uv=/^\[Selected UI element "([^"]*)" — path: (.*); text: (.*)\]$/;function dv(e){let t=uv.exec(e);return t?{label:t[1],path:t[2],text:t[3]}:null}function fv(e,t){if(t.length===0)return[...e];let n=new Set(t);return e.filter(e=>!e.id||!n.has(e.id))}var pv=`pasted-text.txt`;function mv(e){let t=e.replace(/\r\n?/g,`
162
- `).trim();return t.length>=5e4&&t.length<=2e7?t:null}var hv=/@((?:\/|[A-Za-z]:\\)[^\n@]*?[\\/]pasted-text[\\/](?:bot-)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[\\/][0-9a-f]{8}[\\/]pasted-text\.txt)/g;function gv(e){let t=[],n=0;for(let r of e.matchAll(hv))r.index>n&&t.push({type:`text`,text:e.slice(n,r.index)}),t.push({type:`file`,path:r[1]}),n=r.index+r[0].length;return(n<e.length||t.length===0)&&t.push({type:`text`,text:e.slice(n)}),t}var _v=`(?<![A-Za-z0-9_])`,vv=`(?![A-Za-z0-9_])`,yv=(e,t,n)=>({kind:`API_KEY`,rule:e,re:RegExp(`${_v}${t}${vv}`,`g`),keep:n}),bv=/^\{\{[A-Z][A-Z_]*_[a-z2-7]{8}\}\}$/,xv=/^(?:\$\{.*\}|\$[A-Za-z_]\w*|<[^>]*>|%[\w]+%|process\.env\..*|null|nil|none|true|false|undefined|x{3,}|\*{3,}|changeme|password|secret|your[_-].*)$/i,Sv=e=>e.length>=6&&!xv.test(e)&&!bv.test(e),Cv=([e=``])=>/pass|pwd|密码|口令/i.test(e)?`PASSWORD`:/token|令牌/i.test(e)?`TOKEN`:`SECRET`,wv=[{kind:`PRIVATE_KEY`,rule:`pem`,re:/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,keep:0},yv(`openai`,`sk-[A-Za-z0-9_-]{16,}`,/^sk-(?:ant-(?:api\d+-)?|proj-)?/),yv(`stripe`,`[sr]k_(?:live|test)_[A-Za-z0-9]{10,}`,/^[sr]k_(?:live|test)_/),yv(`github`,`gh[opusr]_[A-Za-z0-9]{20,}`,/^gh[opusr]_/),yv(`github`,`github_pat_[A-Za-z0-9_]{20,}`,/^github_pat_/),yv(`gitlab`,`glpat-[A-Za-z0-9_-]{20,}`,/^glpat-/),yv(`google`,`AIza[0-9A-Za-z_-]{35}`,/^AIza/),yv(`slack`,`xox[abprs]-[A-Za-z0-9-]{10,}`,/^xox[abprs]-/),yv(`aws`,`(?:AKIA|ASIA)[0-9A-Z]{16}`,/^(?:AKIA|ASIA)/),yv(`huggingface`,`hf_[A-Za-z0-9]{20,}`,/^hf_/),yv(`groq`,`gsk_[A-Za-z0-9]{20,}`,/^gsk_/),yv(`xai`,`xai-[A-Za-z0-9]{20,}`,/^xai-/),yv(`npm`,`npm_[A-Za-z0-9]{36}`,/^npm_/),yv(`pypi`,`pypi-[A-Za-z0-9_-]{50,}`,/^pypi-/),yv(`digitalocean`,`do[opr]_v1_[a-f0-9]{64}`,/^do[opr]_v1_/),yv(`sendgrid`,`SG\\.[A-Za-z0-9_-]{22}\\.[A-Za-z0-9_-]{43}`,/^SG\./),{kind:`TOKEN`,rule:`jwt`,re:/(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,keep:3},{kind:`TOKEN`,rule:`bearer`,re:/\bBearer\s+([A-Za-z0-9._~+/=-]{16,})/dg,group:1,keep:0},{kind:`PASSWORD`,rule:`url`,re:/:(?<=\b[a-z][a-z0-9+.-]*:)\/\/[^\s/:@]+:([^\s/@]+)@/dgi,group:1,keep:0,validate:e=>!xv.test(e)&&!bv.test(e)},{kind:Cv,rule:`kv`,re:/\b(?<!(?:^|[^A-Za-z0-9_])(?:[A-Za-z0-9]+[_-])+?)(?:[A-Za-z0-9]+[_-])*(api[_-]?key|secret(?:[_-]?key)?|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|passwd|password|pwd|client[_-]?secret|private[_-]?key)["']?\s*[:=]\s*(?:"((?:\\.|[^"\\\n])*)"|'((?:\\.|[^'\\\n])*)'|([^\s"',;{}[\]]+))/dgi,group:-1,keep:0,validate:Sv},{kind:Cv,rule:`cjk`,re:/(密码|口令|密钥|秘钥|令牌)\s*(?:[::=]|为|是)\s*([^\s,。、,;;"'“”‘’]{6,})/dg,group:2,keep:0,validate:Sv}],Tv=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];function Ev(e){let t=Number(e.slice(10,12)),n=Number(e.slice(12,14));return t<1||t>12||n<1||n>31?!1:`10X98765432`[Tv.reduce((t,n,r)=>t+n*Number(e[r]),0)%11]===e[17].toUpperCase()}function Dv(e){let t=0;for(let n=0;n<e.length;n++){let r=Number(e[e.length-1-n]);n%2==1&&(r*=2,r>9&&(r-=9)),t+=r}return t%10==0}var Ov=/(?:^|\.)(?:example\.(?:com|org|net)|example|test|invalid|local|localhost)$/i,kv={email:{kind:`EMAIL`,rule:`email`,re:/(?<![\w.%+-])[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}(?![\w-])/g,keep:0,validate:e=>!/no-?reply/i.test(e)&&!Ov.test(e.slice(e.indexOf(`@`)+1))},phone:{kind:`PHONE`,rule:`cn-mobile`,re:/(?<![\d+])(?:\+?86[- ]?)?1[3-9]\d{9}(?!\d)/g,keep:0},idCard:{kind:`ID_CARD`,rule:`cn-id`,re:/(?<![\dA-Za-z])\d{17}[\dXx](?![\dA-Za-z])/g,keep:0,validate:Ev},bankCard:{kind:`BANK_CARD`,rule:`luhn`,re:/(?<![\d-])\d(?:[ -]?\d){14,18}(?!\d)/g,keep:0,validate:e=>{let t=e.replace(/[ -]/g,``);return!/^(\d)\1+$/.test(t)&&Dv(t)}},ip:{kind:`IP`,rule:`ipv4`,re:/(?<![\d.])(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)(?![\d.])/g,keep:0,validate:e=>!/^(?:127\.|0\.0\.0\.0$|255\.255\.255\.255$)/.test(e)}},Av=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),jv=e=>`${/^\w/.test(e)?_v:``}${Av(e)}${/\w$/.test(e)?vv:``}`;function Mv(e,t){let n=e.map(e=>({kind:`CUSTOM`,rule:`word`,re:new RegExp(jv(e),`gi`),keep:0}));for(let e of t){let t=/^\/(.+)\/([a-z]*)$/s.exec(e);try{n.push(t?{kind:`CUSTOM`,rule:`regex`,re:new RegExp(t[1],`${t[2].replace(/[gyd]/g,``)}g`),keep:0}:{kind:`CUSTOM`,rule:`prefix`,re:RegExp(`${/^\w/.test(e)?_v:``}${Av(e)}[A-Za-z0-9._-]+`,`g`),keep:e.length})}catch{}}return n}function Nv(e){let t=[];if(e.enabled){if(e.secrets.enabled)for(let n of wv)t.push({...n,action:e.secrets.action,category:`secret`});if(e.personal.enabled)for(let n of e.personal.kinds)t.push({...kv[n],action:e.personal.action,category:`personal`});for(let n of Mv(e.custom.words,e.custom.rules))t.push({...n,action:e.custom.action,category:`custom`})}return{active:t.length>0,rules:t,allow:new Set(e.allow.map(e=>e.toLowerCase()))}}var Pv=/\{\{[A-Z][A-Z_]*_[a-z2-7]{8}\}\}/g;function Fv(e,t){let n=t.indices;if(!e.group)return[t.index,t.index+t[0].length];if(n){if(e.group>0)return n[e.group];for(let e=2;e<n.length;e++)if(n[e])return n[e]}}function Iv(e,t){if(!t.active||!e)return[];let n=[];for(let t of e.matchAll(Pv))n.push([t.index,t.index+t[0].length]);let r=[];for(let i of t.rules){i.re.lastIndex=0;for(let a=i.re.exec(e);a;a=i.re.exec(e)){if(a[0].length===0){i.re.lastIndex++;continue}let o=Fv(i,a);if(!o||o[1]<=o[0])continue;let[s,c]=o,l=e.slice(s,c);if(i.validate&&!i.validate(l)||t.allow.has(l.toLowerCase())||n.some(([e,t])=>s<t&&c>e))continue;let u=typeof i.keep==`number`?i.keep:i.keep?.exec(l)?.[0].length??0;r.push({start:s,end:c,kind:typeof i.kind==`string`?i.kind:i.kind([a[1]??``]),rule:i.rule,action:i.action,category:i.category,keep:Math.min(u,l.length)})}}r.sort((e,t)=>e.start-t.start||t.end-e.end);let i=[];for(let e of r)(!i.length||e.start>=i[i.length-1].end)&&i.push(e);return i}function Lv(e,t){let n=Iv(e,Nv(t));return{masked:n.filter(e=>e.action===`mask`).length,blocked:[...new Set(n.filter(e=>e.action===`block`).map(e=>e.kind))]}}var Rv={"/goal":[{name:`pause`,aliases:[],description:`Pause the current session goal`},{name:`resume`,aliases:[],description:`Resume a paused session goal`},{name:`clear`,aliases:[],description:`Clear the session goal`}]};function zv(e,t){if(!e)return null;let n=t.trimStart();return n?n.search(/\s/)>=0?null:n:``}function Bv(e,t){if(!e)return[];let n=Rv[e]??[],r=t.trim().toLowerCase();return r?n.filter(e=>e.name.toLowerCase().startsWith(r)||e.aliases.some(e=>e.toLowerCase().startsWith(r))):n}var Vv=U.createContext(void 0);function Hv(e){let t=U.useContext(Vv);if(!e&&t===void 0)throw Error(Cr(27));return t}var Uv=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),Wv={"data-starting-style":``},Gv={"data-ending-style":``},Kv={transitionStatus(e){return e===`starting`?Wv:e===`ending`?Gv:null}};(function(e){return e.open=`data-open`,e.closed=`data-closed`,e[e.startingStyle=Uv.startingStyle]=`startingStyle`,e[e.endingStyle=Uv.endingStyle]=`endingStyle`,e.anchorHidden=`data-anchor-hidden`,e.side=`data-side`,e.align=`data-align`,e})({});var qv={"data-popup-open":``},Jv={"data-popup-open":``,"data-pressed":``},Yv={"data-open":``},Xv={"data-closed":``},Zv={"data-anchor-hidden":``},Qv={open(e){return e?qv:null}},$v={open(e){return e?Jv:null}},ey={open(e){return e?Yv:Xv},anchorHidden(e){return e?Zv:null}},ty={...ey,...Kv},ny=U.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Hv(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Vr(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:ty,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})});function ry(){return typeof window<`u`}function iy(e){return sy(e)?(e.nodeName||``).toLowerCase():`#document`}function ay(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function oy(e){return((sy(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function sy(e){return ry()?e instanceof Node||e instanceof ay(e).Node:!1}function cy(e){return ry()?e instanceof Element||e instanceof ay(e).Element:!1}function ly(e){return ry()?e instanceof HTMLElement||e instanceof ay(e).HTMLElement:!1}function uy(e){return!ry()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof ay(e).ShadowRoot}function dy(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Sy(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function fy(e){return/^(table|td|th)$/.test(iy(e))}function py(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var my=/transform|translate|scale|rotate|perspective|filter/,hy=/paint|layout|strict|content/,gy=e=>!!e&&e!==`none`,_y;function vy(e){let t=cy(e)?Sy(e):e;return gy(t.transform)||gy(t.translate)||gy(t.scale)||gy(t.rotate)||gy(t.perspective)||!by()&&(gy(t.backdropFilter)||gy(t.filter))||my.test(t.willChange||``)||hy.test(t.contain||``)}function yy(e){let t=wy(e);for(;ly(t)&&!xy(t);){if(vy(t))return t;if(py(t))return null;t=wy(t)}return null}function by(){return _y??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),_y}function xy(e){return/^(html|body|#document)$/.test(iy(e))}function Sy(e){return ay(e).getComputedStyle(e)}function Cy(e){return cy(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wy(e){if(iy(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||uy(e)&&e.host||oy(e);return uy(t)?t.host:t}function Ty(e){let t=wy(e);return xy(t)?(e.ownerDocument||e).body:ly(t)&&dy(t)?t:Ty(t)}function Ey(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ty(e),i=r===e.ownerDocument?.body,a=ay(r);if(i){let e=Dy(a);return t.concat(a,a.visualViewport||[],dy(r)?r:[],e&&n?Ey(e):[])}return t.concat(r,Ey(r,[],n))}function Dy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var Oy={...U},ky=Oy.useInsertionEffect,$ee=ky&&ky!==Oy.useLayoutEffect?ky:e=>e();function Ay(e){let t=Tr(ete).current;return t.next=e,$ee(t.effect),t.trampoline}function ete(){let e={next:void 0,callback:tte,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function tte(){}var X=typeof document<`u`?U.useLayoutEffect:()=>{},nte=U.createContext(void 0);function jy(e=!1){let t=U.useContext(nte);if(t===void 0&&!e)throw Error(Cr(16));return t}function rte(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:U.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function My(e){return e?.ownerDocument||document}function Ny(e,t,{detail:n=0}={}){e.dispatchEvent(new(ay(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Py(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=U.useRef(null),s=jy(!0),c=a??s!==void 0,{props:l}=rte({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=U.useCallback(()=>{let e=o.current;Fy(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:U.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return cr({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(yr(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Fy(r),s=!i&&ite(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),Ny(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Ny(r,e)))},onKeyUp(e){if(!t){if(yr(e),a?.(e),e.target===e.currentTarget&&i&&c&&Fy(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),Ny(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Ay(e=>{o.current=e,u()})}}function Fy(e){return ly(e)&&e.tagName===`BUTTON`}function ite(e){return ly(e)&&e.tagName===`A`&&!!e.href}var Iy=`none`,Ly=`trigger-press`,Ry=`trigger-hover`,zy=`trigger-focus`,ate=`outside-press`,By=`item-press`,ote=`close-press`,Vy=`focus-out`,ste=`escape-key`,Hy=`list-navigation`,Uy=`cancel-open`,Wy=`sibling-open`,Gy=`imperative-action`,cte=`window-resize`;function Ky(e,t,n,r){let i=!1,a=!1,o=r??Lr;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var qy=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=Hv(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Py({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Ky(ote,e.nativeEvent))}return Vr(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),Jy=0;function lte(e,t=`mui`){let[n,r]=U.useState(e),i=e||n;return U.useEffect(()=>{n??(Jy+=1,r(`${t}-${Jy}`))},[n,t]),i}var Yy=Oy.useId;function Xy(e,t){if(Yy!==void 0){let n=Yy();return e??(t?`${t}-${n}`:n)}return lte(e,t)}function Zy(e){return Xy(e,`base-ui`)}var Qy=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Hv(),c=Zy(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Vr(`p`,e,{ref:t,props:[{id:c},o]})});function $y(e){U.useEffect(e,Ir)}var eb=0,tb=class e{static create(){return new e}currentId=eb;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=eb,t()},e)}isStarted(){return this.currentId!==eb}clear=()=>{this.currentId!==eb&&(clearTimeout(this.currentId),this.currentId=eb)};disposeEffect=()=>this.clear};function nb(){let e=Tr(tb.create).current;return $y(e.disposeEffect),e}function ute(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:dte,platform:fte,maxTouchPoints:pte}=ute(),rb=dte.toLowerCase(),ib=fte.toLowerCase(),ab=/^i(os$|p)/.test(ib)||ib===`macintel`&&pte>1,ob=`android`,sb=ib===ob||rb.includes(ob),cb=!ab&&ib.startsWith(`mac`);ib.startsWith(`win`),!sb&&/^(linux|chrome os)/.test(ib);var mte=cb||ab,lb=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!lb&&rb.includes(`firefox`),!lb&&rb.includes(`chrom`);var hte=mte,ub=/jsdom|happydom/.test(rb);function db(e){e.preventDefault(),e.stopPropagation()}function gte(e){return`nativeEvent`in e}function fb(e){return e.pointerType===``&&e.isTrusted?!0:sb&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function pb(e){return ub?!1:!sb&&e.width===0&&e.height===0||sb&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function mb(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function _te(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var vte=`data-base-ui-focusable`,yte=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,hb=`ArrowLeft`,gb=`ArrowRight`,bte=`ArrowUp`,_b=`ArrowDown`;function vb(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function yb(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&uy(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function bb(e){return`composedPath`in e?e.composedPath()[0]:e.target}function xb(e,t){if(!cy(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(`data-trigger-disabled`);for(let[,e]of t.entries())if(yb(e,n))return!e.hasAttribute(`data-trigger-disabled`);return!1}function Sb(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function Cb(e){return e.matches(`html,body`)}function wb(e){return ly(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function Tb(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${yte}`)!=null}function Eb(e){return e?e.getAttribute(`role`)===`combobox`&&wb(e):!1}function Db(e){if(!e||ub)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function Ob(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function kb(e,t){return t!=null&&!mb(t)?0:typeof e==`function`?e():e}function Ab(e,t,n){let r=kb(e,n);return typeof r==`number`?r:r?.[t]}function jb(e){return typeof e==`function`?e():e}function Mb(e,t){return t||e===`click`||e===`mousedown`}function Nb(e){return e?.includes(`mouse`)&&e!==`mousedown`}function Pb(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Fb(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Ib(e){let t=Tr(Lb,e).current;return t.next=e,X(t.effect),t}function Lb(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Rb=null;globalThis.requestAnimationFrame;var zb=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},Bb=class e{static create(){return new e}static request(e){return zb.request(e)}static cancel(e){return zb.cancel(e)}currentId=Rb;request(e){this.cancel(),this.currentId=zb.request(()=>{this.currentId=Rb,e()})}cancel=()=>{this.currentId!==Rb&&(zb.cancel(this.currentId),this.currentId=Rb)};disposeEffect=()=>this.cancel};function Vb(){let e=Tr(Bb.create).current;return $y(e.disposeEffect),e}var Hb={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Ub={...Hb,position:`fixed`,top:0,left:0},Wb={...Hb,position:`absolute`},Gb=U.forwardRef(function(e,t){let[n,r]=U.useState();X(()=>{hte&&lb&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,K.jsx)(`span`,{...e,ref:t,style:Ub,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Kb=Math.min,qb=Math.max,Jb=Math.round,Yb=Math.floor,Xb=e=>({x:e,y:e}),Zb={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Qb(e,t,n){return qb(e,Kb(t,n))}function $b(e,t){return typeof e==`function`?e(t):e}function ex(e){return e.split(`-`)[0]}function tx(e){return e.split(`-`)[1]}function nx(e){return e===`x`?`y`:`x`}function rx(e){return e===`y`?`height`:`width`}function ix(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ax(e){return nx(ix(e))}function ox(e,t,n){n===void 0&&(n=!1);let r=tx(e),i=ax(e),a=rx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=hx(o)),[o,hx(o)]}function sx(e){let t=hx(e);return[cx(e),t,cx(t)]}function cx(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var lx=[`left`,`right`],ux=[`right`,`left`],dx=[`top`,`bottom`],fx=[`bottom`,`top`];function px(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ux:lx:t?lx:ux;case`left`:case`right`:return t?dx:fx;default:return[]}}function mx(e,t,n,r){let i=tx(e),a=px(ex(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(cx)))),a}function hx(e){let t=ex(e);return Zb[t]+e.slice(t.length)}function gx(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function _x(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:gx(e)}function vx(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function yx(e,t){return t<0||t>=e.length}function bx(e,t){return Sx(e.current,{disabledIndices:t})}function xx(e,t){return Sx(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Sx(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Cx(e,a,r));return a}function Cx(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Tx(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function wx(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Tx(e,t=e?Sy(e):null){return!e||!e.isConnected||!t||wx(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Ex=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Dx(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return uy(n)?n.host:null}function Ox(e){for(let t of Array.from(e.children))if(iy(t)===`summary`)return t;return null}function kx(e,t){let n=Ox(t);return!!n&&(e===n||yb(n,e))}function Ax(e){let t=e?iy(e):``;return e!=null&&e.matches(Ex)&&(t!==`summary`||e.parentElement!=null&&iy(e.parentElement)===`details`&&Ox(e.parentElement)===e)&&(t!==`details`||Ox(e)==null)&&(t!==`input`||e.type!==`hidden`)}function jx(e){if(!Ax(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Dx(t)){let n=t!==e,r=iy(t)===`slot`;if(t.hasAttribute(`inert`)||n&&iy(t)===`details`&&!t.open&&!kx(e,t)||t.hasAttribute(`hidden`)||!r&&!Mx(t,n))return!1}return!0}function Mx(e,t){let n=Sy(e);return t?n.display!==`none`:Tx(e,n)}function Nx(e){let t=e.tabIndex;if(t<0){let t=iy(e);if(t===`details`||t===`audio`||t===`video`||ly(e)&&e.isContentEditable)return 0}return t}function Px(e){if(iy(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Fx(e,t){let n=Px(e);if(!n)return!0;let r=t.find(e=>{let t=Px(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Px(e);return t?.name===n.name&&t.form===n.form})===n}function Ix(e){if(ly(e)&&iy(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return ly(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Lx(e,t){Ix(e).forEach(e=>{Ax(e)&&t.push(e),Lx(e,t)})}function Rx(e,t,n){Ix(e).forEach(e=>{ly(e)&&e.matches(t)&&n.push(e),Rx(e,t,n)})}function zx(e){return jx(e)&&Nx(e)>=0}function Bx(e){let t=[];return Lx(e,t),t.filter(jx)}function Vx(e){let t=Bx(e);return t.filter(e=>Nx(e)>=0&&Fx(e,t))}function Hx(e,t){let n=Vx(e),r=n.length;if(r===0)return;let i=vb(My(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Ux(e){return Hx(My(e).body,1)||e}function Wx(e){return Hx(My(e).body,-1)||e}function Gx(e,t){if(!e)return null;let n=Vx(My(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function Kx(e){return Gx(e,1)}function qx(e){return Gx(e,-1)}function Jx(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!yb(n,r)}function Yx(e){Vx(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Xx(e){let t=[];Rx(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Zx(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Zx(e,t.id,n)])}function Qx(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function $x(e){return`data-base-ui-${e}`}var eS=0;function tS(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(eS);function a(){i&&!i()||e?.focus({preventScroll:n})}if(r)return a(),Fr;let o=requestAnimationFrame(a);return eS=o,()=>{eS===o&&(cancelAnimationFrame(o),eS=0)}}var nS={inert:new WeakMap,"aria-hidden":new WeakMap},rS=`data-base-ui-inert`,iS={inert:new WeakSet,"aria-hidden":new WeakSet},aS=new WeakMap,oS=0;function sS(e){return iS[e]}function cS(e){return e?uy(e)?e.host:cS(e.parentNode):null}var lS=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=cS(t);return e.contains(n)?n:null}).filter(e=>e!=null),uS=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},dS=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{iy(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function fS(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=lS(t,e),l=i?dS(t,uS(c),new Set(c)):[],u=[],d=[];if(a){let e=nS[a],n=sS(a);s=n,o=e;let r=lS(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);dS(t,uS(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(aS.get(e)||0)+1;aS.set(e,t),d.push(e),t===1&&e.setAttribute(rS,``)}),oS+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(aS.get(e)||0)-1;aS.set(e,t),t||e.removeAttribute(rS)}),--oS,oS||(nS.inert=new WeakMap,nS[`aria-hidden`]=new WeakMap,iS.inert=new WeakSet,iS[`aria-hidden`]=new WeakSet,aS=new WeakMap)}}function pS(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=My(e[0]).body;return fS(e,a,n,r,{mark:i})}var mS={style:{transition:`none`}},hS=`data-base-ui-click-trigger`,gS={fallbackAxisSide:`none`},_S={fallbackAxisSide:`end`},vS={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},yS=U.createContext(null),bS=()=>U.useContext(yS),xS=$x(`portal`);function SS(e={}){let{ref:t,container:n,componentProps:r=Lr,elementProps:i}=e,a=Xy(),o=bS()?.portalNode,[s,c]=U.useState(null),[l,u]=U.useState(null),d=Ay(e=>{e!==null&&u(e)}),f=U.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(sy(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=Vr(`div`,r,{ref:[t,d],props:[{id:a,[xS]:``},i]}),m=s&&p?Gs.createPortal(p,s):null;return{node:l,nodeId:U.isValidElement(p)?p.props.id:void 0,subtree:m}}var CS=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,...s}=e,{node:c,nodeId:l,subtree:u}=SS({container:o,ref:t,componentProps:e,elementProps:s}),d=U.useRef(null),f=U.useRef(null),p=U.useRef(null),m=U.useRef(null),[h,g]=U.useState(null),_=U.useRef(!1),v=h?.modal,y=h?.open,b=!!h&&!h.modal&&h.open&&!!c;U.useEffect(()=>{if(!c||v)return;function e(e){c&&e.relatedTarget&&Jx(e)&&(e.type===`focusin`?_.current&&=(Xx(c),!1):(Yx(c),_.current=!0))}return Fb(Pb(c,`focusin`,e,!0),Pb(c,`focusout`,e,!0))},[c,v]),X(()=>{!c||y!==!0||!_.current||(Xx(c),_.current=!1)},[y,c]);let x=U.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:p,afterInsideRef:m,portalNode:c,setFocusManagerState:g}),[c]);return(0,K.jsxs)(U.Fragment,{children:[u,(0,K.jsxs)(yS.Provider,{value:x,children:[b&&c&&(0,K.jsx)(Gb,{"data-type":`outside`,ref:d,onFocus:e=>{Jx(e,c)?p.current?.focus():Wx(h?h.domReference:null)?.focus()}}),b&&c&&(0,K.jsx)(`span`,{"aria-owns":l,style:vS}),c&&Gs.createPortal(a,c),b&&c&&(0,K.jsx)(Gb,{"data-type":`outside`,ref:f,onFocus:e=>{Jx(e,c)?m.current?.focus():(Ux(h?h.domReference:null)?.focus(),h?.closeOnFocusOut&&h?.onOpenChange(!1,Ky(`focus-out`,e.nativeEvent)))}})]})]})});function wS(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var TS=class{nodesRef={current:[]};events=wS();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},ES=U.createContext(null),DS=U.createContext(null),OS=()=>U.useContext(ES)?.id||null,kS=e=>{let t=U.useContext(DS);return e??t};function AS(e){let t=Xy(),n=kS(e),r=OS();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function jS(e){let{children:t,id:n}=e,r=OS();return(0,K.jsx)(ES.Provider,{value:U.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function MS(e){let{children:t,externalTree:n}=e,r=Tr(()=>n??new TS).current;return(0,K.jsx)(DS.Provider,{value:r,children:t})}function NS(e){return e==null?e:`current`in e?e.current:e}function PS(e,t){let n=ay(bb(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var FS=20,IS=[];function LS(){IS=IS.filter(e=>e.deref()?.isConnected)}function RS(e){LS(),e&&iy(e)!==`body`&&(IS.push(new WeakRef(e)),IS.length>FS&&(IS=IS.slice(-20)))}function zS(){return LS(),IS[IS.length-1]?.deref()}function BS(e){return e?zx(e)?e:Vx(e)[0]||e:null}function VS(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Bx(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return zx(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function HS(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=Ay(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Eb(_)&&S,w=Ib(i),T=Ib(a),E=Ib(l),D=Ib(g),O=kS(p),k=bS(),A=U.useRef(!1),j=U.useRef(!1),M=U.useRef(!1),N=U.useRef(null),P=U.useRef(``),F=U.useRef(``),I=U.useRef(null),L=U.useRef(null),R=Er(I,f,k?.beforeInsideRef),ee=Er(L,k?.afterInsideRef),z=nb(),B=nb(),V=Vb(),te=k!=null,H=Ob(v),ne=Ay((e=H)=>e?Vx(e):[]),re=Ay(()=>m?.().filter(e=>e!=null)??[]);U.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&yb(H,vb(My(H)))&&ne().length===0&&!C&&db(e)}return Pb(My(H),`keydown`,e)},[r,H,s,C,ne]),U.useEffect(()=>{if(r||!g)return;let e=My(H);function t(){M.current=!1}function n(e){let t=bb(e),n=re(),r=yb(v,t)||yb(_,t)||yb(k?.portalNode,t)||n.some(e=>e===t||yb(e,t));M.current=!r,F.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(j.current=!0,B.start(0,()=>{j.current=!1}))}function i(){F.current=`keyboard`}return Fb(Pb(e,`pointerdown`,n,!0),Pb(e,`pointerup`,t,!0),Pb(e,`pointercancel`,t,!0),Pb(e,`keydown`,i,!0),t)},[r,v,_,H,g,k,B,re]),U.useEffect(()=>{if(r||!c)return;let e=My(H);function t(){j.current=!0,B.start(0,()=>{j.current=!1})}function n(e){let t=bb(e);zx(t)&&(N.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=bb(t);s&&n==null&&i!=null&&yb(v,i)&&RS(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=re(),f=n?.hasAttribute($x(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,NS(d),NS(u)].includes(n),p=!(yb(_,n)||yb(v,n)||yb(n,v)||yb(k?.portalNode,n)||l.some(e=>e===n||yb(e,n))||c.hasMatchingElement(e=>yb(e,n))||f||O&&(Zx(O.nodesRef.current,a).find(e=>yb(e.context?.elements.floating,n)||yb(e.context?.elements.domReference,n))||Qx(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,Ob(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&H&&VS(H),o&&r!==_&&!Tx(i)&&vb(e)===e.body){if(ly(H)&&(H.focus(),o===`popup`)){V.request(()=>{H.focus()});return}let e=ne(),t=N.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||H;ly(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!j.current&&(C||n!==zS())&&(A.current=!0,h.setOpen(!1,Ky(Vy,t)))})}function a(){M.current||(b.current.insideReactTree=!0,z.start(0,()=>{b.current.insideReactTree=!1}))}let l=ly(_)?_:null;if(!(!v&&!l))return Fb(l&&Pb(l,`focusout`,i),l&&Pb(l,`pointerdown`,t),v&&Pb(v,`focusin`,n),v&&Pb(v,`focusout`,i),v&&k&&Pb(v,`focusout`,a,!0))},[r,_,v,H,s,O,k,h,c,o,ne,C,x,b,z,B,V,u,d,re]),U.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${$x(`portal`)}]`)||[]),t=(O?Qx(O.nodesRef.current,x()):[]).find(e=>Eb(e.context?.elements.domReference||null))?.context?.elements.domReference,n=pS([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...re(),t,NS(d),NS(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=pS([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,re]),X(()=>{if(!g||r||!ly(H))return;P.current=``,F.current=``;let e=My(H),t=vb(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||yb(H,t))return;let i=null,a=()=>(i??=ne(H),i[0]||H),o;o=r===!0||r===null?a():NS(r),o||=a();let s=yb(H,vb(e));tS(o,{preventScroll:o===H,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=vb(e);return!(t!==o&&yb(H,t))}})})},[r,g,H,ne,w,E,D]),X(()=>{if(r||!H)return;let e=My(H),t=vb(e),n=E.current==null;RS(t);function i(e){if(e.open||(P.current=PS(e.nativeEvent,F.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(fb(e.nativeEvent)||pb(e.nativeEvent))A.current=!1;else{let e=!1;My(H).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&iy(t)!==`body`?t:null,s=n?o||a:a||o;return s||=zS()||null,typeof i==`boolean`?s:NS(i)||s||null}return()=>{y.off(`openchange`,i);let t=vb(e),n=re(),r=yb(v,t)||n.some(e=>e===t||yb(e,t))||O&&Zx(O.nodesRef.current,x(),!1).some(e=>yb(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s);queueMicrotask(()=>{let n=BS(c),i=typeof o!=`boolean`;if(o&&!A.current&&ly(n)&&(!(!i&&n!==t&&t!==e.body)||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,H,T,E,y,O,_,x,re]),X(()=>{if(!lb||g||!v)return;let e=vb(My(v));!ly(e)||!wb(e)||yb(v,e)&&e.blur()},[g,v]),X(()=>{if(!(r||!k))return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),X(()=>{if(!(r||!H))return VS(H),()=>{queueMicrotask(LS)}},[r,H]);let ie=!r&&(!s||!C)&&(te||s);return(0,K.jsxs)(U.Fragment,{children:[ie&&(0,K.jsx)(Gb,{"data-type":`inside`,ref:R,onFocus:e=>{if(s){let e=ne();tS(e[e.length-1])}else k?.portalNode&&(A.current=!1,Jx(e,k.portalNode)?Ux(_)?.focus():NS(d??k.beforeOutsideRef)?.focus())}}),n,ie&&(0,K.jsx)(Gb,{"data-type":`inside`,ref:ee,onFocus:e=>{s?tS(ne()[0]):k?.portalNode&&(c&&(A.current=!0),Jx(e,k.portalNode)?Wx(_)?.focus():NS(u??k.afterOutsideRef)?.focus())}})]})}function US(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Ly}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=U.useRef(void 0),f=Vb(),p=nb(),m=U.useMemo(()=>{function e(e,t,n,r){let i=Ky(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=mb(e.pointerType,!0)&&pb(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||mb(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=bb(o);if(wb(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}mb(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return U.useMemo(()=>n?{reference:m}:Lr,[n,m])}function WS(){return!1}function GS(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function KS(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=WS,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f}=l.context,p=kS(c),m=Ay(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=Ay(()=>a),{escapeKey:v,outsidePress:y}=GS(s),b=U.useRef(!1),x=U.useRef(!1),S=U.useRef(!1),C=U.useRef(!1),w=U.useRef(``),T=U.useRef(null),E=nb(),D=nb(),O=Ay(()=>{D.clear(),f.current.insideReactTree=!1}),k=Ay(e=>{let t=f.current.floatingContext?.nodeId;return(p?Zx(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),A=Ay(e=>Sb(e,l.select(`floatingElement`))||Sb(e,l.select(`domReferenceElement`))),j=Ay(e=>{o()&&l.setOpen(!1,Ky(Ly,e.nativeEvent))}),M=Ay(e=>{if(!u||!n||!r||e.key!==`Escape`||C.current||!v&&k(`__escapeKeyBubbles`))return;let t=Ky(ste,gte(e)?e.nativeEvent:e);l.setOpen(!1,t),t.isCanceled||e.preventDefault(),!v&&!t.isPropagationAllowed&&e.stopPropagation()}),N=Ay(()=>{f.current.insideReactTree=!0,D.start(0,O)}),P=Ay(e=>{if(!u||!n||e.button!==0)return;let t=bb(e.nativeEvent);yb(l.select(`floatingElement`),t)&&(b.current||(b.current=!0,x.current=!1))}),F=Ay(e=>{!u||!n||(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});U.useEffect(()=>{if(!u||!n)return O;f.current.__escapeKeyBubbles=v,f.current.__outsidePressBubbles=y;let e=new tb,t=new tb;function i(){e.clear(),C.current=!0}function a(){e.start(lb?5:0,()=>{C.current=!1})}function o(){S.current=!0,t.start(0,()=>{S.current=!1})}function s(){b.current=!1,x.current=!1}function c(){let e=w.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=c();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function D(e){let t=f.current.floatingContext?.nodeId,n=p&&Zx(p.nodesRef.current,t).some(t=>Sb(e,t.context?.elements.floating));return A(e)||n}function j(e){if(m(e)){e.type!==`click`&&!A(e)&&(t.clear(),S.current=!1),O();return}if(f.current.insideReactTree){O();return}let n=bb(e),r=`[${$x(`inert`)}]`,i=cy(n)?n.getRootNode():null,a=Array.from((uy(i)?i:My(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>yb(e,n))))return;let s=cy(n)?n:null;for(;s&&!xy(s);){let e=wy(s);if(xy(e)||!cy(e))break;s=e}if(!(a.length&&cy(n)&&!Cb(n)&&!yb(n,l.select(`floatingElement`))&&a.every(e=>!yb(s,e)))){if(ly(n)&&!(`touches`in e)){let t=xy(n),r=Sy(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!D(e)){if(c()===`intentional`&&S.current){t.clear(),S.current=!1;return}typeof h==`function`&&!h(e)||k(`__outsidePressBubbles`)||(l.setOpen(!1,Ky(ate,e)),O())}}}function N(e){c()!==`sloppy`||e.pointerType===`touch`||!l.select(`open`)||!n||A(e)||j(e)}function P(e){if(c()!==`sloppy`||!l.select(`open`)||!n||A(e))return;let t=e.touches[0];t&&(T.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},E.start(1e3,()=>{T.current&&(T.current.dismissOnTouchEnd=!1,T.current.dismissOnMouseDown=!1)}))}function F(e,t){let n=bb(e);if(!n)return;let r=Pb(n,e.type,()=>{t(e),r()})}function I(e){w.current=`touch`,F(e,P)}function L(e){E.clear(),e.type===`pointerdown`&&(w.current=e.pointerType),!(e.type===`mousedown`&&T.current&&!T.current.dismissOnMouseDown)&&F(e,e=>{e.type===`pointerdown`?N(e):j(e)})}function R(e){if(!b.current)return;let n=x.current;if(s(),c()===`intentional`){if(e.type===`pointercancel`){n&&o();return}if(!D(e)){if(n){o();return}typeof h==`function`&&!h(e)||(t.clear(),S.current=!0,O())}}}function ee(e){if(c()!==`sloppy`||!T.current||A(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-T.current.startX),r=Math.abs(t.clientY-T.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(T.current.dismissOnTouchEnd=!0),i>10&&(j(e),E.clear(),T.current=null)}function z(e){F(e,ee)}function B(e){c()!==`sloppy`||!T.current||A(e)||(T.current.dismissOnTouchEnd&&j(e),E.clear(),T.current=null)}function V(e){F(e,B)}let te=My(d),H=Fb(r&&Fb(Pb(te,`keydown`,M),Pb(te,`compositionstart`,i),Pb(te,`compositionend`,a)),g&&Fb(Pb(te,`click`,L,!0),Pb(te,`pointerdown`,L,!0),Pb(te,`pointerup`,R,!0),Pb(te,`pointercancel`,R,!0),Pb(te,`mousedown`,L,!0),Pb(te,`mouseup`,R,!0),Pb(te,`touchstart`,I,!0),Pb(te,`touchmove`,z,!0),Pb(te,`touchend`,V,!0)));return()=>{H(),e.clear(),t.clear(),s(),S.current=!1,O()}},[f,d,r,g,h,u,n,v,y,M,O,_,k,A,p,l,E]);let I=U.useMemo(()=>({onKeyDown:M,onPointerDown:j,onClick:j}),[M,j]),L=U.useMemo(()=>({onKeyDown:M,onPointerDown:F,onMouseDown:F,onClickCapture:N,onMouseDownCapture(e){N(),P(e)},onPointerDownCapture(e){N(),P(e)},onMouseUpCapture:N,onTouchEndCapture:N,onTouchMoveCapture:N}),[M,N,P,F]);return U.useMemo(()=>n?{reference:I,floating:L,trigger:I}:{},[n,I,L])}function qS(e,t,n){let{reference:r,floating:i}=e,a=ix(t),o=ax(t),s=rx(o),c=ex(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=tx(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function JS(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=$b(t,e),p=_x(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=vx(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=vx(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var YS=50,XS=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:JS},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=qS(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<YS&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=qS(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ZS=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=$b(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=ex(r),_=ix(o),v=ex(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[hx(o)]:sx(o)),x=p!==`none`;!d&&x&&b.push(...mx(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ox(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ix(t)||T.every(e=>ix(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ix(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},QS=new Set([`left`,`top`]);async function $S(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ex(n),s=tx(n),c=ix(n)===`y`,l=QS.has(o)?-1:1,u=a&&c?-1:1,d=$b(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var eC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await $S(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},tC=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=$b(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ix(i),p=nx(f),m=u[p],h=u[f],g=(e,t)=>Qb(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},nC=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=$b(e,t),u={x:n,y:r},d=ix(i),f=nx(d),p=u[f],m=u[d],h=$b(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=QS.has(ex(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},rC=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=$b(e,t),c=await i.detectOverflow(t,s),l=ex(n),u=tx(n),d=ix(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Kb(p-c[m],g),y=Kb(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*qb(c.left,c.right):S=p-2*qb(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function iC(e){let t=Sy(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ly(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Jb(n)!==a||Jb(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function aC(e){return cy(e)?e:e.contextElement}function oC(e){let t=aC(e);if(!ly(t))return Xb(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=iC(t),o=(a?Jb(n.width):n.width)/r,s=(a?Jb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var sC=Xb(0);function cC(e){let t=ay(e);return!by()||!t.visualViewport?sC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lC(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===ay(e)}function uC(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=aC(e),o=Xb(1);t&&(r?cy(r)&&(o=oC(r)):o=oC(e));let s=lC(a,n,r)?cC(a):Xb(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=ay(a),t=cy(r)?ay(r):r,n=e,i=Dy(n);for(;i&&t!==n;){let e=oC(i),t=i.getBoundingClientRect(),r=Sy(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=ay(i),i=Dy(n)}}return vx({width:u,height:d,x:c,y:l})}function dC(e,t){let n=Cy(e).scrollLeft;return t?t.left+n:uC(oy(e)).left+n}function fC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-dC(e,n),y:n.top+t.scrollTop}}function pC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=oy(r),s=t?py(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Xb(1),u=Xb(0),d=ly(r);if((d||!a)&&((iy(r)!==`body`||dy(o))&&(c=Cy(r)),d)){let e=uC(r);l=oC(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?fC(o,c):Xb(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function mC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function hC(e){let t=Cy(e),n=e.ownerDocument.body,r=qb(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=qb(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+dC(e),o=-t.scrollTop;return Sy(n).direction===`rtl`&&(a+=qb(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var gC=25;function _C(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=ay(e),a=oy(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!by()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(dC(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=gC&&(s-=o)}return{width:s,height:c,x:l,y:u}}function vC(e,t){let n=uC(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=oC(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function yC(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=_C(e,n,t);else if(t===`document`)r=hC(oy(e));else if(cy(t))r=vC(t,n);else{let n=cC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return vx(r)}function bC(e,t){let n=t.get(e);if(n)return n;let r=Ey(e,[],!1).filter(e=>cy(e)&&iy(e)!==`body`),i=null,a=Sy(e).position===`fixed`,o=a?wy(e):e;for(;cy(o)&&!xy(o);){let e=Sy(o),t=vy(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=wy(o)}return t.set(e,r),r}function xC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?py(t)?[]:bC(t,this._c):[].concat(n),r],o=yC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=yC(t,a[e],i);s=qb(n.top,s),c=Kb(n.right,c),l=Kb(n.bottom,l),u=qb(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function SC(e){let{width:t,height:n}=iC(e);return{width:t,height:n}}function CC(e,t,n){let r=ly(t),i=oy(t),a=n===`fixed`,o=uC(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Xb(0);if((r||!a)&&((iy(t)!==`body`||dy(i))&&(s=Cy(t)),r)){let e=uC(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=dC(i));let l=i&&!r&&!a?fC(i,s):Xb(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function wC(e){return Sy(e).position===`static`}function TC(e,t){if(!ly(e)||Sy(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return oy(e)===n&&(n=n.ownerDocument.body),n}function EC(e,t){let n=ay(e);if(py(e))return n;if(!ly(e)){let t=wy(e);for(;t&&!xy(t);){if(cy(t)&&!wC(t))return t;t=wy(t)}return n}let r=TC(e,t);for(;r&&fy(r)&&wC(r);)r=TC(r,t);return r&&xy(r)&&wC(r)&&!vy(r)?n:r||yy(e)||n}var DC=async function(e){let t=this.getOffsetParent||EC,n=this.getDimensions,r=await n(e.floating);return{reference:CC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function OC(e){return Sy(e).direction===`rtl`}var kC={convertOffsetParentRelativeRectToViewportRelativeRect:pC,getDocumentElement:oy,getClippingRect:xC,getOffsetParent:EC,getElementRects:DC,getClientRects:mC,getDimensions:SC,getScale:oC,isElement:cy,isRTL:OC};function AC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jC(e,t,n){let r=null,i,a=oy(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Yb(d),h=Yb(a.clientWidth-(u+f)),g=Yb(a.clientHeight-(d+p)),_=Yb(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:qb(0,Kb(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!AC(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=ay(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function MC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=aC(e),u=i||a?[...l?Ey(l):[],...t?Ey(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?jC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?uC(e):null;c&&g();function g(){let t=uC(e);h&&!AC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var NC=eC,PC=tC,FC=ZS,IC=rC,LC=nC,RC=(e,t,n)=>{let r=new Map,i=n??{},a={...kC,...i.platform,_c:r};return XS(e,t,{...i,platform:a})},zC=typeof document<`u`?U.useLayoutEffect:function(){};function BC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!BC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!BC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function VC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function HC(e,t){let n=VC(e);return Math.round(t*n)/n}function UC(e){let t=U.useRef(e);return zC(()=>{t.current=e}),t}function WC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=U.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=U.useState(r);BC(f,r)||p(r);let[m,h]=U.useState(null),[g,_]=U.useState(null),v=U.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=U.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=U.useRef(null),C=U.useRef(null),w=U.useRef(u),T=c!=null,E=UC(c),D=UC(i),O=UC(l),k=U.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),RC(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!BC(w.current,t)&&(w.current=t,Gs.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);zC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=U.useRef(!1);zC(()=>(A.current=!0,()=>{A.current=!1}),[]),zC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=U.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=U.useMemo(()=>({reference:b,floating:x}),[b,x]),N=U.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=HC(M.floating,u.x),r=HC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...VC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return U.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var GC=(e,t)=>{let n=NC(e);return{name:n.name,fn:n.fn,options:[e,t]}},KC=(e,t)=>{let n=PC(e);return{name:n.name,fn:n.fn,options:[e,t]}},qC=(e,t)=>({fn:LC(e).fn,options:[e,t]}),JC=(e,t)=>{let n=FC(e);return{name:n.name,fn:n.fn,options:[e,t]}},YC=(e,t)=>{let n=IC(e);return{name:n.name,fn:n.fn,options:[e,t]}};function XC(e,t,n,r){return{left:e,top:t,right:n,bottom:r,x:e,y:t,width:n-e,height:r-t}}function ZC(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function QC(e){let t=[],n,r=1/0,i=1/0,a=-1/0,o=-1/0;for(let s of Array.from(e).sort((e,t)=>e.top-t.top)){if(r=Math.min(r,s.left),i=Math.min(i,s.top),a=Math.max(a,s.right),o=Math.max(o,s.bottom),!n||s.top-n.top>n.height/2)t.push(ZC(s));else{let e=t[t.length-1];e.left=Math.min(e.left,s.left),e.right=Math.max(e.right,s.right),e.bottom=Math.max(e.bottom,s.bottom),e.width=e.right-e.left,e.height=e.bottom-e.top}n=s}return{lines:t,fallback:XC(r,i,a,o)}}function $C(e,t,n){return e.findIndex(e=>t>e.left-2&&t<e.right+2&&n>e.top-2&&n<e.bottom+2)}function ew(e){return XC(e.left,e.top,e.right,e.bottom)}function tw(e,t,n){let{lines:r}=QC(e.getClientRects());if(r.length<2)return;let i=$C(r,t,n);return{x:t,y:n,lineIndex:i===-1?void 0:i,element:e}}function nw(e,t,n){let{lines:r,fallback:i}=QC(e.getClientRects());if(r.length<2)return null;let a=n?.x,o=n?.y,s=t[0];if(n?.lineIndex!=null&&r[n.lineIndex])return ew(r[n.lineIndex]);if(a!=null&&o!=null){let e=$C(r,a,o);if(e!==-1)return ew(r[e])}if(r.length===2&&r[0].left>r[1].right&&a!=null&&o!=null)return i;if(s===`t`||s===`b`){let e=r[0],t=r[r.length-1],n=s===`t`?e:t;return XC(n.left,e.top,n.right,t.bottom)}let c=s===`l`,l=r[0].left,u=r[0].right,d=c?1/0:-1/0,f=r[0],p=r[0];for(let e of r){l=Math.min(l,e.left),u=Math.max(u,e.right);let t=c?e.left:e.right;c&&t<d||!c&&t>d?(d=t,f=e,p=e):t===d&&(p=e)}return XC(l,f.top,u,p.bottom)}function rw(e){return`contextElement`in e&&e.contextElement?e.contextElement:cy(e)?e:void 0}function iw(e,t){function n(t){aw(e,t.currentTarget,t.clientX,t.clientY)}function r(e){t||n(e)}return{onFocus(){e.current=void 0},onMouseEnter:r,onMouseMove:r}}function aw(e,t,n,r){let i=tw(t,n,r);return e.current=i,i}function ow(e){return{name:`inline`,async fn(t){let n=t.elements.reference;if(typeof n?.getClientRects!=`function`)return{};let r=rw(n),i=e.current,a=i?.element===n||i?.element===r?i:void 0,o=nw(n,t.placement,a);if(!o||typeof t.platform.getElementRects!=`function`)return{};let s=await t.platform.getElementRects({reference:{contextElement:r,getBoundingClientRect(){return o}},floating:t.elements.floating,strategy:t.strategy});return t.rects.reference.x===s.reference.x&&t.rects.reference.y===s.reference.y&&t.rects.reference.width===s.reference.width&&t.rects.reference.height===s.reference.height?{}:{reset:{rects:s}}}}}var sw=n((e=>{var t=g();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),cw=n(((e,t)=>{t.exports=sw()})),lw=n((e=>{var t=g(),n=cw();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),uw=n(((e,t)=>{t.exports=lw()})),dw=[],fw=void 0;function pw(){return fw}function mw(e){dw.push(e)}function hw(e){let t=(t,n)=>{let r=Tr(_w).current,i;try{fw=r;for(let e of dw)e.before(r);i=e(t,n);for(let e of dw)e.after(r);r.didInitialize=!0}finally{fw=void 0}return i};return t.displayName=e.displayName||e.name,t}function gw(e){return U.forwardRef(hw(e))}function _w(){return{didInitialize:!1}}var vw=cw(),yw=uw(),bw=Nr(19)?Cw:ww;function xw(e,t,n,r,i){return bw(e,t,n,r,i)}function Sw(e,t,n,r,i){let a=U.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,vw.useSyncExternalStore)(e.subscribe,a,a)}mw({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,vw.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Cw(e,t,n,r,i){let a=pw();if(!a)return Sw(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function ww(e,t,n,r,i){return(0,yw.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var xte=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return xw(this,e,t,n,r)}},Tw=class extends xte{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){U.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;X(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){U.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return U.useDebugValue(e),xw(this,this.selectors[e],t,n,r)}useContextCallback(e,t){U.useDebugValue(e);let n=Ay(t??Fr);this.context[e]=n}useStateSetter(e){let t=U.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},Ste={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},Ew=class extends Tw{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:wS(),nested:n,triggerElements:i},Ste),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&_te(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Dw(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=U.useRef(null);r===void 0&&f.current===null&&(f.current=new Ew({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};cy(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function Ow(e,t=!1,n=!1){let[r,i]=U.useState(e&&t?`idle`:void 0),[a,o]=U.useState(e);return e&&!a&&(o(!0),i(`starting`)),!e&&a&&r!==`ending`&&!n&&i(`ending`),!e&&!a&&r===`ending`&&i(void 0),X(()=>{if(!e&&a&&r!==`ending`&&n){let e=Bb.request(()=>{i(`ending`)});return()=>{Bb.cancel(e)}}},[e,a,r,n]),X(()=>{if(!e||t)return;let n=Bb.request(()=>{i(void 0)});return()=>{Bb.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&a&&r!==`idle`&&i(`starting`);let n=Bb.request(()=>{i(`idle`)});return()=>{Bb.cancel(n)}},[t,e,a,r]),{mounted:a,setMounted:o,transitionStatus:r}}function kw(e,t=!1){let n=Vb();return Ay((r,i=null)=>{n.cancel();let a=NS(e);if(a==null)return;let o=a,s=()=>{Gs.flushSync(r)};if(typeof o.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){r();return}function c(){Promise.all(o.getAnimations().map(e=>e.finished)).then(()=>{i?.aborted||s()},()=>{if(!i?.aborted){if(o.getAnimations().some(e=>e.pending||e.playState!==`finished`)){c();return}s()}})}if(t){let e=`data-starting-style`;if(!o.hasAttribute(e)){n.request(c);return}let t=new MutationObserver(()=>{o.hasAttribute(e)||(t.disconnect(),c())});t.observe(o,{attributes:!0,attributeFilter:[e]}),i?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}n.request(c)})}function Aw(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=Ay(i),o=kw(r,n);U.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var jw={tabIndex:-1,[vte]:``};function Mw(e){return t=>t!==`touch`||e.current}function Nw(e,t=!1){let n=Xy(),r=OS()!=null,i=Tr(()=>e(n,r)).current;return Dw({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Pw({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function Cte(e,t){let n=U.useRef(null),r=U.useRef(null);return U.useCallback(i=>{if(e===void 0)return;let a=!1;if(n.current!==null){let e=n.current,i=r.current,o=t.context.triggerElements.getById(e);i&&o===i&&(t.context.triggerElements.delete(e),a=!0),n.current=null,r.current=null}if(i!==null&&(n.current=e,r.current=i,t.context.triggerElements.add(e,i),a=!0),a){let e=t.context.triggerElements.size;t.select(`open`)&&t.state.triggerCount!==e&&t.set(`triggerCount`,e)}},[t,e])}function Fw(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);let i=n?.id??null;(i||t)&&(e.activeTriggerId=i,e.activeTriggerElement=n??null)}function Iw(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function wte(e,t,n,r={}){let i=n.reason,a=i===Ry,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=Iw(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i={...r.extraState,open:t};o?i.instantType=`focus`:s?i.instantType=`dismiss`:a&&(i.instantType=void 0),Fw(i,t,n.trigger,c()),e.update(i)};a?Gs.flushSync(l):l()}function Lw(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Cte(e,n),o=Ay(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){n.update({activeTriggerElement:t,...i?r:null});return}a==null&&i&&n.update({activeTriggerId:e,activeTriggerElement:t,...r})}),s=U.useCallback(e=>{a(e),e&&o(e)},[a,o]);return X(()=>{i&&n.update({activeTriggerElement:t.current,...r})},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Rw(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=U.useRef(null),i=e.useState(`open`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Ky(Iy);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function zw(e,t,n){let{mounted:r,setMounted:i,transitionStatus:a}=Ow(e),o=t.useState(`preventUnmountingOnClose`),s=!e&&o;t.useSyncedValues({mounted:r,transitionStatus:a,preventUnmountingOnClose:s});let c=Ay(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return Aw({enabled:r&&!e&&!s,open:e,ref:t.context.popupRef,onComplete(){e||c()}}),{forceUnmount:c,transitionStatus:a}}function Bw(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:Lr,inactiveTriggerProps:Lr,popupProps:Lr})},[e])}function Vw(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Hw=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Tte(){return new Ew({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Hw,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function Uw(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:Tte(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Lr,inactiveTriggerProps:Lr,popupProps:Lr}}function Ww(e,t,n=!1){return new Ew({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var Gw=e=>e.triggerIdProp??e.activeTriggerId,Kw=e=>e.openProp??e.open,qw=e=>(e.popupElement?.id??e.floatingId)||void 0;function Jw(e,t){return t!==void 0&&Kw(e)&&Gw(e)===t}function Ete(e,t){return Jw(e,t)?!0:t!==void 0&&Kw(e)&&Gw(e)==null&&e.triggerCount===1}var Yw={open:Kw,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Gw,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:qw,isTriggerActive:(e,t)=>t!==void 0&&Gw(e)===t,isOpenedByTrigger:(e,t)=>Jw(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Gw(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Ete(e,t)?qw(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Xw(e){let t=U.useCallback(t=>e===void 0?Fr:e.subscribeStore(t),[e]),n=U.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,vw.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Dte(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Xy(),a=OS()!=null,o=Tr(()=>new Ew({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Hw,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=cy(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function Ote(e){return kte(e,e.rootContext)}function kte(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=U.useState(null),[d,f]=U.useState(void 0),[p,m]=U.useState(void 0),h=U.useRef(null),g=kS(r),_=U.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=WC({...e,elements:{..._,...l&&{reference:l}}}),y=cy(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=U.useCallback(e=>{let t=cy(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=U.useCallback(e=>{(cy(e)||e===null)&&(h.current=e,f(e)),(cy(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!cy(e))&&v.refs.setReference(e)},[v.refs,f]),C=U.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=U.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=U.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=U.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return X(()=>{o&&(h.current=o)},[o]),X(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),U.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var Zw=cb&&lb;function Qw(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=U.useRef(!1),c=U.useRef(null),l=U.useRef(!0),u=nb();U.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ay(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&ly(e)&&e===vb(My(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return Fb(Pb(t,`blur`,r),Zw&&Pb(t,`keydown`,a,!0),Zw&&Pb(t,`pointerdown`,o,!0))},[i,n]),U.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);cy(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=U.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=bb(t.nativeEvent);if(cy(a)){if(Zw&&!t.relatedTarget){if(!l.current&&!wb(a))return}else if(!Db(a))return}let o=xb(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Ky(zy,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,Ky(zy,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=cy(n)&&n.hasAttribute($x(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=vb(My(e));!n&&t===e||yb(o.current.floatingContext?.refs.floating.current,t)||yb(e,t)||a||xb(n??t,i.context.triggerElements)||i.setOpen(!1,Ky(zy,r))})}}},[o,r,i,u]);return U.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var Ate=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new tb,this.restTimeout=new tb,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},$w=new WeakMap;function eT(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&$w.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),$w.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function tT(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=$w.get(n);a&&a!==e&&eT(a),eT(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,$w.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function nT(e){let t=e.context.dataRef.current,n=Tr(()=>t.hoverInteractionState??Ate.create()).current;return t.hoverInteractionState||=n,$y(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function rT(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=kS(),d=OS(),f=nT(a),p=nb(),m=Ay(()=>Mb(l.current.openEvent?.type,f.interactedInside)),h=Ay(()=>Nb(l.current.openEvent?.type)),g=Ay(()=>{eT(f)});X(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),U.useEffect(()=>g,[g]),X(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&cy(c)&&s){let e=c,t=s,n=My(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return tT(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),U.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&Zx(u.nodesRef.current,d).length>0)}function t(e){let t=Ab(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,Ky(Ry,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=bb(e);if(!Tb(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(xb(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&cy(o)&&Zx(u.nodesRef.current,r,!1).some(e=>yb(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){!u||!d||e()||p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,Ky(Ry,t)),u.events.emit(`floating.closed`,t)})}let y=s;return Fb(y&&Pb(y,`mouseenter`,c),y&&Pb(y,`mouseleave`,_),y&&Pb(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}var jte={current:null};function iT(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=jte,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=kS(l),y=nT(h),b=U.useRef(!1),x=Ib(i),S=Ib(r),C=Ib(o),w=Ib(n),T=Ib(p),E=Ib(f),D=Ay(()=>Mb(g.current.openEvent?.type,y.interactedInside)),O=Ay(()=>T.current?.()!==!1),k=Ay((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!yb(e,t);if(!cy(n))return!1;let i=n;return r.hasMatchingElement(e=>yb(e,i))&&(!e||!yb(e,i))}),A=Ay(()=>{y.handler&&=(My(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=Ay(()=>{eT(y)});return u&&(y.handleCloseOptions=x.current?.__options),U.useEffect(()=>A,[A]),U.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===Ry,A(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,A]),U.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Ab(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,Ky(Ry,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,Ky(Ry,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!cy(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!mb(y.pointerType))return;let t=jb(C.current),n=Ab(S.current,`open`,y.pointerType),r=bb(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(cy(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(yb(e,r)){s=e;break}}cy(i)&&cy(o)&&!h.context.triggerElements.hasElement(i)&&yb(i,o)&&(s=o);let c=s!=null&&k(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&cy(s)&&cy(o)&&yb(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){O()&&h.setOpen(!0,Ky(Ry,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&O()&&h.setOpen(!0,Ky(Ry,e,s))}):g&&O()&&h.setOpen(!0,Ky(Ry,e,s)))}function i(t){if(D()){j();return}A();let n=My(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!xb(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){j(),A(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!yb(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){yb(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?Pb(t,`mouseout`,o):void 0;return s?Fb(Pb(t,`mousemove`,r,{once:!0}),Pb(t,`mouseenter`,r),Pb(t,`mouseleave`,i),l):Fb(Pb(t,`mouseenter`,r),Pb(t,`mouseleave`,i),l)},[A,j,g,S,h,n,x,y,u,k,D,a,s,C,c,v,w,d,E,O,m]),U.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=k(r,n,e.target);if(a&&!mb(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;tT(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=jb(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&O()&&h.setOpen(!0,Ky(Ry,t,n))}y.pointerType===`touch`?Gs.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,k,a,h,C,O])}var Mte=`Escape`;function aT(e){return lb&&e.movementX===0&&e.movementY===0}function oT(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function sT(e,t){return oT(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function cT(e,t,n){return oT(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Nte(e,t,n){return oT(t,n?e===hb:e===gb,e===_b)}function Pte(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===Mte:oT(t,n?e===gb:e===hb,e===bte)}function lT(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=Ob(T),k=Eb(E),A=Ib(O),j=OS(),M=kS(b),N=U.useRef(f),P=U.useRef(o??-1),F=U.useRef(null),I=U.useRef(!0),L=Ay(e=>{i(P.current===-1?null:P.current,e)}),R=U.useRef(!!T),ee=U.useRef(w),z=U.useRef(!1),B=U.useRef(!1),V=U.useRef(null),te=Ib(h),H=Ib(w),ne=Ib(o),re=Ib(y),ie=Vb(),ae=Vb(),oe=Ay(()=>{function e(e){d?M?.events.emit(`virtualfocus`,e):V.current=tS(e,{sync:z.current,preventScroll:!0})}let t=n.current[P.current],r=B.current;t&&e(t),(z.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),fe&&(r||!I.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{D.current.orientation=g},[D,g]),X(()=>{a&&(w&&T?(P.current=o??-1,N.current&&o!=null&&(B.current=!0,L())):R.current&&(P.current=-1,L()))},[a,w,T,o,L]),X(()=>{if(a){if(!w){z.current=!1;return}if(T){if(r==null){if(z.current=!1,ne.current!=null)return;if(R.current&&(P.current=-1,oe()),(!ee.current||!R.current)&&N.current&&(F.current!=null||N.current===!0&&F.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ae.request(e):queueMicrotask)(t),e+=1):(P.current=F.current==null||cT(F.current,g,u)||l?bx(n):xx(n),F.current=null,L())};t()}}else yx(n.current,r)||(P.current=r,oe(),B.current=!1)}}},[a,w,T,r,ne,l,n,g,u,L,oe,ae]),X(()=>{if(!a||T||!M||d||!R.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=vb(My(E??t??null)),r=e.some(e=>e.context&&yb(e.context.elements.floating,n));t&&!r&&I.current&&t.focus({preventScroll:!0})},[a,T,E,M,j,d]),X(()=>{ee.current=w,R.current=!!T}),X(()=>{w||(F.current=null,N.current=f)},[w,f]);let se=r!=null,ce=Ay(e=>{if(!H.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,L(e))}),le=Ay(()=>_??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation),ue=Ay(()=>bx(n,te.current)),de=Ay(e=>{if(I.current=!1,z.current=!0,e.which===229||!H.current&&e.currentTarget===A.current)return;if(l&&Pte(e.key,g,u,S)){sT(e.key,le())||db(e),C.setOpen(!1,Ky(Hy,e.nativeEvent)),ly(E)&&(d?M?.events.emit(`virtualfocus`,E):E.focus());return}let t=P.current,r=bx(n,h),i=xx(n,h);if(k||(e.key===`Home`&&(db(e),P.current=r,L(e)),e.key===`End`&&(db(e),P.current=i,L(e))),x!=null){let t=x(e,P.current,n,g,c,u,h,r,i);if(t!=null&&(P.current=t,L(e)),g===`both`)return}if(sT(e.key,g)){if(db(e),w&&!d&&vb(e.currentTarget.ownerDocument)===e.currentTarget){P.current=cT(e.key,g,u)?r:i,L(e);return}cT(e.key,g,u)?c?t>=i?s&&t!==n.current.length?P.current=-1:(z.current=!1,P.current=r):P.current=Sx(n.current,{startingIndex:t,disabledIndices:h}):P.current=Math.min(i,Sx(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?P.current=n.current.length:(z.current=!1,P.current=i):P.current=Sx(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):P.current=Math.max(r,Sx(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),yx(n.current,P.current)&&(P.current=-1),L(e)}}),fe=U.useMemo(()=>({onFocus(e){z.current=!0,ce(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){aT(e)||(z.current=!0,B.current=!1,p&&ce(e))},onPointerLeave(e){if(!H.current||!I.current||e.pointerType===`touch`)return;z.current=!0;let t=e.relatedTarget;if(!(!p||n.current.includes(t))&&re.current&&(V.current?.(),V.current=null,P.current=-1,L(e),!d)){let e=A.current,t=vb(My(e));e&&yb(e,t)&&e.focus({preventScroll:!0})}}}),[ce,H,A,p,n,L,re,d]),pe=U.useMemo(()=>d&&w&&se&&{"aria-activedescendant":`${v}-${r}`},[d,w,se,v,r]),me=U.useMemo(()=>({"aria-orientation":g===`both`?void 0:g,...k?{}:pe,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=bb(e.nativeEvent);if(t&&!yb(A.current,t))return;db(e),C.setOpen(!1,Ky(Vy,e.nativeEvent)),ly(E)&&E.focus();return}de(e)},onPointerMove(e){aT(e)||(I.current=!0)}}),[pe,de,A,g,k,C,w,d,E]),he=U.useMemo(()=>{function e(e){C.setOpen(!0,Ky(Hy,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&fb(e.nativeEvent)&&(N.current=!d)}function n(e){N.current=f,f===`auto`&&pb(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(t){let n=C.select(`open`);I.current=!1;let r=t.key.startsWith(`Arrow`),i=Nte(t.key,le(),u),a=sT(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return de(t);if(!(!n&&!m&&r)){if(o){let e=sT(t.key,le());F.current=l&&e?null:t.key}if(l){i&&(db(t),n?(P.current=ue(),L(t)):e(t));return}a&&(ne.current!=null&&(P.current=ne.current),db(t),!n&&m?e(t):de(t),n&&L(t))}},onFocus(e){C.select(`open`)&&!d&&(P.current=-1,L(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,f,ue,l,L,C,m,g,le,u,ne,d]),ge=U.useMemo(()=>({...pe,...he}),[pe,he]);return U.useMemo(()=>a?{reference:ge,floating:me,item:fe,trigger:he}:{},[a,ge,me,he,fe])}function uT(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=nb(),m=U.useRef(``),h=U.useRef(u??i??-1),g=U.useRef(null),_=Ay(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Tx(n)||n?.matches(`:disabled`)?!1:o==null||!Cx(Ir,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(i)||!c(n)))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(db(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(db(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Ay(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);yb(n,t)||yb(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});X(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=U.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return U.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var dT=.1,Fte=dT*dT,fT=.5;function pT(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function mT(e,t,n,r,i,a,o,s,c,l){let u=!1;return pT(e,t,n,r,i,a)&&(u=!u),pT(e,t,i,a,o,s)&&(u=!u),pT(e,t,o,s,c,l)&&(u=!u),pT(e,t,c,l,n,r)&&(u=!u),u}function Ite(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function hT(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function gT(e={}){let{blockPointerEvents:t=!1}=e,n=new tb,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*Fte;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=bb(r),g=r.type===`mouseleave`,_=yb(u,h),v=yb(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&cy(r.relatedTarget)&&yb(u,r.relatedTarget))return;function y(){return!!(s&&Zx(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=hT(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=hT(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=hT(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=hT(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Ite(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?fT/2:fT*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+fT+1,o=C||T?S.bottom-fT:S.top,s=C?T?S.bottom-fT:S.top:S.bottom-fT;M=mT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?fT/2:fT*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-fT,o=C||T?S.top+fT:S.bottom,s=C?T?S.top+fT:S.bottom:S.top+fT;M=mT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?fT/2:fT*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+fT+1,o=w||E?S.right-fT:S.left,s=w?E?S.right-fT:S.left:S.right-fT;M=mT(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?fT/2:fT*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-fT,o=w||E?S.left+fT:S.right,s=w?E?S.left+fT:S.right:S.left+fT;M=mT(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}var _T=U.createContext(void 0);function vT(){let e=U.useContext(_T);if(e===void 0)throw Error(Cr(26));return e}var yT=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),bT={...ey,...Kv,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},xT=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Hv(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);vT(),Aw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Mw(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Vr(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...jw,hidden:!m,onKeyDown(e){yT.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:bT});return(0,K.jsx)(HS,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function ST(e){return Nr(19)?e:e?`true`:void 0}var CT=U.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,K.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),wT=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Hv(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,K.jsx)(_T.Provider,{value:n,children:(0,K.jsxs)(CS,{ref:t,...r,children:[a&&o===!0&&(0,K.jsx)(CT,{ref:i.context.internalBackdropRef,inert:ST(!s)}),e.children]})}):null}),TT={},ET={},DT=``;function OT(e,t){return dy(e)?e:t}function kT(e,t,n){return/hidden|clip/.test(e.getComputedStyle(OT(t,n)).overflowY)}function Lte(e){if(typeof document>`u`)return!1;let t=My(e);return ay(t).innerWidth-t.documentElement.clientWidth>0}function Rte(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=My(e),n=t.documentElement,r=t.body,i=OT(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function zte(e){let t=My(e),n=t.documentElement,r=t.body,i=OT(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function Bte(e){let t=My(e),n=t.documentElement,r=t.body,i=ay(n),a=0,o=0,s=!1,c=Bb.create();if(lb&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,TT={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},DT=n.style.scrollBehavior,ET={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=OT(n,r);if(s=Rte(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,TT),Object.assign(r.style,ET),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=DT)}function d(){u(),c.request(l)}l();let f=Pb(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var Vte=new class{lockCount=0;restore=null;timeoutLock=tb.create();timeoutUnlock=tb.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=My(e),n=t.documentElement,r=t.body,i=ay(n);if(kT(i,n,r)){let t=new i.MutationObserver(()=>{kT(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=ab||!Lte(e);this.restore=a?zte(e):Bte(e)}};function AT(e=!0,t=null){X(()=>{if(e)return Vte.acquire(t)},[e,t])}function Hte({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=U.useState(0),[u,d]=U.useState(0),f=c===0,p=KS(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=bb(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||yb(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return AT(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),X(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),Bw(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Ute={...Yw,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Wte=class extends Tw{constructor(e,t,n){let r=new Hw,i=Gte(e,r,t,n);super(i,Kte(r),Ute)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Fw(n,e,t.trigger),this.update(n)}};function Gte(e,t,n,r=!1){let i={...Uw(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=Ww(t,n,r),i}function Kte(e){return{popupRef:U.createRef(),backdropRef:U.createRef(),internalBackdropRef:U.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function jT(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=Hv(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Nw((e,t)=>new Wte({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Vw(b,x),Rw(b);let{forceUnmount:w}=zw(x,b);U.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Ky(Gy))}),[w,b]);let T=x||S;return(0,K.jsxs)(Vv.Provider,{value:b,children:[u&&(0,K.jsx)(Pw,{handle:u,store:b}),T&&(0,K.jsx)(Hte,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}function MT(e){return jT(`dialog`,e)}var NT=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=vT(),c=Hv(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return Vr(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:bT,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),PT=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Hv(),c=Zy(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Vr(`h2`,e,{ref:t,props:[{id:c},o]})});function qte(e){let t=U.useRef(``),n=U.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:U.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function FT(e,t){let n=U.useRef(e),r=Ay(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function IT(e,t){let{onClick:n,onPointerDown:r}=qte(Ay((n,r)=>{(typeof e==`function`?e():e)||t(r||(ab?`touch`:``))}));return U.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function LT(e){let[t,n]=U.useState(null),r=IT(e,n);return FT(e,t=>{t&&!e&&n(null)}),U.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var Jte=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Hv(!0),f=Xw(l)??d;if(!f)throw Error(Cr(79));let p=Zy(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=U.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=Lw(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=Py({disabled:a,native:o}),S=US(m),C=IT(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return Vr(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[hS]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:Qv})}),RT=U.createContext(void 0);function zT(){let e=U.useContext(RT);if(e===void 0)throw Error(Cr(53));return e}function BT(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var VT=`base-ui-disable-scrollbar`,HT={className:VT,getElement(e){return(0,K.jsx)(`style`,{nonce:e,href:VT,precedence:`base-ui:low`,children:`.${VT}{scrollbar-width:none}.${VT}::-webkit-scrollbar{display:none}`})}},UT=e=>t=>t?{[e]:``}:null,WT={hasOverflowX:UT(`data-has-overflow-x`),hasOverflowY:UT(`data-has-overflow-y`),overflowXStart:UT(`data-overflow-x-start`),overflowXEnd:UT(`data-overflow-x-end`),overflowYStart:UT(`data-overflow-y-start`),overflowYEnd:UT(`data-overflow-y-end`),cornerHidden:()=>null},GT=U.createContext(void 0),KT={disableStyleElements:!1};function qT(){return U.useContext(GT)??KT}var JT={x:0,y:0},YT={width:0,height:0},XT={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},ZT={x:!0,y:!0,corner:!0},QT=U.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=$T(i),d=Zy(),f=nb(),p=nb(),{nonce:m,disableStyleElements:h}=qT(),[g,_]=U.useState(!1),[v,y]=U.useState(!1),[b,x]=U.useState(!1),[S,C]=U.useState(!1),[w,T]=U.useState(!1),[E,D]=U.useState(YT),[O,k]=U.useState(YT),[A,j]=U.useState(XT),[M,N]=U.useState(ZT),P=U.useRef(null),F=U.useRef(null),I=U.useRef(null),L=U.useRef(null),R=U.useRef(null),ee=U.useRef(null),z=U.useRef(null),B=U.useRef(null),V=U.useRef(0),te=U.useRef(0),H=U.useRef(0),ne=U.useRef(0),re=U.useRef(`vertical`),ie=U.useRef(JT),ae=U.useRef(null);function oe(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let se=Ay(e=>{let t=e.x-ie.current.x,n=e.y-ie.current.y;ie.current=e,n!==0&&oe(!0),t!==0&&oe(!1)}),ce=Ay(()=>{let e=F.current;e&&ae.current===null&&(ae.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),le=Ay(e=>{if(e.button!==0||B.current!==null&&(re.current===`vertical`?R.current:ee.current)?.hasPointerCapture(B.current))return;B.current=e.pointerId,V.current=e.clientY,te.current=e.clientX,re.current=e.currentTarget.getAttribute(`data-orientation`);let t=F.current;t&&(H.current=t.scrollTop,ne.current=t.scrollLeft,ce()),(re.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),ue=Ay(e=>{if(e.pointerId!==B.current)return;B.current=null,(re.current===`vertical`?x:y)(!1),ae.current!==null&&(F.current&&(F.current.style.scrollSnapType=ae.current),ae.current=null);let t=re.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),de=Ay(e=>{if(e.pointerId!==B.current)return;if(e.buttons%2==0){ue(e);return}let t=F.current;if(!t)return;let n=re.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=BT(i,`padding`,a),s=BT(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-V.current:e.clientX-te.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?H.current:ne.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),oe(n)});function fe(e){C(e.pointerType===`touch`)}function pe(e){if(fe(e),e.pointerType!==`touch`){let t=yb(P.current,e.target);_(t)}}let me=U.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),he={role:`presentation`,onPointerEnter:pe,onPointerMove:pe,onPointerDown:fe,onPointerLeave(){_(!1)},style:{position:`relative`,"--scroll-area-corner-height":`${E.height}px`,"--scroll-area-corner-width":`${E.width}px`}},ge=Vr(`div`,e,{state:me,ref:[t,P],props:[he,o],stateAttributesMapping:WT}),_e=U.useMemo(()=>({handlePointerDown:le,handlePointerMove:de,handlePointerUp:ue,handleScroll:se,disableViewportSnap:ce,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:me,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[le,de,ue,se,ce,E,O,w,S,v,b,g,d,M,A,me,s,c,l,u]);return(0,K.jsxs)(RT.Provider,{value:_e,children:[!h&&HT.getElement(m),ge]})});function $T(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var eE=U.createContext(void 0),tE=U.createContext(void 0);function nE(){return U.useContext(tE)?.direction??`ltr`}function rE(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function iE(e,t){return Math.max(0,e-t)}function aE(e,t){if(t<=0)return 0;let n=rE(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var oE=[`--scroll-area-overflow-x-start`,`--scroll-area-overflow-x-end`,`--scroll-area-overflow-y-start`,`--scroll-area-overflow-y-end`],sE=!1;function cE(){sE||lb||(typeof CSS<`u`&&`registerProperty`in CSS&&oE.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),sE=!0)}var lE=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=zT(),T=nE(),E=U.useRef(!0),D=U.useRef([NaN,NaN,NaN,NaN]),O=nb(),k=nb(),A=Ay(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=uE(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=aE(T===`rtl`?-w:w,P),L=P-I);let R=A?0:aE(x,F),ee=A?0:F-R,z=j?0:b,B=A?0:y,V=0,te=0;!j&&!A&&(V=t?.offsetWidth||0,te=n?.offsetHeight||0);let H=f.width===0&&f.height===0,ne=H?V:0,re=H?te:0,ie=BT(n,`padding`,`x`),ae=BT(t,`padding`,`y`),oe=BT(i,`margin`,`x`),se=BT(r,`margin`,`y`),ce=z-ie-oe,le=B-ae-se,ue=n?Math.min(n.offsetWidth-ne,ce):ce,de=t?Math.min(t.offsetHeight-re,le):le,fe=Math.max(16,ue*M),pe=Math.max(16,de*N);if(m(e=>dE(e,{width:fe,height:pe})),t&&r){let e=fE(r,`--scroll-area-thumb-height`,x,F,h,pe,t.offsetHeight-pe-ae-se);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-fe-ie-oe,t=fE(i,`--scroll-area-thumb-width`,T===`rtl`?-w:w,P,_,fe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let me=[I,L,R,ee];oE.forEach((t,n)=>{e.style.setProperty(t,`${me[n]}px`)}),a&&p(e=>dE(e,{width:V,height:te})),g(e=>dE(e,k));let he={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>dE(e,he))});X(()=>{cE()},[]),X(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),X(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),X(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={role:`presentation`,...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:HT.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=Vr(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:WT}),P=U.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,K.jsx)(eE.Provider,{value:P,children:N})});function uE(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function dE(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function fE(e,t,n,r,i,a,o){let s=rE(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var pE=U.createContext(void 0);function mE(){let e=U.useContext(pE);if(e===void 0)throw Error(Cr(54));return e}var hE=U.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=zT(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=nE(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;U.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return Pb(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},onPointerDown(e){if(e.button!==0)return;let t=bb(e.nativeEvent),n=T?h.current:g.current;if(n&&yb(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=BT(n,`margin`,a),s=BT(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(--scroll-area-corner-height)`,insetInlineEnd:0,"--scroll-area-thumb-height":`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(--scroll-area-corner-width)`,bottom:0,"--scroll-area-thumb-width":`${S.width}px`}}},M=Vr(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:WT});return A?(0,K.jsx)(pE.Provider,{value:i,children:M}):null}),gE=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=zT(),m=mE(),h=m===`vertical`;return Vr(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),_E=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=zT(),l=Vr(`div`,e,{ref:[t,o],props:[{style:{position:`absolute`,bottom:0,insetInlineEnd:0,width:s.width,height:s.height}},a]});return c.corner?null:l});function vE({className:e,children:t,scrollFade:n=!1,scrollbarGutter:r=!1,...i}){return(0,K.jsxs)(QT,{className:G(`size-full min-h-0`,e),...i,children:[(0,K.jsx)(lE,{className:G(`h-full !overflow-y-auto overscroll-contain rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,n&&`mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]`,r&&`data-has-overflow-y:pe-2.5 data-has-overflow-x:pb-2.5`),"data-slot":`scroll-area-viewport`,children:t}),(0,K.jsx)(yE,{orientation:`vertical`}),(0,K.jsx)(yE,{orientation:`horizontal`}),(0,K.jsx)(_E,{"data-slot":`scroll-area-corner`})]})}function yE({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(hE,{className:G(`m-1 flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100`,e),"data-slot":`scroll-area-scrollbar`,orientation:t,...n,children:(0,K.jsx)(gE,{className:`relative flex-1 rounded-full bg-foreground/20`,"data-slot":`scroll-area-thumb`})})}var bE=e=>{typeof window>`u`||window.electronAPI?.browser?.setOverlayActive(e)},xE=0,SE=!1;function CE(){let e=xE>0;e!==SE&&(SE=e,bE(SE))}function wE(){xE+=1,CE()}function TE(){xE=Math.max(0,xE-1),CE()}function EE(){return xE>0}function DE(e=!0){(0,U.useLayoutEffect)(()=>{if(e)return wE(),()=>TE()},[e])}function OE(){return DE(),null}var kE=0,AE=!1,jE=!1,ME=!1;function NE(){let e=kE>0&&!jE;e!==AE&&(AE=e,window.electronAPI?.window?.setTrafficLightsVisible(!e))}function PE(){ME||(ME=!0,window.electronAPI?.window?.isFullScreen().then(e=>{jE=e,NE()}).catch(()=>{}),window.electronAPI?.window?.onFullScreenChange(e=>{jE=e,NE()}))}function FE(){window.electronAPI?.env?.platform===`darwin`&&(PE(),kE++,NE())}function IE(){window.electronAPI?.env?.platform===`darwin`&&(kE=Math.max(0,kE-1),NE())}function LE(e){(0,U.useEffect)(()=>{if(e)return FE(),()=>IE()},[e])}var RE={BASE:0,SETTINGS_WINDOW:10,MOBILE_DRAWER:30,DROPDOWN:40,MODAL_BACKDROP:50,MODAL_CONTENT:51,DROPDOWN_IN_MODAL:60,NESTED_MODAL_BACKDROP:70,NESTED_MODAL_CONTENT:71,DROPDOWN_IN_NESTED_MODAL:80,TOOLTIP:100,TOAST:110,DEVTOOLS_OVERLAY:120},zE=(0,U.createContext)(RE.DROPDOWN);function BE(e){return LE(e.open??!1),(0,K.jsx)(MT,{...e})}var VE=wT;function HE(e){return(0,K.jsx)(Jte,{"data-slot":`dialog-trigger`,...e})}function UE({className:e,...t}){return(0,K.jsx)(ny,{className:G(`fixed inset-0 no-drag bg-black/32 backdrop-blur-sm transition-opacity duration-150 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`dialog-backdrop`,"data-enso-float":``,...t})}function WE({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`fixed inset-0 grid grid-rows-[1fr_auto_3fr] justify-items-center p-4 pointer-events-none`,e),"data-slot":`dialog-viewport`,...t})}function GE({className:e,children:t,showCloseButton:n=!0,bottomStickOnMobile:r=!0,disableNestedTransform:i=!1,showBackdrop:a=!0,zIndexLevel:o=`base`,style:s,...c}){let l=i?{...s??{},"--nested-dialogs":0}:s,u=o===`base`?RE.MODAL_CONTENT:RE.NESTED_MODAL_CONTENT,d=o===`base`?RE.MODAL_BACKDROP:RE.NESTED_MODAL_BACKDROP,f=o===`base`?RE.DROPDOWN_IN_MODAL:RE.DROPDOWN_IN_NESTED_MODAL;return(0,K.jsxs)(VE,{children:[(0,K.jsx)(OE,{}),a&&(0,K.jsx)(UE,{style:{zIndex:d}}),(0,K.jsx)(WE,{className:G(r&&`max-sm:grid-rows-[1fr_auto] max-sm:pt-12`),style:{zIndex:u},children:(0,K.jsxs)(xT,{className:G(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] no-drag pointer-events-auto relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg transition-[scale,opacity,translate] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-95 data-starting-style:scale-95 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,r&&`max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none`,e),style:l,"data-slot":`dialog-popup`,...c,children:[(0,K.jsx)(zE.Provider,{value:f,children:t}),n&&(0,K.jsx)(qy,{"aria-label":`Close`,className:`absolute end-3 top-2.5 z-50 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors`,children:(0,K.jsx)(ir,{className:`h-4 w-4`})})]})})]})}function KE({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`dialog-header`,...t})}function qE({className:e,variant:t=`default`,...n}){return(0,K.jsx)(`div`,{className:G(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t==="default"&&`border-t bg-muted/50 py-4`,t===`bare`&&`in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6`,e),"data-slot":`dialog-footer`,...n})}function JE({className:e,...t}){return(0,K.jsx)(PT,{className:G(`font-heading text-xl leading-none`,e),"data-slot":`dialog-title`,...t})}function YE({className:e,...t}){return(0,K.jsx)(Qy,{className:G(`text-muted-foreground text-sm`,e),"data-slot":`dialog-description`,...t})}var XE=`px-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-header]))]:pt-6 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer]))]:pb-6! in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer].border-t))]:pb-1 pb-6`;function ZE({className:e,bare:t=!1,...n}){let r=(0,K.jsx)(`div`,{className:G(XE,e),"data-slot":`dialog-panel`,...n});return t?r:(0,K.jsx)(vE,{className:`!h-auto min-h-0 flex-1`,children:r})}var QE=0;function $E(e){return QE+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${QE}`}var eD=U.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=SS({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,K.jsxs)(U.Fragment,{children:[l,c&&Gs.createPortal(n,c)]})}),tD=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=$b(e,t)||{};if(l==null)return{};let f=_x(u),p={x:n,y:r},m=ax(i),h=rx(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=Qb(k,j,A),N=!c.arrow&&tx(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),nD=(e,t)=>({...tD(e),options:[e,t]}),rD={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},iD={sideX:`left`,sideY:`top`},aD=`--available-width`,oD=`--available-height`;function sD(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function cD(e,t,n){let{rects:r,placement:i}=e;return{side:sD(t,ex(i),n),align:tx(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function lD(e){return uD(e,Ote)}function uD(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=U.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,O=v?.crossAxis??!1,k=v?.rootBoundary,A=typeof n==`function`?n:void 0,j=Ay(A),M=A?j:n,N=Ib(n),P=Ib(g),F=nE()===`rtl`,I=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let ee=+(i===`bottom`),z=+(i===`top`),B=+(i===`right`),V=+(i===`left`),te={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},H=U.useRef(null),ne=Ib(a),re=Ib(s),ie=typeof a==`function`?0:a,ae=typeof s==`function`?0:s,oe=[];p&&oe.push(p),oe.push(GC(e=>{let t=cD(e,i,F),n=typeof ne.current==`function`?ne.current(t):ne.current,r=typeof re.current==`function`?re.current(t):re.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ie,ae,F,i]));let se=E===`none`&&T!==`shift`,ce=!se&&(u||O||T===`shift`),le=T===`none`?null:JC({...te,padding:{top:R.top+1+ee,right:R.right+1+V,bottom:R.bottom+1+z,left:R.left+1+B},mainAxis:!O&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),ue=se?null:KC({...te,rootBoundary:k,mainAxis:E!==`none`,crossAxis:ce,limiter:u||O?void 0:qC(e=>{if(!H.current)return{};let{width:t,height:n}=H.current.getBoundingClientRect(),r=ix(ex(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[te,u,O,k,R,E]);T===`shift`||E===`shift`||o===`center`?oe.push(ue,le):oe.push(le,ue),oe.push(YC({...te,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(aD,`${t}px`),i.setProperty(oD,`${n}px`);let a=ay(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(`--anchor-width`,`${u}px`),i.setProperty(`--anchor-height`,`${d}px`)}}),nD(e=>({element:H.current||My(e.elements.floating).createElement(`div`),padding:d,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:t,middlewareData:n,placement:r,rects:o,y:s}=e,c=ex(r),l=ix(c),u=H.current,d=n.arrow?.x||0,f=n.arrow?.y||0,p=u?.clientWidth||0,m=u?.clientHeight||0,h=d+p/2,g=f+m/2,_=Math.abs(n.shift?.y||0),v=o.reference.height/2,y=typeof a==`function`?a(cD(e,i,F)):a,b=_>y,x={top:`${h}px calc(100% + ${y}px)`,bottom:`${h}px ${-y}px`,left:`calc(100% + ${y}px) ${g}px`,right:`${-y}px ${g}px`}[c],S=`${h}px ${o.reference.y+v-s}px`;return t.floating.style.setProperty(`--transform-origin`,ce&&l===`y`&&b?S:x),{}}},rD,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=U.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:pe,x:me,y:he,middlewareData:ge,update:_e,placement:ve,context:ye,isPositioned:be,floatingStyles:xe}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:oe,strategy:r,whileElementsMounted:m?void 0:(...e)=>MC(...e,de),nodeId:y,externalTree:S}),{sideX:Se,sideY:Ce}=ge.adaptiveOrigin||iD,we=be?r:`fixed`,Te=U.useMemo(()=>{let e;return e=be?b?{position:we,[Se]:me,[Ce]:he}:{...xe,position:we}:{position:we,top:0,left:0},e[aD]=`100vw`,e[oD]=`100vh`,be||(e.opacity=0),e},[b,we,Se,me,Ce,he,xe,be]),Ee=U.useRef(null);X(()=>{if(!g)return;let e=N.current,t=typeof e==`function`?e():e,n=(dD(t)?t.current:t)||null;n!==Ee.current&&(fe.setPositionReference(n),Ee.current=n)},[g,fe,M,N]),U.useEffect(()=>{if(!g)return;let e=N.current;typeof e!=`function`&&dD(e)&&e.current!==Ee.current&&(fe.setPositionReference(e.current),Ee.current=e.current)},[g,fe,M,N]),U.useEffect(()=>{if(m&&g&&pe.reference&&pe.floating)return MC(pe.reference,pe.floating,_e,de)},[m,g,pe,_e,de]);let De=ex(ve),Oe=sD(i,De,F),ke=tx(ve)||`center`,Ae=!!ge.hide?.referenceHidden;X(()=>{x&&g&&be&&De!==I&&w(De)},[x,g,be,De,I]);let je=U.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),Me=ge.arrow?.centerOffset!==0;return U.useMemo(()=>({positionerStyles:Te,arrowStyles:je,arrowRef:H,arrowUncentered:Me,side:Oe,align:ke,physicalSide:De,anchorHidden:Ae,refs:fe,context:ye,isPositioned:be,update:_e}),[Te,je,H,Me,Oe,ke,De,Ae,fe,ye,be,_e])}function dD(e){return e!=null&&`current`in e}function fD(e){return e===`starting`?mS:Lr}function pD(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Vr(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},fD(r),i],stateAttributesMapping:ey})}function mD(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||$E(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var hD=mD();function gD(e){let t={error:1e4,warning:1e4,loading:0,success:5e3,info:5e3},n=e.type,r=e.timeout??(n?t[n]:5e3),{actions:i,data:a,...o}=e,s=i?{...a,actions:i}:a;return hD.add({...o,data:s,timeout:r})}var _D=[`agents`,`members`,`chats`];function vD(e){return[..._D.flatMap(t=>e[t].map(e=>({candidate:e,group:t}))),...e.files.map(e=>({candidate:e,group:`files`}))]}function yD(e,t){let n=_D.filter(t=>e[t].length>0);return!t.trim()&&n.length>0?[...n.map(e=>({type:`folder`,id:e})),...e.files.map(e=>({type:`item`,candidate:e,group:`files`}))]:vD(e).map(e=>({type:`item`,candidate:e.candidate,group:e.group}))}function bD(e){return e.map(e=>({...e,kind:`agent-type`,id:e.typeKey,label:e.displayName}))}function xD(e){let t=new Set,n=[];for(let r of e)!r.relativePath||t.has(r.relativePath)||(t.add(r.relativePath),n.push({kind:`file`,id:r.relativePath,label:r.name||r.relativePath.split(`/`).at(-1)||r.relativePath,relativePath:r.relativePath}));return n}function SD(e,t,n,r=[]){let i=e.trim().toLocaleLowerCase(),a=i?t.filter(e=>`${e.label}\n${e.description}\n${e.source}\n${e.typeKey}`.toLocaleLowerCase().includes(i)):[...t],o=i?n.filter(e=>`${e.label}\n${e.relativePath}`.toLocaleLowerCase().includes(i)):[...n],s=i?r.filter(e=>e.label.toLocaleLowerCase().includes(i)):[...r];return{agents:a.filter(e=>e.source!==`bot`),members:a.filter(e=>e.source===`bot`),files:o,chats:s}}function CD(e,t,n=[],r={}){let[i,a]=(0,U.useState)([]),[o,s]=(0,U.useState)([]),c=t!==null,{searchFiles:l,agents:u=!0}=r;return(0,U.useEffect)(()=>{if(!c||!u)return;a([]);let e=!1;return window.electronAPI.agentRegistry.list().then(t=>{let n=A(t);e||a(n?bD(n.candidates):[])}).catch(()=>{e||a([])}),()=>{e=!0}},[c,u]),(0,U.useEffect)(()=>{if(t===null||!e&&!l){s([]);return}let n=!1,r=window.setTimeout(()=>{(l?l(t):window.electronAPI.files.search({conversationId:e,query:t})).then(e=>{n||s(xD(e))}).catch(()=>{n||s([])})},150);return()=>{n=!0,window.clearTimeout(r)}},[e,t,l]),(0,U.useMemo)(()=>t===null?{agents:[],members:[],files:[],chats:[]}:SD(t,i,o,n),[i,o,n,t])}var wD=1024,TD=(e,t)=>e<=(t?wD:767),ED=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches,DD=()=>typeof window<`u`&&typeof window.innerWidth==`number`&&TD(window.innerWidth,ED()),OD=e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e));function kD(){return(0,U.useSyncExternalStore)(OD,()=>TD(window.innerWidth,ED()),()=>!1)}var AD=`mod+shift+m`,jD=typeof navigator<`u`&&typeof navigator.platform==`string`?navigator.platform.startsWith(`Mac`):process.platform===`darwin`,MD={"toggle-sidebar":`mod+b`,"toggle-app-mode":`mod+e`,"toggle-side-panel":`mod+j`,"toggle-side-panel-fullscreen":`mod+shift+j`,"open-settings":`mod+,`,"open-secretary":`mod+shift+s`,"switch-model":`mod+.`,"focus-composer":`mod+l`,"send-message":`enter`,"find-in-chat":`mod+f`,"search-workspace":`mod+k`,"new-conversation":`mod+n`,"next-tab":jD?`ctrl+tab`:`mod+tab`,"prev-tab":jD?`ctrl+shift+tab`:`mod+shift+tab`,"new-side-tab":`mod+t`,"new-btw-tab":`mod+shift+b`,"close-side-tab":`mod+w`,"toggle-minimize-to-tray":AD};function ND(e){return{...MD,...e}}function PD(e,t){let n=FD(e);if([`meta`,`control`,`alt`,`shift`].includes(n))return null;let r=jD?e.metaKey:e.ctrlKey,i=jD&&e.ctrlKey;if(!(r||i||e.altKey)&&!(t?.allowBare&&n===`enter`))return null;let a=[];return r&&a.push(`mod`),i&&a.push(`ctrl`),e.altKey&&a.push(`alt`),e.shiftKey&&a.push(`shift`),a.push(n),a.join(`+`)}function FD(e){if(e.key===` `||e.key===`\xA0`)return`space`;if(e.altKey){let t=/^(?:Key([A-Z])|Digit([0-9]))$/.exec(e.code??``);if(t)return(t[1]??t[2]??``).toLowerCase()}return e.key.toLowerCase()}function ID(e){let t=e.split(`+`),n=t.at(-1)??``,r=n.length===1?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1);return jD?[t.includes(`ctrl`)?`⌃`:``,t.includes(`alt`)?`⌥`:``,t.includes(`shift`)?`⇧`:``,t.includes(`mod`)?`⌘`:``,r].join(``):[t.includes(`mod`)?`Ctrl`:``,t.includes(`alt`)?`Alt`:``,t.includes(`shift`)?`Shift`:``,r].filter(Boolean).join(`+`)}var LD=new Set,RD=!1;function zD(e,t){t?LD.add(e):LD.delete(e);let n=LD.size>0;n!==RD&&(RD=n,window.electronAPI?.updater?.reportUnsentDraft?.(n))}var BD=[],VD=e=>`/${e.pluginId}:${e.id}`;function HD(e){return BD.find(t=>VD(t)===e)??null}function UD(){return BD}async function WD(e,t){let n=await window.electronAPI.extensionPlugins.call({pluginId:e.pluginId,method:`command.run`,payload:{id:e.id},sessionId:t});return n.ok?null:n.error}var GD=null,KD=new Map;function qD(e){return GD=e,()=>{GD===e&&(GD=null)}}function JD(e){let t=KD.get(e);return KD.delete(e),t}var YD=[],XD=0,ZD=new Set;function QD(){return XD}function $D(e){return ZD.add(e),()=>ZD.delete(e)}function eO(e){return YD.filter(t=>t.slot===`message.action`&&t.position===e)}function tO(e){let t=e===`left`?`composer.left`:`composer.right`;return YD.filter(e=>e.slot===t)}function nO(e,t){return YD.find(n=>n.slot===`tool.card`&&n.pluginId===e&&n.toolName===t)}function rO(){return YD.find(e=>e.slot===`thinking.body`)}function iO(){return YD.find(e=>e.slot===`message.leaf`)}function aO(e,t){let n=t.toLowerCase();return YD.find(t=>t.slot===`block`&&t.pluginId===e&&t.language===n)}var oO=/^[a-z][a-z0-9]*(\.[a-z0-9]+)+$/;function sO(e){if(!e)return null;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t),r=e.slice(t+1);return!oO.test(n)||r.length===0?null:{pluginId:n,lang:r}}function cO({entry:e,props:t}){return(0,U.createElement)(e.component,t)}function lO(){return(0,U.useSyncExternalStore)($D,QD,QD)}var uO=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[plugin] ${this.props.pluginId} 挂点 ${this.props.slot} 渲染失败`,e)}render(){return this.state.failed?this.props.fallback??null:this.props.children}};function dO({entry:e,props:t,fallback:n}){return(0,K.jsx)(uO,{pluginId:e.pluginId,slot:e.slot,fallback:n,children:(0,K.jsx)(cO,{entry:e,props:t})})}function fO({position:e,text:t,messageIndex:n,sessionId:r}){lO();let i=eO(e);return i.length===0?null:(0,K.jsx)(K.Fragment,{children:i.map(i=>(0,K.jsx)(dO,{entry:i,props:{position:e,text:t,messageIndex:n,sessionId:r}},`${i.pluginId}:${i.uid}`))})}function pO({name:e,output:t,state:n}){lO();let r=w(e);if(!r)return null;let i=nO(r.pluginId,r.toolName);return i?(0,K.jsx)(dO,{entry:i,props:{toolName:r.toolName,output:t,state:n}}):null}var mO=[`t-acc-reveal mt-1 ml-[10px] border-l-2 border-border py-0.5 pl-[19px]`,`text-[13px] leading-relaxed text-muted-foreground whitespace-pre-wrap`].join(` `);function hO({text:e,streaming:t,itemKey:n}){lO();let r=rO();return r?(0,K.jsx)(`div`,{className:mO,children:(0,K.jsx)(dO,{entry:r,props:{text:e,streaming:t,itemKey:n},fallback:e},r.uid)}):(0,K.jsx)(`p`,{className:mO,children:e})}function gO({entry:e,source:t,final:n,messageIndex:r,sessionId:i,Markdown:a}){return(0,K.jsx)(dO,{entry:e,props:{source:t,final:n,messageIndex:r,sessionId:i,Markdown:a}})}function _O({pluginId:e,lang:t,source:n}){lO();let r=aO(e,t);return r?(0,K.jsx)(dO,{entry:r,props:{language:t,source:n}}):null}function vO({side:e,sessionId:t,draft:n,busy:r,pluginPresetId:i}){lO();let a=tO(e);return a.length===0?null:(0,K.jsx)(K.Fragment,{children:a.map(a=>(0,K.jsx)(dO,{entry:a,props:{position:e,sessionId:t,draft:n,busy:r,pluginPresetId:i}},`${a.pluginId}:${a.uid}`))})}var yO=[],bO=new Set;function xO(e){return bO.add(e),()=>bO.delete(e)}var SO=()=>yO,CO={neutral:`text-muted-foreground`,accent:`text-primary`,success:`text-emerald-600 dark:text-emerald-400`,warning:`text-amber-600 dark:text-amber-400`,danger:`text-red-600 dark:text-red-400`};function wO({sessionId:e}){let t=(0,U.useSyncExternalStore)(xO,SO,SO);return t.length===0?null:(0,K.jsx)(K.Fragment,{children:t.map(t=>{let n=t.command?UD().find(e=>e.pluginId===t.pluginId&&e.id===t.command):void 0,r=G(`shrink-0 truncate px-1 text-[11px]`,CO[t.tone]),i=t.tooltip?`${t.tooltip} · ${t.pluginName}`:t.pluginName;return n?(0,K.jsx)(`button`,{type:`button`,title:i,className:G(r,`rounded hover:bg-accent`),onClick:()=>void WD(n,e).then(e=>{e&&gD({title:e})}),children:t.text},`${t.pluginId}:${t.id}`):(0,K.jsx)(`span`,{title:i,className:r,children:t.text},`${t.pluginId}:${t.id}`)})})}var TO=50,EO=64,DO=120,OO=32768,kO=120,AO=[];function jO(e){return/(?:^|\s)#([^\s#]*)$/.exec(e)?.[1]??null}function MO(e,t,n){if(!Array.isArray(n))return[];let r=[];for(let i of n){if(r.length>=TO)break;if(typeof i!=`object`||!i)continue;let{id:n,label:a,detail:o}=i;typeof n!=`string`||!n||typeof a!=`string`||!a||r.push({key:`${e}:${t}:${n}`,pluginId:e,name:t,item:{id:n.slice(0,200),label:a.slice(0,EO),...typeof o==`string`&&o?{detail:o.slice(0,DO)}:{}}})}return r}function NO(e){let t=typeof e==`string`?e:typeof e==`object`&&e?e.text:null;return typeof t==`string`&&t.length<=OO?t:null}var PO=[],FO=new Set;function IO(e){return FO.add(e),()=>FO.delete(e)}var LO=()=>PO;function RO(e,t){let n=(0,U.useSyncExternalStore)(IO,LO,LO),[r,i]=(0,U.useState)(AO);return(0,U.useEffect)(()=>{if(e===null||n.length===0){i(AO);return}let r=!1,a=setTimeout(()=>{Promise.all(n.map(async({pluginId:n,name:r})=>{let i=await window.electronAPI.extensionPlugins.call({pluginId:n,method:`trigger.candidates`,payload:{name:r,query:e},sessionId:t});return i.ok?MO(n,r,i.value):AO})).then(e=>{r||i(e.flat().slice(0,TO))})},kO);return()=>{r=!0,clearTimeout(a)}},[e,n,t]),e===null?AO:r}async function zO(e,t){let n=await window.electronAPI.extensionPlugins.call({pluginId:e.pluginId,method:`trigger.pick`,payload:{name:e.name,item:e.item},sessionId:t});return n.ok?NO(n.value):null}var BO=null,VO=null,HO=null,UO=null,WO=null,GO=null,KO=null,qO=null,JO=null;function YO(e){return BO=e,()=>{BO===e&&(BO=null)}}function XO(e){return UO=e,()=>{UO===e&&(UO=null)}}function ZO(e){return VO=e,()=>{VO===e&&(VO=null)}}function QO(){return UO?(UO(),!0):!1}function $O(e){return HO=e,()=>{HO===e&&(HO=null)}}function ek(e){return HO?(HO(e),!0):!1}function tk(e){return JO=e,()=>{JO===e&&(JO=null)}}function nk(e){return VO?(VO(e),!0):!1}function rk(e){return WO=e,()=>{WO===e&&(WO=null)}}function ik(e){return GO=e,()=>{GO===e&&(GO=null)}}function ak(e){return KO=e,()=>{KO===e&&(KO=null)}}function ok(e){return qO=e,()=>{qO===e&&(qO=null)}}var sk=`composer-drop`,ck=/<quote(?: truncated="true" original-lines="(\d+)")?>\n([\s\S]*?)\n<\/quote>/g;function lk(e){return`<quote${e.originalLines?` truncated="true" original-lines="${e.originalLines}"`:``}>\n${e.text.replace(/<\/quote>/g,`<\\/quote>`)}\n</quote>`}function uk(e){let t=e[2].replace(/<\\\/quote>/g,`</quote>`);return e[1]?{text:t,originalLines:Number(e[1])}:{text:t}}function dk(e){return e.search(ck)>=0}function fk(e){return e.replace(ck,(...e)=>{let t=uk(e),n=t.text.replace(/^/gm,`> `);return t.originalLines?`${n}\n> …`:n})}function pk(e){return e.replace(ck,``).trim()||[...e.matchAll(ck)].map(e=>uk(e).text).join(`
163
- `)}var mk=[{name:`blue`,rgb:[58,150,221],cssVar:`--cursor-blue`},{name:`purple`,rgb:[155,89,182],cssVar:`--cursor-purple`},{name:`green`,rgb:[39,174,96],cssVar:`--cursor-green`},{name:`orange`,rgb:[242,153,74],cssVar:`--cursor-orange`},{name:`cyan`,rgb:[0,184,169],cssVar:`--cursor-cyan`},{name:`magenta`,rgb:[219,68,134],cssVar:`--cursor-magenta`},{name:`red`,rgb:[235,87,87],cssVar:`--cursor-red`},{name:`yellow`,rgb:[170,175,18],cssVar:`--cursor-yellow`}];mk.map(e=>e.name);function hk(e,t){return`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${t})`}mk.map(({rgb:e})=>({fill:hk(e,.04),stroke:hk(e,.5),scribbleStroke:hk(e,.92)})),mk.map(({rgb:e})=>({border:hk(e,1),bg:hk(e,.1),hoverBorder:hk(e,.3),hoverBg:hk(e,.02)}));var{PI:gk}=Math;gk+1e-4;var _k=`CSS edits — `;RegExp(`^${_k}.*$`,`m`),RegExp(`^${_k}`,`gm`);var vk=/\n*```browser_element\n[\s\S]*?```(?=\n|$)/g;function yk(e){return e.replace(vk,``).trimEnd()}var bk=/^<unattended>\n([\s\S]*?)\n<\/unattended>(?:\n\n|$)/;function xk(e){let t=bk.exec(e);return t?{note:/unattended mode is off/i.test(t[1])?`off`:`on`,rest:e.slice(t[0].length)}:{rest:e}}var Sk=`background-tasks-wrap-up`,Ck=RegExp(`^<${Sk}>\\n[\\s\\S]*?\\n</${Sk}>(?:\\n\\n|$)`),wk=/^- (\S+?): (.*?)(?: \(running ([^()]+)\))?$/;function Tk(e){let t=[];for(let n of e.split(`
164
- `)){let e=wk.exec(n);e?.[1]&&t.push({taskId:e[1],command:e[2]??``,...e[3]?{ran:e[3]}:{}})}return t}function Ek(e){let t=Ck.exec(e);return t?{items:Tk(t[0]),rest:e.slice(t[0].length)}:null}function Dk(e){let t=e,n,r,i;for(;;){let a=n?{rest:t}:he(t);if(a.note){n=a.note,t=a.rest;continue}let o=i?null:Ek(t);if(o){let n=e.length-t.length;i={items:o.items,start:n,end:n+t.length-o.rest.length},t=o.rest;continue}let s=r?{rest:t}:xk(t);if(!s.note)break;r=s.note,t=s.rest}return{...n?{plan:n}:{},...r?{unattended:r}:{},wrapUp:i,rest:t}}function Ok(e){let{plan:t,unattended:n,rest:r}=Dk(e);return{...t?{plan:t}:{},...n?{unattended:n}:{},rest:r}}function kk(e){let t=Dk(e).wrapUp;return t?{items:t.items}:void 0}function Ak(e){let t=Dk(e).wrapUp;return t?e.slice(0,t.start)+e.slice(t.end):e}var jk=/^\/skill:(\S+)(?:\s+|$)/,Mk=/^<skill name="([^"]+)" location="([^"]*)">\n([\s\S]*?)\n<\/skill>(?:\n\n|$)/;function Nk(e){let t=[],n=e;for(let e=jk.exec(n);e;e=jk.exec(n))t.push(e[1]),n=n.slice(e[0].length);return{names:t,rest:t.length>0?n.trim():e}}function Pk(e){let t=[],n=e;for(let e=Mk.exec(n);e;e=Mk.exec(n))t.push({name:e[1],location:e[2],body:e[3]}),n=n.slice(e[0].length);return t.length>0?{skills:t,rest:n.trim()}:null}var Fk=/^<workflow-preset name="([^"]*)">\n(\{.*\})\n<\/workflow-preset>(?:\n\n[\s\S]*)?$/,Ik=e=>e.replace(/&(amp|quot|lt|gt);/g,e=>e===`&amp;`?`&`:e===`&quot;`?`"`:e===`&lt;`?`<`:`>`);function Lk(e){let t=Fk.exec(e);if(!t)return null;let n;try{n=JSON.parse(t[2]??``)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let{preset:r,args:i={}}=n;if(typeof r!=`string`||!r||!i||typeof i!=`object`||Array.isArray(i))return null;let a=Object.entries(i);return a.some(([,e])=>typeof e!=`string`)?null:{id:r,name:Ik(t[1]??``),args:a}}var Rk=/\[Referenced past chat "(.+?)" — transcript file: (.+?) \(pi session jsonl; read it if relevant\)\]/g,zk=/\[Selected UI element "([^"]*)" — path: (.*?); text: (.*?)\]/g;function Bk(e,t){for(let n=t-1;n>=0;n--){let r=e[n];if(r===`@`){let r=n>0?e[n-1]:` `;return r===` `||r===`
162
+ `).trim();return t.length>=5e4&&t.length<=2e7?t:null}var hv=/@((?:\/|[A-Za-z]:\\)[^\n@]*?[\\/]pasted-text[\\/](?:bot-)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[\\/][0-9a-f]{8}[\\/]pasted-text\.txt)/g;function gv(e){let t=[],n=0;for(let r of e.matchAll(hv))r.index>n&&t.push({type:`text`,text:e.slice(n,r.index)}),t.push({type:`file`,path:r[1]}),n=r.index+r[0].length;return(n<e.length||t.length===0)&&t.push({type:`text`,text:e.slice(n)}),t}var _v=`(?<![A-Za-z0-9_])`,vv=`(?![A-Za-z0-9_])`,yv=(e,t,n)=>({kind:`API_KEY`,rule:e,re:RegExp(`${_v}${t}${vv}`,`g`),keep:n}),bv=/^\{\{[A-Z][A-Z_]*_[a-z2-7]{8}\}\}$/,xv=/^(?:\$\{.*\}|\$[A-Za-z_]\w*|<[^>]*>|%[\w]+%|process\.env\..*|null|nil|none|true|false|undefined|x{3,}|\*{3,}|changeme|password|secret|your[_-].*)$/i,Sv=e=>e.length>=6&&!xv.test(e)&&!bv.test(e),Cv=([e=``])=>/pass|pwd|密码|口令/i.test(e)?`PASSWORD`:/token|令牌/i.test(e)?`TOKEN`:`SECRET`,wv=[{kind:`PRIVATE_KEY`,rule:`pem`,re:/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,keep:0},yv(`openai`,`sk-[A-Za-z0-9_-]{16,}`,/^sk-(?:ant-(?:api\d+-)?|proj-)?/),yv(`stripe`,`[sr]k_(?:live|test)_[A-Za-z0-9]{10,}`,/^[sr]k_(?:live|test)_/),yv(`github`,`gh[opusr]_[A-Za-z0-9]{20,}`,/^gh[opusr]_/),yv(`github`,`github_pat_[A-Za-z0-9_]{20,}`,/^github_pat_/),yv(`gitlab`,`glpat-[A-Za-z0-9_-]{20,}`,/^glpat-/),yv(`google`,`AIza[0-9A-Za-z_-]{35}`,/^AIza/),yv(`slack`,`xox[abprs]-[A-Za-z0-9-]{10,}`,/^xox[abprs]-/),yv(`aws`,`(?:AKIA|ASIA)[0-9A-Z]{16}`,/^(?:AKIA|ASIA)/),yv(`huggingface`,`hf_[A-Za-z0-9]{20,}`,/^hf_/),yv(`groq`,`gsk_[A-Za-z0-9]{20,}`,/^gsk_/),yv(`xai`,`xai-[A-Za-z0-9]{20,}`,/^xai-/),yv(`npm`,`npm_[A-Za-z0-9]{36}`,/^npm_/),yv(`pypi`,`pypi-[A-Za-z0-9_-]{50,}`,/^pypi-/),yv(`digitalocean`,`do[opr]_v1_[a-f0-9]{64}`,/^do[opr]_v1_/),yv(`sendgrid`,`SG\\.[A-Za-z0-9_-]{22}\\.[A-Za-z0-9_-]{43}`,/^SG\./),{kind:`TOKEN`,rule:`jwt`,re:/(?<![A-Za-z0-9_-])eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,keep:3},{kind:`TOKEN`,rule:`bearer`,re:/\bBearer\s+([A-Za-z0-9._~+/=-]{16,})/dg,group:1,keep:0},{kind:`PASSWORD`,rule:`url`,re:/:(?<=\b[a-z][a-z0-9+.-]*:)\/\/[^\s/:@]+:([^\s/@]+)@/dgi,group:1,keep:0,validate:e=>!xv.test(e)&&!bv.test(e)},{kind:Cv,rule:`kv`,re:/\b(?<!(?:^|[^A-Za-z0-9_])(?:[A-Za-z0-9]+[_-])+?)(?:[A-Za-z0-9]+[_-])*(api[_-]?key|secret(?:[_-]?key)?|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|passwd|password|pwd|client[_-]?secret|private[_-]?key)["']?\s*[:=]\s*(?:"((?:\\.|[^"\\\n])*)"|'((?:\\.|[^'\\\n])*)'|([^\s"',;{}[\]]+))/dgi,group:-1,keep:0,validate:Sv},{kind:Cv,rule:`cjk`,re:/(密码|口令|密钥|秘钥|令牌)\s*(?:[::=]|为|是)\s*([^\s,。、,;;"'“”‘’]{6,})/dg,group:2,keep:0,validate:Sv}],Tv=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];function Ev(e){let t=Number(e.slice(10,12)),n=Number(e.slice(12,14));return t<1||t>12||n<1||n>31?!1:`10X98765432`[Tv.reduce((t,n,r)=>t+n*Number(e[r]),0)%11]===e[17].toUpperCase()}function Dv(e){let t=0;for(let n=0;n<e.length;n++){let r=Number(e[e.length-1-n]);n%2==1&&(r*=2,r>9&&(r-=9)),t+=r}return t%10==0}var Ov=/(?:^|\.)(?:example\.(?:com|org|net)|example|test|invalid|local|localhost)$/i,kv={email:{kind:`EMAIL`,rule:`email`,re:/(?<![\w.%+-])[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}(?![\w-])/g,keep:0,validate:e=>!/no-?reply/i.test(e)&&!Ov.test(e.slice(e.indexOf(`@`)+1))},phone:{kind:`PHONE`,rule:`cn-mobile`,re:/(?<![\d+])(?:\+?86[- ]?)?1[3-9]\d{9}(?!\d)/g,keep:0},idCard:{kind:`ID_CARD`,rule:`cn-id`,re:/(?<![\dA-Za-z])\d{17}[\dXx](?![\dA-Za-z])/g,keep:0,validate:Ev},bankCard:{kind:`BANK_CARD`,rule:`luhn`,re:/(?<![\d-])\d(?:[ -]?\d){14,18}(?!\d)/g,keep:0,validate:e=>{let t=e.replace(/[ -]/g,``);return!/^(\d)\1+$/.test(t)&&Dv(t)}},ip:{kind:`IP`,rule:`ipv4`,re:/(?<![\d.])(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)(?![\d.])/g,keep:0,validate:e=>!/^(?:127\.|0\.0\.0\.0$|255\.255\.255\.255$)/.test(e)}},Av=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),jv=e=>`${/^\w/.test(e)?_v:``}${Av(e)}${/\w$/.test(e)?vv:``}`;function Mv(e,t){let n=e.map(e=>({kind:`CUSTOM`,rule:`word`,re:new RegExp(jv(e),`gi`),keep:0}));for(let e of t){let t=/^\/(.+)\/([a-z]*)$/s.exec(e);try{n.push(t?{kind:`CUSTOM`,rule:`regex`,re:new RegExp(t[1],`${t[2].replace(/[gyd]/g,``)}g`),keep:0}:{kind:`CUSTOM`,rule:`prefix`,re:RegExp(`${/^\w/.test(e)?_v:``}${Av(e)}[A-Za-z0-9._-]+`,`g`),keep:e.length})}catch{}}return n}function Nv(e){let t=[];if(e.enabled){if(e.secrets.enabled)for(let n of wv)t.push({...n,action:e.secrets.action,category:`secret`});if(e.personal.enabled)for(let n of e.personal.kinds)t.push({...kv[n],action:e.personal.action,category:`personal`});for(let n of Mv(e.custom.words,e.custom.rules))t.push({...n,action:e.custom.action,category:`custom`})}return{active:t.length>0,rules:t,allow:new Set(e.allow.map(e=>e.toLowerCase()))}}var Pv=/\{\{[A-Z][A-Z_]*_[a-z2-7]{8}\}\}/g;function Fv(e,t){let n=t.indices;if(!e.group)return[t.index,t.index+t[0].length];if(n){if(e.group>0)return n[e.group];for(let e=2;e<n.length;e++)if(n[e])return n[e]}}function Iv(e,t){if(!t.active||!e)return[];let n=[];for(let t of e.matchAll(Pv))n.push([t.index,t.index+t[0].length]);let r=[];for(let i of t.rules){i.re.lastIndex=0;for(let a=i.re.exec(e);a;a=i.re.exec(e)){if(a[0].length===0){i.re.lastIndex++;continue}let o=Fv(i,a);if(!o||o[1]<=o[0])continue;let[s,c]=o,l=e.slice(s,c);if(i.validate&&!i.validate(l)||t.allow.has(l.toLowerCase())||n.some(([e,t])=>s<t&&c>e))continue;let u=typeof i.keep==`number`?i.keep:i.keep?.exec(l)?.[0].length??0;r.push({start:s,end:c,kind:typeof i.kind==`string`?i.kind:i.kind([a[1]??``]),rule:i.rule,action:i.action,category:i.category,keep:Math.min(u,l.length)})}}r.sort((e,t)=>e.start-t.start||t.end-e.end);let i=[];for(let e of r)(!i.length||e.start>=i[i.length-1].end)&&i.push(e);return i}function Lv(e,t){let n=Iv(e,Nv(t));return{masked:n.filter(e=>e.action===`mask`).length,blocked:[...new Set(n.filter(e=>e.action===`block`).map(e=>e.kind))]}}var Rv={"/goal":[{name:`pause`,aliases:[],description:`Pause the current session goal`},{name:`resume`,aliases:[],description:`Resume a paused session goal`},{name:`clear`,aliases:[],description:`Clear the session goal`}]};function zv(e,t){if(!e)return null;let n=t.trimStart();return n?n.search(/\s/)>=0?null:n:``}function Bv(e,t){if(!e)return[];let n=Rv[e]??[],r=t.trim().toLowerCase();return r?n.filter(e=>e.name.toLowerCase().startsWith(r)||e.aliases.some(e=>e.toLowerCase().startsWith(r))):n}var Vv=U.createContext(void 0);function Hv(e){let t=U.useContext(Vv);if(!e&&t===void 0)throw Error(Cr(27));return t}var Uv=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),Wv={"data-starting-style":``},Gv={"data-ending-style":``},Kv={transitionStatus(e){return e===`starting`?Wv:e===`ending`?Gv:null}};(function(e){return e.open=`data-open`,e.closed=`data-closed`,e[e.startingStyle=Uv.startingStyle]=`startingStyle`,e[e.endingStyle=Uv.endingStyle]=`endingStyle`,e.anchorHidden=`data-anchor-hidden`,e.side=`data-side`,e.align=`data-align`,e})({});var qv={"data-popup-open":``},Jv={"data-popup-open":``,"data-pressed":``},Yv={"data-open":``},Xv={"data-closed":``},Zv={"data-anchor-hidden":``},Qv={open(e){return e?qv:null}},$v={open(e){return e?Jv:null}},ey={open(e){return e?Yv:Xv},anchorHidden(e){return e?Zv:null}},ty={...ey,...Kv},ny=U.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Hv(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Vr(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:ty,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})});function ry(){return typeof window<`u`}function iy(e){return sy(e)?(e.nodeName||``).toLowerCase():`#document`}function ay(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function oy(e){return((sy(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function sy(e){return ry()?e instanceof Node||e instanceof ay(e).Node:!1}function cy(e){return ry()?e instanceof Element||e instanceof ay(e).Element:!1}function ly(e){return ry()?e instanceof HTMLElement||e instanceof ay(e).HTMLElement:!1}function uy(e){return!ry()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof ay(e).ShadowRoot}function dy(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Sy(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function fy(e){return/^(table|td|th)$/.test(iy(e))}function py(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var my=/transform|translate|scale|rotate|perspective|filter/,hy=/paint|layout|strict|content/,gy=e=>!!e&&e!==`none`,_y;function vy(e){let t=cy(e)?Sy(e):e;return gy(t.transform)||gy(t.translate)||gy(t.scale)||gy(t.rotate)||gy(t.perspective)||!by()&&(gy(t.backdropFilter)||gy(t.filter))||my.test(t.willChange||``)||hy.test(t.contain||``)}function yy(e){let t=wy(e);for(;ly(t)&&!xy(t);){if(vy(t))return t;if(py(t))return null;t=wy(t)}return null}function by(){return _y??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),_y}function xy(e){return/^(html|body|#document)$/.test(iy(e))}function Sy(e){return ay(e).getComputedStyle(e)}function Cy(e){return cy(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wy(e){if(iy(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||uy(e)&&e.host||oy(e);return uy(t)?t.host:t}function Ty(e){let t=wy(e);return xy(t)?(e.ownerDocument||e).body:ly(t)&&dy(t)?t:Ty(t)}function Ey(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ty(e),i=r===e.ownerDocument?.body,a=ay(r);if(i){let e=Dy(a);return t.concat(a,a.visualViewport||[],dy(r)?r:[],e&&n?Ey(e):[])}return t.concat(r,Ey(r,[],n))}function Dy(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var Oy={...U},ky=Oy.useInsertionEffect,$ee=ky&&ky!==Oy.useLayoutEffect?ky:e=>e();function Ay(e){let t=Tr(ete).current;return t.next=e,$ee(t.effect),t.trampoline}function ete(){let e={next:void 0,callback:tte,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function tte(){}var X=typeof document<`u`?U.useLayoutEffect:()=>{},nte=U.createContext(void 0);function jy(e=!1){let t=U.useContext(nte);if(t===void 0&&!e)throw Error(Cr(16));return t}function rte(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:U.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function My(e){return e?.ownerDocument||document}function Ny(e,t,{detail:n=0}={}){e.dispatchEvent(new(ay(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Py(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=U.useRef(null),s=jy(!0),c=a??s!==void 0,{props:l}=rte({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=U.useCallback(()=>{let e=o.current;Fy(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return X(u,[u]),{getButtonProps:U.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return cr({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(yr(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Fy(r),s=!i&&ite(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),Ny(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Ny(r,e)))},onKeyUp(e){if(!t){if(yr(e),a?.(e),e.target===e.currentTarget&&i&&c&&Fy(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),Ny(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Ay(e=>{o.current=e,u()})}}function Fy(e){return ly(e)&&e.tagName===`BUTTON`}function ite(e){return ly(e)&&e.tagName===`A`&&!!e.href}var Iy=`none`,Ly=`trigger-press`,Ry=`trigger-hover`,zy=`trigger-focus`,ate=`outside-press`,By=`item-press`,ote=`close-press`,Vy=`focus-out`,ste=`escape-key`,Hy=`list-navigation`,Uy=`cancel-open`,Wy=`sibling-open`,Gy=`imperative-action`,cte=`window-resize`;function Ky(e,t,n,r){let i=!1,a=!1,o=r??Lr;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var qy=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=Hv(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Py({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Ky(ote,e.nativeEvent))}return Vr(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})}),Jy=0;function lte(e,t=`mui`){let[n,r]=U.useState(e),i=e||n;return U.useEffect(()=>{n??(Jy+=1,r(`${t}-${Jy}`))},[n,t]),i}var Yy=Oy.useId;function Xy(e,t){if(Yy!==void 0){let n=Yy();return e??(t?`${t}-${n}`:n)}return lte(e,t)}function Zy(e){return Xy(e,`base-ui`)}var Qy=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Hv(),c=Zy(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Vr(`p`,e,{ref:t,props:[{id:c},o]})});function $y(e){U.useEffect(e,Ir)}var eb=0,tb=class e{static create(){return new e}currentId=eb;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=eb,t()},e)}isStarted(){return this.currentId!==eb}clear=()=>{this.currentId!==eb&&(clearTimeout(this.currentId),this.currentId=eb)};disposeEffect=()=>this.clear};function nb(){let e=Tr(tb.create).current;return $y(e.disposeEffect),e}function ute(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:dte,platform:fte,maxTouchPoints:pte}=ute(),rb=dte.toLowerCase(),ib=fte.toLowerCase(),ab=/^i(os$|p)/.test(ib)||ib===`macintel`&&pte>1,ob=`android`,sb=ib===ob||rb.includes(ob),cb=!ab&&ib.startsWith(`mac`);ib.startsWith(`win`),!sb&&/^(linux|chrome os)/.test(ib);var mte=cb||ab,lb=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`);!lb&&rb.includes(`firefox`),!lb&&rb.includes(`chrom`);var hte=mte,ub=/jsdom|happydom/.test(rb);function db(e){e.preventDefault(),e.stopPropagation()}function gte(e){return`nativeEvent`in e}function fb(e){return e.pointerType===``&&e.isTrusted?!0:sb&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function pb(e){return ub?!1:!sb&&e.width===0&&e.height===0||sb&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function mb(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function _te(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}var vte=`data-base-ui-focusable`,yte=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,hb=`ArrowLeft`,gb=`ArrowRight`,bte=`ArrowUp`,_b=`ArrowDown`;function vb(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function yb(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&uy(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function bb(e){return`composedPath`in e?e.composedPath()[0]:e.target}function xb(e,t){if(!cy(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(`data-trigger-disabled`);for(let[,e]of t.entries())if(yb(e,n))return!e.hasAttribute(`data-trigger-disabled`);return!1}function Sb(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function Cb(e){return e.matches(`html,body`)}function wb(e){return ly(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function Tb(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${yte}`)!=null}function Eb(e){return e?e.getAttribute(`role`)===`combobox`&&wb(e):!1}function Db(e){if(!e||ub)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function Ob(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function kb(e,t){return t!=null&&!mb(t)?0:typeof e==`function`?e():e}function Ab(e,t,n){let r=kb(e,n);return typeof r==`number`?r:r?.[t]}function jb(e){return typeof e==`function`?e():e}function Mb(e,t){return t||e===`click`||e===`mousedown`}function Nb(e){return e?.includes(`mouse`)&&e!==`mousedown`}function Pb(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Fb(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Ib(e){let t=Tr(Lb,e).current;return t.next=e,X(t.effect),t}function Lb(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Rb=null;globalThis.requestAnimationFrame;var zb=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},Bb=class e{static create(){return new e}static request(e){return zb.request(e)}static cancel(e){return zb.cancel(e)}currentId=Rb;request(e){this.cancel(),this.currentId=zb.request(()=>{this.currentId=Rb,e()})}cancel=()=>{this.currentId!==Rb&&(zb.cancel(this.currentId),this.currentId=Rb)};disposeEffect=()=>this.cancel};function Vb(){let e=Tr(Bb.create).current;return $y(e.disposeEffect),e}var Hb={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Ub={...Hb,position:`fixed`,top:0,left:0},Wb={...Hb,position:`absolute`},Gb=U.forwardRef(function(e,t){let[n,r]=U.useState();X(()=>{hte&&lb&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,K.jsx)(`span`,{...e,ref:t,style:Ub,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Kb=Math.min,qb=Math.max,Jb=Math.round,Yb=Math.floor,Xb=e=>({x:e,y:e}),Zb={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Qb(e,t,n){return qb(e,Kb(t,n))}function $b(e,t){return typeof e==`function`?e(t):e}function ex(e){return e.split(`-`)[0]}function tx(e){return e.split(`-`)[1]}function nx(e){return e===`x`?`y`:`x`}function rx(e){return e===`y`?`height`:`width`}function ix(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ax(e){return nx(ix(e))}function ox(e,t,n){n===void 0&&(n=!1);let r=tx(e),i=ax(e),a=rx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=hx(o)),[o,hx(o)]}function sx(e){let t=hx(e);return[cx(e),t,cx(t)]}function cx(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var lx=[`left`,`right`],ux=[`right`,`left`],dx=[`top`,`bottom`],fx=[`bottom`,`top`];function px(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ux:lx:t?lx:ux;case`left`:case`right`:return t?dx:fx;default:return[]}}function mx(e,t,n,r){let i=tx(e),a=px(ex(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(cx)))),a}function hx(e){let t=ex(e);return Zb[t]+e.slice(t.length)}function gx(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function _x(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:gx(e)}function vx(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function yx(e,t){return t<0||t>=e.length}function bx(e,t){return Sx(e.current,{disabledIndices:t})}function xx(e,t){return Sx(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Sx(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Cx(e,a,r));return a}function Cx(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Tx(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function wx(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Tx(e,t=e?Sy(e):null){return!e||!e.isConnected||!t||wx(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Ex=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Dx(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return uy(n)?n.host:null}function Ox(e){for(let t of Array.from(e.children))if(iy(t)===`summary`)return t;return null}function kx(e,t){let n=Ox(t);return!!n&&(e===n||yb(n,e))}function Ax(e){let t=e?iy(e):``;return e!=null&&e.matches(Ex)&&(t!==`summary`||e.parentElement!=null&&iy(e.parentElement)===`details`&&Ox(e.parentElement)===e)&&(t!==`details`||Ox(e)==null)&&(t!==`input`||e.type!==`hidden`)}function jx(e){if(!Ax(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Dx(t)){let n=t!==e,r=iy(t)===`slot`;if(t.hasAttribute(`inert`)||n&&iy(t)===`details`&&!t.open&&!kx(e,t)||t.hasAttribute(`hidden`)||!r&&!Mx(t,n))return!1}return!0}function Mx(e,t){let n=Sy(e);return t?n.display!==`none`:Tx(e,n)}function Nx(e){let t=e.tabIndex;if(t<0){let t=iy(e);if(t===`details`||t===`audio`||t===`video`||ly(e)&&e.isContentEditable)return 0}return t}function Px(e){if(iy(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Fx(e,t){let n=Px(e);if(!n)return!0;let r=t.find(e=>{let t=Px(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Px(e);return t?.name===n.name&&t.form===n.form})===n}function Ix(e){if(ly(e)&&iy(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return ly(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Lx(e,t){Ix(e).forEach(e=>{Ax(e)&&t.push(e),Lx(e,t)})}function Rx(e,t,n){Ix(e).forEach(e=>{ly(e)&&e.matches(t)&&n.push(e),Rx(e,t,n)})}function zx(e){return jx(e)&&Nx(e)>=0}function Bx(e){let t=[];return Lx(e,t),t.filter(jx)}function Vx(e){let t=Bx(e);return t.filter(e=>Nx(e)>=0&&Fx(e,t))}function Hx(e,t){let n=Vx(e),r=n.length;if(r===0)return;let i=vb(My(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Ux(e){return Hx(My(e).body,1)||e}function Wx(e){return Hx(My(e).body,-1)||e}function Gx(e,t){if(!e)return null;let n=Vx(My(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function Kx(e){return Gx(e,1)}function qx(e){return Gx(e,-1)}function Jx(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!yb(n,r)}function Yx(e){Vx(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function Xx(e){let t=[];Rx(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function Zx(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Zx(e,t.id,n)])}function Qx(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function $x(e){return`data-base-ui-${e}`}var eS=0;function tS(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(eS);function a(){i&&!i()||e?.focus({preventScroll:n})}if(r)return a(),Fr;let o=requestAnimationFrame(a);return eS=o,()=>{eS===o&&(cancelAnimationFrame(o),eS=0)}}var nS={inert:new WeakMap,"aria-hidden":new WeakMap},rS=`data-base-ui-inert`,iS={inert:new WeakSet,"aria-hidden":new WeakSet},aS=new WeakMap,oS=0;function sS(e){return iS[e]}function cS(e){return e?uy(e)?e.host:cS(e.parentNode):null}var lS=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=cS(t);return e.contains(n)?n:null}).filter(e=>e!=null),uS=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},dS=(e,t,n)=>{let r=[],i=e=>{!e||n.has(e)||Array.from(e.children).forEach(e=>{iy(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function fS(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=lS(t,e),l=i?dS(t,uS(c),new Set(c)):[],u=[],d=[];if(a){let e=nS[a],n=sS(a);s=n,o=e;let r=lS(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);dS(t,uS(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(aS.get(e)||0)+1;aS.set(e,t),d.push(e),t===1&&e.setAttribute(rS,``)}),oS+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(aS.get(e)||0)-1;aS.set(e,t),t||e.removeAttribute(rS)}),--oS,oS||(nS.inert=new WeakMap,nS[`aria-hidden`]=new WeakMap,iS.inert=new WeakSet,iS[`aria-hidden`]=new WeakSet,aS=new WeakMap)}}function pS(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=My(e[0]).body;return fS(e,a,n,r,{mark:i})}var mS={style:{transition:`none`}},hS=`data-base-ui-click-trigger`,gS={fallbackAxisSide:`none`},_S={fallbackAxisSide:`end`},vS={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},yS=U.createContext(null),bS=()=>U.useContext(yS),xS=$x(`portal`);function SS(e={}){let{ref:t,container:n,componentProps:r=Lr,elementProps:i}=e,a=Xy(),o=bS()?.portalNode,[s,c]=U.useState(null),[l,u]=U.useState(null),d=Ay(e=>{e!==null&&u(e)}),f=U.useRef(null);X(()=>{if(n===null){f.current&&(f.current=null,u(null),c(null));return}let e=(n&&(sy(n)?n:n.current))??o??document.body;if(e==null){f.current&&(f.current=null,u(null),c(null));return}f.current!==e&&(f.current=e,u(null),c(e))},[n,o]);let p=Vr(`div`,r,{ref:[t,d],props:[{id:a,[xS]:``},i]}),m=s&&p?Gs.createPortal(p,s):null;return{node:l,nodeId:U.isValidElement(p)?p.props.id:void 0,subtree:m}}var CS=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,...s}=e,{node:c,nodeId:l,subtree:u}=SS({container:o,ref:t,componentProps:e,elementProps:s}),d=U.useRef(null),f=U.useRef(null),p=U.useRef(null),m=U.useRef(null),[h,g]=U.useState(null),_=U.useRef(!1),v=h?.modal,y=h?.open,b=!!h&&!h.modal&&h.open&&!!c;U.useEffect(()=>{if(!c||v)return;function e(e){c&&e.relatedTarget&&Jx(e)&&(e.type===`focusin`?_.current&&=(Xx(c),!1):(Yx(c),_.current=!0))}return Fb(Pb(c,`focusin`,e,!0),Pb(c,`focusout`,e,!0))},[c,v]),X(()=>{!c||y!==!0||!_.current||(Xx(c),_.current=!1)},[y,c]);let x=U.useMemo(()=>({beforeOutsideRef:d,afterOutsideRef:f,beforeInsideRef:p,afterInsideRef:m,portalNode:c,setFocusManagerState:g}),[c]);return(0,K.jsxs)(U.Fragment,{children:[u,(0,K.jsxs)(yS.Provider,{value:x,children:[b&&c&&(0,K.jsx)(Gb,{"data-type":`outside`,ref:d,onFocus:e=>{Jx(e,c)?p.current?.focus():Wx(h?h.domReference:null)?.focus()}}),b&&c&&(0,K.jsx)(`span`,{"aria-owns":l,style:vS}),c&&Gs.createPortal(a,c),b&&c&&(0,K.jsx)(Gb,{"data-type":`outside`,ref:f,onFocus:e=>{Jx(e,c)?m.current?.focus():(Ux(h?h.domReference:null)?.focus(),h?.closeOnFocusOut&&h?.onOpenChange(!1,Ky(`focus-out`,e.nativeEvent)))}})]})]})});function wS(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var TS=class{nodesRef={current:[]};events=wS();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},ES=U.createContext(null),DS=U.createContext(null),OS=()=>U.useContext(ES)?.id||null,kS=e=>{let t=U.useContext(DS);return e??t};function AS(e){let t=Xy(),n=kS(e),r=OS();return X(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function jS(e){let{children:t,id:n}=e,r=OS();return(0,K.jsx)(ES.Provider,{value:U.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function MS(e){let{children:t,externalTree:n}=e,r=Tr(()=>n??new TS).current;return(0,K.jsx)(DS.Provider,{value:r,children:t})}function NS(e){return e==null?e:`current`in e?e.current:e}function PS(e,t){let n=ay(bb(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var FS=20,IS=[];function LS(){IS=IS.filter(e=>e.deref()?.isConnected)}function RS(e){LS(),e&&iy(e)!==`body`&&(IS.push(new WeakRef(e)),IS.length>FS&&(IS=IS.slice(-20)))}function zS(){return LS(),IS[IS.length-1]?.deref()}function BS(e){return e?zx(e)?e:Vx(e)[0]||e:null}function VS(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Bx(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return zx(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function HS(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:l=``,nextFocusableElement:u,previousFocusableElement:d,beforeContentFocusGuardRef:f,externalTree:p,getInsideElements:m}=e,h=`rootStore`in t?t.rootStore:t,g=h.useState(`open`),_=h.useState(`domReferenceElement`),v=h.useState(`floatingElement`),{events:y,dataRef:b}=h.context,x=Ay(()=>b.current.floatingContext?.nodeId),S=i===!1,C=Eb(_)&&S,w=Ib(i),T=Ib(a),E=Ib(l),D=Ib(g),O=kS(p),k=bS(),A=U.useRef(!1),j=U.useRef(!1),M=U.useRef(!1),N=U.useRef(null),P=U.useRef(``),F=U.useRef(``),I=U.useRef(null),L=U.useRef(null),R=Er(I,f,k?.beforeInsideRef),ee=Er(L,k?.afterInsideRef),z=nb(),B=nb(),V=Vb(),te=k!=null,H=Ob(v),ne=Ay((e=H)=>e?Vx(e):[]),re=Ay(()=>m?.().filter(e=>e!=null)??[]);U.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&yb(H,vb(My(H)))&&ne().length===0&&!C&&db(e)}return Pb(My(H),`keydown`,e)},[r,H,s,C,ne]),U.useEffect(()=>{if(r||!g)return;let e=My(H);function t(){M.current=!1}function n(e){let t=bb(e),n=re(),r=yb(v,t)||yb(_,t)||yb(k?.portalNode,t)||n.some(e=>e===t||yb(e,t));M.current=!r,F.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(j.current=!0,B.start(0,()=>{j.current=!1}))}function i(){F.current=`keyboard`}return Fb(Pb(e,`pointerdown`,n,!0),Pb(e,`pointerup`,t,!0),Pb(e,`pointercancel`,t,!0),Pb(e,`keydown`,i,!0),t)},[r,v,_,H,g,k,B,re]),U.useEffect(()=>{if(r||!c)return;let e=My(H);function t(){j.current=!0,B.start(0,()=>{j.current=!1})}function n(e){let t=bb(e);zx(t)&&(N.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=bb(t);s&&n==null&&i!=null&&yb(v,i)&&RS(i),queueMicrotask(()=>{let a=x(),c=h.context.triggerElements,l=re(),f=n?.hasAttribute($x(`focus-guard`))&&[I.current,L.current,k?.beforeInsideRef.current,k?.afterInsideRef.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,NS(d),NS(u)].includes(n),p=!(yb(_,n)||yb(v,n)||yb(n,v)||yb(k?.portalNode,n)||l.some(e=>e===n||yb(e,n))||c.hasMatchingElement(e=>yb(e,n))||f||O&&(Zx(O.nodesRef.current,a).find(e=>yb(e.context?.elements.floating,n)||yb(e.context?.elements.domReference,n))||Qx(O.nodesRef.current,a).find(e=>[e.context?.elements.floating,Ob(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===_&&H&&VS(H),o&&r!==_&&!Tx(i)&&vb(e)===e.body){if(ly(H)&&(H.focus(),o===`popup`)){V.request(()=>{H.focus()});return}let e=ne(),t=N.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||H;ly(n)&&n.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(C||!s)&&n&&p&&!j.current&&(C||n!==zS())&&(A.current=!0,h.setOpen(!1,Ky(Vy,t)))})}function a(){M.current||(b.current.insideReactTree=!0,z.start(0,()=>{b.current.insideReactTree=!1}))}let l=ly(_)?_:null;if(!(!v&&!l))return Fb(l&&Pb(l,`focusout`,i),l&&Pb(l,`pointerdown`,t),v&&Pb(v,`focusin`,n),v&&Pb(v,`focusout`,i),v&&k&&Pb(v,`focusout`,a,!0))},[r,_,v,H,s,O,k,h,c,o,ne,C,x,b,z,B,V,u,d,re]),U.useEffect(()=>{if(r||!v||!g)return;let e=Array.from(k?.portalNode?.querySelectorAll(`[${$x(`portal`)}]`)||[]),t=(O?Qx(O.nodesRef.current,x()):[]).find(e=>Eb(e.context?.elements.domReference||null))?.context?.elements.domReference,n=pS([v,...e,I.current,L.current,k?.beforeOutsideRef.current,k?.afterOutsideRef.current,...re(),t,NS(d),NS(u),C?_:null].filter(e=>e!=null),{ariaHidden:s||C,mark:!1}),i=pS([v,...e].filter(e=>e!=null));return()=>{i(),n()}},[g,r,_,v,s,k,C,O,x,u,d,re]),X(()=>{if(!g||r||!ly(H))return;P.current=``,F.current=``;let e=My(H),t=vb(e);queueMicrotask(()=>{let n=w.current,r=typeof n==`function`?n(E.current||``):n;if(r===void 0||r===!1||yb(H,t))return;let i=null,a=()=>(i??=ne(H),i[0]||H),o;o=r===!0||r===null?a():NS(r),o||=a();let s=yb(H,vb(e));tS(o,{preventScroll:o===H,shouldFocus(){if(!D.current)return!1;if(s)return!0;let t=vb(e);return!(t!==o&&yb(H,t))}})})},[r,g,H,ne,w,E,D]),X(()=>{if(r||!H)return;let e=My(H),t=vb(e),n=E.current==null;RS(t);function i(e){if(e.open||(P.current=PS(e.nativeEvent,F.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(A.current=!0),e.reason===`outside-press`){if(e.nested)A.current=!1;else if(fb(e.nativeEvent)||pb(e.nativeEvent))A.current=!1;else{let e=!1;My(H).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?A.current=!1:A.current=!0}}}y.on(`openchange`,i);function a(e){let r=T.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=_?.isConnected?_:null,o=t?.isConnected&&iy(t)!==`body`?t:null,s=n?o||a:a||o;return s||=zS()||null,typeof i==`boolean`?s:NS(i)||s||null}return()=>{y.off(`openchange`,i);let t=vb(e),n=re(),r=yb(v,t)||n.some(e=>e===t||yb(e,t))||O&&Zx(O.nodesRef.current,x(),!1).some(e=>yb(e.context?.elements.floating,t)),o=T.current,s=P.current,c=a(s);queueMicrotask(()=>{let n=BS(c),i=typeof o!=`boolean`;if(o&&!A.current&&ly(n)&&(!(!i&&n!==t&&t!==e.body)||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}A.current=!1})}},[r,v,H,T,E,y,O,_,x,re]),X(()=>{if(!lb||g||!v)return;let e=vb(My(v));!ly(e)||!wb(e)||yb(v,e)&&e.blur()},[g,v]),X(()=>{if(!(r||!k))return k.setFocusManagerState({modal:s,closeOnFocusOut:c,open:g,onOpenChange:h.setOpen,domReference:_}),()=>{k.setFocusManagerState(null)}},[r,k,s,g,h,c,_]),X(()=>{if(!(r||!H))return VS(H),()=>{queueMicrotask(LS)}},[r,H]);let ie=!r&&(!s||!C)&&(te||s);return(0,K.jsxs)(U.Fragment,{children:[ie&&(0,K.jsx)(Gb,{"data-type":`inside`,ref:R,onFocus:e=>{if(s){let e=ne();tS(e[e.length-1])}else k?.portalNode&&(A.current=!1,Jx(e,k.portalNode)?Ux(_)?.focus():NS(d??k.beforeOutsideRef)?.focus())}}),n,ie&&(0,K.jsx)(Gb,{"data-type":`inside`,ref:ee,onFocus:e=>{s?tS(ne()[0]):k?.portalNode&&(c&&(A.current=!0),Jx(e,k.portalNode)?Wx(_)?.focus():NS(u??k.afterOutsideRef)?.focus())}})]})}function US(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=Ly}=t,l=`rootStore`in e?e.rootStore:e,u=l.context.dataRef,d=U.useRef(void 0),f=Vb(),p=nb(),m=U.useMemo(()=>{function e(e,t,n,r){let i=Ky(c,t,n);e&&r===`touch`&&s>0?p.start(s,()=>{l.setOpen(!0,i)}):l.setOpen(e,i)}function t(e,t,n){let r=u.current.openEvent,a=l.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){d.current=mb(e.pointerType,!0)&&pb(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=d.current,o=n.nativeEvent,s=l.select(`open`);if(n.button!==0||r===`click`||mb(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),u=bb(o);if(wb(u)){e(c,o,u,i);return}let p=n.currentTarget;f.request(()=>{e(c,o,p,i)})},onClick(n){if(r===`mousedown-only`)return;let i=d.current;if(r===`mousedown`&&i){d.current=void 0;return}mb(i,!0)&&a||e(t(l.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){d.current=void 0}}},[u,r,a,c,l,o,i,f,p,s]);return U.useMemo(()=>n?{reference:m}:Lr,[n,m])}function WS(){return!1}function GS(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function KS(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=WS,bubbles:s,externalTree:c}=t,l=`rootStore`in e?e.rootStore:e,u=l.useState(`open`),d=l.useState(`floatingElement`),{dataRef:f}=l.context,p=kS(c),m=Ay(typeof i==`function`?i:()=>!1),h=typeof i==`function`?m:i,g=h!==!1,_=Ay(()=>a),{escapeKey:v,outsidePress:y}=GS(s),b=U.useRef(!1),x=U.useRef(!1),S=U.useRef(!1),C=U.useRef(!1),w=U.useRef(``),T=U.useRef(null),E=nb(),D=nb(),O=Ay(()=>{D.clear(),f.current.insideReactTree=!1}),k=Ay(e=>{let t=f.current.floatingContext?.nodeId;return(p?Zx(p.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),A=Ay(e=>Sb(e,l.select(`floatingElement`))||Sb(e,l.select(`domReferenceElement`))),j=Ay(e=>{o()&&l.setOpen(!1,Ky(Ly,e.nativeEvent))}),M=Ay(e=>{if(!u||!n||!r||e.key!==`Escape`||C.current||!v&&k(`__escapeKeyBubbles`))return;let t=Ky(ste,gte(e)?e.nativeEvent:e);l.setOpen(!1,t),t.isCanceled||e.preventDefault(),!v&&!t.isPropagationAllowed&&e.stopPropagation()}),N=Ay(()=>{f.current.insideReactTree=!0,D.start(0,O)}),P=Ay(e=>{if(!u||!n||e.button!==0)return;let t=bb(e.nativeEvent);yb(l.select(`floatingElement`),t)&&(b.current||(b.current=!0,x.current=!1))}),F=Ay(e=>{!u||!n||(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&b.current&&(x.current=!0)});U.useEffect(()=>{if(!u||!n)return O;f.current.__escapeKeyBubbles=v,f.current.__outsidePressBubbles=y;let e=new tb,t=new tb;function i(){e.clear(),C.current=!0}function a(){e.start(lb?5:0,()=>{C.current=!1})}function o(){S.current=!0,t.start(0,()=>{S.current=!1})}function s(){b.current=!1,x.current=!1}function c(){let e=w.current,t=e===`pen`||!e?`mouse`:e,n=_(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=c();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function D(e){let t=f.current.floatingContext?.nodeId,n=p&&Zx(p.nodesRef.current,t).some(t=>Sb(e,t.context?.elements.floating));return A(e)||n}function j(e){if(m(e)){e.type!==`click`&&!A(e)&&(t.clear(),S.current=!1),O();return}if(f.current.insideReactTree){O();return}let n=bb(e),r=`[${$x(`inert`)}]`,i=cy(n)?n.getRootNode():null,a=Array.from((uy(i)?i:My(l.select(`floatingElement`))).querySelectorAll(r)),o=l.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>yb(e,n))))return;let s=cy(n)?n:null;for(;s&&!xy(s);){let e=wy(s);if(xy(e)||!cy(e))break;s=e}if(!(a.length&&cy(n)&&!Cb(n)&&!yb(n,l.select(`floatingElement`))&&a.every(e=>!yb(s,e)))){if(ly(n)&&!(`touches`in e)){let t=xy(n),r=Sy(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!D(e)){if(c()===`intentional`&&S.current){t.clear(),S.current=!1;return}typeof h==`function`&&!h(e)||k(`__outsidePressBubbles`)||(l.setOpen(!1,Ky(ate,e)),O())}}}function N(e){c()!==`sloppy`||e.pointerType===`touch`||!l.select(`open`)||!n||A(e)||j(e)}function P(e){if(c()!==`sloppy`||!l.select(`open`)||!n||A(e))return;let t=e.touches[0];t&&(T.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},E.start(1e3,()=>{T.current&&(T.current.dismissOnTouchEnd=!1,T.current.dismissOnMouseDown=!1)}))}function F(e,t){let n=bb(e);if(!n)return;let r=Pb(n,e.type,()=>{t(e),r()})}function I(e){w.current=`touch`,F(e,P)}function L(e){E.clear(),e.type===`pointerdown`&&(w.current=e.pointerType),!(e.type===`mousedown`&&T.current&&!T.current.dismissOnMouseDown)&&F(e,e=>{e.type===`pointerdown`?N(e):j(e)})}function R(e){if(!b.current)return;let n=x.current;if(s(),c()===`intentional`){if(e.type===`pointercancel`){n&&o();return}if(!D(e)){if(n){o();return}typeof h==`function`&&!h(e)||(t.clear(),S.current=!0,O())}}}function ee(e){if(c()!==`sloppy`||!T.current||A(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-T.current.startX),r=Math.abs(t.clientY-T.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(T.current.dismissOnTouchEnd=!0),i>10&&(j(e),E.clear(),T.current=null)}function z(e){F(e,ee)}function B(e){c()!==`sloppy`||!T.current||A(e)||(T.current.dismissOnTouchEnd&&j(e),E.clear(),T.current=null)}function V(e){F(e,B)}let te=My(d),H=Fb(r&&Fb(Pb(te,`keydown`,M),Pb(te,`compositionstart`,i),Pb(te,`compositionend`,a)),g&&Fb(Pb(te,`click`,L,!0),Pb(te,`pointerdown`,L,!0),Pb(te,`pointerup`,R,!0),Pb(te,`pointercancel`,R,!0),Pb(te,`mousedown`,L,!0),Pb(te,`mouseup`,R,!0),Pb(te,`touchstart`,I,!0),Pb(te,`touchmove`,z,!0),Pb(te,`touchend`,V,!0)));return()=>{H(),e.clear(),t.clear(),s(),S.current=!1,O()}},[f,d,r,g,h,u,n,v,y,M,O,_,k,A,p,l,E]);let I=U.useMemo(()=>({onKeyDown:M,onPointerDown:j,onClick:j}),[M,j]),L=U.useMemo(()=>({onKeyDown:M,onPointerDown:F,onMouseDown:F,onClickCapture:N,onMouseDownCapture(e){N(),P(e)},onPointerDownCapture(e){N(),P(e)},onMouseUpCapture:N,onTouchEndCapture:N,onTouchMoveCapture:N}),[M,N,P,F]);return U.useMemo(()=>n?{reference:I,floating:L,trigger:I}:{},[n,I,L])}function qS(e,t,n){let{reference:r,floating:i}=e,a=ix(t),o=ax(t),s=rx(o),c=ex(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=tx(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function JS(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=$b(t,e),p=_x(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=vx(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=vx(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var YS=50,XS=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:JS},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=qS(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<YS&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=qS(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ZS=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=$b(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=ex(r),_=ix(o),v=ex(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[hx(o)]:sx(o)),x=p!==`none`;!d&&x&&b.push(...mx(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ox(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===ix(t)||T.every(e=>ix(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=ix(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}},QS=new Set([`left`,`top`]);async function $S(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ex(n),s=tx(n),c=ix(n)===`y`,l=QS.has(o)?-1:1,u=a&&c?-1:1,d=$b(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var eC=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await $S(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},tC=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=$b(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ix(i),p=nx(f),m=u[p],h=u[f],g=(e,t)=>Qb(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},nC=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=$b(e,t),u={x:n,y:r},d=ix(i),f=nx(d),p=u[f],m=u[d],h=$b(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=QS.has(ex(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},rC=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=$b(e,t),c=await i.detectOverflow(t,s),l=ex(n),u=tx(n),d=ix(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Kb(p-c[m],g),y=Kb(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*qb(c.left,c.right):S=p-2*qb(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function iC(e){let t=Sy(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ly(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Jb(n)!==a||Jb(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function aC(e){return cy(e)?e:e.contextElement}function oC(e){let t=aC(e);if(!ly(t))return Xb(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=iC(t),o=(a?Jb(n.width):n.width)/r,s=(a?Jb(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var sC=Xb(0);function cC(e){let t=ay(e);return!by()||!t.visualViewport?sC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lC(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===ay(e)}function uC(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=aC(e),o=Xb(1);t&&(r?cy(r)&&(o=oC(r)):o=oC(e));let s=lC(a,n,r)?cC(a):Xb(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=ay(a),t=cy(r)?ay(r):r,n=e,i=Dy(n);for(;i&&t!==n;){let e=oC(i),t=i.getBoundingClientRect(),r=Sy(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=ay(i),i=Dy(n)}}return vx({width:u,height:d,x:c,y:l})}function dC(e,t){let n=Cy(e).scrollLeft;return t?t.left+n:uC(oy(e)).left+n}function fC(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-dC(e,n),y:n.top+t.scrollTop}}function pC(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=oy(r),s=t?py(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Xb(1),u=Xb(0),d=ly(r);if((d||!a)&&((iy(r)!==`body`||dy(o))&&(c=Cy(r)),d)){let e=uC(r);l=oC(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?fC(o,c):Xb(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function mC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function xte(e){let t=Cy(e),n=e.ownerDocument.body,r=qb(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=qb(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+dC(e),o=-t.scrollTop;return Sy(n).direction===`rtl`&&(a+=qb(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var hC=25;function gC(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=ay(e),a=oy(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!by()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(dC(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=hC&&(s-=o)}return{width:s,height:c,x:l,y:u}}function _C(e,t){let n=uC(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=oC(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function vC(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=gC(e,n,t);else if(t===`document`)r=xte(oy(e));else if(cy(t))r=_C(t,n);else{let n=cC(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return vx(r)}function yC(e,t){let n=t.get(e);if(n)return n;let r=Ey(e,[],!1).filter(e=>cy(e)&&iy(e)!==`body`),i=null,a=Sy(e).position===`fixed`,o=a?wy(e):e;for(;cy(o)&&!xy(o);){let e=Sy(o),t=vy(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=wy(o)}return t.set(e,r),r}function bC(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?py(t)?[]:yC(t,this._c):[].concat(n),r],o=vC(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=vC(t,a[e],i);s=qb(n.top,s),c=Kb(n.right,c),l=Kb(n.bottom,l),u=qb(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function xC(e){let{width:t,height:n}=iC(e);return{width:t,height:n}}function SC(e,t,n){let r=ly(t),i=oy(t),a=n===`fixed`,o=uC(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Xb(0);if((r||!a)&&((iy(t)!==`body`||dy(i))&&(s=Cy(t)),r)){let e=uC(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=dC(i));let l=i&&!r&&!a?fC(i,s):Xb(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function CC(e){return Sy(e).position===`static`}function wC(e,t){if(!ly(e)||Sy(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return oy(e)===n&&(n=n.ownerDocument.body),n}function TC(e,t){let n=ay(e);if(py(e))return n;if(!ly(e)){let t=wy(e);for(;t&&!xy(t);){if(cy(t)&&!CC(t))return t;t=wy(t)}return n}let r=wC(e,t);for(;r&&fy(r)&&CC(r);)r=wC(r,t);return r&&xy(r)&&CC(r)&&!vy(r)?n:r||yy(e)||n}var EC=async function(e){let t=this.getOffsetParent||TC,n=this.getDimensions,r=await n(e.floating);return{reference:SC(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function DC(e){return Sy(e).direction===`rtl`}var OC={convertOffsetParentRelativeRectToViewportRelativeRect:pC,getDocumentElement:oy,getClippingRect:bC,getOffsetParent:TC,getElementRects:EC,getClientRects:mC,getDimensions:xC,getScale:oC,isElement:cy,isRTL:DC};function kC(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function AC(e,t,n){let r=null,i,a=oy(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Yb(d),h=Yb(a.clientWidth-(u+f)),g=Yb(a.clientHeight-(d+p)),_=Yb(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:qb(0,Kb(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!kC(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=ay(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function jC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=aC(e),u=i||a?[...l?Ey(l):[],...t?Ey(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?AC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?uC(e):null;c&&g();function g(){let t=uC(e);h&&!kC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var MC=eC,NC=tC,PC=ZS,FC=rC,IC=nC,LC=(e,t,n)=>{let r=new Map,i=n??{},a={...OC,...i.platform,_c:r};return XS(e,t,{...i,platform:a})},RC=typeof document<`u`?U.useLayoutEffect:function(){};function zC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!zC(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!zC(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function BC(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function VC(e,t){let n=BC(e);return Math.round(t*n)/n}function HC(e){let t=U.useRef(e);return RC(()=>{t.current=e}),t}function UC(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=U.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=U.useState(r);zC(f,r)||p(r);let[m,h]=U.useState(null),[g,_]=U.useState(null),v=U.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=U.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=U.useRef(null),C=U.useRef(null),w=U.useRef(u),T=c!=null,E=HC(c),D=HC(i),O=HC(l),k=U.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),LC(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!zC(w.current,t)&&(w.current=t,Gs.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);RC(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=U.useRef(!1);RC(()=>(A.current=!0,()=>{A.current=!1}),[]),RC(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=U.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=U.useMemo(()=>({reference:b,floating:x}),[b,x]),N=U.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=VC(M.floating,u.x),r=VC(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...BC(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return U.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var WC=(e,t)=>{let n=MC(e);return{name:n.name,fn:n.fn,options:[e,t]}},GC=(e,t)=>{let n=NC(e);return{name:n.name,fn:n.fn,options:[e,t]}},KC=(e,t)=>({fn:IC(e).fn,options:[e,t]}),qC=(e,t)=>{let n=PC(e);return{name:n.name,fn:n.fn,options:[e,t]}},JC=(e,t)=>{let n=FC(e);return{name:n.name,fn:n.fn,options:[e,t]}};function YC(e,t,n,r){return{left:e,top:t,right:n,bottom:r,x:e,y:t,width:n-e,height:r-t}}function XC(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom,width:e.width,height:e.height}}function ZC(e){let t=[],n,r=1/0,i=1/0,a=-1/0,o=-1/0;for(let s of Array.from(e).sort((e,t)=>e.top-t.top)){if(r=Math.min(r,s.left),i=Math.min(i,s.top),a=Math.max(a,s.right),o=Math.max(o,s.bottom),!n||s.top-n.top>n.height/2)t.push(XC(s));else{let e=t[t.length-1];e.left=Math.min(e.left,s.left),e.right=Math.max(e.right,s.right),e.bottom=Math.max(e.bottom,s.bottom),e.width=e.right-e.left,e.height=e.bottom-e.top}n=s}return{lines:t,fallback:YC(r,i,a,o)}}function QC(e,t,n){return e.findIndex(e=>t>e.left-2&&t<e.right+2&&n>e.top-2&&n<e.bottom+2)}function $C(e){return YC(e.left,e.top,e.right,e.bottom)}function ew(e,t,n){let{lines:r}=ZC(e.getClientRects());if(r.length<2)return;let i=QC(r,t,n);return{x:t,y:n,lineIndex:i===-1?void 0:i,element:e}}function tw(e,t,n){let{lines:r,fallback:i}=ZC(e.getClientRects());if(r.length<2)return null;let a=n?.x,o=n?.y,s=t[0];if(n?.lineIndex!=null&&r[n.lineIndex])return $C(r[n.lineIndex]);if(a!=null&&o!=null){let e=QC(r,a,o);if(e!==-1)return $C(r[e])}if(r.length===2&&r[0].left>r[1].right&&a!=null&&o!=null)return i;if(s===`t`||s===`b`){let e=r[0],t=r[r.length-1],n=s===`t`?e:t;return YC(n.left,e.top,n.right,t.bottom)}let c=s===`l`,l=r[0].left,u=r[0].right,d=c?1/0:-1/0,f=r[0],p=r[0];for(let e of r){l=Math.min(l,e.left),u=Math.max(u,e.right);let t=c?e.left:e.right;c&&t<d||!c&&t>d?(d=t,f=e,p=e):t===d&&(p=e)}return YC(l,f.top,u,p.bottom)}function nw(e){return`contextElement`in e&&e.contextElement?e.contextElement:cy(e)?e:void 0}function rw(e,t){function n(t){iw(e,t.currentTarget,t.clientX,t.clientY)}function r(e){t||n(e)}return{onFocus(){e.current=void 0},onMouseEnter:r,onMouseMove:r}}function iw(e,t,n,r){let i=ew(t,n,r);return e.current=i,i}function aw(e){return{name:`inline`,async fn(t){let n=t.elements.reference;if(typeof n?.getClientRects!=`function`)return{};let r=nw(n),i=e.current,a=i?.element===n||i?.element===r?i:void 0,o=tw(n,t.placement,a);if(!o||typeof t.platform.getElementRects!=`function`)return{};let s=await t.platform.getElementRects({reference:{contextElement:r,getBoundingClientRect(){return o}},floating:t.elements.floating,strategy:t.strategy});return t.rects.reference.x===s.reference.x&&t.rects.reference.y===s.reference.y&&t.rects.reference.width===s.reference.width&&t.rects.reference.height===s.reference.height?{}:{reset:{rects:s}}}}}var ow=n((e=>{var t=g();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),sw=n(((e,t)=>{t.exports=ow()})),cw=n((e=>{var t=g(),n=sw();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),lw=n(((e,t)=>{t.exports=cw()})),uw=[],dw=void 0;function fw(){return dw}function pw(e){uw.push(e)}function mw(e){let t=(t,n)=>{let r=Tr(gw).current,i;try{dw=r;for(let e of uw)e.before(r);i=e(t,n);for(let e of uw)e.after(r);r.didInitialize=!0}finally{dw=void 0}return i};return t.displayName=e.displayName||e.name,t}function hw(e){return U.forwardRef(mw(e))}function gw(){return{didInitialize:!1}}var _w=sw(),vw=lw(),yw=Nr(19)?Sw:Cw;function bw(e,t,n,r,i){return yw(e,t,n,r,i)}function xw(e,t,n,r,i){let a=U.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,_w.useSyncExternalStore)(e.subscribe,a,a)}pw({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,_w.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Sw(e,t,n,r,i){let a=fw();if(!a)return xw(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function Cw(e,t,n,r,i){return(0,vw.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var Ste=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return bw(this,e,t,n,r)}},ww=class extends Ste{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){U.useDebugValue(e);let n=this;X(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;X(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;X(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){U.useDebugValue(e);let n=this,r=t!==void 0;X(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return U.useDebugValue(e),bw(this,this.selectors[e],t,n,r)}useContextCallback(e,t){U.useDebugValue(e);let n=Ay(t??Fr);this.context[e]=n}useStateSetter(e){let t=U.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},Cte={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},Tw=class extends ww{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:wS(),nested:n,triggerElements:i},Cte),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&_te(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function Ew(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),l=t.useState(n?`popupElement`:`positionerElement`),u=t.context.triggerElements,d=o,f=U.useRef(null);r===void 0&&f.current===null&&(f.current=new Tw({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:l,triggerElements:u,onOpenChange:d,floatingId:i,syncOnly:!0,nested:a}));let p=r??f.current;return t.useSyncedValue(`floatingId`,i),X(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:l};cy(c)&&(e.domReferenceElement=c),p.state.positionReference===p.state.referenceElement&&(e.positionReference=c),p.update(e)},[s,i,c,l,p]),p.context.onOpenChange=d,p.context.nested=a,p}function Dw(e,t=!1,n=!1){let[r,i]=U.useState(e&&t?`idle`:void 0),[a,o]=U.useState(e);return e&&!a&&(o(!0),i(`starting`)),!e&&a&&r!==`ending`&&!n&&i(`ending`),!e&&!a&&r===`ending`&&i(void 0),X(()=>{if(!e&&a&&r!==`ending`&&n){let e=Bb.request(()=>{i(`ending`)});return()=>{Bb.cancel(e)}}},[e,a,r,n]),X(()=>{if(!e||t)return;let n=Bb.request(()=>{i(void 0)});return()=>{Bb.cancel(n)}},[t,e]),X(()=>{if(!e||!t)return;e&&a&&r!==`idle`&&i(`starting`);let n=Bb.request(()=>{i(`idle`)});return()=>{Bb.cancel(n)}},[t,e,a,r]),{mounted:a,setMounted:o,transitionStatus:r}}function Ow(e,t=!1){let n=Vb();return Ay((r,i=null)=>{n.cancel();let a=NS(e);if(a==null)return;let o=a,s=()=>{Gs.flushSync(r)};if(typeof o.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){r();return}function c(){Promise.all(o.getAnimations().map(e=>e.finished)).then(()=>{i?.aborted||s()},()=>{if(!i?.aborted){if(o.getAnimations().some(e=>e.pending||e.playState!==`finished`)){c();return}s()}})}if(t){let e=`data-starting-style`;if(!o.hasAttribute(e)){n.request(c);return}let t=new MutationObserver(()=>{o.hasAttribute(e)||(t.disconnect(),c())});t.observe(o,{attributes:!0,attributeFilter:[e]}),i?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}n.request(c)})}function kw(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=Ay(i),o=Ow(r,n);U.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var Aw={tabIndex:-1,[vte]:``};function jw(e){return t=>t!==`touch`||e.current}function Mw(e,t=!1){let n=Xy(),r=OS()!=null,i=Tr(()=>e(n,r)).current;return Ew({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Nw({handle:e,store:t}){return X(()=>e.attachStore(t),[e,t]),null}function wte(e,t){let n=U.useRef(null),r=U.useRef(null);return U.useCallback(i=>{if(e===void 0)return;let a=!1;if(n.current!==null){let e=n.current,i=r.current,o=t.context.triggerElements.getById(e);i&&o===i&&(t.context.triggerElements.delete(e),a=!0),n.current=null,r.current=null}if(i!==null&&(n.current=e,r.current=i,t.context.triggerElements.add(e,i),a=!0),a){let e=t.context.triggerElements.size;t.select(`open`)&&t.state.triggerCount!==e&&t.set(`triggerCount`,e)}},[t,e])}function Pw(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);let i=n?.id??null;(i||t)&&(e.activeTriggerId=i,e.activeTriggerElement=n??null)}function Fw(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Tte(e,t,n,r={}){let i=n.reason,a=i===Ry,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=Fw(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i={...r.extraState,open:t};o?i.instantType=`focus`:s?i.instantType=`dismiss`:a&&(i.instantType=void 0),Pw(i,t,n.trigger,c()),e.update(i)};a?Gs.flushSync(l):l()}function Iw(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=wte(e,n),o=Ay(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){n.update({activeTriggerElement:t,...i?r:null});return}a==null&&i&&n.update({activeTriggerId:e,activeTriggerElement:t,...r})}),s=U.useCallback(e=>{a(e),e&&o(e)},[a,o]);return X(()=>{i&&n.update({activeTriggerElement:t.current,...r})},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Lw(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=U.useRef(null),i=e.useState(`open`);X(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Ky(Iy);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Rw(e,t,n){let{mounted:r,setMounted:i,transitionStatus:a}=Dw(e),o=t.useState(`preventUnmountingOnClose`),s=!e&&o;t.useSyncedValues({mounted:r,transitionStatus:a,preventUnmountingOnClose:s});let c=Ay(()=>{i(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return kw({enabled:r&&!e&&!s,open:e,ref:t.context.popupRef,onComplete(){e||c()}}),{forceUnmount:c,transitionStatus:a}}function zw(e,t){e.useSyncedValues(t),X(()=>()=>{e.update({activeTriggerProps:Lr,inactiveTriggerProps:Lr,popupProps:Lr})},[e])}function Bw(e,t){X(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),X(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Vw=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Ete(){return new Tw({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new Vw,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0})}function Hw(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:Ete(),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Lr,inactiveTriggerProps:Lr,popupProps:Lr}}function Uw(e,t,n=!1){return new Tw({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}var Ww=e=>e.triggerIdProp??e.activeTriggerId,Gw=e=>e.openProp??e.open,Kw=e=>(e.popupElement?.id??e.floatingId)||void 0;function qw(e,t){return t!==void 0&&Gw(e)&&Ww(e)===t}function Dte(e,t){return qw(e,t)?!0:t!==void 0&&Gw(e)&&Ww(e)==null&&e.triggerCount===1}var Jw={open:Gw,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Ww,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Kw,isTriggerActive:(e,t)=>t!==void 0&&Ww(e)===t,isOpenedByTrigger:(e,t)=>qw(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Ww(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Dte(e,t)?Kw(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Yw(e){let t=U.useCallback(t=>e===void 0?Fr:e.subscribeStore(t),[e]),n=U.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,_w.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Ote(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Xy(),a=OS()!=null,o=Tr(()=>new Tw({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Vw,floatingId:i,syncOnly:!1,nested:a})).current;return X(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=cy(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function kte(e){return Ate(e,e.rootContext)}function Ate(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[l,u]=U.useState(null),[d,f]=U.useState(void 0),[p,m]=U.useState(void 0),h=U.useRef(null),g=kS(r),_=U.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),v=UC({...e,elements:{..._,...l&&{reference:l}}}),y=cy(d)?d:null,b=p===void 0?t.state.floatingElement:p;t.useSyncedValue(`referenceElement`,d??null),t.useSyncedValue(`domReferenceElement`,d===void 0?o:y),t.useSyncedValue(`floatingElement`,b);let x=U.useCallback(e=>{let t=cy(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;u(t),v.refs.setReference(t)},[v.refs]),S=U.useCallback(e=>{(cy(e)||e===null)&&(h.current=e,f(e)),(cy(v.refs.reference.current)||v.refs.reference.current===null||e!==null&&!cy(e))&&v.refs.setReference(e)},[v.refs,f]),C=U.useCallback(e=>{m(e),v.refs.setFloating(e)},[v.refs]),w=U.useMemo(()=>({...v.refs,setReference:S,setFloating:C,setPositionReference:x,domReference:h}),[v.refs,S,C,x]),T=U.useMemo(()=>({...v.elements,domReference:o}),[v.elements,o]),E=U.useMemo(()=>({...v,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:w,elements:T,nodeId:n,rootStore:t}),[v,w,T,n,t,s,c]);return X(()=>{o&&(h.current=o)},[o]),X(()=>{t.context.dataRef.current.floatingContext=E;let e=g?.nodesRef.current.find(e=>e.id===n);e&&(e.context=E)}),U.useMemo(()=>({...v,context:E,refs:w,elements:T,rootStore:t}),[v,w,T,E,t])}var Xw=cb&&lb;function Zw(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=U.useRef(!1),c=U.useRef(null),l=U.useRef(!0),u=nb();U.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=ay(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&ly(e)&&e===vb(My(e))&&(s.current=!0)}function a(){l.current=!0}function o(){l.current=!1}return Fb(Pb(t,`blur`,r),Xw&&Pb(t,`keydown`,a,!0),Xw&&Pb(t,`pointerdown`,o,!0))},[i,n]),U.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);cy(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let d=U.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=bb(t.nativeEvent);if(cy(a)){if(Xw&&!t.relatedTarget){if(!l.current&&!wb(a))return}else if(!Db(a))return}let o=xb(t.relatedTarget,i.context.triggerElements),{nativeEvent:d,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Ky(zy,d,f));return}u.start(p,()=>{s.current||i.setOpen(!0,Ky(zy,d,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=cy(n)&&n.hasAttribute($x(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;u.start(0,()=>{let e=i.select(`domReferenceElement`),t=vb(My(e));!n&&t===e||yb(o.current.floatingContext?.refs.floating.current,t)||yb(e,t)||a||xb(n??t,i.context.triggerElements)||i.setOpen(!1,Ky(zy,r))})}}},[o,r,i,u]);return U.useMemo(()=>n?{reference:d,trigger:d}:{},[n,d])}var jte=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new tb,this.restTimeout=new tb,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},Qw=new WeakMap;function $w(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Qw.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Qw.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function eT(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Qw.get(n);a&&a!==e&&$w(a),$w(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Qw.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function tT(e){let t=e.context.dataRef.current,n=Tr(()=>t.hoverInteractionState??jte.create()).current;return t.hoverInteractionState||=n,$y(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function nT(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:l}=a.context,u=kS(),d=OS(),f=tT(a),p=nb(),m=Ay(()=>Mb(l.current.openEvent?.type,f.interactedInside)),h=Ay(()=>Nb(l.current.openEvent?.type)),g=Ay(()=>{$w(f)});X(()=>{o||(f.pointerType=void 0,f.restTimeoutPending=!1,f.interactedInside=!1,g())},[o,f,g]),U.useEffect(()=>g,[g]),X(()=>{if(n&&o&&f.handleCloseOptions?.blockPointerEvents&&h()&&cy(c)&&s){let e=c,t=s,n=My(s),r=u?.nodesRef.current.find(e=>e.id===d)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=f.pointerEventsScopeElement===t?null:f.pointerEventsScopeElement,a=r===t?null:r,o=f.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return eT(f,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{g()}}},[n,o,c,s,f,h,u,d,g]),U.useEffect(()=>{if(!n)return;function e(){return!!(u&&d&&Zx(u.nodesRef.current,d).length>0)}function t(e){let t=Ab(r,`close`,f.pointerType),n=()=>{a.setOpen(!1,Ky(Ry,e)),u?.events.emit(`floating.closed`,e)};t?f.openChangeTimeout.start(t,n):(f.openChangeTimeout.clear(),n())}function o(e){let t=bb(e);if(!Tb(t)){f.interactedInside=!1;return}f.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){f.openChangeTimeout.clear(),p.clear(),u?.events.off(`floating.closed`,v),g()}function _(n){if(e()&&u){u.events.on(`floating.closed`,v);return}if(xb(n.relatedTarget,a.context.triggerElements))return;let r=l.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(u&&r&&cy(o)&&Zx(u.nodesRef.current,r,!1).some(e=>yb(e.context?.elements.floating,o)))){if(f.handler){f.handler(n);return}g(),h()&&!m()&&t(n)}}function v(t){!u||!d||e()||p.start(0,()=>{u.events.off(`floating.closed`,v),a.setOpen(!1,Ky(Ry,t)),u.events.emit(`floating.closed`,t)})}let y=s;return Fb(y&&Pb(y,`mouseenter`,c),y&&Pb(y,`mouseleave`,_),y&&Pb(y,`pointerdown`,o,!0),()=>{u?.events.off(`floating.closed`,v)})},[n,s,a,l,r,i,h,m,g,f,u,d,p])}var Mte={current:null};function rT(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Mte,externalTree:l,isActiveTrigger:u=!0,getHandleCloseContext:d,isClosing:f,shouldOpen:p,guardStaleOpen:m=!1}=t,h=`rootStore`in e?e.rootStore:e,{dataRef:g,events:_}=h.context,v=kS(l),y=tT(h),b=U.useRef(!1),x=Ib(i),S=Ib(r),C=Ib(o),w=Ib(n),T=Ib(p),E=Ib(f),D=Ay(()=>Mb(g.current.openEvent?.type,y.interactedInside)),O=Ay(()=>T.current?.()!==!1),k=Ay((e,t,n)=>{let r=h.context.triggerElements;if(r.hasElement(t))return!e||!yb(e,t);if(!cy(n))return!1;let i=n;return r.hasMatchingElement(e=>yb(e,i))&&(!e||!yb(e,i))}),A=Ay(()=>{y.handler&&=(My(h.select(`domReferenceElement`)).removeEventListener(`mousemove`,y.handler),void 0)}),j=Ay(()=>{$w(y)});return u&&(y.handleCloseOptions=x.current?.__options),U.useEffect(()=>A,[A]),U.useEffect(()=>{if(!n)return;function e(e){e.open?b.current=!1:(b.current=e.reason===Ry,A(),y.openChangeTimeout.clear(),y.restTimeout.clear(),y.blockMouseMove=!0,y.restTimeoutPending=!1)}return _.on(`openchange`,e),()=>{_.off(`openchange`,e)}},[n,_,y,A]),U.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=Ab(S.current,`close`,y.pointerType);n?y.openChangeTimeout.start(n,()=>{h.setOpen(!1,Ky(Ry,e)),v?.events.emit(`floating.closed`,e)}):t&&(y.openChangeTimeout.clear(),h.setOpen(!1,Ky(Ry,e)),v?.events.emit(`floating.closed`,e))}let t=c.current??(u?h.select(`domReferenceElement`):null);if(!cy(t))return;function r(e){if(y.openChangeTimeout.clear(),y.blockMouseMove=!1,a&&!mb(y.pointerType))return;let t=jb(C.current),n=Ab(S.current,`open`,y.pointerType),r=bb(e),i=e.currentTarget??null,o=h.select(`domReferenceElement`),s=i;if(cy(r)&&!h.context.triggerElements.hasElement(r)){for(let e of h.context.triggerElements.elements())if(yb(e,r)){s=e;break}}cy(i)&&cy(o)&&!h.context.triggerElements.hasElement(i)&&yb(i,o)&&(s=o);let c=s!=null&&k(o,s,r),l=h.select(`open`),u=E.current?.()??h.select(`transitionStatus`)===`ending`,d=!l&&u&&b.current,f=!c&&cy(s)&&cy(o)&&yb(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,g=!l||c;if(m){O()&&h.setOpen(!0,Ky(Ry,e,s));return}p||(n?y.openChangeTimeout.start(n,()=>{g&&O()&&h.setOpen(!0,Ky(Ry,e,s))}):g&&O()&&h.setOpen(!0,Ky(Ry,e,s)))}function i(t){if(D()){j();return}A();let n=My(h.select(`domReferenceElement`));y.restTimeout.clear(),y.restTimeoutPending=!1;let r=g.current.floatingContext??d?.();if(!xb(t.relatedTarget,h.context.triggerElements)){if(x.current&&r){h.select(`open`)||y.openChangeTimeout.clear();let i=c.current;y.handler=x.current({...r,tree:v,x:t.clientX,y:t.clientY,onClose(){j(),A(),w.current&&!D()&&i===h.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,y.handler),y.handler(t);return}(y.pointerType!==`touch`||!yb(h.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){yb(t,e.relatedTarget)||(y.openChangeTimeout.clear(),y.restTimeout.clear(),y.restTimeoutPending=!1)}let l=m?Pb(t,`mouseout`,o):void 0;return s?Fb(Pb(t,`mousemove`,r,{once:!0}),Pb(t,`mouseenter`,r),Pb(t,`mouseleave`,i),l):Fb(Pb(t,`mouseenter`,r),Pb(t,`mouseleave`,i),l)},[A,j,g,S,h,n,x,y,u,k,D,a,s,C,c,v,w,d,E,O,m]),U.useMemo(()=>{if(!n)return;function e(e){y.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=h.select(`domReferenceElement`),i=h.select(`open`),o=k(r,n,e.target);if(a&&!mb(y.pointerType))return;if(i&&o&&y.handleCloseOptions?.blockPointerEvents){let e=h.select(`floatingElement`);if(e){let t=y.handleCloseOptions?.getScope?.()??n.ownerDocument.body;eT(y,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=jb(C.current);if(i&&!o||s===0||!o&&y.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;y.restTimeout.clear();function c(){if(y.restTimeoutPending=!1,D())return;let e=h.select(`open`);!y.blockMouseMove&&(!e||o)&&O()&&h.setOpen(!0,Ky(Ry,t,n))}y.pointerType===`touch`?Gs.flushSync(()=>{c()}):o&&i?c():(y.restTimeoutPending=!0,y.restTimeout.start(s,c))}}},[n,y,D,k,a,h,C,O])}var Nte=`Escape`;function iT(e){return lb&&e.movementX===0&&e.movementY===0}function aT(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function oT(e,t){return aT(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function sT(e,t,n){return aT(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function Pte(e,t,n){return aT(t,n?e===hb:e===gb,e===_b)}function Fte(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===Nte:aT(t,n?e===gb:e===hb,e===bte)}function cT(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:l=!1,rtl:u=!1,virtual:d=!1,focusItemOnOpen:f=`auto`,focusItemOnHover:p=!0,openOnArrowKeyDown:m=!0,disabledIndices:h=void 0,orientation:g=`vertical`,parentOrientation:_,id:v,resetOnPointerLeave:y=!0,externalTree:b,grid:x}=t,S=x!=null,C=`rootStore`in e?e.rootStore:e,w=C.useState(`open`),T=C.useState(`floatingElement`),E=C.useState(`domReferenceElement`),D=C.context.dataRef,O=Ob(T),k=Eb(E),A=Ib(O),j=OS(),M=kS(b),N=U.useRef(f),P=U.useRef(o??-1),F=U.useRef(null),I=U.useRef(!0),L=Ay(e=>{i(P.current===-1?null:P.current,e)}),R=U.useRef(!!T),ee=U.useRef(w),z=U.useRef(!1),B=U.useRef(!1),V=U.useRef(null),te=Ib(h),H=Ib(w),ne=Ib(o),re=Ib(y),ie=Vb(),ae=Vb(),oe=Ay(()=>{function e(e){d?M?.events.emit(`virtualfocus`,e):V.current=tS(e,{sync:z.current,preventScroll:!0})}let t=n.current[P.current],r=B.current;t&&e(t),(z.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[P.current]||t;i&&(t||e(i),fe&&(r||!I.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});X(()=>{D.current.orientation=g},[D,g]),X(()=>{a&&(w&&T?(P.current=o??-1,N.current&&o!=null&&(B.current=!0,L())):R.current&&(P.current=-1,L()))},[a,w,T,o,L]),X(()=>{if(a){if(!w){z.current=!1;return}if(T){if(r==null){if(z.current=!1,ne.current!=null)return;if(R.current&&(P.current=-1,oe()),(!ee.current||!R.current)&&N.current&&(F.current!=null||N.current===!0&&F.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ae.request(e):queueMicrotask)(t),e+=1):(P.current=F.current==null||sT(F.current,g,u)||l?bx(n):xx(n),F.current=null,L())};t()}}else yx(n.current,r)||(P.current=r,oe(),B.current=!1)}}},[a,w,T,r,ne,l,n,g,u,L,oe,ae]),X(()=>{if(!a||T||!M||d||!R.current)return;let e=M.nodesRef.current,t=e.find(e=>e.id===j)?.context?.elements.floating,n=vb(My(E??t??null)),r=e.some(e=>e.context&&yb(e.context.elements.floating,n));t&&!r&&I.current&&t.focus({preventScroll:!0})},[a,T,E,M,j,d]),X(()=>{ee.current=w,R.current=!!T}),X(()=>{w||(F.current=null,N.current=f)},[w,f]);let se=r!=null,ce=Ay(e=>{if(!H.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(P.current!==t||r!==t)&&(P.current=t,L(e))}),le=Ay(()=>_??M?.nodesRef.current.find(e=>e.id===j)?.context?.dataRef?.current.orientation),ue=Ay(()=>bx(n,te.current)),de=Ay(e=>{if(I.current=!1,z.current=!0,e.which===229||!H.current&&e.currentTarget===A.current)return;if(l&&Fte(e.key,g,u,S)){oT(e.key,le())||db(e),C.setOpen(!1,Ky(Hy,e.nativeEvent)),ly(E)&&(d?M?.events.emit(`virtualfocus`,E):E.focus());return}let t=P.current,r=bx(n,h),i=xx(n,h);if(k||(e.key===`Home`&&(db(e),P.current=r,L(e)),e.key===`End`&&(db(e),P.current=i,L(e))),x!=null){let t=x(e,P.current,n,g,c,u,h,r,i);if(t!=null&&(P.current=t,L(e)),g===`both`)return}if(oT(e.key,g)){if(db(e),w&&!d&&vb(e.currentTarget.ownerDocument)===e.currentTarget){P.current=sT(e.key,g,u)?r:i,L(e);return}sT(e.key,g,u)?c?t>=i?s&&t!==n.current.length?P.current=-1:(z.current=!1,P.current=r):P.current=Sx(n.current,{startingIndex:t,disabledIndices:h}):P.current=Math.min(i,Sx(n.current,{startingIndex:t,disabledIndices:h})):c?t<=r?s&&t!==-1?P.current=n.current.length:(z.current=!1,P.current=i):P.current=Sx(n.current,{startingIndex:t,decrement:!0,disabledIndices:h}):P.current=Math.max(r,Sx(n.current,{startingIndex:t,decrement:!0,disabledIndices:h})),yx(n.current,P.current)&&(P.current=-1),L(e)}}),fe=U.useMemo(()=>({onFocus(e){z.current=!0,ce(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){iT(e)||(z.current=!0,B.current=!1,p&&ce(e))},onPointerLeave(e){if(!H.current||!I.current||e.pointerType===`touch`)return;z.current=!0;let t=e.relatedTarget;if(!(!p||n.current.includes(t))&&re.current&&(V.current?.(),V.current=null,P.current=-1,L(e),!d)){let e=A.current,t=vb(My(e));e&&yb(e,t)&&e.focus({preventScroll:!0})}}}),[ce,H,A,p,n,L,re,d]),pe=U.useMemo(()=>d&&w&&se&&{"aria-activedescendant":`${v}-${r}`},[d,w,se,v,r]),me=U.useMemo(()=>({"aria-orientation":g===`both`?void 0:g,...k?{}:pe,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&w&&!d){let t=bb(e.nativeEvent);if(t&&!yb(A.current,t))return;db(e),C.setOpen(!1,Ky(Vy,e.nativeEvent)),ly(E)&&E.focus();return}de(e)},onPointerMove(e){iT(e)||(I.current=!0)}}),[pe,de,A,g,k,C,w,d,E]),he=U.useMemo(()=>{function e(e){C.setOpen(!0,Ky(Hy,e.nativeEvent,e.currentTarget))}function t(e){f===`auto`&&fb(e.nativeEvent)&&(N.current=!d)}function n(e){N.current=f,f===`auto`&&pb(e.nativeEvent)&&(N.current=!0)}return{onKeyDown(t){let n=C.select(`open`);I.current=!1;let r=t.key.startsWith(`Arrow`),i=Pte(t.key,le(),u),a=oT(t.key,g),o=(l?i:a)||t.key===`Enter`||t.key.trim()===``;if(d&&n)return de(t);if(!(!n&&!m&&r)){if(o){let e=oT(t.key,le());F.current=l&&e?null:t.key}if(l){i&&(db(t),n?(P.current=ue(),L(t)):e(t));return}a&&(ne.current!=null&&(P.current=ne.current),db(t),!n&&m?e(t):de(t),n&&L(t))}},onFocus(e){C.select(`open`)&&!d&&(P.current=-1,L(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,f,ue,l,L,C,m,g,le,u,ne,d]),ge=U.useMemo(()=>({...pe,...he}),[pe,he]);return U.useMemo(()=>a?{reference:ge,floating:me,item:fe,trigger:he}:{},[a,ge,me,he,fe])}function lT(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:l=750,selectedIndex:u=null}=t,d=`rootStore`in e?e.rootStore:e,f=d.useState(`open`),p=nb(),m=U.useRef(``),h=U.useRef(u??i??-1),g=U.useRef(null),_=Ay(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Tx(n)||n?.matches(`:disabled`)?!1:o==null||!Cx(Ir,e,o)}function d(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(i)||!c(n)))return n}return-1}let _=n.current;if(m.current.length>0&&e.key===` `&&(db(e),s?.(!0)),m.current.length>0&&m.current[0]!==` `&&d(_,m.current)===-1&&e.key!==` `&&s?.(!1),_==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;f&&e.key!==` `&&(db(e),s?.(!0));let v=m.current===``;v&&(h.current=u??i??-1),_.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&m.current===e.key&&(m.current=``,h.current=g.current),m.current+=e.key,p.start(l,()=>{m.current=``,h.current=g.current,s?.(!1)});let y=((v?u??i??-1:h.current)??0)+1,b=d(_,m.current,y);b===-1?e.key!==` `&&(m.current=``,s?.(!1)):(a?.(b),g.current=b)}),v=Ay(e=>{let t=e.relatedTarget,n=d.select(`domReferenceElement`),r=d.select(`floatingElement`);yb(n,t)||yb(r,t)||(p.clear(),m.current=``,h.current=g.current,s?.(!1))});X(()=>{!f&&u!==null||(p.clear(),g.current=null,m.current!==``&&(m.current=``))},[f,u,p]);let y=U.useMemo(()=>({onKeyDown:_,onBlur:v}),[_,v]);return U.useMemo(()=>c?{reference:y,floating:y}:{},[c,y])}var uT=.1,Ite=uT*uT,dT=.5;function fT(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function pT(e,t,n,r,i,a,o,s,c,l){let u=!1;return fT(e,t,n,r,i,a)&&(u=!u),fT(e,t,i,a,o,s)&&(u=!u),fT(e,t,o,s,c,l)&&(u=!u),fT(e,t,c,l,n,r)&&(u=!u),u}function Lte(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function mT(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function hT(e={}){let{blockPointerEvents:t=!1}=e,n=new tb,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*Ite;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=bb(r),g=r.type===`mouseleave`,_=yb(u,h),v=yb(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&cy(r.relatedTarget)&&yb(u,r.relatedTarget))return;function y(){return!!(s&&Zx(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=mT(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=mT(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=mT(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=mT(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!Lte(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?dT/2:dT*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+dT+1,o=C||T?S.bottom-dT:S.top,s=C?T?S.bottom-dT:S.top:S.bottom-dT;M=pT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?dT/2:dT*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-dT,o=C||T?S.top+dT:S.bottom,s=C?T?S.top+dT:S.bottom:S.top+dT;M=pT(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?dT/2:dT*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+dT+1,o=w||E?S.right-dT:S.left,s=w?E?S.right-dT:S.left:S.right-dT;M=pT(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?dT/2:dT*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-dT,o=w||E?S.left+dT:S.right,s=w?E?S.left+dT:S.right:S.left+dT;M=pT(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}var gT=U.createContext(void 0);function _T(){let e=U.useContext(gT);if(e===void 0)throw Error(Cr(26));return e}var vT=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),yT={...ey,...Kv,nestedDialogOpen(e){return e?{"data-nested-dialog-open":``}:null}},bT=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Hv(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);_T(),kw({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?jw(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Vr(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Aw,hidden:!m,onKeyDown(e){vT.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:yT});return(0,K.jsx)(HS,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function xT(e){return Nr(19)?e:e?`true`:void 0}var ST=U.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,K.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),CT=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Hv(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,K.jsx)(gT.Provider,{value:n,children:(0,K.jsxs)(CS,{ref:t,...r,children:[a&&o===!0&&(0,K.jsx)(ST,{ref:i.context.internalBackdropRef,inert:xT(!s)}),e.children]})}):null}),wT={},TT={},ET=``;function DT(e,t){return dy(e)?e:t}function OT(e,t,n){return/hidden|clip/.test(e.getComputedStyle(DT(t,n)).overflowY)}function Rte(e){if(typeof document>`u`)return!1;let t=My(e);return ay(t).innerWidth-t.documentElement.clientWidth>0}function zte(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=My(e),n=t.documentElement,r=t.body,i=DT(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function Bte(e){let t=My(e),n=t.documentElement,r=t.body,i=DT(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function Vte(e){let t=My(e),n=t.documentElement,r=t.body,i=ay(n),a=0,o=0,s=!1,c=Bb.create();if(lb&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,wT={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ET=n.style.scrollBehavior,TT={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=DT(n,r);if(s=zte(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,wT),Object.assign(r.style,TT),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=ET)}function d(){u(),c.request(l)}l();let f=Pb(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var Hte=new class{lockCount=0;restore=null;timeoutLock=tb.create();timeoutUnlock=tb.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=My(e),n=t.documentElement,r=t.body,i=ay(n);if(OT(i,n,r)){let t=new i.MutationObserver(()=>{OT(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=ab||!Rte(e);this.restore=a?Bte(e):Vte(e)}};function kT(e=!0,t=null){X(()=>{if(e)return Hte.acquire(t)},[e,t])}function Ute({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,l]=U.useState(0),[u,d]=U.useState(0),f=c===0,p=KS(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=bb(t);if(f&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||yb(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:f});return kT(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{l(e),d(t)}),X(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,u+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,u,t]),zw(e,{activeTriggerProps:p.reference,inactiveTriggerProps:p.trigger,popupProps:p.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:u}),null}var Wte={...Jw,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Gte=class extends ww{constructor(e,t,n){let r=new Vw,i=Kte(e,r,t,n);super(i,qte(r),Wte)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let n={open:e};Pw(n,e,t.trigger),this.update(n)}};function Kte(e,t,n,r=!1){let i={...Hw(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e};return i.floatingRootContext=Uw(t,n,r),i}function qte(e){return{popupRef:U.createRef(),backdropRef:U.createRef(),internalBackdropRef:U.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function AT(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:l,handle:u,triggerId:d,defaultTriggerId:f=null}=t,p=e===`drawer`,m=e===`alert-dialog`,h=m?!0:c,g=m||s,_=m?`alertdialog`:`dialog`,v=Hv(!0),y={modal:h,disablePointerDismissal:g,nested:v!=null,role:_},b=Mw((e,t)=>new Gte({open:i,openProp:r,activeTriggerId:f,triggerIdProp:d,...y},e,t),!0);b.useControlledProp(`openProp`,r),b.useControlledProp(`triggerIdProp`,d),b.useSyncedValues(y),b.useContextCallback(`onOpenChange`,a),b.useContextCallback(`onOpenChangeComplete`,o);let x=b.useState(`open`),S=b.useState(`mounted`),C=b.useState(`payload`);Bw(b,x),Lw(b);let{forceUnmount:w}=Rw(x,b);U.useImperativeHandle(l,()=>({unmount:w,close:()=>b.setOpen(!1,Ky(Gy))}),[w,b]);let T=x||S;return(0,K.jsxs)(Vv.Provider,{value:b,children:[u&&(0,K.jsx)(Nw,{handle:u,store:b}),T&&(0,K.jsx)(Ute,{store:b,parentContext:v?.context,isDrawer:p}),typeof n==`function`?n({payload:C}):n]})}function jT(e){return AT(`dialog`,e)}var MT=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=_T(),c=Hv(),l=c.useState(`open`),u=c.useState(`nested`),d=c.useState(`transitionStatus`),f=c.useState(`nestedOpenDialogCount`),p=c.useState(`mounted`),m=c.useStateSetter(`viewportElement`);return Vr(`div`,e,{enabled:s||p,state:{open:l,nested:u,transitionStatus:d,nestedDialogOpen:f>0},ref:[t,m],stateAttributesMapping:yT,props:[{role:`presentation`,hidden:!p,style:{pointerEvents:l?void 0:`none`},children:a},o]})}),NT=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Hv(),c=Zy(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Vr(`h2`,e,{ref:t,props:[{id:c},o]})});function Jte(e){let t=U.useRef(``),n=U.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:U.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function PT(e,t){let n=U.useRef(e),r=Ay(t);X(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function FT(e,t){let{onClick:n,onPointerDown:r}=Jte(Ay((n,r)=>{(typeof e==`function`?e():e)||t(r||(ab?`touch`:``))}));return U.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function IT(e){let[t,n]=U.useState(null),r=FT(e,n);return PT(e,t=>{t&&!e&&n(null)}),U.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var Yte=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:l,...u}=e,d=Hv(!0),f=Yw(l)??d;if(!f)throw Error(Cr(79));let p=Zy(s),m=f.useState(`floatingRootContext`),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`triggerPopupId`,p),_=U.useRef(null),{registerTrigger:v,isMountedByThisTrigger:y}=Iw(p,_,f,{payload:c}),{getButtonProps:b,buttonRef:x}=Py({disabled:a,native:o}),S=US(m),C=FT(()=>f.select(`open`),e=>{f.set(`openMethod`,e)}),w={disabled:a,open:h},T=f.useState(`triggerProps`,y);return Vr(`button`,e,{state:w,ref:[x,t,v,_],props:[S.reference,T,C,{[hS]:``,id:p,"aria-haspopup":`dialog`,"aria-expanded":h,"aria-controls":g},u,b],stateAttributesMapping:Qv})}),LT=U.createContext(void 0);function RT(){let e=U.useContext(LT);if(e===void 0)throw Error(Cr(53));return e}function zT(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var BT=`base-ui-disable-scrollbar`,VT={className:BT,getElement(e){return(0,K.jsx)(`style`,{nonce:e,href:BT,precedence:`base-ui:low`,children:`.${BT}{scrollbar-width:none}.${BT}::-webkit-scrollbar{display:none}`})}},HT=e=>t=>t?{[e]:``}:null,UT={hasOverflowX:HT(`data-has-overflow-x`),hasOverflowY:HT(`data-has-overflow-y`),overflowXStart:HT(`data-overflow-x-start`),overflowXEnd:HT(`data-overflow-x-end`),overflowYStart:HT(`data-overflow-y-start`),overflowYEnd:HT(`data-overflow-y-end`),cornerHidden:()=>null},WT=U.createContext(void 0),GT={disableStyleElements:!1};function KT(){return U.useContext(WT)??GT}var qT={x:0,y:0},JT={width:0,height:0},YT={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},XT={x:!0,y:!0,corner:!0},ZT=U.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:a,...o}=e,{xStart:s,xEnd:c,yStart:l,yEnd:u}=QT(i),d=Zy(),f=nb(),p=nb(),{nonce:m,disableStyleElements:h}=KT(),[g,_]=U.useState(!1),[v,y]=U.useState(!1),[b,x]=U.useState(!1),[S,C]=U.useState(!1),[w,T]=U.useState(!1),[E,D]=U.useState(JT),[O,k]=U.useState(JT),[A,j]=U.useState(YT),[M,N]=U.useState(XT),P=U.useRef(null),F=U.useRef(null),I=U.useRef(null),L=U.useRef(null),R=U.useRef(null),ee=U.useRef(null),z=U.useRef(null),B=U.useRef(null),V=U.useRef(0),te=U.useRef(0),H=U.useRef(0),ne=U.useRef(0),re=U.useRef(`vertical`),ie=U.useRef(qT),ae=U.useRef(null);function oe(e){let t=e?x:y,n=e?f:p;t(!0),n.start(500,()=>{t(!1)})}let se=Ay(e=>{let t=e.x-ie.current.x,n=e.y-ie.current.y;ie.current=e,n!==0&&oe(!0),t!==0&&oe(!1)}),ce=Ay(()=>{let e=F.current;e&&ae.current===null&&(ae.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),le=Ay(e=>{if(e.button!==0||B.current!==null&&(re.current===`vertical`?R.current:ee.current)?.hasPointerCapture(B.current))return;B.current=e.pointerId,V.current=e.clientY,te.current=e.clientX,re.current=e.currentTarget.getAttribute(`data-orientation`);let t=F.current;t&&(H.current=t.scrollTop,ne.current=t.scrollLeft,ce()),(re.current===`vertical`?R.current:ee.current)?.setPointerCapture(e.pointerId)}),ue=Ay(e=>{if(e.pointerId!==B.current)return;B.current=null,(re.current===`vertical`?x:y)(!1),ae.current!==null&&(F.current&&(F.current.style.scrollSnapType=ae.current),ae.current=null);let t=re.current===`vertical`?R.current:ee.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),de=Ay(e=>{if(e.pointerId!==B.current)return;if(e.buttons%2==0){ue(e);return}let t=F.current;if(!t)return;let n=re.current===`vertical`,r=n?R.current:ee.current,i=n?I.current:L.current;if(!r||!i)return;let a=n?`y`:`x`,o=zT(i,`padding`,a),s=zT(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-V.current:e.clientX-te.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?H.current:ne.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),oe(n)});function fe(e){C(e.pointerType===`touch`)}function pe(e){if(fe(e),e.pointerType!==`touch`){let t=yb(P.current,e.target);_(t)}}let me=U.useMemo(()=>({scrolling:v||b,hasOverflowX:!M.x,hasOverflowY:!M.y,overflowXStart:A.xStart,overflowXEnd:A.xEnd,overflowYStart:A.yStart,overflowYEnd:A.yEnd,cornerHidden:M.corner}),[v,b,M.x,M.y,M.corner,A]),he={role:`presentation`,onPointerEnter:pe,onPointerMove:pe,onPointerDown:fe,onPointerLeave(){_(!1)},style:{position:`relative`,"--scroll-area-corner-height":`${E.height}px`,"--scroll-area-corner-width":`${E.width}px`}},ge=Vr(`div`,e,{state:me,ref:[t,P],props:[he,o],stateAttributesMapping:UT}),_e=U.useMemo(()=>({handlePointerDown:le,handlePointerMove:de,handlePointerUp:ue,handleScroll:se,disableViewportSnap:ce,cornerSize:E,setCornerSize:D,thumbSize:O,setThumbSize:k,hasMeasuredScrollbar:w,setHasMeasuredScrollbar:T,touchModality:S,cornerRef:z,scrollingX:v,scrollingY:b,hovering:g,setHovering:_,viewportRef:F,scrollbarYRef:I,scrollbarXRef:L,thumbYRef:R,thumbXRef:ee,rootId:d,hiddenState:M,setHiddenState:N,overflowEdges:A,setOverflowEdges:j,viewportState:me,overflowEdgeThreshold:{xStart:s,xEnd:c,yStart:l,yEnd:u}}),[le,de,ue,se,ce,E,O,w,S,v,b,g,d,M,A,me,s,c,l,u]);return(0,K.jsxs)(LT.Provider,{value:_e,children:[!h&&VT.getElement(m),ge]})});function QT(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var $T=U.createContext(void 0),eE=U.createContext(void 0);function tE(){return U.useContext(eE)?.direction??`ltr`}function nE(e,t=-(2**53-1),n=2**53-1){return Math.max(t,Math.min(e,n))}function rE(e,t){return Math.max(0,e-t)}function iE(e,t){if(t<=0)return 0;let n=nE(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var aE=[`--scroll-area-overflow-x-start`,`--scroll-area-overflow-x-end`,`--scroll-area-overflow-y-start`,`--scroll-area-overflow-y-end`],oE=!1;function sE(){oE||lb||(typeof CSS<`u`&&`registerProperty`in CSS&&aE.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),oE=!0)}var cE=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{viewportRef:o,scrollbarYRef:s,scrollbarXRef:c,thumbYRef:l,thumbXRef:u,cornerRef:d,cornerSize:f,setCornerSize:p,setThumbSize:m,rootId:h,setHiddenState:g,hiddenState:_,setHasMeasuredScrollbar:v,handleScroll:y,touchModality:b,setHovering:x,setOverflowEdges:S,overflowEdgeThreshold:C,viewportState:w}=RT(),T=tE(),E=U.useRef(!0),D=U.useRef([NaN,NaN,NaN,NaN]),O=nb(),k=nb(),A=Ay(()=>{let e=o.current,t=s.current,n=c.current,r=l.current,i=u.current,a=d.current;if(!e)return;let h=e.scrollHeight,_=e.scrollWidth,y=e.clientHeight,b=e.clientWidth,x=e.scrollTop,w=e.scrollLeft,E=D.current,O=Number.isNaN(E[0]);if(E[0]=y,E[1]=h,E[2]=b,E[3]=_,O&&v(!0),h===0||_===0)return;let k=lE(e),A=k.y,j=k.x,M=b/_,N=y/h,P=Math.max(0,_-b),F=Math.max(0,h-y),I=0,L=0;j||(I=iE(T===`rtl`?-w:w,P),L=P-I);let R=A?0:iE(x,F),ee=A?0:F-R,z=j?0:b,B=A?0:y,V=0,te=0;!j&&!A&&(V=t?.offsetWidth||0,te=n?.offsetHeight||0);let H=f.width===0&&f.height===0,ne=H?V:0,re=H?te:0,ie=zT(n,`padding`,`x`),ae=zT(t,`padding`,`y`),oe=zT(i,`margin`,`x`),se=zT(r,`margin`,`y`),ce=z-ie-oe,le=B-ae-se,ue=n?Math.min(n.offsetWidth-ne,ce):ce,de=t?Math.min(t.offsetHeight-re,le):le,fe=Math.max(16,ue*M),pe=Math.max(16,de*N);if(m(e=>uE(e,{width:fe,height:pe})),t&&r){let e=dE(r,`--scroll-area-thumb-height`,x,F,h,pe,t.offsetHeight-pe-ae-se);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-fe-ie-oe,t=dE(i,`--scroll-area-thumb-width`,T===`rtl`?-w:w,P,_,fe,e);i.style.transform=`translate3d(${T===`rtl`?-t:t}px,0,0)`}let me=[I,L,R,ee];aE.forEach((t,n)=>{e.style.setProperty(t,`${me[n]}px`)}),a&&p(e=>uE(e,{width:V,height:te})),g(e=>uE(e,k));let he={xStart:!j&&I>C.xStart,xEnd:!j&&L>C.xEnd,yStart:!A&&R>C.yStart,yEnd:!A&&ee>C.yEnd};S(e=>uE(e,he))});X(()=>{sE()},[]),X(()=>{queueMicrotask(A)},[A,_,T,C.xStart,C.xEnd,C.yStart,C.yEnd]),X(()=>{o.current?.matches(`:hover`)&&x(!0)},[o,x]),X(()=>{let e=o.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=D.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}A()});return n.observe(e),k.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(A).catch(()=>{})}),()=>{n.disconnect(),k.clear()}},[A,o,k]);function j(){E.current=!1}let M={role:`presentation`,...h&&{"data-id":`${h}-viewport`},tabIndex:_.x&&_.y?-1:0,className:VT.className,style:{overflow:`scroll`},onScroll(){o.current&&(A(),(b||!E.current)&&y({x:o.current.scrollLeft,y:o.current.scrollTop}),O.start(100,()=>{E.current=!0}))},onWheel:j,onPointerMove:j,onPointerEnter:j,onKeyDown:j},N=Vr(`div`,e,{ref:[t,o],state:w,props:[M,a],stateAttributesMapping:UT}),P=U.useMemo(()=>({computeThumbPosition:A}),[A]);return(0,K.jsx)($T.Provider,{value:P,children:N})});function lE(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function uE(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function dE(e,t,n,r,i,a,o){let s=nE(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var fE=U.createContext(void 0);function pE(){let e=U.useContext(fE);if(e===void 0)throw Error(Cr(54));return e}var mE=U.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,style:o,...s}=e,{hovering:c,scrollingX:l,scrollingY:u,hiddenState:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,handleScroll:y,disableViewportSnap:b,rootId:x,thumbSize:S,hasMeasuredScrollbar:C,viewportState:w}=RT(),T=i===`vertical`,E={...w,hovering:c,scrolling:T?u:l,orientation:i},D=tE(),O=!C&&!a,k=T?d.y:d.x,A=a||!k;U.useEffect(()=>{if(!A)return;let e=m.current,t=T?f.current:p.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!T,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&D===`rtl`?-a:0,s=n&&D===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),y({x:e.scrollLeft,y:e.scrollTop}))}return Pb(t,`wheel`,n,{passive:!1})},[D,y,T,p,f,A,m]);let j={...x&&{"data-id":`${x}-scrollbar`},onPointerDown(e){if(e.button!==0)return;let t=bb(e.nativeEvent),n=T?h.current:g.current;if(n&&yb(n,t))return;let r=m.current;if(!r)return;let i=T?f.current:p.current;if(!n||!i)return;let a=T?`y`:`x`,o=zT(n,`margin`,a),s=zT(i,`padding`,a),c=T?n.offsetHeight:n.offsetWidth,l=i.getBoundingClientRect(),u=T?e.clientY-l.top-c/2-s+o/2:e.clientX-l.left-c/2-s+o/2,d=T?r.scrollHeight:r.scrollWidth,v=T?r.clientHeight:r.clientWidth,x=(T?i.offsetHeight:i.offsetWidth)-c-s-o;if(x<=0)return;let S=u/x,C=d-v;b(),T?r.scrollTop=S*C:r.scrollLeft=D===`rtl`?-(1-S)*C:S*C,y({x:r.scrollLeft,y:r.scrollTop}),_(e)},onPointerUp:v,onPointerCancel:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:O?`hidden`:void 0,...T?{top:0,bottom:`var(--scroll-area-corner-height)`,insetInlineEnd:0,"--scroll-area-thumb-height":`${S.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(--scroll-area-corner-width)`,bottom:0,"--scroll-area-thumb-width":`${S.width}px`}}},M=Vr(`div`,e,{ref:[t,T?f:p],state:E,props:[j,s],stateAttributesMapping:UT});return A?(0,K.jsx)(fE.Provider,{value:i,children:M}):null}),hE=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:d,scrollingY:f,hasMeasuredScrollbar:p}=RT(),m=pE(),h=m===`vertical`;return Vr(`div`,e,{ref:[t,h?o:s],state:{scrolling:h?f:d,orientation:m},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:p?void 0:`hidden`,...h?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),gE=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=RT(),l=Vr(`div`,e,{ref:[t,o],props:[{style:{position:`absolute`,bottom:0,insetInlineEnd:0,width:s.width,height:s.height}},a]});return c.corner?null:l});function _E({className:e,children:t,scrollFade:n=!1,scrollbarGutter:r=!1,...i}){return(0,K.jsxs)(ZT,{className:G(`size-full min-h-0`,e),...i,children:[(0,K.jsx)(cE,{className:G(`h-full !overflow-y-auto overscroll-contain rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background`,n&&`mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]`,r&&`data-has-overflow-y:pe-2.5 data-has-overflow-x:pb-2.5`),"data-slot":`scroll-area-viewport`,children:t}),(0,K.jsx)(vE,{orientation:`vertical`}),(0,K.jsx)(vE,{orientation:`horizontal`}),(0,K.jsx)(gE,{"data-slot":`scroll-area-corner`})]})}function vE({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(mE,{className:G(`m-1 flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100`,e),"data-slot":`scroll-area-scrollbar`,orientation:t,...n,children:(0,K.jsx)(hE,{className:`relative flex-1 rounded-full bg-foreground/20`,"data-slot":`scroll-area-thumb`})})}var yE=e=>{typeof window>`u`||window.electronAPI?.browser?.setOverlayActive(e)},bE=0,xE=!1;function SE(){let e=bE>0;e!==xE&&(xE=e,yE(xE))}function CE(){bE+=1,SE()}function wE(){bE=Math.max(0,bE-1),SE()}function TE(){return bE>0}function EE(e=!0){(0,U.useLayoutEffect)(()=>{if(e)return CE(),()=>wE()},[e])}function DE(){return EE(),null}var OE=0,kE=!1,AE=!1,jE=!1;function ME(){let e=OE>0&&!AE;e!==kE&&(kE=e,window.electronAPI?.window?.setTrafficLightsVisible(!e))}function NE(){jE||(jE=!0,window.electronAPI?.window?.isFullScreen().then(e=>{AE=e,ME()}).catch(()=>{}),window.electronAPI?.window?.onFullScreenChange(e=>{AE=e,ME()}))}function PE(){window.electronAPI?.env?.platform===`darwin`&&(NE(),OE++,ME())}function FE(){window.electronAPI?.env?.platform===`darwin`&&(OE=Math.max(0,OE-1),ME())}function IE(e){(0,U.useEffect)(()=>{if(e)return PE(),()=>FE()},[e])}var LE={BASE:0,SETTINGS_WINDOW:10,MOBILE_DRAWER:30,DROPDOWN:40,MODAL_BACKDROP:50,MODAL_CONTENT:51,DROPDOWN_IN_MODAL:60,NESTED_MODAL_BACKDROP:70,NESTED_MODAL_CONTENT:71,DROPDOWN_IN_NESTED_MODAL:80,TOOLTIP:100,TOAST:110,DEVTOOLS_OVERLAY:120},RE=(0,U.createContext)(LE.DROPDOWN);function zE(e){return IE(e.open??!1),(0,K.jsx)(jT,{...e})}var BE=CT;function VE(e){return(0,K.jsx)(Yte,{"data-slot":`dialog-trigger`,...e})}function HE({className:e,...t}){return(0,K.jsx)(ny,{className:G(`fixed inset-0 no-drag bg-black/32 backdrop-blur-sm transition-opacity duration-150 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`dialog-backdrop`,"data-enso-float":``,...t})}function UE({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`fixed inset-0 grid grid-rows-[1fr_auto_3fr] justify-items-center p-4 pointer-events-none`,e),"data-slot":`dialog-viewport`,...t})}function WE({className:e,children:t,showCloseButton:n=!0,bottomStickOnMobile:r=!0,disableNestedTransform:i=!1,showBackdrop:a=!0,zIndexLevel:o=`base`,style:s,...c}){let l=i?{...s??{},"--nested-dialogs":0}:s,u=o===`base`?LE.MODAL_CONTENT:LE.NESTED_MODAL_CONTENT,d=o===`base`?LE.MODAL_BACKDROP:LE.NESTED_MODAL_BACKDROP,f=o===`base`?LE.DROPDOWN_IN_MODAL:LE.DROPDOWN_IN_NESTED_MODAL;return(0,K.jsxs)(BE,{children:[(0,K.jsx)(DE,{}),a&&(0,K.jsx)(HE,{style:{zIndex:d}}),(0,K.jsx)(UE,{className:G(r&&`max-sm:grid-rows-[1fr_auto] max-sm:pt-12`),style:{zIndex:u},children:(0,K.jsxs)(bT,{className:G(`-translate-y-[calc(1.25rem*var(--nested-dialogs))] no-drag pointer-events-auto relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg transition-[scale,opacity,translate] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-95 data-starting-style:scale-95 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,r&&`max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none`,e),style:l,"data-slot":`dialog-popup`,...c,children:[(0,K.jsx)(RE.Provider,{value:f,children:t}),n&&(0,K.jsx)(qy,{"aria-label":`Close`,className:`absolute end-3 top-2.5 z-50 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors`,children:(0,K.jsx)(ir,{className:`h-4 w-4`})})]})})]})}function GE({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`dialog-header`,...t})}function KE({className:e,variant:t=`default`,...n}){return(0,K.jsx)(`div`,{className:G(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t==="default"&&`border-t bg-muted/50 py-4`,t===`bare`&&`in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pt-3 pt-4 pb-6`,e),"data-slot":`dialog-footer`,...n})}function qE({className:e,...t}){return(0,K.jsx)(NT,{className:G(`font-heading text-xl leading-none`,e),"data-slot":`dialog-title`,...t})}function JE({className:e,...t}){return(0,K.jsx)(Qy,{className:G(`text-muted-foreground text-sm`,e),"data-slot":`dialog-description`,...t})}var YE=`px-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-header]))]:pt-6 in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer]))]:pb-6! in-[[data-slot=dialog-popup]:not(:has([data-slot=dialog-footer].border-t))]:pb-1 pb-6`;function XE({className:e,bare:t=!1,...n}){let r=(0,K.jsx)(`div`,{className:G(YE,e),"data-slot":`dialog-panel`,...n});return t?r:(0,K.jsx)(_E,{className:`!h-auto min-h-0 flex-1`,children:r})}var ZE=0;function QE(e){return ZE+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${ZE}`}var $E=U.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:l}=SS({container:r,ref:t,componentProps:e,elementProps:s});return!l&&!c?null:(0,K.jsxs)(U.Fragment,{children:[l,c&&Gs.createPortal(n,c)]})}),eD=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0,offsetParent:d=`real`}=$b(e,t)||{};if(l==null)return{};let f=_x(u),p={x:n,y:r},m=ax(i),h=rx(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=Qb(k,j,A),N=!c.arrow&&tx(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),tD=(e,t)=>({...eD(e),options:[e,t]}),nD={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},rD={sideX:`left`,sideY:`top`},iD=`--available-width`,aD=`--available-height`;function oD(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function sD(e,t,n){let{rects:r,placement:i}=e;return{side:oD(t,ex(i),n),align:tx(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function cD(e){return lD(e,kte)}function lD(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:l=5,sticky:u=!1,arrowPadding:d=5,disableAnchorTracking:f=!1,inline:p,keepMounted:m=!1,floatingRootContext:h,mounted:g,collisionAvoidance:_,shift:v,nodeId:y,adaptiveOrigin:b,lazyFlip:x=!1,externalTree:S}=e,[C,w]=U.useState(null);!g&&C!==null&&w(null);let T=_.side||`flip`,E=_.align||`flip`,D=_.fallbackAxisSide||`end`,O=v?.crossAxis??!1,k=v?.rootBoundary,A=typeof n==`function`?n:void 0,j=Ay(A),M=A?j:n,N=Ib(n),P=Ib(g),F=tE()===`rtl`,I=C||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":F?`left`:`right`,"inline-start":F?`right`:`left`}[i],L=o===`center`?I:`${I}-${o}`,R=l;typeof R==`number`?R={top:R,right:R,bottom:R,left:R}:R&&={top:R.top||0,right:R.right||0,bottom:R.bottom||0,left:R.left||0};let ee=+(i===`bottom`),z=+(i===`top`),B=+(i===`right`),V=+(i===`left`),te={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:R},H=U.useRef(null),ne=Ib(a),re=Ib(s),ie=typeof a==`function`?0:a,ae=typeof s==`function`?0:s,oe=[];p&&oe.push(p),oe.push(WC(e=>{let t=sD(e,i,F),n=typeof ne.current==`function`?ne.current(t):ne.current,r=typeof re.current==`function`?re.current(t):re.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ie,ae,F,i]));let se=E===`none`&&T!==`shift`,ce=!se&&(u||O||T===`shift`),le=T===`none`?null:qC({...te,padding:{top:R.top+1+ee,right:R.right+1+V,bottom:R.bottom+1+z,left:R.left+1+B},mainAxis:!O&&T===`flip`,crossAxis:E===`flip`&&`alignment`,fallbackAxisSideDirection:D}),ue=se?null:GC({...te,rootBoundary:k,mainAxis:E!==`none`,crossAxis:ce,limiter:u||O?void 0:KC(e=>{if(!H.current)return{};let{width:t,height:n}=H.current.getBoundingClientRect(),r=ix(ex(e.placement)),i=r===`y`?t:n,a=r===`y`?R.left+R.right:R.top+R.bottom;return{offset:i/2+a/2}})},[te,u,O,k,R,E]);T===`shift`||E===`shift`||o===`center`?oe.push(ue,le):oe.push(le,ue),oe.push(JC({...te,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!P.current)return;let i=e.style;i.setProperty(iD,`${t}px`),i.setProperty(aD,`${n}px`);let a=ay(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(`--anchor-width`,`${u}px`),i.setProperty(`--anchor-height`,`${d}px`)}}),tD(e=>({element:H.current||My(e.elements.floating).createElement(`div`),padding:d,offsetParent:`floating`}),[d]),{name:`transformOrigin`,fn(e){let{elements:t,middlewareData:n,placement:r,rects:o,y:s}=e,c=ex(r),l=ix(c),u=H.current,d=n.arrow?.x||0,f=n.arrow?.y||0,p=u?.clientWidth||0,m=u?.clientHeight||0,h=d+p/2,g=f+m/2,_=Math.abs(n.shift?.y||0),v=o.reference.height/2,y=typeof a==`function`?a(sD(e,i,F)):a,b=_>y,x={top:`${h}px calc(100% + ${y}px)`,bottom:`${h}px ${-y}px`,left:`calc(100% + ${y}px) ${g}px`,right:`${-y}px ${g}px`}[c],S=`${h}px ${o.reference.y+v-s}px`;return t.floating.style.setProperty(`--transform-origin`,ce&&l===`y`&&b?S:x),{}}},nD,b),X(()=>{!g&&h&&h.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[g,h]);let de=U.useMemo(()=>({elementResize:!f&&typeof ResizeObserver<`u`,layoutShift:!f&&typeof IntersectionObserver<`u`}),[f]),{refs:fe,elements:pe,x:me,y:he,middlewareData:ge,update:_e,placement:ve,context:ye,isPositioned:be,floatingStyles:xe}=t({rootContext:h,open:m?g:void 0,placement:L,middleware:oe,strategy:r,whileElementsMounted:m?void 0:(...e)=>jC(...e,de),nodeId:y,externalTree:S}),{sideX:Se,sideY:Ce}=ge.adaptiveOrigin||rD,we=be?r:`fixed`,Te=U.useMemo(()=>{let e;return e=be?b?{position:we,[Se]:me,[Ce]:he}:{...xe,position:we}:{position:we,top:0,left:0},e[iD]=`100vw`,e[aD]=`100vh`,be||(e.opacity=0),e},[b,we,Se,me,Ce,he,xe,be]),Ee=U.useRef(null);X(()=>{if(!g)return;let e=N.current,t=typeof e==`function`?e():e,n=(uD(t)?t.current:t)||null;n!==Ee.current&&(fe.setPositionReference(n),Ee.current=n)},[g,fe,M,N]),U.useEffect(()=>{if(!g)return;let e=N.current;typeof e!=`function`&&uD(e)&&e.current!==Ee.current&&(fe.setPositionReference(e.current),Ee.current=e.current)},[g,fe,M,N]),U.useEffect(()=>{if(m&&g&&pe.reference&&pe.floating)return jC(pe.reference,pe.floating,_e,de)},[m,g,pe,_e,de]);let De=ex(ve),Oe=oD(i,De,F),ke=tx(ve)||`center`,Ae=!!ge.hide?.referenceHidden;X(()=>{x&&g&&be&&De!==I&&w(De)},[x,g,be,De,I]);let je=U.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),Me=ge.arrow?.centerOffset!==0;return U.useMemo(()=>({positionerStyles:Te,arrowStyles:je,arrowRef:H,arrowUncentered:Me,side:Oe,align:ke,physicalSide:De,anchorHidden:Ae,refs:fe,context:ye,isPositioned:be,update:_e}),[Te,je,H,Me,Oe,ke,De,Ae,fe,ye,be,_e])}function uD(e){return e!=null&&`current`in e}function dD(e){return e===`starting`?mS:Lr}function fD(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Vr(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},dD(r),i],stateAttributesMapping:ey})}function pD(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||QE(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var mD=pD();function hD(e){let t={error:1e4,warning:1e4,loading:0,success:5e3,info:5e3},n=e.type,r=e.timeout??(n?t[n]:5e3),{actions:i,data:a,...o}=e,s=i?{...a,actions:i}:a;return mD.add({...o,data:s,timeout:r})}var gD=[`agents`,`members`,`chats`];function _D(e){return[...gD.flatMap(t=>e[t].map(e=>({candidate:e,group:t}))),...e.files.map(e=>({candidate:e,group:`files`}))]}function vD(e,t){let n=gD.filter(t=>e[t].length>0);return!t.trim()&&n.length>0?[...n.map(e=>({type:`folder`,id:e})),...e.files.map(e=>({type:`item`,candidate:e,group:`files`}))]:_D(e).map(e=>({type:`item`,candidate:e.candidate,group:e.group}))}function yD(e){return e.map(e=>({...e,kind:`agent-type`,id:e.typeKey,label:e.displayName}))}function bD(e){let t=new Set,n=[];for(let r of e)!r.relativePath||t.has(r.relativePath)||(t.add(r.relativePath),n.push({kind:`file`,id:r.relativePath,label:r.name||r.relativePath.split(`/`).at(-1)||r.relativePath,relativePath:r.relativePath}));return n}function xD(e,t,n,r=[]){let i=e.trim().toLocaleLowerCase(),a=i?t.filter(e=>`${e.label}\n${e.description}\n${e.source}\n${e.typeKey}`.toLocaleLowerCase().includes(i)):[...t],o=i?n.filter(e=>`${e.label}\n${e.relativePath}`.toLocaleLowerCase().includes(i)):[...n],s=i?r.filter(e=>e.label.toLocaleLowerCase().includes(i)):[...r];return{agents:a.filter(e=>e.source!==`bot`),members:a.filter(e=>e.source===`bot`),files:o,chats:s}}function SD(e,t,n=[],r={}){let[i,a]=(0,U.useState)([]),[o,s]=(0,U.useState)([]),c=t!==null,{searchFiles:l,agents:u=!0}=r;return(0,U.useEffect)(()=>{if(!c||!u)return;a([]);let e=!1;return window.electronAPI.agentRegistry.list().then(t=>{let n=A(t);e||a(n?yD(n.candidates):[])}).catch(()=>{e||a([])}),()=>{e=!0}},[c,u]),(0,U.useEffect)(()=>{if(t===null||!e&&!l){s([]);return}let n=!1,r=window.setTimeout(()=>{(l?l(t):window.electronAPI.files.search({conversationId:e,query:t})).then(e=>{n||s(bD(e))}).catch(()=>{n||s([])})},150);return()=>{n=!0,window.clearTimeout(r)}},[e,t,l]),(0,U.useMemo)(()=>t===null?{agents:[],members:[],files:[],chats:[]}:xD(t,i,o,n),[i,o,n,t])}var CD=1024,wD=(e,t)=>e<=(t?CD:767),TD=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches,ED=()=>typeof window<`u`&&typeof window.innerWidth==`number`&&wD(window.innerWidth,TD()),DD=e=>(window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e));function OD(){return(0,U.useSyncExternalStore)(DD,()=>wD(window.innerWidth,TD()),()=>!1)}var kD=`mod+shift+m`,AD=typeof navigator<`u`&&typeof navigator.platform==`string`?navigator.platform.startsWith(`Mac`):process.platform===`darwin`,jD={"toggle-sidebar":`mod+b`,"toggle-app-mode":`mod+e`,"toggle-side-panel":`mod+j`,"toggle-side-panel-fullscreen":`mod+shift+j`,"open-settings":`mod+,`,"open-secretary":`mod+shift+s`,"switch-model":`mod+.`,"focus-composer":`mod+l`,"send-message":`enter`,"find-in-chat":`mod+f`,"search-workspace":`mod+k`,"new-conversation":`mod+n`,"next-tab":AD?`ctrl+tab`:`mod+tab`,"prev-tab":AD?`ctrl+shift+tab`:`mod+shift+tab`,"new-side-tab":`mod+t`,"new-btw-tab":`mod+shift+b`,"close-side-tab":`mod+w`,"toggle-minimize-to-tray":kD};function MD(e){return{...jD,...e}}function ND(e,t){let n=PD(e);if([`meta`,`control`,`alt`,`shift`].includes(n))return null;let r=AD?e.metaKey:e.ctrlKey,i=AD&&e.ctrlKey;if(!(r||i||e.altKey)&&!(t?.allowBare&&n===`enter`))return null;let a=[];return r&&a.push(`mod`),i&&a.push(`ctrl`),e.altKey&&a.push(`alt`),e.shiftKey&&a.push(`shift`),a.push(n),a.join(`+`)}function PD(e){if(e.key===` `||e.key===`\xA0`)return`space`;if(e.altKey){let t=/^(?:Key([A-Z])|Digit([0-9]))$/.exec(e.code??``);if(t)return(t[1]??t[2]??``).toLowerCase()}return e.key.toLowerCase()}function FD(e){let t=e.split(`+`),n=t.at(-1)??``,r=n.length===1?n.toUpperCase():n.charAt(0).toUpperCase()+n.slice(1);return AD?[t.includes(`ctrl`)?`⌃`:``,t.includes(`alt`)?`⌥`:``,t.includes(`shift`)?`⇧`:``,t.includes(`mod`)?`⌘`:``,r].join(``):[t.includes(`mod`)?`Ctrl`:``,t.includes(`alt`)?`Alt`:``,t.includes(`shift`)?`Shift`:``,r].filter(Boolean).join(`+`)}var ID=new Set,LD=!1;function RD(e,t){t?ID.add(e):ID.delete(e);let n=ID.size>0;n!==LD&&(LD=n,window.electronAPI?.updater?.reportUnsentDraft?.(n))}var zD=[],BD=e=>`/${e.pluginId}:${e.id}`;function VD(e){return zD.find(t=>BD(t)===e)??null}function HD(){return zD}async function UD(e,t){let n=await window.electronAPI.extensionPlugins.call({pluginId:e.pluginId,method:`command.run`,payload:{id:e.id},sessionId:t});return n.ok?null:n.error}var WD=null,GD=new Map;function KD(e){return WD=e,()=>{WD===e&&(WD=null)}}function qD(e){let t=GD.get(e);return GD.delete(e),t}var JD=[],YD=0,XD=new Set;function ZD(){return YD}function QD(e){return XD.add(e),()=>XD.delete(e)}function $D(e){return JD.filter(t=>t.slot===`message.action`&&t.position===e)}function eO(e){let t=e===`left`?`composer.left`:`composer.right`;return JD.filter(e=>e.slot===t)}function tO(e,t){return JD.find(n=>n.slot===`tool.card`&&n.pluginId===e&&n.toolName===t)}function nO(){return JD.find(e=>e.slot===`thinking.body`)}function rO(){return JD.find(e=>e.slot===`message.leaf`)}function iO(e,t){let n=t.toLowerCase();return JD.find(t=>t.slot===`block`&&t.pluginId===e&&t.language===n)}var aO=/^[a-z][a-z0-9]*(\.[a-z0-9]+)+$/;function oO(e){if(!e)return null;let t=e.indexOf(`:`);if(t<=0)return null;let n=e.slice(0,t),r=e.slice(t+1);return!aO.test(n)||r.length===0?null:{pluginId:n,lang:r}}function sO({entry:e,props:t}){return(0,U.createElement)(e.component,t)}function cO(){return(0,U.useSyncExternalStore)(QD,ZD,ZD)}var lO=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`[plugin] ${this.props.pluginId} 挂点 ${this.props.slot} 渲染失败`,e)}render(){return this.state.failed?this.props.fallback??null:this.props.children}};function uO({entry:e,props:t,fallback:n}){return(0,K.jsx)(lO,{pluginId:e.pluginId,slot:e.slot,fallback:n,children:(0,K.jsx)(sO,{entry:e,props:t})})}function dO({position:e,text:t,messageIndex:n,sessionId:r}){cO();let i=$D(e);return i.length===0?null:(0,K.jsx)(K.Fragment,{children:i.map(i=>(0,K.jsx)(uO,{entry:i,props:{position:e,text:t,messageIndex:n,sessionId:r}},`${i.pluginId}:${i.uid}`))})}function fO({name:e,output:t,state:n}){cO();let r=w(e);if(!r)return null;let i=tO(r.pluginId,r.toolName);return i?(0,K.jsx)(uO,{entry:i,props:{toolName:r.toolName,output:t,state:n}}):null}var pO=[`t-acc-reveal mt-1 ml-[10px] border-l-2 border-border py-0.5 pl-[19px]`,`text-[13px] leading-relaxed text-muted-foreground whitespace-pre-wrap`].join(` `);function mO({text:e,streaming:t,itemKey:n}){cO();let r=nO();return r?(0,K.jsx)(`div`,{className:pO,children:(0,K.jsx)(uO,{entry:r,props:{text:e,streaming:t,itemKey:n},fallback:e},r.uid)}):(0,K.jsx)(`p`,{className:pO,children:e})}function hO({entry:e,source:t,final:n,messageIndex:r,sessionId:i,Markdown:a}){return(0,K.jsx)(uO,{entry:e,props:{source:t,final:n,messageIndex:r,sessionId:i,Markdown:a}})}function gO({pluginId:e,lang:t,source:n}){cO();let r=iO(e,t);return r?(0,K.jsx)(uO,{entry:r,props:{language:t,source:n}}):null}function _O({side:e,sessionId:t,draft:n,busy:r,pluginPresetId:i}){cO();let a=eO(e);return a.length===0?null:(0,K.jsx)(K.Fragment,{children:a.map(a=>(0,K.jsx)(uO,{entry:a,props:{position:e,sessionId:t,draft:n,busy:r,pluginPresetId:i}},`${a.pluginId}:${a.uid}`))})}var vO=[],yO=new Set;function bO(e){return yO.add(e),()=>yO.delete(e)}var xO=()=>vO,SO={neutral:`text-muted-foreground`,accent:`text-primary`,success:`text-emerald-600 dark:text-emerald-400`,warning:`text-amber-600 dark:text-amber-400`,danger:`text-red-600 dark:text-red-400`};function CO({sessionId:e}){let t=(0,U.useSyncExternalStore)(bO,xO,xO);return t.length===0?null:(0,K.jsx)(K.Fragment,{children:t.map(t=>{let n=t.command?HD().find(e=>e.pluginId===t.pluginId&&e.id===t.command):void 0,r=G(`shrink-0 truncate px-1 text-[11px]`,SO[t.tone]),i=t.tooltip?`${t.tooltip} · ${t.pluginName}`:t.pluginName;return n?(0,K.jsx)(`button`,{type:`button`,title:i,className:G(r,`rounded hover:bg-accent`),onClick:()=>void UD(n,e).then(e=>{e&&hD({title:e})}),children:t.text},`${t.pluginId}:${t.id}`):(0,K.jsx)(`span`,{title:i,className:r,children:t.text},`${t.pluginId}:${t.id}`)})})}var wO=50,TO=64,EO=120,DO=32768,OO=120,kO=[];function AO(e){return/(?:^|\s)#([^\s#]*)$/.exec(e)?.[1]??null}function jO(e,t,n){if(!Array.isArray(n))return[];let r=[];for(let i of n){if(r.length>=wO)break;if(typeof i!=`object`||!i)continue;let{id:n,label:a,detail:o}=i;typeof n!=`string`||!n||typeof a!=`string`||!a||r.push({key:`${e}:${t}:${n}`,pluginId:e,name:t,item:{id:n.slice(0,200),label:a.slice(0,TO),...typeof o==`string`&&o?{detail:o.slice(0,EO)}:{}}})}return r}function MO(e){let t=typeof e==`string`?e:typeof e==`object`&&e?e.text:null;return typeof t==`string`&&t.length<=DO?t:null}var NO=[],PO=new Set;function FO(e){return PO.add(e),()=>PO.delete(e)}var IO=()=>NO;function LO(e,t){let n=(0,U.useSyncExternalStore)(FO,IO,IO),[r,i]=(0,U.useState)(kO);return(0,U.useEffect)(()=>{if(e===null||n.length===0){i(kO);return}let r=!1,a=setTimeout(()=>{Promise.all(n.map(async({pluginId:n,name:r})=>{let i=await window.electronAPI.extensionPlugins.call({pluginId:n,method:`trigger.candidates`,payload:{name:r,query:e},sessionId:t});return i.ok?jO(n,r,i.value):kO})).then(e=>{r||i(e.flat().slice(0,wO))})},OO);return()=>{r=!0,clearTimeout(a)}},[e,n,t]),e===null?kO:r}async function RO(e,t){let n=await window.electronAPI.extensionPlugins.call({pluginId:e.pluginId,method:`trigger.pick`,payload:{name:e.name,item:e.item},sessionId:t});return n.ok?MO(n.value):null}var zO=null,BO=null,VO=null,HO=null,UO=null,WO=null,GO=null,KO=null,qO=null;function JO(e){return zO=e,()=>{zO===e&&(zO=null)}}function YO(e){return HO=e,()=>{HO===e&&(HO=null)}}function XO(e){return BO=e,()=>{BO===e&&(BO=null)}}function ZO(){return HO?(HO(),!0):!1}function QO(e){return VO=e,()=>{VO===e&&(VO=null)}}function $O(e){return VO?(VO(e),!0):!1}function ek(e){return qO=e,()=>{qO===e&&(qO=null)}}function tk(e){return BO?(BO(e),!0):!1}function nk(e){return UO=e,()=>{UO===e&&(UO=null)}}function rk(e){return WO=e,()=>{WO===e&&(WO=null)}}function ik(e){return GO=e,()=>{GO===e&&(GO=null)}}function ak(e){return KO=e,()=>{KO===e&&(KO=null)}}var ok=`composer-drop`,sk=/<quote(?: truncated="true" original-lines="(\d+)")?>\n([\s\S]*?)\n<\/quote>/g;function ck(e){return`<quote${e.originalLines?` truncated="true" original-lines="${e.originalLines}"`:``}>\n${e.text.replace(/<\/quote>/g,`<\\/quote>`)}\n</quote>`}function lk(e){let t=e[2].replace(/<\\\/quote>/g,`</quote>`);return e[1]?{text:t,originalLines:Number(e[1])}:{text:t}}function uk(e){return e.search(sk)>=0}function dk(e){return e.replace(sk,(...e)=>{let t=lk(e),n=t.text.replace(/^/gm,`> `);return t.originalLines?`${n}\n> …`:n})}function fk(e){return e.replace(sk,``).trim()||[...e.matchAll(sk)].map(e=>lk(e).text).join(`
163
+ `)}var pk=[{name:`blue`,rgb:[58,150,221],cssVar:`--cursor-blue`},{name:`purple`,rgb:[155,89,182],cssVar:`--cursor-purple`},{name:`green`,rgb:[39,174,96],cssVar:`--cursor-green`},{name:`orange`,rgb:[242,153,74],cssVar:`--cursor-orange`},{name:`cyan`,rgb:[0,184,169],cssVar:`--cursor-cyan`},{name:`magenta`,rgb:[219,68,134],cssVar:`--cursor-magenta`},{name:`red`,rgb:[235,87,87],cssVar:`--cursor-red`},{name:`yellow`,rgb:[170,175,18],cssVar:`--cursor-yellow`}];pk.map(e=>e.name);function mk(e,t){return`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${t})`}pk.map(({rgb:e})=>({fill:mk(e,.04),stroke:mk(e,.5),scribbleStroke:mk(e,.92)})),pk.map(({rgb:e})=>({border:mk(e,1),bg:mk(e,.1),hoverBorder:mk(e,.3),hoverBg:mk(e,.02)}));var{PI:hk}=Math;hk+1e-4;var gk=`CSS edits — `;RegExp(`^${gk}.*$`,`m`),RegExp(`^${gk}`,`gm`);var _k=/\n*```browser_element\n[\s\S]*?```(?=\n|$)/g;function vk(e){return e.replace(_k,``).trimEnd()}var yk=/^<unattended>\n([\s\S]*?)\n<\/unattended>(?:\n\n|$)/;function bk(e){let t=yk.exec(e);return t?{note:/unattended mode is off/i.test(t[1])?`off`:`on`,rest:e.slice(t[0].length)}:{rest:e}}var xk=`background-tasks-wrap-up`,Sk=RegExp(`^<${xk}>\\n[\\s\\S]*?\\n</${xk}>(?:\\n\\n|$)`),Ck=/^- (\S+?): (.*?)(?: \(running ([^()]+)\))?$/;function wk(e){let t=[];for(let n of e.split(`
164
+ `)){let e=Ck.exec(n);e?.[1]&&t.push({taskId:e[1],command:e[2]??``,...e[3]?{ran:e[3]}:{}})}return t}function Tk(e){let t=Sk.exec(e);return t?{items:wk(t[0]),rest:e.slice(t[0].length)}:null}function Ek(e){let t=e,n,r,i;for(;;){let a=n?{rest:t}:he(t);if(a.note){n=a.note,t=a.rest;continue}let o=i?null:Tk(t);if(o){let n=e.length-t.length;i={items:o.items,start:n,end:n+t.length-o.rest.length},t=o.rest;continue}let s=r?{rest:t}:bk(t);if(!s.note)break;r=s.note,t=s.rest}return{...n?{plan:n}:{},...r?{unattended:r}:{},wrapUp:i,rest:t}}function Dk(e){let{plan:t,unattended:n,rest:r}=Ek(e);return{...t?{plan:t}:{},...n?{unattended:n}:{},rest:r}}function Ok(e){let t=Ek(e).wrapUp;return t?{items:t.items}:void 0}function kk(e){let t=Ek(e).wrapUp;return t?e.slice(0,t.start)+e.slice(t.end):e}var Ak=/^\/skill:(\S+)(?:\s+|$)/,jk=/^<skill name="([^"]+)" location="([^"]*)">\n([\s\S]*?)\n<\/skill>(?:\n\n|$)/;function Mk(e){let t=[],n=e;for(let e=Ak.exec(n);e;e=Ak.exec(n))t.push(e[1]),n=n.slice(e[0].length);return{names:t,rest:t.length>0?n.trim():e}}function Nk(e){let t=[],n=e;for(let e=jk.exec(n);e;e=jk.exec(n))t.push({name:e[1],location:e[2],body:e[3]}),n=n.slice(e[0].length);return t.length>0?{skills:t,rest:n.trim()}:null}var Pk=/^<workflow-preset name="([^"]*)">\n(\{.*\})\n<\/workflow-preset>(?:\n\n[\s\S]*)?$/,Fk=e=>e.replace(/&(amp|quot|lt|gt);/g,e=>e===`&amp;`?`&`:e===`&quot;`?`"`:e===`&lt;`?`<`:`>`);function Ik(e){let t=Pk.exec(e);if(!t)return null;let n;try{n=JSON.parse(t[2]??``)}catch{return null}if(!n||typeof n!=`object`||Array.isArray(n))return null;let{preset:r,args:i={}}=n;if(typeof r!=`string`||!r||!i||typeof i!=`object`||Array.isArray(i))return null;let a=Object.entries(i);return a.some(([,e])=>typeof e!=`string`)?null:{id:r,name:Fk(t[1]??``),args:a}}var Lk=/\[Referenced past chat "(.+?)" — transcript file: (.+?) \(pi session jsonl; read it if relevant\)\]/g,Rk=/\[Selected UI element "([^"]*)" — path: (.*?); text: (.*?)\]/g;function zk(e,t){for(let n=t-1;n>=0;n--){let r=e[n];if(r===`@`){let r=n>0?e[n-1]:` `;return r===` `||r===`
165
165
  `?e.slice(n+1,t):null}if(r===` `||r===`
166
- `)return null}return null}function Vk(e){let t=Math.max(0,e.containerWidth-e.popupWidth),n=Math.min(Math.max(0,e.anchorLeft),t);return{left:n,flyoutSide:e.containerWidth-n-e.popupWidth-e.flyoutGap>=e.flyoutWidth?`right`:`left`}}function Hk(e){if(e.isComposing||e.itemCount===0)return{type:`none`};let t=e.key===`Enter`&&!e.shiftKey||e.key===`Tab`;if(e.folderOpen){if(e.key===`Escape`||e.key===`ArrowLeft`)return{type:`close-folder`};let n=e.folderItemCount??0;if(n===0)return{type:`none`};let r=e.folderIndex??0;return e.key===`ArrowDown`?{type:`move-folder`,index:(r+1)%n}:e.key===`ArrowUp`?{type:`move-folder`,index:(r-1+n)%n}:t?{type:`pick`}:{type:`none`}}return e.activeIsFolder&&(e.key===`ArrowRight`||t)?{type:`open-folder`}:e.key===`ArrowDown`?{type:`move`,index:(e.activeIndex+1)%e.itemCount}:e.key===`ArrowUp`?{type:`move`,index:(e.activeIndex-1+e.itemCount)%e.itemCount}:t?{type:`pick`}:e.key===`Escape`?{type:`close`}:{type:`none`}}function Uk(e,t){return`[Referenced past chat "${e.replace(/["[\]\n]/g,` `).replace(/\s+/g,` `).trim()||`untitled`}" — transcript file: ${t} (pi session jsonl; read it if relevant)]`}var Wk=/^\[Referenced past chat "(.+)" — transcript file: (.+) \(pi session jsonl; read it if relevant\)\]$/,Gk=/^@(\S.*)$/;function Kk(e){let t=``;return e.forEach((n,r)=>{let i=e[r-1];t+=n.type===`text`?i?.type===`quote`?n.text.replace(/^[\u00a0 ]/,``):n.text:n.type===`quote`?`${t&&!t.endsWith(`
166
+ `)return null}return null}function Bk(e){let t=Math.max(0,e.containerWidth-e.popupWidth),n=Math.min(Math.max(0,e.anchorLeft),t);return{left:n,flyoutSide:e.containerWidth-n-e.popupWidth-e.flyoutGap>=e.flyoutWidth?`right`:`left`}}function Vk(e){if(e.isComposing||e.itemCount===0)return{type:`none`};let t=e.key===`Enter`&&!e.shiftKey||e.key===`Tab`;if(e.folderOpen){if(e.key===`Escape`||e.key===`ArrowLeft`)return{type:`close-folder`};let n=e.folderItemCount??0;if(n===0)return{type:`none`};let r=e.folderIndex??0;return e.key===`ArrowDown`?{type:`move-folder`,index:(r+1)%n}:e.key===`ArrowUp`?{type:`move-folder`,index:(r-1+n)%n}:t?{type:`pick`}:{type:`none`}}return e.activeIsFolder&&(e.key===`ArrowRight`||t)?{type:`open-folder`}:e.key===`ArrowDown`?{type:`move`,index:(e.activeIndex+1)%e.itemCount}:e.key===`ArrowUp`?{type:`move`,index:(e.activeIndex-1+e.itemCount)%e.itemCount}:t?{type:`pick`}:e.key===`Escape`?{type:`close`}:{type:`none`}}function Hk(e,t){return`[Referenced past chat "${e.replace(/["[\]\n]/g,` `).replace(/\s+/g,` `).trim()||`untitled`}" — transcript file: ${t} (pi session jsonl; read it if relevant)]`}var Uk=/^\[Referenced past chat "(.+)" — transcript file: (.+) \(pi session jsonl; read it if relevant\)\]$/,Wk=/^@(\S.*)$/;function Gk(e){let t=``;return e.forEach((n,r)=>{let i=e[r-1];t+=n.type===`text`?i?.type===`quote`?n.text.replace(/^[\u00a0 ]/,``):n.text:n.type===`quote`?`${t&&!t.endsWith(`
167
167
  `)?`
168
- `:``}${lk(n)}\n`:n.type===`file`?/\s/.test(n.path)&&!n.path.includes(`"`)?`@"${n.path}"`:`@${n.path}`:n.type===`chat`?Uk(n.label,n.sessionFile):lv(n)}),t}function qk(e,t){Rk.lastIndex=t,zk.lastIndex=t,ck.lastIndex=t;let n=Rk.exec(e),r=zk.exec(e),i=ck.exec(e),a=n?{index:n.index,length:n[0].length,segment:{type:`chat`,label:n[1],sessionFile:n[2]}}:null,o=r?dv(r[0]):null,s=r&&o?{index:r.index,length:r[0].length,segment:{type:`ui-element`,id:``,...o,imageId:``}}:null,c=null;if(i){let n=+(i.index>t&&e[i.index-1]===`
168
+ `:``}${ck(n)}\n`:n.type===`file`?/\s/.test(n.path)&&!n.path.includes(`"`)?`@"${n.path}"`:`@${n.path}`:n.type===`chat`?Hk(n.label,n.sessionFile):lv(n)}),t}function Kk(e,t){Lk.lastIndex=t,Rk.lastIndex=t,sk.lastIndex=t;let n=Lk.exec(e),r=Rk.exec(e),i=sk.exec(e),a=n?{index:n.index,length:n[0].length,segment:{type:`chat`,label:n[1],sessionFile:n[2]}}:null,o=r?dv(r[0]):null,s=r&&o?{index:r.index,length:r[0].length,segment:{type:`ui-element`,id:``,...o,imageId:``}}:null,c=null;if(i){let n=+(i.index>t&&e[i.index-1]===`
169
169
  `),r=+(e[i.index+i[0].length]===`
170
- `);c={index:i.index-n,length:i[0].length+n+r,segment:{type:`quote`,...uk(i)}}}return[c,a,s].filter(e=>e!==null).sort((e,t)=>e.index-t.index)[0]??null}function Jk(e){let t=[],n=0;for(let r of e.matchAll(ck)){let i=r.index??0,a=+(i>n&&e[i-1]===`
171
- `);i-a>n&&t.push({type:`text`,text:e.slice(n,i-a)}),t.push({type:`quote`,...uk(r)}),n=i+r[0].length,e[n]===`
172
- `&&(n+=1)}return n<e.length?t.push({type:`text`,text:e.slice(n)}):t.at(-1)?.type===`quote`&&t.push({type:`text`,text:`\xA0`}),t}function Yk(e){let t=[],n=0,r=qk(e,0);for(;r;){let i=e.slice(n,r.index);for(let e of tA(i))(e.type!==`text`||e.text!==``)&&t.push(e);t.push(r.segment),n=r.index+r.length,r=qk(e,n)}let i=e.slice(n);if(i||t.length===0)for(let e of tA(i))e.type===`text`&&e.text===``&&t.length>0||t.push(e);return t}var Xk=/^(?:[A-Za-z]:[\\/])?(?:[\p{L}\p{N}_./\\-]*\.[\w-]{1,16}(?:#L\d+(?:-L\d+)?)?|[\p{L}\p{N}_./\\-]+[\\/])$/u,Zk=/^"([^"\n]*(?:\.[\w-]{1,16}(?:#L\d+(?:-L\d+)?)?|[\\/]))"/,Qk=/#L\d+(?:-L\d+)?$/;function $k(e){return e.replace(Qk,``)}function eA(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e}function tA(e){return gv(e).flatMap(e=>e.type===`file`?[e]:nA(e.text))}function nA(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`@`,r);if(i===-1){n+=e.slice(r);break}let a=i>0?e[i-1]:` `,o=a===` `||a===`
173
- `?Zk.exec(e.slice(i+1)):null;if(o){n+=e.slice(r,i),n&&=(t.push({type:`text`,text:n}),``),t.push({type:`file`,path:o[1]}),r=i+1+o[0].length;continue}let s=(/^\S*/.exec(e.slice(i+1))?.[0]??``).replace(/[),.;!?]+$/,``);(a===` `||a===`
174
- `)&&s&&Xk.test(s)?(n+=e.slice(r,i),n&&=(t.push({type:`text`,text:n}),``),t.push({type:`file`,path:s}),r=i+1+s.length):(n+=e.slice(r,i+1),r=i+1)}return n&&t.push({type:`text`,text:n}),t.length>0?t:[{type:`text`,text:e}]}function rA(e){let t={body:e,files:[],chats:[]},n=e.split(`
175
- `),r=[],i=[],a=n.length-1;for(;a>=0;a--){let e=n[a],t=Wk.exec(e);if(t){i.unshift({label:t[1],sessionFile:t[2]});continue}if(Gk.test(e)){r.unshift(e.slice(1));continue}break}return r.length+i.length===0||a<0||n[a].trim()!==``?t:{body:n.slice(0,a).join(`
176
- `).trimEnd(),files:r,chats:i}}function iA(e){let t=Kk(e.segments).trim(),n=e.segments.filter(e=>e.type!==`text`&&e.type!==`quote`).map(e=>e.type===`file`?{kind:`file`,id:e.path,label:eA(e.path),relativePath:$k(e.path)}:e.type===`chat`?{kind:`chat`,id:e.conversationId??e.sessionFile,label:e.label,sessionFile:e.sessionFile}:{kind:`ui-element`,id:e.id,label:e.label,path:e.path,text:e.text,imageId:e.imageId});e.recipient&&n.push(e.recipient);let r=e.slashes.join(` `);return{text:r?t?`${r} ${t}`:r:t,images:e.images.map(({data:e,mimeType:t})=>({data:e,mimeType:t})),mentions:n,...e.recipient?{recipient:e.recipient}:{}}}function aA(e){return e.startsWith(`/skill:`)?`skill`:e===`/goal`?`goal`:`command`}function oA(e){return e.startsWith(`/skill:`)?e.slice(7):e.replace(/^\//,``)}function sA(e){let t=/^\/skill:(\S+)(?:\s+([\s\S]*))?$/.exec(e);if(t)return{slash:`/skill:${t[1]}`,rest:t[2]??``};let n=/^\/([A-Za-z][\w:-]*)(?:\s+([\s\S]*))?$/.exec(e);return n?{slash:`/${n[1]}`,rest:n[2]??``}:{slash:null,rest:e}}var cA={skill:Hn,goal:Xn,command:Gn},lA={skill:`bg-info/15 text-info`,goal:`bg-warning/25 text-warning-foreground dark:bg-warning/15 dark:text-warning`,command:`bg-foreground/10 text-foreground`};function uA(e,t=!1){return G(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 align-middle text-xs font-medium`,lA[e],t&&e===`skill`&&`hover:bg-info/25`,t&&e===`goal`&&`hover:bg-warning/35 dark:hover:bg-warning/25`,t&&e===`command`&&`hover:bg-foreground/15`)}function dA({name:e,className:t,interactive:n=!1,trailing:r}){let i=aA(e),a=cA[i];return(0,K.jsxs)(`span`,{className:G(uA(i,n),t),children:[(0,K.jsx)(a,{className:`h-3 w-3`}),oA(e),r]})}var fA=e=>e.startsWith(`/skill:`);function pA(e,t){return!fA(t)||!e.every(fA)?[t]:e.includes(t)?[...e]:[...e,t]}function mA(e){let t=Nk(e);if(t.names.length>0)return{slashes:t.names.map(e=>`/skill:${e}`),rest:t.rest};let n=sA(e);return{slashes:n.slash?[n.slash]:[],rest:n.rest}}function hA(e,t,n=!1){let r=e.segments.some(e=>e.type!==`text`||e.text.length>0);if(n&&(r||e.slashes.length>0))return{slashes:e.slashes,segments:[...e.segments,...t.text?Jk(`${r?`
170
+ `);c={index:i.index-n,length:i[0].length+n+r,segment:{type:`quote`,...lk(i)}}}return[c,a,s].filter(e=>e!==null).sort((e,t)=>e.index-t.index)[0]??null}function qk(e){let t=[],n=0;for(let r of e.matchAll(sk)){let i=r.index??0,a=+(i>n&&e[i-1]===`
171
+ `);i-a>n&&t.push({type:`text`,text:e.slice(n,i-a)}),t.push({type:`quote`,...lk(r)}),n=i+r[0].length,e[n]===`
172
+ `&&(n+=1)}return n<e.length?t.push({type:`text`,text:e.slice(n)}):t.at(-1)?.type===`quote`&&t.push({type:`text`,text:`\xA0`}),t}function Jk(e){let t=[],n=0,r=Kk(e,0);for(;r;){let i=e.slice(n,r.index);for(let e of eA(i))(e.type!==`text`||e.text!==``)&&t.push(e);t.push(r.segment),n=r.index+r.length,r=Kk(e,n)}let i=e.slice(n);if(i||t.length===0)for(let e of eA(i))e.type===`text`&&e.text===``&&t.length>0||t.push(e);return t}var Yk=/^(?:[A-Za-z]:[\\/])?(?:[\p{L}\p{N}_./\\-]*\.[\w-]{1,16}(?:#L\d+(?:-L\d+)?)?|[\p{L}\p{N}_./\\-]+[\\/])$/u,Xk=/^"([^"\n]*(?:\.[\w-]{1,16}(?:#L\d+(?:-L\d+)?)?|[\\/]))"/,Zk=/#L\d+(?:-L\d+)?$/;function Qk(e){return e.replace(Zk,``)}function $k(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e}function eA(e){return gv(e).flatMap(e=>e.type===`file`?[e]:tA(e.text))}function tA(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`@`,r);if(i===-1){n+=e.slice(r);break}let a=i>0?e[i-1]:` `,o=a===` `||a===`
173
+ `?Xk.exec(e.slice(i+1)):null;if(o){n+=e.slice(r,i),n&&=(t.push({type:`text`,text:n}),``),t.push({type:`file`,path:o[1]}),r=i+1+o[0].length;continue}let s=(/^\S*/.exec(e.slice(i+1))?.[0]??``).replace(/[),.;!?]+$/,``);(a===` `||a===`
174
+ `)&&s&&Yk.test(s)?(n+=e.slice(r,i),n&&=(t.push({type:`text`,text:n}),``),t.push({type:`file`,path:s}),r=i+1+s.length):(n+=e.slice(r,i+1),r=i+1)}return n&&t.push({type:`text`,text:n}),t.length>0?t:[{type:`text`,text:e}]}function nA(e){let t={body:e,files:[],chats:[]},n=e.split(`
175
+ `),r=[],i=[],a=n.length-1;for(;a>=0;a--){let e=n[a],t=Uk.exec(e);if(t){i.unshift({label:t[1],sessionFile:t[2]});continue}if(Wk.test(e)){r.unshift(e.slice(1));continue}break}return r.length+i.length===0||a<0||n[a].trim()!==``?t:{body:n.slice(0,a).join(`
176
+ `).trimEnd(),files:r,chats:i}}function rA(e){let t=Gk(e.segments).trim(),n=e.segments.filter(e=>e.type!==`text`&&e.type!==`quote`).map(e=>e.type===`file`?{kind:`file`,id:e.path,label:$k(e.path),relativePath:Qk(e.path)}:e.type===`chat`?{kind:`chat`,id:e.conversationId??e.sessionFile,label:e.label,sessionFile:e.sessionFile}:{kind:`ui-element`,id:e.id,label:e.label,path:e.path,text:e.text,imageId:e.imageId});e.recipient&&n.push(e.recipient);let r=e.slashes.join(` `);return{text:r?t?`${r} ${t}`:r:t,images:e.images.map(({data:e,mimeType:t})=>({data:e,mimeType:t})),mentions:n,...e.recipient?{recipient:e.recipient}:{}}}function iA(e){return e.startsWith(`/skill:`)?`skill`:e===`/goal`?`goal`:`command`}function aA(e){return e.startsWith(`/skill:`)?e.slice(7):e.replace(/^\//,``)}function oA(e){let t=/^\/skill:(\S+)(?:\s+([\s\S]*))?$/.exec(e);if(t)return{slash:`/skill:${t[1]}`,rest:t[2]??``};let n=/^\/([A-Za-z][\w:-]*)(?:\s+([\s\S]*))?$/.exec(e);return n?{slash:`/${n[1]}`,rest:n[2]??``}:{slash:null,rest:e}}var sA={skill:Hn,goal:Xn,command:Gn},cA={skill:`bg-info/15 text-info`,goal:`bg-warning/25 text-warning-foreground dark:bg-warning/15 dark:text-warning`,command:`bg-foreground/10 text-foreground`};function lA(e,t=!1){return G(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 align-middle text-xs font-medium`,cA[e],t&&e===`skill`&&`hover:bg-info/25`,t&&e===`goal`&&`hover:bg-warning/35 dark:hover:bg-warning/25`,t&&e===`command`&&`hover:bg-foreground/15`)}function uA({name:e,className:t,interactive:n=!1,trailing:r}){let i=iA(e),a=sA[i];return(0,K.jsxs)(`span`,{className:G(lA(i,n),t),children:[(0,K.jsx)(a,{className:`h-3 w-3`}),aA(e),r]})}var dA=e=>e.startsWith(`/skill:`);function fA(e,t){return!dA(t)||!e.every(dA)?[t]:e.includes(t)?[...e]:[...e,t]}function pA(e){let t=Mk(e);if(t.names.length>0)return{slashes:t.names.map(e=>`/skill:${e}`),rest:t.rest};let n=oA(e);return{slashes:n.slash?[n.slash]:[],rest:n.rest}}function mA(e,t,n=!1){let r=e.segments.some(e=>e.type!==`text`||e.text.length>0);if(n&&(r||e.slashes.length>0))return{slashes:e.slashes,segments:[...e.segments,...t.text?qk(`${r?`
177
177
 
178
- `:``}${t.text}`):[]],images:[...e.images,...t.images??[]]};let i=mA(t.text??``);return{slashes:i.slashes,segments:i.rest?Jk(i.rest):[],images:[...n?e.images:[],...t.images??[]]}}var gA={"agent-type":`bg-purple-500/15 text-purple-600 dark:text-purple-400`,file:`bg-success/15 text-success`,chat:`bg-warning/25 text-warning-foreground dark:bg-warning/15 dark:text-warning`,"ui-element":`bg-purple-500/15 text-purple-600 dark:text-purple-400`};function _A(e){return G(`inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 py-0.5 align-middle text-xs font-medium`,gA[e])}function vA({label:e,onRemove:t}){return(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm opacity-70 transition-opacity hover:opacity-100`,"aria-label":e,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})}function yA({recipient:e,onRemove:t}){let{t:n}=q();return(0,K.jsxs)(`span`,{className:G(_A(`agent-type`),`mt-0.5 shrink-0`),children:[(0,K.jsx)(ft,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.label}),(0,K.jsx)(vA,{label:n(`Remove Agent recipient`),onRemove:t}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.typeKey})]})}var bA=2e4,xA=3,SA=/^```/gm,CA=/^```/;function wA(e){return e.split(`
179
- `).filter(e=>!CA.test(e)).length}function TA(e){let t=e.replace(/\r\n?/g,`
178
+ `:``}${t.text}`):[]],images:[...e.images,...t.images??[]]};let i=pA(t.text??``);return{slashes:i.slashes,segments:i.rest?qk(i.rest):[],images:[...n?e.images:[],...t.images??[]]}}var hA={"agent-type":`bg-purple-500/15 text-purple-600 dark:text-purple-400`,file:`bg-success/15 text-success`,chat:`bg-warning/25 text-warning-foreground dark:bg-warning/15 dark:text-warning`,"ui-element":`bg-purple-500/15 text-purple-600 dark:text-purple-400`};function gA(e){return G(`inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 py-0.5 align-middle text-xs font-medium`,hA[e])}function _A({label:e,onRemove:t}){return(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm opacity-70 transition-opacity hover:opacity-100`,"aria-label":e,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})}function vA({recipient:e,onRemove:t}){let{t:n}=q();return(0,K.jsxs)(`span`,{className:G(gA(`agent-type`),`mt-0.5 shrink-0`),children:[(0,K.jsx)(ft,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.label}),(0,K.jsx)(_A,{label:n(`Remove Agent recipient`),onRemove:t}),(0,K.jsx)(`span`,{className:`sr-only`,children:e.typeKey})]})}var yA=2e4,bA=3,xA=/^```/gm,SA=/^```/;function CA(e){return e.split(`
179
+ `).filter(e=>!SA.test(e)).length}function wA(e){let t=e.replace(/\r\n?/g,`
180
180
  `).replace(/^\n+|\s+$/g,``);if(!t.trim())return null;let n=t.split(`
181
- `),r=wA(t);if(r<=200&&t.length<=2e4)return{type:`quote`,text:t};let i=0;for(let e=0;i<n.length&&!(!CA.test(n[i])&&++e>200);i++);let a=n.slice(0,i).join(`
182
- `).slice(0,bA);return(a.match(SA)?.length??0)%2==1&&(a+="\n```"),{type:`quote`,text:a,originalLines:r}}function EA(e){let t=e.split(`
183
- `);return t.length<=xA?{preview:e,clipped:!1}:{preview:t.slice(0,xA).join(`
184
- `),clipped:!0}}function DA(e){let t=[],n=0;for(let r of e.matchAll(/^```[^\n]*\n([\s\S]*?)\n?^```[ \t]*$/gm)){let i=e.slice(n,r.index).replace(/^\n|\n$/g,``);i&&t.push({type:`text`,text:i}),t.push({type:`code`,code:r[1]}),n=r.index+r[0].length}let r=e.slice(n).replace(/^\n/,``);return(r||t.length===0)&&t.push({type:`text`,text:r}),t}var OA=`[data-enso="code-block"]`,kA=`[data-quote-skip]`,AA=new Set([`P`,`DIV`,`LI`,`UL`,`OL`,`TR`,`TABLE`,`BLOCKQUOTE`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`PRE`]);function jA(e){return e?e.nodeType===1?e:e.parentElement:null}function MA(e,t){return`\`\`\`${t??``}\n${e.replace(/\n+$/,``)}\n\`\`\``}function NA(e){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1&&e.nodeType!==11)return``;let t=e.nodeType===1?e:null;if(t?.tagName===`BUTTON`||t?.matches(kA))return``;if(t?.tagName===`BR`)return`
185
- `;if(t?.matches(OA))return`\n${MA(t.querySelector(`pre`)?.textContent??t.textContent??``,t.getAttribute(`data-language`)??void 0)}\n`;let n=[...e.childNodes].map(NA).join(``);return t&&AA.has(t.tagName)?`${n}\n`:n}function PA(e,t){if(!e||e.rangeCount===0||e.isCollapsed)return null;let n=jA(e.anchorNode),r=jA(e.focusNode);if(!n||!r||!t.contains(n)||!t.contains(r))return null;let i=n.closest(`[data-nav-key]`);if(!i||i!==r.closest(`[data-nav-key]`))return null;let a=e.toString();if(!a.trim())return null;let o=e.getRangeAt(0),s=jA(o.commonAncestorContainer)?.closest(OA);if(s)return MA(a,s.getAttribute(`data-language`)??void 0);let c=o.cloneContents();return c.querySelector(`${OA}, ${kA}`)?NA(c).replace(/\n{3,}/g,`
181
+ `),r=CA(t);if(r<=200&&t.length<=2e4)return{type:`quote`,text:t};let i=0;for(let e=0;i<n.length&&!(!SA.test(n[i])&&++e>200);i++);let a=n.slice(0,i).join(`
182
+ `).slice(0,yA);return(a.match(xA)?.length??0)%2==1&&(a+="\n```"),{type:`quote`,text:a,originalLines:r}}function TA(e){let t=e.split(`
183
+ `);return t.length<=bA?{preview:e,clipped:!1}:{preview:t.slice(0,bA).join(`
184
+ `),clipped:!0}}function EA(e){let t=[],n=0;for(let r of e.matchAll(/^```[^\n]*\n([\s\S]*?)\n?^```[ \t]*$/gm)){let i=e.slice(n,r.index).replace(/^\n|\n$/g,``);i&&t.push({type:`text`,text:i}),t.push({type:`code`,code:r[1]}),n=r.index+r[0].length}let r=e.slice(n).replace(/^\n/,``);return(r||t.length===0)&&t.push({type:`text`,text:r}),t}var DA=`[data-enso="code-block"]`,OA=`[data-quote-skip]`,kA=new Set([`P`,`DIV`,`LI`,`UL`,`OL`,`TR`,`TABLE`,`BLOCKQUOTE`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`PRE`]);function AA(e){return e?e.nodeType===1?e:e.parentElement:null}function jA(e,t){return`\`\`\`${t??``}\n${e.replace(/\n+$/,``)}\n\`\`\``}function MA(e){if(e.nodeType===3)return e.textContent??``;if(e.nodeType!==1&&e.nodeType!==11)return``;let t=e.nodeType===1?e:null;if(t?.tagName===`BUTTON`||t?.matches(OA))return``;if(t?.tagName===`BR`)return`
185
+ `;if(t?.matches(DA))return`\n${jA(t.querySelector(`pre`)?.textContent??t.textContent??``,t.getAttribute(`data-language`)??void 0)}\n`;let n=[...e.childNodes].map(MA).join(``);return t&&kA.has(t.tagName)?`${n}\n`:n}function NA(e,t){if(!e||e.rangeCount===0||e.isCollapsed)return null;let n=AA(e.anchorNode),r=AA(e.focusNode);if(!n||!r||!t.contains(n)||!t.contains(r))return null;let i=n.closest(`[data-nav-key]`);if(!i||i!==r.closest(`[data-nav-key]`))return null;let a=e.toString();if(!a.trim())return null;let o=e.getRangeAt(0),s=AA(o.commonAncestorContainer)?.closest(DA);if(s)return jA(a,s.getAttribute(`data-language`)??void 0);let c=o.cloneContents();return c.querySelector(`${DA}, ${OA}`)?MA(c).replace(/\n{3,}/g,`
186
186
 
187
- `).trim():a}var FA=8,IA=6;function LA(e,t,n,r,i=[]){let a=(e,t)=>Math.min(Math.max(FA,e),t),o=t.height-n.height-FA,s=t.width-n.width-FA,c=e.top-n.height-IA,l=e.bottom+IA,u=a((e.left+e.right)/2-n.width/2,s),d=(r?[l,c]:[c,l]).filter(e=>e>=FA&&e<=o),f=(e,t)=>i.find(r=>t<r.right&&t+n.width>r.left&&e<r.bottom&&e+n.height>r.top),p=d.map(e=>({top:e,left:u}));for(let e of d){let t=f(e,u);t&&p.push({top:e,left:t.right+IA},{top:e,left:t.left-n.width-IA})}let m=a((e.top+e.bottom)/2-n.height/2,o);return p.push({top:m,left:e.right+IA},{top:m,left:e.left-n.width-IA}),p.find(({top:e,left:t})=>e>=FA&&e<=o&&t>=FA&&t<=s&&!f(e,t))||{top:a(r||c<FA?l:c,o),left:u}}function RA(e,t){return/(?:^|\s)\$([^\s$]*)$/.exec(e.slice(0,t))?.[1]??null}function zA(e){let t=new Set,n=[];for(let r of e){let e=r.name.trim().toLowerCase();!e||t.has(e)||(t.add(e),n.push(r))}return n}function BA(e,t,n){let r=n??t;if(r===null)return[];let i=r.toLowerCase();return zA(e.filter(e=>n===null?e.name.toLowerCase().includes(i):e.name.startsWith(`/skill:`)&&e.name.slice(7).toLowerCase().includes(i))).slice(0,10)}var VA={file:`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>`,chat:`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/></svg>`,"ui-element":`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 3a2 2 0 0 0-2 2"/><path d="M19 3a2 2 0 0 1 2 2"/><path d="M21 19a2 2 0 0 1-2 2"/><path d="M5 21a2 2 0 0 1-2-2"/><path d="M9 3h1"/><path d="M9 21h1"/><path d="M14 3h1"/><path d="M14 21h1"/><path d="M3 9v1"/><path d="M21 9v1"/><path d="M3 14v1"/><path d="M21 14v1"/></svg>`},HA=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,UA={file:`bg-success/15 text-success`,chat:`bg-warning/25 text-warning-foreground dark:bg-warning/15 dark:text-warning`,"ui-element":`bg-purple-500/15 text-purple-600 dark:text-purple-400`},WA=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/><path d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/></svg>`;function GA(e,t){let n=e.dataset.text??``,r=e.dataset.expanded===`true`,{preview:i,clipped:a}=EA(n),o=e.querySelector(`[data-quote-body]`);if(o&&(o.textContent=r?n:a?`${i}\n…`:i,o.className=G(`mt-0.5 block whitespace-pre-wrap break-words text-foreground/80`,r?`max-h-32 overflow-y-auto overscroll-contain`:`max-h-16 overflow-hidden`)),e.querySelector(`[data-quote-toggle]`)?.remove(),!r&&a){let n=document.createElement(`span`);n.dataset.quoteToggle=``,n.className=`shrink-0 text-muted-foreground/80`,n.textContent=t.expand,e.querySelector(`[data-quote-remove]`)?.before(n)}}function KA(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.mentionKind=`quote`,n.dataset.text=e.text,e.originalLines&&(n.dataset.originalLines=String(e.originalLines)),n.className=`my-1 block cursor-pointer rounded-md border-l-2 border-brand/50 bg-muted/60 px-2 py-1 text-xs select-none`;let r=document.createElement(`span`);r.className=`flex items-center gap-1.5 text-muted-foreground`;let i=document.createElement(`span`);i.className=`shrink-0 inline-flex`,i.innerHTML=WA;let a=document.createElement(`span`);if(a.className=`min-w-0 flex-1 truncate`,a.textContent=t.title(wA(e.text)),r.append(i,a),e.originalLines){let n=document.createElement(`span`);n.dataset.quoteTruncated=``,n.className=`shrink-0 rounded bg-warning/20 px-1 text-warning-foreground dark:text-warning`,n.textContent=t.truncated(e.originalLines),r.appendChild(n)}let o=document.createElement(`button`);o.type=`button`,o.dataset.quoteRemove=``,o.setAttribute(`aria-label`,t.remove),o.className=`shrink-0 rounded-sm px-1 opacity-70 hover:opacity-100`,o.textContent=`×`,r.appendChild(o);let s=document.createElement(`span`);return s.dataset.quoteBody=``,n.append(r,s),GA(n,t),n}function qA(e,t){if(e.type===`quote`)return KA(e,t);let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.mentionKind=e.type,e.type===`file`?(n.dataset.path=e.path,e.label&&(n.dataset.label=e.label),n.title=e.path):e.type===`chat`?(n.dataset.label=e.label,n.dataset.sessionFile=e.sessionFile,e.conversationId&&(n.dataset.conversationId=e.conversationId)):(n.dataset.id=e.id,n.dataset.label=e.label,n.dataset.path=e.path,n.dataset.text=e.text,n.dataset.imageId=e.imageId,n.title=`${e.path}${e.text?` · ${e.text}`:``}`),n.className=G(`mx-0.5 inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 py-0.5 align-middle text-xs font-medium leading-4 select-none`,UA[e.type]);let r=document.createElement(`span`);r.className=`shrink-0 inline-flex`,r.innerHTML=e.type===`file`&&/[\\/]$/.test(e.path)?HA:VA[e.type],n.appendChild(r);let i=document.createElement(`span`);return i.className=`truncate`,i.textContent=e.type===`file`?e.label??eA(e.path):e.label,n.appendChild(i),n}function JA(e){if(e.dataset.mentionKind===`quote`&&e.dataset.text){let t=Number(e.dataset.originalLines);return{type:`quote`,text:e.dataset.text,...t>0?{originalLines:t}:{}}}return e.dataset.mentionKind===`file`&&e.dataset.path?{type:`file`,path:e.dataset.path,...e.dataset.label?{label:e.dataset.label}:{}}:e.dataset.mentionKind===`chat`&&e.dataset.label&&e.dataset.sessionFile?{type:`chat`,label:e.dataset.label,sessionFile:e.dataset.sessionFile,...e.dataset.conversationId?{conversationId:e.dataset.conversationId}:{}}:e.dataset.mentionKind===`ui-element`&&e.dataset.label&&e.dataset.path&&e.dataset.text?{type:`ui-element`,id:e.dataset.id??``,label:e.dataset.label,path:e.dataset.path,text:e.dataset.text,imageId:e.dataset.imageId??``}:null}function YA(e){let t=[],n=e=>{if(!e)return;let n=t.at(-1);n?.type===`text`?n.text+=e:t.push({type:`text`,text:e})},r=e=>{if(e.nodeType===Node.TEXT_NODE){n(e.textContent??``);return}if(e instanceof HTMLElement){if(e.dataset.mentionKind){let n=JA(e);n&&t.push(n);return}if(e.tagName===`BR`){n(`
187
+ `).trim():a}var PA=8,FA=6;function IA(e,t,n,r,i=[]){let a=(e,t)=>Math.min(Math.max(PA,e),t),o=t.height-n.height-PA,s=t.width-n.width-PA,c=e.top-n.height-FA,l=e.bottom+FA,u=a((e.left+e.right)/2-n.width/2,s),d=(r?[l,c]:[c,l]).filter(e=>e>=PA&&e<=o),f=(e,t)=>i.find(r=>t<r.right&&t+n.width>r.left&&e<r.bottom&&e+n.height>r.top),p=d.map(e=>({top:e,left:u}));for(let e of d){let t=f(e,u);t&&p.push({top:e,left:t.right+FA},{top:e,left:t.left-n.width-FA})}let m=a((e.top+e.bottom)/2-n.height/2,o);return p.push({top:m,left:e.right+FA},{top:m,left:e.left-n.width-FA}),p.find(({top:e,left:t})=>e>=PA&&e<=o&&t>=PA&&t<=s&&!f(e,t))||{top:a(r||c<PA?l:c,o),left:u}}function LA(e,t){return/(?:^|\s)\$([^\s$]*)$/.exec(e.slice(0,t))?.[1]??null}function RA(e){let t=new Set,n=[];for(let r of e){let e=r.name.trim().toLowerCase();!e||t.has(e)||(t.add(e),n.push(r))}return n}function zA(e,t,n){let r=n??t;if(r===null)return[];let i=r.toLowerCase();return RA(e.filter(e=>n===null?e.name.toLowerCase().includes(i):e.name.startsWith(`/skill:`)&&e.name.slice(7).toLowerCase().includes(i))).slice(0,10)}var BA={file:`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>`,chat:`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M12 7v5l4 2"/></svg>`,"ui-element":`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 3a2 2 0 0 0-2 2"/><path d="M19 3a2 2 0 0 1 2 2"/><path d="M21 19a2 2 0 0 1-2 2"/><path d="M5 21a2 2 0 0 1-2-2"/><path d="M9 3h1"/><path d="M9 21h1"/><path d="M14 3h1"/><path d="M14 21h1"/><path d="M3 9v1"/><path d="M21 9v1"/><path d="M3 14v1"/><path d="M21 14v1"/></svg>`},VA=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,HA={file:`bg-success/15 text-success`,chat:`bg-warning/25 text-warning-foreground dark:bg-warning/15 dark:text-warning`,"ui-element":`bg-purple-500/15 text-purple-600 dark:text-purple-400`},UA=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/><path d="M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"/></svg>`;function WA(e,t){let n=e.dataset.text??``,r=e.dataset.expanded===`true`,{preview:i,clipped:a}=TA(n),o=e.querySelector(`[data-quote-body]`);if(o&&(o.textContent=r?n:a?`${i}\n…`:i,o.className=G(`mt-0.5 block whitespace-pre-wrap break-words text-foreground/80`,r?`max-h-32 overflow-y-auto overscroll-contain`:`max-h-16 overflow-hidden`)),e.querySelector(`[data-quote-toggle]`)?.remove(),!r&&a){let n=document.createElement(`span`);n.dataset.quoteToggle=``,n.className=`shrink-0 text-muted-foreground/80`,n.textContent=t.expand,e.querySelector(`[data-quote-remove]`)?.before(n)}}function GA(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.mentionKind=`quote`,n.dataset.text=e.text,e.originalLines&&(n.dataset.originalLines=String(e.originalLines)),n.className=`my-1 block cursor-pointer rounded-md border-l-2 border-brand/50 bg-muted/60 px-2 py-1 text-xs select-none`;let r=document.createElement(`span`);r.className=`flex items-center gap-1.5 text-muted-foreground`;let i=document.createElement(`span`);i.className=`shrink-0 inline-flex`,i.innerHTML=UA;let a=document.createElement(`span`);if(a.className=`min-w-0 flex-1 truncate`,a.textContent=t.title(CA(e.text)),r.append(i,a),e.originalLines){let n=document.createElement(`span`);n.dataset.quoteTruncated=``,n.className=`shrink-0 rounded bg-warning/20 px-1 text-warning-foreground dark:text-warning`,n.textContent=t.truncated(e.originalLines),r.appendChild(n)}let o=document.createElement(`button`);o.type=`button`,o.dataset.quoteRemove=``,o.setAttribute(`aria-label`,t.remove),o.className=`shrink-0 rounded-sm px-1 opacity-70 hover:opacity-100`,o.textContent=`×`,r.appendChild(o);let s=document.createElement(`span`);return s.dataset.quoteBody=``,n.append(r,s),WA(n,t),n}function KA(e,t){if(e.type===`quote`)return GA(e,t);let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.mentionKind=e.type,e.type===`file`?(n.dataset.path=e.path,e.label&&(n.dataset.label=e.label),n.title=e.path):e.type===`chat`?(n.dataset.label=e.label,n.dataset.sessionFile=e.sessionFile,e.conversationId&&(n.dataset.conversationId=e.conversationId)):(n.dataset.id=e.id,n.dataset.label=e.label,n.dataset.path=e.path,n.dataset.text=e.text,n.dataset.imageId=e.imageId,n.title=`${e.path}${e.text?` · ${e.text}`:``}`),n.className=G(`mx-0.5 inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 py-0.5 align-middle text-xs font-medium leading-4 select-none`,HA[e.type]);let r=document.createElement(`span`);r.className=`shrink-0 inline-flex`,r.innerHTML=e.type===`file`&&/[\\/]$/.test(e.path)?VA:BA[e.type],n.appendChild(r);let i=document.createElement(`span`);return i.className=`truncate`,i.textContent=e.type===`file`?e.label??$k(e.path):e.label,n.appendChild(i),n}function qA(e){if(e.dataset.mentionKind===`quote`&&e.dataset.text){let t=Number(e.dataset.originalLines);return{type:`quote`,text:e.dataset.text,...t>0?{originalLines:t}:{}}}return e.dataset.mentionKind===`file`&&e.dataset.path?{type:`file`,path:e.dataset.path,...e.dataset.label?{label:e.dataset.label}:{}}:e.dataset.mentionKind===`chat`&&e.dataset.label&&e.dataset.sessionFile?{type:`chat`,label:e.dataset.label,sessionFile:e.dataset.sessionFile,...e.dataset.conversationId?{conversationId:e.dataset.conversationId}:{}}:e.dataset.mentionKind===`ui-element`&&e.dataset.label&&e.dataset.path&&e.dataset.text?{type:`ui-element`,id:e.dataset.id??``,label:e.dataset.label,path:e.dataset.path,text:e.dataset.text,imageId:e.dataset.imageId??``}:null}function JA(e){let t=[],n=e=>{if(!e)return;let n=t.at(-1);n?.type===`text`?n.text+=e:t.push({type:`text`,text:e})},r=e=>{if(e.nodeType===Node.TEXT_NODE){n(e.textContent??``);return}if(e instanceof HTMLElement){if(e.dataset.mentionKind){let n=qA(e);n&&t.push(n);return}if(e.tagName===`BR`){n(`
188
188
  `);return}(e.tagName===`DIV`||e.tagName===`P`)&&t.length>0&&n(`
189
- `);for(let t of e.childNodes)r(t)}};for(let t of e.childNodes)r(t);return t}function XA(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return null;let{anchorNode:n,anchorOffset:r}=t;return!n||!e.contains(n)||n.nodeType!==Node.TEXT_NODE?null:{node:n,offset:r}}function ZA(e,t){if(t.rangeCount===0||!t.isCollapsed)return null;let{anchorNode:n,anchorOffset:r}=t;if(!n||n.nodeType===Node.TEXT_NODE||n!==e&&!e.contains(n))return null;let i=n.childNodes,a=i[r],o=r>0?i[r-1]:void 0,s=a?.nodeType===Node.TEXT_NODE?{node:a,offset:0}:o?.nodeType===Node.TEXT_NODE?{node:o,offset:o.length}:null;if(!s)return null;let c=document.createRange();return c.setStart(s.node,s.offset),c.collapse(!0),c}function QA(e){return e instanceof HTMLElement&&!!e.dataset.mentionKind}function $A(e){return e instanceof Text&&!/[^\s\u00a0]/.test(e.textContent??``)}function ej(e,t){let n=window.getSelection();if(!n||n.rangeCount===0||!n.isCollapsed)return null;let{anchorNode:r,anchorOffset:i}=n;if(!r||!e.contains(r))return null;if(r.nodeType===Node.TEXT_NODE){let e=r.textContent??``;if(t===`before`){if(/[^\s\u00a0]/.test(e.slice(0,i)))return null;let t=r.previousSibling;for(;$A(t);)t=t.previousSibling;return QA(t)?t:null}if(/[^\s\u00a0]/.test(e.slice(i)))return null;let n=r.nextSibling;for(;$A(n);)n=n.nextSibling;return QA(n)?n:null}let a=r.childNodes;if(t===`before`){let e=i-1;for(;e>=0&&$A(a[e]);)--e;let t=e>=0?a[e]:null;return QA(t)?t:null}let o=i;for(;o<a.length&&$A(a[o]);)o+=1;let s=a[o];return QA(s)?s:null}function tj(e,t){let n=e.nextSibling;$A(n)&&n.remove();let r=e.previousSibling;if(e.remove(),r){nj(r);return}let i=window.getSelection();if(!i)return;let a=document.createRange();a.setStart(t,0),a.collapse(!0),i.removeAllRanges(),i.addRange(a)}function nj(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}var rj=(0,U.forwardRef)(function({placeholder:e,disabled:t,className:n,onStateChange:r,onKeyDown:i,onPaste:a,onPasteText:o,onCompositionStart:s,onCompositionEnd:c,onChipActivate:l,ariaProps:u},d){let{t:f}=q(),p=(0,U.useRef)(null),m={title:e=>f(`Quote · {{count}} lines`,{count:e}),truncated:e=>f(`Truncated · original {{count}} lines`,{count:e}),expand:f(`Click to expand`),remove:f(`Remove quote`)},h=(0,U.useRef)(m);h.current=m;let g=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=e=>{let t=e.target;for(let e of p.current?.querySelectorAll(`[data-mention-kind="quote"][data-expanded]`)??[])t&&e.contains(t)||(delete e.dataset.expanded,GA(e,h.current))};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[]),(0,U.useEffect)(()=>{let e=()=>{let e=p.current;if(!e||document.activeElement!==e)return;let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return;let n=t.anchorNode;if(n&&(n===e||e.contains(n))){let r=ZA(e,t);r?(t.removeAllRanges(),t.addRange(r)):n.nodeType===Node.TEXT_NODE&&(g.current={node:n,offset:t.anchorOffset});return}let r=g.current,i=document.createRange();r?.node.isConnected&&e.contains(r.node)?(i.setStart(r.node,Math.min(r.offset,r.node.length)),i.collapse(!0)):(i.selectNodeContents(e),i.collapse(!0)),t.removeAllRanges(),t.addRange(i)};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[]);let _=(0,U.useCallback)(()=>{let e=p.current;if(!e)return;let t=YA(e),n=t.map(e=>e.type===`text`?e.text:``).join(``),i=t.some(e=>e.type!==`text`),a=null,o=null,s=null,c=null,l=XA(e);if(l){let t=l.node.textContent?.slice(0,l.offset)??``;a=Bk(t,t.length),a===null&&(s=RA(t,t.length)),a===null&&s===null&&(c=jO(t)),a===null&&l.node===e.firstChild&&/^\/[^\s]*$/.test(t)&&(o=t.slice(1))}r({plainText:n,hasMentions:i,segments:t,mentionQuery:a,slashQuery:o,skillQuery:s,pluginQuery:c})},[r]),v=(0,U.useCallback)(e=>{let t=p.current;if(!t)return null;let n=XA(t);if(!n)return null;let r=n.node.textContent?.slice(0,n.offset)??``;if(e===`#`){let e=jO(r);return e===null?null:{node:n.node,start:r.length-e.length-1,end:n.offset}}if(e===`@`||e===`$`){let t=e===`@`?Bk(r,r.length):RA(r,r.length);return t===null?null:{node:n.node,start:r.length-t.length-1,end:n.offset}}return n.node!==t.firstChild||!/^\/[^\s]*$/.test(r)?null:{node:n.node,start:0,end:n.offset}},[]),y=(0,U.useCallback)((e,t)=>{let n=p.current;if(!n)return;n.focus();let r=document.createRange(),i=t?v(`@`):null;if(i)r.setStart(i.node,i.start),r.setEnd(i.node,i.end),r.deleteContents();else{let e=XA(n);e?(r.setStart(e.node,e.offset),r.collapse(!0)):(r.selectNodeContents(n),r.collapse(!1))}let a=e();r.insertNode(a);let o=document.createTextNode(`\xA0`);a.parentNode?.insertBefore(o,a.nextSibling),nj(o),_()},[v,_]);return(0,U.useImperativeHandle)(d,()=>({focus:()=>p.current?.focus(),isEmpty:()=>{let e=p.current;return!e||!YA(e).some(e=>e.type!==`text`||e.text.trim().length>0)},getSegments:()=>p.current?YA(p.current):[],setSegments:e=>{let t=p.current;if(t){t.textContent=``;for(let n of e)n.type===`text`?t.appendChild(document.createTextNode(n.text)):t.appendChild(qA(n,h.current));_()}},clear:()=>{let e=p.current;e&&(e.textContent=``,_())},insertMention:e=>{let t=e.kind===`file`?{type:`file`,path:e.relativePath}:e.kind===`chat`?{type:`chat`,label:e.label,sessionFile:e.sessionFile,conversationId:e.id}:{type:`ui-element`,id:e.id,label:e.label,path:e.path,text:e.text,imageId:e.imageId};y(()=>qA(t,h.current),e.kind!==`ui-element`)},consumeToken:e=>{let t=v(e);if(!t)return;let n=document.createRange();n.setStart(t.node,t.start),n.setEnd(t.node,t.end),n.deleteContents(),_()},insertFileChip:(e,t)=>{y(()=>qA({type:`file`,path:e,...t?{label:t}:{}},h.current),!1)},insertText:e=>{y(()=>document.createTextNode(e),!1)},insertQuote:e=>{let t=p.current;if(!t)return;let n=document.createTextNode(`\xA0`);t.append(qA(e,h.current),n),t.focus(),window.getSelection()?.collapse(n,n.length),t.scrollTop=t.scrollHeight,_()},getMentionAnchorRect:()=>{let e=v(`@`);if(!e)return null;let t=document.createRange();return t.setStart(e.node,e.start),t.setEnd(e.node,Math.min(e.start+1,e.node.length)),t.getBoundingClientRect()}}),[v,_,y]),(0,K.jsx)(`div`,{ref:p,contentEditable:!t,role:u?.role??`textbox`,"aria-placeholder":e,"data-placeholder":e,...u,onInput:_,onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`Backspace`||e.key===`Delete`)){let t=p.current,n=t&&ej(t,e.key===`Backspace`?`before`:`after`);if(n&&t){e.preventDefault(),tj(n,t),_();return}}i(e)},onClick:e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-mention-kind]`);if(!(n instanceof HTMLElement)||!p.current?.contains(n))return;if(n.dataset.mentionKind===`quote`){t.closest(`[data-quote-remove]`)?(tj(n,p.current),_()):n.dataset.expanded!==`true`&&(n.dataset.expanded=`true`,GA(n,h.current));return}if(!l)return;let r=JA(n);r&&l(r)},onKeyUp:e=>{e.key!==`Escape`&&_()},onMouseUp:_,onPaste:e=>{if(e.clipboardData.files.length>0){a(e);return}e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(o?.(t)||document.execCommand(`insertText`,!1,t))},onCompositionStart:s,onCompositionEnd:()=>{c(),_()},className:G(`max-h-40 min-h-10 min-w-0 flex-1 overflow-y-auto pt-0.5 text-sm break-words whitespace-pre-wrap outline-none`,`empty:before:pointer-events-none empty:before:text-muted-foreground empty:before:content-[attr(data-placeholder)]`,t&&`opacity-60`,n)})}),ij=Qr(`relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button,a&]:cursor-pointer [button,a&]:pointer-coarse:after:absolute [button,a&]:pointer-coarse:after:size-full [button,a&]:pointer-coarse:after:min-h-11 [button,a&]:pointer-coarse:after:min-w-11`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-5.5 min-w-5.5 px-[calc(--spacing(1)-1px)] text-sm sm:h-4.5 sm:min-w-4.5 sm:text-xs`,lg:`h-6.5 min-w-6.5 px-[calc(--spacing(1.5)-1px)] text-base sm:h-5.5 sm:min-w-5.5 sm:text-sm`,sm:`h-5 min-w-5 rounded-[calc(var(--radius-sm)-2px)] px-[calc(--spacing(1)-1px)] text-xs sm:h-4 sm:min-w-4 sm:text-[.625rem]`},variant:{default:`bg-primary text-primary-foreground [button,a&]:hover:bg-primary/90`,destructive:`bg-destructive text-white [button,a&]:hover:bg-destructive/90`,error:`bg-destructive/12 text-destructive dark:bg-destructive/16`,info:`bg-info/12 text-info dark:bg-info/16`,outline:`border-border bg-transparent dark:bg-input/32 [button,a&]:hover:bg-accent/50 dark:[button,a&]:hover:bg-input/48`,secondary:`bg-secondary text-secondary-foreground [button,a&]:hover:bg-secondary/90`,success:`bg-success/12 text-success dark:bg-success/16`,warning:`bg-warning/12 text-warning-foreground dark:bg-warning/16`}}});function aj({className:e,variant:t,size:n,render:r,...i}){return qr({defaultTagName:`span`,props:cr({className:G(ij({className:e,size:n,variant:t})),"data-slot":`badge`},i),render:r})}var oj=/[\\/]/;function sj(e){return e.split(oj).filter(e=>e.length>0)}function cj(e){let t=new Map,n=e.map(sj),r=n.map(e=>e.join(`/`));for(let i=0;i<e.length;i++){let a=e[i],o=n[i]??[],s=Math.max(0,o.length-3);for(;s>0;){let e=o.slice(s).join(`/`);if(!r.some(t=>t!==r[i]&&(t===e||t.endsWith(`/${e}`))))break;s--}let c=o.slice(s).join(`/`);t.set(a,s>0?`…/${c}`:c)}return t}function lj({groups:e,query:t,activeIndex:n,onActiveIndexChange:r,openFolderId:i,folderIndex:a,onOpenFolderIdChange:o,onFolderIndexChange:s,onSelect:c,id:l=`composer-mention-picker`,left:u=0,flyoutSide:d=`right`}){let{t:f}=q(),p=kD(),m=(0,U.useMemo)(()=>yD(e,t),[e,t]),h=(0,U.useMemo)(()=>cj(e.files.map(e=>e.relativePath)),[e.files]),g=(0,U.useRef)(new Map),_=(0,U.useRef)(new Map),v=m[0]?.type===`folder`;if((0,U.useEffect)(()=>{g.current.get(n)?.scrollIntoView({block:`nearest`})},[n]),(0,U.useEffect)(()=>{i&&_.current.get(a)?.scrollIntoView({block:`nearest`})},[i,a]),m.length===0)return null;let y={agents:f(`Agents`),members:f(`Members`),chats:f(`Chats`)},b={agents:ft,members:tr,chats:jn},x=i?e[i]:[],S=0,C=()=>x.map((e,t)=>(0,K.jsx)(uj,{ref:e=>{e?_.current.set(t,e):_.current.delete(t)},id:`${l}-sub-${t}`,candidate:e,active:t===a,onHover:()=>s(t),onSelect:()=>c(e)},`sub:${e.id}`)),w=!!(p&&i&&x.length>0),T=e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,"data-slot":`mention-sheet-back`,onClick:()=>o(null),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,children:[(0,K.jsx)(yt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:y[e]})]}),C()]}),E=(t,i)=>{let a=e[t];if(a.length===0)return null;let s=t===`files`?f(`Files`):y[t];return(0,K.jsxs)(`div`,{role:`group`,"aria-label":s,children:[(0,K.jsx)(`p`,{className:G(`px-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,i?`pt-2`:`pt-1.5`),children:s}),a.map(e=>{let i=S++;return(0,K.jsx)(uj,{ref:e=>{e?g.current.set(i,e):g.current.delete(i)},id:`${l}-option-${i}`,candidate:e,active:i===n,pathLabel:e.kind===`file`?h.get(e.relativePath):void 0,onHover:()=>{r(i),v&&o(null)},onSelect:()=>c(e)},`${t}:${e.id}`)})]})};return(0,K.jsxs)(`div`,{"data-slot":`mention-picker`,className:p?`absolute inset-x-0 bottom-full z-10 mb-1.5 w-full`:`absolute bottom-full z-10 mb-1.5 max-w-full`,style:p?void 0:{left:u},children:[(0,K.jsx)(`div`,{id:l,role:`listbox`,"aria-label":f(`Mention suggestions`),className:p?`max-h-[50dvh] w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`:`max-h-72 w-80 max-w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:w&&i?T(i):v?(0,K.jsxs)(K.Fragment,{children:[m.filter(e=>e.type===`folder`).map(e=>{let t=S++,a=b[e.id];return(0,K.jsxs)(`button`,{ref:e=>{e?g.current.set(t,e):g.current.delete(t)},id:`${l}-option-${t}`,type:`button`,role:`option`,"aria-selected":n===t,onClick:()=>{r(t),o(e.id),s(0)},onMouseMove:()=>{r(t),!p&&i!==e.id&&(o(e.id),s(0))},className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,n===t&&`bg-foreground/10`),children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background`,children:(0,K.jsx)(a,{className:`h-3.5 w-3.5 text-muted-foreground`})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:y[e.id]}),(0,K.jsx)(vt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]},`folder:${e.id}`)}),E(`files`,!0)]}):(0,K.jsxs)(K.Fragment,{children:[E(`agents`,!1),E(`members`,e.agents.length>0),E(`chats`,e.agents.length+e.members.length>0),E(`files`,e.agents.length+e.members.length+e.chats.length>0)]})}),!p&&i&&x.length>0&&(0,K.jsx)(`div`,{role:`listbox`,"aria-label":y[i],"data-slot":`mention-flyout`,className:G(`absolute top-0 z-20 max-h-72 w-72 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,d===`right`?`left-full ml-1`:`right-full mr-1`),children:C()})]})}function uj({ref:e,id:t,candidate:n,active:r,pathLabel:i,onHover:a,onSelect:o}){let{t:s}=q(),c=dj(n),l=n.kind===`agent-type`?n.source===`bot`?tr:ft:n.kind===`chat`?jn:c?Kt:Ht;return(0,K.jsxs)(`button`,{ref:e,id:t,type:`button`,role:`option`,"aria-selected":r,onClick:o,onMouseMove:a,className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,r&&`bg-foreground/10`),children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background`,children:(0,K.jsx)(l,{className:`h-3.5 w-3.5 text-muted-foreground`})}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:n.label}),(0,K.jsx)(aj,{variant:`outline`,className:`px-1 py-0 text-[9px]`,children:n.kind===`agent-type`?s(n.source===`system`?`System`:n.source===`builtin`?`Built-in`:n.source===`bot`?`Member`:`Custom`):n.kind===`chat`?s(`Chat`):s(c?`Folder`:`File`)}),n.kind===`agent-type`&&n.locked&&(0,K.jsx)(aj,{variant:`secondary`,className:`px-1 py-0 text-[9px]`,children:s(`Locked`)})]}),(0,K.jsx)(`span`,{className:G(`block text-muted-foreground`,n.kind===`file`?`whitespace-normal break-all`:`truncate`),title:n.kind===`file`?n.relativePath:void 0,children:n.kind===`agent-type`?n.source===`bot`?n.description:s(n.description):n.kind===`chat`?n.sessionFile.split(`/`).at(-1):n.kind===`file`?i??n.relativePath:n.path})]})]})}function dj(e){return e.kind===`file`&&/[\\/]$/.test(e.relativePath)}var fj=[`on`,`off`],pj=[`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function mj(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function hj(e){return typeof e==`string`&&fj.includes(e)}function gj(e){return typeof e==`string`&&pj.includes(e)}function _j(e){if(!e)return{};let t={};hj(e.reasoning)&&(t.reasoning=e.reasoning),gj(e.thinkingLevel)&&(t.thinkingLevel=e.thinkingLevel);let n=mj(e.contextWindow);n!==void 0&&(t.contextWindow=n);let r=mj(e.maxTokens);return r!==void 0&&(t.maxTokens=r),t}var vj=e=>{let t=e.indexOf(`#`);return t===-1?e:e.slice(0,t)},yj=`enso-virtual`;function bj(e){return e?.providerId===yj}function xj(e,t){if(!(!t||!bj(t)))return e?.find(e=>e.id===t.modelId)}function Sj(e,t){return e?.find(e=>e.id===t)?.name??t}new Set(Object.values({"openrouter.ai":`openrouter`,"opencode.ai":`opencode`,"ai-gateway.vercel.sh":`vercel-ai-gateway`,"api.typesafe.ai":`typesafe`}));function Cj(e,t){if(e===void 0)return t.map(e=>({...e}));let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t.id);n.delete(t.id);let i={id:t.id};t.label!==void 0&&(i.label=t.label),e&&(e.label!==void 0&&(i.label=e.label),e.enabled!==void 0&&(i.enabled=e.enabled),e.imageGeneration!==void 0&&(i.imageGeneration=e.imageGeneration),Object.assign(i,_j(e))),r.push(i)}for(let e of n.values())r.push({...e});return r}function wj(e,t){if(!t)return[...e];let n=new Map(t.providers.map(e=>[e.key,e]));return e.map(e=>{if(!e.oauthAccountKey)return e;let t=n.get(vj(e.oauthAccountKey));return t?{...e,models:Cj(t.models,e.models)}:e})}var Tj=U.createContext(void 0);function Ej(e){let t=U.useContext(Tj);if(t===void 0&&!e)throw Error(Cr(33));return t}var Dj=U.createContext(void 0);function Oj(e){let t=U.useContext(Dj);if(t===void 0&&!e)throw Error(Cr(36));return t}var kj=U.createContext(void 0);function Aj(e=!0){let t=U.useContext(kj);if(t===void 0&&!e)throw Error(Cr(25));return t}var jj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=Oj(),s=o.useState(`open`),c=o.useState(`mounted`),l=o.useState(`transitionStatus`),u=o.useState(`lastOpenChangeReason`),d=Aj(),f={open:s,transitionStatus:l};return Vr(`div`,e,{ref:d?.backdropRef?[t,d.backdropRef]:t,state:f,stateAttributesMapping:ty,props:[{role:`presentation`,hidden:!c,style:{pointerEvents:u===`trigger-hover`?`none`:void 0,userSelect:`none`,WebkitUserSelect:`none`}},a]})});function Mj({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=U.useRef(e!==void 0),[a,o]=U.useState(t);return[i?e:a,U.useCallback(e=>{i||o(e)},[])]}function Nj(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Aj(!0),f=d!==void 0;return U.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:By})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!cb&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&Ny(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var Pj={type:`regular-item`};function Fj(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=U.useRef(null),{getButtonProps:d,buttonRef:f}=Py({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Nj({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=U.useCallback(e=>cr(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Er(u,f);return U.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Ij=U.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Lj(){return U.useContext(Ij)}function Rj(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Lj(),u=U.useRef(-1),[d,f]=U.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=U.useRef(null),h=U.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var zj=U.createContext(void 0);function Bj(){let e=U.useContext(zj);if(e===void 0)throw Error(Cr(31));return e}var Vj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=U.useState(void 0),c=Vr(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,K.jsx)(zj.Provider,{value:s,children:c})}),Hj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Zy(a),c=Bj();return X(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Vr(`div`,e,{ref:t,props:{id:s,role:`presentation`,...o}})}),Uj=U.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Rj({guess:!0,label:a}),f=Ej(!0),p=Zy(i),{store:m}=Oj(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Fj({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Pj});return Vr(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),Wj=U.createContext(void 0);function Gj(e){let t=U.useContext(Wj);if(t===void 0&&!e)throw Error(Cr(69));return t}var Kj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Oj(),{side:c,align:l}=Ej(),u=Gj(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;Aw({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),U.useEffect(()=>{function e(e){s.setOpen(!1,Ky(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),rT(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=Vr(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:ty,props:[p,{onKeyDown(e){u&&yT.has(e.key)&&e.stopPropagation()}},fD(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,K.jsx)(HS,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?k:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:O})}),qj=U.createContext(void 0);function Jj(){let e=U.useContext(qj);if(e===void 0)throw Error(Cr(32));return e}var Yj=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Oj();return i.useState(`mounted`)||n?(0,K.jsx)(qj.Provider,{value:n,children:(0,K.jsx)(CS,{ref:t,...r})}):null});function Xj(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Ay(i),[,o]=U.useState(!1),s=Tr(Qj).current,c=Tr(Zj).current,l=U.useRef(0),u=U.useRef(!0),d=U.useRef([]),f=U.useRef(null),p=Ay(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Ay((e,t)=>{c.set(e,t),p()}),h=Ay(e=>{c.delete(e),p()}),g=Ay(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!tM(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&nM(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=eM(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Ay(()=>{let[e,t]=$j(c),n=g(e);_(t),d.current=e,u.current=!1,s.forEach(e=>e(n)),a(n)});X(()=>(u.current||g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Ay(e=>(s.add(e),()=>{s.delete(e)})),b=U.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,K.jsx)(Ij.Provider,{value:b,children:t})}function Zj(){return new Map}function Qj(){return new Set}function $j(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>nM(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function eM(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function tM(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function nM(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var rM=20;function iM(e,t,n,r){let[i,a]=U.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=My(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-rM)},[e,t,n]),AT(e&&(!t||i),r)}var aM=U.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=gS,style:g,..._}=e,{store:v}=Oj(),y=Jj(),b=Aj(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`activeTriggerElement`),k=v.useState(`transitionStatus`),A=v.useState(`positionerElement`),j=v.useState(`instantType`),M=v.useState(`adaptiveOrigin`),N=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=S.useState(`domReferenceElement`),L=U.useRef(null),R=kw(A),ee=n,z=c,B=l,V=s,te=h;x.type===`context-menu`&&(ee=n??x.context?.anchor,V??=`start`,!o&&V!==`center`&&(B=e.alignOffset??2,z=e.sideOffset??-5));let H=o,ne=V;x.type===`menu`?(H??=`inline-end`,ne??=`start`,te=e.collisionAvoidance??_S):x.type===`menubar`&&(H??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ne??=`start`);let re=x.type===`context-menu`,ie=lD({anchor:ee,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:H,sideOffset:z,align:ne,alignOffset:B,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:te,shift:re?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:M});U.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Ky(Wy)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),U.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Ky(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let ae=nb();U.useEffect(()=>{T||ae.clear()},[T,ae]),U.useEffect(()=>{function e(e){if(!(!T||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&O&&O!==e.target){let e=v.select(`closeDelay`);e>0?ae.isStarted()||ae.start(e,()=>{v.setOpen(!1,Ky(Wy))}):v.setOpen(!1,Ky(Wy))}else ae.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,ae]),U.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,F]),X(()=>{let e=I,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return R(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,R,v]);let oe={open:T,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:x.type===`menu`,instant:j},se=x.type===`menubar`&&x.context.modal;iM(T&&(se||E&&N!==`trigger-hover`),D===`touch`,A,O);let ce=pD(e,oe,{styles:ie.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),le=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&N!==`trigger-hover`||x.type===`menubar`&&x.context.modal),ue=null;return x.type===`menubar`?ue=x.context.contentElement:x.type===void 0&&(ue=O),(0,K.jsxs)(Tj.Provider,{value:ie,children:[le&&(0,K.jsx)(CT,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:ST(!T),cutout:ue}),(0,K.jsx)(jS,{id:P,children:(0,K.jsx)(Xj,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:ce})})]})}),oM=U.createContext(null);function sM(e){let t=U.useContext(oM);if(t===null&&!e)throw Error(Cr(5));return t}var cM={...Yw,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},lM=class extends Tw{constructor(e){super({...dM(),...e},uM(),cM),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function uM(){return{positionerRef:U.createRef(),popupRef:U.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:U.createRef(),beforeContentFocusGuardRef:U.createRef(),onOpenChangeComplete:void 0,triggerElements:new Hw}}function dM(){return{...Uw(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new TS,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Lr,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var fM=U.createContext(void 0);function Yte(){return U.useContext(fM)}var pM=hw(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Aj(!0),_=Oj(!0),v=sM(!0),y=Yte(),b=U.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=mM({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b});x.useControlledProp(`openProp`,n),x.useControlledProp(`triggerIdProp`,p),x.useContextCallback(`onOpenChangeComplete`,i);let S=Xy(),C=Xy(),w=x.useState(`floatingTreeRoot`),T=AS(w),E=OS(),D=x.useState(`open`),O=x.useState(`activeTriggerElement`),k=x.useState(`positionerElement`),A=x.useState(`hoverEnabled`),j=x.useState(`disabled`),M=x.useState(`lastOpenChangeReason`),N=x.useState(`parent`),P=x.useState(`activeIndex`),F=x.useState(`payload`),I=x.useState(`floatingParentNodeId`),L=U.useRef(null),R=U.useRef(N.type!==`context-menu`),ee=nb(),z=U.useRef(!0),B=nb(),V=I!=null,{openMethod:te,triggerProps:H}=LT(D);x.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:N.type===void 0?s:void 0,openMethod:te,rootId:S}),Rw(x);let{forceUnmount:ne}=zw(D,x,()=>{x.set(`allowMouseEnter`,!1)});X(()=>{g&&!_?x.update({parent:{type:`context-menu`,context:g},floatingNodeId:T,floatingParentNodeId:E}):_&&x.update({floatingNodeId:T,floatingParentNodeId:E})},[g,_,T,E,x]),U.useEffect(()=>{if(D||(L.current=null),N.type===`context-menu`){if(!D){ee.clear(),R.current=!1;return}ee.start(500,()=>{R.current=!0})}},[ee,D,N.type]),X(()=>{!D&&!A&&x.set(`hoverEnabled`,!0)},[D,A,x]);let re=Ay((e,t)=>{let n=t.reason;if(!e&&!x.select(`open`)||D===e&&t.trigger===O&&M===n)return;let i=Iw(t);if(!e&&t.trigger==null&&(t.trigger=O??void 0),r?.(e,t),t.isCanceled)return;x.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!z.current)return;e&&n===`trigger-focus`?(z.current=!1,B.start(300,()=>{z.current=!0})):(z.current=!0,B.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};L.current=t.event,Fw(c,e,t.trigger,i()),x.update(c),N.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?x.set(`instantType`,`group`):o||s?x.set(`instantType`,o?`click`:`dismiss`):x.set(`instantType`,void 0)}),ie=Dw({popupStore:x,floatingId:C,nested:E!=null,onOpenChange:re}),ae=ie.context.events;X(()=>{let e=({open:e,eventDetails:t})=>re(e,t);return ae.on(`setOpen`,e),()=>{ae?.off(`setOpen`,e)}},[ae,re]);let oe=U.useCallback(()=>{x.setOpen(!1,Ky(Gy))},[x]);U.useImperativeHandle(u,()=>({unmount:ne,close:oe}),[ne,oe]);let se;N.type===`context-menu`&&(se=N.context),U.useImperativeHandle(se?.positionerRef,()=>k,[k]),U.useImperativeHandle(se?.actionsRef,()=>({setOpen:re}),[re]);let ce=KS(ie,{enabled:!j,bubbles:{escapeKey:d&&N.type===`menu`},outsidePress(){return N.type!==`context-menu`||L.current?.type===`contextmenu`||R.current},externalTree:V?w:void 0}),le=nE(),ue=U.useCallback(e=>{x.select(`activeIndex`)!==e&&x.set(`activeIndex`,e)},[x]),de=lT(ie,{enabled:!j,listRef:x.context.itemDomElements,activeIndex:P,nested:N.type!==void 0,loopFocus:c,orientation:l,parentOrientation:N.type===`menubar`?N.context.orientation:void 0,rtl:le===`rtl`,disabledIndices:Ir,onNavigate:ue,openOnArrowKeyDown:N.type!==`context-menu`,externalTree:V?w:void 0,focusItemOnHover:h}),fe=U.useCallback(e=>{x.context.typingRef.current=e},[x]),pe=uT(ie,{enabled:!j,listRef:x.context.itemLabels,elementsRef:x.context.itemDomElements,activeIndex:P,resetMs:500,onMatch:e=>{D&&e!==P&&x.set(`activeIndex`,e)},onTyping:fe});Bw(x,{floatingRootContext:ie,activeTriggerProps:U.useMemo(()=>{let e=cr(pe.reference,de.reference,ce.reference,{onMouseMove(){x.set(`allowMouseEnter`,!0)}},H);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=D,e},[x,pe.reference,de.reference,ce.reference,H,D]),inactiveTriggerProps:U.useMemo(()=>{let e=cr(de.trigger,ce.trigger,H);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[de.trigger,ce.trigger,H]),popupProps:U.useMemo(()=>cr(jw,{id:C,role:`menu`,"aria-labelledby":O?.id,onMouseMove(){x.set(`allowMouseEnter`,!0),N.type===`menu`&&x.set(`hoverEnabled`,!1)},onClick(){x.select(`hoverEnabled`)&&x.set(`hoverEnabled`,!1)},onKeyDown(e){let t=x.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},pe.floating,de.floating,ce.floating),[O,C,N.type,x,pe.floating,de.floating,ce.floating]),itemProps:de.item??Lr});let me=U.useMemo(()=>({store:x,parent:b}),[x,b]),he=(0,K.jsxs)(Dj.Provider,{value:me,children:[f&&(0,K.jsx)(Pw,{handle:f,store:x}),typeof t==`function`?t({payload:F}):t]});return N.type===void 0||N.type===`context-menu`?(0,K.jsx)(MS,{externalTree:w,children:he}):he});function mM(e){return Tr(()=>new lM(e)).current}var hM=5;function gM(e,t){let n=_M(t);return e.clientX>=n.left-hM&&e.clientX<=n.right+hM&&e.clientY>=n.top-hM&&e.clientY<=n.bottom+hM}function _M(e){let t=e.getBoundingClientRect(),n=ay(e);if(ub)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function vM(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=jy(),{ref:i,index:a}=Rj(e),o=n===a,s=U.useRef(null),c=Er(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function yM(e){let{render:t,className:n,style:r,state:i=Lr,props:a=Ir,refs:o=Ir,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=vM({metadata:s});return Vr(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function bM(e){if(ly(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!xy(e))return bM(wy(e))}function xM(e,t){let n=U.useRef(null);function r(t){Gs.flushSync(()=>{e.setOpen(!1,Ky(Vy,t.nativeEvent,t.currentTarget))}),qx(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&Jx(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{Gs.flushSync(()=>{e.setOpen(!1,Ky(Vy,n.nativeEvent,n.currentTarget))});let i=Kx(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&yb(r,i);){let e=i;if(i=Ux(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function SM(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=U.useRef(!1);return U.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,My(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Lr,[t,n,r])}var CM=gw(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Oj(!0),h=Xw(d)??m?.store;if(!h)throw Error(Cr(85));let g=Zy(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=U.useRef(null),S=TM(),C=jy(!0),w=kS(),T=U.useMemo(()=>w??new TS,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Lw(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:AS(T),floatingParentNodeId:OS(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Py({disabled:A,native:o});U.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=U.useRef(null),P=nb(),F=Ay(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;yb(N.current,t)||yb(h.select(`positionerElement`),t)||t===N.current||(t==null||bM(t)!==h.select(`rootId`))&&(gM(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Uy}))});U.useEffect(()=>{y&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&My(N.current).addEventListener(`mouseup`,F,{once:!0})},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=iT(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:gT({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=wM(y,h.select(`lastOpenChangeReason`)),ee=US(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Qw(v,{enabled:!A&&I}),B=SM({open:y,enabled:O,mouseDownAction:`open`}),V=U.useMemo(()=>cr(z.reference,ee.reference),[z.reference,ee.reference]),te=h.useState(`triggerProps`,D),{preFocusGuardRef:H,handlePreFocusGuardFocus:ne,handleFocusTargetFocus:re}=xM(h,x),ie={disabled:A,open:y},ae=[N,t,M,E,x],oe=[V,L??Lr,te,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),My(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},O?{role:`menuitem`}:{},B,p,j],se=Vr(`button`,e,{enabled:!O,stateAttributesMapping:$v,state:ie,ref:ae,props:oe});return O?(0,K.jsx)(yM,{tag:`button`,render:n,className:r,style:i,state:ie,refs:ae,props:oe,stateAttributesMapping:$v}):y?(0,K.jsxs)(U.Fragment,{children:[(0,K.jsx)(Gb,{ref:H,onFocus:ne},`${g}-pre-focus-guard`),(0,K.jsx)(U.Fragment,{children:se},g),(0,K.jsx)(Gb,{ref:h.context.triggerFocusTargetRef,onFocus:re},`${g}-post-focus-guard`)]}):(0,K.jsx)(U.Fragment,{children:se},g)});function wM(e,t){let n=nb(),[r,i]=U.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function TM(){let e=sM(!0);return U.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}function EM(e){let[t,n]=U.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function DM(e){let t=Sy(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ly(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r;return(Jb(n)!==a||Jb(r)!==o)&&(n=a,r=o),{width:n,height:r}}function OM(e){let{popupElement:t,positionerElement:n,content:r,mounted:i,onMeasureLayout:a,onMeasureLayoutComplete:o,side:s,direction:c}=e,l=kw(t,!0),u=Vb(),d=U.useRef(null),f=U.useRef(!0),p=U.useRef(Fr),m=Ay(a),h=Ay(o),g=U.useMemo(()=>kM(s,c),[s,c]);X(()=>{if(!i){p.current=Fr,f.current=!0,d.current=null;return}if(!t||!n)return;p.current=jM(t,g),MM(t,`auto`);let e=AM(t,`position`,`static`),r=AM(t,`transform`,`none`),a=AM(t,`scale`,`1`),o=jM(n,{"--available-width":`max-content`,"--available-height":`max-content`});function s(){e(),r(),o()}function c(){s(),a()}if(m?.(),f.current||d.current===null){NM(n,`max-content`);let e=DM(t);return d.current=e,NM(n,e),c(),h?.(null,e),f.current=!1,()=>{p.current(),p.current=Fr}}NM(n,`max-content`);let _=d.current,v=DM(t);d.current=v,MM(t,_),c(),h?.(_,v),NM(n,v);let y=new AbortController;return u.request(()=>{MM(t,v),l(()=>{t.style.setProperty(`--popup-width`,`auto`),t.style.setProperty(`--popup-height`,`auto`)},y.signal)}),()=>{y.abort(),u.cancel(),p.current(),p.current=Fr}},[r,t,n,l,u,i,m,h,g])}function kM(e,t){let n=e===`top`,r=e===`left`||e===(t===`rtl`?`inline-end`:`inline-start`);return!n&&!r?Lr:{position:`absolute`,[n?`bottom`:`top`]:`0`,[r?`right`:`left`]:`0`}}function AM(e,t,n){let r=e.style.getPropertyValue(t);return e.style.setProperty(t,n),()=>{e.style.setProperty(t,r)}}function jM(e,t){let n=[];for(let[r,i]of Object.entries(t))n.push(AM(e,r,i));return n.length?()=>{n.forEach(e=>e())}:Fr}function MM(e,t){let n=t===`auto`?`auto`:`${t.width}px`,r=t===`auto`?`auto`:`${t.height}px`;e.style.setProperty(`--popup-width`,n),e.style.setProperty(`--popup-height`,r)}function NM(e,t){let n=t===`max-content`?`max-content`:`${t.width}px`,r=t===`max-content`?`max-content`:`${t.height}px`;e.style.setProperty(`--positioner-width`,n),e.style.setProperty(`--positioner-height`,r)}var PM={name:`adaptiveOrigin`,async fn(e){let{x:t,y:n,rects:{floating:r},elements:{floating:i},platform:a,strategy:o,placement:s}=e,c=ay(i),l=c.getComputedStyle(i);if(l.transitionDuration===`0s`||l.transitionDuration===``)return{x:t,y:n,data:iD};let u=await a.getOffsetParent?.(i),d={width:0,height:0};if(o===`fixed`&&c?.visualViewport)d={width:c.visualViewport.width,height:c.visualViewport.height};else if(u===c){let e=My(i);d={width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}}else await a.isElement?.(u)&&(d=await a.getDimensions(u));let f=ex(s),p=t,m=n;f===`left`&&(p=d.width-(t+r.width)),f===`top`&&(m=d.height-(n+r.height));let h=f===`left`?`right`:iD.sideX,g=f===`top`?`bottom`:iD.sideY;return{x:p,y:m,data:{sideX:h,sideY:g}}}},FM={activationDirection:e=>e?{"data-activation-direction":e}:null};function IM(e){let{store:t,side:n,children:r}=e,i=nE(),a=t.useState(`activeTriggerElement`),o=t.useState(`activeTriggerId`),s=t.useState(`open`),c=t.useState(`payload`),l=t.useState(`mounted`),u=t.useState(`popupElement`),d=t.useState(`positionerElement`),f=EM(s?a:null),p=BM(o,c),m=U.useRef(null),[h,g]=U.useState(null),[_,v]=U.useState(null),y=U.useRef(null),b=U.useRef(null),x=kw(y,!0),S=Vb(),C=U.useRef(null),[w,T]=U.useState(null),[E,D]=U.useState(!1);X(()=>(t.set(`adaptiveOrigin`,PM),()=>{t.set(`adaptiveOrigin`,void 0)}),[t]);let O=Ay(()=>{y.current?.style.setProperty(`animation`,`none`),y.current?.style.setProperty(`transition`,`none`),b.current?.style.setProperty(`display`,`none`)}),k=Ay(e=>{y.current?.style.removeProperty(`animation`),y.current?.style.removeProperty(`transition`),b.current?.style.removeProperty(`display`),e&&T(e)}),A=Ay(()=>{C.current?.abort();let e=new AbortController;C.current=e,x(()=>{g(null),T(null),m.current=null},e.signal)}),j=U.useRef(null);X(()=>{(!s||!l)&&(j.current=null)},[s,l]),X(()=>{if(a&&f&&a!==f&&j.current!==a&&m.current){g(m.current),D(!0);let e=zM(f,a);v(e),j.current=a}},[a,f]),X(()=>{h!=null&&(C.current?.abort(),D(!0),S.request(()=>{Gs.flushSync(()=>{D(!1)}),A()}))},[p,h,A,S]),X(()=>{let e=y.current;if(!e)return;let t=My(e).createElement(`div`);for(let n of Array.from(e.childNodes))t.appendChild(n.cloneNode(!0));m.current=t});let M=h!=null,N;N=M?(0,K.jsxs)(U.Fragment,{children:[(0,K.jsx)(`div`,{"data-previous":!0,inert:ST(!0),ref:b,style:{...w?{"--popup-width":`${w.width}px`,"--popup-height":`${w.height}px`}:null,position:`absolute`},"data-ending-style":E?void 0:``},`previous`),(0,K.jsx)(`div`,{"data-current":!0,ref:y,"data-starting-style":E?``:void 0,children:r},p)]}):(0,K.jsx)(`div`,{"data-current":!0,ref:y,children:r},p),X(()=>{let e=b.current;!e||!h||e.replaceChildren(...Array.from(h.childNodes))},[h]),OM({popupElement:u,positionerElement:d,mounted:l,content:c,onMeasureLayout:O,onMeasureLayoutComplete:k,side:n,direction:i});let P={activationDirection:LM(_),transitioning:M};return{children:N,state:P}}function LM(e){if(e)return`${RM(e.horizontal,5,`right`,`left`)} ${RM(e.vertical,5,`down`,`up`)}`}function RM(e,t,n,r){return e>t?n:e<-t?r:``}function zM(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return{horizontal:a.x-i.x,vertical:a.y-i.y}}function BM(e,t){let[n,r]=U.useState(0),i=U.useRef(e),a=U.useRef(t),o=U.useRef(!1);return X(()=>{let n=i.current,s=a.current,c=e!==n,l=t!==s;c?(r(e=>e+1),o.current=!l):o.current&&l&&(r(e=>e+1),o.current=!1),i.current=e,a.current=t},[e,t]),`${e??`current`}-${n}`}var VM=U.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Vr(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function HM(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var UM=pM,WM=`relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-xl border bg-popover bg-clip-padding shadow-xl outline-none transition-[scale,opacity] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] focus:outline-none has-data-starting-style:scale-95 has-data-starting-style:opacity-0 has-data-ending-style:scale-95 has-data-ending-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`;function GM(e){return(0,K.jsx)(CM,{"data-slot":`menu-trigger`,...e})}function KM({children:e,className:t,sideOffset:n=4,align:r=`center`,alignOffset:i,side:a=`bottom`,zIndex:o,...s}){let c=o??RE.MODAL_BACKDROP;return(0,K.jsxs)(Yj,{children:[(0,K.jsx)(jj,{className:`fixed inset-0`,"data-enso-float":``,style:{zIndex:c-1}}),(0,K.jsx)(aM,{align:r,alignOffset:i,"data-slot":`menu-positioner`,side:a,sideOffset:n,style:{zIndex:c},children:(0,K.jsx)(Kj,{className:G(WM,t),"data-slot":`menu-popup`,...s,children:(0,K.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1.5`,children:e})})})]})}var qM=`[&_svg]:-mx-0.5 flex min-h-8 cursor-default select-none items-center gap-2.5 whitespace-nowrap rounded-md px-2 py-1.5 text-base outline-none data-disabled:cursor-not-allowed data-disabled:bg-transparent! data-disabled:text-muted-foreground! data-highlighted:bg-accent data-inset:ps-8 data-[variant=destructive]:text-destructive data-highlighted:text-accent-foreground data-highlighted:data-[variant=destructive]:bg-destructive/10 data-highlighted:data-[variant=destructive]:text-destructive data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`;function JM(e){return(0,K.jsx)(Vj,{"data-slot":`menu-group`,...e})}function YM({className:e,inset:t,variant:n=`default`,style:r,...i}){return(0,K.jsx)(Uj,{className:G(qM,e),"data-inset":t,"data-slot":`menu-item`,"data-variant":n,style:{WebkitAppRegion:`no-drag`,...r},...i})}function XM({className:e,inset:t,...n}){return(0,K.jsx)(Hj,{className:G(`px-2 py-1.5 font-medium text-muted-foreground text-xs data-inset:ps-9 sm:data-inset:ps-8`,e),"data-inset":t,"data-slot":`menu-label`,...n})}function ZM({className:e,...t}){return(0,K.jsx)(VM,{className:G(`mx-2 my-1 h-px bg-border`,e),"data-slot":`menu-separator`,...t})}function QM(e=`default`){return G(`relative inline-flex min-h-9 w-full min-w-36 select-none items-center justify-between gap-2 rounded-lg border border-input bg-background bg-clip-padding px-[calc(--spacing(3)-1px)] text-left text-base shadow-xs outline-none ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 focus-visible:border-ring focus-visible:ring-[3px] aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/16 data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-8 sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [[data-disabled],:focus-visible,[aria-invalid],[data-pressed]]:shadow-none`,e===`sm`&&`min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:min-h-7`,e===`lg`&&`min-h-10 sm:min-h-9`)}function $M(){return(0,K.jsx)(xt,{className:`-me-1 size-4.5 opacity-80 sm:size-4`})}var eN=U.createContext(void 0);function tN(){let e=U.useContext(eN);if(e===void 0)throw Error(Cr(63));return e}var nN={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},rN={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},iN={valid(e){return e===null?null:e?{"data-valid":``}:{"data-invalid":``}}},aN={...iN,checked(e){return e?{"data-checked":``}:{"data-unchecked":``}}},oN={invalid:void 0,name:void 0,validityData:{state:nN,errors:[],error:``,value:``,initialValue:null},setValidityData:Fr,disabled:void 0,setTouched:Fr,setDirty:Fr,setFilled:Fr,setFocused:Fr,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:rN,registerFieldControl:Fr,validation:{getValidationProps:(e,t=Lr)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Fr,getInputControl:()=>null,commit:async()=>{},change:Fr}},sN=U.createContext(oN);function cN(e=!0){let t=U.useContext(sN);if(t.setValidityData===Fr&&!e)throw Error(Cr(28));return t}function lN(e,t,n,r,i=!0,a){let{registerFieldControl:o}=cN(),s=Tr(()=>Symbol());X(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var uN=U.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Fr,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function dN(){return U.useContext(uN)}var fN=U.createContext({controlId:void 0,registerControlId:Fr,labelId:void 0,setLabelId:Fr,messageIds:[],setMessageIds:Fr,getDescriptionProps:e=>e});function pN(){return U.useContext(fN)}function mN(e,t,n,r=!0,i){let[a,o]=U.useState(),s=Zy(i?`${i}-label`:void 0),c=e??t??a;return X(()=>{let i=e||t||!r?void 0:hN(n.current,s);a!==i&&o(i)}),c}function hN(e,t){let n=gN(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function gN(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function _N(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=pN(),o=Zy(t),s=n?i:void 0,c=Tr(()=>Symbol()),l=U.useRef(!1),u=U.useRef(t!=null),d=Ay(()=>{!l.current||a===Fr||(l.current=!1,a(c.current,void 0))});return X(()=>{if(a===Fr)return;let e;if(n){let n=r?.current;e=cy(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),U.useEffect(()=>d,[d]),i??o}var vN=U.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=dN(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,setFocused:E,validationMode:D,disabled:O,name:k,validation:A}=cN(),{labelId:j}=pN(),M=O||m,N=k??l,P=U.useRef(null),F=Er(P,c,A.inputRef),I=U.useRef(null),L=Zy(),R=_N({id:s,implicit:!1,controlRef:I}),ee=u?void 0:R,[z,B]=Mj({controlled:n,default:!!i,name:`Switch`,state:`checked`});lN(I,L,z,void 0,!M,l),X(()=>{P.current&&T(P.current.checked)},[T]),FT(z,()=>{b(N),C(z!==w.initialValue),T(z),A.change(z)});let{getButtonProps:V,buttonRef:te}=Py({disabled:M,native:u}),H=mN(a,j,P,!u,ee),ne={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":H,onFocus(){M||E(!0)},onBlur(){let e=P.current;!e||M||(S(!0),E(!1),D===`onBlur`&&A.commit(e.checked))},onClick(e){if(f||M)return;e.preventDefault();let t=P.current;t&&Ny(t,e)}},re={...A.getValidationProps(M),checked:z,disabled:M,form:o,id:ee,name:N,required:p,style:N?Wb:Ub,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Ky(Iy,e.nativeEvent);d?.(t,n),!n.isCanceled&&B(t)},onClick(e){e.stopPropagation()},onFocus(){I.current?.focus()},..._===void 0?Lr:{value:_}},ie=U.useMemo(()=>({...x,checked:z,disabled:M,readOnly:f,required:p}),[x,z,M,f,p]),ae=Vr(`span`,e,{state:ie,ref:[t,I,te],props:[ne,y,V,e=>A.getValidationProps(M,e)],stateAttributesMapping:aN});return(0,K.jsxs)(eN.Provider,{value:ie,children:[ae,!z&&N&&g!==void 0&&(0,K.jsx)(`input`,{type:`hidden`,form:o,name:N,value:g,disabled:M}),(0,K.jsx)(`input`,{...re,suppressHydrationWarning:!0})]})}),yN=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Vr(`span`,e,{state:tN(),ref:t,stateAttributesMapping:aN,props:a})});function bN({className:e,...t}){return(0,K.jsx)(vN,{className:G(`group/switch inset-shadow-[0_1px_--theme(--color-black/4%)] inline-flex h-5.5 w-9.5 shrink-0 items-center rounded-full p-px outline-none transition-all focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-checked:bg-primary data-unchecked:bg-input data-disabled:opacity-64 sm:h-4.5 sm:w-7.5`,e),"data-slot":`switch`,...t,children:(0,K.jsx)(yN,{className:G(`pointer-events-none block size-5 rounded-full bg-background shadow-sm transition-[translate,width] group-active/switch:not-data-disabled:w-5.5 data-checked:translate-x-4 data-unchecked:translate-x-0 data-checked:group-active/switch:translate-x-3.5 sm:size-4 sm:data-checked:translate-x-3 sm:group-active/switch:not-data-disabled:w-4.5 sm:data-checked:group-active/switch:translate-x-2.5`),"data-slot":`switch-thumb`})})}var xN=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},SN=(e=>e?xN(e):xN),CN=e=>e;function wN(e,t=CN){let n=U.useSyncExternalStore(e.subscribe,U.useCallback(()=>t(e.getState()),[e,t]),U.useCallback(()=>t(e.getInitialState()),[e,t]));return U.useDebugValue(n),n}var TN=e=>{let t=SN(e),n=e=>wN(t,e);return Object.assign(n,t),n},EN=(e=>e?TN(e):TN);EN(()=>({byScope:{},generation:0}));function DN(e){let t=e=>String(e>=100?Math.round(e):Math.round(e*10)/10);return e<1e3?String(e):e<1e6?`${t(e/1e3)}K`:`${t(e/1e6)}M`}function ON(e){let t=e/1e3;if(t<60)return`${Math.round(t*10)/10}s`;let n=Math.round(t);return`${Math.floor(n/60)}m${n%60}s`}var kN=`enso:open-chat-model-picker`;QM(`sm`),QM();function AN(){window.dispatchEvent(new Event(kN))}function jN(e,t){return e.filter(e=>e!==t)}var MN=new Map,NN=e=>e.images.length>0||e.segments.some(e=>e.type!==`text`||e.text.trim()!==``),PN=()=>!!window.electronAPI?.remote&&window.matchMedia?.(`(pointer: coarse)`).matches===!0;function FN({mentionConversationId:e,commands:t,running:n,busy:r,focusKey:i,pluginPresetId:a=null,autoFocus:o=!window.electronAPI?.remote,enterToSend:s=!PN(),toolbar:c,locked:l=!1,injectedDraft:u,injectedImages:d,injectedDraftAppend:f,onDraftConsumed:p,chatCandidates:m,onActivate:h,onSend:g,onAbort:_,queuedCount:v=0,onSteerQueued:y,isolated:b=!1,placeholder:x,planMode:S=!1,savePastedText:C}){let{t:w}=q(),T=kD(),D=E(e=>e.keybindings),O=E(e=>e.privacyMasking),k=ND(D)[`send-message`],A=(0,U.useId)(),[j,M]=(0,U.useState)([]),[N,P]=(0,U.useState)([]),[F,I]=(0,U.useState)(),L=(0,U.useRef)(i),[R,ee]=(0,U.useState)(!1),{setNodeRef:z,isOver:B}=ov({id:b?`isolated-composer:${i??`side`}`:sk,disabled:b}),[V,te]=(0,U.useState)(null),[H,ne]=(0,U.useState)(null),re=(0,U.useRef)(new Set),ie=(0,U.useRef)(g);ie.current=g;let ae=(0,U.useRef)(O);ae.current=O,(0,U.useEffect)(()=>{if(b)return;let e=YO(e=>oe.current?.insertMention(e)),t=ZO(e=>oe.current?.insertText(e)),n=$O(e=>oe.current?.insertQuote(e)),r=XO(()=>oe.current?.focus()),i=rk((e,t)=>{t&&M(n=>[...n,{...t,id:e.imageId}]),oe.current?.insertMention(e),oe.current?.focus()}),a=ik(e=>{M(t=>[...t,{data:e.data,mimeType:e.mimeType}]),oe.current?.focus()}),o=tk(e=>{if(ue.current)return!1;let t=ae.current,n=t.enabled?Lv(e.text,t).blocked:[];return n.length>0?(gD({type:`error`,title:w(`Message not sent`),description:w(`Privacy masking blocks {{kinds}}. Remove it, or change the action or allow list in Settings → Privacy.`,{kinds:n.join(`, `)})}),!1):ie.current(e)!==!1});return()=>{e(),t(),n(),r(),i(),a(),o()}},[b,w]);let oe=(0,U.useRef)(null),se=(0,U.useRef)(null),ce=(0,U.useRef)(null),le=(0,U.useRef)(!1),ue=(0,U.useRef)(l);ue.current=l,(0,U.useEffect)(()=>{if(!(b||!i))return qD({key:i,segments:()=>oe.current?.getSegments()??[],insertText:e=>oe.current?.insertText(e),setText:e=>oe.current?.setSegments(e?[{type:`text`,text:e}]:[]),busy:()=>le.current||ue.current||!oe.current})},[b,i]);let[de,fe]=(0,U.useState)({left:0,flyoutSide:`right`}),[pe,me]=(0,U.useState)(``),[he,ge]=(0,U.useState)(!1),_e=(0,U.useRef)(Symbol(`composer`)),ve=pe.trim()!==``||he||j.length>0;(0,U.useEffect)(()=>zD(_e.current,ve),[ve]),(0,U.useEffect)(()=>()=>zD(_e.current,!1),[]);let[ye,be]=(0,U.useState)(null),xe=CD(e,ye,m),Se=(0,U.useMemo)(()=>yD(xe,ye??``),[xe,ye]),[Ce,we]=(0,U.useState)(null),[Te,Ee]=(0,U.useState)(null),[De,Oe]=(0,U.useState)(null),ke=RO(De,i??null),[Ae,je]=(0,U.useState)(0),[Me,Ne]=(0,U.useState)(null),[Pe,Fe]=(0,U.useState)(0),Ie=(0,U.useRef)(null),Le=(0,U.useCallback)(e=>{(e.plainText.trim()||e.hasMentions)&&h?.(),me(e.plainText),ge(e.hasMentions);let t=new Set(e.segments.filter(e=>e.type===`ui-element`&&e.imageId).map(e=>e.type===`ui-element`?e.imageId:``)),n=[...re.current].filter(e=>!t.has(e));re.current=t,n.length>0&&(M(e=>fv(e,n)),te(e=>e&&n.includes(e.imageId)?null:e)),be(t=>(t!==e.mentionQuery&&(je(0),Ne(null),Fe(0)),e.mentionQuery)),we(e.slashQuery),Ee(e.skillQuery),Oe(e.pluginQuery)},[h]);(0,U.useEffect)(()=>{let e=L.current;if(e!==i){if(e){let t={segments:oe.current?.getSegments()??[],images:j,slashes:N,recipient:F};MN.set(e,t),zD(`draft:${e}`,NN(t))}let t=i?MN.get(i):void 0;i&&zD(`draft:${i}`,!1);let n=i?JD(i):void 0;oe.current?.setSegments(n?[{type:`text`,text:n}]:t?.segments??[]),re.current=new Set((t?.segments??[]).filter(e=>e.type===`ui-element`&&e.imageId).map(e=>e.type===`ui-element`?e.imageId:``)),M(t?.images??[]),P(t?.slashes??[]),I(t?.recipient),L.current=i,be(null),we(null),Ee(null),je(0),Ne(null),Fe(0)}o&&oe.current?.focus()},[i]),(0,U.useEffect)(()=>{if(!u&&!d?.length)return;let e=hA({segments:oe.current?.getSegments()??[],images:j,slashes:N},{text:u,images:d},f);P(e.slashes),M(e.images),oe.current?.setSegments(e.segments),p?.(),window.setTimeout(()=>oe.current?.focus(),0)},[u,d,f]);let Re=N.length===1?N[0]:null,ze=zv(Re,pe.replaceAll(``,``)),Be=BA(t,Ce,Te),Ve=Ce===null&&Te===null&&ze!==null?Bv(Re,ze):[];(0,U.useEffect)(()=>{je(0)},[Ce,Te,ze,De]),(0,U.useEffect)(()=>{(Ie.current?.children[Ae])?.scrollIntoView({block:`nearest`})},[Ae]);let He=(0,U.useCallback)(e=>{if(e.kind===`agent-type`){oe.current?.consumeToken(`@`),I(e),be(null);return}oe.current?.insertMention(e),be(null)},[]),Ue=(0,U.useCallback)(e=>{Oe(null),zO(e,i??null).then(e=>{let t=oe.current;t&&(t.consumeToken(`#`),e&&t.insertText(e))})},[i]),We=ye!==null&&Se.length>0?`mention`:De!==null&&ke.length>0?`plugin`:Be.length>0?`slash`:Ve.length>0?`slash-sub`:null;(0,U.useLayoutEffect)(()=>{if(We!==`mention`)return;let e=se.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),n=e.querySelector(`[data-slot="mention-picker"]`),r=n?.querySelector(`[role="listbox"]`),i=n?.querySelector(`[data-slot="mention-flyout"]`),a=oe.current?.getMentionAnchorRect(),o=Vk({anchorLeft:a?a.left-t.left:0,containerWidth:t.width,popupWidth:r instanceof HTMLElement?r.offsetWidth:280,flyoutWidth:i instanceof HTMLElement?i.offsetWidth:252,flyoutGap:4});fe(e=>e.left===o.left&&e.flyoutSide===o.flyoutSide?e:o)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[ye,pe,Me,We]);let Ge=We===`mention`?Se.length:We===`plugin`?ke.length:We===`slash-sub`?Ve.length:Be.length,Ke=(0,U.useCallback)((e,t)=>{let n=[{type:`text`,text:e}];oe.current?.setSegments(n),t&&g(iA({segments:n,slashes:N,images:j,recipient:F}))!==!1&&(oe.current?.clear(),M([]),P([]),I(void 0),be(null),we(null),Ee(null))},[j,g,F,N]),qe=(0,U.useCallback)(e=>{oe.current?.consumeToken(Te===null?`/`:`$`),we(null),Ee(null);let t=HD(e);if(!t){P(t=>pA(t,e));return}WD(t,b?null:i??null).then(e=>{e&&gD({type:`error`,title:w(`Plugin command failed`),description:e})})},[Te,b,i,w]),Je=(0,U.useCallback)((e=!1)=>{if(We===`mention`){if(Me){let e=xe[Me][Pe];e&&He(e);return}let e=Se[Ae];e?.type===`item`&&He(e.candidate)}else if(We===`plugin`){let e=ke[Ae];e&&Ue(e)}else if(We===`slash`){let e=Be[Ae];e&&qe(e.name)}else if(We===`slash-sub`){let t=Ve[Ae];if(!t)return;Ke(t.name,e)}},[Ae,Pe,Me,xe,Se,He,Ue,ke,We,Be,qe,Ve,Ke]),Ye=pe.replaceAll(``,``).trim(),Xe=!!(Ye||N.length>0||j.length>0||he),Ze=F!==void 0,Qe=r&&!Ze,$e={sessionId:b?null:i??null,draft:pe.replaceAll(``,``),busy:l,pluginPresetId:a},et=n&&v>0&&y!==void 0&&s&&!!k,tt=et&&!Xe&&!Ze&&!l,nt=(0,U.useMemo)(()=>O.enabled&&Ye?Lv(Ye,O):null,[Ye,O]),W=()=>{if(!Xe)return;let e=iA({segments:oe.current?.getSegments()??[],slashes:N,images:j,recipient:F}),t=O.enabled?Lv(e.text,O).blocked:[];if(t.length>0){gD({type:`error`,title:w(`Message not sent`),description:w(`Privacy masking blocks {{kinds}}. Remove it, or change the action or allow list in Settings → Privacy.`,{kinds:t.join(`, `)})});return}g(e)!==!1&&(oe.current?.clear(),M([]),P([]),I(void 0),be(null),we(null),Ee(null))},rt=(0,U.useCallback)(e=>{for(let t of e){if(t.type.startsWith(`image/`)){let e=new FileReader;e.onload=()=>{let n=e.result,r=n.slice(n.indexOf(`,`)+1);M(e=>[...e,{data:r,mimeType:t.type}])},e.readAsDataURL(t);continue}let e=window.electronAPI.files.pathForFile(t),n=window.electronAPI.remote;if(!e&&n){n.upload(t).then(e=>{e&&oe.current?.insertFileChip(e)}).catch(()=>{});continue}e&&oe.current?.insertFileChip(e)}},[]);return(0,U.useEffect)(()=>{if(b)return;let e=ak(e=>{rt(e),oe.current?.focus()}),t=ok(e=>{for(let t of e)oe.current?.insertFileChip(t);oe.current?.focus()});return()=>{e(),t()}},[b,rt]),(0,K.jsxs)(`div`,{ref:se,className:`relative`,children:[We===`mention`&&(0,K.jsx)(lj,{id:A,groups:xe,query:ye??``,activeIndex:Ae,onActiveIndexChange:je,openFolderId:Me,folderIndex:Pe,onOpenFolderIdChange:Ne,onFolderIndexChange:Fe,onSelect:He,left:de.left,flyoutSide:de.flyoutSide}),We===`plugin`&&(0,K.jsx)(`div`,{ref:Ie,role:`listbox`,"aria-label":w(`Plugin suggestions`),className:`absolute bottom-full left-0 z-10 mb-1.5 max-h-64 w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:ke.map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===Ae,onMouseDown:e=>e.preventDefault(),onClick:()=>Ue(e),onMouseMove:()=>je(t),className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,t===Ae&&`bg-foreground/10`),children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:`#`}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.item.label}),e.item.detail&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:e.item.detail})]},e.key))}),(We===`slash`||We===`slash-sub`)&&(0,K.jsx)(`div`,{ref:Ie,role:`listbox`,"aria-label":w(`Command suggestions`),className:`absolute bottom-full left-0 z-10 mb-1.5 max-h-64 w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:(We===`slash`?Be:Ve).map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===Ae,onClick:()=>{je(t),We===`slash`?qe(e.name):Ke(e.name,!1)},onMouseMove:()=>je(t),className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,t===Ae&&`bg-foreground/10`),children:[(0,K.jsx)(Gn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono font-medium`,children:Te===null?e.name:`$${e.name.slice(7)}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:w(e.description)})]},e.name))}),(0,K.jsxs)(`div`,{ref:z,"data-slot":`composer`,"data-enso":`composer`,className:G(`rounded-[24px] border bg-card shadow-[0_2px_6px_rgb(0_0_0/0.03),0_12px_32px_rgb(0_0_0/0.07)] transition-[border-color,box-shadow] duration-200 focus-within:border-foreground/20 [.dark_&]:shadow-[0_2px_6px_rgb(0_0_0/0.2),0_12px_32px_rgb(0_0_0/0.3)]`,(R||B)&&`border-brand/50 bg-brand/5`,(Ze||S)&&`border-primary/35 shadow-primary/5`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),ee(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ee(!1)},onDrop:e=>{let t=Array.from(e.dataTransfer.files);t.length!==0&&(e.preventDefault(),ee(!1),rt(t))},children:[j.filter(e=>!e.id).length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:j.filter(e=>!e.id).map((e,t)=>(0,K.jsxs)(`div`,{className:`group relative`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>ne(e),className:`block rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,"aria-label":w(`Preview`),children:(0,K.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`h-16 w-16 rounded-md border object-cover`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>M(t=>jN(t,e)),className:`absolute -top-1.5 -right-1.5 rounded-full border bg-background p-0.5 text-muted-foreground shadow-sm transition-opacity hover:text-destructive`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]},t))}),(0,K.jsxs)(`div`,{className:G(`flex items-start gap-1.5 px-4`,j.length>0?`pt-1.5`:`pt-3.5`),children:[F&&(0,K.jsx)(yA,{recipient:F,onRemove:()=>I(void 0)}),N.map(e=>(0,K.jsx)(dA,{name:e,className:`mt-0.5 shrink-0`,trailing:(0,K.jsx)(`button`,{type:`button`,onClick:()=>P(t=>t.filter(t=>t!==e)),className:`rounded-sm opacity-70 hover:opacity-100`,"aria-label":w(`Remove`),children:(0,K.jsx)(ir,{className:`h-3 w-3`})})},e)),(0,K.jsx)(rj,{ref:oe,placeholder:N.length>0?``:l?w(`Resolve the pending approval to continue`):Ze?w(`Message the selected Agent…`):et?w(`Press {{key}} to steer the next queued message into this round…`,{key:ID(k)}):x||w(n?`Message will queue until this round finishes…`:`Type @ to choose a file or Agent`),disabled:l,onStateChange:Le,onChipActivate:e=>{e.type===`ui-element`&&te({kind:`ui-element`,id:e.id,label:e.label,path:e.path,text:e.text,imageId:e.imageId})},onKeyDown:e=>{let t=e.nativeEvent.isComposing||le.current;if(We){let n=We===`mention`?Se[Ae]:void 0,r=Hk({key:e.key,shiftKey:e.shiftKey,isComposing:t,activeIndex:Ae,itemCount:Ge,folderOpen:We===`mention`&&Me!==null,activeIsFolder:We===`mention`&&n?.type===`folder`,folderIndex:Pe,folderItemCount:Me?xe[Me].length:0});if(r.type===`move`){e.preventDefault(),je(r.index),Ne(null);return}if(r.type===`move-folder`){e.preventDefault(),Fe(r.index);return}if(r.type===`open-folder`){e.preventDefault(),n?.type===`folder`&&Ne(n.id),Fe(0);return}if(r.type===`close-folder`){e.preventDefault(),Ne(null);return}if(r.type===`pick`){e.preventDefault(),Je(We===`slash-sub`&&e.key===`Enter`);return}if(r.type===`close`){e.preventDefault(),be(null),we(null),Ee(null),Oe(null),Ne(null);return}}if(t)return;let n=PD(e);if(!b&&n&&n===ND(E.getState().keybindings)[`switch-model`]){e.preventDefault(),AN();return}if(e.key===`Backspace`&&N.length>0&&Ye.length===0&&!he){e.preventDefault(),P(e=>e.slice(0,-1));return}if(e.key===`Backspace`&&F&&oe.current?.isEmpty()&&N.length===0){e.preventDefault(),I(void 0);return}s&&!We&&PD(e,{allowBare:!0})===k&&(e.preventDefault(),tt?y?.():W())},onPasteText:e=>!C||!mv(e)?!1:(C(e).catch(()=>({ok:!1,error:`unavailable`})).then(t=>{let n=oe.current;t.ok?n?.insertFileChip(t.path,`${pv} · ${w(`{{count}} chars`,{count:t.chars.toLocaleString()})}`):n?.insertText(e)}),!0),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length!==0&&(e.preventDefault(),rt(t))},onCompositionStart:()=>{le.current=!0},onCompositionEnd:()=>{le.current=!1},ariaProps:{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":We!==null,"aria-controls":We===`mention`?A:void 0,"aria-activedescendant":We===`mention`?Me?`${A}-sub-${Pe}`:`${A}-option-${Ae}`:void 0}})]}),Ze&&(0,K.jsx)(`p`,{className:`sr-only`,children:w(`Send only to the selected Agent`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5 px-3 pt-0.5 pb-2.5`,children:[(0,K.jsxs)(`div`,{className:G(`flex min-w-0 flex-1 items-center`,T?`gap-0.5 overflow-x-auto [scrollbar-width:none]`:`gap-1 overflow-hidden`),children:[(0,K.jsx)(`input`,{ref:ce,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{rt(Array.from(e.target.files??[])),e.target.value=``}}),(0,K.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>ce.current?.click(),"aria-label":w(`Attach image`),title:w(`Attach image`),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40 max-md:size-[32px]`,children:(0,K.jsx)($t,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(vO,{side:`left`,...$e}),c,!b&&(0,K.jsx)(wO,{sessionId:$e.sessionId}),(0,K.jsx)(vO,{side:`right`,...$e}),nt&&(nt.blocked.length>0||nt.masked>0)&&(0,K.jsxs)(`span`,{className:G(`flex shrink-0 items-center gap-1 text-[11px]`,nt.blocked.length>0?`text-red-600 dark:text-red-400`:`text-sky-600 dark:text-sky-400`),"data-privacy-precheck":!0,children:[nt.blocked.length>0?(0,K.jsx)(Ln,{className:`size-3.5`}):(0,K.jsx)(Rn,{className:`size-3.5`}),nt.blocked.length>0?w(`Will be blocked: {{kinds}}`,{kinds:nt.blocked.join(`, `)}):w(`{{count}} will be masked`,{count:nt.masked})]})]}),Qe&&!Xe?(0,K.jsx)(Oa,{variant:`outline`,size:`icon`,className:`size-8 shrink-0 rounded-full`,onClick:_,"aria-label":w(`Stop`),children:(0,K.jsx)(Et,{className:`h-4 w-4`})}):(0,K.jsx)(Oa,{size:`icon`,className:`size-8 shrink-0 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-35`,onClick:W,disabled:!Xe||l,"aria-label":w(Ze?`Send only to the selected Agent`:`Send`),title:Ze?w(`Send only to the selected Agent`):s&&k?`${w(`Send`)} ${ID(k)}`:w(`Send`),children:(0,K.jsx)(ct,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(BE,{open:V!==null,onOpenChange:e=>!e&&te(null),children:(0,K.jsxs)(GE,{className:`max-w-md`,children:[(0,K.jsx)(KE,{children:(0,K.jsx)(JE,{children:V?.label??w(`Selected UI element`)})}),(0,K.jsx)(ZE,{className:`space-y-2 text-xs`,children:V&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:V.path}),V.text&&(0,K.jsx)(`p`,{children:V.text}),(()=>{let e=j.find(e=>e.id===V.imageId);return e?(0,K.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-72 w-full rounded-md border object-contain`}):null})()]})})]})}),(0,K.jsx)(BE,{open:H!==null,onOpenChange:e=>!e&&ne(null),children:(0,K.jsxs)(GE,{className:`max-w-3xl`,children:[(0,K.jsx)(KE,{children:(0,K.jsx)(JE,{children:w(`Preview`)})}),(0,K.jsx)(ZE,{children:H&&(0,K.jsx)(`img`,{src:`data:${H.mimeType};base64,${H.data}`,alt:``,className:`max-h-[80vh] w-full rounded-md object-contain`})})]})})]})}var IN=(0,U.createContext)(null);function LN(){return(0,U.useContext)(IN)}function RN({className:e}){return(0,K.jsx)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,"aria-hidden":`true`,className:G(`size-4`,e),children:(0,K.jsx)(`path`,{d:`M 38.96 48.86 A 18.24 18.24 0 1 1 48.19 40.4`,stroke:`currentColor`,strokeWidth:`8.32`,strokeLinecap:`round`})})}var zN=12e4;function BN(e){return{id:e.id,dueAt:e.dueAt,...e.label?{label:e.label}:{}}}function VN(e,t){return e.filter(e=>e.dueAt>t-zN).sort((e,t)=>e.dueAt-t.dueAt)}function HN(e,t){let n=VN(e,t),r=n[0];if(r)return{...BN(r),count:n.length}}function UN(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function WN(e,t,n){let r=e-t;if(r<=0)return n(`due now`);if(r<6e4)return n(`<1m`);let i=Math.ceil(r/6e4);if(i<60)return n(`in {{minutes}}m`,{minutes:i});let a=Math.floor(i/60),o=i%60;return o>0?n(`in {{hours}}h {{minutes}}m`,{hours:a,minutes:o}):n(`in {{hours}}h`,{hours:a})}function GN(e,t,n){let r=[`${n(`Waiting for reminder · {{time}}`,{time:UN(e.dueAt)})} (${WN(e.dueAt,t,n)})`];return e.label&&r.push(e.label),e.count>1&&r.push(n(`{{count}} reminders`,{count:e.count})),r.join(` — `)}var KN=6e4,qN=60*KN;1*KN,2*KN,5*KN,10*KN,15*KN,6*qN,30*KN,24*qN,1*KN,1*KN,2*KN,5*KN,10*KN;function JN(e){return e?.status===`waiting`&&e.retry?.reason===`upstream`}function YN(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var XN=3e4,ZN=EN(e=>({byConversation:{},replace:(t,n)=>e(e=>{let r={...e.byConversation};if(n.length>0)r[t]=n;else if(r[t])delete r[t];else return e;return{byConversation:r}}),replaceAll:t=>{let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&r.length>0&&(n[e]=r);e({byConversation:n})}}));function QN(e,t=!0){let n=ZN(n=>t&&e?n.byConversation[e]:void 0),[,r]=(0,U.useState)(0),i=!!(n&&n.length>0);(0,U.useEffect)(()=>{if(!i)return;let e=setInterval(()=>r(e=>e+1),XN);return()=>clearInterval(e)},[i]);let a=Date.now();return!t||!n||n.length===0?{reminder:void 0,now:a}:{reminder:HN(n,a),now:a}}var $N={activeId:null,conversations:{},rewind:()=>{},retry:()=>{},forkFromMessage:async()=>null,selectConversation:()=>{},removeQueuedMessage:()=>{},updateQueuedMessage:()=>{},sendQueuedNow:()=>{},interruptAndSendQueued:async()=>{},pauseGoal:()=>{},resumeGoal:()=>{},clearGoal:()=>{}};function eP(e){Object.assign($N,e)}function tP(e){if(!e){$N.activeId=null,$N.conversations={};return}$N.activeId=e.id,$N.conversations={[e.id]:e}}function nP(e){return e($N)}nP.getState=()=>$N,nP.subscribe=e=>()=>{};var rP=`rounded-lg border border-border/60 bg-muted/20 px-2.5 py-1.5 text-xs`;function iP({className:e}){return(0,K.jsx)(Xn,{className:G(`h-3.5 w-3.5 shrink-0 text-muted-foreground`,e)})}var aP=`w-full overflow-hidden rounded-lg border border-dashed border-border/60 text-xs text-muted-foreground`,oP=G(aP,`px-3 py-2`),sP=`mt-0.5 h-3.5 w-3.5 shrink-0`,cP={active:`bg-green-500 animate-pulse`,paused:`bg-amber-500`,waiting:`bg-amber-500`,blocked:`bg-destructive`,completed:`bg-blue-500`};function lP({conversationId:e,goal:t,sessionStatus:n}){let{t:r}=q(),i=JN(t)?t.retry:void 0,{reminder:a,now:o}=QN(e,!i&&t.status===`active`&&n!==`running`),s={active:r(`working`),paused:r(`paused`),waiting:r(`waiting`),blocked:r(`blocked`),completed:r(`completed`)},c=i?i.kind===`quota`?r(`Quota exhausted · next {{time}}`,{time:YN(i.at)}):r(`Waiting for upstream recovery · next {{time}}`,{time:YN(i.at)}):s[t.status],l=a?GN(a,o,r):void 0;return(0,K.jsxs)(`div`,{className:G(`mb-1 flex items-center gap-2`,rP),children:[(0,K.jsx)(iP,{}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:i?.lastError?`${t.text} — ${i.lastError}`:l?`${t.text} — ${l}`:t.note?`${t.text} — ${t.note}`:t.text,children:[t.text,t.note&&(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,t.note]})]}),a?(0,K.jsxs)(`span`,{"data-enso":`goal-reminder-waiting`,title:l,className:`inline-flex min-w-0 max-w-[260px] shrink-0 items-center gap-1 rounded bg-sky-500/15 px-1.5 py-0.5 font-mono text-[10px] text-sky-600 tabular-nums dark:text-sky-400`,children:[(0,K.jsx)(jt,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`truncate`,children:[r(`Waiting for reminder · {{time}}`,{time:UN(a.dueAt)}),a.label?` · ${a.label}`:``]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,cP[t.status])}),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums`,children:[c,t.status===`active`&&t.autoTurns>0?` · ${t.autoTurns}/25`:``]})]}),i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`upstream-retry-now`,title:r(`Retry now`),onClick:()=>void nP.getState().retryUpstreamNow(e),className:`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-amber-600 transition-colors hover:bg-amber-500/10 dark:text-amber-400`,children:[(0,K.jsx)(Mn,{className:`h-3 w-3`}),r(`Retry now`)]}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`upstream-stop`,title:r(`Stop auto-retry`),onClick:()=>void nP.getState().abort(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive`,children:(0,K.jsx)(Jn,{className:`h-3 w-3`})})]}):t.status===`active`?(0,K.jsx)(`button`,{type:`button`,title:r(`Pause goal`),onClick:()=>nP.getState().pauseGoal(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(Sn,{className:`h-3.5 w-3.5`})}):t.status===`completed`?null:(0,K.jsx)(`button`,{type:`button`,title:r(`Resume goal`),onClick:()=>nP.getState().resumeGoal(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(Tn,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(`button`,{type:`button`,title:r(`Clear goal`),onClick:()=>nP.getState().clearGoal(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]})}function uP(e,t){return e.trim().length>0||t>0}function dP(e,t){return e>0?`${e} ${t}`:null}var fP=fk;function pP(e){return!dk(e)}function mP({conversationId:e,queued:t}){let{t:n}=q(),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(``);if(t.length===0)return null;let s=t=>{uP(a,t.images?.length??0)&&nP.getState().updateQueuedMessage(e,t.id,a.trim()),i(null)};return(0,K.jsx)(`div`,{className:`mb-1 flex flex-col gap-0.5`,children:t.map(t=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 border-dashed bg-muted/20 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground uppercase tracking-wide`,children:n(`Queued`)}),r===t.id?(0,K.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&s(t),e.key===`Escape`&&i(null))},autoFocus:!0,className:`h-6 min-w-0 flex-1 rounded border bg-transparent px-1.5 outline-none focus:ring-1 focus:ring-ring`}):(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:fP(t.text)||`[image]`}),dP(t.images?.length??0,n(`attachments`))&&(0,K.jsxs)(`span`,{title:dP(t.images?.length??0,n(`attachments`))??void 0,className:`flex shrink-0 items-center gap-0.5 text-muted-foreground`,children:[(0,K.jsx)(tn,{className:`h-3 w-3`}),t.images?.length]}),r===t.id?(0,K.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(gt,{className:`h-3.5 w-3.5`})}):(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,title:n(`Withdraw message`),"aria-label":n(`Withdraw message`),onClick:()=>nP.getState().withdrawMessage(e,{kind:`queue`,id:t.id}),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Qn,{className:`h-3 w-3`})}),pP(t.text)&&(0,K.jsx)(`button`,{type:`button`,title:n(`Edit`),onClick:()=>{i(t.id),o(t.text)},className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Cn,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:n(`Send now`),onClick:()=>nP.getState().sendQueuedNow(e,t.id),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Fn,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:n(`Interrupt and send now`),onClick:()=>void nP.getState().interruptAndSendQueued(e,t.id),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(qn,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:n(`Remove`),onClick:()=>nP.getState().removeQueuedMessage(e,t.id),className:`rounded p-0.5 text-muted-foreground hover:text-destructive`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]})]},t.id))})}var hP=0,gP=1,_P=2,vP=4;function yP(e){return()=>e}function bP(e){e()}function xP(e,t){return n=>e(t(n))}function SP(e,t){return()=>e(t)}function CP(e,t){return n=>e(t,n)}function wP(e){return e!==void 0}function TP(...e){return()=>{e.map(bP)}}function EP(){}function DP(e,t){return t(e),e}function OP(e,t){return t(e)}function kP(...e){return e}function AP(e,t){return e(gP,t)}function jP(e,t){e(hP,t)}function MP(e){e(_P)}function NP(e){return e(vP)}function PP(e,t){return AP(e,CP(t,hP))}function FP(e,t){let n=e(gP,e=>{n(),t(e)});return n}function IP(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function LP(e,t){return e===t}function RP(e=LP){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function zP(e){return t=>n=>{e(n)&&t(n)}}function BP(e){return t=>xP(t,e)}function VP(e){return t=>()=>{t(e)}}function Z(e,...t){let n=Xte(...t);return((t,r)=>{switch(t){case _P:MP(e);return;case gP:return AP(e,n(r))}})}function HP(e,t){return n=>r=>{n(t=e(t,r))}}function UP(e){return t=>n=>{e>0?e--:t(n)}}function WP(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function GP(...e){let t=Array.from({length:e.length}),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;AP(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function Xte(...e){return t=>e.reduceRight(OP,t)}function Zte(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case gP:return a?n===a?void 0:(r(),n=a,t=AP(e,a),t):(r(),EP);case _P:r(),n=null;return}}}function Q(e){let t=e,n=qP();return((e,r)=>{switch(e){case hP:t=r;break;case gP:r(t);break;case vP:return t}return n(e,r)})}function KP(e,t){return DP(Q(t),t=>PP(e,t))}function qP(){let e=[];return((t,n)=>{switch(t){case hP:e.slice().forEach(e=>{e(n)});return;case _P:e.splice(0);return;case gP:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function JP(e){return DP(qP(),t=>PP(e,t))}var Qte={singleton:!0};function YP(e,t=[],n=Qte){let{singleton:r}=n;return{constructor:e,dependencies:t,id:$te(),singleton:r}}var $te=()=>Symbol(`id`);function ene(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function XP(...e){let t=qP(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;AP(e,e=>{n[a]=e,r|=o,r===i&&jP(t,n)})}),function(e,a){switch(e){case _P:MP(t);return;case gP:return r===i&&a(n),AP(t,a)}}}function ZP(e,t=LP){return Z(e,RP(t))}function QP(...e){return function(t,n){switch(t){case _P:return;case gP:return TP(...e.map(e=>AP(e,n)))}}}var $P={DEBUG:0,INFO:1,WARN:2,ERROR:3},tne={[$P.DEBUG]:`debug`,[$P.ERROR]:`error`,[$P.INFO]:`log`,[$P.WARN]:`warn`},nne=()=>typeof globalThis>`u`?window:globalThis,eF=YP(()=>{let e=Q($P.ERROR);return{log:Q((t,n,r=$P.INFO)=>{r>=(nne().VIRTUOSO_LOG_LEVEL??NP(e))&&console[tne[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function rne(e){return`self`in e?e.document.documentElement:e}function tF(e){let t=rne(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function nF(e,t){return tF(e)?-t:t}function rF(e,t){return tF(e)?-t:t}function iF(e,t,n){return aF(e,t,n).callbackRef}function aF(e,t,n){let r=U.useRef(null),i=e=>{},a=U.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function oF(e,t,n,r,i,a,o,s,c){return aF(U.useCallback(n=>{let c=ine(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild?.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?nF(o,o.scrollLeft):o.scrollTop:u?s?nF(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?nF(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?sF(`column-gap`,getComputedStyle(n).columnGap,i):sF(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function ine(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index,10),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},$P.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function sF(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,$P.WARN),t===`normal`?0:parseInt(t??`0`,10)}function cF(e,t,n){let r=U.useRef(null),i=U.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=aF(i,!0,n),s=U.useCallback(()=>{i(o.current)},[i,o]);return U.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var lF=YP(()=>{let e=qP(),t=qP(),n=Q(0),r=qP(),i=Q(0),a=qP(),o=qP(),s=Q(0),c=Q(0),l=Q(0),u=Q(0),d=qP(),f=qP(),p=Q(!1),m=Q(!1),h=Q(!1);return PP(Z(e,BP(({scrollTop:e})=>e)),t),PP(Z(e,BP(({scrollHeight:e})=>e)),o),PP(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),uF={lvl:0};function dF(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function fF(e){return e===uF}function pF(e,t){if(!fF(e))return t===e.k?e.v:t<e.k?pF(e.l,t):pF(e.r,t)}function mF(e,t,n=`k`){if(fF(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=mF(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return mF(e.l,t,n)}function hF(e,t,n){return fF(e)?EF(t,n,1):t===e.k?SF(e,{k:t,v:n}):t<e.k?DF(SF(e,{l:hF(e.l,t,n)})):DF(SF(e,{r:hF(e.r,t,n)}))}function gF(){return uF}function _F(e,t,n){if(fF(e))return[];let r=mF(e,t)[0];return ane(bF(e,r,n))}function vF(e,t){if(fF(e))return uF;let{k:n,l:r,r:i}=e;if(t===n){if(fF(r))return i;if(fF(i))return r;let[t,n]=TF(r);return xF(SF(e,{k:t,l:CF(r),v:n}))}return xF(t<n?SF(e,{l:vF(r,t)}):SF(e,{r:vF(i,t)}))}function yF(e){return fF(e)?[]:[...yF(e.l),{k:e.k,v:e.v},...yF(e.r)]}function bF(e,t,n){if(fF(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(bF(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(bF(a,t,n))),s}function xF(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(wF(t))return OF(SF(e,{lvl:n-1}));if(!fF(t)&&!fF(t.r))return SF(t.r,{l:SF(t,{r:t.r.l}),lvl:n,r:SF(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(wF(e))return kF(SF(e,{lvl:n-1}));if(!fF(r)&&!fF(r.l)){let t=r.l,i=wF(t)?r.lvl-1:r.lvl;return SF(t,{l:SF(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:kF(SF(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function SF(e,t){return EF(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function CF(e){return fF(e.r)?e.l:xF(SF(e,{r:CF(e.r)}))}function wF(e){return fF(e)||e.lvl>e.r.lvl}function TF(e){return fF(e.r)?[e.k,e.v]:TF(e.r)}function EF(e,t,n,r=uF,i=uF){return{k:e,l:r,lvl:n,r:i,v:t}}function DF(e){return kF(OF(e))}function OF(e){let{l:t}=e;return!fF(t)&&t.lvl===e.lvl?SF(t,{r:SF(e,{l:t.r})}):e}function kF(e){let{lvl:t,r:n}=e;return!fF(n)&&!fF(n.r)&&n.lvl===t&&n.r.lvl===t?SF(n,{l:SF(e,{r:n.l}),lvl:t+1}):e}function ane(e){return dF(e,({k:e,v:t})=>({index:e,value:t}))}function AF(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function jF(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var MF=YP(()=>({recalcInProgress:Q(!1)}),[],{singleton:!0});function NF(e,t,n){return e[PF(e,t,n)]}function PF(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function one(e,t,n,r){let i=PF(e,t,r),a=PF(e,n,r,i);return e.slice(i,a+1)}function FF(e,t){return Math.round(e.getBoundingClientRect()[t])}function IF(e){return!fF(e.groupOffsetTree)}function LF({index:e},t){return t===e?0:t<e?-1:1}function sne(){return{groupIndices:[],groupOffsetTree:gF(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:gF()}}function cne(e,t){let n=fF(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),fF(e)){e=hF(e,0,i);continue}let o=_F(e,a-1,t+1);if(o.some(hne(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=vF(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=hF(e,t+1,a));c&&(e=hF(e,a,i))}return[e,n]}function lne(e){return e.groupIndex!==void 0}function une({offset:e},t){return t===e?0:t<e?-1:1}function RF(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=NF(t,e,LF),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function zF(e,t){if(!IF(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function BF(e,t,n){if(lne(e))return t.groupIndices[e.groupIndex]+1;let r=zF(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function dne(e,t,n,r=0){return r>0&&(t=Math.max(t,NF(e,r,LF).offset)),dF(one(e,t,n,une),mne)}function fne(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,$P.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&fF(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>hF(hF(t,n,e),n+1,r),o)}else[o,s]=cne(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=HF(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>hF(e,t,RF(t,d,i)),gF()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function pne(e){return yF(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function VF(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function HF(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=PF(i,t-1,LF),s=i[c].offset;let e=mF(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===mF(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of _F(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function mne(e){return{index:e.index,value:e}}function hne(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var gne={offsetHeight:`height`,offsetWidth:`width`},UF=YP(([{log:e},{recalcInProgress:t}])=>{let n=qP(),r=qP(),i=KP(r,0),a=qP(),o=qP(),s=Q(0),c=Q([]),l=Q(void 0),u=Q(void 0),d=Q(void 0),f=Q(void 0),p=Q((e,t)=>FF(e,gne[t])),m=Q(void 0),h=Q(0),g=sne(),_=KP(Z(n,GP(c,e,h),HP(fne,g),RP()),g),v=KP(Z(c,RP(),HP((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),BP(({prev:e})=>e)),[]);PP(Z(c,zP(e=>e.length>0),GP(_,h),BP(([e,t,n])=>{let r=e.reduce((e,r,i)=>hF(e,r,RF(r,t.offsetTree,n)||i),gF());return{...t,groupIndices:e,groupOffsetTree:r}})),_),PP(Z(r,GP(_),zP(([e,{lastIndex:t}])=>e<t),BP(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),PP(l,u);let y=KP(Z(l,BP(e=>e===void 0)),!0);PP(Z(u,zP(e=>e!==void 0&&fF(NP(_).sizeTree)),BP(e=>{let t=NP(d),n=NP(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),PP(Z(f,zP(e=>e!==void 0&&e.length>0&&fF(NP(_).sizeTree)),BP(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),PP(Z(c,GP(d,u),zP(([,e,t])=>e!==void 0&&t!==void 0),BP(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=JP(Z(n,GP(_),HP(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),BP(e=>e.changed)));AP(Z(s,HP((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),BP(e=>e.diff)),e=>{let{groupIndices:n}=NP(_);if(e>0)jP(t,!0),jP(a,e+VF(e,n));else if(e<0){let t=NP(v);t.length>0&&(e-=VF(-e,t)),jP(o,e)}}),AP(Z(s,GP(e)),([e,t])=>{e<0&&t("`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:s},$P.ERROR)});let x=JP(a);PP(Z(a,GP(_),BP(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=pF(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=yF(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return yF(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=JP(Z(o,GP(_,h),BP(([e,{offsetTree:t},n])=>RF(-e,t,n))));return PP(Z(o,GP(_,h),BP(([e,t,n])=>{if(t.groupIndices.length>0){if(fF(t.sizeTree))return t;let r=gF(),i=NP(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=yF(t.sizeTree).reduce((t,{k:n,v:r})=>hF(t,Math.max(0,n+e),r),r),a!==-e){let n=pF(t.sizeTree,s);r=hF(r,0,n);let i=mF(t.sizeTree,-e+1)[1];r=hF(r,1,i)}return{...t,sizeTree:r,...HF(t.offsetTree,0,r,n)}}let r=yF(t.sizeTree).reduce((t,{k:n,v:r})=>hF(t,Math.max(0,n+e),r),gF());return{...t,sizeTree:r,...HF(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},kP(eF,MF),{singleton:!0});function _ne(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var WF=YP(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=qP(),o=qP(),s=JP(Z(a,BP(_ne)));return PP(Z(s,BP(e=>e.totalCount)),n),PP(Z(s,BP(e=>e.groupIndices)),e),PP(Z(XP(i,t,r),zP(([e,t])=>IF(t)),BP(([e,t,n])=>mF(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),RP(),BP(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},kP(UF,lF)),GF=YP(([{log:e}])=>{let t=Q(!1),n=JP(Z(t,zP(e=>e),RP()));return AP(t,t=>{t&&NP(e)(`props updated`,{},$P.DEBUG)}),{didMount:n,propsReady:t}},kP(eF),{singleton:!0}),vne=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function KF(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!vne)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var qF=YP(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=qP(),m=qP(),h=Q(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),jP(c,!1)}return PP(Z(p,GP(n,d,r,h,s,o,f),GP(e,a,i),BP(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=KF(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=BF(b,n,w),E=RF(T,n.offsetTree,d)+o;x===`end`?(E+=f+mF(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+mF(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},$P.DEBUG),jP(p,e)):(jP(m,!0),l(`list did not change, scroll successful`,{},$P.DEBUG))};if(y(),S===`smooth`){let e=!1;v=AP(t,t=>{e||=t}),g=FP(u,()=>{D(e)})}else g=FP(Z(t,yne(150)),D);return _=setTimeout(()=>{y()},1200),jP(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},$P.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},kP(UF,lF,eF),{singleton:!0});function yne(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function JF(e,t){e===0?t():requestAnimationFrame(()=>{JF(e-1,t)})}function YF(e,t){if(e===void 0)return 0;let n=t-1,r=typeof e==`number`?e:e.index===`LAST`?n:e.index;return Math.max(0,Math.min(r,n))}function XF(e){return e===void 0?!0:typeof e==`number`?e===0:e.index===0&&(e.align===void 0||e.align===`start`)&&(e.offset===void 0||e.offset===0)}var ZF=YP(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=Q(!0),c=Q(0),l=Q(!0);return PP(Z(o,GP(c),zP(([e,t])=>!XF(t)),VP(!1)),s),PP(Z(o,GP(c),zP(([e,t])=>!XF(t)),VP(!1)),l),AP(Z(XP(t,o),GP(s,n,e,l),zP(([[,e],t,{sizeTree:n},r,i])=>e&&(!fF(n)||wP(r))&&!t&&!i),GP(c)),([,e])=>{if(e===void 0){jP(s,!0),jP(l,!0);return}FP(i,()=>{jP(l,!0)}),JF(4,()=>{FP(r,()=>{jP(s,!0)}),jP(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},kP(UF,lF,qF,GF),{singleton:!0});function QF(e,t){return Math.abs(e-t)<1.01}var $F=`up`,eI=`down`,bne=`none`,xne={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Sne=0,tI=YP(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=Q(!1),s=Q(!0),c=qP(),l=qP(),u=Q(4),d=Q(Sne),f=KP(Z(QP(Z(ZP(i),UP(1),VP(!0)),Z(ZP(i),UP(1),VP(!1),IP(100))),RP()),!1),p=KP(Z(QP(Z(n,VP(!0)),Z(n,VP(!1),IP(200))),RP()),!1);PP(Z(XP(ZP(i),ZP(d)),BP(([e,t])=>e<=t),RP()),s),PP(Z(s,WP(50)),l);let m=JP(Z(XP(r,ZP(a),ZP(t),ZP(e),ZP(u)),HP((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},xne),RP((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=KP(Z(r,HP((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!QF(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),zP(e=>e.changed),BP(e=>e.jump)),0);PP(Z(m,BP(e=>e.atBottom)),o),PP(Z(o,WP(50)),c);let g=Q(eI);PP(Z(r,BP(({scrollTop:e})=>e),RP(),HP((e,t)=>NP(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?$F:eI,prevScrollTop:t},{direction:eI,prevScrollTop:0}),BP(e=>e.direction)),g),PP(Z(r,WP(50),VP(bne)),g);let _=Q(0);return PP(Z(f,zP(e=>!e),VP(0)),_),PP(Z(i,WP(100),GP(f),zP(([e,t])=>t),HP(([e,t],[n])=>[t,n],[0,0]),BP(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},kP(lF)),nI=`top`,rI=`bottom`,iI=`none`;function aI(e,t,n){return typeof e==`number`?n===$F&&t===nI||n===eI&&t===rI?e:0:n===$F?t===nI?e.main:e.reverse:t===rI?e.main:e.reverse}function oI(e,t){return typeof e==`number`?e:e[t]??0}var sI=YP(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=qP(),o=Q(0),s=Q(0),c=Q(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:KP(Z(XP(ZP(r),ZP(i),ZP(n),ZP(a,jF),ZP(c),ZP(o),ZP(t),ZP(e),ZP(s)),BP(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=iI,m=oI(l,nI),h=oI(l,rI);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=$F),i<e-f+t+h&&(p=eI),p===iI?null:[Math.max(u-n-aI(a,nI,p)-m,0),u-f-s+t+aI(a,rI,p)+h]}),zP(e=>e!==null),RP(jF)),[0,0])}},kP(lF),{singleton:!0});function Cne(e,t,n){if(IF(t)){let r=zF(e,t);return[{index:mF(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var cI={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function lI(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:dI(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:dI(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function uI(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=YF(t,s);return lI(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function dI(e,t,n){if(e.length===0)return[];if(!IF(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=_F(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function fI(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var pI=YP(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=Q([]),g=Q(0),_=qP(),v=Q(0);PP(a.topItemsIndexes,h);let y=KP(Z(XP(p,m,ZP(c,jF),ZP(i),ZP(r),ZP(l),u,ZP(h),ZP(t),ZP(n),ZP(v),e),zP(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),BP(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=NP(g);if(n===0)return{...cI,totalCount:n};if(e===0&&t===0)return m===0?{...cI,totalCount:n}:uI(m,i,r,s,c,u||[]);if(fF(p))return m>0?null:lI(Cne(YF(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of _F(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return lI([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=dne(f,e,t,_);if(v.length===0)return null;let y=n-1,b=DP([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<_&&(a+=(_-o)*s,o=_);let l=Math.min(r.end,y);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=fI(l,nI),S=fI(l,rI);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=_F(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.index<y){let e=Math.min(S,y-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=_F(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return lI(b,h,n,c,d,s)}),zP(e=>e!==null),RP()),cI);PP(Z(e,zP(wP),BP(e=>e?.length)),i),PP(Z(y,BP(e=>e.topListHeight)),d),PP(d,s),PP(Z(y,BP(e=>[e.top,e.bottom])),o),PP(Z(y,BP(e=>e.items)),_);let b=JP(Z(y,zP(({items:e})=>e.length>0),GP(i,e),zP(([{items:e},t])=>e[e.length-1].originalIndex===t-1),BP(([,e,t])=>[e-1,t]),RP(jF),BP(([e])=>e))),x=JP(Z(y,WP(200),zP(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),BP(({items:e})=>e[0].index),RP()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:JP(Z(y,zP(({items:e})=>e.length>0),BP(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),RP(AF))),startReached:x,topItemsIndexes:h,...f}},kP(UF,WF,sI,ZF,qF,tI,GF,MF),{singleton:!0}),mI=YP(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=qP(),o=KP(Z(XP(n,e,r,t,i),BP(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return PP(ZP(o),a),{totalListHeight:o,totalListHeightChanged:a}},kP(lF,pI),{singleton:!0}),wne=YP(([{viewportHeight:e},{totalListHeight:t}])=>{let n=Q(!1);return{alignToBottom:n,paddingTopAddition:KP(Z(XP(n,e,t),zP(([e])=>e),BP(([,e,t])=>Math.max(0,e-t)),WP(0),RP()),0)}},kP(lF,mI),{singleton:!0}),hI=YP(()=>({context:Q(null)})),Tne=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,gI=YP(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=qP();return PP(Z(u,GP(t,c,n,a,i,r,s),GP(e),BP(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=Tne,done:d,...f}=e,p=BF(e,t,r-1),m=RF(p,t.offsetTree,l)+i+a,h=m+mF(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&FP(Z(o,zP(e=>!e),UP(NP(o)?1:2)),d),_}),zP(e=>e!==null)),l),{scrollIntoView:u}},kP(UF,lF,qF,pI,eF),{singleton:!0});function _I(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Ene=(e,t)=>typeof e==`function`?_I(e(t)):t&&_I(e),Dne=YP(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=Q(!1),h=qP(),g=null;function _(e){jP(o,{align:`end`,behavior:e,index:`LAST`})}AP(Z(XP(Z(ZP(t),UP(1)),c),GP(ZP(m),a,s,d),BP(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Ene(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),zP(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),NP(n)===void 0?g=FP(e,()=>{NP(u)(`following output to `,{totalCount:r},$P.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{NP(u)(`following output to `,{totalCount:r},$P.DEBUG),_(t)})});function v(e){let t=FP(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(NP(u)(`scrolling to bottom due to increased size`,{},$P.DEBUG),_(`auto`))});setTimeout(t,100)}AP(Z(XP(ZP(m),t,l),zP(([e,,t])=>e!==!1&&t),HP(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),zP(({refreshed:e})=>e),GP(m,t)),([,e])=>{NP(s)&&v(e!==!1)}),AP(h,()=>{v(NP(m)!==!1)}),AP(XP(ZP(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=Q(null),b=qP();return PP(QP(Z(ZP(r),BP(e=>e?.length??0)),Z(ZP(t))),b),AP(Z(XP(Z(b,UP(1)),c),GP(ZP(y),s,d,f),BP(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),zP(e=>!!e),WP(0)),t=>{g!==null&&(g(),g=null),NP(n)===void 0?g=FP(e,()=>{NP(u)(`scrolling into view`,{}),jP(p,t),g=null}):requestAnimationFrame(()=>{NP(u)(`scrolling into view`,{}),jP(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},kP(UF,tI,qF,ZF,GF,eF,lF,hI,gI)),One=YP(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(PP(Z(s,GP(a),zP(([,e])=>e!==0),GP(i,r,t,n,e),BP(([[,e],t,n,r,i,a=[]])=>uI(e,t,n,r,i,a))),o),{}),kP(UF,ZF,pI,GF),{singleton:!0}),kne=YP(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=Q(0);return AP(Z(e,GP(r),zP(([,e])=>e!==0),BP(([,e])=>({top:e}))),e=>{FP(Z(n,UP(1),zP(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{jP(t,e)})})}),{initialScrollTop:r}},kP(GF,lF,pI),{singleton:!0}),vI=YP(([{scrollVelocity:e}])=>{let t=Q(!1),n=qP(),r=Q(!1);return PP(Z(e,GP(r,t,n),zP(([e,t])=>t!==!1&&t!==void 0),BP(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),RP()),t),AP(Z(XP(t,e,n),GP(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},kP(tI),{singleton:!0}),yI=YP(([{scrollContainerState:e,scrollTo:t}])=>{let n=qP(),r=qP(),i=qP(),a=Q(!1),o=Q(void 0);return PP(Z(XP(n,r),BP(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),PP(Z(t,GP(r),BP(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},kP(lF)),Ane=YP(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=qP(),u=Q(void 0),d=Q(null),f=Q(null);return PP(s,d),PP(c,f),AP(Z(l,GP(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=pne(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),PP(Z(u,zP(wP),BP(jne)),i),PP(Z(a,GP(u),zP(([,e])=>e!==void 0),RP(),BP(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},kP(UF,lF,ZF,GF,yI));function jne(e){return{align:`start`,index:0,offset:e.scrollTop}}var Mne=YP(([{topItemsIndexes:e}])=>{let t=Q(0);return PP(Z(t,zP(e=>e>=0),BP(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},kP(pI));function bI(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var Nne=bI(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),xI=YP(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:k,...A}=b;return PP(k,T.scrollSeekRangeChanged),PP(Z(XP(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),BP(([e,t,n])=>Math.max(t+n+1,e.visibleHeight))),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:k,...A,...T,..._,sizes:u,...v}},kP(UF,ZF,lF,Ane,Dne,pI,qF,YP(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=JP(Z(c,GP(o),HP(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),zP(([e])=>e!==0),GP(r,s,n,i,p,m),zP(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===$F),BP(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},$P.DEBUG),e))));function g(n){n>0?(jP(t,{behavior:`auto`,top:-n}),jP(e,0)):(jP(e,0),jP(t,{behavior:`auto`,top:-n}))}return AP(Z(h,GP(e,a)),([t,n,r])=>{r&&Nne()?jP(e,n-t):g(-t)}),AP(Z(XP(KP(a,!1),e,m),zP(([e,t,n])=>!e&&!n&&t!==0),BP(([e,t])=>t),WP(1)),g),PP(Z(d,BP(e=>({top:-e}))),t),AP(Z(l,GP(f,u),BP(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=pF(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{jP(e,n),requestAnimationFrame(()=>{jP(t,{top:n}),requestAnimationFrame(()=>{jP(e,0),jP(m,!1)})})}),{deviation:e}},kP(lF,tI,pI,UF,eF,MF)),Mne,WF,YP(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),kP(sI,One,GF,vI,mI,kne,wne,yI,gI,eF,hI))));function Pne(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var SI=typeof document>`u`?U.useEffect:U.useLayoutEffect;function CI(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=U.createContext({});function c(e,n){e.propsReady!==void 0&&jP(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];jP(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];jP(i,n[r])}e.propsReady!==void 0&&jP(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];jP(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=Zte(e[t.events[r]]),n),{})}return{Component:U.forwardRef(function(t,a){let{children:d,...f}=t,[p]=U.useState(()=>DP(ene(e),e=>{c(e,f)})),[m]=U.useState(SP(u,p));SI(()=>{for(let e of o)e in f&&AP(m[e],f[e]);return()=>{Object.values(m).map(MP)}},[f,m,p]),SI(()=>{c(p,f)}),U.useImperativeHandle(a,yP(l(p)));let h=n;return(0,K.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,K.jsx)(h,{...Pne([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=U.useContext(s)[e];SI(()=>AP(n,t),[t,n])},useEmitterValue:e=>{let t=U.useContext(s)[e],n=U.useCallback(e=>AP(t,e),[t]);return U.useSyncExternalStore(n,()=>NP(t),()=>NP(t))},usePublisher:e=>{let t=U.useContext(s);return U.useCallback(n=>{jP(t[e],n)},[t,e])}}}var wI=U.createContext(void 0),TI=U.createContext(void 0),EI=`-webkit-sticky`,DI=`sticky`,OI=bI(()=>{if(typeof document>`u`)return DI;let e=document.createElement(`div`);return e.style.position=EI,e.style.position===EI?EI:DI}),kI=typeof document>`u`?U.useEffect:U.useLayoutEffect;function AI(e){return`self`in e}function jI(e){return`body`in e}function MI(e,t,n,r=EP,i,a){let o=U.useRef(null),s=U.useRef(null),c=U.useRef(null),l=U.useCallback(n=>{let r,i,o,l=n.target;if(jI(l)||AI(l)){let e=AI(l)?l:l.defaultView;o=a===!0?nF(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?nF(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():Gs.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);U.useEffect(()=>{let e=i??o.current;return r(i??o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;AI(r)?(u=Math.max(FF(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?nF(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=FF(r,a===!0?`width`:`height`),d=a===!0?nF(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,QF(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:rF(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:rF(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function NI(e){return e}var PI=YP(([e,t])=>({...e,...t}),kP(xI,YP(()=>{let e=Q(e=>`Item ${e}`),t=Q(e=>`Group ${e}`),n=Q({}),r=Q(NI),i=Q(`div`),a=Q(EP),o=(e,t=null)=>KP(Z(n,BP(t=>t[e]),RP()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),FI=({height:e})=>(0,K.jsx)(`div`,{style:{height:e}}),II={overflowAnchor:`none`,position:OI(),zIndex:1},LI={overflowAnchor:`none`},RI={...LI,display:`inline-block`,height:`100%`},zI=U.memo(function({showTopList:e=!1}){let t=nL(`listState`),n=rL(`sizeRanges`),r=nL(`useWindowScroll`),i=nL(`customScrollParent`),a=rL(`windowScrollContainerState`),o=rL(`scrollContainerState`),s=i||r?a:o,c=nL(`itemContent`),l=nL(`context`),u=nL(`groupContent`),d=nL(`trackItemSizes`),f=nL(`itemSize`),p=nL(`log`),m=rL(`gap`),h=nL(`horizontalDirection`),{callbackRef:g}=oF(n,f,d,e?EP:s,p,m,i,h,nL(`skipAnimationFrameInResizeObserver`)),[_,v]=U.useState(0);tL(`deviation`,e=>{_!==e&&v(e)});let y=nL(`EmptyPlaceholder`),b=nL(`ScrollSeekPlaceholder`)??FI,x=nL(`ListComponent`),S=nL(`ItemComponent`),C=nL(`GroupComponent`),w=nL(`computeItemKey`),T=nL(`isSeeking`),E=nL(`groupIndices`).length>0,D=nL(`alignToBottom`),O=nL(`initialItemFinalLocationReached`),k=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?D?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?D?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...O?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&y!=null?(0,K.jsx)(y,{...GI(y,l)}):(0,K.jsx)(x,{...GI(x,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:k,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=w(n+t.firstItemIndex,e.data,l);return T?(0,U.createElement)(b,{...GI(b,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,U.createElement)(C,{...GI(C,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:II},u(e.index,l)):(0,U.createElement)(S,{...GI(S,l),...KI(S,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?RI:LI},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),BI={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},VI={outline:`none`,overflowX:`auto`,position:`relative`},HI=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),UI=(e,t,n=0)=>({...HI(e),position:t?`relative`:`absolute`,top:t?-n:0}),WI={position:OI(),top:0,width:`100%`,zIndex:1};function GI(e,t){if(typeof e!=`string`)return{context:t}}function KI(e,t){return{item:typeof e==`string`?void 0:t}}var qI=U.memo(function(){let e=nL(`HeaderComponent`),t=rL(`headerHeight`),n=nL(`HeaderFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,nL(`skipAnimationFrameInResizeObserver`)),i=nL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})}),JI=U.memo(function(){let e=nL(`FooterComponent`),t=rL(`footerHeight`),n=nL(`HeaderFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,nL(`skipAnimationFrameInResizeObserver`)),i=nL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})});function YI({useEmitter:e,useEmitterValue:t,usePublisher:n}){return U.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=MI(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,K.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?VI:BI,...i},tabIndex:0,...o,...GI(c,a),children:r})})}function XI({useEmitter:e,useEmitterValue:t,usePublisher:n}){return U.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=U.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=MI(s,l,c,t(`scrollerRef`),f);return kI(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,K.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...GI(c,a),children:r})})}var ZI=({children:e})=>{let t=U.useContext(wI),n=rL(`viewportHeight`),r=rL(`fixedItemHeight`),i=nL(`alignToBottom`),a=nL(`horizontalDirection`),o=iF(U.useMemo(()=>xP(n,e=>FF(e,a?`width`:`height`)),[n,a]),!0,nL(`skipAnimationFrameInResizeObserver`));return U.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:HI(i),children:e})},QI=({children:e})=>{let t=U.useContext(wI),n=rL(`windowViewportRect`),r=rL(`fixedItemHeight`),i=nL(`customScrollParent`),a=nL(`useWindowScroll`),o=nL(`topListHeight`),s=cF(n,i,nL(`skipAnimationFrameInResizeObserver`)),c=nL(`alignToBottom`);return U.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:UI(c,a,o),children:e})},$I=({children:e})=>{let t=nL(`TopItemListComponent`)??`div`,n=nL(`headerHeight`),r={...WI,marginTop:`${n}px`},i=nL(`context`);return(0,K.jsx)(t,{style:r,...GI(t,i),children:e})},{Component:eL,useEmitter:tL,useEmitterValue:nL,usePublisher:rL}=CI(PI,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},U.memo(function(e){let t=nL(`useWindowScroll`),n=nL(`topItemsIndexes`).length>0,r=nL(`customScrollParent`),i=nL(`context`);return(0,K.jsxs)(r||t?aL:iL,{...e,context:i,children:[n&&(0,K.jsx)($I,{children:(0,K.jsx)(zI,{showTopList:!0})}),(0,K.jsxs)(r||t?QI:ZI,{children:[(0,K.jsx)(qI,{}),(0,K.jsx)(zI,{}),(0,K.jsx)(JI,{})]})]})})),iL=YI({useEmitter:tL,useEmitterValue:nL,usePublisher:rL}),aL=XI({useEmitter:tL,useEmitterValue:nL,usePublisher:rL}),oL=eL,sL=YP(([e,t])=>({...e,...t}),kP(xI,YP(()=>{let e=Q(e=>(0,K.jsxs)(`td`,{children:[`Item $`,e]})),t=Q(null),n=Q(e=>(0,K.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=Q(null),i=Q(null),a=Q({}),o=Q(NI),s=Q(EP),c=(e,t=null)=>KP(Z(a,BP(t=>t[e]),RP()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),cL=({height:e})=>(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{style:{height:e}})}),lL=({height:e})=>(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),uL={overflowAnchor:`none`},dL={position:OI(),zIndex:2,overflowAnchor:`none`},fL=U.memo(function({showTopList:e=!1}){let t=_L(`listState`),n=_L(`computeItemKey`),r=_L(`firstItemIndex`),i=_L(`context`),a=_L(`isSeeking`),o=_L(`fixedHeaderHeight`),s=_L(`groupIndices`).length>0,c=_L(`itemContent`),l=_L(`groupContent`),u=_L(`ScrollSeekPlaceholder`)??cL,d=_L(`GroupComponent`),f=_L(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,U.createElement)(u,{...GI(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,U.createElement)(d,{...GI(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...dL,top:o}},l(t.index,i)):(0,U.createElement)(f,{...GI(f,i),...KI(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...dL,top:o+g}:uL},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),pL=U.memo(function(){let e=_L(`listState`),t=_L(`topItemsIndexes`).length>0,n=vL(`sizeRanges`),r=_L(`useWindowScroll`),i=_L(`customScrollParent`),a=vL(`windowScrollContainerState`),o=vL(`scrollContainerState`),s=i||r?a:o,c=_L(`trackItemSizes`),{callbackRef:l,ref:u}=oF(n,_L(`itemSize`),c,s,_L(`log`),void 0,i,!1,_L(`skipAnimationFrameInResizeObserver`)),[d,f]=U.useState(0);gL(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=_L(`EmptyPlaceholder`),m=_L(`FillerRow`)??lL,h=_L(`TableBodyComponent`),g=_L(`paddingTopAddition`),_=_L(`statefulTotalCount`),v=_L(`context`);if(_===0&&p!=null)return(0,K.jsx)(p,{...GI(p,v)});let y=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),b=e.offsetTop+g+d-y,x=e.offsetBottom,S=b>0?(0,K.jsx)(m,{context:v,height:b},`padding-top`):null,C=x>0?(0,K.jsx)(m,{context:v,height:x},`padding-bottom`):null;return(0,K.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...GI(h,v),children:[S,t&&(0,K.jsx)(fL,{showTopList:!0}),(0,K.jsx)(fL,{}),C]})}),mL=({children:e})=>{let t=U.useContext(wI),n=vL(`viewportHeight`),r=vL(`fixedItemHeight`),i=iF(U.useMemo(()=>xP(n,e=>FF(e,`height`)),[n]),!0,_L(`skipAnimationFrameInResizeObserver`));return U.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:HI(!1),children:e})},hL=({children:e})=>{let t=U.useContext(wI),n=vL(`windowViewportRect`),r=vL(`fixedItemHeight`),i=_L(`customScrollParent`),a=_L(`useWindowScroll`),o=cF(n,i,_L(`skipAnimationFrameInResizeObserver`));return U.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:UI(!1,a),children:e})},{Component:Fne,useEmitter:gL,useEmitterValue:_L,usePublisher:vL}=CI(sL,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},U.memo(function(e){let t=_L(`useWindowScroll`),n=_L(`customScrollParent`),r=vL(`fixedHeaderHeight`),i=vL(`fixedFooterHeight`),a=_L(`fixedHeaderContent`),o=_L(`fixedFooterContent`),s=_L(`context`),c=iF(U.useMemo(()=>xP(r,e=>FF(e,`height`)),[r]),!0,_L(`skipAnimationFrameInResizeObserver`)),l=iF(U.useMemo(()=>xP(i,e=>FF(e,`height`)),[i]),!0,_L(`skipAnimationFrameInResizeObserver`)),u=n||t?bL:yL,d=n||t?hL:mL,f=_L(`TableComponent`),p=_L(`TableHeadComponent`),m=_L(`TableFooterComponent`),h=a?(0,K.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...GI(p,s),children:a()},`TableHead`):null,g=o?(0,K.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...GI(m,s),children:o()},`TableFoot`):null;return(0,K.jsx)(u,{...e,...GI(u,s),children:(0,K.jsx)(d,{children:(0,K.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...GI(f,s),children:[h,(0,K.jsx)(pL,{},`TableBody`),g]})})})})),yL=YI({useEmitter:gL,useEmitterValue:_L,usePublisher:vL}),bL=XI({useEmitter:gL,useEmitterValue:_L,usePublisher:vL}),xL={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},SL={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:CL,floor:wL,max:TL,min:EL,round:DL}=Math;function OL(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function kL(e){return{...SL,items:e}}function AL(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function jL(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var ML=YP(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=Q(0),C=Q(0),w=Q(xL),T=Q({height:0,width:0}),E=Q({height:0,width:0}),D=qP(),O=qP(),k=Q(0),A=Q(null),j=Q({column:0,row:0}),M=qP(),N=qP(),P=Q(!1),F=Q(0),I=Q(!0),L=Q(!1),R=Q(!1);AP(Z(m,GP(F),zP(([e,t])=>!XF(t))),()=>{jP(I,!1)}),AP(Z(XP(m,I,E,T,F,L),zP(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){jP(I,!0);return}jP(L,!0),JF(1,()=>{jP(D,e)}),FP(Z(l),()=>{jP(t,[0,0]),jP(I,!0)})}),PP(Z(N,zP(e=>e!=null&&e.scrollTop>0),VP(0)),C),AP(Z(m,GP(N),zP(([,e])=>e!=null)),([,e])=>{e&&(jP(T,e.viewport),jP(E,e.item),jP(j,e.gap),e.scrollTop>0&&(jP(P,!0),FP(Z(l,UP(1)),e=>{jP(P,!1)}),jP(c,{top:e.scrollTop})))}),PP(Z(T,BP(({height:e})=>e)),d),PP(Z(XP(ZP(T,AL),ZP(E,AL),ZP(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),ZP(l)),BP(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),PP(Z(XP(ZP(S),r,ZP(j,jL),ZP(E,AL),ZP(T,AL),ZP(A),ZP(C),ZP(P),ZP(I),ZP(F)),zP(([,,,,,,,e])=>!e),BP(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return xL;if(p===0){let t=YF(l,e);return kL(OL(t,t+Math.max(s-1,0),o))}let h=NL(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*wL((t+d)/(f+d)),_=h*CL((n+d)/(f+d))-1,_=EL(e-1,TL(_,h-1)),g=EL(_,TL(0,g))):(g=0,_=-1);let v=OL(g,_,o),{bottom:y,top:b}=PL(a,r,i,v),x=CL(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),PP(Z(A,zP(e=>e!==null),BP(e=>e.length)),S),PP(Z(XP(T,E,w,j),zP(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),BP(([e,t,{items:n},r])=>{let{bottom:i,top:a}=PL(e,r,t,n);return[a,i]}),RP(jF)),t);let ee=Q(!1);PP(Z(l,GP(ee),BP(([e,t])=>t||e!==0)),ee);let z=JP(Z(XP(w,S),zP(([{items:e}])=>e.length>0),GP(ee),zP(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),BP(([[,e]])=>e-1),RP())),B=JP(Z(ZP(w),zP(({items:e})=>e.length>0&&e[0].index===0),VP(0),RP())),V=JP(Z(ZP(w),GP(P),zP(([{items:e},t])=>e.length>0&&!t),BP(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),RP(AF),WP(0)));PP(V,p.scrollSeekRangeChanged),PP(Z(D,GP(T,E,S,j),BP(([e,t,n,r,i])=>{let a=KF(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=TL(0,l,EL(r-1,l));let u=FL(t,i,n,l);return o===`end`?u=DL(u-t.height+n.height):o===`center`&&(u=DL(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let te=KP(Z(w,BP(e=>e.offsetBottom+e.bottom)),0);return PP(Z(b,BP(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:A,deviation:k,footerHeight:i,gap:j,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:N,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:R,initialTopMostItemIndex:F,totalListHeight:te,...f,endReached:z,propsReady:h,rangeChanged:V,startReached:B,stateChanged:M,stateRestoreInProgress:P,...x}},kP(sI,lF,tI,vI,GF,yI,eF));function NL(e,t,n){return TL(1,wL((e+n)/(wL(t)+n)))}function PL(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=FL(e,t,n,r[0].index);return{bottom:FL(e,t,n,r[r.length-1].index)+i,top:a}}function FL(e,t,n,r){let i=wL(r/NL(e.width,n.width,t.column)),a=i*n.height+TL(0,i-1)*t.row;return a>0?a+t.row:a}var IL=YP(([e,t])=>({...e,...t}),kP(ML,YP(()=>{let e=Q(e=>`Item ${e}`),t=Q({}),n=Q(null),r=Q(`virtuoso-grid-item`),i=Q(`virtuoso-grid-list`),a=Q(NI),o=Q(`div`),s=Q(EP),c=(e,n=null)=>KP(Z(t,BP(t=>t[e]),RP()),n),l=Q(!1),u=Q(!1);return PP(ZP(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),LL=U.memo(function(){let e=UL(`gridState`),t=UL(`listClassName`),n=UL(`itemClassName`),r=UL(`itemContent`),i=UL(`computeItemKey`),a=UL(`isSeeking`),o=WL(`scrollHeight`),s=UL(`ItemComponent`),c=UL(`ListComponent`),l=UL(`ScrollSeekPlaceholder`),u=UL(`context`),d=WL(`itemDimensions`),f=WL(`gap`),p=UL(`log`),m=UL(`stateRestoreInProgress`),h=WL(`reportReadyState`),g=iF(U.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:qL(`column-gap`,getComputedStyle(e).columnGap,p),row:qL(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return kI(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,K.jsx)(c,{className:t,ref:g,...GI(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,K.jsx)(l,{...GI(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,U.createElement)(s,{...GI(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),RL=U.memo(function(){let e=UL(`HeaderComponent`),t=WL(`headerHeight`),n=UL(`headerFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,!1),i=UL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})}),zL=U.memo(function(){let e=UL(`FooterComponent`),t=WL(`footerHeight`),n=UL(`headerFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,!1),i=UL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})}),BL=({children:e})=>{let t=U.useContext(TI),n=WL(`itemDimensions`),r=WL(`viewportDimensions`),i=iF(U.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return U.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,K.jsx)(`div`,{ref:i,style:HI(!1),children:e})},VL=({children:e})=>{let t=U.useContext(TI),n=WL(`windowViewportRect`),r=WL(`itemDimensions`),i=UL(`customScrollParent`),a=UL(`useWindowScroll`),o=cF(n,i,!1);return U.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,K.jsx)(`div`,{ref:o,style:UI(!1,a),children:e})},{Component:Ine,useEmitter:HL,useEmitterValue:UL,usePublisher:WL}=CI(IL,{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`}},U.memo(function({...e}){let t=UL(`useWindowScroll`),n=UL(`customScrollParent`),r=n||t?KL:GL,i=n||t?VL:BL,a=UL(`context`);return(0,K.jsx)(r,{...e,...GI(r,a),children:(0,K.jsxs)(i,{children:[(0,K.jsx)(RL,{}),(0,K.jsx)(LL,{}),(0,K.jsx)(zL,{})]})})})),GL=YI({useEmitter:HL,useEmitterValue:UL,usePublisher:WL}),KL=XI({useEmitter:HL,useEmitterValue:UL,usePublisher:WL});function qL(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,$P.WARN),t===`normal`?0:parseInt(t??`0`,10)}function JL({name:e,color:t}){return(0,K.jsx)(Fo,{name:e,variant:`beam`,colors:ro(t),size:`100%`,className:`absolute inset-0 h-full w-full`})}var YL=2e3,XL=6e4;function ZL(){let e=globalThis[c];return typeof e==`string`?e:null}function QL(e,t,n){let r=YL,i=!1,a,o=()=>{t(e).then(e=>{if(!i){if(e)return n();r=Math.min(r*2,XL),a=setTimeout(o,r)}})};return a=setTimeout(o,r),()=>{i=!0,clearTimeout(a)}}var $L=e=>new Promise(t=>{let n=new Image;n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e});function eR(e){let t=ZL();!t||typeof caches>`u`||je(caches,t,e).catch(()=>{})}var tR=`#7c5cff`;function nR({name:e,color:t,image:n,className:r,enso:i}){let[a,o]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!(!n||a!==n||!ZL()))return QL(n,$L,()=>o(null))},[a,n]),n&&a!==n?(0,K.jsx)(`img`,{"data-enso":i,"data-image":`true`,src:n,alt:``,draggable:!1,onError:()=>o(n),className:G(`object-cover`,r),style:t?{backgroundColor:t}:void 0}):(0,K.jsx)(`span`,{"data-enso":i,"data-generated":`true`,className:G(`relative block shrink-0 overflow-hidden`,r),children:(0,K.jsx)(JL,{name:e.trim()||`secretary`,color:t??tR})})}var rR={xs:`size-6 rounded-[8px] text-[11.5px]`,sm:`size-[22px] rounded-[7px] text-[11.5px]`,md:`size-7 rounded-[9px] text-[13px]`,lg:`size-11 rounded-[13px] text-base`};function iR({name:e,color:t,image:n,needsYou:r,running:i,size:a=`md`,enso:o=`secretary-avatar`}){let s=r>0?`warn`:i>0?`run`:null;return(0,K.jsxs)(`span`,{"data-enso":o,"data-image":n?`true`:void 0,className:G(`relative flex shrink-0`,rR[a]),children:[(0,K.jsx)(nR,{name:e,color:t,image:n,enso:`${o}-face`,className:`size-full overflow-hidden rounded-[inherit]`}),s&&(0,K.jsx)(`span`,{"data-enso":`secretary-pip`,"data-tone":s,className:G(`absolute -top-1 -right-1 size-2.5 rounded-full border-2 border-background`,s===`warn`?`bg-warning`:`bg-success`)})]})}function aR(e){return[...e.running,...e.needsYou,...e.done]}function oR(e,t,n){if(n?.secretaryId)return{secretaryId:n.secretaryId};for(let[n,r]of Object.entries(e)){if(r.secretaryId&&r.secretaryId!==n)continue;let e=aR(r.board).find(e=>e.kind===`session`&&e.conversationId===t&&!e.takeover);if(e?.kind===`session`)return{secretaryId:n,secretaryConversationId:e.secretaryConversationId}}for(let[n,r]of Object.entries(e))if(!(r.secretaryId&&r.secretaryId!==n)&&r.takeovers.some(e=>e.conversationId===t))return{secretaryId:n};return null}var sR=e=>e===`oauth-credentials-unloaded`||e===`oauth-credentials-loading`||e===`oauth-credentials-error`;function cR(e){switch(e.oauthCredentials.status){case`unloaded`:return{reason:`oauth-credentials-unloaded`,suggestedAction:`load-oauth-credentials`};case`loading`:return{reason:`oauth-credentials-loading`,suggestedAction:`wait-for-oauth-credentials`};case`error`:return{reason:`oauth-credentials-error`,suggestedAction:`retry-oauth-credentials`,credentialError:e.oauthCredentials.error};case`ready`:return null}}function lR(e,t,n,r){if(!e)return`missing-selection`;if(bj(e)){if(!r)return`provider-missing`;let i=xj(r,e);return i?i.enabled?lR(i.primary,t,n):`model-disabled`:`model-missing`}let i=t.find(t=>t.id===e.providerId);if(!i)return`provider-missing`;if(!i.enabled)return`provider-disabled`;if(_e(i))return`classifier-only`;let a=i.models.find(t=>t.id===e.modelId);return a?a.enabled===!1?`model-disabled`:i.oauthAccountPool!==void 0&&!O(i)?`oauth-account-missing`:i.oauthAccountKey?n.oauthCredentials.status===`ready`?O(i)?u(i,e.modelId,t,n.oauthCredentials.authenticatedAccountKeys).length>0?`usable`:`oauth-account-missing`:n.oauthCredentials.authenticatedAccountKeys.has(i.oauthAccountKey)?`usable`:`oauth-account-missing`:cR(n)?.reason??`oauth-credentials-error`:i.apiKey?`usable`:`api-key-missing`:`model-missing`}function uR(e,t){let n=e?.groupId?t.find(t=>t.id===e.groupId):void 0;return{projectDefaultModel:e?.defaultModel??null,groupDefaultModel:n?.defaultModel??null,projectReasoningEnabled:e?.defaultReasoningEnabled,projectThinkingLevel:e?.defaultThinkingLevel,groupReasoningEnabled:n?.defaultReasoningEnabled,groupThinkingLevel:n?.defaultThinkingLevel}}function dR(e){let t=lR(e.defaultModel,e.providers,e.credentials,e.virtualModels),n=e.defaultModel!==null&&t!==`usable`&&!sR(t),r=[{selection:e.lastProviderId&&e.lastModelId?{providerId:e.lastProviderId,modelId:e.lastModelId}:null,source:`session`},{selection:e.projectDefaultModel??null,source:`project`},{selection:e.groupDefaultModel??null,source:`group`},{selection:e.defaultModel,source:`default`}];for(let t of r){let r=lR(t.selection,e.providers,e.credentials,e.virtualModels);if(r===`usable`&&t.selection)return{...t.selection,source:t.source,invalidDefault:t.source!=="default"&&n};if(sR(r)){let t=cR(e.credentials);if(t)return{providerId:null,modelId:null,source:`none`,invalidDefault:n,...t}}}return{providerId:null,modelId:null,source:`none`,invalidDefault:n,...(sR(t)?cR(e.credentials):null)??{reason:`no-usable-model`}}}var fR={revision:0,availability:{status:`unloaded`}},pR=EN(()=>({snapshot:fR}));function mR(e){return{oauthCredentials:e.availability}}var hR=EN(()=>({snapshot:void 0}));function gR(){return wj(E.getState().providers,hR.getState().snapshot)}function _R(e){new Set(e)}function vR(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var yR=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return yR(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return yR(t)(e)}}}},bR=(e,t)=>(n,r,i)=>{let a={storage:vR(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return yR(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},xR=e=>{if(typeof e!=`string`||!e.startsWith(`plugin:`))return!1;let t=e.indexOf(`:`,7);return t>7&&t<e.length-1};function SR(e,t,n){if(!t)return!1;let r=e.uiByConversation[t]?.open;return r===void 0?!n&&e.liveGlobalTabs.length>0:r}function CR(e){let t=Array.isArray(e.globalTabs)?e.globalTabs.filter(xR):[],n=e.globalScopeOverrides,r={};if(n&&typeof n==`object`&&!Array.isArray(n))for(let[e,t]of Object.entries(n))xR(e)&&(t===`global`||t===`session`)&&(r[e]=t);return{globalTabs:[...new Set(t)],globalScopeOverrides:r}}function wR(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function TR(e,t){if(wR(e)){if(e.type===`leaf`){let n=wR(e.data)?e.data:void 0,r=Array.isArray(n?.views)?n.views.filter(e=>typeof e==`string`&&t.has(e)):[];if(r.length===0)return;let i=n?.views,a=i.indexOf(n?.activeView),o=typeof n?.activeView==`string`&&t.has(n.activeView)?n.activeView:[...i.slice(0,Math.max(a,0)).reverse(),...i.slice(a+1)].find(e=>typeof e==`string`&&t.has(e))??r[0];return{type:`leaf`,data:{...n,views:r,activeView:o},size:e.size}}if(e.type===`branch`){let n=Array.isArray(e.data)?e.data.flatMap(e=>{let n=TR(e,t);return n?[n]:[]}):[];return n.length===0?void 0:{type:`branch`,data:n,size:e.size}}}}function ER(e,t){return!e||!wR(e.panels)||!(t in e.panels)?e:DR(e,e=>e!==t)}function DR(e,t){if(!wR(e)||!wR(e.panels))return;let n={};for(let[r,i]of Object.entries(e.panels))t(r,i)&&(n[r]=i);let r=new Set(Object.keys(n));if(r.size===0)return;let i=wR(e.grid)?e.grid:void 0,a=i?TR(i.root,r):void 0;if(a)return{...e,panels:n,grid:{...i,root:a}}}var OR=4,kR=e=>{if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null};function AR(e){if(!kR(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!kR(r))continue;let e={};for(let[t,n]of Object.entries(r))typeof n==`string`&&(e[t]=n);Object.keys(e).length>0&&(t[n]=e)}return t}function jR(e,t){let n=kR(e)?e:{};if(t<2)return{state:{uiByConversation:{},layouts:{}},snapshots:{}};if(t<OR)return{state:{uiByConversation:t<3?{}:n.uiByConversation??{},layouts:n.layouts??{},changesModeByConversation:n.changesModeByConversation??{}},snapshots:AR(n.snapshotsByConversation)};let{snapshotsByConversation:r,...i}=n;return{state:i,snapshots:{}}}function MR(e,t){let{state:n,snapshots:r}=jR(e,t);return{state:{...n,...CR(n)},snapshots:r}}function NR(e){return typeof e!=`number`||!Number.isFinite(e)?224:Math.min(480,Math.max(160,e))}function PR(e,t){let n=NR(e);if(t<=0)return n;let r=Math.max(224,t-240-1);return Math.min(n,r)}function FR(e,t,n){let r=PR(e,n),i=PR(r+t,n);return i===r?NR(e):i}function IR(e,t,n=1){let r=Math.max(280,e);if(t<=0)return r;let i=Math.max(0,t-360-n);return Math.min(i,r)}function LR(e,t,n,r=1){let i=IR(e,n,r),a=IR(i+t,n,r);return a===i?e:a}function RR(){return nP.getState().activeId??void 0}function zR(e,t){return e.uiByConversation[t]??{width:e.lastWidth}}function BR(e,t){return SR(e,t,DD())}function VR(e,t,n){return{...e.fullscreenByConversation,[t]:n}}function HR(e,t,n){return{...e.uiByConversation,[t]:{...zR(e,t),...n}}}var UR=EN()(bR((e,t)=>({fullscreen:!1,fullscreenByConversation:{},lastWidth:360,filesTreeWidth:224,uiByConversation:{},browserHoles:{},layouts:{},pinnedTabs:[],globalTabs:[],globalScopeOverrides:{},liveGlobalTabs:[],changesModeByConversation:{},snapshotsByConversation:{},toggleOpen:()=>{let n=RR();if(!n)return;let r=!BR(t(),n);e({uiByConversation:HR(t(),n,{open:r}),fullscreen:r?t().fullscreen:!1,fullscreenByConversation:VR(t(),n,r?t().fullscreen:!1)})},reconcileForActiveConversation:()=>{let n=RR(),r=n?t().fullscreenByConversation[n]??!1:!1;r!==t().fullscreen&&e({fullscreen:r})},ensureOpen:n=>{let r=n??RR();!r||zR(t(),r).open||e({uiByConversation:HR(t(),r,{open:!0})})},nudgeWidth:(n,r,i)=>{let a=RR();if(!a)return;let o=LR(zR(t(),a).width,n,r,i);e({uiByConversation:HR(t(),a,{width:o}),lastWidth:o})},nudgeFilesTreeWidth:(n,r=0)=>{let i=FR(t().filesTreeWidth,n,r);i!==t().filesTreeWidth&&e({filesTreeWidth:i})},resetFilesTreeWidth:()=>e({filesTreeWidth:224}),toggleFullscreen:()=>{let n=RR();if(!n)return;let{fullscreen:r}=t();if(!BR(t(),n)){e({uiByConversation:HR(t(),n,{open:!0}),fullscreen:!0,fullscreenByConversation:VR(t(),n,!0)});return}e({fullscreen:!r,fullscreenByConversation:VR(t(),n,!r)})},setFullscreen:n=>{let r=RR();if(n&&r){e({fullscreen:!0,uiByConversation:HR(t(),r,{open:!0}),fullscreenByConversation:VR(t(),r,!0)});return}e({fullscreen:n,...r?{fullscreenByConversation:VR(t(),r,n)}:{}})},togglePinnedTab:n=>{let r=t().pinnedTabs,i=Array.isArray(r)?r:[];e({pinnedTabs:i.includes(n)?i.filter(e=>e!==n):[...i,n]})},setBrowserHole:(n,r)=>{let{[n]:i,...a}=t().browserHoles;!r&&!i||e({browserHoles:r?{...a,[n]:r}:a})},setGlobalTabs:t=>e({globalTabs:t}),setGlobalScopeOverride:(n,r)=>{let{[n]:i,...a}=t().globalScopeOverrides;e({globalScopeOverrides:r?{...a,[n]:r}:a})},setLiveGlobalTabs:n=>{let r=t().liveGlobalTabs;r.length===n.length&&r.every((e,t)=>e===n[t])||e({liveGlobalTabs:n})},dropPanelFromLayouts:(n,r)=>{let{layouts:i,uiByConversation:a}=t(),o={...i},s={...a},c=!1;for(let[e,t]of Object.entries(i)){if(r.has(e))continue;let i=ER(t,n);if(i===t)continue;c=!0,o[e]=i;let l=a[e];!i&&l?.open===!0&&(s[e]={...l,open:!1})}c&&e({layouts:o,uiByConversation:s})},saveLayout:(n,r)=>{nP.getState().conversations[n]&&e({layouts:{...t().layouts,[n]:r}})},forgetConversation:n=>{let{[n]:r,...i}=t().layouts,{[n]:a,...o}=t().uiByConversation,{[n]:s,...c}=t().fullscreenByConversation,{[n]:l,...u}=t().changesModeByConversation,{[n]:d,...f}=t().snapshotsByConversation;e({layouts:i,uiByConversation:o,fullscreenByConversation:c,changesModeByConversation:u,snapshotsByConversation:f})},setChangesMode:(n,r)=>{e({changesModeByConversation:{...t().changesModeByConversation,[n]:r}})},saveSnapshots:(n,r)=>{e({snapshotsByConversation:{...t().snapshotsByConversation,[n]:r}}),window.electronAPI.changes.writeSnapshots({conversationId:n,snapshots:r})},loadSnapshots:n=>{if(n in t().snapshotsByConversation)return;let r=r=>{n in t().snapshotsByConversation||e({snapshotsByConversation:{...t().snapshotsByConversation,[n]:r}})};window.electronAPI.changes.readSnapshots({conversationId:n}).then(r,()=>r({}))}}),{name:`enso-side-panel`,version:5,storage:vR(()=>localStorage),partialize:e=>({lastWidth:e.lastWidth,filesTreeWidth:e.filesTreeWidth,uiByConversation:e.uiByConversation,fullscreenByConversation:e.fullscreenByConversation,layouts:e.layouts,pinnedTabs:e.pinnedTabs,globalTabs:e.globalTabs,globalScopeOverrides:e.globalScopeOverrides,changesModeByConversation:e.changesModeByConversation}),merge:(e,t)=>{let n=e&&typeof e==`object`?e:{};return{...t,...n,...CR(n)}},migrate:(e,t)=>{let{state:n,snapshots:r}=MR(e,t),i=window.electronAPI?.changes;if(i)for(let[e,t]of Object.entries(r))i.writeSnapshots({conversationId:e,snapshots:t});return n}})),WR=`Let's set you up. Ask me a few questions about what to call me, which model you should use, and how much you may do on your own. Then submit the draft with secretary_profile_propose and wait for my confirmation.`,GR={enabled:!1,projectId:null,profile:null,persona:``,board:{needsYou:[],running:[],done:[],todos:[]},proposals:{},takeovers:[]};function KR(e,t){return t&&e.some(e=>e.id===t)?t:e[0]?.id??null}function qR(e){_R(Object.values(e).flatMap(e=>e.takeovers.map(e=>e.conversationId)))}function JR(e){return e?YR.getState().secretaries.find(t=>t.projectId===e)?.id??null:null}var YR=EN()((e,t)=>({secretary:GR,secretaries:[],states:{},focusedId:null,resolving:{},welcomeOpen:!1,focusProposal:null,focus:n=>{let{states:r,focusedId:i}=t();i===n&&r[n]||(e({focusedId:n,secretary:r[n]??GR,welcomeOpen:!1}),r[n]||t().reload(n))},reload:async n=>{let r=n??t().focusedId;if(!r)return;let i=await window.electronAPI.secretary.getState(r).catch(()=>null);i&&e(e=>({states:{...e.states,[r]:i},...e.focusedId===r?{secretary:i}:{}}))},createSecretary:async()=>{let n=await window.electronAPI.secretary.create();return n.ok?(e({secretaries:await window.electronAPI.secretary.list()}),t().focus(n.secretaryId),e({welcomeOpen:!0}),n.secretaryId):null},openWelcome:()=>e({welcomeOpen:!0}),closeWelcome:()=>e({welcomeOpen:!1}),focusProposalCard:t=>e({focusProposal:{proposalId:t,at:Date.now()}}),clearFocusProposal:()=>e({focusProposal:null}),bind:()=>{let n=new Set,r=!0,i=n=>{let r=n.secretaryId??t().focusedId;r&&e(e=>{let t={...e.states,[r]:n};qR(t);let i=KR(e.secretaries,e.focusedId)??r;if(i!==r)return{states:t,focusedId:i};let a=e.states[r]??e.secretary;return{states:t,focusedId:i,secretary:n,welcomeOpen:n.profile?!1:a.profile!==null&&a.enabled?!0:e.welcomeOpen}})},a=window.electronAPI.secretary.onStateChanged(e=>{e.secretaryId&&n.add(e.secretaryId),i(e)}),o=window.electronAPI.secretary.onListChanged(t=>{eR(t.map(e=>e.id)),e(e=>{let n=new Set(t.map(e=>e.id)),r=Object.fromEntries(Object.entries(e.states).filter(([e])=>n.has(e))),i=KR(t,e.focusedId);return qR(r),{secretaries:t,states:r,focusedId:i,secretary:i&&r[i]||(i===e.focusedId?e.secretary:GR)}})});window.electronAPI.secretary.list().then(async t=>{if(r){eR(t.map(e=>e.id)),e(e=>({secretaries:t,focusedId:KR(t,e.focusedId)}));for(let e of t){let t=await window.electronAPI.secretary.getState(e.id);!r||n.has(e.id)||i({...t,secretaryId:t.secretaryId??e.id})}}}).catch(()=>void 0);let s=window.electronAPI.secretary.onOpenConversation(e=>{nP.getState().selectConversation(e.conversationId),UR.getState().ensureOpen(e.conversationId),e.proposalId&&t().focusProposalCard(e.proposalId)}),c=nP.subscribe((e,n)=>{if(e.activeId===n.activeId)return;let r=JR(e.activeId?e.conversations[e.activeId]?.projectId:void 0);r&&t().focus(r)});return()=>{r=!1,a(),o(),s(),c(),_R([]),e({secretary:GR,secretaries:[],states:{},focusedId:null,welcomeOpen:!1,focusProposal:null})}},newSecretaryConversation:async e=>{let{states:n,secretary:r,secretaries:i}=t(),a=e?.secretaryId?n[e.secretaryId]:r;e?.secretaryId&&t().focus(e.secretaryId);let o=a?.projectId??(e?.secretaryId?i.find(t=>t.id===e.secretaryId)?.projectId:null);if(!o)return null;let s=E.getState().projects.find(e=>e.id===o);if(!s)return null;let c=e?.greeting?XR(o):null;if(e?.greeting&&!c)return null;let l=nP.getState(),u=await l.newConversation(o);if(!u)return null;if(c){let e=M(E.getState().language);await l.send(Ie(e,WR),{...c,cwd:s.path},void 0,u)}return u},resolveProposal:async(n,r,i,a)=>{e({resolving:{...t().resolving,[n]:!0}});try{await window.electronAPI.secretary.resolveProposal(n,r,i,a)}catch{}finally{let r={...t().resolving};delete r[n],e({resolving:r})}}}));function XR(e){let t=E.getState(),n=t.projects.find(t=>t.id===e);if(!n)return null;let r=dR({defaultModel:t.defaultModel,...uR(n,t.projectGroups),providers:gR(),credentials:mR(pR.getState().snapshot),virtualModels:t.virtualModels});return r.source===`none`?null:{providerId:r.providerId,modelId:r.modelId}}function ZR(e,t,n){if(!t)return null;let r=t.imageVersion;return{name:e?.trim()||`·`,color:t.color,...r?{image:I(r,t.imageHash,n)}:{}}}function QR(e,t){return t&&e.some(e=>e.id===t)?t:null}function $R(e,t,n,r){if(n){let t=e.secretaries.find(e=>e.projectId===n)?.id;if(t)return t;if(e.secretaries.length===0&&e.secretary.projectId===n&&e.secretary.secretaryId)return e.secretary.secretaryId}let i=QR(e.secretaries,r);if(i)return i;if(e.secretaries.length===0&&r&&(e.states[r]||e.secretary.secretaryId===r))return r;let a=oR(e.states,t)?.secretaryId;return QR(e.secretaries,a)||(e.secretaries.length===0&&a&&e.states[a]?a:null)}function ez(e){let t=nP(t=>e?t.conversations[e]?.projectId:void 0),n=nP(t=>e?t.conversations[e]?.secretaryOrigin?.secretaryId:void 0),r=YR(r=>e?$R(r,e,t,n):null),i=YR(e=>r?e.states[r]??(e.focusedId===r?e.secretary:void 0):void 0),a=YR(e=>r?e.secretaries.find(e=>e.id===r):void 0),o=YR(e=>e.secretary.enabled?e.secretary.profile:null),s=YR(e=>e.secretary.secretaryId??void 0);if(r){if(i&&!i.enabled)return null;let e=i?.profile?.avatar??(i?void 0:a?.avatar),t=i?.profile?.name??(i?void 0:a?.name);return e?ZR(t,e,r):null}return o?ZR(o.name,o.avatar,s):null}var tz=EN(()=>({active:!1})),nz=()=>tz.getState().active;function rz(e){return typeof e!=`number`||!Number.isInteger(e)?5:e<1?1:e>60?60:e}function iz(e){return rz(e)*1e3}var az=new Set(`ls.tree.pwd.cd.cat.bat.head.tail.wc.nl.tac.less.more.rg.grep.egrep.fgrep.ag.find.fd.fdfind.which.type.file.stat.du.df.sort.uniq.cut.tr.awk.sed.diff.jq.yq.echo.printf.basename.dirname.realpath.readlink.printenv.date.whoami.uname.column.true.test.[.git`.split(`.`)),oz=new Set([`status`,`log`,`diff`,`show`,`blame`,`grep`,`ls-files`,`ls-tree`,`rev-parse`,`describe`,`shortlog`,`reflog`,`cat-file`,`name-rev`,`remote`,`config`,`branch`,`tag`]),sz={sed:/^(-[a-zA-Z]*i|--in-place)|\/[a-zA-Z]*e[a-zA-Z]*['"]?$|^['"]?e\b/,awk:/^-[a-zA-Z]*[fiE]|^--(file|include|exec)/,yq:/^-[a-zA-Z]*[is]|^--(inplace|split-exp)/,sort:/^-[a-zA-Z]*o|^--(output|compress-program)/,find:/^-(exec|execdir|ok|okdir|delete|fprint|fprintf|fprint0|fls)$/,git:/^--(output|ext-diff|textconv|filters|exec-path)/,rg:/^--pre($|=)/,fd:/^-[a-zA-Z0-9]*[xX]|^--exec/,fdfind:/^-[a-zA-Z0-9]*[xX]|^--exec/,ag:/^--pager/,bat:/^--pager/,tree:/^-o$|^--output/,file:/^-[a-zA-Z]*C/,date:/^(-s|--set)/},cz={branch:/^-(d|D|m|M|c|C|u|f|-delete|-move|-copy|-set-upstream-to|-unset-upstream|-force)/,tag:/^-(a|s|d|f|m|F|-annotate|-sign|-delete|-force|-message)/,config:/^(-e|--edit|--unset|--unset-all|--add|--replace-all|--rename-section|--remove-section)$/,remote:/^(add|remove|rm|rename|set-url|set-head|set-branches|prune|update)$/,reflog:/^(expire|delete)$/,grep:/^(-O|--open-files-in-pager)/},lz=/^\/(usr\/(local\/)?)?s?bin\/[^/]+$|^\/opt\/homebrew\/bin\/[^/]+$/,uz=new Set([`--no-pager`,`-P`,`--no-optional-locks`]),dz=/^(LC_[A-Z_]+|LANG|LANGUAGE|TZ|NO_COLOR|FORCE_COLOR|CLICOLOR(_FORCE)?|COLUMNS|TERM)=/,fz=new Set([`node`,`npm`,`pnpm`,`yarn`,`bun`,`deno`,`python`,`python3`,`pip`,`pip3`,`ruby`,`go`,`cargo`,`rustc`,`java`,`javac`]),pz=/^['"]?((\d+|\$)(,(\d+|\$))?|\/[^/]*\/)p['"]?$/,mz=new Set([`-n`,`-E`,`-r`,`--quiet`,`--silent`]);function hz(e){let t=e.trim().split(/\s+/),n=0;for(;n<t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[n]);)n+=1;return{env:t.slice(0,n),tokens:t.slice(n)}}function gz(e){let t=hz(e).tokens[0]??``;return t.slice(t.lastIndexOf(`/`)+1)}function _z(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31&&n!==10)return!0}return!1}function vz(e){let t=e.find(e=>!mz.has(e));return!t||!pz.test(t)?!1:e.slice(0,e.indexOf(t)).every(e=>mz.has(e))}function yz(e){let t=1;for(;t<e.length&&e[t].startsWith(`-`);)if(e[t]===`-C`){if(t+1>=e.length)return!1;t+=2}else if(uz.has(e[t]))t+=1;else return!1;if(t>=e.length)return!1;let n=e[t];if(!oz.has(n))return!1;let r=e.slice(t+1),i=cz[n];return!(i&&r.some(e=>i.test(e))||n===`config`&&!r.some(e=>/^(--get|--get-all|--list|-l|--get-regexp)$/.test(e))||(n===`branch`||n===`tag`)&&r.some(e=>!e.startsWith(`-`))&&!r.some(e=>e===`-l`||e===`--list`))}function bz(e){let t=e.trim();if(!t||/\$\(|<\(|`/.test(t)||_z(t))return!1;let n=t.replace(/2>&1|[12]?>\s*\/dev\/null/g,``);if(n.includes(`>`))return!1;let r=n.split(/\|\|?|&&?|;|\n/);for(let e of r){let t=e.trim();if(!t)continue;let{env:n,tokens:r}=hz(t);if(n.some(e=>!dz.test(e)))return!1;let i=gz(t),a=r[0]??``;if(a.includes(`/`)&&!lz.test(a))return!1;let o=r.slice(1);if(fz.has(i)){if(o.length!==1||![`--version`,`-v`,`-V`].includes(o[0]))return!1;continue}if(!az.has(i))return!1;let s=sz[i];if(s&&o.some(e=>s.test(e))||i===`awk`&&/system\s*\(/.test(o.join(` `))||i===`sed`&&!vz(o)||i===`git`&&!yz(r)||i===`uniq`&&o.filter(e=>!e.startsWith(`-`)).length>1)return!1}return!0}var xz=`</untrusted-content`,Sz=`<untrusted-content`;function Cz(e){return e.split(`<\\/untrusted-content`).join(xz).split(`<\\untrusted-content`).join(Sz)}var wz=/^<untrusted-content(?:\s[^<>\n]*)?>([\s\S]*)<\/untrusted-content>$/u,Tz=/<\\?untrusted-content source="plugin:[^"<>\n]*"[^<>\n]*>/u,Ez=/<\\?\/untrusted-content>\s*$/u;function Dz(e){let t=wz.exec(e.trim()),n=!!(t&&!t[1].includes(xz)),r=n&&t?t[1]:e,i=Tz.exec(r),a=Ez.exec(r);return i&&a&&a.index>=i.index+i[0].length&&(r=r.slice(0,i.index)+r.slice(i.index+i[0].length,a.index)),n&&(r=Cz(r)),r===e?e:r.trim()}function Oz(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}function kz(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return t&&typeof t==`object`&&!Array.isArray(t)?t:null}function Az(e){let t=[e.tool,e.name].find(e=>typeof e==`string`&&e);if(typeof t==`string`)return t.startsWith(`mcp__`)||typeof e.server!=`string`||!e.server?t:`mcp__${e.server}__${t}`}function jz(e,t){if(e!==`mcp`)return{name:e,args:t};let n=kz(t);if(!n)return{name:e,args:t};let r=Az(n);return n.action===`list`?{name:e,args:t,summary:typeof n.server==`string`&&n.server?n.server:`list`}:n.action===`describe`&&r?{name:e,args:t,summary:r}:n.action===`call`&&r&&Oz(r)?{name:r,args:kz(n.arguments)??{}}:{name:e,args:t}}function Mz(e,t,n){let r=[];for(let i=0;i<e.length;){let a=e[i];if(a.kind!==`tool`||!a.name||!t(a.name)){r.push(a),i+=1;continue}let o=i+1;for(;o<e.length&&e[o].kind===`tool`&&e[o].name===a.name;)o+=1;r.push(o-i>=2?n(a,e.slice(i+1,o)):a),i=o}return r}var Nz=[`日`,`一`,`二`,`三`,`四`,`五`,`六`],Pz=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function Fz(e){let t=e.trim();return t.length<=8?t:`${t.slice(0,8)}…`}function Iz(e,t){return t?.trim()||(e?Fz(e):``)}function Lz(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Rz(e){return String(e).padStart(2,`0`)}function zz(e,t){return`${Rz(e)}:${Rz(t)}`}function Bz(e,t,n){return e.length===n-t+1&&e[0]===t&&e[e.length-1]===n}function Vz(e,t){if(e.length<2||e[0]!==0)return;let n=e[1]-e[0];if(!(n<1)){for(let t=1;t<e.length;t+=1)if(e[t]-e[t-1]!==n)return;return e[e.length-1]+n>=t?n:void 0}}function Hz(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Uz(e,t){let n=Bo(e);if(!n)return e.trim();let r=Bz(n.dayOfMonth,1,31)&&Bz(n.month,1,12)&&Bz(n.dayOfWeek,0,6);if(r&&Bz(n.hour,0,23)){let e=Vz(n.minute,60);if(e===1)return t===`zh`?`每分钟`:`every minute`;if(e)return t===`zh`?`每 ${e} 分钟`:`every ${e} minutes`}if(n.minute.length!==1||n.hour.length!==1||!Bz(n.month,1,12))return n.source;let i=zz(n.hour[0],n.minute[0]);if(r)return t===`zh`?`每天 ${i}`:`every day at ${i}`;if(Bz(n.dayOfMonth,1,31)&&Hz(n.dayOfWeek,[1,2,3,4,5]))return t===`zh`?`每个工作日 ${i}`:`weekdays at ${i}`;if(Bz(n.dayOfMonth,1,31)&&n.dayOfWeek.length===1){let e=n.dayOfWeek[0];return t===`zh`?`每周${Nz[e]} ${i}`:`every ${Pz[e]} at ${i}`}return n.source}var Wz=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Gz(e){if(!e)return null;try{let t=JSON.parse(e);return Wz(t)?t:null}catch{return null}}function Kz(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){if(!Wz(r)||typeof r.id!=`string`||!r.id||typeof r.title!=`string`||typeof r.content!=`string`)return null;let{spaceId:e,[t]:i}=r;n.push({id:r.id,title:r.title,content:r.content,unitType:typeof r.unitType==`string`&&r.unitType?r.unitType:null,space:e===`global`?`global`:typeof e==`string`&&e.startsWith(`proj:`)?`project`:null,relevance:typeof i==`number`&&Number.isFinite(i)?i:null})}return n}function qz(e){let t=Gz(e);return t?Kz(t.results,`relevance`):null}function Jz(e,t){let n=Gz(e);if(n?.status===`candidates_found`){let e=Kz(n.candidates,`similarity`);return e?{written:!1,candidates:e}:null}if(n?.status!==`inserted`||!Wz(n.memory)||!t)return null;let r=Kz([{...n.memory,content:t}],`relevance`)?.[0];return r?{written:!0,deduplicated:n.deduplicated===!0,memory:r}:null}var Yz=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function Xz(e){for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(!(e.type!==`image`||typeof e.data!=`string`||!e.data)&&typeof e.mimeType==`string`&&Yz.has(e.mimeType))return e}}var Zz=e=>typeof e==`number`?e:null;function Qz(e){let t=e?.split(`
189
+ `);for(let t of e.childNodes)r(t)}};for(let t of e.childNodes)r(t);return t}function YA(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return null;let{anchorNode:n,anchorOffset:r}=t;return!n||!e.contains(n)||n.nodeType!==Node.TEXT_NODE?null:{node:n,offset:r}}function XA(e,t){if(t.rangeCount===0||!t.isCollapsed)return null;let{anchorNode:n,anchorOffset:r}=t;if(!n||n.nodeType===Node.TEXT_NODE||n!==e&&!e.contains(n))return null;let i=n.childNodes,a=i[r],o=r>0?i[r-1]:void 0,s=a?.nodeType===Node.TEXT_NODE?{node:a,offset:0}:o?.nodeType===Node.TEXT_NODE?{node:o,offset:o.length}:null;if(!s)return null;let c=document.createRange();return c.setStart(s.node,s.offset),c.collapse(!0),c}function ZA(e){return e instanceof HTMLElement&&!!e.dataset.mentionKind}function QA(e){return e instanceof Text&&!/[^\s\u00a0]/.test(e.textContent??``)}function $A(e,t){let n=window.getSelection();if(!n||n.rangeCount===0||!n.isCollapsed)return null;let{anchorNode:r,anchorOffset:i}=n;if(!r||!e.contains(r))return null;if(r.nodeType===Node.TEXT_NODE){let e=r.textContent??``;if(t===`before`){if(/[^\s\u00a0]/.test(e.slice(0,i)))return null;let t=r.previousSibling;for(;QA(t);)t=t.previousSibling;return ZA(t)?t:null}if(/[^\s\u00a0]/.test(e.slice(i)))return null;let n=r.nextSibling;for(;QA(n);)n=n.nextSibling;return ZA(n)?n:null}let a=r.childNodes;if(t===`before`){let e=i-1;for(;e>=0&&QA(a[e]);)--e;let t=e>=0?a[e]:null;return ZA(t)?t:null}let o=i;for(;o<a.length&&QA(a[o]);)o+=1;let s=a[o];return ZA(s)?s:null}function ej(e,t){let n=e.nextSibling;QA(n)&&n.remove();let r=e.previousSibling;if(e.remove(),r){tj(r);return}let i=window.getSelection();if(!i)return;let a=document.createRange();a.setStart(t,0),a.collapse(!0),i.removeAllRanges(),i.addRange(a)}function tj(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}var nj=(0,U.forwardRef)(function({placeholder:e,disabled:t,className:n,onStateChange:r,onKeyDown:i,onPaste:a,onPasteText:o,onCompositionStart:s,onCompositionEnd:c,onChipActivate:l,ariaProps:u},d){let{t:f}=q(),p=(0,U.useRef)(null),m={title:e=>f(`Quote · {{count}} lines`,{count:e}),truncated:e=>f(`Truncated · original {{count}} lines`,{count:e}),expand:f(`Click to expand`),remove:f(`Remove quote`)},h=(0,U.useRef)(m);h.current=m;let g=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=e=>{let t=e.target;for(let e of p.current?.querySelectorAll(`[data-mention-kind="quote"][data-expanded]`)??[])t&&e.contains(t)||(delete e.dataset.expanded,WA(e,h.current))};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[]),(0,U.useEffect)(()=>{let e=()=>{let e=p.current;if(!e||document.activeElement!==e)return;let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return;let n=t.anchorNode;if(n&&(n===e||e.contains(n))){let r=XA(e,t);r?(t.removeAllRanges(),t.addRange(r)):n.nodeType===Node.TEXT_NODE&&(g.current={node:n,offset:t.anchorOffset});return}let r=g.current,i=document.createRange();r?.node.isConnected&&e.contains(r.node)?(i.setStart(r.node,Math.min(r.offset,r.node.length)),i.collapse(!0)):(i.selectNodeContents(e),i.collapse(!0)),t.removeAllRanges(),t.addRange(i)};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[]);let _=(0,U.useCallback)(()=>{let e=p.current;if(!e)return;let t=JA(e),n=t.map(e=>e.type===`text`?e.text:``).join(``),i=t.some(e=>e.type!==`text`),a=null,o=null,s=null,c=null,l=YA(e);if(l){let t=l.node.textContent?.slice(0,l.offset)??``;a=zk(t,t.length),a===null&&(s=LA(t,t.length)),a===null&&s===null&&(c=AO(t)),a===null&&l.node===e.firstChild&&/^\/[^\s]*$/.test(t)&&(o=t.slice(1))}r({plainText:n,hasMentions:i,segments:t,mentionQuery:a,slashQuery:o,skillQuery:s,pluginQuery:c})},[r]),v=(0,U.useCallback)(e=>{let t=p.current;if(!t)return null;let n=YA(t);if(!n)return null;let r=n.node.textContent?.slice(0,n.offset)??``;if(e===`#`){let e=AO(r);return e===null?null:{node:n.node,start:r.length-e.length-1,end:n.offset}}if(e===`@`||e===`$`){let t=e===`@`?zk(r,r.length):LA(r,r.length);return t===null?null:{node:n.node,start:r.length-t.length-1,end:n.offset}}return n.node!==t.firstChild||!/^\/[^\s]*$/.test(r)?null:{node:n.node,start:0,end:n.offset}},[]),y=(0,U.useCallback)((e,t)=>{let n=p.current;if(!n)return;n.focus();let r=document.createRange(),i=t?v(`@`):null;if(i)r.setStart(i.node,i.start),r.setEnd(i.node,i.end),r.deleteContents();else{let e=YA(n);e?(r.setStart(e.node,e.offset),r.collapse(!0)):(r.selectNodeContents(n),r.collapse(!1))}let a=e();r.insertNode(a);let o=document.createTextNode(`\xA0`);a.parentNode?.insertBefore(o,a.nextSibling),tj(o),_()},[v,_]);return(0,U.useImperativeHandle)(d,()=>({focus:()=>p.current?.focus(),isEmpty:()=>{let e=p.current;return!e||!JA(e).some(e=>e.type!==`text`||e.text.trim().length>0)},getSegments:()=>p.current?JA(p.current):[],setSegments:e=>{let t=p.current;if(t){t.textContent=``;for(let n of e)n.type===`text`?t.appendChild(document.createTextNode(n.text)):t.appendChild(KA(n,h.current));_()}},clear:()=>{let e=p.current;e&&(e.textContent=``,_())},insertMention:e=>{let t=e.kind===`file`?{type:`file`,path:e.relativePath}:e.kind===`chat`?{type:`chat`,label:e.label,sessionFile:e.sessionFile,conversationId:e.id}:{type:`ui-element`,id:e.id,label:e.label,path:e.path,text:e.text,imageId:e.imageId};y(()=>KA(t,h.current),e.kind!==`ui-element`)},consumeToken:e=>{let t=v(e);if(!t)return;let n=document.createRange();n.setStart(t.node,t.start),n.setEnd(t.node,t.end),n.deleteContents(),_()},insertFileChip:(e,t)=>{y(()=>KA({type:`file`,path:e,...t?{label:t}:{}},h.current),!1)},insertText:e=>{y(()=>document.createTextNode(e),!1)},insertQuote:e=>{let t=p.current;if(!t)return;let n=document.createTextNode(`\xA0`);t.append(KA(e,h.current),n),t.focus(),window.getSelection()?.collapse(n,n.length),t.scrollTop=t.scrollHeight,_()},getMentionAnchorRect:()=>{let e=v(`@`);if(!e)return null;let t=document.createRange();return t.setStart(e.node,e.start),t.setEnd(e.node,Math.min(e.start+1,e.node.length)),t.getBoundingClientRect()}}),[v,_,y]),(0,K.jsx)(`div`,{ref:p,contentEditable:!t,role:u?.role??`textbox`,"aria-placeholder":e,"data-placeholder":e,...u,onInput:_,onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`Backspace`||e.key===`Delete`)){let t=p.current,n=t&&$A(t,e.key===`Backspace`?`before`:`after`);if(n&&t){e.preventDefault(),ej(n,t),_();return}}i(e)},onClick:e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-mention-kind]`);if(!(n instanceof HTMLElement)||!p.current?.contains(n))return;if(n.dataset.mentionKind===`quote`){t.closest(`[data-quote-remove]`)?(ej(n,p.current),_()):n.dataset.expanded!==`true`&&(n.dataset.expanded=`true`,WA(n,h.current));return}if(!l)return;let r=qA(n);r&&l(r)},onKeyUp:e=>{e.key!==`Escape`&&_()},onMouseUp:_,onPaste:e=>{if(e.clipboardData.files.length>0){a(e);return}e.preventDefault();let t=e.clipboardData.getData(`text/plain`);t&&(o?.(t)||document.execCommand(`insertText`,!1,t))},onCompositionStart:s,onCompositionEnd:()=>{c(),_()},className:G(`max-h-40 min-h-10 min-w-0 flex-1 overflow-y-auto pt-0.5 text-sm break-words whitespace-pre-wrap outline-none`,`empty:before:pointer-events-none empty:before:text-muted-foreground empty:before:content-[attr(data-placeholder)]`,t&&`opacity-60`,n)})}),rj=Qr(`relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button,a&]:cursor-pointer [button,a&]:pointer-coarse:after:absolute [button,a&]:pointer-coarse:after:size-full [button,a&]:pointer-coarse:after:min-h-11 [button,a&]:pointer-coarse:after:min-w-11`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-5.5 min-w-5.5 px-[calc(--spacing(1)-1px)] text-sm sm:h-4.5 sm:min-w-4.5 sm:text-xs`,lg:`h-6.5 min-w-6.5 px-[calc(--spacing(1.5)-1px)] text-base sm:h-5.5 sm:min-w-5.5 sm:text-sm`,sm:`h-5 min-w-5 rounded-[calc(var(--radius-sm)-2px)] px-[calc(--spacing(1)-1px)] text-xs sm:h-4 sm:min-w-4 sm:text-[.625rem]`},variant:{default:`bg-primary text-primary-foreground [button,a&]:hover:bg-primary/90`,destructive:`bg-destructive text-white [button,a&]:hover:bg-destructive/90`,error:`bg-destructive/12 text-destructive dark:bg-destructive/16`,info:`bg-info/12 text-info dark:bg-info/16`,outline:`border-border bg-transparent dark:bg-input/32 [button,a&]:hover:bg-accent/50 dark:[button,a&]:hover:bg-input/48`,secondary:`bg-secondary text-secondary-foreground [button,a&]:hover:bg-secondary/90`,success:`bg-success/12 text-success dark:bg-success/16`,warning:`bg-warning/12 text-warning-foreground dark:bg-warning/16`}}});function ij({className:e,variant:t,size:n,render:r,...i}){return qr({defaultTagName:`span`,props:cr({className:G(rj({className:e,size:n,variant:t})),"data-slot":`badge`},i),render:r})}var aj=/[\\/]/;function oj(e){return e.split(aj).filter(e=>e.length>0)}function sj(e){let t=new Map,n=e.map(oj),r=n.map(e=>e.join(`/`));for(let i=0;i<e.length;i++){let a=e[i],o=n[i]??[],s=Math.max(0,o.length-3);for(;s>0;){let e=o.slice(s).join(`/`);if(!r.some(t=>t!==r[i]&&(t===e||t.endsWith(`/${e}`))))break;s--}let c=o.slice(s).join(`/`);t.set(a,s>0?`…/${c}`:c)}return t}function cj({groups:e,query:t,activeIndex:n,onActiveIndexChange:r,openFolderId:i,folderIndex:a,onOpenFolderIdChange:o,onFolderIndexChange:s,onSelect:c,id:l=`composer-mention-picker`,left:u=0,flyoutSide:d=`right`}){let{t:f}=q(),p=OD(),m=(0,U.useMemo)(()=>vD(e,t),[e,t]),h=(0,U.useMemo)(()=>sj(e.files.map(e=>e.relativePath)),[e.files]),g=(0,U.useRef)(new Map),_=(0,U.useRef)(new Map),v=m[0]?.type===`folder`;if((0,U.useEffect)(()=>{g.current.get(n)?.scrollIntoView({block:`nearest`})},[n]),(0,U.useEffect)(()=>{i&&_.current.get(a)?.scrollIntoView({block:`nearest`})},[i,a]),m.length===0)return null;let y={agents:f(`Agents`),members:f(`Members`),chats:f(`Chats`)},b={agents:ft,members:tr,chats:jn},x=i?e[i]:[],S=0,C=()=>x.map((e,t)=>(0,K.jsx)(lj,{ref:e=>{e?_.current.set(t,e):_.current.delete(t)},id:`${l}-sub-${t}`,candidate:e,active:t===a,onHover:()=>s(t),onSelect:()=>c(e)},`sub:${e.id}`)),w=!!(p&&i&&x.length>0),T=e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,"data-slot":`mention-sheet-back`,onClick:()=>o(null),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,children:[(0,K.jsx)(yt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:y[e]})]}),C()]}),E=(t,i)=>{let a=e[t];if(a.length===0)return null;let s=t===`files`?f(`Files`):y[t];return(0,K.jsxs)(`div`,{role:`group`,"aria-label":s,children:[(0,K.jsx)(`p`,{className:G(`px-2 pb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,i?`pt-2`:`pt-1.5`),children:s}),a.map(e=>{let i=S++;return(0,K.jsx)(lj,{ref:e=>{e?g.current.set(i,e):g.current.delete(i)},id:`${l}-option-${i}`,candidate:e,active:i===n,pathLabel:e.kind===`file`?h.get(e.relativePath):void 0,onHover:()=>{r(i),v&&o(null)},onSelect:()=>c(e)},`${t}:${e.id}`)})]})};return(0,K.jsxs)(`div`,{"data-slot":`mention-picker`,className:p?`absolute inset-x-0 bottom-full z-10 mb-1.5 w-full`:`absolute bottom-full z-10 mb-1.5 max-w-full`,style:p?void 0:{left:u},children:[(0,K.jsx)(`div`,{id:l,role:`listbox`,"aria-label":f(`Mention suggestions`),className:p?`max-h-[50dvh] w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`:`max-h-72 w-80 max-w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:w&&i?T(i):v?(0,K.jsxs)(K.Fragment,{children:[m.filter(e=>e.type===`folder`).map(e=>{let t=S++,a=b[e.id];return(0,K.jsxs)(`button`,{ref:e=>{e?g.current.set(t,e):g.current.delete(t)},id:`${l}-option-${t}`,type:`button`,role:`option`,"aria-selected":n===t,onClick:()=>{r(t),o(e.id),s(0)},onMouseMove:()=>{r(t),!p&&i!==e.id&&(o(e.id),s(0))},className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,n===t&&`bg-foreground/10`),children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background`,children:(0,K.jsx)(a,{className:`h-3.5 w-3.5 text-muted-foreground`})}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 font-medium`,children:y[e.id]}),(0,K.jsx)(vt,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]},`folder:${e.id}`)}),E(`files`,!0)]}):(0,K.jsxs)(K.Fragment,{children:[E(`agents`,!1),E(`members`,e.agents.length>0),E(`chats`,e.agents.length+e.members.length>0),E(`files`,e.agents.length+e.members.length+e.chats.length>0)]})}),!p&&i&&x.length>0&&(0,K.jsx)(`div`,{role:`listbox`,"aria-label":y[i],"data-slot":`mention-flyout`,className:G(`absolute top-0 z-20 max-h-72 w-72 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,d===`right`?`left-full ml-1`:`right-full mr-1`),children:C()})]})}function lj({ref:e,id:t,candidate:n,active:r,pathLabel:i,onHover:a,onSelect:o}){let{t:s}=q(),c=uj(n),l=n.kind===`agent-type`?n.source===`bot`?tr:ft:n.kind===`chat`?jn:c?Kt:Ht;return(0,K.jsxs)(`button`,{ref:e,id:t,type:`button`,role:`option`,"aria-selected":r,onClick:o,onMouseMove:a,className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,r&&`bg-foreground/10`),children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background`,children:(0,K.jsx)(l,{className:`h-3.5 w-3.5 text-muted-foreground`})}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:n.label}),(0,K.jsx)(ij,{variant:`outline`,className:`px-1 py-0 text-[9px]`,children:n.kind===`agent-type`?s(n.source===`system`?`System`:n.source===`builtin`?`Built-in`:n.source===`bot`?`Member`:`Custom`):n.kind===`chat`?s(`Chat`):s(c?`Folder`:`File`)}),n.kind===`agent-type`&&n.locked&&(0,K.jsx)(ij,{variant:`secondary`,className:`px-1 py-0 text-[9px]`,children:s(`Locked`)})]}),(0,K.jsx)(`span`,{className:G(`block text-muted-foreground`,n.kind===`file`?`whitespace-normal break-all`:`truncate`),title:n.kind===`file`?n.relativePath:void 0,children:n.kind===`agent-type`?n.source===`bot`?n.description:s(n.description):n.kind===`chat`?n.sessionFile.split(`/`).at(-1):n.kind===`file`?i??n.relativePath:n.path})]})]})}function uj(e){return e.kind===`file`&&/[\\/]$/.test(e.relativePath)}var dj=[`on`,`off`],fj=[`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function pj(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function mj(e){return typeof e==`string`&&dj.includes(e)}function hj(e){return typeof e==`string`&&fj.includes(e)}function gj(e){if(!e)return{};let t={};mj(e.reasoning)&&(t.reasoning=e.reasoning),hj(e.thinkingLevel)&&(t.thinkingLevel=e.thinkingLevel);let n=pj(e.contextWindow);n!==void 0&&(t.contextWindow=n);let r=pj(e.maxTokens);return r!==void 0&&(t.maxTokens=r),t}var _j=e=>{let t=e.indexOf(`#`);return t===-1?e:e.slice(0,t)},vj=`enso-virtual`;function yj(e){return e?.providerId===vj}function bj(e,t){if(!(!t||!yj(t)))return e?.find(e=>e.id===t.modelId)}function xj(e,t){return e?.find(e=>e.id===t)?.name??t}new Set(Object.values({"openrouter.ai":`openrouter`,"opencode.ai":`opencode`,"ai-gateway.vercel.sh":`vercel-ai-gateway`,"api.typesafe.ai":`typesafe`}));function Sj(e,t){if(e===void 0)return t.map(e=>({...e}));let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of e){let e=n.get(t.id);n.delete(t.id);let i={id:t.id};t.label!==void 0&&(i.label=t.label),e&&(e.label!==void 0&&(i.label=e.label),e.enabled!==void 0&&(i.enabled=e.enabled),e.imageGeneration!==void 0&&(i.imageGeneration=e.imageGeneration),Object.assign(i,gj(e))),r.push(i)}for(let e of n.values())r.push({...e});return r}function Cj(e,t){if(!t)return[...e];let n=new Map(t.providers.map(e=>[e.key,e]));return e.map(e=>{if(!e.oauthAccountKey)return e;let t=n.get(_j(e.oauthAccountKey));return t?{...e,models:Sj(t.models,e.models)}:e})}var wj=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Tj=(e=>e?wj(e):wj),Ej=e=>e;function Dj(e,t=Ej){let n=U.useSyncExternalStore(e.subscribe,U.useCallback(()=>t(e.getState()),[e,t]),U.useCallback(()=>t(e.getInitialState()),[e,t]));return U.useDebugValue(n),n}var Oj=e=>{let t=Tj(e),n=e=>Dj(t,e);return Object.assign(n,t),n},kj=(e=>e?Oj(e):Oj);kj(()=>({byScope:{},generation:0})),kj(()=>({entries:{}}));var Aj=U.createContext(void 0);function jj(e){let t=U.useContext(Aj);if(t===void 0&&!e)throw Error(Cr(33));return t}var Mj=U.createContext(void 0);function Nj(e){let t=U.useContext(Mj);if(t===void 0&&!e)throw Error(Cr(36));return t}var Pj=U.createContext(void 0);function Fj(e=!0){let t=U.useContext(Pj);if(t===void 0&&!e)throw Error(Cr(25));return t}var Ij=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=Nj(),s=o.useState(`open`),c=o.useState(`mounted`),l=o.useState(`transitionStatus`),u=o.useState(`lastOpenChangeReason`),d=Fj(),f={open:s,transitionStatus:l};return Vr(`div`,e,{ref:d?.backdropRef?[t,d.backdropRef]:t,state:f,stateAttributesMapping:ty,props:[{role:`presentation`,hidden:!c,style:{pointerEvents:u===`trigger-hover`?`none`:void 0,userSelect:`none`,WebkitUserSelect:`none`}},a]})});function Lj({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=U.useRef(e!==void 0),[a,o]=U.useState(t);return[i?e:a,U.useCallback(e=>{i||o(e)},[])]}function Rj(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:l}=a.useState(`floatingTreeRoot`),u=a.useState(`open`),d=Fj(!0),f=d!==void 0;return U.useMemo(()=>({id:r,role:`menuitem`,tabIndex:u&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&l.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&l.emit(`close`,{domEvent:e,reason:By})},onMouseUp(e){if(d){let t=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,f&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||f&&!cb&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!f||e.button===2)&&c.type===`regular-item`&&Ny(s.current,e,{detail:1})}}),[t,n,r,l,i,u,a,o,s,d,f,c])}var zj={type:`regular-item`};function Bj(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:l}=e,u=U.useRef(null),{getButtonProps:d,buttonRef:f}=Py({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),p=Rj({closeOnClick:t,highlighted:r,id:i,nodeId:l,store:a,typingRef:o,itemRef:u,itemMetadata:c}),m=U.useCallback(e=>cr(p,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,d),[p,d,c]),h=Er(u,f);return U.useMemo(()=>({getItemProps:m,itemRef:h}),[m,h])}var Vj=U.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Hj(){return U.useContext(Vj)}function Uj(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:l}=Hj(),u=U.useRef(-1),[d,f]=U.useState(a==null&&t?()=>{if(u.current===-1){let e=l.current;l.current+=1,u.current=e}return u.current}:-1),p=a??d,m=U.useRef(null),h=U.useCallback(e=>{let t=m.current;t&&s(t),m.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return X(()=>{if(a==null)return c(e=>{let t=m.current?e.get(m.current)?.index:null;t!=null&&f(t)})},[a,c]),{ref:h,index:p}}var Wj=U.createContext(void 0);function Gj(){let e=U.useContext(Wj);if(e===void 0)throw Error(Cr(31));return e}var Kj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,[o,s]=U.useState(void 0),c=Vr(`div`,e,{ref:t,props:{role:`group`,"aria-labelledby":o,...a}});return(0,K.jsx)(Wj.Provider,{value:s,children:c})}),qj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Zy(a),c=Gj();return X(()=>(c(s),()=>{c(e=>e===s?void 0:e)}),[c,s]),Vr(`div`,e,{ref:t,props:{id:s,role:`presentation`,...o}})}),Jj=U.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=Uj({guess:!0,label:a}),f=jj(!0),p=Zy(i),{store:m}=Nj(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Bj({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:zj});return Vr(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),Yj=U.createContext(void 0);function Xj(e){let t=U.useContext(Yj);if(t===void 0&&!e)throw Error(Cr(69));return t}var Zj=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Nj(),{side:c,align:l}=jj(),u=Xj(!0)!=null,d=s.useState(`open`),f=s.useState(`transitionStatus`),p=s.useState(`popupProps`),m=s.useState(`mounted`),h=s.useState(`instantType`),g=s.useState(`activeTriggerElement`),_=s.useState(`parent`),v=s.useState(`lastOpenChangeReason`),y=s.useState(`rootId`),b=s.useState(`floatingRootContext`),x=s.useState(`floatingTreeRoot`),S=s.useState(`closeDelay`),C=s.useState(`hoverEnabled`),w=s.useState(`disabled`),T=s.useState(`openMethod`),E=_.type===`context-menu`;kw({open:d,ref:s.context.popupRef,onComplete(){d&&s.context.onOpenChangeComplete?.(!0)}}),U.useEffect(()=>{function e(e){s.setOpen(!1,Ky(e.reason,e.domEvent))}return x.events.on(`close`,e),()=>{x.events.off(`close`,e)}},[x.events,s]),nT(b,{enabled:C&&!w&&!E&&_.type!==`menubar`,closeDelay:S});let D=s.useStateSetter(`popupElement`),O=Vr(`div`,e,{state:{transitionStatus:f,side:c,align:l,open:d,nested:_.type===`menu`,instant:h},ref:[t,s.context.popupRef,D],stateAttributesMapping:ty,props:[p,{onKeyDown(e){u&&vT.has(e.key)&&e.stopPropagation()}},dD(f),o,{"data-rootownerid":y}]}),k=_.type===void 0||E;return(g||_.type===`menubar`&&v!==`outside-press`)&&(k=!0),(0,K.jsx)(HS,{context:b,openInteractionType:T,modal:E,disabled:!m,returnFocus:a===void 0?k:a,initialFocus:_.type!==`menu`,restoreFocus:!0,externalTree:_.type===`menubar`?void 0:x,previousFocusableElement:g,nextFocusableElement:_.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:_.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:O})}),Qj=U.createContext(void 0);function $j(){let e=U.useContext(Qj);if(e===void 0)throw Error(Cr(32));return e}var eM=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Nj();return i.useState(`mounted`)||n?(0,K.jsx)(Qj.Provider,{value:n,children:(0,K.jsx)(CS,{ref:t,...r})}):null});function tM(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=Ay(i),[,o]=U.useState(!1),s=Tr(rM).current,c=Tr(nM).current,l=U.useRef(0),u=U.useRef(!0),d=U.useRef([]),f=U.useRef(null),p=Ay(()=>{u.current||(u.current=!0,o(e=>!e))}),m=Ay((e,t)=>{c.set(e,t),p()}),h=Ay(e=>{c.delete(e),p()}),g=Ay(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),l.current=n.current.length,t});function _(e){if(f.current?.disconnect(),f.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!oM(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&sM(r,n)>0){t.disconnect(),p();return}r=n}});f.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=aM(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let v=Ay(()=>{let[e,t]=iM(c),n=g(e);_(t),d.current=e,u.current=!1,s.forEach(e=>e(n)),a(n)});X(()=>(u.current||g(d.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,g]),X(()=>{u.current&&v()}),X(()=>()=>{f.current?.disconnect(),u.current=!0},[]);let y=Ay(e=>(s.add(e),()=>{s.delete(e)})),b=U.useMemo(()=>({register:m,unregister:h,subscribeMapChange:y,nextIndexRef:l}),[m,h,y,l]);return(0,K.jsx)(Vj.Provider,{value:b,children:t})}function nM(){return new Map}function rM(){return new Set}function iM(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>sM(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function aM(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function oM(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function sM(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var cM=20;function lM(e,t,n,r){let[i,a]=U.useState(!1);X(()=>{if(!e||!t||n==null){a(!1);return}let r=My(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-cM)},[e,t,n]),kT(e&&(!t||i),r)}var uM=U.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=gS,style:g,..._}=e,{store:v}=Nj(),y=$j(),b=Fj(!0),x=v.useState(`parent`),S=v.useState(`floatingRootContext`),C=v.useState(`floatingTreeRoot`),w=v.useState(`mounted`),T=v.useState(`open`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`activeTriggerElement`),k=v.useState(`transitionStatus`),A=v.useState(`positionerElement`),j=v.useState(`instantType`),M=v.useState(`adaptiveOrigin`),N=v.useState(`lastOpenChangeReason`),P=v.useState(`floatingNodeId`),F=v.useState(`floatingParentNodeId`),I=S.useState(`domReferenceElement`),L=U.useRef(null),R=Ow(A),ee=n,z=c,B=l,V=s,te=h;x.type===`context-menu`&&(ee=n??x.context?.anchor,V??=`start`,!o&&V!==`center`&&(B=e.alignOffset??2,z=e.sideOffset??-5));let H=o,ne=V;x.type===`menu`?(H??=`inline-end`,ne??=`start`,te=e.collisionAvoidance??_S):x.type===`menubar`&&(H??=x.context.orientation===`vertical`?`inline-end`:`bottom`,ne??=`start`);let re=x.type===`context-menu`,ie=cD({anchor:ee,floatingRootContext:S,positionMethod:b?`fixed`:r,mounted:w,side:H,sideOffset:z,align:ne,alignOffset:B,arrowPadding:re?0:f,collisionBoundary:u,collisionPadding:d,sticky:p,nodeId:P,keepMounted:y,disableAnchorTracking:m,collisionAvoidance:te,shift:re?{crossAxis:!(`side`in te&&te.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:C,adaptiveOrigin:M});U.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===P&&v.set(`hoverEnabled`,!1),e.nodeId!==P&&e.parentNodeId===v.select(`floatingParentNodeId`)&&v.setOpen(!1,Ky(Wy)))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[v,C.events,P]),U.useEffect(()=>{if(v.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==v.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;v.setOpen(!1,Ky(t))}return C.events.on(`menuopenchange`,e),()=>{C.events.off(`menuopenchange`,e)}},[C.events,v]);let ae=nb();U.useEffect(()=>{T||ae.clear()},[T,ae]),U.useEffect(()=>{function e(e){if(!(!T||e.nodeId!==v.select(`floatingParentNodeId`))){if(e.target&&O&&O!==e.target){let e=v.select(`closeDelay`);e>0?ae.isStarted()||ae.start(e,()=>{v.setOpen(!1,Ky(Wy))}):v.setOpen(!1,Ky(Wy))}else ae.clear()}}return C.events.on(`itemhover`,e),()=>{C.events.off(`itemhover`,e)}},[C.events,T,O,v,ae]),U.useEffect(()=>{let e={open:T,nodeId:P,parentNodeId:F,reason:v.select(`lastOpenChangeReason`)};C.events.emit(`menuopenchange`,e)},[C.events,T,v,P,F]),X(()=>{let e=I,t=L.current;if(e&&(L.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return R(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[I,R,v]);let oe={open:T,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:x.type===`menu`,instant:j},se=x.type===`menubar`&&x.context.modal;lM(T&&(se||E&&N!==`trigger-hover`),D===`touch`,A,O);let ce=fD(e,oe,{styles:ie.positionerStyles,transitionStatus:k,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!w,inert:!T}),le=w&&x.type!==`menu`&&(x.type!==`menubar`&&E&&N!==`trigger-hover`||x.type===`menubar`&&x.context.modal),ue=null;return x.type===`menubar`?ue=x.context.contentElement:x.type===void 0&&(ue=O),(0,K.jsxs)(Aj.Provider,{value:ie,children:[le&&(0,K.jsx)(ST,{ref:x.type===`context-menu`||x.type===`nested-context-menu`?x.context.internalBackdropRef:null,inert:xT(!T),cutout:ue}),(0,K.jsx)(jS,{id:P,children:(0,K.jsx)(tM,{elementsRef:v.context.itemDomElements,labelsRef:v.context.itemLabels,children:ce})})]})}),dM=U.createContext(null);function fM(e){let t=U.useContext(dM);if(t===null&&!e)throw Error(Cr(5));return t}var pM={...Jw,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},mM=class extends ww{constructor(e){super({...gM(),...e},hM(),pM),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function hM(){return{positionerRef:U.createRef(),popupRef:U.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:U.createRef(),beforeContentFocusGuardRef:U.createRef(),onOpenChangeComplete:void 0,triggerElements:new Vw}}function gM(){return{...Hw(),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new TS,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Lr,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0}}var _M=U.createContext(void 0);function vM(){return U.useContext(_M)}var yM=mw(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:l=`vertical`,actionsRef:u,closeParentOnEsc:d=!1,handle:f,triggerId:p,defaultTriggerId:m=null,highlightItemOnHover:h=!0}=e,g=Fj(!0),_=Nj(!0),v=fM(!0),y=vM(),b=U.useMemo(()=>y&&_?{type:`menu`,store:_.store}:v?{type:`menubar`,context:v}:g&&!_?{type:`context-menu`,context:g}:{type:void 0},[g,_,v,y]),x=bM({open:a,openProp:n,activeTriggerId:m,triggerIdProp:p,parent:b});x.useControlledProp(`openProp`,n),x.useControlledProp(`triggerIdProp`,p),x.useContextCallback(`onOpenChangeComplete`,i);let S=Xy(),C=Xy(),w=x.useState(`floatingTreeRoot`),T=AS(w),E=OS(),D=x.useState(`open`),O=x.useState(`activeTriggerElement`),k=x.useState(`positionerElement`),A=x.useState(`hoverEnabled`),j=x.useState(`disabled`),M=x.useState(`lastOpenChangeReason`),N=x.useState(`parent`),P=x.useState(`activeIndex`),F=x.useState(`payload`),I=x.useState(`floatingParentNodeId`),L=U.useRef(null),R=U.useRef(N.type!==`context-menu`),ee=nb(),z=U.useRef(!0),B=nb(),V=I!=null,{openMethod:te,triggerProps:H}=IT(D);x.useSyncedValues({disabled:o,highlightItemOnHover:h,modal:N.type===void 0?s:void 0,openMethod:te,rootId:S}),Lw(x);let{forceUnmount:ne}=Rw(D,x,()=>{x.set(`allowMouseEnter`,!1)});X(()=>{g&&!_?x.update({parent:{type:`context-menu`,context:g},floatingNodeId:T,floatingParentNodeId:E}):_&&x.update({floatingNodeId:T,floatingParentNodeId:E})},[g,_,T,E,x]),U.useEffect(()=>{if(D||(L.current=null),N.type===`context-menu`){if(!D){ee.clear(),R.current=!1;return}ee.start(500,()=>{R.current=!0})}},[ee,D,N.type]),X(()=>{!D&&!A&&x.set(`hoverEnabled`,!0)},[D,A,x]);let re=Ay((e,t)=>{let n=t.reason;if(!e&&!x.select(`open`)||D===e&&t.trigger===O&&M===n)return;let i=Fw(t);if(!e&&t.trigger==null&&(t.trigger=O??void 0),r?.(e,t),t.isCanceled)return;x.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!z.current)return;e&&n===`trigger-focus`?(z.current=!1,B.start(300,()=>{z.current=!0})):(z.current=!0,B.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null),c={open:e,openChangeReason:n};L.current=t.event,Pw(c,e,t.trigger,i()),x.update(c),N.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?x.set(`instantType`,`group`):o||s?x.set(`instantType`,o?`click`:`dismiss`):x.set(`instantType`,void 0)}),ie=Ew({popupStore:x,floatingId:C,nested:E!=null,onOpenChange:re}),ae=ie.context.events;X(()=>{let e=({open:e,eventDetails:t})=>re(e,t);return ae.on(`setOpen`,e),()=>{ae?.off(`setOpen`,e)}},[ae,re]);let oe=U.useCallback(()=>{x.setOpen(!1,Ky(Gy))},[x]);U.useImperativeHandle(u,()=>({unmount:ne,close:oe}),[ne,oe]);let se;N.type===`context-menu`&&(se=N.context),U.useImperativeHandle(se?.positionerRef,()=>k,[k]),U.useImperativeHandle(se?.actionsRef,()=>({setOpen:re}),[re]);let ce=KS(ie,{enabled:!j,bubbles:{escapeKey:d&&N.type===`menu`},outsidePress(){return N.type!==`context-menu`||L.current?.type===`contextmenu`||R.current},externalTree:V?w:void 0}),le=tE(),ue=U.useCallback(e=>{x.select(`activeIndex`)!==e&&x.set(`activeIndex`,e)},[x]),de=cT(ie,{enabled:!j,listRef:x.context.itemDomElements,activeIndex:P,nested:N.type!==void 0,loopFocus:c,orientation:l,parentOrientation:N.type===`menubar`?N.context.orientation:void 0,rtl:le===`rtl`,disabledIndices:Ir,onNavigate:ue,openOnArrowKeyDown:N.type!==`context-menu`,externalTree:V?w:void 0,focusItemOnHover:h}),fe=U.useCallback(e=>{x.context.typingRef.current=e},[x]),pe=lT(ie,{enabled:!j,listRef:x.context.itemLabels,elementsRef:x.context.itemDomElements,activeIndex:P,resetMs:500,onMatch:e=>{D&&e!==P&&x.set(`activeIndex`,e)},onTyping:fe});zw(x,{floatingRootContext:ie,activeTriggerProps:U.useMemo(()=>{let e=cr(pe.reference,de.reference,ce.reference,{onMouseMove(){x.set(`allowMouseEnter`,!0)}},H);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=D,e},[x,pe.reference,de.reference,ce.reference,H,D]),inactiveTriggerProps:U.useMemo(()=>{let e=cr(de.trigger,ce.trigger,H);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[de.trigger,ce.trigger,H]),popupProps:U.useMemo(()=>cr(Aw,{id:C,role:`menu`,"aria-labelledby":O?.id,onMouseMove(){x.set(`allowMouseEnter`,!0),N.type===`menu`&&x.set(`hoverEnabled`,!1)},onClick(){x.select(`hoverEnabled`)&&x.set(`hoverEnabled`,!1)},onKeyDown(e){let t=x.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},pe.floating,de.floating,ce.floating),[O,C,N.type,x,pe.floating,de.floating,ce.floating]),itemProps:de.item??Lr});let me=U.useMemo(()=>({store:x,parent:b}),[x,b]),he=(0,K.jsxs)(Mj.Provider,{value:me,children:[f&&(0,K.jsx)(Nw,{handle:f,store:x}),typeof t==`function`?t({payload:F}):t]});return N.type===void 0||N.type===`context-menu`?(0,K.jsx)(MS,{externalTree:w,children:he}):he});function bM(e){return Tr(()=>new mM(e)).current}var xM=5;function SM(e,t){let n=CM(t);return e.clientX>=n.left-xM&&e.clientX<=n.right+xM&&e.clientY>=n.top-xM&&e.clientY<=n.bottom+xM}function CM(e){let t=e.getBoundingClientRect(),n=ay(e);if(ub)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}function wM(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=jy(),{ref:i,index:a}=Uj(e),o=n===a,s=U.useRef(null),c=Er(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function TM(e){let{render:t,className:n,style:r,state:i=Lr,props:a=Ir,refs:o=Ir,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=wM({metadata:s});return Vr(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function EM(e){if(ly(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!xy(e))return EM(wy(e))}function DM(e,t){let n=U.useRef(null);function r(t){Gs.flushSync(()=>{e.setOpen(!1,Ky(Vy,t.nativeEvent,t.currentTarget))}),qx(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&Jx(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{Gs.flushSync(()=>{e.setOpen(!1,Ky(Vy,n.nativeEvent,n.currentTarget))});let i=Kx(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&yb(r,i);){let e=i;if(i=Ux(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function OM(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=U.useRef(!1);return U.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,My(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:Lr,[t,n,r])}var kM=hw(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:l=100,closeDelay:u=0,handle:d,payload:f,...p}=e,m=Nj(!0),h=Yw(d)??m?.store;if(!h)throw Error(Cr(85));let g=Zy(s),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=U.useRef(null),S=jM(),C=jy(!0),w=kS(),T=U.useMemo(()=>w??new TS,[w]),{registerTrigger:E,isMountedByThisTrigger:D}=Iw(g,x,h,{payload:f,closeDelay:u,parent:S,floatingTreeRoot:T,floatingNodeId:AS(T),floatingParentNodeId:OS(),keyboardEventRelay:C?.relayKeyboardEvent}),O=S.type===`menubar`,k=h.useState(`disabled`),A=a||k||O&&S.context.disabled,{getButtonProps:j,buttonRef:M}=Py({disabled:A,native:o});U.useEffect(()=>{!y&&S.type===void 0&&(h.context.allowMouseUpTriggerRef.current=!1)},[h,y,S.type]);let N=U.useRef(null),P=nb(),F=Ay(e=>{if(!N.current)return;P.clear(),h.context.allowMouseUpTriggerRef.current=!1;let t=e.target;yb(N.current,t)||yb(h.select(`positionerElement`),t)||t===N.current||(t==null||EM(t)!==h.select(`rootId`))&&(SM(e,N.current)||T.events.emit(`close`,{domEvent:e,reason:Uy}))});U.useEffect(()=>{y&&h.select(`lastOpenChangeReason`)===`trigger-hover`&&My(N.current).addEventListener(`mouseup`,F,{once:!0})},[y,F,h]);let I=O&&S.context.hasSubmenuOpen,L=rT(v,{enabled:(c??I)&&!A&&(!O||I&&!D),handleClose:hT({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:S.type===void 0?l:void 0,delay:{close:u},triggerElementRef:x,externalTree:T,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),R=AM(y,h.select(`lastOpenChangeReason`)),ee=US(v,{enabled:!A,event:y&&O?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:S.type===void 0&&R}),z=Zw(v,{enabled:!A&&I}),B=OM({open:y,enabled:O,mouseDownAction:`open`}),V=U.useMemo(()=>cr(z.reference,ee.reference),[z.reference,ee.reference]),te=h.useState(`triggerProps`,D),{preFocusGuardRef:H,handlePreFocusGuardFocus:ne,handleFocusTargetFocus:re}=DM(h,x),ie={disabled:A,open:y},ae=[N,t,M,E,x],oe=[V,L??Lr,te,{"aria-haspopup":`menu`,"aria-controls":b,id:g,onMouseDown:e=>{h.select(`open`)||(P.start(200,()=>{h.context.allowMouseUpTriggerRef.current=!0}),My(e.currentTarget).addEventListener(`mouseup`,F,{once:!0}))}},O?{role:`menuitem`}:{},B,p,j],se=Vr(`button`,e,{enabled:!O,stateAttributesMapping:$v,state:ie,ref:ae,props:oe});return O?(0,K.jsx)(TM,{tag:`button`,render:n,className:r,style:i,state:ie,refs:ae,props:oe,stateAttributesMapping:$v}):y?(0,K.jsxs)(U.Fragment,{children:[(0,K.jsx)(Gb,{ref:H,onFocus:ne},`${g}-pre-focus-guard`),(0,K.jsx)(U.Fragment,{children:se},g),(0,K.jsx)(Gb,{ref:h.context.triggerFocusTargetRef,onFocus:re},`${g}-post-focus-guard`)]}):(0,K.jsx)(U.Fragment,{children:se},g)});function AM(e,t){let n=nb(),[r,i]=U.useState(!1);return X(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function jM(){let e=fM(!0);return U.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}function MM(e){let[t,n]=U.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}function NM(e){let t=Sy(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ly(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r;return(Jb(n)!==a||Jb(r)!==o)&&(n=a,r=o),{width:n,height:r}}function PM(e){let{popupElement:t,positionerElement:n,content:r,mounted:i,onMeasureLayout:a,onMeasureLayoutComplete:o,side:s,direction:c}=e,l=Ow(t,!0),u=Vb(),d=U.useRef(null),f=U.useRef(!0),p=U.useRef(Fr),m=Ay(a),h=Ay(o),g=U.useMemo(()=>FM(s,c),[s,c]);X(()=>{if(!i){p.current=Fr,f.current=!0,d.current=null;return}if(!t||!n)return;p.current=LM(t,g),RM(t,`auto`);let e=IM(t,`position`,`static`),r=IM(t,`transform`,`none`),a=IM(t,`scale`,`1`),o=LM(n,{"--available-width":`max-content`,"--available-height":`max-content`});function s(){e(),r(),o()}function c(){s(),a()}if(m?.(),f.current||d.current===null){zM(n,`max-content`);let e=NM(t);return d.current=e,zM(n,e),c(),h?.(null,e),f.current=!1,()=>{p.current(),p.current=Fr}}zM(n,`max-content`);let _=d.current,v=NM(t);d.current=v,RM(t,_),c(),h?.(_,v),zM(n,v);let y=new AbortController;return u.request(()=>{RM(t,v),l(()=>{t.style.setProperty(`--popup-width`,`auto`),t.style.setProperty(`--popup-height`,`auto`)},y.signal)}),()=>{y.abort(),u.cancel(),p.current(),p.current=Fr}},[r,t,n,l,u,i,m,h,g])}function FM(e,t){let n=e===`top`,r=e===`left`||e===(t===`rtl`?`inline-end`:`inline-start`);return!n&&!r?Lr:{position:`absolute`,[n?`bottom`:`top`]:`0`,[r?`right`:`left`]:`0`}}function IM(e,t,n){let r=e.style.getPropertyValue(t);return e.style.setProperty(t,n),()=>{e.style.setProperty(t,r)}}function LM(e,t){let n=[];for(let[r,i]of Object.entries(t))n.push(IM(e,r,i));return n.length?()=>{n.forEach(e=>e())}:Fr}function RM(e,t){let n=t===`auto`?`auto`:`${t.width}px`,r=t===`auto`?`auto`:`${t.height}px`;e.style.setProperty(`--popup-width`,n),e.style.setProperty(`--popup-height`,r)}function zM(e,t){let n=t===`max-content`?`max-content`:`${t.width}px`,r=t===`max-content`?`max-content`:`${t.height}px`;e.style.setProperty(`--positioner-width`,n),e.style.setProperty(`--positioner-height`,r)}var BM={name:`adaptiveOrigin`,async fn(e){let{x:t,y:n,rects:{floating:r},elements:{floating:i},platform:a,strategy:o,placement:s}=e,c=ay(i),l=c.getComputedStyle(i);if(l.transitionDuration===`0s`||l.transitionDuration===``)return{x:t,y:n,data:rD};let u=await a.getOffsetParent?.(i),d={width:0,height:0};if(o===`fixed`&&c?.visualViewport)d={width:c.visualViewport.width,height:c.visualViewport.height};else if(u===c){let e=My(i);d={width:e.documentElement.clientWidth,height:e.documentElement.clientHeight}}else await a.isElement?.(u)&&(d=await a.getDimensions(u));let f=ex(s),p=t,m=n;f===`left`&&(p=d.width-(t+r.width)),f===`top`&&(m=d.height-(n+r.height));let h=f===`left`?`right`:rD.sideX,g=f===`top`?`bottom`:rD.sideY;return{x:p,y:m,data:{sideX:h,sideY:g}}}},VM={activationDirection:e=>e?{"data-activation-direction":e}:null};function HM(e){let{store:t,side:n,children:r}=e,i=tE(),a=t.useState(`activeTriggerElement`),o=t.useState(`activeTriggerId`),s=t.useState(`open`),c=t.useState(`payload`),l=t.useState(`mounted`),u=t.useState(`popupElement`),d=t.useState(`positionerElement`),f=MM(s?a:null),p=KM(o,c),m=U.useRef(null),[h,g]=U.useState(null),[_,v]=U.useState(null),y=U.useRef(null),b=U.useRef(null),x=Ow(y,!0),S=Vb(),C=U.useRef(null),[w,T]=U.useState(null),[E,D]=U.useState(!1);X(()=>(t.set(`adaptiveOrigin`,BM),()=>{t.set(`adaptiveOrigin`,void 0)}),[t]);let O=Ay(()=>{y.current?.style.setProperty(`animation`,`none`),y.current?.style.setProperty(`transition`,`none`),b.current?.style.setProperty(`display`,`none`)}),k=Ay(e=>{y.current?.style.removeProperty(`animation`),y.current?.style.removeProperty(`transition`),b.current?.style.removeProperty(`display`),e&&T(e)}),A=Ay(()=>{C.current?.abort();let e=new AbortController;C.current=e,x(()=>{g(null),T(null),m.current=null},e.signal)}),j=U.useRef(null);X(()=>{(!s||!l)&&(j.current=null)},[s,l]),X(()=>{if(a&&f&&a!==f&&j.current!==a&&m.current){g(m.current),D(!0);let e=GM(f,a);v(e),j.current=a}},[a,f]),X(()=>{h!=null&&(C.current?.abort(),D(!0),S.request(()=>{Gs.flushSync(()=>{D(!1)}),A()}))},[p,h,A,S]),X(()=>{let e=y.current;if(!e)return;let t=My(e).createElement(`div`);for(let n of Array.from(e.childNodes))t.appendChild(n.cloneNode(!0));m.current=t});let M=h!=null,N;N=M?(0,K.jsxs)(U.Fragment,{children:[(0,K.jsx)(`div`,{"data-previous":!0,inert:xT(!0),ref:b,style:{...w?{"--popup-width":`${w.width}px`,"--popup-height":`${w.height}px`}:null,position:`absolute`},"data-ending-style":E?void 0:``},`previous`),(0,K.jsx)(`div`,{"data-current":!0,ref:y,"data-starting-style":E?``:void 0,children:r},p)]}):(0,K.jsx)(`div`,{"data-current":!0,ref:y,children:r},p),X(()=>{let e=b.current;!e||!h||e.replaceChildren(...Array.from(h.childNodes))},[h]),PM({popupElement:u,positionerElement:d,mounted:l,content:c,onMeasureLayout:O,onMeasureLayoutComplete:k,side:n,direction:i});let P={activationDirection:UM(_),transitioning:M};return{children:N,state:P}}function UM(e){if(e)return`${WM(e.horizontal,5,`right`,`left`)} ${WM(e.vertical,5,`down`,`up`)}`}function WM(e,t,n,r){return e>t?n:e<-t?r:``}function GM(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return{horizontal:a.x-i.x,vertical:a.y-i.y}}function KM(e,t){let[n,r]=U.useState(0),i=U.useRef(e),a=U.useRef(t),o=U.useRef(!1);return X(()=>{let n=i.current,s=a.current,c=e!==n,l=t!==s;c?(r(e=>e+1),o.current=!l):o.current&&l&&(r(e=>e+1),o.current=!1),i.current=e,a.current=t},[e,t]),`${e??`current`}-${n}`}var qM=U.forwardRef(function(e,t){let{className:n,render:r,orientation:i=`horizontal`,style:a,...o}=e;return Vr(`div`,e,{state:{orientation:i},ref:t,props:[{role:`separator`,"aria-orientation":i},o]})});function JM(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}var YM=yM,XM=`relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-xl border bg-popover bg-clip-padding shadow-xl outline-none transition-[scale,opacity] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] focus:outline-none has-data-starting-style:scale-95 has-data-starting-style:opacity-0 has-data-ending-style:scale-95 has-data-ending-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`;function ZM(e){return(0,K.jsx)(kM,{"data-slot":`menu-trigger`,...e})}function QM({children:e,className:t,sideOffset:n=4,align:r=`center`,alignOffset:i,side:a=`bottom`,zIndex:o,...s}){let c=o??LE.MODAL_BACKDROP;return(0,K.jsxs)(eM,{children:[(0,K.jsx)(Ij,{className:`fixed inset-0`,"data-enso-float":``,style:{zIndex:c-1}}),(0,K.jsx)(uM,{align:r,alignOffset:i,"data-slot":`menu-positioner`,side:a,sideOffset:n,style:{zIndex:c},children:(0,K.jsx)(Zj,{className:G(XM,t),"data-slot":`menu-popup`,...s,children:(0,K.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1.5`,children:e})})})]})}var $M=`[&_svg]:-mx-0.5 flex min-h-8 cursor-default select-none items-center gap-2.5 whitespace-nowrap rounded-md px-2 py-1.5 text-base outline-none data-disabled:cursor-not-allowed data-disabled:bg-transparent! data-disabled:text-muted-foreground! data-highlighted:bg-accent data-inset:ps-8 data-[variant=destructive]:text-destructive data-highlighted:text-accent-foreground data-highlighted:data-[variant=destructive]:bg-destructive/10 data-highlighted:data-[variant=destructive]:text-destructive data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`;function eN(e){return(0,K.jsx)(Kj,{"data-slot":`menu-group`,...e})}function tN({className:e,inset:t,variant:n=`default`,style:r,...i}){return(0,K.jsx)(Jj,{className:G($M,e),"data-inset":t,"data-slot":`menu-item`,"data-variant":n,style:{WebkitAppRegion:`no-drag`,...r},...i})}function nN({className:e,inset:t,...n}){return(0,K.jsx)(qj,{className:G(`px-2 py-1.5 font-medium text-muted-foreground text-xs data-inset:ps-9 sm:data-inset:ps-8`,e),"data-inset":t,"data-slot":`menu-label`,...n})}function rN({className:e,...t}){return(0,K.jsx)(qM,{className:G(`mx-2 my-1 h-px bg-border`,e),"data-slot":`menu-separator`,...t})}function iN(e=`default`){return G(`relative inline-flex min-h-9 w-full min-w-36 select-none items-center justify-between gap-2 rounded-lg border border-input bg-background bg-clip-padding px-[calc(--spacing(3)-1px)] text-left text-base shadow-xs outline-none ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 focus-visible:border-ring focus-visible:ring-[3px] aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/16 data-disabled:pointer-events-none data-disabled:opacity-64 sm:min-h-8 sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/8%)] [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [[data-disabled],:focus-visible,[aria-invalid],[data-pressed]]:shadow-none`,e===`sm`&&`min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:min-h-7`,e===`lg`&&`min-h-10 sm:min-h-9`)}function aN(){return(0,K.jsx)(xt,{className:`-me-1 size-4.5 opacity-80 sm:size-4`})}var oN=U.createContext(void 0);function sN(){let e=U.useContext(oN);if(e===void 0)throw Error(Cr(63));return e}var cN={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},lN={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},uN={valid(e){return e===null?null:e?{"data-valid":``}:{"data-invalid":``}}},dN={...uN,checked(e){return e?{"data-checked":``}:{"data-unchecked":``}}},fN={invalid:void 0,name:void 0,validityData:{state:cN,errors:[],error:``,value:``,initialValue:null},setValidityData:Fr,disabled:void 0,setTouched:Fr,setDirty:Fr,setFilled:Fr,setFocused:Fr,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:lN,registerFieldControl:Fr,validation:{getValidationProps:(e,t=Lr)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:Fr,getInputControl:()=>null,commit:async()=>{},change:Fr}},pN=U.createContext(fN);function mN(e=!0){let t=U.useContext(pN);if(t.setValidityData===Fr&&!e)throw Error(Cr(28));return t}function hN(e,t,n,r,i=!0,a){let{registerFieldControl:o}=mN(),s=Tr(()=>Symbol());X(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),X(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var gN=U.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Fr,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function _N(){return U.useContext(gN)}var vN=U.createContext({controlId:void 0,registerControlId:Fr,labelId:void 0,setLabelId:Fr,messageIds:[],setMessageIds:Fr,getDescriptionProps:e=>e});function yN(){return U.useContext(vN)}function bN(e,t,n,r=!0,i){let[a,o]=U.useState(),s=Zy(i?`${i}-label`:void 0),c=e??t??a;return X(()=>{let i=e||t||!r?void 0:xN(n.current,s);a!==i&&o(i)}),c}function xN(e,t){let n=SN(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function SN(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function CN(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=yN(),o=Zy(t),s=n?i:void 0,c=Tr(()=>Symbol()),l=U.useRef(!1),u=U.useRef(t!=null),d=Ay(()=>{!l.current||a===Fr||(l.current=!1,a(c.current,void 0))});return X(()=>{if(a===Fr)return;let e;if(n){let n=r?.current;e=cy(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),U.useEffect(()=>d,[d]),i??o}var wN=U.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:v,...y}=e,{clearErrors:b}=_N(),{state:x,setTouched:S,setDirty:C,validityData:w,setFilled:T,setFocused:E,validationMode:D,disabled:O,name:k,validation:A}=mN(),{labelId:j}=yN(),M=O||m,N=k??l,P=U.useRef(null),F=Er(P,c,A.inputRef),I=U.useRef(null),L=Zy(),R=CN({id:s,implicit:!1,controlRef:I}),ee=u?void 0:R,[z,B]=Lj({controlled:n,default:!!i,name:`Switch`,state:`checked`});hN(I,L,z,void 0,!M,l),X(()=>{P.current&&T(P.current.checked)},[T]),PT(z,()=>{b(N),C(z!==w.initialValue),T(z),A.change(z)});let{getButtonProps:V,buttonRef:te}=Py({disabled:M,native:u}),H=bN(a,j,P,!u,ee),ne={id:u?R:L,role:`switch`,"aria-checked":z,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":H,onFocus(){M||E(!0)},onBlur(){let e=P.current;!e||M||(S(!0),E(!1),D===`onBlur`&&A.commit(e.checked))},onClick(e){if(f||M)return;e.preventDefault();let t=P.current;t&&Ny(t,e)}},re={...A.getValidationProps(M),checked:z,disabled:M,form:o,id:ee,name:N,required:p,style:N?Wb:Ub,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=Ky(Iy,e.nativeEvent);d?.(t,n),!n.isCanceled&&B(t)},onClick(e){e.stopPropagation()},onFocus(){I.current?.focus()},..._===void 0?Lr:{value:_}},ie=U.useMemo(()=>({...x,checked:z,disabled:M,readOnly:f,required:p}),[x,z,M,f,p]),ae=Vr(`span`,e,{state:ie,ref:[t,I,te],props:[ne,y,V,e=>A.getValidationProps(M,e)],stateAttributesMapping:dN});return(0,K.jsxs)(oN.Provider,{value:ie,children:[ae,!z&&N&&g!==void 0&&(0,K.jsx)(`input`,{type:`hidden`,form:o,name:N,value:g,disabled:M}),(0,K.jsx)(`input`,{...re,suppressHydrationWarning:!0})]})}),TN=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Vr(`span`,e,{state:sN(),ref:t,stateAttributesMapping:dN,props:a})});function EN({className:e,...t}){return(0,K.jsx)(wN,{className:G(`group/switch inset-shadow-[0_1px_--theme(--color-black/4%)] inline-flex h-5.5 w-9.5 shrink-0 items-center rounded-full p-px outline-none transition-all focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-checked:bg-primary data-unchecked:bg-input data-disabled:opacity-64 sm:h-4.5 sm:w-7.5`,e),"data-slot":`switch`,...t,children:(0,K.jsx)(TN,{className:G(`pointer-events-none block size-5 rounded-full bg-background shadow-sm transition-[translate,width] group-active/switch:not-data-disabled:w-5.5 data-checked:translate-x-4 data-unchecked:translate-x-0 data-checked:group-active/switch:translate-x-3.5 sm:size-4 sm:data-checked:translate-x-3 sm:group-active/switch:not-data-disabled:w-4.5 sm:data-checked:group-active/switch:translate-x-2.5`),"data-slot":`switch-thumb`})})}function DN(e){let t=e=>String(e>=100?Math.round(e):Math.round(e*10)/10);return e<1e3?String(e):e<1e6?`${t(e/1e3)}K`:`${t(e/1e6)}M`}function ON(e){let t=e/1e3;if(t<60)return`${Math.round(t*10)/10}s`;let n=Math.round(t);return`${Math.floor(n/60)}m${n%60}s`}var kN=`enso:open-chat-model-picker`;iN(`sm`),iN();function AN(){window.dispatchEvent(new Event(kN))}function jN(e,t){return e.filter(e=>e!==t)}var MN=new Map,NN=e=>e.images.length>0||e.segments.some(e=>e.type!==`text`||e.text.trim()!==``),PN=()=>!!window.electronAPI?.remote&&window.matchMedia?.(`(pointer: coarse)`).matches===!0;function FN({mentionConversationId:e,commands:t,running:n,busy:r,focusKey:i,pluginPresetId:a=null,autoFocus:o=!window.electronAPI?.remote,enterToSend:s=!PN(),toolbar:c,locked:l=!1,injectedDraft:u,injectedImages:d,injectedDraftAppend:f,onDraftConsumed:p,chatCandidates:m,onActivate:h,onSend:g,onAbort:_,queuedCount:v=0,onSteerQueued:y,isolated:b=!1,placeholder:x,planMode:S=!1,savePastedText:C}){let{t:w}=q(),T=OD(),D=E(e=>e.keybindings),O=E(e=>e.privacyMasking),k=MD(D)[`send-message`],A=(0,U.useId)(),[j,M]=(0,U.useState)([]),[N,P]=(0,U.useState)([]),[F,I]=(0,U.useState)(),L=(0,U.useRef)(i),[R,ee]=(0,U.useState)(!1),{setNodeRef:z,isOver:B}=ov({id:b?`isolated-composer:${i??`side`}`:ok,disabled:b}),[V,te]=(0,U.useState)(null),[H,ne]=(0,U.useState)(null),re=(0,U.useRef)(new Set),ie=(0,U.useRef)(g);ie.current=g;let ae=(0,U.useRef)(O);ae.current=O,(0,U.useEffect)(()=>{if(b)return;let e=JO(e=>oe.current?.insertMention(e)),t=XO(e=>oe.current?.insertText(e)),n=QO(e=>oe.current?.insertQuote(e)),r=YO(()=>oe.current?.focus()),i=nk((e,t)=>{t&&M(n=>[...n,{...t,id:e.imageId}]),oe.current?.insertMention(e),oe.current?.focus()}),a=rk(e=>{M(t=>[...t,{data:e.data,mimeType:e.mimeType}]),oe.current?.focus()}),o=ek(e=>{if(ue.current)return!1;let t=ae.current,n=t.enabled?Lv(e.text,t).blocked:[];return n.length>0?(hD({type:`error`,title:w(`Message not sent`),description:w(`Privacy masking blocks {{kinds}}. Remove it, or change the action or allow list in Settings → Privacy.`,{kinds:n.join(`, `)})}),!1):ie.current(e)!==!1});return()=>{e(),t(),n(),r(),i(),a(),o()}},[b,w]);let oe=(0,U.useRef)(null),se=(0,U.useRef)(null),ce=(0,U.useRef)(null),le=(0,U.useRef)(!1),ue=(0,U.useRef)(l);ue.current=l,(0,U.useEffect)(()=>{if(!(b||!i))return KD({key:i,segments:()=>oe.current?.getSegments()??[],insertText:e=>oe.current?.insertText(e),setText:e=>oe.current?.setSegments(e?[{type:`text`,text:e}]:[]),busy:()=>le.current||ue.current||!oe.current})},[b,i]);let[de,fe]=(0,U.useState)({left:0,flyoutSide:`right`}),[pe,me]=(0,U.useState)(``),[he,ge]=(0,U.useState)(!1),_e=(0,U.useRef)(Symbol(`composer`)),ve=pe.trim()!==``||he||j.length>0;(0,U.useEffect)(()=>RD(_e.current,ve),[ve]),(0,U.useEffect)(()=>()=>RD(_e.current,!1),[]);let[ye,be]=(0,U.useState)(null),xe=SD(e,ye,m),Se=(0,U.useMemo)(()=>vD(xe,ye??``),[xe,ye]),[Ce,we]=(0,U.useState)(null),[Te,Ee]=(0,U.useState)(null),[De,Oe]=(0,U.useState)(null),ke=LO(De,i??null),[Ae,je]=(0,U.useState)(0),[Me,Ne]=(0,U.useState)(null),[Pe,Fe]=(0,U.useState)(0),Ie=(0,U.useRef)(null),Le=(0,U.useCallback)(e=>{(e.plainText.trim()||e.hasMentions)&&h?.(),me(e.plainText),ge(e.hasMentions);let t=new Set(e.segments.filter(e=>e.type===`ui-element`&&e.imageId).map(e=>e.type===`ui-element`?e.imageId:``)),n=[...re.current].filter(e=>!t.has(e));re.current=t,n.length>0&&(M(e=>fv(e,n)),te(e=>e&&n.includes(e.imageId)?null:e)),be(t=>(t!==e.mentionQuery&&(je(0),Ne(null),Fe(0)),e.mentionQuery)),we(e.slashQuery),Ee(e.skillQuery),Oe(e.pluginQuery)},[h]);(0,U.useEffect)(()=>{let e=L.current;if(e!==i){if(e){let t={segments:oe.current?.getSegments()??[],images:j,slashes:N,recipient:F};MN.set(e,t),RD(`draft:${e}`,NN(t))}let t=i?MN.get(i):void 0;i&&RD(`draft:${i}`,!1);let n=i?qD(i):void 0;oe.current?.setSegments(n?[{type:`text`,text:n}]:t?.segments??[]),re.current=new Set((t?.segments??[]).filter(e=>e.type===`ui-element`&&e.imageId).map(e=>e.type===`ui-element`?e.imageId:``)),M(t?.images??[]),P(t?.slashes??[]),I(t?.recipient),L.current=i,be(null),we(null),Ee(null),je(0),Ne(null),Fe(0)}o&&oe.current?.focus()},[i]),(0,U.useEffect)(()=>{if(!u&&!d?.length)return;let e=mA({segments:oe.current?.getSegments()??[],images:j,slashes:N},{text:u,images:d},f);P(e.slashes),M(e.images),oe.current?.setSegments(e.segments),p?.(),window.setTimeout(()=>oe.current?.focus(),0)},[u,d,f]);let Re=N.length===1?N[0]:null,ze=zv(Re,pe.replaceAll(``,``)),Be=zA(t,Ce,Te),Ve=Ce===null&&Te===null&&ze!==null?Bv(Re,ze):[];(0,U.useEffect)(()=>{je(0)},[Ce,Te,ze,De]),(0,U.useEffect)(()=>{(Ie.current?.children[Ae])?.scrollIntoView({block:`nearest`})},[Ae]);let He=(0,U.useCallback)(e=>{if(e.kind===`agent-type`){oe.current?.consumeToken(`@`),I(e),be(null);return}oe.current?.insertMention(e),be(null)},[]),Ue=(0,U.useCallback)(e=>{Oe(null),RO(e,i??null).then(e=>{let t=oe.current;t&&(t.consumeToken(`#`),e&&t.insertText(e))})},[i]),We=ye!==null&&Se.length>0?`mention`:De!==null&&ke.length>0?`plugin`:Be.length>0?`slash`:Ve.length>0?`slash-sub`:null;(0,U.useLayoutEffect)(()=>{if(We!==`mention`)return;let e=se.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),n=e.querySelector(`[data-slot="mention-picker"]`),r=n?.querySelector(`[role="listbox"]`),i=n?.querySelector(`[data-slot="mention-flyout"]`),a=oe.current?.getMentionAnchorRect(),o=Bk({anchorLeft:a?a.left-t.left:0,containerWidth:t.width,popupWidth:r instanceof HTMLElement?r.offsetWidth:280,flyoutWidth:i instanceof HTMLElement?i.offsetWidth:252,flyoutGap:4});fe(e=>e.left===o.left&&e.flyoutSide===o.flyoutSide?e:o)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[ye,pe,Me,We]);let Ge=We===`mention`?Se.length:We===`plugin`?ke.length:We===`slash-sub`?Ve.length:Be.length,Ke=(0,U.useCallback)((e,t)=>{let n=[{type:`text`,text:e}];oe.current?.setSegments(n),t&&g(rA({segments:n,slashes:N,images:j,recipient:F}))!==!1&&(oe.current?.clear(),M([]),P([]),I(void 0),be(null),we(null),Ee(null))},[j,g,F,N]),qe=(0,U.useCallback)(e=>{oe.current?.consumeToken(Te===null?`/`:`$`),we(null),Ee(null);let t=VD(e);if(!t){P(t=>fA(t,e));return}UD(t,b?null:i??null).then(e=>{e&&hD({type:`error`,title:w(`Plugin command failed`),description:e})})},[Te,b,i,w]),Je=(0,U.useCallback)((e=!1)=>{if(We===`mention`){if(Me){let e=xe[Me][Pe];e&&He(e);return}let e=Se[Ae];e?.type===`item`&&He(e.candidate)}else if(We===`plugin`){let e=ke[Ae];e&&Ue(e)}else if(We===`slash`){let e=Be[Ae];e&&qe(e.name)}else if(We===`slash-sub`){let t=Ve[Ae];if(!t)return;Ke(t.name,e)}},[Ae,Pe,Me,xe,Se,He,Ue,ke,We,Be,qe,Ve,Ke]),Ye=pe.replaceAll(``,``).trim(),Xe=!!(Ye||N.length>0||j.length>0||he),Ze=F!==void 0,Qe=r&&!Ze,$e={sessionId:b?null:i??null,draft:pe.replaceAll(``,``),busy:l,pluginPresetId:a},et=n&&v>0&&y!==void 0&&s&&!!k,tt=et&&!Xe&&!Ze&&!l,nt=(0,U.useMemo)(()=>O.enabled&&Ye?Lv(Ye,O):null,[Ye,O]),W=()=>{if(!Xe)return;let e=rA({segments:oe.current?.getSegments()??[],slashes:N,images:j,recipient:F}),t=O.enabled?Lv(e.text,O).blocked:[];if(t.length>0){hD({type:`error`,title:w(`Message not sent`),description:w(`Privacy masking blocks {{kinds}}. Remove it, or change the action or allow list in Settings → Privacy.`,{kinds:t.join(`, `)})});return}g(e)!==!1&&(oe.current?.clear(),M([]),P([]),I(void 0),be(null),we(null),Ee(null))},rt=(0,U.useCallback)(e=>{for(let t of e){if(t.type.startsWith(`image/`)){let e=new FileReader;e.onload=()=>{let n=e.result,r=n.slice(n.indexOf(`,`)+1);M(e=>[...e,{data:r,mimeType:t.type}])},e.readAsDataURL(t);continue}let e=window.electronAPI.files.pathForFile(t),n=window.electronAPI.remote;if(!e&&n){n.upload(t).then(e=>{e&&oe.current?.insertFileChip(e)}).catch(()=>{});continue}e&&oe.current?.insertFileChip(e)}},[]);return(0,U.useEffect)(()=>{if(b)return;let e=ik(e=>{rt(e),oe.current?.focus()}),t=ak(e=>{for(let t of e)oe.current?.insertFileChip(t);oe.current?.focus()});return()=>{e(),t()}},[b,rt]),(0,K.jsxs)(`div`,{ref:se,className:`relative`,children:[We===`mention`&&(0,K.jsx)(cj,{id:A,groups:xe,query:ye??``,activeIndex:Ae,onActiveIndexChange:je,openFolderId:Me,folderIndex:Pe,onOpenFolderIdChange:Ne,onFolderIndexChange:Fe,onSelect:He,left:de.left,flyoutSide:de.flyoutSide}),We===`plugin`&&(0,K.jsx)(`div`,{ref:Ie,role:`listbox`,"aria-label":w(`Plugin suggestions`),className:`absolute bottom-full left-0 z-10 mb-1.5 max-h-64 w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:ke.map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===Ae,onMouseDown:e=>e.preventDefault(),onClick:()=>Ue(e),onMouseMove:()=>je(t),className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,t===Ae&&`bg-foreground/10`),children:[(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-muted-foreground`,children:`#`}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.item.label}),e.item.detail&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:e.item.detail})]},e.key))}),(We===`slash`||We===`slash-sub`)&&(0,K.jsx)(`div`,{ref:Ie,role:`listbox`,"aria-label":w(`Command suggestions`),className:`absolute bottom-full left-0 z-10 mb-1.5 max-h-64 w-full overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:(We===`slash`?Be:Ve).map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===Ae,onClick:()=>{je(t),We===`slash`?qe(e.name):Ke(e.name,!1)},onMouseMove:()=>je(t),className:G(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs`,t===Ae&&`bg-foreground/10`),children:[(0,K.jsx)(Gn,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono font-medium`,children:Te===null?e.name:`$${e.name.slice(7)}`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:w(e.description)})]},e.name))}),(0,K.jsxs)(`div`,{ref:z,"data-slot":`composer`,"data-enso":`composer`,className:G(`rounded-[24px] border bg-card shadow-[0_2px_6px_rgb(0_0_0/0.03),0_12px_32px_rgb(0_0_0/0.07)] transition-[border-color,box-shadow] duration-200 focus-within:border-foreground/20 [.dark_&]:shadow-[0_2px_6px_rgb(0_0_0/0.2),0_12px_32px_rgb(0_0_0/0.3)]`,(R||B)&&`border-brand/50 bg-brand/5`,(Ze||S)&&`border-primary/35 shadow-primary/5`),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),ee(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||ee(!1)},onDrop:e=>{let t=Array.from(e.dataTransfer.files);t.length!==0&&(e.preventDefault(),ee(!1),rt(t))},children:[j.filter(e=>!e.id).length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:j.filter(e=>!e.id).map((e,t)=>(0,K.jsxs)(`div`,{className:`group relative`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>ne(e),className:`block rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,"aria-label":w(`Preview`),children:(0,K.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`h-16 w-16 rounded-md border object-cover`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>M(t=>jN(t,e)),className:`absolute -top-1.5 -right-1.5 rounded-full border bg-background p-0.5 text-muted-foreground shadow-sm transition-opacity hover:text-destructive`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]},t))}),(0,K.jsxs)(`div`,{className:G(`flex items-start gap-1.5 px-4`,j.length>0?`pt-1.5`:`pt-3.5`),children:[F&&(0,K.jsx)(vA,{recipient:F,onRemove:()=>I(void 0)}),N.map(e=>(0,K.jsx)(uA,{name:e,className:`mt-0.5 shrink-0`,trailing:(0,K.jsx)(`button`,{type:`button`,onClick:()=>P(t=>t.filter(t=>t!==e)),className:`rounded-sm opacity-70 hover:opacity-100`,"aria-label":w(`Remove`),children:(0,K.jsx)(ir,{className:`h-3 w-3`})})},e)),(0,K.jsx)(nj,{ref:oe,placeholder:N.length>0?``:l?w(`Resolve the pending approval to continue`):Ze?w(`Message the selected Agent…`):et?w(`Press {{key}} to steer the next queued message into this round…`,{key:FD(k)}):x||w(n?`Message will queue until this round finishes…`:`Type @ to choose a file or Agent`),disabled:l,onStateChange:Le,onChipActivate:e=>{e.type===`ui-element`&&te({kind:`ui-element`,id:e.id,label:e.label,path:e.path,text:e.text,imageId:e.imageId})},onKeyDown:e=>{let t=e.nativeEvent.isComposing||le.current;if(We){let n=We===`mention`?Se[Ae]:void 0,r=Vk({key:e.key,shiftKey:e.shiftKey,isComposing:t,activeIndex:Ae,itemCount:Ge,folderOpen:We===`mention`&&Me!==null,activeIsFolder:We===`mention`&&n?.type===`folder`,folderIndex:Pe,folderItemCount:Me?xe[Me].length:0});if(r.type===`move`){e.preventDefault(),je(r.index),Ne(null);return}if(r.type===`move-folder`){e.preventDefault(),Fe(r.index);return}if(r.type===`open-folder`){e.preventDefault(),n?.type===`folder`&&Ne(n.id),Fe(0);return}if(r.type===`close-folder`){e.preventDefault(),Ne(null);return}if(r.type===`pick`){e.preventDefault(),Je(We===`slash-sub`&&e.key===`Enter`);return}if(r.type===`close`){e.preventDefault(),be(null),we(null),Ee(null),Oe(null),Ne(null);return}}if(t)return;let n=ND(e);if(!b&&n&&n===MD(E.getState().keybindings)[`switch-model`]){e.preventDefault(),AN();return}if(e.key===`Backspace`&&N.length>0&&Ye.length===0&&!he){e.preventDefault(),P(e=>e.slice(0,-1));return}if(e.key===`Backspace`&&F&&oe.current?.isEmpty()&&N.length===0){e.preventDefault(),I(void 0);return}s&&!We&&ND(e,{allowBare:!0})===k&&(e.preventDefault(),tt?y?.():W())},onPasteText:e=>!C||!mv(e)?!1:(C(e).catch(()=>({ok:!1,error:`unavailable`})).then(t=>{let n=oe.current;t.ok?n?.insertFileChip(t.path,`${pv} · ${w(`{{count}} chars`,{count:t.chars.toLocaleString()})}`):n?.insertText(e)}),!0),onPaste:e=>{let t=Array.from(e.clipboardData.files);t.length!==0&&(e.preventDefault(),rt(t))},onCompositionStart:()=>{le.current=!0},onCompositionEnd:()=>{le.current=!1},ariaProps:{role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":We!==null,"aria-controls":We===`mention`?A:void 0,"aria-activedescendant":We===`mention`?Me?`${A}-sub-${Pe}`:`${A}-option-${Ae}`:void 0}})]}),Ze&&(0,K.jsx)(`p`,{className:`sr-only`,children:w(`Send only to the selected Agent`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5 px-3 pt-0.5 pb-2.5`,children:[(0,K.jsxs)(`div`,{className:G(`flex min-w-0 flex-1 items-center`,T?`gap-0.5 overflow-x-auto [scrollbar-width:none]`:`gap-1 overflow-hidden`),children:[(0,K.jsx)(`input`,{ref:ce,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{rt(Array.from(e.target.files??[])),e.target.value=``}}),(0,K.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>ce.current?.click(),"aria-label":w(`Attach image`),title:w(`Attach image`),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40 max-md:size-[32px]`,children:(0,K.jsx)($t,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(_O,{side:`left`,...$e}),c,!b&&(0,K.jsx)(CO,{sessionId:$e.sessionId}),(0,K.jsx)(_O,{side:`right`,...$e}),nt&&(nt.blocked.length>0||nt.masked>0)&&(0,K.jsxs)(`span`,{className:G(`flex shrink-0 items-center gap-1 text-[11px]`,nt.blocked.length>0?`text-red-600 dark:text-red-400`:`text-sky-600 dark:text-sky-400`),"data-privacy-precheck":!0,children:[nt.blocked.length>0?(0,K.jsx)(Ln,{className:`size-3.5`}):(0,K.jsx)(Rn,{className:`size-3.5`}),nt.blocked.length>0?w(`Will be blocked: {{kinds}}`,{kinds:nt.blocked.join(`, `)}):w(`{{count}} will be masked`,{count:nt.masked})]})]}),Qe&&!Xe?(0,K.jsx)(Oa,{variant:`outline`,size:`icon`,className:`size-8 shrink-0 rounded-full`,onClick:_,"aria-label":w(`Stop`),children:(0,K.jsx)(Et,{className:`h-4 w-4`})}):(0,K.jsx)(Oa,{size:`icon`,className:`size-8 shrink-0 rounded-full bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-35`,onClick:W,disabled:!Xe||l,"aria-label":w(Ze?`Send only to the selected Agent`:`Send`),title:Ze?w(`Send only to the selected Agent`):s&&k?`${w(`Send`)} ${FD(k)}`:w(`Send`),children:(0,K.jsx)(ct,{className:`h-4 w-4`})})]})]}),(0,K.jsx)(zE,{open:V!==null,onOpenChange:e=>!e&&te(null),children:(0,K.jsxs)(WE,{className:`max-w-md`,children:[(0,K.jsx)(GE,{children:(0,K.jsx)(qE,{children:V?.label??w(`Selected UI element`)})}),(0,K.jsx)(XE,{className:`space-y-2 text-xs`,children:V&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-muted-foreground break-all`,children:V.path}),V.text&&(0,K.jsx)(`p`,{children:V.text}),(()=>{let e=j.find(e=>e.id===V.imageId);return e?(0,K.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``,className:`max-h-72 w-full rounded-md border object-contain`}):null})()]})})]})}),(0,K.jsx)(zE,{open:H!==null,onOpenChange:e=>!e&&ne(null),children:(0,K.jsxs)(WE,{className:`max-w-3xl`,children:[(0,K.jsx)(GE,{children:(0,K.jsx)(qE,{children:w(`Preview`)})}),(0,K.jsx)(XE,{children:H&&(0,K.jsx)(`img`,{src:`data:${H.mimeType};base64,${H.data}`,alt:``,className:`max-h-[80vh] w-full rounded-md object-contain`})})]})})]})}var IN=(0,U.createContext)(null);function LN(){return(0,U.useContext)(IN)}function RN({className:e}){return(0,K.jsx)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,"aria-hidden":`true`,className:G(`size-4`,e),children:(0,K.jsx)(`path`,{d:`M 38.96 48.86 A 18.24 18.24 0 1 1 48.19 40.4`,stroke:`currentColor`,strokeWidth:`8.32`,strokeLinecap:`round`})})}var zN=12e4;function BN(e){return{id:e.id,dueAt:e.dueAt,...e.label?{label:e.label}:{}}}function VN(e,t){return e.filter(e=>e.dueAt>t-zN).sort((e,t)=>e.dueAt-t.dueAt)}function HN(e,t){let n=VN(e,t),r=n[0];if(r)return{...BN(r),count:n.length}}function UN(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function WN(e,t,n){let r=e-t;if(r<=0)return n(`due now`);if(r<6e4)return n(`<1m`);let i=Math.ceil(r/6e4);if(i<60)return n(`in {{minutes}}m`,{minutes:i});let a=Math.floor(i/60),o=i%60;return o>0?n(`in {{hours}}h {{minutes}}m`,{hours:a,minutes:o}):n(`in {{hours}}h`,{hours:a})}function GN(e,t,n){let r=[`${n(`Waiting for reminder · {{time}}`,{time:UN(e.dueAt)})} (${WN(e.dueAt,t,n)})`];return e.label&&r.push(e.label),e.count>1&&r.push(n(`{{count}} reminders`,{count:e.count})),r.join(` — `)}var KN=6e4,qN=60*KN;1*KN,2*KN,5*KN,10*KN,15*KN,6*qN,30*KN,24*qN,1*KN,1*KN,2*KN,5*KN,10*KN;function JN(e){return e?.status===`waiting`&&e.retry?.reason===`upstream`}function YN(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var XN=3e4,ZN=kj(e=>({byConversation:{},replace:(t,n)=>e(e=>{let r={...e.byConversation};if(n.length>0)r[t]=n;else if(r[t])delete r[t];else return e;return{byConversation:r}}),replaceAll:t=>{let n={};for(let[e,r]of Object.entries(t))Array.isArray(r)&&r.length>0&&(n[e]=r);e({byConversation:n})}}));function QN(e,t=!0){let n=ZN(n=>t&&e?n.byConversation[e]:void 0),[,r]=(0,U.useState)(0),i=!!(n&&n.length>0);(0,U.useEffect)(()=>{if(!i)return;let e=setInterval(()=>r(e=>e+1),XN);return()=>clearInterval(e)},[i]);let a=Date.now();return!t||!n||n.length===0?{reminder:void 0,now:a}:{reminder:HN(n,a),now:a}}var $N={activeId:null,conversations:{},rewind:()=>{},retry:()=>{},forkFromMessage:async()=>null,selectConversation:()=>{},removeQueuedMessage:()=>{},updateQueuedMessage:()=>{},sendQueuedNow:()=>{},interruptAndSendQueued:async()=>{},pauseGoal:()=>{},resumeGoal:()=>{},clearGoal:()=>{}};function eP(e){Object.assign($N,e)}function tP(e){if(!e){$N.activeId=null,$N.conversations={};return}$N.activeId=e.id,$N.conversations={[e.id]:e}}function nP(e){return e($N)}nP.getState=()=>$N,nP.subscribe=e=>()=>{};var rP=`rounded-lg border border-border/60 bg-muted/20 px-2.5 py-1.5 text-xs`;function iP({className:e}){return(0,K.jsx)(Xn,{className:G(`h-3.5 w-3.5 shrink-0 text-muted-foreground`,e)})}var aP=`w-full overflow-hidden rounded-lg border border-dashed border-border/60 text-xs text-muted-foreground`,oP=G(aP,`px-3 py-2`),sP=`mt-0.5 h-3.5 w-3.5 shrink-0`,cP={active:`bg-green-500 animate-pulse`,paused:`bg-amber-500`,waiting:`bg-amber-500`,blocked:`bg-destructive`,completed:`bg-blue-500`};function lP({conversationId:e,goal:t,sessionStatus:n}){let{t:r}=q(),i=JN(t)?t.retry:void 0,{reminder:a,now:o}=QN(e,!i&&t.status===`active`&&n!==`running`),s={active:r(`working`),paused:r(`paused`),waiting:r(`waiting`),blocked:r(`blocked`),completed:r(`completed`)},c=i?i.kind===`quota`?r(`Quota exhausted · next {{time}}`,{time:YN(i.at)}):r(`Waiting for upstream recovery · next {{time}}`,{time:YN(i.at)}):s[t.status],l=a?GN(a,o,r):void 0;return(0,K.jsxs)(`div`,{className:G(`mb-1 flex items-center gap-2`,rP),children:[(0,K.jsx)(iP,{}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:i?.lastError?`${t.text} — ${i.lastError}`:l?`${t.text} — ${l}`:t.note?`${t.text} — ${t.note}`:t.text,children:[t.text,t.note&&(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,t.note]})]}),a?(0,K.jsxs)(`span`,{"data-enso":`goal-reminder-waiting`,title:l,className:`inline-flex min-w-0 max-w-[260px] shrink-0 items-center gap-1 rounded bg-sky-500/15 px-1.5 py-0.5 font-mono text-[10px] text-sky-600 tabular-nums dark:text-sky-400`,children:[(0,K.jsx)(jt,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`truncate`,children:[r(`Waiting for reminder · {{time}}`,{time:UN(a.dueAt)}),a.label?` · ${a.label}`:``]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,cP[t.status])}),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums`,children:[c,t.status===`active`&&t.autoTurns>0?` · ${t.autoTurns}/25`:``]})]}),i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`upstream-retry-now`,title:r(`Retry now`),onClick:()=>void nP.getState().retryUpstreamNow(e),className:`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] text-amber-600 transition-colors hover:bg-amber-500/10 dark:text-amber-400`,children:[(0,K.jsx)(Mn,{className:`h-3 w-3`}),r(`Retry now`)]}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`upstream-stop`,title:r(`Stop auto-retry`),onClick:()=>void nP.getState().abort(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive`,children:(0,K.jsx)(Jn,{className:`h-3 w-3`})})]}):t.status===`active`?(0,K.jsx)(`button`,{type:`button`,title:r(`Pause goal`),onClick:()=>nP.getState().pauseGoal(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(Sn,{className:`h-3.5 w-3.5`})}):t.status===`completed`?null:(0,K.jsx)(`button`,{type:`button`,title:r(`Resume goal`),onClick:()=>nP.getState().resumeGoal(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(Tn,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(`button`,{type:`button`,title:r(`Clear goal`),onClick:()=>nP.getState().clearGoal(e),className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]})}function uP(e,t){return e.trim().length>0||t>0}function dP(e,t){return e>0?`${e} ${t}`:null}var fP=dk;function pP(e){return!uk(e)}function mP({conversationId:e,queued:t}){let{t:n}=q(),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(``);if(t.length===0)return null;let s=t=>{uP(a,t.images?.length??0)&&nP.getState().updateQueuedMessage(e,t.id,a.trim()),i(null)};return(0,K.jsx)(`div`,{className:`mb-1 flex flex-col gap-0.5`,children:t.map(t=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 border-dashed bg-muted/20 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground uppercase tracking-wide`,children:n(`Queued`)}),r===t.id?(0,K.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`&&s(t),e.key===`Escape`&&i(null))},autoFocus:!0,className:`h-6 min-w-0 flex-1 rounded border bg-transparent px-1.5 outline-none focus:ring-1 focus:ring-ring`}):(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:fP(t.text)||`[image]`}),dP(t.images?.length??0,n(`attachments`))&&(0,K.jsxs)(`span`,{title:dP(t.images?.length??0,n(`attachments`))??void 0,className:`flex shrink-0 items-center gap-0.5 text-muted-foreground`,children:[(0,K.jsx)(tn,{className:`h-3 w-3`}),t.images?.length]}),r===t.id?(0,K.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(gt,{className:`h-3.5 w-3.5`})}):(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,title:n(`Withdraw message`),"aria-label":n(`Withdraw message`),onClick:()=>nP.getState().withdrawMessage(e,{kind:`queue`,id:t.id}),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Qn,{className:`h-3 w-3`})}),pP(t.text)&&(0,K.jsx)(`button`,{type:`button`,title:n(`Edit`),onClick:()=>{i(t.id),o(t.text)},className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Cn,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:n(`Send now`),onClick:()=>nP.getState().sendQueuedNow(e,t.id),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(Fn,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:n(`Interrupt and send now`),onClick:()=>void nP.getState().interruptAndSendQueued(e,t.id),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(qn,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:n(`Remove`),onClick:()=>nP.getState().removeQueuedMessage(e,t.id),className:`rounded p-0.5 text-muted-foreground hover:text-destructive`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]})]},t.id))})}var hP=0,gP=1,_P=2,vP=4;function yP(e){return()=>e}function bP(e){e()}function xP(e,t){return n=>e(t(n))}function SP(e,t){return()=>e(t)}function CP(e,t){return n=>e(t,n)}function wP(e){return e!==void 0}function TP(...e){return()=>{e.map(bP)}}function EP(){}function DP(e,t){return t(e),e}function OP(e,t){return t(e)}function kP(...e){return e}function AP(e,t){return e(gP,t)}function jP(e,t){e(hP,t)}function MP(e){e(_P)}function NP(e){return e(vP)}function PP(e,t){return AP(e,CP(t,hP))}function FP(e,t){let n=e(gP,e=>{n(),t(e)});return n}function IP(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function LP(e,t){return e===t}function RP(e=LP){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function zP(e){return t=>n=>{e(n)&&t(n)}}function BP(e){return t=>xP(t,e)}function VP(e){return t=>()=>{t(e)}}function Z(e,...t){let n=Xte(...t);return((t,r)=>{switch(t){case _P:MP(e);return;case gP:return AP(e,n(r))}})}function HP(e,t){return n=>r=>{n(t=e(t,r))}}function UP(e){return t=>n=>{e>0?e--:t(n)}}function WP(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function GP(...e){let t=Array.from({length:e.length}),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;AP(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function Xte(...e){return t=>e.reduceRight(OP,t)}function Zte(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case gP:return a?n===a?void 0:(r(),n=a,t=AP(e,a),t):(r(),EP);case _P:r(),n=null;return}}}function Q(e){let t=e,n=qP();return((e,r)=>{switch(e){case hP:t=r;break;case gP:r(t);break;case vP:return t}return n(e,r)})}function KP(e,t){return DP(Q(t),t=>PP(e,t))}function qP(){let e=[];return((t,n)=>{switch(t){case hP:e.slice().forEach(e=>{e(n)});return;case _P:e.splice(0);return;case gP:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function JP(e){return DP(qP(),t=>PP(e,t))}var Qte={singleton:!0};function YP(e,t=[],n=Qte){let{singleton:r}=n;return{constructor:e,dependencies:t,id:$te(),singleton:r}}var $te=()=>Symbol(`id`);function ene(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function XP(...e){let t=qP(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;AP(e,e=>{n[a]=e,r|=o,r===i&&jP(t,n)})}),function(e,a){switch(e){case _P:MP(t);return;case gP:return r===i&&a(n),AP(t,a)}}}function ZP(e,t=LP){return Z(e,RP(t))}function QP(...e){return function(t,n){switch(t){case _P:return;case gP:return TP(...e.map(e=>AP(e,n)))}}}var $P={DEBUG:0,INFO:1,WARN:2,ERROR:3},tne={[$P.DEBUG]:`debug`,[$P.ERROR]:`error`,[$P.INFO]:`log`,[$P.WARN]:`warn`},nne=()=>typeof globalThis>`u`?window:globalThis,eF=YP(()=>{let e=Q($P.ERROR);return{log:Q((t,n,r=$P.INFO)=>{r>=(nne().VIRTUOSO_LOG_LEVEL??NP(e))&&console[tne[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function rne(e){return`self`in e?e.document.documentElement:e}function tF(e){let t=rne(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function nF(e,t){return tF(e)?-t:t}function rF(e,t){return tF(e)?-t:t}function iF(e,t,n){return aF(e,t,n).callbackRef}function aF(e,t,n){let r=U.useRef(null),i=e=>{},a=U.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function oF(e,t,n,r,i,a,o,s,c){return aF(U.useCallback(n=>{let c=ine(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild?.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?nF(o,o.scrollLeft):o.scrollTop:u?s?nF(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?nF(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?sF(`column-gap`,getComputedStyle(n).columnGap,i):sF(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function ine(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index,10),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},$P.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function sF(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,$P.WARN),t===`normal`?0:parseInt(t??`0`,10)}function cF(e,t,n){let r=U.useRef(null),i=U.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=aF(i,!0,n),s=U.useCallback(()=>{i(o.current)},[i,o]);return U.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var lF=YP(()=>{let e=qP(),t=qP(),n=Q(0),r=qP(),i=Q(0),a=qP(),o=qP(),s=Q(0),c=Q(0),l=Q(0),u=Q(0),d=qP(),f=qP(),p=Q(!1),m=Q(!1),h=Q(!1);return PP(Z(e,BP(({scrollTop:e})=>e)),t),PP(Z(e,BP(({scrollHeight:e})=>e)),o),PP(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),uF={lvl:0};function dF(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function fF(e){return e===uF}function pF(e,t){if(!fF(e))return t===e.k?e.v:t<e.k?pF(e.l,t):pF(e.r,t)}function mF(e,t,n=`k`){if(fF(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=mF(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return mF(e.l,t,n)}function hF(e,t,n){return fF(e)?EF(t,n,1):t===e.k?SF(e,{k:t,v:n}):t<e.k?DF(SF(e,{l:hF(e.l,t,n)})):DF(SF(e,{r:hF(e.r,t,n)}))}function gF(){return uF}function _F(e,t,n){if(fF(e))return[];let r=mF(e,t)[0];return ane(bF(e,r,n))}function vF(e,t){if(fF(e))return uF;let{k:n,l:r,r:i}=e;if(t===n){if(fF(r))return i;if(fF(i))return r;let[t,n]=TF(r);return xF(SF(e,{k:t,l:CF(r),v:n}))}return xF(t<n?SF(e,{l:vF(r,t)}):SF(e,{r:vF(i,t)}))}function yF(e){return fF(e)?[]:[...yF(e.l),{k:e.k,v:e.v},...yF(e.r)]}function bF(e,t,n){if(fF(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(bF(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(bF(a,t,n))),s}function xF(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(wF(t))return OF(SF(e,{lvl:n-1}));if(!fF(t)&&!fF(t.r))return SF(t.r,{l:SF(t,{r:t.r.l}),lvl:n,r:SF(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(wF(e))return kF(SF(e,{lvl:n-1}));if(!fF(r)&&!fF(r.l)){let t=r.l,i=wF(t)?r.lvl-1:r.lvl;return SF(t,{l:SF(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:kF(SF(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function SF(e,t){return EF(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function CF(e){return fF(e.r)?e.l:xF(SF(e,{r:CF(e.r)}))}function wF(e){return fF(e)||e.lvl>e.r.lvl}function TF(e){return fF(e.r)?[e.k,e.v]:TF(e.r)}function EF(e,t,n,r=uF,i=uF){return{k:e,l:r,lvl:n,r:i,v:t}}function DF(e){return kF(OF(e))}function OF(e){let{l:t}=e;return!fF(t)&&t.lvl===e.lvl?SF(t,{r:SF(e,{l:t.r})}):e}function kF(e){let{lvl:t,r:n}=e;return!fF(n)&&!fF(n.r)&&n.lvl===t&&n.r.lvl===t?SF(n,{l:SF(e,{r:n.l}),lvl:t+1}):e}function ane(e){return dF(e,({k:e,v:t})=>({index:e,value:t}))}function AF(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function jF(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var MF=YP(()=>({recalcInProgress:Q(!1)}),[],{singleton:!0});function NF(e,t,n){return e[PF(e,t,n)]}function PF(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function one(e,t,n,r){let i=PF(e,t,r),a=PF(e,n,r,i);return e.slice(i,a+1)}function FF(e,t){return Math.round(e.getBoundingClientRect()[t])}function IF(e){return!fF(e.groupOffsetTree)}function LF({index:e},t){return t===e?0:t<e?-1:1}function sne(){return{groupIndices:[],groupOffsetTree:gF(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:gF()}}function cne(e,t){let n=fF(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),fF(e)){e=hF(e,0,i);continue}let o=_F(e,a-1,t+1);if(o.some(hne(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=vF(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=hF(e,t+1,a));c&&(e=hF(e,a,i))}return[e,n]}function lne(e){return e.groupIndex!==void 0}function une({offset:e},t){return t===e?0:t<e?-1:1}function RF(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=NF(t,e,LF),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function zF(e,t){if(!IF(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function BF(e,t,n){if(lne(e))return t.groupIndices[e.groupIndex]+1;let r=zF(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function dne(e,t,n,r=0){return r>0&&(t=Math.max(t,NF(e,r,LF).offset)),dF(one(e,t,n,une),mne)}function fne(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,$P.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&fF(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>hF(hF(t,n,e),n+1,r),o)}else[o,s]=cne(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=HF(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>hF(e,t,RF(t,d,i)),gF()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function pne(e){return yF(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function VF(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function HF(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=PF(i,t-1,LF),s=i[c].offset;let e=mF(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===mF(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of _F(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function mne(e){return{index:e.index,value:e}}function hne(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var gne={offsetHeight:`height`,offsetWidth:`width`},UF=YP(([{log:e},{recalcInProgress:t}])=>{let n=qP(),r=qP(),i=KP(r,0),a=qP(),o=qP(),s=Q(0),c=Q([]),l=Q(void 0),u=Q(void 0),d=Q(void 0),f=Q(void 0),p=Q((e,t)=>FF(e,gne[t])),m=Q(void 0),h=Q(0),g=sne(),_=KP(Z(n,GP(c,e,h),HP(fne,g),RP()),g),v=KP(Z(c,RP(),HP((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),BP(({prev:e})=>e)),[]);PP(Z(c,zP(e=>e.length>0),GP(_,h),BP(([e,t,n])=>{let r=e.reduce((e,r,i)=>hF(e,r,RF(r,t.offsetTree,n)||i),gF());return{...t,groupIndices:e,groupOffsetTree:r}})),_),PP(Z(r,GP(_),zP(([e,{lastIndex:t}])=>e<t),BP(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),PP(l,u);let y=KP(Z(l,BP(e=>e===void 0)),!0);PP(Z(u,zP(e=>e!==void 0&&fF(NP(_).sizeTree)),BP(e=>{let t=NP(d),n=NP(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),PP(Z(f,zP(e=>e!==void 0&&e.length>0&&fF(NP(_).sizeTree)),BP(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),PP(Z(c,GP(d,u),zP(([,e,t])=>e!==void 0&&t!==void 0),BP(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=JP(Z(n,GP(_),HP(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),BP(e=>e.changed)));AP(Z(s,HP((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),BP(e=>e.diff)),e=>{let{groupIndices:n}=NP(_);if(e>0)jP(t,!0),jP(a,e+VF(e,n));else if(e<0){let t=NP(v);t.length>0&&(e-=VF(-e,t)),jP(o,e)}}),AP(Z(s,GP(e)),([e,t])=>{e<0&&t("`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:s},$P.ERROR)});let x=JP(a);PP(Z(a,GP(_),BP(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=pF(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=yF(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return yF(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=JP(Z(o,GP(_,h),BP(([e,{offsetTree:t},n])=>RF(-e,t,n))));return PP(Z(o,GP(_,h),BP(([e,t,n])=>{if(t.groupIndices.length>0){if(fF(t.sizeTree))return t;let r=gF(),i=NP(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=yF(t.sizeTree).reduce((t,{k:n,v:r})=>hF(t,Math.max(0,n+e),r),r),a!==-e){let n=pF(t.sizeTree,s);r=hF(r,0,n);let i=mF(t.sizeTree,-e+1)[1];r=hF(r,1,i)}return{...t,sizeTree:r,...HF(t.offsetTree,0,r,n)}}let r=yF(t.sizeTree).reduce((t,{k:n,v:r})=>hF(t,Math.max(0,n+e),r),gF());return{...t,sizeTree:r,...HF(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},kP(eF,MF),{singleton:!0});function _ne(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var WF=YP(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=qP(),o=qP(),s=JP(Z(a,BP(_ne)));return PP(Z(s,BP(e=>e.totalCount)),n),PP(Z(s,BP(e=>e.groupIndices)),e),PP(Z(XP(i,t,r),zP(([e,t])=>IF(t)),BP(([e,t,n])=>mF(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),RP(),BP(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},kP(UF,lF)),GF=YP(([{log:e}])=>{let t=Q(!1),n=JP(Z(t,zP(e=>e),RP()));return AP(t,t=>{t&&NP(e)(`props updated`,{},$P.DEBUG)}),{didMount:n,propsReady:t}},kP(eF),{singleton:!0}),vne=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function KF(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!vne)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var qF=YP(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=qP(),m=qP(),h=Q(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),jP(c,!1)}return PP(Z(p,GP(n,d,r,h,s,o,f),GP(e,a,i),BP(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=KF(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=BF(b,n,w),E=RF(T,n.offsetTree,d)+o;x===`end`?(E+=f+mF(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+mF(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},$P.DEBUG),jP(p,e)):(jP(m,!0),l(`list did not change, scroll successful`,{},$P.DEBUG))};if(y(),S===`smooth`){let e=!1;v=AP(t,t=>{e||=t}),g=FP(u,()=>{D(e)})}else g=FP(Z(t,yne(150)),D);return _=setTimeout(()=>{y()},1200),jP(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},$P.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},kP(UF,lF,eF),{singleton:!0});function yne(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function JF(e,t){e===0?t():requestAnimationFrame(()=>{JF(e-1,t)})}function YF(e,t){if(e===void 0)return 0;let n=t-1,r=typeof e==`number`?e:e.index===`LAST`?n:e.index;return Math.max(0,Math.min(r,n))}function XF(e){return e===void 0?!0:typeof e==`number`?e===0:e.index===0&&(e.align===void 0||e.align===`start`)&&(e.offset===void 0||e.offset===0)}var ZF=YP(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=Q(!0),c=Q(0),l=Q(!0);return PP(Z(o,GP(c),zP(([e,t])=>!XF(t)),VP(!1)),s),PP(Z(o,GP(c),zP(([e,t])=>!XF(t)),VP(!1)),l),AP(Z(XP(t,o),GP(s,n,e,l),zP(([[,e],t,{sizeTree:n},r,i])=>e&&(!fF(n)||wP(r))&&!t&&!i),GP(c)),([,e])=>{if(e===void 0){jP(s,!0),jP(l,!0);return}FP(i,()=>{jP(l,!0)}),JF(4,()=>{FP(r,()=>{jP(s,!0)}),jP(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},kP(UF,lF,qF,GF),{singleton:!0});function QF(e,t){return Math.abs(e-t)<1.01}var $F=`up`,eI=`down`,bne=`none`,xne={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Sne=0,tI=YP(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=Q(!1),s=Q(!0),c=qP(),l=qP(),u=Q(4),d=Q(Sne),f=KP(Z(QP(Z(ZP(i),UP(1),VP(!0)),Z(ZP(i),UP(1),VP(!1),IP(100))),RP()),!1),p=KP(Z(QP(Z(n,VP(!0)),Z(n,VP(!1),IP(200))),RP()),!1);PP(Z(XP(ZP(i),ZP(d)),BP(([e,t])=>e<=t),RP()),s),PP(Z(s,WP(50)),l);let m=JP(Z(XP(r,ZP(a),ZP(t),ZP(e),ZP(u)),HP((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},xne),RP((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=KP(Z(r,HP((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!QF(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),zP(e=>e.changed),BP(e=>e.jump)),0);PP(Z(m,BP(e=>e.atBottom)),o),PP(Z(o,WP(50)),c);let g=Q(eI);PP(Z(r,BP(({scrollTop:e})=>e),RP(),HP((e,t)=>NP(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?$F:eI,prevScrollTop:t},{direction:eI,prevScrollTop:0}),BP(e=>e.direction)),g),PP(Z(r,WP(50),VP(bne)),g);let _=Q(0);return PP(Z(f,zP(e=>!e),VP(0)),_),PP(Z(i,WP(100),GP(f),zP(([e,t])=>t),HP(([e,t],[n])=>[t,n],[0,0]),BP(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},kP(lF)),nI=`top`,rI=`bottom`,iI=`none`;function aI(e,t,n){return typeof e==`number`?n===$F&&t===nI||n===eI&&t===rI?e:0:n===$F?t===nI?e.main:e.reverse:t===rI?e.main:e.reverse}function oI(e,t){return typeof e==`number`?e:e[t]??0}var sI=YP(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=qP(),o=Q(0),s=Q(0),c=Q(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:KP(Z(XP(ZP(r),ZP(i),ZP(n),ZP(a,jF),ZP(c),ZP(o),ZP(t),ZP(e),ZP(s)),BP(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=iI,m=oI(l,nI),h=oI(l,rI);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=$F),i<e-f+t+h&&(p=eI),p===iI?null:[Math.max(u-n-aI(a,nI,p)-m,0),u-f-s+t+aI(a,rI,p)+h]}),zP(e=>e!==null),RP(jF)),[0,0])}},kP(lF),{singleton:!0});function Cne(e,t,n){if(IF(t)){let r=zF(e,t);return[{index:mF(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var cI={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function lI(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:dI(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:dI(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function uI(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=YF(t,s);return lI(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function dI(e,t,n){if(e.length===0)return[];if(!IF(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=_F(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function fI(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var pI=YP(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=Q([]),g=Q(0),_=qP(),v=Q(0);PP(a.topItemsIndexes,h);let y=KP(Z(XP(p,m,ZP(c,jF),ZP(i),ZP(r),ZP(l),u,ZP(h),ZP(t),ZP(n),ZP(v),e),zP(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),BP(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=NP(g);if(n===0)return{...cI,totalCount:n};if(e===0&&t===0)return m===0?{...cI,totalCount:n}:uI(m,i,r,s,c,u||[]);if(fF(p))return m>0?null:lI(Cne(YF(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of _F(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return lI([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=dne(f,e,t,_);if(v.length===0)return null;let y=n-1,b=DP([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<_&&(a+=(_-o)*s,o=_);let l=Math.min(r.end,y);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=fI(l,nI),S=fI(l,rI);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=_F(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.index<y){let e=Math.min(S,y-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=_F(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return lI(b,h,n,c,d,s)}),zP(e=>e!==null),RP()),cI);PP(Z(e,zP(wP),BP(e=>e?.length)),i),PP(Z(y,BP(e=>e.topListHeight)),d),PP(d,s),PP(Z(y,BP(e=>[e.top,e.bottom])),o),PP(Z(y,BP(e=>e.items)),_);let b=JP(Z(y,zP(({items:e})=>e.length>0),GP(i,e),zP(([{items:e},t])=>e[e.length-1].originalIndex===t-1),BP(([,e,t])=>[e-1,t]),RP(jF),BP(([e])=>e))),x=JP(Z(y,WP(200),zP(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),BP(({items:e})=>e[0].index),RP()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:JP(Z(y,zP(({items:e})=>e.length>0),BP(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),RP(AF))),startReached:x,topItemsIndexes:h,...f}},kP(UF,WF,sI,ZF,qF,tI,GF,MF),{singleton:!0}),mI=YP(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=qP(),o=KP(Z(XP(n,e,r,t,i),BP(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return PP(ZP(o),a),{totalListHeight:o,totalListHeightChanged:a}},kP(lF,pI),{singleton:!0}),wne=YP(([{viewportHeight:e},{totalListHeight:t}])=>{let n=Q(!1);return{alignToBottom:n,paddingTopAddition:KP(Z(XP(n,e,t),zP(([e])=>e),BP(([,e,t])=>Math.max(0,e-t)),WP(0),RP()),0)}},kP(lF,mI),{singleton:!0}),hI=YP(()=>({context:Q(null)})),Tne=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,gI=YP(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=qP();return PP(Z(u,GP(t,c,n,a,i,r,s),GP(e),BP(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=Tne,done:d,...f}=e,p=BF(e,t,r-1),m=RF(p,t.offsetTree,l)+i+a,h=m+mF(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&FP(Z(o,zP(e=>!e),UP(NP(o)?1:2)),d),_}),zP(e=>e!==null)),l),{scrollIntoView:u}},kP(UF,lF,qF,pI,eF),{singleton:!0});function _I(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var Ene=(e,t)=>typeof e==`function`?_I(e(t)):t&&_I(e),Dne=YP(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=Q(!1),h=qP(),g=null;function _(e){jP(o,{align:`end`,behavior:e,index:`LAST`})}AP(Z(XP(Z(ZP(t),UP(1)),c),GP(ZP(m),a,s,d),BP(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=Ene(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),zP(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),NP(n)===void 0?g=FP(e,()=>{NP(u)(`following output to `,{totalCount:r},$P.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{NP(u)(`following output to `,{totalCount:r},$P.DEBUG),_(t)})});function v(e){let t=FP(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(NP(u)(`scrolling to bottom due to increased size`,{},$P.DEBUG),_(`auto`))});setTimeout(t,100)}AP(Z(XP(ZP(m),t,l),zP(([e,,t])=>e!==!1&&t),HP(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),zP(({refreshed:e})=>e),GP(m,t)),([,e])=>{NP(s)&&v(e!==!1)}),AP(h,()=>{v(NP(m)!==!1)}),AP(XP(ZP(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=Q(null),b=qP();return PP(QP(Z(ZP(r),BP(e=>e?.length??0)),Z(ZP(t))),b),AP(Z(XP(Z(b,UP(1)),c),GP(ZP(y),s,d,f),BP(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),zP(e=>!!e),WP(0)),t=>{g!==null&&(g(),g=null),NP(n)===void 0?g=FP(e,()=>{NP(u)(`scrolling into view`,{}),jP(p,t),g=null}):requestAnimationFrame(()=>{NP(u)(`scrolling into view`,{}),jP(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},kP(UF,tI,qF,ZF,GF,eF,lF,hI,gI)),One=YP(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(PP(Z(s,GP(a),zP(([,e])=>e!==0),GP(i,r,t,n,e),BP(([[,e],t,n,r,i,a=[]])=>uI(e,t,n,r,i,a))),o),{}),kP(UF,ZF,pI,GF),{singleton:!0}),kne=YP(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=Q(0);return AP(Z(e,GP(r),zP(([,e])=>e!==0),BP(([,e])=>({top:e}))),e=>{FP(Z(n,UP(1),zP(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{jP(t,e)})})}),{initialScrollTop:r}},kP(GF,lF,pI),{singleton:!0}),vI=YP(([{scrollVelocity:e}])=>{let t=Q(!1),n=qP(),r=Q(!1);return PP(Z(e,GP(r,t,n),zP(([e,t])=>t!==!1&&t!==void 0),BP(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),RP()),t),AP(Z(XP(t,e,n),GP(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},kP(tI),{singleton:!0}),yI=YP(([{scrollContainerState:e,scrollTo:t}])=>{let n=qP(),r=qP(),i=qP(),a=Q(!1),o=Q(void 0);return PP(Z(XP(n,r),BP(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),PP(Z(t,GP(r),BP(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},kP(lF)),Ane=YP(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=qP(),u=Q(void 0),d=Q(null),f=Q(null);return PP(s,d),PP(c,f),AP(Z(l,GP(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=pne(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),PP(Z(u,zP(wP),BP(jne)),i),PP(Z(a,GP(u),zP(([,e])=>e!==void 0),RP(),BP(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},kP(UF,lF,ZF,GF,yI));function jne(e){return{align:`start`,index:0,offset:e.scrollTop}}var Mne=YP(([{topItemsIndexes:e}])=>{let t=Q(0);return PP(Z(t,zP(e=>e>=0),BP(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},kP(pI));function bI(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var Nne=bI(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),xI=YP(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:k,...A}=b;return PP(k,T.scrollSeekRangeChanged),PP(Z(XP(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),BP(([e,t,n])=>Math.max(t+n+1,e.visibleHeight))),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:k,...A,...T,..._,sizes:u,...v}},kP(UF,ZF,lF,Ane,Dne,pI,qF,YP(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=JP(Z(c,GP(o),HP(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),zP(([e])=>e!==0),GP(r,s,n,i,p,m),zP(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===$F),BP(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},$P.DEBUG),e))));function g(n){n>0?(jP(t,{behavior:`auto`,top:-n}),jP(e,0)):(jP(e,0),jP(t,{behavior:`auto`,top:-n}))}return AP(Z(h,GP(e,a)),([t,n,r])=>{r&&Nne()?jP(e,n-t):g(-t)}),AP(Z(XP(KP(a,!1),e,m),zP(([e,t,n])=>!e&&!n&&t!==0),BP(([e,t])=>t),WP(1)),g),PP(Z(d,BP(e=>({top:-e}))),t),AP(Z(l,GP(f,u),BP(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=pF(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{jP(e,n),requestAnimationFrame(()=>{jP(t,{top:n}),requestAnimationFrame(()=>{jP(e,0),jP(m,!1)})})}),{deviation:e}},kP(lF,tI,pI,UF,eF,MF)),Mne,WF,YP(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),kP(sI,One,GF,vI,mI,kne,wne,yI,gI,eF,hI))));function Pne(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var SI=typeof document>`u`?U.useEffect:U.useLayoutEffect;function CI(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=U.createContext({});function c(e,n){e.propsReady!==void 0&&jP(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];jP(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];jP(i,n[r])}e.propsReady!==void 0&&jP(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];jP(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=Zte(e[t.events[r]]),n),{})}return{Component:U.forwardRef(function(t,a){let{children:d,...f}=t,[p]=U.useState(()=>DP(ene(e),e=>{c(e,f)})),[m]=U.useState(SP(u,p));SI(()=>{for(let e of o)e in f&&AP(m[e],f[e]);return()=>{Object.values(m).map(MP)}},[f,m,p]),SI(()=>{c(p,f)}),U.useImperativeHandle(a,yP(l(p)));let h=n;return(0,K.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,K.jsx)(h,{...Pne([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=U.useContext(s)[e];SI(()=>AP(n,t),[t,n])},useEmitterValue:e=>{let t=U.useContext(s)[e],n=U.useCallback(e=>AP(t,e),[t]);return U.useSyncExternalStore(n,()=>NP(t),()=>NP(t))},usePublisher:e=>{let t=U.useContext(s);return U.useCallback(n=>{jP(t[e],n)},[t,e])}}}var wI=U.createContext(void 0),TI=U.createContext(void 0),EI=`-webkit-sticky`,DI=`sticky`,OI=bI(()=>{if(typeof document>`u`)return DI;let e=document.createElement(`div`);return e.style.position=EI,e.style.position===EI?EI:DI}),kI=typeof document>`u`?U.useEffect:U.useLayoutEffect;function AI(e){return`self`in e}function jI(e){return`body`in e}function MI(e,t,n,r=EP,i,a){let o=U.useRef(null),s=U.useRef(null),c=U.useRef(null),l=U.useCallback(n=>{let r,i,o,l=n.target;if(jI(l)||AI(l)){let e=AI(l)?l:l.defaultView;o=a===!0?nF(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?nF(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():Gs.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);U.useEffect(()=>{let e=i??o.current;return r(i??o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;AI(r)?(u=Math.max(FF(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?nF(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=FF(r,a===!0?`width`:`height`),d=a===!0?nF(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,QF(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:rF(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:rF(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function NI(e){return e}var PI=YP(([e,t])=>({...e,...t}),kP(xI,YP(()=>{let e=Q(e=>`Item ${e}`),t=Q(e=>`Group ${e}`),n=Q({}),r=Q(NI),i=Q(`div`),a=Q(EP),o=(e,t=null)=>KP(Z(n,BP(t=>t[e]),RP()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),FI=({height:e})=>(0,K.jsx)(`div`,{style:{height:e}}),II={overflowAnchor:`none`,position:OI(),zIndex:1},LI={overflowAnchor:`none`},RI={...LI,display:`inline-block`,height:`100%`},zI=U.memo(function({showTopList:e=!1}){let t=nL(`listState`),n=rL(`sizeRanges`),r=nL(`useWindowScroll`),i=nL(`customScrollParent`),a=rL(`windowScrollContainerState`),o=rL(`scrollContainerState`),s=i||r?a:o,c=nL(`itemContent`),l=nL(`context`),u=nL(`groupContent`),d=nL(`trackItemSizes`),f=nL(`itemSize`),p=nL(`log`),m=rL(`gap`),h=nL(`horizontalDirection`),{callbackRef:g}=oF(n,f,d,e?EP:s,p,m,i,h,nL(`skipAnimationFrameInResizeObserver`)),[_,v]=U.useState(0);tL(`deviation`,e=>{_!==e&&v(e)});let y=nL(`EmptyPlaceholder`),b=nL(`ScrollSeekPlaceholder`)??FI,x=nL(`ListComponent`),S=nL(`ItemComponent`),C=nL(`GroupComponent`),w=nL(`computeItemKey`),T=nL(`isSeeking`),E=nL(`groupIndices`).length>0,D=nL(`alignToBottom`),O=nL(`initialItemFinalLocationReached`),k=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:_===0?D?`auto`:0:_,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:_===0?D?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...O?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&y!=null?(0,K.jsx)(y,{...GI(y,l)}):(0,K.jsx)(x,{...GI(x,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:k,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=w(n+t.firstItemIndex,e.data,l);return T?(0,U.createElement)(b,{...GI(b,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,U.createElement)(C,{...GI(C,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:II},u(e.index,l)):(0,U.createElement)(S,{...GI(S,l),...KI(S,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?RI:LI},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),BI={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},VI={outline:`none`,overflowX:`auto`,position:`relative`},HI=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),UI=(e,t,n=0)=>({...HI(e),position:t?`relative`:`absolute`,top:t?-n:0}),WI={position:OI(),top:0,width:`100%`,zIndex:1};function GI(e,t){if(typeof e!=`string`)return{context:t}}function KI(e,t){return{item:typeof e==`string`?void 0:t}}var qI=U.memo(function(){let e=nL(`HeaderComponent`),t=rL(`headerHeight`),n=nL(`HeaderFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,nL(`skipAnimationFrameInResizeObserver`)),i=nL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})}),JI=U.memo(function(){let e=nL(`FooterComponent`),t=rL(`footerHeight`),n=nL(`HeaderFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,nL(`skipAnimationFrameInResizeObserver`)),i=nL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})});function YI({useEmitter:e,useEmitterValue:t,usePublisher:n}){return U.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=MI(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,K.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?VI:BI,...i},tabIndex:0,...o,...GI(c,a),children:r})})}function XI({useEmitter:e,useEmitterValue:t,usePublisher:n}){return U.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=U.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=MI(s,l,c,t(`scrollerRef`),f);return kI(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,K.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...GI(c,a),children:r})})}var ZI=({children:e})=>{let t=U.useContext(wI),n=rL(`viewportHeight`),r=rL(`fixedItemHeight`),i=nL(`alignToBottom`),a=nL(`horizontalDirection`),o=iF(U.useMemo(()=>xP(n,e=>FF(e,a?`width`:`height`)),[n,a]),!0,nL(`skipAnimationFrameInResizeObserver`));return U.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:HI(i),children:e})},QI=({children:e})=>{let t=U.useContext(wI),n=rL(`windowViewportRect`),r=rL(`fixedItemHeight`),i=nL(`customScrollParent`),a=nL(`useWindowScroll`),o=nL(`topListHeight`),s=cF(n,i,nL(`skipAnimationFrameInResizeObserver`)),c=nL(`alignToBottom`);return U.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:UI(c,a,o),children:e})},$I=({children:e})=>{let t=nL(`TopItemListComponent`)??`div`,n=nL(`headerHeight`),r={...WI,marginTop:`${n}px`},i=nL(`context`);return(0,K.jsx)(t,{style:r,...GI(t,i),children:e})},{Component:eL,useEmitter:tL,useEmitterValue:nL,usePublisher:rL}=CI(PI,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},U.memo(function(e){let t=nL(`useWindowScroll`),n=nL(`topItemsIndexes`).length>0,r=nL(`customScrollParent`),i=nL(`context`);return(0,K.jsxs)(r||t?aL:iL,{...e,context:i,children:[n&&(0,K.jsx)($I,{children:(0,K.jsx)(zI,{showTopList:!0})}),(0,K.jsxs)(r||t?QI:ZI,{children:[(0,K.jsx)(qI,{}),(0,K.jsx)(zI,{}),(0,K.jsx)(JI,{})]})]})})),iL=YI({useEmitter:tL,useEmitterValue:nL,usePublisher:rL}),aL=XI({useEmitter:tL,useEmitterValue:nL,usePublisher:rL}),oL=eL,sL=YP(([e,t])=>({...e,...t}),kP(xI,YP(()=>{let e=Q(e=>(0,K.jsxs)(`td`,{children:[`Item $`,e]})),t=Q(null),n=Q(e=>(0,K.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=Q(null),i=Q(null),a=Q({}),o=Q(NI),s=Q(EP),c=(e,t=null)=>KP(Z(a,BP(t=>t[e]),RP()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),cL=({height:e})=>(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{style:{height:e}})}),lL=({height:e})=>(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),uL={overflowAnchor:`none`},dL={position:OI(),zIndex:2,overflowAnchor:`none`},fL=U.memo(function({showTopList:e=!1}){let t=_L(`listState`),n=_L(`computeItemKey`),r=_L(`firstItemIndex`),i=_L(`context`),a=_L(`isSeeking`),o=_L(`fixedHeaderHeight`),s=_L(`groupIndices`).length>0,c=_L(`itemContent`),l=_L(`groupContent`),u=_L(`ScrollSeekPlaceholder`)??cL,d=_L(`GroupComponent`),f=_L(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,U.createElement)(u,{...GI(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,U.createElement)(d,{...GI(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...dL,top:o}},l(t.index,i)):(0,U.createElement)(f,{...GI(f,i),...KI(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...dL,top:o+g}:uL},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),pL=U.memo(function(){let e=_L(`listState`),t=_L(`topItemsIndexes`).length>0,n=vL(`sizeRanges`),r=_L(`useWindowScroll`),i=_L(`customScrollParent`),a=vL(`windowScrollContainerState`),o=vL(`scrollContainerState`),s=i||r?a:o,c=_L(`trackItemSizes`),{callbackRef:l,ref:u}=oF(n,_L(`itemSize`),c,s,_L(`log`),void 0,i,!1,_L(`skipAnimationFrameInResizeObserver`)),[d,f]=U.useState(0);gL(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=_L(`EmptyPlaceholder`),m=_L(`FillerRow`)??lL,h=_L(`TableBodyComponent`),g=_L(`paddingTopAddition`),_=_L(`statefulTotalCount`),v=_L(`context`);if(_===0&&p!=null)return(0,K.jsx)(p,{...GI(p,v)});let y=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),b=e.offsetTop+g+d-y,x=e.offsetBottom,S=b>0?(0,K.jsx)(m,{context:v,height:b},`padding-top`):null,C=x>0?(0,K.jsx)(m,{context:v,height:x},`padding-bottom`):null;return(0,K.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...GI(h,v),children:[S,t&&(0,K.jsx)(fL,{showTopList:!0}),(0,K.jsx)(fL,{}),C]})}),mL=({children:e})=>{let t=U.useContext(wI),n=vL(`viewportHeight`),r=vL(`fixedItemHeight`),i=iF(U.useMemo(()=>xP(n,e=>FF(e,`height`)),[n]),!0,_L(`skipAnimationFrameInResizeObserver`));return U.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:HI(!1),children:e})},hL=({children:e})=>{let t=U.useContext(wI),n=vL(`windowViewportRect`),r=vL(`fixedItemHeight`),i=_L(`customScrollParent`),a=_L(`useWindowScroll`),o=cF(n,i,_L(`skipAnimationFrameInResizeObserver`));return U.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,K.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:UI(!1,a),children:e})},{Component:Fne,useEmitter:gL,useEmitterValue:_L,usePublisher:vL}=CI(sL,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},U.memo(function(e){let t=_L(`useWindowScroll`),n=_L(`customScrollParent`),r=vL(`fixedHeaderHeight`),i=vL(`fixedFooterHeight`),a=_L(`fixedHeaderContent`),o=_L(`fixedFooterContent`),s=_L(`context`),c=iF(U.useMemo(()=>xP(r,e=>FF(e,`height`)),[r]),!0,_L(`skipAnimationFrameInResizeObserver`)),l=iF(U.useMemo(()=>xP(i,e=>FF(e,`height`)),[i]),!0,_L(`skipAnimationFrameInResizeObserver`)),u=n||t?bL:yL,d=n||t?hL:mL,f=_L(`TableComponent`),p=_L(`TableHeadComponent`),m=_L(`TableFooterComponent`),h=a?(0,K.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...GI(p,s),children:a()},`TableHead`):null,g=o?(0,K.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...GI(m,s),children:o()},`TableFoot`):null;return(0,K.jsx)(u,{...e,...GI(u,s),children:(0,K.jsx)(d,{children:(0,K.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...GI(f,s),children:[h,(0,K.jsx)(pL,{},`TableBody`),g]})})})})),yL=YI({useEmitter:gL,useEmitterValue:_L,usePublisher:vL}),bL=XI({useEmitter:gL,useEmitterValue:_L,usePublisher:vL}),xL={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},SL={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:CL,floor:wL,max:TL,min:EL,round:DL}=Math;function OL(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function kL(e){return{...SL,items:e}}function AL(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function jL(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var ML=YP(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=Q(0),C=Q(0),w=Q(xL),T=Q({height:0,width:0}),E=Q({height:0,width:0}),D=qP(),O=qP(),k=Q(0),A=Q(null),j=Q({column:0,row:0}),M=qP(),N=qP(),P=Q(!1),F=Q(0),I=Q(!0),L=Q(!1),R=Q(!1);AP(Z(m,GP(F),zP(([e,t])=>!XF(t))),()=>{jP(I,!1)}),AP(Z(XP(m,I,E,T,F,L),zP(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){jP(I,!0);return}jP(L,!0),JF(1,()=>{jP(D,e)}),FP(Z(l),()=>{jP(t,[0,0]),jP(I,!0)})}),PP(Z(N,zP(e=>e!=null&&e.scrollTop>0),VP(0)),C),AP(Z(m,GP(N),zP(([,e])=>e!=null)),([,e])=>{e&&(jP(T,e.viewport),jP(E,e.item),jP(j,e.gap),e.scrollTop>0&&(jP(P,!0),FP(Z(l,UP(1)),e=>{jP(P,!1)}),jP(c,{top:e.scrollTop})))}),PP(Z(T,BP(({height:e})=>e)),d),PP(Z(XP(ZP(T,AL),ZP(E,AL),ZP(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),ZP(l)),BP(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),PP(Z(XP(ZP(S),r,ZP(j,jL),ZP(E,AL),ZP(T,AL),ZP(A),ZP(C),ZP(P),ZP(I),ZP(F)),zP(([,,,,,,,e])=>!e),BP(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return xL;if(p===0){let t=YF(l,e);return kL(OL(t,t+Math.max(s-1,0),o))}let h=NL(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*wL((t+d)/(f+d)),_=h*CL((n+d)/(f+d))-1,_=EL(e-1,TL(_,h-1)),g=EL(_,TL(0,g))):(g=0,_=-1);let v=OL(g,_,o),{bottom:y,top:b}=PL(a,r,i,v),x=CL(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),PP(Z(A,zP(e=>e!==null),BP(e=>e.length)),S),PP(Z(XP(T,E,w,j),zP(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),BP(([e,t,{items:n},r])=>{let{bottom:i,top:a}=PL(e,r,t,n);return[a,i]}),RP(jF)),t);let ee=Q(!1);PP(Z(l,GP(ee),BP(([e,t])=>t||e!==0)),ee);let z=JP(Z(XP(w,S),zP(([{items:e}])=>e.length>0),GP(ee),zP(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),BP(([[,e]])=>e-1),RP())),B=JP(Z(ZP(w),zP(({items:e})=>e.length>0&&e[0].index===0),VP(0),RP())),V=JP(Z(ZP(w),GP(P),zP(([{items:e},t])=>e.length>0&&!t),BP(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),RP(AF),WP(0)));PP(V,p.scrollSeekRangeChanged),PP(Z(D,GP(T,E,S,j),BP(([e,t,n,r,i])=>{let a=KF(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=TL(0,l,EL(r-1,l));let u=FL(t,i,n,l);return o===`end`?u=DL(u-t.height+n.height):o===`center`&&(u=DL(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let te=KP(Z(w,BP(e=>e.offsetBottom+e.bottom)),0);return PP(Z(b,BP(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:A,deviation:k,footerHeight:i,gap:j,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:N,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:R,initialTopMostItemIndex:F,totalListHeight:te,...f,endReached:z,propsReady:h,rangeChanged:V,startReached:B,stateChanged:M,stateRestoreInProgress:P,...x}},kP(sI,lF,tI,vI,GF,yI,eF));function NL(e,t,n){return TL(1,wL((e+n)/(wL(t)+n)))}function PL(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=FL(e,t,n,r[0].index);return{bottom:FL(e,t,n,r[r.length-1].index)+i,top:a}}function FL(e,t,n,r){let i=wL(r/NL(e.width,n.width,t.column)),a=i*n.height+TL(0,i-1)*t.row;return a>0?a+t.row:a}var IL=YP(([e,t])=>({...e,...t}),kP(ML,YP(()=>{let e=Q(e=>`Item ${e}`),t=Q({}),n=Q(null),r=Q(`virtuoso-grid-item`),i=Q(`virtuoso-grid-list`),a=Q(NI),o=Q(`div`),s=Q(EP),c=(e,n=null)=>KP(Z(t,BP(t=>t[e]),RP()),n),l=Q(!1),u=Q(!1);return PP(ZP(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),LL=U.memo(function(){let e=UL(`gridState`),t=UL(`listClassName`),n=UL(`itemClassName`),r=UL(`itemContent`),i=UL(`computeItemKey`),a=UL(`isSeeking`),o=WL(`scrollHeight`),s=UL(`ItemComponent`),c=UL(`ListComponent`),l=UL(`ScrollSeekPlaceholder`),u=UL(`context`),d=WL(`itemDimensions`),f=WL(`gap`),p=UL(`log`),m=UL(`stateRestoreInProgress`),h=WL(`reportReadyState`),g=iF(U.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:qL(`column-gap`,getComputedStyle(e).columnGap,p),row:qL(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return kI(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,K.jsx)(c,{className:t,ref:g,...GI(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,K.jsx)(l,{...GI(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,U.createElement)(s,{...GI(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),RL=U.memo(function(){let e=UL(`HeaderComponent`),t=WL(`headerHeight`),n=UL(`headerFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,!1),i=UL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})}),zL=U.memo(function(){let e=UL(`FooterComponent`),t=WL(`footerHeight`),n=UL(`headerFooterTag`),r=iF(U.useMemo(()=>e=>{t(FF(e,`height`))},[t]),!0,!1),i=UL(`context`);return e==null?null:(0,K.jsx)(n,{ref:r,children:(0,K.jsx)(e,{...GI(e,i)})})}),BL=({children:e})=>{let t=U.useContext(TI),n=WL(`itemDimensions`),r=WL(`viewportDimensions`),i=iF(U.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return U.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,K.jsx)(`div`,{ref:i,style:HI(!1),children:e})},VL=({children:e})=>{let t=U.useContext(TI),n=WL(`windowViewportRect`),r=WL(`itemDimensions`),i=UL(`customScrollParent`),a=UL(`useWindowScroll`),o=cF(n,i,!1);return U.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,K.jsx)(`div`,{ref:o,style:UI(!1,a),children:e})},{Component:Ine,useEmitter:HL,useEmitterValue:UL,usePublisher:WL}=CI(IL,{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`}},U.memo(function({...e}){let t=UL(`useWindowScroll`),n=UL(`customScrollParent`),r=n||t?KL:GL,i=n||t?VL:BL,a=UL(`context`);return(0,K.jsx)(r,{...e,...GI(r,a),children:(0,K.jsxs)(i,{children:[(0,K.jsx)(RL,{}),(0,K.jsx)(LL,{}),(0,K.jsx)(zL,{})]})})})),GL=YI({useEmitter:HL,useEmitterValue:UL,usePublisher:WL}),KL=XI({useEmitter:HL,useEmitterValue:UL,usePublisher:WL});function qL(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,$P.WARN),t===`normal`?0:parseInt(t??`0`,10)}function JL({name:e,color:t}){return(0,K.jsx)(Fo,{name:e,variant:`beam`,colors:ro(t),size:`100%`,className:`absolute inset-0 h-full w-full`})}var YL=2e3,XL=6e4;function ZL(){let e=globalThis[c];return typeof e==`string`?e:null}function QL(e,t,n){let r=YL,i=!1,a,o=()=>{t(e).then(e=>{if(!i){if(e)return n();r=Math.min(r*2,XL),a=setTimeout(o,r)}})};return a=setTimeout(o,r),()=>{i=!0,clearTimeout(a)}}var $L=e=>new Promise(t=>{let n=new Image;n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e});function eR(e){let t=ZL();!t||typeof caches>`u`||je(caches,t,e).catch(()=>{})}var tR=`#7c5cff`;function nR({name:e,color:t,image:n,className:r,enso:i}){let[a,o]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!(!n||a!==n||!ZL()))return QL(n,$L,()=>o(null))},[a,n]),n&&a!==n?(0,K.jsx)(`img`,{"data-enso":i,"data-image":`true`,src:n,alt:``,draggable:!1,onError:()=>o(n),className:G(`object-cover`,r),style:t?{backgroundColor:t}:void 0}):(0,K.jsx)(`span`,{"data-enso":i,"data-generated":`true`,className:G(`relative block shrink-0 overflow-hidden`,r),children:(0,K.jsx)(JL,{name:e.trim()||`secretary`,color:t??tR})})}var rR={xs:`size-6 rounded-[8px] text-[11.5px]`,sm:`size-[22px] rounded-[7px] text-[11.5px]`,md:`size-7 rounded-[9px] text-[13px]`,lg:`size-11 rounded-[13px] text-base`};function iR({name:e,color:t,image:n,needsYou:r,running:i,size:a=`md`,enso:o=`secretary-avatar`}){let s=r>0?`warn`:i>0?`run`:null;return(0,K.jsxs)(`span`,{"data-enso":o,"data-image":n?`true`:void 0,className:G(`relative flex shrink-0`,rR[a]),children:[(0,K.jsx)(nR,{name:e,color:t,image:n,enso:`${o}-face`,className:`size-full overflow-hidden rounded-[inherit]`}),s&&(0,K.jsx)(`span`,{"data-enso":`secretary-pip`,"data-tone":s,className:G(`absolute -top-1 -right-1 size-2.5 rounded-full border-2 border-background`,s===`warn`?`bg-warning`:`bg-success`)})]})}function aR(e){return[...e.running,...e.needsYou,...e.done]}function oR(e,t,n){if(n?.secretaryId)return{secretaryId:n.secretaryId};for(let[n,r]of Object.entries(e)){if(r.secretaryId&&r.secretaryId!==n)continue;let e=aR(r.board).find(e=>e.kind===`session`&&e.conversationId===t&&!e.takeover);if(e?.kind===`session`)return{secretaryId:n,secretaryConversationId:e.secretaryConversationId}}for(let[n,r]of Object.entries(e))if(!(r.secretaryId&&r.secretaryId!==n)&&r.takeovers.some(e=>e.conversationId===t))return{secretaryId:n};return null}var sR=e=>e===`oauth-credentials-unloaded`||e===`oauth-credentials-loading`||e===`oauth-credentials-error`;function cR(e){switch(e.oauthCredentials.status){case`unloaded`:return{reason:`oauth-credentials-unloaded`,suggestedAction:`load-oauth-credentials`};case`loading`:return{reason:`oauth-credentials-loading`,suggestedAction:`wait-for-oauth-credentials`};case`error`:return{reason:`oauth-credentials-error`,suggestedAction:`retry-oauth-credentials`,credentialError:e.oauthCredentials.error};case`ready`:return null}}function lR(e,t,n,r){if(!e)return`missing-selection`;if(yj(e)){if(!r)return`provider-missing`;let i=bj(r,e);return i?i.enabled?lR(i.primary,t,n):`model-disabled`:`model-missing`}let i=t.find(t=>t.id===e.providerId);if(!i)return`provider-missing`;if(!i.enabled)return`provider-disabled`;if(_e(i))return`classifier-only`;let a=i.models.find(t=>t.id===e.modelId);return a?a.enabled===!1?`model-disabled`:i.oauthAccountPool!==void 0&&!O(i)?`oauth-account-missing`:i.oauthAccountKey?n.oauthCredentials.status===`ready`?O(i)?u(i,e.modelId,t,n.oauthCredentials.authenticatedAccountKeys).length>0?`usable`:`oauth-account-missing`:n.oauthCredentials.authenticatedAccountKeys.has(i.oauthAccountKey)?`usable`:`oauth-account-missing`:cR(n)?.reason??`oauth-credentials-error`:i.apiKey?`usable`:`api-key-missing`:`model-missing`}function uR(e,t){let n=e?.groupId?t.find(t=>t.id===e.groupId):void 0;return{projectDefaultModel:e?.defaultModel??null,groupDefaultModel:n?.defaultModel??null,projectReasoningEnabled:e?.defaultReasoningEnabled,projectThinkingLevel:e?.defaultThinkingLevel,groupReasoningEnabled:n?.defaultReasoningEnabled,groupThinkingLevel:n?.defaultThinkingLevel}}function dR(e){let t=lR(e.defaultModel,e.providers,e.credentials,e.virtualModels),n=e.defaultModel!==null&&t!==`usable`&&!sR(t),r=[{selection:e.lastProviderId&&e.lastModelId?{providerId:e.lastProviderId,modelId:e.lastModelId}:null,source:`session`},{selection:e.projectDefaultModel??null,source:`project`},{selection:e.groupDefaultModel??null,source:`group`},{selection:e.defaultModel,source:`default`}];for(let t of r){let r=lR(t.selection,e.providers,e.credentials,e.virtualModels);if(r===`usable`&&t.selection)return{...t.selection,source:t.source,invalidDefault:t.source!=="default"&&n};if(sR(r)){let t=cR(e.credentials);if(t)return{providerId:null,modelId:null,source:`none`,invalidDefault:n,...t}}}return{providerId:null,modelId:null,source:`none`,invalidDefault:n,...(sR(t)?cR(e.credentials):null)??{reason:`no-usable-model`}}}var fR={revision:0,availability:{status:`unloaded`}},pR=kj(()=>({snapshot:fR}));function mR(e){return{oauthCredentials:e.availability}}var hR=kj(()=>({snapshot:void 0}));function gR(){return Cj(E.getState().providers,hR.getState().snapshot)}function _R(e){new Set(e)}function vR(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var yR=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return yR(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return yR(t)(e)}}}},bR=(e,t)=>(n,r,i)=>{let a={storage:vR(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return yR(u.getItem.bind(u))(a.name).then(e=>{if(e){if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state]}return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{++s,u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},xR=e=>{if(typeof e!=`string`||!e.startsWith(`plugin:`))return!1;let t=e.indexOf(`:`,7);return t>7&&t<e.length-1};function SR(e,t,n){if(!t)return!1;let r=e.uiByConversation[t]?.open;return r===void 0?!n&&e.liveGlobalTabs.length>0:r}function CR(e){let t=Array.isArray(e.globalTabs)?e.globalTabs.filter(xR):[],n=e.globalScopeOverrides,r={};if(n&&typeof n==`object`&&!Array.isArray(n))for(let[e,t]of Object.entries(n))xR(e)&&(t===`global`||t===`session`)&&(r[e]=t);return{globalTabs:[...new Set(t)],globalScopeOverrides:r}}function wR(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function TR(e,t){if(wR(e)){if(e.type===`leaf`){let n=wR(e.data)?e.data:void 0,r=Array.isArray(n?.views)?n.views.filter(e=>typeof e==`string`&&t.has(e)):[];if(r.length===0)return;let i=n?.views,a=i.indexOf(n?.activeView),o=typeof n?.activeView==`string`&&t.has(n.activeView)?n.activeView:[...i.slice(0,Math.max(a,0)).reverse(),...i.slice(a+1)].find(e=>typeof e==`string`&&t.has(e))??r[0];return{type:`leaf`,data:{...n,views:r,activeView:o},size:e.size}}if(e.type===`branch`){let n=Array.isArray(e.data)?e.data.flatMap(e=>{let n=TR(e,t);return n?[n]:[]}):[];return n.length===0?void 0:{type:`branch`,data:n,size:e.size}}}}function ER(e,t){return!e||!wR(e.panels)||!(t in e.panels)?e:DR(e,e=>e!==t)}function DR(e,t){if(!wR(e)||!wR(e.panels))return;let n={};for(let[r,i]of Object.entries(e.panels))t(r,i)&&(n[r]=i);let r=new Set(Object.keys(n));if(r.size===0)return;let i=wR(e.grid)?e.grid:void 0,a=i?TR(i.root,r):void 0;if(a)return{...e,panels:n,grid:{...i,root:a}}}var OR=4,kR=e=>{if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null};function AR(e){if(!kR(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!kR(r))continue;let e={};for(let[t,n]of Object.entries(r))typeof n==`string`&&(e[t]=n);Object.keys(e).length>0&&(t[n]=e)}return t}function jR(e,t){let n=kR(e)?e:{};if(t<2)return{state:{uiByConversation:{},layouts:{}},snapshots:{}};if(t<OR)return{state:{uiByConversation:t<3?{}:n.uiByConversation??{},layouts:n.layouts??{},changesModeByConversation:n.changesModeByConversation??{}},snapshots:AR(n.snapshotsByConversation)};let{snapshotsByConversation:r,...i}=n;return{state:i,snapshots:{}}}function MR(e,t){let{state:n,snapshots:r}=jR(e,t);return{state:{...n,...CR(n)},snapshots:r}}function NR(e){return typeof e!=`number`||!Number.isFinite(e)?224:Math.min(480,Math.max(160,e))}function PR(e,t){let n=NR(e);if(t<=0)return n;let r=Math.max(224,t-240-1);return Math.min(n,r)}function FR(e,t,n){let r=PR(e,n),i=PR(r+t,n);return i===r?NR(e):i}function IR(e,t,n=1){let r=Math.max(280,e);if(t<=0)return r;let i=Math.max(0,t-360-n);return Math.min(i,r)}function LR(e,t,n,r=1){let i=IR(e,n,r),a=IR(i+t,n,r);return a===i?e:a}function RR(){return nP.getState().activeId??void 0}function zR(e,t){return e.uiByConversation[t]??{width:e.lastWidth}}function BR(e,t){return SR(e,t,ED())}function VR(e,t,n){return{...e.fullscreenByConversation,[t]:n}}function HR(e,t,n){return{...e.uiByConversation,[t]:{...zR(e,t),...n}}}var UR=kj()(bR((e,t)=>({fullscreen:!1,fullscreenByConversation:{},lastWidth:360,filesTreeWidth:224,uiByConversation:{},browserHoles:{},layouts:{},pinnedTabs:[],globalTabs:[],globalScopeOverrides:{},liveGlobalTabs:[],changesModeByConversation:{},snapshotsByConversation:{},toggleOpen:()=>{let n=RR();if(!n)return;let r=!BR(t(),n);e({uiByConversation:HR(t(),n,{open:r}),fullscreen:r?t().fullscreen:!1,fullscreenByConversation:VR(t(),n,r?t().fullscreen:!1)})},reconcileForActiveConversation:()=>{let n=RR(),r=n?t().fullscreenByConversation[n]??!1:!1;r!==t().fullscreen&&e({fullscreen:r})},ensureOpen:n=>{let r=n??RR();!r||zR(t(),r).open||e({uiByConversation:HR(t(),r,{open:!0})})},nudgeWidth:(n,r,i)=>{let a=RR();if(!a)return;let o=LR(zR(t(),a).width,n,r,i);e({uiByConversation:HR(t(),a,{width:o}),lastWidth:o})},nudgeFilesTreeWidth:(n,r=0)=>{let i=FR(t().filesTreeWidth,n,r);i!==t().filesTreeWidth&&e({filesTreeWidth:i})},resetFilesTreeWidth:()=>e({filesTreeWidth:224}),toggleFullscreen:()=>{let n=RR();if(!n)return;let{fullscreen:r}=t();if(!BR(t(),n)){e({uiByConversation:HR(t(),n,{open:!0}),fullscreen:!0,fullscreenByConversation:VR(t(),n,!0)});return}e({fullscreen:!r,fullscreenByConversation:VR(t(),n,!r)})},setFullscreen:n=>{let r=RR();if(n&&r){e({fullscreen:!0,uiByConversation:HR(t(),r,{open:!0}),fullscreenByConversation:VR(t(),r,!0)});return}e({fullscreen:n,...r?{fullscreenByConversation:VR(t(),r,n)}:{}})},togglePinnedTab:n=>{let r=t().pinnedTabs,i=Array.isArray(r)?r:[];e({pinnedTabs:i.includes(n)?i.filter(e=>e!==n):[...i,n]})},setBrowserHole:(n,r)=>{let{[n]:i,...a}=t().browserHoles;!r&&!i||e({browserHoles:r?{...a,[n]:r}:a})},setGlobalTabs:t=>e({globalTabs:t}),setGlobalScopeOverride:(n,r)=>{let{[n]:i,...a}=t().globalScopeOverrides;e({globalScopeOverrides:r?{...a,[n]:r}:a})},setLiveGlobalTabs:n=>{let r=t().liveGlobalTabs;r.length===n.length&&r.every((e,t)=>e===n[t])||e({liveGlobalTabs:n})},dropPanelFromLayouts:(n,r)=>{let{layouts:i,uiByConversation:a}=t(),o={...i},s={...a},c=!1;for(let[e,t]of Object.entries(i)){if(r.has(e))continue;let i=ER(t,n);if(i===t)continue;c=!0,o[e]=i;let l=a[e];!i&&l?.open===!0&&(s[e]={...l,open:!1})}c&&e({layouts:o,uiByConversation:s})},saveLayout:(n,r)=>{nP.getState().conversations[n]&&e({layouts:{...t().layouts,[n]:r}})},forgetConversation:n=>{let{[n]:r,...i}=t().layouts,{[n]:a,...o}=t().uiByConversation,{[n]:s,...c}=t().fullscreenByConversation,{[n]:l,...u}=t().changesModeByConversation,{[n]:d,...f}=t().snapshotsByConversation;e({layouts:i,uiByConversation:o,fullscreenByConversation:c,changesModeByConversation:u,snapshotsByConversation:f})},setChangesMode:(n,r)=>{e({changesModeByConversation:{...t().changesModeByConversation,[n]:r}})},saveSnapshots:(n,r)=>{e({snapshotsByConversation:{...t().snapshotsByConversation,[n]:r}}),window.electronAPI.changes.writeSnapshots({conversationId:n,snapshots:r})},loadSnapshots:n=>{if(n in t().snapshotsByConversation)return;let r=r=>{n in t().snapshotsByConversation||e({snapshotsByConversation:{...t().snapshotsByConversation,[n]:r}})};window.electronAPI.changes.readSnapshots({conversationId:n}).then(r,()=>r({}))}}),{name:`enso-side-panel`,version:5,storage:vR(()=>localStorage),partialize:e=>({lastWidth:e.lastWidth,filesTreeWidth:e.filesTreeWidth,uiByConversation:e.uiByConversation,fullscreenByConversation:e.fullscreenByConversation,layouts:e.layouts,pinnedTabs:e.pinnedTabs,globalTabs:e.globalTabs,globalScopeOverrides:e.globalScopeOverrides,changesModeByConversation:e.changesModeByConversation}),merge:(e,t)=>{let n=e&&typeof e==`object`?e:{};return{...t,...n,...CR(n)}},migrate:(e,t)=>{let{state:n,snapshots:r}=MR(e,t),i=window.electronAPI?.changes;if(i)for(let[e,t]of Object.entries(r))i.writeSnapshots({conversationId:e,snapshots:t});return n}})),WR=`Let's set you up. Ask me a few questions about what to call me, which model you should use, and how much you may do on your own. Then submit the draft with secretary_profile_propose and wait for my confirmation.`,GR={enabled:!1,projectId:null,profile:null,persona:``,board:{needsYou:[],running:[],done:[],todos:[]},proposals:{},takeovers:[]};function KR(e,t){return t&&e.some(e=>e.id===t)?t:e[0]?.id??null}function qR(e){_R(Object.values(e).flatMap(e=>e.takeovers.map(e=>e.conversationId)))}function JR(e){return e?YR.getState().secretaries.find(t=>t.projectId===e)?.id??null:null}var YR=kj()((e,t)=>({secretary:GR,secretaries:[],states:{},focusedId:null,resolving:{},welcomeOpen:!1,focusProposal:null,focus:n=>{let{states:r,focusedId:i}=t();i===n&&r[n]||(e({focusedId:n,secretary:r[n]??GR,welcomeOpen:!1}),r[n]||t().reload(n))},reload:async n=>{let r=n??t().focusedId;if(!r)return;let i=await window.electronAPI.secretary.getState(r).catch(()=>null);i&&e(e=>({states:{...e.states,[r]:i},...e.focusedId===r?{secretary:i}:{}}))},createSecretary:async()=>{let n=await window.electronAPI.secretary.create();return n.ok?(e({secretaries:await window.electronAPI.secretary.list()}),t().focus(n.secretaryId),e({welcomeOpen:!0}),n.secretaryId):null},openWelcome:()=>e({welcomeOpen:!0}),closeWelcome:()=>e({welcomeOpen:!1}),focusProposalCard:t=>e({focusProposal:{proposalId:t,at:Date.now()}}),clearFocusProposal:()=>e({focusProposal:null}),bind:()=>{let n=new Set,r=!0,i=n=>{let r=n.secretaryId??t().focusedId;r&&e(e=>{let t={...e.states,[r]:n};qR(t);let i=KR(e.secretaries,e.focusedId)??r;if(i!==r)return{states:t,focusedId:i};let a=e.states[r]??e.secretary;return{states:t,focusedId:i,secretary:n,welcomeOpen:n.profile?!1:a.profile!==null&&a.enabled?!0:e.welcomeOpen}})},a=window.electronAPI.secretary.onStateChanged(e=>{e.secretaryId&&n.add(e.secretaryId),i(e)}),o=window.electronAPI.secretary.onListChanged(t=>{eR(t.map(e=>e.id)),e(e=>{let n=new Set(t.map(e=>e.id)),r=Object.fromEntries(Object.entries(e.states).filter(([e])=>n.has(e))),i=KR(t,e.focusedId);return qR(r),{secretaries:t,states:r,focusedId:i,secretary:i&&r[i]||(i===e.focusedId?e.secretary:GR)}})});window.electronAPI.secretary.list().then(async t=>{if(r){eR(t.map(e=>e.id)),e(e=>({secretaries:t,focusedId:KR(t,e.focusedId)}));for(let e of t){let t=await window.electronAPI.secretary.getState(e.id);!r||n.has(e.id)||i({...t,secretaryId:t.secretaryId??e.id})}}}).catch(()=>void 0);let s=window.electronAPI.secretary.onOpenConversation(e=>{nP.getState().selectConversation(e.conversationId),UR.getState().ensureOpen(e.conversationId),e.proposalId&&t().focusProposalCard(e.proposalId)}),c=nP.subscribe((e,n)=>{if(e.activeId===n.activeId)return;let r=JR(e.activeId?e.conversations[e.activeId]?.projectId:void 0);r&&t().focus(r)});return()=>{r=!1,a(),o(),s(),c(),_R([]),e({secretary:GR,secretaries:[],states:{},focusedId:null,welcomeOpen:!1,focusProposal:null})}},newSecretaryConversation:async e=>{let{states:n,secretary:r,secretaries:i}=t(),a=e?.secretaryId?n[e.secretaryId]:r;e?.secretaryId&&t().focus(e.secretaryId);let o=a?.projectId??(e?.secretaryId?i.find(t=>t.id===e.secretaryId)?.projectId:null);if(!o)return null;let s=E.getState().projects.find(e=>e.id===o);if(!s)return null;let c=e?.greeting?XR(o):null;if(e?.greeting&&!c)return null;let l=nP.getState(),u=await l.newConversation(o);if(!u)return null;if(c){let e=M(E.getState().language);await l.send(Ie(e,WR),{...c,cwd:s.path},void 0,u)}return u},resolveProposal:async(n,r,i,a)=>{e({resolving:{...t().resolving,[n]:!0}});try{await window.electronAPI.secretary.resolveProposal(n,r,i,a)}catch{}finally{let r={...t().resolving};delete r[n],e({resolving:r})}}}));function XR(e){let t=E.getState(),n=t.projects.find(t=>t.id===e);if(!n)return null;let r=dR({defaultModel:t.defaultModel,...uR(n,t.projectGroups),providers:gR(),credentials:mR(pR.getState().snapshot),virtualModels:t.virtualModels});return r.source===`none`?null:{providerId:r.providerId,modelId:r.modelId}}function ZR(e,t,n){if(!t)return null;let r=t.imageVersion;return{name:e?.trim()||`·`,color:t.color,...r?{image:I(r,t.imageHash,n)}:{}}}function QR(e,t){return t&&e.some(e=>e.id===t)?t:null}function $R(e,t,n,r){if(n){let t=e.secretaries.find(e=>e.projectId===n)?.id;if(t)return t;if(e.secretaries.length===0&&e.secretary.projectId===n&&e.secretary.secretaryId)return e.secretary.secretaryId}let i=QR(e.secretaries,r);if(i)return i;if(e.secretaries.length===0&&r&&(e.states[r]||e.secretary.secretaryId===r))return r;let a=oR(e.states,t)?.secretaryId;return QR(e.secretaries,a)||(e.secretaries.length===0&&a&&e.states[a]?a:null)}function ez(e){let t=nP(t=>e?t.conversations[e]?.projectId:void 0),n=nP(t=>e?t.conversations[e]?.secretaryOrigin?.secretaryId:void 0),r=YR(r=>e?$R(r,e,t,n):null),i=YR(e=>r?e.states[r]??(e.focusedId===r?e.secretary:void 0):void 0),a=YR(e=>r?e.secretaries.find(e=>e.id===r):void 0),o=YR(e=>e.secretary.enabled?e.secretary.profile:null),s=YR(e=>e.secretary.secretaryId??void 0);if(r){if(i&&!i.enabled)return null;let e=i?.profile?.avatar??(i?void 0:a?.avatar),t=i?.profile?.name??(i?void 0:a?.name);return e?ZR(t,e,r):null}return o?ZR(o.name,o.avatar,s):null}var tz=kj(()=>({active:!1})),nz=()=>tz.getState().active;function rz(e){return typeof e!=`number`||!Number.isInteger(e)?5:e<1?1:e>60?60:e}function iz(e){return rz(e)*1e3}var az=new Set(`ls.tree.pwd.cd.cat.bat.head.tail.wc.nl.tac.less.more.rg.grep.egrep.fgrep.ag.find.fd.fdfind.which.type.file.stat.du.df.sort.uniq.cut.tr.awk.sed.diff.jq.yq.echo.printf.basename.dirname.realpath.readlink.printenv.date.whoami.uname.column.true.test.[.git`.split(`.`)),oz=new Set([`status`,`log`,`diff`,`show`,`blame`,`grep`,`ls-files`,`ls-tree`,`rev-parse`,`describe`,`shortlog`,`reflog`,`cat-file`,`name-rev`,`remote`,`config`,`branch`,`tag`]),sz={sed:/^(-[a-zA-Z]*i|--in-place)|\/[a-zA-Z]*e[a-zA-Z]*['"]?$|^['"]?e\b/,awk:/^-[a-zA-Z]*[fiE]|^--(file|include|exec)/,yq:/^-[a-zA-Z]*[is]|^--(inplace|split-exp)/,sort:/^-[a-zA-Z]*o|^--(output|compress-program)/,find:/^-(exec|execdir|ok|okdir|delete|fprint|fprintf|fprint0|fls)$/,git:/^--(output|ext-diff|textconv|filters|exec-path)/,rg:/^--pre($|=)/,fd:/^-[a-zA-Z0-9]*[xX]|^--exec/,fdfind:/^-[a-zA-Z0-9]*[xX]|^--exec/,ag:/^--pager/,bat:/^--pager/,tree:/^-o$|^--output/,file:/^-[a-zA-Z]*C/,date:/^(-s|--set)/},cz={branch:/^-(d|D|m|M|c|C|u|f|-delete|-move|-copy|-set-upstream-to|-unset-upstream|-force)/,tag:/^-(a|s|d|f|m|F|-annotate|-sign|-delete|-force|-message)/,config:/^(-e|--edit|--unset|--unset-all|--add|--replace-all|--rename-section|--remove-section)$/,remote:/^(add|remove|rm|rename|set-url|set-head|set-branches|prune|update)$/,reflog:/^(expire|delete)$/,grep:/^(-O|--open-files-in-pager)/},lz=/^\/(usr\/(local\/)?)?s?bin\/[^/]+$|^\/opt\/homebrew\/bin\/[^/]+$/,uz=new Set([`--no-pager`,`-P`,`--no-optional-locks`]),dz=/^(LC_[A-Z_]+|LANG|LANGUAGE|TZ|NO_COLOR|FORCE_COLOR|CLICOLOR(_FORCE)?|COLUMNS|TERM)=/,fz=new Set([`node`,`npm`,`pnpm`,`yarn`,`bun`,`deno`,`python`,`python3`,`pip`,`pip3`,`ruby`,`go`,`cargo`,`rustc`,`java`,`javac`]),pz=/^['"]?((\d+|\$)(,(\d+|\$))?|\/[^/]*\/)p['"]?$/,mz=new Set([`-n`,`-E`,`-r`,`--quiet`,`--silent`]);function hz(e){let t=e.trim().split(/\s+/),n=0;for(;n<t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[n]);)n+=1;return{env:t.slice(0,n),tokens:t.slice(n)}}function gz(e){let t=hz(e).tokens[0]??``;return t.slice(t.lastIndexOf(`/`)+1)}function _z(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=31&&n!==10)return!0}return!1}function vz(e){let t=e.find(e=>!mz.has(e));return!t||!pz.test(t)?!1:e.slice(0,e.indexOf(t)).every(e=>mz.has(e))}function yz(e){let t=1;for(;t<e.length&&e[t].startsWith(`-`);)if(e[t]===`-C`){if(t+1>=e.length)return!1;t+=2}else if(uz.has(e[t]))t+=1;else return!1;if(t>=e.length)return!1;let n=e[t];if(!oz.has(n))return!1;let r=e.slice(t+1),i=cz[n];return!(i&&r.some(e=>i.test(e))||n===`config`&&!r.some(e=>/^(--get|--get-all|--list|-l|--get-regexp)$/.test(e))||(n===`branch`||n===`tag`)&&r.some(e=>!e.startsWith(`-`))&&!r.some(e=>e===`-l`||e===`--list`))}function bz(e){let t=e.trim();if(!t||/\$\(|<\(|`/.test(t)||_z(t))return!1;let n=t.replace(/2>&1|[12]?>\s*\/dev\/null/g,``);if(n.includes(`>`))return!1;let r=n.split(/\|\|?|&&?|;|\n/);for(let e of r){let t=e.trim();if(!t)continue;let{env:n,tokens:r}=hz(t);if(n.some(e=>!dz.test(e)))return!1;let i=gz(t),a=r[0]??``;if(a.includes(`/`)&&!lz.test(a))return!1;let o=r.slice(1);if(fz.has(i)){if(o.length!==1||![`--version`,`-v`,`-V`].includes(o[0]))return!1;continue}if(!az.has(i))return!1;let s=sz[i];if(s&&o.some(e=>s.test(e))||i===`awk`&&/system\s*\(/.test(o.join(` `))||i===`sed`&&!vz(o)||i===`git`&&!yz(r)||i===`uniq`&&o.filter(e=>!e.startsWith(`-`)).length>1)return!1}return!0}var xz=`</untrusted-content`,Sz=`<untrusted-content`;function Cz(e){return e.split(`<\\/untrusted-content`).join(xz).split(`<\\untrusted-content`).join(Sz)}var wz=/^<untrusted-content(?:\s[^<>\n]*)?>([\s\S]*)<\/untrusted-content>$/u,Tz=/<\\?untrusted-content source="plugin:[^"<>\n]*"[^<>\n]*>/u,Ez=/<\\?\/untrusted-content>\s*$/u;function Dz(e){let t=wz.exec(e.trim()),n=!!(t&&!t[1].includes(xz)),r=n&&t?t[1]:e,i=Tz.exec(r),a=Ez.exec(r);return i&&a&&a.index>=i.index+i[0].length&&(r=r.slice(0,i.index)+r.slice(i.index+i[0].length,a.index)),n&&(r=Cz(r)),r===e?e:r.trim()}function Oz(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}function kz(e){let t=e;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return null}return t&&typeof t==`object`&&!Array.isArray(t)?t:null}function Az(e){let t=[e.tool,e.name].find(e=>typeof e==`string`&&e);if(typeof t==`string`)return t.startsWith(`mcp__`)||typeof e.server!=`string`||!e.server?t:`mcp__${e.server}__${t}`}function jz(e,t){if(e!==`mcp`)return{name:e,args:t};let n=kz(t);if(!n)return{name:e,args:t};let r=Az(n);return n.action===`list`?{name:e,args:t,summary:typeof n.server==`string`&&n.server?n.server:`list`}:n.action===`describe`&&r?{name:e,args:t,summary:r}:n.action===`call`&&r&&Oz(r)?{name:r,args:kz(n.arguments)??{}}:{name:e,args:t}}function Mz(e,t,n){let r=[];for(let i=0;i<e.length;){let a=e[i];if(a.kind!==`tool`||!a.name||!t(a.name)){r.push(a),i+=1;continue}let o=i+1;for(;o<e.length&&e[o].kind===`tool`&&e[o].name===a.name;)o+=1;r.push(o-i>=2?n(a,e.slice(i+1,o)):a),i=o}return r}var Nz=[`日`,`一`,`二`,`三`,`四`,`五`,`六`],Pz=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function Fz(e){let t=e.trim();return t.length<=8?t:`${t.slice(0,8)}…`}function Iz(e,t){return t?.trim()||(e?Fz(e):``)}function Lz(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Rz(e){return String(e).padStart(2,`0`)}function zz(e,t){return`${Rz(e)}:${Rz(t)}`}function Bz(e,t,n){return e.length===n-t+1&&e[0]===t&&e[e.length-1]===n}function Vz(e,t){if(e.length<2||e[0]!==0)return;let n=e[1]-e[0];if(!(n<1)){for(let t=1;t<e.length;t+=1)if(e[t]-e[t-1]!==n)return;return e[e.length-1]+n>=t?n:void 0}}function Hz(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function Uz(e,t){let n=Bo(e);if(!n)return e.trim();let r=Bz(n.dayOfMonth,1,31)&&Bz(n.month,1,12)&&Bz(n.dayOfWeek,0,6);if(r&&Bz(n.hour,0,23)){let e=Vz(n.minute,60);if(e===1)return t===`zh`?`每分钟`:`every minute`;if(e)return t===`zh`?`每 ${e} 分钟`:`every ${e} minutes`}if(n.minute.length!==1||n.hour.length!==1||!Bz(n.month,1,12))return n.source;let i=zz(n.hour[0],n.minute[0]);if(r)return t===`zh`?`每天 ${i}`:`every day at ${i}`;if(Bz(n.dayOfMonth,1,31)&&Hz(n.dayOfWeek,[1,2,3,4,5]))return t===`zh`?`每个工作日 ${i}`:`weekdays at ${i}`;if(Bz(n.dayOfMonth,1,31)&&n.dayOfWeek.length===1){let e=n.dayOfWeek[0];return t===`zh`?`每周${Nz[e]} ${i}`:`every ${Pz[e]} at ${i}`}return n.source}var Wz=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function Gz(e){if(!e)return null;try{let t=JSON.parse(e);return Wz(t)?t:null}catch{return null}}function Kz(e,t){if(!Array.isArray(e))return null;let n=[];for(let r of e){if(!Wz(r)||typeof r.id!=`string`||!r.id||typeof r.title!=`string`||typeof r.content!=`string`)return null;let{spaceId:e,[t]:i}=r;n.push({id:r.id,title:r.title,content:r.content,unitType:typeof r.unitType==`string`&&r.unitType?r.unitType:null,space:e===`global`?`global`:typeof e==`string`&&e.startsWith(`proj:`)?`project`:null,relevance:typeof i==`number`&&Number.isFinite(i)?i:null})}return n}function qz(e){let t=Gz(e);return t?Kz(t.results,`relevance`):null}function Jz(e,t){let n=Gz(e);if(n?.status===`candidates_found`){let e=Kz(n.candidates,`similarity`);return e?{written:!1,candidates:e}:null}if(n?.status!==`inserted`||!Wz(n.memory)||!t)return null;let r=Kz([{...n.memory,content:t}],`relevance`)?.[0];return r?{written:!0,deduplicated:n.deduplicated===!0,memory:r}:null}var Yz=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]);function Xz(e){for(let t of e){if(!t||typeof t!=`object`)continue;let e=t;if(!(e.type!==`image`||typeof e.data!=`string`||!e.data)&&typeof e.mimeType==`string`&&Yz.has(e.mimeType))return e}}var Zz=e=>typeof e==`number`?e:null;function Qz(e){let t=e?.split(`
190
190
  `,1)[0]?.trim();if(!t?.startsWith(`{`))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!n||typeof n!=`object`)return null;let r=n;return{path:typeof r.path==`string`&&r.path?r.path:null,size:Zz(r.size),width:Zz(r.width),height:Zz(r.height)}}var $z=/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u;function eB(e,t,n){return n?e?`data:${e.mimeType};base64,${e.data}`:t&&$z.test(t)?f(t):null:null}var tB=new Set([...se,`memory_search`,`memory_capture`,`memory_delete`,`memory_crystallize`,`web_search`,`web_fetch`]);function nB(e,t=!1){return e===`task_settle`?!0:t?tB.has(e)||e.startsWith(`my_`)||Oz(e)!==null:!1}var rB=new Map;function iB(e,t){rB.set(e,t)}function aB(e,t){return(rB.get(e.name)??KB)(e,t)}var oB={todo_item_update:`Updated {{count}} to-dos`,todo_item_add:`Added {{count}} to-dos`,session_send:`Sent {{count}} messages`,session_stop:`Stopped {{count}} sessions`,session_task_stop:`Stopped {{count}} background tasks`,session_archive:`Archived {{count}} sessions`,session_unarchive:`Unarchived {{count}} sessions`,result_mark_done:`Marked {{count}} sessions done`,result_mark_undo:`Undid {{count}} marks`,needs_user_escalate:`Escalated {{count}} items to you`,session_answer:`Answered {{count}} questions`,session_create:`Created {{count}} sessions`,todo_item_dispatch:`Dispatched {{count}} to-dos`,schedule_add:`Added {{count}} schedules`,schedule_remove:`Removed {{count}} schedules`};function sB(e,t){let n=e.map(e=>aB(e,t));if(n.length<=1)return{grouped:!1,title:n[0]?.title??``,cards:n};let r=e[0]?.name??``,i=oB[r];return{grouped:!0,title:i?t.t(i,{count:n.length}):t.t(`{{count}} × {{tool}}`,{count:n.length,tool:cB(r,t)}),cards:n}}function cB(e,t){if(e.startsWith(`my_`))return t.t(`Custom tool {{name}}`,{name:e.slice(3).replaceAll(`-`,` `)});let n=Oz(e);if(n)return`${n.tool.replaceAll(`_`,` `)} · ${n.server}`;let r=Ms[e];return r?t.t(r):e.replaceAll(`_`,` `)}function lB(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function uB(e){return lB(e)?e:null}function dB(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function fB(e){let t=dB(e);return t===null?dB(e?.split(`
191
191
  `,1)[0]??null):t}function $(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function pB(e){let t=$(e);if(!t)return;let n=t.match(/^<untrusted-content\b[^>]*>([\s\S]*)<\/untrusted-content>$/u);return(n?n[1]:t).trim()||void 0}function mB(e){return e.length>280||e.split(`
192
192
  `).length>6}function hB(e){let t=``;try{t=typeof e.args==`string`?e.args:JSON.stringify(e.args,null,2)??``}catch{t=String(e.args)}return{rawArgs:t,rawOutput:e.output??``}}function gB(e,t,n,r){return{name:e.name,title:t,state:e.state,blocks:n,...r?{status:r}:{},...hB(e)}}var _B={"dispatch-limit":`Dispatch limit reached`,"project-not-visible":`Project is not visible`,"project-required":`A project is required`,"not-found":`Not found`,"invalid-cron":`Invalid schedule`,"invalid-at":`Invalid schedule`,"at-in-past":`Invalid schedule`,"exactly-one-of-at-or-cron":`Invalid schedule`,"stale-index":`The message changed (the session was rewound or switched branches). List the session again and read it with the new id.`,"not-readable":`Only user and assistant messages can be read; tool calls and tool output are not shown.`};function vB(e,t){if(e.state!==`error`)return null;let n=e.output?.trim()??``;if(!n)return t.t(`Tool failed`);let r=_B[n]??_B[/^([a-z][a-z-]*):\s/u.exec(n)?.[1]??``];return r?t.t(r):n}function yB(e,t){return e?Iz(e,t.lookup?.sessionTitle?.(e)):t.t(`Unknown session`)}function bB(e,t){return e?Iz(e,t.lookup?.projectName?.(e)):t.t(`Not set`)}function xB(e,t){if(e==null||e===``)return t.t(`Not set`);if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function SB(e,t){return Object.entries(e).map(([e,n])=>({label:e,value:xB(n,t)}))}var CB={running:{key:`Session running`,tone:`ok`},idle:{key:`Session idle`,tone:`neutral`},waiting:{key:`Session needs you`,tone:`pending`},error:{key:`Session error`,tone:`error`},"not-started":{key:`Session not started`,tone:`neutral`}};function wB(e,t){let n=typeof e==`string`?CB[e]:void 0;return n?{badge:t.t(n.key),badgeTone:n.tone}:{badge:typeof e==`string`?e:``,badgeTone:`neutral`}}function TB(e){let t=uB(e);return(typeof t?.approvals==`number`?t.approvals:0)+(typeof t?.asks==`number`?t.asks:0)}function EB(e){return e.replace(/<untrusted-content[^>]*>/gu,``).replace(/<\/untrusted-content>/gu,``).trim()}function DB(e){let t=EB(e).split(`
@@ -204,8 +204,8 @@ XID_Start XIDS`.split(/\s/).map(e=>[_h(e),e])),dg=new Map([[`s`,Yh(383)],[Yh(383
204
204
  `)||null}}function YV(e,t){if(e!==`edit`||!t||typeof t!=`object`)return null;let n=t;if(!(`edits`in n)&&typeof n.oldText==`string`&&typeof n.newText==`string`)return QV(n,n.oldText,n.newText);let r=n.edits;if(typeof r==`string`)try{r=JSON.parse(r)}catch{return null}return!Array.isArray(r)||r.length===0?null:r.every(e=>e&&typeof e==`object`&&typeof e.oldText==`string`&&typeof e.newText==`string`)?r:null}function XV(e,t){return e!==`edit`||!t||typeof t.oldText!=`string`||typeof t.newText!=`string`?null:QV(t,t.oldText,t.newText)}var ZV=new WeakMap;function QV(e,t,n){let r=ZV.get(e);return r||(r=[{oldText:t,newText:n}],ZV.set(e,r)),r}var $V=e=>e.content.map(e=>e.type===`text`?e.text:``).join(``),eH=/(?:^|\n)<source_reference type="(?:file|web)" (?:path|url)="[^"\n]*" \/>(?:\n<source_reference type="(?:file|web)" (?:path|url)="[^"\n]*" \/>)*$/,tH=e=>e.content.map(e=>e.type===`text`?e.text.replace(eH,``):``).join(``);function nH(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`text`&&n.text.trim()||n.type===`thinking`&&n.text||n.type===`toolCall`||n.type===`image`)return t}return-1}function rH(e){let t=e.timing;if(t?.completedMs)return typeof e.duration==`number`&&e.duration>0?e.duration:Math.max(0,t.completedMs-t.stepStartMs)}function iH(e,t){let n=e.timing,r=rH(e);if(!n||r===void 0)return;let{stepStartMs:i,firstTokenMs:a}=n,o=e.usage?.output??0,s=typeof e.ttft==`number`&&e.ttft>0?e.ttft:a===void 0?void 0:Math.max(0,a-i);return{runMs:r,...t===void 0?{}:{turnMs:t},...s===void 0?{}:{ttftMs:s},...o>0&&r>0?{tps:o/(r/1e3)}:{}}}var aH=`<thinking>`,oH=`</thinking>`;function sH(e){let t=[],n=(e,n)=>{let r=n.trim();r&&t.push({kind:e,text:r})},r=0;for(;r<e.length;){let t=e.indexOf(aH,r);if(t===-1){n(`text`,e.slice(r));break}t>r&&n(`text`,e.slice(r,t));let i=t+10,a=e.indexOf(oH,i);if(a===-1){n(`thinking`,e.slice(i));break}n(`thinking`,e.slice(i,a)),r=a+11}return t}function cH(e){let t=new Set;for(let n of e??[])if(n.phase===`reviewing`&&n.toolCallId){t.add(n.toolCallId);let e=Ts(n.toolCallId);e&&t.add(e)}return t}function lH(e,t){return(t??[]).filter(t=>t.toolCallId&&Ts(t.toolCallId)===e).length}function uH(e,t,n,r,i,a,o=0,s,c=!1,l){let u=cH(i),d=new Map;for(let t of e)t.role===`toolResult`&&t.toolCallId&&d.set(t.toolCallId,{output:tH(t),isError:t.isError===!0,todos:t.todos??null,durationMs:t.toolDurationMs??null,agentMeta:t.subagentMeta??null,editDiff:t.editDiff??null,fileChanges:t.fileChanges??null,applyPatchOutcome:t.applyPatchOutcome??null,codemodeCalls:t.codemodeCalls??null,rtk:t.rtk,approvalReview:t.approvalReview,backgroundTaskId:t.backgroundTaskId,shellFailure:t.shellFailure,dcgWarning:t.dcgWarning,pluginArtifacts:t.pluginArtifacts,generatedImages:t.generatedImages,image:Xz(t.content)});let f=-1;for(let t=e.length-1;t>=0;t--)if(!e[t].optimistic&&e[t].role!==`toolResult`){f=t;break}let p=[],m=new Map,h=new Map,g=Array(e.length);for(let t=e.length-1,n;t>=0;t--)g[t]=n,tV(e[t])?n=`user`:e[t].role===`assistant`&&!e[t].optimistic&&(n=`assistant`);let _=e.findLastIndex(e=>e.role===`user`&&!e.optimistic),v=e.findLastIndex(e=>!e.optimistic),y=0,x=0,S=!1,C,w=!1,T;return e.forEach((E,D)=>{let O=D===v,k=o+D;if(E.role===`user`&&E.optimistic){p.push({kind:`user`,key:`${k}`,text:$V(E),images:E.content.filter(e=>e.type===`image`),timestamp:E.timestamp,canCollapse:!1,deliveryState:E.deliveryRejected?E.rejectedReason===`turn-stuck`?`stuck`:`rejected`:`pending`});return}if(E.role===`user`){C=E.timestamp,w=!1,y=0,x=0,S=!1;let n=$V(E),r=E.content.filter(e=>e.type===`image`),i=/^<background-task-update>\n?([\s\S]*?)\n?<\/background-task-update>\s*$/.exec(n.trim());if(i&&r.length===0){let e=i[1].trim();p.push({kind:`task-note`,key:`${k}`,summary:e.split(`
205
205
  `,1)[0]??e,detail:e}),T=void 0;return}if(n||r.length>0){let i=D+1;for(;e[i]?.role===`system`||e[i]?.optimistic;)i++;let a=i<e.length&&!tV(e[i])&&!(t&&D===_),o={kind:`user`,key:`${k}`,text:n,images:r,timestamp:E.timestamp,canCollapse:a};p.push(o),T=o}return}if(E.role===`custom`){E.pluginSource&&(C=E.timestamp,w=!1,y=0,x=0,S=!1,T=void 0,p.push({kind:`plugin-message`,key:`${k}`,text:Dz($V(E)),...E.pluginSource}));return}if(E.role===`compactionSummary`){p.push({kind:`compaction`,key:`${k}`,summary:$V(E),tokensBefore:E.tokensBefore??null,...E.verified?{verified:!0}:{},...E.memory?{memory:!0}:{}});return}if(E.role===`toolResult`){E.toolName===`ask_user`&&(w=!0),x>0&&E.toolName!==`ask_user`&&typeof E.toolDurationMs==`number`&&Number.isFinite(E.toolDurationMs)&&E.toolDurationMs>0&&(y+=E.toolDurationMs);return}if(E.role!==`assistant`)return;x+=1,T&&E.model&&(x===1||S)&&(T.replyModel=E.model,S=E.stopReason===`error`),x===1&&T&&E.timestamp!==void 0&&(T.replyAt=E.timestamp),T&&E.privacyMask&&(T.replyPrivacyMask=b(T.replyPrivacyMask,E.privacyMask));let A=rH(E);A!==void 0&&(y+=A);let j=g[D]===void 0||g[D]===`user`,M=j&&x>1?y:void 0,N=!(g[D]===void 0&&(t||E.stopReason===`pending`)),P;if(j&&N){if(y>0)P=y;else if(!w){let e=E.timing?.completedMs??E.timestamp;typeof C==`number`&&typeof e==`number`&&e>C&&(P=e-C)}T&&P!==void 0&&(T.turnDurationMs=P)}if(E.restartResumed){p.push(dH(E,k,n));return}let F=nH(E.content);if(E.content.forEach((e,o)=>{let l=`${k}-${o}`,g=O&&o===F,_=!!E.stopReason&&E.stopReason!==`pending`,v=t&&g&&!_;switch(e.type){case`text`:{if(!e.text.trim())return;let t=sH(e.text);if(t.length===0)return;if(t.length===1&&t[0].kind===`text`){let t=j&&!v;p.push({kind:`text`,key:l,text:e.text,streaming:v,timestamp:E.timestamp,perf:iH(E,M),...t?{turnEnd:!0,...P===void 0?{}:{turnDurationMs:P}}:{}});return}t.forEach((e,n)=>{let r=t.length===1?l:`${l}-${n}`,i=v&&n===t.length-1;if(e.kind===`thinking`){p.push({kind:`thinking`,key:r,text:e.text,streaming:i,durationMs:null});return}let a=j&&!i&&n===t.length-1;p.push({kind:`text`,key:r,text:e.text,streaming:i,timestamp:E.timestamp,perf:iH(E,M),...a?{turnEnd:!0,...P===void 0?{}:{turnDurationMs:P}}:{}})});return}case`thinking`:if(e.text){let t=E.timing,n=t?.thinkingEndMs??t?.completedMs;p.push({kind:`thinking`,key:l,text:e.text,streaming:v,durationMs:t&&n!==void 0?Math.max(0,n-t.stepStartMs):null,...t?{startedAt:t.stepStartMs}:{}})}return;case`toolCall`:{let o=d.get(e.id),g=r?.[e.id],_=wV(e.name),v=_?xV(e.arguments):null,y=o?o.applyPatchOutcome?rV(o.applyPatchOutcome):o.output:(g??null)||null,b=e.name===`codemode`?EV(y):y,x=e.name===`exec`?AV(b):e.name===`codemode`&&o?kV(b,o.isError,o.codemodeCalls):null,S=jz(e.name,e.arguments);e.name===`subagent`&&VV(m,h,e.arguments,o?.output);let C=e.name===`subagent`?WV(e.arguments,m,h):null,w=IV(e.name,e.arguments,m),T=w?.text??LV(e.name,e.arguments),E=GV(e.name,e.arguments),O=JV(e.name,e.arguments,b,!!(o&&!o.isError)),k=e.name===`apply_patch`?o?.fileChanges?.length?o.fileChanges.map(e=>e.path):_V(e.arguments):null,A=!o&&t&&D===f,j=A&&(e.name===`bash`||e.name===`powershell`),M=A?UV(e.name,e.arguments):null,N=e.name===`read`&&!o?.isError?hV(e.arguments,n):null;p.push({kind:`tool`,key:l,name:S.name,...nB(S.name,c)?{args:S.args??null}:{},summary:v?SV(v):k?k.length>1?`${k.length} files`:fV(k[0]??``,n):w?.summary??E?.title??O?.ask.question??C?.title??S.summary??vV(S.args,n),source:v,output:w?zV(b):O?O.output:b,nestedPending:lH(e.id,i)||void 0,...N?{imagePath:N}:{},...e.name===`image_view`&&o?.image&&!o.isError?{image:o.image}:{},...o?.generatedImages?.length?{generatedImages:o.generatedImages}:{},..._?{sandbox:x}:{},state:o?o.isError||x?.status===`failed`?`error`:`ok`:t&&D===f?u.has(e.id)?`reviewing`:`running`:t?`ok`:`error`,edits:o?.isError?null:YV(e.name,e.arguments)??XV(e.name,o?.editDiff),writeContent:MV(e.name,e.arguments),fileChanges:o?.fileChanges??null,todos:o?.todos??null,durationMs:o?.durationMs??null,agentMeta:o?.agentMeta??null,...o?.rtk?{rtk:o.rtk}:{},...o?.approvalReview?{approvalReview:o.approvalReview}:{},...j||M?{callId:e.id}:{},...M?{waiting:M}:{},...o?.backgroundTaskId?{backgroundTaskId:o.backgroundTaskId}:{},...o?.shellFailure?{shellFailure:o.shellFailure}:{},...o?.dcgWarning?{dcgWarning:o.dcgWarning}:{},...e.name===`submit_plan`?{plan:jV(e.name,e.arguments)}:{},...T?{sentMessage:T}:{},...E?{memoryContent:E.content}:{},...O?{ask:O.ask}:{},...C?.op?{subagentOp:C.op}:{},...C?.titles?{subagentTitles:C.titles}:{},...o?.pluginArtifacts?{pluginArtifacts:o.pluginArtifacts}:{},...s?.has(e.id)?{batchLabel:s.get(e.id)}:{},...o||!a?{}:{startedAt:a[e.id]??null}});return}default:return}}),E.errorMessage){let n=D+1;for(;e[n]?.role===`system`;)n++;let r=e[n]?.role===`assistant`,i=t&&D===e.length-1,a=l!==void 0&&E.errorMessage===l;!r&&!i&&!a&&p.push({kind:`error`,key:`${k}-err`,text:E.errorMessage})}}),p}function dH(e,t,n){let r=t=>e.content.flatMap(e=>e.type===t&&e.text.trim()?[e.text.trim()]:[]).join(`
206
206
 
207
- `);return{kind:`resumed-reply`,key:`${t}-resumed`,thinking:r(`thinking`),text:r(`text`),tools:e.content.flatMap(e=>e.type===`toolCall`?[{name:e.name,summary:vV(e.arguments,n)}]:[]),expanded:!1}}var fH=e=>e.kind===`capability-receipt`?e.receipt.occurredAt:e.at,pH=`<${Sk}>`;function mH(e){return e.content.map(e=>e.type===`text`?e.text:``).join(`
208
- `).trim()}function hH(e){if(!e.includes(pH))return!1;if(kk(e))return!0;let t=Pk(e);return!!(t&&kk(t.rest))}function gH(e,t,n){let r=new Set,i=t.filter(e=>e.kind===`task-wrap-up-nudge`).map(e=>e.at).sort((e,t)=>e-t);if(i.length===0)return r;let a=0,o=!1;return e.forEach((e,t)=>{if(e.optimistic)return;let s=e.timestamp??-1/0;for(;a<i.length&&(i[a]??0)<=s;)o=!0,a+=1;if(!o||e.role!==`user`&&e.role!==`toolResult`)return;let c=mH(e);if(e.role===`toolResult`){c.includes(pH)&&(o=!1);return}hH(c)&&(r.add(n+t),o=!1)}),r}var _H=e=>{let t=e.key.indexOf(`-`),n=Number.parseInt(t===-1?e.key:e.key.slice(0,t),10);return Number.isInteger(n)?n:-1},vH=(e,t,n=0)=>{let r=_H(e)-n;return r>=0?t[r]?.timestamp??-1/0:-1/0};function yH(e,t){let n=e.findLast(e=>e.kind===`compaction`);if(!n||t<=_H(n))return e;let r=e.length;for(let n=0;n<e.length;n++)if(_H(e[n])>=t){r=n;break}if(r===e.length&&_H(e.at(-1)??e[0])+1<t||e[r-1]?.kind===`compaction`)return e;let i={kind:`compaction-notice`,key:`compaction-notice:${n.key}`,summary:n.summary,tokensBefore:n.tokensBefore,...n.tokensAfter===void 0?{}:{tokensAfter:n.tokensAfter},...n.verified?{verified:!0}:{},...n.memory?{memory:!0}:{}};return[...e.slice(0,r),i,...e.slice(r)]}function bH(e,t){if(t===void 0)return e;let n=e.findLastIndex(e=>e.kind===`compaction`),r=e[n];if(r?.kind!==`compaction`)return e;let i=[...e];return i[n]={...r,tokensAfter:t},i}function xH(e,t,n,r){let i=bH(e,r),a=n===void 0?i:yH(i,n);return t?[...a,{kind:`compaction-progress`,key:`compaction:${t}`,state:t}]:a}function SH(e,t,n=[],r,i){let a=i?.historyBaseIndex??0,o=new Map,s=[];for(let e of n)e.kind===`tool-batch-label`?o.set(e.callId,e.label):s.push(e);let c=uH(e,t,r,i?.toolOutputs,i?.pendingApprovals,i?.toolStartedAt,a,o,i?.secretarySession===!0,i?.interrupted?.suppressedError),l=gH(e,s,a),u=l.size===0?c:c.map(e=>e.kind===`user`&&!e.deliveryState&&l.has(_H(e))?{...e,hostTaskWrapUp:!0}:e),d=s.length===0?u:[...u.map((t,n)=>({item:t,at:vH(t,e,a),order:n})),...s.map((e,t)=>({item:{kind:`session-custom`,key:e.kind===`capability-receipt`?`custom:receipt:${e.receipt.receiptId}`:e.kind===`oauth-account-selected`?`custom:${e.kind}:${e.accountKey}:${e.at}:${t}`:e.kind===`task-wrap-up-nudge`?`custom:${e.kind}:${e.at}:${t}`:`custom:${e.kind}:${e.child.generation}:${e.at}:${t}`,entry:e},at:fH(e),order:u.length+t}))].sort((e,t)=>e.at-t.at||e.order-t.order).map(({item:e})=>e),f=u.filter(e=>e.kind===`user`&&e.deliveryState),p=f.length?d.filter(e=>!(e.kind===`user`&&e.deliveryState)):d;for(let e of f){let t=e.kind===`user`?e.timestamp:void 0,n=t!==void 0&&Number.isFinite(t)?p.findIndex(e=>e.kind===`user`&&!e.deliveryState&&e.timestamp!==void 0&&Number.isFinite(e.timestamp)&&e.timestamp>t):-1;p.splice(n<0?p.length:n,0,e)}let m=xH(i?.runDividers?.length?wH(p,i.runDividers,t=>t.kind===`session-custom`?fH(t.entry):vH(t,e,a),a===0):p,i?.compaction,i?.compactionNoticeAt,i?.compactionTokensAfter);return i?.interrupted?[...m,{kind:`interrupted`,key:`interrupted`,at:i.interrupted.at,exitKind:i.interrupted.kind,unfinishedTools:i.interrupted.unfinishedTools}]:m}var CH=1e4;function wH(e,t,n,r){let i=[...e],a=-1;for(let e of t){let t=i.findIndex((t,r)=>r>a&&n(t)>=e.at);if(t<0&&(t=i.length),!r&&!i.slice(0,t).some(t=>n(t)<e.at))continue;let o=i[t-1];t-1>a&&o.kind===`user`&&e.at-n(o)<=CH&&--t,i.splice(t,0,{kind:`divider`,key:e.key,text:e.text}),a=t+1}return i}var TH=3;function EH(e){switch(e.kind){case`compaction`:case`compaction-notice`:case`compaction-progress`:case`error`:case`divider`:case`plugin-message`:case`discarded-turn`:case`interrupted`:return!1;default:return!0}}var DH=new Set([`grep`,`find`,`glob`,`ls`]);function OH(e,t,n,r){e===`read`?n.reads+=1:DH.has(e)?n.searches+=1:e===`bash`?!r||!bz(t)?n.commands+=1:jH.has(gz(t))?n.reads+=1:n.searches+=1:n.others+=1}var kH=new Set([`read`,...DH]);function AH(e){let t=[],n=e=>{e.kind===`tool-group`?e.children.forEach(n):e.kind===`tool`&&e.batchLabel&&!t.includes(e.batchLabel)&&t.push(e.batchLabel)};return e.forEach(n),t.length>0?t.join(` · `):void 0}var jH=new Set([`cat`,`bat`,`head`,`tail`,`less`,`more`,`nl`,`tac`]);function MH(e){return kH.has(e.name)||e.name===`bash`&&bz(e.summary)}function NH(e){let t=[];for(let n of e){let e=t.at(-1);n.kind===`thinking`&&e?.kind===`thinking`&&_H(n)>=0&&_H(e)===_H(n)?t[t.length-1]={...e,text:`${e.text}\n\n${n.text}`,streaming:e.streaming||n.streaming,durationMs:e.durationMs??n.durationMs,startedAt:e.startedAt??n.startedAt}:t.push(n)}return t}var PH=new Set([`explore_mark`,`explore_fold`]),FH=/^Explore folded\.[^\n]*\n*/,IH=e=>`${e}:steps`;function LH(e,t,n){let r=[],i=-1;for(let a of e){if(a.kind!==`tool`&&a.kind!==`thinking`&&a.kind!==`text`)i=-1;else if(a.kind===`tool`&&a.state===`ok`){if(a.name===`explore_fold`&&i>=0){let e=[...r.splice(i),a],o=e[0],s={commands:0,reads:0,searches:0,others:0},c=0;for(let t of e)t.kind!==`tool`||PH.has(t.name)||(OH(t.name,t.summary,s,n),c+=1);let l=`explore-${o.key}`,u=t.has(l);r.push({kind:`tool-group`,key:l,expanded:u,count:c,stats:s,exploring:!1,explore:{goal:o.summary,report:(a.output??``).replace(FH,``).trim(),steps:u&&t.has(IH(l))},children:e}),i=-1;continue}a.name===`explore_mark`&&i<0&&(i=r.length)}r.push(a)}return r}var RH=/^Turn discarded[:.]?\s*/;function zH(e,t){let n=[];for(let r of e){if(r.kind===`tool`&&r.name===`turn_discard`&&r.state===`ok`){let e=n.length;for(;e>0&&(n[e-1].kind===`thinking`||n[e-1].kind===`text`||n[e-1].kind===`tool`);)e--;let i=e;for(;e>0&&n[e-1].kind===`plugin-message`;)e--;if(e<i){let i=n.splice(e),a=i.filter(e=>e.kind===`plugin-message`),o=`discard-${a[0].key}`;n.push({kind:`discarded-turn`,key:o,reason:r.output==null?r.summary:r.output.replace(RH,``).trim(),pluginId:a[0].pluginId,pluginName:a[0].pluginName,messages:a.map(e=>e.text),tools:i.flatMap(e=>e.kind===`tool`?[{name:e.name,summary:e.summary}]:[]),expanded:t.has(o)});continue}}n.push(r)}return n}function BH(e){return e.kind===`tool-group`&&e.explore?.steps?[e,...e.children]:[e]}function VH(e,t,n=!1){if(e.length<2)return e.flatMap(BH);let r={commands:0,reads:0,searches:0,others:0},i=0,a=0,o=0;for(let t of e.flatMap(e=>e.kind===`tool-group`?e.children:[e]))t.kind===`thinking`?i+=1:t.kind===`tool`&&(OH(t.name,t.summary,r,!1),o+=1),(t.kind===`thinking`||t.kind===`tool`)&&(a+=t.durationMs??0);let s=`group-${e[0].key}`,c=t.has(s),l=AH(e),u={kind:`tool-group`,key:s,expanded:c,count:o,stats:r,exploring:!1,activity:{thinking:i,workedMs:a},...n?{live:!0}:{},...l?{summary:l}:{},children:e};return c?[u,...e.flatMap(BH)]:[u]}var HH={signature:``,closedAt:null,held:[]};function UH(e){return e.kind===`tool-group`&&e.children[0]?e.children[0].key:e.key}function WH(e,t){return e.kind===`tool`&&e.generatedImages?.length||e.kind===`tool`&&nB(e.name,t)?!1:e.kind===`thinking`||e.kind===`tool-group`||e.kind===`tool`&&e.state===`ok`&&!e.name.startsWith(`goal_`)&&e.name!==`submit_plan`}function GH(e,t,n,r){let i=zH(e,n),a=r.autoCollapseCompletedTurns===!0,o=r.turnOverrides,s=i.findLastIndex(e=>e.kind===`user`&&!e.deliveryState),c=i;if(a||o&&o.size>0){let e=[],n=0;for(;n<i.length;){let r=i[n];if(r.kind===`user`){let c=n===s,l=a&&!c&&r.canCollapse===!0,u=!r.deliveryState&&!(t&&c)&&(o?.get(r.key)??l);if(e.push(u?{...r,collapsed:!0}:r),n+=1,u)for(;n<i.length&&i[n].kind!==`user`;){let t=i[n];EH(t)||e.push(t),n+=1}}else e.push(r),n+=1}c=e}c=LH(c,n,r.compact===!0);let l=c.findLastIndex(e=>e.kind===`user`&&!e.deliveryState),u=Math.max(l,c.findLastIndex(e=>e.kind===`text`));return{sourceItems:c,lastUserIndex:l,liveFrom:u}}function KH(e,t,n){if(n.collapseLiveActivity!==!0||!t)return null;let{sourceItems:r,liveFrom:i}=GH(e,t,new Set,n),a=n.readableToolCards===!0,o=[],s=!1,c=0;for(;c<r.length;){if(!(c>i)||!WH(r[c],a)){c+=1;continue}let e=[],t=c;for(;t<r.length&&WH(r[t],a);){let n=r[t];if(n.kind===`thinking`&&n.streaming){s=!0;break}e.push(UH(n)),t+=1}for(e.length>0&&o.push(e);t<r.length&&WH(r[t],a);)t+=1;c=t}return o.length===0?null:{segments:o,blocked:s}}function qH(e,t,n,r,i){let a=KH(e,t,n);if(!a)return{witness:HH,released:new Set,wakeAt:null};let{segments:o,blocked:s}=a,c=new Set(r.held),l=[],u=[],d=!0;for(let e of o)for(let t of e)d&&c.has(t)?l.push(t):(d=!1,u.push(t));let f=new Set(l);if(s)return{witness:{signature:``,closedAt:null,held:l},released:f,wakeAt:null};let p=o.some(e=>e.filter(e=>!f.has(e)).length>0&&e.length>=2);if(u.length===0||!p)return{witness:{signature:``,closedAt:null,held:l},released:f,wakeAt:null};let m=u.join(`\0`),h=r.signature===m&&r.closedAt!==null?r.closedAt:i,g=h+iz(n.liveActivityFoldDelaySec);if(i<g)return{witness:{signature:m,closedAt:h,held:l},released:f,wakeAt:g};let _=[...l,...u];return{witness:{signature:``,closedAt:null,held:_},released:new Set(_),wakeAt:null}}function JH(e,t,n,r,i,a,o,s,c,l){let u=e=>e.kind===`tool`&&c?.has(e.key)===!0,d=e=>e.kind===`tool`&&nB(e.name,l),f=e=>i&&!(t&&e>s),p=n=>{if(!a||!t||!(n>s)||!WH(e[n],l)||u(e[n])||!a.has(UH(e[n])))return n;let r=n;for(;r<e.length&&WH(e[r],l)&&!u(e[r])&&a.has(UH(e[r]));)r+=1;return r-n>=2?r:n},m=(e,t)=>!d(e)&&!u(e)&&!(e.kind===`tool`&&e.generatedImages?.length)&&(e.kind===`thinking`||e.kind===`tool-group`&&f(t)||e.kind===`tool`&&(f(t)?e.state===`ok`&&!e.name.startsWith(`goal_`)&&e.name!==`submit_plan`:!r||MH(e))),h=[],g=0;for(;g<e.length;){let i=e[g],a=p(g);if(a>g){h.push(...VH(NH(e.slice(g,a)),n,!0)),g=a;continue}if(!m(i,g)){h.push(...BH(i)),g+=1;continue}let s=g;for(;s<e.length&&m(e[s],s)&&p(s)===s;)s+=1;let c=NH(e.slice(g,s));if(f(g)){h.push(...VH(c,n)),g=s;continue}let l=!r&&t&&o>=0&&g>o,u=e=>e.kind===`tool`?e.edits!==null||e.writeContent||e.fileChanges?.length||e.imagePath&&e.state!==`error`||e.name===`todo`||e.name===`submit_plan`?!0:e.state!==`running`&&e.state!==`reviewing`?!1:!(r&&MH(e)):!1,d=c.filter(u),_=c.filter(e=>!u(e)),v=_.filter(e=>e.kind===`tool`).length;if(l||v<TH)h.push(...c);else{let i={commands:0,reads:0,searches:0,others:0};for(let e of _)e.kind===`tool`&&OH(e.name,e.summary,i,r);let a=`group-${c[0].key}`,o=n.has(a),l=AH(_);h.push({kind:`tool-group`,key:a,expanded:o,count:v,stats:i,exploring:r&&(t&&s===e.length||_.some(e=>e.kind===`tool`&&(e.state===`running`||e.state===`reviewing`))),...l?{summary:l}:{},children:_}),o?h.push(...c):h.push(...d)}g=s}return h}function YH(e){return e.kind===`user`&&!e.deliveryState}function XH(e){return e.kind===`text`&&fe(e.text)}function ZH(e){return e.kind===`text`&&e.text.trim().length>0&&!fe(e.text)}function QH(e,t){for(let n of e)n.kind===`tool`?t(n):n.kind===`tool-group`&&QH(n.children,t)}function $H(e,t,n){if(e.length===0)return[];let r={commands:0,reads:0,searches:0,others:0},i=0,a=0,o=0;QH(e,e=>{OH(e.name,e.summary,r,!1),i+=1,o+=e.durationMs??0});for(let t of e)t.kind===`thinking`&&(a+=1,o+=t.durationMs??0);let s=`${n?`silent`:`group`}-${e[0].key}`,c=t.has(s),l=AH(e),u={kind:`tool-group`,key:s,expanded:c,count:i,stats:r,exploring:!1,activity:{thinking:a,workedMs:o},...n?{notice:n}:{},...l&&!n?{summary:l}:{},children:e};return c?[u,...e]:[u]}function eU(e){return/<secretary-schedule>/.test(e)&&!/<session-updates>/.test(e)?`patrol`:`seen`}function tU(e){let t=!1;return QH(e,e=>{e.name===`silence_turn`&&(t=!0)}),t||e.some(XH)}function nU(e,t,n,r){let i=[],a=0;for(;a<e.length;){if(!YH(e[a])){i.push(e[a]),a+=1;continue}let o=a+1;for(;o<e.length&&!YH(e[o]);)o+=1;let s=e.slice(a,o),c=t&&o===e.length;i.push(...rU(s,c,n,r)),a=o}return i}function rU(e,t,n,r){let i=e[0];if(t||i?.kind!==`user`)return e;let a=e.slice(1).filter(e=>!XH(e));if(xe(i.text)&&tU(e.slice(1))){let e=eU(i.text);return $H([{...i,canCollapse:!1},...a],n,e)}if(!r||a.some(ZH))return e;let o=!1,s=0;return QH(a,e=>{s+=1,e.state!==`ok`&&(o=!0)}),o||s<1||a.some(e=>e.kind!==`tool`&&e.kind!==`thinking`&&e.kind!==`tool-group`)?e:[{...i,canCollapse:!1},...$H(a,n)]}function iU(e,t,n,r={}){let{sourceItems:i,lastUserIndex:a,liveFrom:o}=GH(nU(e.map(e=>e.kind===`resumed-reply`?{...e,expanded:n.has(e.key)}:e),t,n,r.foldToolOnlyTurns===!0),t,n,r),s=r.readableToolCards===!0,c=Mz(i,e=>nB(e,s),(e,t)=>e.kind===`tool`?{...e,cardPeers:t.flatMap(e=>e.kind===`tool`?[{key:e.key,args:e.args??null,output:e.output,state:e.state,...e.image?{image:e.image}:{}}]:[])}:e),l=r.collapseLiveActivity===!0?r.releasedLiveActivity??null:null;return JH(c,t,n,r.compact===!0,r.collapseCompletedActivity===!0,l,a,o,r.heldOpenTools??null,s)}var aU={rows:new Set,expanded:new Set};function oU(e,t,n){let r=[],i=[],a=new Map,o=new Set;for(let s of t){if(s.kind!==`tool-group`||!s.explore)continue;let t=e.rows.has(s.key);if(s.explore.steps){o.add(s.key),t&&!e.expanded.has(s.key)&&i.push(s.key),s.children.forEach((e,t)=>{a.set(e.key,{group:s.key,index:t})});continue}let c=s.children[0]?.key??``,l=s.children.at(-1)?.key??``,u=!t&&e.rows.has(c)&&e.rows.has(l);if(!u&&!e.expanded.has(s.key))continue;let d=n(u?c:s.key,l);d>0&&r.push({key:s.key,height:d,pair:u})}return{collapses:r,expands:i,children:a,next:{rows:new Set(t.map(e=>e.key)),expanded:o}}}function sU({loading:e=!1,runStartedAt:t}){if(!e)return t}var cU=(0,U.createContext)({query:``,activeKey:``,activeNth:-1});function lU(){return(0,U.useContext)(cU)}var uU=`rounded-[2px] px-0.5 py-px`,dU=`${uU} bg-yellow-300 text-foreground dark:bg-yellow-500/80`,fU=`${uU} bg-orange-600 text-white dark:bg-orange-500`;function pU(e,t,n,r){let i=t.trim();if(!i)return e;let a=e.toLowerCase(),o=i.toLowerCase(),s=0,c=a.indexOf(o,s);if(c<0)return e;let l=[];for(;c>=0;){c>s&&l.push(e.slice(s,c));let t=r.n++;l.push((0,K.jsx)(`mark`,{className:t===n?fU:dU,children:e.slice(c,c+i.length)},t)),s=c+i.length,c=a.indexOf(o,s)}return s<e.length&&l.push(e.slice(s)),l}function mU(e,t,n,r){return e==null||typeof e==`boolean`?e:typeof e==`string`||typeof e==`number`?pU(String(e),t,n,r):Array.isArray(e)?e.map((e,i)=>(0,K.jsx)(U.Fragment,{children:mU(e,t,n,r)},i)):e}function hU(e){return e===`right`||e===`off`?e:`left`}function gU(e,t,n){return e!==`off`&&!t&&n>=2}var _U=40;function vU({items:e,activeKey:t,onJump:n}){let r=E(e=>e.chatWide),i=hU(E(e=>e.navRailSide)),[a,o]=(0,U.useState)(null);if(!gU(i,r,e.length))return null;let s=i===`right`,c=Math.max(0,e.findIndex(e=>e.key===t)),l=Math.min(Math.max(0,c-Math.floor(_U/2)),Math.max(0,e.length-_U)),u=e.slice(l,l+_U),d=l>0,f=l+_U<e.length,p=(e,t)=>{let n=t?24:12;if(a===null)return n;let r=Math.abs(e-a);return n+Math.max(0,16-r*6)};return(0,K.jsx)(`div`,{className:G(`group/rail absolute top-0 z-10 hidden h-full w-14 @min-[52rem]:block`,s?`right-0`:`left-0`),children:(0,K.jsx)(`div`,{className:G(`absolute top-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover/rail:opacity-100`,s?`right-2`:`left-2`),onMouseLeave:()=>o(null),children:(0,K.jsxs)(`div`,{className:`relative flex flex-col justify-center gap-[5px]`,style:{maskImage:d||f?`linear-gradient(to bottom, ${d?`transparent, black 24px`:`black`}, ${f?`black calc(100% - 24px), transparent`:`black`})`:void 0},children:[u.map((e,r)=>{let i=e.key===t,c=r===a;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(e.key),onMouseEnter:()=>o(r),className:G(`flex h-[7px] w-10 items-center`,s&&`justify-end`),children:(0,K.jsx)(`span`,{className:G(`rounded-full transition-all duration-150`,i||c?`h-[3px] bg-foreground`:`h-[2px] bg-muted-foreground/40`),style:{width:p(r,i)}})},e.key)}),a!==null&&u[a]&&(0,K.jsxs)(`div`,{className:G(`pointer-events-none absolute w-72 -translate-y-1/2 rounded-xl border bg-popover p-3 shadow-lg`,s?`right-10`:`left-10`),style:{top:`${(a+.5)/u.length*100}%`},children:[(0,K.jsx)(`p`,{className:`line-clamp-2 text-xs font-semibold`,children:u[a].question}),u[a].answer&&(0,K.jsx)(`p`,{className:`mt-1 line-clamp-3 text-xs text-muted-foreground`,children:u[a].answer})]})]})})})}var yU={width:72,height:28};function bU(e,t){let n=[];for(let r of e.querySelectorAll(`[data-quote-skip]`)){let e=r.getBoundingClientRect();e.height>0&&e.bottom>0&&e.top<t&&n.push(e)}return n}function xU({containerRef:e}){let{t}=q(),n=E(e=>e.quoteSelectionButton),r=kD(),[i,a]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!n){a(null);return}let t=()=>{let t=e.current,n=window.getSelection(),i=t?PA(n,t):null;if(!i||!n||!t){a(null);return}let o=n.getRangeAt(0).getBoundingClientRect(),s={width:window.innerWidth,height:window.innerHeight},c=bU(t,s.height);a({text:i,...LA(o,s,yU,r,c)})};return document.addEventListener(`selectionchange`,t),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`selectionchange`,t),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[n,r,e]),!n||!i?null:(0,Gs.createPortal)((0,K.jsxs)(`button`,{type:`button`,"data-enso":`quote-selection`,title:t(`Quote into the input box`),onMouseDown:e=>e.preventDefault(),onClick:()=>{let e=TA(i.text);!e||!ek(e)||(window.getSelection()?.removeAllRanges(),a(null))},style:{top:i.top,left:i.left,minWidth:yU.width},className:`fixed z-50 inline-flex h-7 items-center justify-center gap-1 rounded-full border bg-card px-2.5 text-xs text-foreground shadow-float hover:bg-muted`,children:[(0,K.jsx)(kn,{className:`h-3 w-3`}),t(`Quote`)]}),document.body)}var SU=/\n*<chat-reference id="([^"]*)" title="([^"]*)" kind="(?:direct|group)">\n[\s\S]*?\n<\/chat-reference>/g;function CU(e){let t=[],n=e.replace(SU,(e,n,r)=>(t.push({id:n,title:r}),``));return t.length?{body:n.trim(),refs:t}:{body:e,refs:t}}var wU={zh:`这是同一件事的补充,保留原目标,把它并进这一轮的结果;不要单独回一句「收到」。只有明确说换掉或取消才改目标。
207
+ `);return{kind:`resumed-reply`,key:`${t}-resumed`,thinking:r(`thinking`),text:r(`text`),tools:e.content.flatMap(e=>e.type===`toolCall`?[{name:e.name,summary:vV(e.arguments,n)}]:[]),expanded:!1}}var fH=e=>e.kind===`capability-receipt`?e.receipt.occurredAt:e.at,pH=`<${xk}>`;function mH(e){return e.content.map(e=>e.type===`text`?e.text:``).join(`
208
+ `).trim()}function hH(e){if(!e.includes(pH))return!1;if(Ok(e))return!0;let t=Nk(e);return!!(t&&Ok(t.rest))}function gH(e,t,n){let r=new Set,i=t.filter(e=>e.kind===`task-wrap-up-nudge`).map(e=>e.at).sort((e,t)=>e-t);if(i.length===0)return r;let a=0,o=!1;return e.forEach((e,t)=>{if(e.optimistic)return;let s=e.timestamp??-1/0;for(;a<i.length&&(i[a]??0)<=s;)o=!0,a+=1;if(!o||e.role!==`user`&&e.role!==`toolResult`)return;let c=mH(e);if(e.role===`toolResult`){c.includes(pH)&&(o=!1);return}hH(c)&&(r.add(n+t),o=!1)}),r}var _H=e=>{let t=e.key.indexOf(`-`),n=Number.parseInt(t===-1?e.key:e.key.slice(0,t),10);return Number.isInteger(n)?n:-1},vH=(e,t,n=0)=>{let r=_H(e)-n;return r>=0?t[r]?.timestamp??-1/0:-1/0};function yH(e,t){let n=e.findLast(e=>e.kind===`compaction`);if(!n||t<=_H(n))return e;let r=e.length;for(let n=0;n<e.length;n++)if(_H(e[n])>=t){r=n;break}if(r===e.length&&_H(e.at(-1)??e[0])+1<t||e[r-1]?.kind===`compaction`)return e;let i={kind:`compaction-notice`,key:`compaction-notice:${n.key}`,summary:n.summary,tokensBefore:n.tokensBefore,...n.tokensAfter===void 0?{}:{tokensAfter:n.tokensAfter},...n.verified?{verified:!0}:{},...n.memory?{memory:!0}:{}};return[...e.slice(0,r),i,...e.slice(r)]}function bH(e,t){if(t===void 0)return e;let n=e.findLastIndex(e=>e.kind===`compaction`),r=e[n];if(r?.kind!==`compaction`)return e;let i=[...e];return i[n]={...r,tokensAfter:t},i}function xH(e,t,n,r){let i=bH(e,r),a=n===void 0?i:yH(i,n);return t?[...a,{kind:`compaction-progress`,key:`compaction:${t}`,state:t}]:a}function SH(e,t,n=[],r,i){let a=i?.historyBaseIndex??0,o=new Map,s=[];for(let e of n)e.kind===`tool-batch-label`?o.set(e.callId,e.label):s.push(e);let c=uH(e,t,r,i?.toolOutputs,i?.pendingApprovals,i?.toolStartedAt,a,o,i?.secretarySession===!0,i?.interrupted?.suppressedError),l=gH(e,s,a),u=l.size===0?c:c.map(e=>e.kind===`user`&&!e.deliveryState&&l.has(_H(e))?{...e,hostTaskWrapUp:!0}:e),d=s.length===0?u:[...u.map((t,n)=>({item:t,at:vH(t,e,a),order:n})),...s.map((e,t)=>({item:{kind:`session-custom`,key:e.kind===`capability-receipt`?`custom:receipt:${e.receipt.receiptId}`:e.kind===`oauth-account-selected`?`custom:${e.kind}:${e.accountKey}:${e.at}:${t}`:e.kind===`task-wrap-up-nudge`?`custom:${e.kind}:${e.at}:${t}`:`custom:${e.kind}:${e.child.generation}:${e.at}:${t}`,entry:e},at:fH(e),order:u.length+t}))].sort((e,t)=>e.at-t.at||e.order-t.order).map(({item:e})=>e),f=u.filter(e=>e.kind===`user`&&e.deliveryState),p=f.length?d.filter(e=>!(e.kind===`user`&&e.deliveryState)):d;for(let e of f){let t=e.kind===`user`?e.timestamp:void 0,n=t!==void 0&&Number.isFinite(t)?p.findIndex(e=>e.kind===`user`&&!e.deliveryState&&e.timestamp!==void 0&&Number.isFinite(e.timestamp)&&e.timestamp>t):-1;p.splice(n<0?p.length:n,0,e)}let m=xH(i?.runDividers?.length?wH(p,i.runDividers,t=>t.kind===`session-custom`?fH(t.entry):vH(t,e,a),a===0):p,i?.compaction,i?.compactionNoticeAt,i?.compactionTokensAfter);return i?.interrupted?[...m,{kind:`interrupted`,key:`interrupted`,at:i.interrupted.at,exitKind:i.interrupted.kind,unfinishedTools:i.interrupted.unfinishedTools}]:m}var CH=1e4;function wH(e,t,n,r){let i=[...e],a=-1;for(let e of t){let t=i.findIndex((t,r)=>r>a&&n(t)>=e.at);if(t<0&&(t=i.length),!r&&!i.slice(0,t).some(t=>n(t)<e.at))continue;let o=i[t-1];t-1>a&&o.kind===`user`&&e.at-n(o)<=CH&&--t,i.splice(t,0,{kind:`divider`,key:e.key,text:e.text}),a=t+1}return i}var TH=3;function EH(e){switch(e.kind){case`compaction`:case`compaction-notice`:case`compaction-progress`:case`error`:case`divider`:case`plugin-message`:case`discarded-turn`:case`interrupted`:return!1;default:return!0}}var DH=new Set([`grep`,`find`,`glob`,`ls`]);function OH(e,t,n,r){e===`read`?n.reads+=1:DH.has(e)?n.searches+=1:e===`bash`?!r||!bz(t)?n.commands+=1:jH.has(gz(t))?n.reads+=1:n.searches+=1:n.others+=1}var kH=new Set([`read`,...DH]);function AH(e){let t=[],n=e=>{e.kind===`tool-group`?e.children.forEach(n):e.kind===`tool`&&e.batchLabel&&!t.includes(e.batchLabel)&&t.push(e.batchLabel)};return e.forEach(n),t.length>0?t.join(` · `):void 0}var jH=new Set([`cat`,`bat`,`head`,`tail`,`less`,`more`,`nl`,`tac`]);function MH(e){return kH.has(e.name)||e.name===`bash`&&bz(e.summary)}function NH(e){let t=[];for(let n of e){let e=t.at(-1);n.kind===`thinking`&&e?.kind===`thinking`&&_H(n)>=0&&_H(e)===_H(n)?t[t.length-1]={...e,text:`${e.text}\n\n${n.text}`,streaming:e.streaming||n.streaming,durationMs:e.durationMs??n.durationMs,startedAt:e.startedAt??n.startedAt}:t.push(n)}return t}var PH=new Set([`explore_mark`,`explore_fold`]),FH=/^Explore folded\.[^\n]*\n*/,IH=e=>`${e}:steps`;function LH(e,t,n){let r=[],i=-1;for(let a of e){if(a.kind!==`tool`&&a.kind!==`thinking`&&a.kind!==`text`)i=-1;else if(a.kind===`tool`&&a.state===`ok`){if(a.name===`explore_fold`&&i>=0){let e=[...r.splice(i),a],o=e[0],s={commands:0,reads:0,searches:0,others:0},c=0;for(let t of e)t.kind!==`tool`||PH.has(t.name)||(OH(t.name,t.summary,s,n),c+=1);let l=`explore-${o.key}`,u=t.has(l);r.push({kind:`tool-group`,key:l,expanded:u,count:c,stats:s,exploring:!1,explore:{goal:o.summary,report:(a.output??``).replace(FH,``).trim(),steps:u&&t.has(IH(l))},children:e}),i=-1;continue}a.name===`explore_mark`&&i<0&&(i=r.length)}r.push(a)}return r}var RH=/^Turn discarded[:.]?\s*/;function zH(e,t){let n=[];for(let r of e){if(r.kind===`tool`&&r.name===`turn_discard`&&r.state===`ok`){let e=n.length;for(;e>0&&(n[e-1].kind===`thinking`||n[e-1].kind===`text`||n[e-1].kind===`tool`);)e--;let i=e;for(;e>0&&n[e-1].kind===`plugin-message`;)e--;if(e<i){let i=n.splice(e),a=i.filter(e=>e.kind===`plugin-message`),o=`discard-${a[0].key}`;n.push({kind:`discarded-turn`,key:o,reason:r.output==null?r.summary:r.output.replace(RH,``).trim(),pluginId:a[0].pluginId,pluginName:a[0].pluginName,messages:a.map(e=>e.text),tools:i.flatMap(e=>e.kind===`tool`?[{name:e.name,summary:e.summary}]:[]),expanded:t.has(o)});continue}}n.push(r)}return n}function BH(e){return e.kind===`tool-group`&&e.explore?.steps?[e,...e.children]:[e]}function VH(e,t,n=!1){if(e.length<2)return e.flatMap(BH);let r={commands:0,reads:0,searches:0,others:0},i=0,a=0,o=0;for(let t of e.flatMap(e=>e.kind===`tool-group`?e.children:[e]))t.kind===`thinking`?i+=1:t.kind===`tool`&&(OH(t.name,t.summary,r,!1),o+=1),(t.kind===`thinking`||t.kind===`tool`)&&(a+=t.durationMs??0);let s=`group-${e[0].key}`,c=t.has(s),l=AH(e),u={kind:`tool-group`,key:s,expanded:c,count:o,stats:r,exploring:!1,activity:{thinking:i,workedMs:a},...n?{live:!0}:{},...l?{summary:l}:{},children:e};return c?[u,...e.flatMap(BH)]:[u]}var HH={signature:``,closedAt:null,held:[]};function UH(e){return e.kind===`tool-group`&&e.children[0]?e.children[0].key:e.key}function WH(e,t){return e.kind===`tool`&&e.generatedImages?.length||e.kind===`tool`&&nB(e.name,t)?!1:e.kind===`thinking`||e.kind===`tool-group`||e.kind===`tool`&&e.state===`ok`&&!e.name.startsWith(`goal_`)&&e.name!==`submit_plan`}function GH(e,t,n,r){let i=zH(e,n),a=r.autoCollapseCompletedTurns===!0,o=r.turnOverrides,s=i.findLastIndex(e=>e.kind===`user`&&!e.deliveryState),c=i;if(a||o&&o.size>0){let e=[],n=0;for(;n<i.length;){let r=i[n];if(r.kind===`user`){let c=n===s,l=a&&!c&&r.canCollapse===!0,u=!r.deliveryState&&!(t&&c)&&(o?.get(r.key)??l);if(e.push(u?{...r,collapsed:!0}:r),n+=1,u)for(;n<i.length&&i[n].kind!==`user`;){let t=i[n];EH(t)||e.push(t),n+=1}}else e.push(r),n+=1}c=e}c=LH(c,n,r.compact===!0);let l=c.findLastIndex(e=>e.kind===`user`&&!e.deliveryState),u=Math.max(l,c.findLastIndex(e=>e.kind===`text`));return{sourceItems:c,lastUserIndex:l,liveFrom:u}}function KH(e,t,n){if(n.collapseLiveActivity!==!0||!t)return null;let{sourceItems:r,liveFrom:i}=GH(e,t,new Set,n),a=n.readableToolCards===!0,o=[],s=!1,c=0;for(;c<r.length;){if(!(c>i)||!WH(r[c],a)){c+=1;continue}let e=[],t=c;for(;t<r.length&&WH(r[t],a);){let n=r[t];if(n.kind===`thinking`&&n.streaming){s=!0;break}e.push(UH(n)),t+=1}for(e.length>0&&o.push(e);t<r.length&&WH(r[t],a);)t+=1;c=t}return o.length===0?null:{segments:o,blocked:s}}function qH(e,t,n,r,i){let a=KH(e,t,n);if(!a)return{witness:HH,released:new Set,wakeAt:null};let{segments:o,blocked:s}=a,c=new Set(r.held),l=[],u=[],d=!0;for(let e of o)for(let t of e)d&&c.has(t)?l.push(t):(d=!1,u.push(t));let f=new Set(l);if(s)return{witness:{signature:``,closedAt:null,held:l},released:f,wakeAt:null};let p=o.some(e=>e.filter(e=>!f.has(e)).length>0&&e.length>=2);if(u.length===0||!p)return{witness:{signature:``,closedAt:null,held:l},released:f,wakeAt:null};let m=u.join(`\0`),h=r.signature===m&&r.closedAt!==null?r.closedAt:i,g=h+iz(n.liveActivityFoldDelaySec);if(i<g)return{witness:{signature:m,closedAt:h,held:l},released:f,wakeAt:g};let _=[...l,...u];return{witness:{signature:``,closedAt:null,held:_},released:new Set(_),wakeAt:null}}function JH(e,t,n,r,i,a,o,s,c,l){let u=e=>e.kind===`tool`&&c?.has(e.key)===!0,d=e=>e.kind===`tool`&&nB(e.name,l),f=e=>i&&!(t&&e>s),p=n=>{if(!a||!t||!(n>s)||!WH(e[n],l)||u(e[n])||!a.has(UH(e[n])))return n;let r=n;for(;r<e.length&&WH(e[r],l)&&!u(e[r])&&a.has(UH(e[r]));)r+=1;return r-n>=2?r:n},m=(e,t)=>!d(e)&&!u(e)&&!(e.kind===`tool`&&e.generatedImages?.length)&&(e.kind===`thinking`||e.kind===`tool-group`&&f(t)||e.kind===`tool`&&(f(t)?e.state===`ok`&&!e.name.startsWith(`goal_`)&&e.name!==`submit_plan`:!r||MH(e))),h=[],g=0;for(;g<e.length;){let i=e[g],a=p(g);if(a>g){h.push(...VH(NH(e.slice(g,a)),n,!0)),g=a;continue}if(!m(i,g)){h.push(...BH(i)),g+=1;continue}let s=g;for(;s<e.length&&m(e[s],s)&&p(s)===s;)s+=1;let c=NH(e.slice(g,s));if(f(g)){h.push(...VH(c,n)),g=s;continue}let l=!r&&t&&o>=0&&g>o,u=e=>e.kind===`tool`?e.edits!==null||e.writeContent||e.fileChanges?.length||e.imagePath&&e.state!==`error`||e.name===`todo`||e.name===`submit_plan`?!0:e.state!==`running`&&e.state!==`reviewing`?!1:!(r&&MH(e)):!1,d=c.filter(u),_=c.filter(e=>!u(e)),v=_.filter(e=>e.kind===`tool`).length;if(l||v<TH)h.push(...c);else{let i={commands:0,reads:0,searches:0,others:0};for(let e of _)e.kind===`tool`&&OH(e.name,e.summary,i,r);let a=`group-${c[0].key}`,o=n.has(a),l=AH(_);h.push({kind:`tool-group`,key:a,expanded:o,count:v,stats:i,exploring:r&&(t&&s===e.length||_.some(e=>e.kind===`tool`&&(e.state===`running`||e.state===`reviewing`))),...l?{summary:l}:{},children:_}),o?h.push(...c):h.push(...d)}g=s}return h}function YH(e){return e.kind===`user`&&!e.deliveryState}function XH(e){return e.kind===`text`&&fe(e.text)}function ZH(e){return e.kind===`text`&&e.text.trim().length>0&&!fe(e.text)}function QH(e,t){for(let n of e)n.kind===`tool`?t(n):n.kind===`tool-group`&&QH(n.children,t)}function $H(e,t,n){if(e.length===0)return[];let r={commands:0,reads:0,searches:0,others:0},i=0,a=0,o=0;QH(e,e=>{OH(e.name,e.summary,r,!1),i+=1,o+=e.durationMs??0});for(let t of e)t.kind===`thinking`&&(a+=1,o+=t.durationMs??0);let s=`${n?`silent`:`group`}-${e[0].key}`,c=t.has(s),l=AH(e),u={kind:`tool-group`,key:s,expanded:c,count:i,stats:r,exploring:!1,activity:{thinking:a,workedMs:o},...n?{notice:n}:{},...l&&!n?{summary:l}:{},children:e};return c?[u,...e]:[u]}function eU(e){return/<secretary-schedule>/.test(e)&&!/<session-updates>/.test(e)?`patrol`:`seen`}function tU(e){let t=!1;return QH(e,e=>{e.name===`silence_turn`&&(t=!0)}),t||e.some(XH)}function nU(e,t,n,r){let i=[],a=0;for(;a<e.length;){if(!YH(e[a])){i.push(e[a]),a+=1;continue}let o=a+1;for(;o<e.length&&!YH(e[o]);)o+=1;let s=e.slice(a,o),c=t&&o===e.length;i.push(...rU(s,c,n,r)),a=o}return i}function rU(e,t,n,r){let i=e[0];if(t||i?.kind!==`user`)return e;let a=e.slice(1).filter(e=>!XH(e));if(xe(i.text)&&tU(e.slice(1))){let e=eU(i.text);return $H([{...i,canCollapse:!1},...a],n,e)}if(!r||a.some(ZH))return e;let o=!1,s=0;return QH(a,e=>{s+=1,e.state!==`ok`&&(o=!0)}),o||s<1||a.some(e=>e.kind!==`tool`&&e.kind!==`thinking`&&e.kind!==`tool-group`)?e:[{...i,canCollapse:!1},...$H(a,n)]}function iU(e,t,n,r={}){let{sourceItems:i,lastUserIndex:a,liveFrom:o}=GH(nU(e.map(e=>e.kind===`resumed-reply`?{...e,expanded:n.has(e.key)}:e),t,n,r.foldToolOnlyTurns===!0),t,n,r),s=r.readableToolCards===!0,c=Mz(i,e=>nB(e,s),(e,t)=>e.kind===`tool`?{...e,cardPeers:t.flatMap(e=>e.kind===`tool`?[{key:e.key,args:e.args??null,output:e.output,state:e.state,...e.image?{image:e.image}:{}}]:[])}:e),l=r.collapseLiveActivity===!0?r.releasedLiveActivity??null:null;return JH(c,t,n,r.compact===!0,r.collapseCompletedActivity===!0,l,a,o,r.heldOpenTools??null,s)}var aU={rows:new Set,expanded:new Set};function oU(e,t,n){let r=[],i=[],a=new Map,o=new Set;for(let s of t){if(s.kind!==`tool-group`||!s.explore)continue;let t=e.rows.has(s.key);if(s.explore.steps){o.add(s.key),t&&!e.expanded.has(s.key)&&i.push(s.key),s.children.forEach((e,t)=>{a.set(e.key,{group:s.key,index:t})});continue}let c=s.children[0]?.key??``,l=s.children.at(-1)?.key??``,u=!t&&e.rows.has(c)&&e.rows.has(l);if(!u&&!e.expanded.has(s.key))continue;let d=n(u?c:s.key,l);d>0&&r.push({key:s.key,height:d,pair:u})}return{collapses:r,expands:i,children:a,next:{rows:new Set(t.map(e=>e.key)),expanded:o}}}function sU({loading:e=!1,runStartedAt:t}){if(!e)return t}var cU=(0,U.createContext)({query:``,activeKey:``,activeNth:-1});function lU(){return(0,U.useContext)(cU)}var uU=`rounded-[2px] px-0.5 py-px`,dU=`${uU} bg-yellow-300 text-foreground dark:bg-yellow-500/80`,fU=`${uU} bg-orange-600 text-white dark:bg-orange-500`;function pU(e,t,n,r){let i=t.trim();if(!i)return e;let a=e.toLowerCase(),o=i.toLowerCase(),s=0,c=a.indexOf(o,s);if(c<0)return e;let l=[];for(;c>=0;){c>s&&l.push(e.slice(s,c));let t=r.n++;l.push((0,K.jsx)(`mark`,{className:t===n?fU:dU,children:e.slice(c,c+i.length)},t)),s=c+i.length,c=a.indexOf(o,s)}return s<e.length&&l.push(e.slice(s)),l}function mU(e,t,n,r){return e==null||typeof e==`boolean`?e:typeof e==`string`||typeof e==`number`?pU(String(e),t,n,r):Array.isArray(e)?e.map((e,i)=>(0,K.jsx)(U.Fragment,{children:mU(e,t,n,r)},i)):e}function hU(e){return e===`right`||e===`off`?e:`left`}function gU(e,t,n){return e!==`off`&&!t&&n>=2}var _U=40;function vU({items:e,activeKey:t,onJump:n}){let r=E(e=>e.chatWide),i=hU(E(e=>e.navRailSide)),[a,o]=(0,U.useState)(null);if(!gU(i,r,e.length))return null;let s=i===`right`,c=Math.max(0,e.findIndex(e=>e.key===t)),l=Math.min(Math.max(0,c-Math.floor(_U/2)),Math.max(0,e.length-_U)),u=e.slice(l,l+_U),d=l>0,f=l+_U<e.length,p=(e,t)=>{let n=t?24:12;if(a===null)return n;let r=Math.abs(e-a);return n+Math.max(0,16-r*6)};return(0,K.jsx)(`div`,{className:G(`group/rail absolute top-0 z-10 hidden h-full w-14 @min-[52rem]:block`,s?`right-0`:`left-0`),children:(0,K.jsx)(`div`,{className:G(`absolute top-1/2 -translate-y-1/2 opacity-0 transition-opacity duration-200 group-hover/rail:opacity-100`,s?`right-2`:`left-2`),onMouseLeave:()=>o(null),children:(0,K.jsxs)(`div`,{className:`relative flex flex-col justify-center gap-[5px]`,style:{maskImage:d||f?`linear-gradient(to bottom, ${d?`transparent, black 24px`:`black`}, ${f?`black calc(100% - 24px), transparent`:`black`})`:void 0},children:[u.map((e,r)=>{let i=e.key===t,c=r===a;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(e.key),onMouseEnter:()=>o(r),className:G(`flex h-[7px] w-10 items-center`,s&&`justify-end`),children:(0,K.jsx)(`span`,{className:G(`rounded-full transition-all duration-150`,i||c?`h-[3px] bg-foreground`:`h-[2px] bg-muted-foreground/40`),style:{width:p(r,i)}})},e.key)}),a!==null&&u[a]&&(0,K.jsxs)(`div`,{className:G(`pointer-events-none absolute w-72 -translate-y-1/2 rounded-xl border bg-popover p-3 shadow-lg`,s?`right-10`:`left-10`),style:{top:`${(a+.5)/u.length*100}%`},children:[(0,K.jsx)(`p`,{className:`line-clamp-2 text-xs font-semibold`,children:u[a].question}),u[a].answer&&(0,K.jsx)(`p`,{className:`mt-1 line-clamp-3 text-xs text-muted-foreground`,children:u[a].answer})]})]})})})}var yU={width:72,height:28};function bU(e,t){let n=[];for(let r of e.querySelectorAll(`[data-quote-skip]`)){let e=r.getBoundingClientRect();e.height>0&&e.bottom>0&&e.top<t&&n.push(e)}return n}function xU({containerRef:e}){let{t}=q(),n=E(e=>e.quoteSelectionButton),r=OD(),[i,a]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!n){a(null);return}let t=()=>{let t=e.current,n=window.getSelection(),i=t?NA(n,t):null;if(!i||!n||!t){a(null);return}let o=n.getRangeAt(0).getBoundingClientRect(),s={width:window.innerWidth,height:window.innerHeight},c=bU(t,s.height);a({text:i,...IA(o,s,yU,r,c)})};return document.addEventListener(`selectionchange`,t),window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`selectionchange`,t),window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t)}},[n,r,e]),!n||!i?null:(0,Gs.createPortal)((0,K.jsxs)(`button`,{type:`button`,"data-enso":`quote-selection`,title:t(`Quote into the input box`),onMouseDown:e=>e.preventDefault(),onClick:()=>{let e=wA(i.text);!e||!$O(e)||(window.getSelection()?.removeAllRanges(),a(null))},style:{top:i.top,left:i.left,minWidth:yU.width},className:`fixed z-50 inline-flex h-7 items-center justify-center gap-1 rounded-full border bg-card px-2.5 text-xs text-foreground shadow-float hover:bg-muted`,children:[(0,K.jsx)(kn,{className:`h-3 w-3`}),t(`Quote`)]}),document.body)}var SU=/\n*<chat-reference id="([^"]*)" title="([^"]*)" kind="(?:direct|group)">\n[\s\S]*?\n<\/chat-reference>/g;function CU(e){let t=[],n=e.replace(SU,(e,n,r)=>(t.push({id:n,title:r}),``));return t.length?{body:n.trim(),refs:t}:{body:e,refs:t}}var wU={zh:`这是同一件事的补充,保留原目标,把它并进这一轮的结果;不要单独回一句「收到」。只有明确说换掉或取消才改目标。
209
209
  补充内容:
210
210
  `,en:`This adds to the same request. Keep the original goal and fold it into this turn's result; do not reply with a standalone "got it". Only change the goal if explicitly told to replace or cancel it.
211
211
  Addition:
@@ -219,8 +219,8 @@ Addition:
219
219
  `).map(e=>e.trim()).find(Boolean)??``),body:t}}var lW=`#7c5cff`,uW=/^#[0-9a-f]{6}$/iu,dW=/^[0-9a-f]{8}$/u,fW=/^([01]\d|2[0-3]):[0-5]\d$/u,pW=[`ui`,`zh`,`en`],mW=[`concise`,`detailed`],hW=[`needs-user`,`with-done`,`off`],gW=[`goal-complete`,`goal-blocked`,`turn-ended`,`needs-user`,`failed`,`stalled`,`interrupted`];function _W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vW(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function yW(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?e:void 0}function bW(e){let t=yW(e);return t===void 0?void 0:Math.floor(t)}function xW(e,t,n){if(!(typeof e!=`number`||!Number.isFinite(e)))return Math.min(n,Math.max(t,Math.round(e)))}function SW(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=vW(n);e&&!t.includes(e)&&t.push(e)}return t}function CW(e,t,n){return t.includes(e)?e:n}function wW(e,t){return typeof e==`boolean`?e:t}var TW={mode:`projects`,projectIds:[]};function EW(e){return _W(e)?e.mode===`all`?{mode:`all`}:e.mode===`explicit`?{mode:`explicit`}:e.mode===`projects`?{mode:`projects`,projectIds:SW(e.projectIds)}:TW:TW}function DW(e){if(!_W(e))return null;let t=_W(e.avatar)?e.avatar:{},n=bW(t.imageVersion),r=typeof t.imageHash==`string`&&dW.test(t.imageHash)?t.imageHash:void 0,i={version:1,name:vW(e.name)??`秘书`,avatar:{color:typeof t.color==`string`&&uW.test(t.color)?t.color:lW,...n&&n>0?{imageVersion:n,...r?{imageHash:r}:{}}:{}},takeoverScope:EW(e.takeoverScope),pluginIds:SW(e.pluginIds),skillIds:SW(e.skillIds),visibleProjectIds:Array.isArray(e.visibleProjectIds)?SW(e.visibleProjectIds):`all`,maxRunningDispatches:xW(e.maxRunningDispatches,1,10)??3,patrolEnabled:wW(e.patrolEnabled,!0),...e.cleanupSkipConfirm===!0?{cleanupSkipConfirm:!0}:{},replyLanguage:CW(e.replyLanguage,pW,`ui`),style:CW(e.style,mW,`concise`),notify:CW(e.notify,hW,`needs-user`),updatedAt:yW(e.updatedAt)??0},a=xW(e.updateWindowMs,1e3,6e4);a!==void 0&&(i.updateWindowMs=a);let o=SW(e.disabledSkillNames);o.length>0&&(i.disabledSkillNames=o);let s=vW(e.addressAs);return s&&(i.addressAs=s),typeof e.dailyBriefAt==`string`&&fW.test(e.dailyBriefAt)&&(i.dailyBriefAt=e.dailyBriefAt),i}var OW=/^<(session-updates|secretary-schedule)>\n([\s\S]*?)\n<\/\1>(?:\n|$)/,kW=/^- \[([a-z-]+)(?: (?:session|pending):([^\]\s]+))?\] ([^\n]*)(?:\n|$)/,AW=/^<untrusted-content source="[^"]*">/,jW=`</untrusted-content>`;function MW(e){return gW.includes(e)}function NW(e,t,n,r){return e===`secretary-schedule`?t===`schedule`&&!n?{kind:t,text:r}:null:t===`proposal`?n?null:{kind:t,text:r}:t===`pending`?{kind:t,text:r}:t===`ask-relay`||t===`leftover`||t===`queued`?n?{kind:t,text:r,conversationId:n}:null:MW(t)?n?{kind:t,text:r,conversationId:n}:{kind:t,text:r}:null}function PW(e,t){let n=[],r=t;for(;r;){let t=kW.exec(r),i=t&&NW(e,t[1],t[2],t[3]);if(!t||!i)return null;r=r.slice(t[0].length);let a=AW.exec(r);if(a){let e=r.indexOf(jW);if(e<0)return null;if(i.detail=Cz(r.slice(a[0].length,e)),r=r.slice(e+20),r.startsWith(`
220
220
  `))r=r.slice(1);else if(r)return null}n.push(i)}return n.length>0?n:null}function FW(e){let t=[],n=e.trim();for(;n;){let e=OW.exec(n),r=e&&PW(e[1],e[2]);if(!e||!r)return null;t.push(...r),n=n.slice(e[0].length)}return t.length>0?t:null}var IW=new Set([`Shell read-only shortcut: prefer read (offset/limit) for files, grep for content, find for paths — the dedicated tools handle line ranges and stream far less output.`,"Sleep-waiting in a foreground command costs a model round per check. Put the whole wait in one command that exits when the condition holds (e.g. `until <check>; do sleep 10; done; <report>`) and run it with background: true — you are notified when it finishes, then end your turn.",`timeout only kills the process; it does not keep this call in the foreground. If the command may outlast the yield, set background: true and end your turn — completion wakes you. Do not poll with sleep, ps, pgrep, or task_output loops.`]);function LW(e){let t=e.split(`
221
221
  `),n=0;for(;n<t.length&&IW.has(t[n].replace(/\r$/,``));)n++;if(n===0)return e;for(;n<t.length&&!t[n].trim();)n++;return t.slice(n).join(`
222
- `)||e}var RW=/^Command exited with code \d+$/,zW=/^Command (?:aborted|timed out after \d+ seconds|terminated without an exit code)/,BW=/^\[[^\]]+\]/,VW=/^at\s/,HW=/\b(?:error|fatal|panic|exception|failed|failure|cannot|not found|no such file|denied|refused)\b(?!\.\w|\()/i;function UW(e){let t=LW(e).split(/\r?\n/).map(e=>e.trim()),n=t.findLastIndex(e=>RW.test(e)||zW.test(e));if(n<0)return t.find(Boolean)??``;if(zW.test(t[n]))return t[n];for(let e=n-1;e>=0;e--){let n=t[e];if(n&&!BW.test(n)&&!VW.test(n)&&HW.test(n))return n}return t[n]}function WW({message:e}){let{t}=q(),n={queued:t(`Queued`),running:t(`In progress`),completed:t(`Completed`),failed:t(`Failed`),canceled:t(`Canceled`)},r=e.kind===`routine`?jt:e.kind===`group`?fn:e.kind===`delegation-task`?At:e.kind===`delegation-retry`||e.kind===`delegation-check-failed`?Mn:Ft,i=e.kind===`routine`?`${e.dryRun?t(`Routine dry run`):t(`Routine task`)} · ${e.title}`:e.kind===`group`?t(`Group messages`):e.kind===`delegation-task`?t(`Task from {{name}}`,{name:e.from}):e.kind===`delegation-results`?t(`Delegation results`):e.kind===`delegation-retry`?t(`Continue delegated task`):e.kind===`delegation-check-failed`?t(`Acceptance check not passed`):t(`Result from {{name}}`,{name:e.from});return(0,K.jsxs)(`div`,{"data-bot-injection":e.kind,className:`w-full rounded-lg border border-border/60 bg-muted/20 px-3 py-2 text-sm`,children:[(0,K.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(r,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:i}),e.kind===`delegation-result`&&e.status&&(0,K.jsxs)(`span`,{children:[`· `,n[e.status]??e.status]})]}),(0,K.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.kind===`routine`?e.prompt:e.kind===`delegation-task`?e.task:e.kind===`delegation-result`||e.kind===`delegation-retry`||e.kind===`delegation-check-failed`?e.text:e.kind===`delegation-results`?e.results.map((e,t)=>(0,K.jsxs)(`p`,{children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.from,e.status&&` · ${n[e.status]??e.status}`,`:`]}),e.text]},`${t}:${e.from}`)):e.messages.map((e,t)=>(0,K.jsxs)(`p`,{children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.from,`:`]}),e.text]},`${t}:${e.from}`))}),e.kind===`delegation-task`&&e.context&&(0,K.jsxs)(`details`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:t(`Context`)}),(0,K.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.context})]}),e.kind===`group`&&e.instruction&&(0,K.jsxs)(`details`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:t(`Instructions`)}),(0,K.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.instruction})]}),e.kind===`group`&&!!e.refs?.length&&(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:e.refs.map(e=>(0,K.jsxs)(`span`,{title:t(`Referenced chat`),className:`inline-flex h-6 max-w-56 items-center gap-1 rounded-md bg-muted px-1.5 text-xs`,children:[(0,K.jsx)(fn,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.id))}),e.kind===`group`&&e.note&&(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:t(`Dispatch hint: {{note}}`,{note:e.note})}),e.kind!==`group`&&!!e.group?.length&&(0,K.jsxs)(`details`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer`,children:[t(`Group messages`),` · `,e.group.length]}),(0,K.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.group.map((e,t)=>(0,K.jsxs)(`p`,{children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.from,`:`]}),e.text]},`${t}:${e.from}`))})]})]})}async function GW(e,t){let n=await nP.getState().restartConversation(e);n&&gD({type:`error`,title:t(`Failed to restart conversation`),description:n})}function KW(e,t){if(!t)return null;for(let[n,r]of Object.entries(e))if(r?.sessionFile===t)return n;return null}function qW(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function JW(e){return e.alias?.trim()||(e.name===e.path?qW(e.path):e.name)}function YW(e,t,n){if(!t)return``;if(bj(t))return Sj(n,t.modelId);let r=e.find(e=>e.id===t.providerId);return r?`${r.name} / ${t.modelId}`:t.modelId}var XW=DW({});if(!XW)throw Error(`secretary default profile`);var ZW=XW;function QW(e,t){let n=e??ZW;return{name:e?.name.trim()||t,avatar:{color:n.avatar.color,...n.avatar.imageVersion?{imageVersion:n.avatar.imageVersion}:{}},takeoverScope:n.takeoverScope.mode===`projects`?{mode:`projects`,projectIds:[...n.takeoverScope.projectIds]}:n.takeoverScope,visibleProjectIds:n.visibleProjectIds===`all`?`all`:[...n.visibleProjectIds],maxRunningDispatches:n.maxRunningDispatches,patrolEnabled:n.patrolEnabled,cleanupSkipConfirm:n.cleanupSkipConfirm===!0,replyLanguage:n.replyLanguage,style:n.style,notify:n.notify,addressAs:n.addressAs??null,dailyBriefAt:n.dailyBriefAt??null}}function $W(e){return QW(null,e)}function eG(e,t){switch(t.type){case`patch`:{let{avatar:n,...r}=t.patch;return{...e,...r,...n?{avatar:{...e.avatar,...n}}:{}}}case`reset`:return t.draft}}var tG=U.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=cN(),{clearErrors:C}=dN(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=pN(),O=_N({id:i});X(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=U.useRef(null);X(()=>{u&&k.current===vb(My(k.current))&&y(!0)},[u,y]);let[A]=Mj({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=Ay(()=>S.inputRef.current?.value);return lN(S.inputRef,O,M,N,!w,a),Vr(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,Ky(Iy,e.nativeEvent)),_(t!==(v.initialValue??``)),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:iN})}),nG=U.forwardRef(function(e,t){return(0,K.jsx)(tG,{ref:t,...e})});function rG({className:e,size:t=`default`,unstyled:n=!1,...r}){return(0,K.jsx)(`span`,{className:G(!n&&`relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base shadow-xs ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e)||void 0,"data-size":t,"data-slot":`input-control`,children:(0,K.jsx)(nG,{className:G(`h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5`,t===`sm`&&`h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5`,t===`lg`&&`h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5`,r.type===`search`&&`[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none`,r.type===`file`&&`text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm`),"data-slot":`input`,size:typeof t==`number`?t:void 0,...r})})}var iG=[`#7c5cff`,`#2f9e75`,`#c2553f`,`#2f7fc2`,`#b07a1e`,`#7a4fb5`],aG=/^#[0-9a-f]{6}$/iu;function oG(e){let t=e.trim();return aG.test(t)?t.toLowerCase():null}function sG(e){let t=e?oG(e):null,n=iG.find(e=>e===t)??null;return{preset:n,customSelected:t!==null&&n===null}}function cG({color:e,onChange:t}){let{t:n}=q(),[r,i]=(0,U.useState)(e);(0,U.useEffect)(()=>i(e),[e]);let a=sG(e),o=e=>{let n=oG(e);n&&t(n)};return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pointer-coarse:gap-[23px]`,"data-enso":`secretary-form-avatar`,children:[iG.map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":a.preset===e,"aria-label":e,onClick:()=>t(e),style:{backgroundColor:e},className:G(`size-6 rounded-full border-2 transition-transform`,a.preset===e?`border-foreground`:`border-transparent hover:scale-105`)},e)),(0,K.jsxs)(`label`,{"data-enso":`secretary-form-avatar-custom`,"data-selected":a.customSelected?`true`:`false`,title:n(`Custom color`),style:a.customSelected?{backgroundColor:e}:void 0,className:G(`relative grid size-6 cursor-pointer place-items-center overflow-hidden rounded-full border-2 text-[10px] pointer-coarse:overflow-visible`,a.customSelected?`border-foreground text-white`:`border-border text-muted-foreground`),children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:a.customSelected?`sr-only`:void 0,children:`+`}),(0,K.jsx)(`input`,{type:`color`,"aria-label":n(`Custom color`),value:oG(e)??`#7c5cff`,onChange:e=>o(e.target.value),className:`absolute inset-0 cursor-pointer opacity-0 pointer-coarse:-inset-[12px]`})]}),(0,K.jsx)(rG,{"data-enso":`secretary-form-avatar-hex`,value:r,spellCheck:!1,"aria-label":n(`Custom color`),onChange:e=>{let t=e.target.value;i(t),o(t)},className:`h-7 w-24 font-mono text-xs`})]})}var lG=[1,2,3,4,5];function uG({value:e,options:t,onChange:n,enso:r}){let{t:i}=q();return(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-enso":r,children:t.map(t=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":t.value===e,onClick:()=>n(t.value),className:G(`rounded-md border px-2.5 py-1 text-xs transition-colors`,t.value===e?`border-primary/60 bg-primary/10 text-foreground`:`border-border text-muted-foreground hover:bg-muted`),children:i(t.label)},t.value))})}function dG({label:e,hint:t,children:n}){let{t:r}=q();return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-sm`,children:r(e)}),n,t?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(t)}):null]})}function fG({label:e,hint:t,checked:n,onChange:r,enso:i}){let{t:a}=q();return(0,K.jsxs)(`label`,{className:`flex items-start justify-between gap-3`,"data-enso":i,children:[(0,K.jsxs)(`span`,{className:`space-y-1`,children:[(0,K.jsx)(`span`,{className:`block text-sm`,children:a(e)}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(t)})]}),(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:()=>r(!n),className:G(`relative mt-0.5 h-5 w-9 shrink-0 rounded-full border transition-colors`,n?`border-primary bg-primary`:`border-border bg-muted`),children:(0,K.jsx)(`span`,{className:G(`absolute top-0.5 size-3.5 rounded-full bg-background transition-all`,n?`left-[18px]`:`left-0.5`)})})]})}function pG({selected:e,onChange:t,enso:n}){let r=E(e=>e.projects).filter(e=>e.kind!==`scratch`&&e.kind!==`secretary`);return r.length===0?null:(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-enso":n,children:r.map(n=>{let r=e.includes(n.id);return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(r?e.filter(e=>e!==n.id):[...e,n.id]),className:G(`rounded-md border px-2.5 py-1 text-xs transition-colors`,r?`border-primary/60 bg-primary/10 text-foreground`:`border-border text-muted-foreground hover:bg-muted`),children:JW(n)},n.id)})})}function mG({initialDraft:e,submitLabel:t,onSubmit:n,busy:r=!1,error:i=null,allowDefaults:a=!1,onCancel:o,hideMaxRunning:s=!1}){let{t:c}=q(),[l,u]=U.useReducer(eG,e),d=e=>u({type:`patch`,patch:e});return(0,K.jsxs)(`div`,{className:`space-y-4`,"data-enso":`secretary-profile-form`,children:[(0,K.jsx)(dG,{label:`Name`,children:(0,K.jsx)(rG,{"data-enso":`secretary-form-name`,value:l.name??``,onChange:e=>d({name:e.target.value}),className:`max-w-xs`})}),(0,K.jsx)(dG,{label:`Avatar color`,children:(0,K.jsx)(cG,{color:l.avatar?.color??`#7c5cff`,onChange:e=>d({avatar:{color:e}})})}),(0,K.jsxs)(dG,{label:`Visible projects`,children:[(0,K.jsx)(uG,{enso:`secretary-form-visible-mode`,value:l.visibleProjectIds===`all`?`all`:`selected`,options:[{value:`all`,label:`All projects`},{value:`selected`,label:`Selected projects`}],onChange:e=>d({visibleProjectIds:e===`all`?`all`:l.visibleProjectIds===`all`?[]:l.visibleProjectIds})}),l.visibleProjectIds===`all`?null:(0,K.jsx)(pG,{enso:`secretary-form-visible-projects`,selected:l.visibleProjectIds??[],onChange:e=>d({visibleProjectIds:e})})]}),!s&&(0,K.jsx)(dG,{label:`Running dispatches at most`,children:(0,K.jsx)(uG,{enso:`secretary-form-max-running`,value:String(l.maxRunningDispatches??3),options:lG.map(e=>({value:String(e),label:String(e)})),onChange:e=>d({maxRunningDispatches:Number(e)})})}),(0,K.jsx)(fG,{enso:`secretary-form-patrol`,label:`Watch running sessions automatically`,hint:`While anything is running the secretary checks it and only reports an anomaly: a goal session idle for 3 minutes with an unfinished goal and no live background task, idle for 20 minutes with a background task that never woke it, or running for 30 minutes without any event. Every hour it also reports background tasks left running in finished sessions; nothing is killed. Nothing is sent when all is well.`,checked:l.patrolEnabled??!0,onChange:e=>d({patrolEnabled:e})}),(0,K.jsx)(fG,{enso:`secretary-form-cleanup-skip-confirm`,label:`Clean up without asking`,hint:`Off by default. When on, this secretary's cleanup deletes immediately, with no confirmation card: merged local branches and their worktrees. Sessions are only archived, never deleted. Unmerged branches, branches in use, feat/secretary-agent, main, the current branch and worktrees with uncommitted changes are still refused or skipped.`,checked:l.cleanupSkipConfirm??!1,onChange:e=>d({cleanupSkipConfirm:e})}),i?(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:i}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(Oa,{size:`sm`,disabled:r,"data-enso":`secretary-form-submit`,onClick:()=>n(l),children:t}),o&&(0,K.jsx)(Oa,{variant:`ghost`,size:`sm`,disabled:r,onClick:o,children:c(`Cancel`)}),a&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-form-defaults`,disabled:r,onClick:()=>n($W(c(`Secretary`))),className:`text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,children:c(`Use all defaults and start`)})]})]})}var hG=new Set([`session_create`,`todo_item_dispatch`,`secretary_profile_propose`,`skill_propose`,`tool_propose`,`session_takeover_propose`,`cleanup_apply`]);function gG(e){if(!hG.has(e.name)||e.state===`running`||e.state===`error`||!e.output)return null;let t;try{t=JSON.parse(e.output)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;return n.status===`awaiting_confirmation`&&typeof n.proposalId==`string`?n.proposalId:null}var _G={pending:`Waiting for your confirmation`,executing:`Creating the session…`,succeeded:`Session created`,failed:`Failed`,rejected:`Rejected`,expired:`Expired`},vG={..._G,executing:`Saving the profile…`,succeeded:`Profile saved`};function yG(e){return G(`mb-1 w-full rounded-lg border px-2.5 py-2`,e?`border-warning/40 bg-warning/5`:`border-border/60 bg-muted/20`)}function bG(e){return e.draft.title?.trim()||e.draft.prompt.split(`
223
- `)[0]?.trim()||``}function xG({proposalId:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.secretary.proposals[e]),i=YR(t=>t.resolving[e]===!0),a=YR(e=>e.resolveProposal),o=E(e=>e.projects),s=E(e=>e.providers)??[],c=E(e=>e.virtualModels);if(!r)return(0,K.jsx)(`div`,{"data-enso":`secretary-proposal`,className:G(yG(t),`text-[11px] text-muted-foreground`),children:n(`Waiting for your confirmation`)});if(r.kind===`profile`)return(0,K.jsx)(SG,{proposal:r,prominent:t});if(r.kind===`skill`)return(0,K.jsx)(OG,{proposal:r,prominent:t});if(r.kind===`tool`)return(0,K.jsx)(DG,{proposal:r,prominent:t});if(r.kind===`takeover`)return(0,K.jsx)(EG,{proposal:r,prominent:t});if(r.kind===`cleanup`)return(0,K.jsx)(PG,{proposal:r,prominent:t});let l=o.find(e=>e.id===r.draft.projectId),u=r.status===`failed`,d=YW(s,r.draft.model,c);return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Dispatch`)}),l&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:JW(l)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:bG(r)}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:r.draft.worktree?n(`Isolated worktree`):n(`Project checkout`)})]}),(r.draft.branch||r.draft.baseRef||d||(r.draft.after?.length??0)>0)&&(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal-base`,className:`mt-1 flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[r.draft.branch&&(0,K.jsx)(`span`,{children:r.draft.branch}),r.draft.baseRef&&(0,K.jsx)(`span`,{children:n(`from {{ref}}`,{ref:r.draft.baseRef})}),d&&(0,K.jsx)(`span`,{"data-enso":`secretary-proposal-model`,children:n(`Model: {{model}}`,{model:d})}),r.draft.after&&r.draft.after.length>0&&(0,K.jsx)(`span`,{children:n(`After {{ids}}`,{ids:r.draft.after.join(`, `)})})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,u?`text-destructive`:`text-muted-foreground`),children:[n(_G[r.status]),u&&r.error?` · ${r.error}`:``]}),r.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>void a(r.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm dispatch`)}),(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>void a(r.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function SG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),[a,o]=U.useState(!1),s=e.draft,c=e.status===`failed`,l=U.useMemo(()=>({...QW(null,n(`Secretary`)),...s}),[s,n]);return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`profile`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Profile`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s.name??n(`Secretary`)})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:n(`Up to {{n}} at a time`,{n:s.maxRunningDispatches??3})}),(0,K.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,K.jsx)(`span`,{children:n(s.patrolEnabled===!1?`Patrol off`:`Patrol on`)}),(0,K.jsx)(`span`,{children:n(s.cleanupSkipConfirm?`Cleanup without confirmation`:`Cleanup asks first`)})]}),a?(0,K.jsx)(`div`,{className:`mt-2 border-t border-border/60 pt-2`,children:(0,K.jsx)(mG,{initialDraft:l,submitLabel:n(`Confirm`),busy:r,onSubmit:t=>{o(!1),i(e.id,`confirm`,void 0,t)},onCancel:()=>o(!1)})}):(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,c?`text-destructive`:`text-muted-foreground`),children:[n(vG[e.status]),c&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-proposal-edit`,disabled:r,onClick:()=>o(!0),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Edit here`)})]})]})]})}var CG={..._G,executing:`Saving the skill…`,succeeded:`Skill saved`},wG={..._G,executing:`Saving the tool…`,succeeded:`Tool saved`},TG={..._G,executing:`Handing it over…`,succeeded:`Handed over to the secretary`};function EG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=E(e=>e.projects).find(t=>t.id===e.draft.projectId),o=e.status===`failed`;return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`takeover`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Take over`)}),a&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:JW(a)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.draft.title??n(`Unnamed`)})]}),(0,K.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[n(`The secretary asks to manage this session: it may message and stop it like its own.`),e.draft.reason?` ${e.draft.reason}`:``]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,o?`text-destructive`:`text-muted-foreground`),children:[n(TG[e.status]),o&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Allow takeover`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function DG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=e.draft,o=e.status===`failed`;return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`tool`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Tool`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:a.name}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.runtime===`python`?`Python`:`Node`}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.readOnly?n(`Read-only`):n(`Asks every call`)}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:e.previous?n(`Update`):n(`New`)})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:a.description}),(0,K.jsxs)(`details`,{className:`mt-1.5 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the arguments`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap text-[11px]`,children:JSON.stringify(a.parameters,null,2)})]}),(0,K.jsxs)(`details`,{className:`mt-1 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the code`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre font-mono text-[11px]`,children:a.code})]}),e.previous?(0,K.jsxs)(`details`,{className:`mt-1 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the current version`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre font-mono text-[11px]`,children:e.previous.code})]}):null,(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,o?`text-destructive`:`text-muted-foreground`),children:[n(wG[e.status]),o&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function OG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=e.draft,o=e.status===`failed`;return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`skill`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Skill`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:a.name}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:e.previous?n(`Update`):n(`New`)})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:a.description}),(0,K.jsxs)(`details`,{className:`mt-1.5 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the content`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap text-[11px]`,children:a.body})]}),e.previous?(0,K.jsxs)(`details`,{className:`mt-1 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the current version`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap text-[11px]`,children:e.previous.body})]}):null,(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,o?`text-destructive`:`text-muted-foreground`),children:[n(CG[e.status]),o&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}var kG={..._G,executing:`Cleaning up…`,succeeded:`Cleanup done`},AG={branch:`Branch`,worktree:`Worktree`,session:`Session`},jG={"not-merged":`Not merged yet`,"current-branch":`Currently checked out`,"used-by-worktree":`Used by a worktree`,"detached-head":`Detached HEAD`,"uncommitted-changes":`Has uncommitted changes`};function MG(e){return e===void 0?null:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var NG=5;function PG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=e.draft.items,o=a.slice(0,NG),s=a.length-o.length,c=e.status===`failed`,l=a.reduce((e,t)=>(e[t.kind]=(e[t.kind]??0)+1,e),{});return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`cleanup`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Clean up`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`{{count}} items`,{count:a.length})}),[`branch`,`worktree`,`session`].map(e=>l[e]?(0,K.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:[l[e],` `,n(AG[e])]},e):null)]}),(0,K.jsxs)(`ul`,{"data-enso":`secretary-cleanup-items`,className:`mt-1.5 space-y-0.5`,children:[o.map(e=>{let t=MG(e.sizeBytes),r=[e.mergedInto?.length?n(`merged into {{refs}}`,{refs:e.mergedInto.join(`, `)}):null,t,e.blocked?n(jG[e.blocked]??e.blocked):null].filter(Boolean);return(0,K.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 text-[11px]`,children:[(0,K.jsx)(`span`,{"data-enso":`secretary-cleanup-kind`,className:`shrink-0 rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:n(AG[e.kind])}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:e.name}),r.length>0&&(0,K.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:r.join(` · `)})]},e.id)}),s>0&&(0,K.jsx)(`li`,{"data-enso":`secretary-cleanup-rest`,className:`text-[11px] text-muted-foreground`,children:n(`and {{count}} more`,{count:s})})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,c?`text-destructive`:`text-muted-foreground`),children:[n(kG[e.status]),c&&e.error?` · ${e.error}`:``,e.report?` · ${e.report}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-cleanup-confirm`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm cleanup`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function FG(e){let[t,n]=U.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=U.useRef(null),i=U.useRef(null),a=U.useRef(null),o=U.useRef(null),s=U.useRef(!0),c=U.useRef(null),l=Xy(),u=U.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,K.jsx)(kj.Provider,{value:u,children:(0,K.jsx)(Dj.Provider,{value:void 0,children:(0,K.jsx)(pM,{...e})})})}var IG=500,LG=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Aj(!1),{store:m}=Oj(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=U.useRef(null),v=U.useRef(null),y=nb(),b=nb(),x=U.useRef(!1),S=U.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Ky(Ly,n)),b.start(IG,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,db(e),C(e.clientX,e.clientY,e.nativeEvent);let t=My(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=bb(e);yb(u.current,t)||p&&t&&bM(t)===p||s.current?.setOpen(!1,Ky(Uy,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(IG,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return U.useEffect(()=>()=>{S.current?.abort()},[]),U.useEffect(()=>{function e(e){if(g)return;let t=bb(e);(yb(_.current,t)||yb(c.current,t)||yb(l.current,t))&&e.preventDefault()}return Pb(My(_.current),`contextmenu`,e)},[l,g,c]),Vr(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:$v})}),RG=FG;function zG(e){return(0,K.jsx)(LG,{"data-slot":`context-menu-trigger`,...e})}function BG({children:e,className:t,zIndex:n,...r}){return(0,K.jsxs)(Yj,{children:[(0,K.jsx)(jj,{className:`fixed inset-0 z-40`,"data-enso-float":``,style:n===void 0?void 0:{zIndex:n-1}}),(0,K.jsx)(aM,{className:`z-50`,"data-slot":`context-menu-positioner`,style:n===void 0?void 0:{zIndex:n},children:(0,K.jsx)(Kj,{className:G(WM,t),"data-slot":`context-menu-popup`,...r,children:(0,K.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1.5`,children:e})})})]})}function VG({className:e,variant:t=`default`,...n}){return(0,K.jsx)(Uj,{className:G(qM,e),"data-slot":`context-menu-item`,"data-variant":t,...n})}async function HG(e){let t=/^data:([^;,]+);base64,(.*)$/s.exec(e);if(!t)return(await fetch(e)).blob();let n=atob(t[2]),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new Blob([r],{type:t[1]})}async function UG(e){let t=await HG(e),n=t;if(t.type!==`image/png`){let e=await createImageBitmap(t),r=new OffscreenCanvas(e.width,e.height);r.getContext(`2d`)?.drawImage(e,0,0),e.close(),n=await r.convertToBlob({type:`image/png`})}await navigator.clipboard.write([new ClipboardItem({"image/png":n})])}function WG({src:e,className:t,frameClassName:n,onError:r,alt:i=``,lazy:a=!1,children:o,title:s}){let{t:c}=q(),[l,u]=(0,U.useState)(!1);DE(l),(0,U.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]);let d=()=>{UG(e).then(()=>gD({type:`success`,title:c(`Image copied`)}),e=>gD({type:`error`,title:c(`Could not copy image`),description:e instanceof Error?e.message:String(e)}))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(RG,{children:[(0,K.jsx)(zG,{render:(0,K.jsx)(`button`,{type:`button`,onClick:()=>u(!0),title:s,className:G(`cursor-zoom-in`,n),children:o??(0,K.jsx)(`img`,{src:e,alt:i,className:t,onError:r,...a?{loading:`lazy`,decoding:`async`}:{}})}),onContextMenu:e=>e.stopPropagation()}),(0,K.jsx)(BG,{className:`min-w-36`,children:(0,K.jsx)(VG,{closeOnClick:!0,onClick:d,children:c(`Copy image`)})})]}),l&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:G(`fixed inset-0 flex cursor-zoom-out items-center justify-center bg-black/75`),style:{zIndex:RE.NESTED_MODAL_BACKDROP},"data-enso-float":``,children:(0,K.jsx)(`img`,{src:e,alt:``,className:`max-h-[92vh] max-w-[92vw] rounded-lg object-contain`})})]})}var GG={"too-large":`over 10 MB, not saved`,"not-image":`not a png / jpeg / webp / gif image, not saved`,unavailable:`could not be saved`};function KG(e){return e.split(/[\\/]/u).pop()??e}function qG({entries:e,thumbnails:t=0,align:n=`end`}){let{t:r}=q(),i=e.filter(e=>`path`in e&&e.index>t),a=e.filter(e=>`rejected`in e);return i.length===0&&a.length===0?null:(0,K.jsxs)(`div`,{"data-enso":`inbound-images`,className:G(`flex flex-col gap-1`,n===`end`?`items-end`:`items-start`),children:[i.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,K.jsxs)(WG,{src:f(e.path),title:KG(e.path),frameClassName:`inline-flex h-6 items-center gap-1 rounded-md bg-muted px-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(en,{className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{children:r(`Image {{n}}`,{n:e.index})})]},e.index))}),a.map(e=>(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`Image {{n}} not accepted: {{reason}}`,{n:e.index,reason:r(GG[e.rejected])})},e.index))]})}var JG={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,ico:`image/x-icon`,avif:`image/avif`,svg:`image/svg+xml`};function YG(e){let t=e.split(/[?#]/)[0]??``,n=t.lastIndexOf(`.`);return n<0?null:JG[t.slice(n+1).toLowerCase()]??null}var XG=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZG=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QG={};function $G(e,t){return((t||QG).jsx?ZG:XG).test(e)}var eK=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
222
+ `)||e}var RW=/^Command exited with code \d+$/,zW=/^Command (?:aborted|timed out after \d+ seconds|terminated without an exit code)/,BW=/^\[[^\]]+\]/,VW=/^at\s/,HW=/\b(?:error|fatal|panic|exception|failed|failure|cannot|not found|no such file|denied|refused)\b(?!\.\w|\()/i;function UW(e){let t=LW(e).split(/\r?\n/).map(e=>e.trim()),n=t.findLastIndex(e=>RW.test(e)||zW.test(e));if(n<0)return t.find(Boolean)??``;if(zW.test(t[n]))return t[n];for(let e=n-1;e>=0;e--){let n=t[e];if(n&&!BW.test(n)&&!VW.test(n)&&HW.test(n))return n}return t[n]}function WW({message:e}){let{t}=q(),n={queued:t(`Queued`),running:t(`In progress`),completed:t(`Completed`),failed:t(`Failed`),canceled:t(`Canceled`)},r=e.kind===`routine`?jt:e.kind===`group`?fn:e.kind===`delegation-task`?At:e.kind===`delegation-retry`||e.kind===`delegation-check-failed`?Mn:Ft,i=e.kind===`routine`?`${e.dryRun?t(`Routine dry run`):t(`Routine task`)} · ${e.title}`:e.kind===`group`?t(`Group messages`):e.kind===`delegation-task`?t(`Task from {{name}}`,{name:e.from}):e.kind===`delegation-results`?t(`Delegation results`):e.kind===`delegation-retry`?t(`Continue delegated task`):e.kind===`delegation-check-failed`?t(`Acceptance check not passed`):t(`Result from {{name}}`,{name:e.from});return(0,K.jsxs)(`div`,{"data-bot-injection":e.kind,className:`w-full rounded-lg border border-border/60 bg-muted/20 px-3 py-2 text-sm`,children:[(0,K.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(r,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:i}),e.kind===`delegation-result`&&e.status&&(0,K.jsxs)(`span`,{children:[`· `,n[e.status]??e.status]})]}),(0,K.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:e.kind===`routine`?e.prompt:e.kind===`delegation-task`?e.task:e.kind===`delegation-result`||e.kind===`delegation-retry`||e.kind===`delegation-check-failed`?e.text:e.kind===`delegation-results`?e.results.map((e,t)=>(0,K.jsxs)(`p`,{children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.from,e.status&&` · ${n[e.status]??e.status}`,`:`]}),e.text]},`${t}:${e.from}`)):e.messages.map((e,t)=>(0,K.jsxs)(`p`,{children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.from,`:`]}),e.text]},`${t}:${e.from}`))}),e.kind===`delegation-task`&&e.context&&(0,K.jsxs)(`details`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:t(`Context`)}),(0,K.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.context})]}),e.kind===`group`&&e.instruction&&(0,K.jsxs)(`details`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer`,children:t(`Instructions`)}),(0,K.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.instruction})]}),e.kind===`group`&&!!e.refs?.length&&(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:e.refs.map(e=>(0,K.jsxs)(`span`,{title:t(`Referenced chat`),className:`inline-flex h-6 max-w-56 items-center gap-1 rounded-md bg-muted px-1.5 text-xs`,children:[(0,K.jsx)(fn,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.id))}),e.kind===`group`&&e.note&&(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:t(`Dispatch hint: {{note}}`,{note:e.note})}),e.kind!==`group`&&!!e.group?.length&&(0,K.jsxs)(`details`,{className:`mt-1.5 text-xs text-muted-foreground`,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer`,children:[t(`Group messages`),` · `,e.group.length]}),(0,K.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.group.map((e,t)=>(0,K.jsxs)(`p`,{children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.from,`:`]}),e.text]},`${t}:${e.from}`))})]})]})}async function GW(e,t){let n=await nP.getState().restartConversation(e);n&&hD({type:`error`,title:t(`Failed to restart conversation`),description:n})}function KW(e,t){if(!t)return null;for(let[n,r]of Object.entries(e))if(r?.sessionFile===t)return n;return null}function qW(e){return e.split(/[\\/]/).filter(Boolean).pop()??e}function JW(e){return e.alias?.trim()||(e.name===e.path?qW(e.path):e.name)}function YW(e,t,n){if(!t)return``;if(yj(t))return xj(n,t.modelId);let r=e.find(e=>e.id===t.providerId);return r?`${r.name} / ${t.modelId}`:t.modelId}var XW=DW({});if(!XW)throw Error(`secretary default profile`);var ZW=XW;function QW(e,t){let n=e??ZW;return{name:e?.name.trim()||t,avatar:{color:n.avatar.color,...n.avatar.imageVersion?{imageVersion:n.avatar.imageVersion}:{}},takeoverScope:n.takeoverScope.mode===`projects`?{mode:`projects`,projectIds:[...n.takeoverScope.projectIds]}:n.takeoverScope,visibleProjectIds:n.visibleProjectIds===`all`?`all`:[...n.visibleProjectIds],maxRunningDispatches:n.maxRunningDispatches,patrolEnabled:n.patrolEnabled,cleanupSkipConfirm:n.cleanupSkipConfirm===!0,replyLanguage:n.replyLanguage,style:n.style,notify:n.notify,addressAs:n.addressAs??null,dailyBriefAt:n.dailyBriefAt??null}}function $W(e){return QW(null,e)}function eG(e,t){switch(t.type){case`patch`:{let{avatar:n,...r}=t.patch;return{...e,...r,...n?{avatar:{...e.avatar,...n}}:{}}}case`reset`:return t.draft}}var tG=U.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=mN(),{clearErrors:C}=_N(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=yN(),O=CN({id:i});X(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=U.useRef(null);X(()=>{u&&k.current===vb(My(k.current))&&y(!0)},[u,y]);let[A]=Lj({controlled:o,default:l,name:`FieldControl`,state:`value`}),j=o!==void 0,M=j?A:void 0,N=Ay(()=>S.inputRef.current?.value);return hN(S.inputRef,O,M,N,!w,a),Vr(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...j?{value:M}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,Ky(Iy,e.nativeEvent)),_(t!==(v.initialValue??``)),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:uN})}),nG=U.forwardRef(function(e,t){return(0,K.jsx)(tG,{ref:t,...e})});function rG({className:e,size:t=`default`,unstyled:n=!1,...r}){return(0,K.jsx)(`span`,{className:G(!n&&`relative inline-flex w-full rounded-lg border border-input bg-background bg-clip-padding text-base shadow-xs ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:not-in-data-[slot=group]:bg-clip-border dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e)||void 0,"data-size":t,"data-slot":`input-control`,children:(0,K.jsx)(nG,{className:G(`h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5`,t===`sm`&&`h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5`,t===`lg`&&`h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5`,r.type===`search`&&`[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none`,r.type===`file`&&`text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm`),"data-slot":`input`,size:typeof t==`number`?t:void 0,...r})})}var iG=[`#7c5cff`,`#2f9e75`,`#c2553f`,`#2f7fc2`,`#b07a1e`,`#7a4fb5`],aG=/^#[0-9a-f]{6}$/iu;function oG(e){let t=e.trim();return aG.test(t)?t.toLowerCase():null}function sG(e){let t=e?oG(e):null,n=iG.find(e=>e===t)??null;return{preset:n,customSelected:t!==null&&n===null}}function cG({color:e,onChange:t}){let{t:n}=q(),[r,i]=(0,U.useState)(e);(0,U.useEffect)(()=>i(e),[e]);let a=sG(e),o=e=>{let n=oG(e);n&&t(n)};return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 pointer-coarse:gap-[23px]`,"data-enso":`secretary-form-avatar`,children:[iG.map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":a.preset===e,"aria-label":e,onClick:()=>t(e),style:{backgroundColor:e},className:G(`size-6 rounded-full border-2 transition-transform`,a.preset===e?`border-foreground`:`border-transparent hover:scale-105`)},e)),(0,K.jsxs)(`label`,{"data-enso":`secretary-form-avatar-custom`,"data-selected":a.customSelected?`true`:`false`,title:n(`Custom color`),style:a.customSelected?{backgroundColor:e}:void 0,className:G(`relative grid size-6 cursor-pointer place-items-center overflow-hidden rounded-full border-2 text-[10px] pointer-coarse:overflow-visible`,a.customSelected?`border-foreground text-white`:`border-border text-muted-foreground`),children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:a.customSelected?`sr-only`:void 0,children:`+`}),(0,K.jsx)(`input`,{type:`color`,"aria-label":n(`Custom color`),value:oG(e)??`#7c5cff`,onChange:e=>o(e.target.value),className:`absolute inset-0 cursor-pointer opacity-0 pointer-coarse:-inset-[12px]`})]}),(0,K.jsx)(rG,{"data-enso":`secretary-form-avatar-hex`,value:r,spellCheck:!1,"aria-label":n(`Custom color`),onChange:e=>{let t=e.target.value;i(t),o(t)},className:`h-7 w-24 font-mono text-xs`})]})}var lG=[1,2,3,4,5];function uG({value:e,options:t,onChange:n,enso:r}){let{t:i}=q();return(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-enso":r,children:t.map(t=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":t.value===e,onClick:()=>n(t.value),className:G(`rounded-md border px-2.5 py-1 text-xs transition-colors`,t.value===e?`border-primary/60 bg-primary/10 text-foreground`:`border-border text-muted-foreground hover:bg-muted`),children:i(t.label)},t.value))})}function dG({label:e,hint:t,children:n}){let{t:r}=q();return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-sm`,children:r(e)}),n,t?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(t)}):null]})}function fG({label:e,hint:t,checked:n,onChange:r,enso:i}){let{t:a}=q();return(0,K.jsxs)(`label`,{className:`flex items-start justify-between gap-3`,"data-enso":i,children:[(0,K.jsxs)(`span`,{className:`space-y-1`,children:[(0,K.jsx)(`span`,{className:`block text-sm`,children:a(e)}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:a(t)})]}),(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:()=>r(!n),className:G(`relative mt-0.5 h-5 w-9 shrink-0 rounded-full border transition-colors`,n?`border-primary bg-primary`:`border-border bg-muted`),children:(0,K.jsx)(`span`,{className:G(`absolute top-0.5 size-3.5 rounded-full bg-background transition-all`,n?`left-[18px]`:`left-0.5`)})})]})}function pG({selected:e,onChange:t,enso:n}){let r=E(e=>e.projects).filter(e=>e.kind!==`scratch`&&e.kind!==`secretary`);return r.length===0?null:(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,"data-enso":n,children:r.map(n=>{let r=e.includes(n.id);return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(r?e.filter(e=>e!==n.id):[...e,n.id]),className:G(`rounded-md border px-2.5 py-1 text-xs transition-colors`,r?`border-primary/60 bg-primary/10 text-foreground`:`border-border text-muted-foreground hover:bg-muted`),children:JW(n)},n.id)})})}function mG({initialDraft:e,submitLabel:t,onSubmit:n,busy:r=!1,error:i=null,allowDefaults:a=!1,onCancel:o,hideMaxRunning:s=!1}){let{t:c}=q(),[l,u]=U.useReducer(eG,e),d=e=>u({type:`patch`,patch:e});return(0,K.jsxs)(`div`,{className:`space-y-4`,"data-enso":`secretary-profile-form`,children:[(0,K.jsx)(dG,{label:`Name`,children:(0,K.jsx)(rG,{"data-enso":`secretary-form-name`,value:l.name??``,onChange:e=>d({name:e.target.value}),className:`max-w-xs`})}),(0,K.jsx)(dG,{label:`Avatar color`,children:(0,K.jsx)(cG,{color:l.avatar?.color??`#7c5cff`,onChange:e=>d({avatar:{color:e}})})}),(0,K.jsxs)(dG,{label:`Visible projects`,children:[(0,K.jsx)(uG,{enso:`secretary-form-visible-mode`,value:l.visibleProjectIds===`all`?`all`:`selected`,options:[{value:`all`,label:`All projects`},{value:`selected`,label:`Selected projects`}],onChange:e=>d({visibleProjectIds:e===`all`?`all`:l.visibleProjectIds===`all`?[]:l.visibleProjectIds})}),l.visibleProjectIds===`all`?null:(0,K.jsx)(pG,{enso:`secretary-form-visible-projects`,selected:l.visibleProjectIds??[],onChange:e=>d({visibleProjectIds:e})})]}),!s&&(0,K.jsx)(dG,{label:`Running dispatches at most`,children:(0,K.jsx)(uG,{enso:`secretary-form-max-running`,value:String(l.maxRunningDispatches??3),options:lG.map(e=>({value:String(e),label:String(e)})),onChange:e=>d({maxRunningDispatches:Number(e)})})}),(0,K.jsx)(fG,{enso:`secretary-form-patrol`,label:`Watch running sessions automatically`,hint:`While anything is running the secretary checks it and only reports an anomaly: a goal session idle for 3 minutes with an unfinished goal and no live background task, idle for 20 minutes with a background task that never woke it, or running for 30 minutes without any event. Every hour it also reports background tasks left running in finished sessions; nothing is killed. Nothing is sent when all is well.`,checked:l.patrolEnabled??!0,onChange:e=>d({patrolEnabled:e})}),(0,K.jsx)(fG,{enso:`secretary-form-cleanup-skip-confirm`,label:`Clean up without asking`,hint:`Off by default. When on, this secretary's cleanup deletes immediately, with no confirmation card: merged local branches and their worktrees. Sessions are only archived, never deleted. Unmerged branches, branches in use, feat/secretary-agent, main, the current branch and worktrees with uncommitted changes are still refused or skipped.`,checked:l.cleanupSkipConfirm??!1,onChange:e=>d({cleanupSkipConfirm:e})}),i?(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:i}):null,(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(Oa,{size:`sm`,disabled:r,"data-enso":`secretary-form-submit`,onClick:()=>n(l),children:t}),o&&(0,K.jsx)(Oa,{variant:`ghost`,size:`sm`,disabled:r,onClick:o,children:c(`Cancel`)}),a&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-form-defaults`,disabled:r,onClick:()=>n($W(c(`Secretary`))),className:`text-xs text-muted-foreground transition-colors hover:text-foreground disabled:opacity-50`,children:c(`Use all defaults and start`)})]})]})}var hG=new Set([`session_create`,`todo_item_dispatch`,`secretary_profile_propose`,`skill_propose`,`tool_propose`,`session_takeover_propose`,`cleanup_apply`]);function gG(e){if(!hG.has(e.name)||e.state===`running`||e.state===`error`||!e.output)return null;let t;try{t=JSON.parse(e.output)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;return n.status===`awaiting_confirmation`&&typeof n.proposalId==`string`?n.proposalId:null}var _G={pending:`Waiting for your confirmation`,executing:`Creating the session…`,succeeded:`Session created`,failed:`Failed`,rejected:`Rejected`,expired:`Expired`},vG={..._G,executing:`Saving the profile…`,succeeded:`Profile saved`};function yG(e){return G(`mb-1 w-full rounded-lg border px-2.5 py-2`,e?`border-warning/40 bg-warning/5`:`border-border/60 bg-muted/20`)}function bG(e){return e.draft.title?.trim()||e.draft.prompt.split(`
223
+ `)[0]?.trim()||``}function xG({proposalId:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.secretary.proposals[e]),i=YR(t=>t.resolving[e]===!0),a=YR(e=>e.resolveProposal),o=E(e=>e.projects),s=E(e=>e.providers)??[],c=E(e=>e.virtualModels);if(!r)return(0,K.jsx)(`div`,{"data-enso":`secretary-proposal`,className:G(yG(t),`text-[11px] text-muted-foreground`),children:n(`Waiting for your confirmation`)});if(r.kind===`profile`)return(0,K.jsx)(SG,{proposal:r,prominent:t});if(r.kind===`skill`)return(0,K.jsx)(OG,{proposal:r,prominent:t});if(r.kind===`tool`)return(0,K.jsx)(DG,{proposal:r,prominent:t});if(r.kind===`takeover`)return(0,K.jsx)(EG,{proposal:r,prominent:t});if(r.kind===`cleanup`)return(0,K.jsx)(PG,{proposal:r,prominent:t});let l=o.find(e=>e.id===r.draft.projectId),u=r.status===`failed`,d=YW(s,r.draft.model,c);return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Dispatch`)}),l&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:JW(l)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:bG(r)}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:r.draft.worktree?n(`Isolated worktree`):n(`Project checkout`)})]}),(r.draft.branch||r.draft.baseRef||d||(r.draft.after?.length??0)>0)&&(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal-base`,className:`mt-1 flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[r.draft.branch&&(0,K.jsx)(`span`,{children:r.draft.branch}),r.draft.baseRef&&(0,K.jsx)(`span`,{children:n(`from {{ref}}`,{ref:r.draft.baseRef})}),d&&(0,K.jsx)(`span`,{"data-enso":`secretary-proposal-model`,children:n(`Model: {{model}}`,{model:d})}),r.draft.after&&r.draft.after.length>0&&(0,K.jsx)(`span`,{children:n(`After {{ids}}`,{ids:r.draft.after.join(`, `)})})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,u?`text-destructive`:`text-muted-foreground`),children:[n(_G[r.status]),u&&r.error?` · ${r.error}`:``]}),r.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>void a(r.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm dispatch`)}),(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>void a(r.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function SG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),[a,o]=U.useState(!1),s=e.draft,c=e.status===`failed`,l=U.useMemo(()=>({...QW(null,n(`Secretary`)),...s}),[s,n]);return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`profile`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Profile`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s.name??n(`Secretary`)})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:n(`Up to {{n}} at a time`,{n:s.maxRunningDispatches??3})}),(0,K.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,K.jsx)(`span`,{children:n(s.patrolEnabled===!1?`Patrol off`:`Patrol on`)}),(0,K.jsx)(`span`,{children:n(s.cleanupSkipConfirm?`Cleanup without confirmation`:`Cleanup asks first`)})]}),a?(0,K.jsx)(`div`,{className:`mt-2 border-t border-border/60 pt-2`,children:(0,K.jsx)(mG,{initialDraft:l,submitLabel:n(`Confirm`),busy:r,onSubmit:t=>{o(!1),i(e.id,`confirm`,void 0,t)},onCancel:()=>o(!1)})}):(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,c?`text-destructive`:`text-muted-foreground`),children:[n(vG[e.status]),c&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-proposal-edit`,disabled:r,onClick:()=>o(!0),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Edit here`)})]})]})]})}var CG={..._G,executing:`Saving the skill…`,succeeded:`Skill saved`},wG={..._G,executing:`Saving the tool…`,succeeded:`Tool saved`},TG={..._G,executing:`Handing it over…`,succeeded:`Handed over to the secretary`};function EG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=E(e=>e.projects).find(t=>t.id===e.draft.projectId),o=e.status===`failed`;return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`takeover`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Take over`)}),a&&(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:JW(a)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.draft.title??n(`Unnamed`)})]}),(0,K.jsxs)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:[n(`The secretary asks to manage this session: it may message and stop it like its own.`),e.draft.reason?` ${e.draft.reason}`:``]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,o?`text-destructive`:`text-muted-foreground`),children:[n(TG[e.status]),o&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Allow takeover`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function DG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=e.draft,o=e.status===`failed`;return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`tool`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Tool`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:a.name}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.runtime===`python`?`Python`:`Node`}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:a.readOnly?n(`Read-only`):n(`Asks every call`)}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:e.previous?n(`Update`):n(`New`)})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:a.description}),(0,K.jsxs)(`details`,{className:`mt-1.5 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the arguments`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap text-[11px]`,children:JSON.stringify(a.parameters,null,2)})]}),(0,K.jsxs)(`details`,{className:`mt-1 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the code`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre font-mono text-[11px]`,children:a.code})]}),e.previous?(0,K.jsxs)(`details`,{className:`mt-1 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the current version`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre font-mono text-[11px]`,children:e.previous.code})]}):null,(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,o?`text-destructive`:`text-muted-foreground`),children:[n(wG[e.status]),o&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function OG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=e.draft,o=e.status===`failed`;return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`skill`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Skill`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:a.name}),(0,K.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:e.previous?n(`Update`):n(`New`)})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-muted-foreground`,children:a.description}),(0,K.jsxs)(`details`,{className:`mt-1.5 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the content`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap text-[11px]`,children:a.body})]}),e.previous?(0,K.jsxs)(`details`,{className:`mt-1 rounded border border-border/60 bg-background/40 px-2 py-1`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[11px] text-muted-foreground`,children:n(`Show the current version`)}),(0,K.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap text-[11px]`,children:e.previous.body})]}):null,(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,o?`text-destructive`:`text-muted-foreground`),children:[n(CG[e.status]),o&&e.error?` · ${e.error}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}var kG={..._G,executing:`Cleaning up…`,succeeded:`Cleanup done`},AG={branch:`Branch`,worktree:`Worktree`,session:`Session`},jG={"not-merged":`Not merged yet`,"current-branch":`Currently checked out`,"used-by-worktree":`Used by a worktree`,"detached-head":`Detached HEAD`,"uncommitted-changes":`Has uncommitted changes`};function MG(e){return e===void 0?null:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var NG=5;function PG({proposal:e,prominent:t}){let{t:n}=q(),r=YR(t=>t.resolving[e.id]===!0),i=YR(e=>e.resolveProposal),a=e.draft.items,o=a.slice(0,NG),s=a.length-o.length,c=e.status===`failed`,l=a.reduce((e,t)=>(e[t.kind]=(e[t.kind]??0)+1,e),{});return(0,K.jsxs)(`div`,{"data-enso":`secretary-proposal`,"data-kind":`cleanup`,className:yG(t),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:n(`Clean up`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`{{count}} items`,{count:a.length})}),[`branch`,`worktree`,`session`].map(e=>l[e]?(0,K.jsxs)(`span`,{className:`shrink-0 rounded bg-muted px-1.5 text-[10px] text-muted-foreground`,children:[l[e],` `,n(AG[e])]},e):null)]}),(0,K.jsxs)(`ul`,{"data-enso":`secretary-cleanup-items`,className:`mt-1.5 space-y-0.5`,children:[o.map(e=>{let t=MG(e.sizeBytes),r=[e.mergedInto?.length?n(`merged into {{refs}}`,{refs:e.mergedInto.join(`, `)}):null,t,e.blocked?n(jG[e.blocked]??e.blocked):null].filter(Boolean);return(0,K.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 text-[11px]`,children:[(0,K.jsx)(`span`,{"data-enso":`secretary-cleanup-kind`,className:`shrink-0 rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:n(AG[e.kind])}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:e.name}),r.length>0&&(0,K.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:r.join(` · `)})]},e.id)}),s>0&&(0,K.jsx)(`li`,{"data-enso":`secretary-cleanup-rest`,className:`text-[11px] text-muted-foreground`,children:n(`and {{count}} more`,{count:s})})]}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:G(`text-[11px]`,c?`text-destructive`:`text-muted-foreground`),children:[n(kG[e.status]),c&&e.error?` · ${e.error}`:``,e.report?` · ${e.report}`:``]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-cleanup-confirm`,disabled:r,onClick:()=>void i(e.id,`confirm`),className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,children:n(`Confirm cleanup`)}),(0,K.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>void i(e.id,`reject`),className:`rounded-md px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50`,children:n(`Reject`)})]})]})]})}function FG(e){let[t,n]=U.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=U.useRef(null),i=U.useRef(null),a=U.useRef(null),o=U.useRef(null),s=U.useRef(!0),c=U.useRef(null),l=Xy(),u=U.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:l}),[t,l]);return(0,K.jsx)(Pj.Provider,{value:u,children:(0,K.jsx)(Mj.Provider,{value:void 0,children:(0,K.jsx)(yM,{...e})})})}var IG=500,LG=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:l,positionerRef:u,allowMouseUpTriggerRef:d,initialCursorPointRef:f,rootId:p}=Fj(!1),{store:m}=Nj(!1),h=m.useState(`open`),g=m.useState(`disabled`),_=U.useRef(null),v=U.useRef(null),y=nb(),b=nb(),x=U.useRef(!1),S=U.useRef(null);function C(e,t,n){let r=n.type.startsWith(`touch`);f.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),x.current=!1,s.current?.setOpen(!0,Ky(Ly,n)),b.start(IG,()=>{x.current=!0})}function w(e){if(g)return;d.current=!0,db(e),C(e.clientX,e.clientY,e.nativeEvent);let t=My(_.current);S.current?.abort();let n=new AbortController;S.current=n,t.addEventListener(`mouseup`,e=>{if(d.current=!1,!x.current)return;b.clear(),x.current=!1;let t=bb(e);yb(u.current,t)||p&&t&&EM(t)===p||s.current?.setOpen(!1,Ky(Uy,e))},{once:!0,signal:n.signal})}function T(){y.clear(),v.current=null}function E(e){if(g){T();return}if(d.current=!1,e.touches.length!==1){T();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};v.current=n,y.start(IG,()=>{C(n.x,n.y,e.nativeEvent)})}function D(e){if(e.touches.length!==1){T();return}if(y.isStarted()&&v.current){let t=e.touches[0],n=Math.abs(t.clientX-v.current.x),r=Math.abs(t.clientY-v.current.y);(n>10||r>10)&&T()}}return U.useEffect(()=>()=>{S.current?.abort()},[]),U.useEffect(()=>{function e(e){if(g)return;let t=bb(e);(yb(_.current,t)||yb(c.current,t)||yb(l.current,t))&&e.preventDefault()}return Pb(My(_.current),`contextmenu`,e)},[l,g,c]),Vr(`div`,e,{state:{open:h},ref:[_,t],props:[{onContextMenu:w,onTouchStart:E,onTouchMove:D,onTouchEnd:T,onTouchCancel:T,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:$v})}),RG=FG;function zG(e){return(0,K.jsx)(LG,{"data-slot":`context-menu-trigger`,...e})}function BG({children:e,className:t,zIndex:n,...r}){return(0,K.jsxs)(eM,{children:[(0,K.jsx)(Ij,{className:`fixed inset-0 z-40`,"data-enso-float":``,style:n===void 0?void 0:{zIndex:n-1}}),(0,K.jsx)(uM,{className:`z-50`,"data-slot":`context-menu-positioner`,style:n===void 0?void 0:{zIndex:n},children:(0,K.jsx)(Zj,{className:G(XM,t),"data-slot":`context-menu-popup`,...r,children:(0,K.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1.5`,children:e})})})]})}function VG({className:e,variant:t=`default`,...n}){return(0,K.jsx)(Jj,{className:G($M,e),"data-slot":`context-menu-item`,"data-variant":t,...n})}async function HG(e){let t=/^data:([^;,]+);base64,(.*)$/s.exec(e);if(!t)return(await fetch(e)).blob();let n=atob(t[2]),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new Blob([r],{type:t[1]})}async function UG(e){let t=await HG(e),n=t;if(t.type!==`image/png`){let e=await createImageBitmap(t),r=new OffscreenCanvas(e.width,e.height);r.getContext(`2d`)?.drawImage(e,0,0),e.close(),n=await r.convertToBlob({type:`image/png`})}await navigator.clipboard.write([new ClipboardItem({"image/png":n})])}function WG({src:e,className:t,frameClassName:n,onError:r,alt:i=``,lazy:a=!1,children:o,title:s}){let{t:c}=q(),[l,u]=(0,U.useState)(!1);EE(l),(0,U.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]);let d=()=>{UG(e).then(()=>hD({type:`success`,title:c(`Image copied`)}),e=>hD({type:`error`,title:c(`Could not copy image`),description:e instanceof Error?e.message:String(e)}))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(RG,{children:[(0,K.jsx)(zG,{render:(0,K.jsx)(`button`,{type:`button`,onClick:()=>u(!0),title:s,className:G(`cursor-zoom-in`,n),children:o??(0,K.jsx)(`img`,{src:e,alt:i,className:t,onError:r,...a?{loading:`lazy`,decoding:`async`}:{}})}),onContextMenu:e=>e.stopPropagation()}),(0,K.jsx)(BG,{className:`min-w-36`,children:(0,K.jsx)(VG,{closeOnClick:!0,onClick:d,children:c(`Copy image`)})})]}),l&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:G(`fixed inset-0 flex cursor-zoom-out items-center justify-center bg-black/75`),style:{zIndex:LE.NESTED_MODAL_BACKDROP},"data-enso-float":``,children:(0,K.jsx)(`img`,{src:e,alt:``,className:`max-h-[92vh] max-w-[92vw] rounded-lg object-contain`})})]})}var GG={"too-large":`over 10 MB, not saved`,"not-image":`not a png / jpeg / webp / gif image, not saved`,unavailable:`could not be saved`};function KG(e){return e.split(/[\\/]/u).pop()??e}function qG({entries:e,thumbnails:t=0,align:n=`end`}){let{t:r}=q(),i=e.filter(e=>`path`in e&&e.index>t),a=e.filter(e=>`rejected`in e);return i.length===0&&a.length===0?null:(0,K.jsxs)(`div`,{"data-enso":`inbound-images`,className:G(`flex flex-col gap-1`,n===`end`?`items-end`:`items-start`),children:[i.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(e=>(0,K.jsxs)(WG,{src:f(e.path),title:KG(e.path),frameClassName:`inline-flex h-6 items-center gap-1 rounded-md bg-muted px-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(en,{className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{children:r(`Image {{n}}`,{n:e.index})})]},e.index))}),a.map(e=>(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`Image {{n}} not accepted: {{reason}}`,{n:e.index,reason:r(GG[e.rejected])})},e.index))]})}var JG={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,ico:`image/x-icon`,avif:`image/avif`,svg:`image/svg+xml`};function YG(e){let t=e.split(/[?#]/)[0]??``,n=t.lastIndexOf(`.`);return n<0?null:JG[t.slice(n+1).toLowerCase()]??null}var XG=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZG=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,QG={};function $G(e,t){return((t||QG).jsx?ZG:XG).test(e)}var eK=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
224
224
  `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),tK=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(eK());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),nK=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),rK=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(tK()),r=nK();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),iK=oK(`end`),aK=oK(`start`);function oK(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function sK(e){let t=aK(e),n=iK(e);if(t&&n)return{start:t,end:n}}function cK(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?uK(e.position):`start`in e||`end`in e?uK(e):`line`in e||`column`in e?lK(e):``}function lK(e){return dK(e&&e.line)+`:`+dK(e&&e.column)}function uK(e){return lK(e&&e.start)+`-`+lK(e&&e.end)}function dK(e){return e&&typeof e==`number`?e:1}var fK=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=cK(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};fK.prototype.file=``,fK.prototype.name=``,fK.prototype.reason=``,fK.prototype.message=``,fK.prototype.stack=``,fK.prototype.column=void 0,fK.prototype.line=void 0,fK.prototype.ancestors=void 0,fK.prototype.cause=void 0,fK.prototype.fatal=void 0,fK.prototype.place=void 0,fK.prototype.ruleId=void 0,fK.prototype.source=void 0;var pK=e(rK(),1),mK={}.hasOwnProperty,hK=new Map,gK=/[A-Z]/g,_K=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),vK=new Set([`td`,`th`]),yK=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function bK(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=jK(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=AK(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Nd:Md,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=xK(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function xK(e,t,n){if(t.type===`element`)return SK(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return CK(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return TK(e,t,n);if(t.type===`mdxjsEsm`)return wK(e,t);if(t.type===`root`)return EK(e,t,n);if(t.type===`text`)return DK(e,t)}function SK(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Nd,e.schema=i),e.ancestors.push(t);let a=LK(e,t.tagName,!1),o=MK(e,t),s=PK(e,t);return _K.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!mf(e)})),OK(e,o,a,t),kK(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function CK(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}RK(e,t.position)}function wK(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);RK(e,t.position)}function TK(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Nd,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:LK(e,t.name,!0),o=NK(e,t),s=PK(e,t);return OK(e,o,a,t),kK(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function EK(e,t,n){let r={};return kK(r,PK(e,t)),e.create(t,e.Fragment,r,n)}function DK(e,t){return t.value}function OK(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function kK(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function AK(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function jK(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=aK(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function MK(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&mK.call(t.properties,i)){let a=FK(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&vK.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function NK(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else RK(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else RK(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function PK(e,t){let n=[],r=-1,i=e.passKeys?new Map:hK;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=xK(e,a,o);s!==void 0&&n.push(s)}return n}function FK(e,t,n){let r=kd(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?df(n):ff(n)),r.property===`style`){let t=typeof n==`object`?n:IK(e,String(n));return e.stylePropertyNameCase===`css`&&(t=zK(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Td[r.property]||r.property:r.attribute,n]}}function IK(e,t){try{return(0,pK.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new fK("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=yK+`#cannot-parse-style-attribute`,r}}function LK(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=$G(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=$G(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return mK.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);RK(e)}function RK(e,t){let n=new fK("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=yK+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function zK(e){let t={},n;for(n in e)mK.call(e,n)&&(t[BK(n)]=e[n]);return t}function BK(e){let t=e.replace(gK,VK);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function VK(e){return`-`+e.toLowerCase()}var HK={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},UK={};function WK(e,t){let n=t||UK;return GK(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function GK(e,t,n){if(qK(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return KK(e.children,t,n)}return Array.isArray(e)?KK(e,t,n):``}function KK(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=GK(e[i],t,n);return r.join(``)}function qK(e){return!!(e&&typeof e==`object`)}var JK=document.createElement(`i`);function YK(e){let t=`&`+e+`;`;JK.innerHTML=t;let n=JK.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function XK(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function ZK(e,t){return e.length>0?(XK(e,e.length,0,t),e):t}var QK={}.hasOwnProperty;function $K(e){let t={},n=-1;for(;++n<e.length;)eq(t,e[n]);return t}function eq(e,t){let n;for(n in t){let r=(QK.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){QK.call(r,a)||(r[a]=[]);let e=i[a];tq(r[a],Array.isArray(e)?e:e?[e]:[])}}}function tq(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);XK(e,0,0,r)}function nq(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function rq(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var iq=gq(/[A-Za-z]/),aq=gq(/[\dA-Za-z]/),oq=gq(/[#-'*+\--9=?A-Z^-~]/);function sq(e){return e!==null&&(e<32||e===127)}var cq=gq(/\d/),lq=gq(/[\dA-Fa-f]/),uq=gq(/[!-/:-@[-`{-~]/);function dq(e){return e!==null&&e<-2}function fq(e){return e!==null&&(e<0||e===32)}function pq(e){return e===-2||e===-1||e===32}var mq=gq(/\p{P}|\p{S}/u),hq=gq(/\s/);function gq(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function _q(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&aq(e.charCodeAt(n+1))&&aq(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function vq(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return pq(r)?(e.enter(n),s(r)):t(r)}function s(r){return pq(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var yq={tokenize:bq};function bq(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),vq(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return dq(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var xq={tokenize:Cq},Sq={tokenize:wq};function Cq(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return XK(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Sq,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Sq,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return dq(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;XK(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function wq(e,t,n){return vq(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Tq(e){if(e===null||fq(e)||hq(e))return 1;if(mq(e))return 2}function Eq(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Dq={name:`attention`,resolveAll:Oq,tokenize:kq};function Oq(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Aq(d,-c),Aq(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=ZK(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=ZK(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=ZK(l,Eq(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=ZK(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=ZK(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,XK(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function kq(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Tq(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Tq(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Aq(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var jq={name:`autolink`,tokenize:Mq};function Mq(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return iq(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||aq(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||aq(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||sq(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):oq(t)?(e.consume(t),l):n(t)}function u(e){return aq(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||aq(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Nq={partial:!0,tokenize:Pq};function Pq(e,t,n){return r;function r(t){return pq(t)?vq(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||dq(e)?t(e):n(e)}}var Fq={continuation:{tokenize:Lq},exit:Rq,name:`blockQuote`,tokenize:Iq};function Iq(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return pq(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Lq(e,t,n){let r=this;return i;function i(t){return pq(t)?vq(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Fq,t,n)(r)}}function Rq(e){e.exit(`blockQuote`)}var zq={name:`characterEscape`,tokenize:Bq};function Bq(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return uq(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var Vq={name:`characterReference`,tokenize:Hq};function Hq(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=aq,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=lq,u):(e.enter(`characterReferenceValue`),a=7,o=cq,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===aq&&!YK(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Uq={partial:!0,tokenize:Kq},Wq={concrete:!0,name:`codeFenced`,tokenize:Gq};function Gq(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),pq(t)?vq(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||dq(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Uq,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||dq(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):pq(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),vq(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||dq(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||dq(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&pq(t)?vq(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||dq(t)?e.check(Uq,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||dq(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),pq(t)?vq(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),pq(t)?vq(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||dq(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Kq(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var qq={name:`codeIndented`,tokenize:Yq},Jq={partial:!0,tokenize:Xq};function Yq(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),vq(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):dq(t)?e.attempt(Jq,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||dq(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Xq(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):dq(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):vq(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):dq(e)?i(e):n(e)}}var Zq={name:`codeText`,previous:$q,resolve:Qq,tokenize:eJ};function Qq(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function $q(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function eJ(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):dq(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||dq(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var tJ=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&nJ(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),nJ(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),nJ(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);nJ(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);nJ(this.left,t.reverse())}}}};function nJ(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function rJ(e){let t={},n=-1,r,i,a,o,s,c,l,u=new tJ(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,iJ(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return XK(e,0,1/0,u.slice(0)),!l}function iJ(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var aJ={resolve:sJ,tokenize:cJ},oJ={partial:!0,tokenize:lJ};function sJ(e){return rJ(e),e}function cJ(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):dq(t)?e.check(oJ,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function lJ(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),vq(e,a,`linePrefix`)}function a(i){if(i===null||dq(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function uJ(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||sq(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||dq(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||fq(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||sq(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function dJ(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):dq(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||dq(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!pq(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function fJ(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):dq(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),vq(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||dq(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function pJ(e,t){let n;return r;function r(i){return dq(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):pq(i)?vq(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var mJ={name:`definition`,tokenize:gJ},hJ={partial:!0,tokenize:_J};function gJ(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return dJ.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=rq(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return fq(t)?pJ(e,l)(t):l(t)}function l(t){return uJ(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(hJ,d,d)(t)}function d(t){return pq(t)?vq(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||dq(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function _J(e,t,n){return r;function r(t){return fq(t)?pJ(e,i)(t):n(t)}function i(t){return fJ(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return pq(t)?vq(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||dq(e)?t(e):n(e)}}var vJ={name:`hardBreakEscape`,tokenize:yJ};function yJ(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return dq(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var bJ={name:`headingAtx`,resolve:xJ,tokenize:SJ};function xJ(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},XK(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function SJ(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||fq(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||dq(n)?(e.exit(`atxHeading`),t(n)):pq(n)?vq(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||fq(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var CJ=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),wJ=[`pre`,`script`,`style`,`textarea`],TJ={concrete:!0,name:`htmlFlow`,resolveTo:OJ,tokenize:kJ},EJ={partial:!0,tokenize:jJ},DJ={partial:!0,tokenize:AJ};function OJ(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function kJ(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):iq(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):iq(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return iq(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||fq(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&wJ.includes(l)?(i=1,r.interrupt?t(s):O(s)):CJ.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||aq(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return pq(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||iq(t)?(e.consume(t),b):pq(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||aq(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):pq(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):pq(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||dq(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||fq(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||pq(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||dq(t)?O(t):pq(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):dq(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(EJ,R,k)(t)):t===null||dq(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(DJ,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||dq(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return wJ.includes(n)?(e.consume(t),L):O(t)}return iq(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||dq(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function AJ(e,t,n){let r=this;return i;function i(t){return dq(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function jJ(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Nq,t,n)}}var MJ={name:`htmlText`,tokenize:NJ};function NJ(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):iq(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):iq(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):dq(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):dq(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):dq(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):dq(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return iq(t)?(e.consume(t),S):n(t)}function S(t){return t===45||aq(t)?(e.consume(t),S):C(t)}function C(t){return dq(t)?(o=C,N(t)):pq(t)?(e.consume(t),C):M(t)}function w(t){return t===45||aq(t)?(e.consume(t),w):t===47||t===62||fq(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||iq(t)?(e.consume(t),E):dq(t)?(o=T,N(t)):pq(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||aq(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):dq(t)?(o=D,N(t)):pq(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):dq(t)?(o=O,N(t)):pq(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):dq(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||fq(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||fq(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return pq(t)?vq(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var PJ={name:`labelEnd`,resolveAll:RJ,resolveTo:zJ,tokenize:BJ},FJ={tokenize:VJ},IJ={tokenize:HJ},LJ={tokenize:UJ};function RJ(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&XK(e,0,e.length,n),e}function zJ(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=ZK(s,e.slice(a+1,a+r+3)),s=ZK(s,[[`enter`,u,t]]),s=ZK(s,Eq(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=ZK(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=ZK(s,e.slice(o+1)),s=ZK(s,[[`exit`,c,t]]),XK(e,a,e.length,s),e}function BJ(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(rq(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(FJ,u,o?u:d)(t):t===91?e.attempt(IJ,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(LJ,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function VJ(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return fq(t)?pJ(e,a)(t):a(t)}function a(t){return t===41?u(t):uJ(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return fq(t)?pJ(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?fJ(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return fq(t)?pJ(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function HJ(e,t,n){let r=this;return i;function i(t){return dJ.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(rq(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function UJ(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var WJ={name:`labelStartImage`,resolveAll:PJ.resolveAll,tokenize:GJ};function GJ(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var KJ={name:`labelStartLink`,resolveAll:PJ.resolveAll,tokenize:qJ};function qJ(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var JJ={name:`lineEnding`,tokenize:YJ};function YJ(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),vq(e,t,`linePrefix`)}}var XJ={name:`thematicBreak`,tokenize:ZJ};function ZJ(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||dq(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),pq(t)?vq(e,s,`whitespace`)(t):s(t))}}var QJ={continuation:{tokenize:nY},exit:iY,name:`list`,tokenize:tY},$J={partial:!0,tokenize:aY},eY={partial:!0,tokenize:rY};function tY(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:cq(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(XJ,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return cq(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Nq,r.interrupt?n:u,e.attempt($J,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return pq(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function nY(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Nq,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,vq(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!pq(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(eY,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,vq(e,e.attempt(QJ,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function rY(e,t,n){let r=this;return vq(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function iY(e){e.exit(this.containerState.type)}function aY(e,t,n){let r=this;return vq(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!pq(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var oY={name:`setextUnderline`,resolveTo:sY,tokenize:cY};function sY(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function cY(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),pq(t)?vq(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||dq(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var lY={tokenize:uY};function uY(e){let t=this,n=e.attempt(Nq,r,e.attempt(this.parser.constructs.flowInitial,i,vq(e,e.attempt(this.parser.constructs.flow,i,e.attempt(aJ,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var dY={resolveAll:hY()},fY=mY(`string`),pY=mY(`text`);function mY(e){return{resolveAll:hY(e===`text`?gY:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function hY(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function gY(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var _Y=t({attentionMarkers:()=>TY,contentInitial:()=>yY,disable:()=>EY,document:()=>vY,flow:()=>xY,flowInitial:()=>bY,insideSpan:()=>wY,string:()=>SY,text:()=>CY}),vY={42:QJ,43:QJ,45:QJ,48:QJ,49:QJ,50:QJ,51:QJ,52:QJ,53:QJ,54:QJ,55:QJ,56:QJ,57:QJ,62:Fq},yY={91:mJ},bY={[-2]:qq,[-1]:qq,32:qq},xY={35:bJ,42:XJ,45:[oY,XJ],60:TJ,61:oY,95:XJ,96:Wq,126:Wq},SY={38:Vq,92:zq},CY={[-5]:JJ,[-4]:JJ,[-3]:JJ,33:WJ,38:Vq,42:Dq,60:[jq,MJ],91:KJ,92:[vJ,zq],93:PJ,95:Dq,96:Zq},wY={null:[Dq,dY]},TY={null:[42,95]},EY={null:[]};function DY(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=ZK(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=Eq(a,l.events,l),l.events):[]}function f(e,t){return kY(p(e),t)}function p(e){return OY(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){dq(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&XK(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function OY(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function kY(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
225
225
  `;break;case-3:o=`\r
226
226
  `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function AY(e){let t={constructs:$K([_Y,...(e||{}).extensions||[]]),content:n(yq),defined:[],document:n(xq),flow:n(lY),lazy:{},string:n(fY),text:n(pY)};return t;function n(e){return n;function n(n){return DY(t,e,n)}}}function jY(e){for(;!rJ(e););return e}var MY=/[\0\t\n\r]/g;function NY(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(MY.lastIndex=u,c=MY.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var PY=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FY(e){return e.replace(PY,IY)}function IY(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return nq(n.slice(t?2:1),t?16:10)}return YK(n)||e}var LY={}.hasOwnProperty;function RY(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),zY(n)(jY(AY(n).document().write(NY()(e,t,!0))))}function zY(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(fe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ce),blockQuote:a(re),characterEscape:T,characterReference:T,codeFenced:a(ie),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ie,o),codeText:a(ae,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(oe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(se),hardBreakEscape:a(le),hardBreakTrailing:a(le),htmlFlow:a(ue,o),htmlFlowData:T,htmlText:a(ue,o),htmlTextData:T,image:a(de),label:o,link:a(fe),listItem:a(me),listItemValue:f,listOrdered:a(pe,d),listUnordered:a(pe),paragraph:a(he),reference:ee,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ce),strong:a(ge),thematicBreak:a(ve)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ne,autolinkProtocol:H,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:V,characterReference:te,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:z,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};VY(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];LY.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||UY).call(a,void 0,e[0])}for(r.position={start:BY(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:BY(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:BY(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||UY).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+cK({start:e.start,end:e.end})+`): it’s not open`);n.position.end=BY(e.end)}function u(){return WK(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rq(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=_e(),n.position={start:BY(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=BY(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=BY(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=FY(t),n.identifier=rq(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function z(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rq(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function B(e){this.data.characterReferenceType=e.type}function V(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=nq(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=YK(t);let i=this.stack[this.stack.length-1];i.value+=r}function te(e){let t=this.stack.pop();t.position.end=BY(e.end)}function H(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ne(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function re(){return{type:`blockquote`,children:[]}}function ie(){return{type:`code`,lang:null,meta:null,value:``}}function ae(){return{type:`inlineCode`,value:``}}function oe(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function se(){return{type:`emphasis`,children:[]}}function ce(){return{type:`heading`,depth:0,children:[]}}function le(){return{type:`break`}}function ue(){return{type:`html`,value:``}}function de(){return{type:`image`,title:null,url:``,alt:null}}function fe(){return{type:`link`,title:null,url:``,children:[]}}function pe(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function me(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function he(){return{type:`paragraph`,children:[]}}function ge(){return{type:`strong`,children:[]}}function _e(){return{type:`text`,value:``}}function ve(){return{type:`thematicBreak`}}}function BY(e){return{line:e.line,column:e.column,offset:e.offset}}function VY(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?VY(e,r):HY(e,r)}}function HY(e,t){let n;for(n in t)if(LY.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function UY(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+cK({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cK({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+cK({start:t.start,end:t.end})+`) is still open`)}function WY(e){let t=this;t.parser=n;function n(n){return RY(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function GY(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function KY(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
@@ -248,30 +248,30 @@ Addition:
248
248
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
249
249
  `,...a.current()});return/^[\t ]/.test(l)&&(l=r$(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}l$.peek=u$;function l$(e){return e.value||``}function u$(){return`<`}d$.peek=f$;function d$(e,t,n,r){let i=e$(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function f$(){return`!`}p$.peek=m$;function p$(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function m$(){return`!`}h$.peek=g$;function h$(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function g$(){return"`"}function _$(e,t){let n=WK(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}v$.peek=y$;function v$(e,t,n,r){let i=e$(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(_$(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function y$(e,t,n){return _$(e,n)?`<`:`[`}b$.peek=x$;function b$(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function x$(){return`[`}function S$(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function C$(e){let t=S$(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function w$(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function T$(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function E$(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?w$(n):S$(n),s=e.ordered?o===`.`?`)`:`.`:C$(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),T$(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function D$(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function O$(e,t,n,r){let i=D$(n),a=n.bulletCurrent||S$(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function k$(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var A$=RX([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function j$(e,t,n,r){return(e.children.some(function(e){return A$(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function M$(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}N$.peek=P$;function N$(e,t,n,r){let i=M$(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=i$(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=r$(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=i$(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+r$(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function P$(e,t,n){return n.options.strong||`*`}function F$(e,t,n,r){return n.safe(e.value,r)}function I$(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function L$(e,t,n){let r=(T$(n)+(n.options.ruleSpaces?` `:``)).repeat(I$(n));return n.options.ruleSpaces?r.slice(0,-1):r}var R$={blockquote:WQ,break:JQ,code:QQ,definition:t$,emphasis:a$,hardBreak:JQ,heading:c$,html:l$,image:d$,imageReference:p$,inlineCode:h$,link:v$,linkReference:b$,list:E$,listItem:O$,paragraph:k$,root:j$,strong:N$,text:F$,thematicBreak:L$};function z$(){return{enter:{table:B$,tableData:W$,tableHeader:W$,tableRow:H$},exit:{codeText:G$,table:V$,tableData:U$,tableHeader:U$,tableRow:U$}}}function B$(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function V$(e){this.exit(e),this.data.inTable=void 0}function H$(e){this.enter({type:`tableRow`,children:[]},e)}function U$(e){this.exit(e)}function W$(e){this.enter({type:`tableCell`,children:[]},e)}function G$(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,K$));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function K$(e,t){return t===`|`?t:e}function q$(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
250
250
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
251
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return VQ(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=R$.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function J$(){return{exit:{taskListCheckValueChecked:X$,taskListCheckValueUnchecked:X$,paragraph:Z$}}}function Y$(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Q$}}}function X$(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Z$(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Q$(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=R$.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function $$(){return[aQ(),kQ(),PQ(),z$(),J$()]}function e1(e){return{extensions:[oQ(),AQ(e),FQ(),q$(e),Y$()]}}var t1={tokenize:h1,partial:!0},n1={tokenize:g1,partial:!0},r1={tokenize:_1,partial:!0},i1={tokenize:v1,partial:!0},a1={tokenize:y1,partial:!0},o1={name:`wwwAutolink`,tokenize:p1,previous:b1},s1={name:`protocolAutolink`,tokenize:m1,previous:x1},c1={name:`emailAutolink`,tokenize:f1,previous:S1},l1={};function u1(){return{text:l1}}for(var d1=48;d1<123;)l1[d1]=c1,d1++,d1===58?d1=65:d1===91&&(d1=97);l1[43]=c1,l1[45]=c1,l1[46]=c1,l1[95]=c1,l1[72]=[c1,s1],l1[104]=[c1,s1],l1[87]=[c1,o1],l1[119]=[c1,o1];function f1(e,t,n){let r=this,i,a;return o;function o(t){return!C1(t)||!S1.call(r,r.previous)||w1(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return C1(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(a1,u,l)(t):t===45||t===95||aq(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&iq(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function p1(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!b1.call(r,r.previous)||w1(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(t1,e.attempt(n1,e.attempt(r1,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function m1(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&x1.call(r,r.previous)&&!w1(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(iq(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||sq(t)||fq(t)||hq(t)||mq(t)?n(t):e.attempt(n1,e.attempt(r1,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function h1(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function g1(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(i1,c,s)(t):t===null||fq(t)||hq(t)||t!==45&&mq(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function _1(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(i1,t,a)(o):o===null||fq(o)||hq(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function v1(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||fq(o)||hq(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||fq(e)||hq(e)?t(e):r(e)}function a(e){return iq(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):iq(t)?(e.consume(t),o):n(t)}}function y1(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return aq(e)?n(e):t(e)}}function b1(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||fq(e)}function x1(e){return!iq(e)}function S1(e){return!(e===47||C1(e))}function C1(e){return e===43||e===45||e===46||e===95||aq(e)}function w1(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var T1={tokenize:N1,partial:!0};function E1(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:A1,continuation:{tokenize:j1},exit:M1}},text:{91:{name:`gfmFootnoteCall`,tokenize:k1},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:D1,resolveTo:O1}}}}function D1(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=rq(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function O1(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function k1(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||fq(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(rq(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return fq(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function A1(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||fq(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=rq(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return fq(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),vq(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function j1(e,t,n){return e.check(Nq,t,e.attempt(T1,t,n))}function M1(e){e.exit(`gfmFootnoteDefinition`)}function N1(e,t,n){let r=this;return vq(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function P1(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&XK(o,o.length,0,Eq(s,e.slice(r+1,n),t)),XK(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),XK(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Tq(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Tq(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var F1=class{constructor(){this.map=[]}add(e,t,n){I1(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function I1(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function L1(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function R1(){return{flow:{null:{name:`table`,tokenize:z1,resolveAll:B1}}}}function z1(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):dq(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):pq(t)?vq(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||fq(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,pq(t)?vq(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return pq(t)?vq(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||dq(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return pq(t)?vq(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||dq(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||dq(n)?(e.exit(`tableRow`),t(n)):pq(n)?vq(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||fq(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function B1(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new F1;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(H1(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=V1(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=V1(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=V1(f,t,o,i,n,d)):(o[0]=o[1],d=V1(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&H1(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=L1(t.events,n))}return e}function V1(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},U1(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=U1(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=U1(t.events,n[2]),a=U1(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},U1(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function H1(e,t,n,r,i){let a=[],o=U1(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function U1(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var W1={name:`tasklistCheck`,tokenize:K1};function G1(){return{text:{91:W1}}}function K1(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return fq(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return dq(r)?t(r):pq(r)?e.check({tokenize:q1},t,n)(r):n(r)}}function q1(e,t,n){return vq(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function J1(e){return $K([u1(),E1(),P1(e),R1(),G1()])}var Y1={};function X1(e){let t=this,n=e||Y1,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(J1(n)),a.push($$()),o.push(e1(n))}function Z1(){let e=navigator.userAgent;return e.includes(`Mac`)?`Reveal in Finder`:e.includes(`Linux`)?`Open Containing Folder`:`Reveal in File Explorer`}function Q1({image:e,onClose:t}){let{t:n}=q();return(0,K.jsx)(BE,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(GE,{className:`max-w-4xl`,children:[(0,K.jsxs)(KE,{children:[(0,K.jsx)(JE,{children:n(`Image preview`)}),(0,K.jsx)(YE,{className:`break-all`,children:e?.rel})]}),(0,K.jsx)(ZE,{className:`max-h-[70vh]`,children:e&&(0,K.jsx)(`img`,{src:e.dataUrl,alt:e.rel,className:`mx-auto max-h-[65vh] max-w-full object-contain`})}),(0,K.jsx)(qE,{children:(0,K.jsx)(Oa,{variant:`outline`,onClick:t,children:n(`Close`)})})]})})}function $1(e){try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length);let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function e0(e){let t=typeof navigator>`u`?void 0:navigator.clipboard;if(!t?.writeText||window.isSecureContext===!1)return Promise.resolve($1(e));try{return Promise.resolve(t.writeText(e)).then(()=>!0,()=>$1(e))}catch{return Promise.resolve($1(e))}}function t0(){return!!window.electronAPI?.remote}function n0(e){return new TextDecoder().decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))}function r0(e,t){return e[t]?.btwParentId||t}var i0=new Map,a0=new Map,o0=new Map,s0=new Set,c0=[];function l0(){let e=nP.getState(),t=e.activeId;if(!t)return null;let n=e.conversations[t],r=i0.get(t);return!n||!r?null:{api:r,conversationId:t,projectId:n.projectId}}function u0(e){let t=l0();if(!t||f0(t.projectId))return;UR.getState().ensureOpen();let n=t.api.getPanel(`changes`);if(n){n.focus();return}t.api.addPanel({id:`changes`,component:`changes`,title:e?.title??`Changes`,params:{conversationId:t.conversationId,projectId:t.projectId}})}function d0(e,t){return t?e.some(e=>e.id===t&&e.kind===`secretary`):!1}function f0(e){return d0(E.getState().projects,e)}function p0(e,t,n,r){let i=e.getPanel(`files`);if(i){i.focus();return}e.addPanel({id:`files`,component:`files`,title:r??`Files`,params:{conversationId:t,projectId:n}})}function m0(e,t,n,r){let i=nP.getState(),a=r0(i.conversations,e),o=i.conversations[a]?.projectId;if(!o||f0(o))return;UR.getState().ensureOpen(a);let s=r?[t,n,r]:n?[t,n]:[t],c=a0.get(a);c?c(...s):o0.set(a,s);let l=i0.get(a);l?p0(l,a,o):s0.add(a)}function h0(e){let t=nP.getState(),n=e?.conversationId??t.activeId;if(!n)return;let r=t.conversations[n];if(!r)return;let i=r0(t.conversations,n),a=i0.get(i);UR.getState().ensureOpen(i);let o=e?.tabId??`browser:${crypto.randomUUID()}`;if(!a){c0.push({conversationId:i,tabId:o,ownerId:n});return}let s=a.getPanel(o);if(s){s.focus();return}a.addPanel({id:o,component:`browser`,title:e?.title??`Browser`,params:{conversationId:n,projectId:r.projectId}})}function g0(e,t){if(!nP.getState().conversations[e])return null;let n=`browser:${crypto.randomUUID()}`;return h0({conversationId:e,tabId:n,title:new URL(t).host}),window.electronAPI.browser.navigate(n,e,t)}var _0=`my-2 overflow-x-auto rounded-lg border bg-[var(--sunken,var(--muted))] text-(length:--chat-code-block-size) [font-weight:var(--chat-code-block-weight)] leading-relaxed`;function v0(e){let t=e.trimStart();return/^<[a-zA-Z!/]/.test(t)?`html`:/^[{[]/.test(t)?`json`:/^[$#] /.test(t)?`shellscript`:`text`}function y0({code:e,language:t,streaming:n=!1}){let[r,i]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(n){i(null);return}let r=!0;return Yg(e,t??v0(e),!0).then(e=>{r&&i(e)}),()=>{r=!1}},[e,t,n]);let a=!n&&(0,K.jsx)(Fs,{text:e,className:`absolute top-1.5 right-1.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/code:opacity-100`});return r==null?(0,K.jsxs)(`div`,{"data-enso":`code-block`,"data-language":t,className:`group/code relative`,children:[(0,K.jsx)(`pre`,{className:`${_0} p-3 font-mono`,children:(0,K.jsx)(`code`,{children:e})}),a]}):(0,K.jsxs)(`div`,{"data-enso":`code-block`,"data-language":t,className:`group/code relative`,children:[(0,K.jsx)(`div`,{className:`${_0} [&_pre]:m-0 [&_pre]:overflow-x-auto [&_pre]:bg-transparent! [&_pre]:p-3 [&_pre]:font-mono [&_pre]:[--shiki-dark-bg:transparent]!`,dangerouslySetInnerHTML:{__html:r}}),a]})}var b0=50,x0=3e4,S0={status:`missing`},C0=new Map,w0=new Map,T0=new Set,E0=new Map,D0=null,O0=0,k0={batches:0,paths:0,ms:0},A0=e=>e.cwd??`conversation:${e.conversationId}`,j0=(e,t)=>`${A0(e)}\0${t}`;function M0(e){return e?e.state.status===`ok`?e.epoch===O0:Date.now()-e.at<x0:!1}function N0(e,t){let n=C0.get(e)?.state,r=n?.status===t.status&&(t.status===`missing`||n.status===`ok`&&n.rel===t.rel&&n.kind===t.kind);if(C0.set(e,{state:r&&n?n:t,epoch:O0,at:Date.now()}),!r)for(let t of w0.get(e)??[])t()}function P0(e){return e?{status:`ok`,rel:e.rel,kind:e.kind}:S0}async function F0(e,t){let n=performance.now();try{let n=await window.electronAPI.workspaceFiles.resolveLinks({conversationId:e.conversationId,projectId:e.projectId,rels:t});return t.map((e,t)=>P0(n.ok?n.items[t]:null))}catch{return t.map(()=>S0)}finally{k0.batches+=1,k0.paths+=t.length,k0.ms+=performance.now()-n}}function I0(){D0=null;let e=[...E0.values()];E0.clear();for(let{scope:t,rels:n}of e){let e=[...n];for(let n=0;n<e.length;n+=200){let r=e.slice(n,n+200);F0(t,r).then(e=>{r.forEach((n,r)=>{let i=j0(t,n);T0.delete(i),N0(i,e[r])})})}}}function L0(e,t){let n=j0(e,t);if(T0.has(n)||M0(C0.get(n)))return;T0.add(n);let r=`${e.conversationId}\0${e.projectId}`,i=E0.get(r)??{scope:e,rels:new Set};i.rels.add(t),E0.set(r,i),D0??=setTimeout(I0,b0)}async function R0(e,t){let[n]=await F0(e,[t]);return N0(j0(e,t),n),n}function z0(e,t,n){let r=e&&t?j0(e,t):null,i=(0,U.useCallback)(e=>{if(!r)return()=>{};let t=w0.get(r)??new Set;return w0.set(r,t),t.add(e),()=>{t.delete(e),t.size===0&&w0.delete(r)}},[r]),a=(0,U.useSyncExternalStore)(i,()=>r?C0.get(r)?.state:void 0);return(0,U.useEffect)(()=>{n&&e&&t&&L0(e,t)},[n,r]),a}var B0=2;function V0({value:e}){return typeof e==`string`?(0,K.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:JSON.stringify(e)}):typeof e==`number`?(0,K.jsx)(`span`,{className:`text-sky-700 dark:text-sky-400`,children:String(e)}):(0,K.jsx)(`span`,{className:`text-violet-700 dark:text-violet-400`,children:String(e)})}function H0({name:e,value:t,depth:n}){let[r,i]=(0,U.useState)(n<B0),a=e!==void 0&&(0,K.jsxs)(`span`,{className:`text-foreground/80`,children:[e,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`: `})]});if(typeof t!=`object`||!t)return(0,K.jsxs)(`div`,{className:`pl-4`,children:[a,(0,K.jsx)(V0,{value:t})]});let o=Array.isArray(t),s=o?t.map((e,t)=>[String(t),e]):Object.entries(t),[c,l]=o?[`[`,`]`]:[`{`,`}`];return(0,K.jsxs)(`div`,{className:n>0?`pl-4`:void 0,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:()=>i(!r),className:`-ml-4 inline-flex items-center text-left hover:text-foreground`,children:[(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,r&&`rotate-90`)}),(0,K.jsxs)(`span`,{className:`ml-1`,children:[a,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[c,!r&&` ${s.length} ${l}`]})]})]}),r&&(0,K.jsxs)(K.Fragment,{children:[s.map(([e,t])=>(0,K.jsx)(H0,{name:o?void 0:e,value:t,depth:n+1},e)),(0,K.jsx)(`div`,{className:`text-muted-foreground`,children:l})]})]})}function U0({source:e,value:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1),a=e=>G(`rounded px-1.5 py-0.5`,e?`bg-muted text-foreground`:`hover:text-foreground`);return(0,K.jsxs)(`div`,{"data-enso":`json-tree`,className:`group/code relative my-2 rounded-lg border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 border-b px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`mr-auto font-mono`,children:`JSON`}),(0,K.jsx)(`button`,{type:`button`,className:a(!r),onClick:()=>i(!1),children:n(`Tree view`)}),(0,K.jsx)(`button`,{type:`button`,className:a(r),onClick:()=>i(!0),children:n(`Raw text`)}),(0,K.jsx)(Fs,{text:e,className:`rounded p-1`})]}),r?(0,K.jsx)(`div`,{className:`px-2`,children:(0,K.jsx)(y0,{code:e,language:`json`})}):(0,K.jsx)(`div`,{className:`max-h-[480px] overflow-auto py-2 pr-3 pl-6 font-mono text-(length:--chat-code-block-size) leading-relaxed`,children:(0,K.jsx)(H0,{value:t,depth:0})})]})}function W0(e,{prefersDark:t,terminalIsDark:n}){switch(e){case`light`:return`light`;case`dark`:return`dark`;case`system`:return t?`dark`:`light`;case`sync-terminal`:return n?`dark`:`light`}}function G0(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function K0(){let e=E(e=>e.theme),t=E(e=>e.terminalTheme),[n,r]=(0,U.useState)(G0);return(0,U.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),W0(e,{prefersDark:n,terminalIsDark:Ae(t)})}function q0(e){let t=K0();return(0,U.useMemo)(()=>({...e,themeType:t}),[e,t])}var J0=`http://www.w3.org/2000/svg`,Y0=`http://www.w3.org/1999/xlink`,X0=/<svg\b(?:[^>"']|"[^"]*"|'[^']*')*>/i,Z0=16384,Q0=Z0*Z0,$0=2;function e2(e){return RegExp(`\\s${e}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'>]+)`,`i`)}function t2(e,t){let n=e.match(e2(t));return n?n[0].replace(/^[^=]*=\s*/,``).replace(/^["']|["']$/g,``):null}function n2(e,t,n){let r=` ${t}="${n}"`,i=e2(t);return i.test(e)?e.replace(i,r):e.replace(/\s*\/?>$/,e=>`${r}${e}`)}function r2(e){let t=e.match(X0)?.[0],n=t?t2(t,`viewBox`):null;if(!n)return null;let r=n.trim().split(/[\s,]+/).map(Number);if(r.length!==4)return null;let[,,i,a]=r;return Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0?{width:i,height:a}:null}function i2(e){let t=e.match(X0);if(!t)return e;let n=t[0];t2(n,`xmlns`)||(n=n2(n,`xmlns`,J0)),e.includes(`xlink:`)&&!t2(n,`xmlns:xlink`)&&(n=n2(n,`xmlns:xlink`,Y0));let r=r2(e);if(r){n=n2(n,`width`,String(r.width)),n=n2(n,`height`,String(r.height));let e=t2(n,`style`);if(e!==null){let t=e.split(`;`).filter(e=>e.trim()&&!/^\s*max-width\s*:/i.test(e)).join(`;`).trim();n=t?n2(n,`style`,t):n.replace(e2(`style`),``)}}return e.replace(t[0],()=>n)}function a2(e,t=new Date){let n=e=>String(e).padStart(2,`0`);return`mermaid-${`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}`}-${`${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`}.${e}`}function o2(e,t){let n=Math.min($0,Z0/e,Z0/t,Math.sqrt(Q0/(e*t)));return n>=1?n:null}function s2(e){return new Blob([i2(e)],{type:`image/svg+xml`})}function c2(e){return i2(new XMLSerializer().serializeToString(e))}function l2(e){let t=new DOMParser().parseFromString(e,`text/html`).querySelector(`svg`);if(!t)throw Error(`No svg in markup`);return c2(t)}function u2(e,t){let n=typeof e==`string`?e:URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),typeof e!=`string`&&setTimeout(()=>URL.revokeObjectURL(n),0)}async function d2(e,t,n,r,i){let a=new Image;a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,await a.decode();let o=document.createElement(`canvas`);o.width=Math.floor(t*r),o.height=Math.floor(n*r);let s=o.getContext(`2d`);if(!s)throw Error(`Canvas unavailable`);s.fillStyle=i,s.fillRect(0,0,o.width,o.height),s.drawImage(a,0,0,o.width,o.height);let c=o.toDataURL(`image/png`);if(!c.startsWith(`data:image/png`))throw Error(`Canvas export failed`);return c}async function f2(e){let t=t=>{try{let n=e.currentSvg();return n?(e.download(s2(n),a2(`svg`)),{kind:`svg`,reason:t}):{kind:`failed`}}catch{return{kind:`failed`}}},n;try{n=i2(await e.rerender())}catch{return t(`rerender-failed`)}if(/<foreignObject\b/i.test(n))return t(`rerender-failed`);let r=r2(n);if(!r)return t(`draw-failed`);let i=o2(r.width,r.height);if(i===null)return t(`too-large`);try{let t=await e.rasterize(n,r.width,r.height,i);return e.download(t,a2(`png`)),{kind:`png`}}catch{return t(`draw-failed`)}}var p2=`position:fixed;left:0;top:0;width:800px;height:600px;overflow:hidden;opacity:0;pointer-events:none;visibility:hidden;contain:strict;`;function m2(e){return!e.includes(`<svg`)||/\bfocusable=/.test(e)?e:e.replace(`<svg`,`<svg focusable="false" tabindex="-1"`)}function h2(e){return{startOnLoad:!1,theme:e,securityLevel:`strict`,fontFamily:`inherit`,suppressErrorRendering:!0,flowchart:{htmlLabels:!1,useMaxWidth:!0}}}var g2=/<(?:a|area)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,_2=/\s(?:xlink:)?(?:href|target)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+)/gi;function v2(e){return e.replace(g2,e=>e.replace(_2,``))}var y2=null,b2=null,x2=Promise.resolve(),S2=0;async function C2(){return b2||(y2||=J(()=>import(`./mermaid.core-96kZPVvg.js`).then(e=>(b2=e.default,b2)),__vite__mapDeps([126,127,128,1,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143])).catch(e=>{throw y2=null,e}),y2)}function w2(e){let t=x2.then(e,e);return x2=t.then(()=>void 0,()=>void 0),t}async function T2(e,t,n={}){return w2(async()=>{let r=await C2();r.initialize({...h2(t),...n});let i=`ensoMermaid${++S2}`,a=document.createElement(`div`);a.setAttribute(`aria-hidden`,`true`),a.style.cssText=p2,document.body.appendChild(a);try{let{svg:t}=await r.render(i,e,a);return m2(v2(t))}finally{a.remove(),document.getElementById(i)?.remove(),document.getElementById(`d${i}`)?.remove()}})}var E2=.1,D2={dark:`#1f2020`,default:`#ffffff`},O2=.1;function k2({code:e,streaming:t=!1,className:n}){let{t:r}=q(),i=(0,U.useRef)(null),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(1),[d,f]=(0,U.useState)({x:0,y:0}),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1);DE(h);let _=(0,U.useRef)({x:0,y:0}),v=(0,U.useRef)({x:0,y:0}),y=(0,U.useRef)(null),b=(0,U.useRef)(!1),x=K0()===`dark`?`dark`:`default`;(0,U.useEffect)(()=>{if(t){o(null),c(null);return}let n=!1;return(async()=>{if(!e.trim()){o(null),c(null);return}try{let t=await T2(e,x);n||(o(t),c(null),u(1),f({x:0,y:0}))}catch(e){n||(c(e instanceof Error?e.message:`Mermaid render failed`),o(null))}})(),()=>{n=!0}},[e,x,t]);let S=(0,U.useCallback)(()=>u(e=>e+E2),[]),C=(0,U.useCallback)(()=>u(e=>Math.max(e-E2,O2)),[]),w=(0,U.useCallback)(()=>{u(1),f({x:0,y:0})},[]),T=(0,U.useCallback)(()=>{g(!1),u(1),f({x:0,y:0})},[]),E=(0,U.useCallback)(()=>{g(!0),requestAnimationFrame(()=>{let e=y.current,t=e?.firstElementChild;if(!e||!t?.offsetWidth||!t.offsetHeight)return;let n=Math.min((e.clientWidth-48)/t.offsetWidth,(e.clientHeight-48)/t.offsetHeight);u(Math.round(n*100)/100),f({x:0,y:0})})},[]),D=(0,U.useCallback)(e=>{if(!h)return;e.preventDefault();let t=e.deltaY>0?-.1:E2;u(e=>Math.round(Math.max(e+t,O2)*100)/100)},[h]),O=(0,U.useCallback)(e=>{!h||e.button!==0||(m(!0),b.current=!1,_.current={x:e.clientX,y:e.clientY},v.current={...d})},[h,d]),k=(0,U.useCallback)(e=>{if(!p)return;let t=e.clientX-_.current.x,n=e.clientY-_.current.y;(Math.abs(t)>2||Math.abs(n)>2)&&(b.current=!0),f({x:v.current.x+t,y:v.current.y+n})},[p]),A=(0,U.useCallback)(()=>m(!1),[]),j=(0,U.useCallback)(e=>{e.stopPropagation()},[]),M=(0,U.useCallback)(()=>{b.current||T()},[T]),N=(0,U.useCallback)(()=>{try{let e=i.current?.querySelector(`svg`);if(!e)throw Error(`No svg`);u2(s2(c2(e)),a2(`svg`))}catch{gD({type:`error`,title:r(`Export failed`)})}},[r]),P=(0,U.useCallback)(async()=>{let t=await f2({currentSvg:()=>{let e=i.current?.querySelector(`svg`);return e?c2(e):null},rerender:async()=>l2(await T2(e,x,{htmlLabels:!1})),rasterize:(e,t,n,r)=>d2(e,t,n,r,D2[x]),download:u2});t.kind===`failed`?gD({type:`error`,title:r(`Export failed`)}):t.kind===`svg`&&gD({type:`warning`,title:t.reason===`too-large`?r(`Diagram is too large for PNG, exported SVG instead`):r(`PNG export failed, exported SVG instead`)})},[e,x,r]),F=e=>{let t=e===`sm`?`h-6 w-6`:`h-7 w-7`,n=e===`sm`?`h-3.5 w-3.5`:`h-4 w-4`,i=e===`sm`?`h-6 min-w-[2.5rem]`:`h-7 min-w-[3rem]`;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:S,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Zoom in`),children:(0,K.jsx)(Dn,{className:n})}),(0,K.jsxs)(`button`,{type:`button`,onClick:w,className:G(`flex items-center justify-center rounded text-xs transition-colors hover:bg-accent hover:text-accent-foreground`,i),title:r(`Reset zoom`),children:[Math.round(l*100),`%`]}),(0,K.jsx)(`button`,{type:`button`,onClick:C,disabled:l<=O2,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t,l<=O2&&`cursor-not-allowed opacity-50`),title:r(`Zoom out`),children:(0,K.jsx)(mn,{className:n})}),l!==1&&(0,K.jsx)(`button`,{type:`button`,onClick:w,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Fit to original size`),children:(0,K.jsx)(Mn,{className:n})}),(0,K.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`}),(0,K.jsx)(`button`,{type:`button`,onClick:N,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Export SVG`),children:(0,K.jsx)(Rt,{className:n})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void P(),className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Export PNG`),children:(0,K.jsx)(Zt,{className:n})}),h?(0,K.jsx)(`button`,{type:`button`,onClick:T,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Exit fullscreen`),children:(0,K.jsx)(pn,{className:n})}):(0,K.jsx)(`button`,{type:`button`,onClick:E,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`View fullscreen`),children:(0,K.jsx)(cn,{className:n})})]})};return s?(0,K.jsxs)(`div`,{className:G(`overflow-x-auto rounded-lg border border-destructive/50`,n),children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:(0,K.jsx)(`span`,{children:r(`Mermaid render error`)})}),(0,K.jsx)(`pre`,{className:`p-4 text-sm`,children:(0,K.jsx)(`code`,{className:`block font-mono leading-relaxed text-muted-foreground`,children:e})}),(0,K.jsx)(`div`,{className:`border-t border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:s})]}):a?(0,K.jsxs)(`div`,{className:G(`relative rounded-lg border border-border bg-muted/30`,n),style:{userSelect:`none`,WebkitUserSelect:`none`},children:[(0,K.jsx)(`div`,{ref:i,className:G(`max-h-[min(50vh,20rem)] overflow-hidden [overflow-anchor:none]`,h&&(p?`cursor-grabbing`:`cursor-grab`)),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onDoubleClick:h?void 0:E,children:(0,K.jsx)(`div`,{className:`origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,K.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,K.jsx)(`div`,{className:`absolute right-2 bottom-2`,children:F(`sm`)}),h&&(0,K.jsxs)(`div`,{className:`fixed inset-0 flex select-none flex-col bg-background`,style:{zIndex:RE.TOAST},"data-enso-float":``,onClick:M,onKeyDown:e=>{e.key===`Escape`&&T()},children:[(0,K.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center justify-between border-b border-border bg-muted/30 px-4 py-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-muted-foreground`,children:r(`Mermaid preview`)}),(0,K.jsx)(`button`,{type:`button`,onClick:T,className:`flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background/95 text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,title:r(`Exit fullscreen`),children:(0,K.jsx)(ir,{className:`h-4 w-4`})})]}),(0,K.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`div`,{ref:y,className:G(`flex min-h-0 flex-1 select-none overflow-hidden`,p?`cursor-grabbing`:`cursor-grab`),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onClick:j,onKeyDown:j,children:(0,K.jsx)(`div`,{className:`m-auto origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,K.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,K.jsx)(`div`,{className:`absolute right-4 bottom-4`,children:F(`md`)})]})]})]}):(0,K.jsx)(`div`,{className:G(`flex items-center justify-center rounded-lg border border-border bg-muted/30 p-8`,n),children:(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`Loading Mermaid diagram...`)})})}var A2=/^[a-z][a-z\d+.-]*:/i,j2=/^(?:https?|ircs?|mailto|xmpp):/i,M2=/^(?:[a-z]:[\\/]|\\\\)/i;function N2(e){let t=e?.trim();if(!t||!/^https?:\/\//i.test(t))return null;try{return new URL(t)}catch{return null}}function P2(e){let t=/^(.*?):(\d+)(?:-\d+)?$/.exec(e);if(!t)return{path:e};let n=Number(t[2]);return n>0?{path:t[1],line:n}:{path:t[1]}}function F2(e){try{return decodeURIComponent(e)}catch{return null}}function I2(e){let t=e.search(/[?#]/);return t<0?e:e.slice(0,t)}function L2(e){try{let t=new URL(e);if(t.protocol!==`file:`)return null;let n=decodeURIComponent(t.pathname);return n?(t.hostname&&t.hostname.toLowerCase()!==`localhost`?n=`//${t.hostname}${n}`:/^\/[a-z]:[\\/]/i.test(n)&&(n=n.slice(1)),n):null}catch{return null}}function R2(e){let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`?`))return{kind:`external`};if(/^file:/i.test(t)){let e=L2(t);return e?{kind:`local`,path:e}:{kind:`blocked`}}if(j2.test(t)||t.startsWith(`//`))return{kind:`external`};let n=F2(I2(t));return n==null||n.includes(`\0`)||A2.test(n)&&!M2.test(n)?{kind:`blocked`}:{kind:`local`,path:n}}function z2(e){let t=e.replace(/\\/g,`/`),n=/^[a-z]:\//i.test(t)||t.startsWith(`//`);if(!n&&!t.startsWith(`/`))return null;let r=/^[a-z]:\//i.test(t)?t.slice(0,2).toLowerCase():null,i=(r||n?t.slice(2):t.slice(1)).split(`/`),a=[];for(let e of i)if(!(!e||e===`.`)){if(e===`..`){if(a.length===0)return null;a.pop()}else a.push(e)}return r?{value:`${r}/${a.join(`/`)}`.replace(/\/$/,``),windows:!0}:n?{value:`//${a.join(`/`)}`,windows:!0}:{value:`/${a.join(`/`)}`.replace(/\/$/,``)||`/`,windows:!1}}function B2(e){let t=e.replace(/\\/g,`/`),n=[];for(let e of t.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(n.length===0)return null;n.pop()}else{if(e.includes(`\0`))return null;n.push(e)}}return n.join(`/`)}function V2(e){return z2(e)!==null}function H2(e,t){if(!t)return z2(e)?null:B2(e);let n=z2(t);if(!n)return null;let r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e,i=z2(r);if(!i)return r===e?B2(e):null;if(i.windows!==n.windows)return null;let a=n.value.toLowerCase(),o=i.value.toLowerCase();if(o===a)return``;let s=n.value.endsWith(`/`)?n.value:`${n.value}/`;return o.startsWith(s.toLowerCase())?B2(i.value.slice(s.length)):null}function U2(e,t){let n=t?z2(t):null;if(!n||H2(e,t)!==null)return null;let r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e;return z2(r)?r:null}var W2=/^(?:%|ms|s|sec|min|h|ms\/op|ns|µs|us|b|kb|mb|gb|tb|kib|mib|gib|x|×|k|m|bn)$/i;function G2(e){let t=e.trim().replace(/^[$€£¥₹]\s*/,``),n=!1;/^\(.*\)$/.test(t)&&(n=!0,t=t.slice(1,-1));let r=/^([+-]?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?)\s*(\S*)$/.exec(t);if(!r||r[2]&&!W2.test(r[2]))return null;let i=Number(r[1].replace(/,/g,``));return n?-i:i}function K2(e){let t=Math.max(0,...e.map(e=>e.length));return Array.from({length:t},(t,n)=>{let r=e.map(e=>e[n]?.trim()??``).filter(Boolean);return r.length>0&&r.every(e=>G2(e)!==null)})}function q2(e,t,n){return n?(G2(e)??0)-(G2(t)??0):e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function J2(e,t,n){let r=e.map((e,t)=>t);if(!t)return r;let i=t.dir===`asc`?1:-1,a=n=>e[n][t.column]?.trim()??``;return r.sort((e,r)=>{let o=a(e),s=a(r);return!o||!s?o?-1:+!!s:i*q2(o,s,n[t.column]??!1)||e-r})}function Y2(e,t){return e?.column===t?e.dir===`asc`?{column:t,dir:`desc`}:null:{column:t,dir:`asc`}}var X2=new Set([`json`,`jsonc`,`json5`]),Z2=new Set([`console`,`shell-session`,`terminal`,`output`,`ansi`]),Q2=new Set([`sh`,`bash`,`shell`,`zsh`,`shellscript`]),$2=`$ `;function e4(e,t){let n=e?.toLowerCase();if(n&&X2.has(n))return t4(t)?`json`:null;if(!n&&/^\s*[{[]/.test(t)&&t4(t))return`json`;if(n&&Z2.has(n)||t.includes(`\x1B[`))return`terminal`;if(!n||Q2.has(n)){let e=t.split(`
251
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return VQ(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=R$.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function J$(){return{exit:{taskListCheckValueChecked:X$,taskListCheckValueUnchecked:X$,paragraph:Z$}}}function Y$(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Q$}}}function X$(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Z$(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Q$(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=R$.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function $$(){return[aQ(),kQ(),PQ(),z$(),J$()]}function e1(e){return{extensions:[oQ(),AQ(e),FQ(),q$(e),Y$()]}}var t1={tokenize:h1,partial:!0},n1={tokenize:g1,partial:!0},r1={tokenize:_1,partial:!0},i1={tokenize:v1,partial:!0},a1={tokenize:y1,partial:!0},o1={name:`wwwAutolink`,tokenize:p1,previous:b1},s1={name:`protocolAutolink`,tokenize:m1,previous:x1},c1={name:`emailAutolink`,tokenize:f1,previous:S1},l1={};function u1(){return{text:l1}}for(var d1=48;d1<123;)l1[d1]=c1,d1++,d1===58?d1=65:d1===91&&(d1=97);l1[43]=c1,l1[45]=c1,l1[46]=c1,l1[95]=c1,l1[72]=[c1,s1],l1[104]=[c1,s1],l1[87]=[c1,o1],l1[119]=[c1,o1];function f1(e,t,n){let r=this,i,a;return o;function o(t){return!C1(t)||!S1.call(r,r.previous)||w1(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return C1(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(a1,u,l)(t):t===45||t===95||aq(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&iq(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function p1(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!b1.call(r,r.previous)||w1(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(t1,e.attempt(n1,e.attempt(r1,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function m1(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&x1.call(r,r.previous)&&!w1(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(iq(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||sq(t)||fq(t)||hq(t)||mq(t)?n(t):e.attempt(n1,e.attempt(r1,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function h1(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function g1(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(i1,c,s)(t):t===null||fq(t)||hq(t)||t!==45&&mq(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function _1(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(i1,t,a)(o):o===null||fq(o)||hq(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function v1(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||fq(o)||hq(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||fq(e)||hq(e)?t(e):r(e)}function a(e){return iq(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):iq(t)?(e.consume(t),o):n(t)}}function y1(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return aq(e)?n(e):t(e)}}function b1(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||fq(e)}function x1(e){return!iq(e)}function S1(e){return!(e===47||C1(e))}function C1(e){return e===43||e===45||e===46||e===95||aq(e)}function w1(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var T1={tokenize:N1,partial:!0};function E1(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:A1,continuation:{tokenize:j1},exit:M1}},text:{91:{name:`gfmFootnoteCall`,tokenize:k1},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:D1,resolveTo:O1}}}}function D1(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=rq(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function O1(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function k1(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||fq(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(rq(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return fq(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function A1(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||fq(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=rq(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return fq(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),vq(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function j1(e,t,n){return e.check(Nq,t,e.attempt(T1,t,n))}function M1(e){e.exit(`gfmFootnoteDefinition`)}function N1(e,t,n){let r=this;return vq(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function P1(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&XK(o,o.length,0,Eq(s,e.slice(r+1,n),t)),XK(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),XK(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Tq(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Tq(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var F1=class{constructor(){this.map=[]}add(e,t,n){I1(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function I1(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function L1(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function R1(){return{flow:{null:{name:`table`,tokenize:z1,resolveAll:B1}}}}function z1(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):dq(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):pq(t)?vq(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||fq(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,pq(t)?vq(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return pq(t)?vq(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||dq(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return pq(t)?vq(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||dq(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||dq(n)?(e.exit(`tableRow`),t(n)):pq(n)?vq(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||fq(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function B1(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new F1;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(H1(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=V1(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=V1(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=V1(f,t,o,i,n,d)):(o[0]=o[1],d=V1(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&H1(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=L1(t.events,n))}return e}function V1(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},U1(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=U1(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=U1(t.events,n[2]),a=U1(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},U1(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function H1(e,t,n,r,i){let a=[],o=U1(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function U1(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var W1={name:`tasklistCheck`,tokenize:K1};function G1(){return{text:{91:W1}}}function K1(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return fq(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return dq(r)?t(r):pq(r)?e.check({tokenize:q1},t,n)(r):n(r)}}function q1(e,t,n){return vq(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function J1(e){return $K([u1(),E1(),P1(e),R1(),G1()])}var Y1={};function X1(e){let t=this,n=e||Y1,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(J1(n)),a.push($$()),o.push(e1(n))}function Z1(){let e=navigator.userAgent;return e.includes(`Mac`)?`Reveal in Finder`:e.includes(`Linux`)?`Open Containing Folder`:`Reveal in File Explorer`}function Q1({image:e,onClose:t}){let{t:n}=q();return(0,K.jsx)(zE,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,K.jsxs)(WE,{className:`max-w-4xl`,children:[(0,K.jsxs)(GE,{children:[(0,K.jsx)(qE,{children:n(`Image preview`)}),(0,K.jsx)(JE,{className:`break-all`,children:e?.rel})]}),(0,K.jsx)(XE,{className:`max-h-[70vh]`,children:e&&(0,K.jsx)(`img`,{src:e.dataUrl,alt:e.rel,className:`mx-auto max-h-[65vh] max-w-full object-contain`})}),(0,K.jsx)(KE,{children:(0,K.jsx)(Oa,{variant:`outline`,onClick:t,children:n(`Close`)})})]})})}function $1(e){try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length);let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function e0(e){let t=typeof navigator>`u`?void 0:navigator.clipboard;if(!t?.writeText||window.isSecureContext===!1)return Promise.resolve($1(e));try{return Promise.resolve(t.writeText(e)).then(()=>!0,()=>$1(e))}catch{return Promise.resolve($1(e))}}function t0(){return!!window.electronAPI?.remote}function n0(e){return new TextDecoder().decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))}function r0(e,t){return e[t]?.btwParentId||t}var i0=new Map,a0=new Map,o0=new Map,s0=new Set,c0=[];function l0(){let e=nP.getState(),t=e.activeId;if(!t)return null;let n=e.conversations[t],r=i0.get(t);return!n||!r?null:{api:r,conversationId:t,projectId:n.projectId}}function u0(e){let t=l0();if(!t||f0(t.projectId))return;UR.getState().ensureOpen();let n=t.api.getPanel(`changes`);if(n){n.focus();return}t.api.addPanel({id:`changes`,component:`changes`,title:e?.title??`Changes`,params:{conversationId:t.conversationId,projectId:t.projectId}})}function d0(e,t){return t?e.some(e=>e.id===t&&e.kind===`secretary`):!1}function f0(e){return d0(E.getState().projects,e)}function p0(e,t,n,r){let i=e.getPanel(`files`);if(i){i.focus();return}e.addPanel({id:`files`,component:`files`,title:r??`Files`,params:{conversationId:t,projectId:n}})}function m0(e,t,n,r){let i=nP.getState(),a=r0(i.conversations,e),o=i.conversations[a]?.projectId;if(!o||f0(o))return;UR.getState().ensureOpen(a);let s=r?[t,n,r]:n?[t,n]:[t],c=a0.get(a);c?c(...s):o0.set(a,s);let l=i0.get(a);l?p0(l,a,o):s0.add(a)}function h0(e){let t=nP.getState(),n=e?.conversationId??t.activeId;if(!n)return;let r=t.conversations[n];if(!r)return;let i=r0(t.conversations,n),a=i0.get(i);UR.getState().ensureOpen(i);let o=e?.tabId??`browser:${crypto.randomUUID()}`;if(!a){c0.push({conversationId:i,tabId:o,ownerId:n});return}let s=a.getPanel(o);if(s){s.focus();return}a.addPanel({id:o,component:`browser`,title:e?.title??`Browser`,params:{conversationId:n,projectId:r.projectId}})}function g0(e,t){if(!nP.getState().conversations[e])return null;let n=`browser:${crypto.randomUUID()}`;return h0({conversationId:e,tabId:n,title:new URL(t).host}),window.electronAPI.browser.navigate(n,e,t)}var _0=`my-2 overflow-x-auto rounded-lg border bg-[var(--sunken,var(--muted))] text-(length:--chat-code-block-size) [font-weight:var(--chat-code-block-weight)] leading-relaxed`;function v0(e){let t=e.trimStart();return/^<[a-zA-Z!/]/.test(t)?`html`:/^[{[]/.test(t)?`json`:/^[$#] /.test(t)?`shellscript`:`text`}function y0({code:e,language:t,streaming:n=!1}){let[r,i]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(n){i(null);return}let r=!0;return Yg(e,t??v0(e),!0).then(e=>{r&&i(e)}),()=>{r=!1}},[e,t,n]);let a=!n&&(0,K.jsx)(Fs,{text:e,className:`absolute top-1.5 right-1.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/code:opacity-100`});return r==null?(0,K.jsxs)(`div`,{"data-enso":`code-block`,"data-language":t,className:`group/code relative`,children:[(0,K.jsx)(`pre`,{className:`${_0} p-3 font-mono`,children:(0,K.jsx)(`code`,{children:e})}),a]}):(0,K.jsxs)(`div`,{"data-enso":`code-block`,"data-language":t,className:`group/code relative`,children:[(0,K.jsx)(`div`,{className:`${_0} [&_pre]:m-0 [&_pre]:overflow-x-auto [&_pre]:bg-transparent! [&_pre]:p-3 [&_pre]:font-mono [&_pre]:[--shiki-dark-bg:transparent]!`,dangerouslySetInnerHTML:{__html:r}}),a]})}var b0=50,x0=3e4,S0={status:`missing`},C0=new Map,w0=new Map,T0=new Set,E0=new Map,D0=null,O0=0,k0={batches:0,paths:0,ms:0},A0=e=>e.cwd??`conversation:${e.conversationId}`,j0=(e,t)=>`${A0(e)}\0${t}`;function M0(e){return e?e.state.status===`ok`?e.epoch===O0:Date.now()-e.at<x0:!1}function N0(e,t){let n=C0.get(e)?.state,r=n?.status===t.status&&(t.status===`missing`||n.status===`ok`&&n.rel===t.rel&&n.kind===t.kind);if(C0.set(e,{state:r&&n?n:t,epoch:O0,at:Date.now()}),!r)for(let t of w0.get(e)??[])t()}function P0(e){return e?{status:`ok`,rel:e.rel,kind:e.kind}:S0}async function F0(e,t){let n=performance.now();try{let n=await window.electronAPI.workspaceFiles.resolveLinks({conversationId:e.conversationId,projectId:e.projectId,rels:t});return t.map((e,t)=>P0(n.ok?n.items[t]:null))}catch{return t.map(()=>S0)}finally{k0.batches+=1,k0.paths+=t.length,k0.ms+=performance.now()-n}}function I0(){D0=null;let e=[...E0.values()];E0.clear();for(let{scope:t,rels:n}of e){let e=[...n];for(let n=0;n<e.length;n+=200){let r=e.slice(n,n+200);F0(t,r).then(e=>{r.forEach((n,r)=>{let i=j0(t,n);T0.delete(i),N0(i,e[r])})})}}}function L0(e,t){let n=j0(e,t);if(T0.has(n)||M0(C0.get(n)))return;T0.add(n);let r=`${e.conversationId}\0${e.projectId}`,i=E0.get(r)??{scope:e,rels:new Set};i.rels.add(t),E0.set(r,i),D0??=setTimeout(I0,b0)}async function R0(e,t){let[n]=await F0(e,[t]);return N0(j0(e,t),n),n}function z0(e,t,n){let r=e&&t?j0(e,t):null,i=(0,U.useCallback)(e=>{if(!r)return()=>{};let t=w0.get(r)??new Set;return w0.set(r,t),t.add(e),()=>{t.delete(e),t.size===0&&w0.delete(r)}},[r]),a=(0,U.useSyncExternalStore)(i,()=>r?C0.get(r)?.state:void 0);return(0,U.useEffect)(()=>{n&&e&&t&&L0(e,t)},[n,r]),a}var B0=2;function V0({value:e}){return typeof e==`string`?(0,K.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-400`,children:JSON.stringify(e)}):typeof e==`number`?(0,K.jsx)(`span`,{className:`text-sky-700 dark:text-sky-400`,children:String(e)}):(0,K.jsx)(`span`,{className:`text-violet-700 dark:text-violet-400`,children:String(e)})}function H0({name:e,value:t,depth:n}){let[r,i]=(0,U.useState)(n<B0),a=e!==void 0&&(0,K.jsxs)(`span`,{className:`text-foreground/80`,children:[e,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`: `})]});if(typeof t!=`object`||!t)return(0,K.jsxs)(`div`,{className:`pl-4`,children:[a,(0,K.jsx)(V0,{value:t})]});let o=Array.isArray(t),s=o?t.map((e,t)=>[String(t),e]):Object.entries(t),[c,l]=o?[`[`,`]`]:[`{`,`}`];return(0,K.jsxs)(`div`,{className:n>0?`pl-4`:void 0,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:()=>i(!r),className:`-ml-4 inline-flex items-center text-left hover:text-foreground`,children:[(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,r&&`rotate-90`)}),(0,K.jsxs)(`span`,{className:`ml-1`,children:[a,(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[c,!r&&` ${s.length} ${l}`]})]})]}),r&&(0,K.jsxs)(K.Fragment,{children:[s.map(([e,t])=>(0,K.jsx)(H0,{name:o?void 0:e,value:t,depth:n+1},e)),(0,K.jsx)(`div`,{className:`text-muted-foreground`,children:l})]})]})}function U0({source:e,value:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1),a=e=>G(`rounded px-1.5 py-0.5`,e?`bg-muted text-foreground`:`hover:text-foreground`);return(0,K.jsxs)(`div`,{"data-enso":`json-tree`,className:`group/code relative my-2 rounded-lg border`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 border-b px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`mr-auto font-mono`,children:`JSON`}),(0,K.jsx)(`button`,{type:`button`,className:a(!r),onClick:()=>i(!1),children:n(`Tree view`)}),(0,K.jsx)(`button`,{type:`button`,className:a(r),onClick:()=>i(!0),children:n(`Raw text`)}),(0,K.jsx)(Fs,{text:e,className:`rounded p-1`})]}),r?(0,K.jsx)(`div`,{className:`px-2`,children:(0,K.jsx)(y0,{code:e,language:`json`})}):(0,K.jsx)(`div`,{className:`max-h-[480px] overflow-auto py-2 pr-3 pl-6 font-mono text-(length:--chat-code-block-size) leading-relaxed`,children:(0,K.jsx)(H0,{value:t,depth:0})})]})}function W0(e,{prefersDark:t,terminalIsDark:n}){switch(e){case`light`:return`light`;case`dark`:return`dark`;case`system`:return t?`dark`:`light`;case`sync-terminal`:return n?`dark`:`light`}}function G0(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches}function K0(){let e=E(e=>e.theme),t=E(e=>e.terminalTheme),[n,r]=(0,U.useState)(G0);return(0,U.useEffect)(()=>{let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),W0(e,{prefersDark:n,terminalIsDark:Ae(t)})}function q0(e){let t=K0();return(0,U.useMemo)(()=>({...e,themeType:t}),[e,t])}var J0=`http://www.w3.org/2000/svg`,Y0=`http://www.w3.org/1999/xlink`,X0=/<svg\b(?:[^>"']|"[^"]*"|'[^']*')*>/i,Z0=16384,Q0=Z0*Z0,$0=2;function e2(e){return RegExp(`\\s${e}\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s"'>]+)`,`i`)}function t2(e,t){let n=e.match(e2(t));return n?n[0].replace(/^[^=]*=\s*/,``).replace(/^["']|["']$/g,``):null}function n2(e,t,n){let r=` ${t}="${n}"`,i=e2(t);return i.test(e)?e.replace(i,r):e.replace(/\s*\/?>$/,e=>`${r}${e}`)}function r2(e){let t=e.match(X0)?.[0],n=t?t2(t,`viewBox`):null;if(!n)return null;let r=n.trim().split(/[\s,]+/).map(Number);if(r.length!==4)return null;let[,,i,a]=r;return Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0?{width:i,height:a}:null}function i2(e){let t=e.match(X0);if(!t)return e;let n=t[0];t2(n,`xmlns`)||(n=n2(n,`xmlns`,J0)),e.includes(`xlink:`)&&!t2(n,`xmlns:xlink`)&&(n=n2(n,`xmlns:xlink`,Y0));let r=r2(e);if(r){n=n2(n,`width`,String(r.width)),n=n2(n,`height`,String(r.height));let e=t2(n,`style`);if(e!==null){let t=e.split(`;`).filter(e=>e.trim()&&!/^\s*max-width\s*:/i.test(e)).join(`;`).trim();n=t?n2(n,`style`,t):n.replace(e2(`style`),``)}}return e.replace(t[0],()=>n)}function a2(e,t=new Date){let n=e=>String(e).padStart(2,`0`);return`mermaid-${`${t.getFullYear()}${n(t.getMonth()+1)}${n(t.getDate())}`}-${`${n(t.getHours())}${n(t.getMinutes())}${n(t.getSeconds())}`}.${e}`}function o2(e,t){let n=Math.min($0,Z0/e,Z0/t,Math.sqrt(Q0/(e*t)));return n>=1?n:null}function s2(e){return new Blob([i2(e)],{type:`image/svg+xml`})}function c2(e){return i2(new XMLSerializer().serializeToString(e))}function l2(e){let t=new DOMParser().parseFromString(e,`text/html`).querySelector(`svg`);if(!t)throw Error(`No svg in markup`);return c2(t)}function u2(e,t){let n=typeof e==`string`?e:URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),typeof e!=`string`&&setTimeout(()=>URL.revokeObjectURL(n),0)}async function d2(e,t,n,r,i){let a=new Image;a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,await a.decode();let o=document.createElement(`canvas`);o.width=Math.floor(t*r),o.height=Math.floor(n*r);let s=o.getContext(`2d`);if(!s)throw Error(`Canvas unavailable`);s.fillStyle=i,s.fillRect(0,0,o.width,o.height),s.drawImage(a,0,0,o.width,o.height);let c=o.toDataURL(`image/png`);if(!c.startsWith(`data:image/png`))throw Error(`Canvas export failed`);return c}async function f2(e){let t=t=>{try{let n=e.currentSvg();return n?(e.download(s2(n),a2(`svg`)),{kind:`svg`,reason:t}):{kind:`failed`}}catch{return{kind:`failed`}}},n;try{n=i2(await e.rerender())}catch{return t(`rerender-failed`)}if(/<foreignObject\b/i.test(n))return t(`rerender-failed`);let r=r2(n);if(!r)return t(`draw-failed`);let i=o2(r.width,r.height);if(i===null)return t(`too-large`);try{let t=await e.rasterize(n,r.width,r.height,i);return e.download(t,a2(`png`)),{kind:`png`}}catch{return t(`draw-failed`)}}var p2=`position:fixed;left:0;top:0;width:800px;height:600px;overflow:hidden;opacity:0;pointer-events:none;visibility:hidden;contain:strict;`;function m2(e){return!e.includes(`<svg`)||/\bfocusable=/.test(e)?e:e.replace(`<svg`,`<svg focusable="false" tabindex="-1"`)}function h2(e){return{startOnLoad:!1,theme:e,securityLevel:`strict`,fontFamily:`inherit`,suppressErrorRendering:!0,flowchart:{htmlLabels:!1,useMaxWidth:!0}}}var g2=/<(?:a|area)\b(?:[^>"']|"[^"]*"|'[^']*')*>/gi,_2=/\s(?:xlink:)?(?:href|target)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+)/gi;function v2(e){return e.replace(g2,e=>e.replace(_2,``))}var y2=null,b2=null,x2=Promise.resolve(),S2=0;async function C2(){return b2||(y2||=J(()=>import(`./mermaid.core-DyabQfxY.js`).then(e=>(b2=e.default,b2)),__vite__mapDeps([126,127,128,1,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143])).catch(e=>{throw y2=null,e}),y2)}function w2(e){let t=x2.then(e,e);return x2=t.then(()=>void 0,()=>void 0),t}async function T2(e,t,n={}){return w2(async()=>{let r=await C2();r.initialize({...h2(t),...n});let i=`ensoMermaid${++S2}`,a=document.createElement(`div`);a.setAttribute(`aria-hidden`,`true`),a.style.cssText=p2,document.body.appendChild(a);try{let{svg:t}=await r.render(i,e,a);return m2(v2(t))}finally{a.remove(),document.getElementById(i)?.remove(),document.getElementById(`d${i}`)?.remove()}})}var E2=.1,D2={dark:`#1f2020`,default:`#ffffff`},O2=.1;function k2({code:e,streaming:t=!1,className:n}){let{t:r}=q(),i=(0,U.useRef)(null),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(1),[d,f]=(0,U.useState)({x:0,y:0}),[p,m]=(0,U.useState)(!1),[h,g]=(0,U.useState)(!1);EE(h);let _=(0,U.useRef)({x:0,y:0}),v=(0,U.useRef)({x:0,y:0}),y=(0,U.useRef)(null),b=(0,U.useRef)(!1),x=K0()===`dark`?`dark`:`default`;(0,U.useEffect)(()=>{if(t){o(null),c(null);return}let n=!1;return(async()=>{if(!e.trim()){o(null),c(null);return}try{let t=await T2(e,x);n||(o(t),c(null),u(1),f({x:0,y:0}))}catch(e){n||(c(e instanceof Error?e.message:`Mermaid render failed`),o(null))}})(),()=>{n=!0}},[e,x,t]);let S=(0,U.useCallback)(()=>u(e=>e+E2),[]),C=(0,U.useCallback)(()=>u(e=>Math.max(e-E2,O2)),[]),w=(0,U.useCallback)(()=>{u(1),f({x:0,y:0})},[]),T=(0,U.useCallback)(()=>{g(!1),u(1),f({x:0,y:0})},[]),E=(0,U.useCallback)(()=>{g(!0),requestAnimationFrame(()=>{let e=y.current,t=e?.firstElementChild;if(!e||!t?.offsetWidth||!t.offsetHeight)return;let n=Math.min((e.clientWidth-48)/t.offsetWidth,(e.clientHeight-48)/t.offsetHeight);u(Math.round(n*100)/100),f({x:0,y:0})})},[]),D=(0,U.useCallback)(e=>{if(!h)return;e.preventDefault();let t=e.deltaY>0?-.1:E2;u(e=>Math.round(Math.max(e+t,O2)*100)/100)},[h]),O=(0,U.useCallback)(e=>{!h||e.button!==0||(m(!0),b.current=!1,_.current={x:e.clientX,y:e.clientY},v.current={...d})},[h,d]),k=(0,U.useCallback)(e=>{if(!p)return;let t=e.clientX-_.current.x,n=e.clientY-_.current.y;(Math.abs(t)>2||Math.abs(n)>2)&&(b.current=!0),f({x:v.current.x+t,y:v.current.y+n})},[p]),A=(0,U.useCallback)(()=>m(!1),[]),j=(0,U.useCallback)(e=>{e.stopPropagation()},[]),M=(0,U.useCallback)(()=>{b.current||T()},[T]),N=(0,U.useCallback)(()=>{try{let e=i.current?.querySelector(`svg`);if(!e)throw Error(`No svg`);u2(s2(c2(e)),a2(`svg`))}catch{hD({type:`error`,title:r(`Export failed`)})}},[r]),P=(0,U.useCallback)(async()=>{let t=await f2({currentSvg:()=>{let e=i.current?.querySelector(`svg`);return e?c2(e):null},rerender:async()=>l2(await T2(e,x,{htmlLabels:!1})),rasterize:(e,t,n,r)=>d2(e,t,n,r,D2[x]),download:u2});t.kind===`failed`?hD({type:`error`,title:r(`Export failed`)}):t.kind===`svg`&&hD({type:`warning`,title:t.reason===`too-large`?r(`Diagram is too large for PNG, exported SVG instead`):r(`PNG export failed, exported SVG instead`)})},[e,x,r]),F=e=>{let t=e===`sm`?`h-6 w-6`:`h-7 w-7`,n=e===`sm`?`h-3.5 w-3.5`:`h-4 w-4`,i=e===`sm`?`h-6 min-w-[2.5rem]`:`h-7 min-w-[3rem]`;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background/95 p-1 shadow-sm`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:S,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Zoom in`),children:(0,K.jsx)(Dn,{className:n})}),(0,K.jsxs)(`button`,{type:`button`,onClick:w,className:G(`flex items-center justify-center rounded text-xs transition-colors hover:bg-accent hover:text-accent-foreground`,i),title:r(`Reset zoom`),children:[Math.round(l*100),`%`]}),(0,K.jsx)(`button`,{type:`button`,onClick:C,disabled:l<=O2,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t,l<=O2&&`cursor-not-allowed opacity-50`),title:r(`Zoom out`),children:(0,K.jsx)(mn,{className:n})}),l!==1&&(0,K.jsx)(`button`,{type:`button`,onClick:w,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Fit to original size`),children:(0,K.jsx)(Mn,{className:n})}),(0,K.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`}),(0,K.jsx)(`button`,{type:`button`,onClick:N,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Export SVG`),children:(0,K.jsx)(Rt,{className:n})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void P(),className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Export PNG`),children:(0,K.jsx)(Zt,{className:n})}),h?(0,K.jsx)(`button`,{type:`button`,onClick:T,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`Exit fullscreen`),children:(0,K.jsx)(pn,{className:n})}):(0,K.jsx)(`button`,{type:`button`,onClick:E,className:G(`flex items-center justify-center rounded text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,t),title:r(`View fullscreen`),children:(0,K.jsx)(cn,{className:n})})]})};return s?(0,K.jsxs)(`div`,{className:G(`overflow-x-auto rounded-lg border border-destructive/50`,n),children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:(0,K.jsx)(`span`,{children:r(`Mermaid render error`)})}),(0,K.jsx)(`pre`,{className:`p-4 text-sm`,children:(0,K.jsx)(`code`,{className:`block font-mono leading-relaxed text-muted-foreground`,children:e})}),(0,K.jsx)(`div`,{className:`border-t border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground`,children:s})]}):a?(0,K.jsxs)(`div`,{className:G(`relative rounded-lg border border-border bg-muted/30`,n),style:{userSelect:`none`,WebkitUserSelect:`none`},children:[(0,K.jsx)(`div`,{ref:i,className:G(`max-h-[min(50vh,20rem)] overflow-hidden [overflow-anchor:none]`,h&&(p?`cursor-grabbing`:`cursor-grab`)),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onDoubleClick:h?void 0:E,children:(0,K.jsx)(`div`,{className:`origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,K.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,K.jsx)(`div`,{className:`absolute right-2 bottom-2`,children:F(`sm`)}),h&&(0,K.jsxs)(`div`,{className:`fixed inset-0 flex select-none flex-col bg-background`,style:{zIndex:LE.TOAST},"data-enso-float":``,onClick:M,onKeyDown:e=>{e.key===`Escape`&&T()},children:[(0,K.jsxs)(`div`,{className:`relative z-10 flex shrink-0 items-center justify-between border-b border-border bg-muted/30 px-4 py-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-muted-foreground`,children:r(`Mermaid preview`)}),(0,K.jsx)(`button`,{type:`button`,onClick:T,className:`flex h-7 w-7 items-center justify-center rounded-md border border-border bg-background/95 text-sm transition-colors hover:bg-accent hover:text-accent-foreground`,title:r(`Exit fullscreen`),children:(0,K.jsx)(ir,{className:`h-4 w-4`})})]}),(0,K.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`div`,{ref:y,className:G(`flex min-h-0 flex-1 select-none overflow-hidden`,p?`cursor-grabbing`:`cursor-grab`),onWheel:D,onMouseDown:O,onMouseMove:k,onMouseUp:A,onMouseLeave:A,onClick:j,onKeyDown:j,children:(0,K.jsx)(`div`,{className:`m-auto origin-center transition-transform duration-100 ease-out`,style:{transform:`translate(${d.x}px, ${d.y}px) scale(${l})`},children:(0,K.jsx)(`div`,{className:`p-4`,dangerouslySetInnerHTML:{__html:a}})})}),(0,K.jsx)(`div`,{className:`absolute right-4 bottom-4`,children:F(`md`)})]})]})]}):(0,K.jsx)(`div`,{className:G(`flex items-center justify-center rounded-lg border border-border bg-muted/30 p-8`,n),children:(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`Loading Mermaid diagram...`)})})}var A2=/^[a-z][a-z\d+.-]*:/i,j2=/^(?:https?|ircs?|mailto|xmpp):/i,M2=/^(?:[a-z]:[\\/]|\\\\)/i;function N2(e){let t=e?.trim();if(!t||!/^https?:\/\//i.test(t))return null;try{return new URL(t)}catch{return null}}function P2(e){let t=/^(.*?):(\d+)(?:-\d+)?$/.exec(e);if(!t)return{path:e};let n=Number(t[2]);return n>0?{path:t[1],line:n}:{path:t[1]}}function F2(e){try{return decodeURIComponent(e)}catch{return null}}function I2(e){let t=e.search(/[?#]/);return t<0?e:e.slice(0,t)}function L2(e){try{let t=new URL(e);if(t.protocol!==`file:`)return null;let n=decodeURIComponent(t.pathname);return n?(t.hostname&&t.hostname.toLowerCase()!==`localhost`?n=`//${t.hostname}${n}`:/^\/[a-z]:[\\/]/i.test(n)&&(n=n.slice(1)),n):null}catch{return null}}function R2(e){let t=e.trim();if(!t||t.startsWith(`#`)||t.startsWith(`?`))return{kind:`external`};if(/^file:/i.test(t)){let e=L2(t);return e?{kind:`local`,path:e}:{kind:`blocked`}}if(j2.test(t)||t.startsWith(`//`))return{kind:`external`};let n=F2(I2(t));return n==null||n.includes(`\0`)||A2.test(n)&&!M2.test(n)?{kind:`blocked`}:{kind:`local`,path:n}}function z2(e){let t=e.replace(/\\/g,`/`),n=/^[a-z]:\//i.test(t)||t.startsWith(`//`);if(!n&&!t.startsWith(`/`))return null;let r=/^[a-z]:\//i.test(t)?t.slice(0,2).toLowerCase():null,i=(r||n?t.slice(2):t.slice(1)).split(`/`),a=[];for(let e of i)if(!(!e||e===`.`)){if(e===`..`){if(a.length===0)return null;a.pop()}else a.push(e)}return r?{value:`${r}/${a.join(`/`)}`.replace(/\/$/,``),windows:!0}:n?{value:`//${a.join(`/`)}`,windows:!0}:{value:`/${a.join(`/`)}`.replace(/\/$/,``)||`/`,windows:!1}}function B2(e){let t=e.replace(/\\/g,`/`),n=[];for(let e of t.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(n.length===0)return null;n.pop()}else{if(e.includes(`\0`))return null;n.push(e)}}return n.join(`/`)}function V2(e){return z2(e)!==null}function H2(e,t){if(!t)return z2(e)?null:B2(e);let n=z2(t);if(!n)return null;let r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e,i=z2(r);if(!i)return r===e?B2(e):null;if(i.windows!==n.windows)return null;let a=n.value.toLowerCase(),o=i.value.toLowerCase();if(o===a)return``;let s=n.value.endsWith(`/`)?n.value:`${n.value}/`;return o.startsWith(s.toLowerCase())?B2(i.value.slice(s.length)):null}function U2(e,t){let n=t?z2(t):null;if(!n||H2(e,t)!==null)return null;let r=n.windows&&/^\/[a-z]:[\\/]/i.test(e)?e.slice(1):e;return z2(r)?r:null}var W2=/^(?:%|ms|s|sec|min|h|ms\/op|ns|µs|us|b|kb|mb|gb|tb|kib|mib|gib|x|×|k|m|bn)$/i;function G2(e){let t=e.trim().replace(/^[$€£¥₹]\s*/,``),n=!1;/^\(.*\)$/.test(t)&&(n=!0,t=t.slice(1,-1));let r=/^([+-]?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?)\s*(\S*)$/.exec(t);if(!r||r[2]&&!W2.test(r[2]))return null;let i=Number(r[1].replace(/,/g,``));return n?-i:i}function K2(e){let t=Math.max(0,...e.map(e=>e.length));return Array.from({length:t},(t,n)=>{let r=e.map(e=>e[n]?.trim()??``).filter(Boolean);return r.length>0&&r.every(e=>G2(e)!==null)})}function q2(e,t,n){return n?(G2(e)??0)-(G2(t)??0):e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function J2(e,t,n){let r=e.map((e,t)=>t);if(!t)return r;let i=t.dir===`asc`?1:-1,a=n=>e[n][t.column]?.trim()??``;return r.sort((e,r)=>{let o=a(e),s=a(r);return!o||!s?o?-1:+!!s:i*q2(o,s,n[t.column]??!1)||e-r})}function Y2(e,t){return e?.column===t?e.dir===`asc`?{column:t,dir:`desc`}:null:{column:t,dir:`asc`}}var X2=new Set([`json`,`jsonc`,`json5`]),Z2=new Set([`console`,`shell-session`,`terminal`,`output`,`ansi`]),Q2=new Set([`sh`,`bash`,`shell`,`zsh`,`shellscript`]),$2=`$ `;function e4(e,t){let n=e?.toLowerCase();if(n&&X2.has(n))return t4(t)?`json`:null;if(!n&&/^\s*[{[]/.test(t)&&t4(t))return`json`;if(n&&Z2.has(n)||t.includes(`\x1B[`))return`terminal`;if(!n||Q2.has(n)){let e=t.split(`
252
252
  `).filter(e=>e.trim());if(e[0]?.startsWith($2)&&e.some(e=>!e.startsWith($2)))return`terminal`}return null}function t4(e){let t=n4(e);return t.ok&&typeof t.value==`object`&&t.value!==null}function n4(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`"`){let r=n+1;for(;r<e.length&&e[r]!==`"`;)r+=e[r]===`\\`?2:1;t+=e.slice(n,r+1),n=r+1}else if(r===`/`&&e[n+1]===`/`)for(;n<e.length&&e[n]!==`
253
253
  `;)n++;else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t<0?e.length:t+2}else r===`,`&&/^\s*[}\]]/.test(e.slice(n+1))||(t+=r),n++}try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1}}}var r4=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`],i4=[0,95,135,175,215,255],a4=`\x1B`,o4=`\x07`,s4=RegExp(`${a4}\\[([0-9;?]*)([A-Za-z])|${a4}\\][^${o4}${a4}]*(?:${o4}|${a4}\\\\)?|${a4}[@-Z\\\\-_]`,`g`);function c4(...e){return`#${e.map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function l4(e){if(e<0||e>255)return;if(e<8)return r4[e];if(e<16)return`bright-${r4[e-8]}`;if(e<232){let t=e-16;return c4(i4[Math.floor(t/36)],i4[Math.floor(t/6)%6],i4[t%6])}let t=8+(e-232)*10;return c4(t,t,t)}function u4(e,t){if(e[t+1]===5)return[l4(e[t+2]??-1),3];if(e[t+1]===2){let[n,r,i]=e.slice(t+2,t+5);return[n===void 0||r===void 0||i===void 0?void 0:`rgb(${n},${r},${i})`,5]}return[void 0,1]}function d4(e,t){let n=t?t.split(`;`).map(e=>Number(e||0)):[0],r={...e};for(let e=0;e<n.length;e++){let t=n[e];if(t===0)r={};else if(t===1)r.bold=!0;else if(t===2)r.dim=!0;else if(t===3)r.italic=!0;else if(t===4)r.underline=!0;else if(t===22)delete r.bold,delete r.dim;else if(t===23)delete r.italic;else if(t===24)delete r.underline;else if(t>=30&&t<=37)r.fg=r4[t-30];else if(t>=90&&t<=97)r.fg=`bright-${r4[t-90]}`;else if(t>=40&&t<=47)r.bg=r4[t-40];else if(t>=100&&t<=107)r.bg=`bright-${r4[t-100]}`;else if(t===39)delete r.fg;else if(t===49)delete r.bg;else if(t===38||t===48){let[i,a]=u4(n,e);i&&(r[t===38?`fg`:`bg`]=i),e+=a-1}}return r}var f4=(e,t)=>e.fg===t.fg&&e.bg===t.bg&&e.bold===t.bold&&e.dim===t.dim&&e.italic===t.italic&&e.underline===t.underline;function p4(e){let t=[],n={},r=e=>{if(!e)return;let r=t.at(-1);r&&f4(r,n)?r.text+=e:t.push({text:e,...n})},i=0;for(let t of e.matchAll(s4))r(e.slice(i,t.index)),i=t.index+t[0].length,t[2]===`m`&&!t[1]?.includes(`?`)&&(n=d4(n,t[1]??``));return r(e.slice(i)),t}function m4(e){return e.replace(s4,``)}function h4(e){let t=[];for(let n of e.split(`
254
254
  `)){if(n.startsWith($2)){t.push({kind:`command`,text:n.slice(2)});continue}let e=t.at(-1);e?.kind===`output`?e.text+=`\n${n}`:t.push({kind:`output`,text:n})}return t}var g4=40,_4={black:`#6e7781`,red:`#d1242f`,green:`#1a7f37`,yellow:`#9a6700`,blue:`#0969da`,magenta:`#8250df`,cyan:`#1b7c83`,white:`#8c959f`,"bright-black":`#8c959f`,"bright-red":`#e5534b`,"bright-green":`#3fb950`,"bright-yellow":`#d4a72c`,"bright-blue":`#539bf5`,"bright-magenta":`#b083f0`,"bright-cyan":`#39c5cf`,"bright-white":`#adbac7`};function v4({segment:e}){let{text:t,fg:n,bg:r,bold:i,dim:a,italic:o,underline:s}=e;return!n&&!r&&!i&&!a&&!o&&!s?t:(0,K.jsx)(`span`,{style:{color:n?_4[n]??n:void 0,backgroundColor:r?_4[r]??r:void 0},className:G(i&&`font-semibold`,a&&`opacity-60`,o&&`italic`,s&&`underline`),children:t})}function y4({source:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),i=e.split(`
255
255
  `),a=!n&&i.length>g4,o=a?i.slice(-20).join(`
256
- `):e,s=(0,U.useMemo)(()=>h4(o),[o]);return(0,K.jsxs)(`div`,{"data-enso":`terminal-block`,className:`group/code relative my-2`,children:[(0,K.jsxs)(`div`,{className:`overflow-x-auto rounded-lg border bg-[var(--sunken,var(--muted))] p-3 font-mono text-(length:--chat-code-block-size) leading-relaxed`,children:[a&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`mb-1 text-[11px] text-muted-foreground hover:text-foreground`,children:t(`Show all {{count}} lines`,{count:i.length})}),s.map((e,t)=>e.kind===`command`?(0,K.jsxs)(`div`,{className:`whitespace-pre font-semibold`,children:[(0,K.jsx)(`span`,{className:`select-none text-muted-foreground`,children:`$ `}),m4(e.text)]},t):(0,K.jsx)(`div`,{className:`whitespace-pre`,children:p4(e.text).map((e,t)=>(0,K.jsx)(v4,{segment:e},t))},t))]}),(0,K.jsx)(Fs,{text:()=>m4(e),className:`absolute top-1.5 right-1.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/code:opacity-100`})]})}function b4(e){if(!e)return;let t=e.split(`:`).at(-1)??e;return/\.(\w+)$/.exec(t)?.[1]||(/^[\w-]+$/.test(e)?e:void 0)}var x4={note:{label:`Note`,border:`border-blue-500`,text:`text-blue-600 dark:text-blue-400`},tip:{label:`Tip`,border:`border-green-500`,text:`text-green-600 dark:text-green-400`},important:{label:`Important`,border:`border-purple-500`,text:`text-purple-600 dark:text-purple-400`},warning:{label:`Warning`,border:`border-amber-500`,text:`text-amber-600 dark:text-amber-400`},caution:{label:`Caution`,border:`border-red-500`,text:`text-red-600 dark:text-red-400`}};function S4(){return e=>{YX(e,`blockquote`,e=>{let t=e.children[0];if(t?.type!==`paragraph`)return;let n=t.children[0];if(n?.type!==`text`)return;let r=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i.exec(n.value);if(!r)return;n.value=n.value.slice(r[0].length),n.value||t.children.shift();let i=r[1].toLowerCase();e.data={...e.data,hProperties:{...e.data?.hProperties,"data-alert":i,dataAlert:i}}})}}var C4=/^(?:[\w.@-]+\/)+[\w.@-]+\.\w{1,8}(?::\d+(?:-\d+)?)?$|^[\w.-]+\.\w{1,8}:\d+(?:-\d+)?$/,w4=/^(?!(?:\.+\/)+$)(?:[\w.@-]+\/)+$/,T4=`rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px font-mono text-(length:--chat-inline-code-size) [font-weight:var(--chat-inline-code-weight)]`,E4=[X1,S4],D4=(0,U.createContext)({text:``,streaming:!1,searchQuery:``,activeNth:-1}),O4=(0,U.createContext)(null),k4=(0,U.createContext)(!0);function A4({text:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),i=()=>{let n=window.getSelection?.();n&&!n.isCollapsed&&n.toString()||e0(e).then(e=>{e&&(r(!0),setTimeout(()=>r(!1),1200),gD({type:`success`,title:t(`Copied`)}))})};return(0,K.jsxs)(`span`,{role:`button`,tabIndex:0,title:t(`Copy`),"data-copy-code":``,className:`group/copy relative cursor-pointer`,onClick:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())},children:[(0,K.jsx)(`code`,{className:T4,children:e}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:G(`pointer-events-none absolute -top-2.5 -right-2 inline-flex rounded-[4px] border border-border bg-background p-0.5 text-muted-foreground shadow-sm transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/copy:opacity-100`),children:n?(0,K.jsx)(gt,{className:`h-3 w-3`}):(0,K.jsx)(Pt,{className:`h-3 w-3`})})]})}function j4(e){for(let t=e.parentElement;t;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if(e===`auto`||e===`scroll`)return t}return null}function M4(e){let[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(()=>typeof IntersectionObserver!=`function`);return(0,U.useEffect)(()=>{if(!e||!t||r)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i(!0)},{root:j4(t),rootMargin:`100% 0px`});return n.observe(t),()=>n.disconnect()},[e,t,r]),[n,r]}function N4(e,t){let[n,r]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!t)return;let n=setTimeout(()=>r(e),300);return()=>clearTimeout(n)},[e,t]),!t||n===e}function P4(e,t){switch(e){case`invalid-path`:return t(`The link is outside the current workspace.`);case`unsupported`:return t(`This link is not available on the local computer.`);case`unavailable`:return t(`The linked file or folder is unavailable.`);case`unsupported-viewer`:return t(`This file format cannot be previewed inside EnsoCode.`);case`too-large`:return t(`The image is too large to preview.`);case`invalid-application`:return t(`The selected application path is invalid.`);case`application-unavailable`:return t(`VS Code is unavailable. Install it or select another application.`);default:return e}}async function F4(e,t,n,r){try{let r=H2(t,e.cwd);if(r===null)throw Error(`invalid-path`);let i=await window.electronAPI.workspaceFiles.openContext({conversationId:e.conversationId,projectId:e.projectId,rel:r,itemId:n});if(!i.ok)throw Error(i.error)}catch(e){gD({type:`error`,title:r(`Could not open local file link`),description:P4(e instanceof Error?e.message:String(e),r)})}}function I4({context:e,file:t,extra:n,children:r}){let{t:i}=q(),a=E(e=>e.contextMenuOpen),o=e?a.filter(e=>e.enabled):[];return o.length===0&&!n?r:(0,K.jsxs)(RG,{children:[(0,K.jsx)(zG,{render:r,onContextMenu:e=>e.stopPropagation()}),(0,K.jsxs)(BG,{className:`min-w-48`,children:[n,o.map(n=>{let r=n.target===`application`?(n.applicationPath.split(/[/\\]/).at(-1)??n.applicationPath).replace(/\.(?:exe|app)$/i,``):`VS Code`;return(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>e&&void F4(e,t,n.id,i),children:n.target===`reveal`?i(Z1()):i(`Open in {{app}}`,{app:r})},n.id)})]})]})}function L4(e){let t=R2(e);if(t.kind===`external`)return{classification:t,line:void 0};let n=P2(t.kind===`local`?t.path:e);return n.line&&/\.[\w]+$/.test(n.path)?{classification:R2(n.path),line:n.line}:{classification:t,line:void 0}}function R4(e){let t=e?.children;if(t?.length!==1)return null;let n=t[0],r=n.tagName===`code`&&n.children?.length===1?n.children[0]:null;return r?.type===`text`&&typeof r.value==`string`?r.value:null}function z4(e,t){let{t:n}=q(),r=(0,U.useContext)(O4),[i,a]=(0,U.useState)(null),o=e=>{gD({type:`error`,title:n(`Could not open local file link`),description:P4(e,n)})},s=r&&e!==null?U2(e,r.cwd):null,c=async e=>{if(r)try{let t=await window.electronAPI.workspaceFiles.revealExternal({conversationId:r.conversationId,projectId:r.projectId,path:e});!t.ok&&t.error!==`cancelled`&&o(t.error)}catch(e){o(e instanceof Error?e.message:String(e))}};return{linkContext:r,external:s,openLocal:async n=>{if(!r||e===null)return;let i=H2(e,r.cwd);if(i==null){s?await c(s):o(`invalid-path`);return}if(!n&&t){m0(r.conversationId,i,t);return}let l={conversationId:r.conversationId,projectId:r.projectId,rel:i};try{if(n){let e=await window.electronAPI.workspaceFiles.reveal(l);e.ok||o(e.error);return}let e=await window.electronAPI.workspaceFiles.open(l);if(!e.ok){o(e.error);return}if(e.target===`handled`)return;if(e.viewer===`image`){let t=YG(e.rel);if(!t){o(`unsupported-viewer`);return}let n=await window.electronAPI.workspaceFiles.readImage({...l,rel:e.rel});if(!n.ok){o(n.error);return}let r=`data:${t};base64,`;if(!n.dataUrl.startsWith(r)||!/^[A-Za-z0-9+/=]+$/.test(n.dataUrl.slice(r.length))){o(`unsupported-viewer`);return}a({rel:e.rel,dataUrl:n.dataUrl})}else e.viewer===`markdown`?m0(r.conversationId,e.rel,void 0,`markdown`):m0(r.conversationId,e.rel)}catch(e){o(e instanceof Error?e.message:String(e))}},preview:(0,K.jsx)(Q1,{image:i,onClose:()=>a(null)})}}function B4({path:e,children:t}){let{t:n}=q(),r=E(e=>e.contextMenuOpen.some(e=>e.enabled&&e.target===`reveal`)),{classification:i}=L4(e),a=i.kind===`local`?i.path:null,{linkContext:o,external:s,openLocal:c,preview:l}=z4(a),u=E(e=>e.projects.some(e=>e.id===o?.projectId&&e.kind===`ssh`)),d=o!==null&&a!==null&&H2(a,o.cwd)!==null,f=(0,K.jsxs)(K.Fragment,{children:[(d&&!r||!d&&s)&&!u&&(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>void c(!0),children:n(Z1())}),(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>{navigator.clipboard.writeText(a??e).then(()=>gD({type:`success`,title:n(`Copied`)}),e=>gD({type:`error`,title:n(`Copy failed`),description:e instanceof Error?e.message:String(e)}))},children:n(`Copy Path`)})]});return d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I4,{context:o,file:a??e,extra:f,children:(0,K.jsx)(`span`,{role:`link`,tabIndex:0,className:`cursor-pointer`,onClick:()=>void c(!1),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c(!1))},children:t})}),l]}):(0,K.jsx)(I4,{context:null,file:a??e,extra:f,children:(0,K.jsx)(`span`,{children:t})})}function V4({children:e,href:t,node:n}){let{t:r}=q(),{classification:i,line:a}=L4(t??``),{linkContext:o,external:s,openLocal:c,preview:l}=z4(i.kind===`local`?i.path:null,a),u=i.kind===`local`&&o!==null,d=u?R4(n):null,f=(0,U.useContext)(k4),p=u&&!s&&i.kind===`local`&&H2(i.path,o?.cwd)||null,m=z0(p?o:null,p,f),h=E(e=>e.openLinksInBuiltinBrowser&&le(e.disabledBuiltinTools,e.projects,o?.projectId,`browser`))&&o&&i.kind===`external`?N2(t):null,g=e=>{if(i.kind===`external`){if(!h||!o||(jD?e.metaKey:e.ctrlKey))return;let t=g0(o.conversationId,h.href);if(!t)return;e.preventDefault(),t.then(e=>{e.ok||gD({type:`error`,title:r(`Navigation failed`),description:e.error})});return}e.preventDefault(),u&&_()},_=async()=>{if(p&&o&&(await R0(o,p)).status!==`ok`){gD({type:`error`,title:r(`Could not open local file link`),description:P4(`unavailable`,r)});return}await c(!1)},v=(0,K.jsx)(`a`,{href:i.kind===`external`&&t||void 0,className:G(`text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand`,u&&`cursor-pointer break-all`),role:u?`link`:void 0,tabIndex:u?0:void 0,title:h?r(`{{key}}+Click to open in external browser`,{key:jD?`Cmd`:`Ctrl`}):void 0,...i.kind===`external`?{target:`_blank`,rel:`noreferrer`}:{},onClick:g,onKeyDown:e=>{u&&e.key===`Enter`&&(e.preventDefault(),_())},children:d??e});if(!u||i.kind!==`local`||!o)return v;if(!s&&m?.status!==`ok`)return d===null?(0,K.jsx)(`span`,{children:e}):p&&!m?(0,K.jsx)(`code`,{className:T4,children:d}):(0,K.jsx)(A4,{text:d});let y=s?(0,K.jsx)(I4,{context:null,file:i.path,extra:(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>void c(!0),children:r(Z1())}),children:v}):(0,K.jsx)(I4,{context:o,file:i.path,children:v});return d===null?(0,K.jsxs)(`span`,{className:`inline`,children:[y,(0,K.jsx)(`button`,{type:`button`,className:`ml-1 inline-flex rounded p-0.5 align-middle text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":r(Z1()),title:r(Z1()),onClick:()=>void c(!0),children:(0,K.jsx)(Gt,{className:`h-3.5 w-3.5`})}),l]}):(0,K.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded-[5px] border border-border/70 bg-muted/70 py-px pr-0.5 pl-1 align-baseline font-mono text-(length:--chat-inline-code-size) [font-weight:var(--chat-inline-code-weight)]`,children:[y,(0,K.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 rounded-[3px] p-0.5 text-muted-foreground hover:bg-background hover:text-foreground`,"aria-label":r(Z1()),title:r(Z1()),onClick:()=>void c(!0),children:(0,K.jsx)(Gt,{className:`h-3 w-3`})}),l]})}function H4(e,t,n=!0){let r=ZZ(e);return r||t!==`href`?r:n&&L4(e).classification.kind===`local`?e:``}var U4=`my-2 leading-[1.625] first:mt-0 last:mb-0`;function W4({children:e}){let{t}=q(),n=(0,U.useContext)(O4),r=(0,U.useContext)(k4),i=typeof e==`string`?e:``,a=w4.test(i)||C4.test(i),{path:o,line:s}=P2(i),c=a&&n&&!(w4.test(i)&&t0())&&H2(o,n.cwd)||null,l=z0(c?n:null,c,r);if(!a)return(0,K.jsx)(`code`,{className:T4,children:e});if(!c||!n||l?.status===`missing`)return(0,K.jsx)(A4,{text:i});if(!l)return(0,K.jsx)(`code`,{className:T4,children:e});if(l.kind===`dir`&&t0())return(0,K.jsx)(A4,{text:i});let u=e=>gD({type:`error`,title:t(`Could not open local file link`),description:P4(e,t)}),d=async()=>{let e=await R0(n,c);if(e.status!==`ok`){u(`unavailable`);return}if(e.kind===`file`){m0(n.conversationId,e.rel,s);return}try{let t=await window.electronAPI.workspaceFiles.reveal({conversationId:n.conversationId,projectId:n.projectId,rel:e.rel});t.ok||u(t.error)}catch(e){u(e instanceof Error?e.message:String(e))}};return(0,K.jsx)(I4,{context:n,file:l.rel,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void d(),title:i,className:`inline-flex max-w-full items-center rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px align-baseline font-mono text-(length:--chat-inline-code-size) [font-weight:var(--chat-inline-code-weight)] text-brand transition-colors hover:bg-muted`,children:(0,K.jsx)(`span`,{className:`truncate`,children:i})})})}var G4=`mt-4 mb-2 text-(length:--chat-h1-size) leading-tight [font-weight:var(--chat-h1-weight)]`,K4=`mt-4 mb-2 text-(length:--chat-h2-size) leading-tight [font-weight:var(--chat-h2-weight)]`,q4=`mt-3 mb-1.5 text-(length:--chat-h3-size) leading-tight [font-weight:var(--chat-h3-weight)]`,J4=`mt-3 mb-1 text-(length:--chat-h4-size) [font-weight:var(--chat-h4-weight)]`,Y4=`whitespace-nowrap border-b border-border px-2 py-1 text-left font-medium`,X4=`whitespace-nowrap border-b border-border/50 px-2 py-1`;function Z4({source:e,language:t,streaming:n}){let r=(0,U.useMemo)(()=>{let r=e4(t,e);if(r===`json`){let t=n4(e);return!n&&t.ok?{kind:r,value:t.value}:null}return r?{kind:r}:null},[t,e,n]);return r?.kind===`json`?(0,K.jsx)(U0,{source:e,value:r.value}):r?.kind===`terminal`?(0,K.jsx)(y4,{source:e}):(0,K.jsx)(y0,{code:e,language:t,streaming:n})}var Q4=6;function $4(e){return e.type===`text`?e.value:`children`in e?e.children.map($4).join(``):``}var e3=(e,t)=>(e?.children??[]).filter(e=>e.type===`element`&&e.tagName===t),t3=(e,t)=>U.Children.toArray(e).filter(e=>(0,U.isValidElement)(e)&&(t===void 0||e.type===t));function n3({children:e,sort:t,onSort:n}){return n?(0,K.jsx)(`th`,{className:Y4,"aria-sort":t===`asc`?`ascending`:t===`desc`?`descending`:void 0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`group/sort inline-flex items-center gap-1 hover:text-foreground`,children:[e,(0,K.jsx)(t===`desc`?ot:ct,{className:G(`h-3 w-3 shrink-0`,t===`none`?`opacity-0 group-hover/sort:opacity-40`:`opacity-70`)})]})}):(0,K.jsx)(`th`,{className:Y4,children:e})}function r3({children:e,node:t}){let{t:n}=q(),{text:r,streaming:i}=(0,U.useContext)(D4),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),l=t?.position?.start?.offset,u=t?.position?.end?.offset,d=l!==void 0&&u!==void 0?r.slice(l,u):null,f=t3(e),p=f.find(e=>e.type===`thead`),m=t3(f.find(e=>e.type===`tbody`)?.props.children,`tr`),h=(0,U.useMemo)(()=>e3(t,`tbody`).flatMap(e=>e3(e,`tr`)).map(e=>e.children.filter(e=>e.type===`element`).map($4)),[t]),g=(0,U.useMemo)(()=>K2(h),[h]),_=!i&&p!==void 0&&h.length>=2&&m.length===h.length,v=e;if(_){let e=s?.trim().toLowerCase(),t=J2(h,a,g).filter(t=>!e||h[t].join(` `).toLowerCase().includes(e)),n=t3(p.props.children,`tr`);v=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`thead`,{children:n.map((e,t)=>(0,U.cloneElement)(e,{key:e.key??t},t3(e.props.children).map((e,t)=>(0,U.cloneElement)(e,{key:e.key??t,sort:a?.column===t?a.dir:`none`,onSort:()=>o(e=>Y2(e,t))}))))}),(0,K.jsx)(`tbody`,{children:t.map(e=>m[e])})]})}let y=`rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/table:opacity-100`;return(0,K.jsxs)(`div`,{className:`group/table relative my-2 min-w-0 max-w-full`,children:[_&&s!==null&&(0,K.jsx)(`input`,{autoFocus:!0,type:`text`,onInput:e=>c(e.currentTarget.value),onKeyDown:e=>{e.key===`Escape`&&c(null)},placeholder:n(`Search table`),className:`mb-1 h-7 w-56 rounded-md border bg-background px-2 text-xs outline-none focus:border-ring`}),(0,K.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,K.jsx)(`table`,{className:`w-max min-w-full border-collapse text-(length:--chat-table-size) [font-weight:var(--chat-table-weight)] leading-[1.5] [overflow-wrap:normal]`,children:v})}),d&&!i&&(0,K.jsxs)(`div`,{className:`absolute top-0.5 right-0.5 flex gap-1`,children:[_&&h.length>=Q4&&(0,K.jsx)(`button`,{type:`button`,title:n(`Search table`),onClick:()=>c(e=>e===null?``:null),className:G(y,`hover:text-foreground`),children:(0,K.jsx)(Pn,{className:`h-3 w-3`})}),(0,K.jsx)(Fs,{text:d,className:y})]})]})}var i3={p:({children:e})=>(0,K.jsx)(m3,{className:U4,children:e}),a:V4,ul:({children:e})=>(0,K.jsx)(`ul`,{className:`my-2 list-disc space-y-1 pl-5 leading-[1.625] marker:text-muted-foreground [&_p]:leading-[1.625]`,children:e}),ol:({children:e})=>(0,K.jsx)(`ol`,{className:`my-2 list-decimal space-y-1 pl-5 leading-[1.625] marker:text-muted-foreground [&_p]:leading-[1.625]`,children:e}),h1:({children:e})=>(0,K.jsx)(`h1`,{className:G4,children:e}),h2:({children:e})=>(0,K.jsx)(`h2`,{className:K4,children:e}),h3:({children:e})=>(0,K.jsx)(`h3`,{className:q4,children:e}),h4:({children:e})=>(0,K.jsx)(`h4`,{className:J4,children:e}),h5:({children:e})=>(0,K.jsx)(`h5`,{className:J4,children:e}),h6:({children:e})=>(0,K.jsx)(`h6`,{className:J4,children:e}),blockquote:({children:e,node:t})=>{let{t:n}=q(),r=t?.properties,i=x4[String(r?.dataAlert??r?.[`data-alert`]??``)];return i?(0,K.jsxs)(`blockquote`,{className:G(`my-1.5 border-l-2 pl-3`,i.border),children:[(0,K.jsx)(`p`,{className:G(`mt-1.5 mb-0.5 text-xs font-semibold`,i.text),children:n(i.label)}),e]}):(0,K.jsx)(`blockquote`,{className:`my-2 border-l-2 border-brand/30 pl-3 text-muted-foreground`,children:e})},code:W4,pre:({node:e})=>{let{streaming:t}=(0,U.useContext)(D4),n=e?.children?.[0],r=n&&`properties`in n?n.properties:void 0,i=/language-(\S+)/.exec(r?.className?.join(` `)??``)?.[1],a=n&&`children`in n?n.children?.[0]:void 0,o=(a&&`value`in a?String(a.value):``).replace(/\n$/,``),s=b4(i),c=sO(s);return c?(0,K.jsx)(_O,{pluginId:c.pluginId,lang:c.lang,source:o}):s?.toLowerCase()===`mermaid`?(0,K.jsx)(k2,{code:o,streaming:t}):(0,K.jsx)(Z4,{source:o,language:s,streaming:t})},table:r3,th:n3,td:({children:e})=>(0,K.jsx)(`td`,{className:X4,children:e}),hr:()=>(0,K.jsx)(`hr`,{className:`my-3 border-border`})},a3=new Set([`blockquote`,`div`,`dl`,`figure`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`li`,`ol`,`p`,`pre`,`table`,`ul`]),o3=`mt-2 mb-0 leading-[1.625] first:mt-0`,s3=`empty:hidden whitespace-normal`;function c3(e){return e.type===`element`&&a3.has(e.tagName)}function l3(e,t,n){let r,i;for(let t of e?.children??[]){if(c3(t))break;let e=t.position?.start?.offset,n=t.position?.end?.offset;e!=null&&n!=null&&(r??=e,i=n)}if(r==null||i==null)return null;let a=t.slice(r,i);if(!a.trim())return null;let o=e?.position?.end?.offset??i;return{source:a,final:!n||o<t.trimEnd().length}}function u3(e,t){let n=0;for(let r of e)if(!(t&&r.type===`text`&&!r.value.trim())){if(c3(r))return n;n+=1}return null}function d3(e){let{text:t,streaming:n,leafSlot:r}=(0,U.useContext)(D4);if(!r)return null;let i=l3(e,t,n);return i?{...i,messageIndex:r.messageIndex,sessionId:r.sessionId,entry:r.entry}:null}function f3({text:e}){return(0,K.jsx)(T3,{text:e})}function p3({leaf:e}){return(0,K.jsx)(`div`,{className:s3,children:(0,K.jsx)(gO,{entry:e.entry,source:e.source,final:e.final,messageIndex:e.messageIndex,sessionId:e.sessionId,Markdown:f3})})}function m3({children:e,className:t}){let{searchQuery:n,activeNth:r}=(0,U.useContext)(D4);return(0,K.jsx)(`p`,{className:t,children:n.trim()?mU(e,n,r,{n:0}):e})}function h3({children:e,node:t}){let n=d3(t);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m3,{className:o3,children:e}),(0,K.jsx)(p3,{leaf:n})]}):(0,K.jsx)(m3,{className:U4,children:e})}function g3(e,t){return function({children:n,node:r}){let i=d3(r),a=(0,K.jsx)(e,{className:t,children:n});return i?(0,K.jsxs)(K.Fragment,{children:[a,(0,K.jsx)(p3,{leaf:i})]}):a}}function _3({tag:e,className:t,children:n,node:r}){let i=d3(r),a=e;if(!i)return(0,K.jsx)(a,{className:t,children:n});let o=u3(r?.children??[],e!==`li`),s=U.Children.toArray(n);return(0,K.jsxs)(a,{className:t,children:[o==null?s:s.slice(0,o),(0,K.jsx)(p3,{leaf:i}),o==null?null:s.slice(o)]})}var v3=g3(`h1`,G4),y3=g3(`h2`,K4),b3=g3(`h3`,q4),x3=g3(`h4`,J4),S3=g3(`h5`,J4),C3=g3(`h6`,J4),w3={...i3,p:h3,h1:v3,h2:y3,h3:b3,h4:x3,h5:S3,h6:C3,li:({children:e,node:t,className:n})=>(0,K.jsx)(_3,{tag:`li`,className:n,node:t,children:e}),th:({children:e,node:t})=>(0,K.jsx)(_3,{tag:`th`,className:Y4,node:t,children:e}),td:({children:e,node:t})=>(0,K.jsx)(_3,{tag:`td`,className:X4,node:t,children:e})};function T3({text:e,streaming:t=!1,searchQuery:n=``,activeNth:r=-1,leafSlot:i=null}){let a=(0,U.useContext)(O4)!==null,[o,s]=M4(a),c=N4(e,t),l=s&&c,u=(0,U.useMemo)(()=>({text:e,streaming:t,searchQuery:n,activeNth:r,...i?{leafSlot:i}:{}}),[e,t,n,r,i]),d=(0,U.useMemo)(()=>(e,t)=>H4(e,t,a),[a]);return(0,K.jsx)(D4.Provider,{value:u,children:(0,K.jsx)(k4.Provider,{value:l,children:(0,K.jsx)(`div`,{ref:o,className:G(`[font-weight:var(--chat-body-weight)]`,t&&`t-stream-live`),children:(0,K.jsx)(qZ,{remarkPlugins:E4,components:i?w3:i3,urlTransform:d,children:e})})})})}function E3({leaf:e,...t}){lO();let n=iO(),r=(0,U.useMemo)(()=>n?{messageIndex:e.messageIndex,sessionId:e.sessionId,entry:n}:null,[n,e.messageIndex,e.sessionId]);return(0,K.jsx)(T3,{...t,leafSlot:r})}function D3({text:e,streaming:t=!1,searchQuery:n=``,activeNth:r=-1,leaf:i}){return i?(0,K.jsx)(E3,{text:e,streaming:t,searchQuery:n,activeNth:r,leaf:i}):(0,K.jsx)(T3,{text:e,streaming:t,searchQuery:n,activeNth:r})}function O3(e){let t=(e.split(`
257
- `).map(e=>e.replace(/^[#>\-*\s]+/u,``).trim()).find(Boolean)??``).replace(/\s+/gu,` `);return t.length>60?`${t.slice(0,60)}…`:t}function k3({message:e}){let{t}=q(),n=e.username?`@${e.username}`:``;return(0,K.jsxs)(`div`,{"data-telegram-inbound":e.channel,className:`w-full rounded-lg border border-border/60 bg-muted/20 px-3 py-2 text-sm`,children:[(0,K.jsxs)(`details`,{className:`group`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(Fn,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`shrink-0`,children:e.channel===`telegram`?t(`From Telegram`):t(`From {{name}}`,{name:e.title})}),n&&(0,K.jsx)(`span`,{className:`shrink-0 text-foreground`,children:n}),e.time&&(0,K.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.time]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-normal group-open:hidden`,children:O3(e.body)})]}),(0,K.jsx)(`div`,{className:`mt-1.5 break-words`,children:(0,K.jsx)(D3,{text:e.body})})]}),e.imageLines&&(0,K.jsx)(`div`,{className:`mt-1.5`,children:(0,K.jsx)(qG,{entries:e.imageLines,align:`start`})})]})}var A3=U.createContext(void 0);function j3(e){let t=U.useContext(A3);if(t===void 0&&!e)throw Error(Cr(47));return t}var M3={...Yw,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},N3=class extends Tw{constructor(e,t,n){let r=new Hw;super(P3(e,r,t,n),F3(r),M3)}setOpen=(e,t)=>{let n=t.reason===Ry,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Iw(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};Fw(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Gs.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function P3(e,t,n,r=!1){let i={...Uw(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Ww(t,n,r),i}function F3(e){return{popupRef:U.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:U.createRef(),beforeContentFocusGuardRef:U.createRef(),stickIfOpenTimeout:new tb,triggerElements:e}}function I3({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=R3(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Vw(u,d),Rw(u);let{forceUnmount:m}=zw(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),U.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),U.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ky(Gy))}),[m,u]);let h=d||f;return(0,K.jsxs)(A3.Provider,{value:u,children:[s&&(0,K.jsx)(Pw,{handle:s,store:u}),h&&(0,K.jsx)(z3,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function L3(e){return j3(!0)?(0,K.jsx)(I3,{props:e}):(0,K.jsx)(MS,{children:(0,K.jsx)(I3,{props:e})})}function R3(e,t){let n=Nw((e,n)=>new N3(t,e,n));return U.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function z3({store:e,modal:t}){let n=KS(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return Bw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var B3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=j3(!0),h=Xw(s)??m;if(!h)throw Error(Cr(74));let g=Zy(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=U.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Lw(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=iT(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:gT(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=US(v,{stickIfOpen:T}),A=IT(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=Py({disabled:a,native:o}),P={open(e){return e&&w===`trigger-press`?$v.open(e):Qv.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=xM(h,x),R=Vr(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[hS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),ee=(0,K.jsx)(U.Fragment,{children:R},g);return C&&!D?(0,K.jsxs)(U.Fragment,{children:[(0,K.jsx)(Gb,{ref:F,onFocus:I}),ee,(0,K.jsx)(Gb,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):ee}),V3=U.createContext(void 0);function H3(){let e=U.useContext(V3);if(e===void 0)throw Error(Cr(45));return e}var U3=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return j3().useState(`mounted`)||n?(0,K.jsx)(V3.Provider,{value:n,children:(0,K.jsx)(CS,{ref:t,...r})}):null}),W3=U.createContext(void 0);function G3(){let e=U.useContext(W3);if(!e)throw Error(Cr(46));return e}var K3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=_S,..._}=e,v=j3(),y=H3(),b=AS(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=U.useRef(null),N=kw(O),P=lD({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),F=x.useState(`domReferenceElement`);X(()=>{let e=F,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[F,N,v]);let I=E===!0&&w!==`trigger-hover`;iM(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=pD(e,{open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:k},{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,L],hidden:!S,inert:!C});return(0,K.jsxs)(W3.Provider,{value:P,children:[S&&I&&(0,K.jsx)(CT,{inert:ST(!C),cutout:T}),(0,K.jsx)(jS,{id:b,children:R})]})}),q3=U.createContext(void 0);function J3(){let[e,t]=U.useState(0),n=Ay(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:U.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Y3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=j3(),l=G3(),u=Gj(!0)!=null,{context:d,hasClosePart:f}=J3(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);Aw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),rT(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?Mw(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Vr(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...jw,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&yT.has(e.key)&&e.stopPropagation()}},fD(g),s],stateAttributesMapping:ty});return(0,K.jsx)(HS,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:ly(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,K.jsx)(q3.Provider,{value:d,children:M})})}),X3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=j3(),{side:c}=G3(),l=s.useState(`instantType`),{children:u,state:d}=IM({store:s,side:c,children:a});return Vr(`div`,e,{state:{activationDirection:d.activationDirection,transitioning:d.transitioning,instant:l},ref:t,props:[o,{children:u}],stateAttributesMapping:FM})}),Z3=L3;function Q3(e){return(0,K.jsx)(B3,{"data-slot":`popover-trigger`,...e})}function $3({children:e,className:t,positionerClassName:n,side:r=`bottom`,align:i=`center`,sideOffset:a=4,alignOffset:o=0,tooltipStyle:s=!1,...c}){return(0,K.jsx)(U3,{children:(0,K.jsx)(K3,{align:i,alignOffset:o,className:G(`z-50 h-(--positioner-height) max-h-(--available-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none`,n),"data-slot":`popover-positioner`,side:r,sideOffset:a,children:(0,K.jsx)(Y3,{className:G(`relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg border bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-starting-style:scale-98 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,s&&`w-fit text-balance rounded-md text-xs shadow-black/5 shadow-md before:rounded-[calc(var(--radius-md)-1px)]`,t),"data-slot":`popover-popup`,...c,children:(0,K.jsx)(X3,{className:G(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 outline-none [--viewport-inline-padding:--spacing(4)] data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,s?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`),"data-slot":`popover-viewport`,children:e})})})})}var e6=new Map,t6;function n6(e){if(t6?.revision===e)return t6.request;let t=window.electronAPI.providers.listOauth().then(t=>{let n=new Map;for(let e of t)for(let t of e.accounts){if(typeof t.email!=`string`)continue;let e=``;for(let n of t.email){let t=n.codePointAt(0)??0;t>=32&&t!==127&&(e+=n)}e=e.trim(),e&&n.set(t.key,e)}return{revision:e,emails:n}}).catch(t=>(console.error(`Failed to load OAuth account metadata`,t),{revision:e,emails:e6})),n={revision:e,request:t,data:void 0};return t6=n,t.then(e=>{t6===n&&(n.data=e)}),t}function r6(){let e=pR(e=>e.snapshot.revision),[t,n]=(0,U.useState)(()=>t6?.revision===e?t6.data:void 0);return(0,U.useEffect)(()=>{let t=!1;return n6(e).then(e=>{t||n(e)}),()=>{t=!0}},[e]),t?.revision===e?t.emails:e6}function i6(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36)}function a6(e,t,n){return`${e}:${i6(t)}:${i6(n,1)}`}var o6=/(?:\x1b\]|\x9d)[^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c|$)/g,s6=/(?:\x1b\[|\x9b)[0-?]*[ -/]*(?:[@-~]|$)/g;function c6(e){return e.replace(o6,``).replace(s6,``)}var l6=EN()(e=>({conversationId:null,result:null,tab:`session`,from:null,open:(t,n,r)=>e({conversationId:t,result:n??null,tab:n?`result`:`session`,from:r??null}),setTab:t=>e({tab:t}),close:()=>e({conversationId:null,result:null,tab:`session`,from:null})})),u6=EN()(()=>({back:null}));function d6(e){return nP.getState().conversations[e]?.parentId??e}function f6(e){let t=nP.getState().conversations[e]?.projectId;return E.getState().projects.some(e=>e.id===t&&e.kind===`secretary`)}var p6=!1;function m6(){p6||(p6=!0,nP.subscribe((e,t)=>{if(e.activeId===t.activeId)return;let{back:n}=u6.getState();n&&(!e.activeId||d6(e.activeId)!==n.to)&&u6.setState({back:null})}))}function h6(e,t){let n=nP.getState();if(!n.conversations[e])return;let r=t??n.activeId,i=r?d6(r):null,a=d6(e);m6(),l6.getState().close(),n.selectConversation(e),u6.setState({back:i&&i!==a&&f6(i)&&!f6(a)?{from:i,to:a}:null})}var g6=`
258
- …`;function _6(e){return e.length>=32768&&e.endsWith(g6)?e.slice(0,-2):null}function v6(e){return!!(e?.role===`user`&&e.optimistic&&e.deliveryRejected&&e.deliveryId&&!e.entryId)}function y6(e){return!!(e?.role===`user`&&e.optimistic&&!e.deliveryRejected&&!e.withdrawRequested&&e.deliveryId&&!e.entryId)}var b6=EN(e=>({byConversation:{},replace:(t,n)=>e(e=>{let r={...e.byConversation};if(n.length>0)r[t]=n;else if(r[t])delete r[t];else return e;return{byConversation:r}})}));function x6(e){let t=e.toLowerCase();return t.startsWith(`image/`)?`image`:t.startsWith(`text/`)||t===`application/json`||t===`application/javascript`||t===`application/xml`||t.endsWith(`+json`)||t.endsWith(`+xml`)?`text`:`file`}function S6(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}async function C6(e){if(!window.electronAPI.remote){let t=await window.electronAPI.extensionPlugins.artifactSave(e.id);return t.ok?null:t.error}let t=await window.electronAPI.extensionPlugins.artifactRead(e.id);if(!t.ok)return t.error;let n=Uint8Array.from(atob(t.base64),e=>e.charCodeAt(0)),r=URL.createObjectURL(new Blob([n],{type:e.mime||`application/octet-stream`})),i=document.createElement(`a`);return i.href=r,i.download=e.name,i.click(),URL.revokeObjectURL(r),null}function w6({artifact:e,onDelete:t}){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(!1),c=x6(e.mime),l=async()=>{s(!0),a(null);let t=await window.electronAPI.extensionPlugins.artifactRead(e.id);if(s(!1),!t.ok){a(t.error),r(null);return}if(c===`image`){r({kind:`image`,body:`data:${t.info.mime};base64,${t.base64}`});return}if(c===`text`){r({kind:`text`,body:n0(t.base64)});return}r(null),a(`这个文件不能在这里预览`)};return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:[e.name,(0,K.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[e.mime,` · `,S6(e.size)]})]}),c!==`file`&&(0,K.jsx)(Oa,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>void l(),children:`预览`}),(0,K.jsx)(Oa,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>{s(!0),C6(e).then(e=>{s(!1),a(e)})},children:window.electronAPI.remote?`下载`:`另存`}),t&&(0,K.jsx)(Oa,{size:`sm`,variant:`ghost`,onClick:()=>t(e.id),children:`删除`})]}),i&&(0,K.jsx)(`p`,{className:`text-destructive text-xs`,children:i}),n?.kind===`text`&&(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all font-mono text-muted-foreground text-xs`,children:n.body}),n?.kind===`image`&&(0,K.jsx)(`img`,{src:n.body,alt:e.name,className:`max-h-48 max-w-full rounded border object-contain`})]})}function T6({artifacts:e,onDelete:t}){return e.length===0?(0,K.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`还没有产出文件`}):(0,K.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,K.jsx)(w6,{artifact:e,onDelete:t},e.id))})}function E6({artifacts:e,align:t=`tool-row`}){return(0,K.jsxs)(`div`,{className:G(`mt-1 mb-1.5 rounded-lg border border-border/70 bg-card px-3 py-2`,t===`card`?`w-full`:`ml-[30px]`),children:[(0,K.jsx)(`p`,{className:`mb-1 text-[11px] text-muted-foreground`,children:`产出文件`}),(0,K.jsx)(T6,{artifacts:e})]})}var D6={},O6=new Set,k6=new Map;function A6(e){return O6.add(e),()=>O6.delete(e)}function j6(e,t){let n=`${e}\0${t}`,r=k6.get(n);return r||(r=window.electronAPI.extensionPlugins.asset(e,t).then(e=>e.ok?`data:${e.mime};base64,${e.base64}`:null).catch(()=>null),r.then(e=>e===null&&k6.delete(n)),k6.set(n,r)),r}function M6({pluginId:e,icon:t,className:n}){let r=(0,U.useSyncExternalStore)(A6,()=>D6[e]),i=t??r,[a,o]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(o(null),!i)return;let t=!0;return j6(e,i).then(e=>t&&o(e)),()=>{t=!1}},[e,i]),a?(0,K.jsx)(`img`,{src:a,alt:``,className:G(`object-contain`,n)}):(0,K.jsx)(On,{className:n})}var N6={read_only:`Read-only`,regenerable:`Regenerable output`,reversible_workspace_change:`Reversible workspace change`,data_loss:`Possible data loss`,system_state:`Changes system state`,exfiltration:`Sends data externally`,unclear_target:`Unclear target or intent`};function P6({value:e}){let t=we(e),{t:n}=q();if(!t)return null;let r=`allow ${t.allow.toFixed(2)} · ask ${t.ask.toFixed(2)} · block ${t.block.toFixed(2)}`;return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 border-border/60 border-t px-3 py-1 text-[10px] text-muted-foreground`,"data-approval-review":t.verdict,children:[(0,K.jsx)(`span`,{className:`font-semibold tracking-wide text-foreground/75`,children:t.verdict===`allow`?n(`Auto-managed · allowed`):n(`Auto-managed · denied`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono`,children:t.model}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono`,children:r}),t.reason&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`span`,{children:[n(`Reason`),`: `,n(N6[t.reason])]})]})]})}function F6({ask:e,waiting:t}){let{t:n}=q(),r=e.answer!==null&&!e.options.includes(e.answer)?e.answer:null;return(0,K.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2 text-xs`,children:[(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words leading-relaxed text-foreground`,children:e.question}),(e.options.length>0||r!==null)&&(0,K.jsxs)(`ul`,{className:`space-y-0.5`,children:[e.options.map(t=>(0,K.jsx)(I6,{selected:t===e.answer,text:t},t)),r!==null&&(0,K.jsx)(I6,{selected:!0,text:r,label:e.options.length>0&&!e.autoSelected?n(`Custom answer`):void 0})]}),e.autoSelected&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:n(`No answer in time; the default was selected`)}),t&&e.answer===null&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:n(`Waiting for your answer`)})]})}function I6({selected:e,text:t,label:n}){let{t:r}=q(),i=e?Ct:Ot;return(0,K.jsxs)(`li`,{"data-selected":e||void 0,className:G(`flex items-start gap-1.5 rounded-md px-2 py-1 leading-relaxed`,e?`bg-primary/10 text-foreground`:`text-muted-foreground`),children:[(0,K.jsx)(i,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,e?`text-primary`:`opacity-40`)}),(0,K.jsxs)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:[n&&(0,K.jsx)(`span`,{className:`mr-1.5 text-muted-foreground`,children:n}),t]}),e&&(0,K.jsx)(`span`,{className:`sr-only`,children:r(`Selected`)})]})}var L6=/^Subagent ".*" \(agentId [^,\s]+, runId [^)\s]+\) \S+ after .+\.$/gm,R6=/^The following is the subagent's report: .*$\n?/m,z6=/<usage>([\s\S]*?)<\/usage>/,B6=/^Background tasks this subagent started\b.*\n((?:- .*(?:\n|$))+)/m,V6=(e,t)=>{let n=RegExp(`^${t}: (\\d+)$`,`m`).exec(e);return n?Number(n[1]):null};function H6(e){let t=e.indexOf(`
256
+ `):e,s=(0,U.useMemo)(()=>h4(o),[o]);return(0,K.jsxs)(`div`,{"data-enso":`terminal-block`,className:`group/code relative my-2`,children:[(0,K.jsxs)(`div`,{className:`overflow-x-auto rounded-lg border bg-[var(--sunken,var(--muted))] p-3 font-mono text-(length:--chat-code-block-size) leading-relaxed`,children:[a&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`mb-1 text-[11px] text-muted-foreground hover:text-foreground`,children:t(`Show all {{count}} lines`,{count:i.length})}),s.map((e,t)=>e.kind===`command`?(0,K.jsxs)(`div`,{className:`whitespace-pre font-semibold`,children:[(0,K.jsx)(`span`,{className:`select-none text-muted-foreground`,children:`$ `}),m4(e.text)]},t):(0,K.jsx)(`div`,{className:`whitespace-pre`,children:p4(e.text).map((e,t)=>(0,K.jsx)(v4,{segment:e},t))},t))]}),(0,K.jsx)(Fs,{text:()=>m4(e),className:`absolute top-1.5 right-1.5 rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/code:opacity-100`})]})}function b4(e){if(!e)return;let t=e.split(`:`).at(-1)??e;return/\.(\w+)$/.exec(t)?.[1]||(/^[\w-]+$/.test(e)?e:void 0)}var x4={note:{label:`Note`,border:`border-blue-500`,text:`text-blue-600 dark:text-blue-400`},tip:{label:`Tip`,border:`border-green-500`,text:`text-green-600 dark:text-green-400`},important:{label:`Important`,border:`border-purple-500`,text:`text-purple-600 dark:text-purple-400`},warning:{label:`Warning`,border:`border-amber-500`,text:`text-amber-600 dark:text-amber-400`},caution:{label:`Caution`,border:`border-red-500`,text:`text-red-600 dark:text-red-400`}};function S4(){return e=>{YX(e,`blockquote`,e=>{let t=e.children[0];if(t?.type!==`paragraph`)return;let n=t.children[0];if(n?.type!==`text`)return;let r=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i.exec(n.value);if(!r)return;n.value=n.value.slice(r[0].length),n.value||t.children.shift();let i=r[1].toLowerCase();e.data={...e.data,hProperties:{...e.data?.hProperties,"data-alert":i,dataAlert:i}}})}}var C4=/^(?:[\w.@-]+\/)+[\w.@-]+\.\w{1,8}(?::\d+(?:-\d+)?)?$|^[\w.-]+\.\w{1,8}:\d+(?:-\d+)?$/,w4=/^(?!(?:\.+\/)+$)(?:[\w.@-]+\/)+$/,T4=`rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px font-mono text-(length:--chat-inline-code-size) [font-weight:var(--chat-inline-code-weight)]`,E4=[X1,S4],D4=(0,U.createContext)({text:``,streaming:!1,searchQuery:``,activeNth:-1}),O4=(0,U.createContext)(null),k4=(0,U.createContext)(!0);function A4({text:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),i=()=>{let n=window.getSelection?.();n&&!n.isCollapsed&&n.toString()||e0(e).then(e=>{e&&(r(!0),setTimeout(()=>r(!1),1200),hD({type:`success`,title:t(`Copied`)}))})};return(0,K.jsxs)(`span`,{role:`button`,tabIndex:0,title:t(`Copy`),"data-copy-code":``,className:`group/copy relative cursor-pointer`,onClick:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())},children:[(0,K.jsx)(`code`,{className:T4,children:e}),(0,K.jsx)(`span`,{"aria-hidden":!0,className:G(`pointer-events-none absolute -top-2.5 -right-2 inline-flex rounded-[4px] border border-border bg-background p-0.5 text-muted-foreground shadow-sm transition-opacity`,n?`opacity-100`:`opacity-0 group-hover/copy:opacity-100`),children:n?(0,K.jsx)(gt,{className:`h-3 w-3`}):(0,K.jsx)(Pt,{className:`h-3 w-3`})})]})}function j4(e){for(let t=e.parentElement;t;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if(e===`auto`||e===`scroll`)return t}return null}function M4(e){let[t,n]=(0,U.useState)(null),[r,i]=(0,U.useState)(()=>typeof IntersectionObserver!=`function`);return(0,U.useEffect)(()=>{if(!e||!t||r)return;let n=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i(!0)},{root:j4(t),rootMargin:`100% 0px`});return n.observe(t),()=>n.disconnect()},[e,t,r]),[n,r]}function N4(e,t){let[n,r]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(!t)return;let n=setTimeout(()=>r(e),300);return()=>clearTimeout(n)},[e,t]),!t||n===e}function P4(e,t){switch(e){case`invalid-path`:return t(`The link is outside the current workspace.`);case`unsupported`:return t(`This link is not available on the local computer.`);case`unavailable`:return t(`The linked file or folder is unavailable.`);case`unsupported-viewer`:return t(`This file format cannot be previewed inside EnsoCode.`);case`too-large`:return t(`The image is too large to preview.`);case`invalid-application`:return t(`The selected application path is invalid.`);case`application-unavailable`:return t(`VS Code is unavailable. Install it or select another application.`);default:return e}}async function F4(e,t,n,r){try{let r=H2(t,e.cwd);if(r===null)throw Error(`invalid-path`);let i=await window.electronAPI.workspaceFiles.openContext({conversationId:e.conversationId,projectId:e.projectId,rel:r,itemId:n});if(!i.ok)throw Error(i.error)}catch(e){hD({type:`error`,title:r(`Could not open local file link`),description:P4(e instanceof Error?e.message:String(e),r)})}}function I4({context:e,file:t,extra:n,children:r}){let{t:i}=q(),a=E(e=>e.contextMenuOpen),o=e?a.filter(e=>e.enabled):[];return o.length===0&&!n?r:(0,K.jsxs)(RG,{children:[(0,K.jsx)(zG,{render:r,onContextMenu:e=>e.stopPropagation()}),(0,K.jsxs)(BG,{className:`min-w-48`,children:[n,o.map(n=>{let r=n.target===`application`?(n.applicationPath.split(/[/\\]/).at(-1)??n.applicationPath).replace(/\.(?:exe|app)$/i,``):`VS Code`;return(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>e&&void F4(e,t,n.id,i),children:n.target===`reveal`?i(Z1()):i(`Open in {{app}}`,{app:r})},n.id)})]})]})}function L4(e){let t=R2(e);if(t.kind===`external`)return{classification:t,line:void 0};let n=P2(t.kind===`local`?t.path:e);return n.line&&/\.[\w]+$/.test(n.path)?{classification:R2(n.path),line:n.line}:{classification:t,line:void 0}}function R4(e){let t=e?.children;if(t?.length!==1)return null;let n=t[0],r=n.tagName===`code`&&n.children?.length===1?n.children[0]:null;return r?.type===`text`&&typeof r.value==`string`?r.value:null}function z4(e,t){let{t:n}=q(),r=(0,U.useContext)(O4),[i,a]=(0,U.useState)(null),o=e=>{hD({type:`error`,title:n(`Could not open local file link`),description:P4(e,n)})},s=r&&e!==null?U2(e,r.cwd):null,c=async e=>{if(r)try{let t=await window.electronAPI.workspaceFiles.revealExternal({conversationId:r.conversationId,projectId:r.projectId,path:e});!t.ok&&t.error!==`cancelled`&&o(t.error)}catch(e){o(e instanceof Error?e.message:String(e))}};return{linkContext:r,external:s,openLocal:async n=>{if(!r||e===null)return;let i=H2(e,r.cwd);if(i==null){s?await c(s):o(`invalid-path`);return}if(!n&&t){m0(r.conversationId,i,t);return}let l={conversationId:r.conversationId,projectId:r.projectId,rel:i};try{if(n){let e=await window.electronAPI.workspaceFiles.reveal(l);e.ok||o(e.error);return}let e=await window.electronAPI.workspaceFiles.open(l);if(!e.ok){o(e.error);return}if(e.target===`handled`)return;if(e.viewer===`image`){let t=YG(e.rel);if(!t){o(`unsupported-viewer`);return}let n=await window.electronAPI.workspaceFiles.readImage({...l,rel:e.rel});if(!n.ok){o(n.error);return}let r=`data:${t};base64,`;if(!n.dataUrl.startsWith(r)||!/^[A-Za-z0-9+/=]+$/.test(n.dataUrl.slice(r.length))){o(`unsupported-viewer`);return}a({rel:e.rel,dataUrl:n.dataUrl})}else e.viewer===`markdown`?m0(r.conversationId,e.rel,void 0,`markdown`):m0(r.conversationId,e.rel)}catch(e){o(e instanceof Error?e.message:String(e))}},preview:(0,K.jsx)(Q1,{image:i,onClose:()=>a(null)})}}function B4({path:e,children:t}){let{t:n}=q(),r=E(e=>e.contextMenuOpen.some(e=>e.enabled&&e.target===`reveal`)),{classification:i}=L4(e),a=i.kind===`local`?i.path:null,{linkContext:o,external:s,openLocal:c,preview:l}=z4(a),u=E(e=>e.projects.some(e=>e.id===o?.projectId&&e.kind===`ssh`)),d=o!==null&&a!==null&&H2(a,o.cwd)!==null,f=(0,K.jsxs)(K.Fragment,{children:[(d&&!r||!d&&s)&&!u&&(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>void c(!0),children:n(Z1())}),(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>{navigator.clipboard.writeText(a??e).then(()=>hD({type:`success`,title:n(`Copied`)}),e=>hD({type:`error`,title:n(`Copy failed`),description:e instanceof Error?e.message:String(e)}))},children:n(`Copy Path`)})]});return d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I4,{context:o,file:a??e,extra:f,children:(0,K.jsx)(`span`,{role:`link`,tabIndex:0,className:`cursor-pointer`,onClick:()=>void c(!1),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c(!1))},children:t})}),l]}):(0,K.jsx)(I4,{context:null,file:a??e,extra:f,children:(0,K.jsx)(`span`,{children:t})})}function V4({children:e,href:t,node:n}){let{t:r}=q(),{classification:i,line:a}=L4(t??``),{linkContext:o,external:s,openLocal:c,preview:l}=z4(i.kind===`local`?i.path:null,a),u=i.kind===`local`&&o!==null,d=u?R4(n):null,f=(0,U.useContext)(k4),p=u&&!s&&i.kind===`local`&&H2(i.path,o?.cwd)||null,m=z0(p?o:null,p,f),h=E(e=>e.openLinksInBuiltinBrowser&&le(e.disabledBuiltinTools,e.projects,o?.projectId,`browser`))&&o&&i.kind===`external`?N2(t):null,g=e=>{if(i.kind===`external`){if(!h||!o||(AD?e.metaKey:e.ctrlKey))return;let t=g0(o.conversationId,h.href);if(!t)return;e.preventDefault(),t.then(e=>{e.ok||hD({type:`error`,title:r(`Navigation failed`),description:e.error})});return}e.preventDefault(),u&&_()},_=async()=>{if(p&&o&&(await R0(o,p)).status!==`ok`){hD({type:`error`,title:r(`Could not open local file link`),description:P4(`unavailable`,r)});return}await c(!1)},v=(0,K.jsx)(`a`,{href:i.kind===`external`&&t||void 0,className:G(`text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand`,u&&`cursor-pointer break-all`),role:u?`link`:void 0,tabIndex:u?0:void 0,title:h?r(`{{key}}+Click to open in external browser`,{key:AD?`Cmd`:`Ctrl`}):void 0,...i.kind===`external`?{target:`_blank`,rel:`noreferrer`}:{},onClick:g,onKeyDown:e=>{u&&e.key===`Enter`&&(e.preventDefault(),_())},children:d??e});if(!u||i.kind!==`local`||!o)return v;if(!s&&m?.status!==`ok`)return d===null?(0,K.jsx)(`span`,{children:e}):p&&!m?(0,K.jsx)(`code`,{className:T4,children:d}):(0,K.jsx)(A4,{text:d});let y=s?(0,K.jsx)(I4,{context:null,file:i.path,extra:(0,K.jsx)(VG,{closeOnClick:!0,onClick:()=>void c(!0),children:r(Z1())}),children:v}):(0,K.jsx)(I4,{context:o,file:i.path,children:v});return d===null?(0,K.jsxs)(`span`,{className:`inline`,children:[y,(0,K.jsx)(`button`,{type:`button`,className:`ml-1 inline-flex rounded p-0.5 align-middle text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":r(Z1()),title:r(Z1()),onClick:()=>void c(!0),children:(0,K.jsx)(Gt,{className:`h-3.5 w-3.5`})}),l]}):(0,K.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-0.5 rounded-[5px] border border-border/70 bg-muted/70 py-px pr-0.5 pl-1 align-baseline font-mono text-(length:--chat-inline-code-size) [font-weight:var(--chat-inline-code-weight)]`,children:[y,(0,K.jsx)(`button`,{type:`button`,className:`inline-flex shrink-0 rounded-[3px] p-0.5 text-muted-foreground hover:bg-background hover:text-foreground`,"aria-label":r(Z1()),title:r(Z1()),onClick:()=>void c(!0),children:(0,K.jsx)(Gt,{className:`h-3 w-3`})}),l]})}function H4(e,t,n=!0){let r=ZZ(e);return r||t!==`href`?r:n&&L4(e).classification.kind===`local`?e:``}var U4=`my-2 leading-[1.625] first:mt-0 last:mb-0`;function W4({children:e}){let{t}=q(),n=(0,U.useContext)(O4),r=(0,U.useContext)(k4),i=typeof e==`string`?e:``,a=w4.test(i)||C4.test(i),{path:o,line:s}=P2(i),c=a&&n&&!(w4.test(i)&&t0())&&H2(o,n.cwd)||null,l=z0(c?n:null,c,r);if(!a)return(0,K.jsx)(`code`,{className:T4,children:e});if(!c||!n||l?.status===`missing`)return(0,K.jsx)(A4,{text:i});if(!l)return(0,K.jsx)(`code`,{className:T4,children:e});if(l.kind===`dir`&&t0())return(0,K.jsx)(A4,{text:i});let u=e=>hD({type:`error`,title:t(`Could not open local file link`),description:P4(e,t)}),d=async()=>{let e=await R0(n,c);if(e.status!==`ok`){u(`unavailable`);return}if(e.kind===`file`){m0(n.conversationId,e.rel,s);return}try{let t=await window.electronAPI.workspaceFiles.reveal({conversationId:n.conversationId,projectId:n.projectId,rel:e.rel});t.ok||u(t.error)}catch(e){u(e instanceof Error?e.message:String(e))}};return(0,K.jsx)(I4,{context:n,file:l.rel,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>void d(),title:i,className:`inline-flex max-w-full items-center rounded-[5px] border border-border/70 bg-muted/70 px-1 py-px align-baseline font-mono text-(length:--chat-inline-code-size) [font-weight:var(--chat-inline-code-weight)] text-brand transition-colors hover:bg-muted`,children:(0,K.jsx)(`span`,{className:`truncate`,children:i})})})}var G4=`mt-4 mb-2 text-(length:--chat-h1-size) leading-tight [font-weight:var(--chat-h1-weight)]`,K4=`mt-4 mb-2 text-(length:--chat-h2-size) leading-tight [font-weight:var(--chat-h2-weight)]`,q4=`mt-3 mb-1.5 text-(length:--chat-h3-size) leading-tight [font-weight:var(--chat-h3-weight)]`,J4=`mt-3 mb-1 text-(length:--chat-h4-size) [font-weight:var(--chat-h4-weight)]`,Y4=`whitespace-nowrap border-b border-border px-2 py-1 text-left font-medium`,X4=`whitespace-nowrap border-b border-border/50 px-2 py-1`;function Z4({source:e,language:t,streaming:n}){let r=(0,U.useMemo)(()=>{let r=e4(t,e);if(r===`json`){let t=n4(e);return!n&&t.ok?{kind:r,value:t.value}:null}return r?{kind:r}:null},[t,e,n]);return r?.kind===`json`?(0,K.jsx)(U0,{source:e,value:r.value}):r?.kind===`terminal`?(0,K.jsx)(y4,{source:e}):(0,K.jsx)(y0,{code:e,language:t,streaming:n})}var Q4=6;function $4(e){return e.type===`text`?e.value:`children`in e?e.children.map($4).join(``):``}var e3=(e,t)=>(e?.children??[]).filter(e=>e.type===`element`&&e.tagName===t),t3=(e,t)=>U.Children.toArray(e).filter(e=>(0,U.isValidElement)(e)&&(t===void 0||e.type===t));function n3({children:e,sort:t,onSort:n}){return n?(0,K.jsx)(`th`,{className:Y4,"aria-sort":t===`asc`?`ascending`:t===`desc`?`descending`:void 0,children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`group/sort inline-flex items-center gap-1 hover:text-foreground`,children:[e,(0,K.jsx)(t===`desc`?ot:ct,{className:G(`h-3 w-3 shrink-0`,t===`none`?`opacity-0 group-hover/sort:opacity-40`:`opacity-70`)})]})}):(0,K.jsx)(`th`,{className:Y4,children:e})}function r3({children:e,node:t}){let{t:n}=q(),{text:r,streaming:i}=(0,U.useContext)(D4),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),l=t?.position?.start?.offset,u=t?.position?.end?.offset,d=l!==void 0&&u!==void 0?r.slice(l,u):null,f=t3(e),p=f.find(e=>e.type===`thead`),m=t3(f.find(e=>e.type===`tbody`)?.props.children,`tr`),h=(0,U.useMemo)(()=>e3(t,`tbody`).flatMap(e=>e3(e,`tr`)).map(e=>e.children.filter(e=>e.type===`element`).map($4)),[t]),g=(0,U.useMemo)(()=>K2(h),[h]),_=!i&&p!==void 0&&h.length>=2&&m.length===h.length,v=e;if(_){let e=s?.trim().toLowerCase(),t=J2(h,a,g).filter(t=>!e||h[t].join(` `).toLowerCase().includes(e)),n=t3(p.props.children,`tr`);v=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`thead`,{children:n.map((e,t)=>(0,U.cloneElement)(e,{key:e.key??t},t3(e.props.children).map((e,t)=>(0,U.cloneElement)(e,{key:e.key??t,sort:a?.column===t?a.dir:`none`,onSort:()=>o(e=>Y2(e,t))}))))}),(0,K.jsx)(`tbody`,{children:t.map(e=>m[e])})]})}let y=`rounded-md border bg-background/80 p-1.5 text-muted-foreground opacity-0 backdrop-blur transition-opacity group-hover/table:opacity-100`;return(0,K.jsxs)(`div`,{className:`group/table relative my-2 min-w-0 max-w-full`,children:[_&&s!==null&&(0,K.jsx)(`input`,{autoFocus:!0,type:`text`,onInput:e=>c(e.currentTarget.value),onKeyDown:e=>{e.key===`Escape`&&c(null)},placeholder:n(`Search table`),className:`mb-1 h-7 w-56 rounded-md border bg-background px-2 text-xs outline-none focus:border-ring`}),(0,K.jsx)(`div`,{className:`overflow-x-auto overscroll-x-contain [-webkit-overflow-scrolling:touch]`,children:(0,K.jsx)(`table`,{className:`w-max min-w-full border-collapse text-(length:--chat-table-size) [font-weight:var(--chat-table-weight)] leading-[1.5] [overflow-wrap:normal]`,children:v})}),d&&!i&&(0,K.jsxs)(`div`,{className:`absolute top-0.5 right-0.5 flex gap-1`,children:[_&&h.length>=Q4&&(0,K.jsx)(`button`,{type:`button`,title:n(`Search table`),onClick:()=>c(e=>e===null?``:null),className:G(y,`hover:text-foreground`),children:(0,K.jsx)(Pn,{className:`h-3 w-3`})}),(0,K.jsx)(Fs,{text:d,className:y})]})]})}var i3={p:({children:e})=>(0,K.jsx)(m3,{className:U4,children:e}),a:V4,ul:({children:e})=>(0,K.jsx)(`ul`,{className:`my-2 list-disc space-y-1 pl-5 leading-[1.625] marker:text-muted-foreground [&_p]:leading-[1.625]`,children:e}),ol:({children:e})=>(0,K.jsx)(`ol`,{className:`my-2 list-decimal space-y-1 pl-5 leading-[1.625] marker:text-muted-foreground [&_p]:leading-[1.625]`,children:e}),h1:({children:e})=>(0,K.jsx)(`h1`,{className:G4,children:e}),h2:({children:e})=>(0,K.jsx)(`h2`,{className:K4,children:e}),h3:({children:e})=>(0,K.jsx)(`h3`,{className:q4,children:e}),h4:({children:e})=>(0,K.jsx)(`h4`,{className:J4,children:e}),h5:({children:e})=>(0,K.jsx)(`h5`,{className:J4,children:e}),h6:({children:e})=>(0,K.jsx)(`h6`,{className:J4,children:e}),blockquote:({children:e,node:t})=>{let{t:n}=q(),r=t?.properties,i=x4[String(r?.dataAlert??r?.[`data-alert`]??``)];return i?(0,K.jsxs)(`blockquote`,{className:G(`my-1.5 border-l-2 pl-3`,i.border),children:[(0,K.jsx)(`p`,{className:G(`mt-1.5 mb-0.5 text-xs font-semibold`,i.text),children:n(i.label)}),e]}):(0,K.jsx)(`blockquote`,{className:`my-2 border-l-2 border-brand/30 pl-3 text-muted-foreground`,children:e})},code:W4,pre:({node:e})=>{let{streaming:t}=(0,U.useContext)(D4),n=e?.children?.[0],r=n&&`properties`in n?n.properties:void 0,i=/language-(\S+)/.exec(r?.className?.join(` `)??``)?.[1],a=n&&`children`in n?n.children?.[0]:void 0,o=(a&&`value`in a?String(a.value):``).replace(/\n$/,``),s=b4(i),c=oO(s);return c?(0,K.jsx)(gO,{pluginId:c.pluginId,lang:c.lang,source:o}):s?.toLowerCase()===`mermaid`?(0,K.jsx)(k2,{code:o,streaming:t}):(0,K.jsx)(Z4,{source:o,language:s,streaming:t})},table:r3,th:n3,td:({children:e})=>(0,K.jsx)(`td`,{className:X4,children:e}),hr:()=>(0,K.jsx)(`hr`,{className:`my-3 border-border`})},a3=new Set([`blockquote`,`div`,`dl`,`figure`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`li`,`ol`,`p`,`pre`,`table`,`ul`]),o3=`mt-2 mb-0 leading-[1.625] first:mt-0`,s3=`empty:hidden whitespace-normal`;function c3(e){return e.type===`element`&&a3.has(e.tagName)}function l3(e,t,n){let r,i;for(let t of e?.children??[]){if(c3(t))break;let e=t.position?.start?.offset,n=t.position?.end?.offset;e!=null&&n!=null&&(r??=e,i=n)}if(r==null||i==null)return null;let a=t.slice(r,i);if(!a.trim())return null;let o=e?.position?.end?.offset??i;return{source:a,final:!n||o<t.trimEnd().length}}function u3(e,t){let n=0;for(let r of e)if(!(t&&r.type===`text`&&!r.value.trim())){if(c3(r))return n;n+=1}return null}function d3(e){let{text:t,streaming:n,leafSlot:r}=(0,U.useContext)(D4);if(!r)return null;let i=l3(e,t,n);return i?{...i,messageIndex:r.messageIndex,sessionId:r.sessionId,entry:r.entry}:null}function f3({text:e}){return(0,K.jsx)(T3,{text:e})}function p3({leaf:e}){return(0,K.jsx)(`div`,{className:s3,children:(0,K.jsx)(hO,{entry:e.entry,source:e.source,final:e.final,messageIndex:e.messageIndex,sessionId:e.sessionId,Markdown:f3})})}function m3({children:e,className:t}){let{searchQuery:n,activeNth:r}=(0,U.useContext)(D4);return(0,K.jsx)(`p`,{className:t,children:n.trim()?mU(e,n,r,{n:0}):e})}function h3({children:e,node:t}){let n=d3(t);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m3,{className:o3,children:e}),(0,K.jsx)(p3,{leaf:n})]}):(0,K.jsx)(m3,{className:U4,children:e})}function g3(e,t){return function({children:n,node:r}){let i=d3(r),a=(0,K.jsx)(e,{className:t,children:n});return i?(0,K.jsxs)(K.Fragment,{children:[a,(0,K.jsx)(p3,{leaf:i})]}):a}}function _3({tag:e,className:t,children:n,node:r}){let i=d3(r),a=e;if(!i)return(0,K.jsx)(a,{className:t,children:n});let o=u3(r?.children??[],e!==`li`),s=U.Children.toArray(n);return(0,K.jsxs)(a,{className:t,children:[o==null?s:s.slice(0,o),(0,K.jsx)(p3,{leaf:i}),o==null?null:s.slice(o)]})}var v3=g3(`h1`,G4),y3=g3(`h2`,K4),b3=g3(`h3`,q4),x3=g3(`h4`,J4),S3=g3(`h5`,J4),C3=g3(`h6`,J4),w3={...i3,p:h3,h1:v3,h2:y3,h3:b3,h4:x3,h5:S3,h6:C3,li:({children:e,node:t,className:n})=>(0,K.jsx)(_3,{tag:`li`,className:n,node:t,children:e}),th:({children:e,node:t})=>(0,K.jsx)(_3,{tag:`th`,className:Y4,node:t,children:e}),td:({children:e,node:t})=>(0,K.jsx)(_3,{tag:`td`,className:X4,node:t,children:e})};function T3({text:e,streaming:t=!1,searchQuery:n=``,activeNth:r=-1,leafSlot:i=null}){let a=(0,U.useContext)(O4)!==null,[o,s]=M4(a),c=N4(e,t),l=s&&c,u=(0,U.useMemo)(()=>({text:e,streaming:t,searchQuery:n,activeNth:r,...i?{leafSlot:i}:{}}),[e,t,n,r,i]),d=(0,U.useMemo)(()=>(e,t)=>H4(e,t,a),[a]);return(0,K.jsx)(D4.Provider,{value:u,children:(0,K.jsx)(k4.Provider,{value:l,children:(0,K.jsx)(`div`,{ref:o,className:G(`[font-weight:var(--chat-body-weight)]`,t&&`t-stream-live`),children:(0,K.jsx)(qZ,{remarkPlugins:E4,components:i?w3:i3,urlTransform:d,children:e})})})})}function E3({leaf:e,...t}){cO();let n=rO(),r=(0,U.useMemo)(()=>n?{messageIndex:e.messageIndex,sessionId:e.sessionId,entry:n}:null,[n,e.messageIndex,e.sessionId]);return(0,K.jsx)(T3,{...t,leafSlot:r})}function D3({text:e,streaming:t=!1,searchQuery:n=``,activeNth:r=-1,leaf:i}){return i?(0,K.jsx)(E3,{text:e,streaming:t,searchQuery:n,activeNth:r,leaf:i}):(0,K.jsx)(T3,{text:e,streaming:t,searchQuery:n,activeNth:r})}function O3(e){let t=(e.split(`
257
+ `).map(e=>e.replace(/^[#>\-*\s]+/u,``).trim()).find(Boolean)??``).replace(/\s+/gu,` `);return t.length>60?`${t.slice(0,60)}…`:t}function k3({message:e}){let{t}=q(),n=e.username?`@${e.username}`:``;return(0,K.jsxs)(`div`,{"data-telegram-inbound":e.channel,className:`w-full rounded-lg border border-border/60 bg-muted/20 px-3 py-2 text-sm`,children:[(0,K.jsxs)(`details`,{className:`group`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(Fn,{className:`size-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`shrink-0`,children:e.channel===`telegram`?t(`From Telegram`):t(`From {{name}}`,{name:e.title})}),n&&(0,K.jsx)(`span`,{className:`shrink-0 text-foreground`,children:n}),e.time&&(0,K.jsxs)(`span`,{className:`shrink-0`,children:[`· `,e.time]}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-normal group-open:hidden`,children:O3(e.body)})]}),(0,K.jsx)(`div`,{className:`mt-1.5 break-words`,children:(0,K.jsx)(D3,{text:e.body})})]}),e.imageLines&&(0,K.jsx)(`div`,{className:`mt-1.5`,children:(0,K.jsx)(qG,{entries:e.imageLines,align:`start`})})]})}var A3=U.createContext(void 0);function j3(e){let t=U.useContext(A3);if(t===void 0&&!e)throw Error(Cr(47));return t}var M3={...Jw,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},N3=class extends ww{constructor(e,t,n){let r=new Vw;super(P3(e,r,t,n),F3(r),M3)}setOpen=(e,t)=>{let n=t.reason===Ry,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Fw(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};Pw(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),Gs.flushSync(s)):s();let c;r?c=`click`:i?c=`dismiss`:t.reason===`focus-out`&&(c=`focus`),this.set(`instantType`,c)}};function P3(e,t,n,r=!1){let i={...Hw(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return i.open&&e?.mounted===void 0&&(i.mounted=!0),i.floatingRootContext=Uw(t,n,r),i}function F3(e){return{popupRef:U.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:U.createRef(),beforeContentFocusGuardRef:U.createRef(),stickIfOpenTimeout:new tb,triggerElements:e}}function I3({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=R3(s,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`);u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),Bw(u,d),Lw(u);let{forceUnmount:m}=Rw(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o}),U.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]),U.useImperativeHandle(e.actionsRef,()=>({unmount:m,close:()=>u.setOpen(!1,Ky(Gy))}),[m,u]);let h=d||f;return(0,K.jsxs)(A3.Provider,{value:u,children:[s&&(0,K.jsx)(Nw,{handle:s,store:u}),h&&(0,K.jsx)(z3,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function L3(e){return j3(!0)?(0,K.jsx)(I3,{props:e}):(0,K.jsx)(MS,{children:(0,K.jsx)(I3,{props:e})})}function R3(e,t){let n=Mw((e,n)=>new N3(t,e,n));return U.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function z3({store:e,modal:t}){let n=KS(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}}),r=n.reference,i=n.floating;return zw(e,{activeTriggerProps:r,inactiveTriggerProps:r,popupProps:i}),null}var B3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:s,payload:c,openOnHover:l=!1,delay:u=300,closeDelay:d=0,id:f,...p}=e,m=j3(!0),h=Yw(s)??m;if(!h)throw Error(Cr(74));let g=Zy(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`floatingRootContext`),y=h.useState(`isOpenedByTrigger`,g),b=h.useState(`triggerPopupId`,g),x=U.useRef(null),{registerTrigger:S,isMountedByThisTrigger:C}=Iw(g,x,h,{payload:c,disabled:a,openOnHover:l,closeDelay:d}),w=h.useState(`openChangeReason`),T=h.useState(`stickIfOpen`),E=h.useState(`openMethod`),D=h.useState(`focusManagerModal`),O=rT(v,{enabled:!a&&l&&(E!==`touch`||w!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:hT(),restMs:u,delay:{close:d},triggerElementRef:x,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`}),k=US(v,{stickIfOpen:T}),A=FT(()=>h.select(`open`),e=>{h.set(`openMethod`,e)}),j=h.useState(`triggerProps`,C),{getButtonProps:M,buttonRef:N}=Py({disabled:a,native:o}),P={open(e){return e&&w===`trigger-press`?$v.open(e):Qv.open(e)}},{preFocusGuardRef:F,handlePreFocusGuardFocus:I,handleFocusTargetFocus:L}=DM(h,x),R=Vr(`button`,e,{state:{disabled:a,open:y},ref:[N,t,S,x],props:[k.reference,O,j,A,{[hS]:``,id:g,"aria-haspopup":`dialog`,"aria-expanded":y,"aria-controls":b},p,M],stateAttributesMapping:P}),ee=(0,K.jsx)(U.Fragment,{children:R},g);return C&&!D?(0,K.jsxs)(U.Fragment,{children:[(0,K.jsx)(Gb,{ref:F,onFocus:I}),ee,(0,K.jsx)(Gb,{ref:h.context.triggerFocusTargetRef,onFocus:L})]}):ee}),V3=U.createContext(void 0);function H3(){let e=U.useContext(V3);if(e===void 0)throw Error(Cr(45));return e}var U3=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return j3().useState(`mounted`)||n?(0,K.jsx)(V3.Provider,{value:n,children:(0,K.jsx)(CS,{ref:t,...r})}):null}),W3=U.createContext(void 0);function G3(){let e=U.useContext(W3);if(!e)throw Error(Cr(46));return e}var K3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o,side:s,align:c,sideOffset:l,alignOffset:u,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f,arrowPadding:p,sticky:m,disableAnchorTracking:h=!1,collisionAvoidance:g=_S,..._}=e,v=j3(),y=H3(),b=AS(),x=v.useState(`floatingRootContext`),S=v.useState(`mounted`),C=v.useState(`open`),w=v.useState(`openChangeReason`),T=v.useState(`activeTriggerElement`),E=v.useState(`modal`),D=v.useState(`openMethod`),O=v.useState(`positionerElement`),k=v.useState(`instantType`),A=v.useState(`transitionStatus`),j=v.useState(`adaptiveOrigin`),M=U.useRef(null),N=Ow(O),P=cD({anchor:a,floatingRootContext:x,positionMethod:o,mounted:S,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:p,collisionBoundary:d,collisionPadding:f,sticky:m,disableAnchorTracking:h,keepMounted:y,nodeId:b,collisionAvoidance:g,adaptiveOrigin:j}),F=x.useState(`domReferenceElement`);X(()=>{let e=F,t=M.current;if(e&&(M.current=e),t&&e&&e!==t){v.set(`instantType`,void 0);let e=new AbortController;return N(()=>{v.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[F,N,v]);let I=E===!0&&w!==`trigger-hover`;lM(C&&I,D===`touch`,O,T);let L=v.useStateSetter(`positionerElement`),R=fD(e,{open:C,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:k},{styles:P.positionerStyles,transitionStatus:A,props:_,refs:[t,L],hidden:!S,inert:!C});return(0,K.jsxs)(W3.Provider,{value:P,children:[S&&I&&(0,K.jsx)(ST,{inert:xT(!C),cutout:T}),(0,K.jsx)(jS,{id:b,children:R})]})}),q3=U.createContext(void 0);function J3(){let[e,t]=U.useState(0),n=Ay(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:U.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}var Y3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=j3(),l=G3(),u=Xj(!0)!=null,{context:d,hasClosePart:f}=J3(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),x=c.useState(`mounted`),S=c.useState(`openChangeReason`),C=c.useState(`activeTriggerElement`),w=c.useState(`floatingRootContext`),T=w.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),O=c.useState(`closeDelay`);kw({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),nT(w,{enabled:D&&!E,closeDelay:O});let k=a===void 0?jw(c.context.popupRef):a,A=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,A);let j=c.useStateSetter(`popupElement`),M=Vr(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,j],props:[_,{id:T,role:`dialog`,...Aw,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&vT.has(e.key)&&e.stopPropagation()}},dD(g),s],stateAttributesMapping:ty});return(0,K.jsx)(HS,{context:w,openInteractionType:m,modal:A,disabled:!x||S===`trigger-hover`,initialFocus:k,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:ly(C)?C:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,K.jsx)(q3.Provider,{value:d,children:M})})}),X3=U.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,s=j3(),{side:c}=G3(),l=s.useState(`instantType`),{children:u,state:d}=HM({store:s,side:c,children:a});return Vr(`div`,e,{state:{activationDirection:d.activationDirection,transitioning:d.transitioning,instant:l},ref:t,props:[o,{children:u}],stateAttributesMapping:VM})}),Z3=L3;function Q3(e){return(0,K.jsx)(B3,{"data-slot":`popover-trigger`,...e})}function $3({children:e,className:t,positionerClassName:n,side:r=`bottom`,align:i=`center`,sideOffset:a=4,alignOffset:o=0,tooltipStyle:s=!1,...c}){return(0,K.jsx)(U3,{children:(0,K.jsx)(K3,{align:i,alignOffset:o,className:G(`z-50 h-(--positioner-height) max-h-(--available-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none`,n),"data-slot":`popover-positioner`,side:r,sideOffset:a,children:(0,K.jsx)(Y3,{className:G(`relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg border bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-starting-style:scale-98 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,s&&`w-fit text-balance rounded-md text-xs shadow-black/5 shadow-md before:rounded-[calc(var(--radius-md)-1px)]`,t),"data-slot":`popover-popup`,...c,children:(0,K.jsx)(X3,{className:G(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 outline-none [--viewport-inline-padding:--spacing(4)] data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,s?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`),"data-slot":`popover-viewport`,children:e})})})})}var e6=new Map,t6;function n6(e){if(t6?.revision===e)return t6.request;let t=window.electronAPI.providers.listOauth().then(t=>{let n=new Map;for(let e of t)for(let t of e.accounts){if(typeof t.email!=`string`)continue;let e=``;for(let n of t.email){let t=n.codePointAt(0)??0;t>=32&&t!==127&&(e+=n)}e=e.trim(),e&&n.set(t.key,e)}return{revision:e,emails:n}}).catch(t=>(console.error(`Failed to load OAuth account metadata`,t),{revision:e,emails:e6})),n={revision:e,request:t,data:void 0};return t6=n,t.then(e=>{t6===n&&(n.data=e)}),t}function r6(){let e=pR(e=>e.snapshot.revision),[t,n]=(0,U.useState)(()=>t6?.revision===e?t6.data:void 0);return(0,U.useEffect)(()=>{let t=!1;return n6(e).then(e=>{t||n(e)}),()=>{t=!0}},[e]),t?.revision===e?t.emails:e6}function i6(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36)}function a6(e,t,n){return`${e}:${i6(t)}:${i6(n,1)}`}var o6=/(?:\x1b\]|\x9d)[^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c|$)/g,s6=/(?:\x1b\[|\x9b)[0-?]*[ -/]*(?:[@-~]|$)/g;function c6(e){return e.replace(o6,``).replace(s6,``)}var l6=kj()(e=>({conversationId:null,result:null,tab:`session`,from:null,open:(t,n,r)=>e({conversationId:t,result:n??null,tab:n?`result`:`session`,from:r??null}),setTab:t=>e({tab:t}),close:()=>e({conversationId:null,result:null,tab:`session`,from:null})})),u6=kj()(()=>({back:null}));function d6(e){return nP.getState().conversations[e]?.parentId??e}function f6(e){let t=nP.getState().conversations[e]?.projectId;return E.getState().projects.some(e=>e.id===t&&e.kind===`secretary`)}var p6=!1;function m6(){p6||(p6=!0,nP.subscribe((e,t)=>{if(e.activeId===t.activeId)return;let{back:n}=u6.getState();n&&(!e.activeId||d6(e.activeId)!==n.to)&&u6.setState({back:null})}))}function h6(e,t){let n=nP.getState();if(!n.conversations[e])return;let r=t??n.activeId,i=r?d6(r):null,a=d6(e);m6(),l6.getState().close(),n.selectConversation(e),u6.setState({back:i&&i!==a&&f6(i)&&!f6(a)?{from:i,to:a}:null})}var g6=`
258
+ …`;function _6(e){return e.length>=32768&&e.endsWith(g6)?e.slice(0,-2):null}function v6(e){return!!(e?.role===`user`&&e.optimistic&&e.deliveryRejected&&e.deliveryId&&!e.entryId)}function y6(e){return!!(e?.role===`user`&&e.optimistic&&!e.deliveryRejected&&!e.withdrawRequested&&e.deliveryId&&!e.entryId)}var b6=kj(e=>({byConversation:{},replace:(t,n)=>e(e=>{let r={...e.byConversation};if(n.length>0)r[t]=n;else if(r[t])delete r[t];else return e;return{byConversation:r}})}));function x6(e){let t=e.toLowerCase();return t.startsWith(`image/`)?`image`:t.startsWith(`text/`)||t===`application/json`||t===`application/javascript`||t===`application/xml`||t.endsWith(`+json`)||t.endsWith(`+xml`)?`text`:`file`}function S6(e){return!Number.isFinite(e)||e<1024?`${Math.max(0,Math.round(e))} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}async function C6(e){if(!window.electronAPI.remote){let t=await window.electronAPI.extensionPlugins.artifactSave(e.id);return t.ok?null:t.error}let t=await window.electronAPI.extensionPlugins.artifactRead(e.id);if(!t.ok)return t.error;let n=Uint8Array.from(atob(t.base64),e=>e.charCodeAt(0)),r=URL.createObjectURL(new Blob([n],{type:e.mime||`application/octet-stream`})),i=document.createElement(`a`);return i.href=r,i.download=e.name,i.click(),URL.revokeObjectURL(r),null}function w6({artifact:e,onDelete:t}){let[n,r]=(0,U.useState)(null),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(!1),c=x6(e.mime),l=async()=>{s(!0),a(null);let t=await window.electronAPI.extensionPlugins.artifactRead(e.id);if(s(!1),!t.ok){a(t.error),r(null);return}if(c===`image`){r({kind:`image`,body:`data:${t.info.mime};base64,${t.base64}`});return}if(c===`text`){r({kind:`text`,body:n0(t.base64)});return}r(null),a(`这个文件不能在这里预览`)};return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:[e.name,(0,K.jsxs)(`span`,{className:`ml-2 text-muted-foreground`,children:[e.mime,` · `,S6(e.size)]})]}),c!==`file`&&(0,K.jsx)(Oa,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>void l(),children:`预览`}),(0,K.jsx)(Oa,{size:`sm`,variant:`ghost`,disabled:o,onClick:()=>{s(!0),C6(e).then(e=>{s(!1),a(e)})},children:window.electronAPI.remote?`下载`:`另存`}),t&&(0,K.jsx)(Oa,{size:`sm`,variant:`ghost`,onClick:()=>t(e.id),children:`删除`})]}),i&&(0,K.jsx)(`p`,{className:`text-destructive text-xs`,children:i}),n?.kind===`text`&&(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all font-mono text-muted-foreground text-xs`,children:n.body}),n?.kind===`image`&&(0,K.jsx)(`img`,{src:n.body,alt:e.name,className:`max-h-48 max-w-full rounded border object-contain`})]})}function T6({artifacts:e,onDelete:t}){return e.length===0?(0,K.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`还没有产出文件`}):(0,K.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,K.jsx)(w6,{artifact:e,onDelete:t},e.id))})}function E6({artifacts:e,align:t=`tool-row`}){return(0,K.jsxs)(`div`,{className:G(`mt-1 mb-1.5 rounded-lg border border-border/70 bg-card px-3 py-2`,t===`card`?`w-full`:`ml-[30px]`),children:[(0,K.jsx)(`p`,{className:`mb-1 text-[11px] text-muted-foreground`,children:`产出文件`}),(0,K.jsx)(T6,{artifacts:e})]})}var D6={},O6=new Set,k6=new Map;function A6(e){return O6.add(e),()=>O6.delete(e)}function j6(e,t){let n=`${e}\0${t}`,r=k6.get(n);return r||(r=window.electronAPI.extensionPlugins.asset(e,t).then(e=>e.ok?`data:${e.mime};base64,${e.base64}`:null).catch(()=>null),r.then(e=>e===null&&k6.delete(n)),k6.set(n,r)),r}function M6({pluginId:e,icon:t,className:n}){let r=(0,U.useSyncExternalStore)(A6,()=>D6[e]),i=t??r,[a,o]=(0,U.useState)(null);return(0,U.useEffect)(()=>{if(o(null),!i)return;let t=!0;return j6(e,i).then(e=>t&&o(e)),()=>{t=!1}},[e,i]),a?(0,K.jsx)(`img`,{src:a,alt:``,className:G(`object-contain`,n)}):(0,K.jsx)(On,{className:n})}var N6={read_only:`Read-only`,regenerable:`Regenerable output`,reversible_workspace_change:`Reversible workspace change`,data_loss:`Possible data loss`,system_state:`Changes system state`,exfiltration:`Sends data externally`,unclear_target:`Unclear target or intent`};function P6({value:e}){let t=we(e),{t:n}=q();if(!t)return null;let r=`allow ${t.allow.toFixed(2)} · ask ${t.ask.toFixed(2)} · block ${t.block.toFixed(2)}`;return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 border-border/60 border-t px-3 py-1 text-[10px] text-muted-foreground`,"data-approval-review":t.verdict,children:[(0,K.jsx)(`span`,{className:`font-semibold tracking-wide text-foreground/75`,children:t.verdict===`allow`?n(`Auto-managed · allowed`):n(`Auto-managed · denied`)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono`,children:t.model}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{className:`font-mono`,children:r}),t.reason&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsxs)(`span`,{children:[n(`Reason`),`: `,n(N6[t.reason])]})]})]})}function F6({ask:e,waiting:t}){let{t:n}=q(),r=e.answer!==null&&!e.options.includes(e.answer)?e.answer:null;return(0,K.jsxs)(`div`,{className:`space-y-1.5 px-3 py-2 text-xs`,children:[(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words leading-relaxed text-foreground`,children:e.question}),(e.options.length>0||r!==null)&&(0,K.jsxs)(`ul`,{className:`space-y-0.5`,children:[e.options.map(t=>(0,K.jsx)(I6,{selected:t===e.answer,text:t},t)),r!==null&&(0,K.jsx)(I6,{selected:!0,text:r,label:e.options.length>0&&!e.autoSelected?n(`Custom answer`):void 0})]}),e.autoSelected&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:n(`No answer in time; the default was selected`)}),t&&e.answer===null&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:n(`Waiting for your answer`)})]})}function I6({selected:e,text:t,label:n}){let{t:r}=q(),i=e?Ct:Ot;return(0,K.jsxs)(`li`,{"data-selected":e||void 0,className:G(`flex items-start gap-1.5 rounded-md px-2 py-1 leading-relaxed`,e?`bg-primary/10 text-foreground`:`text-muted-foreground`),children:[(0,K.jsx)(i,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,e?`text-primary`:`opacity-40`)}),(0,K.jsxs)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:[n&&(0,K.jsx)(`span`,{className:`mr-1.5 text-muted-foreground`,children:n}),t]}),e&&(0,K.jsx)(`span`,{className:`sr-only`,children:r(`Selected`)})]})}var L6=/^Subagent ".*" \(agentId [^,\s]+, runId [^)\s]+\) \S+ after .+\.$/gm,R6=/^The following is the subagent's report: .*$\n?/m,z6=/<usage>([\s\S]*?)<\/usage>/,B6=/^Background tasks this subagent started\b.*\n((?:- .*(?:\n|$))+)/m,V6=(e,t)=>{let n=RegExp(`^${t}: (\\d+)$`,`m`).exec(e);return n?Number(n[1]):null};function H6(e){let t=e.indexOf(`
259
259
  `),n=t<0?e:e.slice(0,t),r=t<0?``:e.slice(t+1),i=null,a=[],o=z6.exec(r);if(o){let e=B6.exec(r.slice(o.index+o[0].length));e&&(a=e[1].split(`
260
- `).filter(e=>e.startsWith(`- `)).map(e=>e.slice(2))),r=r.slice(0,o.index);let t=V6(o[1],`subagent_tokens`),n=V6(o[1],`tool_uses`),s=V6(o[1],`duration_ms`);t!==null&&n!==null&&s!==null&&(i={tokens:t,toolUses:n,durationMs:s})}return{header:n,report:r.replace(R6,``).trim(),usage:i,...a.length>0?{tasks:a}:{}}}function U6(e){let t=e.trim(),n=[...t.matchAll(L6)].map(e=>e.index);return n[0]===0?n.map((e,r)=>H6(t.slice(e,n[r+1]).replace(/\n+---\s*$/,``).trim())):null}function W6(e){return jT(`alert-dialog`,e)}function G6(e){return LE(e.open??!1),(0,K.jsx)(W6,{...e})}var K6=wT;function q6({className:e,style:t,...n}){return(0,K.jsx)(ny,{className:G(`fixed inset-0 bg-black/32 backdrop-blur-sm transition-all duration-200 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),style:t,"data-slot":`alert-dialog-backdrop`,...n})}function J6({className:e,style:t,...n}){return(0,K.jsx)(NT,{className:G(`fixed inset-0 grid grid-rows-[1fr_auto] justify-items-center pt-6 sm:grid-rows-[1fr_auto_3fr] sm:p-4`,e),style:t,"data-slot":`alert-dialog-viewport`,...n})}function Y6({className:e,showBackdrop:t=!0,zIndexLevel:n=`base`,...r}){let i=n===`nested`?RE.NESTED_MODAL_BACKDROP:RE.MODAL_BACKDROP,a=n===`nested`?RE.NESTED_MODAL_CONTENT:RE.MODAL_CONTENT,o=n===`nested`?RE.DROPDOWN_IN_NESTED_MODAL:RE.DROPDOWN_IN_MODAL;return(0,K.jsxs)(K6,{children:[(0,K.jsx)(OE,{}),t&&(0,K.jsx)(q6,{style:{zIndex:i}}),(0,K.jsx)(J6,{style:{zIndex:a},children:(0,K.jsx)(zE.Provider,{value:o,children:(0,K.jsx)(xT,{className:G(`sm:-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 grid max-h-full w-full min-w-0 border-t bg-popover bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-nested-dialog-open:origin-top data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden sm:max-w-lg sm:data-nested:data-ending-style:translate-y-8 sm:data-nested:data-starting-style:translate-y-8 sm:scale-[calc(1-0.1*var(--nested-dialogs))] sm:rounded-2xl sm:border sm:data-ending-style:scale-98 sm:data-starting-style:scale-98 sm:before:rounded-[calc(var(--radius-2xl)-1px)] dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e),"data-slot":`alert-dialog-popup`,...r})})})]})}function X6({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex flex-col gap-2 p-6 not-has-[+[data-slot=alert-dialog-footer]]:pb-4 text-center max-sm:pb-4 sm:text-left`,e),"data-slot":`alert-dialog-header`,...t})}function Z6({className:e,variant:t=`default`,...n}){return(0,K.jsx)(`div`,{className:G(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t==="default"&&`border-t bg-muted/50 py-4`,t===`bare`&&`pt-4 pb-6`,e),"data-slot":`alert-dialog-footer`,...n})}function Q6({className:e,...t}){return(0,K.jsx)(PT,{className:G(`font-heading text-xl leading-none`,e),"data-slot":`alert-dialog-title`,...t})}function $6({className:e,...t}){return(0,K.jsx)(Qy,{className:G(`text-muted-foreground text-sm`,e),"data-slot":`alert-dialog-description`,...t})}function e8(e){return(0,K.jsx)(qy,{"data-slot":`alert-dialog-close`,...e})}function t8({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i,cancelLabel:a,onConfirm:o,zIndexLevel:s}){let{t:c}=q();return(0,K.jsx)(G6,{open:e,onOpenChange:t,children:(0,K.jsxs)(Y6,{className:`sm:max-w-sm`,zIndexLevel:s,children:[(0,K.jsxs)(X6,{children:[(0,K.jsx)(Q6,{className:`text-base`,children:n}),r&&(0,K.jsx)($6,{children:r})]}),(0,K.jsxs)(Z6,{variant:`bare`,children:[(0,K.jsx)(e8,{render:(0,K.jsx)(Oa,{variant:`outline`,size:`sm`}),children:a??c(`Cancel`)}),(0,K.jsx)(Oa,{variant:`destructive`,size:`sm`,onClick:()=>{o(),t(!1)},children:i})]})]})})}function n8(e,t){return!e||e<=0||t===void 0||t>=e?null:Math.round((1-t/e)*100)}function r8({hits:e,defaultOpen:t=!1}){let{t:n}=q();return e.length===0?(0,K.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`No results`)}):(0,K.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,K.jsx)(a8,{hit:e,defaultOpen:t},e.id))})}function i8({view:e}){let{t}=q(),n=e.written?e.deduplicated&&t(`Identical memory already exists, nothing new was written`):t(`Similar memories already exist, nothing was written`);return(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsx)(`p`,{className:`px-3 pt-2 text-xs text-muted-foreground`,children:n}),e.written?(0,K.jsx)(r8,{hits:[e.memory],defaultOpen:!0}):(0,K.jsx)(r8,{hits:e.candidates})]})}function a8({hit:e,defaultOpen:t}){let{t:n}=q(),[r,i]=(0,U.useState)(t);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:e=>{let t=window.getSelection();t?.toString()&&e.currentTarget.contains(t.anchorNode)||i(e=>!e)},className:`block w-full cursor-pointer px-3 py-2 text-left transition-colors hover:bg-muted/40`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1 font-medium text-foreground text-xs`,r?`break-words`:`truncate`),children:e.title}),e.unitType&&(0,K.jsx)(aj,{variant:`secondary`,size:`sm`,children:e.unitType}),e.space&&(0,K.jsx)(aj,{variant:`outline`,size:`sm`,children:n(e.space===`global`?`Global`:`Project`)}),e.relevance!==null&&(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,title:n(`Semantic similarity`),children:e.relevance.toFixed(2)})]}),(0,K.jsx)(`span`,{className:G(`mt-0.5 whitespace-pre-wrap break-words text-muted-foreground text-xs leading-relaxed`,r?`block`:`line-clamp-2`),children:e.content})]})})}var o8=U.createContext(void 0);function s8(e){let t=U.useContext(o8);if(t===void 0&&!e)throw Error(Cr(50));return t}var c8={...Yw,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay},l8=class extends Tw{constructor(e,t,n){let r=new Hw;super(u8(e,r,t,n),d8(r),c8)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;wte(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&aw(n,t.trigger,r.clientX,r.clientY)}})}};function u8(e,t,n,r=!1){let i={...Uw(),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e};return i.floatingRootContext=Ww(t,n,r),i}function d8(e){return{popupRef:U.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function f8(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=Nw((e,r)=>new l8({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);Rw(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=zw(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});X(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),U.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,Ky(Gy))}),[h,u]);let g=d||p;return(0,K.jsxs)(o8.Provider,{value:u,children:[o&&(0,K.jsx)(Pw,{handle:o,store:u}),g&&(0,K.jsx)(p8,{store:u}),typeof l==`function`?l({payload:m}):l]})}function p8({store:e}){let t=KS(e.useState(`floatingRootContext`));return Bw(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}var m8=hw(function(e){return s8(!0)?(0,K.jsx)(f8,{...e}):(0,K.jsx)(MS,{children:(0,K.jsx)(f8,{...e})})}),h8=U.createContext(void 0);function g8(){let e=U.useContext(h8);if(e===void 0)throw Error(Cr(48));return e}var _8=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return s8().useState(`mounted`)||n?(0,K.jsx)(h8.Provider,{value:n,children:(0,K.jsx)(eD,{ref:t,...r})}):null}),v8=gw(function(e,t){let{render:n,className:r,delay:i,closeDelay:a,id:o,payload:s,handle:c,style:l,...u}=e,d=s8(!0),f=Xw(c)??d;if(!f)throw Error(Cr(89));let p=Zy(o),m=f.useState(`isTriggerActive`,p),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`floatingRootContext`),_=f.context.inlineRectCoordsRef,v=U.useRef(null),y=i??600,b=a??300,{registerTrigger:x,isMountedByThisTrigger:S}=Lw(p,v,f,{payload:s,closeDelay:b}),C=iT(g,{mouseOnly:!0,move:!1,handleClose:gT(),delay:()=>({open:y,close:b}),triggerElementRef:v,isActiveTrigger:m,isClosing:()=>f.select(`transitionStatus`)===`ending`}),w=Qw(g,{delay:y}),T={open:h},E=f.useState(`triggerProps`,S),D=iw(_,h);return Vr(`a`,e,{state:T,ref:[t,x,v],props:[C,w.reference,E,D,{id:p},u],stateAttributesMapping:Qv})}),y8=U.createContext(void 0);function b8(){let e=U.useContext(y8);if(e===void 0)throw Error(Cr(49));return e}var x8=U.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=_S,style:g,..._}=e,v=s8(),y=g8(),b=AS(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=lD({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:ow(D)}),k=O.update;X(()=>{x&&S&&k()},[x,S,k]);let A=pD(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return(0,K.jsx)(y8.Provider,{value:O,children:(0,K.jsx)(jS,{id:b,children:A})})}),S8=U.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=s8(),{side:s,align:c}=b8(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return Aw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),rT(p,{closeDelay:m}),Vr(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[jw,f,fD(d),a],stateAttributesMapping:ty})}),C8=m8;function w8({...e}){return(0,K.jsx)(v8,{"data-slot":`preview-card-trigger`,...e})}function T8({className:e,children:t,align:n=`center`,sideOffset:r=4,...i}){return(0,K.jsx)(_8,{children:(0,K.jsx)(x8,{align:n,className:`z-50`,"data-slot":`preview-card-positioner`,sideOffset:r,children:(0,K.jsx)(S8,{className:G(`relative flex w-64 origin-(--transform-origin) text-balance rounded-lg border bg-popover bg-clip-padding p-4 text-popover-foreground text-sm shadow-lg transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e),"data-slot":`preview-card-content`,...i,children:t})})})}var E8={mask:`text-sky-600 dark:text-sky-400`,warn:`text-amber-600 dark:text-amber-400`,block:`text-red-600 dark:text-red-400`},D8={mask:Rn,warn:In,block:Ln},O8={mask:`Mask`,warn:`Warn only`,block:`Block`},k8={system:`System prompt`,user:`Your message`,tool_result:`Tool output`,tool_args:`Tool arguments`,assistant:`Earlier replies`,tools:`Tool descriptions`};function A8({report:e}){let{t}=q(),n=S(e);if(!n)return null;let r=D8[n],i=new Set(e.hits.map(e=>e.token)).size;return(0,K.jsxs)(C8,{children:[(0,K.jsxs)(w8,{render:(0,K.jsx)(`span`,{className:G(`inline-flex shrink-0 items-center gap-0.5 text-[11px]`,E8[n]),"data-privacy-mask":n}),children:[(0,K.jsx)(r,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:i})]}),(0,K.jsxs)(T8,{className:`max-h-(--available-height) w-72 flex-col overflow-y-auto overscroll-contain text-xs`,children:[(0,K.jsx)(`p`,{className:`mb-1.5 font-medium`,children:t(`Privacy masking`)}),(0,K.jsx)(`ul`,{className:`space-y-1`,children:m(e.hits).map(e=>(0,K.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,K.jsx)(`span`,{className:E8[e.action],children:t(O8[e.action])}),(0,K.jsx)(`span`,{children:e.kind}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:t(k8[e.where]??e.where)}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.values>1?t(`{{count}} values`,{count:e.values}):e.preview}),e.count>1&&(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.count]})]},`${e.action}-${e.kind}-${e.where}`))}),e.restored>0&&(0,K.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t(`Restored {{count}} in the reply`,{count:e.restored})})]})]})}function j8(e){let{inputTokens:t,outputTokens:n}=e;if(typeof t!=`number`||!Number.isFinite(t)||t<0||typeof n!=`number`||!Number.isFinite(n)||n<0)return null;let r=Math.max(0,t-n);return{tokens:r,percent:t>0?Math.round(r/t*100):null}}var M8={compressed:`Compressed`,unchanged:`Unchanged`,pending:`Background task started`,bypassed:`Bypassed`,unavailable:`Unavailable`};function N8({value:e}){let t=ne(e),{t:n}=q();if(!t)return null;let r=j8(t);return(0,K.jsxs)(`div`,{className:`border-border/60 border-t text-[10px] text-muted-foreground`,"data-rtk-status":t.status,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 px-3 py-1`,children:[(0,K.jsx)(`span`,{className:`font-semibold tracking-wide text-foreground/75`,children:`RTK`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:n(M8[t.status])}),r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:n(`~{{count}} tokens saved`,{count:DN(r.tokens)})}),r.percent!==null&&(0,K.jsxs)(`span`,{children:[`(`,r.percent,`%)`]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2 px-3 pb-2`,children:[t.status===`pending`&&(0,K.jsx)(`p`,{className:`rounded bg-muted/40 px-2 py-1 text-foreground/80`,children:n(`This is the startup receipt; see the task_output result for final statistics.`)}),(t.inputTokens!==void 0||t.reason)&&(0,K.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[t.inputTokens!==void 0&&t.outputTokens!==void 0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:n(`Input estimate`)}),(0,K.jsx)(`dd`,{className:`font-mono text-foreground/80`,children:n(`{{count}} tokens`,{count:DN(t.inputTokens)})}),(0,K.jsx)(`dt`,{children:n(`Output estimate`)}),(0,K.jsx)(`dd`,{className:`font-mono text-foreground/80`,children:n(`{{count}} tokens`,{count:DN(t.outputTokens)})})]}),t.reason&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:n(`Reason`)}),(0,K.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap text-foreground/80`,children:t.reason})]})]})]})]})}function P8(e,t,n){if(e==null||t===void 0||t<=e)return null;let r=Math.max(0,t-n);return{remainingMs:r,fraction:Math.min(1,r/(t-e))}}function F8(e,t,n=pe){let r=t-e;return r>=n?r:null}var I8={exit_nonzero:`Exit {{code}}`,deadline:`Killed at timeout`,stopped_by_user:`Stopped by you`,tty_required:`Needs terminal`,auth_required:`Needs login`,not_found:`Command not found`,not_executable:`Not executable`,binary_output:`Binary output`,output_truncated:`Log truncated`},L8={deadline:`Killed when its timeout was reached. Raise the timeout or run it in the background.`,tty_required:`Needs an interactive terminal. Use a non-interactive flag (such as --yes) or run it in your own terminal.`,auth_required:`Needs credentials. Sign in from your own terminal, then retry.`,not_found:`The program is not installed or not on PATH.`};function R8(e){return e?.kind===`deadline`?[`background`,`timeout`]:[]}function z8(e,t,n){let r=`\`\`\`\n${t}\n\`\`\``;return e===`background`?n(`Rerun this command with background: true:
260
+ `).filter(e=>e.startsWith(`- `)).map(e=>e.slice(2))),r=r.slice(0,o.index);let t=V6(o[1],`subagent_tokens`),n=V6(o[1],`tool_uses`),s=V6(o[1],`duration_ms`);t!==null&&n!==null&&s!==null&&(i={tokens:t,toolUses:n,durationMs:s})}return{header:n,report:r.replace(R6,``).trim(),usage:i,...a.length>0?{tasks:a}:{}}}function U6(e){let t=e.trim(),n=[...t.matchAll(L6)].map(e=>e.index);return n[0]===0?n.map((e,r)=>H6(t.slice(e,n[r+1]).replace(/\n+---\s*$/,``).trim())):null}function W6(e){return AT(`alert-dialog`,e)}function G6(e){return IE(e.open??!1),(0,K.jsx)(W6,{...e})}var K6=CT;function q6({className:e,style:t,...n}){return(0,K.jsx)(ny,{className:G(`fixed inset-0 bg-black/32 backdrop-blur-sm transition-all duration-200 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),style:t,"data-slot":`alert-dialog-backdrop`,...n})}function J6({className:e,style:t,...n}){return(0,K.jsx)(MT,{className:G(`fixed inset-0 grid grid-rows-[1fr_auto] justify-items-center pt-6 sm:grid-rows-[1fr_auto_3fr] sm:p-4`,e),style:t,"data-slot":`alert-dialog-viewport`,...n})}function Y6({className:e,showBackdrop:t=!0,zIndexLevel:n=`base`,...r}){let i=n===`nested`?LE.NESTED_MODAL_BACKDROP:LE.MODAL_BACKDROP,a=n===`nested`?LE.NESTED_MODAL_CONTENT:LE.MODAL_CONTENT,o=n===`nested`?LE.DROPDOWN_IN_NESTED_MODAL:LE.DROPDOWN_IN_MODAL;return(0,K.jsxs)(K6,{children:[(0,K.jsx)(DE,{}),t&&(0,K.jsx)(q6,{style:{zIndex:i}}),(0,K.jsx)(J6,{style:{zIndex:a},children:(0,K.jsx)(RE.Provider,{value:o,children:(0,K.jsx)(bT,{className:G(`sm:-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 grid max-h-full w-full min-w-0 border-t bg-popover bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-nested-dialog-open:origin-top data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden sm:max-w-lg sm:data-nested:data-ending-style:translate-y-8 sm:data-nested:data-starting-style:translate-y-8 sm:scale-[calc(1-0.1*var(--nested-dialogs))] sm:rounded-2xl sm:border sm:data-ending-style:scale-98 sm:data-starting-style:scale-98 sm:before:rounded-[calc(var(--radius-2xl)-1px)] dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e),"data-slot":`alert-dialog-popup`,...r})})})]})}function X6({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex flex-col gap-2 p-6 not-has-[+[data-slot=alert-dialog-footer]]:pb-4 text-center max-sm:pb-4 sm:text-left`,e),"data-slot":`alert-dialog-header`,...t})}function Z6({className:e,variant:t=`default`,...n}){return(0,K.jsx)(`div`,{className:G(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,t==="default"&&`border-t bg-muted/50 py-4`,t===`bare`&&`pt-4 pb-6`,e),"data-slot":`alert-dialog-footer`,...n})}function Q6({className:e,...t}){return(0,K.jsx)(NT,{className:G(`font-heading text-xl leading-none`,e),"data-slot":`alert-dialog-title`,...t})}function $6({className:e,...t}){return(0,K.jsx)(Qy,{className:G(`text-muted-foreground text-sm`,e),"data-slot":`alert-dialog-description`,...t})}function e8(e){return(0,K.jsx)(qy,{"data-slot":`alert-dialog-close`,...e})}function t8({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i,cancelLabel:a,onConfirm:o,zIndexLevel:s}){let{t:c}=q();return(0,K.jsx)(G6,{open:e,onOpenChange:t,children:(0,K.jsxs)(Y6,{className:`sm:max-w-sm`,zIndexLevel:s,children:[(0,K.jsxs)(X6,{children:[(0,K.jsx)(Q6,{className:`text-base`,children:n}),r&&(0,K.jsx)($6,{children:r})]}),(0,K.jsxs)(Z6,{variant:`bare`,children:[(0,K.jsx)(e8,{render:(0,K.jsx)(Oa,{variant:`outline`,size:`sm`}),children:a??c(`Cancel`)}),(0,K.jsx)(Oa,{variant:`destructive`,size:`sm`,onClick:()=>{o(),t(!1)},children:i})]})]})})}function n8(e,t){return!e||e<=0||t===void 0||t>=e?null:Math.round((1-t/e)*100)}function r8({hits:e,defaultOpen:t=!1}){let{t:n}=q();return e.length===0?(0,K.jsx)(`p`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:n(`No results`)}):(0,K.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,K.jsx)(a8,{hit:e,defaultOpen:t},e.id))})}function i8({view:e}){let{t}=q(),n=e.written?e.deduplicated&&t(`Identical memory already exists, nothing new was written`):t(`Similar memories already exist, nothing was written`);return(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsx)(`p`,{className:`px-3 pt-2 text-xs text-muted-foreground`,children:n}),e.written?(0,K.jsx)(r8,{hits:[e.memory],defaultOpen:!0}):(0,K.jsx)(r8,{hits:e.candidates})]})}function a8({hit:e,defaultOpen:t}){let{t:n}=q(),[r,i]=(0,U.useState)(t);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:e=>{let t=window.getSelection();t?.toString()&&e.currentTarget.contains(t.anchorNode)||i(e=>!e)},className:`block w-full cursor-pointer px-3 py-2 text-left transition-colors hover:bg-muted/40`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1 font-medium text-foreground text-xs`,r?`break-words`:`truncate`),children:e.title}),e.unitType&&(0,K.jsx)(ij,{variant:`secondary`,size:`sm`,children:e.unitType}),e.space&&(0,K.jsx)(ij,{variant:`outline`,size:`sm`,children:n(e.space===`global`?`Global`:`Project`)}),e.relevance!==null&&(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,title:n(`Semantic similarity`),children:e.relevance.toFixed(2)})]}),(0,K.jsx)(`span`,{className:G(`mt-0.5 whitespace-pre-wrap break-words text-muted-foreground text-xs leading-relaxed`,r?`block`:`line-clamp-2`),children:e.content})]})})}var o8=U.createContext(void 0);function s8(e){let t=U.useContext(o8);if(t===void 0&&!e)throw Error(Cr(50));return t}var c8={...Jw,instantType:e=>e.instantType,adaptiveOrigin:e=>e.adaptiveOrigin,closeDelay:e=>e.closeDelay},l8=class extends ww{constructor(e,t,n){let r=new Vw;super(u8(e,r,t,n),d8(r),c8)}setOpen=(e,t)=>{let{inlineRectCoordsRef:n}=this.context;Tte(this,e,t,{onBeforeDispatch(){let r=t.event;e&&t.reason===`trigger-hover`&&t.trigger&&`clientX`in r&&`clientY`in r&&n.current?.element!==t.trigger&&iw(n,t.trigger,r.clientX,r.clientY)}})}};function u8(e,t,n,r=!1){let i={...Hw(),instantType:void 0,adaptiveOrigin:void 0,closeDelay:300,...e};return i.floatingRootContext=Uw(t,n,r),i}function d8(e){return{popupRef:U.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e,inlineRectCoordsRef:{current:void 0}}}function f8(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,onOpenChangeComplete:i,actionsRef:a,handle:o,triggerId:s,defaultTriggerId:c=null,children:l}=e,u=Mw((e,r)=>new l8({open:n,openProp:t,activeTriggerId:c,triggerIdProp:s},e,r));u.useControlledProp(`openProp`,t),u.useControlledProp(`triggerIdProp`,s),u.useContextCallback(`onOpenChange`,r),u.useContextCallback(`onOpenChangeComplete`,i);let d=u.useState(`open`),f=u.useState(`activeTriggerId`),p=u.useState(`mounted`),m=u.useState(`payload`);Lw(u,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:h}=Rw(d,u,()=>{u.context.inlineRectCoordsRef.current=void 0});X(()=>{d&&(f??u.set(`payload`,void 0))},[u,f,d]),U.useImperativeHandle(a,()=>({unmount:h,close:()=>u.setOpen(!1,Ky(Gy))}),[h,u]);let g=d||p;return(0,K.jsxs)(o8.Provider,{value:u,children:[o&&(0,K.jsx)(Nw,{handle:o,store:u}),g&&(0,K.jsx)(p8,{store:u}),typeof l==`function`?l({payload:m}):l]})}function p8({store:e}){let t=KS(e.useState(`floatingRootContext`));return zw(e,{activeTriggerProps:t.reference,inactiveTriggerProps:t.trigger,popupProps:t.floating}),null}var m8=mw(function(e){return s8(!0)?(0,K.jsx)(f8,{...e}):(0,K.jsx)(MS,{children:(0,K.jsx)(f8,{...e})})}),h8=U.createContext(void 0);function g8(){let e=U.useContext(h8);if(e===void 0)throw Error(Cr(48));return e}var _8=U.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return s8().useState(`mounted`)||n?(0,K.jsx)(h8.Provider,{value:n,children:(0,K.jsx)($E,{ref:t,...r})}):null}),v8=hw(function(e,t){let{render:n,className:r,delay:i,closeDelay:a,id:o,payload:s,handle:c,style:l,...u}=e,d=s8(!0),f=Yw(c)??d;if(!f)throw Error(Cr(89));let p=Zy(o),m=f.useState(`isTriggerActive`,p),h=f.useState(`isOpenedByTrigger`,p),g=f.useState(`floatingRootContext`),_=f.context.inlineRectCoordsRef,v=U.useRef(null),y=i??600,b=a??300,{registerTrigger:x,isMountedByThisTrigger:S}=Iw(p,v,f,{payload:s,closeDelay:b}),C=rT(g,{mouseOnly:!0,move:!1,handleClose:hT(),delay:()=>({open:y,close:b}),triggerElementRef:v,isActiveTrigger:m,isClosing:()=>f.select(`transitionStatus`)===`ending`}),w=Zw(g,{delay:y}),T={open:h},E=f.useState(`triggerProps`,S),D=rw(_,h);return Vr(`a`,e,{state:T,ref:[t,x,v],props:[C,w.reference,E,D,{id:p},u],stateAttributesMapping:Qv})}),y8=U.createContext(void 0);function b8(){let e=U.useContext(y8);if(e===void 0)throw Error(Cr(49));return e}var x8=U.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`bottom`,align:s=`center`,sideOffset:c=0,alignOffset:l=0,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d=5,arrowPadding:f=5,sticky:p=!1,disableAnchorTracking:m=!1,collisionAvoidance:h=_S,style:g,..._}=e,v=s8(),y=g8(),b=AS(),x=v.useState(`open`),S=v.useState(`mounted`),C=v.useState(`floatingRootContext`),w=v.useState(`instantType`),T=v.useState(`transitionStatus`),E=v.useState(`adaptiveOrigin`),D=v.context.inlineRectCoordsRef,O=cD({anchor:i,floatingRootContext:C,positionMethod:a,mounted:S,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:y,nodeId:b,collisionAvoidance:h,adaptiveOrigin:E,inline:aw(D)}),k=O.update;X(()=>{x&&S&&k()},[x,S,k]);let A=fD(e,{open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:w},{styles:O.positionerStyles,transitionStatus:T,props:_,refs:[t,v.useStateSetter(`positionerElement`)],hidden:!S,inert:!x});return(0,K.jsx)(y8.Provider,{value:O,children:(0,K.jsx)(jS,{id:b,children:A})})}),S8=U.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,o=s8(),{side:s,align:c}=b8(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`closeDelay`);return kw({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),nT(p,{closeDelay:m}),Vr(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,o.useStateSetter(`popupElement`)],props:[Aw,f,dD(d),a],stateAttributesMapping:ty})}),C8=m8;function w8({...e}){return(0,K.jsx)(v8,{"data-slot":`preview-card-trigger`,...e})}function T8({className:e,children:t,align:n=`center`,sideOffset:r=4,...i}){return(0,K.jsx)(_8,{children:(0,K.jsx)(x8,{align:n,className:`z-50`,"data-slot":`preview-card-positioner`,sideOffset:r,children:(0,K.jsx)(S8,{className:G(`relative flex w-64 origin-(--transform-origin) text-balance rounded-lg border bg-popover bg-clip-padding p-4 text-popover-foreground text-sm shadow-lg transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,e),"data-slot":`preview-card-content`,...i,children:t})})})}var E8={mask:`text-sky-600 dark:text-sky-400`,warn:`text-amber-600 dark:text-amber-400`,block:`text-red-600 dark:text-red-400`},D8={mask:Rn,warn:In,block:Ln},O8={mask:`Mask`,warn:`Warn only`,block:`Block`},k8={system:`System prompt`,user:`Your message`,tool_result:`Tool output`,tool_args:`Tool arguments`,assistant:`Earlier replies`,tools:`Tool descriptions`};function A8({report:e}){let{t}=q(),n=S(e);if(!n)return null;let r=D8[n],i=new Set(e.hits.map(e=>e.token)).size;return(0,K.jsxs)(C8,{children:[(0,K.jsxs)(w8,{render:(0,K.jsx)(`span`,{className:G(`inline-flex shrink-0 items-center gap-0.5 text-[11px]`,E8[n]),"data-privacy-mask":n}),children:[(0,K.jsx)(r,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:i})]}),(0,K.jsxs)(T8,{className:`max-h-(--available-height) w-72 flex-col overflow-y-auto overscroll-contain text-xs`,children:[(0,K.jsx)(`p`,{className:`mb-1.5 font-medium`,children:t(`Privacy masking`)}),(0,K.jsx)(`ul`,{className:`space-y-1`,children:m(e.hits).map(e=>(0,K.jsxs)(`li`,{className:`flex flex-wrap gap-x-2`,children:[(0,K.jsx)(`span`,{className:E8[e.action],children:t(O8[e.action])}),(0,K.jsx)(`span`,{children:e.kind}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:t(k8[e.where]??e.where)}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.values>1?t(`{{count}} values`,{count:e.values}):e.preview}),e.count>1&&(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.count]})]},`${e.action}-${e.kind}-${e.where}`))}),e.restored>0&&(0,K.jsx)(`p`,{className:`mt-1.5 text-muted-foreground`,children:t(`Restored {{count}} in the reply`,{count:e.restored})})]})]})}function j8(e){let{inputTokens:t,outputTokens:n}=e;if(typeof t!=`number`||!Number.isFinite(t)||t<0||typeof n!=`number`||!Number.isFinite(n)||n<0)return null;let r=Math.max(0,t-n);return{tokens:r,percent:t>0?Math.round(r/t*100):null}}var M8={compressed:`Compressed`,unchanged:`Unchanged`,pending:`Background task started`,bypassed:`Bypassed`,unavailable:`Unavailable`};function N8({value:e}){let t=ne(e),{t:n}=q();if(!t)return null;let r=j8(t);return(0,K.jsxs)(`div`,{className:`border-border/60 border-t text-[10px] text-muted-foreground`,"data-rtk-status":t.status,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 px-3 py-1`,children:[(0,K.jsx)(`span`,{className:`font-semibold tracking-wide text-foreground/75`,children:`RTK`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:n(M8[t.status])}),r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:n(`~{{count}} tokens saved`,{count:DN(r.tokens)})}),r.percent!==null&&(0,K.jsxs)(`span`,{children:[`(`,r.percent,`%)`]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2 px-3 pb-2`,children:[t.status===`pending`&&(0,K.jsx)(`p`,{className:`rounded bg-muted/40 px-2 py-1 text-foreground/80`,children:n(`This is the startup receipt; see the task_output result for final statistics.`)}),(t.inputTokens!==void 0||t.reason)&&(0,K.jsxs)(`dl`,{className:`grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[t.inputTokens!==void 0&&t.outputTokens!==void 0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:n(`Input estimate`)}),(0,K.jsx)(`dd`,{className:`font-mono text-foreground/80`,children:n(`{{count}} tokens`,{count:DN(t.inputTokens)})}),(0,K.jsx)(`dt`,{children:n(`Output estimate`)}),(0,K.jsx)(`dd`,{className:`font-mono text-foreground/80`,children:n(`{{count}} tokens`,{count:DN(t.outputTokens)})})]}),t.reason&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{children:n(`Reason`)}),(0,K.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap text-foreground/80`,children:t.reason})]})]})]})]})}function P8(e,t,n){if(e==null||t===void 0||t<=e)return null;let r=Math.max(0,t-n);return{remainingMs:r,fraction:Math.min(1,r/(t-e))}}function F8(e,t,n=pe){let r=t-e;return r>=n?r:null}var I8={exit_nonzero:`Exit {{code}}`,deadline:`Killed at timeout`,stopped_by_user:`Stopped by you`,tty_required:`Needs terminal`,auth_required:`Needs login`,not_found:`Command not found`,not_executable:`Not executable`,binary_output:`Binary output`,output_truncated:`Log truncated`},L8={deadline:`Killed when its timeout was reached. Raise the timeout or run it in the background.`,tty_required:`Needs an interactive terminal. Use a non-interactive flag (such as --yes) or run it in your own terminal.`,auth_required:`Needs credentials. Sign in from your own terminal, then retry.`,not_found:`The program is not installed or not on PATH.`};function R8(e){return e?.kind===`deadline`?[`background`,`timeout`]:[]}function z8(e,t,n){let r=`\`\`\`\n${t}\n\`\`\``;return e===`background`?n(`Rerun this command with background: true:
261
261
 
262
262
  {{command}}`,{command:r}):n(`Rerun this command with timeout: {{seconds}}:
263
263
 
264
264
  {{command}}`,{seconds:600,command:r})}function B8(e,t,n){return t(e)?(n(),!0):!1}function V8(){let[e,t]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}var H8=5,U8=2*Math.PI*H8;function W8({startedAt:e,deadlineAt:t,output:n}){let{t:r}=q(),i=V8(),a=(0,U.useRef)({output:n,at:e??Date.now()});a.current.output!==n&&(a.current={output:n,at:Date.now()});let o=P8(e,t,i),s=F8(a.current.at,i);return!o&&s===null?null:(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[10px] text-muted-foreground/70 tabular-nums`,children:[s!==null&&(0,K.jsx)(`span`,{"data-shell-quiet":!0,className:`rounded bg-muted px-1`,children:r(`No output for {{seconds}}s`,{seconds:Math.floor(s/1e3)})}),o&&o.remainingMs>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-0.5`,title:r(`Moves to background in {{seconds}}s`,{seconds:Math.ceil(o.remainingMs/1e3)}),children:[(0,K.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`6`,cy:`6`,r:H8,fill:`none`,stroke:`currentColor`,opacity:`0.25`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`6`,r:H8,fill:`none`,stroke:`currentColor`,strokeDasharray:U8,strokeDashoffset:U8*(1-o.fraction),transform:`rotate(-90 6 6)`})]}),Math.ceil(o.remainingMs/1e3),`s`]})]})}function G8(e,t){return e.kind===`exit_nonzero`&&e.exitCode===void 0?t(`Failed`):t(I8[e.kind],{code:e.exitCode??``})}function K8({failure:e}){let{t}=q();return(0,K.jsx)(`span`,{"data-shell-failure":e.kind,className:G(`shrink-0 rounded px-1 text-[10px]`,e.retryable?`bg-muted text-muted-foreground`:`bg-destructive/10 text-destructive`),children:G8(e,t)})}function q8({warning:e}){let{t,locale:n}=q(),r=n===`zh`?bs(e):{what:e.reason};return(0,K.jsx)(`span`,{"data-dcg-warning":e.ruleId,title:[r.what,r.why,e.ruleId].filter(Boolean).join(`
265
- `),className:`shrink-0 rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:t(`dcg notice`)})}function J8({failure:e,command:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1);if(!e)return null;let a=L8[e.kind],o=R8(e);return(0,K.jsxs)(`div`,{"data-shell-status":e.kind,className:`mt-2 flex items-center gap-2 border-t border-current/10 pt-1.5 text-[11px] opacity-80`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:G8(e,n)}),a&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:n(a)}),o.map(e=>(0,K.jsx)(`button`,{type:`button`,"data-shell-rerun":e,onClick:()=>{B8(z8(e,t,n),nk,QO)},className:`flex shrink-0 items-center gap-1 underline-offset-2 hover:underline hover:opacity-100`,children:e===`background`?n(`Rerun in background`):n(`Rerun with {{seconds}}s timeout`,{seconds:600})},e)),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1e3)})},className:`ml-auto flex shrink-0 items-center gap-1 hover:opacity-100`,title:n(`Copy command`),children:[r?(0,K.jsx)(gt,{className:`h-3 w-3`}):(0,K.jsx)(Pt,{className:`h-3 w-3`}),n(`Copy command`)]})]})}function Y8({icon:e,state:t}){let n=t===`running`||t===`reviewing`;return(0,K.jsxs)(`span`,{className:G(`relative flex size-[22px] shrink-0 items-center justify-center rounded-full border text-muted-foreground`,n&&`border-transparent text-brand`,t===`error`&&`border-destructive/40 text-destructive`),children:[(0,K.jsx)(e,{className:`size-3`}),n&&(0,K.jsx)(`span`,{className:`absolute -inset-px animate-spin rounded-full border-[1.5px] border-brand/20 border-t-brand`})]})}function X8({state:e}){return(0,K.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:e===`running`||e===`reviewing`?(0,K.jsx)(`span`,{className:`size-2.5 animate-spin rounded-full border-[1.5px] border-border border-t-brand`}):e===`error`?(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive`}):(0,K.jsx)(`span`,{className:`size-1 rounded-full bg-current opacity-60`})})}var Z8={queued:[`Queued`,`bg-muted-foreground`],running:[`running`,`bg-amber-500`],awaiting_input:[`awaiting input`,`bg-amber-500`],validating:[`validating`,`bg-amber-500`],succeeded:[`succeeded`,`bg-emerald-500`],failed:[`failed`,`bg-destructive`],cancelled:[`cancelled`,`bg-muted-foreground`],interrupted:[`interrupted`,`bg-muted-foreground`],creating:[`creating`,`bg-amber-500`],ready:[`idle`,`bg-muted-foreground`],active:[`running`,`bg-amber-500`],parked:[`parked`,`bg-muted-foreground`],closed:[`closed`,`bg-muted-foreground`]};function Q8({view:e,titles:t}){let{t:n}=q();return(0,K.jsxs)(`div`,{className:`space-y-2 px-3 py-2 text-sm`,children:[e.kind===`report`&&e.text&&(0,K.jsx)(D3,{text:e.text}),e.kind===`report`&&e.value&&(0,K.jsx)(D3,{text:`\`\`\`json\n${e.value}\n\`\`\``}),e.kind===`report`&&e.error&&(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-destructive`,children:e.error}),e.runs.length>0&&(0,K.jsx)(`ul`,{className:`space-y-0.5 text-xs text-muted-foreground`,children:e.runs.map(e=>(0,K.jsx)($8,{run:e,title:t?.[e.agentId]},e.runId||e.agentId))}),e.kind===`list`&&e.runs.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`No agents`)}),e.kind===`wait`&&e.timedOut&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Timed out; unfinished agents keep running`)}),e.kind===`wait`&&e.interrupted&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Wait was interrupted`)}),(0,K.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:n(`Run info`)}),(0,K.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap font-mono`,children:e.info})]}),e.head&&(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-muted-foreground`,children:e.head})]})}function $8({run:e,title:t}){let{t:n}=q(),[r,i]=Z8[e.status]??[null,`bg-muted-foreground`],a=e.durationMs===null?``:n(`took {{duration}}`,{duration:ON(e.durationMs)});return(0,K.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,i)}),t&&(0,K.jsx)(`span`,{className:`truncate text-foreground`,children:t}),(0,K.jsx)(`span`,{className:`shrink-0`,children:[r?n(r):e.status,a].filter(Boolean).join(` · `)})]})}var e5=e=>!!e&&typeof e==`object`&&!Array.isArray(e),t5=e=>typeof e==`string`&&e.trim()?e:null;function n5(e){if(!e5(e))return null;let{agentId:t,runId:n,status:r,createdAt:i,startedAt:a,finishedAt:o}=e;if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return null;let s=typeof a==`number`?a:i;return{agentId:t,runId:n,status:r,durationMs:typeof o==`number`&&typeof s==`number`?Math.max(0,o-s):null}}var r5=new Set([`closed`,`parked`,`creating`]);function i5(e){if(!e5(e))return null;let{agentId:t,status:n,latestRun:r}=e;return typeof t!=`string`||typeof n!=`string`?null:(r5.has(n)?null:n5(r))??{agentId:t,runId:``,status:n,durationMs:null}}function a5(e,t){let n=RV(t);if(!n)return null;let{head:r,value:i}=n;if(e===`report`){let e=n5(i.run);if(!e)return null;let{text:t,value:n,error:a,...o}=i;return{kind:`report`,head:r,runs:[e],text:t5(t),value:n==null?null:JSON.stringify(n,null,2),error:t5(a),info:JSON.stringify(o,null,2)}}if(e===`list`){if(!Array.isArray(i.agents))return null;let e=i.agents.flatMap(e=>i5(e)??[]);return e.length===i.agents.length?{kind:`list`,head:r,runs:e,info:JSON.stringify(i,null,2)}:null}let a=e===`wait`?i:e===void 0?i.report:null;if(!e5(a)||!Array.isArray(a.runs))return(e===void 0||e===`resume`)&&i.report===void 0&&typeof i.agentId==`string`&&typeof i.runId==`string`?{kind:`receipt`,head:r,runs:[],info:JSON.stringify(i,null,2)}:null;let o=a.runs.flatMap(e=>n5(e)??[]);return o.length===a.runs.length?{kind:`wait`,head:r,runs:o,timedOut:a.timedOut===!0,interrupted:a.interrupted===!0,info:JSON.stringify(i,null,2)}:null}var o5={"restart-lost":`This subagent was started before EnsoCode restarted, and its record was lost in the restart`,"other-owner":`This subagent belongs to another conversation and cannot be controlled here`,"not-found":`This conversation has no subagent with this id (mistyped, or agentId and runId mixed up)`};function s5(e){let t=/^([a-z][a-z-]*):\s/u.exec(e?.trim()??``)?.[1];return t&&o5[t]||null}function c5({items:e,live:t=[],onOpen:n}){let{t:r}=q(),[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{"data-enso":`task-wrap-up`,"data-open":i?`true`:`false`,className:oP,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`flex w-full items-start gap-2 text-left hover:text-foreground`,children:[(0,K.jsx)(Xt,{className:sP}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:r(`{{count}} background tasks to wrap up: stop them or say why they keep running`,{count:e.length})})]}),i&&(0,K.jsx)(`ul`,{className:`mt-1.5 space-y-1.5 border-t border-border/60 pt-1.5`,children:e.map(e=>{let r=t.find(t=>t.taskId===e.taskId);return(0,K.jsx)(l5,{item:e,command:r?.command??e.command,onOpen:r?.status===`running`?n:void 0},e.taskId)})})]})}function l5({item:e,command:t,onOpen:n}){let{t:r}=q(),[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`li`,{"data-enso":`task-wrap-up-item`,"data-task-id":e.taskId,className:`flex min-w-0 gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`min-w-0 flex-1 text-left hover:text-foreground`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-foreground`,children:e.taskId}),e.ran&&(0,K.jsx)(`span`,{className:`shrink-0`,children:r(`Running for {{duration}}`,{duration:e.ran})})]}),(0,K.jsx)(`span`,{"data-enso":`task-wrap-up-command`,title:t,className:G(`block font-mono text-[11px]`,i?`whitespace-pre-wrap break-all`:`truncate`),children:t})]}),n&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`task-wrap-up-open`,title:r(`Show in task bar`),"aria-label":r(`Show in task bar`),onClick:()=>n(e.taskId),className:`flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(st,{className:`h-3.5 w-3.5`})})]})}function u5({command:e,output:t,failure:n}){let r=E(e=>e.terminalTheme),i=E(e=>e.terminalFontFamily),a=ye(r)??ae;return(0,K.jsxs)(`div`,{"data-slot":`terminal-output`,className:`px-3 py-2 text-xs leading-relaxed`,style:{backgroundColor:a.background,"--terminal-bg":a.background,color:a.foreground,fontFamily:i},children:[(0,K.jsxs)(`div`,{className:`whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,K.jsx)(`span`,{style:{color:a.green},children:`$ `}),e]}),t&&(0,K.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap [overflow-wrap:anywhere]`,style:{fontFamily:`inherit`},children:c6(t)}),(0,K.jsx)(J8,{failure:n,command:e})]})}function d5(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(!(n.role!==`toolResult`||n.toolName!==`todo`||!n.todos))return n.todos.some(e=>e.status!==`completed`)?{id:n.toolCallId??String(t),todos:n.todos}:null}return null}function f5({todos:e}){return(0,K.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[e.status===`completed`?(0,K.jsx)(gt,{className:`mt-0.5 h-3 w-3 shrink-0 text-brand`}):e.status===`in_progress`?(0,K.jsx)(wt,{className:`mt-0.5 h-3 w-3 shrink-0 text-brand`}):(0,K.jsx)(Ot,{className:`mt-0.5 h-3 w-3 shrink-0 text-muted-foreground/50`}),(0,K.jsx)(`span`,{className:G(e.status===`completed`?`text-muted-foreground line-through`:e.status===`in_progress`?`font-medium`:`text-muted-foreground`),children:e.content})]},e.content))})}function p5({done:e,total:t,className:n}){return(0,K.jsx)(`div`,{className:G(`h-0.5 overflow-hidden rounded-full bg-border`,n),children:(0,K.jsx)(`div`,{className:`h-full rounded-full bg-brand transition-[width]`,style:{width:`${t?e/t*100:0}%`}})})}var m5=new Set;function h5({conversationId:e}){let{t}=q(),n=E(e=>e.pinUnfinishedTodos),r=nP(t=>t.conversations[e]?.messages),i=(0,U.useMemo)(()=>n&&r?d5(r):null,[n,r]),[a,o]=(0,U.useState)(!1),[,s]=(0,U.useState)(0);if(!i||m5.has(i.id))return null;let c=i.todos.filter(e=>e.status===`completed`).length,l=i.todos.find(e=>e.status===`in_progress`)??i.todos.find(e=>e.status===`pending`);return(0,K.jsxs)(`div`,{"data-enso":`todo`,className:`mb-1.5 rounded-xl border bg-card px-3 py-1.5 text-xs shadow-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,K.jsx)(an,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:t(`Todos`)}),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums`,children:[c,`/`,i.todos.length]}),!a&&l&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,title:l.content,children:l.content}),a?(0,K.jsx)(_t,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,K.jsx)(vt,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,K.jsx)(`button`,{type:`button`,title:t(`Hide until the todo list updates`),onClick:()=>{m5.add(i.id),s(e=>e+1)},className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]}),a&&(0,K.jsxs)(`div`,{className:`mt-1.5 max-h-48 overflow-y-auto pb-0.5`,children:[(0,K.jsx)(p5,{done:c,total:i.todos.length,className:`mb-2`}),(0,K.jsx)(f5,{todos:i.todos})]})]})}function g5({image:e,path:t,alt:n}){let{t:r}=q(),i=(0,U.useMemo)(()=>eB(e,t,!0),[e,t]),[a,o]=(0,U.useState)(!1);return!i||a?(0,K.jsx)(`p`,{"data-slot":`tool-image-missing`,className:`text-xs text-muted-foreground`,children:r(`Image unavailable`)}):(0,K.jsx)(WG,{src:i,alt:n,lazy:!0,onError:()=>o(!0),frameClassName:`block max-w-full`,className:`block max-h-64 max-w-full rounded-md border border-border/60 bg-muted/40 object-contain`})}function _5({image:e,output:t}){let{t:n}=q(),r=(0,U.useMemo)(()=>Qz(t),[t]),i=[];return r?.path&&i.push([n(`Path`),r.path]),r?.width&&r.height&&i.push([n(`Dimensions`),`${r.width} × ${r.height}`]),r?.size!==null&&r?.size!==void 0&&i.push([n(`File size`),BB(r.size)]),(0,K.jsxs)(`div`,{"data-slot":`image-view`,className:`space-y-2 px-3 py-2`,children:[(0,K.jsx)(g5,{image:e,path:r?.path,alt:r?.path??``}),i.length>0?(0,K.jsx)(`dl`,{className:`space-y-0.5 text-xs`,children:i.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,K.jsx)(`dt`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:t})]},e))}):null]})}function v5(){let e=nP(e=>e.conversations),t=E(e=>e.projects),n=YR(e=>e.secretary.board.todos),r=YR(e=>e.secretary.proposals);return{sessionTitle(t){return e[t]?.title?.trim()||void 0},projectName(e){let n=t.find(t=>t.id===e);return n?.alias?.trim()||n?.name?.trim()||void 0},todoText(e){return n.find(t=>t.id===e)?.text},proposal(e){let t=r[e];return t?{status:t.status,kind:t.kind}:void 0}}}function y5(e){let t=e.cardPeers??[];return[{name:e.name,args:e.args??null,output:e.output,state:e.state,...e.image?{image:e.image}:{}},...t.map(t=>({name:e.name,args:t.args??null,output:t.output,state:t.state,...t.image?{image:t.image}:{}}))]}function b5({item:e,framed:t=!1}){let{t:n,locale:r}=q(),i=v5(),a=nP(e=>e.conversations),o=sB(y5(e),{t:n,locale:r===`zh`?`zh`:`en`,lookup:i}),s=qB(o.cards.map(e=>e.state)),[c,l]=(0,U.useState)(!1),u=o.grouped?null:o.cards[0]??null;return(0,K.jsxs)(`div`,{"data-enso":`tool-card`,"data-tool":e.name,"data-open":c?`true`:`false`,"data-grouped":o.grouped?`true`:`false`,"data-count":o.cards.length,className:`my-0.5 w-full min-w-0 text-[13px]`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`tool-card-expand`,"aria-expanded":c,onClick:()=>l(e=>!e),className:`group/step flex min-h-6 w-full min-w-0 items-center gap-2 text-left text-[13px] text-muted-foreground`,children:[(0,K.jsx)(X8,{state:s}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.grouped?o.title:u?.title}),u?.status?(0,K.jsx)(x5,{status:u.status}):null,(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 opacity-0 transition-[opacity,transform] group-hover/step:opacity-100`,c&&`rotate-90 opacity-100`)})]}),c&&o.grouped?o.cards.map((e,n)=>(0,K.jsx)(S5,{card:e,known:a,onOpen:h6,framed:t},`${e.title}-${n}`)):null,c&&u?(0,K.jsx)(C5,{card:u,known:a,onOpen:h6,framed:t}):null]})}function x5({status:e}){return(0,K.jsx)(`span`,{"data-enso":`tool-card-status`,"data-tone":e.tone,className:G(`shrink-0 rounded px-1 py-px text-[10px]`,e.tone===`error`&&`bg-destructive/15 text-destructive`,e.tone===`ok`&&`bg-success/15 text-success`,(e.tone===`queued`||e.tone===`pending`)&&`bg-warning/15 text-warning`,e.tone===`neutral`&&`bg-muted text-muted-foreground`),children:e.label})}function S5({card:e,known:t,onOpen:n,framed:r}){let[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{className:`pl-5`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`tool-card-expand`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`group/step flex min-h-6 w-full min-w-0 items-center gap-2 text-left text-[13px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.status?(0,K.jsx)(x5,{status:e.status}):null,(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 opacity-0 transition-[opacity,transform] group-hover/step:opacity-100`,i&&`rotate-90 opacity-100`)})]}),i?(0,K.jsx)(C5,{card:e,known:t,onOpen:n,framed:r,nested:!0}):null]})}function C5({card:e,known:t,onOpen:n,framed:r,nested:i=!1}){let{t:a}=q(),[o,s]=(0,U.useState)(!1),c=(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-raw`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground`,children:a(`View raw data`)}),l=o?(0,K.jsxs)(`div`,{className:G(`mt-1 space-y-1`,r&&`max-h-60 overflow-auto`),children:[e.rawArgs&&(0,K.jsx)(`pre`,{className:`overflow-auto font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawArgs}),e.rawOutput&&(0,K.jsx)(`pre`,{className:`overflow-auto font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawOutput})]}):null,u=(e,r)=>(0,K.jsx)(Bne,{block:e,known:t,onOpen:n},`${e.kind}-${r}`);if(r){let t=[];e.blocks.forEach((e,n)=>{let r=e.kind===`prompt`,i=t.at(-1);!r&&i&&!i.prompt?i.blocks.push([e,n]):t.push({prompt:r,blocks:[[e,n]]})});let n=t.at(-1),r=!n||n.prompt,a=(0,K.jsxs)(`div`,{children:[c,l]});return(0,K.jsxs)(`div`,{"data-enso":`tool-card-body`,"data-framed":`true`,className:G(`mt-1 mb-1.5 min-w-0 overflow-hidden rounded-lg border border-border/70 bg-card text-[12px]`,!i&&`ml-5`),children:[t.map((e,t)=>(0,K.jsxs)(`div`,{className:G(`min-w-0`,t>0&&`border-t border-border/60`,!e.prompt&&`space-y-1.5 px-3 py-2`),children:[e.blocks.map(([e,t])=>e.kind===`prompt`?(0,K.jsx)(T5,{label:e.label,text:e.text},t):u(e,t)),!r&&e===n?a:null]},t)),r?(0,K.jsx)(`div`,{className:G(`px-3 py-2`,n&&`border-t border-border/60`),children:a}):null]})}return(0,K.jsxs)(`div`,{"data-enso":`tool-card-body`,className:`space-y-1 py-0.5 pl-5 text-[12px]`,children:[(0,K.jsx)(`div`,{className:`space-y-1`,children:e.blocks.map(u)}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-raw`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`mt-1 text-[11px] text-muted-foreground hover:text-foreground`,children:a(`View raw data`)}),l]})}var Lne={"--chat-h1-size":`1em`,"--chat-h2-size":`1em`,"--chat-h3-size":`1em`,"--chat-h4-size":`1em`,"--chat-code-block-size":`11px`},w5=4;function Rne(e){let t=e.split(`
265
+ `),className:`shrink-0 rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:t(`dcg notice`)})}function J8({failure:e,command:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1);if(!e)return null;let a=L8[e.kind],o=R8(e);return(0,K.jsxs)(`div`,{"data-shell-status":e.kind,className:`mt-2 flex items-center gap-2 border-t border-current/10 pt-1.5 text-[11px] opacity-80`,children:[(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:G8(e,n)}),a&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:n(a)}),o.map(e=>(0,K.jsx)(`button`,{type:`button`,"data-shell-rerun":e,onClick:()=>{B8(z8(e,t,n),tk,ZO)},className:`flex shrink-0 items-center gap-1 underline-offset-2 hover:underline hover:opacity-100`,children:e===`background`?n(`Rerun in background`):n(`Rerun with {{seconds}}s timeout`,{seconds:600})},e)),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1e3)})},className:`ml-auto flex shrink-0 items-center gap-1 hover:opacity-100`,title:n(`Copy command`),children:[r?(0,K.jsx)(gt,{className:`h-3 w-3`}):(0,K.jsx)(Pt,{className:`h-3 w-3`}),n(`Copy command`)]})]})}function Y8({icon:e,state:t}){let n=t===`running`||t===`reviewing`;return(0,K.jsxs)(`span`,{className:G(`relative flex size-[22px] shrink-0 items-center justify-center rounded-full border text-muted-foreground`,n&&`border-transparent text-brand`,t===`error`&&`border-destructive/40 text-destructive`),children:[(0,K.jsx)(e,{className:`size-3`}),n&&(0,K.jsx)(`span`,{className:`absolute -inset-px animate-spin rounded-full border-[1.5px] border-brand/20 border-t-brand`})]})}function X8({state:e}){return(0,K.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:e===`running`||e===`reviewing`?(0,K.jsx)(`span`,{className:`size-2.5 animate-spin rounded-full border-[1.5px] border-border border-t-brand`}):e===`error`?(0,K.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive`}):(0,K.jsx)(`span`,{className:`size-1 rounded-full bg-current opacity-60`})})}var Z8={queued:[`Queued`,`bg-muted-foreground`],running:[`running`,`bg-amber-500`],awaiting_input:[`awaiting input`,`bg-amber-500`],validating:[`validating`,`bg-amber-500`],succeeded:[`succeeded`,`bg-emerald-500`],failed:[`failed`,`bg-destructive`],cancelled:[`cancelled`,`bg-muted-foreground`],interrupted:[`interrupted`,`bg-muted-foreground`],creating:[`creating`,`bg-amber-500`],ready:[`idle`,`bg-muted-foreground`],active:[`running`,`bg-amber-500`],parked:[`parked`,`bg-muted-foreground`],closed:[`closed`,`bg-muted-foreground`]};function Q8({view:e,titles:t}){let{t:n}=q();return(0,K.jsxs)(`div`,{className:`space-y-2 px-3 py-2 text-sm`,children:[e.kind===`report`&&e.text&&(0,K.jsx)(D3,{text:e.text}),e.kind===`report`&&e.value&&(0,K.jsx)(D3,{text:`\`\`\`json\n${e.value}\n\`\`\``}),e.kind===`report`&&e.error&&(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-destructive`,children:e.error}),e.runs.length>0&&(0,K.jsx)(`ul`,{className:`space-y-0.5 text-xs text-muted-foreground`,children:e.runs.map(e=>(0,K.jsx)($8,{run:e,title:t?.[e.agentId]},e.runId||e.agentId))}),e.kind===`list`&&e.runs.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`No agents`)}),e.kind===`wait`&&e.timedOut&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Timed out; unfinished agents keep running`)}),e.kind===`wait`&&e.interrupted&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Wait was interrupted`)}),(0,K.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:n(`Run info`)}),(0,K.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap font-mono`,children:e.info})]}),e.head&&(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-xs text-muted-foreground`,children:e.head})]})}function $8({run:e,title:t}){let{t:n}=q(),[r,i]=Z8[e.status]??[null,`bg-muted-foreground`],a=e.durationMs===null?``:n(`took {{duration}}`,{duration:ON(e.durationMs)});return(0,K.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,i)}),t&&(0,K.jsx)(`span`,{className:`truncate text-foreground`,children:t}),(0,K.jsx)(`span`,{className:`shrink-0`,children:[r?n(r):e.status,a].filter(Boolean).join(` · `)})]})}var e5=e=>!!e&&typeof e==`object`&&!Array.isArray(e),t5=e=>typeof e==`string`&&e.trim()?e:null;function n5(e){if(!e5(e))return null;let{agentId:t,runId:n,status:r,createdAt:i,startedAt:a,finishedAt:o}=e;if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return null;let s=typeof a==`number`?a:i;return{agentId:t,runId:n,status:r,durationMs:typeof o==`number`&&typeof s==`number`?Math.max(0,o-s):null}}var r5=new Set([`closed`,`parked`,`creating`]);function i5(e){if(!e5(e))return null;let{agentId:t,status:n,latestRun:r}=e;return typeof t!=`string`||typeof n!=`string`?null:(r5.has(n)?null:n5(r))??{agentId:t,runId:``,status:n,durationMs:null}}function a5(e,t){let n=RV(t);if(!n)return null;let{head:r,value:i}=n;if(e===`report`){let e=n5(i.run);if(!e)return null;let{text:t,value:n,error:a,...o}=i;return{kind:`report`,head:r,runs:[e],text:t5(t),value:n==null?null:JSON.stringify(n,null,2),error:t5(a),info:JSON.stringify(o,null,2)}}if(e===`list`){if(!Array.isArray(i.agents))return null;let e=i.agents.flatMap(e=>i5(e)??[]);return e.length===i.agents.length?{kind:`list`,head:r,runs:e,info:JSON.stringify(i,null,2)}:null}let a=e===`wait`?i:e===void 0?i.report:null;if(!e5(a)||!Array.isArray(a.runs))return(e===void 0||e===`resume`)&&i.report===void 0&&typeof i.agentId==`string`&&typeof i.runId==`string`?{kind:`receipt`,head:r,runs:[],info:JSON.stringify(i,null,2)}:null;let o=a.runs.flatMap(e=>n5(e)??[]);return o.length===a.runs.length?{kind:`wait`,head:r,runs:o,timedOut:a.timedOut===!0,interrupted:a.interrupted===!0,info:JSON.stringify(i,null,2)}:null}var o5={"restart-lost":`This subagent was started before EnsoCode restarted, and its record was lost in the restart`,"other-owner":`This subagent belongs to another conversation and cannot be controlled here`,"not-found":`This conversation has no subagent with this id (mistyped, or agentId and runId mixed up)`};function s5(e){let t=/^([a-z][a-z-]*):\s/u.exec(e?.trim()??``)?.[1];return t&&o5[t]||null}function c5({items:e,live:t=[],onOpen:n}){let{t:r}=q(),[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{"data-enso":`task-wrap-up`,"data-open":i?`true`:`false`,className:oP,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`flex w-full items-start gap-2 text-left hover:text-foreground`,children:[(0,K.jsx)(Xt,{className:sP}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:r(`{{count}} background tasks to wrap up: stop them or say why they keep running`,{count:e.length})})]}),i&&(0,K.jsx)(`ul`,{className:`mt-1.5 space-y-1.5 border-t border-border/60 pt-1.5`,children:e.map(e=>{let r=t.find(t=>t.taskId===e.taskId);return(0,K.jsx)(l5,{item:e,command:r?.command??e.command,onOpen:r?.status===`running`?n:void 0},e.taskId)})})]})}function l5({item:e,command:t,onOpen:n}){let{t:r}=q(),[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`li`,{"data-enso":`task-wrap-up-item`,"data-task-id":e.taskId,className:`flex min-w-0 gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`min-w-0 flex-1 text-left hover:text-foreground`,children:[(0,K.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-foreground`,children:e.taskId}),e.ran&&(0,K.jsx)(`span`,{className:`shrink-0`,children:r(`Running for {{duration}}`,{duration:e.ran})})]}),(0,K.jsx)(`span`,{"data-enso":`task-wrap-up-command`,title:t,className:G(`block font-mono text-[11px]`,i?`whitespace-pre-wrap break-all`:`truncate`),children:t})]}),n&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`task-wrap-up-open`,title:r(`Show in task bar`),"aria-label":r(`Show in task bar`),onClick:()=>n(e.taskId),className:`flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(st,{className:`h-3.5 w-3.5`})})]})}function u5({command:e,output:t,failure:n}){let r=E(e=>e.terminalTheme),i=E(e=>e.terminalFontFamily),a=ye(r)??ae;return(0,K.jsxs)(`div`,{"data-slot":`terminal-output`,className:`px-3 py-2 text-xs leading-relaxed`,style:{backgroundColor:a.background,"--terminal-bg":a.background,color:a.foreground,fontFamily:i},children:[(0,K.jsxs)(`div`,{className:`whitespace-pre-wrap [overflow-wrap:anywhere]`,children:[(0,K.jsx)(`span`,{style:{color:a.green},children:`$ `}),e]}),t&&(0,K.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap [overflow-wrap:anywhere]`,style:{fontFamily:`inherit`},children:c6(t)}),(0,K.jsx)(J8,{failure:n,command:e})]})}function d5(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(!(n.role!==`toolResult`||n.toolName!==`todo`||!n.todos))return n.todos.some(e=>e.status!==`completed`)?{id:n.toolCallId??String(t),todos:n.todos}:null}return null}function f5({todos:e}){return(0,K.jsx)(`ul`,{className:`space-y-0.5 text-xs`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[e.status===`completed`?(0,K.jsx)(gt,{className:`mt-0.5 h-3 w-3 shrink-0 text-brand`}):e.status===`in_progress`?(0,K.jsx)(wt,{className:`mt-0.5 h-3 w-3 shrink-0 text-brand`}):(0,K.jsx)(Ot,{className:`mt-0.5 h-3 w-3 shrink-0 text-muted-foreground/50`}),(0,K.jsx)(`span`,{className:G(e.status===`completed`?`text-muted-foreground line-through`:e.status===`in_progress`?`font-medium`:`text-muted-foreground`),children:e.content})]},e.content))})}function p5({done:e,total:t,className:n}){return(0,K.jsx)(`div`,{className:G(`h-0.5 overflow-hidden rounded-full bg-border`,n),children:(0,K.jsx)(`div`,{className:`h-full rounded-full bg-brand transition-[width]`,style:{width:`${t?e/t*100:0}%`}})})}var m5=new Set;function h5({conversationId:e}){let{t}=q(),n=E(e=>e.pinUnfinishedTodos),r=nP(t=>t.conversations[e]?.messages),i=(0,U.useMemo)(()=>n&&r?d5(r):null,[n,r]),[a,o]=(0,U.useState)(!1),[,s]=(0,U.useState)(0);if(!i||m5.has(i.id))return null;let c=i.todos.filter(e=>e.status===`completed`).length,l=i.todos.find(e=>e.status===`in_progress`)??i.todos.find(e=>e.status===`pending`);return(0,K.jsxs)(`div`,{"data-enso":`todo`,className:`mb-1.5 rounded-xl border bg-card px-3 py-1.5 text-xs shadow-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,children:[(0,K.jsx)(an,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:t(`Todos`)}),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground tabular-nums`,children:[c,`/`,i.todos.length]}),!a&&l&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,title:l.content,children:l.content}),a?(0,K.jsx)(_t,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`}):(0,K.jsx)(vt,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,K.jsx)(`button`,{type:`button`,title:t(`Hide until the todo list updates`),onClick:()=>{m5.add(i.id),s(e=>e+1)},className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]}),a&&(0,K.jsxs)(`div`,{className:`mt-1.5 max-h-48 overflow-y-auto pb-0.5`,children:[(0,K.jsx)(p5,{done:c,total:i.todos.length,className:`mb-2`}),(0,K.jsx)(f5,{todos:i.todos})]})]})}function g5({image:e,path:t,alt:n}){let{t:r}=q(),i=(0,U.useMemo)(()=>eB(e,t,!0),[e,t]),[a,o]=(0,U.useState)(!1);return!i||a?(0,K.jsx)(`p`,{"data-slot":`tool-image-missing`,className:`text-xs text-muted-foreground`,children:r(`Image unavailable`)}):(0,K.jsx)(WG,{src:i,alt:n,lazy:!0,onError:()=>o(!0),frameClassName:`block max-w-full`,className:`block max-h-64 max-w-full rounded-md border border-border/60 bg-muted/40 object-contain`})}function _5({image:e,output:t}){let{t:n}=q(),r=(0,U.useMemo)(()=>Qz(t),[t]),i=[];return r?.path&&i.push([n(`Path`),r.path]),r?.width&&r.height&&i.push([n(`Dimensions`),`${r.width} × ${r.height}`]),r?.size!==null&&r?.size!==void 0&&i.push([n(`File size`),BB(r.size)]),(0,K.jsxs)(`div`,{"data-slot":`image-view`,className:`space-y-2 px-3 py-2`,children:[(0,K.jsx)(g5,{image:e,path:r?.path,alt:r?.path??``}),i.length>0?(0,K.jsx)(`dl`,{className:`space-y-0.5 text-xs`,children:i.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,K.jsx)(`dt`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 break-all font-mono`,children:t})]},e))}):null]})}function v5(){let e=nP(e=>e.conversations),t=E(e=>e.projects),n=YR(e=>e.secretary.board.todos),r=YR(e=>e.secretary.proposals);return{sessionTitle(t){return e[t]?.title?.trim()||void 0},projectName(e){let n=t.find(t=>t.id===e);return n?.alias?.trim()||n?.name?.trim()||void 0},todoText(e){return n.find(t=>t.id===e)?.text},proposal(e){let t=r[e];return t?{status:t.status,kind:t.kind}:void 0}}}function y5(e){let t=e.cardPeers??[];return[{name:e.name,args:e.args??null,output:e.output,state:e.state,...e.image?{image:e.image}:{}},...t.map(t=>({name:e.name,args:t.args??null,output:t.output,state:t.state,...t.image?{image:t.image}:{}}))]}function b5({item:e,framed:t=!1}){let{t:n,locale:r}=q(),i=v5(),a=nP(e=>e.conversations),o=sB(y5(e),{t:n,locale:r===`zh`?`zh`:`en`,lookup:i}),s=qB(o.cards.map(e=>e.state)),[c,l]=(0,U.useState)(!1),u=o.grouped?null:o.cards[0]??null;return(0,K.jsxs)(`div`,{"data-enso":`tool-card`,"data-tool":e.name,"data-open":c?`true`:`false`,"data-grouped":o.grouped?`true`:`false`,"data-count":o.cards.length,className:`my-0.5 w-full min-w-0 text-[13px]`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`tool-card-expand`,"aria-expanded":c,onClick:()=>l(e=>!e),className:`group/step flex min-h-6 w-full min-w-0 items-center gap-2 text-left text-[13px] text-muted-foreground`,children:[(0,K.jsx)(X8,{state:s}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o.grouped?o.title:u?.title}),u?.status?(0,K.jsx)(x5,{status:u.status}):null,(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 opacity-0 transition-[opacity,transform] group-hover/step:opacity-100`,c&&`rotate-90 opacity-100`)})]}),c&&o.grouped?o.cards.map((e,n)=>(0,K.jsx)(S5,{card:e,known:a,onOpen:h6,framed:t},`${e.title}-${n}`)):null,c&&u?(0,K.jsx)(C5,{card:u,known:a,onOpen:h6,framed:t}):null]})}function x5({status:e}){return(0,K.jsx)(`span`,{"data-enso":`tool-card-status`,"data-tone":e.tone,className:G(`shrink-0 rounded px-1 py-px text-[10px]`,e.tone===`error`&&`bg-destructive/15 text-destructive`,e.tone===`ok`&&`bg-success/15 text-success`,(e.tone===`queued`||e.tone===`pending`)&&`bg-warning/15 text-warning`,e.tone===`neutral`&&`bg-muted text-muted-foreground`),children:e.label})}function S5({card:e,known:t,onOpen:n,framed:r}){let[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{className:`pl-5`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`tool-card-expand`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`group/step flex min-h-6 w-full min-w-0 items-center gap-2 text-left text-[13px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),e.status?(0,K.jsx)(x5,{status:e.status}):null,(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 opacity-0 transition-[opacity,transform] group-hover/step:opacity-100`,i&&`rotate-90 opacity-100`)})]}),i?(0,K.jsx)(C5,{card:e,known:t,onOpen:n,framed:r,nested:!0}):null]})}function C5({card:e,known:t,onOpen:n,framed:r,nested:i=!1}){let{t:a}=q(),[o,s]=(0,U.useState)(!1),c=(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-raw`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground`,children:a(`View raw data`)}),l=o?(0,K.jsxs)(`div`,{className:G(`mt-1 space-y-1`,r&&`max-h-60 overflow-auto`),children:[e.rawArgs&&(0,K.jsx)(`pre`,{className:`overflow-auto font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawArgs}),e.rawOutput&&(0,K.jsx)(`pre`,{className:`overflow-auto font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawOutput})]}):null,u=(e,r)=>(0,K.jsx)(Bne,{block:e,known:t,onOpen:n},`${e.kind}-${r}`);if(r){let t=[];e.blocks.forEach((e,n)=>{let r=e.kind===`prompt`,i=t.at(-1);!r&&i&&!i.prompt?i.blocks.push([e,n]):t.push({prompt:r,blocks:[[e,n]]})});let n=t.at(-1),r=!n||n.prompt,a=(0,K.jsxs)(`div`,{children:[c,l]});return(0,K.jsxs)(`div`,{"data-enso":`tool-card-body`,"data-framed":`true`,className:G(`mt-1 mb-1.5 min-w-0 overflow-hidden rounded-lg border border-border/70 bg-card text-[12px]`,!i&&`ml-5`),children:[t.map((e,t)=>(0,K.jsxs)(`div`,{className:G(`min-w-0`,t>0&&`border-t border-border/60`,!e.prompt&&`space-y-1.5 px-3 py-2`),children:[e.blocks.map(([e,t])=>e.kind===`prompt`?(0,K.jsx)(T5,{label:e.label,text:e.text},t):u(e,t)),!r&&e===n?a:null]},t)),r?(0,K.jsx)(`div`,{className:G(`px-3 py-2`,n&&`border-t border-border/60`),children:a}):null]})}return(0,K.jsxs)(`div`,{"data-enso":`tool-card-body`,className:`space-y-1 py-0.5 pl-5 text-[12px]`,children:[(0,K.jsx)(`div`,{className:`space-y-1`,children:e.blocks.map(u)}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-raw`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`mt-1 text-[11px] text-muted-foreground hover:text-foreground`,children:a(`View raw data`)}),l]})}var Lne={"--chat-h1-size":`1em`,"--chat-h2-size":`1em`,"--chat-h3-size":`1em`,"--chat-h4-size":`1em`,"--chat-code-block-size":`11px`},w5=4;function Rne(e){let t=e.split(`
266
266
  `).filter(e=>e.trim()&&!/^\s*(```|~~~)/.test(e)).map(e=>e.replace(/^\s*#{1,6}\s+/,``).trimEnd());return{preview:t.slice(0,w5).join(`
267
267
  `),folded:t.length>w5||e.length>320}}function T5({label:e,text:t}){let{t:n}=q(),{preview:r,folded:i}=Rne(t),[a,o]=(0,U.useState)(!1),s=a||!i;return(0,K.jsxs)(`section`,{"data-enso":`tool-card-prompt`,"data-open":s?`true`:`false`,className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3 pt-1.5 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e}),(0,K.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2.5`,children:[i&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-prompt-toggle`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`hover:text-foreground`,children:n(a?`Show less`:`Show full text`)}),(0,K.jsx)(Fs,{text:t,label:n(`Copy`)})]})]}),s?(0,K.jsx)(`div`,{"data-enso":`tool-card-prompt-body`,style:Lne,className:`max-h-80 min-w-0 overflow-y-auto overscroll-contain px-3 pt-1 pb-2 text-xs leading-relaxed [&_:is(h1,h2,h3,h4)]:mt-2.5 [&_:is(h1,h2,h3,h4)]:mb-1 [&_[data-enso=code-block]>:first-child]:border-0`,children:(0,K.jsx)(D3,{text:t})}):(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-prompt-preview`,onClick:()=>o(!0),className:`line-clamp-4 block w-full min-w-0 px-3 pt-1 pb-2 text-left text-xs leading-relaxed text-muted-foreground break-words whitespace-pre-wrap`,children:r})]})}function zne({row:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),i=e.display===`long`&&(e.value.length>120||e.value.includes(`
268
268
  `));return(0,K.jsxs)(`div`,{className:`contents`,children:[(0,K.jsx)(`dt`,{className:`whitespace-nowrap text-muted-foreground`,children:e.label}),(0,K.jsxs)(`dd`,{"data-enso":`tool-card-kv-value`,"data-display":e.display,title:e.display===`path`?e.value:void 0,className:G(`min-w-0`,e.display===`path`?`truncate`:`whitespace-pre-wrap break-words`),children:[i&&!n?(0,K.jsx)(`span`,{className:`line-clamp-2`,children:e.value}):e.value,i&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-kv-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),className:`block text-[11px] text-muted-foreground hover:text-foreground`,children:t(n?`Show less`:`Show more`)})]})]})}function Bne({block:e,known:t,onOpen:n}){let{t:r}=q(),[i,a]=(0,U.useState)(!1);if(e.kind===`error`)return(0,K.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs whitespace-pre-wrap`,children:e.text});if(e.kind===`note`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-xs`,children:e.text});if(e.kind===`prompt`)return(0,K.jsx)(T5,{label:e.label,text:e.text});if(e.kind===`markdown`){let t=e.collapsed&&!i;return(0,K.jsxs)(`div`,{className:`text-sm`,children:[t?(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.text.split(`
269
- `).find(e=>e.trim())}):(0,K.jsx)(D3,{text:e.text}),e.collapsed&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-fold`,onClick:()=>a(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r(i?`Show less`:`Show more`)})]})}return e.kind===`image`?(0,K.jsx)(`div`,{"data-enso":`tool-card-image`,children:(0,K.jsx)(g5,{image:e.image,path:e.path,alt:e.alt})}):e.kind===`session`?t[e.id]?(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-session`,"data-conversation-id":e.id,onClick:()=>n(e.id),className:`truncate text-left text-xs text-foreground underline-offset-2 hover:underline`,children:e.label}):(0,K.jsx)(`p`,{className:`text-xs`,children:e.label}):e.kind===`kv`?(0,K.jsx)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-xs`,children:e.rows.map(e=>(0,K.jsx)(zne,{row:e},e.label))}):e.kind===`diff`?(0,K.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:e.rows.map(e=>(0,K.jsxs)(`p`,{className:`min-w-0 break-words`,children:[(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.label,` `]}),(0,K.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),(0,K.jsxs)(`span`,{children:[` → `,e.after]})]},e.label))}):e.kind===`list`?(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:e.items.map((e,r)=>(0,K.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 text-xs`,children:[e.sessionId&&t[e.sessionId]?(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-session`,"data-conversation-id":e.sessionId,onClick:()=>n(e.sessionId),className:`min-w-0 truncate text-left hover:underline`,children:e.title}):(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.badge&&(0,K.jsx)(`span`,{"data-enso":`tool-card-badge`,"data-tone":e.badgeTone,className:G(`shrink-0 rounded px-1 py-px text-[10px]`,e.badgeTone===`error`&&`bg-destructive/15 text-destructive`,e.badgeTone===`ok`&&`bg-success/15 text-success`,e.badgeTone===`pending`&&`bg-warning/15 text-warning`,(!e.badgeTone||e.badgeTone===`neutral`||e.badgeTone===`queued`)&&`bg-muted text-muted-foreground`),children:e.badge}),e.detail&&(0,K.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.detail})]},`${e.title}-${r}`))}):null}var E5=(0,U.createContext)({report:()=>{},scroller:{current:null}}),Vne=E5.Provider;function Hne(){return(0,U.useContext)(E5)}var D5=(0,U.lazy)(()=>J(()=>import(`./EditDiff-CSimrAEO.js`).then(e=>({default:e.EditDiff})),__vite__mapDeps([144,1,145,146]))),O5=(0,U.lazy)(()=>J(()=>import(`./ReadFileView-Jn3R6r7-.js`).then(e=>({default:e.ReadFileView})),__vite__mapDeps([147,1,145,146]))),Une=(e,t)=>e===t||!!e&&!!t&&e.runMs===t.runMs&&e.turnMs===t.turnMs&&e.ttftMs===t.ttftMs&&e.tps===t.tps;function Wne(e,t){let n=e??[],r=t??[];return n.length===r.length&&n.every((e,t)=>{let n=r[t];return n!==void 0&&e.key===n.key&&e.state===n.state&&e.output===n.output&&e.image?.data===n.image?.data&&JSON.stringify(e.args??null)===JSON.stringify(n.args??null)})}function Gne(e,t){if(e.secretarySession!==t.secretarySession)return!1;let n=e.item,r=t.item;if(n===r)return!0;if(n.kind!==r.kind||n.key!==r.key)return!1;switch(n.kind){case`user`:return r.kind!==`user`||n.text!==r.text||n.images.length!==r.images.length||n.timestamp!==r.timestamp||n.deliveryState!==r.deliveryState||n.turnDurationMs!==r.turnDurationMs||n.collapsed!==r.collapsed||n.canCollapse!==r.canCollapse||n.hostTaskWrapUp!==r.hostTaskWrapUp?!1:n.images.every((e,t)=>e===r.images[t]);case`text`:case`thinking`:return r.kind===n.kind&&n.text===r.text&&n.streaming===r.streaming&&(n.kind!==`text`||r.kind===`text`&&Une(n.perf,r.perf)&&n.timestamp===r.timestamp&&n.turnDurationMs===r.turnDurationMs)&&(n.kind!==`thinking`||r.kind===`thinking`&&n.durationMs===r.durationMs);case`tool`:return r.kind===`tool`&&n.state===r.state&&n.name===r.name&&n.summary===r.summary&&n.output===r.output&&n.edits===r.edits&&n.writeContent===r.writeContent&&n.fileChanges===r.fileChanges&&n.imagePath===r.imagePath&&n.image?.data===r.image?.data&&n.image?.mimeType===r.image?.mimeType&&n.generatedImages===r.generatedImages&&n.todos===r.todos&&n.durationMs===r.durationMs&&n.startedAt===r.startedAt&&n.agentMeta===r.agentMeta&&n.source===r.source&&n.nestedPending===r.nestedPending&&JSON.stringify(n.sandbox)===JSON.stringify(r.sandbox)&&n.rtk===r.rtk&&n.approvalReview===r.approvalReview&&n.plan?.title===r.plan?.title&&n.plan?.text===r.plan?.text&&n.sentMessage===r.sentMessage&&n.memoryContent===r.memoryContent&&n.ask?.question===r.ask?.question&&n.ask?.options.join(`
269
+ `).find(e=>e.trim())}):(0,K.jsx)(D3,{text:e.text}),e.collapsed&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-fold`,onClick:()=>a(e=>!e),className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r(i?`Show less`:`Show more`)})]})}return e.kind===`image`?(0,K.jsx)(`div`,{"data-enso":`tool-card-image`,children:(0,K.jsx)(g5,{image:e.image,path:e.path,alt:e.alt})}):e.kind===`session`?t[e.id]?(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-session`,"data-conversation-id":e.id,onClick:()=>n(e.id),className:`truncate text-left text-xs text-foreground underline-offset-2 hover:underline`,children:e.label}):(0,K.jsx)(`p`,{className:`text-xs`,children:e.label}):e.kind===`kv`?(0,K.jsx)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-xs`,children:e.rows.map(e=>(0,K.jsx)(zne,{row:e},e.label))}):e.kind===`diff`?(0,K.jsx)(`div`,{className:`space-y-0.5 text-xs`,children:e.rows.map(e=>(0,K.jsxs)(`p`,{className:`min-w-0 break-words`,children:[(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.label,` `]}),(0,K.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.before}),(0,K.jsxs)(`span`,{children:[` → `,e.after]})]},e.label))}):e.kind===`list`?(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:e.items.map((e,r)=>(0,K.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5 text-xs`,children:[e.sessionId&&t[e.sessionId]?(0,K.jsx)(`button`,{type:`button`,"data-enso":`tool-card-session`,"data-conversation-id":e.sessionId,onClick:()=>n(e.sessionId),className:`min-w-0 truncate text-left hover:underline`,children:e.title}):(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.badge&&(0,K.jsx)(`span`,{"data-enso":`tool-card-badge`,"data-tone":e.badgeTone,className:G(`shrink-0 rounded px-1 py-px text-[10px]`,e.badgeTone===`error`&&`bg-destructive/15 text-destructive`,e.badgeTone===`ok`&&`bg-success/15 text-success`,e.badgeTone===`pending`&&`bg-warning/15 text-warning`,(!e.badgeTone||e.badgeTone===`neutral`||e.badgeTone===`queued`)&&`bg-muted text-muted-foreground`),children:e.badge}),e.detail&&(0,K.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.detail})]},`${e.title}-${r}`))}):null}var E5=(0,U.createContext)({report:()=>{},scroller:{current:null}}),Vne=E5.Provider;function Hne(){return(0,U.useContext)(E5)}var D5=(0,U.lazy)(()=>J(()=>import(`./EditDiff-Dl1v7xzD.js`).then(e=>({default:e.EditDiff})),__vite__mapDeps([144,1,145,146]))),O5=(0,U.lazy)(()=>J(()=>import(`./ReadFileView-DnbZC0ty.js`).then(e=>({default:e.ReadFileView})),__vite__mapDeps([147,1,145,146]))),Une=(e,t)=>e===t||!!e&&!!t&&e.runMs===t.runMs&&e.turnMs===t.turnMs&&e.ttftMs===t.ttftMs&&e.tps===t.tps;function Wne(e,t){let n=e??[],r=t??[];return n.length===r.length&&n.every((e,t)=>{let n=r[t];return n!==void 0&&e.key===n.key&&e.state===n.state&&e.output===n.output&&e.image?.data===n.image?.data&&JSON.stringify(e.args??null)===JSON.stringify(n.args??null)})}function Gne(e,t){if(e.secretarySession!==t.secretarySession)return!1;let n=e.item,r=t.item;if(n===r)return!0;if(n.kind!==r.kind||n.key!==r.key)return!1;switch(n.kind){case`user`:return r.kind!==`user`||n.text!==r.text||n.images.length!==r.images.length||n.timestamp!==r.timestamp||n.deliveryState!==r.deliveryState||n.turnDurationMs!==r.turnDurationMs||n.collapsed!==r.collapsed||n.canCollapse!==r.canCollapse||n.hostTaskWrapUp!==r.hostTaskWrapUp?!1:n.images.every((e,t)=>e===r.images[t]);case`text`:case`thinking`:return r.kind===n.kind&&n.text===r.text&&n.streaming===r.streaming&&(n.kind!==`text`||r.kind===`text`&&Une(n.perf,r.perf)&&n.timestamp===r.timestamp&&n.turnDurationMs===r.turnDurationMs)&&(n.kind!==`thinking`||r.kind===`thinking`&&n.durationMs===r.durationMs);case`tool`:return r.kind===`tool`&&n.state===r.state&&n.name===r.name&&n.summary===r.summary&&n.output===r.output&&n.edits===r.edits&&n.writeContent===r.writeContent&&n.fileChanges===r.fileChanges&&n.imagePath===r.imagePath&&n.image?.data===r.image?.data&&n.image?.mimeType===r.image?.mimeType&&n.generatedImages===r.generatedImages&&n.todos===r.todos&&n.durationMs===r.durationMs&&n.startedAt===r.startedAt&&n.agentMeta===r.agentMeta&&n.source===r.source&&n.nestedPending===r.nestedPending&&JSON.stringify(n.sandbox)===JSON.stringify(r.sandbox)&&n.rtk===r.rtk&&n.approvalReview===r.approvalReview&&n.plan?.title===r.plan?.title&&n.plan?.text===r.plan?.text&&n.sentMessage===r.sentMessage&&n.memoryContent===r.memoryContent&&n.ask?.question===r.ask?.question&&n.ask?.options.join(`
270
270
  `)===r.ask?.options.join(`
271
271
  `)&&n.ask?.answer===r.ask?.answer&&n.ask?.autoSelected===r.ask?.autoSelected&&n.subagentOp===r.subagentOp&&JSON.stringify(n.subagentTitles)===JSON.stringify(r.subagentTitles)&&n.waiting===r.waiting&&n.pluginArtifacts===r.pluginArtifacts&&n.shellFailure===r.shellFailure&&n.dcgWarning===r.dcgWarning&&JSON.stringify(n.args??null)===JSON.stringify(r.args??null)&&Wne(n.cardPeers,r.cardPeers);case`tool-group`:return r.kind===`tool-group`&&n.expanded===r.expanded&&n.count===r.count&&n.stats.commands===r.stats.commands&&n.stats.reads===r.stats.reads&&n.stats.searches===r.stats.searches&&n.stats.others===r.stats.others&&n.exploring===r.exploring&&n.live===r.live&&n.activity?.thinking===r.activity?.thinking&&n.activity?.workedMs===r.activity?.workedMs&&n.explore?.goal===r.explore?.goal&&n.explore?.report===r.explore?.report&&n.explore?.steps===r.explore?.steps&&n.notice===r.notice;case`error`:return r.kind===`error`&&n.text===r.text;case`interrupted`:return r.kind===`interrupted`&&n.at===r.at&&n.exitKind===r.exitKind&&n.unfinishedTools.length===r.unfinishedTools.length;case`task-note`:return r.kind===`task-note`&&n.detail===r.detail;case`compaction`:case`compaction-notice`:return(r.kind===`compaction`||r.kind===`compaction-notice`)&&n.kind===r.kind&&n.summary===r.summary&&n.tokensBefore===r.tokensBefore&&n.tokensAfter===r.tokensAfter&&n.verified===r.verified;case`compaction-progress`:return r.kind===`compaction-progress`&&n.state===r.state;case`session-custom`:return r.kind===`session-custom`&&n.entry===r.entry;case`divider`:return r.kind===`divider`&&n.text===r.text;case`plugin-message`:return r.kind===`plugin-message`&&n.text===r.text&&n.pluginId===r.pluginId;case`resumed-reply`:return r.kind===`resumed-reply`&&n.expanded===r.expanded&&n.text===r.text&&n.thinking===r.thinking&&n.tools.length===r.tools.length;case`discarded-turn`:return r.kind===`discarded-turn`&&n.expanded===r.expanded&&n.reason===r.reason&&n.messages.length===r.messages.length&&n.messages.every((e,t)=>e===r.messages[t])&&n.tools.length===r.tools.length}}var k5=/^<role>\n?([\s\S]*?)\n?<\/role>\s*/,Kne=/^<workspace-migrated>\n?([\s\S]*?)\n?<\/workspace-migrated>\s*/,qne=/^<workspace-branch-changed>\n?([\s\S]*?)\n?<\/workspace-branch-changed>\s*/;function Jne({note:e}){let{t}=q(),n=/on Git branch ("(?:[^"\\]|\\.)*")/.exec(e)?.[1],r=``;try{r=n?String(JSON.parse(n)):``}catch{}return(0,K.jsxs)(`aside`,{title:e,className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(Jt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 break-all`,children:r?t(`Workspace switched to branch {{branch}}`,{branch:r}):t(`Workspace switched branch`)})]})}function A5({items:e}){let t=LN(),n=nP(e=>t?void 0:K5(e)?.id),r=nP(e=>t?void 0:K5(e)?.backgroundTasks);return(0,K.jsx)(c5,{items:e,live:r,onOpen:n?e=>nP.setState({pendingAgentOpen:{sessionId:n,agentId:e}}):void 0})}function Yne({note:e}){let{t}=q(),n=/(?:moved to|main working tree): (.+)$/m.exec(e)?.[1]?.trim(),r=e.includes(`main working tree`);return(0,K.jsxs)(`aside`,{title:e,className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(Jt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[t(r?`Workspace fell back to the main working tree`:`Workspace moved to an isolated worktree`),n&&(0,K.jsx)(`span`,{className:`ml-1.5 break-all font-mono text-[11px] opacity-80`,children:n})]})]})}function j5({note:e}){let{t}=q();return(0,K.jsxs)(`aside`,{className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(At,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0`,children:t(e===`on`?`Plan mode on: read-only research, then a plan for your approval`:e===`off`?`Plan mode off`:`Context compacted: the approved plan was attached again`)})]})}function M5({note:e}){let{t}=q(),n=e===`on`;return(0,K.jsxs)(`aside`,{className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[n?(0,K.jsx)(zt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}):(0,K.jsx)(er,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0`,children:t(n?`Unattended mode on: no one is watching, so it decides and keeps going`:`Unattended mode off: a person is available again`)})]})}function Xne({tag:e,body:t}){let n=e===`agent-notification`?U6(t):null;return n?(0,K.jsx)($ne,{notices:n}):(0,K.jsx)(ere,{tag:e,body:t})}function Zne({goal:e,instructions:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1),a=eW(e);return(0,K.jsxs)(`div`,{"data-enso":`goal-continuation`,"data-open":r?`true`:`false`,className:G(`my-1 w-full min-w-0`,rP),children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:()=>i(e=>!e),className:`flex w-full min-w-0 items-center gap-2 text-left text-muted-foreground hover:text-foreground`,children:[(0,K.jsx)(iP,{}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n(`Continue goal: {{summary}}`,{summary:a||e})})]}),r&&(0,K.jsxs)(`div`,{className:`mt-1.5 space-y-1.5 border-t border-border/60 pt-1.5`,children:[(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-foreground`,children:e}),t&&(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-[11px] leading-relaxed text-muted-foreground`,children:t})]})]})}function N5({enso:e,icon:t,title:n,body:r}){let[i,a]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{"data-enso":e,"data-open":i?`true`:`false`,className:oP,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`flex w-full items-start gap-2 text-left enabled:hover:text-foreground`,children:[(0,K.jsx)(t,{className:sP}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n})]}),i&&r&&(0,K.jsx)(`p`,{className:`mt-1.5 whitespace-pre-wrap text-foreground`,children:r})]})}function Qne({segments:e,searchQuery:t,activeNth:n}){let{t:r}=q();return(0,K.jsx)(K.Fragment,{children:e.map((e,i)=>{let a=`${e.kind}-${i}`;if(e.kind===`text`){let r=e.text.trim();return r?(0,K.jsx)(B5,{text:r,searchQuery:t,activeNth:n},a):null}if(e.kind===`goal`)return(0,K.jsx)(Zne,{goal:e.goal,instructions:e.instructions},a);if(e.kind===`schedule`){let t=sW(e.raw),n=t.length>0?t:[{summary:``,body:``}];return(0,K.jsx)(U.Fragment,{children:n.map((e,t)=>(0,K.jsx)(N5,{enso:`secretary-schedule-card`,icon:rt,title:e.summary?r(`Scheduled: {{summary}}`,{summary:e.summary}):r(`Scheduled`),body:e.body},t))},a)}if(e.kind===`updates`){let t=FW(e.raw);if(t)return(0,K.jsx)(P5,{lines:t},a);let n=cW(e.raw);return(0,K.jsx)(N5,{enso:`session-updates-card`,icon:fn,title:n.summary?r(`Session updates: {{summary}}`,{summary:n.summary}):r(`Session updates`),body:n.body},a)}return(0,K.jsx)(Xne,{tag:e.tag,body:e.body},a)})})}function $ne({notices:e}){let{t}=q(),[n,r]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{className:aP,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-start gap-2 px-3 py-2 text-left hover:text-foreground`,children:[(0,K.jsx)(ft,{className:sP}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.map(e=>e.header).join(` · `)})]}),n&&e.map((n,r)=>(0,K.jsxs)(`div`,{className:`border-border/60 border-t`,children:[e.length>1&&(0,K.jsx)(`p`,{className:`truncate px-3 pt-2`,children:n.header}),n.report&&(0,K.jsx)(`div`,{className:`max-h-80 overflow-auto px-3 py-2 text-sm text-foreground`,children:(0,K.jsx)(D3,{text:n.report})}),n.usage&&(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5 border-border/60 border-t px-3 py-1 text-[10px]`,children:[(0,K.jsx)(`span`,{className:`font-semibold tracking-wide text-foreground/75`,children:`Subagent`}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:t(`{{count}} tokens`,{count:DN(n.usage.tokens)})}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:t(`{{count}} tool calls`,{count:n.usage.toolUses})}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{children:ON(n.usage.durationMs)})]}),n.tasks&&(0,K.jsxs)(`div`,{className:`border-border/60 border-t px-3 py-1 text-[11px]`,children:[(0,K.jsx)(`p`,{className:`text-foreground/75`,children:t(`Background tasks started by this subagent`)}),n.tasks.map(e=>(0,K.jsx)(`p`,{className:`truncate font-mono text-muted-foreground`,children:e},e))]})]},r))]})}function ere({tag:e,body:t}){let[n,r]=(0,U.useState)(!1),i=iW(t);if(!i)return null;let a=i.indexOf(`
272
- `),o=a>0,s=e.startsWith(`coworker-`)||e===`agent-notification`?ft:Kn;return(0,K.jsxs)(`div`,{className:oP,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:!o,onClick:()=>r(e=>!e),className:`flex w-full items-start gap-2 text-left enabled:hover:text-foreground`,children:[(0,K.jsx)(s,{className:sP}),(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1`,o?`truncate`:`whitespace-pre-wrap`),children:o?i.slice(0,a):i})]}),o&&n&&(0,K.jsx)(`pre`,{className:`mt-1.5 max-h-80 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words`,children:i.slice(a+1)})]})}var tre={"goal-complete":gt,"goal-blocked":St,"needs-user":er,"turn-ended":fn,failed:Dt,stalled:Xt,interrupted:jn,proposal:kt,schedule:rt,pending:Xt,"ask-relay":ln,leftover:Xt,queued:rt};function P5({lines:e}){return(0,K.jsx)(`div`,{"data-enso":`secretary-updates`,className:G(aP,`divide-y divide-border/60`),children:e.map((e,t)=>(0,K.jsx)(nre,{line:e,onOpen:h6},t))})}function nre({line:e,onOpen:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1),a=tre[e.kind],o=`conversationId`in e?e.conversationId:void 0,s=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text})]});return(0,K.jsxs)(`div`,{"data-enso":`secretary-update`,"data-open":r?`true`:`false`,className:`px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[e.detail?(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-update-expand`,"aria-expanded":r,onClick:()=>i(e=>!e),className:`flex min-w-0 flex-1 items-start gap-2 text-left hover:text-foreground`,children:s}):(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:s}),o&&t?(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-update-open`,title:n(`Open session`),"aria-label":n(`Open session`),onClick:e=>{e.stopPropagation(),t(o)},className:`-mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(st,{className:`h-3.5 w-3.5`})}):null]}),e.detail&&r&&(0,K.jsx)(`pre`,{className:`mt-1.5 ml-5.5 max-h-60 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words`,children:e.detail})]})}var F5=/^<message-from-main-agent>\n?([\s\S]*?)\n?<\/message-from-main-agent>\s*$/;function rre(e){let t=k5.exec(e);return F5.test(t?e.slice(t[0].length):e)}function ire({name:e,content:t}){let{t:n}=q();return(0,K.jsxs)(BE,{children:[(0,K.jsxs)(HE,{className:uA(`skill`,!0),children:[(0,K.jsx)(Hn,{className:`h-3 w-3`}),e]}),(0,K.jsxs)(GE,{className:`max-w-lg`,children:[(0,K.jsx)(KE,{children:(0,K.jsxs)(JE,{className:`text-base`,children:[n(`Skill`),` · `,e]})}),(0,K.jsx)(ZE,{className:`max-h-[50vh] text-sm`,children:(0,K.jsx)(D3,{text:t})})]})]})}function I5({chip:e,extra:t}){return(0,K.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-md bg-muted px-4 py-2.5 text-sm`,children:[(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:e}),t?(0,K.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap break-words leading-relaxed`,children:(0,K.jsx)(R5,{text:t})}):null]})}function are({blocks:e,hostTaskWrapUp:t}){let n=Ok(e.rest),r=t?kk(e.rest):void 0,i=(0,K.jsx)(I5,{chip:(0,K.jsx)(`span`,{className:`inline-flex flex-wrap gap-1 align-middle`,children:e.skills.map(e=>(0,K.jsx)(ire,{name:e.name,content:e.body},e.location))}),extra:n.rest.trim()});return!n.plan&&!n.unattended&&!r?i:(0,K.jsxs)(K.Fragment,{children:[n.plan&&(0,K.jsx)(j5,{note:n.plan}),n.unattended&&(0,K.jsx)(M5,{note:n.unattended}),r&&(0,K.jsx)(A5,{items:r.items}),i]})}function ore({text:e}){let t=Nk(e);if(t.names.length>1)return(0,K.jsx)(I5,{chip:(0,K.jsx)(`span`,{className:`inline-flex flex-wrap gap-1 align-middle`,children:t.names.map(e=>(0,K.jsx)(dA,{name:`/skill:${e}`},e))}),extra:t.rest});let n=sA(e);return n.slash?(0,K.jsx)(I5,{chip:(0,K.jsx)(dA,{name:n.slash}),extra:n.rest.trim()}):null}function sre({preset:e}){let{t}=q();return(0,K.jsxs)(`div`,{className:`min-w-64 max-w-[80%] overflow-hidden rounded-2xl rounded-br-md bg-muted text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2.5`,children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-info/15 text-info`,children:(0,K.jsx)(nr,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t(`Workflow preset`)}),(0,K.jsx)(`p`,{className:`truncate font-medium`,title:e.id,children:e.name||e.id})]})]}),e.args.length>0&&(0,K.jsx)(`dl`,{className:`space-y-1 border-t border-border/60 px-3.5 py-2 text-xs`,children:e.args.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`shrink-0 font-mono text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:t})]},e))})]})}function L5({kind:e,label:t,title:n}){let r=e===`file`?Ht:e===`chat`?jn:Un;return(0,K.jsxs)(`span`,{className:G(_A(e),`mx-0.5 max-w-52 rounded-md px-1.5 align-middle leading-4`),title:n,children:[(0,K.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:t})]})}function cre({label:e,sessionFile:t}){let n=KW(nP(e=>e.conversations),t);return n?(0,K.jsxs)(`button`,{type:`button`,"data-enso":`chat-ref`,onClick:()=>h6(n),title:t,className:G(_A(`chat`),`mx-0.5 inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 align-middle leading-4 hover:bg-muted`),children:[(0,K.jsx)(jn,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e})]}):(0,K.jsx)(L5,{kind:`chat`,label:e,title:t})}var lre=240;function ure({text:e,originalLines:t}){let{t:n}=q(),r=(0,U.useRef)(null),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(!1);(0,U.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.scrollHeight>241);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let c=i&&!o;return(0,K.jsxs)(`span`,{"data-enso":`quote-block`,className:`mt-1 mb-2.5 block border-l-2 border-brand/40 pl-2.5 text-muted-foreground`,children:[t?(0,K.jsx)(`span`,{"data-quote-truncated":``,className:`mb-0.5 block text-[11px] text-warning`,children:n(`Truncated · original {{count}} lines`,{count:t})}):null,(0,K.jsx)(`span`,{ref:r,"data-quote-body":``,"data-clipped":c?``:void 0,style:c?{maxHeight:lre}:void 0,className:G(`block`,c&&`overflow-hidden mask-b-from-60%`),children:DA(e).map((e,t)=>e.type===`code`?(0,K.jsx)(`span`,{"data-quote-code":``,className:`my-1 block overflow-x-auto whitespace-pre rounded-md bg-background/60 px-2 py-1 font-mono text-xs`,children:e.code},t):(0,K.jsx)(`span`,{children:e.text},t))}),i?(0,K.jsx)(`button`,{type:`button`,"data-quote-toggle":``,"data-quote-skip":``,onClick:()=>s(e=>!e),className:`mt-0.5 text-[11px] text-muted-foreground/80 select-none hover:text-foreground`,children:n(o?`Show less`:`Show more`)}):null]})}function R5({text:e,searchQuery:t=``,activeNth:n=-1}){let r=Yk(yk(e)),i={n:0};return(0,K.jsx)(`span`,{className:`whitespace-pre-wrap`,children:r.map((e,r)=>e.type===`file`?(0,K.jsx)(B4,{path:e.path,children:(0,K.jsx)(L5,{kind:`file`,label:eA(e.path),title:e.path})},r):e.type===`chat`?(0,K.jsx)(cre,{label:e.label,sessionFile:e.sessionFile},r):e.type===`ui-element`?(0,K.jsx)(L5,{kind:`ui-element`,label:e.label,title:`${e.path}${e.text?` · ${e.text}`:``}`},r):e.type===`quote`?(0,K.jsx)(ure,{text:e.text,originalLines:e.originalLines},r):(0,K.jsx)(`span`,{children:t.trim()?pU(e.text,t,n,i):e.text},r))})}function dre({files:e,chats:t}){return(0,K.jsxs)(`span`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[e.map(e=>(0,K.jsx)(B4,{path:e,children:(0,K.jsx)(L5,{kind:`file`,label:eA(e),title:e})},`f:${e}`)),t.map(e=>(0,K.jsx)(L5,{kind:`chat`,label:e.label,title:e.sessionFile},`c:${e.sessionFile}`))]})}var z5=`max-w-[82%] rounded-[10px] bg-muted px-3.5 py-[9px] text-(length:--chat-body-size) leading-[1.6]`;function B5({text:e,searchQuery:t=``,activeNth:n=-1,thumbnails:r=0,align:a=`end`,hostTaskWrapUp:o=!1}){let{t:s}=q(),c=LN(),l=!!(c?.speaker||c?.botSession),u=qU(e,r);if(u)return(0,K.jsxs)(K.Fragment,{children:[u.text&&(0,K.jsx)(B5,{text:u.text,searchQuery:t,activeNth:n,hostTaskWrapUp:o}),(0,K.jsx)(qG,{entries:u.entries,thumbnails:r,align:a})]});let d=ZU(e);if(d)return(0,K.jsx)(k3,{message:d});let f=l?jU(e):null;if(f)return(0,K.jsx)(WW,{message:f});let p=l?DU(e):e;if(p!==e)return(0,K.jsx)(B5,{text:p,searchQuery:t,activeNth:n,hostTaskWrapUp:o});let m=l?CU(e):null;if(m?.refs.length)return(0,K.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-1.5`,children:[m.body&&(0,K.jsx)(B5,{text:m.body,searchQuery:t,activeNth:n}),(0,K.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:m.refs.map(e=>(0,K.jsxs)(`span`,{title:s(`Referenced chat`),className:`inline-flex h-6 max-w-56 items-center gap-1 rounded-md bg-muted px-1.5 text-xs`,children:[(0,K.jsx)(fn,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.id))})]});let h=he(e);if(h.note){let e=h.rest.trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j5,{note:h.note}),e&&(0,K.jsx)(B5,{text:e,searchQuery:t,activeNth:n,hostTaskWrapUp:o})]})}let g=xk(e);if(g.note){let e=g.rest.trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(M5,{note:g.note}),e&&(0,K.jsx)(B5,{text:e,searchQuery:t,activeNth:n,hostTaskWrapUp:o})]})}let _=o?Ek(e):null;if(_){let e=_.rest.trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(A5,{items:_.items}),e&&(0,K.jsx)(B5,{text:e,searchQuery:t,activeNth:n})]})}let v=qne.exec(e);if(v){let r=e.slice(v[0].length).trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Jne,{note:v[1]??``}),r&&(0,K.jsx)(B5,{text:r,searchQuery:t,activeNth:n})]})}let y=i(e);if(y?.kind===`approved`)return(0,K.jsxs)(`div`,{className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(kt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[s(`Plan approved, executing`),(0,K.jsx)(`span`,{className:`ml-1.5 text-foreground`,children:y.title})]})]});if(y?.kind===`feedback`)return(0,K.jsxs)(`div`,{className:G(z5,`whitespace-pre-wrap`),children:[(0,K.jsxs)(`p`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,K.jsx)(At,{className:`h-3 w-3`}),s(`Plan feedback`)]}),(0,K.jsx)(R5,{text:y.feedback,searchQuery:t,activeNth:n})]});let b=Lk(e);if(b)return(0,K.jsx)(sre,{preset:b});let x=rA(e);if(x.files.length>0||x.chats.length>0){let e=sA(x.body);return(0,K.jsxs)(`div`,{className:z5,children:[e.slash?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dA,{name:e.slash}),e.rest.trim()?(0,K.jsx)(`span`,{className:`ml-1.5 align-middle`,children:(0,K.jsx)(R5,{text:e.rest.trim(),searchQuery:t,activeNth:n})}):null]}):(0,K.jsx)(R5,{text:x.body,searchQuery:t,activeNth:n}),(0,K.jsx)(dre,{files:x.files,chats:x.chats})]})}let S=Pk(e);if(S)return(0,K.jsx)(are,{blocks:S,hostTaskWrapUp:o});if(sA(e).slash)return(0,K.jsx)(ore,{text:e});let C=Kne.exec(e);if(C){let r=e.slice(C[0].length).trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yne,{note:C[1]}),r&&(0,K.jsx)(B5,{text:r,searchQuery:t,activeNth:n})]})}let w=nW(e);if(w)return(0,K.jsx)(Qne,{segments:w,searchQuery:t,activeNth:n});let T=FW(e);if(T)return(0,K.jsx)(P5,{lines:T});let E=k5.exec(e),D=E?e.slice(E[0].length):e,O=F5.exec(D),k=O?O[1]:D;return(0,K.jsxs)(`div`,{className:G(O?`max-w-[80%] rounded-2xl rounded-bl-md border border-blue-500/20 bg-blue-500/8 px-4 py-2.5 text-sm`:G(z5,`whitespace-pre-wrap`)),children:[O&&(0,K.jsxs)(`p`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium tracking-wide text-blue-600 uppercase dark:text-blue-400`,children:[(0,K.jsx)(ft,{className:`h-3 w-3`}),s(`From main agent`)]}),E?.[1]&&!PU(E[1])&&(0,K.jsxs)(`div`,{className:`mb-2 rounded-md bg-background/60 px-2.5 py-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:s(`Role`)}),` · `,E[1]]}),O?(0,K.jsx)(D3,{text:k,searchQuery:t,activeNth:n}):(0,K.jsx)(R5,{text:k,searchQuery:t,activeNth:n})]})}function V5(e){return e.kind===`tool-group`||e.kind===`thinking`||e.kind===`tool`&&MH(e)}var H5=`text-[color:var(--subtle-foreground,var(--muted-foreground))]`,U5=`animate-pulse motion-reduce:animate-none`;function fre({model:e,at:t,privacyMask:n,secretarySession:r=!1,face:i,conversationId:a}){let o=LN(),s=ez(a),c=r?i??s:null,l=o?.speaker??(o?null:c),u=!o&&c?!0:void 0,d=[e,typeof t==`number`?$5(t):null].filter(Boolean).join(` · `);return!l&&!d&&!n?null:(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`mb-2 flex h-6 min-w-0 items-center gap-2 text-xs select-none`,children:[l&&(l.image?(0,K.jsx)(`img`,{"data-enso":u?`secretary-chat-avatar`:void 0,"data-image":u?`true`:void 0,src:l.image,alt:``,draggable:!1,className:`size-[22px] shrink-0 rounded-full object-cover`,style:{backgroundColor:l.color}}):u?(0,K.jsx)(nR,{name:l.name,color:l.color,enso:`secretary-chat-avatar`,className:`size-[22px] rounded-full`}):(0,K.jsx)(`span`,{className:`flex size-[22px] shrink-0 items-center justify-center rounded-full font-semibold text-[11px] text-white`,style:{backgroundColor:l.color},children:[...l.name.trim()][0]?.toUpperCase()??`?`})),l&&(0,K.jsx)(`span`,{className:`shrink-0 truncate text-[13px] font-semibold text-foreground`,children:l.name}),d&&(0,K.jsx)(`span`,{className:G(`min-w-0 truncate text-[11.5px]`,H5),children:d}),n&&(0,K.jsx)(A8,{report:n})]})}var pre=(0,U.memo)(function({item:e,secretarySession:t=!1,onToggleGroup:n,onToggleTurn:r}){let i=lU(),a=i.query,o=i.activeKey===e.key?i.activeNth:-1,s=t;switch(e.kind){case`user`:{let t=e.text?rre(e.text):!1,n=e.collapsed===!0,i=e.hostTaskWrapUp?Ak(e.text):e.text;return(0,K.jsxs)(`div`,{"data-enso":`message-user`,className:G(`group/user flex flex-col gap-1.5`,t?`items-start`:`items-end`),children:[e.images.map((e,t)=>(0,K.jsx)(WG,{src:`data:${e.mimeType};base64,${e.data}`,className:`max-h-48 max-w-full rounded-lg border object-contain`},t)),e.text&&(0,K.jsx)(B5,{text:e.text,searchQuery:a,activeNth:o,thumbnails:e.images.length,align:t?`start`:`end`,hostTaskWrapUp:e.hostTaskWrapUp===!0}),n?(0,K.jsx)(Dre,{turnKey:e.key,text:i,timestamp:e.timestamp,turnDurationMs:e.turnDurationMs,onToggle:r}):(0,K.jsx)(Ore,{turnKey:e.key,messageIndex:Number(e.key),text:i,timestamp:e.timestamp,deliveryState:e.deliveryState,canCollapse:e.canCollapse,onToggleTurn:r})]})}case`text`:return(0,K.jsx)(Are,{item:e,searchQuery:a,activeNth:o});case`thinking`:return(0,K.jsx)(Pre,{itemKey:e.key,text:e.text,streaming:e.streaming,durationMs:e.durationMs,startedAt:e.startedAt});case`tool`:{let t=gG(e),n=nB(e.name,s),r=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pO,{name:e.name,output:e.output,state:e.state}),n?(0,K.jsx)(b5,{item:e,framed:s}):(0,K.jsx)(Vre,{item:e}),t?(0,K.jsx)(xG,{proposalId:t}):null,e.pluginArtifacts?(0,K.jsx)(E6,{artifacts:e.pluginArtifacts,align:n?`card`:`tool-row`}):null]});return n?(0,K.jsx)(`div`,{"data-enso":`tool-card-pair`,className:`w-full min-w-0`,children:r}):r}case`tool-group`:return(0,K.jsx)(Rre,{item:e,onToggle:n});case`error`:return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm text-destructive`,children:[(0,K.jsx)(St,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap`,children:e.text}),(0,K.jsx)(J5,{})]});case`interrupted`:return(0,K.jsx)(yre,{item:e});case`task-note`:return(0,K.jsx)(Fre,{item:e});case`compaction`:case`compaction-notice`:return(0,K.jsx)(Lre,{item:e});case`compaction-progress`:return(0,K.jsx)(Ire,{state:e.state});case`session-custom`:return(0,K.jsx)(vre,{entry:e.entry});case`plugin-message`:return(0,K.jsx)(hre,{item:e});case`discarded-turn`:return(0,K.jsx)(gre,{item:e,onToggle:n});case`resumed-reply`:return(0,K.jsx)(_re,{item:e,onToggle:n});case`divider`:return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`}),e.text,(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`})]})}},Gne),W5=e=>{if(typeof e==`string`)return e;if(e===void 0)return`—`;try{return JSON.stringify(e)}catch{return String(e)}};function mre({entry:e}){let{t}=q(),n=r6(),r=n.get(e.accountKey),i=e.previousAccountKey?n.get(e.previousAccountKey):void 0,a=e.previousAccountKey?i&&r?t(`ChatGPT account switched: {{previous}} → {{current}}`,{previous:i,current:r}):t(`ChatGPT account switched`):r?t(`ChatGPT account selected: {{account}}`,{account:r}):t(`ChatGPT account selected`);return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(An,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-primary`}),(0,K.jsx)(`p`,{className:`min-w-0 break-words text-muted-foreground`,children:a})]})}function hre({item:e}){let{t}=q();return(0,K.jsxs)(`div`,{"data-plugin-message":e.pluginId,className:`rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs`,children:[(0,K.jsxs)(`p`,{className:`mb-1 flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(M6,{pluginId:e.pluginId,className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:t(`From plugin {{name}}`,{name:e.pluginName})}),(0,K.jsx)(`span`,{className:`font-mono opacity-70`,children:e.pluginId})]}),(0,K.jsx)(`div`,{className:G5,children:(0,K.jsx)(D3,{text:e.text})})]})}var G5=`break-words text-foreground [&_p]:whitespace-pre-line`;function gre({item:e,onToggle:t}){let{t:n}=q();return(0,K.jsxs)(`div`,{"data-discarded-turn":e.pluginId,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.key),"data-enso":`tool-row`,className:G(`group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(zn,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground group-hover/step:text-foreground`,children:Ns(`turn_discard`,n)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.pluginName,e.reason].filter(Boolean).join(` · `)}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,e.expanded&&`rotate-90`)})]}),e.expanded&&(0,K.jsxs)(`div`,{className:`t-acc-reveal mt-1 mb-1.5 ml-5 space-y-2 rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(M6,{pluginId:e.pluginId,className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`From plugin {{name}}`,{name:e.pluginName})})]}),e.messages.map((e,t)=>(0,K.jsx)(`div`,{className:G5,children:(0,K.jsx)(D3,{text:e})},t)),e.tools.map((e,t)=>(0,K.jsxs)(`p`,{className:G(`truncate`,H5),children:[Ns(e.name,n),` `,e.summary]},t))]})]})}function _re({item:e,onToggle:t}){let{t:n}=q();return(0,K.jsxs)(`div`,{"data-resumed-reply":``,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.key),"aria-expanded":e.expanded,"data-enso":`tool-row`,className:G(`group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(Sn,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[n(`Interrupted by a restart, continued below`),(0,K.jsx)(`span`,{className:`ml-1.5 opacity-70`,children:e.expanded?n(`Hide the interrupted part`):n(`Show the interrupted part`)})]}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,e.expanded&&`rotate-90`)})]}),e.expanded&&(0,K.jsxs)(`div`,{className:`t-acc-reveal mt-1 mb-1.5 ml-5 space-y-2 rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs`,children:[e.thinking&&(0,K.jsx)(`p`,{className:G(`whitespace-pre-wrap break-words`,H5),children:e.thinking}),e.text&&(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-foreground`,children:e.text}),e.tools.map((e,t)=>(0,K.jsxs)(`p`,{className:G(`truncate`,H5),children:[Ns(e.name,n),` `,e.summary]},t))]})]})}function vre({entry:e}){let{t}=q();if(e.kind===`oauth-account-selected`)return(0,K.jsx)(mre,{entry:e});if(e.kind===`agent-dispatch`)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(ft,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:t(`Dispatched to`)}),(0,K.jsx)(`span`,{className:`font-medium`,children:e.child.instanceName})]});if(e.kind===`agent-completed`)return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-emerald-500/20 bg-emerald-500/5 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[e.child.instanceName,` · `,t(`Completed`)]}),e.receiptSummary&&(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground`,children:e.receiptSummary})]})]});if(e.kind===`agent-failed`)return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/20 bg-destructive/5 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(St,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[e.child.instanceName,` · `,t(`Failed`)]}),(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground`,children:e.message})]})]});if(e.kind===`tool-batch-label`)return null;if(e.kind===`task-wrap-up-nudge`)return(0,K.jsxs)(`div`,{"data-enso":`task-wrap-up-nudge`,className:`my-1 flex items-center gap-1.5 text-[12px] text-subtle-foreground`,children:[(0,K.jsx)(nn,{className:`size-3.5 shrink-0`}),t(`{{count}} background tasks are still undeclared; the next message asks the agent to stop each one or state why it keeps running`,{count:e.count})]});let n=e.receipt,r=n.outcome===`succeeded`;return(0,K.jsx)(`div`,{className:G(`rounded-md border px-2.5 py-2 text-xs`,r?`border-emerald-500/20 bg-emerald-500/5`:n.outcome===`failed`?`border-destructive/20 bg-destructive/5`:`border-amber-500/20 bg-amber-500/5`),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[r?(0,K.jsx)(gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500`}):(0,K.jsx)(St,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,n.outcome===`failed`?`text-destructive`:`text-amber-500`)}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[n.subject.label,` · `,t(n.outcome)]}),(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground`,children:n.summary}),n.changes&&n.changes.length>0&&(0,K.jsx)(`dl`,{className:`mt-2 space-y-1 border-t border-border/50 pt-2`,children:n.changes.map(e=>(0,K.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,K.jsx)(`dt`,{className:`truncate text-muted-foreground`,children:e.field}),(0,K.jsxs)(`dd`,{className:`text-right font-mono`,children:[W5(e.previous),` → `,W5(e.value)]})]},e.field))})]})]})})}function K5(e){let t=e.activeId?e.conversations[e.activeId]:null;return t?t.activeTabId?e.conversations[t.activeTabId]??t:t:null}var q5=()=>()=>{};function yre({item:e}){let{locale:t}=q(),n=RU({at:e.at,kind:e.exitKind,unfinishedTools:e.unfinishedTools,lang:t});return(0,K.jsxs)(`div`,{"data-enso":`timeline-interrupted`,className:`flex items-start gap-2 text-sm text-warning`,children:[(0,K.jsx)(St,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap`,children:n}),(0,K.jsx)(bre,{})]})}function bre(){let{t:e}=q();return nP(e=>{let t=K5(e);return!!(t&&!t.spawning&&t.status!==`running`)})?(0,K.jsxs)(`button`,{type:`button`,"data-enso":`timeline-interrupted-retry`,title:e(`Retry`),onClick:()=>{let e=K5(nP.getState());e&&nP.getState().retryInterrupted(e.id)},className:`mt-0.5 inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(An,{className:`h-3 w-3`}),e(`Retry`)]}):null}function J5(){let{t:e}=q(),t=LN(),n=t?.botControls,r=nP(e=>{if(t&&(!t.canRetry||t.botControls))return!1;let n=K5(e);return!!(n?.started&&!n.spawning&&n.status!==`running`)}),i=()=>{if(!n||!t?.canRetry)return!1;let e=n.projection();return!!(e&&e.status!==`running`)},a=(0,U.useSyncExternalStore)(n?.subscribe??q5,i,i);return(n?a:r)?(0,K.jsxs)(`button`,{type:`button`,title:e(`Retry`),onClick:()=>{if(n)return n.retry();let e=K5(nP.getState());e&&nP.getState().retry(e.id)},className:`mt-0.5 inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(An,{className:`h-3 w-3`}),e(`Retry`)]}):null}function xre(e,t){return XB(K5(e),t)}var Y5=`flex items-center gap-1 text-[11px] text-muted-foreground transition-opacity hover:text-foreground`;function Sre({messageIndex:e}){let{t}=q(),n=LN();return nP(e=>{let t=K5(e);return ZB(t,n,t?JB(e.conversations,t.id):1)})?(0,K.jsxs)(`button`,{type:`button`,className:Y5,title:t(`Keep this session and start a parallel one from here`),onClick:()=>{let t=nP.getState(),n=K5(t);n&&t.forkFromTurn(n.id,e)},children:[(0,K.jsx)(Jt,{className:`h-3 w-3`}),t(`Conversation branch`)]}):null}function Cre({messageIndex:e}){let{t}=q(),n=LN(),r=nP(e=>K5(e)?.id),i=nP(t=>{let i=r?t.conversations[r]:void 0;if(n||!i||i.historyOnly||i.rewinding||i.restoringFiles||i.workspaceMigrating)return;let a=i.messages[e-(i.historyBaseIndex??0)];return v6(a)||i.status===`running`&&y6(a)?a?.deliveryId:void 0});return!r||!i?null:(0,K.jsxs)(`button`,{type:`button`,title:t(`Withdraw message`),onClick:()=>nP.getState().withdrawMessage(r,{kind:`delivery`,id:i}),className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(Qn,{className:`h-3 w-3`}),t(`Withdraw message`)]})}function wre(){let{t:e}=q(),t=nP(e=>K5(e)?.id);return t?(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void GW(t,e),className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(Mn,{className:`h-3 w-3`}),e(`Restart conversation`)]}):null}function Tre({messageIndex:e}){let{t}=q(),n=LN(),r=nP(e=>K5(e)?.id),i=nP(t=>{let i=r?t.conversations[r]:void 0;if(n||!i||i.historyOnly)return;let a=i.messages[e-(i.historyBaseIndex??0)];return v6(a)?a?.deliveryId:void 0});return!r||!i?null:(0,K.jsxs)(`button`,{type:`button`,title:t(`Resend`),onClick:()=>nP.getState().resendMessage(r,i),className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(An,{className:`h-3 w-3`}),t(`Resend`)]})}function Ere({messageIndex:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(null),o=LN(),s=o?.botControls,c=nP(t=>{if(o?.botControls)return!1;let n=K5(t);return xre(t,o)&&!!(n&&$B(n.id,n.id,n,e))}),l=()=>{if(!s||!o?.canRewind||!o.sessionId)return null;let t=s.projection();return!t||t.status===`running`?null:$B(o.sessionId,o.sessionId,t,e)?.entryId??null},u=(0,U.useSyncExternalStore)(s?.subscribe??q5,l,l);if(!(s?u!==null:c))return null;let d=t=>{if(s&&o?.sessionId&&u){a({restoreFiles:t,conversationId:o.sessionId,entryId:u});return}let n=K5(nP.getState());if(!n)return;let r=$B(n.id,n.id,n,e);r&&a({restoreFiles:t,conversationId:n.id,entryId:r.entryId})},f=(t,n,r)=>{if(s)return s.rewind(r,t);let i=nP.getState(),a=$B(n,K5(i)?.id,i.conversations[n],e,r);a&&i.rewind(a.conversationId,a.entryId,t)},p=[{icon:Qn,label:t(`Conversation only`),desc:t(`Rewind to this message`),restoreFiles:!1,action:()=>d(!1)},{icon:jn,label:t(`Conversation + files`),desc:t(`Rewind and restore files to before this turn`),restoreFiles:!0,action:()=>d(!0)}];return(0,K.jsxs)(Z3,{open:n,onOpenChange:r,children:[(0,K.jsxs)(Q3,{className:Y5,title:t(`Rewind to this message`),children:[(0,K.jsx)(Qn,{className:`h-3 w-3`}),t(`Rewind`)]}),(0,K.jsx)($3,{side:`bottom`,align:`end`,className:`w-72 [&_[data-slot=popover-viewport]]:p-1`,children:p.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{r(!1),e.action()},className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-muted/60`,children:[(0,K.jsx)(e.icon,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block`,children:e.label}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.desc})]})]},e.label))}),(0,K.jsx)(t8,{open:i!==null,onOpenChange:e=>{e||a(null)},title:t(`Rewind to this message?`),description:i?.restoreFiles?t(`Later messages leave the current branch and working-tree files are restored to before this turn.`):t(`Later messages leave the current branch; the text returns to the input box.`),confirmLabel:t(`Rewind`),onConfirm:()=>{i&&f(i.restoreFiles,i.conversationId,i.entryId)}})]})}function Dre({turnKey:e,text:t,timestamp:n,turnDurationMs:r,onToggle:i}){let{t:a}=q();return(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`flex items-center gap-1.5 text-[11px] text-muted-foreground/80 select-none`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i?.(e,!1),className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground cursor-pointer border border-border/40`,title:a(`Expand`),children:[(0,K.jsx)(vt,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{children:a(`Expand`)})]}),(0,K.jsx)(X5,{text:t}),typeof n==`number`&&(0,K.jsx)(`span`,{children:$5(n)}),r!==void 0&&(0,K.jsxs)(`span`,{children:[`· `,a(`took {{duration}}`,{duration:ON(r)})]})]})}function X5({text:e}){return e.trim()?(0,K.jsx)(`span`,{"data-enso":`copy-user-prompt`,className:`inline-flex`,children:(0,K.jsx)(Z5,{text:fk(e),className:`opacity-0 transition-opacity group-hover/user:opacity-100 focus-visible:opacity-100`})}):null}function Ore({turnKey:e,messageIndex:t,text:n,timestamp:r,canCollapse:i,deliveryState:a,onToggleTurn:o}){let{t:s}=q(),c=E(e=>e.autoCollapseTurns);return(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`flex items-center gap-2 text-[11px] text-muted-foreground/75 select-none`,children:[(0,K.jsx)(Ere,{messageIndex:t}),(0,K.jsx)(Tre,{messageIndex:t}),(0,K.jsx)(Cre,{messageIndex:t}),(0,K.jsx)(X5,{text:n}),a&&(0,K.jsx)(`span`,{children:s(a===`stuck`?`Not sent: the previous turn is stuck and could not be interrupted. Restart the conversation, then resend.`:a===`rejected`?`Not sent`:`Delivery unconfirmed`)}),a===`stuck`&&(0,K.jsx)(wre,{}),c&&i&&o&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(e,!0),className:G(Y5,`cursor-pointer opacity-0 group-hover/user:opacity-100`),title:s(`Collapse`),children:[(0,K.jsx)(_t,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{children:s(`Collapse`)})]}),typeof r==`number`&&(0,K.jsx)(`span`,{children:$5(r)})]})}function kre({turnKey:e,canCollapse:t,collapsed:n,onToggleTurn:r}){let{t:i}=q();return!E(e=>e.autoCollapseTurns)||!t||!r||n?null:(0,K.jsxs)(`button`,{type:`button`,"data-enso":`turn-collapse`,"data-quote-skip":``,onClick:()=>r(e,!0),className:G(`mt-1 flex min-h-6 select-none items-center gap-1 text-[12px] transition-colors hover:text-foreground [@media(hover:none)]:min-h-10 [@media(hover:none)]:pr-3`,H5),children:[(0,K.jsx)(bt,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:i(`Collapse`)})]})}function Are({item:e,searchQuery:t=``,activeNth:n=-1}){let{t:r}=q(),i=LN(),a=e.perf?jre(e.perf,r,e.turnDurationMs!==void 0):``,o=nP(e=>K5(e)?.id??null),s=Number(e.key.split(`-`)[0]),c={text:e.text,messageIndex:s,sessionId:i?i.sessionId:o};return(0,K.jsxs)(`div`,{"data-enso":`message-assistant`,className:`group text-(length:--chat-body-size)`,children:[(0,K.jsx)(D3,{text:e.text,streaming:e.streaming,searchQuery:t,activeNth:n,leaf:{messageIndex:c.messageIndex,sessionId:c.sessionId}}),e.turnEnd&&!e.streaming&&i?.turnFooter?.(Number(e.key.split(`-`)[0])),!e.streaming&&(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,K.jsx)(fO,{position:`left`,...c}),(0,K.jsx)(Z5,{text:e.text}),(0,K.jsx)(fO,{position:`right`,...c}),e.turnEnd&&(0,K.jsx)(Sre,{messageIndex:Number(e.key.split(`-`)[0])}),e.timestamp&&!e.turnEnd&&(0,K.jsx)(`span`,{children:$5(e.timestamp)}),e.turnDurationMs!==void 0&&(0,K.jsxs)(`span`,{children:[e.timestamp&&!e.turnEnd&&`· `,r(`took {{duration}}`,{duration:ON(e.turnDurationMs)})]}),a&&(0,K.jsxs)(`span`,{children:[`· `,a]})]})]})}function Z5({text:e,className:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1e3)})},className:G(`flex items-center gap-1 transition-colors hover:text-foreground`,t),title:n(`Copy`),children:r?(0,K.jsx)(gt,{className:`h-3 w-3`}):(0,K.jsx)(Pt,{className:`h-3 w-3`})})}var Q5=e=>String(e).padStart(2,`0`),$5=e=>{let t=new Date(e);return`${Q5(t.getHours())}:${Q5(t.getMinutes())}`},e7=e=>{let t=e/1e3;return String(t<10?Math.round(t*10)/10:Math.round(t))};function jre(e,t,n=!1){let r=[];return(!n||e.turnMs!==void 0)&&r.push(`${e7(e.runMs)}s`),e.ttftMs!==void 0&&r.push(`TTFT ${e7(e.ttftMs)}s`),e.tps!==void 0&&r.push(`${Math.round(e.tps)} tok/s`),!n&&e.turnMs!==void 0&&r.push(t(`total {{duration}}`,{duration:ON(e.turnMs)})),r.join(` · `)}function Mre(e,t,n=16){return e.top<t.top?e.top-t.top-n:e.bottom>t.bottom?e.bottom-t.bottom+n:0}function Nre(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(`data-virtuoso-scroller`))return t;let e=typeof window.getComputedStyle==`function`?window.getComputedStyle(t).overflowY:t.style.overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return null}function t7(e,t=Nre(e)){if(!t){e.getBoundingClientRect().top<0&&e.scrollIntoView?.({block:`nearest`});return}let n=Mre(e.getBoundingClientRect(),t.getBoundingClientRect());n!==0&&(t.scrollTop=Math.max(0,t.scrollTop+n))}function Pre({itemKey:e,text:t,streaming:n,durationMs:r,startedAt:i}){let{t:a}=q(),o=E(e=>e.expandLiveReasoning),[s,c]=(0,U.useState)(null),l=aV(s,n,o),u=(0,U.useRef)(null),d=(0,U.useRef)(!1);return(0,U.useLayoutEffect)(()=>{l||!d.current||(d.current=!1,u.current&&t7(u.current))},[l]),(0,K.jsxs)(`div`,{ref:u,"data-enso":`thinking`,"data-live":n||void 0,children:[(0,K.jsxs)(`button`,{type:`button`,"data-quote-skip":``,onClick:()=>c(!l),className:G(`flex min-h-6 select-none items-center gap-2 text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:(0,K.jsx)(pt,{className:G(`size-3`,n&&`animate-pulse text-brand`)})}),n?(0,K.jsx)(`span`,{className:G(`text-foreground`,U5),children:a(`Thinking…`)}):r===null?(0,K.jsx)(`span`,{children:a(`Thought process`)}):(0,K.jsx)(`span`,{children:a(`Thought for {{duration}}`,{duration:ON(r)})}),n&&(0,K.jsx)(a7,{itemKey:e,since:i}),(0,K.jsx)(vt,{className:G(`h-3 w-3 transition-transform`,l&&`rotate-90`)})]}),l&&(0,K.jsx)(hO,{text:t,streaming:n,itemKey:e}),l&&!n&&(0,K.jsxs)(`button`,{type:`button`,"data-enso":`thinking-collapse`,"data-quote-skip":``,onClick:()=>{d.current=!0,c(!1)},className:G(`mt-1 ml-[31px] flex min-h-6 select-none items-center gap-1 text-[12px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(bt,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:a(`Collapse thinking`)})]})]})}function Fre({item:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(void 0),o=/^Background task (\S+) finished \((.+?), ran (.+?)\)/.exec(e.summary),s=o?`${o[1]} · ${o[2]} · ${o[3]}`:e.summary,c=/(?:read ((?:\/|[A-Za-z]:[\\/]).+?\.log) for the complete log|Full log: ((?:\/|[A-Za-z]:[\\/])\S+?\.log))/.exec(e.detail)?.slice(1).find(Boolean)??null;return(0,U.useEffect)(()=>{!n||!c||i!==void 0||window.electronAPI.files.read(c).then(e=>{a(typeof e==`string`?e:null)}).catch(()=>a(null))},[n,c,i]),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-3`,title:e.detail,children:[(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,K.jsx)(gt,{className:`h-3 w-3 text-green-600 dark:text-green-500`}),s,(0,K.jsx)(vt,{className:G(`h-3 w-3 transition-transform`,n&&`rotate-90`)})]}),(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),n&&(0,K.jsxs)(`div`,{className:`mt-1.5 rounded-lg border border-border/60 bg-muted/20`,children:[(0,K.jsx)(`pre`,{className:`border-b border-border/60 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:e.detail}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 py-2 font-mono text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:c?i===void 0?t(`Loading…`):c6(i??t(`(log unavailable)`)):t(`(no log available)`)})]})]})}function Ire({state:e}){let{t}=q();return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(sn,{className:`h-3 w-3 animate-spin`}),(0,K.jsx)(`span`,{children:t(e===`queued`?`Compacts after this turn`:`Compacting…`)})]})}function Lre({item:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),i=e.kind===`compaction`,a=e.tokensBefore===null?null:DN(e.tokensBefore),o=n8(e.tokensBefore,e.tokensAfter),s=o!==null&&e.tokensBefore!==null&&e.tokensAfter!==void 0?t(`{{kind}} · {{before}} → {{after}} · freed {{percent}}%`,{kind:t(e.memory?`Memory context compacted`:e.verified?`Verified context compacted`:`Context compacted`),before:DN(e.tokensBefore),after:DN(e.tokensAfter),percent:o}):e.memory?a===null?t(`Memory context compacted`):t(`Memory context compacted ({{tokens}} tokens before)`,{tokens:a}):e.verified?a===null?t(`Verified context compacted`):t(`Verified context compacted ({{tokens}} tokens before)`,{tokens:a}):a===null?t(`Context compacted`):t(`Context compacted ({{tokens}} tokens before)`,{tokens:a});return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:G(`flex items-center gap-3`,i&&`w-full`),title:e.memory?t(`Summary rendered from continuous memory. Messages above are no longer in the model context; use recall for sources.`):e.verified?t(`Verified summary from smart compaction. Messages above are no longer in the model context.`):t(i?`Messages above are no longer in the model context; only this summary is.`:`Latest compaction summary — expand to read what the model kept.`),children:[i&&(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,K.jsx)(_n,{className:`h-3 w-3`}),s,(0,K.jsx)(vt,{className:G(`h-3 w-3 transition-transform`,n&&`rotate-90`)})]}),i&&(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),n&&(0,K.jsx)(`pre`,{className:`mt-1.5 max-h-80 overflow-auto rounded-lg border border-border/60 bg-muted/20 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:e.summary||t(`(summary unavailable)`)})]})}function Rre({item:e,onToggle:t}){let{t:n}=q(),r=E(e=>e.compactReadOnlyTools),i=[];e.stats.commands>0&&i.push(n(`ran {{count}} commands`,{count:e.stats.commands})),e.stats.reads>0&&i.push(n(`read {{count}} files`,{count:e.stats.reads})),e.stats.searches>0&&i.push(n(`searched {{count}} times`,{count:e.stats.searches})),e.stats.others>0&&i.push(n(`{{count}} other calls`,{count:e.stats.others}));let a=[];r&&(e.stats.reads>0&&a.push(n(`{{count}} files`,{count:e.stats.reads})),e.stats.searches>0&&a.push(n(`{{count}} searches`,{count:e.stats.searches})));let o=e.activity,s=[];o&&(o.thinking>0&&s.push(n(`{{count}} thinking steps`,{count:o.thinking})),e.count>0&&s.push(n(`{{count}} tool calls`,{count:e.count})));let c=e.explore,l=e.exploring||!!(o&&e.live),u=e.notice===`patrol`?n(`Patrol clear`):e.notice===`seen`?n(`Update seen`):null,d=c?Ns(`explore_fold`,n):u||(o?n(`Worked for {{duration}}`,{duration:ON(o.workedMs)}):r?e.exploring?n(`Exploring`):n(`Explored`):n(`{{count}} tool calls`,{count:e.count})),f=c?[c.goal,n(`{{count}} tool calls`,{count:e.count})].filter(Boolean):u?s:e.summary&&!e.exploring?[e.summary]:o?s:r?a:i,p=(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{c?.steps&&t?.(IH(e.key)),t?.(e.key)},title:c?.goal,"data-explore-head":c?``:void 0,"data-enso":`tool-row`,"data-notice":e.notice,className:G(`group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(X8,{state:e.exploring?`running`:`ok`}),(0,K.jsx)(`span`,{className:G(`shrink-0 text-muted-foreground group-hover/step:text-foreground`,l&&G(U5,`text-foreground`),e.exploring&&`font-medium`),children:d}),(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1 truncate`,l&&U5),children:f.join(` · `)}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,e.expanded&&`rotate-90`)})]});return!c||!e.expanded?p:(0,K.jsxs)(K.Fragment,{children:[p,(0,K.jsxs)(`div`,{"data-slot":`tool-details`,className:`t-acc-reveal mt-1 mb-1.5 ml-5 overflow-hidden rounded-lg border border-border/70 bg-card text-sm shadow-xs`,children:[c.goal&&(0,K.jsxs)(`div`,{className:`border-b border-border/60 px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`mb-0.5 text-[11px] text-muted-foreground`,children:n(`Goal`)}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap`,children:c.goal})]}),c.report&&(0,K.jsxs)(`div`,{className:`border-b border-border/60 px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`mb-0.5 text-[11px] text-muted-foreground`,children:n(`Result`)}),(0,K.jsx)(D3,{text:c.report})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(IH(e.key)),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,c.steps&&`rotate-90`)}),(0,K.jsx)(`span`,{children:c.steps?n(`Hide process`):n(`Show process`)}),(0,K.jsxs)(`span`,{children:[`· `,n(`{{count}} tool calls`,{count:e.count})]})]})]})]})}function n7({children:e,className:t,follow:n}){let r=(0,U.useRef)(null),i=(0,U.useRef)(null),a=(0,U.useRef)(n),o=(0,U.useRef)(n),s=(0,U.useRef)(null),c=(0,U.useRef)(null),l=(0,U.useRef)(0);o.current=n;let u=(0,U.useCallback)(()=>{a.current=!1,s.current=null,cancelAnimationFrame(l.current)},[]),d=(0,U.useCallback)(()=>{!o.current||!a.current||(cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{let e=r.current;if(!e||!o.current||!a.current)return;let t=Math.max(0,e.scrollHeight-e.clientHeight);s.current=t,e.scrollTop=t}))},[]);return(0,U.useEffect)(()=>{n?(a.current=!0,d()):(s.current=null,cancelAnimationFrame(l.current))},[n,d]),(0,U.useEffect)(d),(0,U.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(d);return t.observe(e),()=>t.disconnect()},[d]),(0,U.useEffect)(()=>()=>cancelAnimationFrame(l.current),[]),(0,K.jsx)(`div`,{ref:r,onWheel:e=>{e.deltaY<0&&u()},onPointerDown:e=>{e.target===e.currentTarget&&u()},onTouchStart:e=>{c.current=e.touches[0]?.clientY??null},onTouchMove:e=>{let t=e.touches[0]?.clientY;t!==void 0&&c.current!==null&&t>c.current&&u(),c.current=t??null},onTouchEnd:()=>{c.current=null},onScroll:e=>{if(!o.current)return;let t=e.currentTarget;if(t.scrollHeight-t.scrollTop-t.clientHeight<=2){a.current=!0,s.current=null;return}let n=s.current;if(n!==null&&t.scrollTop>=n-2){s.current=null,d();return}u()},className:G(`max-h-96 overflow-auto [overflow-anchor:none]`,t),children:(0,K.jsx)(`div`,{ref:i,children:e})})}function zre(e){if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Bre({source:e,output:t,view:n}){let r=n?.status===`completed`?zre(n.value):n?.error??t;return(0,K.jsxs)(`div`,{className:`space-y-1 px-3 py-1`,children:[e?(0,K.jsx)(y0,{code:e,language:`javascript`}):null,n&&n.calls.length>0?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...new Map(n.calls.map(e=>[e.name,e])).keys()].map(e=>{let t=n.calls.filter(t=>t.name===e),r=t.find(e=>!e.ok),i=`${e} ×${t.length}`;return(0,K.jsx)(`span`,{className:G(`rounded-md border px-1.5 py-0.5 font-mono text-[10px]`,r?`border-destructive/40 text-destructive`:`text-muted-foreground`),title:t.map(e=>e.summary).filter(Boolean).join(`
272
+ `),o=a>0,s=e.startsWith(`coworker-`)||e===`agent-notification`?ft:Kn;return(0,K.jsxs)(`div`,{className:oP,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:!o,onClick:()=>r(e=>!e),className:`flex w-full items-start gap-2 text-left enabled:hover:text-foreground`,children:[(0,K.jsx)(s,{className:sP}),(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1`,o?`truncate`:`whitespace-pre-wrap`),children:o?i.slice(0,a):i})]}),o&&n&&(0,K.jsx)(`pre`,{className:`mt-1.5 max-h-80 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words`,children:i.slice(a+1)})]})}var tre={"goal-complete":gt,"goal-blocked":St,"needs-user":er,"turn-ended":fn,failed:Dt,stalled:Xt,interrupted:jn,proposal:kt,schedule:rt,pending:Xt,"ask-relay":ln,leftover:Xt,queued:rt};function P5({lines:e}){return(0,K.jsx)(`div`,{"data-enso":`secretary-updates`,className:G(aP,`divide-y divide-border/60`),children:e.map((e,t)=>(0,K.jsx)(nre,{line:e,onOpen:h6},t))})}function nre({line:e,onOpen:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1),a=tre[e.kind],o=`conversationId`in e?e.conversationId:void 0,s=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text})]});return(0,K.jsxs)(`div`,{"data-enso":`secretary-update`,"data-open":r?`true`:`false`,className:`px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[e.detail?(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-update-expand`,"aria-expanded":r,onClick:()=>i(e=>!e),className:`flex min-w-0 flex-1 items-start gap-2 text-left hover:text-foreground`,children:s}):(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:s}),o&&t?(0,K.jsx)(`button`,{type:`button`,"data-enso":`secretary-update-open`,title:n(`Open session`),"aria-label":n(`Open session`),onClick:e=>{e.stopPropagation(),t(o)},className:`-mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-[5px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(st,{className:`h-3.5 w-3.5`})}):null]}),e.detail&&r&&(0,K.jsx)(`pre`,{className:`mt-1.5 ml-5.5 max-h-60 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words`,children:e.detail})]})}var F5=/^<message-from-main-agent>\n?([\s\S]*?)\n?<\/message-from-main-agent>\s*$/;function rre(e){let t=k5.exec(e);return F5.test(t?e.slice(t[0].length):e)}function ire({name:e,content:t}){let{t:n}=q();return(0,K.jsxs)(zE,{children:[(0,K.jsxs)(VE,{className:lA(`skill`,!0),children:[(0,K.jsx)(Hn,{className:`h-3 w-3`}),e]}),(0,K.jsxs)(WE,{className:`max-w-lg`,children:[(0,K.jsx)(GE,{children:(0,K.jsxs)(qE,{className:`text-base`,children:[n(`Skill`),` · `,e]})}),(0,K.jsx)(XE,{className:`max-h-[50vh] text-sm`,children:(0,K.jsx)(D3,{text:t})})]})]})}function I5({chip:e,extra:t}){return(0,K.jsxs)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-md bg-muted px-4 py-2.5 text-sm`,children:[(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:e}),t?(0,K.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap break-words leading-relaxed`,children:(0,K.jsx)(R5,{text:t})}):null]})}function are({blocks:e,hostTaskWrapUp:t}){let n=Dk(e.rest),r=t?Ok(e.rest):void 0,i=(0,K.jsx)(I5,{chip:(0,K.jsx)(`span`,{className:`inline-flex flex-wrap gap-1 align-middle`,children:e.skills.map(e=>(0,K.jsx)(ire,{name:e.name,content:e.body},e.location))}),extra:n.rest.trim()});return!n.plan&&!n.unattended&&!r?i:(0,K.jsxs)(K.Fragment,{children:[n.plan&&(0,K.jsx)(j5,{note:n.plan}),n.unattended&&(0,K.jsx)(M5,{note:n.unattended}),r&&(0,K.jsx)(A5,{items:r.items}),i]})}function ore({text:e}){let t=Mk(e);if(t.names.length>1)return(0,K.jsx)(I5,{chip:(0,K.jsx)(`span`,{className:`inline-flex flex-wrap gap-1 align-middle`,children:t.names.map(e=>(0,K.jsx)(uA,{name:`/skill:${e}`},e))}),extra:t.rest});let n=oA(e);return n.slash?(0,K.jsx)(I5,{chip:(0,K.jsx)(uA,{name:n.slash}),extra:n.rest.trim()}):null}function sre({preset:e}){let{t}=q();return(0,K.jsxs)(`div`,{className:`min-w-64 max-w-[80%] overflow-hidden rounded-2xl rounded-br-md bg-muted text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2.5`,children:[(0,K.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-info/15 text-info`,children:(0,K.jsx)(nr,{className:`h-4 w-4`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:t(`Workflow preset`)}),(0,K.jsx)(`p`,{className:`truncate font-medium`,title:e.id,children:e.name||e.id})]})]}),e.args.length>0&&(0,K.jsx)(`dl`,{className:`space-y-1 border-t border-border/60 px-3.5 py-2 text-xs`,children:e.args.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`shrink-0 font-mono text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:t})]},e))})]})}function L5({kind:e,label:t,title:n}){let r=e===`file`?Ht:e===`chat`?jn:Un;return(0,K.jsxs)(`span`,{className:G(gA(e),`mx-0.5 max-w-52 rounded-md px-1.5 align-middle leading-4`),title:n,children:[(0,K.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:t})]})}function cre({label:e,sessionFile:t}){let n=KW(nP(e=>e.conversations),t);return n?(0,K.jsxs)(`button`,{type:`button`,"data-enso":`chat-ref`,onClick:()=>h6(n),title:t,className:G(gA(`chat`),`mx-0.5 inline-flex max-w-52 items-center gap-1 rounded-md px-1.5 align-middle leading-4 hover:bg-muted`),children:[(0,K.jsx)(jn,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e})]}):(0,K.jsx)(L5,{kind:`chat`,label:e,title:t})}var lre=240;function ure({text:e,originalLines:t}){let{t:n}=q(),r=(0,U.useRef)(null),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(!1);(0,U.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=()=>a(e.scrollHeight>241);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let c=i&&!o;return(0,K.jsxs)(`span`,{"data-enso":`quote-block`,className:`mt-1 mb-2.5 block border-l-2 border-brand/40 pl-2.5 text-muted-foreground`,children:[t?(0,K.jsx)(`span`,{"data-quote-truncated":``,className:`mb-0.5 block text-[11px] text-warning`,children:n(`Truncated · original {{count}} lines`,{count:t})}):null,(0,K.jsx)(`span`,{ref:r,"data-quote-body":``,"data-clipped":c?``:void 0,style:c?{maxHeight:lre}:void 0,className:G(`block`,c&&`overflow-hidden mask-b-from-60%`),children:EA(e).map((e,t)=>e.type===`code`?(0,K.jsx)(`span`,{"data-quote-code":``,className:`my-1 block overflow-x-auto whitespace-pre rounded-md bg-background/60 px-2 py-1 font-mono text-xs`,children:e.code},t):(0,K.jsx)(`span`,{children:e.text},t))}),i?(0,K.jsx)(`button`,{type:`button`,"data-quote-toggle":``,"data-quote-skip":``,onClick:()=>s(e=>!e),className:`mt-0.5 text-[11px] text-muted-foreground/80 select-none hover:text-foreground`,children:n(o?`Show less`:`Show more`)}):null]})}function R5({text:e,searchQuery:t=``,activeNth:n=-1}){let r=Jk(vk(e)),i={n:0};return(0,K.jsx)(`span`,{className:`whitespace-pre-wrap`,children:r.map((e,r)=>e.type===`file`?(0,K.jsx)(B4,{path:e.path,children:(0,K.jsx)(L5,{kind:`file`,label:$k(e.path),title:e.path})},r):e.type===`chat`?(0,K.jsx)(cre,{label:e.label,sessionFile:e.sessionFile},r):e.type===`ui-element`?(0,K.jsx)(L5,{kind:`ui-element`,label:e.label,title:`${e.path}${e.text?` · ${e.text}`:``}`},r):e.type===`quote`?(0,K.jsx)(ure,{text:e.text,originalLines:e.originalLines},r):(0,K.jsx)(`span`,{children:t.trim()?pU(e.text,t,n,i):e.text},r))})}function dre({files:e,chats:t}){return(0,K.jsxs)(`span`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[e.map(e=>(0,K.jsx)(B4,{path:e,children:(0,K.jsx)(L5,{kind:`file`,label:$k(e),title:e})},`f:${e}`)),t.map(e=>(0,K.jsx)(L5,{kind:`chat`,label:e.label,title:e.sessionFile},`c:${e.sessionFile}`))]})}var z5=`max-w-[82%] rounded-[10px] bg-muted px-3.5 py-[9px] text-(length:--chat-body-size) leading-[1.6]`;function B5({text:e,searchQuery:t=``,activeNth:n=-1,thumbnails:r=0,align:a=`end`,hostTaskWrapUp:o=!1}){let{t:s}=q(),c=LN(),l=!!(c?.speaker||c?.botSession),u=qU(e,r);if(u)return(0,K.jsxs)(K.Fragment,{children:[u.text&&(0,K.jsx)(B5,{text:u.text,searchQuery:t,activeNth:n,hostTaskWrapUp:o}),(0,K.jsx)(qG,{entries:u.entries,thumbnails:r,align:a})]});let d=ZU(e);if(d)return(0,K.jsx)(k3,{message:d});let f=l?jU(e):null;if(f)return(0,K.jsx)(WW,{message:f});let p=l?DU(e):e;if(p!==e)return(0,K.jsx)(B5,{text:p,searchQuery:t,activeNth:n,hostTaskWrapUp:o});let m=l?CU(e):null;if(m?.refs.length)return(0,K.jsxs)(`div`,{className:`flex w-full flex-col items-end gap-1.5`,children:[m.body&&(0,K.jsx)(B5,{text:m.body,searchQuery:t,activeNth:n}),(0,K.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:m.refs.map(e=>(0,K.jsxs)(`span`,{title:s(`Referenced chat`),className:`inline-flex h-6 max-w-56 items-center gap-1 rounded-md bg-muted px-1.5 text-xs`,children:[(0,K.jsx)(fn,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]},e.id))})]});let h=he(e);if(h.note){let e=h.rest.trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(j5,{note:h.note}),e&&(0,K.jsx)(B5,{text:e,searchQuery:t,activeNth:n,hostTaskWrapUp:o})]})}let g=bk(e);if(g.note){let e=g.rest.trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(M5,{note:g.note}),e&&(0,K.jsx)(B5,{text:e,searchQuery:t,activeNth:n,hostTaskWrapUp:o})]})}let _=o?Tk(e):null;if(_){let e=_.rest.trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(A5,{items:_.items}),e&&(0,K.jsx)(B5,{text:e,searchQuery:t,activeNth:n})]})}let v=qne.exec(e);if(v){let r=e.slice(v[0].length).trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Jne,{note:v[1]??``}),r&&(0,K.jsx)(B5,{text:r,searchQuery:t,activeNth:n})]})}let y=i(e);if(y?.kind===`approved`)return(0,K.jsxs)(`div`,{className:`flex w-full items-start gap-2 rounded-lg border border-dashed border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(kt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[s(`Plan approved, executing`),(0,K.jsx)(`span`,{className:`ml-1.5 text-foreground`,children:y.title})]})]});if(y?.kind===`feedback`)return(0,K.jsxs)(`div`,{className:G(z5,`whitespace-pre-wrap`),children:[(0,K.jsxs)(`p`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:[(0,K.jsx)(At,{className:`h-3 w-3`}),s(`Plan feedback`)]}),(0,K.jsx)(R5,{text:y.feedback,searchQuery:t,activeNth:n})]});let b=Ik(e);if(b)return(0,K.jsx)(sre,{preset:b});let x=nA(e);if(x.files.length>0||x.chats.length>0){let e=oA(x.body);return(0,K.jsxs)(`div`,{className:z5,children:[e.slash?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(uA,{name:e.slash}),e.rest.trim()?(0,K.jsx)(`span`,{className:`ml-1.5 align-middle`,children:(0,K.jsx)(R5,{text:e.rest.trim(),searchQuery:t,activeNth:n})}):null]}):(0,K.jsx)(R5,{text:x.body,searchQuery:t,activeNth:n}),(0,K.jsx)(dre,{files:x.files,chats:x.chats})]})}let S=Nk(e);if(S)return(0,K.jsx)(are,{blocks:S,hostTaskWrapUp:o});if(oA(e).slash)return(0,K.jsx)(ore,{text:e});let C=Kne.exec(e);if(C){let r=e.slice(C[0].length).trim();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Yne,{note:C[1]}),r&&(0,K.jsx)(B5,{text:r,searchQuery:t,activeNth:n})]})}let w=nW(e);if(w)return(0,K.jsx)(Qne,{segments:w,searchQuery:t,activeNth:n});let T=FW(e);if(T)return(0,K.jsx)(P5,{lines:T});let E=k5.exec(e),D=E?e.slice(E[0].length):e,O=F5.exec(D),k=O?O[1]:D;return(0,K.jsxs)(`div`,{className:G(O?`max-w-[80%] rounded-2xl rounded-bl-md border border-blue-500/20 bg-blue-500/8 px-4 py-2.5 text-sm`:G(z5,`whitespace-pre-wrap`)),children:[O&&(0,K.jsxs)(`p`,{className:`mb-1 flex items-center gap-1 text-[10px] font-medium tracking-wide text-blue-600 uppercase dark:text-blue-400`,children:[(0,K.jsx)(ft,{className:`h-3 w-3`}),s(`From main agent`)]}),E?.[1]&&!PU(E[1])&&(0,K.jsxs)(`div`,{className:`mb-2 rounded-md bg-background/60 px-2.5 py-1.5 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:s(`Role`)}),` · `,E[1]]}),O?(0,K.jsx)(D3,{text:k,searchQuery:t,activeNth:n}):(0,K.jsx)(R5,{text:k,searchQuery:t,activeNth:n})]})}function V5(e){return e.kind===`tool-group`||e.kind===`thinking`||e.kind===`tool`&&MH(e)}var H5=`text-[color:var(--subtle-foreground,var(--muted-foreground))]`,U5=`animate-pulse motion-reduce:animate-none`;function fre({model:e,at:t,privacyMask:n,secretarySession:r=!1,face:i,conversationId:a}){let o=LN(),s=ez(a),c=r?i??s:null,l=o?.speaker??(o?null:c),u=!o&&c?!0:void 0,d=[e,typeof t==`number`?$5(t):null].filter(Boolean).join(` · `);return!l&&!d&&!n?null:(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`mb-2 flex h-6 min-w-0 items-center gap-2 text-xs select-none`,children:[l&&(l.image?(0,K.jsx)(`img`,{"data-enso":u?`secretary-chat-avatar`:void 0,"data-image":u?`true`:void 0,src:l.image,alt:``,draggable:!1,className:`size-[22px] shrink-0 rounded-full object-cover`,style:{backgroundColor:l.color}}):u?(0,K.jsx)(nR,{name:l.name,color:l.color,enso:`secretary-chat-avatar`,className:`size-[22px] rounded-full`}):(0,K.jsx)(`span`,{className:`flex size-[22px] shrink-0 items-center justify-center rounded-full font-semibold text-[11px] text-white`,style:{backgroundColor:l.color},children:[...l.name.trim()][0]?.toUpperCase()??`?`})),l&&(0,K.jsx)(`span`,{className:`shrink-0 truncate text-[13px] font-semibold text-foreground`,children:l.name}),d&&(0,K.jsx)(`span`,{className:G(`min-w-0 truncate text-[11.5px]`,H5),children:d}),n&&(0,K.jsx)(A8,{report:n})]})}var pre=(0,U.memo)(function({item:e,secretarySession:t=!1,onToggleGroup:n,onToggleTurn:r}){let i=lU(),a=i.query,o=i.activeKey===e.key?i.activeNth:-1,s=t;switch(e.kind){case`user`:{let t=e.text?rre(e.text):!1,n=e.collapsed===!0,i=e.hostTaskWrapUp?kk(e.text):e.text;return(0,K.jsxs)(`div`,{"data-enso":`message-user`,className:G(`group/user flex flex-col gap-1.5`,t?`items-start`:`items-end`),children:[e.images.map((e,t)=>(0,K.jsx)(WG,{src:`data:${e.mimeType};base64,${e.data}`,className:`max-h-48 max-w-full rounded-lg border object-contain`},t)),e.text&&(0,K.jsx)(B5,{text:e.text,searchQuery:a,activeNth:o,thumbnails:e.images.length,align:t?`start`:`end`,hostTaskWrapUp:e.hostTaskWrapUp===!0}),n?(0,K.jsx)(Dre,{turnKey:e.key,text:i,timestamp:e.timestamp,turnDurationMs:e.turnDurationMs,onToggle:r}):(0,K.jsx)(Ore,{turnKey:e.key,messageIndex:Number(e.key),text:i,timestamp:e.timestamp,deliveryState:e.deliveryState,canCollapse:e.canCollapse,onToggleTurn:r})]})}case`text`:return(0,K.jsx)(Are,{item:e,searchQuery:a,activeNth:o});case`thinking`:return(0,K.jsx)(Pre,{itemKey:e.key,text:e.text,streaming:e.streaming,durationMs:e.durationMs,startedAt:e.startedAt});case`tool`:{let t=gG(e),n=nB(e.name,s),r=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fO,{name:e.name,output:e.output,state:e.state}),n?(0,K.jsx)(b5,{item:e,framed:s}):(0,K.jsx)(Vre,{item:e}),t?(0,K.jsx)(xG,{proposalId:t}):null,e.pluginArtifacts?(0,K.jsx)(E6,{artifacts:e.pluginArtifacts,align:n?`card`:`tool-row`}):null]});return n?(0,K.jsx)(`div`,{"data-enso":`tool-card-pair`,className:`w-full min-w-0`,children:r}):r}case`tool-group`:return(0,K.jsx)(Rre,{item:e,onToggle:n});case`error`:return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm text-destructive`,children:[(0,K.jsx)(St,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap`,children:e.text}),(0,K.jsx)(J5,{})]});case`interrupted`:return(0,K.jsx)(yre,{item:e});case`task-note`:return(0,K.jsx)(Fre,{item:e});case`compaction`:case`compaction-notice`:return(0,K.jsx)(Lre,{item:e});case`compaction-progress`:return(0,K.jsx)(Ire,{state:e.state});case`session-custom`:return(0,K.jsx)(vre,{entry:e.entry});case`plugin-message`:return(0,K.jsx)(hre,{item:e});case`discarded-turn`:return(0,K.jsx)(gre,{item:e,onToggle:n});case`resumed-reply`:return(0,K.jsx)(_re,{item:e,onToggle:n});case`divider`:return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`}),e.text,(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`})]})}},Gne),W5=e=>{if(typeof e==`string`)return e;if(e===void 0)return`—`;try{return JSON.stringify(e)}catch{return String(e)}};function mre({entry:e}){let{t}=q(),n=r6(),r=n.get(e.accountKey),i=e.previousAccountKey?n.get(e.previousAccountKey):void 0,a=e.previousAccountKey?i&&r?t(`ChatGPT account switched: {{previous}} → {{current}}`,{previous:i,current:r}):t(`ChatGPT account switched`):r?t(`ChatGPT account selected: {{account}}`,{account:r}):t(`ChatGPT account selected`);return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(An,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-primary`}),(0,K.jsx)(`p`,{className:`min-w-0 break-words text-muted-foreground`,children:a})]})}function hre({item:e}){let{t}=q();return(0,K.jsxs)(`div`,{"data-plugin-message":e.pluginId,className:`rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs`,children:[(0,K.jsxs)(`p`,{className:`mb-1 flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(M6,{pluginId:e.pluginId,className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:t(`From plugin {{name}}`,{name:e.pluginName})}),(0,K.jsx)(`span`,{className:`font-mono opacity-70`,children:e.pluginId})]}),(0,K.jsx)(`div`,{className:G5,children:(0,K.jsx)(D3,{text:e.text})})]})}var G5=`break-words text-foreground [&_p]:whitespace-pre-line`;function gre({item:e,onToggle:t}){let{t:n}=q();return(0,K.jsxs)(`div`,{"data-discarded-turn":e.pluginId,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.key),"data-enso":`tool-row`,className:G(`group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(zn,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground group-hover/step:text-foreground`,children:Ns(`turn_discard`,n)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.pluginName,e.reason].filter(Boolean).join(` · `)}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,e.expanded&&`rotate-90`)})]}),e.expanded&&(0,K.jsxs)(`div`,{className:`t-acc-reveal mt-1 mb-1.5 ml-5 space-y-2 rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs`,children:[(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,K.jsx)(M6,{pluginId:e.pluginId,className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`From plugin {{name}}`,{name:e.pluginName})})]}),e.messages.map((e,t)=>(0,K.jsx)(`div`,{className:G5,children:(0,K.jsx)(D3,{text:e})},t)),e.tools.map((e,t)=>(0,K.jsxs)(`p`,{className:G(`truncate`,H5),children:[Ns(e.name,n),` `,e.summary]},t))]})]})}function _re({item:e,onToggle:t}){let{t:n}=q();return(0,K.jsxs)(`div`,{"data-resumed-reply":``,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.key),"aria-expanded":e.expanded,"data-enso":`tool-row`,className:G(`group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(Sn,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[n(`Interrupted by a restart, continued below`),(0,K.jsx)(`span`,{className:`ml-1.5 opacity-70`,children:e.expanded?n(`Hide the interrupted part`):n(`Show the interrupted part`)})]}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,e.expanded&&`rotate-90`)})]}),e.expanded&&(0,K.jsxs)(`div`,{className:`t-acc-reveal mt-1 mb-1.5 ml-5 space-y-2 rounded-md border border-dashed border-border bg-muted/20 px-3 py-2 text-xs`,children:[e.thinking&&(0,K.jsx)(`p`,{className:G(`whitespace-pre-wrap break-words`,H5),children:e.thinking}),e.text&&(0,K.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-foreground`,children:e.text}),e.tools.map((e,t)=>(0,K.jsxs)(`p`,{className:G(`truncate`,H5),children:[Ns(e.name,n),` `,e.summary]},t))]})]})}function vre({entry:e}){let{t}=q();if(e.kind===`oauth-account-selected`)return(0,K.jsx)(mre,{entry:e});if(e.kind===`agent-dispatch`)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(ft,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:t(`Dispatched to`)}),(0,K.jsx)(`span`,{className:`font-medium`,children:e.child.instanceName})]});if(e.kind===`agent-completed`)return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-emerald-500/20 bg-emerald-500/5 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[e.child.instanceName,` · `,t(`Completed`)]}),e.receiptSummary&&(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground`,children:e.receiptSummary})]})]});if(e.kind===`agent-failed`)return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-destructive/20 bg-destructive/5 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(St,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-destructive`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[e.child.instanceName,` · `,t(`Failed`)]}),(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground`,children:e.message})]})]});if(e.kind===`tool-batch-label`)return null;if(e.kind===`task-wrap-up-nudge`)return(0,K.jsxs)(`div`,{"data-enso":`task-wrap-up-nudge`,className:`my-1 flex items-center gap-1.5 text-[12px] text-subtle-foreground`,children:[(0,K.jsx)(nn,{className:`size-3.5 shrink-0`}),t(`{{count}} background tasks are still undeclared; the next message asks the agent to stop each one or state why it keeps running`,{count:e.count})]});let n=e.receipt,r=n.outcome===`succeeded`;return(0,K.jsx)(`div`,{className:G(`rounded-md border px-2.5 py-2 text-xs`,r?`border-emerald-500/20 bg-emerald-500/5`:n.outcome===`failed`?`border-destructive/20 bg-destructive/5`:`border-amber-500/20 bg-amber-500/5`),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[r?(0,K.jsx)(gt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-500`}):(0,K.jsx)(St,{className:G(`mt-0.5 h-3.5 w-3.5 shrink-0`,n.outcome===`failed`?`text-destructive`:`text-amber-500`)}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`font-medium`,children:[n.subject.label,` · `,t(n.outcome)]}),(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground`,children:n.summary}),n.changes&&n.changes.length>0&&(0,K.jsx)(`dl`,{className:`mt-2 space-y-1 border-t border-border/50 pt-2`,children:n.changes.map(e=>(0,K.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,K.jsx)(`dt`,{className:`truncate text-muted-foreground`,children:e.field}),(0,K.jsxs)(`dd`,{className:`text-right font-mono`,children:[W5(e.previous),` → `,W5(e.value)]})]},e.field))})]})]})})}function K5(e){let t=e.activeId?e.conversations[e.activeId]:null;return t?t.activeTabId?e.conversations[t.activeTabId]??t:t:null}var q5=()=>()=>{};function yre({item:e}){let{locale:t}=q(),n=RU({at:e.at,kind:e.exitKind,unfinishedTools:e.unfinishedTools,lang:t});return(0,K.jsxs)(`div`,{"data-enso":`timeline-interrupted`,className:`flex items-start gap-2 text-sm text-warning`,children:[(0,K.jsx)(St,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap`,children:n}),(0,K.jsx)(bre,{})]})}function bre(){let{t:e}=q();return nP(e=>{let t=K5(e);return!!(t&&!t.spawning&&t.status!==`running`)})?(0,K.jsxs)(`button`,{type:`button`,"data-enso":`timeline-interrupted-retry`,title:e(`Retry`),onClick:()=>{let e=K5(nP.getState());e&&nP.getState().retryInterrupted(e.id)},className:`mt-0.5 inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(An,{className:`h-3 w-3`}),e(`Retry`)]}):null}function J5(){let{t:e}=q(),t=LN(),n=t?.botControls,r=nP(e=>{if(t&&(!t.canRetry||t.botControls))return!1;let n=K5(e);return!!(n?.started&&!n.spawning&&n.status!==`running`)}),i=()=>{if(!n||!t?.canRetry)return!1;let e=n.projection();return!!(e&&e.status!==`running`)},a=(0,U.useSyncExternalStore)(n?.subscribe??q5,i,i);return(n?a:r)?(0,K.jsxs)(`button`,{type:`button`,title:e(`Retry`),onClick:()=>{if(n)return n.retry();let e=K5(nP.getState());e&&nP.getState().retry(e.id)},className:`mt-0.5 inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(An,{className:`h-3 w-3`}),e(`Retry`)]}):null}function xre(e,t){return XB(K5(e),t)}var Y5=`flex items-center gap-1 text-[11px] text-muted-foreground transition-opacity hover:text-foreground`;function Sre({messageIndex:e}){let{t}=q(),n=LN();return nP(e=>{let t=K5(e);return ZB(t,n,t?JB(e.conversations,t.id):1)})?(0,K.jsxs)(`button`,{type:`button`,className:Y5,title:t(`Keep this session and start a parallel one from here`),onClick:()=>{let t=nP.getState(),n=K5(t);n&&t.forkFromTurn(n.id,e)},children:[(0,K.jsx)(Jt,{className:`h-3 w-3`}),t(`Conversation branch`)]}):null}function Cre({messageIndex:e}){let{t}=q(),n=LN(),r=nP(e=>K5(e)?.id),i=nP(t=>{let i=r?t.conversations[r]:void 0;if(n||!i||i.historyOnly||i.rewinding||i.restoringFiles||i.workspaceMigrating)return;let a=i.messages[e-(i.historyBaseIndex??0)];return v6(a)||i.status===`running`&&y6(a)?a?.deliveryId:void 0});return!r||!i?null:(0,K.jsxs)(`button`,{type:`button`,title:t(`Withdraw message`),onClick:()=>nP.getState().withdrawMessage(r,{kind:`delivery`,id:i}),className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(Qn,{className:`h-3 w-3`}),t(`Withdraw message`)]})}function wre(){let{t:e}=q(),t=nP(e=>K5(e)?.id);return t?(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void GW(t,e),className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(Mn,{className:`h-3 w-3`}),e(`Restart conversation`)]}):null}function Tre({messageIndex:e}){let{t}=q(),n=LN(),r=nP(e=>K5(e)?.id),i=nP(t=>{let i=r?t.conversations[r]:void 0;if(n||!i||i.historyOnly)return;let a=i.messages[e-(i.historyBaseIndex??0)];return v6(a)?a?.deliveryId:void 0});return!r||!i?null:(0,K.jsxs)(`button`,{type:`button`,title:t(`Resend`),onClick:()=>nP.getState().resendMessage(r,i),className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(An,{className:`h-3 w-3`}),t(`Resend`)]})}function Ere({messageIndex:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(null),o=LN(),s=o?.botControls,c=nP(t=>{if(o?.botControls)return!1;let n=K5(t);return xre(t,o)&&!!(n&&$B(n.id,n.id,n,e))}),l=()=>{if(!s||!o?.canRewind||!o.sessionId)return null;let t=s.projection();return!t||t.status===`running`?null:$B(o.sessionId,o.sessionId,t,e)?.entryId??null},u=(0,U.useSyncExternalStore)(s?.subscribe??q5,l,l);if(!(s?u!==null:c))return null;let d=t=>{if(s&&o?.sessionId&&u){a({restoreFiles:t,conversationId:o.sessionId,entryId:u});return}let n=K5(nP.getState());if(!n)return;let r=$B(n.id,n.id,n,e);r&&a({restoreFiles:t,conversationId:n.id,entryId:r.entryId})},f=(t,n,r)=>{if(s)return s.rewind(r,t);let i=nP.getState(),a=$B(n,K5(i)?.id,i.conversations[n],e,r);a&&i.rewind(a.conversationId,a.entryId,t)},p=[{icon:Qn,label:t(`Conversation only`),desc:t(`Rewind to this message`),restoreFiles:!1,action:()=>d(!1)},{icon:jn,label:t(`Conversation + files`),desc:t(`Rewind and restore files to before this turn`),restoreFiles:!0,action:()=>d(!0)}];return(0,K.jsxs)(Z3,{open:n,onOpenChange:r,children:[(0,K.jsxs)(Q3,{className:Y5,title:t(`Rewind to this message`),children:[(0,K.jsx)(Qn,{className:`h-3 w-3`}),t(`Rewind`)]}),(0,K.jsx)($3,{side:`bottom`,align:`end`,className:`w-72 [&_[data-slot=popover-viewport]]:p-1`,children:p.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{r(!1),e.action()},className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-muted/60`,children:[(0,K.jsx)(e.icon,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block`,children:e.label}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.desc})]})]},e.label))}),(0,K.jsx)(t8,{open:i!==null,onOpenChange:e=>{e||a(null)},title:t(`Rewind to this message?`),description:i?.restoreFiles?t(`Later messages leave the current branch and working-tree files are restored to before this turn.`):t(`Later messages leave the current branch; the text returns to the input box.`),confirmLabel:t(`Rewind`),onConfirm:()=>{i&&f(i.restoreFiles,i.conversationId,i.entryId)}})]})}function Dre({turnKey:e,text:t,timestamp:n,turnDurationMs:r,onToggle:i}){let{t:a}=q();return(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`flex items-center gap-1.5 text-[11px] text-muted-foreground/80 select-none`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i?.(e,!1),className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground cursor-pointer border border-border/40`,title:a(`Expand`),children:[(0,K.jsx)(vt,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{children:a(`Expand`)})]}),(0,K.jsx)(X5,{text:t}),typeof n==`number`&&(0,K.jsx)(`span`,{children:$5(n)}),r!==void 0&&(0,K.jsxs)(`span`,{children:[`· `,a(`took {{duration}}`,{duration:ON(r)})]})]})}function X5({text:e}){return e.trim()?(0,K.jsx)(`span`,{"data-enso":`copy-user-prompt`,className:`inline-flex`,children:(0,K.jsx)(Z5,{text:dk(e),className:`opacity-0 transition-opacity group-hover/user:opacity-100 focus-visible:opacity-100`})}):null}function Ore({turnKey:e,messageIndex:t,text:n,timestamp:r,canCollapse:i,deliveryState:a,onToggleTurn:o}){let{t:s}=q(),c=E(e=>e.autoCollapseTurns);return(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`flex items-center gap-2 text-[11px] text-muted-foreground/75 select-none`,children:[(0,K.jsx)(Ere,{messageIndex:t}),(0,K.jsx)(Tre,{messageIndex:t}),(0,K.jsx)(Cre,{messageIndex:t}),(0,K.jsx)(X5,{text:n}),a&&(0,K.jsx)(`span`,{children:s(a===`stuck`?`Not sent: the previous turn is stuck and could not be interrupted. Restart the conversation, then resend.`:a===`rejected`?`Not sent`:`Delivery unconfirmed`)}),a===`stuck`&&(0,K.jsx)(wre,{}),c&&i&&o&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(e,!0),className:G(Y5,`cursor-pointer opacity-0 group-hover/user:opacity-100`),title:s(`Collapse`),children:[(0,K.jsx)(_t,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{children:s(`Collapse`)})]}),typeof r==`number`&&(0,K.jsx)(`span`,{children:$5(r)})]})}function kre({turnKey:e,canCollapse:t,collapsed:n,onToggleTurn:r}){let{t:i}=q();return!E(e=>e.autoCollapseTurns)||!t||!r||n?null:(0,K.jsxs)(`button`,{type:`button`,"data-enso":`turn-collapse`,"data-quote-skip":``,onClick:()=>r(e,!0),className:G(`mt-1 flex min-h-6 select-none items-center gap-1 text-[12px] transition-colors hover:text-foreground [@media(hover:none)]:min-h-10 [@media(hover:none)]:pr-3`,H5),children:[(0,K.jsx)(bt,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:i(`Collapse`)})]})}function Are({item:e,searchQuery:t=``,activeNth:n=-1}){let{t:r}=q(),i=LN(),a=e.perf?jre(e.perf,r,e.turnDurationMs!==void 0):``,o=nP(e=>K5(e)?.id??null),s=Number(e.key.split(`-`)[0]),c={text:e.text,messageIndex:s,sessionId:i?i.sessionId:o};return(0,K.jsxs)(`div`,{"data-enso":`message-assistant`,className:`group text-(length:--chat-body-size)`,children:[(0,K.jsx)(D3,{text:e.text,streaming:e.streaming,searchQuery:t,activeNth:n,leaf:{messageIndex:c.messageIndex,sessionId:c.sessionId}}),e.turnEnd&&!e.streaming&&i?.turnFooter?.(Number(e.key.split(`-`)[0])),!e.streaming&&(0,K.jsxs)(`div`,{"data-quote-skip":``,className:`mt-1 flex items-center gap-2 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100`,children:[(0,K.jsx)(dO,{position:`left`,...c}),(0,K.jsx)(Z5,{text:e.text}),(0,K.jsx)(dO,{position:`right`,...c}),e.turnEnd&&(0,K.jsx)(Sre,{messageIndex:Number(e.key.split(`-`)[0])}),e.timestamp&&!e.turnEnd&&(0,K.jsx)(`span`,{children:$5(e.timestamp)}),e.turnDurationMs!==void 0&&(0,K.jsxs)(`span`,{children:[e.timestamp&&!e.turnEnd&&`· `,r(`took {{duration}}`,{duration:ON(e.turnDurationMs)})]}),a&&(0,K.jsxs)(`span`,{children:[`· `,a]})]})]})}function Z5({text:e,className:t}){let{t:n}=q(),[r,i]=(0,U.useState)(!1);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{i(!0),setTimeout(()=>i(!1),1e3)})},className:G(`flex items-center gap-1 transition-colors hover:text-foreground`,t),title:n(`Copy`),children:r?(0,K.jsx)(gt,{className:`h-3 w-3`}):(0,K.jsx)(Pt,{className:`h-3 w-3`})})}var Q5=e=>String(e).padStart(2,`0`),$5=e=>{let t=new Date(e);return`${Q5(t.getHours())}:${Q5(t.getMinutes())}`},e7=e=>{let t=e/1e3;return String(t<10?Math.round(t*10)/10:Math.round(t))};function jre(e,t,n=!1){let r=[];return(!n||e.turnMs!==void 0)&&r.push(`${e7(e.runMs)}s`),e.ttftMs!==void 0&&r.push(`TTFT ${e7(e.ttftMs)}s`),e.tps!==void 0&&r.push(`${Math.round(e.tps)} tok/s`),!n&&e.turnMs!==void 0&&r.push(t(`total {{duration}}`,{duration:ON(e.turnMs)})),r.join(` · `)}function Mre(e,t,n=16){return e.top<t.top?e.top-t.top-n:e.bottom>t.bottom?e.bottom-t.bottom+n:0}function Nre(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(`data-virtuoso-scroller`))return t;let e=typeof window.getComputedStyle==`function`?window.getComputedStyle(t).overflowY:t.style.overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return t;t=t.parentElement}return null}function t7(e,t=Nre(e)){if(!t){e.getBoundingClientRect().top<0&&e.scrollIntoView?.({block:`nearest`});return}let n=Mre(e.getBoundingClientRect(),t.getBoundingClientRect());n!==0&&(t.scrollTop=Math.max(0,t.scrollTop+n))}function Pre({itemKey:e,text:t,streaming:n,durationMs:r,startedAt:i}){let{t:a}=q(),o=E(e=>e.expandLiveReasoning),[s,c]=(0,U.useState)(null),l=aV(s,n,o),u=(0,U.useRef)(null),d=(0,U.useRef)(!1);return(0,U.useLayoutEffect)(()=>{l||!d.current||(d.current=!1,u.current&&t7(u.current))},[l]),(0,K.jsxs)(`div`,{ref:u,"data-enso":`thinking`,"data-live":n||void 0,children:[(0,K.jsxs)(`button`,{type:`button`,"data-quote-skip":``,onClick:()=>c(!l),className:G(`flex min-h-6 select-none items-center gap-2 text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(`span`,{className:`flex size-3 shrink-0 items-center justify-center`,children:(0,K.jsx)(pt,{className:G(`size-3`,n&&`animate-pulse text-brand`)})}),n?(0,K.jsx)(`span`,{className:G(`text-foreground`,U5),children:a(`Thinking…`)}):r===null?(0,K.jsx)(`span`,{children:a(`Thought process`)}):(0,K.jsx)(`span`,{children:a(`Thought for {{duration}}`,{duration:ON(r)})}),n&&(0,K.jsx)(a7,{itemKey:e,since:i}),(0,K.jsx)(vt,{className:G(`h-3 w-3 transition-transform`,l&&`rotate-90`)})]}),l&&(0,K.jsx)(mO,{text:t,streaming:n,itemKey:e}),l&&!n&&(0,K.jsxs)(`button`,{type:`button`,"data-enso":`thinking-collapse`,"data-quote-skip":``,onClick:()=>{d.current=!0,c(!1)},className:G(`mt-1 ml-[31px] flex min-h-6 select-none items-center gap-1 text-[12px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(bt,{className:`h-3 w-3`}),(0,K.jsx)(`span`,{children:a(`Collapse thinking`)})]})]})}function Fre({item:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(void 0),o=/^Background task (\S+) finished \((.+?), ran (.+?)\)/.exec(e.summary),s=o?`${o[1]} · ${o[2]} · ${o[3]}`:e.summary,c=/(?:read ((?:\/|[A-Za-z]:[\\/]).+?\.log) for the complete log|Full log: ((?:\/|[A-Za-z]:[\\/])\S+?\.log))/.exec(e.detail)?.slice(1).find(Boolean)??null;return(0,U.useEffect)(()=>{!n||!c||i!==void 0||window.electronAPI.files.read(c).then(e=>{a(typeof e==`string`?e:null)}).catch(()=>a(null))},[n,c,i]),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-3`,title:e.detail,children:[(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,K.jsx)(gt,{className:`h-3 w-3 text-green-600 dark:text-green-500`}),s,(0,K.jsx)(vt,{className:G(`h-3 w-3 transition-transform`,n&&`rotate-90`)})]}),(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),n&&(0,K.jsxs)(`div`,{className:`mt-1.5 rounded-lg border border-border/60 bg-muted/20`,children:[(0,K.jsx)(`pre`,{className:`border-b border-border/60 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:e.detail}),(0,K.jsx)(`pre`,{className:`max-h-64 overflow-auto px-3 py-2 font-mono text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:c?i===void 0?t(`Loading…`):c6(i??t(`(log unavailable)`)):t(`(no log available)`)})]})]})}function Ire({state:e}){let{t}=q();return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,K.jsx)(sn,{className:`h-3 w-3 animate-spin`}),(0,K.jsx)(`span`,{children:t(e===`queued`?`Compacts after this turn`:`Compacting…`)})]})}function Lre({item:e}){let{t}=q(),[n,r]=(0,U.useState)(!1),i=e.kind===`compaction`,a=e.tokensBefore===null?null:DN(e.tokensBefore),o=n8(e.tokensBefore,e.tokensAfter),s=o!==null&&e.tokensBefore!==null&&e.tokensAfter!==void 0?t(`{{kind}} · {{before}} → {{after}} · freed {{percent}}%`,{kind:t(e.memory?`Memory context compacted`:e.verified?`Verified context compacted`:`Context compacted`),before:DN(e.tokensBefore),after:DN(e.tokensAfter),percent:o}):e.memory?a===null?t(`Memory context compacted`):t(`Memory context compacted ({{tokens}} tokens before)`,{tokens:a}):e.verified?a===null?t(`Verified context compacted`):t(`Verified context compacted ({{tokens}} tokens before)`,{tokens:a}):a===null?t(`Context compacted`):t(`Context compacted ({{tokens}} tokens before)`,{tokens:a});return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:G(`flex items-center gap-3`,i&&`w-full`),title:e.memory?t(`Summary rendered from continuous memory. Messages above are no longer in the model context; use recall for sources.`):e.verified?t(`Verified summary from smart compaction. Messages above are no longer in the model context.`):t(i?`Messages above are no longer in the model context; only this summary is.`:`Latest compaction summary — expand to read what the model kept.`),children:[i&&(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`}),(0,K.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,K.jsx)(_n,{className:`h-3 w-3`}),s,(0,K.jsx)(vt,{className:G(`h-3 w-3 transition-transform`,n&&`rotate-90`)})]}),i&&(0,K.jsx)(`span`,{className:`h-px flex-1 bg-border`})]}),n&&(0,K.jsx)(`pre`,{className:`mt-1.5 max-h-80 overflow-auto rounded-lg border border-border/60 bg-muted/20 px-3 py-2 font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:e.summary||t(`(summary unavailable)`)})]})}function Rre({item:e,onToggle:t}){let{t:n}=q(),r=E(e=>e.compactReadOnlyTools),i=[];e.stats.commands>0&&i.push(n(`ran {{count}} commands`,{count:e.stats.commands})),e.stats.reads>0&&i.push(n(`read {{count}} files`,{count:e.stats.reads})),e.stats.searches>0&&i.push(n(`searched {{count}} times`,{count:e.stats.searches})),e.stats.others>0&&i.push(n(`{{count}} other calls`,{count:e.stats.others}));let a=[];r&&(e.stats.reads>0&&a.push(n(`{{count}} files`,{count:e.stats.reads})),e.stats.searches>0&&a.push(n(`{{count}} searches`,{count:e.stats.searches})));let o=e.activity,s=[];o&&(o.thinking>0&&s.push(n(`{{count}} thinking steps`,{count:o.thinking})),e.count>0&&s.push(n(`{{count}} tool calls`,{count:e.count})));let c=e.explore,l=e.exploring||!!(o&&e.live),u=e.notice===`patrol`?n(`Patrol clear`):e.notice===`seen`?n(`Update seen`):null,d=c?Ns(`explore_fold`,n):u||(o?n(`Worked for {{duration}}`,{duration:ON(o.workedMs)}):r?e.exploring?n(`Exploring`):n(`Explored`):n(`{{count}} tool calls`,{count:e.count})),f=c?[c.goal,n(`{{count}} tool calls`,{count:e.count})].filter(Boolean):u?s:e.summary&&!e.exploring?[e.summary]:o?s:r?a:i,p=(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{c?.steps&&t?.(IH(e.key)),t?.(e.key)},title:c?.goal,"data-explore-head":c?``:void 0,"data-enso":`tool-row`,"data-notice":e.notice,className:G(`group/step flex min-h-6 w-full items-center gap-2 text-left text-[13px] transition-colors hover:text-foreground`,H5),children:[(0,K.jsx)(X8,{state:e.exploring?`running`:`ok`}),(0,K.jsx)(`span`,{className:G(`shrink-0 text-muted-foreground group-hover/step:text-foreground`,l&&G(U5,`text-foreground`),e.exploring&&`font-medium`),children:d}),(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1 truncate`,l&&U5),children:f.join(` · `)}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,e.expanded&&`rotate-90`)})]});return!c||!e.expanded?p:(0,K.jsxs)(K.Fragment,{children:[p,(0,K.jsxs)(`div`,{"data-slot":`tool-details`,className:`t-acc-reveal mt-1 mb-1.5 ml-5 overflow-hidden rounded-lg border border-border/70 bg-card text-sm shadow-xs`,children:[c.goal&&(0,K.jsxs)(`div`,{className:`border-b border-border/60 px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`mb-0.5 text-[11px] text-muted-foreground`,children:n(`Goal`)}),(0,K.jsx)(`p`,{className:`whitespace-pre-wrap`,children:c.goal})]}),c.report&&(0,K.jsxs)(`div`,{className:`border-b border-border/60 px-3 py-2`,children:[(0,K.jsx)(`div`,{className:`mb-0.5 text-[11px] text-muted-foreground`,children:n(`Result`)}),(0,K.jsx)(D3,{text:c.report})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(IH(e.key)),className:`flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 transition-transform`,c.steps&&`rotate-90`)}),(0,K.jsx)(`span`,{children:c.steps?n(`Hide process`):n(`Show process`)}),(0,K.jsxs)(`span`,{children:[`· `,n(`{{count}} tool calls`,{count:e.count})]})]})]})]})}function n7({children:e,className:t,follow:n}){let r=(0,U.useRef)(null),i=(0,U.useRef)(null),a=(0,U.useRef)(n),o=(0,U.useRef)(n),s=(0,U.useRef)(null),c=(0,U.useRef)(null),l=(0,U.useRef)(0);o.current=n;let u=(0,U.useCallback)(()=>{a.current=!1,s.current=null,cancelAnimationFrame(l.current)},[]),d=(0,U.useCallback)(()=>{!o.current||!a.current||(cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{let e=r.current;if(!e||!o.current||!a.current)return;let t=Math.max(0,e.scrollHeight-e.clientHeight);s.current=t,e.scrollTop=t}))},[]);return(0,U.useEffect)(()=>{n?(a.current=!0,d()):(s.current=null,cancelAnimationFrame(l.current))},[n,d]),(0,U.useEffect)(d),(0,U.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(d);return t.observe(e),()=>t.disconnect()},[d]),(0,U.useEffect)(()=>()=>cancelAnimationFrame(l.current),[]),(0,K.jsx)(`div`,{ref:r,onWheel:e=>{e.deltaY<0&&u()},onPointerDown:e=>{e.target===e.currentTarget&&u()},onTouchStart:e=>{c.current=e.touches[0]?.clientY??null},onTouchMove:e=>{let t=e.touches[0]?.clientY;t!==void 0&&c.current!==null&&t>c.current&&u(),c.current=t??null},onTouchEnd:()=>{c.current=null},onScroll:e=>{if(!o.current)return;let t=e.currentTarget;if(t.scrollHeight-t.scrollTop-t.clientHeight<=2){a.current=!0,s.current=null;return}let n=s.current;if(n!==null&&t.scrollTop>=n-2){s.current=null,d();return}u()},className:G(`max-h-96 overflow-auto [overflow-anchor:none]`,t),children:(0,K.jsx)(`div`,{ref:i,children:e})})}function zre(e){if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Bre({source:e,output:t,view:n}){let r=n?.status===`completed`?zre(n.value):n?.error??t;return(0,K.jsxs)(`div`,{className:`space-y-1 px-3 py-1`,children:[e?(0,K.jsx)(y0,{code:e,language:`javascript`}):null,n&&n.calls.length>0?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...new Map(n.calls.map(e=>[e.name,e])).keys()].map(e=>{let t=n.calls.filter(t=>t.name===e),r=t.find(e=>!e.ok),i=`${e} ×${t.length}`;return(0,K.jsx)(`span`,{className:G(`rounded-md border px-1.5 py-0.5 font-mono text-[10px]`,r?`border-destructive/40 text-destructive`:`text-muted-foreground`),title:t.map(e=>e.summary).filter(Boolean).join(`
273
273
  `),children:r?`${i} · ${r.error??`error`}`:i},e)})}):null,r?n?.status===`completed`&&typeof n.value!=`string`?(0,K.jsx)(y0,{code:r,language:`json`}):(0,K.jsx)(`pre`,{className:`font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:c6(r)}):null,n?.console?(0,K.jsx)(`pre`,{className:`border-l-2 pl-2 font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:c6(n.console)}):null]})}function r7({path:e,fallback:t}){let[n,r]=(0,U.useState)(!1);return n?t:(0,K.jsx)(`div`,{"data-slot":`read-image`,className:`w-full min-w-0 px-3 py-3`,children:(0,K.jsx)(WG,{src:f(e),onError:()=>r(!0),frameClassName:`block w-full`,className:`mx-auto block max-h-80 max-w-full rounded-md bg-muted/40 object-contain`})})}function Vre({item:e}){let{t}=q(),n=LN(),r=E(e=>e.compactReadOnlyTools),i=E(e=>e.expandLiveEdits),a=r&&e.name!==`bash`&&MH(e),o=!!(e.edits&&e.edits.length>0),s=!!e.writeContent,c=!!(e.fileChanges&&e.fileChanges.length>0),l=e.sandbox??null,u=e.state===`error`?null:e.sentMessage,d=!!e.imagePath&&e.state!==`error`,f=Ms[e.name],p=Oz(e.name),m=e.state!==`error`&&e.todos?.length===0,h=m?t(`Todo list cleared`):e.subagentOp?[t(Ps[e.subagentOp]),e.summary].filter(Boolean).join(` · `):e.summary,g=e.nestedPending&&e.state===`running`?`${h} · ${e.nestedPending} pending`:l?.calls.length&&e.state!==`error`?CV(l.calls):h,_=!m&&!!(e.output||e.source||u||e.ask),v=e.state===`running`&&e.waiting===`subagent`&&!n,y=o||s||c||_||v||d,b=i&&(o||s||d)&&e.state===`running`,[x,S]=(0,U.useState)(b),[C,w]=(0,U.useState)(!1),T=(0,U.useRef)(null),D=Hne();(0,U.useEffect)(()=>{if(!C)return;let t=T.current;if(!t)return;let n=e.key,r=D.report,i=new IntersectionObserver(([e])=>r(n,e?.isIntersecting===!0),{root:D.scroller.current});return i.observe(t),()=>{i.disconnect(),r(n,!1)}},[C,e.key,D]);let O=x&&e.name===`memory_search`?qz(e.output):null,k=x&&e.name===`memory_capture`?Jz(e.output,e.memoryContent):null,A=x&&e.name===`subagent`&&e.state!==`error`?a5(e.subagentOp,e.output):null,j=e.name===`subagent`&&e.state===`error`?s5(e.output):null,M=(0,U.useRef)(c);return(0,U.useEffect)(()=>{let t=iV(e,M.current);M.current=c,(b||i&&t)&&S(!0)},[b,i,c,e]),e.todos&&e.todos.length>0?(0,K.jsx)(Wre,{todos:e.todos}):e.name.startsWith(`goal_`)?(0,K.jsx)(Hre,{item:e}):e.plan&&e.state!==`error`?(0,K.jsx)(Ure,{plan:e.plan}):(0,K.jsxs)(`div`,{ref:T,"data-enso":`tool-row`,"data-tool-style":a?`compact`:`full`,"data-user-open":C?`true`:void 0,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,disabled:!y,onClick:()=>{let t=!x;S(t),w(t),D.report(e.key,t)},className:G(`group/step flex min-h-6 min-w-0 flex-1 items-center gap-2 text-left text-[13px]`,H5,y&&`cursor-pointer`),children:[(0,K.jsx)(X8,{state:e.state}),(0,K.jsx)(`span`,{className:G(`shrink-0 text-muted-foreground transition-colors group-hover/step:text-foreground`,e.state===`running`&&G(U5,`text-foreground`)),children:f?t(f):p?.tool??e.name}),(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1 truncate font-mono text-[12px]`,e.state===`error`?`text-destructive`:`text-muted-foreground`,e.state===`running`&&U5),children:e.state===`error`&&e.output?h&&e.name===`apply_patch`&&c?`${g} · ${Zre(e.output)}`:j?t(j):UW(c6(e.output)):h?g:null}),e.backgroundTaskId&&(0,K.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-foreground`,title:e.backgroundTaskId,children:t(`Moved to background`)}),e.shellFailure&&e.state!==`running`&&(0,K.jsx)(K8,{failure:e.shellFailure}),e.dcgWarning&&(0,K.jsx)(q8,{warning:e.dcgWarning}),e.state===`reviewing`?(0,K.jsx)(`span`,{className:G(`shrink-0 text-[11px] text-foreground`,U5),children:t(`Assistant reviewing…`)}):e.state===`running`&&e.startedAt!==null?(0,K.jsxs)(K.Fragment,{children:[e.callId&&(e.name===`bash`||e.name===`powershell`)&&(0,K.jsx)(Xre,{callId:e.callId,startedAt:e.startedAt,output:e.output??``}),(0,K.jsx)(a7,{itemKey:e.key,since:e.startedAt??void 0})]}):(e.agentMeta||e.durationMs!==null)&&(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:[e.agentMeta?.modelId,e.agentMeta?.outputTokens?`${e.agentMeta.outputTokens} tok`:null,e.durationMs===null?null:ON(e.durationMs)].filter(Boolean).join(` · `)}),y&&(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 text-muted-foreground opacity-0 transition-[opacity,transform] group-hover/step:opacity-100`,x&&`rotate-90 opacity-100`)})]}),e.state===`running`&&e.callId&&!n&&(0,K.jsx)(Gre,{callId:e.callId,waiting:!!e.waiting}),(o||s||c)&&(e.state===`ok`||c)&&(0,K.jsx)(`button`,{type:`button`,title:t(`Open in side panel`),className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,onClick:()=>u0(),children:(0,K.jsx)(Yt,{className:`h-3 w-3`})})]}),e.generatedImages?.length?(0,K.jsx)(`div`,{"data-slot":`generated-images`,className:`mt-2 mb-3 ml-5 grid gap-3`,children:e.generatedImages.map(e=>(0,K.jsx)(r7,{path:e,fallback:(0,K.jsx)(`p`,{className:`break-all px-3 py-2 text-xs text-muted-foreground`,children:e})},e))}):null,x&&y&&(0,K.jsxs)(`div`,{"data-slot":`tool-details`,className:`t-acc-reveal mt-1 mb-1.5 ml-5 overflow-hidden rounded-lg border border-border/70 bg-card shadow-xs`,children:[p&&(0,K.jsxs)(`div`,{className:`truncate border-b border-border/60 px-3 py-1 font-mono text-[10px] text-muted-foreground`,children:[p.server,`.`,p.tool]}),v&&(0,K.jsx)(Yre,{agentIds:e.subagentTitles?Object.keys(e.subagentTitles):void 0}),o&&e.edits&&(0,K.jsx)(n7,{follow:e.state===`running`,children:(0,K.jsx)(U.Suspense,{fallback:null,children:(0,K.jsx)(D5,{path:e.summary,blocks:e.edits})})}),c&&e.fileChanges&&(0,K.jsx)(n7,{follow:e.state===`running`,children:e.fileChanges.map((e,n)=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:G(`flex items-center gap-2 border-border/60 px-3 py-1 font-mono text-[10px] text-muted-foreground`,(n>0||o)&&`border-t`),children:[(0,K.jsx)(`span`,{className:`uppercase`,children:e.type}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.path,children:e.path}),e.truncated&&(0,K.jsx)(`span`,{children:t(`Truncated preview`)})]}),(0,K.jsx)(U.Suspense,{fallback:null,children:(0,K.jsx)(D5,{path:e.path,blocks:[e],snapshot:e})})]},`${e.type}:${a6(e.path,e.oldText,e.newText)}`))}),oV(e)&&(0,K.jsx)(n7,{follow:!1,className:`border-t border-border/60`,children:(0,K.jsx)(`pre`,{className:`px-3 py-2 font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:c6(e.output??``)})}),s&&e.writeContent&&(0,K.jsx)(n7,{follow:e.state===`running`,className:G((o||c)&&`border-t border-border/60`),children:(0,K.jsx)(U.Suspense,{fallback:null,children:(0,K.jsx)(O5,{path:e.summary,contents:e.writeContent})})}),!o&&!s&&!c&&(_||d)&&(0,K.jsxs)(n7,{follow:e.state===`running`,children:[wV(e.name)?(0,K.jsx)(Bre,{source:e.source,output:e.output,view:l}):e.name===`bash`||e.name===`powershell`?(0,K.jsx)(u5,{command:e.summary,output:e.output??``,failure:e.shellFailure}):e.name===`read`&&d&&e.imagePath?(0,K.jsx)(r7,{path:e.imagePath,fallback:(0,K.jsx)(U.Suspense,{fallback:null,children:(0,K.jsx)(O5,{path:e.summary,contents:e.output??``})})},e.imagePath):e.name===`image_view`&&e.state===`ok`?(0,K.jsx)(_5,{image:e.image,output:e.output}):e.name===`read`?(0,K.jsx)(U.Suspense,{fallback:null,children:(0,K.jsx)(O5,{path:e.summary,contents:e.output??``})}):e.name===`subagent`&&e.state!==`error`&&!u&&!A?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm`,children:(0,K.jsx)(D3,{text:e.output??``})}):O?(0,K.jsx)(r8,{hits:O}):k?(0,K.jsx)(i8,{view:k}):(0,K.jsxs)(K.Fragment,{children:[e.ask&&(0,K.jsx)(F6,{ask:e.ask,waiting:e.state===`running`}),u&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm`,children:(0,K.jsx)(D3,{text:u})}),A?(0,K.jsx)(Q8,{view:A,titles:e.subagentTitles}):e.output&&(0,K.jsx)(`pre`,{className:`px-3 py-2 font-mono text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:c6(e.output)})]}),(0,K.jsx)(N8,{value:e.rtk}),(0,K.jsx)(P6,{value:e.approvalReview})]})]})]})}function Hre({item:e}){let{t}=q(),n=e.name.replace(`goal_`,``),r=t(n===`complete`?`Goal completed`:n===`blocked`?`Goal blocked`:`Goal waiting`);return(0,K.jsxs)(`div`,{className:G(`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm`,n===`complete`&&`border-green-500/50 bg-green-500/5`,n===`blocked`&&`border-destructive/50 bg-destructive/5`,n===`wait`&&`border-amber-500/50 bg-amber-500/5`),children:[(0,K.jsx)(Xn,{className:G(`mt-0.5 h-4 w-4 shrink-0`,n===`complete`&&`text-green-600 dark:text-green-500`,n===`blocked`&&`text-destructive`,n===`wait`&&`text-amber-500`)}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`font-medium`,children:r}),e.summary&&(0,K.jsx)(`p`,{className:`mt-0.5 whitespace-pre-wrap text-muted-foreground text-xs`,children:e.summary})]})]})}function Ure({plan:e}){let{t}=q(),[n,r]=(0,U.useState)(!1);return(0,K.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-muted/30 px-3 py-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full min-w-0 items-center gap-2 text-left text-xs`,children:[(0,K.jsx)(At,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium text-muted-foreground`,children:t(`Plan`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,K.jsx)(vt,{className:G(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,n&&`rotate-90`)})]}),n&&(0,K.jsx)(`div`,{className:`mt-2 border-border/60 border-t pt-2 text-sm`,children:(0,K.jsx)(D3,{text:e.text})})]})}function Wre({todos:e}){let{t}=q(),n=e.filter(e=>e.status===`completed`).length;return(0,K.jsxs)(`div`,{"data-enso":`todo`,className:`rounded-lg border bg-card px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(an,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:t(`Todos`)}),(0,K.jsxs)(`span`,{className:`ml-auto tabular-nums`,children:[n,`/`,e.length]})]}),(0,K.jsx)(p5,{done:n,total:e.length,className:`mt-1.5 mb-2`}),(0,K.jsx)(f5,{todos:e})]})}var i7=new Map;function Gre({callId:e,waiting:t}){let{t:n}=q(),r=nP(e=>K5(e)?.id??``),[i,a]=(0,U.useState)(!1);if((0,U.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>a(!1),5e3);return()=>clearTimeout(e)},[i]),!r)return null;let o=n(t?i?`Stopping wait…`:`Stop waiting`:i?`Moving to background…`:`Move to background`);return(0,K.jsxs)(`button`,{type:`button`,disabled:i,title:o,className:`flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-60`,onClick:()=>{a(!0),window.electronAPI.agent.backgroundTool(r,e).then(e=>{e.ok||a(!1)},()=>a(!1))},children:[(0,K.jsx)(t?zn:at,{className:`h-3 w-3`}),o]})}var Kre=5e3,qre=[];function Jre(e,t){if(e.status===`queued`)return t(`Queued`);let n=e.activity;return n?.phase===`tool`?[n.tool,n.detail].filter(Boolean).join(` `):n?.phase===`writing`?t(`Writing reply…`):t(`Thinking…`)}function Yre({agentIds:e}){let{t}=q(),n=nP(e=>K5(e)?.id??``),r=b6(e=>e.byConversation[n]??qre),[i,a]=(0,U.useState)(!1);if((0,U.useEffect)(()=>{if(!n)return;let e=!0,t=t=>{e&&(b6.getState().replace(n,t),a(!0))},r=()=>window.electronAPI.agent.subagentProgress(n).then(t,()=>{}),i=window.electronAPI.agent.onSubagentProgress(e=>{e.sessionId===n&&t(e.runs)});r();let o=setInterval(r,Kre);return()=>{e=!1,clearInterval(o),i()}},[n]),!i)return null;let o=e?.length?r.filter(t=>e.includes(t.agentId)):r;return(0,K.jsxs)(`div`,{className:`border-b border-border/60 px-3 py-2 text-xs`,children:[o.length===0?(0,K.jsx)(`div`,{className:`text-muted-foreground`,children:t(`No running subagents`)}):o.map(e=>(0,K.jsxs)(`div`,{className:`py-0.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate font-medium`,children:e.title??e.agentId.slice(0,8)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:Jre(e,t)}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:ON(e.elapsedMs)})]}),e.text&&(0,K.jsx)(`div`,{className:`line-clamp-2 break-words pl-2 text-[11px] text-muted-foreground/80`,children:e.text.replace(/\s+/g,` `)})]},e.runId)),(0,K.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground/80`,children:t(`Stopping the wait does not stop subagents; the assistant is notified when they finish.`)})]})}function a7({itemKey:e,since:t}){let n=LN(),r=nP(e=>K5(e)?.id??``),i=n?n.sessionId??``:r,a=(0,U.useRef)(null);if(a.current===null){let n=`${i}:${e}`;a.current=t??i7.get(n)??Date.now(),t===void 0&&i7.set(n,a.current)}let o=t??a.current,[,s]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>s(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:ON(Date.now()-o)})}function Xre({callId:e,startedAt:t,output:n}){let r=LN(),i=nP(t=>r?void 0:K5(t)?.toolDeadlineAt?.[e]);return(0,K.jsx)(W8,{startedAt:t,deadlineAt:i,output:n})}function o7(e){return e.kind===`tool-group`||e.kind===`tool`&&!e.todos?.length&&!e.name.startsWith(`goal_`)}var Zre=e=>c6(e.split(`
274
- `,1)[0]??``);function Qre(e,t,n,r,i=100){if(r||!n)return{hiddenSince:t,delayMs:null};let a=t??e;return{hiddenSince:a,delayMs:Math.max(0,i-(e-a))}}var $re=1e6;function eie(e,t,n=$re){if(t.length===0)return{anchor:null,firstItemIndex:n,remount:!1};if(!e)return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!1};let r=new Map(t.map((e,t)=>[e,t]));for(let n=0;n<e.keys.length;n++){let i=r.get(e.keys[n]);if(i===void 0)continue;let a=e.index+n-i;return{anchor:{keys:t,index:a},firstItemIndex:a,remount:!1}}return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!0}}function s7(e,t){return t}var tie=new Set([`text`,`thinking`,`tool`,`tool-group`]);function nie(e,t,n,r){let i=(0,U.useRef)(HH),[a,o]=(0,U.useState)(()=>Date.now()),s=r.compact,c=r.autoCollapseCompletedTurns,l=r.collapseCompletedActivity===!0,u=r.collapseLiveActivity===!0,d={compact:s,autoCollapseCompletedTurns:c,turnOverrides:r.turnOverrides},f=u?qH(e,t,r,i.current,a):null;i.current=f?.witness??HH;let p=f?.wakeAt??null,m=iU(e,t,n,{...d,collapseCompletedActivity:l,collapseLiveActivity:u,releasedLiveActivity:f?.released,heldOpenTools:r.heldOpenTools,foldToolOnlyTurns:r.foldToolOnlyTurns===!0,readableToolCards:r.readableToolCards===!0});return(0,U.useEffect)(()=>{if(p===null||p<=a)return;let e=window.setTimeout(()=>o(p),p-a);return()=>window.clearTimeout(e)},[p,a]),m}var rie=[{icon:Nt,title:`Map the project`,hint:`Entry points, modules and key dependencies`,prompt:`Walk me through this project's structure: entry points, module layout and key dependencies.`},{icon:mt,title:`Find potential issues`,hint:`Suspicious logic and unhandled edge cases`,prompt:`Review this project for potential bugs, suspicious logic and unhandled edge cases, and list them by severity.`},{icon:Ut,title:`Add unit tests`,hint:`Cover the core modules with tests`,prompt:`Find the core modules that lack tests and add unit tests for them.`},{icon:jn,title:`Summarize recent changes`,hint:`A digest based on git log`,prompt:`Summarize the recent changes in this repository based on git log.`}],iie=[{icon:Yn,title:`Check today's progress`,hint:`Progress report and items waiting on you`,prompt:`Summarize today's progress and list anything waiting on me.`},{icon:Fn,title:`Assign a task`,hint:`A one-off job for the secretary to run`,prompt:`Take care of a one-off task: `},{icon:At,title:`Organize the to-do list`,hint:`Sort the board into clear next steps`,prompt:`Go through the board and organize it into clear next steps.`},{icon:Jt,title:`Clean up merged branches`,hint:`Remove branches that are already merged`,prompt:`Clean up merged branches and worktrees you no longer need.`}];function aie({onPick:e,variant:t=`project`}){let{t:n}=q();return(0,K.jsx)(`div`,{className:`mx-auto grid w-full max-w-[560px] grid-cols-1 gap-2.5 text-left @min-[36rem]:grid-cols-2`,children:(t===`secretary`?iie:rie).map(({icon:t,title:r,hint:i,prompt:a})=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>e(n(a)),"data-slot":`welcome-suggestion`,className:`group flex items-start gap-3 rounded-xl border bg-card px-3.5 py-3 text-left shadow-xs transition-[border-color,box-shadow,transform] duration-200 hover:-translate-y-px hover:border-brand/25 hover:shadow-float`,children:[(0,K.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(t,{className:`size-3.5`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block text-[13px] font-medium`,children:n(r)}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:n(i)})]})]},r))})}var c7=`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,l7=1e3;function u7({className:e,children:t}){let[n,r]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{let e=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(e)},[]),(0,K.jsx)(`div`,{className:G(`t-stagger`,n&&`is-shown`,e),children:t})}var d7=40,oie={index:`LAST`,align:`end`},sie={top:600,bottom:600},cie=e=>e&&!nz()?`auto`:!1,lie={owners:new Map,ends:new Map};function uie(e){let t=new Map,n=new Map,r=null,i=null,a=()=>{r&&i&&n.set(i,r)};for(let n of e)n.kind===`user`?(a(),r=!n.collapsed&&n.canCollapse===!0?n.key:null,i=null,r&&t.set(n.key,r)):r&&(t.set(n.key,r),i=n.key);return a(),{owners:t,ends:n}}var die=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`;function fie({style:e,...t}){let n=e?.visibility===`hidden`,[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let e=Qre(Date.now(),a.current,n,r);if(a.current=e.hiddenSince,e.delayMs===null)return;let t=window.setTimeout(()=>i(!0),e.delayMs);return()=>window.clearTimeout(t)},[n,r]),(0,K.jsx)(`div`,{...t,style:n&&r?{...e,visibility:`visible`}:e})}function pie({ref:e,items:t,busy:n,loading:r=!1,running:i,runStartedAt:a,lastOutputAt:o,error:s,emptyTitle:c,emptyDescription:l,onSuggestion:u,emptyVariant:d,onRetryResume:f,onRetrySync:p,virtualize:m=!0,onStartReached:h,historyLoading:g=!1,hasOlder:_,olderCursor:v,searchQuery:y=``,activeHit:b=null,secretarySession:x=!1,secretaryFace:S,conversationId:C,quotable:w=!1}){let{t:T}=q(),D=LN(),O=ez(C),k=x?S??O:null,A=!D&&k?k:null,j=x,M=(0,U.useRef)(null),[N,P]=(0,U.useState)(!0),[F,I]=(0,U.useState)(!1),L=(0,U.useRef)(!0),R=(0,U.useRef)(null),ee=(0,U.useRef)(null),z=(0,U.useRef)(0),B=(0,U.useRef)(0),V=(0,U.useRef)(null),te=(0,U.useRef)(!1),H=(0,U.useRef)(!1),ne=(0,U.useRef)(0),re=(0,U.useRef)(!1),[ie,ae]=(0,U.useState)(null),oe=(0,U.useRef)(0),se=(0,U.useCallback)(e=>{cancelAnimationFrame(oe.current),oe.current=requestAnimationFrame(()=>ae(e()))},[]);(0,U.useEffect)(()=>()=>cancelAnimationFrame(oe.current),[]);let[ce,le]=(0,U.useState)(new Set),ue=(0,U.useRef)(new Set),[de,fe]=(0,U.useState)(()=>new Set),pe=(0,U.useCallback)((e,t)=>{let n=ue.current;t!==n.has(e)&&(t?n.add(e):n.delete(e),fe(new Set(n)))},[]),me=(0,U.useRef)({report:pe,scroller:R});me.current.report=pe;let he=(0,U.useCallback)(e=>{le(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[ge,_e]=(0,U.useState)(new Map),ve=E(e=>e.autoCollapseTurns),ye=E(e=>e.collapseCompletedActivity),be=E(e=>e.collapseLiveActivity),xe=E(e=>e.liveActivityFoldDelaySec),Se=E(e=>e.compactReadOnlyTools),Ce=nie(t,i,ce,{compact:Se,autoCollapseCompletedTurns:ve,collapseCompletedActivity:ye,collapseLiveActivity:be,liveActivityFoldDelaySec:xe,heldOpenTools:de,turnOverrides:ge,foldToolOnlyTurns:!D&&j,readableToolCards:j}),we=(0,U.useRef)({state:aU,collapse:new Map,reveal:new Map}),Te=(0,U.useMemo)(()=>{let e=we.current,t=e=>R.current?.querySelector(`[data-nav-key="${CSS.escape(e)}"]`),n=oU(e.state,Ce,(e,n)=>{let r=t(e)?.getBoundingClientRect().top,i=t(n)?.getBoundingClientRect().bottom;return r===void 0||i===void 0?0:i-r}),r=Date.now();e.state=n.next;for(let{key:t,...i}of n.collapses)e.collapse.set(t,{at:r,...i});for(let t of n.expands)e.reveal.set(t,r);return n.children},[Ce]),Ee=(0,U.useRef)(null),De=(0,U.useRef)(0),Oe=(0,U.useRef)(null),ke=eie(Ee.current,Ce.map(e=>e.key));Ee.current=ke.anchor,ke.remount&&(De.current+=1,Oe.current=null);let Ae=ke.firstItemIndex,je=(0,U.useCallback)((e,t)=>{_e(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),Me=(0,U.useMemo)(()=>ve?uie(Ce):lie,[ve,Ce]),Ne=(0,U.useRef)(null),Pe=(0,U.useMemo)(()=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.kind!==`user`)continue;let i=``;for(let e=n+1;e<t.length;e++){let n=t[e];if(n.kind===`user`)break;if(n.kind===`text`){i=n.text;break}}e.push({key:r.key,question:pk(r.text)||`[image]`,answer:i})}return e},[t]),Fe=(0,U.useCallback)(()=>{let e=R.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight>2&&(te.current=!0,e.scrollTop=e.scrollHeight)},[]),Ie=(0,U.useCallback)(()=>{cancelAnimationFrame(z.current);let e=Date.now()+1200,t=null,n=()=>{cancelAnimationFrame(z.current),te.current=!1,t?.removeEventListener(`touchstart`,n),t?.removeEventListener(`wheel`,n)},r=()=>{if(H.current){n();return}!t&&R.current&&(t=R.current,t.addEventListener(`touchstart`,n,{passive:!0,once:!0}),t.addEventListener(`wheel`,n,{passive:!0,once:!0})),Fe(),L.current=!0,P(!0),Date.now()<e?z.current=requestAnimationFrame(r):n()};r(),P(!0),L.current=!0},[Fe]);(0,U.useEffect)(()=>()=>{cancelAnimationFrame(z.current),cancelAnimationFrame(B.current),window.clearTimeout(ne.current)},[]),(0,U.useEffect)(()=>tz.subscribe(({active:e},t)=>{if(e===t.active)return;if(e){cancelAnimationFrame(z.current),cancelAnimationFrame(B.current),te.current=!1;return}let n=re.current;re.current=!1,n&&L.current&&!H.current&&Fe()}),[Fe]);let Le=()=>{H.current=!0,window.clearTimeout(ne.current)},Re=()=>{window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{H.current=!1},400)},ze=()=>{Le(),Re()},Be=()=>[...R.current?.querySelectorAll(`[data-nav-key]`)??[]],Ve=e=>{ze(),Ne.current=e,je(e,!0)},He=e=>{if(e.key!==`Escape`||e.defaultPrevented||Me.owners.size===0)return;let t=R.current,n=e.target;if(!t?.contains(n)||n.closest?.(die)||EE()||document.querySelector(`[role="dialog"], [role="alertdialog"]`))return;let r=t.getBoundingClientRect();for(let t of Be()){let n=Me.owners.get(t.getAttribute(`data-nav-key`)??``);if(!n)continue;let i=t.getBoundingClientRect();if(i.bottom<=r.top||i.top>=r.bottom)continue;let a=e.nativeEvent;window.addEventListener(`keydown`,e=>{e!==a||e.defaultPrevented||(e.preventDefault(),Ve(n))},{once:!0});return}},Ue=()=>{cancelAnimationFrame(z.current),cancelAnimationFrame(B.current),te.current=!1,L.current=!1,P(!1)},We=(0,U.useCallback)(e=>{if(V.current?.disconnect(),V.current=null,!e)return;let t=new ResizeObserver(()=>{if(!L.current&&!te.current)return;cancelAnimationFrame(B.current);let e=8,t=()=>{Fe();let n=R.current;(n?n.scrollHeight-n.scrollTop-n.clientHeight:0)<=2||(--e>0?B.current=requestAnimationFrame(t):Ie())};t()});t.observe(e),V.current=t,Ie()},[Fe,Ie]);(0,U.useEffect)(()=>()=>V.current?.disconnect(),[]);let Ge=e=>Ce.findIndex(t=>t.key===e||t.kind===`tool-group`&&f7(t,e)),Ke=e=>{if(!m){R.current?.querySelector(`[data-nav-key="${CSS.escape(e)}"]`)?.scrollIntoView({block:`center`});return}let t=Ge(e);t>=0&&M.current?.scrollToIndex({index:s7(Ae,t),align:`center`})},qe=(0,U.useRef)(null),Je=e=>{if(Ue(),Ge(e)>=0){qe.current=null,Ke(e);return}let n=null,r=!1;for(let i of t)if(i.kind===`user`&&(n=i.key),i.key===e){r=!0;break}!r||!n||(qe.current=e,je(n,!1))};(0,U.useLayoutEffect)(()=>{let e=qe.current;!e||Ge(e)<0||(qe.current=null,Ke(e))},[Ce]),(0,U.useLayoutEffect)(()=>{let e=Ne.current;if(!e)return;Ne.current=null;let t=Be().find(t=>t.getAttribute(`data-nav-key`)===e);if(t){t7(t,R.current);return}let n=Ce.findIndex(t=>t.key===e);m&&n>=0&&M.current?.scrollToIndex({index:s7(Ae,n),align:`start`})},[Ce]),(0,U.useImperativeHandle)(e,()=>({scrollToBottom:Ie,pinToBottom:Fe,isAtBottom:()=>L.current,getScroller:()=>m?null:R.current,scrollToKey:Je}));let Ye=(0,U.useRef)(!1),Xe=`${v}:${Ae}`,Ze=(0,U.useRef)(Xe);Ze.current!==Xe&&(Ze.current=Xe,Ye.current=!1);let Qe=()=>{!h||Ye.current||(Ye.current=!0,h())};(0,U.useEffect)(()=>{m&&!g&&Oe.current===Ae&&Qe()},[v,g]);let $e=(0,U.useMemo)(()=>({query:y,activeKey:b?.key??``,activeNth:b?.nth??-1}),[y,b?.key,b?.nth]),et=(e,t)=>{let n=Ce[t+1];if(n!==void 0&&o7(e)&&o7(n))return`pb-0`;if(!Se)return`pb-4`;let r=n!==void 0&&V5(n);return V5(e)?r?`pb-1`:`pb-2`:e.kind===`text`&&r?`pb-1`:`pb-4`},tt=(e,t)=>{let n=Ce[t-1],r=n?.kind===`user`&&!n.collapsed&&tie.has(e.kind)?n:void 0,i=Date.now(),a=we.current.collapse.get(e.key),o=a&&i-a.at<l7?a:void 0,s=Te.get(e.key),c=s&&we.current.reveal.get(s.group),l=s&&c!==void 0&&i-c<l7,u=Me.ends.get(e.key);return(0,K.jsxs)(`div`,{"data-nav-key":e.key,"data-fold-collapse":o?o.pair?`pair`:`toggle`:void 0,style:o?{"--fold-from":`${o.height}px`}:l?{"--fold-i":s.index}:void 0,className:G(c7,et(e,t),l&&`t-fold-reveal`,`[overflow-wrap:anywhere]`),children:[r&&(0,K.jsx)(fre,{model:r.replyModel,at:r.replyAt,privacyMask:r.replyPrivacyMask,secretarySession:j,face:k,conversationId:C}),(0,K.jsx)(yie,{itemKey:e.key,children:(0,K.jsx)(pre,{item:e,secretarySession:j,onToggleGroup:he,onToggleTurn:je})}),u&&(0,K.jsx)(kre,{turnKey:u,canCollapse:!0,collapsed:!1,onToggleTurn:Ve})]},e.key)},nt=(0,U.useRef)(!1);_===!0&&(nt.current=!0);let W=yV(t.length>0,g,_,nt.current,!m&&F);(0,U.useLayoutEffect)(()=>{if(m){I(!1);return}let e=R.current;I(!!e&&bV(_===!0,g,e.scrollHeight,e.clientHeight))},[m,_,g,Ae,Ce.length,t.length]);let rt={pageChrome:W,onLoadMore:W===`more`?Qe:void 0,busy:n,loading:!!r,since:sU({loading:!!r,runStartedAt:a,lastOutputAt:o}),error:s,onRetryResume:f};return(0,K.jsx)(cU.Provider,{value:$e,children:(0,K.jsx)(Vne,{value:me.current,children:(0,K.jsxs)(`div`,{ref:ee,"data-enso":`timeline`,className:`@container relative min-h-24 flex-1`,onWheel:ze,onKeyDown:e=>{ze(),He(e)},onTouchStart:e=>{R.current?.contains(e.target)&&Le()},onTouchEnd:Re,onPointerDown:e=>{e.target===R.current&&(Le(),window.addEventListener(`pointerup`,Re,{once:!0}))},children:[(0,K.jsx)(vU,{items:Pe,activeKey:ie,onJump:Je}),w&&(0,K.jsx)(xU,{containerRef:ee}),t.length===0&&!n?(0,K.jsxs)(u7,{className:`flex h-full flex-col items-center justify-center gap-2 overflow-y-auto px-4 text-center`,children:[(0,K.jsx)(`span`,{className:`t-stagger-line t-stagger-line--1 mb-3`,children:A?(0,K.jsx)(iR,{name:A.name,color:A.color,image:A.image,needsYou:0,running:0,size:`lg`,enso:`secretary-chat-avatar`}):(0,K.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(RN,{className:`size-6`})})}),(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--1 text-[22px] font-semibold tracking-tight`,children:c}),s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 max-w-md text-sm text-destructive whitespace-pre-wrap`,children:T(s)}),f&&(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:f,children:T(`Retry resume`)})]}):(0,K.jsxs)(K.Fragment,{children:[p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 max-w-md text-sm text-muted-foreground`,children:T(`Session is not ready yet — no history to show.`)}),(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:p,children:T(`Retry sync`)})]}):l===``?null:(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 text-sm text-muted-foreground`,children:l??T(d===`secretary`?`Tell the secretary what to take care of…`:`Ask the agent…`)}),u&&(0,K.jsx)(`div`,{className:`t-stagger-line t-stagger-line--3 mt-5 w-full`,children:(0,K.jsx)(aie,{onPick:u,variant:d})})]})]}):t.length===0&&s?(0,K.jsxs)(u7,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--1 max-w-md text-sm text-destructive whitespace-pre-wrap`,children:T(s)}),f&&(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:f,children:T(`Retry resume`)})]}):t.length===0?(0,K.jsxs)(`div`,{"data-timeline-loading":``,className:`flex h-full flex-col items-center justify-center gap-2.5 text-center`,children:[(0,K.jsx)(sn,{className:`h-5 w-5 animate-spin text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:T(`Preparing session…`)})]}):m?(0,K.jsx)(oL,{ref:M,data:Ce,defaultItemHeight:80,computeItemKey:(e,t)=>t.key,firstItemIndex:Ae,startReached:Qe,followOutput:cie,atBottomThreshold:d7,atBottomStateChange:e=>{if(!e&&L.current&&!H.current){if(nz()){re.current=!0;return}Ie();return}P(e),L.current=e},increaseViewportBy:sie,initialTopMostItemIndex:oie,rangeChanged:({startIndex:e})=>{Oe.current=e,e>Ae+4&&(Ye.current=!1),se(()=>{let t=Math.max(0,e-Ae),n=null;for(let e=0;e<=Math.min(t+1,Ce.length-1);e++)Ce[e]?.kind===`user`&&(n=Ce[e].key);return n})},scrollerRef:e=>{R.current=e instanceof HTMLElement?e:null},className:`h-full select-text`,context:rt,components:hie,itemContent:(e,t)=>tt(t,e-Ae)},De.current):(0,K.jsx)(`div`,{ref:e=>{R.current=e},onScroll:e=>{let t=e.currentTarget;if(te.current){te.current=!1,L.current=!0,P(!0);return}if(!H.current){L.current&&Fe();return}let n=t.scrollHeight-t.scrollTop-t.clientHeight<=d7;n!==L.current&&(L.current=n,P(n)),h&&(t.scrollTop<80&&!Ye.current?(Ye.current=!0,h()):t.scrollTop>240&&(Ye.current=!1))},className:`h-full select-text overflow-y-auto [overflow-anchor:none]`,children:(0,K.jsxs)(`div`,{ref:We,children:[(0,K.jsx)(p7,{context:rt}),Ce.map((e,t)=>tt(e,t)),(0,K.jsx)(m7,{context:rt})]})}),!N&&t.length>0&&(0,K.jsxs)(`button`,{type:`button`,onClick:Ie,className:`absolute bottom-4 left-1/2 z-10 inline-flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-full border bg-card px-3 text-xs text-muted-foreground shadow-float transition-colors hover:text-foreground`,children:[(0,K.jsx)(ot,{className:`h-3 w-3`}),T(`Scroll to bottom`)]})]})})})}function f7(e,t){return e.children.some(e=>e.key===t||e.kind===`tool-group`&&f7(e,t))}function mie({chrome:e,onLoadMore:t}){let{t:n}=q();return e===`none`?(0,K.jsx)(`div`,{className:`h-6`}):(0,K.jsx)(`div`,{className:G(c7,`flex items-center justify-center gap-2 py-3`),children:e===`loading`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(sn,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Loading earlier messages…`)})]}):e===`more`?(0,K.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline-offset-2 hover:underline`,onClick:t,children:n(`Load earlier messages`)}):(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Beginning of conversation`)})})}function p7({context:e}){return(0,K.jsx)(mie,{chrome:e.pageChrome,onLoadMore:e.onLoadMore})}function m7({context:e}){let{t}=q(),{busy:n,loading:r,since:i,error:a,onRetryResume:o}=e;return(0,K.jsxs)(`div`,{className:G(c7,`pb-6 [overflow-wrap:anywhere]`),children:[n&&(0,K.jsxs)(`div`,{className:`flex min-h-[26px] items-center gap-2 text-[13px]`,children:[(0,K.jsx)(gie,{}),(0,K.jsx)(`span`,{className:`animate-pulse text-foreground motion-reduce:animate-none`,children:t(r?`Loading…`:`Working…`)}),i!==void 0&&(0,K.jsx)(vie,{since:i})]}),a&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(`p`,{className:`min-w-0 flex-1 text-sm text-destructive whitespace-pre-wrap`,children:t(a)}),(0,K.jsx)(J5,{}),o&&(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:o,children:t(`Retry resume`)})]})]})}var hie={List:fie,Header:p7,Footer:m7};function gie(){return(0,K.jsxs)(`span`,{className:`relative flex size-[22px] shrink-0 items-center justify-center`,children:[(0,K.jsx)(`span`,{className:`absolute size-2 animate-ping rounded-full bg-brand/50`}),(0,K.jsx)(`span`,{className:`relative size-2 rounded-full bg-brand`})]})}var _ie=e=>{let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`},vie=(0,U.memo)(function({since:e}){let[,t]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:_ie(Date.now()-e)})}),yie=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(e){e.itemKey!==this.props.itemKey&&this.state.failed&&this.setState({failed:!1})}render(){return this.state.failed?(0,K.jsxs)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-1.5 text-xs text-destructive`,children:[`message render failed · `,this.props.itemKey]}):this.props.children}};function bie({retry:e,onCancel:t}){let{t:n}=q(),[r,i]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),500);return()=>clearInterval(e)},[]);let a=Math.max(0,Math.ceil((e.at+e.delayMs-r)/1e3));return(0,K.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(An,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-amber-500 [animation-duration:2s]`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.error,children:[e.maxAttempts>0?n(`Auto-retrying ({{attempt}}/{{max}})`,{attempt:e.attempt,max:e.maxAttempts}):n(`Auto-retrying ({{attempt}})`,{attempt:e.attempt}),(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a>0?n(`retrying in {{seconds}}s`,{seconds:a}):n(`retrying…`),` — `,e.error]})]}),t&&(0,K.jsx)(`button`,{type:`button`,title:n(`Cancel auto-retry`),onClick:t,className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]})}function h7(e){return e.status===`running`?e.idle?`idle`:e.keep?`kept`:`running`:e.status}function g7(e,t){let n=Math.max(0,Math.floor(e/6e4));if(n<60)return t(`{{n}} min`,{n});let r=Math.floor(n/60),i=n%60;return i===0?t(`{{n}} h`,{n:r}):t(`{{h}} h {{m}} min`,{h:r,m:i})}function xie(e){let t=Math.max(0,Math.floor(e/6e4));return t<60?`${t}m`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,`0`)}m`}function _7(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function v7(e=3e4){let[t,n]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var y7={ok:`bg-success/15 text-success`,pending:`bg-warning/15 text-warning`,neutral:`bg-muted text-muted-foreground`};function b7({tone:e,children:t,className:n}){return(0,K.jsx)(`span`,{className:G(`shrink-0 rounded px-1 py-px text-[10px]`,y7[e],n),children:t})}function x7(e,t,n){return n(`Idle {{duration}}`,{duration:g7(t-(e.idle?.since??t),n)})}function Sie({task:e,now:t}){let{t:n}=q(),r=h7(e);return r===`idle`?(0,K.jsx)(b7,{tone:`pending`,children:x7(e,t,n)}):r===`kept`?(0,K.jsx)(b7,{tone:`neutral`,children:n(`Kept`)}):r===`running`?(0,K.jsx)(b7,{tone:`ok`,children:n(`Running`)}):e.interrupted===`restart`?(0,K.jsx)(b7,{tone:`pending`,children:n(`Interrupted by restart`)}):null}function Cie({task:e}){return h7(e)===`idle`?(0,K.jsx)(`span`,{className:`relative flex size-[22px] shrink-0 items-center justify-center rounded-full border border-dashed border-warning/60 text-warning`,children:(0,K.jsx)(gn,{className:`size-3`})}):(0,K.jsx)(Y8,{icon:Kn,state:e.status===`running`?`running`:e.status===`failed`?`error`:`ok`})}function wie(e,t){let n=e.keep;if(!n)return;let r=n.reason??_7(n.at);return n.by===`user`?t(`Kept by you · {{detail}}`,{detail:r}):t(`Kept: {{reason}}`,{reason:r})}function Tie({task:e,className:t}){let{t:n}=q(),r=h7(e)===`kept`?wie(e,n):void 0;return r?(0,K.jsxs)(`div`,{className:G(`flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground/85`,t),children:[(0,K.jsx)(wn,{className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,title:r,children:r})]}):null}function S7(e,t){window.electronAPI.agent.stopTask(e,t)}function C7(e,t,n){window.electronAPI.agent.keepTask(e,t,n)}function Eie({onStop:e,className:t}){let{t:n}=q();return(0,K.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},title:n(`Stop task`),className:G(`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,t),children:n(`Stop`)})}function w7({sessionId:e,taskId:t}){let{t:n}=q();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oa,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,onClick:n=>{n.stopPropagation(),C7(e,t,``)},children:n(`Keep`)}),(0,K.jsx)(Oa,{size:`xs`,variant:`outline`,className:`hover:text-destructive`,onClick:n=>{n.stopPropagation(),S7(e,t)},children:n(`Stop`)})]})}var Die=[`pattern`,`query`,`path`,`file_path`],Oie=[`path`,`file_path`,`query`,`pattern`],kie=[`command`,`cmd`,`script`],Aie=[`path`,`file_path`,`pattern`,`query`,`command`,`url`,`description`,`summary`],jie=120;function T7(e){let t=e.replace(/\s+/g,` `).trim();return t.length>jie?`${t.slice(0,119)}…`:t}function Mie(e){let t=e.toLowerCase();return t.includes(`search`)||t.includes(`grep`)||t===`find`?Die:t===`read`||t.endsWith(`_read`)?Oie:t===`bash`||t.includes(`shell`)||t.includes(`terminal`)?kie:Aie}function Nie(e,t){let n=t.trim();if(!n)return``;let r;try{r=JSON.parse(n)}catch{return T7(n)}if(r===null)return``;if(typeof r!=`object`||Array.isArray(r))return T7(JSON.stringify(r)??String(r));let i=jz(e,r);if(i.summary!==void 0)return T7(i.summary);if(!i.args||typeof i.args!=`object`)return``;let a=i.args;for(let e of Mie(i.name)){let t=a[e];if(typeof t==`string`&&t.trim())return T7(t)}let o=JSON.stringify(a);return o===`{}`?``:T7(o)}function Pie(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=24}var E7=new Map,Fie=e=>{let t=E7.get(e);return t?new Set(t):new Set},D7=(e,t)=>(E7.set(e,t),t),O7=new Map,Iie=(e,t)=>{let n=O7.get(e)??new Set;O7.set(e,n);for(let e of t)n.add(e);return n},k7=`enso:task-bar-expanded`,A7=new Map,j7=()=>{try{let e=JSON.parse(window.sessionStorage.getItem(k7)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}},Lie=e=>A7.get(e)??j7().includes(e),Rie=(e,t)=>{A7.set(e,t);try{let n=j7().filter(t=>t!==e);window.sessionStorage.setItem(k7,JSON.stringify(t?[...n,e]:n))}catch{}return t};function zie({sessionId:e,tasks:t,subagents:n,readOnly:r}){let i=E(e=>e.virtualModels),{t:a}=q(),[o,s]=(0,U.useState)(()=>Fie(e)),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(()=>Lie(e)),f=nP(e=>e.pendingAgentOpen);(0,U.useEffect)(()=>{!f||f.sessionId!==e||(l(f.agentId),nP.setState({pendingAgentOpen:null}))},[f,e]);let p=Iie(e,[...t.filter(e=>e.status===`running`).map(e=>e.taskId),...n.filter(e=>e.status===`running`).map(e=>e.id)]),m=(e,t)=>!o.has(e)&&(t===`running`||p.has(e)),h=t.filter(e=>m(e.taskId,e.status)),g=n.filter(e=>m(e.id,e.status));if((0,U.useEffect)(()=>{let r=O7.get(e),i=[...t.filter(e=>e.status!==`running`).map(e=>e.taskId),...n.filter(e=>e.status!==`running`).map(e=>e.id)].filter(e=>r?.has(e)&&!o.has(e)&&e!==c);if(i.length===0)return;let a=setTimeout(()=>{s(t=>{let n=new Set(t);for(let e of i)n.add(e);return D7(e,n)})},5e3);return()=>clearTimeout(a)},[e,t,n,o,c]),h.length===0&&g.length===0)return null;let _=t=>{s(n=>D7(e,new Set(n).add(t))),c===t&&l(null)},v=h.find(e=>e.taskId===c)??null,y=g.find(e=>e.id===c)??null,b=h.length>=2;return(0,K.jsxs)(`div`,{className:`relative mb-1.5`,children:[(v||y)&&(0,K.jsxs)(`div`,{className:`absolute bottom-full left-0 right-0 z-30 mb-1.5 rounded-xl border bg-card shadow-float`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5 text-xs`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:[v?v.command:y?.description,y?.modelId?` · ${Sj(i,y.modelId)}`:``]}),v&&(0,K.jsx)(Uie,{sessionId:e,task:v,readOnly:r}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]}),v&&(0,K.jsx)(Wie,{sessionId:e,task:v,readOnly:r}),y&&(0,K.jsx)(Gie,{agent:y},y.id)]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-xl border bg-card p-1 shadow-xs`,children:[b&&(0,K.jsx)(Bie,{sessionId:e,tasks:h,expanded:u,readOnly:r,onToggle:()=>d(Rie(e,!u))}),(!b||u)&&h.map(t=>(0,K.jsx)(Hie,{sessionId:e,task:t,readOnly:r,open:c===t.taskId,onToggle:()=>l(c===t.taskId?null:t.taskId),onDismiss:()=>_(t.taskId)},t.taskId)),g.map(t=>(0,K.jsxs)(Vie,{icon:ft,status:t.status,meta:(0,K.jsx)(Xie,{agent:t}),open:c===t.id,onToggle:()=>l(c===t.id?null:t.id),stopTitle:a(`Stop subagent`),onStop:r?void 0:()=>void window.electronAPI.agent.stopSubagent(e,t.id),onDismiss:()=>_(t.id),children:[t.agentType&&(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:t.agentType}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:[t.description,t.modelId&&(0,K.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` `,`· `,Sj(i,t.modelId)]}),t.status===`running`&&t.currentActivity&&(0,K.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` · `,t.currentActivity]})]})]},t.id))]})]})}function Bie({sessionId:e,tasks:t,expanded:n,readOnly:r,onToggle:i}){let{t:a}=q(),o=v7(1e3),[s,c]=(0,U.useState)(!1),l=t.filter(e=>e.status===`running`),u=t.filter(e=>h7(e)===`idle`).length,d=l.reduce((e,t)=>Math.min(e,t.startedAt),o),f=!r&&l.length>0;return(0,U.useEffect)(()=>{f||c(!1)},[f]),(0,K.jsxs)(`div`,{"data-enso":`background-task-summary`,className:`flex min-h-[30px] min-w-0 items-center gap-2 rounded-lg px-1 text-[13px]`,children:[(0,K.jsx)(Y8,{icon:Kn,state:l.length>0?`running`:`ok`}),s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:a(`Stop {{count}} background tasks?`,{count:l.length})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs whitespace-nowrap text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:a(`Cancel`)}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`background-task-stop-all-confirm`,onClick:()=>{for(let t of l)S7(e,t.taskId);c(!1)},className:`flex h-6 shrink-0 items-center rounded-md bg-destructive/10 px-1.5 text-xs whitespace-nowrap text-destructive transition-colors hover:bg-destructive/15`,children:a(`Stop {{count}}`,{count:l.length})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`background-task-summary-toggle`,onClick:i,"aria-expanded":n,className:`flex h-6 min-w-0 flex-1 items-center gap-1.5 rounded-md text-left text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 truncate`,children:[a(`{{count}} background tasks`,{count:t.length}),l.length>0&&` · ${a(`longest running {{duration}}`,{duration:ON(o-d)})}`]}),u>0&&(0,K.jsx)(b7,{tone:`pending`,className:`whitespace-nowrap`,children:a(`{{count}} suspected idle`,{count:u})}),(0,K.jsx)(_t,{className:G(`h-3 w-3 shrink-0 transition-transform`,n&&`rotate-180`)})]}),f&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`background-task-stop-all`,onClick:()=>c(!0),className:`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs whitespace-nowrap text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:a(`Stop all`)})]})]})}function Vie({icon:e,status:t,meta:n,open:r,onToggle:i,stopTitle:a,onStop:o,onDismiss:s,children:c}){let{t:l}=q();return(0,K.jsxs)(`div`,{className:`flex min-h-[30px] min-w-0 items-center gap-2 px-1 text-[13px]`,children:[(0,K.jsx)(Y8,{icon:e,state:t===`running`?`running`:t===`failed`?`error`:`ok`}),c,n,(0,K.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":r,className:`flex h-6 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[l(`Output`),(0,K.jsx)(_t,{className:G(`h-3 w-3 transition-transform`,r&&`rotate-180`)})]}),t===`running`?o&&(0,K.jsx)(`button`,{type:`button`,onClick:o,title:a,className:`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:l(`Stop`)}):(0,K.jsx)(`button`,{type:`button`,onClick:s,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]})}function Hie({sessionId:e,task:t,readOnly:n,open:r,onToggle:i,onDismiss:a}){let{t:o}=q(),s=v7(),c=h7(t);return(0,K.jsxs)(`div`,{"data-enso":`background-task-row`,"data-view":c,className:G(`flex min-h-[30px] min-w-0 items-center gap-2 rounded-lg px-1 text-[13px]`,c===`kept`&&`py-1`,c===`idle`&&`bg-warning/[0.06]`,r&&`bg-muted`),children:[(0,K.jsx)(Cie,{task:t}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,title:t.command,children:t.command}),c===`idle`&&(0,K.jsx)(b7,{tone:`pending`,children:x7(t,s,o)})]}),(0,K.jsx)(Tie,{task:t,className:`mt-0.5`})]}),(0,K.jsx)(Zie,{task:t}),(0,K.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":r,className:G(`flex h-6 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,r&&`bg-foreground/[0.06] text-foreground`),children:[o(`Output`),(0,K.jsx)(_t,{className:G(`h-3 w-3 transition-transform`,r&&`rotate-180`)})]}),t.status===`running`?n?null:c===`idle`?(0,K.jsx)(w7,{sessionId:e,taskId:t.taskId}):(0,K.jsx)(Eie,{onStop:()=>S7(e,t.taskId)}):(0,K.jsx)(`button`,{type:`button`,onClick:a,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]})}function Uie({sessionId:e,task:t,readOnly:n}){let{t:r}=q(),i=v7(),a=h7(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sie,{task:t,now:i}),!n&&a===`idle`&&(0,K.jsx)(w7,{sessionId:e,taskId:t.taskId}),!n&&a===`kept`&&(0,K.jsx)(Oa,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,onClick:()=>C7(e,t.taskId,null),children:r(`Unkeep`)})]})}function M7({icon:e,label:t,value:n}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md bg-muted px-2 py-1.5`,children:[(0,K.jsx)(e,{className:`size-3.5 shrink-0 text-warning`}),(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 font-medium tabular-nums`,children:n})]})}function N7({children:e}){return(0,K.jsx)(`div`,{className:`text-[11px] text-subtle-foreground tabular-nums`,children:e})}function Wie({sessionId:e,task:t,readOnly:n}){let{t:r}=q(),i=v7(),a=h7(t),o=xie(i-t.startedAt),s=t.idle?.ports??[],c=a===`idle`||a===`kept`;return(0,K.jsxs)(K.Fragment,{children:[a===`idle`&&(0,K.jsxs)(`div`,{className:`space-y-2.5 px-3 py-2.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[(0,K.jsx)(M7,{icon:jt,label:r(`No new output`),value:g7(i-(t.idle?.since??i),r)}),(0,K.jsx)(M7,{icon:$n,label:s.length>0?r(`Port {{ports}}`,{ports:s.join(`, `)}):r(`Ports`),value:s.length>0?r(`No connections`):r(`Not listening`)}),(0,K.jsx)(M7,{icon:It,label:`CPU`,value:`0%`})]}),(0,K.jsx)(N7,{children:r(`Running for {{duration}} · Suspected idle tasks are never stopped automatically`,{duration:o})})]}),a===`kept`&&t.keep&&(0,K.jsxs)(`div`,{className:`space-y-2.5 px-3 py-2.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted px-2.5 py-2`,children:[(0,K.jsx)(wn,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[t.keep.by===`user`&&!n?(0,K.jsx)(`input`,{"data-enso":`background-task-keep-reason`,defaultValue:t.keep.reason??``,maxLength:200,placeholder:r(`Add a reason (optional)`),className:`w-full bg-transparent text-[13px] outline-none placeholder:text-subtle-foreground`,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:n=>{let r=n.currentTarget.value.trim();r!==(t.keep?.reason??``)&&C7(e,t.taskId,r)}},t.keep.at):(0,K.jsx)(`div`,{className:`text-[13px]`,children:t.keep.reason??`—`}),(0,K.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:t.keep.by===`agent`?r(`Kept by the agent at {{time}} when wrapping up`,{time:_7(t.keep.at)}):r(`Kept by you at {{time}}`,{time:_7(t.keep.at)})})]})]}),(0,K.jsx)(N7,{children:r(`Running for {{duration}}`,{duration:o})})]}),c&&(0,K.jsx)(`div`,{className:`flex items-center gap-2 border-t border-border/60 px-3 pt-2 text-[11px] text-subtle-foreground`,children:(0,K.jsx)(`span`,{children:r(`Recent output`)})}),(0,K.jsx)(Qie,{tail:t.tail,outputBytes:t.outputBytes,running:t.status===`running`,framed:!c})]})}function Gie({agent:e}){let{t}=q(),n=e.activities??[],r=(0,U.useRef)(null),i=(0,U.useRef)(!0);return(0,U.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[n,e.resultText]),(0,K.jsxs)(`div`,{ref:r,className:`max-h-96 space-y-2 overflow-auto px-3 py-2 text-sm`,onScroll:e=>{i.current=Pie(e.currentTarget)},children:[n.map(e=>(0,K.jsx)(Kie,{activity:e},e.id)),n.length===0&&!e.resultText&&(0,K.jsx)(`pre`,{className:`font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:(e.activityLog??[]).join(`
274
+ `,1)[0]??``);function Qre(e,t,n,r,i=100){if(r||!n)return{hiddenSince:t,delayMs:null};let a=t??e;return{hiddenSince:a,delayMs:Math.max(0,i-(e-a))}}var $re=1e6;function eie(e,t,n=$re){if(t.length===0)return{anchor:null,firstItemIndex:n,remount:!1};if(!e)return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!1};let r=new Map(t.map((e,t)=>[e,t]));for(let n=0;n<e.keys.length;n++){let i=r.get(e.keys[n]);if(i===void 0)continue;let a=e.index+n-i;return{anchor:{keys:t,index:a},firstItemIndex:a,remount:!1}}return{anchor:{keys:t,index:n},firstItemIndex:n,remount:!0}}function s7(e,t){return t}var tie=new Set([`text`,`thinking`,`tool`,`tool-group`]);function nie(e,t,n,r){let i=(0,U.useRef)(HH),[a,o]=(0,U.useState)(()=>Date.now()),s=r.compact,c=r.autoCollapseCompletedTurns,l=r.collapseCompletedActivity===!0,u=r.collapseLiveActivity===!0,d={compact:s,autoCollapseCompletedTurns:c,turnOverrides:r.turnOverrides},f=u?qH(e,t,r,i.current,a):null;i.current=f?.witness??HH;let p=f?.wakeAt??null,m=iU(e,t,n,{...d,collapseCompletedActivity:l,collapseLiveActivity:u,releasedLiveActivity:f?.released,heldOpenTools:r.heldOpenTools,foldToolOnlyTurns:r.foldToolOnlyTurns===!0,readableToolCards:r.readableToolCards===!0});return(0,U.useEffect)(()=>{if(p===null||p<=a)return;let e=window.setTimeout(()=>o(p),p-a);return()=>window.clearTimeout(e)},[p,a]),m}var rie=[{icon:Nt,title:`Map the project`,hint:`Entry points, modules and key dependencies`,prompt:`Walk me through this project's structure: entry points, module layout and key dependencies.`},{icon:mt,title:`Find potential issues`,hint:`Suspicious logic and unhandled edge cases`,prompt:`Review this project for potential bugs, suspicious logic and unhandled edge cases, and list them by severity.`},{icon:Ut,title:`Add unit tests`,hint:`Cover the core modules with tests`,prompt:`Find the core modules that lack tests and add unit tests for them.`},{icon:jn,title:`Summarize recent changes`,hint:`A digest based on git log`,prompt:`Summarize the recent changes in this repository based on git log.`}],iie=[{icon:Yn,title:`Check today's progress`,hint:`Progress report and items waiting on you`,prompt:`Summarize today's progress and list anything waiting on me.`},{icon:Fn,title:`Assign a task`,hint:`A one-off job for the secretary to run`,prompt:`Take care of a one-off task: `},{icon:At,title:`Organize the to-do list`,hint:`Sort the board into clear next steps`,prompt:`Go through the board and organize it into clear next steps.`},{icon:Jt,title:`Clean up merged branches`,hint:`Remove branches that are already merged`,prompt:`Clean up merged branches and worktrees you no longer need.`}];function aie({onPick:e,variant:t=`project`}){let{t:n}=q();return(0,K.jsx)(`div`,{className:`mx-auto grid w-full max-w-[560px] grid-cols-1 gap-2.5 text-left @min-[36rem]:grid-cols-2`,children:(t===`secretary`?iie:rie).map(({icon:t,title:r,hint:i,prompt:a})=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>e(n(a)),"data-slot":`welcome-suggestion`,className:`group flex items-start gap-3 rounded-xl border bg-card px-3.5 py-3 text-left shadow-xs transition-[border-color,box-shadow,transform] duration-200 hover:-translate-y-px hover:border-brand/25 hover:shadow-float`,children:[(0,K.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(t,{className:`size-3.5`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block text-[13px] font-medium`,children:n(r)}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:n(i)})]})]},r))})}var c7=`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,l7=1e3;function u7({className:e,children:t}){let[n,r]=(0,U.useState)(!1);return(0,U.useEffect)(()=>{let e=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(e)},[]),(0,K.jsx)(`div`,{className:G(`t-stagger`,n&&`is-shown`,e),children:t})}var d7=40,oie={index:`LAST`,align:`end`},sie={top:600,bottom:600},cie=e=>e&&!nz()?`auto`:!1,lie={owners:new Map,ends:new Map};function uie(e){let t=new Map,n=new Map,r=null,i=null,a=()=>{r&&i&&n.set(i,r)};for(let n of e)n.kind===`user`?(a(),r=!n.collapsed&&n.canCollapse===!0?n.key:null,i=null,r&&t.set(n.key,r)):r&&(t.set(n.key,r),i=n.key);return a(),{owners:t,ends:n}}var die=`input, textarea, select, [contenteditable=""], [contenteditable="true"]`;function fie({style:e,...t}){let n=e?.visibility===`hidden`,[r,i]=(0,U.useState)(!1),a=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let e=Qre(Date.now(),a.current,n,r);if(a.current=e.hiddenSince,e.delayMs===null)return;let t=window.setTimeout(()=>i(!0),e.delayMs);return()=>window.clearTimeout(t)},[n,r]),(0,K.jsx)(`div`,{...t,style:n&&r?{...e,visibility:`visible`}:e})}function pie({ref:e,items:t,busy:n,loading:r=!1,running:i,runStartedAt:a,lastOutputAt:o,error:s,emptyTitle:c,emptyDescription:l,onSuggestion:u,emptyVariant:d,onRetryResume:f,onRetrySync:p,virtualize:m=!0,onStartReached:h,historyLoading:g=!1,hasOlder:_,olderCursor:v,searchQuery:y=``,activeHit:b=null,secretarySession:x=!1,secretaryFace:S,conversationId:C,quotable:w=!1}){let{t:T}=q(),D=LN(),O=ez(C),k=x?S??O:null,A=!D&&k?k:null,j=x,M=(0,U.useRef)(null),[N,P]=(0,U.useState)(!0),[F,I]=(0,U.useState)(!1),L=(0,U.useRef)(!0),R=(0,U.useRef)(null),ee=(0,U.useRef)(null),z=(0,U.useRef)(0),B=(0,U.useRef)(0),V=(0,U.useRef)(null),te=(0,U.useRef)(!1),H=(0,U.useRef)(!1),ne=(0,U.useRef)(0),re=(0,U.useRef)(!1),[ie,ae]=(0,U.useState)(null),oe=(0,U.useRef)(0),se=(0,U.useCallback)(e=>{cancelAnimationFrame(oe.current),oe.current=requestAnimationFrame(()=>ae(e()))},[]);(0,U.useEffect)(()=>()=>cancelAnimationFrame(oe.current),[]);let[ce,le]=(0,U.useState)(new Set),ue=(0,U.useRef)(new Set),[de,fe]=(0,U.useState)(()=>new Set),pe=(0,U.useCallback)((e,t)=>{let n=ue.current;t!==n.has(e)&&(t?n.add(e):n.delete(e),fe(new Set(n)))},[]),me=(0,U.useRef)({report:pe,scroller:R});me.current.report=pe;let he=(0,U.useCallback)(e=>{le(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[ge,_e]=(0,U.useState)(new Map),ve=E(e=>e.autoCollapseTurns),ye=E(e=>e.collapseCompletedActivity),be=E(e=>e.collapseLiveActivity),xe=E(e=>e.liveActivityFoldDelaySec),Se=E(e=>e.compactReadOnlyTools),Ce=nie(t,i,ce,{compact:Se,autoCollapseCompletedTurns:ve,collapseCompletedActivity:ye,collapseLiveActivity:be,liveActivityFoldDelaySec:xe,heldOpenTools:de,turnOverrides:ge,foldToolOnlyTurns:!D&&j,readableToolCards:j}),we=(0,U.useRef)({state:aU,collapse:new Map,reveal:new Map}),Te=(0,U.useMemo)(()=>{let e=we.current,t=e=>R.current?.querySelector(`[data-nav-key="${CSS.escape(e)}"]`),n=oU(e.state,Ce,(e,n)=>{let r=t(e)?.getBoundingClientRect().top,i=t(n)?.getBoundingClientRect().bottom;return r===void 0||i===void 0?0:i-r}),r=Date.now();e.state=n.next;for(let{key:t,...i}of n.collapses)e.collapse.set(t,{at:r,...i});for(let t of n.expands)e.reveal.set(t,r);return n.children},[Ce]),Ee=(0,U.useRef)(null),De=(0,U.useRef)(0),Oe=(0,U.useRef)(null),ke=eie(Ee.current,Ce.map(e=>e.key));Ee.current=ke.anchor,ke.remount&&(De.current+=1,Oe.current=null);let Ae=ke.firstItemIndex,je=(0,U.useCallback)((e,t)=>{_e(n=>n.get(e)===t?n:new Map(n).set(e,t))},[]),Me=(0,U.useMemo)(()=>ve?uie(Ce):lie,[ve,Ce]),Ne=(0,U.useRef)(null),Pe=(0,U.useMemo)(()=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.kind!==`user`)continue;let i=``;for(let e=n+1;e<t.length;e++){let n=t[e];if(n.kind===`user`)break;if(n.kind===`text`){i=n.text;break}}e.push({key:r.key,question:fk(r.text)||`[image]`,answer:i})}return e},[t]),Fe=(0,U.useCallback)(()=>{let e=R.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight>2&&(te.current=!0,e.scrollTop=e.scrollHeight)},[]),Ie=(0,U.useCallback)(()=>{cancelAnimationFrame(z.current);let e=Date.now()+1200,t=null,n=()=>{cancelAnimationFrame(z.current),te.current=!1,t?.removeEventListener(`touchstart`,n),t?.removeEventListener(`wheel`,n)},r=()=>{if(H.current){n();return}!t&&R.current&&(t=R.current,t.addEventListener(`touchstart`,n,{passive:!0,once:!0}),t.addEventListener(`wheel`,n,{passive:!0,once:!0})),Fe(),L.current=!0,P(!0),Date.now()<e?z.current=requestAnimationFrame(r):n()};r(),P(!0),L.current=!0},[Fe]);(0,U.useEffect)(()=>()=>{cancelAnimationFrame(z.current),cancelAnimationFrame(B.current),window.clearTimeout(ne.current)},[]),(0,U.useEffect)(()=>tz.subscribe(({active:e},t)=>{if(e===t.active)return;if(e){cancelAnimationFrame(z.current),cancelAnimationFrame(B.current),te.current=!1;return}let n=re.current;re.current=!1,n&&L.current&&!H.current&&Fe()}),[Fe]);let Le=()=>{H.current=!0,window.clearTimeout(ne.current)},Re=()=>{window.clearTimeout(ne.current),ne.current=window.setTimeout(()=>{H.current=!1},400)},ze=()=>{Le(),Re()},Be=()=>[...R.current?.querySelectorAll(`[data-nav-key]`)??[]],Ve=e=>{ze(),Ne.current=e,je(e,!0)},He=e=>{if(e.key!==`Escape`||e.defaultPrevented||Me.owners.size===0)return;let t=R.current,n=e.target;if(!t?.contains(n)||n.closest?.(die)||TE()||document.querySelector(`[role="dialog"], [role="alertdialog"]`))return;let r=t.getBoundingClientRect();for(let t of Be()){let n=Me.owners.get(t.getAttribute(`data-nav-key`)??``);if(!n)continue;let i=t.getBoundingClientRect();if(i.bottom<=r.top||i.top>=r.bottom)continue;let a=e.nativeEvent;window.addEventListener(`keydown`,e=>{e!==a||e.defaultPrevented||(e.preventDefault(),Ve(n))},{once:!0});return}},Ue=()=>{cancelAnimationFrame(z.current),cancelAnimationFrame(B.current),te.current=!1,L.current=!1,P(!1)},We=(0,U.useCallback)(e=>{if(V.current?.disconnect(),V.current=null,!e)return;let t=new ResizeObserver(()=>{if(!L.current&&!te.current)return;cancelAnimationFrame(B.current);let e=8,t=()=>{Fe();let n=R.current;(n?n.scrollHeight-n.scrollTop-n.clientHeight:0)<=2||(--e>0?B.current=requestAnimationFrame(t):Ie())};t()});t.observe(e),V.current=t,Ie()},[Fe,Ie]);(0,U.useEffect)(()=>()=>V.current?.disconnect(),[]);let Ge=e=>Ce.findIndex(t=>t.key===e||t.kind===`tool-group`&&f7(t,e)),Ke=e=>{if(!m){R.current?.querySelector(`[data-nav-key="${CSS.escape(e)}"]`)?.scrollIntoView({block:`center`});return}let t=Ge(e);t>=0&&M.current?.scrollToIndex({index:s7(Ae,t),align:`center`})},qe=(0,U.useRef)(null),Je=e=>{if(Ue(),Ge(e)>=0){qe.current=null,Ke(e);return}let n=null,r=!1;for(let i of t)if(i.kind===`user`&&(n=i.key),i.key===e){r=!0;break}!r||!n||(qe.current=e,je(n,!1))};(0,U.useLayoutEffect)(()=>{let e=qe.current;!e||Ge(e)<0||(qe.current=null,Ke(e))},[Ce]),(0,U.useLayoutEffect)(()=>{let e=Ne.current;if(!e)return;Ne.current=null;let t=Be().find(t=>t.getAttribute(`data-nav-key`)===e);if(t){t7(t,R.current);return}let n=Ce.findIndex(t=>t.key===e);m&&n>=0&&M.current?.scrollToIndex({index:s7(Ae,n),align:`start`})},[Ce]),(0,U.useImperativeHandle)(e,()=>({scrollToBottom:Ie,pinToBottom:Fe,isAtBottom:()=>L.current,getScroller:()=>m?null:R.current,scrollToKey:Je}));let Ye=(0,U.useRef)(!1),Xe=`${v}:${Ae}`,Ze=(0,U.useRef)(Xe);Ze.current!==Xe&&(Ze.current=Xe,Ye.current=!1);let Qe=()=>{!h||Ye.current||(Ye.current=!0,h())};(0,U.useEffect)(()=>{m&&!g&&Oe.current===Ae&&Qe()},[v,g]);let $e=(0,U.useMemo)(()=>({query:y,activeKey:b?.key??``,activeNth:b?.nth??-1}),[y,b?.key,b?.nth]),et=(e,t)=>{let n=Ce[t+1];if(n!==void 0&&o7(e)&&o7(n))return`pb-0`;if(!Se)return`pb-4`;let r=n!==void 0&&V5(n);return V5(e)?r?`pb-1`:`pb-2`:e.kind===`text`&&r?`pb-1`:`pb-4`},tt=(e,t)=>{let n=Ce[t-1],r=n?.kind===`user`&&!n.collapsed&&tie.has(e.kind)?n:void 0,i=Date.now(),a=we.current.collapse.get(e.key),o=a&&i-a.at<l7?a:void 0,s=Te.get(e.key),c=s&&we.current.reveal.get(s.group),l=s&&c!==void 0&&i-c<l7,u=Me.ends.get(e.key);return(0,K.jsxs)(`div`,{"data-nav-key":e.key,"data-fold-collapse":o?o.pair?`pair`:`toggle`:void 0,style:o?{"--fold-from":`${o.height}px`}:l?{"--fold-i":s.index}:void 0,className:G(c7,et(e,t),l&&`t-fold-reveal`,`[overflow-wrap:anywhere]`),children:[r&&(0,K.jsx)(fre,{model:r.replyModel,at:r.replyAt,privacyMask:r.replyPrivacyMask,secretarySession:j,face:k,conversationId:C}),(0,K.jsx)(yie,{itemKey:e.key,children:(0,K.jsx)(pre,{item:e,secretarySession:j,onToggleGroup:he,onToggleTurn:je})}),u&&(0,K.jsx)(kre,{turnKey:u,canCollapse:!0,collapsed:!1,onToggleTurn:Ve})]},e.key)},nt=(0,U.useRef)(!1);_===!0&&(nt.current=!0);let W=yV(t.length>0,g,_,nt.current,!m&&F);(0,U.useLayoutEffect)(()=>{if(m){I(!1);return}let e=R.current;I(!!e&&bV(_===!0,g,e.scrollHeight,e.clientHeight))},[m,_,g,Ae,Ce.length,t.length]);let rt={pageChrome:W,onLoadMore:W===`more`?Qe:void 0,busy:n,loading:!!r,since:sU({loading:!!r,runStartedAt:a,lastOutputAt:o}),error:s,onRetryResume:f};return(0,K.jsx)(cU.Provider,{value:$e,children:(0,K.jsx)(Vne,{value:me.current,children:(0,K.jsxs)(`div`,{ref:ee,"data-enso":`timeline`,className:`@container relative min-h-24 flex-1`,onWheel:ze,onKeyDown:e=>{ze(),He(e)},onTouchStart:e=>{R.current?.contains(e.target)&&Le()},onTouchEnd:Re,onPointerDown:e=>{e.target===R.current&&(Le(),window.addEventListener(`pointerup`,Re,{once:!0}))},children:[(0,K.jsx)(vU,{items:Pe,activeKey:ie,onJump:Je}),w&&(0,K.jsx)(xU,{containerRef:ee}),t.length===0&&!n?(0,K.jsxs)(u7,{className:`flex h-full flex-col items-center justify-center gap-2 overflow-y-auto px-4 text-center`,children:[(0,K.jsx)(`span`,{className:`t-stagger-line t-stagger-line--1 mb-3`,children:A?(0,K.jsx)(iR,{name:A.name,color:A.color,image:A.image,needsYou:0,running:0,size:`lg`,enso:`secretary-chat-avatar`}):(0,K.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(RN,{className:`size-6`})})}),(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--1 text-[22px] font-semibold tracking-tight`,children:c}),s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 max-w-md text-sm text-destructive whitespace-pre-wrap`,children:T(s)}),f&&(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:f,children:T(`Retry resume`)})]}):(0,K.jsxs)(K.Fragment,{children:[p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 max-w-md text-sm text-muted-foreground`,children:T(`Session is not ready yet — no history to show.`)}),(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:p,children:T(`Retry sync`)})]}):l===``?null:(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--2 text-sm text-muted-foreground`,children:l??T(d===`secretary`?`Tell the secretary what to take care of…`:`Ask the agent…`)}),u&&(0,K.jsx)(`div`,{className:`t-stagger-line t-stagger-line--3 mt-5 w-full`,children:(0,K.jsx)(aie,{onPick:u,variant:d})})]})]}):t.length===0&&s?(0,K.jsxs)(u7,{className:`flex h-full flex-col items-center justify-center gap-2 text-center`,children:[(0,K.jsx)(`p`,{className:`t-stagger-line t-stagger-line--1 max-w-md text-sm text-destructive whitespace-pre-wrap`,children:T(s)}),f&&(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:f,children:T(`Retry resume`)})]}):t.length===0?(0,K.jsxs)(`div`,{"data-timeline-loading":``,className:`flex h-full flex-col items-center justify-center gap-2.5 text-center`,children:[(0,K.jsx)(sn,{className:`h-5 w-5 animate-spin text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:T(`Preparing session…`)})]}):m?(0,K.jsx)(oL,{ref:M,data:Ce,defaultItemHeight:80,computeItemKey:(e,t)=>t.key,firstItemIndex:Ae,startReached:Qe,followOutput:cie,atBottomThreshold:d7,atBottomStateChange:e=>{if(!e&&L.current&&!H.current){if(nz()){re.current=!0;return}Ie();return}P(e),L.current=e},increaseViewportBy:sie,initialTopMostItemIndex:oie,rangeChanged:({startIndex:e})=>{Oe.current=e,e>Ae+4&&(Ye.current=!1),se(()=>{let t=Math.max(0,e-Ae),n=null;for(let e=0;e<=Math.min(t+1,Ce.length-1);e++)Ce[e]?.kind===`user`&&(n=Ce[e].key);return n})},scrollerRef:e=>{R.current=e instanceof HTMLElement?e:null},className:`h-full select-text`,context:rt,components:hie,itemContent:(e,t)=>tt(t,e-Ae)},De.current):(0,K.jsx)(`div`,{ref:e=>{R.current=e},onScroll:e=>{let t=e.currentTarget;if(te.current){te.current=!1,L.current=!0,P(!0);return}if(!H.current){L.current&&Fe();return}let n=t.scrollHeight-t.scrollTop-t.clientHeight<=d7;n!==L.current&&(L.current=n,P(n)),h&&(t.scrollTop<80&&!Ye.current?(Ye.current=!0,h()):t.scrollTop>240&&(Ye.current=!1))},className:`h-full select-text overflow-y-auto [overflow-anchor:none]`,children:(0,K.jsxs)(`div`,{ref:We,children:[(0,K.jsx)(p7,{context:rt}),Ce.map((e,t)=>tt(e,t)),(0,K.jsx)(m7,{context:rt})]})}),!N&&t.length>0&&(0,K.jsxs)(`button`,{type:`button`,onClick:Ie,className:`absolute bottom-4 left-1/2 z-10 inline-flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-full border bg-card px-3 text-xs text-muted-foreground shadow-float transition-colors hover:text-foreground`,children:[(0,K.jsx)(ot,{className:`h-3 w-3`}),T(`Scroll to bottom`)]})]})})})}function f7(e,t){return e.children.some(e=>e.key===t||e.kind===`tool-group`&&f7(e,t))}function mie({chrome:e,onLoadMore:t}){let{t:n}=q();return e===`none`?(0,K.jsx)(`div`,{className:`h-6`}):(0,K.jsx)(`div`,{className:G(c7,`flex items-center justify-center gap-2 py-3`),children:e===`loading`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(sn,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Loading earlier messages…`)})]}):e===`more`?(0,K.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline-offset-2 hover:underline`,onClick:t,children:n(`Load earlier messages`)}):(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`Beginning of conversation`)})})}function p7({context:e}){return(0,K.jsx)(mie,{chrome:e.pageChrome,onLoadMore:e.onLoadMore})}function m7({context:e}){let{t}=q(),{busy:n,loading:r,since:i,error:a,onRetryResume:o}=e;return(0,K.jsxs)(`div`,{className:G(c7,`pb-6 [overflow-wrap:anywhere]`),children:[n&&(0,K.jsxs)(`div`,{className:`flex min-h-[26px] items-center gap-2 text-[13px]`,children:[(0,K.jsx)(gie,{}),(0,K.jsx)(`span`,{className:`animate-pulse text-foreground motion-reduce:animate-none`,children:t(r?`Loading…`:`Working…`)}),i!==void 0&&(0,K.jsx)(vie,{since:i})]}),a&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(`p`,{className:`min-w-0 flex-1 text-sm text-destructive whitespace-pre-wrap`,children:t(a)}),(0,K.jsx)(J5,{}),o&&(0,K.jsx)(Oa,{size:`sm`,variant:`outline`,onClick:o,children:t(`Retry resume`)})]})]})}var hie={List:fie,Header:p7,Footer:m7};function gie(){return(0,K.jsxs)(`span`,{className:`relative flex size-[22px] shrink-0 items-center justify-center`,children:[(0,K.jsx)(`span`,{className:`absolute size-2 animate-ping rounded-full bg-brand/50`}),(0,K.jsx)(`span`,{className:`relative size-2 rounded-full bg-brand`})]})}var _ie=e=>{let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m${t%60}s`},vie=(0,U.memo)(function({since:e}){let[,t]=(0,U.useState)(0);return(0,U.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:_ie(Date.now()-e)})}),yie=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidUpdate(e){e.itemKey!==this.props.itemKey&&this.state.failed&&this.setState({failed:!1})}render(){return this.state.failed?(0,K.jsxs)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-1.5 text-xs text-destructive`,children:[`message render failed · `,this.props.itemKey]}):this.props.children}};function bie({retry:e,onCancel:t}){let{t:n}=q(),[r,i]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>i(Date.now()),500);return()=>clearInterval(e)},[]);let a=Math.max(0,Math.ceil((e.at+e.delayMs-r)/1e3));return(0,K.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(An,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-amber-500 [animation-duration:2s]`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.error,children:[e.maxAttempts>0?n(`Auto-retrying ({{attempt}}/{{max}})`,{attempt:e.attempt,max:e.maxAttempts}):n(`Auto-retrying ({{attempt}})`,{attempt:e.attempt}),(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,a>0?n(`retrying in {{seconds}}s`,{seconds:a}):n(`retrying…`),` — `,e.error]})]}),t&&(0,K.jsx)(`button`,{type:`button`,title:n(`Cancel auto-retry`),onClick:t,className:`shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]})}function h7(e){return e.status===`running`?e.idle?`idle`:e.keep?`kept`:`running`:e.status}function g7(e,t){let n=Math.max(0,Math.floor(e/6e4));if(n<60)return t(`{{n}} min`,{n});let r=Math.floor(n/60),i=n%60;return i===0?t(`{{n}} h`,{n:r}):t(`{{h}} h {{m}} min`,{h:r,m:i})}function xie(e){let t=Math.max(0,Math.floor(e/6e4));return t<60?`${t}m`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,`0`)}m`}function _7(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function v7(e=3e4){let[t,n]=(0,U.useState)(()=>Date.now());return(0,U.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var y7={ok:`bg-success/15 text-success`,pending:`bg-warning/15 text-warning`,neutral:`bg-muted text-muted-foreground`};function b7({tone:e,children:t,className:n}){return(0,K.jsx)(`span`,{className:G(`shrink-0 rounded px-1 py-px text-[10px]`,y7[e],n),children:t})}function x7(e,t,n){return n(`Idle {{duration}}`,{duration:g7(t-(e.idle?.since??t),n)})}function Sie({task:e,now:t}){let{t:n}=q(),r=h7(e);return r===`idle`?(0,K.jsx)(b7,{tone:`pending`,children:x7(e,t,n)}):r===`kept`?(0,K.jsx)(b7,{tone:`neutral`,children:n(`Kept`)}):r===`running`?(0,K.jsx)(b7,{tone:`ok`,children:n(`Running`)}):e.interrupted===`restart`?(0,K.jsx)(b7,{tone:`pending`,children:n(`Interrupted by restart`)}):null}function Cie({task:e}){return h7(e)===`idle`?(0,K.jsx)(`span`,{className:`relative flex size-[22px] shrink-0 items-center justify-center rounded-full border border-dashed border-warning/60 text-warning`,children:(0,K.jsx)(gn,{className:`size-3`})}):(0,K.jsx)(Y8,{icon:Kn,state:e.status===`running`?`running`:e.status===`failed`?`error`:`ok`})}function wie(e,t){let n=e.keep;if(!n)return;let r=n.reason??_7(n.at);return n.by===`user`?t(`Kept by you · {{detail}}`,{detail:r}):t(`Kept: {{reason}}`,{reason:r})}function Tie({task:e,className:t}){let{t:n}=q(),r=h7(e)===`kept`?wie(e,n):void 0;return r?(0,K.jsxs)(`div`,{className:G(`flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground/85`,t),children:[(0,K.jsx)(wn,{className:`size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,title:r,children:r})]}):null}function S7(e,t){window.electronAPI.agent.stopTask(e,t)}function C7(e,t,n){window.electronAPI.agent.keepTask(e,t,n)}function Eie({onStop:e,className:t}){let{t:n}=q();return(0,K.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),e()},title:n(`Stop task`),className:G(`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,t),children:n(`Stop`)})}function w7({sessionId:e,taskId:t}){let{t:n}=q();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oa,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,onClick:n=>{n.stopPropagation(),C7(e,t,``)},children:n(`Keep`)}),(0,K.jsx)(Oa,{size:`xs`,variant:`outline`,className:`hover:text-destructive`,onClick:n=>{n.stopPropagation(),S7(e,t)},children:n(`Stop`)})]})}var Die=[`pattern`,`query`,`path`,`file_path`],Oie=[`path`,`file_path`,`query`,`pattern`],kie=[`command`,`cmd`,`script`],Aie=[`path`,`file_path`,`pattern`,`query`,`command`,`url`,`description`,`summary`],jie=120;function T7(e){let t=e.replace(/\s+/g,` `).trim();return t.length>jie?`${t.slice(0,119)}…`:t}function Mie(e){let t=e.toLowerCase();return t.includes(`search`)||t.includes(`grep`)||t===`find`?Die:t===`read`||t.endsWith(`_read`)?Oie:t===`bash`||t.includes(`shell`)||t.includes(`terminal`)?kie:Aie}function Nie(e,t){let n=t.trim();if(!n)return``;let r;try{r=JSON.parse(n)}catch{return T7(n)}if(r===null)return``;if(typeof r!=`object`||Array.isArray(r))return T7(JSON.stringify(r)??String(r));let i=jz(e,r);if(i.summary!==void 0)return T7(i.summary);if(!i.args||typeof i.args!=`object`)return``;let a=i.args;for(let e of Mie(i.name)){let t=a[e];if(typeof t==`string`&&t.trim())return T7(t)}let o=JSON.stringify(a);return o===`{}`?``:T7(o)}function Pie(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=24}var E7=new Map,Fie=e=>{let t=E7.get(e);return t?new Set(t):new Set},D7=(e,t)=>(E7.set(e,t),t),O7=new Map,Iie=(e,t)=>{let n=O7.get(e)??new Set;O7.set(e,n);for(let e of t)n.add(e);return n},k7=`enso:task-bar-expanded`,A7=new Map,j7=()=>{try{let e=JSON.parse(window.sessionStorage.getItem(k7)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}},Lie=e=>A7.get(e)??j7().includes(e),Rie=(e,t)=>{A7.set(e,t);try{let n=j7().filter(t=>t!==e);window.sessionStorage.setItem(k7,JSON.stringify(t?[...n,e]:n))}catch{}return t};function zie({sessionId:e,tasks:t,subagents:n,readOnly:r}){let i=E(e=>e.virtualModels),{t:a}=q(),[o,s]=(0,U.useState)(()=>Fie(e)),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(()=>Lie(e)),f=nP(e=>e.pendingAgentOpen);(0,U.useEffect)(()=>{!f||f.sessionId!==e||(l(f.agentId),nP.setState({pendingAgentOpen:null}))},[f,e]);let p=Iie(e,[...t.filter(e=>e.status===`running`).map(e=>e.taskId),...n.filter(e=>e.status===`running`).map(e=>e.id)]),m=(e,t)=>!o.has(e)&&(t===`running`||p.has(e)),h=t.filter(e=>m(e.taskId,e.status)),g=n.filter(e=>m(e.id,e.status));if((0,U.useEffect)(()=>{let r=O7.get(e),i=[...t.filter(e=>e.status!==`running`).map(e=>e.taskId),...n.filter(e=>e.status!==`running`).map(e=>e.id)].filter(e=>r?.has(e)&&!o.has(e)&&e!==c);if(i.length===0)return;let a=setTimeout(()=>{s(t=>{let n=new Set(t);for(let e of i)n.add(e);return D7(e,n)})},5e3);return()=>clearTimeout(a)},[e,t,n,o,c]),h.length===0&&g.length===0)return null;let _=t=>{s(n=>D7(e,new Set(n).add(t))),c===t&&l(null)},v=h.find(e=>e.taskId===c)??null,y=g.find(e=>e.id===c)??null,b=h.length>=2;return(0,K.jsxs)(`div`,{className:`relative mb-1.5`,children:[(v||y)&&(0,K.jsxs)(`div`,{className:`absolute bottom-full left-0 right-0 z-30 mb-1.5 rounded-xl border bg-card shadow-float`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1.5 text-xs`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:[v?v.command:y?.description,y?.modelId?` · ${xj(i,y.modelId)}`:``]}),v&&(0,K.jsx)(Uie,{sessionId:e,task:v,readOnly:r}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded p-0.5 text-muted-foreground hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]}),v&&(0,K.jsx)(Wie,{sessionId:e,task:v,readOnly:r}),y&&(0,K.jsx)(Gie,{agent:y},y.id)]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-xl border bg-card p-1 shadow-xs`,children:[b&&(0,K.jsx)(Bie,{sessionId:e,tasks:h,expanded:u,readOnly:r,onToggle:()=>d(Rie(e,!u))}),(!b||u)&&h.map(t=>(0,K.jsx)(Hie,{sessionId:e,task:t,readOnly:r,open:c===t.taskId,onToggle:()=>l(c===t.taskId?null:t.taskId),onDismiss:()=>_(t.taskId)},t.taskId)),g.map(t=>(0,K.jsxs)(Vie,{icon:ft,status:t.status,meta:(0,K.jsx)(Xie,{agent:t}),open:c===t.id,onToggle:()=>l(c===t.id?null:t.id),stopTitle:a(`Stop subagent`),onStop:r?void 0:()=>void window.electronAPI.agent.stopSubagent(e,t.id),onDismiss:()=>_(t.id),children:[t.agentType&&(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:t.agentType}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:[t.description,t.modelId&&(0,K.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` `,`· `,xj(i,t.modelId)]}),t.status===`running`&&t.currentActivity&&(0,K.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` · `,t.currentActivity]})]})]},t.id))]})]})}function Bie({sessionId:e,tasks:t,expanded:n,readOnly:r,onToggle:i}){let{t:a}=q(),o=v7(1e3),[s,c]=(0,U.useState)(!1),l=t.filter(e=>e.status===`running`),u=t.filter(e=>h7(e)===`idle`).length,d=l.reduce((e,t)=>Math.min(e,t.startedAt),o),f=!r&&l.length>0;return(0,U.useEffect)(()=>{f||c(!1)},[f]),(0,K.jsxs)(`div`,{"data-enso":`background-task-summary`,className:`flex min-h-[30px] min-w-0 items-center gap-2 rounded-lg px-1 text-[13px]`,children:[(0,K.jsx)(Y8,{icon:Kn,state:l.length>0?`running`:`ok`}),s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:a(`Stop {{count}} background tasks?`,{count:l.length})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs whitespace-nowrap text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:a(`Cancel`)}),(0,K.jsx)(`button`,{type:`button`,"data-enso":`background-task-stop-all-confirm`,onClick:()=>{for(let t of l)S7(e,t.taskId);c(!1)},className:`flex h-6 shrink-0 items-center rounded-md bg-destructive/10 px-1.5 text-xs whitespace-nowrap text-destructive transition-colors hover:bg-destructive/15`,children:a(`Stop {{count}}`,{count:l.length})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{type:`button`,"data-enso":`background-task-summary-toggle`,onClick:i,"aria-expanded":n,className:`flex h-6 min-w-0 flex-1 items-center gap-1.5 rounded-md text-left text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 truncate`,children:[a(`{{count}} background tasks`,{count:t.length}),l.length>0&&` · ${a(`longest running {{duration}}`,{duration:ON(o-d)})}`]}),u>0&&(0,K.jsx)(b7,{tone:`pending`,className:`whitespace-nowrap`,children:a(`{{count}} suspected idle`,{count:u})}),(0,K.jsx)(_t,{className:G(`h-3 w-3 shrink-0 transition-transform`,n&&`rotate-180`)})]}),f&&(0,K.jsx)(`button`,{type:`button`,"data-enso":`background-task-stop-all`,onClick:()=>c(!0),className:`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs whitespace-nowrap text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:a(`Stop all`)})]})]})}function Vie({icon:e,status:t,meta:n,open:r,onToggle:i,stopTitle:a,onStop:o,onDismiss:s,children:c}){let{t:l}=q();return(0,K.jsxs)(`div`,{className:`flex min-h-[30px] min-w-0 items-center gap-2 px-1 text-[13px]`,children:[(0,K.jsx)(Y8,{icon:e,state:t===`running`?`running`:t===`failed`?`error`:`ok`}),c,n,(0,K.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":r,className:`flex h-6 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[l(`Output`),(0,K.jsx)(_t,{className:G(`h-3 w-3 transition-transform`,r&&`rotate-180`)})]}),t===`running`?o&&(0,K.jsx)(`button`,{type:`button`,onClick:o,title:a,className:`flex h-6 shrink-0 items-center rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:l(`Stop`)}):(0,K.jsx)(`button`,{type:`button`,onClick:s,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]})}function Hie({sessionId:e,task:t,readOnly:n,open:r,onToggle:i,onDismiss:a}){let{t:o}=q(),s=v7(),c=h7(t);return(0,K.jsxs)(`div`,{"data-enso":`background-task-row`,"data-view":c,className:G(`flex min-h-[30px] min-w-0 items-center gap-2 rounded-lg px-1 text-[13px]`,c===`kept`&&`py-1`,c===`idle`&&`bg-warning/[0.06]`,r&&`bg-muted`),children:[(0,K.jsx)(Cie,{task:t}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,title:t.command,children:t.command}),c===`idle`&&(0,K.jsx)(b7,{tone:`pending`,children:x7(t,s,o)})]}),(0,K.jsx)(Tie,{task:t,className:`mt-0.5`})]}),(0,K.jsx)(Zie,{task:t}),(0,K.jsxs)(`button`,{type:`button`,onClick:i,"aria-expanded":r,className:G(`flex h-6 shrink-0 items-center gap-0.5 rounded-md px-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,r&&`bg-foreground/[0.06] text-foreground`),children:[o(`Output`),(0,K.jsx)(_t,{className:G(`h-3 w-3 transition-transform`,r&&`rotate-180`)})]}),t.status===`running`?n?null:c===`idle`?(0,K.jsx)(w7,{sessionId:e,taskId:t.taskId}):(0,K.jsx)(Eie,{onStop:()=>S7(e,t.taskId)}):(0,K.jsx)(`button`,{type:`button`,onClick:a,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]})}function Uie({sessionId:e,task:t,readOnly:n}){let{t:r}=q(),i=v7(),a=h7(t);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sie,{task:t,now:i}),!n&&a===`idle`&&(0,K.jsx)(w7,{sessionId:e,taskId:t.taskId}),!n&&a===`kept`&&(0,K.jsx)(Oa,{size:`xs`,variant:`ghost`,className:`text-muted-foreground`,onClick:()=>C7(e,t.taskId,null),children:r(`Unkeep`)})]})}function M7({icon:e,label:t,value:n}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md bg-muted px-2 py-1.5`,children:[(0,K.jsx)(e,{className:`size-3.5 shrink-0 text-warning`}),(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 font-medium tabular-nums`,children:n})]})}function N7({children:e}){return(0,K.jsx)(`div`,{className:`text-[11px] text-subtle-foreground tabular-nums`,children:e})}function Wie({sessionId:e,task:t,readOnly:n}){let{t:r}=q(),i=v7(),a=h7(t),o=xie(i-t.startedAt),s=t.idle?.ports??[],c=a===`idle`||a===`kept`;return(0,K.jsxs)(K.Fragment,{children:[a===`idle`&&(0,K.jsxs)(`div`,{className:`space-y-2.5 px-3 py-2.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-1.5`,children:[(0,K.jsx)(M7,{icon:jt,label:r(`No new output`),value:g7(i-(t.idle?.since??i),r)}),(0,K.jsx)(M7,{icon:$n,label:s.length>0?r(`Port {{ports}}`,{ports:s.join(`, `)}):r(`Ports`),value:s.length>0?r(`No connections`):r(`Not listening`)}),(0,K.jsx)(M7,{icon:It,label:`CPU`,value:`0%`})]}),(0,K.jsx)(N7,{children:r(`Running for {{duration}} · Suspected idle tasks are never stopped automatically`,{duration:o})})]}),a===`kept`&&t.keep&&(0,K.jsxs)(`div`,{className:`space-y-2.5 px-3 py-2.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md bg-muted px-2.5 py-2`,children:[(0,K.jsx)(wn,{className:`mt-0.5 size-3.5 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[t.keep.by===`user`&&!n?(0,K.jsx)(`input`,{"data-enso":`background-task-keep-reason`,defaultValue:t.keep.reason??``,maxLength:200,placeholder:r(`Add a reason (optional)`),className:`w-full bg-transparent text-[13px] outline-none placeholder:text-subtle-foreground`,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},onBlur:n=>{let r=n.currentTarget.value.trim();r!==(t.keep?.reason??``)&&C7(e,t.taskId,r)}},t.keep.at):(0,K.jsx)(`div`,{className:`text-[13px]`,children:t.keep.reason??`—`}),(0,K.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:t.keep.by===`agent`?r(`Kept by the agent at {{time}} when wrapping up`,{time:_7(t.keep.at)}):r(`Kept by you at {{time}}`,{time:_7(t.keep.at)})})]})]}),(0,K.jsx)(N7,{children:r(`Running for {{duration}}`,{duration:o})})]}),c&&(0,K.jsx)(`div`,{className:`flex items-center gap-2 border-t border-border/60 px-3 pt-2 text-[11px] text-subtle-foreground`,children:(0,K.jsx)(`span`,{children:r(`Recent output`)})}),(0,K.jsx)(Qie,{tail:t.tail,outputBytes:t.outputBytes,running:t.status===`running`,framed:!c})]})}function Gie({agent:e}){let{t}=q(),n=e.activities??[],r=(0,U.useRef)(null),i=(0,U.useRef)(!0);return(0,U.useEffect)(()=>{let e=r.current;e&&i.current&&(e.scrollTop=e.scrollHeight)},[n,e.resultText]),(0,K.jsxs)(`div`,{ref:r,className:`max-h-96 space-y-2 overflow-auto px-3 py-2 text-sm`,onScroll:e=>{i.current=Pie(e.currentTarget)},children:[n.map(e=>(0,K.jsx)(Kie,{activity:e},e.id)),n.length===0&&!e.resultText&&(0,K.jsx)(`pre`,{className:`font-mono text-xs whitespace-pre-wrap text-muted-foreground`,children:(e.activityLog??[]).join(`
275
275
  `)||t(`(no output yet)`)}),e.detailsPruned&&(0,K.jsx)(`div`,{className:`rounded-md border border-dashed px-2.5 py-2 text-xs text-muted-foreground`,children:t(`Earlier activity details were cleared; the final report is still available.`)}),e.resultText&&e.status!==`running`&&(0,K.jsxs)(`section`,{className:G(`rounded-lg border px-3 py-2`,e.status===`failed`?`border-destructive/30 bg-destructive/5`:`border-blue-500/30 bg-blue-500/5`),children:[(0,K.jsx)(`div`,{className:`mb-1.5 font-medium text-xs text-foreground`,children:t(`Final report`)}),(0,K.jsx)(D3,{text:e.resultText})]})]})}function Kie({activity:e}){let{t}=q(),[n,r]=(0,U.useState)(!1);if(e.type===`assistant`)return(0,K.jsxs)(`section`,{className:`rounded-md bg-muted/30 px-2.5 py-2`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,children:t(`Assistant`)}),(0,K.jsx)(Yie,{text:e.text,markdown:!0})]});let i=Nie(e.toolName,e.argumentsText),a=jz(e.toolName,e.argumentsText).name,o=Oz(a),s=`subagent-tool-${e.id.replace(/[^A-Za-z0-9_-]/g,`-`)}`;return(0,K.jsxs)(`section`,{className:`border-b border-border/40 last:border-b-0`,children:[(0,K.jsxs)(`button`,{type:`button`,"aria-controls":s,"aria-expanded":n,onClick:()=>r(e=>!e),className:`flex w-full min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-left text-xs transition-colors hover:bg-muted/50`,children:[(0,K.jsx)(qie,{toolName:a}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium text-foreground/80`,children:o?.tool??a}),i&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground`,title:i,children:i}),!i&&(0,K.jsx)(`span`,{className:`min-w-0 flex-1`}),(0,K.jsx)(Jie,{status:e.status,label:t(e.status)}),(0,K.jsx)(vt,{"aria-hidden":`true`,className:G(`h-3 w-3 shrink-0 text-muted-foreground transition-transform`,n&&`rotate-90`)})]}),n&&(0,K.jsxs)(`div`,{id:s,className:`ml-5 border-border/50 border-l pb-2 pl-2.5`,children:[o&&(0,K.jsxs)(`div`,{className:`mb-1 truncate font-mono text-[10px] text-muted-foreground/70`,children:[o.server,`.`,o.tool]}),(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground/70`,children:t(`Arguments`)}),(0,K.jsx)(`pre`,{className:`max-h-28 overflow-auto font-mono text-[10px] leading-relaxed whitespace-pre-wrap text-muted-foreground/80`,children:c6(e.argumentsText)}),e.outputText&&(0,K.jsxs)(`div`,{className:`mt-1.5 border-border/40 border-t pt-1.5`,children:[(0,K.jsx)(`div`,{className:`mb-0.5 text-[10px] text-muted-foreground`,children:t(`Result`)}),(0,K.jsx)(`pre`,{className:`overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-foreground/80`,children:c6(e.outputText)})]})]})]})}function qie({toolName:e}){let t=e.toLowerCase(),n=`h-3.5 w-3.5 shrink-0 text-muted-foreground`;return t.includes(`search`)||t.includes(`grep`)||t===`find`?(0,K.jsx)(Pn,{"aria-hidden":`true`,className:n}):t===`read`||t===`write`||t===`edit`||t===`apply_patch`||t.endsWith(`_read`)?(0,K.jsx)(Ht,{"aria-hidden":`true`,className:n}):t===`bash`||t===`exec`||t===`codemode`||t.includes(`shell`)||t.includes(`terminal`)?(0,K.jsx)(Zn,{"aria-hidden":`true`,className:n}):(0,K.jsx)(rr,{"aria-hidden":`true`,className:n})}function Jie({status:e,label:t}){let n=`h-3.5 w-3.5`;return(0,K.jsx)(`span`,{role:`status`,"aria-label":t,title:t,className:G(`shrink-0`,e===`failed`?`text-destructive`:`text-muted-foreground`),children:e===`running`?(0,K.jsx)(sn,{"aria-hidden":`true`,className:G(n,`animate-spin`)}):e===`done`?(0,K.jsx)(gt,{"aria-hidden":`true`,className:n}):e===`failed`?(0,K.jsx)(St,{"aria-hidden":`true`,className:n}):(0,K.jsx)(lt,{"aria-hidden":`true`,className:n})})}function Yie({text:e,label:t,markdown:n=!1}){let{t:r}=q(),i=e.length>800||e.split(`
276
276
  `).length>16,a=n?(0,K.jsx)(D3,{text:e}):(0,K.jsx)(`pre`,{className:`overflow-x-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap text-muted-foreground`,children:c6(e)});return i?(0,K.jsxs)(`details`,{className:`group/details`,children:[(0,K.jsxs)(`summary`,{className:`cursor-pointer text-[10px] text-muted-foreground hover:text-foreground`,children:[t?`${t} · `:``,r(`{{count}} chars`,{count:e.length})]}),(0,K.jsx)(`div`,{className:`mt-1.5`,children:a})]}):(0,K.jsxs)(`div`,{children:[t&&(0,K.jsx)(`div`,{className:`mb-0.5 text-[10px] text-muted-foreground`,children:t}),a]})}function Xie({agent:e}){let[,t]=(0,U.useState)(0);return(0,U.useEffect)(()=>{if(e.status!==`running`)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e.status]),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:[e.steps>0?`${e.steps} steps · `:``,e.outputTokens?`${e.outputTokens} tok · `:``,e.status===`running`?ON(Date.now()-e.startedAt):e.status]})}function Zie({task:e}){let[,t]=(0,U.useState)(0);return(0,U.useEffect)(()=>{if(e.status!==`running`)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e.status]),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/70 tabular-nums`,children:e.status===`running`?ON(Date.now()-e.startedAt):e.exitCode===void 0?e.status:`exit ${e.exitCode}`})}function Qie({tail:e,outputBytes:t,running:n,framed:r=!0}){let{t:i}=q(),a=(0,U.useRef)(null);return(0,U.useEffect)(()=>{let e=a.current;e&&(e.scrollTop=e.scrollHeight)},[e]),(0,K.jsx)(`pre`,{ref:a,className:G(`max-h-56 overflow-auto font-mono text-xs leading-relaxed whitespace-pre-wrap text-muted-foreground`,r?`border-t border-border/60 px-2.5 py-2`:`px-3 pt-1 pb-2.5`),children:c6(e)||(t===void 0?i(`Loading…`):t>0?i(`Output written ({{size}}), not loaded yet`,{size:BB(t)}):n?`${i(`(no output yet)`)}\n${i(`The process has not written anything. Without a terminal, some programs buffer output and only write it in blocks or on exit.`)}`:i(`(no output yet)`))})}function $ie(e){return{sessionId:e.sessionId,canRewind:!e.bot&&!e.deviceReadOnly,canRetry:!e.bot&&!e.deviceReadOnly,canFork:!1,...e.bot?{botSession:!0}:{}}}var P7=7e5,eae=1600;async function F7(e,t=P7,n=eae){let r=await createImageBitmap(e),i=Math.min(1,n/Math.max(r.width,r.height)),a=document.createElement(`canvas`);a.width=Math.round(r.width*i),a.height=Math.round(r.height*i);let o=a.getContext(`2d`);if(!o)throw Error(`画布不可用`);o.drawImage(r,0,0,a.width,a.height),r.close();for(let e of[.85,.7,.55,.4]){let n=a.toDataURL(`image/jpeg`,e),r=n.slice(n.indexOf(`,`)+1);if(r.length*.75<=t)return{data:r,mimeType:`image/jpeg`}}throw Error(`图片太大,请换一张更小的图`)}var I7=e=>Math.floor(P7/Math.max(1,e));async function L7(e,t){try{return await F7(e,t)}catch{return F7(e,t,1024)}}async function tae(e){let t=I7(e.length),n=[];for(let r of e)n.push(await L7(r,t));return n}function nae(e,t,n,r){let i=e?.find(e=>e.id===n);if(!i)return null;let a=i.text;return{sessionId:t,messageId:n,text:a,...i.hasImages?{hasImages:!0}:{},priorMatches:r.filter(e=>R7(a,e)).length,priorUserCount:r.length}}function R7(e,t){if(t===e)return!0;let n=_6(t);return n!==null&&e.trimStart().startsWith(n)}function rae(e,t,n){let r=new Set(t.filter(e=>e.sessionId===n).map(e=>e.messageId));return(e??[]).filter(e=>!r.has(e.id))}function iae(e,t,n){let r=t.filter(e=>e.sessionId===n).map(e=>oae(e));return r.length===0?[...e]:[...e,...r]}function aae(e,t,n,r){return e.filter(e=>e.sessionId===t?r?.turnSettled&&n.length>e.priorUserCount?!1:e.text?n.filter(t=>R7(e.text,t)).length<=e.priorMatches:n.length<=e.priorUserCount:!0)}function z7(e){return e.filter(e=>e.role===`user`).map(sae)}function oae(e){let t=e.text||(e.hasImages?`[image]`:``);return{role:`user`,content:t?[{type:`text`,text:t}]:[]}}function sae(e){return e.content.map(e=>e.type===`text`?e.text:``).join(`
277
- `).trim()}var cae=e=>e===`outbox-discarding`?`正在移除…`:e===`outbox-discard`?`移除未保存,请勿关闭页面;请再次移除,重启后可能重新入队`:e===`outbox-storage`?`无法保存离线消息,请勿关闭页面;可重试或复制消息`:e===`delivery-unconfirmed`?`未收到回执,发送结果未确认;可重试确认`:e===`read-only`?`此设备为只读`:e===`session-busy`?`请等当前回复结束`:e&&Ie(`zh`,Ma(e)??e),B7=(e=!1)=>e?`此设备为只读,刚才的操作未执行;可在桌面「设置 → 设备」切换为可操作`:`此设备为只读,只能查看;可在桌面「设置 → 设备」切换为可操作`,lae=70;function uae({percent:e,critical:t}){return(0,K.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-7 shrink-0 overflow-hidden rounded-full bg-muted-foreground/20`,children:(0,K.jsx)(`span`,{className:G(`block h-full rounded-full`,t?`bg-destructive`:e>=lae?`bg-warning`:`bg-muted-foreground/70`),style:{width:`${e}%`}})})}function dae(e,t){let n={inputTokens:0,outputTokens:0,...e};return t&&(n.contextUsed=t.used,t.window!==void 0&&(n.contextWindow=t.window)),n.inputTokens===0&&n.outputTokens===0&&n.cacheHitPercent===void 0&&n.ttftAvgMs===void 0&&n.tokensPerSecond===void 0&&n.contextUsed===void 0?void 0:n}function fae(e,t){let n={tokens:void 0,cache:void 0,context:void 0,speed:void 0};if(!t)return n;if(t.contextUsed!==void 0){let e=t.contextUsed,r=t.contextWindow??0;if(r>0){let t=Math.min(100,Math.round(e/r*100));n.context={compact:`${t}%`,full:`${DN(r)} · ${t}%`,percent:t,critical:t>=90}}else n.context={compact:`${DN(e)}·?`,full:`${DN(e)} · ?`}}let r=[],i=[];return t.ttftAvgMs!==void 0&&(r.push(ON(t.ttftAvgMs)),i.push(e(`First token avg {{duration}}`,{duration:ON(t.ttftAvgMs)}))),t.tokensPerSecond!==void 0&&(r.push(`${t.tokensPerSecond} tok/s`),i.push(e(`{{speed}} tok/s`,{speed:t.tokensPerSecond}))),r.length>0&&(n.speed={compact:r.join(` · `),full:i.join(` · `)}),(t.inputTokens>0||t.outputTokens>0)&&(n.tokens={compact:`↑${DN(t.inputTokens)} ↓${DN(t.outputTokens)}`,full:e(`Input {{input}} tok · Output {{output}} tok`,{input:DN(t.inputTokens),output:DN(t.outputTokens)})}),t.cacheHitPercent!==void 0&&(n.cache={compact:`${t.cacheHitPercent}%`,full:e(`Cache hit {{percent}}%`,{percent:t.cacheHitPercent})}),n}var pae=[[`tokens`,Mt],[`cache`,Lt],[`context`,qt],[`speed`,ar]];function mae({usageTotals:e,context:t}){let{t:n}=q(),r=fae(n,dae(e,t));return(0,K.jsx)(`div`,{"data-slot":`stats-line`,className:`flex min-h-6 flex-wrap items-center justify-center gap-x-3 px-1`,children:pae.map(([e,t])=>{let n=r[e];return n?(0,K.jsxs)(`span`,{className:G(`flex items-center gap-1 text-[11px] tabular-nums`,n.critical?`text-destructive`:`text-muted-foreground/80`),children:[n.percent===void 0?(0,K.jsx)(t,{className:`h-3 w-3 shrink-0 opacity-75`}):(0,K.jsx)(uae,{percent:n.percent,critical:!!n.critical}),n.compact]},e):null})})}function V7(e){let{view:t,sessionId:n}=e,r=(0,U.useRef)(null),[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null),s=(0,U.useRef)(null),c=(0,U.useRef)(!1);(0,U.useLayoutEffect)(()=>{let e=o.current,t=s.current,n=e?.querySelector(`[aria-selected="true"]`);!e||!t||!n||(c.current||(t.style.transition=`none`),t.style.transform=`translate(${n.offsetLeft}px, ${n.offsetTop}px)`,t.style.width=`${n.offsetWidth}px`,t.style.height=`${n.offsetHeight}px`,c.current||=(t.offsetWidth,t.style.transition=``,!0))},[n,e.tabGroup]);let l=t?.status===`running`,u=e.bot,d=!!(u?.readOnly||e.deviceReadOnly),f=e.artifacts?.chatId,p=e.artifacts?.conversationId,m=(0,U.useMemo)(()=>({...$ie({sessionId:n,bot:u,deviceReadOnly:e.deviceReadOnly}),...f&&p?{turnFooter:e=>(0,K.jsx)(Xa,{target:{chatId:f,conversationId:p,messageIndex:e}})}:{}}),[n,u,e.deviceReadOnly,f,p]),h=(0,U.useMemo)(()=>{if(u)return[];let t=[{name:`/goal`,description:`Set a session goal (/goal <objective> · pause · resume · clear)`},{name:`/compact`,description:`Compact the context now (/compact [summary focus])`}],n=(e.slashCommands??[]).filter(e=>e.name!==`/goal`&&e.name!==`/compact`);return[...t,...n]},[e.slashCommands,u]),g=(0,U.useMemo)(()=>t?[...t.messages.entries()].sort((e,t)=>e[0]-t[0]):[],[t]),_=(0,U.useMemo)(()=>iae(g.map(([,e])=>e),e.echoes??[],n??``),[g,e.echoes,n]),v=_.length>0||t?.status===`running`||t?.status===`failed`;tP(n?{id:n,projectId:``,status:t?.status??`idle`,started:v,spawning:!1,messages:_,queuedMessages:e.queued?.map(e=>({id:e.id,text:e.text}))}:null);let y=(0,U.useMemo)(()=>SH(_,l,[],e.cwd,{pendingApprovals:t?.approvals,compaction:t?.compaction,compactionNoticeAt:V(g.map(([e])=>e),t?.compactionNoticeAt)}),[_,g,l,e.cwd,t?.approvals,t?.compaction,t?.compactionNoticeAt]),b=t?.messages.size?Math.min(...t.messages.keys()):null,x=(0,U.useRef)(null),S=(0,U.useCallback)(()=>{if(!e.hasOlder||!e.onLoadOlder)return;let t=r.current?.getScroller();x.current=t?{height:t.scrollHeight,top:t.scrollTop}:null,e.onLoadOlder()},[e.hasOlder,e.onLoadOlder]);(0,U.useLayoutEffect)(()=>{let e=r.current?.getScroller(),t=x.current;!e||!t||(x.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height))},[b]),(0,U.useEffect)(()=>{r.current?.isAtBottom()&&r.current.pinToBottom()},[y]);let C=async(t,n)=>{a(!0);try{let i=I7(n.length),a=[];for(let e of n)a.push(await hae(e,i));e.onSend(t,a),r.current?.scrollToBottom()}finally{a(!1)}};return(0,K.jsx)(IN.Provider,{value:m,children:(0,K.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[u?.onBack||!e.drawerDocked?(0,K.jsx)(`button`,{type:`button`,onClick:u?.onBack??e.onOpenDrawer,"aria-label":u?.onBack?`返回群聊`:`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:u?.onBack?(0,K.jsx)(yt,{className:`h-4.5 w-4.5`}):(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}):(0,K.jsx)(`span`,{className:`h-9 w-9 shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,K.jsxs)(`p`,{className:`flex min-w-0 items-center justify-center gap-1.5`,children:[e.connState!==`host-offline`&&e.connState!==`unauthorized`&&(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,e.connState===`online`&&!e.syncing?`bg-emerald-500`:`animate-pulse bg-amber-500`),title:e.connState===`online`&&e.syncing?`同步中…`:e.stateLabel}),(0,K.jsx)(`span`,{className:`truncate font-medium text-sm`,children:e.title})]}),(0,K.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.projectName||e.stateLabel})]}),u?.readOnly?(0,K.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,K.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||d||!!u&&i||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Wn,{className:`h-4.5 w-4.5`})})]}),e.connState===`host-offline`&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-1.5 bg-amber-500/10 py-1 text-amber-700 text-xs dark:text-amber-400`,children:[(0,K.jsx)(sn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),(0,K.jsx)(`span`,{children:e.stateLabel})]}),e.tabGroup&&e.tabGroup.children.length>0&&(0,K.jsxs)(`div`,{ref:o,role:`tablist`,className:`t-tabs relative flex shrink-0 items-center justify-start gap-1 overflow-x-auto border-b px-2 py-1`,children:[(0,K.jsx)(`span`,{ref:s,"aria-hidden":`true`,className:`t-tabs-pill pointer-events-none absolute top-0 left-0 z-0 rounded-md bg-muted`}),(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e.tabGroup.parent.id,className:H7(n===e.tabGroup.parent.id),onClick:()=>e.onSelectTab?.(e.tabGroup?.parent.id??``),children:[(0,K.jsx)(un,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`max-w-40 truncate`,children:e.tabGroup.parent.title||`新对话`})]}),e.tabGroup.children.map(t=>(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t.id,className:H7(n===t.id),onClick:()=>e.onSelectTab?.(t.id),children:[(0,K.jsx)(ft,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`max-w-28 truncate`,children:t.title||`coworker`}),(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`?`animate-pulse bg-brand`:t.status===`failed`?`bg-destructive`:`bg-muted-foreground/30`)})]},t.id))]}),n===null?(0,K.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,K.jsx)(`span`,{className:`mb-3 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(RN,{className:`size-6`})}),(0,K.jsx)(`p`,{className:`font-semibold text-[22px] tracking-tight`,children:`EnsoCode`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.connState===`online`?`从左上角选择会话,或新建一个`:e.stateLabel})]}):(0,K.jsx)(pie,{ref:r,items:y,busy:t===null?!!e.syncing:l,loading:t===null,running:l,error:void 0,emptyTitle:e.projectName||`EnsoCode`,virtualize:!1,historyLoading:e.historyLoading,hasOlder:e.hasOlder,firstItemIndex:b??0,onStartReached:e.hasOlder?S:void 0},n),n!==null&&(0,K.jsx)(`div`,{className:`phone-dock @container flex min-h-0 flex-col pt-1 pb-safe`,children:(0,K.jsxs)(`div`,{className:G(`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,`flex min-h-0 flex-col`),children:[t?.retry&&(0,K.jsx)(bie,{retry:t.retry}),!d&&(0,K.jsx)(mP,{conversationId:n,queued:(e.queued??[]).map(e=>({id:e.id,text:e.text}))}),e.goal&&!d&&(0,K.jsx)(lP,{conversationId:n,goal:{...e.goal,noProgressRuns:0}}),(0,K.jsx)(h5,{conversationId:n},n),(0,K.jsx)(zie,{sessionId:n,tasks:t?.tasks??[],subagents:t?.subagents??[],readOnly:e.deviceReadOnly}),(0,K.jsxs)(`div`,{"data-enso":`composer-stack`,className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain`,children:[u?.outbox,u?.notice&&(0,K.jsx)(`p`,{className:`mb-1 rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:u.notice}),e.deviceReadOnly?(0,K.jsx)(`p`,{className:`mb-1 rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:B7(e.readOnlyRejected)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i_,{approvals:t?.approvals??[],onRespond:e.onApproval,clockOffset:e.clockOffset}),(0,K.jsx)(c_,{asks:t?.asks??[],onAnswer:e.onAsk,clockOffset:e.clockOffset,autoFocus:!1})]})]}),!d&&(0,K.jsx)(FN,{commands:h,running:l,busy:l,locked:e.newSessionBusy||!!u&&i||(t?.approvals??[]).length>0,focusKey:u?.chatId?`bot-chat:${u.chatId}`:n,autoFocus:!1,enterToSend:!1,toolbar:e.modelLabel&&e.onOpenConfig?(0,K.jsxs)(`button`,{type:`button`,onClick:e.onOpenConfig,className:`flex min-w-0 items-center gap-0.5 rounded-md px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.modelLabel}),(0,K.jsx)(_t,{className:`h-3 w-3 shrink-0`})]}):void 0,onSend:e=>{C(e.text,e.images)},onAbort:e.onAbort}),!d&&(0,K.jsx)(mae,{usageTotals:e.usageTotals,context:e.context})]})})]})})}function H7(e){return G(`t-tab flex min-w-0 shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors`,e?`font-medium`:`text-muted-foreground`)}async function hae(e,t){if(e.data.length*.75<=t)return e;let n=await(await fetch(`data:${e.mimeType};base64,${e.data}`)).blob();return L7(new File([n],`image`,{type:e.mimeType}),t)}function U7(e){if(e.kind===`ssh`)return e.sshConnectionName?.trim()||e.sshHost}function W7(e){return e.alias?.trim()||e.name}function G7(e){let t=W7(e),n=U7(e);return n?`${t} (${n})`:t}var K7=`enso-phone-drawer-segment`;function gae(){let e=localStorage.getItem(K7);return e===`bot`||e===`code`?e:null}function _ae(e){localStorage.setItem(K7,e)}function q7(e,t){if(!e)return!1;let n=gae();return n?n===`bot`:t!==null}function vae(e,t=0){let n=new Map;for(let r of e)if(!(r.seq<=t)&&((r.kind===`human`||r.newConversation)&&n.clear(),r.kind===`bot`&&r.botId&&n.delete(r.botId),r.failure&&n.set(r.failure.botId,r.id),r.retryOf))for(let[e,t]of n)t===r.retryOf&&n.delete(e);return new Set(n.values())}function yae(e,t){let n=RegExp(`#${t}(?!\\d)`).exec(e);if(!n)return;let r=n.index+n[0].length;return[e.slice(0,n.index),n[0],e.slice(r)]}function bae({status:e}){return e===`running`?(0,K.jsx)(sn,{className:`h-3 w-3 shrink-0 animate-spin text-brand`}):e===`done`?(0,K.jsx)(gt,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`denied`?(0,K.jsx)(Bn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`timeout`?(0,K.jsx)(jt,{className:`h-3 w-3 shrink-0 text-warning`}):(0,K.jsx)(ir,{className:`h-3 w-3 shrink-0 text-destructive`})}function xae({item:e,bots:t,clockOffset:n,onOpen:r}){let i=t.get(e.botId),a=e.ownerBotId?t.get(e.ownerBotId):void 0,o=e.state!==`queued`,[s,c]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(e)},[o]);let l=s-n,u=o&&r?()=>r(e.conversationId):void 0;return(0,K.jsxs)(`button`,{type:`button`,disabled:!u,onClick:u,className:`flex w-full gap-2 rounded-lg border bg-muted/30 px-2.5 py-2 text-left disabled:cursor-default`,children:[(0,K.jsx)(Io,{bot:i,size:`sm`,busy:o}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,K.jsxs)(`span`,{className:`truncate font-medium`,children:[i?.name??`成员`,a?(0,K.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` 替 `,a.name]}):null]}),(0,K.jsx)(`span`,{className:G(`shrink-0`,o?`text-brand`:`text-muted-foreground`),children:ss(e)}),o&&e.startedAt!==void 0&&(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:us(l-e.startedAt)}),u&&(0,K.jsx)(vt,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),e.more>0&&(0,K.jsxs)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:[`+`,e.more,` 个更早的步骤`]}),e.steps.map((e,t)=>(0,K.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-[11px]`,children:[(0,K.jsx)(bae,{status:e.status}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:e.detail}),e.status===`timeout`&&(0,K.jsx)(`span`,{className:`shrink-0 text-warning`,children:e.name===`ask_user`?`已超时未回答`:`已超时拒绝`}),(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:e.durationMs===void 0?e.startedAt===void 0?``:us(l-e.startedAt):us(e.durationMs)})]},t))]})]})}var J7=e=>[...e].sort((e,t)=>t.activityAt-e.activityAt);function Sae(e,t,n=10){let r=J7(e),i=e=>e.id===t.currentId||e.id===t.rootId?0:e.unread||e.running?1:2,a=new Set([...r].sort((e,t)=>i(e)-i(t)).slice(0,n).map(e=>e.id));return r.filter(e=>a.has(e.id)).sort((e,n)=>Number(n.id===t.rootId)-Number(e.id===t.rootId))}function Cae(e,t,n){let r=t.trim().toLowerCase();return J7(e).filter(e=>(n===`all`||(n===`unread`?e.unread:e.running))&&(!r||`${e.title}\n${e.preview??``}`.toLowerCase().includes(r)))}var Y7=MT,wae=wT;function Tae({className:e,...t}){return(0,K.jsx)(ny,{className:G(`fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-150 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`sheet-backdrop`,...t})}function Eae({className:e,side:t,inset:n=!1,...r}){return(0,K.jsx)(NT,{className:G(`fixed inset-0 z-50 grid`,t===`bottom`&&`grid grid-rows-[1fr_auto] pt-12`,t===`top`&&`grid grid-rows-[auto_1fr] pb-12`,t===`left`&&`flex justify-start`,t===`right`&&`flex justify-end`,n&&`sm:p-4`),"data-slot":`sheet-viewport`,...r})}function X7({className:e,children:t,showCloseButton:n=!0,side:r=`right`,inset:i=!1,...a}){return(0,K.jsxs)(wae,{children:[(0,K.jsx)(OE,{}),(0,K.jsx)(Tae,{}),(0,K.jsx)(Eae,{inset:i,side:r,children:(0,K.jsxs)(xT,{className:G(`relative flex max-h-full min-h-0 w-full min-w-0 flex-col bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[opacity,translate] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:before:hidden dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,r===`bottom`&&`row-start-2 border-t data-ending-style:translate-y-8 data-starting-style:translate-y-8`,r===`top`&&`data-ending-style:-translate-y-8 data-starting-style:-translate-y-8 border-b`,r===`left`&&`data-ending-style:-translate-x-8 data-starting-style:-translate-x-8 w-[calc(100%-(--spacing(12)))] max-w-md border-e`,r===`right`&&`col-start-2 w-[calc(100%-(--spacing(12)))] max-w-md border-s data-ending-style:translate-x-8 data-starting-style:translate-x-8`,i&&`before:hidden sm:rounded-2xl sm:border sm:before:rounded-[calc(var(--radius-2xl)-1px)] sm:**:data-[slot=sheet-footer]:rounded-b-[calc(var(--radius-2xl)-1px)]`,e),"data-slot":`sheet-popup`,...a,children:[t,n&&(0,K.jsx)(qy,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,K.jsx)(Oa,{size:`icon`,variant:`ghost`}),children:(0,K.jsx)(ir,{})})]})})]})}function Z7({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex flex-col gap-2 p-6 in-[[data-slot=sheet-popup]:has([data-slot=sheet-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`sheet-header`,...t})}function Q7({className:e,...t}){return(0,K.jsx)(PT,{className:G(`font-heading text-xl leading-none`,e),"data-slot":`sheet-title`,...t})}function $7(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e-n,a=Math.abs(i);return a<6e4?r.format(0,`second`):a<36e5?r.format(Math.trunc(i/6e4),`minute`):a<864e5?r.format(Math.trunc(i/36e5),`hour`):a<2592e6?r.format(Math.trunc(i/864e5),`day`):a<31536e6?r.format(Math.trunc(i/2592e6),`month`):r.format(Math.trunc(i/31536e6),`year`)}function e9({entry:e}){return(0,K.jsxs)(K.Fragment,{children:[e.running&&(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-warning`}),(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:$7(e.activityAt,`zh`)})]})}function Dae({threads:e,status:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(``),{entries:o,currentId:s,rootId:c,disabledHint:l}=e,u=o.find(e=>e.id===s),d=Sae(o,{currentId:s,rootId:c}),f=o.length-d.length,p=Cae(o,i,`all`),m=t=>{!l&&t!==s&&e.onSelect(t)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(UM,{children:[(0,K.jsxs)(GM,{"aria-label":`切换话题`,className:`mx-auto flex max-w-full items-center justify-center gap-0.5 text-[11px] text-muted-foreground`,children:[(0,K.jsxs)(`span`,{className:`truncate`,children:[u?.title??`主话题`,t&&` · ${t}`]}),(0,K.jsx)(_t,{className:`h-3 w-3 shrink-0`})]}),(0,K.jsxs)(KM,{className:`w-72 max-w-[calc(100vw-1rem)]`,children:[(0,K.jsxs)(JM,{children:[(0,K.jsx)(XM,{children:`话题`}),d.map(e=>(0,K.jsxs)(YM,{disabled:!!l&&e.id!==s,onClick:()=>m(e.id),children:[(0,K.jsx)(gt,{className:G(e.id!==s&&`invisible`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,K.jsx)(e9,{entry:e})]},e.id))]}),(0,K.jsx)(ZM,{}),f>0&&(0,K.jsxs)(YM,{onClick:()=>{a(``),r(!0)},children:[(0,K.jsx)(on,{}),`全部话题(`,o.length,`)`]}),(0,K.jsxs)(YM,{disabled:!!l,onClick:e.onCreate,children:[(0,K.jsx)(dn,{}),`新话题`]}),l&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-muted-foreground text-xs`,children:l})]})]}),(0,K.jsx)(Y7,{open:n,onOpenChange:r,children:(0,K.jsxs)(X7,{side:`bottom`,className:`max-h-[80vh] pb-safe`,children:[(0,K.jsx)(Z7,{children:(0,K.jsxs)(Q7,{children:[`全部话题(`,o.length,`)`]})}),(0,K.jsx)(`div`,{className:`px-4 pb-2`,children:(0,K.jsx)(rG,{value:i,placeholder:`搜索话题…`,onChange:e=>a(e.target.value)})}),l&&(0,K.jsx)(`p`,{className:`px-4 pb-2 text-muted-foreground text-xs`,children:l}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3`,children:[p.map(e=>(0,K.jsxs)(`button`,{type:`button`,disabled:!!l&&e.id!==s,onClick:()=>{m(e.id),r(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-accent disabled:opacity-60`,children:[(0,K.jsx)(gt,{className:G(`h-4 w-4 shrink-0`,e.id!==s&&`invisible`)}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-sm`,children:e.title}),e.preview&&(0,K.jsx)(`span`,{className:`block truncate text-muted-foreground text-xs`,children:e.preview})]}),(0,K.jsx)(e9,{entry:e})]},e.id)),p.length===0&&(0,K.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`没有匹配的话题`})]})]})})]})}var Oae={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,canceled:`已取消`,blocked:`卡住了`},t9=4,kae=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),Aae={started:{icon:Tt,className:`border-brand/50 text-brand`},blocked:{icon:St,className:`border-warning/60 text-warning`},delivered:{icon:Ct,className:`border-success/60 text-success`}};function jae({entry:e,bots:t}){let n=!!e.taskId,[r,i]=(0,U.useState)(!n),a=(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsx)(vt,{"aria-hidden":!0,className:G(`h-3 w-3 shrink-0 transition-transform`,r&&`rotate-90`)}),(0,K.jsxs)(`span`,{className:`font-medium`,children:[t.get(e.from)?.name??`成员`,` → `,t.get(e.to)?.name??`成员`]}),(0,K.jsx)(`span`,{className:G(`rounded px-1.5 py-0.5`,e.state===`running`||e.state===`queued`?`bg-brand/10 text-brand`:e.state===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`),children:Oae[e.state]})]});return(0,K.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2 text-xs`,children:[n?(0,K.jsx)(`button`,{type:`button`,"aria-expanded":r,"aria-label":r?`收起委派结果`:`展开委派结果`,className:`flex w-full items-center gap-1.5 text-left`,onClick:()=>i(e=>!e),children:a}):(0,K.jsx)(`p`,{className:`flex items-center gap-1.5`,children:a}),r&&e.summary&&(0,K.jsx)(`p`,{className:`mt-1 line-clamp-3 text-muted-foreground`,children:e.summary})]})}function n9(e,t){let n=[...t].sort((e,t)=>t.length-e.length),r=[],i=e,a=0;for(;i;){let e=i.indexOf(`@`),t=e<0?void 0:n.find(t=>i.startsWith(t,e+1));if(e<0||!t){r.push(i);break}e>0&&r.push(i.slice(0,e)),r.push((0,K.jsxs)(`span`,{className:`font-medium text-brand`,children:[`@`,t]},a++)),i=i.slice(e+1+t.length)}return r}function Mae(e){let{chat:t,bots:n,timeline:r,state:i}=e,a=(0,U.useRef)(null),o=(0,U.useRef)(null),s=(0,U.useRef)(null),c=(0,U.useRef)(!0),l=(0,U.useRef)(null),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(0),[m,h]=(0,U.useState)([]),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),b=r?.entries??[],x=t.epochSeq??b.findLast(e=>e.kind===`system`&&e.newConversation)?.seq??0,[S,C]=(0,U.useState)(!1);(0,U.useEffect)(()=>C(!1),[t.id,x]);let w=x>0&&!S,T=Xo(b,x,S),E=vae(b,x),D=t.members.map(e=>n.get(e)).filter(e=>!!(e&&!e.archived)),O=D.map(e=>e.name),k=!!i?.current||t.status!==`idle`,A=$o(u,f),j=A?ts(A.query,D):[],M=T[0]?.seq,N=T.at(-1)?.seq;(0,U.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=s.current;t?(s.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height)):c.current&&(e.scrollTop=e.scrollHeight)},[M,N,i?.current,e.activities.length]);let P=()=>{let t=a.current;!r?.hasOlder||!t||e.historyLoading||e.connState!==`online`||w&&(b[0]?.seq??x)<=x||(s.current={height:t.scrollHeight,top:t.scrollTop},e.onLoadOlder())},F=e=>{if(!A)return;let t=ns(u,A,f,e.name);d(t.text),p(t.caret),requestAnimationFrame(()=>{o.current?.focus(),o.current?.setSelectionRange(t.caret,t.caret)})},I=(0,U.useRef)(m);I.current=m,(0,U.useEffect)(()=>()=>{for(let e of I.current)URL.revokeObjectURL(e.url)},[]);let L=e=>{let t=[...e??[]].filter(e=>e.type.startsWith(`image/`)).slice(0,t9-m.length).map(e=>({file:e,url:URL.createObjectURL(e)}));h(e=>[...e,...t]),y(null)},R=e=>{URL.revokeObjectURL(e),h(t=>t.filter(t=>t.url!==e))},ee=async()=>{if(!u.trim()&&m.length===0||g||e.newSessionBusy)return;let t=[];if(m.length){_(!0);try{t=await tae(m.map(e=>e.file))}catch(e){y(e instanceof Error?e.message:`图片处理失败`);return}finally{_(!1)}}e.onSend(u,t);for(let e of m)URL.revokeObjectURL(e.url);h([]),y(null),d(``),p(0),c.current=!0},z=t=>{switch(t.kind){case`human`:return(0,K.jsxs)(`div`,{className:`flex flex-col items-end`,children:[t.text&&(0,K.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-brand/10 px-3 py-2 text-sm`,children:[n9(t.text,O),t.truncated&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),t.images?.length?(0,K.jsx)(Xa,{target:{chatId:e.chat.id,entryId:t.id}}):null]},t.seq);case`bot`:{let r=n.get(t.botId);return(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Io,{bot:r,size:`sm`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex items-baseline gap-1.5 text-xs`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:r?.name??`成员`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:kae(t.at)})]}),(0,K.jsxs)(`div`,{className:`mt-0.5 min-w-0 text-sm`,children:[(0,K.jsx)(D3,{text:t.text}),t.truncated&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),(0,K.jsx)(Xa,{target:{chatId:e.chat.id,entryId:t.id}}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>e.onOpenProcess(t.conversationId),className:`mt-0.5 flex items-center gap-0.5 text-muted-foreground text-xs hover:text-foreground`,children:[(0,K.jsx)(vt,{className:`h-3 w-3`}),`查看过程`]})]})]},t.seq)}case`delegation`:return(0,K.jsx)(jae,{entry:t,bots:n},t.seq);case`progress`:{let e=n.get(t.botId),r=Aae[t.phase],i=r.icon,a=yae(t.text,t.taskSeq);return(0,K.jsxs)(`div`,{"data-phase":t.phase,className:`flex gap-2 text-xs`,children:[(0,K.jsx)(Io,{bot:e,size:`sm`}),(0,K.jsxs)(`div`,{className:G(`flex min-w-0 items-start gap-1.5 rounded-md border-l-2 bg-muted/50 px-2 py-1`,r.className),children:[(0,K.jsx)(i,{"aria-hidden":!0,className:`mt-px h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`p`,{className:`line-clamp-2 min-w-0 break-words text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.name??`成员`}),` `,a?(0,K.jsxs)(K.Fragment,{children:[n9(a[0],O),(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:a[1]}),n9(a[2],O)]}):n9(t.text,O)]})]})]},t.seq)}case`system`:return(0,K.jsxs)(`p`,{className:`text-center text-muted-foreground text-xs`,children:[t.text,E.has(t.id)&&e.onRetry&&!e.deviceReadOnly&&(0,K.jsx)(`button`,{type:`button`,className:`ml-2 underline disabled:opacity-50`,disabled:k||e.connState!==`online`,onClick:()=>e.onRetry?.(t.id),children:`重试`})]},t.seq)}},B=i?.current?n.get(i.current):void 0;return(0,K.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[e.drawerDocked?(0,K.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,K.jsx)(`button`,{type:`button`,onClick:e.onOpenDrawer,"aria-label":`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,K.jsx)(`p`,{className:`truncate font-medium text-sm`,children:t.title||`群聊`}),e.threads?(0,K.jsx)(Dae,{threads:e.threads,status:e.connState===`online`?void 0:e.stateLabel}):(0,K.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:e.connState===`online`?`${t.members.length} 位成员`:e.stateLabel})]}),e.threads?(0,K.jsx)(`button`,{type:`button`,onClick:e.threads.onCreate,disabled:!!e.threads.disabledHint,"aria-label":`新话题`,title:e.threads.disabledHint??`新话题`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Wn,{className:`h-4.5 w-4.5`})}):(0,K.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||e.deviceReadOnly||g||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Wn,{className:`h-4.5 w-4.5`})})]}),(0,K.jsxs)(`div`,{ref:a,onScroll:e=>{let t=e.currentTarget;c.current=t.scrollHeight-t.scrollTop-t.clientHeight<40,t.scrollTop<60&&P()},className:`min-h-24 flex-1 space-y-3 overflow-y-auto px-3 py-3`,children:[r===void 0?(0,K.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 py-8 text-muted-foreground text-sm`,children:[(0,K.jsx)(sn,{className:`h-4 w-4 animate-spin`}),`读取中…`]}):r.hasOlder&&(!w||(b[0]?.seq??x)>x)?(0,K.jsx)(`button`,{type:`button`,onClick:P,disabled:e.historyLoading||e.connState!==`online`,className:`w-full py-1 text-center text-muted-foreground text-xs`,children:e.historyLoading?`加载中…`:`加载更早的消息`}):T.length===0?(0,K.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`@ 成员开始对话,未 @ 时由群主回复`}):null,x>0&&(0,K.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-muted-foreground text-xs`,onClick:()=>{C(!S),S&&r?.history?e.onJumpLatest?.():!S&&r?.hasOlder&&!b.some(e=>e.seq<x)&&e.onLoadOlder()},children:w?`更早的对话 · ${x-1} 条`:`收起更早的对话`}),r?.history&&(0,K.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-brand text-xs`,onClick:()=>{c.current=!0,e.onJumpLatest?.()},children:`回到最新消息`}),T.map(z),e.activities.map(t=>(0,K.jsx)(xae,{item:t,bots:n,clockOffset:e.clockOffset,onOpen:e.onOpenProcess},t.conversationId)),B&&e.activities.length===0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Io,{bot:B,size:`sm`,busy:!0}),(0,K.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[B.name,` 正在回复…`]})]})]}),(0,K.jsxs)(`div`,{className:`phone-dock flex min-h-0 flex-col gap-2 px-3 pt-1 pb-safe`,children:[(0,K.jsxs)(`div`,{"data-enso":`composer-stack`,className:`flex min-h-0 flex-col gap-2 overflow-y-auto overscroll-contain empty:hidden`,children:[e.outbox,e.notice&&(0,K.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:e.notice}),e.deviceReadOnly&&(0,K.jsx)(`p`,{className:`rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:B7(e.readOnlyRejected)}),!e.deviceReadOnly&&e.pending.map(({sessionId:t,botId:r,view:i})=>i.approvals.length>0||i.asks.length>0?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n.get(r)?.name??`成员`}),(0,K.jsx)(i_,{approvals:i.approvals,clockOffset:e.clockOffset,onRespond:(n,r)=>e.onApproval(t,n,r)}),(0,K.jsx)(c_,{asks:i.asks,clockOffset:e.clockOffset,onAnswer:(n,r)=>e.onAsk(t,n,r),autoFocus:!1})]},t):null)]}),(0,K.jsxs)(`div`,{className:G(`relative`,e.deviceReadOnly&&`hidden`),children:[j.length>0&&(0,K.jsx)(`div`,{className:`absolute right-0 bottom-full left-0 mb-1 max-h-48 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:j.map(e=>{let t=n.get(e.id);return(0,K.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>F(e),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent`,children:[t?(0,K.jsx)(Io,{bot:t,size:`sm`}):(0,K.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-muted text-xs`,children:`@`}),(0,K.jsx)(`span`,{className:`font-medium`,children:e.name}),t?.title&&(0,K.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:t.title})]},e.id)})}),v&&(0,K.jsx)(`p`,{className:`mb-1 text-destructive text-xs`,children:v}),m.length>0&&(0,K.jsx)(`div`,{className:`mb-1.5 flex gap-1.5`,children:m.map(e=>(0,K.jsxs)(`div`,{className:`relative h-14 w-14 overflow-hidden rounded-lg border`,children:[(0,K.jsx)(`img`,{src:e.url,alt:``,className:`h-full w-full object-cover`}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`移除图片`,onClick:()=>R(e.url),className:`absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-black/60 text-white`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]},e.url))}),(0,K.jsxs)(`div`,{className:`flex items-end gap-2 rounded-2xl border bg-background px-3 py-2`,children:[(0,K.jsx)(`input`,{ref:l,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,onChange:e=>{L(e.target.files),e.target.value=``}}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`添加图片`,disabled:m.length>=t9,onClick:()=>l.current?.click(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground disabled:opacity-40`,children:(0,K.jsx)($t,{className:`h-4.5 w-4.5`})}),(0,K.jsx)(`textarea`,{ref:o,rows:1,value:u,placeholder:`@ 成员,或直接说…`,onChange:e=>{d(e.target.value),p(e.target.selectionStart??e.target.value.length)},onSelect:e=>p(e.currentTarget.selectionStart??0),className:`max-h-32 min-h-6 flex-1 resize-none bg-transparent text-sm outline-none field-sizing-content`}),k&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`停止`,onClick:e.onStop,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-foreground`,children:(0,K.jsx)(Jn,{className:`h-3.5 w-3.5 fill-current`})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`发送`,disabled:!u.trim()&&m.length===0||g||e.newSessionBusy||!e.outbox&&e.connState!==`online`,onClick:()=>void ee(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-brand text-brand-foreground disabled:opacity-40`,children:(0,K.jsx)(ct,{className:`h-4 w-4`})})]})]})]})]})}var r9=e=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches;function Nae(e){return(0,U.useSyncExternalStore)(t=>{if(typeof window.matchMedia!=`function`)return()=>{};let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>r9(e),()=>r9(e))}var Pae=`(min-width: 900px)`;function Fae(e){let t=U.useRef(!0);t.current&&(t.current=!1,e())}var i9=U.createContext(null);function a9(){let e=U.useContext(i9);if(e===null)throw Error(Cr(60));return e}var Iae=(e,t)=>Object.is(e,t);function o9(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function s9(e,t,n){return!e||e.length===0?-1:e.findIndex(e=>e!==void 0&&o9(e,t,n))}function Lae(e,t,n){return e.filter(e=>!o9(t,e,n))}function c9(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function l9(e){return e!=null&&e.length>0&&typeof e[0]==`object`&&e[0]!=null&&`items`in e[0]}function Rae(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(l9(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function u9(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return c9(e)}function d9(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?c9(e.value):c9(e)}function f9(e,t,n){function r(){return u9(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){let n=t,i=l9(n)?n.flatMap(e=>e.items):n;if(typeof e!=`object`||!e){let t=i.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=i.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function zae(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,K.jsx)(U.Fragment,{children:f9(r,t,n)},i)),e),[])}var p9={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:d9(t,r)!==``},hasNullItemLabel:(e,t)=>t?Rae(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>o9(t,e,n)):o9(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function Bae(e,t,n=(e,t)=>e===t){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}function Vae(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=Iae,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=dN(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=cN(),F=_N({id:t}),I=M||d,L=j??c,[R,ee]=Mj({controlled:n,default:y?r??Ir:r,name:`Select`,state:`value`}),[z,B]=Mj({controlled:a,default:o,name:`Select`,state:`open`}),V=U.useRef([]),te=U.useRef([]),H=U.useRef(null),ne=U.useRef(null),re=U.useRef(0),ie=U.useRef(null),ae=U.useRef([]),oe=U.useRef(!1),se=U.useRef(null),ce=U.useRef(null),le=U.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ue=U.useRef(!1),{mounted:de,setMounted:fe,transitionStatus:pe}=Ow(z),{openMethod:me,triggerProps:he}=LT(z),ge=Tr(()=>new Tw({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:de,transitionStatus:pe,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,_e=xw(ge,p9.activeIndex),ve=xw(ge,p9.selectedIndex),ye=xw(ge,p9.triggerElement),be=xw(ge,p9.positionerElement),xe=EM(me),Se=me??xe,Ce=U.useMemo(()=>y?``:d9(R,x),[y,R,x]),we=U.useMemo(()=>y&&Array.isArray(R)?R.map(e=>d9(e,x)):d9(R,x),[y,R,x]);lN(Ib(ye),F,R,Ay(()=>we),!I,c);let Te=U.useRef(R),Ee=y?Array.isArray(R)&&R.length>0:R!=null&&Ce!==``;X(()=>{A(Ee)},[Ee,A]),X(function(){let e=R,t=!1;if(y){let n=Array.isArray(R)?R:[];t=n.length===0,e=n[n.length-1]}let n=t?-1:s9(ae.current,e,S),r=n===-1?null:n;r===null&&(ce.current=null),!z&&ge.set(`selectedIndex`,r)},[y,z,R,S,ge]);function De(e){let t=k.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Bae(e,t,(e,t)=>o9(e,t,S)):e!==t}FT(R,()=>{T(L),E(De(R)),N.change(R)});let Oe=Ay((e,t)=>{s?.(e,t),!t.isCanceled&&(B(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),ke=Ay(()=>{fe(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});Aw({enabled:!h,open:z,ref:H,onComplete(){z||ke()}}),U.useImperativeHandle(h,()=>({unmount:ke}),[ke]);let Ae=Ay((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),je=Ay(e=>{let t=iE(e.scrollHeight,e.clientHeight),n=aE(e.scrollTop,t),r=n>0,i=n<t;ge.set(`scrollUpArrowVisible`,r),ge.set(`scrollDownArrowVisible`,i)}),Me=Dte({open:z,onOpenChange:Oe,elements:{reference:ye,floating:be}}),Ne=US(Me,{enabled:!f&&!I,event:`mousedown`}),Pe=KS(Me),Fe=lT(Me,{enabled:!f&&!I,listRef:V,activeIndex:_e,selectedIndex:ve,disabledIndices:Ir,onNavigate(e){e===null&&!z||ge.set(`activeIndex`,e)},focusItemOnHover:C}),Ie=uT(Me,{enabled:!f&&!I&&(z||!y),listRef:te,activeIndex:_e,selectedIndex:ve,disabledIndices:e=>HM(V.current[e]),onMatch(e){z?ge.set(`activeIndex`,e):Ae(ae.current[e],Ky(Iy))},onTyping(e){oe.current=e}}),Le=U.useMemo(()=>cr(Ie.reference,Fe.reference,Pe.reference,Ne.reference,he),[Ne.reference,Ie.reference,Fe.reference,Pe.reference,he]),Re=U.useMemo(()=>cr(jw,Ie.floating,Fe.floating,Pe.floating),[Ie.floating,Fe.floating,Pe.floating]),ze=Fe.item??Lr;Fae(()=>{ge.update({popupProps:Re,triggerProps:Le})}),ge.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:z,mounted:de,transitionStatus:pe,popupProps:Re,triggerProps:Le,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Se});let Be=U.useMemo(()=>({store:ge,floatingContext:Me,required:p,disabled:I,readOnly:f,multiple:y,highlightItemOnHover:C,setValue:Ae,setOpen:Oe,listRef:V,popupRef:H,scrollHandlerRef:ne,handleScrollArrowVisibility:je,scrollArrowsMountedCountRef:re,itemProps:ze,valueRef:ie,valuesRef:ae,labelsRef:te,typingRef:oe,selectionRef:le,firstItemTextRef:se,selectedItemTextRef:ce,validation:N,onOpenChangeComplete:_,alignItemWithTriggerActiveRef:ue,initialValueRef:Te}),[ge,Me,p,I,f,y,C,Ae,Oe,ze,N,_,je]),Ve=Er(g,N.inputRef),He=y?void 0:L,Ue=U.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=d9(e,x);return(0,K.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,K.jsxs)(i9.Provider,{value:Be,children:[w,(0,K.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Ky(Iy,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ae.current.findIndex(t=>d9(t,x).toLowerCase()===e||u9(t,b).toLowerCase()===e);r===-1&&(r=ae.current.findIndex((t,n)=>{let r=te.current[n];return r!=null&&r.toLowerCase()===e}));let i=ae.current[r];i!=null&&Ae(i,n)}ge.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&He==null?`${F}-hidden-input`:void 0,form:l,name:He,autoComplete:u,value:Ce,disabled:I,required:p&&!(y&&Ee),readOnly:f,ref:Ve,style:L?Wb:Ub,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ue]})}function Hae(e,t){return e??t}var Uae=400,Wae={...$v,...iN,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},Gae=U.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,state:f,disabled:p}=cN(),{labelId:m}=pN(),{store:h,setOpen:g,selectionRef:_,validation:v,readOnly:y,required:b,alignItemWithTriggerActiveRef:x,disabled:S}=a9(),C=p||S||a,w=xw(h,p9.open),T=xw(h,p9.mounted),E=xw(h,p9.value),D=xw(h,p9.triggerProps),O=xw(h,p9.positionerElement),k=xw(h,p9.listElement),A=xw(h,p9.popupSide),j=xw(h,p9.id),M=xw(h,p9.labelId),N=xw(h,p9.hasSelectedValue),P=T&&O?A:null,F=i??j,I=Hae(m,M);_N({id:F});let L=Ib(O),R=U.useRef(null),{getButtonProps:ee,buttonRef:z}=Py({disabled:C,native:o}),B=h.useStateSetter(`triggerElement`),V=nb(),te=nb(),H=nb();U.useEffect(()=>{if(w)return H.start(Uae,()=>{_.current.allowUnselectedMouseUp=!0,_.current.allowSelectedMouseUp=!0}),()=>{H.clear()};_.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},te.clear()},[w,_,te,H]);let ne=cr(D,{id:F,role:`combobox`,"aria-expanded":w,"aria-haspopup":`listbox`,"aria-controls":w?k?.id??Ob(O)?.id:void 0,"aria-labelledby":I,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:C?-1:0,onFocus(e){u(!0),w&&x.current&&g(!1,Ky(Iy,e.nativeEvent)),V.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){yb(O,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&v.commit(E))},onMouseDown(e){if(w)return;let t=My(e.currentTarget);function n(e){if(!R.current)return;let t=e.target;yb(R.current,t)||yb(L.current,t)||gM(e,R.current)||g(!1,Ky(Uy,e))}te.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,ee),re=v.getValidationProps(C,ne);re.role=`combobox`;let ie={...f,open:w,disabled:C,value:E,readOnly:y,popupSide:P,placeholder:!N};return Vr(`button`,e,{ref:[t,R,z,B],state:ie,stateAttributesMapping:Wae,props:re})}),Kae={value:()=>null},qae=U.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,{store:c,valueRef:l}=a9(),u=xw(c,p9.value),d=xw(c,p9.items),f=xw(c,p9.itemToStringLabel),p=xw(c,p9.hasSelectedValue),m=!p&&a!=null&&i==null,h=xw(c,p9.hasNullItemLabel,m),g={value:u,placeholder:!p},_=null;return _=typeof i==`function`?i(u):i??(m&&!h?a:Array.isArray(u)?zae(u,d,f):f9(u,d,f)),Vr(`span`,e,{state:g,ref:[t,l],props:[{children:_},s],stateAttributesMapping:Kae})}),Jae=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=a9();return Vr(`span`,e,{state:{open:xw(o,p9.open)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Qv})}),Yae=U.forwardRef(function(e,t){let{store:n}=a9(),r=xw(n,p9.mounted),i=xw(n,p9.forceMount);return r||i?(0,K.jsx)(CS,{ref:t,...e}):null}),m9=U.createContext(void 0);function h9(){let e=U.useContext(m9);if(!e)throw Error(Cr(59));return e}function g9(e,t){e&&Object.assign(e.style,t)}var _9={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},Xae={position:`fixed`},Zae=U.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=gS,style:_,...v}=e,{store:y,listRef:b,labelsRef:x,alignItemWithTriggerActiveRef:S,selectedItemTextRef:C,valuesRef:w,initialValueRef:T,popupRef:E,setValue:D,floatingContext:O}=a9(),k=xw(y,p9.open),A=xw(y,p9.mounted),j=xw(y,p9.modal),M=xw(y,p9.value),N=xw(y,p9.openMethod),P=xw(y,p9.positionerElement),F=xw(y,p9.triggerElement),I=xw(y,p9.isItemEqualToValue),L=xw(y,p9.transitionStatus),R=U.useRef(null),ee=U.useRef(null),[z,B]=U.useState(h),V=A&&z&&N!==`touch`;!A&&z!==h&&B(h),U.useImperativeHandle(S,()=>V),iM((V||j)&&k,N===`touch`,P,F);let te=lD({anchor:n,floatingRootContext:O,positionMethod:a,mounted:A,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??V,collisionAvoidance:g,keepMounted:!0}),H=V?`none`:te.side,ne=V?Xae:te.positionerStyles,re={open:k,side:H,align:te.align,anchorHidden:te.anchorHidden};X(()=>{y.set(`popupSide`,te.side)},[y,te.side]);let ie=pD(e,re,{styles:ne,transitionStatus:L,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!A,inert:!k}),ae=U.useRef(0),oe=Ay(e=>{if(w.current.length===0)return;let t=ae.current;if(ae.current=e.size,e.size===t)return;let n=Ky(Iy);if(t!==0&&!y.state.multiple&&M!==null&&s9(w.current,M,I)===-1){let e=T.current,t=e!=null&&s9(w.current,e,I)!==-1?e:null;D(t,n),t===null&&(y.set(`selectedIndex`,null),C.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(M)){let e=M.filter(e=>s9(w.current,e,I)!==-1);e.length!==M.length&&(D(e,n),e.length===0&&(y.set(`selectedIndex`,null),C.current=null))}if(k&&V){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};g9(P,e),g9(E.current,e)}}),se=U.useMemo(()=>({...te,side:H,alignItemWithTriggerActive:V,setControlledAlignItemWithTrigger:B,scrollUpArrowRef:R,scrollDownArrowRef:ee}),[te,H,V,B]);return(0,K.jsx)(Xj,{elementsRef:b,labelsRef:x,onMapChange:oe,children:(0,K.jsxs)(m9.Provider,{value:se,children:[A&&j&&(0,K.jsx)(CT,{inert:ST(!k),cutout:F}),ie]})})}),Qae={...ey,...Kv},$ae=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s,popupRef:c,onOpenChangeComplete:l,setOpen:u,valueRef:d,firstItemTextRef:f,selectedItemTextRef:p,multiple:m,handleScrollArrowVisibility:h,scrollHandlerRef:g,listRef:_,highlightItemOnHover:v,floatingContext:y}=a9(),{side:b,align:x,alignItemWithTriggerActive:S,isPositioned:C,setControlledAlignItemWithTrigger:w}=h9(),T=Gj(!0)!=null,E=nE(),{nonce:D,disableStyleElements:O}=qT(),k=xw(s,p9.id),A=xw(s,p9.open),j=xw(s,p9.openMethod),M=xw(s,p9.mounted),N=xw(s,p9.popupProps),P=xw(s,p9.transitionStatus),F=xw(s,p9.triggerElement),I=xw(s,p9.positionerElement),L=xw(s,p9.listElement),R=U.useRef(!1),ee=U.useRef(!1),z=U.useRef({}),B=Vb(),V=Ay(e=>{if(!I||!c.current||!ee.current)return;let t=I.style.top===`0px`,n=I.style.bottom===`0px`;if(R.current||!S||!t&&!n){h(e);return}let r=b9(I),i=x9(I.getBoundingClientRect().height,`y`,r),a=My(I),o=ay(I),s=o.getComputedStyle(I),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=v9(o.getComputedStyle(c.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=y9(e),g=null,_=e=>{I.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=rE(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(R.current=!0),h(e);return}f-y>1?g=t?1/0:0:n&&p<m&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=rE(g,0,y9(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(R.current=!0),h(e)});U.useImperativeHandle(g,()=>V,[V]),Aw({open:A,ref:c,onComplete(){A&&l?.(!0)}});let te={open:A,transitionStatus:P,side:b,align:x};X(()=>{!I||!c.current||Object.keys(z.current).length||(z.current={top:I.style.top||`0`,left:I.style.left||`0`,right:I.style.right,height:I.style.height,bottom:I.style.bottom,minHeight:I.style.minHeight,maxHeight:I.style.maxHeight,marginTop:I.style.marginTop,marginBottom:I.style.marginBottom})},[c,I]),X(()=>{A||S||(ee.current=!1,R.current=!1,g9(I,z.current))},[A,S,I,c]),X(()=>{let e=c.current;if(!A||!F||!I||!e||S&&!C||s.state.transitionStatus===`ending`)return;if(ee.current=!0,e.style.removeProperty(`--transform-origin`),!S){B.request(()=>h(L||e));return}let t=eoe(e);try{let t=p.current;t?.isConnected||(t=!p9.hasSelectedValue(s.state)&&f.current?.isConnected?f.current:null);let n=d.current,r=ay(I),i=r.getComputedStyle(I),a=r.getComputedStyle(e),o=My(F),c=b9(F),l=S9(F.getBoundingClientRect(),c),u=S9(I.getBoundingClientRect(),c),m=l.height,g=L||e,y=g.scrollHeight,b=parseFloat(a.borderBottomWidth),x=parseFloat(i.marginTop)||10,S=parseFloat(i.marginBottom)||10,C=parseFloat(i.minHeight)||100,T=v9(a),D=o.documentElement.clientHeight-x-S,O=o.documentElement.clientWidth,k=D-l.bottom+m,A,j=E===`rtl`?l.right-u.width:l.left,M=0;if(t&&n){let e=S9(n.getBoundingClientRect(),c);A=S9(t.getBoundingClientRect(),c),j=u.left+(E===`rtl`?e.right-A.right:e.left-A.left);let r=e.top-l.top+e.height/2;M=A.top-u.top+A.height/2-r}let N=k+M+S+b,P=Math.min(D,N),ee=D-x-S,B=N-P,V=O-5;I.style.left=`${rE(j,5,V-u.width)}px`,I.style.height=`${P}px`,I.style.maxHeight=`none`,I.style.marginTop=`${x}px`,I.style.marginBottom=`${S}px`,e.style.height=`100%`;let te=y9(g),H=B>=te-1;H&&(P=Math.min(D,u.height)-(B-te));let ne=l.top<20||l.bottom>D-20||Math.ceil(P)+1<Math.min(y,C),re=(r.visualViewport?.scale??1)!==1&&lb;if(ne||re){g9(I,z.current),w(!1);return}let ie=Math.max(C,P);if(H){let e=Math.max(0,D-N);I.style.top=u.height>=ee?`0`:`${e}px`,I.style.height=`${P}px`,g.scrollTop=y9(g)}else I.style.bottom=`0`,g.scrollTop=B;if(A){let t=u.top,n=u.height,r=A.top+A.height/2,i=rE(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(ie===D||P>=T)&&(R.current=!0),h(g),v&&s.state.selectedIndex===null&&s.state.activeIndex===null&&_.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,A,I,F,d,f,p,c,h,S,w,B,L,_,v,E,C]),U.useEffect(()=>{if(!S||!I||!A)return;let e=ay(I);function t(e){u(!1,Ky(cte,e))}return Pb(e,`resize`,t)},[u,S,I,A]);let H={...L?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":m||void 0,id:`${k}-list`},onKeyDown(e){T&&yT.has(e.key)&&e.stopPropagation()},onScroll(e){L||V(e.currentTarget)},...S&&{style:L?{height:`100%`}:_9},className:!L&&S?HT.className:void 0},ne=Vr(`div`,e,{ref:[t,c],state:te,stateAttributesMapping:Qae,props:[N,H,fD(P),o]});return(0,K.jsxs)(U.Fragment,{children:[!O&&HT.getElement(D),(0,K.jsx)(HS,{context:y,modal:!1,disabled:!M,openInteractionType:j,returnFocus:a,restoreFocus:!0,children:ne})]})});function v9(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function y9(e){return iE(e.scrollHeight,e.clientHeight)}function b9(e){return kC.getScale(e)}function x9(e,t,n){return e/n[t]}function S9(e,t){return vx({x:x9(e.x,`x`,t),y:x9(e.y,`y`,t),width:x9(e.width,`x`,t),height:x9(e.height,`y`,t)})}var C9=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function eoe(e){let{style:t}=e,n={};for(let[e,r]of C9)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of C9){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var toe=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o,scrollHandlerRef:s,multiple:c}=a9(),{alignItemWithTriggerActive:l}=h9(),u=xw(o,p9.hasScrollArrows),d=xw(o,p9.openMethod),f={id:`${xw(o,p9.id)}-list`,role:`listbox`,"aria-multiselectable":c||void 0,onScroll(e){s.current?.(e.currentTarget)},...l&&{style:_9},className:u&&d!==`touch`?HT.className:void 0};return Vr(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),w9=U.createContext(void 0);function T9(){let e=U.useContext(w9);if(!e)throw Error(Cr(57));return e}var noe=U.memo(U.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=U.useRef(null),d=Rj({guess:!0,label:o,textRef:u}),{store:f,itemProps:p,setOpen:m,setValue:h,selectionRef:g,typingRef:_,valuesRef:v,multiple:y,selectedItemTextRef:b,disabled:x,readOnly:S}=a9(),C=x||s,w=xw(f,p9.isActive,d.index),T=xw(f,p9.open),E=xw(f,p9.isSelected,a),D=xw(f,p9.isSelectedByFocus,d.index),O=xw(f,p9.isItemEqualToValue),k=d.index,A=U.useRef(null);X(()=>{let e=v.current;return e[k]=a,()=>{delete e[k]}},[k,a,v]),X(()=>{let e=f.state.value,t=e;y&&Array.isArray(e)&&(t=e.length>0?e[e.length-1]:void 0),t!==void 0&&o9(a,t,O)&&(f.set(`selectedIndex`,k),u.current&&(b.current=u.current))},[k,y,O,f,a,b]);let j=U.useRef(`mouse`),M=U.useRef(!1),{getButtonProps:N,buttonRef:P}=Py({disabled:C,focusableWhenDisabled:!0,native:c,composite:!0}),F={disabled:C,selected:E,highlighted:w};function I(e){if(x||S)return;let t=f.state.value;if(y){let n=Array.isArray(t)?t:[],r=E?Lae(n,a,O):[...n,a];h(r,Ky(By,e))}else h(a,Ky(By,e)),m(!1,Ky(By,e))}function L(){g.current.dragY=0}let R={role:`option`,"aria-selected":E,tabIndex:T&&w?0:-1,onKeyDown(e){f.set(`activeIndex`,k),e.key===` `&&_.current&&e.preventDefault()},onClick(e){let t=j.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&fb(e.nativeEvent)&&(n!==void 0||w),i=t&&!r&&!M.current;M.current=!1,!(C||i)&&I(e.nativeEvent)},onPointerEnter(e){j.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=g.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){j.current=e.pointerType,M.current=!0,L()},onMouseUp(){if(L(),C||j.current===`touch`||M.current)return;let e=!g.current.allowSelectedMouseUp&&E,t=!g.current.allowUnselectedMouseUp&&!E;e||t||(M.current=!0,A.current?.click(),M.current=!1)}},ee=Vr(`div`,e,{ref:[P,t,d.ref,A],state:F,props:[p,R,l,N]}),z=U.useMemo(()=>({selected:E,index:k,textRef:u,selectedByFocus:D}),[E,k,u,D]);return(0,K.jsx)(w9.Provider,{value:z,children:ee})})),roe=U.forwardRef(function(e,t){let{selected:n}=T9();return e.keepMounted||n?(0,K.jsx)(ioe,{...e,ref:t}):null}),ioe=U.memo(U.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=T9(),c=U.useRef(null),{transitionStatus:l,setMounted:u}=Ow(s),d=Vr(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:Kv});return Aw({open:s,ref:c,onComplete(){s||u(!1)}}),d})),aoe=U.memo(U.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=T9(),{firstItemTextRef:a,selectedItemTextRef:o}=a9(),{render:s,className:c,style:l,...u}=e;return Vr(`div`,e,{ref:[U.useCallback(e=>{e&&(n===0&&(a.current=e),i&&(o.current=e))},[a,o,n,i]),t,r],props:u})})),E9=U.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,{store:l,popupRef:u,listRef:d,handleScrollArrowVisibility:f,scrollArrowsMountedCountRef:p}=a9(),{side:m,scrollDownArrowRef:h,scrollUpArrowRef:g}=h9(),_=xw(l,c?p9.scrollUpArrowVisible:p9.scrollDownArrowVisible),v=xw(l,p9.openMethod),y=_&&v!==`touch`,b=nb(),x=c?g:h,{mounted:S,transitionStatus:C,setMounted:w}=Ow(y);X(()=>(p.current+=1,l.set(`hasScrollArrows`,!0),()=>{p.current=Math.max(0,p.current-1),p.current===0&&l.set(`hasScrollArrows`,!1)}),[l,p]),Aw({open:y,ref:x,onComplete(){y||w(!1)}});let T=Vr(`div`,e,{ref:[t,x],state:{direction:a,visible:y,side:m,transitionStatus:C},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||b.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??u.current;if(!e)return;l.set(`activeIndex`,null),f(e);let n=iE(e.scrollHeight,e.clientHeight),r=aE(e.scrollTop,n),i=r===(c?0:n),a=d.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){b.clear();return}if(a.length>0){let t=x.current?.offsetHeight||0;e.scrollTop=ooe(a,c,r,e.clientHeight,t,n)}b.start(40,t)}b.start(40,t)},onMouseLeave(){b.clear()}},s],stateAttributesMapping:Kv});return S||o?T:null});function ooe(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?aE(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?aE(l.offsetTop+l.offsetHeight-r+i,a):a}var soe=U.forwardRef(function(e,t){return(0,K.jsx)(E9,{...e,ref:t,direction:`down`})}),coe=U.forwardRef(function(e,t){return(0,K.jsx)(E9,{...e,ref:t,direction:`up`})}),D9=Vae;function O9({className:e,size:t=`default`,children:n,...r}){return(0,K.jsxs)(Gae,{className:G(QM(t),e),"data-slot":`select-trigger`,...r,children:[n,(0,K.jsx)(Jae,{"data-slot":`select-icon`,children:(0,K.jsx)($M,{})})]})}function k9({className:e,...t}){return(0,K.jsx)(qae,{className:G(`flex-1 truncate data-placeholder:text-muted-foreground`,e),"data-slot":`select-value`,...t})}function A9({className:e,children:t,sideOffset:n=4,alignItemWithTrigger:r=!0,zIndex:i,...a}){let o=U.useContext(zE);return(0,K.jsx)(Yae,{children:(0,K.jsx)(Zae,{alignItemWithTrigger:r,className:`select-none`,style:{zIndex:i??o},"data-slot":`select-positioner`,sideOffset:n,children:(0,K.jsxs)($ae,{className:`origin-(--transform-origin) transition-[scale,opacity] has-data-[side=none]:scale-100 has-data-starting-style:scale-98 has-data-starting-style:opacity-0 has-data-[side=none]:transition-none`,"data-slot":`select-popup`,...a,children:[(0,K.jsx)(coe,{className:`top-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:top-px before:h-[200%] before:rounded-t-[calc(var(--radius-lg)-1px)] before:bg-linear-to-b before:from-50% before:from-popover`,"data-slot":`select-scroll-up-arrow`,children:(0,K.jsx)(bt,{className:`relative size-4.5 sm:size-4`})}),(0,K.jsx)(`span`,{className:`relative block h-full rounded-lg border bg-popover bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-lg dark:not-in-data-[slot=group]:bg-clip-border`,children:(0,K.jsx)(toe,{className:G(`max-h-(--available-height) min-w-(--anchor-width) overflow-y-auto p-1`,e),"data-slot":`select-list`,children:t})}),(0,K.jsx)(soe,{className:`bottom-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:bottom-px before:h-[200%] before:rounded-b-[calc(var(--radius-lg)-1px)] before:bg-linear-to-t before:from-50% before:from-popover`,"data-slot":`select-scroll-down-arrow`,children:(0,K.jsx)(_t,{className:`relative size-4.5 sm:size-4`})})]})})})}function j9({className:e,children:t,...n}){return(0,K.jsxs)(noe,{className:G(`grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 ps-2 pe-4 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),"data-slot":`select-item`,...n,children:[(0,K.jsx)(roe,{className:`col-start-1`,children:(0,K.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/1500/svg`,children:(0,K.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})}),(0,K.jsx)(aoe,{className:`col-start-2 min-w-0`,children:t})]})}function loe(e,t,n){return e.find(e=>e.id===t)?.id??e.find(e=>e.id===n)?.id??e[0]?.id??``}var M9={supervised:`受监督(每步确认)`,"auto-edits":`自动接受编辑`,full:`完全放行`,assistant:`助手代审`},N9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function uoe({projects:e,providers:t,open:n,preferredProjectId:r,onClose:i,onCreate:a}){let[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(`full`),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(`medium`),[v,y]=(0,U.useState)(n);n!==v&&(y(n),n&&s(null));let b=loe(e,o,r),x=t.find(e=>e.id===c)??t[0]??{id:``,models:[]},S=x.id,C=x.models.find(e=>e.id===u)?.id??x.models[0]?.id??``,w=!!(b&&S&&C);return(0,K.jsx)(Y7,{open:n,onOpenChange:e=>!e&&i(),children:(0,K.jsxs)(X7,{side:`bottom`,className:`pb-safe`,children:[(0,K.jsx)(Z7,{children:(0,K.jsx)(Q7,{children:`新建会话`})}),(0,K.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,K.jsx)(P9,{label:`项目`,children:(0,K.jsxs)(D9,{items:e.map(e=>({value:e.id,label:G7(e)})),value:b,onValueChange:e=>s(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,K.jsx)(j9,{value:e.id,children:G7(e)},e.id))})]})}),(0,K.jsx)(P9,{label:`模型服务`,children:(0,K.jsxs)(D9,{items:t.map(e=>({value:e.id,label:e.name})),value:S,onValueChange:e=>{l(e),d(null)},children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:t.map(e=>(0,K.jsx)(j9,{value:e.id,children:e.name},e.id))})]})}),(0,K.jsx)(P9,{label:`模型`,children:(0,K.jsxs)(D9,{items:x.models.map(e=>({value:e.id,label:e.label??e.id})),value:C,onValueChange:e=>d(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:x.models.map(e=>(0,K.jsx)(j9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,K.jsx)(P9,{label:`审批模式`,children:(0,K.jsxs)(D9,{items:Object.keys(M9).map(e=>({value:e,label:M9[e]})),value:f,onValueChange:e=>p(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:Object.keys(M9).map(e=>(0,K.jsx)(j9,{value:e,children:M9[e]},e))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,K.jsx)(bN,{checked:m,onCheckedChange:h})]}),m&&(0,K.jsx)(P9,{label:`推理档位`,children:(0,K.jsxs)(D9,{items:Object.keys(N9).map(e=>({value:e,label:N9[e]})),value:g,onValueChange:e=>_(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:Object.keys(N9).map(e=>(0,K.jsx)(j9,{value:e,children:N9[e]},e))})]})}),e.length===0&&(0,K.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端还没有项目,请先在桌面添加。`}),e.length>0&&t.length===0&&(0,K.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端没有可用的模型服务。`}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,K.jsx)(Oa,{variant:`outline`,onClick:i,children:`取消`}),(0,K.jsx)(Oa,{disabled:!w,onClick:()=>a({projectId:b,providerId:S,modelId:C,approvalMode:f,...m?{reasoningEnabled:m,thinkingLevel:g}:{}}),children:`创建`})]})]})]})})}function P9({label:e,children:t}){return(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}var doe={pending:`待发送`,sending:`发送中…`,failed:`发送失败`};function foe({items:e,readOnly:t,onRetry:n,onDiscard:r}){return e.length===0?null:(0,K.jsx)(`div`,{className:`mb-1 space-y-1`,children:e.map(e=>(0,K.jsxs)(`div`,{className:G(`flex flex-wrap items-center gap-2 rounded-xl border px-2.5 py-1.5 text-xs`,e.status===`failed`?`border-destructive/40 bg-destructive/5`:`bg-muted/40`),children:[(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1`,e.status===`failed`?`whitespace-pre-wrap break-words select-text`:`truncate`),children:e.text||(e.images?.length?`[${e.images.length} 张图片]`:``)}),(0,K.jsxs)(`span`,{className:G(`min-w-0 break-words`,e.status===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.error?.startsWith(`outbox-discard`)?`移除消息`:e.error===`delivery-unconfirmed`?`结果未确认`:doe[e.status],e.status===`failed`&&e.error?`:${cae(e.error)}`:``]}),e.status===`failed`&&!e.error?.startsWith(`outbox-discard`)&&!t&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`重试`,onClick:()=>n(e.deliveryId),className:`shrink-0 rounded p-0.5 text-foreground hover:bg-accent`,children:(0,K.jsx)(Nn,{className:`h-3.5 w-3.5`})}),e.status!==`sending`&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`删除`,disabled:e.error===`outbox-discarding`,onClick:()=>r(e.deliveryId),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-accent`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]},e.deliveryId))})}function poe(){let e=globalThis.BarcodeDetector;if(!e)return null;let t=new e({formats:[`qr_code`]});return{async scan(e){return(await t.detect(e))[0]?.rawValue??null}}}async function moe(){let{default:t}=await J(async()=>{let{default:t}=await import(`./jsQR-B1eQcpQl.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([148,1])),n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});return{async scan(e){if(!r||!e.videoWidth)return null;let i=Math.min(1,640/Math.max(e.videoWidth,e.videoHeight));n.width=Math.round(e.videoWidth*i),n.height=Math.round(e.videoHeight*i),r.drawImage(e,0,0,n.width,n.height);let{data:a,width:o,height:s}=r.getImageData(0,0,n.width,n.height);return t(a,o,s,{inversionAttempts:`dontInvert`})?.data??null}}}async function hoe(){return poe()??await moe()}function goe(e){try{return Ee(e),!0}catch{return!1}}function _oe({onPaired:e,autoInvite:t,onCancel:n,notice:r}){let[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(!1),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=()=>{for(let e of p.current?.getTracks()??[])e.stop();p.current=null,d(!1)},h=async t=>{s(!0),l(null);try{let n=Ee(t),r=/iPhone|iPad|Android/i.exec(navigator.userAgent)?.[0]??`Phone`,i=await ke(n.relay,n.publicKey,r);e({pairId:i.pairId,token:i.deviceToken,contentKey:btoa(String.fromCharCode(...i.contentKey)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``),deviceName:r,relayUrl:n.relay,pairedAt:Date.now()})}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}},g=(0,U.useRef)(!1);(0,U.useEffect)(()=>{!t||g.current||(g.current=!0,h(t))},[t]);let _=(0,U.useRef)(()=>{});_.current=e=>{m(),h(e)};let v=async()=>{l(null);try{p.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),d(!0)}catch(e){l(window.isSecureContext?e instanceof DOMException&&e.name===`NotAllowedError`?`摄像头权限被拒绝,请在浏览器设置中允许后重试`:`无法访问摄像头,请粘贴配对码`:`扫码需要 HTTPS 环境,请改用粘贴配对码`),d(!1)}};return(0,U.useEffect)(()=>{if(!u)return;let e=f.current,t=p.current;if(!e||!t)return;let n=!1,r=0;return e.srcObject=t,e.muted=!0,(async()=>{try{await e.play();let t=await hoe(),i=async()=>{if(!(n||!p.current)){try{let n=await t.scan(e);if(n&&goe(n)){_.current(n);return}}catch{}r=requestAnimationFrame(()=>void i())}};await i()}catch{n||l(`无法开始预览,请粘贴配对码`)}})(),()=>{n=!0,cancelAnimationFrame(r)}},[u]),(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-5 px-6 pt-safe pb-safe`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 text-center`,children:[(0,K.jsx)(`span`,{className:`mb-2 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(RN,{className:`size-6`})}),(0,K.jsx)(`h1`,{className:`font-medium text-lg`,children:`连接到 EnsoCode`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`在桌面端「设置 → 手机」生成配对码,扫码或粘贴。`}),r?(0,K.jsx)(`p`,{role:`status`,className:`mt-2 max-w-sm rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-left text-amber-700 text-xs dark:text-amber-300`,children:r}):null]}),u?(0,K.jsxs)(`div`,{className:`w-full max-w-sm space-y-2`,children:[(0,K.jsx)(`video`,{ref:f,playsInline:!0,muted:!0,className:`aspect-square w-full rounded-lg bg-black object-cover`}),(0,K.jsx)(Oa,{variant:`outline`,className:`w-full`,onClick:m,children:`取消扫码`})]}):(0,K.jsxs)(Oa,{className:`w-full max-w-sm`,onClick:()=>void v(),children:[(0,K.jsx)(ht,{className:`mr-1.5 h-4 w-4`}),`扫描二维码`]}),(0,K.jsxs)(`div`,{className:`flex w-full max-w-sm items-center gap-2`,children:[(0,K.jsx)(rG,{value:i,onChange:e=>a(e.target.value),placeholder:`enso://pair?relay=…`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`font-mono text-xs`}),(0,K.jsx)(Oa,{variant:`outline`,className:`shrink-0`,disabled:o||!i.trim(),onClick:()=>void h(i.trim()),children:o?(0,K.jsx)(sn,{className:`h-4 w-4 animate-spin`}):`配对`})]}),c&&(0,K.jsx)(`p`,{className:`max-w-sm text-center text-destructive text-xs`,children:c}),n&&(0,K.jsx)(Oa,{variant:`ghost`,className:`w-full max-w-sm`,onClick:n,children:`返回`})]})}var F9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function voe({providers:e,config:t,open:n,onClose:r,onSetModel:i,onSetReasoning:a,onSetThinking:o}){let s=e.find(e=>e.id===t.providerId),c=t.reasoningEnabled??!1,l=t.thinkingLevel??`medium`;return(0,K.jsx)(Y7,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(X7,{side:`bottom`,className:`pb-safe`,children:[(0,K.jsx)(Z7,{children:(0,K.jsx)(Q7,{children:`会话设置`})}),(0,K.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,K.jsx)(I9,{label:`模型服务`,children:(0,K.jsxs)(D9,{items:e.map(e=>({value:e.id,label:e.name})),value:t.providerId??``,onValueChange:t=>{let n=e.find(e=>e.id===t),r=n?.models[0]?.id;n&&r&&i(n.id,r)},children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,K.jsx)(j9,{value:e.id,children:e.name},e.id))})]})}),(0,K.jsx)(I9,{label:`模型`,children:(0,K.jsxs)(D9,{items:(s?.models??[]).map(e=>({value:e.id,label:e.label??e.id})),value:t.modelId??``,onValueChange:e=>{t.providerId&&i(t.providerId,e)},children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:(s?.models??[]).map(e=>(0,K.jsx)(j9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,K.jsx)(bN,{checked:c,onCheckedChange:a})]}),c&&(0,K.jsx)(I9,{label:`推理档位`,children:(0,K.jsxs)(D9,{items:Object.keys(F9).map(e=>({value:e,label:F9[e]})),value:l,onValueChange:e=>o(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:Object.keys(F9).map(e=>(0,K.jsx)(j9,{value:e,children:F9[e]},e))})]})}),(0,K.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`模型切换对运行中的会话在下次启动时生效;推理档位即时生效。`})]})]})})}function I9({label:e,children:t}){return(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}var L9=`__all__`,yoe=`__ungrouped__`;function R9(e){return new Set(e.map(e=>e.id))}function z9(e,t){return t.includes(e)}function boe(e,t){let n=e.groupId;return!n||!R9(t).has(n)}function xoe(e,t,n,r){let i=e.filter(e=>!z9(e.id,n));return r===`__all__`||r===`__recent__`?i:r===`__ungrouped__`?i.filter(e=>boe(e,t)):i.filter(e=>e.groupId===r)}function Soe(e,t,n){let r=e.filter(e=>!z9(e.id,n)),i=[...t].sort((e,t)=>e.order-t.order),a=R9(t),o=i.map(e=>({groupId:e.id,group:e,projects:r.filter(t=>t.groupId===e.id)})),s=r.filter(e=>!e.groupId||!a.has(e.groupId));return s.length>0&&o.push({groupId:yoe,projects:s}),o}var Coe=`default`;function woe(e,t){return e===`__recent__`?{kind:`all`,fallbackFrom:`recent`}:e===`__ungrouped__`?{kind:`ungrouped`}:e!==`__all__`&&t.some(t=>t.id===e)?{kind:`group`,groupId:e}:{kind:`all`}}var Toe=e=>e?.secretaryOrigin?e.secretaryOrigin.secretaryId??Coe:void 0;function Eoe(e,t,{projects:n,projectGroups:r,conversations:i}){switch(t.kind){case`all`:return[...e];case`secretary`:return e.map(e=>({...e,ids:e.ids.filter(e=>Toe(i[e])===t.secretaryId)})).filter(e=>e.ids.length>0);default:{let i=new Set(r.map(e=>e.id));return e.filter(e=>{let r=n.find(t=>t.id===e.projectId)?.groupId;return t.kind===`group`?r===t.groupId:!r||!i.has(r)})}}}function Doe(e){return e.status===`failed`&&!e.spawning?`failed`:e.queued?`queued`:(e.pendingAskCount??0)>0?`waiting`:e.status===`running`||e.spawning||e.hasRunningChild?`running`:e.hasPendingReminder?`reminder`:e.unread?`unread`:`idle`}function B9(e){return[...e].sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))}function V9(e){let t=e=>(e.pendingAskCount??0)>0||(e.pendingApprovalCount??0)>0;return[...e.filter(t),...e.filter(e=>!t(e))]}function Ooe(e,t){let n=B9(e),r=new Map(n.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}return[...i,...V9([...r.values()])]}function H9(e){return V9([...B9(e.filter(e=>e.pinned)),...B9(e.filter(e=>!e.pinned))])}function U9(e,t){return Doe({status:e.queueFailed?`failed`:e.status,unread:e.unread,pendingAskCount:e.pendingAskCount,hasRunningChild:t,queued:e.status===`queued`&&!e.queueFailed||e.parked===`upstream`,hasPendingReminder:e.parked===`reminder`})}function koe(e,t){return U9(e,t)!==`idle`||e.goal?.status===`active`}function Aoe(e,t){let n=B9(e.filter(e=>koe(e,t(e.id)))),r=e=>{let n=U9(e,t(e.id));return n===`queued`||n===`reminder`};return[...n.filter(e=>!r(e)),...n.filter(r)]}function W9(e,t){return e<=0?0:Math.min(e,5+Math.max(0,t))}function joe(e,t){return W9(e,t)>=e?0:Math.min(Math.max(0,e-5),t+15)}function Moe(e){return Math.max(0,e-15)}var Noe=[{value:`auto`,label:`跟随桌面`},{value:`light`,label:`浅`},{value:`dark`,label:`深`}];function Poe({open:e,docked:t=!1,pinnable:n=!1,onTogglePinned:r,projects:i,groups:a=[],catalog:o,pinnedOrder:s=[],activeId:c,canCreate:l,devices:u,activeDevicePairId:d,remoteDesktop:f,connected:p,connectionLabel:m,pushEnabled:g,pushBusy:v,pushError:y,pushAvailability:b,pushConfigReady:x,onTogglePush:S,onClose:C,onSelect:w,onNewConversation:T,onSwitchDevice:E,onAddDevice:D,onRenameDevice:O,onUnpairDevice:k,botSegment:A}){let j=A?.active===!0,[M,N]=(0,U.useState)({}),[P,F]=(0,U.useState)({}),[I,L]=(0,U.useState)(!1),[R,ee]=(0,U.useState)(!1),[z,V]=(0,U.useState)(null),te=f?u.find(e=>e.pairId===d&&e.scope!==`read`):void 0,[ne,re]=(0,U.useState)(_),[ie,ae]=(0,U.useState)(()=>{try{return localStorage.getItem(`enso-phone-selected-project-group`)??`__all__`}catch{return L9}}),[oe,se]=(0,U.useState)({}),le=ie===`__all__`||ie===`__ungrouped__`||a.some(e=>e.id===ie)?ie:L9;(0,U.useEffect)(()=>ee(!1),[le]),(0,U.useEffect)(()=>h(()=>re(_())),[]),(0,U.useEffect)(()=>{e||V(null)},[e]);let[ue,de]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!e)return;de(Date.now());let t=setInterval(()=>de(Date.now()),6e4);return()=>clearInterval(t)},[e]);let fe=new Set(i.filter(e=>e.archived).map(e=>e.id)),pe=[...fe],me=e=>e.archived||fe.has(e.projectId),he=xoe(i,a,pe,le),ge=Soe(i,a,pe),_e=new Set(he.map(e=>e.id)),ve=o.filter(e=>!e.parentId),ye=e=>!e.projectId||_e.has(e.projectId),be=Aoe(ve.filter(e=>!me(e)&&ye(e)),e=>o.some(t=>t.parentId===e&&t.status===`running`)),xe=Ooe(ve.filter(e=>e.pinned&&!me(e)&&ye(e)),s),Se=B9(ve.filter(me)),Ce=woe(le,a),we=new Set(Eoe(Se.map(e=>({projectId:e.projectId,ids:[e.id]})),Ce,{projects:i,projectGroups:a,conversations:{}}).flatMap(e=>e.ids)),Te=Se.filter(e=>we.has(e.id)),Ee=Ce.kind!==`all`,De=R?Se:Te,Oe=!Ee||R?`范围:全部归档`:Ce.kind===`group`?`范围:分组「${a.find(e=>e.id===Ce.groupId)?.name??``}」的归档`:`范围:未分组项目的归档`,ke=ve.filter(e=>!me(e)),Ae=new Set(i.map(e=>e.id)),je=H9(ke.filter(e=>!Ae.has(e.projectId)));return(0,K.jsxs)(K.Fragment,{children:[!t&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`关闭侧栏`,onClick:C,className:G(`fixed inset-0 z-40 bg-black/40 transition-[opacity,visibility] duration-200`,e?`visible opacity-100`:`invisible pointer-events-none opacity-0`)}),(0,K.jsxs)(`aside`,{className:G(`flex shrink-0 flex-col border-r bg-background`,t?`relative h-full w-72`:G(`fixed inset-y-0 left-0 z-50 w-[82vw] max-w-xs transition-transform duration-200`,e?`translate-x-0`:`-translate-x-full`)),children:[(0,K.jsxs)(`div`,{className:G(`flex h-12 shrink-0 items-center justify-between px-3 pt-safe`,a.length===0&&`border-b`),children:[A?(0,K.jsx)(`span`,{className:`flex rounded-lg bg-muted p-0.5 text-sm`,children:[`项目`,`Bot`].map(e=>{let t=e===`Bot`===A.active;return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>A.onChange(e===`Bot`),className:G(`rounded-md px-3 py-0.5 transition-colors`,t?`bg-background font-medium shadow-xs`:`text-muted-foreground`),children:e},e)})}):(0,K.jsx)(`span`,{className:`font-medium text-sm`,children:`项目`}),t?n&&r?(0,K.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`收起侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(yn,{className:`h-4 w-4`})}):null:(0,K.jsxs)(`span`,{className:`flex items-center`,children:[n&&r&&(0,K.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`固定侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(bn,{className:`h-4 w-4`})}),(0,K.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`关闭侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-4 w-4`})})]})]}),!j&&a.length>0&&(0,K.jsx)(`div`,{className:`shrink-0 border-b px-3 pb-2`,children:(0,K.jsxs)(D9,{items:[{value:`__all__`,label:`全部`},...a.slice().sort((e,t)=>e.order-t.order).map(e=>({value:e.id,label:`${e.emoji?`${e.emoji} `:``}${e.name}`})),{value:`__ungrouped__`,label:`未分组`}],value:le,onValueChange:e=>{if(e){ae(e);try{localStorage.setItem(`enso-phone-selected-project-group`,e)}catch{}}},children:[(0,K.jsx)(O9,{className:`w-full`,size:`sm`,children:(0,K.jsx)(k9,{})}),(0,K.jsxs)(A9,{zIndex:RE.DROPDOWN_IN_MODAL,children:[(0,K.jsx)(j9,{value:`__all__`,children:`全部`}),a.slice().sort((e,t)=>e.order-t.order).map(e=>(0,K.jsxs)(j9,{value:e.id,children:[e.emoji?`${e.emoji} `:``,e.name]},e.id)),(0,K.jsx)(j9,{value:`__ungrouped__`,children:`未分组`})]})]})}),j?A?.panel:(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2`,children:[i.length===0&&(0,K.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-6 text-center text-muted-foreground text-sm`,children:`桌面端还没有项目`}),be.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:(0,K.jsx)(`span`,{className:`font-medium text-sm`,children:`活跃中`})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:be.map(e=>(0,K.jsx)(G9,{session:e,active:c===e.id,nowTick:ue,onSelect:w},e.id))})]}),xe.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:[(0,K.jsx)(wn,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`font-medium text-sm`,children:`置顶`})]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:xe.map(e=>(0,K.jsx)(G9,{session:e,active:c===e.id,nowTick:ue,onSelect:w},e.id))})]}),(le===`__all__`&&a.length>0?ge.flatMap(e=>{let t=oe[e.groupId]===!0;return[{kind:`header`,section:e,folded:t},...t?[]:e.projects.map(e=>({kind:`project`,project:e}))]}):he.map(e=>({kind:`project`,project:e}))).map(e=>e.kind===`header`?(0,K.jsxs)(`button`,{type:`button`,onClick:()=>se(t=>({...t,[e.section.groupId]:!t[e.section.groupId]})),className:`flex h-7 w-full items-center gap-1 rounded-md px-2 text-left text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(vt,{className:G(`h-3.5 w-3.5 shrink-0 transition-transform duration-150`,!e.folded&&`rotate-90`)}),e.section.group?.emoji&&(0,K.jsx)(`span`,{className:`shrink-0 text-sm`,children:e.section.group.emoji}),e.section.group?.color&&(0,K.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.section.group.color}}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.section.group?.name??`未分组`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:e.section.projects.length})]},`hdr-${e.section.groupId}`):(0,K.jsx)(K9,{name:W7(e.project),badge:U7(e.project),sessions:H9(ke.filter(t=>t.projectId===e.project.id)),folded:M[e.project.id]===!0,revealedExtra:P[e.project.id]??0,activeId:c,nowTick:ue,canCreate:l,onToggleFold:()=>N(t=>({...t,[e.project.id]:!t[e.project.id]})),onRevealMore:t=>F(n=>({...n,[e.project.id]:t})),onSelect:w,onNew:()=>T(e.project.id)},e.project.id)),je.length>0&&(0,K.jsx)(K9,{name:`其他`,sessions:je,folded:M.__orphan===!0,revealedExtra:P.__orphan??0,activeId:c,nowTick:ue,canCreate:!1,onToggleFold:()=>N(e=>({...e,__orphan:!e.__orphan})),onRevealMore:e=>F(t=>({...t,__orphan:e})),onSelect:w})]}),!j&&(0,K.jsxs)(`div`,{className:`shrink-0 border-t p-2`,children:[I&&(0,K.jsxs)(`div`,{className:`mb-0.5 flex max-h-64 flex-col gap-y-0.5 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1`,children:[(0,K.jsx)(`span`,{"data-slot":`archive-scope`,className:`min-w-0 flex-1 truncate text-[11px] text-muted-foreground`,children:Oe}),Ee&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>ee(e=>!e),className:`shrink-0 rounded-full border px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60`,children:R?`仅本分组`:`全部归档`})]}),De.length===0&&(0,K.jsx)(`p`,{className:`px-2 py-3 text-center text-muted-foreground text-xs`,children:`没有归档会话`}),De.map(e=>(0,K.jsx)(G9,{session:e,active:c===e.id,nowTick:ue,subtitle:(()=>{let t=i.find(t=>t.id===e.projectId);return t?W7(t):void 0})(),onSelect:w},e.id))]}),(0,K.jsxs)(`button`,{type:`button`,"data-slot":`archived-button`,"data-empty":Te.length===0||void 0,onClick:()=>L(e=>!e),className:G(`flex w-full items-center gap-1 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60`,Te.length===0&&`opacity-55`),children:[(0,K.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,K.jsx)(vt,{className:G(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,I?`-rotate-90`:`rotate-0`)})}),(0,K.jsx)(it,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground text-sm`,children:`已归档`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:Te.length})]})]}),(0,K.jsxs)(`div`,{className:`shrink-0 space-y-1 border-t p-2 pb-safe`,children:[!z&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,K.jsx)(vn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`主题`}),(0,K.jsx)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:Noe.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>B(e.value),className:G(`rounded px-2 py-1 text-[11px] transition-colors`,ne===e.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`),children:e.label},e.value))})]}),!z&&te&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,K.jsx)(hn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`界面`}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:[(0,K.jsx)(`span`,{className:`rounded bg-primary px-2 py-1 text-[11px] text-primary-foreground`,children:`精简`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{window.location.href=H(te.pairId)},className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent`,children:`完整`})]})]}),!z&&(0,K.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(dt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`推送通知`}),(0,K.jsx)(bN,{checked:g,disabled:v||b!==`ok`||!p||!x,onCheckedChange:S})]}),ce({busy:v,error:y,availability:b,connected:p,configReady:x}).map(e=>(0,K.jsx)(`p`,{className:G(`mt-1 pl-6 text-[11px]`,e.error?`text-destructive`:`text-muted-foreground`),children:e.text},e.text))]}),(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[u.map(e=>{let t=e.pairId===d;return z===e.pairId?(0,K.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-dashed p-3`,children:[(0,K.jsxs)(`p`,{className:`text-xs`,children:[`解绑「`,e.label,`」后需重新扫码才能连接,确定吗?`]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(Oa,{variant:`outline`,size:`sm`,onClick:()=>V(null),children:`取消`}),(0,K.jsx)(Oa,{variant:`destructive`,size:`sm`,onClick:()=>{V(null),k(e.pairId)},children:`确定解绑`})]})]},e.pairId):(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>E(e.pairId),className:G(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left text-sm transition-colors hover:bg-muted/60`,t?`text-foreground`:`text-muted-foreground`),children:[(0,K.jsx)(rn,{className:`h-4 w-4 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,K.jsx)(`span`,{className:G(`shrink-0 text-[10px]`,p?`text-muted-foreground`:`text-destructive`),children:m})]}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`重命名 ${e.label}`,onClick:()=>{let t=window.prompt(`给这台电脑起个名:`,e.label);t?.trim()&&O(e.pairId,t)},className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(Cn,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`解绑 ${e.label}`,onClick:()=>V(e.pairId),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-destructive`,children:(0,K.jsx)($n,{className:`h-3.5 w-3.5`})})]},e.pairId)}),(0,K.jsxs)(`button`,{type:`button`,onClick:D,className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-muted-foreground text-sm transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(Dn,{className:`h-4 w-4 shrink-0`}),(0,K.jsx)(`span`,{children:`配对新电脑`})]})]}),(0,K.jsxs)(`p`,{className:`px-2 pt-0.5 text-center text-[10px] text-muted-foreground/60`,children:[`版本 `,`732f4e6-dirty`]})]})]})]})}function G9({session:e,active:t,nowTick:n,subtitle:r,onSelect:i}){return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:G(`flex w-full items-center gap-2 rounded-lg py-2 pr-2 pl-4 text-left text-sm transition-colors`,t?`bg-brand/10 dark:bg-brand/15`:`hover:bg-muted/60`),children:[(0,K.jsx)(Foe,{status:e.status,unread:e.unread,conversationId:e.id,queuePosition:e.queuePosition,queueFailed:e.queueFailed}),e.pinned&&(0,K.jsx)(wn,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),e.muted&&(0,K.jsx)(ut,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-label":`静音`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.title||`新对话`,r&&(0,K.jsx)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:r})]}),e.updatedAt&&(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/80 tabular-nums`,children:$7(e.updatedAt,`zh`,n)})]})}function K9({name:e,badge:t,sessions:n,folded:r,revealedExtra:i,activeId:a,nowTick:o,canCreate:s,onToggleFold:c,onRevealMore:l,onSelect:u,onNew:d}){let{t:f}=q(),p=W9(n.length,i),m=n.slice(0,p),h=n.length-p;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex w-full items-center gap-1 rounded-lg px-2 py-2 transition-colors hover:bg-muted/60`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:c,className:`flex min-w-0 flex-1 items-center gap-1 text-left`,children:[(0,K.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,K.jsx)(vt,{className:G(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,!r&&`rotate-90`)})}),(0,K.jsx)(Wt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-sm`,children:[e,t&&(0,K.jsx)(`span`,{className:`ml-1.5 rounded bg-muted px-1 py-0.5 text-[10px] font-normal text-muted-foreground`,children:t})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:n.length})]}),s&&d&&(0,K.jsx)(`button`,{type:`button`,onClick:d,className:`shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(dn,{className:`h-3.5 w-3.5`})})]}),!r&&(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-col gap-y-0.5`,children:[m.map(e=>(0,K.jsx)(G9,{session:e,active:a===e.id,nowTick:o,onSelect:u},e.id)),n.length>5&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(joe(n.length,i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Show {{n}} more`,{n:h})}),i>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(Moe(i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Collapse`)})]})]})]})}function Foe({status:e,unread:t,conversationId:n,queuePosition:r,queueFailed:i}){let{t:a}=q();if(e===`queued`&&!i){let e=a(`Queued · #{{n}}, starts automatically when a slot opens`,{n:r??1});return(0,K.jsx)(rt,{className:`h-3.5 w-3.5 shrink-0 text-orange-500`,"aria-label":e,title:e,"data-enso":`conversation-queued`,"data-conversation-id":n,"data-tone":`queued`})}let o=e===`running`,s=!o&&(e===`failed`||e===`queued`&&!!i),c=!o&&!s&&t===!0;return(0,K.jsx)(`span`,{title:i,className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,o&&`animate-pulse bg-brand`,s&&`bg-destructive`,c&&`bg-green-500`,!o&&!s&&!c&&`bg-muted-foreground/30`)})}function Ioe(e,t){return e?t.some(e=>e.status===`running`||typeof e.pendingAskCount==`number`&&e.pendingAskCount>0||typeof e.pendingApprovalCount==`number`&&e.pendingApprovalCount>0):!1}var q9=null;async function J9(e,t=typeof navigator>`u`?void 0:navigator.wakeLock){if(!e||!t){if(!q9)return;let e=q9;q9=null;try{await e.release()}catch{}return}if(!q9)try{let e=await t.request(`screen`);q9=e,e.addEventListener(`release`,()=>{q9===e&&(q9=null)})}catch{q9=null}}function Loe(){if(!window.location.hash.replace(/^#/,``).includes(`pk=`))return null;let e=window.location.href;return history.replaceState(null,``,window.location.pathname+window.location.search),e}var Y9=`enso-phone-sidebar-pinned`,Roe=R();function zoe(){let e=k(window.location.search);if(!e)return null;let t=new URLSearchParams(window.location.search);t.delete(`session`);let n=t.toString();return history.replaceState(null,``,window.location.pathname+(n?`?${n}`:``)),e}function Boe(){return ue()?`ok`:/iphone|ipad|ipod/i.test(navigator.userAgent)&&!te()?`needs-install`:`unsupported`}function Voe(){let[e,t]=(0,U.useState)(F),[n,i]=(0,U.useState)(Me),o=x(e,n),[c]=(0,U.useState)(Loe),[u]=(0,U.useState)(ve),[f,m]=(0,U.useState)(u),[h,g]=(0,U.useState)(null),_=o!==null;(0,U.useEffect)(()=>{if(_)return;let e=!1;return r().then(t=>{e||g(C({paired:!1,marked:t,standalone:te()}))}),()=>{e=!0}},[_]);let[b,S]=(0,U.useState)(`connecting`),[w,T]=(0,U.useState)(`relay`),[E,O]=(0,U.useState)(null),[k,A]=(0,U.useState)([]),[M,P]=(0,U.useState)([]),[I,L]=(0,U.useState)([]),[R,B]=(0,U.useState)([]),[V,ne]=(0,U.useState)([]),[ie]=(0,U.useState)(zoe),[ae]=(0,U.useState)(()=>d(o?.pairId??null,ie)),[se,ce]=(0,U.useState)(ae.activeId),[le,ue]=(0,U.useState)(null),[fe,pe]=(0,U.useState)(!1),[me,he]=(0,U.useState)(new Set),[_e,ye]=(0,U.useState)([]),[xe,Se]=(0,U.useState)(!1),Ce=Nae(Pae),[we,Ee]=(0,U.useState)(()=>localStorage.getItem(Y9)!==`off`),De=Ce&&we,Oe=()=>{Ee(e=>(localStorage.setItem(Y9,e?`off`:`on`),!e))},[ke,Ae]=(0,U.useState)(!1),[je,Ne]=(0,U.useState)(null),[Ie,Le]=(0,U.useState)(!1),[ze,Be]=(0,U.useState)(()=>localStorage.getItem(de)===`on`),[Ve,He]=(0,U.useState)(!1),[Ue,We]=(0,U.useState)(!1),[Ge,Ke]=(0,U.useState)(!1),[Je,Ye]=(0,U.useState)(!1),[Xe,Ze]=(0,U.useState)(!1),[Qe,$e]=(0,U.useState)(null),[et,tt]=(0,U.useState)(!1),[nt,W]=(0,U.useState)(!1),[rt,it]=(0,U.useState)(!1),at=(0,U.useRef)(!1),[ot,st]=(0,U.useState)(!1),[ct,lt]=(0,U.useState)(!1),ut=(0,U.useRef)(!1),[dt,ft]=(0,U.useState)([]),[pt,mt]=(0,U.useState)([]),[ht,gt]=(0,U.useState)([]),[_t,vt]=(0,U.useState)(!1),[yt,bt]=(0,U.useState)([]),[xt,St]=(0,U.useState)({items:[],offset:0}),[Ct,wt]=(0,U.useState)(()=>q7(!0,ae.botChatId)),[Tt,Et]=(0,U.useState)(ae.botChatId),[Dt,Ot]=(0,U.useState)(null),[kt,At]=(0,U.useState)({}),[jt,Mt]=(0,U.useState)({}),[Nt,Pt]=(0,U.useState)({}),[Ft,It]=(0,U.useState)(null),Lt=(0,U.useRef)(null),Rt=(0,U.useMemo)(()=>new Wa(e=>Ut.current?.send(e)),[]),zt=(0,U.useMemo)(()=>new ms(e=>Ut.current?.send(e)),[]),Bt=(0,U.useMemo)(()=>new gs(e=>Ut.current?.send(e)),[]),[Vt,Ht]=(0,U.useState)([]),Ut=(0,U.useRef)(null),Wt=(0,U.useRef)(se),Gt=(0,U.useRef)(k),Kt=(0,U.useRef)(le);Gt.current=k,Kt.current=le,Wt.current=se;let qt=Tt?ht.find(e=>e.id===Tt):void 0,Jt=qt?.kind===`group`?qo(qt,dt):void 0,Yt=Jt?.current??qt,Xt=qt?.kind===`direct`?qt.sessions[qt.members[0]]?.conversationId??null:null,Zt=Tt?Xt??Dt:se,Qt=(0,U.useRef)(Zt);Qt.current=Zt;let $t=(0,U.useRef)(ht);$t.current=ht;let en=(0,U.useRef)(Tt);en.current=Tt;let tn=(0,U.useRef)(null);tn.current=Jt?.current.id??null;let nn=(0,U.useRef)(new Set);nn.current=new Set(Jt?Object.values(Jt.current.sessions).map(e=>e.conversationId):[]);let rn=(0,U.useRef)(null),an=(0,U.useRef)(new Map),on=(0,U.useRef)(null),[sn,cn]=(0,U.useState)(!1),ln=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(Pe(),!(`serviceWorker`in navigator))return;let e=e=>{let t=e.data;if(t?.type!==`open-session`)return;let n=p(t.sessionId);if(!n)return;let r=$t.current.find(e=>Object.values(e.sessions).some(e=>e.conversationId===n));r?(Et(r.id),Ot(null)):(Et(null),ce(n)),Dn()};return navigator.serviceWorker.addEventListener(`message`,e),()=>navigator.serviceWorker.removeEventListener(`message`,e)},[]),(0,U.useEffect)(()=>{ja(ka(k))},[k]),(0,U.useEffect)(()=>{let e=()=>{J9(Ioe(document.visibilityState===`visible`&&b===`online`,k))};return e(),document.addEventListener(`visibilitychange`,e),document.addEventListener(`pointerdown`,e,{passive:!0}),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`pointerdown`,e),J9(!1)}},[k,b]),(0,U.useEffect)(()=>{if(ie){y();return}y().then(e=>{e&&(Et(null),Ot(null),ce(e),Dn())})},[ie]),(0,U.useEffect)(()=>{c&&e.length>0&&m(!0)},[]),(0,U.useEffect)(()=>{if(!o)return;ln.current=null,He(!1),he(new Set),T(`relay`),We(!1),Ke(!1),Ye(!1),W(!1),it(!1),at.current=!1,st(!1),lt(!1),ut.current=!1;let e=()=>{We(!0),Ye(!0)},t=new ee(o,{onState:e=>{e!==`online`&&(Lt.current?.interrupted(),Rt.reset(),zt.reset(),Bt.reset(),W(!1),st(!1)),S(e)},onBotArtifacts:e=>Rt.receive(e),onBotArtifactImage:e=>Rt.receiveImage(e),onBotNewSessionResult:t=>{zt.receive(t),t.error===`read-only`&&e()},onBotThreadResult:t=>{Bt.receive(t),t.error===`read-only`&&e()},onTransport:e=>{T(e),O(null)},onRtt:O,onRemoteDesktop:Ke,onReadOnly:e=>{We(e),e||Ye(!1)},onCommandRejected:(t,n)=>{n===`read-only`&&e()},onCatalog:(e,t)=>{A(e),P(t??[])},onProjects:(e,t)=>{L(e),B(t??[])},onProviders:ne,onSession:(e,t)=>{ue(n=>e===Qt.current?t:n),nn.current.has(e)&&Pt(n=>({...n,[e]:t}))},onBotCatalog:(e,t,n,r)=>{tt(e),W(e&&n),st(e&&r),mt(t),!e&&(gt([]),ft([]),bt([]),St({items:[],offset:0}),Et(null),Ot(null),wt(!1))},onBotChats:(e,t)=>{gt(e),ft(t),vt(!0)},onBotInbox:bt,onBotActivity:(e,t)=>{for(let t of e)an.current.set(t.conversationId,t.botId);St({items:e,offset:t})},onGroupTimeline:e=>{e.beforeSeq!==void 0&&on.current===`${e.chatId}:${e.beforeSeq}`&&(on.current=null,cn(!1)),At(t=>({...t,[e.chatId]:Zo(t[e.chatId],e)}))},onBotChatState:({type:e,chatId:t,...n})=>Mt(e=>({...e,[t]:n})),onBotEvent:e=>{if(e.kind===`model-notice`){e.text&&(e.chatId===en.current||e.chatId===tn.current)&&It(e.text);return}!e.chatId||e.chatId!==tn.current||rn.current||(rn.current=setTimeout(()=>{rn.current=null;let e=tn.current;e&&t.send({type:`bot-chat-open`,chatId:e})},200))},onBotSendResult:t=>{Lt.current?.settle(t.deliveryId,t.ok,t.error),t.error===`read-only`&&e()},onBotRetryResult:e=>{e.chatId===tn.current&&It(e.ok?`已开始重试`:`重试失败:${e.error===`session-busy`?`请等当前回复结束`:`该回复已过期或无法恢复,请重新发送需求`}`)},onSync:e=>pe(e===`syncing`),onGhostSession:e=>{e===Wt.current&&ce(null)},onHistoryPending:(e,t)=>{he(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},onPushConfig:e=>{ln.current=e,He(!0),localStorage.getItem(`enso-phone-push`)===`on`&&re(e).then(e=>{e.ok&&t.send({type:`push-subscribe`,subscription:e.subscription})})}});Ut.current=t,t.connect();let n=()=>{document.visibilityState===`visible`?(t.nudge(`visibility`),t.send({type:`presence`,visible:!0}),r()):(t.conceal(),t.send({type:`presence`,visible:!1}),t.flushCache())},r=()=>navigator.serviceWorker?.controller?.postMessage({type:`badge-clear`});r();let i=()=>{document.visibilityState===`visible`&&(t.nudge(`online`),t.send({type:`presence`,visible:!0}),r())},a=e=>{document.visibilityState===`visible`&&(t.nudge(e.persisted?`online`:`visibility`),t.send({type:`presence`,visible:!0}),r())},s=()=>{document.visibilityState===`visible`&&t.nudge(`visibility`)},c=()=>{t.conceal(),t.flushCache()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,i),window.addEventListener(`pageshow`,a),window.addEventListener(`focus`,s),window.addEventListener(`pagehide`,c),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,i),window.removeEventListener(`pageshow`,a),window.removeEventListener(`focus`,s),window.removeEventListener(`pagehide`,c),rn.current&&clearTimeout(rn.current),rn.current=null,t.close(),Ut.current=null,zt.reset(),Bt.reset()}},[o?.pairId,o?.token,o?.relayUrl,o?.contentKey]);let un=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{let e=Zt!==null&&un.current.has(Zt);Ut.current?.subscribe(Zt,{fresh:e});for(let e of un.current)e!==Zt&&un.current.delete(e);ue(Zt?Ut.current?.getSession(Zt)??null:null)},[Zt,o?.pairId]);let dn=o?.pairId;(0,U.useEffect)(()=>{dn&&ge(dn,{activeId:se,botChatId:Tt})},[se,Tt,dn]),(0,U.useEffect)(()=>{if(!dn)return;let e=new z(v,dn);Lt.current=e,Ht([]);let t=e.subscribe(e=>Ht([...e]));return e.restore().catch(()=>It(`离线消息读取失败,请勿清除浏览器数据;恢复存储后可重试。`)),()=>{t(),Lt.current===e&&(Lt.current=null)}},[dn]),(0,U.useEffect)(()=>{if(b===`online`)for(let e of Lt.current?.drain()??[])Ut.current?.send({type:`bot-send`,chatId:e.chatId,text:e.text,...e.images?.length?{images:e.images}:{},deliveryId:e.deliveryId})},[b,Vt]),(0,U.useEffect)(()=>{let e=setInterval(()=>Lt.current?.expire(),1e3);return()=>clearInterval(e)},[]);let fn=Jt?.current.id??null;(0,U.useEffect)(()=>{!fn||b!==`online`||(on.current=null,cn(!1),Ut.current?.send({type:`bot-chat-open`,chatId:fn}))},[fn,b]),(0,U.useEffect)(()=>{if(!sn)return;let e=setTimeout(()=>{on.current=null,cn(!1),It(`历史加载未完成,请点击加载重试。`)},1e4);return()=>clearTimeout(e)},[sn]),(0,U.useEffect)(()=>{let e={};for(let t of nn.current){let n=Ut.current?.getSession(t);n&&(e[t]=n)}Pt(e)},[fn,Jt?.current.sessions]),(0,U.useEffect)(()=>{if(!se||Tt)return;let e=ht.find(e=>Object.values(e.sessions).some(e=>e.conversationId===se));e&&(Et(e.id),ce(null))},[se,Tt,ht]),(0,U.useEffect)(()=>{let e=(e,t)=>{let n=Gt.current.find(t=>t.id===e)?.queued,r=nae(n,e,t,z7(e===Wt.current&&Kt.current?[...Kt.current.messages.values()]:[]));r&&ye(e=>[...e,r])};eP({removeQueuedMessage:(e,t)=>Ut.current?.send({type:`queue-remove`,sessionId:e,messageId:t}),updateQueuedMessage:(e,t,n)=>Ut.current?.send({type:`queue-update`,sessionId:e,messageId:t,text:n}),sendQueuedNow:(t,n)=>{e(t,n),Ut.current?.send({type:`queue-send-now`,sessionId:t,messageId:n})},interruptAndSendQueued:async(t,n)=>{e(t,n),Ut.current?.send({type:`queue-interrupt-send`,sessionId:t,messageId:n})},pauseGoal:e=>Ut.current?.send({type:`goal-pause`,sessionId:e}),resumeGoal:e=>Ut.current?.send({type:`goal-resume`,sessionId:e}),clearGoal:e=>Ut.current?.send({type:`goal-clear`,sessionId:e}),rewind:(e,t,n)=>Ut.current?.send({type:`rewind`,sessionId:e,userIndexFromEnd:t,...n?{restoreFiles:n}:{}}),retry:e=>Ut.current?.send({type:`retry`,sessionId:e})}),Re({stopTask:(e,t)=>Ut.current?.send({type:`task-stop`,sessionId:e,taskId:t}),stopSubagent:(e,t)=>Ut.current?.send({type:`subagent-stop`,sessionId:e,agentId:t})})},[]);let pn=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!se)return;let e=z7(le?[...le.messages.values()]:[]),t=le?.status===`running`,n=pn.current,r=n?.id===se&&n.running&&!t;pn.current={id:se,running:t},ye(t=>{let n=aae(t,se,e,{turnSettled:r});return n.length===t.length&&n.every((e,n)=>e===t[n])?t:n})},[le,se]);let mn=k.find(e=>!e.parentId)?.id;(0,U.useEffect)(()=>{!Tt&&!se&&mn&&ce(mn)},[se,Tt,mn]);let hn=(0,U.useMemo)(()=>k.find(e=>e.id===se),[k,se]),gn=(0,U.useMemo)(()=>{if(!hn)return;let e=hn.parentId?k.find(e=>e.id===hn.parentId):hn;if(!e)return;let t=k.filter(t=>t.parentId===e.id);return t.length>0?{parent:e,children:t}:void 0},[k,hn]),_n=hn&&!hn.parentId,vn=_n?V.find(e=>e.id===hn.providerId)?.models.find(e=>e.id===hn.modelId)?.label??hn.modelId??`选择模型`:void 0,yn=b===`online`?a(w,E):Fe[b],bn=e=>{A([]),P([]),L([]),B([]),ne([]),ue(null),pe(!1),ye([]),O(null),tt(!1),mt([]),gt([]),ft([]),vt(!1),Et(e.botChatId),wt(e.botChatId!==null),Ot(null),At({}),Mt({}),St({items:[],offset:0}),Pt({}),It(null),ce(e.activeId)},Sn=e=>{e!==o?.pairId&&(l(e),i(e),S(`connecting`),bn(d(e)),Dn())},Cn=n=>{let r=j(e,n);if(D(r),l(n.pairId),u&&n.scope!==`read`){window.location.replace(H(n.pairId));return}t(r),i(n.pairId),bn(d(n.pairId)),m(!1)},wn=n=>{n===o?.pairId&&Ut.current?.close();let{devices:r,fallback:a}=s(e,n,o?.pairId??null);t(r),a!==void 0&&(i(a?.pairId??null),a&&S(`connecting`),bn(d(a?.pairId??null)),a||Dn())},Tn=(n,r)=>{t(N(e,n,r))};if(!o||f)return(0,K.jsx)(_oe,{autoInvite:c,onPaired:Cn,onCancel:o?()=>{u?window.location.replace(H(o.pairId)):m(!1)}:void 0,notice:o?null:h});if(b===`unauthorized`){let t=e.length>1;return(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,K.jsx)(Vn,{className:`h-8 w-8 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`font-medium text-lg`,children:`配对已失效`}),(0,K.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`「`,o.label,`」已解绑此设备,`,t?`可移除它并切到其他电脑。`:`请重新扫码配对。`]}),(0,K.jsx)(Oa,{onClick:()=>wn(o.pairId),children:t?`移除此配对`:`重新配对`})]})}if(b===`replaced`)return(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,K.jsx)(Vn,{className:`h-8 w-8 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`font-medium text-lg`,children:`已在其他页面打开`}),(0,K.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`「`,o.label,`」正被另一个页面连着,同一时间只能有一个页面。`]}),(0,K.jsx)(Oa,{onClick:()=>window.location.reload(),children:`在这个页面重连`})]});let En=e=>Ut.current?.send(e),Dn=()=>{(localStorage.getItem(Y9)===`off`||!window.matchMedia(`(min-width: 900px)`).matches)&&Se(!1)},On=()=>{wt(q7(et,Tt)),Se(!0),et&&En({type:`bot-catalog-request`})},kn=(e,t,n=[])=>{It(null),Lt.current?.enqueue({chatId:e,text:t,images:n})},An=e=>(0,K.jsx)(foe,{items:Vt.filter(t=>t.chatId===e),readOnly:Ue,onRetry:e=>Lt.current?.retry(e),onDiscard:e=>Lt.current?.discard(e)}),jn=new Map(pt.map(e=>[e.id,e])),Mn=e=>Ue?`只读设备不能新建会话`:b===`online`?nt?rt?`正在新建会话…`:Vt.some(t=>t.chatId===e)?`请先处理待发送消息`:void 0:`请升级桌面端以支持新建会话`:`请先连接桌面端`,Nn=async e=>{if(Mn(e)||at.current)return;let t=Ut.current;at.current=!0,it(!0),It(null);try{let n=await zt.start(e,()=>t===Ut.current&&en.current===e&&window.confirm(`群聊中仍有回复、排队或委派任务。新建会话将停止成员回复,并取消未标记保留的委派。旧消息会保留。继续吗?`));if(t!==Ut.current||en.current!==e)return;It(!n||n.ok?null:n.error===`read-only`?`只读设备不能新建会话`:n.error===`timeout`||n.error===`offline`?`未收到新会话确认,请连接后核对聊天状态,勿重复操作`:`新建会话失败:${n.error??`请稍后重试`}`),n?.ok&&(t?.send({type:`bot-catalog-request`}),t?.send({type:`bot-chat-open`,chatId:e}))}finally{t===Ut.current&&(at.current=!1,it(!1))}},Pn=Ue?`只读设备不能切换或新建话题`:b===`online`?ct?`正在处理话题…`:void 0:`请先连接桌面端`,Fn=async e=>{if(Pn||ut.current)return;let t=Ut.current;ut.current=!0,lt(!0),It(null);try{let n=await Bt.request(e);if(t!==Ut.current||en.current!==e.chatId)return;n.ok?Ot(null):It(n.error===`read-only`?`只读设备不能切换或新建话题`:n.error===`timeout`||n.error===`offline`?`未收到桌面确认,请连接后核对当前话题`:n.error===`invalid`?`该话题已不存在或群已归档`:`话题操作失败:${n.error??`请稍后重试`}`)}finally{t===Ut.current&&(ut.current=!1,lt(!1))}},In=e=>{if(e.kind===`group`&&!Dt){let t=Object.entries(e.sessions).flatMap(([e,{conversationId:t}])=>{let n=Nt[t];return n?[{sessionId:t,botId:e,view:n}]:[]});return(0,K.jsx)(Mae,{chat:e,bots:jn,timeline:kt[e.id],state:jt[e.id],pending:t,activities:ls(xt.items,e.id),clockOffset:xt.offset,connState:b,stateLabel:yn,notice:Ft,outbox:An(e.id),deviceReadOnly:Ue,readOnlyRejected:Je,onOpenDrawer:On,drawerDocked:De,onNewSession:()=>void Nn(e.id),canCreate:!Mn(e.id),newSessionHint:Mn(e.id),newSessionBusy:rt,threads:ot&&Jt&&qt?{entries:Jt.entries,currentId:e.id,rootId:qt.id,disabledHint:Pn,onSelect:e=>void Fn({type:`bot-thread-select`,chatId:qt.id,threadId:e}),onCreate:()=>void Fn({type:`bot-thread-create`,chatId:qt.id})}:void 0,onLoadOlder:()=>{let t=kt[e.id]?.entries[0]?.seq,n=`${e.id}:${t}`;b!==`online`||t===void 0||on.current||(on.current=n,cn(!0),En({type:`bot-timeline`,chatId:e.id,beforeSeq:t}))},historyLoading:sn,onJumpLatest:()=>{on.current=null,cn(!1),At(t=>{let n={...t};return delete n[e.id],n}),En({type:`bot-chat-open`,chatId:e.id})},onSend:(t,n)=>kn(e.id,t,n),onStop:()=>En({type:`bot-stop`,chatId:e.id}),onRetry:t=>{It(`正在请求重试…`),En({type:`bot-retry`,chatId:e.id,entryId:t})},onOpenProcess:Ot,onApproval:(e,t,n)=>En({type:`approval-respond`,sessionId:e,requestId:t,decision:n}),onAsk:(e,t,n)=>En({type:`ask-respond`,sessionId:e,requestId:t,answer:n})})}let t=e.kind===`group`,n=kt[e.id]?.entries.find(e=>e.kind===`bot`&&e.conversationId===Dt),r=Dt?an.current.get(Dt):void 0,i=jn.get(t?n?.kind===`bot`?n.botId:r??``:e.members[0]);return(0,K.jsx)(V7,{sessionId:Zt??`bot-chat:${e.id}`,clockOffset:xt.offset,title:t?`${i?.name??`成员`} · 过程`:i?.name??e.title,projectName:t?e.title:i?.title??``,view:Zt?le:Roe,connState:b,stateLabel:yn,syncing:fe&&!!Zt,onOpenDrawer:On,drawerDocked:De,onNewSession:()=>!t&&void Nn(e.id),canCreate:!t&&!Mn(e.id),newSessionHint:Mn(e.id),newSessionBusy:rt,hasOlder:!!(Zt&&le&&le.messages.size>0&&Math.min(...le.messages.keys())>0),historyLoading:!!(Zt&&me.has(Zt)),onLoadOlder:()=>Zt&&Ut.current?.requestHistory(Zt),bot:t?{readOnly:!0,onBack:()=>Ot(null)}:{chatId:e.id,notice:Ft,outbox:An(e.id)},artifacts:!t&&Zt?{chatId:e.id,conversationId:Zt}:void 0,deviceReadOnly:Ue,readOnlyRejected:Je,onSend:(t,n)=>kn(e.id,t,n),onAbort:()=>Zt&&En({type:`abort`,sessionId:Zt}),onApproval:(e,t)=>Zt&&En({type:`approval-respond`,sessionId:Zt,requestId:e,decision:t}),onAsk:(e,t)=>Zt&&En({type:`ask-respond`,sessionId:Zt,requestId:e,answer:t})})},Ln=async e=>{$e(null);let t=oe(En);if(!e){Be(!1),Te(t);return}let n=ln.current;if(!n)return;Be(!0),Ze(!0);let r=await be(n,t);Ze(!1),r.ok||(Be(!1),$e(r.reason))};return(0,K.jsxs)(`div`,{className:`phone-app-root flex h-full min-h-0`,children:[(0,K.jsx)(Poe,{open:De||xe,docked:De,pinnable:Ce,onTogglePinned:Oe,projects:I,groups:R,catalog:k,pinnedOrder:M,activeId:Tt?null:se,canCreate:b===`online`&&!Ue,devices:e,activeDevicePairId:o.pairId,remoteDesktop:Ge,connected:b===`online`,connectionLabel:yn,onClose:()=>Dn(),onSelect:e=>{Et(null),Ot(null),ce(e),Dn()},onNewConversation:e=>{Dn(),Ne(e),Ae(!0)},pushEnabled:ze,pushBusy:Xe,pushError:Qe,pushAvailability:Boe(),pushConfigReady:Ve,onTogglePush:e=>void Ln(e),onSwitchDevice:Sn,onAddDevice:()=>{Dn(),m(!0)},onRenameDevice:Tn,onUnpairDevice:wn,botSegment:et?{active:Ct,onChange:e=>{wt(e),_ae(e?`bot`:`code`),e&&En({type:`bot-catalog-request`})},panel:(0,K.jsx)(ps,{bots:pt,chats:ht,activeChatId:Tt,inbox:yt,activities:xt.items,onDismiss:Ue?void 0:e=>En({type:`bot-inbox-dismiss`,key:e}),onSelect:e=>{Et(e),Ot(null),It(null),Dn()}})}:void 0}),(0,K.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Ce&&!De&&!xe&&(0,K.jsx)(`button`,{type:`button`,onClick:On,"aria-label":`打开会话列表`,className:`fixed top-1/2 left-0 z-40 flex h-16 w-6 -translate-y-1/2 items-center justify-center rounded-r-lg border border-l-0 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}),qt?(0,K.jsx)(qa.Provider,{value:{port:Rt,online:b===`online`},children:In(Yt??qt)}):Tt?(0,K.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[!De&&(0,K.jsx)(`button`,{type:`button`,onClick:On,"aria-label":`打开会话列表`,className:`absolute top-2 left-2 flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}),(0,K.jsx)(`p`,{children:_t?`该 Bot 聊天已不存在或不可用`:`正在恢复 Bot 聊天…`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:yn}),(0,K.jsx)(Oa,{onClick:On,children:`选择聊天`})]}):(0,K.jsx)(V7,{sessionId:se,title:hn?.title||(se?`会话`:`EnsoCode`),projectName:hn?.projectName??``,cwd:hn?.cwd,view:le,connState:b,stateLabel:yn,syncing:fe&&!!se,onOpenDrawer:On,drawerDocked:De,onNewSession:()=>{Ne(null),Ae(!0)},canCreate:b===`online`&&I.length>0&&!Ue,modelLabel:b===`online`?vn:void 0,onOpenConfig:()=>Le(!0),tabGroup:gn,onSelectTab:ce,hasOlder:!!(se&&le&&le.messages.size>0&&Math.min(...le.messages.keys())>0),historyLoading:!!(se&&me.has(se)),onLoadOlder:()=>se&&Ut.current?.requestHistory(se),queued:rae(hn?.queued,_e,se??``),echoes:_e,goal:hn?.goal,context:hn?.context,usageTotals:hn?.usageTotals,slashCommands:hn?.slashCommands,deviceReadOnly:Ue,readOnlyRejected:Je,onSend:(e,t)=>{if(!se)return;let n=qe(e);if(n){En({type:`compact`,sessionId:se,...n.instructions?{instructions:n.instructions}:{}});return}let r=/^\/goal(?:\s+([\s\S]+))?$/.exec(e.trim());if(r){let e=r[1]?.trim();if(!e)return;En(e===`clear`?{type:`goal-clear`,sessionId:se}:e===`pause`?{type:`goal-pause`,sessionId:se}:e===`resume`?{type:`goal-resume`,sessionId:se}:{type:`goal-set`,sessionId:se,text:e});return}En({type:le?.status===`running`?`enqueue`:`prompt`,sessionId:se,text:e,...t.length?{images:t}:{}})},onAbort:()=>se&&En({type:`abort`,sessionId:se}),onApproval:(e,t)=>se&&En({type:`approval-respond`,sessionId:se,requestId:e,decision:t}),onAsk:(e,t)=>se&&En({type:`ask-respond`,sessionId:se,requestId:e,answer:t})}),(0,K.jsx)(uoe,{open:ke&&!Ue,projects:I,providers:V,preferredProjectId:je,onClose:()=>{Ae(!1),Ne(null)},onCreate:e=>{let t=crypto.randomUUID();En({type:`spawn`,sessionId:t,...e}),un.current.add(t),Ae(!1),Ne(null),Et(null),Ot(null),ce(t)}}),_n&&se&&!Ue&&(0,K.jsx)(voe,{open:Ie,providers:V,config:{providerId:hn.providerId,modelId:hn.modelId,reasoningEnabled:hn.reasoningEnabled,thinkingLevel:hn.thinkingLevel},onClose:()=>Le(!1),onSetModel:(e,t)=>En({type:`set-model`,sessionId:se,providerId:e,modelId:t}),onSetReasoning:e=>En({type:`set-reasoning`,sessionId:se,enabled:e}),onSetThinking:e=>En({type:`set-thinking`,sessionId:se,level:e})})]})]})}function Hoe(e){return!e.appleMobile||!e.standalone||e.safeTop<=0||e.innerHeight<=e.innerWidth?!1:e.innerHeight>=Math.max(e.screenWidth,e.screenHeight)-1}function Uoe(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^viewport-fit\s*=/i.test(e)).join(`, `)}function Woe(){return/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function Goe(){let e=document.querySelector(`meta[name="viewport"]`);if(!e||!Woe())return;let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)`,document.body.appendChild(t);let n=()=>{let r=getComputedStyle(t);if(!Hoe({appleMobile:!0,standalone:te(),safeTop:Number.parseFloat(r.paddingTop)||0,innerWidth:window.innerWidth,innerHeight:window.innerHeight,screenWidth:window.screen.width,screenHeight:window.screen.height}))return;let i=Number.parseFloat(r.paddingBottom)||0;document.documentElement.style.setProperty(`--phone-safe-bottom`,`${i}px`),e.content=Uoe(e.content),window.removeEventListener(`resize`,n),document.removeEventListener(`visibilitychange`,n),t.remove()};window.addEventListener(`resize`,n),document.addEventListener(`visibilitychange`,n),n()}var X9=new URLSearchParams(location.search);if(X9.get(`mode`)===`phone`){ie(`phone`),X9.delete(`mode`);let e=X9.toString();history.replaceState(null,``,`${location.pathname}${e?`?${e}`:``}${location.hash}`)}var Z9=F(),Q9=Ce(location.search,De(),Z9,Me());Q9?location.replace(Q9):Z9.length>0&&(me(),T(!0)),L(),Goe(),Q9||Se(window),!Q9&&`serviceWorker`in navigator&&Oe({container:navigator.serviceWorker,doc:document,storage:sessionStorage,canReloadNow:()=>!1,reload:()=>location.reload()});var $9=document.getElementById(`root`);$9&&!Q9&&(0,Ge.createRoot)($9).render((0,K.jsx)(U.StrictMode,{children:(0,K.jsx)(Voe,{})}));export{q0 as a,ip as c,Qs as d,J as f,H2 as i,Tu as l,Ka as m,O4 as n,Wg as o,q as p,V2 as r,Qp as s,a6 as t,Oc as u};
277
+ `).trim()}var cae=e=>e===`outbox-discarding`?`正在移除…`:e===`outbox-discard`?`移除未保存,请勿关闭页面;请再次移除,重启后可能重新入队`:e===`outbox-storage`?`无法保存离线消息,请勿关闭页面;可重试或复制消息`:e===`delivery-unconfirmed`?`未收到回执,发送结果未确认;可重试确认`:e===`read-only`?`此设备为只读`:e===`session-busy`?`请等当前回复结束`:e&&Ie(`zh`,Ma(e)??e),B7=(e=!1)=>e?`此设备为只读,刚才的操作未执行;可在桌面「设置 → 设备」切换为可操作`:`此设备为只读,只能查看;可在桌面「设置 → 设备」切换为可操作`,lae=70;function uae({percent:e,critical:t}){return(0,K.jsx)(`span`,{"aria-hidden":!0,className:`h-1 w-7 shrink-0 overflow-hidden rounded-full bg-muted-foreground/20`,children:(0,K.jsx)(`span`,{className:G(`block h-full rounded-full`,t?`bg-destructive`:e>=lae?`bg-warning`:`bg-muted-foreground/70`),style:{width:`${e}%`}})})}function dae(e,t){let n={inputTokens:0,outputTokens:0,...e};return t&&(n.contextUsed=t.used,t.window!==void 0&&(n.contextWindow=t.window)),n.inputTokens===0&&n.outputTokens===0&&n.cacheHitPercent===void 0&&n.ttftAvgMs===void 0&&n.tokensPerSecond===void 0&&n.contextUsed===void 0?void 0:n}function fae(e,t){let n={tokens:void 0,cache:void 0,context:void 0,speed:void 0};if(!t)return n;if(t.contextUsed!==void 0){let e=t.contextUsed,r=t.contextWindow??0;if(r>0){let t=Math.min(100,Math.round(e/r*100));n.context={compact:`${t}%`,full:`${DN(r)} · ${t}%`,percent:t,critical:t>=90}}else n.context={compact:`${DN(e)}·?`,full:`${DN(e)} · ?`}}let r=[],i=[];return t.ttftAvgMs!==void 0&&(r.push(ON(t.ttftAvgMs)),i.push(e(`First token avg {{duration}}`,{duration:ON(t.ttftAvgMs)}))),t.tokensPerSecond!==void 0&&(r.push(`${t.tokensPerSecond} tok/s`),i.push(e(`{{speed}} tok/s`,{speed:t.tokensPerSecond}))),r.length>0&&(n.speed={compact:r.join(` · `),full:i.join(` · `)}),(t.inputTokens>0||t.outputTokens>0)&&(n.tokens={compact:`↑${DN(t.inputTokens)} ↓${DN(t.outputTokens)}`,full:e(`Input {{input}} tok · Output {{output}} tok`,{input:DN(t.inputTokens),output:DN(t.outputTokens)})}),t.cacheHitPercent!==void 0&&(n.cache={compact:`${t.cacheHitPercent}%`,full:e(`Cache hit {{percent}}%`,{percent:t.cacheHitPercent})}),n}var pae=[[`tokens`,Mt],[`cache`,Lt],[`context`,qt],[`speed`,ar]];function mae({usageTotals:e,context:t}){let{t:n}=q(),r=fae(n,dae(e,t));return(0,K.jsx)(`div`,{"data-slot":`stats-line`,className:`flex min-h-6 flex-wrap items-center justify-center gap-x-3 px-1`,children:pae.map(([e,t])=>{let n=r[e];return n?(0,K.jsxs)(`span`,{className:G(`flex items-center gap-1 text-[11px] tabular-nums`,n.critical?`text-destructive`:`text-muted-foreground/80`),children:[n.percent===void 0?(0,K.jsx)(t,{className:`h-3 w-3 shrink-0 opacity-75`}):(0,K.jsx)(uae,{percent:n.percent,critical:!!n.critical}),n.compact]},e):null})})}function V7(e){let{view:t,sessionId:n}=e,r=(0,U.useRef)(null),[i,a]=(0,U.useState)(!1),o=(0,U.useRef)(null),s=(0,U.useRef)(null),c=(0,U.useRef)(!1);(0,U.useLayoutEffect)(()=>{let e=o.current,t=s.current,n=e?.querySelector(`[aria-selected="true"]`);!e||!t||!n||(c.current||(t.style.transition=`none`),t.style.transform=`translate(${n.offsetLeft}px, ${n.offsetTop}px)`,t.style.width=`${n.offsetWidth}px`,t.style.height=`${n.offsetHeight}px`,c.current||=(t.offsetWidth,t.style.transition=``,!0))},[n,e.tabGroup]);let l=t?.status===`running`,u=e.bot,d=!!(u?.readOnly||e.deviceReadOnly),f=e.artifacts?.chatId,p=e.artifacts?.conversationId,m=(0,U.useMemo)(()=>({...$ie({sessionId:n,bot:u,deviceReadOnly:e.deviceReadOnly}),...f&&p?{turnFooter:e=>(0,K.jsx)(Xa,{target:{chatId:f,conversationId:p,messageIndex:e}})}:{}}),[n,u,e.deviceReadOnly,f,p]),h=(0,U.useMemo)(()=>{if(u)return[];let t=[{name:`/goal`,description:`Set a session goal (/goal <objective> · pause · resume · clear)`},{name:`/compact`,description:`Compact the context now (/compact [summary focus])`}],n=(e.slashCommands??[]).filter(e=>e.name!==`/goal`&&e.name!==`/compact`);return[...t,...n]},[e.slashCommands,u]),g=(0,U.useMemo)(()=>t?[...t.messages.entries()].sort((e,t)=>e[0]-t[0]):[],[t]),_=(0,U.useMemo)(()=>iae(g.map(([,e])=>e),e.echoes??[],n??``),[g,e.echoes,n]),v=_.length>0||t?.status===`running`||t?.status===`failed`;tP(n?{id:n,projectId:``,status:t?.status??`idle`,started:v,spawning:!1,messages:_,queuedMessages:e.queued?.map(e=>({id:e.id,text:e.text}))}:null);let y=(0,U.useMemo)(()=>SH(_,l,[],e.cwd,{pendingApprovals:t?.approvals,compaction:t?.compaction,compactionNoticeAt:V(g.map(([e])=>e),t?.compactionNoticeAt)}),[_,g,l,e.cwd,t?.approvals,t?.compaction,t?.compactionNoticeAt]),b=t?.messages.size?Math.min(...t.messages.keys()):null,x=(0,U.useRef)(null),S=(0,U.useCallback)(()=>{if(!e.hasOlder||!e.onLoadOlder)return;let t=r.current?.getScroller();x.current=t?{height:t.scrollHeight,top:t.scrollTop}:null,e.onLoadOlder()},[e.hasOlder,e.onLoadOlder]);(0,U.useLayoutEffect)(()=>{let e=r.current?.getScroller(),t=x.current;!e||!t||(x.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height))},[b]),(0,U.useEffect)(()=>{r.current?.isAtBottom()&&r.current.pinToBottom()},[y]);let C=async(t,n)=>{a(!0);try{let i=I7(n.length),a=[];for(let e of n)a.push(await hae(e,i));e.onSend(t,a),r.current?.scrollToBottom()}finally{a(!1)}};return(0,K.jsx)(IN.Provider,{value:m,children:(0,K.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[u?.onBack||!e.drawerDocked?(0,K.jsx)(`button`,{type:`button`,onClick:u?.onBack??e.onOpenDrawer,"aria-label":u?.onBack?`返回群聊`:`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:u?.onBack?(0,K.jsx)(yt,{className:`h-4.5 w-4.5`}):(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}):(0,K.jsx)(`span`,{className:`h-9 w-9 shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,K.jsxs)(`p`,{className:`flex min-w-0 items-center justify-center gap-1.5`,children:[e.connState!==`host-offline`&&e.connState!==`unauthorized`&&(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,e.connState===`online`&&!e.syncing?`bg-emerald-500`:`animate-pulse bg-amber-500`),title:e.connState===`online`&&e.syncing?`同步中…`:e.stateLabel}),(0,K.jsx)(`span`,{className:`truncate font-medium text-sm`,children:e.title})]}),(0,K.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e.projectName||e.stateLabel})]}),u?.readOnly?(0,K.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,K.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||d||!!u&&i||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Wn,{className:`h-4.5 w-4.5`})})]}),e.connState===`host-offline`&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center justify-center gap-1.5 bg-amber-500/10 py-1 text-amber-700 text-xs dark:text-amber-400`,children:[(0,K.jsx)(sn,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}),(0,K.jsx)(`span`,{children:e.stateLabel})]}),e.tabGroup&&e.tabGroup.children.length>0&&(0,K.jsxs)(`div`,{ref:o,role:`tablist`,className:`t-tabs relative flex shrink-0 items-center justify-start gap-1 overflow-x-auto border-b px-2 py-1`,children:[(0,K.jsx)(`span`,{ref:s,"aria-hidden":`true`,className:`t-tabs-pill pointer-events-none absolute top-0 left-0 z-0 rounded-md bg-muted`}),(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===e.tabGroup.parent.id,className:H7(n===e.tabGroup.parent.id),onClick:()=>e.onSelectTab?.(e.tabGroup?.parent.id??``),children:[(0,K.jsx)(un,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`max-w-40 truncate`,children:e.tabGroup.parent.title||`新对话`})]}),e.tabGroup.children.map(t=>(0,K.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t.id,className:H7(n===t.id),onClick:()=>e.onSelectTab?.(t.id),children:[(0,K.jsx)(ft,{className:`h-3 w-3 shrink-0`}),(0,K.jsx)(`span`,{className:`max-w-28 truncate`,children:t.title||`coworker`}),(0,K.jsx)(`span`,{className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`?`animate-pulse bg-brand`:t.status===`failed`?`bg-destructive`:`bg-muted-foreground/30`)})]},t.id))]}),n===null?(0,K.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,K.jsx)(`span`,{className:`mb-3 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(RN,{className:`size-6`})}),(0,K.jsx)(`p`,{className:`font-semibold text-[22px] tracking-tight`,children:`EnsoCode`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.connState===`online`?`从左上角选择会话,或新建一个`:e.stateLabel})]}):(0,K.jsx)(pie,{ref:r,items:y,busy:t===null?!!e.syncing:l,loading:t===null,running:l,error:void 0,emptyTitle:e.projectName||`EnsoCode`,virtualize:!1,historyLoading:e.historyLoading,hasOlder:e.hasOlder,firstItemIndex:b??0,onStartReached:e.hasOlder?S:void 0},n),n!==null&&(0,K.jsx)(`div`,{className:`phone-dock @container flex min-h-0 flex-col pt-1 pb-safe`,children:(0,K.jsxs)(`div`,{className:G(`enso-chat-col mx-auto w-full max-w-2xl px-4 @min-[56rem]:max-w-3xl @min-[72rem]:max-w-4xl @min-[84rem]:max-w-5xl @min-[96rem]:max-w-6xl @min-[112rem]:max-w-7xl`,`flex min-h-0 flex-col`),children:[t?.retry&&(0,K.jsx)(bie,{retry:t.retry}),!d&&(0,K.jsx)(mP,{conversationId:n,queued:(e.queued??[]).map(e=>({id:e.id,text:e.text}))}),e.goal&&!d&&(0,K.jsx)(lP,{conversationId:n,goal:{...e.goal,noProgressRuns:0}}),(0,K.jsx)(h5,{conversationId:n},n),(0,K.jsx)(zie,{sessionId:n,tasks:t?.tasks??[],subagents:t?.subagents??[],readOnly:e.deviceReadOnly}),(0,K.jsxs)(`div`,{"data-enso":`composer-stack`,className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain`,children:[u?.outbox,u?.notice&&(0,K.jsx)(`p`,{className:`mb-1 rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:u.notice}),e.deviceReadOnly?(0,K.jsx)(`p`,{className:`mb-1 rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:B7(e.readOnlyRejected)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i_,{approvals:t?.approvals??[],onRespond:e.onApproval,clockOffset:e.clockOffset}),(0,K.jsx)(c_,{asks:t?.asks??[],onAnswer:e.onAsk,clockOffset:e.clockOffset,autoFocus:!1})]})]}),!d&&(0,K.jsx)(FN,{commands:h,running:l,busy:l,locked:e.newSessionBusy||!!u&&i||(t?.approvals??[]).length>0,focusKey:u?.chatId?`bot-chat:${u.chatId}`:n,autoFocus:!1,enterToSend:!1,toolbar:e.modelLabel&&e.onOpenConfig?(0,K.jsxs)(`button`,{type:`button`,onClick:e.onOpenConfig,className:`flex min-w-0 items-center gap-0.5 rounded-md px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.modelLabel}),(0,K.jsx)(_t,{className:`h-3 w-3 shrink-0`})]}):void 0,onSend:e=>{C(e.text,e.images)},onAbort:e.onAbort}),!d&&(0,K.jsx)(mae,{usageTotals:e.usageTotals,context:e.context})]})})]})})}function H7(e){return G(`t-tab flex min-w-0 shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors`,e?`font-medium`:`text-muted-foreground`)}async function hae(e,t){if(e.data.length*.75<=t)return e;let n=await(await fetch(`data:${e.mimeType};base64,${e.data}`)).blob();return L7(new File([n],`image`,{type:e.mimeType}),t)}function U7(e){if(e.kind===`ssh`)return e.sshConnectionName?.trim()||e.sshHost}function W7(e){return e.alias?.trim()||e.name}function G7(e){let t=W7(e),n=U7(e);return n?`${t} (${n})`:t}var K7=`enso-phone-drawer-segment`;function gae(){let e=localStorage.getItem(K7);return e===`bot`||e===`code`?e:null}function _ae(e){localStorage.setItem(K7,e)}function q7(e,t){if(!e)return!1;let n=gae();return n?n===`bot`:t!==null}function vae(e,t=0){let n=new Map;for(let r of e)if(!(r.seq<=t)&&((r.kind===`human`||r.newConversation)&&n.clear(),r.kind===`bot`&&r.botId&&n.delete(r.botId),r.failure&&n.set(r.failure.botId,r.id),r.retryOf))for(let[e,t]of n)t===r.retryOf&&n.delete(e);return new Set(n.values())}function yae(e,t){let n=RegExp(`#${t}(?!\\d)`).exec(e);if(!n)return;let r=n.index+n[0].length;return[e.slice(0,n.index),n[0],e.slice(r)]}function bae({status:e}){return e===`running`?(0,K.jsx)(sn,{className:`h-3 w-3 shrink-0 animate-spin text-brand`}):e===`done`?(0,K.jsx)(gt,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`denied`?(0,K.jsx)(Bn,{className:`h-3 w-3 shrink-0 text-muted-foreground`}):e===`timeout`?(0,K.jsx)(jt,{className:`h-3 w-3 shrink-0 text-warning`}):(0,K.jsx)(ir,{className:`h-3 w-3 shrink-0 text-destructive`})}function xae({item:e,bots:t,clockOffset:n,onOpen:r}){let i=t.get(e.botId),a=e.ownerBotId?t.get(e.ownerBotId):void 0,o=e.state!==`queued`,[s,c]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(e)},[o]);let l=s-n,u=o&&r?()=>r(e.conversationId):void 0;return(0,K.jsxs)(`button`,{type:`button`,disabled:!u,onClick:u,className:`flex w-full gap-2 rounded-lg border bg-muted/30 px-2.5 py-2 text-left disabled:cursor-default`,children:[(0,K.jsx)(Io,{bot:i,size:`sm`,busy:o}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,K.jsxs)(`span`,{className:`truncate font-medium`,children:[i?.name??`成员`,a?(0,K.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` 替 `,a.name]}):null]}),(0,K.jsx)(`span`,{className:G(`shrink-0`,o?`text-brand`:`text-muted-foreground`),children:ss(e)}),o&&e.startedAt!==void 0&&(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:us(l-e.startedAt)}),u&&(0,K.jsx)(vt,{className:`ml-auto h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),e.more>0&&(0,K.jsxs)(`span`,{className:`mt-1 block text-[11px] text-muted-foreground`,children:[`+`,e.more,` 个更早的步骤`]}),e.steps.map((e,t)=>(0,K.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-[11px]`,children:[(0,K.jsx)(bae,{status:e.status}),(0,K.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-muted-foreground`,children:e.detail}),e.status===`timeout`&&(0,K.jsx)(`span`,{className:`shrink-0 text-warning`,children:e.name===`ask_user`?`已超时未回答`:`已超时拒绝`}),(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:e.durationMs===void 0?e.startedAt===void 0?``:us(l-e.startedAt):us(e.durationMs)})]},t))]})]})}var J7=e=>[...e].sort((e,t)=>t.activityAt-e.activityAt);function Sae(e,t,n=10){let r=J7(e),i=e=>e.id===t.currentId||e.id===t.rootId?0:e.unread||e.running?1:2,a=new Set([...r].sort((e,t)=>i(e)-i(t)).slice(0,n).map(e=>e.id));return r.filter(e=>a.has(e.id)).sort((e,n)=>Number(n.id===t.rootId)-Number(e.id===t.rootId))}function Cae(e,t,n){let r=t.trim().toLowerCase();return J7(e).filter(e=>(n===`all`||(n===`unread`?e.unread:e.running))&&(!r||`${e.title}\n${e.preview??``}`.toLowerCase().includes(r)))}var Y7=jT,wae=CT;function Tae({className:e,...t}){return(0,K.jsx)(ny,{className:G(`fixed inset-0 z-50 bg-black/32 backdrop-blur-sm transition-opacity duration-150 ease-out data-ending-style:opacity-0 data-starting-style:opacity-0`,e),"data-slot":`sheet-backdrop`,...t})}function Eae({className:e,side:t,inset:n=!1,...r}){return(0,K.jsx)(MT,{className:G(`fixed inset-0 z-50 grid`,t===`bottom`&&`grid grid-rows-[1fr_auto] pt-12`,t===`top`&&`grid grid-rows-[auto_1fr] pb-12`,t===`left`&&`flex justify-start`,t===`right`&&`flex justify-end`,n&&`sm:p-4`),"data-slot":`sheet-viewport`,...r})}function X7({className:e,children:t,showCloseButton:n=!0,side:r=`right`,inset:i=!1,...a}){return(0,K.jsxs)(wae,{children:[(0,K.jsx)(DE,{}),(0,K.jsx)(Tae,{}),(0,K.jsx)(Eae,{inset:i,side:r,children:(0,K.jsxs)(bT,{className:G(`relative flex max-h-full min-h-0 w-full min-w-0 flex-col bg-popover bg-clip-padding text-popover-foreground shadow-lg transition-[opacity,translate] duration-150 [transition-timing-function:cubic-bezier(0.34,1.56,0.64,1)] will-change-transform before:pointer-events-none before:absolute before:inset-0 before:shadow-[0_1px_--theme(--color-black/4%)] data-ending-style:opacity-0 data-starting-style:opacity-0 max-sm:before:hidden dark:bg-clip-border dark:before:shadow-[0_-1px_--theme(--color-white/8%)]`,r===`bottom`&&`row-start-2 border-t data-ending-style:translate-y-8 data-starting-style:translate-y-8`,r===`top`&&`data-ending-style:-translate-y-8 data-starting-style:-translate-y-8 border-b`,r===`left`&&`data-ending-style:-translate-x-8 data-starting-style:-translate-x-8 w-[calc(100%-(--spacing(12)))] max-w-md border-e`,r===`right`&&`col-start-2 w-[calc(100%-(--spacing(12)))] max-w-md border-s data-ending-style:translate-x-8 data-starting-style:translate-x-8`,i&&`before:hidden sm:rounded-2xl sm:border sm:before:rounded-[calc(var(--radius-2xl)-1px)] sm:**:data-[slot=sheet-footer]:rounded-b-[calc(var(--radius-2xl)-1px)]`,e),"data-slot":`sheet-popup`,...a,children:[t,n&&(0,K.jsx)(qy,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,K.jsx)(Oa,{size:`icon`,variant:`ghost`}),children:(0,K.jsx)(ir,{})})]})})]})}function Z7({className:e,...t}){return(0,K.jsx)(`div`,{className:G(`flex flex-col gap-2 p-6 in-[[data-slot=sheet-popup]:has([data-slot=sheet-panel])]:pb-3 max-sm:pb-4`,e),"data-slot":`sheet-header`,...t})}function Q7({className:e,...t}){return(0,K.jsx)(NT,{className:G(`font-heading text-xl leading-none`,e),"data-slot":`sheet-title`,...t})}function $7(e,t,n=Date.now()){let r=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),i=e-n,a=Math.abs(i);return a<6e4?r.format(0,`second`):a<36e5?r.format(Math.trunc(i/6e4),`minute`):a<864e5?r.format(Math.trunc(i/36e5),`hour`):a<2592e6?r.format(Math.trunc(i/864e5),`day`):a<31536e6?r.format(Math.trunc(i/2592e6),`month`):r.format(Math.trunc(i/31536e6),`year`)}function e9({entry:e}){return(0,K.jsxs)(K.Fragment,{children:[e.running&&(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-warning`}),(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground text-xs`,children:$7(e.activityAt,`zh`)})]})}function Dae({threads:e,status:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(``),{entries:o,currentId:s,rootId:c,disabledHint:l}=e,u=o.find(e=>e.id===s),d=Sae(o,{currentId:s,rootId:c}),f=o.length-d.length,p=Cae(o,i,`all`),m=t=>{!l&&t!==s&&e.onSelect(t)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(YM,{children:[(0,K.jsxs)(ZM,{"aria-label":`切换话题`,className:`mx-auto flex max-w-full items-center justify-center gap-0.5 text-[11px] text-muted-foreground`,children:[(0,K.jsxs)(`span`,{className:`truncate`,children:[u?.title??`主话题`,t&&` · ${t}`]}),(0,K.jsx)(_t,{className:`h-3 w-3 shrink-0`})]}),(0,K.jsxs)(QM,{className:`w-72 max-w-[calc(100vw-1rem)]`,children:[(0,K.jsxs)(eN,{children:[(0,K.jsx)(nN,{children:`话题`}),d.map(e=>(0,K.jsxs)(tN,{disabled:!!l&&e.id!==s,onClick:()=>m(e.id),children:[(0,K.jsx)(gt,{className:G(e.id!==s&&`invisible`)}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,K.jsx)(e9,{entry:e})]},e.id))]}),(0,K.jsx)(rN,{}),f>0&&(0,K.jsxs)(tN,{onClick:()=>{a(``),r(!0)},children:[(0,K.jsx)(on,{}),`全部话题(`,o.length,`)`]}),(0,K.jsxs)(tN,{disabled:!!l,onClick:e.onCreate,children:[(0,K.jsx)(dn,{}),`新话题`]}),l&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-muted-foreground text-xs`,children:l})]})]}),(0,K.jsx)(Y7,{open:n,onOpenChange:r,children:(0,K.jsxs)(X7,{side:`bottom`,className:`max-h-[80vh] pb-safe`,children:[(0,K.jsx)(Z7,{children:(0,K.jsxs)(Q7,{children:[`全部话题(`,o.length,`)`]})}),(0,K.jsx)(`div`,{className:`px-4 pb-2`,children:(0,K.jsx)(rG,{value:i,placeholder:`搜索话题…`,onChange:e=>a(e.target.value)})}),l&&(0,K.jsx)(`p`,{className:`px-4 pb-2 text-muted-foreground text-xs`,children:l}),(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-3`,children:[p.map(e=>(0,K.jsxs)(`button`,{type:`button`,disabled:!!l&&e.id!==s,onClick:()=>{m(e.id),r(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-accent disabled:opacity-60`,children:[(0,K.jsx)(gt,{className:G(`h-4 w-4 shrink-0`,e.id!==s&&`invisible`)}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-sm`,children:e.title}),e.preview&&(0,K.jsx)(`span`,{className:`block truncate text-muted-foreground text-xs`,children:e.preview})]}),(0,K.jsx)(e9,{entry:e})]},e.id)),p.length===0&&(0,K.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`没有匹配的话题`})]})]})})]})}var Oae={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,canceled:`已取消`,blocked:`卡住了`},t9=4,kae=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),Aae={started:{icon:Tt,className:`border-brand/50 text-brand`},blocked:{icon:St,className:`border-warning/60 text-warning`},delivered:{icon:Ct,className:`border-success/60 text-success`}};function jae({entry:e,bots:t}){let n=!!e.taskId,[r,i]=(0,U.useState)(!n),a=(0,K.jsxs)(K.Fragment,{children:[n&&(0,K.jsx)(vt,{"aria-hidden":!0,className:G(`h-3 w-3 shrink-0 transition-transform`,r&&`rotate-90`)}),(0,K.jsxs)(`span`,{className:`font-medium`,children:[t.get(e.from)?.name??`成员`,` → `,t.get(e.to)?.name??`成员`]}),(0,K.jsx)(`span`,{className:G(`rounded px-1.5 py-0.5`,e.state===`running`||e.state===`queued`?`bg-brand/10 text-brand`:e.state===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`),children:Oae[e.state]})]});return(0,K.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 px-3 py-2 text-xs`,children:[n?(0,K.jsx)(`button`,{type:`button`,"aria-expanded":r,"aria-label":r?`收起委派结果`:`展开委派结果`,className:`flex w-full items-center gap-1.5 text-left`,onClick:()=>i(e=>!e),children:a}):(0,K.jsx)(`p`,{className:`flex items-center gap-1.5`,children:a}),r&&e.summary&&(0,K.jsx)(`p`,{className:`mt-1 line-clamp-3 text-muted-foreground`,children:e.summary})]})}function n9(e,t){let n=[...t].sort((e,t)=>t.length-e.length),r=[],i=e,a=0;for(;i;){let e=i.indexOf(`@`),t=e<0?void 0:n.find(t=>i.startsWith(t,e+1));if(e<0||!t){r.push(i);break}e>0&&r.push(i.slice(0,e)),r.push((0,K.jsxs)(`span`,{className:`font-medium text-brand`,children:[`@`,t]},a++)),i=i.slice(e+1+t.length)}return r}function Mae(e){let{chat:t,bots:n,timeline:r,state:i}=e,a=(0,U.useRef)(null),o=(0,U.useRef)(null),s=(0,U.useRef)(null),c=(0,U.useRef)(!0),l=(0,U.useRef)(null),[u,d]=(0,U.useState)(``),[f,p]=(0,U.useState)(0),[m,h]=(0,U.useState)([]),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),b=r?.entries??[],x=t.epochSeq??b.findLast(e=>e.kind===`system`&&e.newConversation)?.seq??0,[S,C]=(0,U.useState)(!1);(0,U.useEffect)(()=>C(!1),[t.id,x]);let w=x>0&&!S,T=Xo(b,x,S),E=vae(b,x),D=t.members.map(e=>n.get(e)).filter(e=>!!(e&&!e.archived)),O=D.map(e=>e.name),k=!!i?.current||t.status!==`idle`,A=$o(u,f),j=A?ts(A.query,D):[],M=T[0]?.seq,N=T.at(-1)?.seq;(0,U.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=s.current;t?(s.current=null,e.scrollTop=t.top+(e.scrollHeight-t.height)):c.current&&(e.scrollTop=e.scrollHeight)},[M,N,i?.current,e.activities.length]);let P=()=>{let t=a.current;!r?.hasOlder||!t||e.historyLoading||e.connState!==`online`||w&&(b[0]?.seq??x)<=x||(s.current={height:t.scrollHeight,top:t.scrollTop},e.onLoadOlder())},F=e=>{if(!A)return;let t=ns(u,A,f,e.name);d(t.text),p(t.caret),requestAnimationFrame(()=>{o.current?.focus(),o.current?.setSelectionRange(t.caret,t.caret)})},I=(0,U.useRef)(m);I.current=m,(0,U.useEffect)(()=>()=>{for(let e of I.current)URL.revokeObjectURL(e.url)},[]);let L=e=>{let t=[...e??[]].filter(e=>e.type.startsWith(`image/`)).slice(0,t9-m.length).map(e=>({file:e,url:URL.createObjectURL(e)}));h(e=>[...e,...t]),y(null)},R=e=>{URL.revokeObjectURL(e),h(t=>t.filter(t=>t.url!==e))},ee=async()=>{if(!u.trim()&&m.length===0||g||e.newSessionBusy)return;let t=[];if(m.length){_(!0);try{t=await tae(m.map(e=>e.file))}catch(e){y(e instanceof Error?e.message:`图片处理失败`);return}finally{_(!1)}}e.onSend(u,t);for(let e of m)URL.revokeObjectURL(e.url);h([]),y(null),d(``),p(0),c.current=!0},z=t=>{switch(t.kind){case`human`:return(0,K.jsxs)(`div`,{className:`flex flex-col items-end`,children:[t.text&&(0,K.jsxs)(`div`,{className:`max-w-[85%] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-brand/10 px-3 py-2 text-sm`,children:[n9(t.text,O),t.truncated&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),t.images?.length?(0,K.jsx)(Xa,{target:{chatId:e.chat.id,entryId:t.id}}):null]},t.seq);case`bot`:{let r=n.get(t.botId);return(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Io,{bot:r,size:`sm`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`flex items-baseline gap-1.5 text-xs`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:r?.name??`成员`}),(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:kae(t.at)})]}),(0,K.jsxs)(`div`,{className:`mt-0.5 min-w-0 text-sm`,children:[(0,K.jsx)(D3,{text:t.text}),t.truncated&&(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`消息过长,仅显示部分内容`})]}),(0,K.jsx)(Xa,{target:{chatId:e.chat.id,entryId:t.id}}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>e.onOpenProcess(t.conversationId),className:`mt-0.5 flex items-center gap-0.5 text-muted-foreground text-xs hover:text-foreground`,children:[(0,K.jsx)(vt,{className:`h-3 w-3`}),`查看过程`]})]})]},t.seq)}case`delegation`:return(0,K.jsx)(jae,{entry:t,bots:n},t.seq);case`progress`:{let e=n.get(t.botId),r=Aae[t.phase],i=r.icon,a=yae(t.text,t.taskSeq);return(0,K.jsxs)(`div`,{"data-phase":t.phase,className:`flex gap-2 text-xs`,children:[(0,K.jsx)(Io,{bot:e,size:`sm`}),(0,K.jsxs)(`div`,{className:G(`flex min-w-0 items-start gap-1.5 rounded-md border-l-2 bg-muted/50 px-2 py-1`,r.className),children:[(0,K.jsx)(i,{"aria-hidden":!0,className:`mt-px h-3.5 w-3.5 shrink-0`}),(0,K.jsxs)(`p`,{className:`line-clamp-2 min-w-0 break-words text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.name??`成员`}),` `,a?(0,K.jsxs)(K.Fragment,{children:[n9(a[0],O),(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:a[1]}),n9(a[2],O)]}):n9(t.text,O)]})]})]},t.seq)}case`system`:return(0,K.jsxs)(`p`,{className:`text-center text-muted-foreground text-xs`,children:[t.text,E.has(t.id)&&e.onRetry&&!e.deviceReadOnly&&(0,K.jsx)(`button`,{type:`button`,className:`ml-2 underline disabled:opacity-50`,disabled:k||e.connState!==`online`,onClick:()=>e.onRetry?.(t.id),children:`重试`})]},t.seq)}},B=i?.current?n.get(i.current):void 0;return(0,K.jsxs)(`div`,{className:`phone-chat-root flex h-full min-h-0 flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b bg-background px-2 py-2 pt-safe`,children:[e.drawerDocked?(0,K.jsx)(`span`,{className:`h-9 w-9 shrink-0`}):(0,K.jsx)(`button`,{type:`button`,onClick:e.onOpenDrawer,"aria-label":`打开会话列表`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 text-center`,children:[(0,K.jsx)(`p`,{className:`truncate font-medium text-sm`,children:t.title||`群聊`}),e.threads?(0,K.jsx)(Dae,{threads:e.threads,status:e.connState===`online`?void 0:e.stateLabel}):(0,K.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:e.connState===`online`?`${t.members.length} 位成员`:e.stateLabel})]}),e.threads?(0,K.jsx)(`button`,{type:`button`,onClick:e.threads.onCreate,disabled:!!e.threads.disabledHint,"aria-label":`新话题`,title:e.threads.disabledHint??`新话题`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Wn,{className:`h-4.5 w-4.5`})}):(0,K.jsx)(`button`,{type:`button`,onClick:e.onNewSession,disabled:!e.canCreate||e.deviceReadOnly||g||e.connState!==`online`,"aria-label":`新建会话`,title:e.newSessionHint??`新建会话`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-40`,children:(0,K.jsx)(Wn,{className:`h-4.5 w-4.5`})})]}),(0,K.jsxs)(`div`,{ref:a,onScroll:e=>{let t=e.currentTarget;c.current=t.scrollHeight-t.scrollTop-t.clientHeight<40,t.scrollTop<60&&P()},className:`min-h-24 flex-1 space-y-3 overflow-y-auto px-3 py-3`,children:[r===void 0?(0,K.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 py-8 text-muted-foreground text-sm`,children:[(0,K.jsx)(sn,{className:`h-4 w-4 animate-spin`}),`读取中…`]}):r.hasOlder&&(!w||(b[0]?.seq??x)>x)?(0,K.jsx)(`button`,{type:`button`,onClick:P,disabled:e.historyLoading||e.connState!==`online`,className:`w-full py-1 text-center text-muted-foreground text-xs`,children:e.historyLoading?`加载中…`:`加载更早的消息`}):T.length===0?(0,K.jsx)(`p`,{className:`py-8 text-center text-muted-foreground text-sm`,children:`@ 成员开始对话,未 @ 时由群主回复`}):null,x>0&&(0,K.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-muted-foreground text-xs`,onClick:()=>{C(!S),S&&r?.history?e.onJumpLatest?.():!S&&r?.hasOlder&&!b.some(e=>e.seq<x)&&e.onLoadOlder()},children:w?`更早的对话 · ${x-1} 条`:`收起更早的对话`}),r?.history&&(0,K.jsx)(`button`,{type:`button`,className:`w-full py-1 text-center text-brand text-xs`,onClick:()=>{c.current=!0,e.onJumpLatest?.()},children:`回到最新消息`}),T.map(z),e.activities.map(t=>(0,K.jsx)(xae,{item:t,bots:n,clockOffset:e.clockOffset,onOpen:e.onOpenProcess},t.conversationId)),B&&e.activities.length===0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Io,{bot:B,size:`sm`,busy:!0}),(0,K.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[B.name,` 正在回复…`]})]})]}),(0,K.jsxs)(`div`,{className:`phone-dock flex min-h-0 flex-col gap-2 px-3 pt-1 pb-safe`,children:[(0,K.jsxs)(`div`,{"data-enso":`composer-stack`,className:`flex min-h-0 flex-col gap-2 overflow-y-auto overscroll-contain empty:hidden`,children:[e.outbox,e.notice&&(0,K.jsx)(`p`,{className:`rounded-md bg-destructive/10 px-2 py-1 text-destructive text-xs`,children:e.notice}),e.deviceReadOnly&&(0,K.jsx)(`p`,{className:`rounded-md bg-muted px-2 py-1 text-center text-muted-foreground text-xs`,children:B7(e.readOnlyRejected)}),!e.deviceReadOnly&&e.pending.map(({sessionId:t,botId:r,view:i})=>i.approvals.length>0||i.asks.length>0?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n.get(r)?.name??`成员`}),(0,K.jsx)(i_,{approvals:i.approvals,clockOffset:e.clockOffset,onRespond:(n,r)=>e.onApproval(t,n,r)}),(0,K.jsx)(c_,{asks:i.asks,clockOffset:e.clockOffset,onAnswer:(n,r)=>e.onAsk(t,n,r),autoFocus:!1})]},t):null)]}),(0,K.jsxs)(`div`,{className:G(`relative`,e.deviceReadOnly&&`hidden`),children:[j.length>0&&(0,K.jsx)(`div`,{className:`absolute right-0 bottom-full left-0 mb-1 max-h-48 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md`,children:j.map(e=>{let t=n.get(e.id);return(0,K.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>F(e),className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent`,children:[t?(0,K.jsx)(Io,{bot:t,size:`sm`}):(0,K.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-muted text-xs`,children:`@`}),(0,K.jsx)(`span`,{className:`font-medium`,children:e.name}),t?.title&&(0,K.jsx)(`span`,{className:`truncate text-muted-foreground text-xs`,children:t.title})]},e.id)})}),v&&(0,K.jsx)(`p`,{className:`mb-1 text-destructive text-xs`,children:v}),m.length>0&&(0,K.jsx)(`div`,{className:`mb-1.5 flex gap-1.5`,children:m.map(e=>(0,K.jsxs)(`div`,{className:`relative h-14 w-14 overflow-hidden rounded-lg border`,children:[(0,K.jsx)(`img`,{src:e.url,alt:``,className:`h-full w-full object-cover`}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`移除图片`,onClick:()=>R(e.url),className:`absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-black/60 text-white`,children:(0,K.jsx)(ir,{className:`h-3 w-3`})})]},e.url))}),(0,K.jsxs)(`div`,{className:`flex items-end gap-2 rounded-2xl border bg-background px-3 py-2`,children:[(0,K.jsx)(`input`,{ref:l,type:`file`,accept:`image/*`,multiple:!0,hidden:!0,onChange:e=>{L(e.target.files),e.target.value=``}}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`添加图片`,disabled:m.length>=t9,onClick:()=>l.current?.click(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-muted-foreground disabled:opacity-40`,children:(0,K.jsx)($t,{className:`h-4.5 w-4.5`})}),(0,K.jsx)(`textarea`,{ref:o,rows:1,value:u,placeholder:`@ 成员,或直接说…`,onChange:e=>{d(e.target.value),p(e.target.selectionStart??e.target.value.length)},onSelect:e=>p(e.currentTarget.selectionStart??0),className:`max-h-32 min-h-6 flex-1 resize-none bg-transparent text-sm outline-none field-sizing-content`}),k&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`停止`,onClick:e.onStop,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-foreground`,children:(0,K.jsx)(Jn,{className:`h-3.5 w-3.5 fill-current`})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`发送`,disabled:!u.trim()&&m.length===0||g||e.newSessionBusy||!e.outbox&&e.connState!==`online`,onClick:()=>void ee(),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-brand text-brand-foreground disabled:opacity-40`,children:(0,K.jsx)(ct,{className:`h-4 w-4`})})]})]})]})]})}var r9=e=>typeof window.matchMedia==`function`&&window.matchMedia(e).matches;function Nae(e){return(0,U.useSyncExternalStore)(t=>{if(typeof window.matchMedia!=`function`)return()=>{};let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},()=>r9(e),()=>r9(e))}var Pae=`(min-width: 900px)`;function Fae(e){let t=U.useRef(!0);t.current&&(t.current=!1,e())}var i9=U.createContext(null);function a9(){let e=U.useContext(i9);if(e===null)throw Error(Cr(60));return e}var Iae=(e,t)=>Object.is(e,t);function o9(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function s9(e,t,n){return!e||e.length===0?-1:e.findIndex(e=>e!==void 0&&o9(e,t,n))}function Lae(e,t,n){return e.filter(e=>!o9(t,e,n))}function c9(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function l9(e){return e!=null&&e.length>0&&typeof e[0]==`object`&&e[0]!=null&&`items`in e[0]}function Rae(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(l9(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function u9(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return c9(e)}function d9(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?c9(e.value):c9(e)}function f9(e,t,n){function r(){return u9(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){let n=t,i=l9(n)?n.flatMap(e=>e.items):n;if(typeof e!=`object`||!e){let t=i.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=i.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function zae(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,K.jsx)(U.Fragment,{children:f9(r,t,n)},i)),e),[])}var p9={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:d9(t,r)!==``},hasNullItemLabel:(e,t)=>t?Rae(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>o9(t,e,n)):o9(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function Bae(e,t,n=(e,t)=>e===t){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}function Vae(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:p=!1,modal:m=!0,actionsRef:h,inputRef:g,onOpenChangeComplete:_,items:v,multiple:y=!1,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S=Iae,highlightItemOnHover:C=!0,children:w}=e,{clearErrors:T}=_N(),{setDirty:E,setTouched:D,setFocused:O,validityData:k,setFilled:A,name:j,disabled:M,validation:N,validationMode:P}=mN(),F=CN({id:t}),I=M||d,L=j??c,[R,ee]=Lj({controlled:n,default:y?r??Ir:r,name:`Select`,state:`value`}),[z,B]=Lj({controlled:a,default:o,name:`Select`,state:`open`}),V=U.useRef([]),te=U.useRef([]),H=U.useRef(null),ne=U.useRef(null),re=U.useRef(0),ie=U.useRef(null),ae=U.useRef([]),oe=U.useRef(!1),se=U.useRef(null),ce=U.useRef(null),le=U.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),ue=U.useRef(!1),{mounted:de,setMounted:fe,transitionStatus:pe}=Dw(z),{openMethod:me,triggerProps:he}=IT(z),ge=Tr(()=>new ww({id:F,labelId:void 0,modal:m,multiple:y,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,value:R,open:z,mounted:de,transitionStatus:pe,items:v,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:{},triggerProps:{},triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1})).current,_e=bw(ge,p9.activeIndex),ve=bw(ge,p9.selectedIndex),ye=bw(ge,p9.triggerElement),be=bw(ge,p9.positionerElement),xe=MM(me),Se=me??xe,Ce=U.useMemo(()=>y?``:d9(R,x),[y,R,x]),we=U.useMemo(()=>y&&Array.isArray(R)?R.map(e=>d9(e,x)):d9(R,x),[y,R,x]);hN(Ib(ye),F,R,Ay(()=>we),!I,c);let Te=U.useRef(R),Ee=y?Array.isArray(R)&&R.length>0:R!=null&&Ce!==``;X(()=>{A(Ee)},[Ee,A]),X(function(){let e=R,t=!1;if(y){let n=Array.isArray(R)?R:[];t=n.length===0,e=n[n.length-1]}let n=t?-1:s9(ae.current,e,S),r=n===-1?null:n;r===null&&(ce.current=null),!z&&ge.set(`selectedIndex`,r)},[y,z,R,S,ge]);function De(e){let t=k.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Bae(e,t,(e,t)=>o9(e,t,S)):e!==t}PT(R,()=>{T(L),E(De(R)),N.change(R)});let Oe=Ay((e,t)=>{s?.(e,t),!t.isCanceled&&(B(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(D(!0),O(!1),P===`onBlur`&&N.commit(R)))}),ke=Ay(()=>{fe(!1),ge.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),_?.(!1)});kw({enabled:!h,open:z,ref:H,onComplete(){z||ke()}}),U.useImperativeHandle(h,()=>({unmount:ke}),[ke]);let Ae=Ay((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),je=Ay(e=>{let t=rE(e.scrollHeight,e.clientHeight),n=iE(e.scrollTop,t),r=n>0,i=n<t;ge.set(`scrollUpArrowVisible`,r),ge.set(`scrollDownArrowVisible`,i)}),Me=Ote({open:z,onOpenChange:Oe,elements:{reference:ye,floating:be}}),Ne=US(Me,{enabled:!f&&!I,event:`mousedown`}),Pe=KS(Me),Fe=cT(Me,{enabled:!f&&!I,listRef:V,activeIndex:_e,selectedIndex:ve,disabledIndices:Ir,onNavigate(e){e===null&&!z||ge.set(`activeIndex`,e)},focusItemOnHover:C}),Ie=lT(Me,{enabled:!f&&!I&&(z||!y),listRef:te,activeIndex:_e,selectedIndex:ve,disabledIndices:e=>JM(V.current[e]),onMatch(e){z?ge.set(`activeIndex`,e):Ae(ae.current[e],Ky(Iy))},onTyping(e){oe.current=e}}),Le=U.useMemo(()=>cr(Ie.reference,Fe.reference,Pe.reference,Ne.reference,he),[Ne.reference,Ie.reference,Fe.reference,Pe.reference,he]),Re=U.useMemo(()=>cr(Aw,Ie.floating,Fe.floating,Pe.floating),[Ie.floating,Fe.floating,Pe.floating]),ze=Fe.item??Lr;Fae(()=>{ge.update({popupProps:Re,triggerProps:Le})}),ge.useSyncedValues({id:F,modal:m,multiple:y,value:R,open:z,mounted:de,transitionStatus:pe,popupProps:Re,triggerProps:Le,items:v,itemToStringLabel:b,itemToStringValue:x,isItemEqualToValue:S,openMethod:Se});let Be=U.useMemo(()=>({store:ge,floatingContext:Me,required:p,disabled:I,readOnly:f,multiple:y,highlightItemOnHover:C,setValue:Ae,setOpen:Oe,listRef:V,popupRef:H,scrollHandlerRef:ne,handleScrollArrowVisibility:je,scrollArrowsMountedCountRef:re,itemProps:ze,valueRef:ie,valuesRef:ae,labelsRef:te,typingRef:oe,selectionRef:le,firstItemTextRef:se,selectedItemTextRef:ce,validation:N,onOpenChangeComplete:_,alignItemWithTriggerActiveRef:ue,initialValueRef:Te}),[ge,Me,p,I,f,y,C,Ae,Oe,ze,N,_,je]),Ve=Er(g,N.inputRef),He=y?void 0:L,Ue=U.useMemo(()=>!y||!Array.isArray(R)||!L?null:R.map(e=>{let t=d9(e,x);return(0,K.jsx)(`input`,{type:`hidden`,form:l,name:L,value:t,disabled:I},t)}),[y,R,l,L,x,I]);return(0,K.jsxs)(i9.Provider,{value:Be,children:[w,(0,K.jsx)(`input`,{...N.getValidationProps(I,{onFocus(){ge.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||I||f)return;let t=e.currentTarget.value,n=Ky(Iy,e.nativeEvent);function r(){if(y)return;let e=t.toLowerCase(),r=ae.current.findIndex(t=>d9(t,x).toLowerCase()===e||u9(t,b).toLowerCase()===e);r===-1&&(r=ae.current.findIndex((t,n)=>{let r=te.current[n];return r!=null&&r.toLowerCase()===e}));let i=ae.current[r];i!=null&&Ae(i,n)}ge.set(`forceMount`,!0),queueMicrotask(r)}}),id:F&&He==null?`${F}-hidden-input`:void 0,form:l,name:He,autoComplete:u,value:Ce,disabled:I,required:p&&!(y&&Ee),readOnly:f,ref:Ve,style:L?Wb:Ub,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ue]})}function Hae(e,t){return e??t}var Uae=400,Wae={...$v,...uN,popupSide:e=>e?{"data-popup-side":e}:null,value:()=>null},Gae=U.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,state:f,disabled:p}=mN(),{labelId:m}=yN(),{store:h,setOpen:g,selectionRef:_,validation:v,readOnly:y,required:b,alignItemWithTriggerActiveRef:x,disabled:S}=a9(),C=p||S||a,w=bw(h,p9.open),T=bw(h,p9.mounted),E=bw(h,p9.value),D=bw(h,p9.triggerProps),O=bw(h,p9.positionerElement),k=bw(h,p9.listElement),A=bw(h,p9.popupSide),j=bw(h,p9.id),M=bw(h,p9.labelId),N=bw(h,p9.hasSelectedValue),P=T&&O?A:null,F=i??j,I=Hae(m,M);CN({id:F});let L=Ib(O),R=U.useRef(null),{getButtonProps:ee,buttonRef:z}=Py({disabled:C,native:o}),B=h.useStateSetter(`triggerElement`),V=nb(),te=nb(),H=nb();U.useEffect(()=>{if(w)return H.start(Uae,()=>{_.current.allowUnselectedMouseUp=!0,_.current.allowSelectedMouseUp=!0}),()=>{H.clear()};_.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},te.clear()},[w,_,te,H]);let ne=cr(D,{id:F,role:`combobox`,"aria-expanded":w,"aria-haspopup":`listbox`,"aria-controls":w?k?.id??Ob(O)?.id:void 0,"aria-labelledby":I,"aria-readonly":y||void 0,"aria-required":b||void 0,tabIndex:C?-1:0,onFocus(e){u(!0),w&&x.current&&g(!1,Ky(Iy,e.nativeEvent)),V.start(0,()=>{h.set(`forceMount`,!0)})},onBlur(e){yb(O,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&v.commit(E))},onMouseDown(e){if(w)return;let t=My(e.currentTarget);function n(e){if(!R.current)return;let t=e.target;yb(R.current,t)||yb(L.current,t)||SM(e,R.current)||g(!1,Ky(Uy,e))}te.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,ee),re=v.getValidationProps(C,ne);re.role=`combobox`;let ie={...f,open:w,disabled:C,value:E,readOnly:y,popupSide:P,placeholder:!N};return Vr(`button`,e,{ref:[t,R,z,B],state:ie,stateAttributesMapping:Wae,props:re})}),Kae={value:()=>null},qae=U.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,{store:c,valueRef:l}=a9(),u=bw(c,p9.value),d=bw(c,p9.items),f=bw(c,p9.itemToStringLabel),p=bw(c,p9.hasSelectedValue),m=!p&&a!=null&&i==null,h=bw(c,p9.hasNullItemLabel,m),g={value:u,placeholder:!p},_=null;return _=typeof i==`function`?i(u):i??(m&&!h?a:Array.isArray(u)?zae(u,d,f):f9(u,d,f)),Vr(`span`,e,{state:g,ref:[t,l],props:[{children:_},s],stateAttributesMapping:Kae})}),Jae=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o}=a9();return Vr(`span`,e,{state:{open:bw(o,p9.open)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Qv})}),Yae=U.forwardRef(function(e,t){let{store:n}=a9(),r=bw(n,p9.mounted),i=bw(n,p9.forceMount);return r||i?(0,K.jsx)(CS,{ref:t,...e}):null}),m9=U.createContext(void 0);function h9(){let e=U.useContext(m9);if(!e)throw Error(Cr(59));return e}function g9(e,t){e&&Object.assign(e.style,t)}var _9={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},Xae={position:`fixed`},Zae=U.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:g=gS,style:_,...v}=e,{store:y,listRef:b,labelsRef:x,alignItemWithTriggerActiveRef:S,selectedItemTextRef:C,valuesRef:w,initialValueRef:T,popupRef:E,setValue:D,floatingContext:O}=a9(),k=bw(y,p9.open),A=bw(y,p9.mounted),j=bw(y,p9.modal),M=bw(y,p9.value),N=bw(y,p9.openMethod),P=bw(y,p9.positionerElement),F=bw(y,p9.triggerElement),I=bw(y,p9.isItemEqualToValue),L=bw(y,p9.transitionStatus),R=U.useRef(null),ee=U.useRef(null),[z,B]=U.useState(h),V=A&&z&&N!==`touch`;!A&&z!==h&&B(h),U.useImperativeHandle(S,()=>V),lM((V||j)&&k,N===`touch`,P,F);let te=cD({anchor:n,floatingRootContext:O,positionMethod:a,mounted:A,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??V,collisionAvoidance:g,keepMounted:!0}),H=V?`none`:te.side,ne=V?Xae:te.positionerStyles,re={open:k,side:H,align:te.align,anchorHidden:te.anchorHidden};X(()=>{y.set(`popupSide`,te.side)},[y,te.side]);let ie=fD(e,re,{styles:ne,transitionStatus:L,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!A,inert:!k}),ae=U.useRef(0),oe=Ay(e=>{if(w.current.length===0)return;let t=ae.current;if(ae.current=e.size,e.size===t)return;let n=Ky(Iy);if(t!==0&&!y.state.multiple&&M!==null&&s9(w.current,M,I)===-1){let e=T.current,t=e!=null&&s9(w.current,e,I)!==-1?e:null;D(t,n),t===null&&(y.set(`selectedIndex`,null),C.current=null)}if(t!==0&&y.state.multiple&&Array.isArray(M)){let e=M.filter(e=>s9(w.current,e,I)!==-1);e.length!==M.length&&(D(e,n),e.length===0&&(y.set(`selectedIndex`,null),C.current=null))}if(k&&V){y.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};g9(P,e),g9(E.current,e)}}),se=U.useMemo(()=>({...te,side:H,alignItemWithTriggerActive:V,setControlledAlignItemWithTrigger:B,scrollUpArrowRef:R,scrollDownArrowRef:ee}),[te,H,V,B]);return(0,K.jsx)(tM,{elementsRef:b,labelsRef:x,onMapChange:oe,children:(0,K.jsxs)(m9.Provider,{value:se,children:[A&&j&&(0,K.jsx)(ST,{inert:xT(!k),cutout:F}),ie]})})}),Qae={...ey,...Kv},$ae=U.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s,popupRef:c,onOpenChangeComplete:l,setOpen:u,valueRef:d,firstItemTextRef:f,selectedItemTextRef:p,multiple:m,handleScrollArrowVisibility:h,scrollHandlerRef:g,listRef:_,highlightItemOnHover:v,floatingContext:y}=a9(),{side:b,align:x,alignItemWithTriggerActive:S,isPositioned:C,setControlledAlignItemWithTrigger:w}=h9(),T=Xj(!0)!=null,E=tE(),{nonce:D,disableStyleElements:O}=KT(),k=bw(s,p9.id),A=bw(s,p9.open),j=bw(s,p9.openMethod),M=bw(s,p9.mounted),N=bw(s,p9.popupProps),P=bw(s,p9.transitionStatus),F=bw(s,p9.triggerElement),I=bw(s,p9.positionerElement),L=bw(s,p9.listElement),R=U.useRef(!1),ee=U.useRef(!1),z=U.useRef({}),B=Vb(),V=Ay(e=>{if(!I||!c.current||!ee.current)return;let t=I.style.top===`0px`,n=I.style.bottom===`0px`;if(R.current||!S||!t&&!n){h(e);return}let r=b9(I),i=x9(I.getBoundingClientRect().height,`y`,r),a=My(I),o=ay(I),s=o.getComputedStyle(I),l=parseFloat(s.marginTop),u=parseFloat(s.marginBottom),d=v9(o.getComputedStyle(c.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,m=y9(e),g=null,_=e=>{I.style.height=`${e}px`},v=t?m-p:p,y=Math.min(i+v,f);if(v<=1){let n=nE(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?m:0,f-(i+n)<=1&&(R.current=!0),h(e);return}f-y>1?g=t?1/0:0:n&&p<m&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=nE(g,0,y9(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(R.current=!0),h(e)});U.useImperativeHandle(g,()=>V,[V]),kw({open:A,ref:c,onComplete(){A&&l?.(!0)}});let te={open:A,transitionStatus:P,side:b,align:x};X(()=>{!I||!c.current||Object.keys(z.current).length||(z.current={top:I.style.top||`0`,left:I.style.left||`0`,right:I.style.right,height:I.style.height,bottom:I.style.bottom,minHeight:I.style.minHeight,maxHeight:I.style.maxHeight,marginTop:I.style.marginTop,marginBottom:I.style.marginBottom})},[c,I]),X(()=>{A||S||(ee.current=!1,R.current=!1,g9(I,z.current))},[A,S,I,c]),X(()=>{let e=c.current;if(!A||!F||!I||!e||S&&!C||s.state.transitionStatus===`ending`)return;if(ee.current=!0,e.style.removeProperty(`--transform-origin`),!S){B.request(()=>h(L||e));return}let t=eoe(e);try{let t=p.current;t?.isConnected||(t=!p9.hasSelectedValue(s.state)&&f.current?.isConnected?f.current:null);let n=d.current,r=ay(I),i=r.getComputedStyle(I),a=r.getComputedStyle(e),o=My(F),c=b9(F),l=S9(F.getBoundingClientRect(),c),u=S9(I.getBoundingClientRect(),c),m=l.height,g=L||e,y=g.scrollHeight,b=parseFloat(a.borderBottomWidth),x=parseFloat(i.marginTop)||10,S=parseFloat(i.marginBottom)||10,C=parseFloat(i.minHeight)||100,T=v9(a),D=o.documentElement.clientHeight-x-S,O=o.documentElement.clientWidth,k=D-l.bottom+m,A,j=E===`rtl`?l.right-u.width:l.left,M=0;if(t&&n){let e=S9(n.getBoundingClientRect(),c);A=S9(t.getBoundingClientRect(),c),j=u.left+(E===`rtl`?e.right-A.right:e.left-A.left);let r=e.top-l.top+e.height/2;M=A.top-u.top+A.height/2-r}let N=k+M+S+b,P=Math.min(D,N),ee=D-x-S,B=N-P,V=O-5;I.style.left=`${nE(j,5,V-u.width)}px`,I.style.height=`${P}px`,I.style.maxHeight=`none`,I.style.marginTop=`${x}px`,I.style.marginBottom=`${S}px`,e.style.height=`100%`;let te=y9(g),H=B>=te-1;H&&(P=Math.min(D,u.height)-(B-te));let ne=l.top<20||l.bottom>D-20||Math.ceil(P)+1<Math.min(y,C),re=(r.visualViewport?.scale??1)!==1&&lb;if(ne||re){g9(I,z.current),w(!1);return}let ie=Math.max(C,P);if(H){let e=Math.max(0,D-N);I.style.top=u.height>=ee?`0`:`${e}px`,I.style.height=`${P}px`,g.scrollTop=y9(g)}else I.style.bottom=`0`,g.scrollTop=B;if(A){let t=u.top,n=u.height,r=A.top+A.height/2,i=nE(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(`--transform-origin`,`50% ${i}%`)}(ie===D||P>=T)&&(R.current=!0),h(g),v&&s.state.selectedIndex===null&&s.state.activeIndex===null&&_.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,A,I,F,d,f,p,c,h,S,w,B,L,_,v,E,C]),U.useEffect(()=>{if(!S||!I||!A)return;let e=ay(I);function t(e){u(!1,Ky(cte,e))}return Pb(e,`resize`,t)},[u,S,I,A]);let H={...L?{role:`presentation`,"aria-orientation":void 0}:{role:`listbox`,"aria-multiselectable":m||void 0,id:`${k}-list`},onKeyDown(e){T&&vT.has(e.key)&&e.stopPropagation()},onScroll(e){L||V(e.currentTarget)},...S&&{style:L?{height:`100%`}:_9},className:!L&&S?VT.className:void 0},ne=Vr(`div`,e,{ref:[t,c],state:te,stateAttributesMapping:Qae,props:[N,H,dD(P),o]});return(0,K.jsxs)(U.Fragment,{children:[!O&&VT.getElement(D),(0,K.jsx)(HS,{context:y,modal:!1,disabled:!M,openInteractionType:j,returnFocus:a,restoreFocus:!0,children:ne})]})});function v9(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function y9(e){return rE(e.scrollHeight,e.clientHeight)}function b9(e){return OC.getScale(e)}function x9(e,t,n){return e/n[t]}function S9(e,t){return vx({x:x9(e.x,`x`,t),y:x9(e.y,`y`,t),width:x9(e.width,`x`,t),height:x9(e.height,`y`,t)})}var C9=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function eoe(e){let{style:t}=e,n={};for(let[e,r]of C9)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of C9){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var toe=U.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{store:o,scrollHandlerRef:s,multiple:c}=a9(),{alignItemWithTriggerActive:l}=h9(),u=bw(o,p9.hasScrollArrows),d=bw(o,p9.openMethod),f={id:`${bw(o,p9.id)}-list`,role:`listbox`,"aria-multiselectable":c||void 0,onScroll(e){s.current?.(e.currentTarget)},...l&&{style:_9},className:u&&d!==`touch`?VT.className:void 0};return Vr(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),w9=U.createContext(void 0);function T9(){let e=U.useContext(w9);if(!e)throw Error(Cr(57));return e}var noe=U.memo(U.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=U.useRef(null),d=Uj({guess:!0,label:o,textRef:u}),{store:f,itemProps:p,setOpen:m,setValue:h,selectionRef:g,typingRef:_,valuesRef:v,multiple:y,selectedItemTextRef:b,disabled:x,readOnly:S}=a9(),C=x||s,w=bw(f,p9.isActive,d.index),T=bw(f,p9.open),E=bw(f,p9.isSelected,a),D=bw(f,p9.isSelectedByFocus,d.index),O=bw(f,p9.isItemEqualToValue),k=d.index,A=U.useRef(null);X(()=>{let e=v.current;return e[k]=a,()=>{delete e[k]}},[k,a,v]),X(()=>{let e=f.state.value,t=e;y&&Array.isArray(e)&&(t=e.length>0?e[e.length-1]:void 0),t!==void 0&&o9(a,t,O)&&(f.set(`selectedIndex`,k),u.current&&(b.current=u.current))},[k,y,O,f,a,b]);let j=U.useRef(`mouse`),M=U.useRef(!1),{getButtonProps:N,buttonRef:P}=Py({disabled:C,focusableWhenDisabled:!0,native:c,composite:!0}),F={disabled:C,selected:E,highlighted:w};function I(e){if(x||S)return;let t=f.state.value;if(y){let n=Array.isArray(t)?t:[],r=E?Lae(n,a,O):[...n,a];h(r,Ky(By,e))}else h(a,Ky(By,e)),m(!1,Ky(By,e))}function L(){g.current.dragY=0}let R={role:`option`,"aria-selected":E,tabIndex:T&&w?0:-1,onKeyDown(e){f.set(`activeIndex`,k),e.key===` `&&_.current&&e.preventDefault()},onClick(e){let t=j.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&fb(e.nativeEvent)&&(n!==void 0||w),i=t&&!r&&!M.current;M.current=!1,!(C||i)&&I(e.nativeEvent)},onPointerEnter(e){j.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=g.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){j.current=e.pointerType,M.current=!0,L()},onMouseUp(){if(L(),C||j.current===`touch`||M.current)return;let e=!g.current.allowSelectedMouseUp&&E,t=!g.current.allowUnselectedMouseUp&&!E;e||t||(M.current=!0,A.current?.click(),M.current=!1)}},ee=Vr(`div`,e,{ref:[P,t,d.ref,A],state:F,props:[p,R,l,N]}),z=U.useMemo(()=>({selected:E,index:k,textRef:u,selectedByFocus:D}),[E,k,u,D]);return(0,K.jsx)(w9.Provider,{value:z,children:ee})})),roe=U.forwardRef(function(e,t){let{selected:n}=T9();return e.keepMounted||n?(0,K.jsx)(ioe,{...e,ref:t}):null}),ioe=U.memo(U.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=T9(),c=U.useRef(null),{transitionStatus:l,setMounted:u}=Dw(s),d=Vr(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:Kv});return kw({open:s,ref:c,onComplete(){s||u(!1)}}),d})),aoe=U.memo(U.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=T9(),{firstItemTextRef:a,selectedItemTextRef:o}=a9(),{render:s,className:c,style:l,...u}=e;return Vr(`div`,e,{ref:[U.useCallback(e=>{e&&(n===0&&(a.current=e),i&&(o.current=e))},[a,o,n,i]),t,r],props:u})})),E9=U.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,{store:l,popupRef:u,listRef:d,handleScrollArrowVisibility:f,scrollArrowsMountedCountRef:p}=a9(),{side:m,scrollDownArrowRef:h,scrollUpArrowRef:g}=h9(),_=bw(l,c?p9.scrollUpArrowVisible:p9.scrollDownArrowVisible),v=bw(l,p9.openMethod),y=_&&v!==`touch`,b=nb(),x=c?g:h,{mounted:S,transitionStatus:C,setMounted:w}=Dw(y);X(()=>(p.current+=1,l.set(`hasScrollArrows`,!0),()=>{p.current=Math.max(0,p.current-1),p.current===0&&l.set(`hasScrollArrows`,!1)}),[l,p]),kw({open:y,ref:x,onComplete(){y||w(!1)}});let T=Vr(`div`,e,{ref:[t,x],state:{direction:a,visible:y,side:m,transitionStatus:C},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||b.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??u.current;if(!e)return;l.set(`activeIndex`,null),f(e);let n=rE(e.scrollHeight,e.clientHeight),r=iE(e.scrollTop,n),i=r===(c?0:n),a=d.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){b.clear();return}if(a.length>0){let t=x.current?.offsetHeight||0;e.scrollTop=ooe(a,c,r,e.clientHeight,t,n)}b.start(40,t)}b.start(40,t)},onMouseLeave(){b.clear()}},s],stateAttributesMapping:Kv});return S||o?T:null});function ooe(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?iE(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?iE(l.offsetTop+l.offsetHeight-r+i,a):a}var soe=U.forwardRef(function(e,t){return(0,K.jsx)(E9,{...e,ref:t,direction:`down`})}),coe=U.forwardRef(function(e,t){return(0,K.jsx)(E9,{...e,ref:t,direction:`up`})}),D9=Vae;function O9({className:e,size:t=`default`,children:n,...r}){return(0,K.jsxs)(Gae,{className:G(iN(t),e),"data-slot":`select-trigger`,...r,children:[n,(0,K.jsx)(Jae,{"data-slot":`select-icon`,children:(0,K.jsx)(aN,{})})]})}function k9({className:e,...t}){return(0,K.jsx)(qae,{className:G(`flex-1 truncate data-placeholder:text-muted-foreground`,e),"data-slot":`select-value`,...t})}function A9({className:e,children:t,sideOffset:n=4,alignItemWithTrigger:r=!0,zIndex:i,...a}){let o=U.useContext(RE);return(0,K.jsx)(Yae,{children:(0,K.jsx)(Zae,{alignItemWithTrigger:r,className:`select-none`,style:{zIndex:i??o},"data-slot":`select-positioner`,sideOffset:n,children:(0,K.jsxs)($ae,{className:`origin-(--transform-origin) transition-[scale,opacity] has-data-[side=none]:scale-100 has-data-starting-style:scale-98 has-data-starting-style:opacity-0 has-data-[side=none]:transition-none`,"data-slot":`select-popup`,...a,children:[(0,K.jsx)(coe,{className:`top-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:top-px before:h-[200%] before:rounded-t-[calc(var(--radius-lg)-1px)] before:bg-linear-to-b before:from-50% before:from-popover`,"data-slot":`select-scroll-up-arrow`,children:(0,K.jsx)(bt,{className:`relative size-4.5 sm:size-4`})}),(0,K.jsx)(`span`,{className:`relative block h-full rounded-lg border bg-popover bg-clip-padding before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-lg dark:not-in-data-[slot=group]:bg-clip-border`,children:(0,K.jsx)(toe,{className:G(`max-h-(--available-height) min-w-(--anchor-width) overflow-y-auto p-1`,e),"data-slot":`select-list`,children:t})}),(0,K.jsx)(soe,{className:`bottom-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:bottom-px before:h-[200%] before:rounded-b-[calc(var(--radius-lg)-1px)] before:bg-linear-to-t before:from-50% before:from-popover`,"data-slot":`select-scroll-down-arrow`,children:(0,K.jsx)(_t,{className:`relative size-4.5 sm:size-4`})})]})})})}function j9({className:e,children:t,...n}){return(0,K.jsxs)(noe,{className:G(`grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-sm py-1 ps-2 pe-4 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,e),"data-slot":`select-item`,...n,children:[(0,K.jsx)(roe,{className:`col-start-1`,children:(0,K.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/1500/svg`,children:(0,K.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})}),(0,K.jsx)(aoe,{className:`col-start-2 min-w-0`,children:t})]})}function loe(e,t,n){return e.find(e=>e.id===t)?.id??e.find(e=>e.id===n)?.id??e[0]?.id??``}var M9={supervised:`受监督(每步确认)`,"auto-edits":`自动接受编辑`,full:`完全放行`,assistant:`助手代审`},N9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function uoe({projects:e,providers:t,open:n,preferredProjectId:r,onClose:i,onCreate:a}){let[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(`full`),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(`medium`),[v,y]=(0,U.useState)(n);n!==v&&(y(n),n&&s(null));let b=loe(e,o,r),x=t.find(e=>e.id===c)??t[0]??{id:``,models:[]},S=x.id,C=x.models.find(e=>e.id===u)?.id??x.models[0]?.id??``,w=!!(b&&S&&C);return(0,K.jsx)(Y7,{open:n,onOpenChange:e=>!e&&i(),children:(0,K.jsxs)(X7,{side:`bottom`,className:`pb-safe`,children:[(0,K.jsx)(Z7,{children:(0,K.jsx)(Q7,{children:`新建会话`})}),(0,K.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,K.jsx)(P9,{label:`项目`,children:(0,K.jsxs)(D9,{items:e.map(e=>({value:e.id,label:G7(e)})),value:b,onValueChange:e=>s(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,K.jsx)(j9,{value:e.id,children:G7(e)},e.id))})]})}),(0,K.jsx)(P9,{label:`模型服务`,children:(0,K.jsxs)(D9,{items:t.map(e=>({value:e.id,label:e.name})),value:S,onValueChange:e=>{l(e),d(null)},children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:t.map(e=>(0,K.jsx)(j9,{value:e.id,children:e.name},e.id))})]})}),(0,K.jsx)(P9,{label:`模型`,children:(0,K.jsxs)(D9,{items:x.models.map(e=>({value:e.id,label:e.label??e.id})),value:C,onValueChange:e=>d(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:x.models.map(e=>(0,K.jsx)(j9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,K.jsx)(P9,{label:`审批模式`,children:(0,K.jsxs)(D9,{items:Object.keys(M9).map(e=>({value:e,label:M9[e]})),value:f,onValueChange:e=>p(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:Object.keys(M9).map(e=>(0,K.jsx)(j9,{value:e,children:M9[e]},e))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,K.jsx)(EN,{checked:m,onCheckedChange:h})]}),m&&(0,K.jsx)(P9,{label:`推理档位`,children:(0,K.jsxs)(D9,{items:Object.keys(N9).map(e=>({value:e,label:N9[e]})),value:g,onValueChange:e=>_(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:Object.keys(N9).map(e=>(0,K.jsx)(j9,{value:e,children:N9[e]},e))})]})}),e.length===0&&(0,K.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端还没有项目,请先在桌面添加。`}),e.length>0&&t.length===0&&(0,K.jsx)(`p`,{className:`text-destructive text-xs`,children:`桌面端没有可用的模型服务。`}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,K.jsx)(Oa,{variant:`outline`,onClick:i,children:`取消`}),(0,K.jsx)(Oa,{disabled:!w,onClick:()=>a({projectId:b,providerId:S,modelId:C,approvalMode:f,...m?{reasoningEnabled:m,thinkingLevel:g}:{}}),children:`创建`})]})]})]})})}function P9({label:e,children:t}){return(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}var doe={pending:`待发送`,sending:`发送中…`,failed:`发送失败`};function foe({items:e,readOnly:t,onRetry:n,onDiscard:r}){return e.length===0?null:(0,K.jsx)(`div`,{className:`mb-1 space-y-1`,children:e.map(e=>(0,K.jsxs)(`div`,{className:G(`flex flex-wrap items-center gap-2 rounded-xl border px-2.5 py-1.5 text-xs`,e.status===`failed`?`border-destructive/40 bg-destructive/5`:`bg-muted/40`),children:[(0,K.jsx)(`span`,{className:G(`min-w-0 flex-1`,e.status===`failed`?`whitespace-pre-wrap break-words select-text`:`truncate`),children:e.text||(e.images?.length?`[${e.images.length} 张图片]`:``)}),(0,K.jsxs)(`span`,{className:G(`min-w-0 break-words`,e.status===`failed`?`text-destructive`:`text-muted-foreground`),children:[e.error?.startsWith(`outbox-discard`)?`移除消息`:e.error===`delivery-unconfirmed`?`结果未确认`:doe[e.status],e.status===`failed`&&e.error?`:${cae(e.error)}`:``]}),e.status===`failed`&&!e.error?.startsWith(`outbox-discard`)&&!t&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`重试`,onClick:()=>n(e.deliveryId),className:`shrink-0 rounded p-0.5 text-foreground hover:bg-accent`,children:(0,K.jsx)(Nn,{className:`h-3.5 w-3.5`})}),e.status!==`sending`&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`删除`,disabled:e.error===`outbox-discarding`,onClick:()=>r(e.deliveryId),className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-accent`,children:(0,K.jsx)(ir,{className:`h-3.5 w-3.5`})})]},e.deliveryId))})}function poe(){let e=globalThis.BarcodeDetector;if(!e)return null;let t=new e({formats:[`qr_code`]});return{async scan(e){return(await t.detect(e))[0]?.rawValue??null}}}async function moe(){let{default:t}=await J(async()=>{let{default:t}=await import(`./jsQR-B1eQcpQl.js`).then(t=>e(t.default,1));return{default:t}},__vite__mapDeps([148,1])),n=document.createElement(`canvas`),r=n.getContext(`2d`,{willReadFrequently:!0});return{async scan(e){if(!r||!e.videoWidth)return null;let i=Math.min(1,640/Math.max(e.videoWidth,e.videoHeight));n.width=Math.round(e.videoWidth*i),n.height=Math.round(e.videoHeight*i),r.drawImage(e,0,0,n.width,n.height);let{data:a,width:o,height:s}=r.getImageData(0,0,n.width,n.height);return t(a,o,s,{inversionAttempts:`dontInvert`})?.data??null}}}async function hoe(){return poe()??await moe()}function goe(e){try{return Ee(e),!0}catch{return!1}}function _oe({onPaired:e,autoInvite:t,onCancel:n,notice:r}){let[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(!1),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=()=>{for(let e of p.current?.getTracks()??[])e.stop();p.current=null,d(!1)},h=async t=>{s(!0),l(null);try{let n=Ee(t),r=/iPhone|iPad|Android/i.exec(navigator.userAgent)?.[0]??`Phone`,i=await ke(n.relay,n.publicKey,r);e({pairId:i.pairId,token:i.deviceToken,contentKey:btoa(String.fromCharCode(...i.contentKey)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``),deviceName:r,relayUrl:n.relay,pairedAt:Date.now()})}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}},g=(0,U.useRef)(!1);(0,U.useEffect)(()=>{!t||g.current||(g.current=!0,h(t))},[t]);let _=(0,U.useRef)(()=>{});_.current=e=>{m(),h(e)};let v=async()=>{l(null);try{p.current=await navigator.mediaDevices.getUserMedia({video:{facingMode:`environment`}}),d(!0)}catch(e){l(window.isSecureContext?e instanceof DOMException&&e.name===`NotAllowedError`?`摄像头权限被拒绝,请在浏览器设置中允许后重试`:`无法访问摄像头,请粘贴配对码`:`扫码需要 HTTPS 环境,请改用粘贴配对码`),d(!1)}};return(0,U.useEffect)(()=>{if(!u)return;let e=f.current,t=p.current;if(!e||!t)return;let n=!1,r=0;return e.srcObject=t,e.muted=!0,(async()=>{try{await e.play();let t=await hoe(),i=async()=>{if(!(n||!p.current)){try{let n=await t.scan(e);if(n&&goe(n)){_.current(n);return}}catch{}r=requestAnimationFrame(()=>void i())}};await i()}catch{n||l(`无法开始预览,请粘贴配对码`)}})(),()=>{n=!0,cancelAnimationFrame(r)}},[u]),(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-5 px-6 pt-safe pb-safe`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 text-center`,children:[(0,K.jsx)(`span`,{className:`mb-2 flex size-11 items-center justify-center rounded-[13px] border border-brand/20 bg-brand/8 text-brand dark:bg-brand/14`,children:(0,K.jsx)(RN,{className:`size-6`})}),(0,K.jsx)(`h1`,{className:`font-medium text-lg`,children:`连接到 EnsoCode`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`在桌面端「设置 → 手机」生成配对码,扫码或粘贴。`}),r?(0,K.jsx)(`p`,{role:`status`,className:`mt-2 max-w-sm rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-left text-amber-700 text-xs dark:text-amber-300`,children:r}):null]}),u?(0,K.jsxs)(`div`,{className:`w-full max-w-sm space-y-2`,children:[(0,K.jsx)(`video`,{ref:f,playsInline:!0,muted:!0,className:`aspect-square w-full rounded-lg bg-black object-cover`}),(0,K.jsx)(Oa,{variant:`outline`,className:`w-full`,onClick:m,children:`取消扫码`})]}):(0,K.jsxs)(Oa,{className:`w-full max-w-sm`,onClick:()=>void v(),children:[(0,K.jsx)(ht,{className:`mr-1.5 h-4 w-4`}),`扫描二维码`]}),(0,K.jsxs)(`div`,{className:`flex w-full max-w-sm items-center gap-2`,children:[(0,K.jsx)(rG,{value:i,onChange:e=>a(e.target.value),placeholder:`enso://pair?relay=…`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`font-mono text-xs`}),(0,K.jsx)(Oa,{variant:`outline`,className:`shrink-0`,disabled:o||!i.trim(),onClick:()=>void h(i.trim()),children:o?(0,K.jsx)(sn,{className:`h-4 w-4 animate-spin`}):`配对`})]}),c&&(0,K.jsx)(`p`,{className:`max-w-sm text-center text-destructive text-xs`,children:c}),n&&(0,K.jsx)(Oa,{variant:`ghost`,className:`w-full max-w-sm`,onClick:n,children:`返回`})]})}var F9={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`};function voe({providers:e,config:t,open:n,onClose:r,onSetModel:i,onSetReasoning:a,onSetThinking:o}){let s=e.find(e=>e.id===t.providerId),c=t.reasoningEnabled??!1,l=t.thinkingLevel??`medium`;return(0,K.jsx)(Y7,{open:n,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(X7,{side:`bottom`,className:`pb-safe`,children:[(0,K.jsx)(Z7,{children:(0,K.jsx)(Q7,{children:`会话设置`})}),(0,K.jsxs)(`div`,{className:`space-y-4 p-4 pt-0`,children:[(0,K.jsx)(I9,{label:`模型服务`,children:(0,K.jsxs)(D9,{items:e.map(e=>({value:e.id,label:e.name})),value:t.providerId??``,onValueChange:t=>{let n=e.find(e=>e.id===t),r=n?.models[0]?.id;n&&r&&i(n.id,r)},children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:e.map(e=>(0,K.jsx)(j9,{value:e.id,children:e.name},e.id))})]})}),(0,K.jsx)(I9,{label:`模型`,children:(0,K.jsxs)(D9,{items:(s?.models??[]).map(e=>({value:e.id,label:e.label??e.id})),value:t.modelId??``,onValueChange:e=>{t.providerId&&i(t.providerId,e)},children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:(s?.models??[]).map(e=>(0,K.jsx)(j9,{value:e.id,children:e.label??e.id},e.id))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`推理`}),(0,K.jsx)(EN,{checked:c,onCheckedChange:a})]}),c&&(0,K.jsx)(I9,{label:`推理档位`,children:(0,K.jsxs)(D9,{items:Object.keys(F9).map(e=>({value:e,label:F9[e]})),value:l,onValueChange:e=>o(e),children:[(0,K.jsx)(O9,{className:`w-full`,children:(0,K.jsx)(k9,{})}),(0,K.jsx)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:Object.keys(F9).map(e=>(0,K.jsx)(j9,{value:e,children:F9[e]},e))})]})}),(0,K.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`模型切换对运行中的会话在下次启动时生效;推理档位即时生效。`})]})]})})}function I9({label:e,children:t}){return(0,K.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e}),t]})}var L9=`__all__`,yoe=`__ungrouped__`;function R9(e){return new Set(e.map(e=>e.id))}function z9(e,t){return t.includes(e)}function boe(e,t){let n=e.groupId;return!n||!R9(t).has(n)}function xoe(e,t,n,r){let i=e.filter(e=>!z9(e.id,n));return r===`__all__`||r===`__recent__`?i:r===`__ungrouped__`?i.filter(e=>boe(e,t)):i.filter(e=>e.groupId===r)}function Soe(e,t,n){let r=e.filter(e=>!z9(e.id,n)),i=[...t].sort((e,t)=>e.order-t.order),a=R9(t),o=i.map(e=>({groupId:e.id,group:e,projects:r.filter(t=>t.groupId===e.id)})),s=r.filter(e=>!e.groupId||!a.has(e.groupId));return s.length>0&&o.push({groupId:yoe,projects:s}),o}var Coe=`default`;function woe(e,t){return e===`__recent__`?{kind:`all`,fallbackFrom:`recent`}:e===`__ungrouped__`?{kind:`ungrouped`}:e!==`__all__`&&t.some(t=>t.id===e)?{kind:`group`,groupId:e}:{kind:`all`}}var Toe=e=>e?.secretaryOrigin?e.secretaryOrigin.secretaryId??Coe:void 0;function Eoe(e,t,{projects:n,projectGroups:r,conversations:i}){switch(t.kind){case`all`:return[...e];case`secretary`:return e.map(e=>({...e,ids:e.ids.filter(e=>Toe(i[e])===t.secretaryId)})).filter(e=>e.ids.length>0);default:{let i=new Set(r.map(e=>e.id));return e.filter(e=>{let r=n.find(t=>t.id===e.projectId)?.groupId;return t.kind===`group`?r===t.groupId:!r||!i.has(r)})}}}function Doe(e){return e.status===`failed`&&!e.spawning?`failed`:e.queued?`queued`:(e.pendingAskCount??0)>0?`waiting`:e.status===`running`||e.spawning||e.hasRunningChild?`running`:e.hasPendingReminder?`reminder`:e.unread?`unread`:`idle`}function B9(e){return[...e].sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))}function V9(e){let t=e=>(e.pendingAskCount??0)>0||(e.pendingApprovalCount??0)>0;return[...e.filter(t),...e.filter(e=>!t(e))]}function Ooe(e,t){let n=B9(e),r=new Map(n.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}return[...i,...V9([...r.values()])]}function H9(e){return V9([...B9(e.filter(e=>e.pinned)),...B9(e.filter(e=>!e.pinned))])}function U9(e,t){return Doe({status:e.queueFailed?`failed`:e.status,unread:e.unread,pendingAskCount:e.pendingAskCount,hasRunningChild:t,queued:e.status===`queued`&&!e.queueFailed||e.parked===`upstream`,hasPendingReminder:e.parked===`reminder`})}function koe(e,t){return U9(e,t)!==`idle`||e.goal?.status===`active`}function Aoe(e,t){let n=B9(e.filter(e=>koe(e,t(e.id)))),r=e=>{let n=U9(e,t(e.id));return n===`queued`||n===`reminder`};return[...n.filter(e=>!r(e)),...n.filter(r)]}function W9(e,t){return e<=0?0:Math.min(e,5+Math.max(0,t))}function joe(e,t){return W9(e,t)>=e?0:Math.min(Math.max(0,e-5),t+15)}function Moe(e){return Math.max(0,e-15)}var Noe=[{value:`auto`,label:`跟随桌面`},{value:`light`,label:`浅`},{value:`dark`,label:`深`}];function Poe({open:e,docked:t=!1,pinnable:n=!1,onTogglePinned:r,projects:i,groups:a=[],catalog:o,pinnedOrder:s=[],activeId:c,canCreate:l,devices:u,activeDevicePairId:d,remoteDesktop:f,connected:p,connectionLabel:m,pushEnabled:g,pushBusy:v,pushError:y,pushAvailability:b,pushConfigReady:x,onTogglePush:S,onClose:C,onSelect:w,onNewConversation:T,onSwitchDevice:E,onAddDevice:D,onRenameDevice:O,onUnpairDevice:k,botSegment:A}){let j=A?.active===!0,[M,N]=(0,U.useState)({}),[P,F]=(0,U.useState)({}),[I,L]=(0,U.useState)(!1),[R,ee]=(0,U.useState)(!1),[z,V]=(0,U.useState)(null),te=f?u.find(e=>e.pairId===d&&e.scope!==`read`):void 0,[ne,re]=(0,U.useState)(_),[ie,ae]=(0,U.useState)(()=>{try{return localStorage.getItem(`enso-phone-selected-project-group`)??`__all__`}catch{return L9}}),[oe,se]=(0,U.useState)({}),le=ie===`__all__`||ie===`__ungrouped__`||a.some(e=>e.id===ie)?ie:L9;(0,U.useEffect)(()=>ee(!1),[le]),(0,U.useEffect)(()=>h(()=>re(_())),[]),(0,U.useEffect)(()=>{e||V(null)},[e]);let[ue,de]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{if(!e)return;de(Date.now());let t=setInterval(()=>de(Date.now()),6e4);return()=>clearInterval(t)},[e]);let fe=new Set(i.filter(e=>e.archived).map(e=>e.id)),pe=[...fe],me=e=>e.archived||fe.has(e.projectId),he=xoe(i,a,pe,le),ge=Soe(i,a,pe),_e=new Set(he.map(e=>e.id)),ve=o.filter(e=>!e.parentId),ye=e=>!e.projectId||_e.has(e.projectId),be=Aoe(ve.filter(e=>!me(e)&&ye(e)),e=>o.some(t=>t.parentId===e&&t.status===`running`)),xe=Ooe(ve.filter(e=>e.pinned&&!me(e)&&ye(e)),s),Se=B9(ve.filter(me)),Ce=woe(le,a),we=new Set(Eoe(Se.map(e=>({projectId:e.projectId,ids:[e.id]})),Ce,{projects:i,projectGroups:a,conversations:{}}).flatMap(e=>e.ids)),Te=Se.filter(e=>we.has(e.id)),Ee=Ce.kind!==`all`,De=R?Se:Te,Oe=!Ee||R?`范围:全部归档`:Ce.kind===`group`?`范围:分组「${a.find(e=>e.id===Ce.groupId)?.name??``}」的归档`:`范围:未分组项目的归档`,ke=ve.filter(e=>!me(e)),Ae=new Set(i.map(e=>e.id)),je=H9(ke.filter(e=>!Ae.has(e.projectId)));return(0,K.jsxs)(K.Fragment,{children:[!t&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`关闭侧栏`,onClick:C,className:G(`fixed inset-0 z-40 bg-black/40 transition-[opacity,visibility] duration-200`,e?`visible opacity-100`:`invisible pointer-events-none opacity-0`)}),(0,K.jsxs)(`aside`,{className:G(`flex shrink-0 flex-col border-r bg-background`,t?`relative h-full w-72`:G(`fixed inset-y-0 left-0 z-50 w-[82vw] max-w-xs transition-transform duration-200`,e?`translate-x-0`:`-translate-x-full`)),children:[(0,K.jsxs)(`div`,{className:G(`flex h-12 shrink-0 items-center justify-between px-3 pt-safe`,a.length===0&&`border-b`),children:[A?(0,K.jsx)(`span`,{className:`flex rounded-lg bg-muted p-0.5 text-sm`,children:[`项目`,`Bot`].map(e=>{let t=e===`Bot`===A.active;return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>A.onChange(e===`Bot`),className:G(`rounded-md px-3 py-0.5 transition-colors`,t?`bg-background font-medium shadow-xs`:`text-muted-foreground`),children:e},e)})}):(0,K.jsx)(`span`,{className:`font-medium text-sm`,children:`项目`}),t?n&&r?(0,K.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`收起侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(yn,{className:`h-4 w-4`})}):null:(0,K.jsxs)(`span`,{className:`flex items-center`,children:[n&&r&&(0,K.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`固定侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(bn,{className:`h-4 w-4`})}),(0,K.jsx)(`button`,{type:`button`,onClick:C,"aria-label":`关闭侧栏`,className:`rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(ir,{className:`h-4 w-4`})})]})]}),!j&&a.length>0&&(0,K.jsx)(`div`,{className:`shrink-0 border-b px-3 pb-2`,children:(0,K.jsxs)(D9,{items:[{value:`__all__`,label:`全部`},...a.slice().sort((e,t)=>e.order-t.order).map(e=>({value:e.id,label:`${e.emoji?`${e.emoji} `:``}${e.name}`})),{value:`__ungrouped__`,label:`未分组`}],value:le,onValueChange:e=>{if(e){ae(e);try{localStorage.setItem(`enso-phone-selected-project-group`,e)}catch{}}},children:[(0,K.jsx)(O9,{className:`w-full`,size:`sm`,children:(0,K.jsx)(k9,{})}),(0,K.jsxs)(A9,{zIndex:LE.DROPDOWN_IN_MODAL,children:[(0,K.jsx)(j9,{value:`__all__`,children:`全部`}),a.slice().sort((e,t)=>e.order-t.order).map(e=>(0,K.jsxs)(j9,{value:e.id,children:[e.emoji?`${e.emoji} `:``,e.name]},e.id)),(0,K.jsx)(j9,{value:`__ungrouped__`,children:`未分组`})]})]})}),j?A?.panel:(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2`,children:[i.length===0&&(0,K.jsx)(`p`,{className:`rounded-lg border border-dashed px-3 py-6 text-center text-muted-foreground text-sm`,children:`桌面端还没有项目`}),be.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:(0,K.jsx)(`span`,{className:`font-medium text-sm`,children:`活跃中`})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:be.map(e=>(0,K.jsx)(G9,{session:e,active:c===e.id,nowTick:ue,onSelect:w},e.id))})]}),xe.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-2`,children:[(0,K.jsx)(wn,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`font-medium text-sm`,children:`置顶`})]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-y-0.5`,children:xe.map(e=>(0,K.jsx)(G9,{session:e,active:c===e.id,nowTick:ue,onSelect:w},e.id))})]}),(le===`__all__`&&a.length>0?ge.flatMap(e=>{let t=oe[e.groupId]===!0;return[{kind:`header`,section:e,folded:t},...t?[]:e.projects.map(e=>({kind:`project`,project:e}))]}):he.map(e=>({kind:`project`,project:e}))).map(e=>e.kind===`header`?(0,K.jsxs)(`button`,{type:`button`,onClick:()=>se(t=>({...t,[e.section.groupId]:!t[e.section.groupId]})),className:`flex h-7 w-full items-center gap-1 rounded-md px-2 text-left text-xs font-medium text-muted-foreground`,children:[(0,K.jsx)(vt,{className:G(`h-3.5 w-3.5 shrink-0 transition-transform duration-150`,!e.folded&&`rotate-90`)}),e.section.group?.emoji&&(0,K.jsx)(`span`,{className:`shrink-0 text-sm`,children:e.section.group.emoji}),e.section.group?.color&&(0,K.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.section.group.color}}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.section.group?.name??`未分组`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:e.section.projects.length})]},`hdr-${e.section.groupId}`):(0,K.jsx)(K9,{name:W7(e.project),badge:U7(e.project),sessions:H9(ke.filter(t=>t.projectId===e.project.id)),folded:M[e.project.id]===!0,revealedExtra:P[e.project.id]??0,activeId:c,nowTick:ue,canCreate:l,onToggleFold:()=>N(t=>({...t,[e.project.id]:!t[e.project.id]})),onRevealMore:t=>F(n=>({...n,[e.project.id]:t})),onSelect:w,onNew:()=>T(e.project.id)},e.project.id)),je.length>0&&(0,K.jsx)(K9,{name:`其他`,sessions:je,folded:M.__orphan===!0,revealedExtra:P.__orphan??0,activeId:c,nowTick:ue,canCreate:!1,onToggleFold:()=>N(e=>({...e,__orphan:!e.__orphan})),onRevealMore:e=>F(t=>({...t,__orphan:e})),onSelect:w})]}),!j&&(0,K.jsxs)(`div`,{className:`shrink-0 border-t p-2`,children:[I&&(0,K.jsxs)(`div`,{className:`mb-0.5 flex max-h-64 flex-col gap-y-0.5 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1`,children:[(0,K.jsx)(`span`,{"data-slot":`archive-scope`,className:`min-w-0 flex-1 truncate text-[11px] text-muted-foreground`,children:Oe}),Ee&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>ee(e=>!e),className:`shrink-0 rounded-full border px-2 py-0.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60`,children:R?`仅本分组`:`全部归档`})]}),De.length===0&&(0,K.jsx)(`p`,{className:`px-2 py-3 text-center text-muted-foreground text-xs`,children:`没有归档会话`}),De.map(e=>(0,K.jsx)(G9,{session:e,active:c===e.id,nowTick:ue,subtitle:(()=>{let t=i.find(t=>t.id===e.projectId);return t?W7(t):void 0})(),onSelect:w},e.id))]}),(0,K.jsxs)(`button`,{type:`button`,"data-slot":`archived-button`,"data-empty":Te.length===0||void 0,onClick:()=>L(e=>!e),className:G(`flex w-full items-center gap-1 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60`,Te.length===0&&`opacity-55`),children:[(0,K.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,K.jsx)(vt,{className:G(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,I?`-rotate-90`:`rotate-0`)})}),(0,K.jsx)(it,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground text-sm`,children:`已归档`}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:Te.length})]})]}),(0,K.jsxs)(`div`,{className:`shrink-0 space-y-1 border-t p-2 pb-safe`,children:[!z&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,K.jsx)(vn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`主题`}),(0,K.jsx)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:Noe.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>B(e.value),className:G(`rounded px-2 py-1 text-[11px] transition-colors`,ne===e.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent`),children:e.label},e.value))})]}),!z&&te&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,K.jsx)(hn,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`界面`}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-0.5 rounded-md border p-0.5`,children:[(0,K.jsx)(`span`,{className:`rounded bg-primary px-2 py-1 text-[11px] text-primary-foreground`,children:`精简`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{window.location.href=H(te.pairId)},className:`rounded px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent`,children:`完整`})]})]}),!z&&(0,K.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(dt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground text-sm`,children:`推送通知`}),(0,K.jsx)(EN,{checked:g,disabled:v||b!==`ok`||!p||!x,onCheckedChange:S})]}),ce({busy:v,error:y,availability:b,connected:p,configReady:x}).map(e=>(0,K.jsx)(`p`,{className:G(`mt-1 pl-6 text-[11px]`,e.error?`text-destructive`:`text-muted-foreground`),children:e.text},e.text))]}),(0,K.jsxs)(`div`,{className:`space-y-0.5`,children:[u.map(e=>{let t=e.pairId===d;return z===e.pairId?(0,K.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-dashed p-3`,children:[(0,K.jsxs)(`p`,{className:`text-xs`,children:[`解绑「`,e.label,`」后需重新扫码才能连接,确定吗?`]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(Oa,{variant:`outline`,size:`sm`,onClick:()=>V(null),children:`取消`}),(0,K.jsx)(Oa,{variant:`destructive`,size:`sm`,onClick:()=>{V(null),k(e.pairId)},children:`确定解绑`})]})]},e.pairId):(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>E(e.pairId),className:G(`flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 py-2 text-left text-sm transition-colors hover:bg-muted/60`,t?`text-foreground`:`text-muted-foreground`),children:[(0,K.jsx)(rn,{className:`h-4 w-4 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),t&&(0,K.jsx)(`span`,{className:G(`shrink-0 text-[10px]`,p?`text-muted-foreground`:`text-destructive`),children:m})]}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`重命名 ${e.label}`,onClick:()=>{let t=window.prompt(`给这台电脑起个名:`,e.label);t?.trim()&&O(e.pairId,t)},className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(Cn,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`解绑 ${e.label}`,onClick:()=>V(e.pairId),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent hover:text-destructive`,children:(0,K.jsx)($n,{className:`h-3.5 w-3.5`})})]},e.pairId)}),(0,K.jsxs)(`button`,{type:`button`,onClick:D,className:`flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left text-muted-foreground text-sm transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,K.jsx)(Dn,{className:`h-4 w-4 shrink-0`}),(0,K.jsx)(`span`,{children:`配对新电脑`})]})]}),(0,K.jsxs)(`p`,{className:`px-2 pt-0.5 text-center text-[10px] text-muted-foreground/60`,children:[`版本 `,`1983285-dirty`]})]})]})]})}function G9({session:e,active:t,nowTick:n,subtitle:r,onSelect:i}){return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:G(`flex w-full items-center gap-2 rounded-lg py-2 pr-2 pl-4 text-left text-sm transition-colors`,t?`bg-brand/10 dark:bg-brand/15`:`hover:bg-muted/60`),children:[(0,K.jsx)(Foe,{status:e.status,unread:e.unread,conversationId:e.id,queuePosition:e.queuePosition,queueFailed:e.queueFailed}),e.pinned&&(0,K.jsx)(wn,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),e.muted&&(0,K.jsx)(ut,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-label":`静音`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[e.title||`新对话`,r&&(0,K.jsx)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:r})]}),e.updatedAt&&(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/80 tabular-nums`,children:$7(e.updatedAt,`zh`,n)})]})}function K9({name:e,badge:t,sessions:n,folded:r,revealedExtra:i,activeId:a,nowTick:o,canCreate:s,onToggleFold:c,onRevealMore:l,onSelect:u,onNew:d}){let{t:f}=q(),p=W9(n.length,i),m=n.slice(0,p),h=n.length-p;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex w-full items-center gap-1 rounded-lg px-2 py-2 transition-colors hover:bg-muted/60`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:c,className:`flex min-w-0 flex-1 items-center gap-1 text-left`,children:[(0,K.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,K.jsx)(vt,{className:G(`h-3.5 w-3.5 text-muted-foreground transition-transform duration-200`,!r&&`rotate-90`)})}),(0,K.jsx)(Wt,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-sm`,children:[e,t&&(0,K.jsx)(`span`,{className:`ml-1.5 rounded bg-muted px-1 py-0.5 text-[10px] font-normal text-muted-foreground`,children:t})]}),(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground tabular-nums`,children:n.length})]}),s&&d&&(0,K.jsx)(`button`,{type:`button`,onClick:d,className:`shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,K.jsx)(dn,{className:`h-3.5 w-3.5`})})]}),!r&&(0,K.jsxs)(`div`,{className:`mt-0.5 flex flex-col gap-y-0.5`,children:[m.map(e=>(0,K.jsx)(G9,{session:e,active:a===e.id,nowTick:o,onSelect:u},e.id)),n.length>5&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[h>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(joe(n.length,i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Show {{n}} more`,{n:h})}),i>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>l(Moe(i)),className:`flex-1 rounded-lg py-1 text-center text-muted-foreground text-xs transition-colors hover:bg-muted/60 hover:text-foreground`,children:f(`Collapse`)})]})]})]})}function Foe({status:e,unread:t,conversationId:n,queuePosition:r,queueFailed:i}){let{t:a}=q();if(e===`queued`&&!i){let e=a(`Queued · #{{n}}, starts automatically when a slot opens`,{n:r??1});return(0,K.jsx)(rt,{className:`h-3.5 w-3.5 shrink-0 text-orange-500`,"aria-label":e,title:e,"data-enso":`conversation-queued`,"data-conversation-id":n,"data-tone":`queued`})}let o=e===`running`,s=!o&&(e===`failed`||e===`queued`&&!!i),c=!o&&!s&&t===!0;return(0,K.jsx)(`span`,{title:i,className:G(`h-1.5 w-1.5 shrink-0 rounded-full`,o&&`animate-pulse bg-brand`,s&&`bg-destructive`,c&&`bg-green-500`,!o&&!s&&!c&&`bg-muted-foreground/30`)})}function Ioe(e,t){return e?t.some(e=>e.status===`running`||typeof e.pendingAskCount==`number`&&e.pendingAskCount>0||typeof e.pendingApprovalCount==`number`&&e.pendingApprovalCount>0):!1}var q9=null;async function J9(e,t=typeof navigator>`u`?void 0:navigator.wakeLock){if(!e||!t){if(!q9)return;let e=q9;q9=null;try{await e.release()}catch{}return}if(!q9)try{let e=await t.request(`screen`);q9=e,e.addEventListener(`release`,()=>{q9===e&&(q9=null)})}catch{q9=null}}function Loe(){if(!window.location.hash.replace(/^#/,``).includes(`pk=`))return null;let e=window.location.href;return history.replaceState(null,``,window.location.pathname+window.location.search),e}var Y9=`enso-phone-sidebar-pinned`,Roe=R();function zoe(){let e=k(window.location.search);if(!e)return null;let t=new URLSearchParams(window.location.search);t.delete(`session`);let n=t.toString();return history.replaceState(null,``,window.location.pathname+(n?`?${n}`:``)),e}function Boe(){return ue()?`ok`:/iphone|ipad|ipod/i.test(navigator.userAgent)&&!te()?`needs-install`:`unsupported`}function Voe(){let[e,t]=(0,U.useState)(F),[n,i]=(0,U.useState)(Me),o=x(e,n),[c]=(0,U.useState)(Loe),[u]=(0,U.useState)(ve),[f,m]=(0,U.useState)(u),[h,g]=(0,U.useState)(null),_=o!==null;(0,U.useEffect)(()=>{if(_)return;let e=!1;return r().then(t=>{e||g(C({paired:!1,marked:t,standalone:te()}))}),()=>{e=!0}},[_]);let[b,S]=(0,U.useState)(`connecting`),[w,T]=(0,U.useState)(`relay`),[E,O]=(0,U.useState)(null),[k,A]=(0,U.useState)([]),[M,P]=(0,U.useState)([]),[I,L]=(0,U.useState)([]),[R,B]=(0,U.useState)([]),[V,ne]=(0,U.useState)([]),[ie]=(0,U.useState)(zoe),[ae]=(0,U.useState)(()=>d(o?.pairId??null,ie)),[se,ce]=(0,U.useState)(ae.activeId),[le,ue]=(0,U.useState)(null),[fe,pe]=(0,U.useState)(!1),[me,he]=(0,U.useState)(new Set),[_e,ye]=(0,U.useState)([]),[xe,Se]=(0,U.useState)(!1),Ce=Nae(Pae),[we,Ee]=(0,U.useState)(()=>localStorage.getItem(Y9)!==`off`),De=Ce&&we,Oe=()=>{Ee(e=>(localStorage.setItem(Y9,e?`off`:`on`),!e))},[ke,Ae]=(0,U.useState)(!1),[je,Ne]=(0,U.useState)(null),[Ie,Le]=(0,U.useState)(!1),[ze,Be]=(0,U.useState)(()=>localStorage.getItem(de)===`on`),[Ve,He]=(0,U.useState)(!1),[Ue,We]=(0,U.useState)(!1),[Ge,Ke]=(0,U.useState)(!1),[Je,Ye]=(0,U.useState)(!1),[Xe,Ze]=(0,U.useState)(!1),[Qe,$e]=(0,U.useState)(null),[et,tt]=(0,U.useState)(!1),[nt,W]=(0,U.useState)(!1),[rt,it]=(0,U.useState)(!1),at=(0,U.useRef)(!1),[ot,st]=(0,U.useState)(!1),[ct,lt]=(0,U.useState)(!1),ut=(0,U.useRef)(!1),[dt,ft]=(0,U.useState)([]),[pt,mt]=(0,U.useState)([]),[ht,gt]=(0,U.useState)([]),[_t,vt]=(0,U.useState)(!1),[yt,bt]=(0,U.useState)([]),[xt,St]=(0,U.useState)({items:[],offset:0}),[Ct,wt]=(0,U.useState)(()=>q7(!0,ae.botChatId)),[Tt,Et]=(0,U.useState)(ae.botChatId),[Dt,Ot]=(0,U.useState)(null),[kt,At]=(0,U.useState)({}),[jt,Mt]=(0,U.useState)({}),[Nt,Pt]=(0,U.useState)({}),[Ft,It]=(0,U.useState)(null),Lt=(0,U.useRef)(null),Rt=(0,U.useMemo)(()=>new Wa(e=>Ut.current?.send(e)),[]),zt=(0,U.useMemo)(()=>new ms(e=>Ut.current?.send(e)),[]),Bt=(0,U.useMemo)(()=>new gs(e=>Ut.current?.send(e)),[]),[Vt,Ht]=(0,U.useState)([]),Ut=(0,U.useRef)(null),Wt=(0,U.useRef)(se),Gt=(0,U.useRef)(k),Kt=(0,U.useRef)(le);Gt.current=k,Kt.current=le,Wt.current=se;let qt=Tt?ht.find(e=>e.id===Tt):void 0,Jt=qt?.kind===`group`?qo(qt,dt):void 0,Yt=Jt?.current??qt,Xt=qt?.kind===`direct`?qt.sessions[qt.members[0]]?.conversationId??null:null,Zt=Tt?Xt??Dt:se,Qt=(0,U.useRef)(Zt);Qt.current=Zt;let $t=(0,U.useRef)(ht);$t.current=ht;let en=(0,U.useRef)(Tt);en.current=Tt;let tn=(0,U.useRef)(null);tn.current=Jt?.current.id??null;let nn=(0,U.useRef)(new Set);nn.current=new Set(Jt?Object.values(Jt.current.sessions).map(e=>e.conversationId):[]);let rn=(0,U.useRef)(null),an=(0,U.useRef)(new Map),on=(0,U.useRef)(null),[sn,cn]=(0,U.useState)(!1),ln=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(Pe(),!(`serviceWorker`in navigator))return;let e=e=>{let t=e.data;if(t?.type!==`open-session`)return;let n=p(t.sessionId);if(!n)return;let r=$t.current.find(e=>Object.values(e.sessions).some(e=>e.conversationId===n));r?(Et(r.id),Ot(null)):(Et(null),ce(n)),Dn()};return navigator.serviceWorker.addEventListener(`message`,e),()=>navigator.serviceWorker.removeEventListener(`message`,e)},[]),(0,U.useEffect)(()=>{ja(ka(k))},[k]),(0,U.useEffect)(()=>{let e=()=>{J9(Ioe(document.visibilityState===`visible`&&b===`online`,k))};return e(),document.addEventListener(`visibilitychange`,e),document.addEventListener(`pointerdown`,e,{passive:!0}),()=>{document.removeEventListener(`visibilitychange`,e),document.removeEventListener(`pointerdown`,e),J9(!1)}},[k,b]),(0,U.useEffect)(()=>{if(ie){y();return}y().then(e=>{e&&(Et(null),Ot(null),ce(e),Dn())})},[ie]),(0,U.useEffect)(()=>{c&&e.length>0&&m(!0)},[]),(0,U.useEffect)(()=>{if(!o)return;ln.current=null,He(!1),he(new Set),T(`relay`),We(!1),Ke(!1),Ye(!1),W(!1),it(!1),at.current=!1,st(!1),lt(!1),ut.current=!1;let e=()=>{We(!0),Ye(!0)},t=new ee(o,{onState:e=>{e!==`online`&&(Lt.current?.interrupted(),Rt.reset(),zt.reset(),Bt.reset(),W(!1),st(!1)),S(e)},onBotArtifacts:e=>Rt.receive(e),onBotArtifactImage:e=>Rt.receiveImage(e),onBotNewSessionResult:t=>{zt.receive(t),t.error===`read-only`&&e()},onBotThreadResult:t=>{Bt.receive(t),t.error===`read-only`&&e()},onTransport:e=>{T(e),O(null)},onRtt:O,onRemoteDesktop:Ke,onReadOnly:e=>{We(e),e||Ye(!1)},onCommandRejected:(t,n)=>{n===`read-only`&&e()},onCatalog:(e,t)=>{A(e),P(t??[])},onProjects:(e,t)=>{L(e),B(t??[])},onProviders:ne,onSession:(e,t)=>{ue(n=>e===Qt.current?t:n),nn.current.has(e)&&Pt(n=>({...n,[e]:t}))},onBotCatalog:(e,t,n,r)=>{tt(e),W(e&&n),st(e&&r),mt(t),!e&&(gt([]),ft([]),bt([]),St({items:[],offset:0}),Et(null),Ot(null),wt(!1))},onBotChats:(e,t)=>{gt(e),ft(t),vt(!0)},onBotInbox:bt,onBotActivity:(e,t)=>{for(let t of e)an.current.set(t.conversationId,t.botId);St({items:e,offset:t})},onGroupTimeline:e=>{e.beforeSeq!==void 0&&on.current===`${e.chatId}:${e.beforeSeq}`&&(on.current=null,cn(!1)),At(t=>({...t,[e.chatId]:Zo(t[e.chatId],e)}))},onBotChatState:({type:e,chatId:t,...n})=>Mt(e=>({...e,[t]:n})),onBotEvent:e=>{if(e.kind===`model-notice`){e.text&&(e.chatId===en.current||e.chatId===tn.current)&&It(e.text);return}!e.chatId||e.chatId!==tn.current||rn.current||(rn.current=setTimeout(()=>{rn.current=null;let e=tn.current;e&&t.send({type:`bot-chat-open`,chatId:e})},200))},onBotSendResult:t=>{Lt.current?.settle(t.deliveryId,t.ok,t.error),t.error===`read-only`&&e()},onBotRetryResult:e=>{e.chatId===tn.current&&It(e.ok?`已开始重试`:`重试失败:${e.error===`session-busy`?`请等当前回复结束`:`该回复已过期或无法恢复,请重新发送需求`}`)},onSync:e=>pe(e===`syncing`),onGhostSession:e=>{e===Wt.current&&ce(null)},onHistoryPending:(e,t)=>{he(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},onPushConfig:e=>{ln.current=e,He(!0),localStorage.getItem(`enso-phone-push`)===`on`&&re(e).then(e=>{e.ok&&t.send({type:`push-subscribe`,subscription:e.subscription})})}});Ut.current=t,t.connect();let n=()=>{document.visibilityState===`visible`?(t.nudge(`visibility`),t.send({type:`presence`,visible:!0}),r()):(t.conceal(),t.send({type:`presence`,visible:!1}),t.flushCache())},r=()=>navigator.serviceWorker?.controller?.postMessage({type:`badge-clear`});r();let i=()=>{document.visibilityState===`visible`&&(t.nudge(`online`),t.send({type:`presence`,visible:!0}),r())},a=e=>{document.visibilityState===`visible`&&(t.nudge(e.persisted?`online`:`visibility`),t.send({type:`presence`,visible:!0}),r())},s=()=>{document.visibilityState===`visible`&&t.nudge(`visibility`)},c=()=>{t.conceal(),t.flushCache()};return document.addEventListener(`visibilitychange`,n),window.addEventListener(`online`,i),window.addEventListener(`pageshow`,a),window.addEventListener(`focus`,s),window.addEventListener(`pagehide`,c),()=>{document.removeEventListener(`visibilitychange`,n),window.removeEventListener(`online`,i),window.removeEventListener(`pageshow`,a),window.removeEventListener(`focus`,s),window.removeEventListener(`pagehide`,c),rn.current&&clearTimeout(rn.current),rn.current=null,t.close(),Ut.current=null,zt.reset(),Bt.reset()}},[o?.pairId,o?.token,o?.relayUrl,o?.contentKey]);let un=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{let e=Zt!==null&&un.current.has(Zt);Ut.current?.subscribe(Zt,{fresh:e});for(let e of un.current)e!==Zt&&un.current.delete(e);ue(Zt?Ut.current?.getSession(Zt)??null:null)},[Zt,o?.pairId]);let dn=o?.pairId;(0,U.useEffect)(()=>{dn&&ge(dn,{activeId:se,botChatId:Tt})},[se,Tt,dn]),(0,U.useEffect)(()=>{if(!dn)return;let e=new z(v,dn);Lt.current=e,Ht([]);let t=e.subscribe(e=>Ht([...e]));return e.restore().catch(()=>It(`离线消息读取失败,请勿清除浏览器数据;恢复存储后可重试。`)),()=>{t(),Lt.current===e&&(Lt.current=null)}},[dn]),(0,U.useEffect)(()=>{if(b===`online`)for(let e of Lt.current?.drain()??[])Ut.current?.send({type:`bot-send`,chatId:e.chatId,text:e.text,...e.images?.length?{images:e.images}:{},deliveryId:e.deliveryId})},[b,Vt]),(0,U.useEffect)(()=>{let e=setInterval(()=>Lt.current?.expire(),1e3);return()=>clearInterval(e)},[]);let fn=Jt?.current.id??null;(0,U.useEffect)(()=>{!fn||b!==`online`||(on.current=null,cn(!1),Ut.current?.send({type:`bot-chat-open`,chatId:fn}))},[fn,b]),(0,U.useEffect)(()=>{if(!sn)return;let e=setTimeout(()=>{on.current=null,cn(!1),It(`历史加载未完成,请点击加载重试。`)},1e4);return()=>clearTimeout(e)},[sn]),(0,U.useEffect)(()=>{let e={};for(let t of nn.current){let n=Ut.current?.getSession(t);n&&(e[t]=n)}Pt(e)},[fn,Jt?.current.sessions]),(0,U.useEffect)(()=>{if(!se||Tt)return;let e=ht.find(e=>Object.values(e.sessions).some(e=>e.conversationId===se));e&&(Et(e.id),ce(null))},[se,Tt,ht]),(0,U.useEffect)(()=>{let e=(e,t)=>{let n=Gt.current.find(t=>t.id===e)?.queued,r=nae(n,e,t,z7(e===Wt.current&&Kt.current?[...Kt.current.messages.values()]:[]));r&&ye(e=>[...e,r])};eP({removeQueuedMessage:(e,t)=>Ut.current?.send({type:`queue-remove`,sessionId:e,messageId:t}),updateQueuedMessage:(e,t,n)=>Ut.current?.send({type:`queue-update`,sessionId:e,messageId:t,text:n}),sendQueuedNow:(t,n)=>{e(t,n),Ut.current?.send({type:`queue-send-now`,sessionId:t,messageId:n})},interruptAndSendQueued:async(t,n)=>{e(t,n),Ut.current?.send({type:`queue-interrupt-send`,sessionId:t,messageId:n})},pauseGoal:e=>Ut.current?.send({type:`goal-pause`,sessionId:e}),resumeGoal:e=>Ut.current?.send({type:`goal-resume`,sessionId:e}),clearGoal:e=>Ut.current?.send({type:`goal-clear`,sessionId:e}),rewind:(e,t,n)=>Ut.current?.send({type:`rewind`,sessionId:e,userIndexFromEnd:t,...n?{restoreFiles:n}:{}}),retry:e=>Ut.current?.send({type:`retry`,sessionId:e})}),Re({stopTask:(e,t)=>Ut.current?.send({type:`task-stop`,sessionId:e,taskId:t}),stopSubagent:(e,t)=>Ut.current?.send({type:`subagent-stop`,sessionId:e,agentId:t})})},[]);let pn=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!se)return;let e=z7(le?[...le.messages.values()]:[]),t=le?.status===`running`,n=pn.current,r=n?.id===se&&n.running&&!t;pn.current={id:se,running:t},ye(t=>{let n=aae(t,se,e,{turnSettled:r});return n.length===t.length&&n.every((e,n)=>e===t[n])?t:n})},[le,se]);let mn=k.find(e=>!e.parentId)?.id;(0,U.useEffect)(()=>{!Tt&&!se&&mn&&ce(mn)},[se,Tt,mn]);let hn=(0,U.useMemo)(()=>k.find(e=>e.id===se),[k,se]),gn=(0,U.useMemo)(()=>{if(!hn)return;let e=hn.parentId?k.find(e=>e.id===hn.parentId):hn;if(!e)return;let t=k.filter(t=>t.parentId===e.id);return t.length>0?{parent:e,children:t}:void 0},[k,hn]),_n=hn&&!hn.parentId,vn=_n?V.find(e=>e.id===hn.providerId)?.models.find(e=>e.id===hn.modelId)?.label??hn.modelId??`选择模型`:void 0,yn=b===`online`?a(w,E):Fe[b],bn=e=>{A([]),P([]),L([]),B([]),ne([]),ue(null),pe(!1),ye([]),O(null),tt(!1),mt([]),gt([]),ft([]),vt(!1),Et(e.botChatId),wt(e.botChatId!==null),Ot(null),At({}),Mt({}),St({items:[],offset:0}),Pt({}),It(null),ce(e.activeId)},Sn=e=>{e!==o?.pairId&&(l(e),i(e),S(`connecting`),bn(d(e)),Dn())},Cn=n=>{let r=j(e,n);if(D(r),l(n.pairId),u&&n.scope!==`read`){window.location.replace(H(n.pairId));return}t(r),i(n.pairId),bn(d(n.pairId)),m(!1)},wn=n=>{n===o?.pairId&&Ut.current?.close();let{devices:r,fallback:a}=s(e,n,o?.pairId??null);t(r),a!==void 0&&(i(a?.pairId??null),a&&S(`connecting`),bn(d(a?.pairId??null)),a||Dn())},Tn=(n,r)=>{t(N(e,n,r))};if(!o||f)return(0,K.jsx)(_oe,{autoInvite:c,onPaired:Cn,onCancel:o?()=>{u?window.location.replace(H(o.pairId)):m(!1)}:void 0,notice:o?null:h});if(b===`unauthorized`){let t=e.length>1;return(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,K.jsx)(Vn,{className:`h-8 w-8 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`font-medium text-lg`,children:`配对已失效`}),(0,K.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`「`,o.label,`」已解绑此设备,`,t?`可移除它并切到其他电脑。`:`请重新扫码配对。`]}),(0,K.jsx)(Oa,{onClick:()=>wn(o.pairId),children:t?`移除此配对`:`重新配对`})]})}if(b===`replaced`)return(0,K.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,K.jsx)(Vn,{className:`h-8 w-8 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`font-medium text-lg`,children:`已在其他页面打开`}),(0,K.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[`「`,o.label,`」正被另一个页面连着,同一时间只能有一个页面。`]}),(0,K.jsx)(Oa,{onClick:()=>window.location.reload(),children:`在这个页面重连`})]});let En=e=>Ut.current?.send(e),Dn=()=>{(localStorage.getItem(Y9)===`off`||!window.matchMedia(`(min-width: 900px)`).matches)&&Se(!1)},On=()=>{wt(q7(et,Tt)),Se(!0),et&&En({type:`bot-catalog-request`})},kn=(e,t,n=[])=>{It(null),Lt.current?.enqueue({chatId:e,text:t,images:n})},An=e=>(0,K.jsx)(foe,{items:Vt.filter(t=>t.chatId===e),readOnly:Ue,onRetry:e=>Lt.current?.retry(e),onDiscard:e=>Lt.current?.discard(e)}),jn=new Map(pt.map(e=>[e.id,e])),Mn=e=>Ue?`只读设备不能新建会话`:b===`online`?nt?rt?`正在新建会话…`:Vt.some(t=>t.chatId===e)?`请先处理待发送消息`:void 0:`请升级桌面端以支持新建会话`:`请先连接桌面端`,Nn=async e=>{if(Mn(e)||at.current)return;let t=Ut.current;at.current=!0,it(!0),It(null);try{let n=await zt.start(e,()=>t===Ut.current&&en.current===e&&window.confirm(`群聊中仍有回复、排队或委派任务。新建会话将停止成员回复,并取消未标记保留的委派。旧消息会保留。继续吗?`));if(t!==Ut.current||en.current!==e)return;It(!n||n.ok?null:n.error===`read-only`?`只读设备不能新建会话`:n.error===`timeout`||n.error===`offline`?`未收到新会话确认,请连接后核对聊天状态,勿重复操作`:`新建会话失败:${n.error??`请稍后重试`}`),n?.ok&&(t?.send({type:`bot-catalog-request`}),t?.send({type:`bot-chat-open`,chatId:e}))}finally{t===Ut.current&&(at.current=!1,it(!1))}},Pn=Ue?`只读设备不能切换或新建话题`:b===`online`?ct?`正在处理话题…`:void 0:`请先连接桌面端`,Fn=async e=>{if(Pn||ut.current)return;let t=Ut.current;ut.current=!0,lt(!0),It(null);try{let n=await Bt.request(e);if(t!==Ut.current||en.current!==e.chatId)return;n.ok?Ot(null):It(n.error===`read-only`?`只读设备不能切换或新建话题`:n.error===`timeout`||n.error===`offline`?`未收到桌面确认,请连接后核对当前话题`:n.error===`invalid`?`该话题已不存在或群已归档`:`话题操作失败:${n.error??`请稍后重试`}`)}finally{t===Ut.current&&(ut.current=!1,lt(!1))}},In=e=>{if(e.kind===`group`&&!Dt){let t=Object.entries(e.sessions).flatMap(([e,{conversationId:t}])=>{let n=Nt[t];return n?[{sessionId:t,botId:e,view:n}]:[]});return(0,K.jsx)(Mae,{chat:e,bots:jn,timeline:kt[e.id],state:jt[e.id],pending:t,activities:ls(xt.items,e.id),clockOffset:xt.offset,connState:b,stateLabel:yn,notice:Ft,outbox:An(e.id),deviceReadOnly:Ue,readOnlyRejected:Je,onOpenDrawer:On,drawerDocked:De,onNewSession:()=>void Nn(e.id),canCreate:!Mn(e.id),newSessionHint:Mn(e.id),newSessionBusy:rt,threads:ot&&Jt&&qt?{entries:Jt.entries,currentId:e.id,rootId:qt.id,disabledHint:Pn,onSelect:e=>void Fn({type:`bot-thread-select`,chatId:qt.id,threadId:e}),onCreate:()=>void Fn({type:`bot-thread-create`,chatId:qt.id})}:void 0,onLoadOlder:()=>{let t=kt[e.id]?.entries[0]?.seq,n=`${e.id}:${t}`;b!==`online`||t===void 0||on.current||(on.current=n,cn(!0),En({type:`bot-timeline`,chatId:e.id,beforeSeq:t}))},historyLoading:sn,onJumpLatest:()=>{on.current=null,cn(!1),At(t=>{let n={...t};return delete n[e.id],n}),En({type:`bot-chat-open`,chatId:e.id})},onSend:(t,n)=>kn(e.id,t,n),onStop:()=>En({type:`bot-stop`,chatId:e.id}),onRetry:t=>{It(`正在请求重试…`),En({type:`bot-retry`,chatId:e.id,entryId:t})},onOpenProcess:Ot,onApproval:(e,t,n)=>En({type:`approval-respond`,sessionId:e,requestId:t,decision:n}),onAsk:(e,t,n)=>En({type:`ask-respond`,sessionId:e,requestId:t,answer:n})})}let t=e.kind===`group`,n=kt[e.id]?.entries.find(e=>e.kind===`bot`&&e.conversationId===Dt),r=Dt?an.current.get(Dt):void 0,i=jn.get(t?n?.kind===`bot`?n.botId:r??``:e.members[0]);return(0,K.jsx)(V7,{sessionId:Zt??`bot-chat:${e.id}`,clockOffset:xt.offset,title:t?`${i?.name??`成员`} · 过程`:i?.name??e.title,projectName:t?e.title:i?.title??``,view:Zt?le:Roe,connState:b,stateLabel:yn,syncing:fe&&!!Zt,onOpenDrawer:On,drawerDocked:De,onNewSession:()=>!t&&void Nn(e.id),canCreate:!t&&!Mn(e.id),newSessionHint:Mn(e.id),newSessionBusy:rt,hasOlder:!!(Zt&&le&&le.messages.size>0&&Math.min(...le.messages.keys())>0),historyLoading:!!(Zt&&me.has(Zt)),onLoadOlder:()=>Zt&&Ut.current?.requestHistory(Zt),bot:t?{readOnly:!0,onBack:()=>Ot(null)}:{chatId:e.id,notice:Ft,outbox:An(e.id)},artifacts:!t&&Zt?{chatId:e.id,conversationId:Zt}:void 0,deviceReadOnly:Ue,readOnlyRejected:Je,onSend:(t,n)=>kn(e.id,t,n),onAbort:()=>Zt&&En({type:`abort`,sessionId:Zt}),onApproval:(e,t)=>Zt&&En({type:`approval-respond`,sessionId:Zt,requestId:e,decision:t}),onAsk:(e,t)=>Zt&&En({type:`ask-respond`,sessionId:Zt,requestId:e,answer:t})})},Ln=async e=>{$e(null);let t=oe(En);if(!e){Be(!1),Te(t);return}let n=ln.current;if(!n)return;Be(!0),Ze(!0);let r=await be(n,t);Ze(!1),r.ok||(Be(!1),$e(r.reason))};return(0,K.jsxs)(`div`,{className:`phone-app-root flex h-full min-h-0`,children:[(0,K.jsx)(Poe,{open:De||xe,docked:De,pinnable:Ce,onTogglePinned:Oe,projects:I,groups:R,catalog:k,pinnedOrder:M,activeId:Tt?null:se,canCreate:b===`online`&&!Ue,devices:e,activeDevicePairId:o.pairId,remoteDesktop:Ge,connected:b===`online`,connectionLabel:yn,onClose:()=>Dn(),onSelect:e=>{Et(null),Ot(null),ce(e),Dn()},onNewConversation:e=>{Dn(),Ne(e),Ae(!0)},pushEnabled:ze,pushBusy:Xe,pushError:Qe,pushAvailability:Boe(),pushConfigReady:Ve,onTogglePush:e=>void Ln(e),onSwitchDevice:Sn,onAddDevice:()=>{Dn(),m(!0)},onRenameDevice:Tn,onUnpairDevice:wn,botSegment:et?{active:Ct,onChange:e=>{wt(e),_ae(e?`bot`:`code`),e&&En({type:`bot-catalog-request`})},panel:(0,K.jsx)(ps,{bots:pt,chats:ht,activeChatId:Tt,inbox:yt,activities:xt.items,onDismiss:Ue?void 0:e=>En({type:`bot-inbox-dismiss`,key:e}),onSelect:e=>{Et(e),Ot(null),It(null),Dn()}})}:void 0}),(0,K.jsxs)(`div`,{className:`flex h-full min-w-0 flex-1 flex-col`,children:[Ce&&!De&&!xe&&(0,K.jsx)(`button`,{type:`button`,onClick:On,"aria-label":`打开会话列表`,className:`fixed top-1/2 left-0 z-40 flex h-16 w-6 -translate-y-1/2 items-center justify-center rounded-r-lg border border-l-0 bg-background/90 text-muted-foreground shadow-sm backdrop-blur transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}),qt?(0,K.jsx)(qa.Provider,{value:{port:Rt,online:b===`online`},children:In(Yt??qt)}):Tt?(0,K.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[!De&&(0,K.jsx)(`button`,{type:`button`,onClick:On,"aria-label":`打开会话列表`,className:`absolute top-2 left-2 flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(xn,{className:`h-4.5 w-4.5`})}),(0,K.jsx)(`p`,{children:_t?`该 Bot 聊天已不存在或不可用`:`正在恢复 Bot 聊天…`}),(0,K.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:yn}),(0,K.jsx)(Oa,{onClick:On,children:`选择聊天`})]}):(0,K.jsx)(V7,{sessionId:se,title:hn?.title||(se?`会话`:`EnsoCode`),projectName:hn?.projectName??``,cwd:hn?.cwd,view:le,connState:b,stateLabel:yn,syncing:fe&&!!se,onOpenDrawer:On,drawerDocked:De,onNewSession:()=>{Ne(null),Ae(!0)},canCreate:b===`online`&&I.length>0&&!Ue,modelLabel:b===`online`?vn:void 0,onOpenConfig:()=>Le(!0),tabGroup:gn,onSelectTab:ce,hasOlder:!!(se&&le&&le.messages.size>0&&Math.min(...le.messages.keys())>0),historyLoading:!!(se&&me.has(se)),onLoadOlder:()=>se&&Ut.current?.requestHistory(se),queued:rae(hn?.queued,_e,se??``),echoes:_e,goal:hn?.goal,context:hn?.context,usageTotals:hn?.usageTotals,slashCommands:hn?.slashCommands,deviceReadOnly:Ue,readOnlyRejected:Je,onSend:(e,t)=>{if(!se)return;let n=qe(e);if(n){En({type:`compact`,sessionId:se,...n.instructions?{instructions:n.instructions}:{}});return}let r=/^\/goal(?:\s+([\s\S]+))?$/.exec(e.trim());if(r){let e=r[1]?.trim();if(!e)return;En(e===`clear`?{type:`goal-clear`,sessionId:se}:e===`pause`?{type:`goal-pause`,sessionId:se}:e===`resume`?{type:`goal-resume`,sessionId:se}:{type:`goal-set`,sessionId:se,text:e});return}En({type:le?.status===`running`?`enqueue`:`prompt`,sessionId:se,text:e,...t.length?{images:t}:{}})},onAbort:()=>se&&En({type:`abort`,sessionId:se}),onApproval:(e,t)=>se&&En({type:`approval-respond`,sessionId:se,requestId:e,decision:t}),onAsk:(e,t)=>se&&En({type:`ask-respond`,sessionId:se,requestId:e,answer:t})}),(0,K.jsx)(uoe,{open:ke&&!Ue,projects:I,providers:V,preferredProjectId:je,onClose:()=>{Ae(!1),Ne(null)},onCreate:e=>{let t=crypto.randomUUID();En({type:`spawn`,sessionId:t,...e}),un.current.add(t),Ae(!1),Ne(null),Et(null),Ot(null),ce(t)}}),_n&&se&&!Ue&&(0,K.jsx)(voe,{open:Ie,providers:V,config:{providerId:hn.providerId,modelId:hn.modelId,reasoningEnabled:hn.reasoningEnabled,thinkingLevel:hn.thinkingLevel},onClose:()=>Le(!1),onSetModel:(e,t)=>En({type:`set-model`,sessionId:se,providerId:e,modelId:t}),onSetReasoning:e=>En({type:`set-reasoning`,sessionId:se,enabled:e}),onSetThinking:e=>En({type:`set-thinking`,sessionId:se,level:e})})]})]})}function Hoe(e){return!e.appleMobile||!e.standalone||e.safeTop<=0||e.innerHeight<=e.innerWidth?!1:e.innerHeight>=Math.max(e.screenWidth,e.screenHeight)-1}function Uoe(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e&&!/^viewport-fit\s*=/i.test(e)).join(`, `)}function Woe(){return/iphone|ipad|ipod/i.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>1}function Goe(){let e=document.querySelector(`meta[name="viewport"]`);if(!e||!Woe())return;let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),t.style.cssText=`position:fixed;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)`,document.body.appendChild(t);let n=()=>{let r=getComputedStyle(t);if(!Hoe({appleMobile:!0,standalone:te(),safeTop:Number.parseFloat(r.paddingTop)||0,innerWidth:window.innerWidth,innerHeight:window.innerHeight,screenWidth:window.screen.width,screenHeight:window.screen.height}))return;let i=Number.parseFloat(r.paddingBottom)||0;document.documentElement.style.setProperty(`--phone-safe-bottom`,`${i}px`),e.content=Uoe(e.content),window.removeEventListener(`resize`,n),document.removeEventListener(`visibilitychange`,n),t.remove()};window.addEventListener(`resize`,n),document.addEventListener(`visibilitychange`,n),n()}var X9=new URLSearchParams(location.search);if(X9.get(`mode`)===`phone`){ie(`phone`),X9.delete(`mode`);let e=X9.toString();history.replaceState(null,``,`${location.pathname}${e?`?${e}`:``}${location.hash}`)}var Z9=F(),Q9=Ce(location.search,De(),Z9,Me());Q9?location.replace(Q9):Z9.length>0&&(me(),T(!0)),L(),Goe(),Q9||Se(window),!Q9&&`serviceWorker`in navigator&&Oe({container:navigator.serviceWorker,doc:document,storage:sessionStorage,canReloadNow:()=>!1,reload:()=>location.reload()});var $9=document.getElementById(`root`);$9&&!Q9&&(0,Ge.createRoot)($9).render((0,K.jsx)(U.StrictMode,{children:(0,K.jsx)(Voe,{})}));export{q0 as a,ip as c,Qs as d,J as f,H2 as i,Tu as l,Ka as m,O4 as n,Wg as o,q as p,V2 as r,Qp as s,a6 as t,Oc as u};